Browse Source

点开重新刷新下拉选

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

+ 24 - 3
business-common/src/main/java/com/rongwei/bscommon/sys/feign/LuckySheetService.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.feign;
 
 import com.alibaba.fastjson.JSONObject;
 import com.rongwei.bscommon.sys.config.api.ResponseVO;
+import com.rongwei.bsentity.dto.luckysheet.CoverageUpdateJsonDataRequest;
 import com.rongwei.bsentity.dto.project.ProjectSummaryParamExcelDto;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -9,7 +10,9 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
-@FeignClient(name = "luckySheetService", url = "${luckysheet-provider.url}")
+import java.util.List;
+
+@FeignClient(name = "luckySheetService", url = "${luckysheet-provider.url}/luckysheet")
 public interface LuckySheetService {
 
     /**
@@ -18,10 +21,28 @@ public interface LuckySheetService {
      * @param excelDto
      * @return
      */
-    @PostMapping("luckysheet/api/genLuckysheetExcel")
+    @PostMapping("api/genLuckysheetExcel")
     JSONObject genLuckysheetExcel(@RequestBody ProjectSummaryParamExcelDto excelDto);
 
-    @GetMapping("luckysheet/test/get/LuckySheetJson")
+    @GetMapping("test/get/LuckySheetJson")
     ResponseVO getLuckySheetJson(@RequestParam("listId") String listId);
 
+    /**
+     * 获取整个excel json
+     *
+     * @param listId
+     * @return
+     */
+    @GetMapping("api/get/excelJson")
+    List<JSONObject> getExcelJson(@RequestParam("listId") String listId);
+
+    /**
+     * 覆盖更新jsondata
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("api/updateCoverageJsonData")
+    ResponseVO updateJsonData(@RequestBody CoverageUpdateJsonDataRequest req);
+
 }

+ 8 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/LuckysheetService.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.service;
 
 import com.rongwei.bsentity.domain.LuckysheetDo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.dto.project.UpdateDataVerificationRequest;
 
 /**
  * <p>
@@ -21,4 +22,11 @@ public interface LuckysheetService extends IService<LuckysheetDo> {
      */
     String genProjectSummaryFiles(String projectId);
 
+    /**
+     * 更新项目数据校验
+     *
+     * @param req
+     */
+    void updateDataVerification(UpdateDataVerificationRequest req);
+
 }

+ 8 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxProjectManageService.java

@@ -28,6 +28,14 @@ public interface ZhcxProjectManageService extends IService<ZhcxProjectManageDo>
      */
     SysFileItemDo genSummaryFiles(String projectId);
 
+    /**
+     * 组装汇总文件参数
+     *
+     * @param projectId
+     * @return
+     */
+    ProjectSummaryParamExcelDto assembleProjectSummaryParam(String projectId);
+
     /**
      * 组装汇总文件参数
      *

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

@@ -1,17 +1,28 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.rongwei.bscommon.sys.feign.LuckySheetService;
 import com.rongwei.bscommon.sys.service.ZhcxProjectManageService;
+import com.rongwei.bscommon.sys.utils.LuckySheet4SummaryHelp;
 import com.rongwei.bsentity.domain.LuckysheetDo;
 import com.rongwei.bscommon.sys.dao.LuckysheetDao;
 import com.rongwei.bscommon.sys.service.LuckysheetService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.domain.ZhcxProjectManageDo;
+import com.rongwei.bsentity.dto.luckysheet.CoverageUpdateJsonDataRequest;
 import com.rongwei.bsentity.dto.project.ProjectSummaryParamExcelDto;
+import com.rongwei.bsentity.dto.project.UpdateDataVerificationRequest;
+import com.rongwei.rwcommon.base.exception.CustomException;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * <p>
  *  服务实现类
@@ -37,15 +48,8 @@ public class LuckysheetServiceImpl extends ServiceImpl<LuckysheetDao, Luckysheet
      */
     @Override
     public String genProjectSummaryFiles(String projectId) {
-
-        //项目信息
-        ZhcxProjectManageDo project = projectManageService.getById(projectId);
-
         //组装汇总文件参数
-        ProjectSummaryParamExcelDto paramExcelDto = projectManageService.assembleProjectSummaryParam(project);
-
-        //生成excel
-//        String listId = genLuckysheetObj(paramExcelDto);
+        ProjectSummaryParamExcelDto paramExcelDto = projectManageService.assembleProjectSummaryParam(projectId);
 
         JSONObject lssResult = luckySheetService.genLuckysheetExcel(paramExcelDto);
         String listId = lssResult.getString("data");
@@ -56,4 +60,129 @@ public class LuckysheetServiceImpl extends ServiceImpl<LuckysheetDao, Luckysheet
         projectManageService.updateById(projectEntity);
         return listId;
     }
