package com.welampiot.service.impl; import com.welampiot.common.BaseResult; import com.welampiot.common.InterfaceResultEnum; import com.welampiot.dto.*; import com.welampiot.dao.LampDao; import com.welampiot.dto.LampInfoCacheByDayDTO; import com.welampiot.dto.LampInfoDTO; import com.welampiot.dto.LampInfoLogDTO; import com.welampiot.dto.NetworkDTO; import com.welampiot.service.LampInfoCacheByDayService; import com.welampiot.service.LampInfoLogService; import com.welampiot.service.LampService; import com.welampiot.service.NetworkService; import com.welampiot.utils.ToolUtils; import com.welampiot.vo.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @Service public class LampServiceImpl implements LampService { @Autowired private LampDao lampDao; @Autowired private ToolUtils toolUtils; @Autowired private LampInfoLogService lampInfoLogService; @Autowired private NetworkService networkService; @Autowired private LampInfoCacheByDayService lampInfoCacheByDayService; @Override public Integer getCountByVO(LampCountVO lampCountVO) {return lampDao.getCountByVO(lampCountVO);} @Override public Float getDayConsumptionByVO(LampCountVO lampCountVO) { Float dayConsumptionByVO = lampDao.getDayConsumptionByVO(lampCountVO); dayConsumptionByVO = dayConsumptionByVO == null ? 0 : dayConsumptionByVO; return dayConsumptionByVO; } @Override public Float getConsumptionByVO(LampCountVO lampCountVO) { Float consumptionByVO = lampDao.getConsumptionByVO(lampCountVO); consumptionByVO = consumptionByVO == null ? 0 : consumptionByVO; return consumptionByVO; } @Override public List getConsumptionListByVO(LampCountVO lampCountVO) {return lampDao.getConsumptionListByVO(lampCountVO);} @Override public List getListByVO(LampListResponseVO lampListResponseVO) { List listByVO = lampDao.getListByVO(lampListResponseVO); List list = new ArrayList<>(); for (LampInfoDTO lamp :listByVO) { if (lamp.getCurrent() != null) { if (Math.abs(Float.parseFloat(lamp.getCurrent())) >= 0.01){ lamp.setCurrent(String.valueOf((Math.round((Float.parseFloat(lamp.getCurrent()))*100)/100f))); }else { lamp.setCurrent("0"); } }else { lamp.setCurrent(""); } if (lamp.getVoltage() != null) { if (Math.abs(Float.parseFloat(lamp.getCurrent())) >= 0.01){ lamp.setVoltage(String.valueOf((Math.round((Float.parseFloat(lamp.getVoltage()))*100)/100f))); }else { lamp.setCurrent("0"); } }else { lamp.setVoltage(""); } if (lamp.getPower() != null) { if (Math.abs(Float.parseFloat(lamp.getCurrent())) >= 0.01){ lamp.setPower(String.valueOf((Math.round((Float.parseFloat(lamp.getPower()))*100)/100f))); }else { lamp.setCurrent("0"); } }else { lamp.setPower(""); } if (lamp.getLedLuxValue() == null){ lamp.setLedLuxValue(0); } if (Integer.parseInt(lamp.getNetworkStatus()) == 0){ lamp.setLighteness(0); } if (lamp.getPolicyName() == null || lamp.getPolicyType() != 1){ lamp.setPolicyName("暂无"); } lamp.setControlTypeStr(toolUtils.getLampControlNameById(lamp.getControlType())); if (lamp.getControlType() == 5){ if (lamp.getMode() == 0){ lamp.setNumber(lamp.getNumber()+"-1"); }else { lamp.setNumber(lamp.getNumber()+"-2"); } } list.add(lamp); } return list; } @Override public LampInfoDTO getDetailsById(Integer id,Integer version) { LampInfoDTO detailsById = lampDao.getDetailsById(id,version); return detailsById; } @Override public Integer findByVO(LampInfoDTO lampInfoDTO) { return lampDao.findByVO(lampInfoDTO); } @Override public Integer checkData(LampInfoDTO lampInfoDTO) { Integer integer = lampDao.checkData(lampInfoDTO); if (integer == null) integer = 0; return integer; } @Override public BaseResult add(LampInfoDTO lampInfoDTO) { if (lampInfoDTO.getNumber() == null || lampInfoDTO.getNumber().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LAMP_NUMBER_ERROR,lampInfoDTO.getVersion()); if (!lampInfoDTO.getNumber().matches("^[A-Za-z0-9_]+$")) return toolUtils.response(InterfaceResultEnum.LAMP_NUMBER_FORMAT_ERROR,lampInfoDTO.getVersion()); if (lampInfoDTO.getName() == null || lampInfoDTO.getName().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LAMP_NAME_ERROR,lampInfoDTO.getVersion()); if (lampInfoDTO.getSn() == null || lampInfoDTO.getSn().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LAMP_ADDRESS_ERROR,lampInfoDTO.getVersion()); if (lampInfoDTO.getAreaId() == 0) return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR,lampInfoDTO.getVersion()); if (lampInfoDTO.getSectionId() == 0) return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,lampInfoDTO.getVersion()); LampInfoDTO lampInfoDTO1 = new LampInfoDTO(); lampInfoDTO1.setSn(lampInfoDTO.getSn()); if (lampDao.findByVO(lampInfoDTO1) > 0) return toolUtils.response(InterfaceResultEnum.LAMP_ADDRESS_UNIQUE_ERROR,lampInfoDTO.getVersion()); lampInfoDTO1 = new LampInfoDTO(); lampInfoDTO1.setNumber(lampInfoDTO.getNumber()); lampInfoDTO1.setSectionId(lampInfoDTO.getSectionId()); if (lampDao.findByVO(lampInfoDTO1) > 0) return toolUtils.response(InterfaceResultEnum.LAMP_NUMBER_UNIQUE_ERROR,lampInfoDTO.getVersion()); lampInfoDTO1 = new LampInfoDTO(); lampInfoDTO1.setName(lampInfoDTO.getName()); lampInfoDTO1.setSectionId(lampInfoDTO.getSectionId()); if (lampDao.findByVO(lampInfoDTO) > 0) return toolUtils.response(InterfaceResultEnum.LAMP_NAME_UNIQUE_ERROR,lampInfoDTO.getVersion()); NetworkDTO networkDTO = new NetworkDTO(); networkDTO.setNetworkName(lampInfoDTO.getSn()); networkDTO.setDeviceSn(lampInfoDTO.getSn()); networkDTO.setAreaId(lampInfoDTO.getAreaId()); networkDTO.setSectionId(lampInfoDTO.getSectionId()); networkDTO.setNetType(1); networkDTO.setGatewayType("direct"); if (lampInfoDTO.getProtocolType() == 10) networkDTO.setDeviceType(4); networkDTO.setProtocolType(lampInfoDTO.getProtocolType()); networkService.add(networkDTO); lampInfoDTO.setNetworkId(networkDTO.getId()); Date endDate = new Date(System.currentTimeMillis()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String createTime = simpleDateFormat.format(endDate).toString(); lampInfoDTO.setCreateTime(createTime); if (lampInfoDTO.getControlType() == 5 || lampInfoDTO.getControlType() == 6 || lampInfoDTO.getControlType() == 7){ lampInfoDTO.setMode(1); } lampDao.add(lampInfoDTO); if (lampInfoDTO.getControlType() == 5){ // 4G 双灯 lampInfoDTO.setMode(0); lampDao.add(lampInfoDTO); } return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,lampInfoDTO.getVersion()); } @Override public BaseResult update(LampInfoDTO lampInfoDTO) { LampInfoDTO oldLamp = lampDao.getDetailsById(lampInfoDTO.getId(),lampInfoDTO.getVersion()); lampInfoDTO.setNetworkId(oldLamp.getNetworkId()); LampInfoDTO lampInfoDTO1 = new LampInfoDTO(); // lampInfoDTO1. lampInfoDTO1.setSn(lampInfoDTO.getSn()); lampInfoDTO1.setId(lampInfoDTO.getId()); lampInfoDTO1.setNetworkId(lampInfoDTO.getNetworkId()); if (this.checkData(lampInfoDTO1) > 0) return toolUtils.response(InterfaceResultEnum.LAMP_ADDRESS_UNIQUE_ERROR,lampInfoDTO.getVersion()); lampInfoDTO1 = new LampInfoDTO(); lampInfoDTO1.setNetworkId(lampInfoDTO.getNetworkId()); lampInfoDTO1.setNumber(lampInfoDTO.getNumber()); lampInfoDTO1.setSectionId(lampInfoDTO.getSectionId()); if (this.checkData(lampInfoDTO1) > 0) return toolUtils.response(InterfaceResultEnum.LAMP_NUMBER_UNIQUE_ERROR,lampInfoDTO.getVersion()); lampInfoDTO1 = new LampInfoDTO(); lampInfoDTO1.setNetworkId(lampInfoDTO.getNetworkId()); lampInfoDTO1.setName(lampInfoDTO.getName()); lampInfoDTO1.setSectionId(lampInfoDTO.getSectionId()); if (this.checkData(lampInfoDTO) > 0) return toolUtils.response(InterfaceResultEnum.LAMP_NAME_UNIQUE_ERROR,lampInfoDTO.getVersion()); if (oldLamp.getProtocolType() != lampInfoDTO.getProtocolType()){ NetworkDTO networkDTO = new NetworkDTO(); networkDTO.setId(oldLamp.getNetworkId()); networkDTO.setNetworkName(lampInfoDTO.getSn()); networkDTO.setDeviceSn(lampInfoDTO.getSn()); networkDTO.setAreaId(lampInfoDTO.getAreaId()); networkDTO.setSectionId(lampInfoDTO.getSectionId()); networkDTO.setDeviceType(0); if (lampInfoDTO.getProtocolType() == 10) networkDTO.setDeviceType(4); networkDTO.setProtocolType(lampInfoDTO.getProtocolType()); networkService.update(networkDTO); } if (lampInfoDTO.getControlType() == 5 || lampInfoDTO.getControlType() == 6 || lampInfoDTO.getControlType() == 7){ lampInfoDTO.setMode(oldLamp.getMode()); } lampDao.update(lampInfoDTO); System.out.println(lampInfoDTO.getMode()); if (lampInfoDTO.getControlType() == 5){ // 4G 双灯 lampInfoDTO1 = new LampInfoDTO(); lampInfoDTO1.setSn(lampInfoDTO.getSn()); lampInfoDTO1.setId(lampInfoDTO.getId()); Integer lampId = this.checkData(lampInfoDTO1); if (oldLamp.getMode() == null || oldLamp.getMode() == 0){ lampInfoDTO.setMode(1); }else { lampInfoDTO.setMode(0); } System.out.println(lampInfoDTO.getMode()); if (lampId > 0){ lampInfoDTO.setId(lampId); lampDao.update(lampInfoDTO); }else { Date endDate = new Date(System.currentTimeMillis()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String createTime = simpleDateFormat.format(endDate).toString(); lampInfoDTO.setCreateTime(createTime); lampDao.add(lampInfoDTO); } }else { if (oldLamp.getControlType() == 5){ lampInfoDTO1 = new LampInfoDTO(); lampInfoDTO1.setSn(lampInfoDTO.getSn()); lampInfoDTO1.setId(lampInfoDTO.getId()); Integer lampId = this.checkData(lampInfoDTO1); System.out.println(lampId); if (lampId > 0){ lampDao.deleteById(lampId); } } } return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,lampInfoDTO.getVersion()); } @Override public Integer deleteById(Integer id) { LampInfoDTO detailsById = this.getDetailsById(id, 0); lampInfoLogService.deleteByLampId(id); Integer integer = lampDao.deleteById(id); if (detailsById.getControlType() == 5){ // 4G 双灯 LampInfoDTO detailsByAddress = this.getDetailsByAddress(detailsById.getSn(), 0); lampInfoLogService.deleteByLampId(detailsByAddress.getId()); lampDao.deleteById(detailsByAddress.getId()); } return integer; } @Override public LampInfoDTO getDetailsByAddress(String address, Integer version) { return lampDao.getDetailsByAddress(address,version); } @Override public List groupSelectLamp(LampListResponseVO lampListResponseVO) { List lampInfoDTOS = lampDao.groupSelectLamp(lampListResponseVO); return lampInfoDTOS; } @Override public List getNavByVO(LampListResponseVO lampListResponseVO) { List navByVO = lampDao.getNavByVO(lampListResponseVO); List list = new ArrayList<>(); for (LampInfoDTO l :navByVO) { if ((l.getProtocolType() == 10 && l.getControlType() == 5) || (l.getProtocolType() == 3 && l.getControlType() == 9) || (l.getProtocolType() == 11 && l.getControlType() == 8) || l.getControlType() == 25 || l.getControlType() == 27){ if (l.getMode() == 0){ l.setNumber(l.getNumber()+"-1"); }else { l.setNumber(l.getNumber()+"-2"); } } list.add(l); } return list; } @Override public List getLampPoleDetailListByLampPoleId(Integer lampPoleId) { return lampDao.getLampPoleDetailListByLampPoleId(lampPoleId); } @Override public List getLampInfoListByDTO(LampInfoDTO dto) { return lampDao.getLampInfoListByDTO(dto); } @Override public List getLampLocationByGroupId(Integer id) { return lampDao.getLampLocationByGroupId(id); } @Override public List getLampLocationByLoopId(Integer id) { return lampDao.getLampLocationByLoopId(id); } @Override public Integer getLampInstallTotalByDTO(LampInfoDTO dto) { return lampDao.getLampInstallTotalByDTO(dto); } @Override public Integer getLampLightTotalByDTO(LampInfoDTO dto) { return lampDao.getLampLightTotalByDTO(dto); } @Override public Integer getLampOnlineTotalByDTO(LampInfoDTO dto) { return lampDao.getLampOnlineTotalByDTO(dto); } @Override public Integer getLampFaultTotalByDTO(LampInfoDTO dto) { return lampDao.getLampFaultTotalByDTO(dto); } @Override public void changeLampLocationById(LampInfoDTO dto) { lampDao.changeLampLocationById(dto); } @Override public Integer getSectionOfLampCountBySectionId(Integer id) { return lampDao.getSectionOfLampCountBySectionId(id); } @Override public String getNameOrNumber(Integer type, Integer value, Integer version) { return lampDao.getNameOrNumber(type, value, version); } @Override public LampInfoDTO getLampInfoDTOById(Integer id) { return lampDao.getLampInfoDTOById(id); } @Override public List getLampList(LampVO vo) { return lampDao.getLampList(vo); } @Override public Integer getLampTotal(LampVO vo) { return lampDao.getLampTotal(vo); } @Override public List getLampDataByLampIds(List lampIds) { return lampDao.getLampDataByLampIds(lampIds); } @Override public List getLampListByLampPoleId(Integer lampPoleId) { return lampDao.getLampListByLampPoleId(lampPoleId); } @Override public Integer getLampPoleIdByLampId(Integer id) { return lampDao.getLampPoleIdByLampId(id); } @Override public Integer getLampCountByLampPoleId(Integer lampPoleId) { return lampDao.getLampCountByLampPoleId(lampPoleId); } @Override public void updateLampInfoForLoopId(LampInfoDTO dto) { lampDao.updateLampInfoForLoopId(dto); } @Override public List getLampInfoListForGroup(LampVO vo) { return lampDao.getLampInfoListForGroup(vo); } @Override public LampInfoVO getLampConsumptionData(LampInfoDataVO vo) throws ParseException { String dateType = vo.getDateType(); Integer type = vo.getType(); Integer value = vo.getValue(); String date = vo.getDate(); long l = System.currentTimeMillis(); Date date1 = new Date(l); Calendar calendar = Calendar.getInstance(); calendar.setTime(date1); int year = calendar.get(Calendar.YEAR); // 获取年份 int month = calendar.get(Calendar.MONTH) + 1; // 获取月份 long startTime = 0L; long endTime = 0L; String startDate = ""; DecimalFormat decimalFormat = new DecimalFormat("0.00"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd 23:59:59"); SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String endDate = simpleDateFormat.format(l); if (dateType != null && !dateType.isEmpty()) { switch (dateType) { case "day": startDate = format.format(l); endDate = format1.format(l); startTime = format2.parse(startDate).getTime(); endTime = format2.parse(endDate).getTime(); break; case "month": if (month < 10) { startDate = year + "-0" + month + "-01"; } else { startDate = year + "-" + month + "-01"; } startTime = simpleDateFormat.parse(startDate).getTime(); endTime = simpleDateFormat.parse(endDate).getTime(); break; case "year": month = 1; startDate = year + "-0" + month + "-01"; endDate = simpleDateFormat.format(l); startTime = simpleDateFormat.parse(startDate).getTime(); endTime = simpleDateFormat.parse(endDate).getTime(); break; } } else if (date != null && !date.isEmpty()) { List split = Arrays.asList(date.split("/")); startDate = split.get(0); endDate = split.get(1); startTime = simpleDateFormat.parse(startDate + " 00:00:00").getTime(); endTime = simpleDateFormat.parse(endDate + " 23:59:59").getTime(); if (endTime < startTime) { LampInfoVO lampInfoVO = new LampInfoVO(); lampInfoVO.setName("错误1"); return lampInfoVO; } if (endTime - startTime > 29L * 24 * 3600 * 1000) { LampInfoVO lampInfoVO = new LampInfoVO(); lampInfoVO.setName("错误2"); return lampInfoVO; } } HashMap objectObjectHashMap = new HashMap<>(); long timeT = startTime; int i = 0; List dateList = new ArrayList<>(); List valueList1 = new ArrayList<>(); List valueList2 = new ArrayList<>(); List valueList3 = new ArrayList<>(); List conSumList = new ArrayList<>(); List dayEleList = new ArrayList<>(); LampInfoCacheByDayDTO dayDTO = new LampInfoCacheByDayDTO(); dayDTO.setType(type); dayDTO.setValue(value); dayDTO.setStartDate(startDate); dayDTO.setEndDate(endDate); if (dateType != null && !dateType.isEmpty()) { switch (dateType) { case "day": // 当天 dayEleList = lampInfoLogService.getDayEleUsedList(type, value); break; case "month": // 当月 conSumList = lampInfoCacheByDayService.getMonthConSum(dayDTO); break; case "year": conSumList = lampInfoCacheByDayService.getYearConSum(dayDTO); break; } if (dateType.equals("month")) { // 当月 while (timeT <= endTime) { objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i); dateList.add(simpleDateFormat.format(new Date(timeT))); valueList1.add(0); valueList2.add(0); valueList3.add(0); timeT += 3600 * 1000 * 24; i ++; } for (LampInfoCacheByDayDTO dto : conSumList) { Date date2 = new Date(simpleDateFormat.parse(dto.getUpdateTime()).getTime()); String s = simpleDateFormat.format(date2); Integer integer = null; if (objectObjectHashMap.containsKey(s)) { integer = objectObjectHashMap.get(s); } // 当月累计用电量 if (dto.getConSum() != null && !dto.getConSum().equals("0") && integer != null) { String formatConSum = decimalFormat.format(dto.getConSum()); valueList1.set(integer, Float.parseFloat(formatConSum)); } // 当月累计亮灯时间 if (dto.getLightTime() != null && dto.getLightTime() != 0 && integer != null) { valueList2.set(integer,dto.getLightTime()); } // 当月累计省电量 if (dto.getPowerSave() != null && !dto.getPowerSave().equals("0") && integer != null) { String formatSave = decimalFormat.format(dto.getPowerSave()); valueList3.set(integer,Float.parseFloat(formatSave)); } } } else if (dateType.equals("day")) { // 当天 format = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); while (timeT < endTime) { objectObjectHashMap.put(format.format(new Date(timeT)),i); dateList.add(format.format(new Date(timeT))); valueList1.add(0); valueList2.add(0); valueList3.add(0); timeT += 3600 * 1000; i ++; } for (LampInfoLogDTO dto : dayEleList) { Date date2 = new Date(format.parse(dto.getUpdateTime()).getTime()); String s = format.format(date2); Integer integer = null; if (objectObjectHashMap.containsKey(s)) { integer = objectObjectHashMap.get(s); } // 当天累计用电量 if (dto.getSumMinEle() != null && !dto.getSumMinEle().equals("0") && integer != null && dto.getSumMaxEle() != null && !dto.getSumMaxEle().equals("0")) { Float sumEle = Float.parseFloat(dto.getSumMaxEle()) - Float.parseFloat(dto.getSumMinEle()); String formatEle = decimalFormat.format(sumEle); valueList1.set(integer, Float.parseFloat(formatEle)); } // 当天累计亮灯时间 if (dto.getSumMinLightTime() != null && !dto.getSumMinLightTime().equals("0") && integer != null && dto.getSumMaxLightTime() != null && !dto.getSumMaxLightTime().equals("0")) { Float sumTime = Float.parseFloat(dto.getSumMaxLightTime()) - Float.parseFloat(dto.getSumMinLightTime()); String formatTime = decimalFormat.format(sumTime); valueList1.set(integer, Float.parseFloat(formatTime)); } // 当天累计省电量 if (dto.getSumMinSave() != null && !dto.getSumMinSave().equals("0") && integer != null && dto.getSumMaxSave() != null && !dto.getSumMaxSave().equals("0")) { Float sumSave = Float.parseFloat(dto.getSumMaxSave()) - Float.parseFloat(dto.getSumMinSave()); String formatSave = decimalFormat.format(sumSave); valueList1.set(integer, Float.parseFloat(formatSave)); } } } else { // 当年 String dateStr; while (timeT <= endTime) { objectObjectHashMap.put(dateFormat.format(new Date(timeT)),i); dateList.add(dateFormat.format(new Date(timeT))); valueList1.add(0); valueList2.add(0); valueList3.add(0); month ++; if (month == 13) { month = 1; year ++; } if (month < 10) { dateStr = year + "-0" + month; } else { dateStr = year + "-" + month; } timeT = dateFormat.parse(dateStr).getTime(); i ++; } for (LampInfoCacheByDayDTO dto : conSumList) { Date date2 = new Date(dateFormat.parse(dto.getUpdateTime()).getTime()); String s = dateFormat.format(date2); Integer integer = null; if (objectObjectHashMap.containsKey(s)) { integer = objectObjectHashMap.get(s); } // 当年累计用电量 if (dto.getConSum() != null && !dto.getConSum().equals("0") && integer != null) { String formatConSum = decimalFormat.format(dto.getConSum()); valueList1.set(integer, Float.parseFloat(formatConSum)); } // 当年累计亮灯时间 if (dto.getLightTime() != null && dto.getLightTime() != 0 && integer != null) { valueList2.set(integer,dto.getLightTime()); } // 当年累计省电量 if (dto.getPowerSave() != null && !dto.getPowerSave().equals("0") && integer != null) { String formatSave = decimalFormat.format(dto.getPowerSave()); valueList3.set(integer,Float.parseFloat(formatSave)); } } } } else if (date != null && !date.isEmpty()) { while (timeT <= endTime) { objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i); dateList.add(simpleDateFormat.format(new Date(timeT))); valueList1.add(0); valueList2.add(0); valueList3.add(0); timeT += 3600 * 1000 * 24; i ++; } conSumList = lampInfoCacheByDayService.getMonthConSum(dayDTO); for (LampInfoCacheByDayDTO dto : conSumList) { Date date2 = new Date(simpleDateFormat.parse(dto.getUpdateTime()).getTime()); String s = simpleDateFormat.format(date2); Integer integer = null; if (objectObjectHashMap.containsKey(s)) { integer = objectObjectHashMap.get(s); } // 具体日期累计用电量 if (dto.getConSum() != null && !dto.getConSum().equals("0") && integer != null) { String formatConSum = decimalFormat.format(dto.getConSum()); valueList1.set(integer, Float.parseFloat(formatConSum)); } // 具体日期累计亮灯时间 if (dto.getLightTime() != null && dto.getLightTime() != 0 && integer != null) { valueList2.set(integer,dto.getLightTime()); } // 具体日期累计省电量 if (dto.getPowerSave() != null && !dto.getPowerSave().equals("0") && integer != null) { String formatSave = decimalFormat.format(dto.getPowerSave()); valueList3.set(integer,Float.parseFloat(formatSave)); } } } LampInfoVO lampInfoVO = new LampInfoVO(); lampInfoVO.setDate(dateList); lampInfoVO.setConsumption(valueList1); lampInfoVO.setLightTime(valueList2); lampInfoVO.setSavePower(valueList3); return lampInfoVO; } @Override public List getAlarmAreaCountTop(LampInfoDTO dto) { return lampDao.getAlarmAreaCountTop(dto); } @Override public List getLampEleUseSectionTop(LampInfoDTO dto) { return lampDao.getLampEleUseSectionTop(dto); } @Override public List getLampInfoAlarmList(LampInfoDTO dto) { return lampDao.getLampInfoAlarmList(dto); } @Override public List getLampAlarmTotal(LampInfoDTO dto) { return lampDao.getLampAlarmTotal(dto); } @Override public int getAlarmCountByVO(LampVO lampVO) { return lampDao.getAlarmCountByVO(lampVO); } @Override public int getOnlineCountByVO(LampVO lampVO) { return lampDao.getOnlineCountByVO(lampVO); } @Override public List getLampSectionAlarmCountTop(LampVO vo) { return lampDao.getLampSectionAlarmCountTop(vo); } @Override public LampInfoDTO getLampOfLampPoleById(Integer lampPoleId, Integer lampId) { LampInfoDTO lampInfoDTO = lampDao.getLampOfLampPoleById(lampPoleId, lampId); String workTimeTotal = lampInfoDTO.getWorkTimeTotal(); int workTime = Integer.parseInt(workTimeTotal); int hour = workTime / 60; int min = workTime % 60; String hourStr,minStr; if (hour < 10) { hourStr = "0" + hour; } else { hourStr = hour + ""; } if (min < 10) { minStr = "0" + min; } else { minStr = min + ""; } workTimeTotal = hourStr + ":" + minStr; lampInfoDTO.setWorkTimeTotal(workTimeTotal); return lampInfoDTO; } @Override public LampInfoLogNewDTO getComBySectionList(LampVO vo) { return lampDao.getComBySectionList(vo); } @Override public Integer updateLight(LampInfoDTO lampInfoDTO) { return lampDao.updateLight(lampInfoDTO); } @Override public List getListByIdList(List idList) { return lampDao.getListByIdList(idList); } @Override public Integer getLampPoleCountByVO(LampCountVO lampCountVO) { return lampDao.getLampPoleCountByVO(lampCountVO); } @Override public List areaInfoLampList(LampListResponseVO lampListResponseVO) { return lampDao.areaInfoLampList(lampListResponseVO); } }