|
@@ -16,11 +16,13 @@ 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 com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -96,93 +98,78 @@ public class LuckysheetServiceImpl extends ServiceImpl<LuckysheetDao, Luckysheet
|
|
|
* @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;
|
|
|
+ Map<Integer, Integer> dataVerifyMap = new HashMap<>();
|
|
|
for(int m = 0, n = celldatas.size(); m < n; m++) {
|
|
|
JSONObject cellData = celldatas.getJSONObject(m);
|
|
|
|
|
|
if(cellData.getIntValue("r") > maxRowIdx) {
|
|
|
maxRowIdx = cellData.getIntValue("r");
|
|
|
}
|
|
|
+
|
|
|
+ //找出所有第三行中标题所在列下标
|
|
|
+ //状态、施工部门、责任部门、总状态
|
|
|
+ if(cellData.getIntValue("r") != 2) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String v = LuckySheet4SummaryHelp.getCellValue4V(cellData.getJSONObject("v"), String.class);
|
|
|
+ if("状态".equals(v) || "总状态".equals(v)) {
|
|
|
+ dataVerifyMap.put(cellData.getInteger("c"), 1);
|
|
|
+ } else if("施工部门".equals(v) || "责任部门".equals(v)) {
|
|
|
+ dataVerifyMap.put(cellData.getInteger("c"), 0);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return getDataVerification(paramExcelDto, maxRowIdx);
|
|
|
+ return getDataVerification(dataVerifyMap, maxRowIdx);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 数据校验
|
|
|
*
|
|
|
- * @param paramExcelDto
|
|
|
+ * @param dataVerifyMap
|
|
|
* @param maxRowIdx
|
|
|
* @return
|
|
|
*/
|
|
|
- private JSONObject getDataVerification(ProjectSummaryParamExcelDto paramExcelDto, int maxRowIdx) {
|
|
|
+ private JSONObject getDataVerification(Map<Integer, Integer> dataVerifyMap, int maxRowIdx) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
+ //数据校验值
|
|
|
//部门
|
|
|
- List<String> departList = paramExcelDto.getWorkshopList().stream()
|
|
|
+ List<JSONObject> workshopList = projectManageService.getWorkshop();
|
|
|
+ List<String> departList = workshopList.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);
|
|
|
+ //状态
|
|
|
+ List<String> verifyStatus = LuckySheet4SummaryHelp.DATA_VERIFY_STATUS;
|
|
|
+ String[] vals = new String[] {StringUtils.join(departList, ","), StringUtils.join(verifyStatus, ",")};
|
|
|
+
|
|
|
+ /* 给每行指定列加上数据校验
|
|
|
+ * "3_4": {
|
|
|
+ * "type": "dropdown",
|
|
|
+ * "remote": false,
|
|
|
+ * "value1": "OK,X,√",
|
|
|
+ * "value2": "",
|
|
|
+ * "checked": false,
|
|
|
+ * "hintShow": false,
|
|
|
+ * "hintText": "",
|
|
|
+ * "prohibitInput": false
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ //行
|
|
|
+ for(int startRows = 3; startRows <= maxRowIdx; startRows++) {
|
|
|
+ for(Integer colIdx : dataVerifyMap.keySet()) {
|
|
|
+ JSONObject statusObj = LuckySheet4SummaryHelp.getNewDataVerification(vals[dataVerifyMap.get(colIdx)]);
|
|
|
+ result.put(String.valueOf(startRows).concat("_").concat(String.valueOf(colIdx)), statusObj);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //总状态
|
|
|
- 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;
|
|
|
}
|
|
|
}
|