|
@@ -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;
|
|
|
+ }
|
|
|
}
|