huangfuli 1 rok temu
rodzic
commit
69d98c15dc

+ 87 - 78
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/WarehouseBaseInfoServiceImpl.java

@@ -2119,7 +2119,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         // 指定单元格自动换行
         contextstyle1.setWrapText(true);
         // 设置单元格字体
-        contextstyle1.setFont(fontDetail1);
+        contextstyle1.setFont(fontDetail);
         // 右边框
         contextstyle1.setBorderRight(HSSFCellStyle.BORDER_THIN);
         // 左边框
@@ -2385,6 +2385,14 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         pageView.put("warehouseName", warehouseBaseInfo.getWarehouseName());
         // 查询入库记录总数
         List<ExportVView> dataList = baseMapper.getListByCondition(pageView);
+
+        DecimalFormat df = new DecimalFormat("0.00");
+        DecimalFormat df1 = new DecimalFormat("0.000");
+        contextstyle2.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,#####0.00000"));//保留两位小数点
+        contextstyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));//保留两位小数点
+        contextstyle1.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.000"));//保留两位小数点
+        contextstyle2.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));//保留两位小数点
+
         // 详情信息
         if (!CollectionUtils.isEmpty(dataList)) {
             for (int i = 0; i < dataList.size(); i++) {
@@ -2415,10 +2423,6 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
 
         HSSFRow rowp = sheet.createRow((int) (rownum));
         rowp.setHeightInPoints(20);
-        HSSFDataFormat df1 = wb.createDataFormat(); // 此处设置数据格式
-        contextstyle1.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));//保留两位小数点
-        HSSFDataFormat df2 = wb.createDataFormat(); // 此处设置数据格式
-        contextstyle2.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,#####0.00000"));//保留三位小数点
         cell = rowp.createCell(1);
         cell.setCellValue("平均值/合计");
         cell.setCellStyle(styleDetail);
@@ -2444,27 +2448,27 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         cell.setCellStyle(styleDetail);
         cell = rowp.createCell(12);
         cell.setCellStyle(styleDetail);
-        //水分平均值
         cell = rowp.createCell(13);
-        cell.setCellValue(bulkDensityTotal / netWeightTmp);
-        cell.setCellStyle(contextstyle1);
+        cell.setCellStyle(styleDetail);
+        //水分平均值
         cell = rowp.createCell(14);
-        cell.setCellValue(waterContentTotal / netWeightTmp);
-        cell.setCellStyle(contextstyle1);
+        cell.setCellValue(Double.parseDouble(df.format(bulkDensityTotal / netWeightTmp)));
+        cell.setCellStyle(contextstyle2);
         cell = rowp.createCell(15);
-        cell.setCellValue(mildewGrainTotal / netWeightTmp);
-        cell.setCellStyle(contextstyle1);
+        cell.setCellValue(Double.parseDouble(df.format(waterContentTotal / netWeightTmp)));
+        cell.setCellStyle(contextstyle2);
         cell = rowp.createCell(16);
-        cell.setCellValue(impurityTotal / netWeightTmp);
-        cell.setCellStyle(contextstyle1);
+        cell.setCellValue(Double.parseDouble(df.format(mildewGrainTotal / netWeightTmp)));
+        cell.setCellStyle(contextstyle2);
         cell = rowp.createCell(17);
-        cell.setCellValue(jiaorenliTotal / netWeightTmp);
-        cell.setCellStyle(contextstyle1);
+        cell.setCellValue(Double.parseDouble(df.format(impurityTotal / netWeightTmp)));
+        cell.setCellStyle(contextstyle2);
         cell = rowp.createCell(18);
-        cell.setCellValue(imperfectGrainTotal / netWeightTmp);
-        cell.setCellStyle(contextstyle1);
+        cell.setCellValue(Double.parseDouble(df.format(jiaorenliTotal / netWeightTmp)));
+        cell.setCellStyle(contextstyle2);
         cell = rowp.createCell(19);
-        cell.setCellStyle(styleDetail);
+        cell.setCellValue(Double.parseDouble(df.format(imperfectGrainTotal / netWeightTmp)));
+        cell.setCellStyle(contextstyle2);
         cell = rowp.createCell(20);
         cell.setCellStyle(styleDetail);
         cell = rowp.createCell(21);
@@ -2478,8 +2482,8 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         cell = rowp.createCell(25);
         cell.setCellStyle(styleDetail);
         cell = rowp.createCell(26);
