Bläddra i källkod

处理小时精度问题

wangmiaomiao 11 månader sedan
förälder
incheckning
9d5542dce7

+ 15 - 12
slibra-admin/src/main/java/com/slibra/web/controller/business/WarningController.java

@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.ZoneId;
@@ -74,7 +75,9 @@ public class WarningController extends BaseController {
         Date currentDate = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
         Date currentDate = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
         //获取对个格式日期字符串
         //获取对个格式日期字符串
         String currentDateStr = DateUtil.format(currentDate, DateUtils.YYYYMMDD_TS);
         String currentDateStr = DateUtil.format(currentDate, DateUtils.YYYYMMDD_TS);
+        currentDateStr = "2024/03/12";
         String currentHourStr = DateUtil.format(currentDate, DateUtils.YYYYMMDDHH_TS);
         String currentHourStr = DateUtil.format(currentDate, DateUtils.YYYYMMDDHH_TS);
+        currentHourStr = "2024/05/05 11";
         //查询工业库 日报库 机器人化验库
         //查询工业库 日报库 机器人化验库
         List<TXinyiDaily> tXinyiDailies = this.dailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(currentDateStr).build());
         List<TXinyiDaily> tXinyiDailies = this.dailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(currentDateStr).build());
         List<TXinyiIndustry> tXinyiIndustries = this.industryMapper.selectTXinyiIndustryList(TXinyiIndustry.builder().testHour(currentHourStr).build());
         List<TXinyiIndustry> tXinyiIndustries = this.industryMapper.selectTXinyiIndustryList(TXinyiIndustry.builder().testHour(currentHourStr).build());
