فهرست منبع

预测结果比对 乘以100再加百分号 解决直接修改get方法导出Excel没有数据的bug

wangmiaomiao 9 ماه پیش
والد
کامیت
b5974f1718

+ 35 - 1
slibra-admin/src/main/java/com/slibra/web/controller/business/TXinyiForecastComparisonController.java

@@ -1,9 +1,13 @@
 package com.slibra.web.controller.business;
 
+import java.math.BigDecimal;
 import java.util.List;
+import java.util.Objects;
 import javax.servlet.http.HttpServletResponse;
-import org.springframework.security.access.prepost.PreAuthorize;
+
+import com.slibra.common.DecimalUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
@@ -21,6 +25,9 @@ import com.slibra.business.service.ITXinyiForecastComparisonService;
 import com.slibra.common.utils.poi.ExcelUtil;
 import com.slibra.common.core.page.TableDataInfo;
 
+import static com.slibra.common.constant.MyConstants.BigDecimal_100;
+import static com.slibra.common.constant.MyConstants.PERCENT_SYMBOL;
+
 /**
  * 信义预测对比Controller
  * 
@@ -43,6 +50,7 @@ public class TXinyiForecastComparisonController extends BaseController
     {
         startPage();
         List<TXinyiForecastComparison> list = tXinyiForecastComparisonService.selectTXinyiForecastComparisonList(tXinyiForecastComparison);
+        this.addListExtra(list);//处理误差率 乘以100,取绝对值 保留2位小数
         return getDataTable(list);
     }
 
@@ -55,10 +63,36 @@ public class TXinyiForecastComparisonController extends BaseController
     public void export(HttpServletResponse response, TXinyiForecastComparison tXinyiForecastComparison)
     {
         List<TXinyiForecastComparison> list = tXinyiForecastComparisonService.selectTXinyiForecastComparisonList(tXinyiForecastComparison);
+        this.addListExtra(list);//处理误差率 乘以100,取绝对值 保留2位小数
         ExcelUtil<TXinyiForecastComparison> util = new ExcelUtil<TXinyiForecastComparison>(TXinyiForecastComparison.class);
         util.exportExcel(response, list, "信义预测对比数据");
     }
 
+    private void addListExtra(List<TXinyiForecastComparison> list) {
+        if(!CollectionUtils.isEmpty(list)){
+            for (TXinyiForecastComparison tXinyiForecastComparison : list) {
+                BigDecimal hsErrorRateOne = tXinyiForecastComparison.getHsErrorRateOne();
+                if(!Objects.isNull(hsErrorRateOne))
+                    tXinyiForecastComparison.setHsErrorRateOneStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(hsErrorRateOne), 2) + PERCENT_SYMBOL);
+                BigDecimal hsErrorRateTwo = tXinyiForecastComparison.getHsErrorRateTwo();
+                if(!Objects.isNull(hsErrorRateTwo))
+                    tXinyiForecastComparison.setHsErrorRateTwoStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(hsErrorRateTwo), 2) + PERCENT_SYMBOL);
+                BigDecimal hsErrorRateThree = tXinyiForecastComparison.getHsErrorRateThree();
+                if(!Objects.isNull(hsErrorRateThree))
+                    tXinyiForecastComparison.setHsErrorRateThreeStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(hsErrorRateThree), 2) + PERCENT_SYMBOL);
+                BigDecimal yyErrorRateOne = tXinyiForecastComparison.getYyErrorRateOne();
+                if(!Objects.isNull(yyErrorRateOne))
+                    tXinyiForecastComparison.setYyErrorRateOneStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(yyErrorRateOne), 2) + PERCENT_SYMBOL);
+                BigDecimal yyErrorRateTwo = tXinyiForecastComparison.getYyErrorRateTwo();
+                if(!Objects.isNull(yyErrorRateTwo))
+                    tXinyiForecastComparison.setYyErrorRateTwoStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(yyErrorRateTwo), 2) + PERCENT_SYMBOL);
+                BigDecimal yyErrorRateThree = tXinyiForecastComparison.getYyErrorRateThree();
+                if(!Objects.isNull(yyErrorRateThree))
+                    tXinyiForecastComparison.setYyErrorRateThreeStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(yyErrorRateThree), 2) + PERCENT_SYMBOL);
+            }
+        }
+    }
+
     /**
      * 获取信义预测对比详细信息
      */

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

@@ -27,6 +27,7 @@ public class MyConstants {
     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");
+    public static final BigDecimal BigDecimal_100  = new BigDecimal(100);
     public static final BigDecimal GSLSONE_LAST = BigDecimal.valueOf(0.02 * 1.3 * 40 * 2);
     public static final BigDecimal GSLSTWO_LAST = BigDecimal.valueOf(0.016 * 1.1 * 41 * 2);
     public static final BigDecimal GSLS_XGS_LAST = BigDecimal.valueOf(Math.PI * 0.003 * 0.003 * 4 * 97119);

+ 3 - 2
slibra-system/src/main/java/com/slibra/business/domain/TXinyiForecastComparison.java

@@ -141,7 +141,8 @@ public class TXinyiForecastComparison extends BaseEntity
     private String timeEnd;
 
 
-    public String getHsErrorRateOneStr() {
+    //2024年6月24日15:27:47 因为导出关系,必须要set进去才能有结果
+    /*public String getHsErrorRateOneStr() {
         if(Objects.isNull(hsErrorRateOne))
             return null;
         return DecimalUtils.getAbsAndScale(hsErrorRateOne, 2) + PERCENT_SYMBOL;
@@ -175,5 +176,5 @@ public class TXinyiForecastComparison extends BaseEntity
         if(Objects.isNull(yyErrorRateThree))
             return null;
         return DecimalUtils.getAbsAndScale(yyErrorRateThree, 2) + PERCENT_SYMBOL;
-    }
+    }*/
 }