Browse Source

模板调整

wangming 1 năm trước cách đây
mục cha
commit
07332263d2

+ 28 - 29
luckysheet/src/main/java/com/xc/luckysheet/db/server/JfGridUpdateService.java

@@ -102,7 +102,7 @@ public class JfGridUpdateService {
     public String genLuckysheetExcel(ProjectSummaryParamExcelDto paramExcelDto) {
         SheetInfoParam sheet1 = SheetInfoParam.builder()
                 .index("1")
-                .sheetName("Sheet1")
+                .sheetName("整改清单")
                 .order(0)
                 .rowSize(rowSize)
                 .build();
@@ -116,9 +116,11 @@ public class JfGridUpdateService {
         config.put("rowlen", configResultDto.getRowlenConfig());
         config.put("columnlen", configResultDto.getColumnlenConfig());
         config.put("borderInfo", configResultDto.getBorderInfoConfig());
-
         sheet.getJSONObject("dataVerification").putAll(configResultDto.getDataVerification());
 
+        //其他默认配置
+        setDefaultSheetOther(sheet);
+
         String listId = String.valueOf(new Date().getTime()).concat("#").concat(String.valueOf(snowFlake.nextId().longValue()));
 
         //保存结构
@@ -148,6 +150,24 @@ public class JfGridUpdateService {
         return listId;
     }
 
+    /**
+     * 设置其他默认配置
+     *
+     * @param sheet
+     */
+    private void setDefaultSheetOther(JSONObject sheet) {
+
+        //冻结列 3行3列
+        JSONObject frozen = new JSONObject();
+        frozen.put("type", "rangeBoth");
+        JSONObject fronzeRange = new JSONObject();
+        fronzeRange.put("row_focus", 2);
+        fronzeRange.put("column_focus", 2);
+        frozen.put("range", fronzeRange);
+        sheet.put("frozen", frozen);
+
+    }
+
     /**
      * 执行更新操作,集合拆分
      *
@@ -205,7 +225,7 @@ public class JfGridUpdateService {
         columnLen.put("2", 130); //部门
         columnLen.put("3", 300); //内容
         //数据
-        JSONArray cellData = getCellData(paramExcelDto, columnLen);
+        JSONArray cellData = getCellData(paramExcelDto);
         //行高
         JSONObject rowLenObj = new JSONObject();
         rowLenObj.put("0", 24);
@@ -224,10 +244,9 @@ public class JfGridUpdateService {
      * 获取数据
      *
      * @param paramExcelDto
-     * @param columnLen
      * @return
      */
-    private JSONArray getCellData(ProjectSummaryParamExcelDto paramExcelDto, JSONObject columnLen) {
+    private JSONArray getCellData(ProjectSummaryParamExcelDto paramExcelDto) {
 
         String[] titleFirst = LuckySheet4SummaryHelp.MAIN_TITLE_FIRST;
         String[] titleSecond = LuckySheet4SummaryHelp.MAIN_TITLE_SECOND;
@@ -242,7 +261,7 @@ public class JfGridUpdateService {
         JSONArray celldata2 = new JSONArray();
         celldata2.addAll(LuckySheet4SummaryHelp.assembleCommonRow2Col1());
 
-        String[] colors = {"#ffd9ff", "#ffffcc"};
+        String[] colors = LuckySheet4SummaryHelp.MACHINE_COL_BGS;
 
         //遍历机号
         for(int m = 0, n = paramExcelDto.getDeviceNumberList().size(); m < n; m++) {
@@ -261,29 +280,9 @@ public class JfGridUpdateService {
         celldata.addAll(celldata1);
         celldata.addAll(celldata2);
 
-        //自动换行
-        for(int m = 3, n = rowSize; m < n; m++) {
-            //部位
-            JSONObject positionCell = new JSONObject();
-            positionCell.put("r", m);
-            positionCell.put("c", 2);
-
-            JSONObject positionCellV = new JSONObject();
-            positionCellV.put("tb", 2);
-            positionCell.put("v", positionCellV);
-            celldata.add(positionCell);
-
-            //内容
-            JSONObject contentCell = new JSONObject();
-            contentCell.put("r", m);
-            contentCell.put("c", 3);
-
-            JSONObject contentCellV = new JSONObject();
-            contentCellV.put("tb", 2); //自动换行
-            contentCell.put("v", contentCellV);
-            celldata.add(contentCell);
-
-        }
+        //其他初始化行
+        JSONArray cellData4Row3ToMore = LuckySheet4SummaryHelp.getCellData4Row3ToMore(3, rowSize, paramExcelDto);
+        celldata.addAll(cellData4Row3ToMore);
 
         return celldata;
     }

+ 98 - 2
luckysheet/src/main/java/com/xc/luckysheet/utils/LuckySheet4SummaryHelp.java

@@ -25,6 +25,16 @@ public class LuckySheet4SummaryHelp {
      */
     public static final String[] MAIN_TITLE_SECOND = {"总状态","提出日期","整改期限","提出者","备注1","备注2"};
 
+    /**
+     * 列背景色
+     */
+    public static final String[] COL_BGS = {"#3366ff", "#ccffcc" };
+
+    /**
+     * 机号背景色
+     */
+    public static final String[] MACHINE_COL_BGS = {"#ffd9ff", "#ffffcc"};
+
     /**
      * {
      * 		"c": 0,
@@ -65,7 +75,7 @@ public class LuckySheet4SummaryHelp {
                 .rowSize(1)
                 .colSize(colSize)
                 .value(fileName)
-                .bg("#3366ff")
+                .bg(COL_BGS[0])
                 .build();
         return assembleMergeTitle(cellParam);
     }
@@ -112,7 +122,7 @@ public class LuckySheet4SummaryHelp {
             JSONObject remark2v = new JSONObject();
 //            remark2v.put("m", MAIN_TITLE_FIRST[m]);
 //            remark2v.put("v", MAIN_TITLE_FIRST[m]);
-            remark2v.put("bg", "#ccffcc");
+            remark2v.put("bg", COL_BGS[1]);
             remark2v.put("bl", 1);
             remark2v.put("fc", "rgb(0, 0, 0)");
             remark2v.put("ff", 5);
@@ -656,6 +666,29 @@ public class LuckySheet4SummaryHelp {
             }
         }
 
+        JSONObject content = new JSONObject();
+        content.put("rangeType", "range");
+        content.put("borderType", "border-all");
+        content.put("style", 1);
+        content.put("color", "#000");
+
+        JSONObject contentRange = new JSONObject();
+        JSONArray rowArray = new JSONArray();
+        rowArray.add(3);
+        rowArray.add(999);
+        contentRange.put("row", rowArray);
+
+        JSONArray colArray = new JSONArray();
+        colArray.add(0);
+        colArray.add(colsSize - 1);
+        contentRange.put("column", colArray);
+
+        JSONArray rangArray = new JSONArray();
+        rangArray.add(contentRange);
+        content.put("range", rangArray);
+
+        result.add(content);
+
         return result;
     }
 
@@ -728,6 +761,12 @@ public class LuckySheet4SummaryHelp {
         return result;
     }
 
+    /**
+     * 数组验证 下拉框
+     *
+     * @param options
+     * @return
+     */
     public static JSONObject getNewDataVerification(String options) {
         JSONObject departObj = new JSONObject();
         departObj.put("type", "dropdown");
@@ -740,4 +779,61 @@ public class LuckySheet4SummaryHelp {
         departObj.put("prohibitInput", false);
         return departObj;
     }
+
+    /**
+     * 初始化行数据
+     *
+     * @param rowStart
+     * @param rowSize
+     * @param paramExcelDto
+     * @return
+     */
+    public static JSONArray getCellData4Row3ToMore(int rowStart, int rowSize, ProjectSummaryParamExcelDto paramExcelDto) {
+        JSONArray celldatas = new JSONArray();
+
+        for(int m = rowStart, n = rowSize; m < n; m++) {
+
+            //自动换行
+            //部位
+            JSONObject positionCell = new JSONObject();
+            positionCell.put("r", m);
+            positionCell.put("c", 2);
+
+            JSONObject positionCellV = new JSONObject();
+            positionCellV.put("tb", 2);
+            positionCell.put("v", positionCellV);
+            celldatas.add(positionCell);
+
+            //内容
+            JSONObject contentCell = new JSONObject();
+            contentCell.put("r", m);
+            contentCell.put("c", 3);
+
+            JSONObject contentCellV = new JSONObject();
+            contentCellV.put("tb", 2); //自动换行
+            contentCell.put("v", contentCellV);
+            celldatas.add(contentCell);
+
+            String[] colors = MACHINE_COL_BGS;
+
+            //机号列颜色设置
+            for(int h = 0, k = paramExcelDto.getDeviceNumberList().size(); h < k; h++) {
+                String color = colors[h % 2];
+
+                for(int i = 0; i < MACHINE_TITLE_COLS.length; i++) {
+                    JSONObject machineContentCell = new JSONObject();
+                    machineContentCell.put("r", m);
+                    machineContentCell.put("c", MAIN_TITLE_FIRST.length + MACHINE_TITLE_COLS.length * h + i);
+
+                    JSONObject machineContentCellV = new JSONObject();
+                    machineContentCellV.put("bg", color);
+                    machineContentCell.put("v", machineContentCellV);
+                    celldatas.add(machineContentCell);
+                }
+            }
+
+        }
+
+        return celldatas;
+    }
 }