Commit 2fa67eb3 authored by suhuiguang's avatar suhuiguang

1.历史无证设备创建编辑联调

parent de0d4b2f
...@@ -95,6 +95,8 @@ import java.time.ZoneId; ...@@ -95,6 +95,8 @@ import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -383,11 +385,56 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -383,11 +385,56 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
if (paramMap == null) { if (paramMap == null) {
throw new IllegalArgumentException("参数Map不能为空"); throw new IllegalArgumentException("参数Map不能为空");
} }
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
String dataSource = (String) equipmentInfoForm.get(DATA_SOURCE);
if(dataSource.contains("black")){
return this.blackEquipCreateOrUpdate(paramMap);
} else {
return this.otherEquipCreateOrUpdate(paramMap);
}
}
private ResponseModel blackEquipCreateOrUpdate(Map<String, Object> paramMap) {
LinkedHashMap equipmentClassForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_CLASS_FORM_ID)); LinkedHashMap equipmentClassForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_CLASS_FORM_ID));
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID)); LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
LinkedHashMap equipmentParamsForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_PARAMS_FORM_ID)); LinkedHashMap equipmentParamsForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_PARAMS_FORM_ID));
String submitType = String.valueOf(paramMap.get("submitType")); String submitType = String.valueOf(paramMap.get("submitType"));
String record = (String) equipmentInfoForm.get(RECORD); String record = (String) equipmentInfoForm.get(RECORD);
try {
// 设备代码 字段的唯一性校验
checkEquCodeUniqueness(equipmentInfoForm);
// 车用气瓶业务里面的 产品编号 校验唯一性(产品编号在车用气瓶范围内全局唯一)
checkFactoryNumUniqueness(equipmentInfoForm);
// 96333码 字段的唯一性校验
check96333Code(equipmentInfoForm);
} catch (Exception e) {
handleError(e, null);
}
// 操作类型
try {
// 保存数据
record = batchSubmitOrUpdate(equipmentClassForm, equipmentInfoForm, equipmentParamsForm, submitType);
// 保存Es数据
if (!ObjectUtils.isEmpty(record)) {
checkEsData(record);
}
} catch (Exception e) {
log.error("操作失败,数据异常: " + e.getMessage(), e);
handleError(e, record);
}
return ResponseHelper.buildResponse(record);
}
private ResponseModel otherEquipCreateOrUpdate(Map<String, Object> paramMap) {
if (paramMap == null) {
throw new IllegalArgumentException("参数Map不能为空");
}
LinkedHashMap equipmentClassForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_CLASS_FORM_ID));
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
LinkedHashMap equipmentParamsForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_PARAMS_FORM_ID));
String submitType = String.valueOf(paramMap.get("submitType"));
String record = (String) equipmentInfoForm.get(RECORD);
String dataSource = (String) equipmentInfoForm.get(DATA_SOURCE);
try { try {
// 设备代码 字段的唯一性校验 // 设备代码 字段的唯一性校验
...@@ -429,6 +476,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -429,6 +476,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
return ResponseHelper.buildResponse(record); return ResponseHelper.buildResponse(record);
} }
private Object checkAndCast(Object obj) { private Object checkAndCast(Object obj) {
if (obj instanceof LinkedHashMap) { if (obj instanceof LinkedHashMap) {
return obj; return obj;
...@@ -441,12 +491,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -441,12 +491,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
// 根据设备代码检查唯一性 // 根据设备代码检查唯一性
String equCode = (String) equipmentInfoForm.get(EQU_CODE); String equCode = (String) equipmentInfoForm.get(EQU_CODE);
String sequenceNbr = (String) equipmentInfoForm.get(SEQUENCE_NBR); String sequenceNbr = (String) equipmentInfoForm.get(SEQUENCE_NBR);
List<Integer> results = Stream.of(idxBizJgRegisterInfoMapper.selectByEquCodeAndClaimStatus(equCode, sequenceNbr, null), if(StringUtils.isNotEmpty(equCode)) {
idxBizJgRegisterInfoMapper.selectInstallNoticeEqByEquCode(equCode, sequenceNbr) List<Integer> results = Stream.of(idxBizJgRegisterInfoMapper.selectByEquCodeAndClaimStatus(equCode, sequenceNbr, null),
).collect(Collectors.toList()); idxBizJgRegisterInfoMapper.selectInstallNoticeEqByEquCode(equCode, sequenceNbr)
).collect(Collectors.toList());
if (results.stream().anyMatch(count -> count > 0)) { if (results.stream().anyMatch(count -> count > 0)) {
throw new BadRequest("设备代码已存在,请重新输入!"); throw new BadRequest("设备代码已存在,请重新输入!");
}
} }
} }
...@@ -2355,23 +2407,21 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -2355,23 +2407,21 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
String equDefine = String.valueOf(equipmentClassForm.get(EQU_DEFINE)); String equDefine = String.valueOf(equipmentClassForm.get(EQU_DEFINE));
// 业务场景 // 业务场景
String businessScenarios = String.valueOf(equipmentClassForm.get(BUSINESS_SCENARIOS)); String businessScenarios = String.valueOf(equipmentClassForm.get(BUSINESS_SCENARIOS));
// 数据来源 历史数据his 新数据new
String equipSource = String.valueOf(equipmentClassForm.get(DATA_SOURCE));
// 操作类型 // 操作类型
String operateType = ValidationUtil.isEmpty(equipmentInfoForm.get(SEQUENCE_NBR)) ? OPERATESAVE : OPERATEEDIT; String operateType = ValidationUtil.isEmpty(equipmentInfoForm.get(SEQUENCE_NBR)) ? OPERATESAVE : OPERATEEDIT;
// 设备是否复制而来,复制来的设备走新增 // 设备是否复制而来,复制来的设备走新增
boolean isCopy = !ValidationUtil.isEmpty(equipmentInfoForm.get(IS_COPY)); boolean isCopy = !ValidationUtil.isEmpty(equipmentInfoForm.get(IS_COPY));
operateType = isCopy ? OPERATESAVE : operateType; operateType = isCopy ? OPERATESAVE : operateType;
// 新增设备保存时 : 历史设备=》dataSource为"his" jg新录入设备dataSource为"jg" // 新增设备保存时 : 历史设备=》dataSource为"his" jg新录入设备dataSource为"jg"
String dataSource = OPERATESAVE.equals(operateType) ? ("new".equals(equipSource) ? "jg" : "jg_his") : ValidationUtil.isEmpty(equipmentInfoForm.get("DATA_SOURCE")) ? "jg_his" : equipmentInfoForm.get("DATA_SOURCE").toString(); String dataSource = this.getDataSource(operateType, equipmentInfoForm);
if (isCopy) { if (isCopy) {
String sourceRecord = equipmentClassForm.get(RECORD).toString(); String sourceRecord = equipmentClassForm.get(RECORD).toString();
// dataSource = "new".equals(equipSource) ? ("jg_" + sourceRecord) : ("jg_his_" + sourceRecord);
// bug-21203 // bug-21203
if (equipmentInfoForm.containsKey("DATA_SOURCE")) { if (equipmentInfoForm.containsKey("DATA_SOURCE")) {
String dataSourceCopy = equipmentInfoForm.get("DATA_SOURCE").toString(); String dataSourceCopy = equipmentInfoForm.get("DATA_SOURCE").toString();
if (dataSourceCopy.startsWith("jg_his")) { if (dataSourceCopy.startsWith("jg_his_black")) {
dataSource = "jg_his_black" + sourceRecord;
} else if (dataSourceCopy.startsWith("jg_his")) {
dataSource = "jg_his_" + sourceRecord; dataSource = "jg_his_" + sourceRecord;
} else { } else {
dataSource = "jg_" + sourceRecord; dataSource = "jg_" + sourceRecord;
...@@ -2690,6 +2740,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -2690,6 +2740,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
return record; return record;
} }
private String getDataSource(String operateType, LinkedHashMap equipmentInfoForm) {
// 数据来源 历史数据his 新数据new
String equipSource = String.valueOf(equipmentInfoForm.get(DATA_SOURCE));
if(OPERATESAVE.equals(operateType)){
return "new".equals(equipSource) ? "jg" : "his".equals(equipSource) ? "jg_his" : "jg_his_black";
} else {
return equipSource;
}
}
public void checkEsData(String id) { public void checkEsData(String id) {
Map<String, Object> map = categoryOtherInfoMapper.selectDataById(id); Map<String, Object> map = categoryOtherInfoMapper.selectDataById(id);
categoryOtherInfoMapper.updateEsStatus(id); categoryOtherInfoMapper.updateEsStatus(id);
......
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