Explorar o código

整改数据保存

wangming hai 1 ano
pai
achega
2bdb6a5959

+ 19 - 12
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/LuckysheetServiceImpl.java

@@ -23,6 +23,8 @@ import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 
+import static com.rongwei.bscommon.sys.utils.LuckySheet4SummaryHelp.*;
+
 /**
  * <p>
  *  服务实现类
@@ -55,11 +57,8 @@ public class LuckysheetServiceImpl extends ServiceImpl<LuckysheetDao, Luckysheet
         //组装汇总文件参数
         ProjectSummaryParamExcelDto paramExcelDto = projectManageService.assembleProjectSummaryParam(project);
 
-        //配置信息
-        SheetConfigResultDto configResultDto = assembleProjectSummaryTitle(paramExcelDto);
-
         //生成excel
-        String listId = genLuckysheetObj(configResultDto);
+        String listId = genLuckysheetObj(paramExcelDto);
 
         ZhcxProjectManageDo projectEntity = new ZhcxProjectManageDo();
         projectEntity.setId(projectId);
@@ -71,10 +70,10 @@ public class LuckysheetServiceImpl extends ServiceImpl<LuckysheetDao, Luckysheet
     /**
      * 生成luckysheet对象
      *
-     * @param configResultDto
+     * @param paramExcelDto
      * @return
      */
