Commit 9f697632 authored by tianyiming's avatar tianyiming

修改因一码通多线程校验code重复问题衍生出来的删除redis key不存在问题

parent c3efe130
......@@ -541,7 +541,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
it.remove();
}
// 删除检验检测机构
if (!"company".equals(e.get("level")) && e.get("companyType").toString().contains("检验检测机构")){
if (!"company".equals(e.get("level")) && e.get("companyType").toString().contains("检验检测机构")) {
it.remove();
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
......@@ -821,7 +821,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
.collect(Collectors.toList());
List<Integer> codeList = categoryOtherInfoMapper.selectExceedElevatorCodeList(start, prefix);
List<Integer> resultList = getDiffrent(allCodeList, codeList);
if(!ObjectUtils.isEmpty(resultList)){
if (!ObjectUtils.isEmpty(resultList)) {
elevatorCode.setLength(0);
elevatorCode.append(resultList.get(0));
} else {
......@@ -846,6 +846,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/**
* 获取两个List的不同元素
*
* @param list1
* @param list2
* @return
......@@ -1442,10 +1443,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override
@Transactional(rollbackFor = Exception.class)
public ResponseModel submit(Map<String, Object> map) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
StopWatch stopWatch3 = new StopWatch();
stopWatch3.start();
SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo();
LinkedHashMap useInfoFrom = (LinkedHashMap) map.get(use_info_form_id);
Calendar calendar = Calendar.getInstance();
......@@ -1456,15 +1453,35 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String record = null;
LinkedHashMap superviseMap = (LinkedHashMap) map.get("data");
String equCategory = String.valueOf(superviseMap.get("equCategory"));
String code96333 = String.valueOf(superviseMap.get("code96333"));
String useOrgCode = null;
String equCode = null;
// String alias = String.valueOf(supervisionMap.get("ALIAS"));
// if(){
//
// }
String alias = String.valueOf(supervisionMap.get("ALIAS"));
if ("null".equals(alias)) {
throw new BadRequest("该数据存在问题,请联系管理员补充数据的ALIAS字段");
}
LinkedHashMap registerForm = null;
if (EquipmentTypeEnum.GL.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(gl_register_from_id);
} else if (EquipmentTypeEnum.YL_RQ.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(ylrq_register_from_id);
} else if (EquipmentTypeEnum.DT.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(dt_register_from_id);
} else if (EquipmentTypeEnum.QZJ.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(qzjx_register_from_id);
} else if (EquipmentTypeEnum.CS.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(cc_register_from_id);
} else if (EquipmentTypeEnum.YL_SS.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(ylss_register_from_id);
} else if (EquipmentTypeEnum.YL_GD.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(ylgd_register_from_id);
} else {
registerForm = (LinkedHashMap) map.get(kysd_register_from_id);
}
useOrgCode = ObjectUtils.isEmpty(registerForm.get("USE_ORG_CODE")) ? null : String.valueOf(registerForm.get("USE_ORG_CODE"));
equCode = ObjectUtils.isEmpty(registerForm.get("EQU_CODE")) ? null : String.valueOf(registerForm.get("EQU_CODE"));
try {
String claimStatus = String.valueOf(superviseMap.get("claimStatus"));
String code96333 = String.valueOf(superviseMap.get("code96333"));
String operateType = String.valueOf(superviseMap.get("operateType"));
String isCopy = String.valueOf(useInfoFrom.get("isCopy"));
//生成码
......@@ -1482,17 +1499,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisionMap.put("CODE96333", codeMap.get("code96333"));
supervisionMap.put("SUPERVISORY_CODE", codeMap.get("superviseCode"));
map.put(supervision_form_id, supervisionMap);
stopWatch.stop();
if (log.isInfoEnabled()) {
log.info("业务存数据前耗时:{} 秒", stopWatch.getTotalTimeSeconds());
}
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
record = batchSubmitOrUpdate(map, isCopy, operateType,claimStatus);
stopWatch1.stop();
if (log.isInfoEnabled()) {
log.info("业务存数据耗时:{} 秒", stopWatch1.getTotalTimeSeconds());
}
record = batchSubmitOrUpdate(map, registerForm, alias, isCopy, operateType, claimStatus);
if (!ObjectUtils.isEmpty(record)) {
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.YSY.getCode());
} else {
......@@ -1503,23 +1510,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisionMap.put("CODE96333", "null".equals(code96333) ? null : code96333);
map.put(supervision_form_id, supervisionMap);
//根据操作状态判断是调用新增还是修改接口
record = batchSubmitOrUpdate(map, isCopy, operateType,claimStatus);
record = batchSubmitOrUpdate(map, registerForm, alias, isCopy, operateType, claimStatus);
} else {
record = batchSubmitOrUpdate(map, isCopy, operateType,claimStatus);
record = batchSubmitOrUpdate(map, registerForm, alias, isCopy, operateType, claimStatus);
}
StopWatch stopWatch4 = new StopWatch();
stopWatch4.start();
if (!ObjectUtils.isEmpty(record)) {
checkEsData(record);
}
stopWatch4.stop();
if (log.isInfoEnabled()) {
log.info("更新es耗时:{} 秒", stopWatch4.getTotalTimeSeconds());
}
stopWatch3.stop();
if (log.isInfoEnabled()) {
log.info("通用提交耗时:{} 秒", stopWatch3.getTotalTimeSeconds());
}
String finalRecord = record;
threadPool.submit(() -> {
if (log.isInfoEnabled()) {
......@@ -1546,15 +1543,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
response.setStatus(HttpStatus.BAD_REQUEST.value());
return response;
} finally {
redisUtils.del(CHECK_CODE_USE_ORG_CODE + useOrgCode);
redisUtils.del(CHECK_CODE_EQU_CODE + equCode);
redisUtils.del(CHECK_CODE_CODE96333 + supervisionMap.get("CODE96333"));
redisUtils.del(CHECK_CODE_CODE96333 + code96333);
redisUtils.del(CHECK_CODE_USE_ORG_CODE + useOrgCode);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionMap.get("SUPERVISORY_CODE")));
}
return ResponseHelper.buildResponse(record);
}
private String batchSubmitOrUpdate(Map<String, Object> map, String isCopy, String type, String claimStatus) {
private String batchSubmitOrUpdate(Map<String, Object> map, LinkedHashMap registerForm, String alias, String isCopy, String type, String claimStatus) {
Date date = new Date();
String record = null;
LinkedHashMap useInfoForm = (LinkedHashMap) map.get(use_info_form_id);
......@@ -1589,7 +1586,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
useInfo.setRecDate(date);
useInfo.setCreateDate("save".equals(type) ? new Date() : null);
useInfo.setClaimDate((EquipmentCategoryEnum.YRL.getName().equals(claimStatus) || EquipmentCategoryEnum.YJL.getName().equals(claimStatus)) ? new Date() : null);
if("save".equals(type)){
if ("save".equals(type)) {
useInfo.setDataSource(IS_COPY.equals(isCopy) ? useInfo.getSequenceNbr() : "0");
}
if (IS_COPY.equals(isCopy)) {
......@@ -1607,7 +1604,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
IdxBizJgOtherInfo idxBizJgOtherInfo = JSON.parseObject(JSON.toJSONString(supervisionForm), IdxBizJgOtherInfo.class);
if (!ObjectUtils.isEmpty(idxBizJgOtherInfo)) {
if(EquipmentCategoryEnum.DRL.getName().equals(claimStatus) && "save".equals(type)){
if (EquipmentCategoryEnum.DRL.getName().equals(claimStatus) && "save".equals(type)) {
idxBizJgOtherInfo.setClaimStatus("草稿");
}
idxBizJgOtherInfo.setRecord(record);
......@@ -1636,7 +1633,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
LinkedHashMap inspectionForm = (LinkedHashMap) map.get(inspection_form_id);
List inspectionList = (ArrayList) inspectionForm.get("subForm_pbim1pfid8");
List<IdxBizJgInspectionDetectionInfo> detectionInfoList = new ArrayList<>();
if(!ObjectUtils.isEmpty(inspectionList)){
if (!ObjectUtils.isEmpty(inspectionList)) {
for (Object obj : inspectionList) {
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = JSON.parseObject(JSON.toJSONString(obj), IdxBizJgInspectionDetectionInfo.class);
inspectionDetectionInfo.setRecord(record);
......@@ -1665,9 +1662,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//八大类技术参数实体填充
List<IdxBizJgMainParts> mainPartsList = new ArrayList<>();
List<IdxBizJgProtectionDevices> protectionDevicesList = new ArrayList<>();
LinkedHashMap registerForm = null;
String equList = idxBizJgOtherInfo.getAlias().toString();
if (equList.startsWith("3")) {
if (EquipmentTypeEnum.DT.getCode().equals(alias)) {
//维保备案信息
LinkedHashMap maintenanceForm = (LinkedHashMap) map.get(maintenance_form_id);
List subFormMaintenanceList = (ArrayList) maintenanceForm.get("subForm_6i16fox27e");
......@@ -1683,7 +1679,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
idxBizJgMaintenanceRecordInfoService.saveOrUpdateBatch(maintenanceList);
}
//技术参数
registerForm = (LinkedHashMap) map.get(dt_register_from_id);
IdxBizJgTechParamsElevator elevator = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsElevator.class);
if (!ObjectUtils.isEmpty(elevator)) {
elevator.setRecord(record);
......@@ -1691,8 +1686,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
elevator.setSequenceNbr("save".equals(type) ? null : techParamsElevator.getSequenceNbr());
idxBizJgTechParamsElevatorService.saveOrUpdate(elevator);
}
} else if (equList.startsWith("1")) {
registerForm = (LinkedHashMap) map.get(gl_register_from_id);
} else if (EquipmentTypeEnum.GL.getCode().equals(alias)) {
IdxBizJgTechParamsBoiler boiler = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsBoiler.class);
if (!ObjectUtils.isEmpty(boiler)) {
boiler.setRecord(record);
......@@ -1703,8 +1697,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
subFormMainPartsList.add("subForm_1hh88r4m69");
mainPartsList = getAccessoryEntity(registerForm, subFormMainPartsList, main_parts, record, date, type);
}
} else if (equList.startsWith("2")) {
registerForm = (LinkedHashMap) map.get(ylrq_register_from_id);
} else if (EquipmentTypeEnum.YL_RQ.getCode().equals(alias)) {
IdxBizJgTechParamsVessel vessel = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsVessel.class);
if (!ObjectUtils.isEmpty(vessel)) {
vessel.setRecord(record);
......@@ -1718,8 +1711,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
subFormProtectionDevicesList.add("subForm_d4xdzhsgdj");
protectionDevicesList = getAccessoryEntity(registerForm, subFormProtectionDevicesList, protection_devices, record, date, type);
}
} else if (equList.startsWith("4")) {
registerForm = (LinkedHashMap) map.get(qzjx_register_from_id);
} else if (EquipmentTypeEnum.QZJ.getCode().equals(alias)) {
IdxBizJgTechParamsLifting lifting = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsLifting.class);
if (!ObjectUtils.isEmpty(lifting)) {
lifting.setRecord(record);
......@@ -1734,8 +1726,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
subFormProtectionDevicesList.add("subForm_h5h4x0zhur");
protectionDevicesList = getAccessoryEntity(registerForm, subFormProtectionDevicesList, protection_devices, record, date, type);
}
} else if (equList.startsWith("5")) {
registerForm = (LinkedHashMap) map.get(cc_register_from_id);
} else if (EquipmentTypeEnum.CS.getCode().equals(alias)) {
IdxBizJgTechParamsVehicle vehicle = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsVehicle.class);
if (!ObjectUtils.isEmpty(vehicle)) {
vehicle.setRecord(record);
......@@ -1747,7 +1738,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
subFormMainPartsList.add("subForm_tef7yf5fbr");
mainPartsList = getAccessoryEntity(registerForm, subFormMainPartsList, main_parts, record, date, type);
}
} else if (equList.startsWith("6")) {
} else if (EquipmentTypeEnum.YL_SS.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(ylss_register_from_id);
IdxBizJgTechParamsRides rides = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsRides.class);
if (!ObjectUtils.isEmpty(rides)) {
......@@ -1756,7 +1747,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
rides.setSequenceNbr("save".equals(type) ? null : techParamsRides.getSequenceNbr());
idxBizJgTechParamsRidesService.saveOrUpdate(rides);
}
} else if (equList.startsWith("8")) {
} else if (EquipmentTypeEnum.YL_GD.getCode().equals(alias)) {
registerForm = (LinkedHashMap) map.get(ylgd_register_from_id);
IdxBizJgTechParamsPipeline pipeline = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsPipeline.class);
if (!ObjectUtils.isEmpty(pipeline)) {
......@@ -1769,7 +1760,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
mainPartsList = getAccessoryEntity(registerForm, subFormMainPartsList, main_parts, record, date, type);
}
} else {
registerForm = (LinkedHashMap) map.get(kysd_register_from_id);
IdxBizJgTechParamsRopeway ropeway = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsRopeway.class);
if (!ObjectUtils.isEmpty(ropeway)) {
ropeway.setRecord(record);
......@@ -1782,7 +1772,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
}
IdxBizJgRegisterInfo registerInfo = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgRegisterInfo.class);
if(!ObjectUtils.isEmpty(registerInfo)){
if (!ObjectUtils.isEmpty(registerInfo)) {
registerInfo.setRecord(record);
registerInfo.setRecDate(date);
registerInfo.setSequenceNbr("save".equals(type) ? null : registerForm.get("sequenceNbr").toString());
......@@ -1849,6 +1839,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/**
* 分页查询所有数据
*
* @param map
* @return
*/
......@@ -2067,7 +2058,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("STATUS"));
if (test.contains("非")) {
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", test.replace("非","")));
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", test.replace("非", "")));
boolMust.mustNot(meBuilder);
} else {
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", test));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment