Browse Source

修改表底计算逻辑

xieshengjie 3 years ago
parent
commit
a079705b98

+ 6 - 4
src/main/java/cn/gyee/tamplate/model/auto/Meterpoint2.java

@@ -1,6 +1,8 @@
 package cn.gyee.tamplate.model.auto;
 
 import java.math.BigDecimal;
+
+import cn.gyee.tamplate.util.DoubleUtils;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -60,7 +62,7 @@ public class Meterpoint2 extends Model {
     private String uniformcode;
 
     @TableField("MAGNIFICATION")
-    private BigDecimal magnification;
+    private Double magnification;
 
     @TableField("SHORTID")
     private String shortid;
@@ -72,13 +74,13 @@ public class Meterpoint2 extends Model {
     private String realtimeid;
 
     @TableField("INITIALVALUE")
-    private BigDecimal initialvalue;
+    private Double initialvalue;
 
     @TableField("XS")
-    private BigDecimal xs;
+    private Double xs;
 
     @TableField("MAGNIFICATIONXS")
-    private BigDecimal magnificationxs;
+    private Double magnificationxs;
 
 
 }

+ 7 - 5
src/main/java/cn/gyee/tamplate/service/analysis/AnalysisNewService.java

@@ -160,8 +160,9 @@ public class AnalysisNewService {
                     analysissubtablebottom.setRecorddate(DateUtils.parseDate(day));
                     analysissubtablebottom.setStopcode(m.getNow());
                     analysissubtablebottom.setStopcodemodify(m.getNow());
-                    analysissubtablebottom.setDayvalue(m.getDayvalue());
-                    analysissubtablebottom.setDayvaluemodify(m.getDayvalue());
+                    double dayvalue = DoubleUtils.GetResult(DoubleUtils.GetResult(m.getNow(),m.getDay(),"-"),meterMap.get(m.getMeterid()).getMagnification(),"*");
+                    analysissubtablebottom.setDayvalue(dayvalue);
+                    analysissubtablebottom.setDayvaluemodify(dayvalue);
                     analysissubtablebottomService.save(analysissubtablebottom);
                 });
             }
@@ -207,8 +208,9 @@ public class AnalysisNewService {
                     analysissubtablebottom.setRecorddate(DateUtils.parseDate(day));
                     analysissubtablebottom.setStopcode(m.getNow());
                     analysissubtablebottom.setStopcodemodify(m.getNow());
-                    analysissubtablebottom.setDayvalue(m.getDayvalue());
-                    analysissubtablebottom.setDayvaluemodify(m.getDayvalue());
+                    double dayvalue = DoubleUtils.GetResult(DoubleUtils.GetResult(m.getNow(),m.getDay(),"-"),meterMap.get(m.getMeterid()).getMagnification(),"*");
+                    analysissubtablebottom.setDayvalue(dayvalue);
+                    analysissubtablebottom.setDayvaluemodify(dayvalue);
                     analysissubtablebottomService.save(analysissubtablebottom);
                 });
             }
@@ -1024,7 +1026,7 @@ public class AnalysisNewService {
             LinkedHashMap addValMap = new LinkedHashMap();
 
             for (String meterid : collect) {
-                addMap.put(meterMap.get(meterid).getCode() + "_" + meterMap.get(meterid).getDescription(), Class.forName("java.math.BigDecimal"));
+                addMap.put(meterMap.get(meterid).getCode() + "_" + meterMap.get(meterid).getDescription(), Class.forName("java.lang.Double"));
                 addValMap.put(meterMap.get(meterid).getCode() + "_" + meterMap.get(meterid).getDescription(), meterMap.get(meterid).getMagnification());
             }
             Object blo = new ClassUtil().dynamicClass(blObject, addMap, addValMap);

+ 33 - 0
src/main/java/cn/gyee/tamplate/util/DoubleUtils.java

@@ -78,5 +78,38 @@ public class DoubleUtils {
 
     }
 
+    /**
+     *
+     * @param numA 数字A
+     * @param numB 数字B
+     * @param operate 运算符
+     * @return
+     */
+    public static double GetResult(double numA, double numB, String operate){
+        double res = 0;
+        BigDecimal bigA = new BigDecimal(Double.toString(numA));
+        BigDecimal bigB = new BigDecimal(Double.toString(numB));
+        switch (operate) {
+
+            case "+":
+                res = bigA.add(bigB).doubleValue();
+                break;
+            case "-":
+                res = bigA.subtract(bigB).doubleValue();
+                break;
+            case "*":
+                res = bigA.multiply(bigB).doubleValue();
+                break;
+            case "/":
+                res = bigA.divide(bigB).doubleValue();
+                break;
+            default :
+                System.out.println("运算符不合法~");
+                break;
+        }
+        return res;
+    }
+
+
 
 }

+ 5 - 5
src/test/java/cn/gyee/tamplate/AnalysisTest.java

@@ -33,11 +33,11 @@ public class AnalysisTest {
 //        analysisNewService.savePvStation("2021-04-01", "2021-04-22");
 
 
-//                analysisNewService.savaAnalysismain("2021-04-01", "2021-04-22");
-//        analysisNewService.saveAnalysisTableBottom("2021-03-31", "2021-04-22");
-//        analysisNewService.saveWindProject("2021-04-01", "2021-04-05");
-//        analysisNewService.saveWindStation("2021-04-01", "2021-04-05");
-//        analysisNewService.saveCompany("2021-04-01", "2021-04-05");
+              //  analysisNewService.savaAnalysismain("2021-04-25", "2021-04-25");
+//        analysisNewService.saveAnalysisTableBottom("2021-04-26", "2021-04-26");
+//        analysisNewService.saveWindProject("2021-04-26", "2021-04-26");
+//        analysisNewService.saveWindStation("2021-04-26", "2021-04-26");
+//        analysisNewService.saveCompany("2021-04-26", "2021-04-26");