-    private String genLuckysheetObj(SheetConfigResultDto configResultDto) {
+    private String genLuckysheetObj(ProjectSummaryParamExcelDto paramExcelDto) {
         SheetInfoParam sheet1 = SheetInfoParam.builder()
                 .index("1")
                 .sheetName("Sheet1")
@@ -82,6 +81,9 @@ public class LuckysheetServiceImpl extends ServiceImpl<LuckysheetDao, Luckysheet
                 .build();
         JSONObject sheet = LuckySheet4SummaryHelp.getEmptySheet(sheet1);
 
+        //配置信息
+        SheetConfigResultDto configResultDto = assembleProjectSummaryTitle(paramExcelDto);
+
         JSONObject config = sheet.getJSONObject("config");
         config.put("merge", configResultDto.getMergeConfig());
         config.put("rowlen", configResultDto.getRowlenConfig());
@@ -155,26 +157,31 @@ public class LuckysheetServiceImpl extends ServiceImpl<LuckysheetDao, Luckysheet
      */
     public JSONArray getCellData(ProjectSummaryParamExcelDto paramExcelDto) {
 
-        int colsSize = 10 + paramExcelDto.getDeviceNumberList().size() * 4;
+        String[] titleFirst = MAIN_TITLE_FIRST;
+        String[] titleSecond = MAIN_TITLE_SECOND;
+        String[] machineTitleCols = MACHINE_TITLE_COLS;
+
+        int colsSize = titleFirst.length + paramExcelDto.getDeviceNumberList().size() * machineTitleCols.length + titleSecond.length;
         //数据
         JSONArray celldata = LuckySheet4SummaryHelp.assembleFirstTitle(paramExcelDto.getFileName(), colsSize);
         //二级标题1
         JSONArray celldata1 = LuckySheet4SummaryHelp.assembleCommonCol1();
-        JSONArray celldata2 = new JSONArray();
 
+        JSONArray celldata2 = new JSONArray();
         celldata2.addAll(LuckySheet4SummaryHelp.assembleCommonRow2Col1());
+
         //遍历机号
         for(int m = 0, n = paramExcelDto.getDeviceNumberList().size(); m < n; m++) {
             //机号
-            celldata1.addAll(LuckySheet4SummaryHelp.genDeviceNumberFirstTitle(paramExcelDto.getDeviceNumberList().get(m), 4 + m * 4));
+            celldata1.addAll(LuckySheet4SummaryHelp.genDeviceNumberFirstTitle(paramExcelDto.getDeviceNumberList().get(m), titleFirst.length + m * machineTitleCols.length));
             //机号标题
-            celldata2.addAll(LuckySheet4SummaryHelp.assembleDeviceNumberSecondTitle(4 + m * 4));
+            celldata2.addAll(LuckySheet4SummaryHelp.assembleDeviceNumberSecondTitle(titleFirst.length + m * machineTitleCols.length));
         }
 
-        celldata1.addAll(LuckySheet4SummaryHelp.assembleCommonRow1Col2(4 + paramExcelDto.getDeviceNumberList().size() * 4));
+        celldata1.addAll(LuckySheet4SummaryHelp.assembleCommonRow1Col2(titleFirst.length + paramExcelDto.getDeviceNumberList().size() * machineTitleCols.length));
 
         //最后6列数据
-        celldata2.addAll(LuckySheet4SummaryHelp.assembleCommonCol2(4 + paramExcelDto.getDeviceNumberList().size() * 4));
+        celldata2.addAll(LuckySheet4SummaryHelp.assembleCommonCol2(titleFirst.length + paramExcelDto.getDeviceNumberList().size() * machineTitleCols.length));
         celldata.addAll(celldata1);
         celldata.addAll(celldata2);
 

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

@@ -22,7 +22,6 @@ import com.rongwei.bsentity.dto.RectifyDto;
 import com.rongwei.bsentity.dto.RectifyMachineDto;
 import com.rongwei.bsentity.dto.RectifyReportDto;
 import com.rongwei.bsentity.dto.project.*;
-import com.rongwei.rwadmincommon.system.domain.SysUserDo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.SecurityUtil;

+ 38 - 45
business-common/src/main/java/com/rongwei/bscommon/sys/utils/LuckySheet4SummaryHelp.java

@@ -12,6 +12,18 @@ import java.util.stream.Collectors;
 
 public class LuckySheet4SummaryHelp {
 
+    /**
+     * 机号下班组
+     */
+    public static final String[] MACHINE_TITLE_COLS = {"状态", "施工部门", "施工分包商/班组", "责任部门", "责任分包商/班组", "完成日期"};
+
+    public static final String[] MAIN_TITLE_FIRST = { "总序号","监理编号","部位","内容" };
+
+    /**
+     * 主标题下第二部门
+     */
+    public static final String[] MAIN_TITLE_SECOND = {"总状态","提出日期","整改期限","提出者","备注1","备注2"};
+
     /**
      * {
      * 		"c": 0,
@@ -90,16 +102,14 @@ public class LuckySheet4SummaryHelp {
 
         JSONArray result = new JSONArray();
 
-        String[] cols = { "总序号","监理编号","部位","内容" };
-
-        for(int m = 0, n = cols.length; m < n; m++) {
+        for(int m = 0, n = MAIN_TITLE_FIRST.length; m < n; m++) {
             //一级标题
             JSONObject remark2 = new JSONObject();
             remark2.put("c", m);
             remark2.put("r", 1);
             JSONObject remark2v = new JSONObject();
-            remark2v.put("m", cols[m]);
-            remark2v.put("v", cols[m]);
+            remark2v.put("m", MAIN_TITLE_FIRST[m]);
+            remark2v.put("v", MAIN_TITLE_FIRST[m]);
             remark2v.put("bg", "rgb(204, 255, 204)");
             remark2v.put("bl", 1);
             remark2v.put("fc", "rgb(0, 0, 0)");
@@ -137,7 +147,7 @@ public class LuckySheet4SummaryHelp {
 
         JSONArray result = new JSONArray();
 
-        for(int m = 0; m < 4; m++) {
+        for(int m = 0; m < MAIN_TITLE_FIRST.length; m++) {
             JSONObject temp = new JSONObject();
 
             JSONObject mc2 = new JSONObject();
@@ -182,8 +192,7 @@ public class LuckySheet4SummaryHelp {
      * @return
      */
     public static JSONArray assembleCommonCol2(int startColPosition) {
-        String[] cols = {"总状态","提出日期","整改期限","提出者","备注1","备注2"};
-        return assembleSingleTitle(startColPosition, 2, cols);
+        return assembleSingleTitle(startColPosition, 2, MAIN_TITLE_SECOND);
     }
 
     /**
@@ -245,7 +254,7 @@ public class LuckySheet4SummaryHelp {
                 .startRowPos(1)
                 .startColPos(startColPosition)
                 .rowSize(1)
-                .colSize(4)
+                .colSize(MACHINE_TITLE_COLS.length)
                 .value(cellName)
                 .build();
         return assembleMergeTitle(cellParam);
@@ -258,8 +267,7 @@ public class LuckySheet4SummaryHelp {
      * @return
      */
     public static JSONArray assembleDeviceNumberSecondTitle(int startColPosition) {
-        String[] cols = {"状态", "施工部门", "责任部门", "完成日期"};
-        return assembleSingleTitle(startColPosition, 2,cols);
+        return assembleSingleTitle(startColPosition, 2, MACHINE_TITLE_COLS);
     }
 
     /**
@@ -482,7 +490,9 @@ public class LuckySheet4SummaryHelp {
     public static JSONObject getMergeConfig(List<String> deviceNumberList) {
         JSONObject result = new JSONObject();
 
-        int colSize = deviceNumberList.size() * 4 + 10;
+        int colSize = deviceNumberList.size() * MACHINE_TITLE_COLS.length
+                + MAIN_TITLE_FIRST.length
+                + MAIN_TITLE_SECOND.length;
 
         //第一行 标题
         JSONObject row0Title = new JSONObject();
@@ -493,41 +503,22 @@ public class LuckySheet4SummaryHelp {
         result.put("0_0", row0Title);
 
         //第二行 前4列
-        JSONObject row1Col0Title = new JSONObject();
-        row1Col0Title.put("c", 0);
-        row1Col0Title.put("r", 1);
-        row1Col0Title.put("cs", 1);
-        row1Col0Title.put("rs", 2);
-        result.put("1_0", row1Col0Title);
-
-        JSONObject row1Col1Title = new JSONObject();
-        row1Col1Title.put("c", 1);
-        row1Col1Title.put("r", 1);
-        row1Col1Title.put("cs", 1);
-        row1Col1Title.put("rs", 2);
-        result.put("1_1", row1Col1Title);
-
-        JSONObject row1Col2Title = new JSONObject();
-        row1Col2Title.put("c", 2);
-        row1Col2Title.put("r", 1);
-        row1Col2Title.put("cs", 1);
-        row1Col2Title.put("rs", 2);
-        result.put("1_2", row1Col2Title);
-
-        JSONObject row1Col3Title = new JSONObject();
-        row1Col3Title.put("c", 3);
-        row1Col3Title.put("r", 1);
-        row1Col3Title.put("cs", 1);
-        row1Col3Title.put("rs", 2);
-        result.put("1_3", row1Col3Title);
+        for(int m = 0, n = MAIN_TITLE_FIRST.length; m < n; m++) {
+            JSONObject row1Col0Title = new JSONObject();
+            row1Col0Title.put("c", m);
+            row1Col0Title.put("r", 1);
+            row1Col0Title.put("cs", 1);
+            row1Col0Title.put("rs", 2);
+            result.put("1_".concat(String.valueOf(m)), row1Col0Title);
+        }
 
         //第二行机号
         for(int m = 0,  n = deviceNumberList.size(); m < n; m++) {
             JSONObject deviceNumObj = new JSONObject();
-            int colPos = 4 + m * 4;
+            int colPos = MAIN_TITLE_FIRST.length + m * MACHINE_TITLE_COLS.length;
             deviceNumObj.put("c", colPos);
             deviceNumObj.put("r", 1);
-            deviceNumObj.put("cs", 4);
+            deviceNumObj.put("cs", MACHINE_TITLE_COLS.length);
             deviceNumObj.put("rs", 1);
             result.put("1_".concat(String.valueOf(colPos)), deviceNumObj);
         }
@@ -563,7 +554,9 @@ public class LuckySheet4SummaryHelp {
         JSONArray result = new JSONArray();
 
         //计算列行
-        int rowsSize = 3, colsSize = 10 + deviceNumberList.size() * 4;
+        int rowsSize = 3, colsSize = deviceNumberList.size() * MACHINE_TITLE_COLS.length
+                + MAIN_TITLE_FIRST.length
+                + MAIN_TITLE_SECOND.length;;
 
         //行
         for(int m = 0; m < rowsSize; m++) {
@@ -613,7 +606,7 @@ public class LuckySheet4SummaryHelp {
         String departChose = StringUtils.join(departList, ",");
 
         for(int m = 0,  n = paramExcelDto.getDeviceNumberList().size() - 1; m <= n; m++) {
-            int colPos = 4 + m * 4;
+            int colPos = MAIN_TITLE_FIRST.length + m * MACHINE_TITLE_COLS.length;
 //            int departColPos = 4 + 4 * m;
             for(int startRows = 3, endRows = 200; startRows < endRows; startRows++) {
 
@@ -652,12 +645,12 @@ public class LuckySheet4SummaryHelp {
 
                 //责任部门
                 JSONObject depart2Obj = getNewDataVerification(departChose);
-                result.put(String.valueOf(startRows).concat("_").concat(String.valueOf(colPos + 2)), depart2Obj);
+                result.put(String.valueOf(startRows).concat("_").concat(String.valueOf(colPos + 3)), depart2Obj);
             }
         }
 
         //总状态
-        int statusColIndex = 4 + paramExcelDto.getDeviceNumberList().size() * 4;
+        int statusColIndex = MAIN_TITLE_FIRST.length + paramExcelDto.getDeviceNumberList().size() * MACHINE_TITLE_COLS.length;
         for(int startRows = 3, endRows = 200; startRows < endRows; startRows++) {
             JSONObject statusObj = getNewDataVerification("OK,X,√");
             result.put(String.valueOf(startRows).concat("_").concat(String.valueOf(statusColIndex)), statusObj);