+
+    /**
+     * 更新项目数据校验
+     *
+     * @param req
+     */
+    @Override
+    public void updateDataVerification(UpdateDataVerificationRequest req) {
+
+        //项目相关信息
+        ZhcxProjectManageDo project = projectManageService.getById(req.getProjectId()); //项目信息
+
+        //下拉json
+        JSONObject dropdownJson = assembleDataVerification(project);
+
+        //更新excel中json
+        JSONObject whereObj = new JSONObject();
+        whereObj.put("list_id", project.getSummaryfiles());
+        whereObj.put("block_id", "fblock");
+        whereObj.put("index", 1);
+
+        CoverageUpdateJsonDataRequest updateReq = CoverageUpdateJsonDataRequest.builder()
+                .key("dataVerification")
+                .value(dropdownJson)
+                .andWhereObj(whereObj)
+                .build();
+        luckySheetService.updateJsonData(updateReq);
+    }
+
+    /**
+     * 组装
+     *
+     * @param project
+     * @return
+     */
+    private JSONObject assembleDataVerification(ZhcxProjectManageDo project) {
+        ProjectSummaryParamExcelDto paramExcelDto = projectManageService.assembleProjectSummaryParam(project);
+
+        //获取第一页数据最大行数
+        List<JSONObject> sheetList = luckySheetService.getExcelJson(project.getSummaryfiles());
+        if(ObjectUtil.isEmpty(sheetList)) {
+            throw new CustomException("整改数据不存在");
+        }
+        JSONArray celldatas = sheetList.get(0).getJSONArray("celldata");
+        int maxRowIdx = 3;
+        for(int m = 0,  n = celldatas.size(); m < n; m++) {
+            JSONObject cellData = celldatas.getJSONObject(m);
+
+            if(cellData.getIntValue("r") > maxRowIdx) {
+                maxRowIdx = cellData.getIntValue("r");
+            }
+        }
+
+        return getDataVerification(paramExcelDto, maxRowIdx);
+    }
+
+    /**
+     * 数据校验
+     *
+     * @param paramExcelDto
+     * @param maxRowIdx
+     * @return
+     */
+    private JSONObject getDataVerification(ProjectSummaryParamExcelDto paramExcelDto, int maxRowIdx) {
+        JSONObject result = new JSONObject();
+
+        //部门
+        List<String> departList = paramExcelDto.getWorkshopList().stream()
+                .map(item -> item.getString("SHORTNAME"))
+                .collect(Collectors.toList());
+        String departChose = StringUtils.join(departList, ",");
+
+        for(int m = 0,  n = paramExcelDto.getDeviceNumberList().size() - 1; m <= n; m++) {
+            int colPos = LuckySheet4SummaryHelp.MAIN_TITLE_FIRST.length + m * LuckySheet4SummaryHelp.MACHINE_TITLE_COLS.length;
+//            int departColPos = 4 + 4 * m;
+            for(int startRows = 3; startRows < maxRowIdx; startRows++) {
+
+                //状态
+                /**
+                 * "3_4": {
+                 * 			"type": "dropdown",
+                 * 			"remote": false,
+                 * 			"value1": "OK,X,√",
+                 * 			"value2": "",
+                 * 			"checked": false,
+                 * 			"hintShow": false,
+                 * 			"hintText": "",
+                 * 			"prohibitInput": false
+                 * }
+                 */
+                JSONObject statusObj = LuckySheet4SummaryHelp.getNewDataVerification("OK,X,√");
+                result.put(String.valueOf(startRows).concat("_").concat(String.valueOf(colPos)), statusObj);
+
+                //部门
+                /**
+                 * "3_4": {
+                 * 			"type": "dropdown",
+                 * 			"remote": false,
+                 * 			"value1": "OK,X,√",
+                 * 			"value2": "",
+                 * 			"checked": false,
+                 * 			"hintShow": false,
+                 * 			"hintText": "",
+                 * 			"prohibitInput": false
+                 * }
+                 */
+                //施工部门
+                JSONObject departObj = LuckySheet4SummaryHelp.getNewDataVerification(departChose);
+                result.put(String.valueOf(startRows).concat("_").concat(String.valueOf(colPos + 1)), departObj);
+
+                //责任部门
+                JSONObject depart2Obj = LuckySheet4SummaryHelp.getNewDataVerification(departChose);
+                result.put(String.valueOf(startRows).concat("_").concat(String.valueOf(colPos + 3)), depart2Obj);
+            }
+        }
+
+        //总状态
+        int statusColIndex = LuckySheet4SummaryHelp.MAIN_TITLE_FIRST.length + paramExcelDto.getDeviceNumberList().size() * LuckySheet4SummaryHelp.MACHINE_TITLE_COLS.length;
+        for(int startRows = 3; startRows < maxRowIdx; startRows++) {
+            JSONObject statusObj = LuckySheet4SummaryHelp.getNewDataVerification("OK,X,√");
+            result.put(String.valueOf(startRows).concat("_").concat(String.valueOf(statusColIndex)), statusObj);
+        }
+
+        return result;
+    }
 }

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

