zhuang 8 月之前
父節點
當前提交
3e74c2fa59

+ 56 - 18
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxProjectManageServiceImpl.java

@@ -116,10 +116,10 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
     };
     //整改快照颜色
     private static final Color[] RECTIFY_SNAP_COLORS = {
-            Color.fromArgb(43, 133, 239),
-            Color.fromArgb(255, 217, 255),
-            Color.fromArgb(204, 255, 204),
-            Color.fromArgb(51, 102, 255)
+            Color.fromArgb(165, 184, 225),
+            Color.fromArgb(154, 200, 124),
+            Color.fromArgb(21, 164, 63),
+            Color.fromArgb(251, 0, 6)
     };
     /**
      * 生成汇总文件
@@ -2401,6 +2401,13 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         WorksheetCollection worksheets = workbook.getWorksheets();
         Worksheet worksheet = worksheets.get(0);
         Cells cells = worksheet.getCells();
+        Style commonStyle = workbook.createStyle();
+        commonStyle.setHorizontalAlignment(TextAlignmentType.CENTER);
+        commonStyle.setVerticalAlignment(TextAlignmentType.CENTER);
+        commonStyle.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, Color.getBlack());
+        commonStyle.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.getBlack());
+        commonStyle.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.getBlack());
+        commonStyle.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.getBlack());
         if (data != null) {
             if (!excelUtils.GetLicense()) {
                 throw new CustomException("导出错误,请联系系统管理员");
@@ -2413,14 +2420,6 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
                 String machineNo = row.getMachineNo();
                 List<RectifySnapVo> snapList = row.getSnapList();
                 cells.get(startRow1, startCol1).putValue(projectCode + "-" + machineNo + " " + projectName + "整改计划");
-                // 设置公共样式
-//                Style commonStyle = workbook.createStyle();
-//                commonStyle.setHorizontalAlignment(TextAlignmentType.CENTER);
-//                commonStyle.setVerticalAlignment(TextAlignmentType.CENTER);
-//                commonStyle.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, Color.getBlack());
-//                commonStyle.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.getBlack());
-//                commonStyle.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.getBlack());
-//                commonStyle.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.getBlack());
 
                 cells.merge(startRow1 + 1, 0, 2, 1);
                 cells.get(startRow1 + 1, 0).putValue("施工部门");
@@ -2433,31 +2432,69 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
                     cells.get(startRow1 +2, colIndex + 1).putValue("当日完成数");
                     colIndex += 2;
                 }
+                for(int i = 1 ; i< 3 ; i++){
+                    for (int j = 0; j < colIndex; j++) {
+                        Style cellStyle1 = cells.get(startRow1+i, j).getStyle();
+                        cellStyle1.copy(commonStyle);
+                        cellStyle1.setForegroundColor(RECTIFY_SNAP_COLORS[0]);
+                        cellStyle1.setPattern(BackgroundType.SOLID);
+                        cells.get(startRow1+i, j).setStyle(cellStyle1);
+                    }
+                }
                 cells.merge(startRow1 , 0, 1, dateList.size() * 2 + 1);
-                Style cellStyle = cells.get(startRow1, 0).getStyle();
+                for (int col = 0; col <= dateList.size() * 2; col++) {
+                    Cell cell = cells.get(startRow1, col);
+                    cell.setStyle(commonStyle);
+                }
+                Style cellStyle = cells.get(startRow1, startCol1).getStyle();
+                cellStyle.copy(commonStyle);
                 cellStyle.getFont().setBold(true);
                 cellStyle.getFont().setSize(20);
-                cells.get(0, 0).setStyle(cellStyle);
+                cells.get(startRow1, startCol1).setStyle(cellStyle);
                 int rowIndex = startRow1 + 3;
 
                 for (RectifySnapVo snapData : snapList) {
                     List<ZhcxProjectRectifySnapVo> data1 = snapData.getData();
                     //填充固定列头数据
                     //fillFrozenData(cells, rowIndex, row,noList);
+                    Style cellStyle2 = cells.get(rowIndex, 0).getStyle();
+                    cellStyle2.copy(commonStyle);
+                    cellStyle2.setPattern(BackgroundType.SOLID);
                     cells.get(rowIndex, 0).putValue(snapData.getFirstdeptname());
+                    if("inside".equals(snapData.getIfoutsidebase())){
+                        cellStyle2.setForegroundColor(RECTIFY_SNAP_COLORS[1]);
+                    }else if("outside".equals(snapData.getIfoutsidebase())){
+                        cellStyle2.setForegroundColor(RECTIFY_SNAP_COLORS[2]);
+                    }else{
+                        cellStyle2.setForegroundColor(RECTIFY_SNAP_COLORS[3]);
+                    }
+                    cells.get(rowIndex, 0).setStyle(cellStyle2);
                     colIndex = 1;
                     for (int i = 0; i < data1.size(); i++) {
+                        cellStyle2 = cells.get(rowIndex, colIndex).getStyle();
+                        cellStyle2.copy(commonStyle);
+                        cellStyle2.setPattern(BackgroundType.SOLID);
                         if (!snapData.getFirstdeptname().equals("待确认")) {
                             cells.get(rowIndex, colIndex).putValue(data1.get(i).getUnFinishNum());
                             cells.get(rowIndex, colIndex + 1).putValue(data1.get(i).getNowFinishNum());
+                            cells.get(rowIndex, colIndex + 1).setStyle(commonStyle);
+                            cellStyle2.setForegroundColor(RECTIFY_SNAP_COLORS[0]);
+                            if(StringUtils.isBlank(snapData.getIfoutsidebase())){
+                                cellStyle2.setForegroundColor(RECTIFY_SNAP_COLORS[3]);
+                                cells.get(rowIndex, colIndex + 1).setStyle(cellStyle2);
+                            }
+                            cells.get(rowIndex, colIndex).setStyle(cellStyle2);
                         }else{
+                            cellStyle2.setForegroundColor(RECTIFY_SNAP_COLORS[3]);
                             cells.merge(rowIndex, colIndex, 1, 2);
                             cells.get(rowIndex, colIndex).putValue(data1.get(i).getTbcnum());
+                            for (int y = colIndex; y < colIndex + 2; y++) {
+                                Cell cell = cells.get(rowIndex, y);
+                                cell.setStyle(cellStyle2);
+                            }
                         }
-//                        Style cellStyle2 = cells.get(rowIndex, colIndex).getStyle();
-//                        cellStyle2.setForegroundColor(RECTIFY_SNAP_COLORS[0]);
-//                        cellStyle2.setPattern(BackgroundType.SOLID);
-//                        cells.get(rowIndex, colIndex).setStyle(cellStyle2);
+
+
                         colIndex += 2;
                     }
 
@@ -2471,6 +2508,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
             response.addHeader("Cache-Control", "no-cache");
             response.setContentType("application/octet-stream;charset=ISO8859-1");
             response.setHeader("Content-Disposition", "attachment;filename=整改清单.xlsx");
+            worksheet.autoFitColumns();
             workbook.save(response.getOutputStream(), SaveFormat.XLSX);
             workbook.dispose();
         } catch (Exception e) {