Răsfoiți Sursa

todo 给前端接口

wangmiaomiao 8 luni în urmă
părinte
comite
c8db5ce8ce

+ 3 - 1
slibra-admin/src/main/java/com/slibra/web/controller/business/GRPCController.java

@@ -11,6 +11,7 @@ import com.slibra.business.res.WorkOrderRes;
 import com.slibra.business.service.IFrontService;
 import com.slibra.common.DecimalUtils;
 import com.slibra.common.config.BigModelConfig;
+import com.slibra.common.constant.MyConstants;
 import com.slibra.common.core.controller.BaseController;
 import com.slibra.common.enums.BusinessEnum;
 import com.slibra.common.exception.ServiceException;
@@ -432,7 +433,7 @@ public class GRPCController extends BaseController {
             TXinyiDaily daily = this.xinyiDailyMapper.selectNewestData();
             for (DecisionReq decisionReq : decisionReqs) {
                 if(!Objects.isNull(daily)){
-                    decisionReq.setT(daily.getJsSw());
+                    decisionReq.setT(DecimalUtils.getAbsAndScale(daily.getJsSw(), MyConstants.INT_0));
                     decisionReq.setSVI(daily.getWntjzsAll());
                     decisionReq.setSV(daily.getWncjbAll());
                     decisionReq.setMlvss(daily.getHfxwnndAll());
@@ -458,6 +459,7 @@ public class GRPCController extends BaseController {
                     //2024年6月1日08:37:09 内回流加上
                     decisionReq.setR(daily.getNhlR());
                     decisionReq.setRR(daily.getWhlR());
+                    //todo 字符串的调用getAbsAndScaleStr()
                 }
             }
         }

+ 14 - 0
slibra-common/src/main/java/com/slibra/common/DecimalUtils.java

@@ -1,5 +1,7 @@
 package com.slibra.common;
 
+import com.slibra.common.utils.StringUtils;
+
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.Objects;
@@ -20,6 +22,18 @@ public class DecimalUtils {
         return req.abs().setScale(length, RoundingMode.HALF_UP);
     }
 
+    /**
+     * 处理字符串类型的数值 取绝对值并保持N位小数。
+     * @param req
+     * @param length
+     * @return
+     */
+    public static BigDecimal getAbsAndScaleStr(String req, int length){
+        if(StringUtils.isBlank(req))
+            return null;
+        return new BigDecimal(req).abs().setScale(length, RoundingMode.HALF_UP);
+    }
+
 
     public static void main(String[] args) {
         System.out.println(getAbsAndScale(null, 3));

+ 8 - 0
slibra-common/src/main/java/com/slibra/common/constant/MyConstants.java

@@ -1,5 +1,7 @@
 package com.slibra.common.constant;
 
+import com.slibra.common.DecimalUtils;
+
 import java.math.BigDecimal;
 
 public class MyConstants {
@@ -29,6 +31,7 @@ public class MyConstants {
     public static final String NUMBER_3600 = "3600";
     public static final String NUMBER_24 = "24";
     public static final String NUMBER_2 = "2";
+    public static final int INT_0 = 0;
     public static final Double DOUBLE_75 = 75D;
     public static final int NUMBER_SCALE_4 = 4;
 //    public static final BigDecimal ROBOT_HY_DIVIDE = new BigDecimal("0.8");
@@ -260,4 +263,9 @@ public class MyConstants {
             "总结分析报告的主要发现,强调当前水质和生化指标的整体状况。\n" +
             "对未来水质管理和监控工作提出建议和展望。";
 
+
+    public static void main(String[] args) {
+        System.out.println(DecimalUtils.getAbsAndScale(new BigDecimal("2.211"), MyConstants.INT_0));
+    }
+
 }

+ 1 - 0
slibra-quartz/src/main/java/com/slibra/quartz/task/AsyncTask.java

@@ -1314,6 +1314,7 @@ public class AsyncTask {
                         }
                     }
                 }
+                //todo 字符串的调用getAbsAndScaleStr()
             }
         }
 //        String rows = JSON.toJSONString(decisionReqs, JSONWriter.Feature.WriteNulls);