-        cell.setCellValue(amountIngPayableTotal / netWeightTotal);
-        cell.setCellStyle(contextstyle1);
+        cell.setCellValue(Double.parseDouble(df.format(amountIngPayableTotal / netWeightTotal)));
+        cell.setCellStyle(contextstyle2);
         cell = rowp.createCell(27);
         cell.setCellStyle(styleDetail);
         cell = rowp.createCell(28);
@@ -2508,7 +2512,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         cell.setCellStyle(styleDetail);
         cell = rowp.createCell(39);
         cell.setCellValue(amountIngPayableTotal);
-        cell.setCellStyle(contextstyle1);
+        cell.setCellStyle(contextstyle2);
         cell = rowp.createCell(40);
         cell.setCellStyle(styleDetail);
         cell = rowp.createCell(41);
@@ -2602,7 +2606,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         cell.setCellStyle(styleDetail);
         cell = row1.createCell(26);
         cell.setCellValue("净重单价");
-        cell.setCellStyle(contextstyle);
+        cell.setCellStyle(styleDetail);
         cell = row1.createCell(27);
         cell.setCellValue("毛重");
         cell.setCellStyle(styleDetail);
@@ -2660,18 +2664,8 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         cell = row1.createCell(45);
         cell.setCellValue("开户支行");
         cell.setCellStyle(styleDetail);
-
-
         rownum++;
-        DecimalFormat decimalFormat = new DecimalFormat(".00");
-//        Map<String, Object> pageView = new HashMap<>();
-//        //  公司ID
-//        pageView.put("compId", AuthSecurityUtils.getCurrentUserInfo().getCompId());
-//        pageView.put("startDate", warehouseBaseInfo.getStartDate());
-//        pageView.put("endDate", warehouseBaseInfo.getEndDate());
-//        pageView.put("warehouseName", warehouseBaseInfo.getWarehouseName());
-//        // 查询入库记录总数
-//        List<ExportVView> dataList = baseMapper.getListByCondition(pageView);
+
         // 详情信息
         if (!CollectionUtils.isEmpty(dataList)) {
             for (int i = 0; i < dataList.size(); i++) {
@@ -2776,10 +2770,6 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                 cell.setCellValue(Double.parseDouble(exportVView.getNetWeightPrice() != null ? exportVView.getNetWeightPrice() : "0"));
                 cell.setCellStyle(contextstyle);
                 cell = rowx.createCell(27);
-                HSSFDataFormat df = wb.createDataFormat(); // 此处设置数据格式
-                contextstyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));//保留两位小数点
-                HSSFDataFormat df3 = wb.createDataFormat(); // 此处设置数据格式
-                contextstyle2.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,#####0.00000"));//保留两位小数点
                 if (exportVView.getGrossWeight() != null) {
                     cell.setCellValue(editDouble(exportVView.getGrossWeight()));
                 }
@@ -2790,7 +2780,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                 }
                 cell.setCellStyle(contextstyle);
                 cell = rowx.createCell(29);
-                cell.setCellValue(editFloat(exportVView.getBuckleWeight()));
+                cell.setCellValue(editDouble(Double.parseDouble(df.format(exportVView.getBuckleWeight() != null ? exportVView.getBuckleWeight() : 0))));
                 cell.setCellStyle(contextstyle);
                 cell = rowx.createCell(30);
                 cell.setCellValue(Double.parseDouble(exportVView.getNetWeight()));
@@ -2811,12 +2801,13 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                 cell.setCellValue(editDouble(exportVView.getUnitDeduction()));
                 cell.setCellStyle(styleDetail);
                 cell = rowx.createCell(36);