@@ -330,7 +333,7 @@ public class WarningController extends BaseController {
             BigDecimal shcHyOneMlvss = tXinyiDaily.getShcHyOneMlvss();
             BigDecimal shcHyOneMlvss = tXinyiDaily.getShcHyOneMlvss();
             BigDecimal hfxwnndzbGkz = normConfig.getHfxwnndzbGkz();
             BigDecimal hfxwnndzbGkz = normConfig.getHfxwnndzbGkz();
             if(!Objects.isNull(shcHyOneMlss) && !Objects.isNull(shcHyOneMlvss) && !Objects.isNull(hfxwnndzbGkz)){
             if(!Objects.isNull(shcHyOneMlss) && !Objects.isNull(shcHyOneMlvss) && !Objects.isNull(hfxwnndzbGkz)){
-                BigDecimal divide = shcHyOneMlvss.divide(shcHyOneMlss);
+                BigDecimal divide = shcHyOneMlvss.divide(shcHyOneMlss, 4, RoundingMode.HALF_UP);
                 if(divide.compareTo(hfxwnndzbGkz) < 0)
                 if(divide.compareTo(hfxwnndzbGkz) < 0)
                     System.out.println("挥发性污泥浓度占比(一池)报警级别为 一级");
                     System.out.println("挥发性污泥浓度占比(一池)报警级别为 一级");
                 BigDecimal hfxwnndzbSjz = normConfig.getHfxwnndzbSjz();
                 BigDecimal hfxwnndzbSjz = normConfig.getHfxwnndzbSjz();
@@ -347,7 +350,7 @@ public class WarningController extends BaseController {
             BigDecimal shcHyTwoMlss = tXinyiDaily.getShcHyTwoMlss();
             BigDecimal shcHyTwoMlss = tXinyiDaily.getShcHyTwoMlss();
             BigDecimal shcHyTwoMlvss = tXinyiDaily.getShcHyTwoMlvss();
             BigDecimal shcHyTwoMlvss = tXinyiDaily.getShcHyTwoMlvss();
             if(!Objects.isNull(shcHyTwoMlss) && !Objects.isNull(shcHyTwoMlvss) && !Objects.isNull(hfxwnndzbGkz)){
             if(!Objects.isNull(shcHyTwoMlss) && !Objects.isNull(shcHyTwoMlvss) && !Objects.isNull(hfxwnndzbGkz)){
-                BigDecimal divide = shcHyTwoMlvss.divide(shcHyTwoMlss);
+                BigDecimal divide = shcHyTwoMlvss.divide(shcHyTwoMlss, 4, RoundingMode.HALF_UP);
                 if(divide.compareTo(hfxwnndzbGkz) < 0)
                 if(divide.compareTo(hfxwnndzbGkz) < 0)
                     System.out.println("挥发性污泥浓度占比(二池)报警级别为 一级");
                     System.out.println("挥发性污泥浓度占比(二池)报警级别为 一级");
                 BigDecimal hfxwnndzbSjz = normConfig.getHfxwnndzbSjz();
                 BigDecimal hfxwnndzbSjz = normConfig.getHfxwnndzbSjz();
@@ -402,7 +405,7 @@ public class WarningController extends BaseController {
             BigDecimal jsBod5 = tXinyiDaily.getJsBod5();
             BigDecimal jsBod5 = tXinyiDaily.getJsBod5();
             BigDecimal jsTn = tXinyiDaily.getJsTn();
             BigDecimal jsTn = tXinyiDaily.getJsTn();
             if(!Objects.isNull(jsBod5) && !Objects.isNull(jsTn)){
             if(!Objects.isNull(jsBod5) && !Objects.isNull(jsTn)){
-                BigDecimal divide = jsBod5.divide(jsTn);
+                BigDecimal divide = jsBod5.divide(jsTn, 4, RoundingMode.HALF_UP);
                 BigDecimal jstdbnkzXxz = normConfig.getJstdbnkzXxz();
                 BigDecimal jstdbnkzXxz = normConfig.getJstdbnkzXxz();
                 if(!Objects.isNull(jstdbnkzXxz) && divide.compareTo(jstdbnkzXxz) < 0)
                 if(!Objects.isNull(jstdbnkzXxz) && divide.compareTo(jstdbnkzXxz) < 0)
                     System.out.println("进水碳氮比报警级别为 一级");
                     System.out.println("进水碳氮比报警级别为 一级");
@@ -417,7 +420,7 @@ public class WarningController extends BaseController {
             //21 进水碳磷比报警 进水碳磷比=[c]=[BOD_in]/[TP_in]
             //21 进水碳磷比报警 进水碳磷比=[c]=[BOD_in]/[TP_in]
             BigDecimal jsTp = tXinyiDaily.getJsTp();
             BigDecimal jsTp = tXinyiDaily.getJsTp();
             if(!Objects.isNull(jsBod5) && !Objects.isNull(jsTp)){
             if(!Objects.isNull(jsBod5) && !Objects.isNull(jsTp)){
-                BigDecimal divide = jsTp.divide(jsTp);
+                BigDecimal divide = jsTp.divide(jsTp, 4, RoundingMode.HALF_UP);
                 BigDecimal jstlbNkz = normConfig.getJstlbNkz();
                 BigDecimal jstlbNkz = normConfig.getJstlbNkz();
                 if(!Objects.isNull(jstlbNkz)){
                 if(!Objects.isNull(jstlbNkz)){
                     if(divide.compareTo(jstlbNkz) < 0)
                     if(divide.compareTo(jstlbNkz) < 0)
@@ -435,7 +438,7 @@ public class WarningController extends BaseController {
             BigDecimal jsCod = tXinyiDaily.getJsCod();
             BigDecimal jsCod = tXinyiDaily.getJsCod();
             if(!Objects.isNull(jsBod5) && !Objects.isNull(jsCod)){
             if(!Objects.isNull(jsBod5) && !Objects.isNull(jsCod)){
                 BigDecimal jsbodycodbzSzj = normConfig.getJsbodycodbzSzj();
                 BigDecimal jsbodycodbzSzj = normConfig.getJsbodycodbzSzj();
-                BigDecimal divide = jsBod5.divide(jsCod);
+                BigDecimal divide = jsBod5.divide(jsCod, 4, RoundingMode.HALF_UP);
                 if(!Objects.isNull(jsbodycodbzSzj) && divide.compareTo(jsbodycodbzSzj) < 0)
                 if(!Objects.isNull(jsbodycodbzSzj) && divide.compareTo(jsbodycodbzSzj) < 0)
                     System.out.println("进水BOD与COD比值报警别为 一级");
                     System.out.println("进水BOD与COD比值报警别为 一级");
                 System.out.println("进水BOD与COD比值报警级别为数据正常~~~");
                 System.out.println("进水BOD与COD比值报警级别为数据正常~~~");
@@ -584,8 +587,8 @@ public class WarningController extends BaseController {
             BigDecimal eccsjzzj = normConfig.getECCSJZZJ();
             BigDecimal eccsjzzj = normConfig.getECCSJZZJ();
             BigDecimal eccbmfhznkzSxz = normConfig.getEccbmfhznkzSxz();
             BigDecimal eccbmfhznkzSxz = normConfig.getEccbmfhznkzSxz();
             if(!Objects.isNull(eccbmfhznkzSxz) && !Objects.isNull(jsl) && !Objects.isNull(eccsl) && !Objects.isNull(eccsjzzj)){
             if(!Objects.isNull(eccbmfhznkzSxz) && !Objects.isNull(jsl) && !Objects.isNull(eccsl) && !Objects.isNull(eccsjzzj)){
-                BigDecimal eccArea = new BigDecimal(Math.PI).multiply(eccsjzzj).multiply(eccsjzzj).divide(new BigDecimal("4"));
-                BigDecimal multiply = jsl.divide(eccsl).multiply(eccArea);
+                BigDecimal eccArea = new BigDecimal(Math.PI).multiply(eccsjzzj).multiply(eccsjzzj).divide(new BigDecimal("4"), 4, RoundingMode.HALF_UP);
+                BigDecimal multiply = jsl.divide(eccsl, 4, RoundingMode.HALF_UP).multiply(eccArea);
                 if(multiply.compareTo(eccbmfhznkzSxz) > 0)
                 if(multiply.compareTo(eccbmfhznkzSxz) > 0)
                     System.out.println("二沉池表面负荷报警别为 一级");
                     System.out.println("二沉池表面负荷报警别为 一级");
                 System.out.println("二沉池表面负荷报警级别为数据正常~~~");
                 System.out.println("二沉池表面负荷报警级别为数据正常~~~");
@@ -598,9 +601,9 @@ public class WarningController extends BaseController {
             BigDecimal eccglfhnkzSxz = normConfig.getEccglfhnkzSxz();
             BigDecimal eccglfhnkzSxz = normConfig.getEccglfhnkzSxz();
             if(!Objects.isNull(whlR) && !Objects.isNull(eccglfhnkzSxz) && !Objects.isNull(jsl)
             if(!Objects.isNull(whlR) && !Objects.isNull(eccglfhnkzSxz) && !Objects.isNull(jsl)
                 && !Objects.isNull(shcHyOneMlss) && !Objects.isNull(shcHyTwoMlss) && !Objects.isNull(eccsl) && !Objects.isNull(eccsjzzj)){
                 && !Objects.isNull(shcHyOneMlss) && !Objects.isNull(shcHyTwoMlss) && !Objects.isNull(eccsl) && !Objects.isNull(eccsjzzj)){
-                BigDecimal avgMlss = shcHyOneMlss.add(shcHyTwoMlss).divide(new BigDecimal("2"));
-                BigDecimal eccArea = new BigDecimal(Math.PI).multiply(eccsjzzj).multiply(eccsjzzj).divide(new BigDecimal("4"));
-                BigDecimal divide = whlR.add(new BigDecimal("1")).multiply(jsl).multiply(new BigDecimal("24")).multiply(avgMlss).divide(eccsl).divide(eccArea).divide(new BigDecimal("1000"));
+                BigDecimal avgMlss = shcHyOneMlss.add(shcHyTwoMlss).divide(new BigDecimal("2"), 4, RoundingMode.HALF_UP);
+                BigDecimal eccArea = new BigDecimal(Math.PI).multiply(eccsjzzj).multiply(eccsjzzj).divide(new BigDecimal("4"), 4, RoundingMode.HALF_UP);
+                BigDecimal divide = whlR.add(new BigDecimal("1")).multiply(jsl).multiply(new BigDecimal("24")).multiply(avgMlss).divide(eccsl, 4, RoundingMode.HALF_UP).divide(eccArea, 4, RoundingMode.HALF_UP).divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
                 if(divide.compareTo(eccglfhnkzSxz) > 0)
                 if(divide.compareTo(eccglfhnkzSxz) > 0)
                     System.out.println("二沉池固体负荷报警别为 一级");
                     System.out.println("二沉池固体负荷报警别为 一级");
                 BigDecimal eccgtfhSjz = normConfig.getEccgtfhSjz();
                 BigDecimal eccgtfhSjz = normConfig.getEccgtfhSjz();
@@ -616,7 +619,7 @@ public class WarningController extends BaseController {
             BigDecimal fclbsl = normConfig.getFCLBSL();
             BigDecimal fclbsl = normConfig.getFCLBSL();
             BigDecimal fcxbgzxl = normConfig.getFCXBGZXL();
             BigDecimal fcxbgzxl = normConfig.getFCXBGZXL();
             if(!Objects.isNull(jsl) && !Objects.isNull(fcxbsjll) && !Objects.isNull(fclbsl) && !Objects.isNull(fcxbgzxl)){
             if(!Objects.isNull(jsl) && !Objects.isNull(fcxbsjll) && !Objects.isNull(fclbsl) && !Objects.isNull(fcxbgzxl)){
-                BigDecimal divide = fcxbsjll.multiply(fclbsl).multiply(fcxbgzxl).divide(jsl);
+                BigDecimal divide = fcxbsjll.multiply(fclbsl).multiply(fcxbgzxl).divide(jsl, 4, RoundingMode.HALF_UP);
                 BigDecimal fcxslblsjzXxz = normConfig.getFcxslblsjzXxz();
                 BigDecimal fcxslblsjzXxz = normConfig.getFcxslblsjzXxz();
                 if(!Objects.isNull(fcxslblsjzXxz) && divide.compareTo(fcxslblsjzXxz) < 0)
                 if(!Objects.isNull(fcxslblsjzXxz) && divide.compareTo(fcxslblsjzXxz) < 0)
                     System.out.println("深度处理反冲洗水量比例报警别为 一级");
                     System.out.println("深度处理反冲洗水量比例报警别为 一级");
@@ -633,7 +636,7 @@ public class WarningController extends BaseController {
             BigDecimal hxslcglmj = normConfig.getHXSLCGLMJ();
             BigDecimal hxslcglmj = normConfig.getHXSLCGLMJ();
             BigDecimal sdclfzglsdSjz = normConfig.getSdclfzglsdSjz();
             BigDecimal sdclfzglsdSjz = normConfig.getSdclfzglsdSjz();
             if(!Objects.isNull(hxslcsl) && !Objects.isNull(hxslcglmj) && !Objects.isNull(jsl) && !Objects.isNull(sdclfzglsdSjz)){
             if(!Objects.isNull(hxslcsl) && !Objects.isNull(hxslcglmj) && !Objects.isNull(jsl) && !Objects.isNull(sdclfzglsdSjz)){
-                BigDecimal divide = jsl.divide(hxslcsl).divide(hxslcglmj);
+                BigDecimal divide = jsl.divide(hxslcsl, 4, RoundingMode.HALF_UP).divide(hxslcglmj, 4, RoundingMode.HALF_UP);
                 if(divide.compareTo(sdclfzglsdSjz) >0 )
                 if(divide.compareTo(sdclfzglsdSjz) >0 )
                     System.out.println("深度处理峰值过滤速度报警别为 一级");
                     System.out.println("深度处理峰值过滤速度报警别为 一级");
                 System.out.println("深度处理峰值过滤速度报警级别为数据正常~~~");
                 System.out.println("深度处理峰值过滤速度报警级别为数据正常~~~");