package com.welampiot.service.impl; import com.welampiot.dao.LampInfoCacheByDayDao; import com.welampiot.dto.LampInfoCacheByDayDTO; import com.welampiot.dto.LampInfoDTO; import com.welampiot.service.LampInfoCacheByDayService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.DecimalFormat; import java.util.List; /** * ClassName: LampInfoCacheByDayServiceImpl * Package: com.welampiot.service.impl * Description: * * @Author: zhj_Start * @Create: 2023/6/8 - 9:51 * @Version: v1.0 */ @Service public class LampInfoCacheByDayServiceImpl implements LampInfoCacheByDayService { @Autowired private LampInfoCacheByDayDao lampInfoCacheByDayDao; @Override public List getDayEleListByDTO(LampInfoDTO dto) { return lampInfoCacheByDayDao.getDayEleListByDTO(dto); } @Override public Integer getTimezoneBySectionId() { return lampInfoCacheByDayDao.getTimezoneBySectionId(); } @Override public List getMonthConSum(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getMonthConSum(dto); } @Override public List getYearConSum(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getYearConSum(dto); } @Override public LampInfoCacheByDayDTO getAreaOrSectionOfConSum(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getAreaOrSectionOfConSum(dto); } @Override public List getSectionOfYearConSum(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getSectionOfYearConSum(dto); } @Override public List getSectionOfMonthConSum(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getSectionOfMonthConSum(dto); } @Override public List getConSumListBySection(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getConSumListBySection(dto); } @Override public List getEleConsumptionSaveList(LampInfoCacheByDayDTO dto) { List list = lampInfoCacheByDayDao.getEleConsumptionSaveList(dto); DecimalFormat decimalFormat = new DecimalFormat("0.00"); for (LampInfoCacheByDayDTO l : list) { if (l.getDayConsumption() != null) { // 当天用电量 float dayConSum = Float.parseFloat(l.getDayConsumption()); float dayFree = dayConSum * 0.75f; String format = decimalFormat.format(dayConSum); String format1 = decimalFormat.format(dayFree); l.setDayConsumption(format); l.setDayUser(format1); } else { l.setDayConsumption("0"); l.setDayUser("0"); } if (l.getMonthConsumption() != null) { // 当月用电量 float monthConSum = Float.parseFloat(l.getMonthConsumption()); float monthFree = monthConSum * 0.75f; String format = decimalFormat.format(monthConSum); String format1 = decimalFormat.format(monthFree); l.setMonthConsumption(format); l.setMonthUser(format1); } else { l.setMonthConsumption("0"); l.setMonthUser("0"); } if (l.getYearConsumption() != null) { // 当年用电量 float conSum = Float.parseFloat(l.getYearConsumption()); float free = conSum * 0.75f; String format = decimalFormat.format(conSum); String format1 = decimalFormat.format(free); l.setYearConsumption(format); l.setYearUser(format1); } else { l.setYearConsumption("0"); l.setYearUser("0"); } if (l.getTotalConsumption() != null) { // 累计用电量 float conSum = Float.parseFloat(l.getTotalConsumption()); float free = conSum * 0.75f; String format = decimalFormat.format(conSum); String format1 = decimalFormat.format(free); l.setTotalConsumption(format); l.setTotalUser(format1); } else { l.setTotalConsumption("0"); l.setTotalUser("0"); } if (l.getDayEleSave() != null) { // 当天省电量 float save = Float.parseFloat(l.getDayEleSave()); float free = save * 0.75f; String format = decimalFormat.format(save); String format1 = decimalFormat.format(free); l.setDayEleSave(format); l.setDayEleUser(format1); } else { l.setDayEleSave("0"); l.setDayEleUser("0"); } if (l.getMonthEleSave() != null) { // 当月省电量 float save = Float.parseFloat(l.getMonthEleSave()); float free = save * 0.75f; String format = decimalFormat.format(save); String format1 = decimalFormat.format(free); l.setMonthEleSave(format); l.setMonthEleUser(format1); } else { l.setMonthEleSave("0"); l.setMonthEleUser("0"); } if (l.getYearEleSave() != null) { // 当年省电量 float save = Float.parseFloat(l.getYearEleSave()); float free = save * 0.75f; String format = decimalFormat.format(save); String format1 = decimalFormat.format(free); l.setYearEleSave(format); l.setYearEleUser(format1); } else { l.setYearEleSave("0"); l.setYearEleUser("0"); } if (l.getTotalEleSave() != null) { // 累计省电量 float save = Float.parseFloat(l.getTotalEleSave()); float free = save * 0.75f; String format = decimalFormat.format(save); String format1 = decimalFormat.format(free); l.setTotalEleSave(format); l.setTotalEleUser(format1); } else { l.setTotalEleSave("0"); l.setTotalEleUser("0"); } if (l.getDayLightTime() == null) { // 当天亮灯时长 l.setDayLightTime(0); } if (l.getMonthLightTime() == null) { // 当月亮灯时长 l.setMonthLightTime(0); } if (l.getYearLightTime() == null) { // 当年亮灯时长 l.setYearLightTime(0); } if (l.getLightTime() == null) { // 累计亮灯时长 l.setLightTime(0L); } if (l.getNewTime() != null) { l.setUpdateTime(l.getNewTime()); } } return list; } @Override public void deleteLampInfoCacheByDayData(LampInfoCacheByDayDTO dto) { lampInfoCacheByDayDao.deleteLampInfoCacheByDayData(dto); } @Override public LampInfoCacheByDayDTO getOneDayConSum(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getOneDayConSum(dto); } @Override public List getNearDayConSumList(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getNearDayConSumList(dto); } @Override public List getNearSaveAndEleList(LampInfoCacheByDayDTO dto) { return lampInfoCacheByDayDao.getNearSaveAndEleList(dto); } }