-                if (exportVView.getPureWeightPrice() == null) {
-                    cell.setCellValue(new Formatter().format("%.3f", editDouble(exportVView.getPureWeightPrice())).toString());
-                } else {
-                    cell.setCellValue(new Formatter().format("%.3f", editDouble(exportVView.getPureWeightPrice() * 1000)).toString());
-                }
-                cell.setCellStyle(styleDetail);
+                cell.setCellValue(editDouble(Double.parseDouble(df1.format(exportVView.getPureWeightPrice() != null ? exportVView.getPureWeightPrice() * 1000 : 0))));
+//                if (exportVView.getPureWeightPrice() == null) {
+//                    cell.setCellValue(editDouble(Double.parseDouble(df1.format(exportVView.getPureWeightPrice()))));
+//                } else {
+//                    cell.setCellValue(new Formatter().format("%.3f", editDouble(exportVView.getPureWeightPrice() * 1000)).toString());
+//                }
+                cell.setCellStyle(contextstyle1);
                 cell = rowx.createCell(37);
                 if (exportVView.getPureWeight() == null) {
                     cell.setCellValue(editFloat(exportVView.getPureWeight()));
@@ -2831,9 +2822,8 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                 cell.setCellValue(editDouble(exportVView.getAmountIngPayable() != null ? exportVView.getAmountIngPayable() : 0));
                 cell.setCellStyle(contextstyle);
                 cell = rowx.createCell(40);
-                cell.setCellValue(new Formatter().format("%.2f", editDouble(exportVView.getAmountEdPayable())).toString());
-//                cell.setCellValue(editDouble(exportVView.getAmountEdPayable()));
-                cell.setCellStyle(styleDetail);
+                cell.setCellValue(editDouble(Double.parseDouble(df.format(exportVView.getAmountEdPayable()))));
+                cell.setCellStyle(contextstyle);
                 cell = rowx.createCell(41);
                 cell.setCellValue(new Formatter().format("%.2f", editDouble(exportVView.getTranPrice())).toString());
                 cell.setCellStyle(contextstyle);
@@ -3924,7 +3914,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         // 指定单元格自动换行
         contextstyle1.setWrapText(true);
         // 设置单元格字体
-        contextstyle1.setFont(fontDetail1);
+        contextstyle1.setFont(fontDetail);
         // 右边框
         contextstyle1.setBorderRight(HSSFCellStyle.BORDER_THIN);
         // 左边框
@@ -3934,6 +3924,24 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         // 下styleDetailTitle
         contextstyle1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
 
+        HSSFCellStyle contextstyle2 = wb.createCellStyle();
+        // 指定单元格居中对齐
+        contextstyle2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 指定单元格垂直居中对齐
+        contextstyle2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        contextstyle2.setWrapText(true);
+        // 设置单元格字体
+        contextstyle2.setFont(fontDetail1);
+        // 右边框
+        contextstyle2.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        // 左边框
+        contextstyle2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        // 上边框
+        contextstyle2.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        // 下styleDetailTitle
+        contextstyle2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+
         HSSFCellStyle styleDetailYellow = wb.createCellStyle();
         // 指定单元格居中对齐
         styleDetailYellow.setAlignment(HSSFCellStyle.ALIGN_CENTER);
@@ -4158,6 +4166,12 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         pageView.put("warehouseName", warehouseBaseInfo.getWarehouseName());
         // 查询服务商总数
         List<ExportVView> dataList = baseMapper.getListByConditionOut(pageView);
+
+        DecimalFormat df = new DecimalFormat("0.00");
+        DecimalFormat df1 = new DecimalFormat("0.000");
+        contextstyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));//保留两位小数点
+        contextstyle2.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));//保留两位小数点
+
         // 详情信息
         if (!CollectionUtils.isEmpty(dataList)) {
             Double waterContentTotal = 0d;//水分合计
@@ -4197,8 +4211,6 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
             }
             HSSFRow rowp = sheet.createRow((int) (rownum));
             rowp.setHeightInPoints(20);
-            HSSFDataFormat df1 = wb.createDataFormat(); // 此处设置数据格式
-            contextstyle1.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));//保留两位小数点
             cell = rowp.createCell(1);
             cell.setCellValue("平均值/合计");
             cell.setCellStyle(styleDetail);
@@ -4221,8 +4233,8 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
             cell = rowp.createCell(10);
             cell.setCellStyle(styleDetail);
             cell = rowp.createCell(11);
-            cell.setCellValue(netWeightPriceTotal / dataList.size());
-            cell.setCellStyle(contextstyle1);
+            cell.setCellValue(Double.parseDouble(df.format(netWeightPriceTotal / dataList.size())));
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(12);
             cell.setCellStyle(styleDetail);
             cell = rowp.createCell(13);
@@ -4235,26 +4247,26 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
             cell.setCellStyle(styleDetail);
             //水分平均值
             cell = rowp.createCell(17);
-            cell.setCellStyle(contextstyle1);
-            cell.setCellValue(waterContentTotal / netWeightTmp);
+            cell.setCellStyle(contextstyle2);
+            cell.setCellValue(Double.parseDouble(df.format(waterContentTotal / netWeightTmp)));
             cell = rowp.createCell(18);
