LampInfoCacheByDayServiceImpl.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. package com.welampiot.service.impl;
  2. import com.welampiot.dao.LampInfoCacheByDayDao;
  3. import com.welampiot.dto.LampInfoCacheByDayDTO;
  4. import com.welampiot.dto.LampInfoDTO;
  5. import com.welampiot.service.LampInfoCacheByDayService;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import java.text.DecimalFormat;
  9. import java.util.List;
  10. /**
  11. * ClassName: LampInfoCacheByDayServiceImpl
  12. * Package: com.welampiot.service.impl
  13. * Description:
  14. *
  15. * @Author: zhj_Start
  16. * @Create: 2023/6/8 - 9:51
  17. * @Version: v1.0
  18. */
  19. @Service
  20. public class LampInfoCacheByDayServiceImpl implements LampInfoCacheByDayService {
  21. @Autowired
  22. private LampInfoCacheByDayDao lampInfoCacheByDayDao;
  23. @Override
  24. public List<LampInfoCacheByDayDTO> getDayEleListByDTO(LampInfoDTO dto) {
  25. return lampInfoCacheByDayDao.getDayEleListByDTO(dto);
  26. }
  27. @Override
  28. public Integer getTimezoneBySectionId() {
  29. return lampInfoCacheByDayDao.getTimezoneBySectionId();
  30. }
  31. @Override
  32. public List<LampInfoCacheByDayDTO> getMonthConSum(LampInfoCacheByDayDTO dto) {
  33. return lampInfoCacheByDayDao.getMonthConSum(dto);
  34. }
  35. @Override
  36. public List<LampInfoCacheByDayDTO> getYearConSum(LampInfoCacheByDayDTO dto) {
  37. return lampInfoCacheByDayDao.getYearConSum(dto);
  38. }
  39. @Override
  40. public LampInfoCacheByDayDTO getAreaOrSectionOfConSum(LampInfoCacheByDayDTO dto) {
  41. return lampInfoCacheByDayDao.getAreaOrSectionOfConSum(dto);
  42. }
  43. @Override
  44. public List<LampInfoCacheByDayDTO> getSectionOfYearConSum(LampInfoCacheByDayDTO dto) {
  45. return lampInfoCacheByDayDao.getSectionOfYearConSum(dto);
  46. }
  47. @Override
  48. public List<LampInfoCacheByDayDTO> getSectionOfMonthConSum(LampInfoCacheByDayDTO dto) {
  49. return lampInfoCacheByDayDao.getSectionOfMonthConSum(dto);
  50. }
  51. @Override
  52. public List<LampInfoCacheByDayDTO> getConSumListBySection(LampInfoCacheByDayDTO dto) {
  53. return lampInfoCacheByDayDao.getConSumListBySection(dto);
  54. }
  55. @Override
  56. public List<LampInfoCacheByDayDTO> getEleConsumptionSaveList(LampInfoCacheByDayDTO dto) {
  57. List<LampInfoCacheByDayDTO> list = lampInfoCacheByDayDao.getEleConsumptionSaveList(dto);
  58. DecimalFormat decimalFormat = new DecimalFormat("0.00");
  59. for (LampInfoCacheByDayDTO l : list) {
  60. if (l.getDayConsumption() != null) { // 当天用电量
  61. float dayConSum = Float.parseFloat(l.getDayConsumption());
  62. float dayFree = dayConSum * 0.75f;
  63. String format = decimalFormat.format(dayConSum);
  64. String format1 = decimalFormat.format(dayFree);
  65. l.setDayConsumption(format);
  66. l.setDayUser(format1);
  67. } else {
  68. l.setDayConsumption("0");
  69. l.setDayUser("0");
  70. }
  71. if (l.getMonthConsumption() != null) { // 当月用电量
  72. float monthConSum = Float.parseFloat(l.getMonthConsumption());
  73. float monthFree = monthConSum * 0.75f;
  74. String format = decimalFormat.format(monthConSum);
  75. String format1 = decimalFormat.format(monthFree);
  76. l.setMonthConsumption(format);
  77. l.setMonthUser(format1);
  78. } else {
  79. l.setMonthConsumption("0");
  80. l.setMonthUser("0");
  81. }
  82. if (l.getYearConsumption() != null) { // 当年用电量
  83. float conSum = Float.parseFloat(l.getYearConsumption());
  84. float free = conSum * 0.75f;
  85. String format = decimalFormat.format(conSum);
  86. String format1 = decimalFormat.format(free);
  87. l.setYearConsumption(format);
  88. l.setYearUser(format1);
  89. } else {
  90. l.setYearConsumption("0");
  91. l.setYearUser("0");
  92. }
  93. if (l.getTotalConsumption() != null) { // 累计用电量
  94. float conSum = Float.parseFloat(l.getTotalConsumption());
  95. float free = conSum * 0.75f;
  96. String format = decimalFormat.format(conSum);
  97. String format1 = decimalFormat.format(free);
  98. l.setTotalConsumption(format);
  99. l.setTotalUser(format1);
  100. } else {
  101. l.setTotalConsumption("0");
  102. l.setTotalUser("0");
  103. }
  104. if (l.getDayEleSave() != null) { // 当天省电量
  105. float save = Float.parseFloat(l.getDayEleSave());
  106. float free = save * 0.75f;
  107. String format = decimalFormat.format(save);
  108. String format1 = decimalFormat.format(free);
  109. l.setDayEleSave(format);
  110. l.setDayEleUser(format1);
  111. } else {
  112. l.setDayEleSave("0");
  113. l.setDayEleUser("0");
  114. }
  115. if (l.getMonthEleSave() != null) { // 当月省电量
  116. float save = Float.parseFloat(l.getMonthEleSave());
  117. float free = save * 0.75f;
  118. String format = decimalFormat.format(save);
  119. String format1 = decimalFormat.format(free);
  120. l.setMonthEleSave(format);
  121. l.setMonthEleUser(format1);
  122. } else {
  123. l.setMonthEleSave("0");
  124. l.setMonthEleUser("0");
  125. }
  126. if (l.getYearEleSave() != null) { // 当年省电量
  127. float save = Float.parseFloat(l.getYearEleSave());
  128. float free = save * 0.75f;
  129. String format = decimalFormat.format(save);
  130. String format1 = decimalFormat.format(free);
  131. l.setYearEleSave(format);
  132. l.setYearEleUser(format1);
  133. } else {
  134. l.setYearEleSave("0");
  135. l.setYearEleUser("0");
  136. }
  137. if (l.getTotalEleSave() != null) { // 累计省电量
  138. float save = Float.parseFloat(l.getTotalEleSave());
  139. float free = save * 0.75f;
  140. String format = decimalFormat.format(save);
  141. String format1 = decimalFormat.format(free);
  142. l.setTotalEleSave(format);
  143. l.setTotalEleUser(format1);
  144. } else {
  145. l.setTotalEleSave("0");
  146. l.setTotalEleUser("0");
  147. }
  148. if (l.getDayLightTime() == null) { // 当天亮灯时长
  149. l.setDayLightTime(0);
  150. }
  151. if (l.getMonthLightTime() == null) { // 当月亮灯时长
  152. l.setMonthLightTime(0);
  153. }
  154. if (l.getYearLightTime() == null) { // 当年亮灯时长
  155. l.setYearLightTime(0);
  156. }
  157. if (l.getLightTime() == null) { // 累计亮灯时长
  158. l.setLightTime(0L);
  159. }
  160. if (l.getNewTime() != null) {
  161. l.setUpdateTime(l.getNewTime());
  162. }
  163. }
  164. return list;
  165. }
  166. @Override
  167. public void deleteLampInfoCacheByDayData(LampInfoCacheByDayDTO dto) {
  168. lampInfoCacheByDayDao.deleteLampInfoCacheByDayData(dto);
  169. }
  170. @Override
  171. public LampInfoCacheByDayDTO getOneDayConSum(LampInfoCacheByDayDTO dto) {
  172. return lampInfoCacheByDayDao.getOneDayConSum(dto);
  173. }
  174. @Override
  175. public List<LampInfoCacheByDayDTO> getNearDayConSumList(LampInfoCacheByDayDTO dto) {
  176. return lampInfoCacheByDayDao.getNearDayConSumList(dto);
  177. }
  178. @Override
  179. public List<LampInfoCacheByDayDTO> getNearSaveAndEleList(LampInfoCacheByDayDTO dto) {
  180. return lampInfoCacheByDayDao.getNearSaveAndEleList(dto);
  181. }
  182. }