|
@@ -1,7 +1,6 @@
|
|
|
package com.huaxu.service;
|
|
|
|
|
|
-import com.huaxu.dto.AmountDayThirtyDto;
|
|
|
-import com.huaxu.dto.AmountTotalDto;
|
|
|
+import com.huaxu.dto.*;
|
|
|
import com.huaxu.entity.*;
|
|
|
import com.huaxu.util.ByteArrayUtils;
|
|
|
import com.huaxu.util.RedisUtil;
|
|
@@ -10,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -154,11 +154,11 @@ public class SecSupplyService {
|
|
|
monthReportLast.setMonth(begin.get(Calendar.MONTH) + 1);
|
|
|
monthReportLast.setParentSceneLists(sceneEntities);
|
|
|
List<MonthReportEntity> monthReportsLast = monthReportService.findAmountTotalBySceneIds(monthReportLast);
|
|
|
- if (monthReportNew.size() > 0 && monthReportsLast.size() > 0&& monthReportNew.get(0)!=null&&monthReportsLast.get(0)!=null) {
|
|
|
+ if (monthReportNew.size() > 0 && monthReportsLast.size() > 0 && monthReportNew.get(0) != null && monthReportsLast.get(0) != null) {
|
|
|
monthAmount = monthReportNew.get(0).getLatestValue() - monthReportsLast.get(0).getLatestValue() + dayAmount;
|
|
|
- }else if (monthReportNew.size() > 0&&monthReportNew.get(0)!=null) {
|
|
|
+ } else if (monthReportNew.size() > 0 && monthReportNew.get(0) != null) {
|
|
|
monthAmount = monthReportNew.get(0).getLatestValue() + dayAmount;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
monthAmount = dayAmount;
|
|
|
}
|
|
|
amountTotalDto.setMonthAmount((double) Math.round(monthAmount * 1000) / 1000);
|
|
@@ -169,18 +169,64 @@ public class SecSupplyService {
|
|
|
yearReportEntity.setYear(begin.get(Calendar.YEAR));
|
|
|
yearReportEntity.setParentSceneLists(sceneEntities);
|
|
|
List<YearReportEntity> yearReportsNew = yearReportService.findAmountTotalBySceneIds(yearReportEntity);
|
|
|
- yearReportEntity.setYear(begin.get(Calendar.YEAR)-1);
|
|
|
+ yearReportEntity.setYear(begin.get(Calendar.YEAR) - 1);
|
|
|
List<YearReportEntity> yearReportsLast = yearReportService.findAmountTotalBySceneIds(yearReportEntity);
|
|
|
- if (yearReportsNew.size() > 0 && yearReportsLast.size() > 0&&yearReportsNew.get(0)!=null&&yearReportsLast.get(0)!=null) {
|
|
|
+ if (yearReportsNew.size() > 0 && yearReportsLast.size() > 0 && yearReportsNew.get(0) != null && yearReportsLast.get(0) != null) {
|
|
|
yearAmount = yearReportsNew.get(0).getLatestValue() - yearReportsLast.get(0).getLatestValue() + monthAmount;
|
|
|
- }else if (yearReportsNew.size() > 0&&yearReportsNew.get(0)!=null) {
|
|
|
+ } else if (yearReportsNew.size() > 0 && yearReportsNew.get(0) != null) {
|
|
|
yearAmount = yearReportsNew.get(0).getLatestValue() + monthAmount;
|
|
|
- }else
|
|
|
- {
|
|
|
- yearAmount=monthAmount;
|
|
|
+ } else {
|
|
|
+ yearAmount = monthAmount;
|
|
|
}
|
|
|
amountTotalDto.setYearAmount((double) Math.round(yearAmount * 1000) / 1000);
|
|
|
return amountTotalDto;
|
|
|
}
|
|
|
|
|
|
+ public WaterPieDto selectWaterQualityByTypeName(SceneEntity sceneEntity) {
|
|
|
+ List<SceneEntity> sceneEntities = sceneService.selectByTypeName(sceneEntity);
|
|
|
+ if (sceneEntities.size() == 0)
|
|
|
+ return null;
|
|
|
+ WaterPieDto waterPieDto = new WaterPieDto();
|
|
|
+ DeviceParmEntity deviceParmEntity = new DeviceParmEntity();
|
|
|
+ deviceParmEntity.setSceneEntities(sceneEntities);
|
|
|
+ List<ParmTypeCountDto> list = deviceParmService.findAlarmCount(deviceParmEntity);
|
|
|
+ //余氯11 浊度9 PH7 cod 15
|
|
|
+ for(ParmTypeCountDto item : list)
|
|
|
+ {
|
|
|
+ switch(item.getParmType())
|
|
|
+ {
|
|
|
+ case 7:
|
|
|
+ WaterPieStateDto waterPieStateDto1 = new WaterPieStateDto();
|
|
|
+ waterPieStateDto1.setNormalCount(item.getTotalCount()- item.getNbnormalCount());
|
|
|
+ waterPieStateDto1.setNbnormalCount(item.getNbnormalCount());
|
|
|
+ DecimalFormat df1 = new DecimalFormat("#.00");
|
|
|
+ waterPieStateDto1.setPercentage((double) (Math.round((Double.valueOf(item.getTotalCount()- item.getNbnormalCount())/Double.valueOf(item.getTotalCount()))*100)));
|
|
|
+ waterPieDto.setPh(waterPieStateDto1);
|
|
|
+ break;
|
|
|
+ case 9:
|
|
|
+ WaterPieStateDto waterPieStateDto2 = new WaterPieStateDto();
|
|
|
+ waterPieStateDto2.setNormalCount(item.getTotalCount()- item.getNbnormalCount());
|
|
|
+ waterPieStateDto2.setNbnormalCount(item.getNbnormalCount());
|
|
|
+ DecimalFormat df2 = new DecimalFormat("#.00");
|
|
|
+ waterPieStateDto2.setPercentage((double) (Math.round((Double.valueOf(item.getTotalCount()- item.getNbnormalCount())/Double.valueOf(item.getTotalCount()))*100)));
|
|
|
+ waterPieDto.setTurbidity(waterPieStateDto2);
|
|
|
+ break;
|
|
|
+ case 11:
|
|
|
+ WaterPieStateDto waterPieStateDto3 = new WaterPieStateDto();
|
|
|
+ waterPieStateDto3.setNormalCount(item.getTotalCount()- item.getNbnormalCount());
|
|
|
+ waterPieStateDto3.setNbnormalCount(item.getNbnormalCount());
|
|
|
+ waterPieStateDto3.setPercentage((double) (Math.round((Double.valueOf(item.getTotalCount()- item.getNbnormalCount())/Double.valueOf(item.getTotalCount()))*100)));
|
|
|
+ waterPieDto.setResidualChlorine(waterPieStateDto3);
|
|
|
+ break;
|
|
|
+ case 15:
|
|
|
+ WaterPieStateDto waterPieStateDto4 = new WaterPieStateDto();
|
|
|
+ waterPieStateDto4.setNormalCount(item.getTotalCount()- item.getNbnormalCount());
|
|
|
+ waterPieStateDto4.setNbnormalCount(item.getNbnormalCount());
|
|
|
+ waterPieStateDto4.setPercentage((double) (Math.round((Double.valueOf(item.getTotalCount()- item.getNbnormalCount())/Double.valueOf(item.getTotalCount()))*100)));
|
|
|
+ waterPieDto.setWaterQuality(waterPieStateDto4);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return waterPieDto;
|
|
|
+ }
|
|
|
}
|