@@ -113,6 +113,17 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         return fileItemDo;
     }
 
+    /**
+     * 组装汇总文件参数
+     *
+     * @param projectId
+     * @return
+     */
+    @Override
+    public ProjectSummaryParamExcelDto assembleProjectSummaryParam(String projectId) {
+        return assembleProjectSummaryParam(getById(projectId));
+    }
+
     /**
      * 组装整改汇总文件参数
      *

+ 19 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/utils/LuckySheet4SummaryHelp.java

@@ -101,4 +101,23 @@ public class LuckySheet4SummaryHelp {
 
         return ymdSb.toString();
     }
+
+    /**
+     * 数组验证 下拉框
+     *
+     * @param options
+     * @return
+     */
+    public static JSONObject getNewDataVerification(String options) {
+        JSONObject departObj = new JSONObject();
+        departObj.put("type", "dropdown");
+        departObj.put("remote", false);
+        departObj.put("value1", options);
+        departObj.put("value2", "");
+        departObj.put("checked", false);
+        departObj.put("hintShow", false);
+        departObj.put("hintText", "");
+        departObj.put("prohibitInput", false);
+        return departObj;
+    }
 }

+ 38 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/luckysheet/CoverageUpdateJsonDataRequest.java

@@ -0,0 +1,38 @@
+package com.rongwei.bsentity.dto.luckysheet;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.*;
+
+/**
+ * 覆盖更新参数
+ */
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class CoverageUpdateJsonDataRequest {
+
+    /**
+     * where条件,and连接
+     *
+     */
+    private JSONObject andWhereObj;
+
+    /**
+     * 路径
+     */
+    private String key;
+
+    /**
+     * 更新数组时使用
+     */
+    private String position;
+
+    /**
+     * 需要修改的值
+     *
+     */
+    private JSONObject value;
+
+}

+ 13 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/project/UpdateDataVerificationRequest.java

@@ -0,0 +1,13 @@
+package com.rongwei.bsentity.dto.project;
+
+import lombok.*;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class UpdateDataVerificationRequest {
+
+    private String projectId;
+}

+ 14 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxProjectManageController.java

@@ -9,6 +9,7 @@ import com.rongwei.bscommon.sys.service.ZhcxProjectManageService;
 import com.rongwei.bsentity.domain.ZhcxProjectManageDo;
 import com.rongwei.bsentity.dto.project.ExportProjectSummaryDto;
 import com.rongwei.bsentity.dto.project.SavePorjectSummaryDto;
+import com.rongwei.bsentity.dto.project.UpdateDataVerificationRequest;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import io.swagger.annotations.Api;
@@ -80,6 +81,19 @@ public class ZhcxProjectManageController {
         return R.ok();
     }
 
+    /**
+     * 更新excel下拉框
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/updateDataVerification")
+    @ApiOperation("保存汇总文件数据")
+    public R updateDataVerification(@RequestBody UpdateDataVerificationRequest req) {
+        luckysheetService.updateDataVerification(req);
+        return R.ok();
+    }
+
     @PostMapping("/getRectifyReportData")
     @ApiOperation("获取整改报表数据")
     public R getRectifyReportData(@RequestBody Map<String,Object> map) {

+ 2 - 2
business-server/src/main/resources/bootstrap.yml

@@ -116,7 +116,7 @@ sso:
 #redis通道名称
 redis.channel: luckysheet.channel
 #表格中块的大小,新增加时写入每一个sheet的第一个模块中
-row_size: 1500
-col_size: 1500
+row_size: 100
+col_size: 100
 #使用服务器类型
 servertype: tomcat