123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- 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<LampInfoCacheByDayDTO> getDayEleListByDTO(LampInfoDTO dto) {
- return lampInfoCacheByDayDao.getDayEleListByDTO(dto);
- }
- @Override
- public Integer getTimezoneBySectionId() {
- return lampInfoCacheByDayDao.getTimezoneBySectionId();
- }
- @Override
- public List<LampInfoCacheByDayDTO> getMonthConSum(LampInfoCacheByDayDTO dto) {
- return lampInfoCacheByDayDao.getMonthConSum(dto);
- }
- @Override
- public List<LampInfoCacheByDayDTO> getYearConSum(LampInfoCacheByDayDTO dto) {
- return lampInfoCacheByDayDao.getYearConSum(dto);
- }
- @Override
- public LampInfoCacheByDayDTO getAreaOrSectionOfConSum(LampInfoCacheByDayDTO dto) {
- return lampInfoCacheByDayDao.getAreaOrSectionOfConSum(dto);
- }
- @Override
- public List<LampInfoCacheByDayDTO> getSectionOfYearConSum(LampInfoCacheByDayDTO dto) {
- return lampInfoCacheByDayDao.getSectionOfYearConSum(dto);
- }
- @Override
- public List<LampInfoCacheByDayDTO> getSectionOfMonthConSum(LampInfoCacheByDayDTO dto) {
- return lampInfoCacheByDayDao.getSectionOfMonthConSum(dto);
- }
- @Override
- public List<LampInfoCacheByDayDTO> getConSumListBySection(LampInfoCacheByDayDTO dto) {
- return lampInfoCacheByDayDao.getConSumListBySection(dto);
- }
- @Override
- public List<LampInfoCacheByDayDTO> getEleConsumptionSaveList(LampInfoCacheByDayDTO dto) {
- List<LampInfoCacheByDayDTO> 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<LampInfoCacheByDayDTO> getNearDayConSumList(LampInfoCacheByDayDTO dto) {
- return lampInfoCacheByDayDao.getNearDayConSumList(dto);
- }
- @Override
- public List<LampInfoCacheByDayDTO> getNearSaveAndEleList(LampInfoCacheByDayDTO dto) {
- return lampInfoCacheByDayDao.getNearSaveAndEleList(dto);
- }
- }
|