Browse Source

万盛中期计量

chenr 4 ngày trước cách đây
mục cha
commit
57f58d345d

+ 24 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -73,6 +73,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.constraints.NotNull;
 import java.io.*;
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDate;
@@ -2957,12 +2958,32 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         return reportResult;
     }
 
+      public static void setZeroBigDecimalFieldsToNull(Object obj) throws IllegalAccessException {
+        Class<?> clazz = obj.getClass();
+        Field[] fields = clazz.getDeclaredFields();
+
+        for (Field field : fields) {
+            if (field.getType() == BigDecimal.class) {
+                field.setAccessible(true); // 设置访问权限
+                BigDecimal value = (BigDecimal) field.get(obj);
+                if (value != null && value.compareTo(BigDecimal.ZERO) == 0) {
+                    field.set(obj, null);
+                }
+            }
+        }
+    }
+
+    public static void setZeroBigDecimalFieldsToNullInList(List<?> list) throws IllegalAccessException {
+        for (Object obj : list) {
+            setZeroBigDecimalFieldsToNull(obj);
+        }
+    }
     /**
      * 工程支付月报获取pdfUrl  CR2
      * @param url
      * @return
      */
-    public ReportResult getMonthlyReportPDF(String url, Long reportId,Long contractId, Long periodId, Long projectId,List<ContractMeterPeriod> list,Long redisId){
+    public ReportResult getMonthlyReportPDF(String url, Long reportId,Long contractId, Long periodId, Long projectId,List<ContractMeterPeriod> list,Long redisId) throws IllegalAccessException {
         String sql="SELECT id from s_contract_inventory_form where contract_id="+contractId+" and parent_id=0";
         Long id = jdbcTemplate.queryForObject(sql, Long.class);
         InventoryFormDetailVO detail = iContractInventoryFormClient.detail(id);
@@ -3167,7 +3188,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         percentage6 = percentage6.setScale(2, BigDecimal.ROUND_HALF_UP);
         m19.setNowC(percentage6);
         values.add(m19);
-
+        setZeroBigDecimalFieldsToNullInList(values);
         InputStream modInput = null;
         FileInputStream excelFileInput = null;
         FileOutputStream outputStream = null;
@@ -3349,6 +3370,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             }
             list1.add(vo);
         }
+        setZeroBigDecimalFieldsToNullInList(list1);
         ReportResult reportResult = new ReportResult();
           String suffix=SnowFlakeUtil.getId()+".pdf";
         String sysLocalFileUrl = FileUtils.getSysLocalFileUrl();