-            cell.setCellValue(impurityTotal / netWeightTmp);
-            cell.setCellStyle(contextstyle1);
+            cell.setCellValue(Double.parseDouble(df.format(impurityTotal / netWeightTmp)));
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(19);
-            cell.setCellValue(mildewGrainTotal / netWeightTmp);
-            cell.setCellStyle(contextstyle1);
+            cell.setCellValue(Double.parseDouble(df.format(mildewGrainTotal / netWeightTmp)));
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(20);
-            cell.setCellValue(imperfectGrainTotal / netWeightTmp);
-            cell.setCellStyle(contextstyle1);
+            cell.setCellValue(Double.parseDouble(df.format(imperfectGrainTotal / netWeightTmp)));
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(21);
-            cell.setCellValue(bulkDensityTotal / netWeightTmp);
-            cell.setCellStyle(contextstyle1);
+            cell.setCellValue(Double.parseDouble(df.format(bulkDensityTotal / netWeightTmp)));
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(22);
-            cell.setCellValue(jiaorenliTotal / netWeightTmp);
-            cell.setCellStyle(contextstyle1);
+            cell.setCellValue(Double.parseDouble(df.format(jiaorenliTotal / netWeightTmp)));
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(23);
-            cell.setCellValue(protrinTotal / netWeightTmp);
-            cell.setCellStyle(contextstyle1);
+            cell.setCellValue(Double.parseDouble(df.format(protrinTotal / netWeightTmp)));
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(24);
             cell.setCellStyle(styleDetail);
             cell = rowp.createCell(25);
@@ -4281,7 +4293,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
             //纯重合计
             cell = rowp.createCell(35);
             cell.setCellValue(netWeightTotal);
-            cell.setCellStyle(contextstyle1);
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(36);
             cell.setCellStyle(styleDetail);
             cell = rowp.createCell(37);
@@ -4302,7 +4314,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
             cell.setCellStyle(styleDetail);
             cell = rowp.createCell(45);
             cell.setCellValue(amountIngPayableTotal);
-            cell.setCellStyle(contextstyle1);
+            cell.setCellStyle(contextstyle2);
             cell = rowp.createCell(46);
             cell.setCellStyle(styleDetail);
             cell = rowp.createCell(47);
@@ -4592,10 +4604,6 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                 cell = rowx.createCell(32);
                 cell.setCellValue("1");
                 cell.setCellStyle(styleDetail);
-                HSSFDataFormat df = wb.createDataFormat(); // 此处设置数据格式
-                contextstyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));//保留两位小数点
-                HSSFDataFormat df1 = wb.createDataFormat(); // 此处设置数据格式
-                contextstyle1.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));//保留两位小数点
                 cell = rowx.createCell(33);
                 cell.setCellValue(editDouble(exportVView.getGrossWeight()));
                 cell.setCellStyle(contextstyle);
@@ -4606,18 +4614,19 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                 cell.setCellValue(Double.parseDouble(exportVView.getNetWeight()));
                 cell.setCellStyle(contextstyle);
                 cell = rowx.createCell(36);
-                cell.setCellValue(editFloat(exportVView.getFeedbackWeight()));
+                cell.setCellValue(editDouble(Double.parseDouble(df.format(exportVView.getFeedbackWeight() != null ? exportVView.getFeedbackWeight() : 0))));
                 cell.setCellStyle(contextstyle);
+                contextstyle1.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.000"));//保留3位小数点
                 cell = rowx.createCell(37);
-                cell.setCellValue(editFloat(exportVView.getBuckleWeight()));
-                cell.setCellStyle(contextstyle);
+                cell.setCellValue(df1.format(exportVView.getBuckleWeight() != null ? exportVView.getBuckleWeight() : 0));
+                cell.setCellStyle(contextstyle1);
                 cell = rowx.createCell(38);
                 String date1 = addDateOneDay(exportVView.getFeedbackDate() != null ? exportVView.getFeedbackDate() : new Date());
                 cell.setCellValue(date1);
                 cell.setCellStyle(styleDetail);
                 cell = rowx.createCell(39);
-                cell.setCellValue(editFloat(exportVView.getSettlementWeight()));
-                cell.setCellStyle(contextstyle);
+                cell.setCellValue(df1.format(exportVView.getSettlementWeight() != null ? exportVView.getSettlementWeight() : 0));
+                cell.setCellStyle(contextstyle1);
                 cell = rowx.createCell(40);
                 cell.setCellValue(editFloat(exportVView.getSettlementPrice()));
                 cell.setCellStyle(contextstyle);