Commit bfa56274 authored by 刘凡's avatar 刘凡

优化:公共更新es方法

parent c73e9e77
...@@ -98,6 +98,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -98,6 +98,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.DateUtil; import org.typroject.tyboot.core.foundation.utils.DateUtil;
...@@ -106,6 +107,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -106,6 +107,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -126,6 +128,7 @@ import java.util.concurrent.ExecutorService; ...@@ -126,6 +128,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static com.alibaba.fastjson.JSON.toJSONString; import static com.alibaba.fastjson.JSON.toJSONString;
/** /**
...@@ -396,7 +399,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -396,7 +399,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if ("QTBF".equals(type)) { if ("QTBF".equals(type)) {
type = "superviseBusiness"; type = "superviseBusiness";
} }
mapList = resourceJson.get(type) == null ? resourceJson.get( EquipmentClassifityEnum.BDLS.getCode()):resourceJson.get(type) ; mapList = resourceJson.get(type) == null ? resourceJson.get(EquipmentClassifityEnum.BDLS.getCode()) : resourceJson.get(type);
} }
for (Map map : mapList) { for (Map map : mapList) {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
...@@ -491,7 +494,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -491,7 +494,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*/ */
@Override @Override
public Map<String, String> createSupervisorCode(Map<String, Object> map) { public Map<String, String> createSupervisorCode(Map<String, Object> map) {
String city, county, equipCategory,isNotXiXian; String city, county, equipCategory, isNotXiXian;
//获取对应行政区划 //获取对应行政区划
city = String.valueOf(map.get("cityCode")); city = String.valueOf(map.get("cityCode"));
county = String.valueOf(map.get("countyCode")); county = String.valueOf(map.get("countyCode"));
...@@ -713,7 +716,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -713,7 +716,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* 具体生成监管码和电梯96333识别码逻辑 * 具体生成监管码和电梯96333识别码逻辑
*/ */
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Map<String, String> creatCode(String isNotXiXian,String city, String county, String equipCategory, String code96333, String supervisionCode) { public Map<String, String> creatCode(String isNotXiXian, String city, String county, String equipCategory, String code96333, String supervisionCode) {
//RLock lock = redissonClient.getLock(LOCK_KEY); //RLock lock = redissonClient.getLock(LOCK_KEY);
Map<String, String> resultMap = null; Map<String, String> resultMap = null;
try { try {
...@@ -737,7 +740,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -737,7 +740,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//查询未使用的电梯码 //查询未使用的电梯码
categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode()); categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode());
//如果存在未使用的电梯码则启用未使用的否则创建 //如果存在未使用的电梯码则启用未使用的否则创建
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? generateCodeService.createElevatorCode("96333_"+ prefix) : categoryOtherInfo.getCode(); String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? generateCodeService.createElevatorCode("96333_" + prefix) : categoryOtherInfo.getCode();
if (!ObjectUtils.isEmpty(categoryOtherInfo)) { if (!ObjectUtils.isEmpty(categoryOtherInfo)) {
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333", categoryOtherInfo.getCode())); supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333", categoryOtherInfo.getCode()));
} }
...@@ -836,7 +839,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -836,7 +839,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
/** /**
*
* 生成96333电梯识别码 * 生成96333电梯识别码
* *
* @param prefix 电梯码前缀 * @param prefix 电梯码前缀
...@@ -1542,7 +1544,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1542,7 +1544,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String supervisionCode = String.valueOf(superviseMap.get("supervisionCode")); String supervisionCode = String.valueOf(superviseMap.get("supervisionCode"));
EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy(); EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy();
//生成码 //生成码
codeMap = categoryService.creatCode(isNotXiXian,city, county, equCategory, code96333, supervisionCode); codeMap = categoryService.creatCode(isNotXiXian, city, county, equCategory, code96333, supervisionCode);
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据 //删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data"); map.remove("data");
supervisionMap.put("CODE96333", codeMap.get("code96333")); supervisionMap.put("CODE96333", codeMap.get("code96333"));
...@@ -1613,7 +1615,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1613,7 +1615,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
// 2查找管辖机构为西咸,但96333码不为31开头的数据recordList // 2查找管辖机构为西咸,但96333码不为31开头的数据recordList
List<String> recordList = !"new".equals(type) ? equipmentCategoryMapper.selectXiXian() : equipmentCategoryMapper.selectXiXianNew(); List<String> recordList = !"new".equals(type) ? equipmentCategoryMapper.selectXiXian() : equipmentCategoryMapper.selectXiXianNew();
if(!ObjectUtils.isEmpty(recordList)){ if (!ObjectUtils.isEmpty(recordList)) {
// 2.1删除码表中recordList对应的码数据 // 2.1删除码表中recordList对应的码数据
equipmentCategoryMapper.clearSupervisoryCode(); equipmentCategoryMapper.clearSupervisoryCode();
// 2.2清空业务表中recordList对应的96333码和监管码 // 2.2清空业务表中recordList对应的96333码和监管码
...@@ -2361,7 +2363,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2361,7 +2363,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return true; return true;
} }
public void updateStatus(String supervisoryCode){ public void updateStatus(String supervisoryCode) {
SupervisoryCodeInfo info = new SupervisoryCodeInfo(); SupervisoryCodeInfo info = new SupervisoryCodeInfo();
info.setStatus("1"); info.setStatus("1");
LambdaQueryWrapper<SupervisoryCodeInfo> lambda = new QueryWrapper<SupervisoryCodeInfo>().lambda(); LambdaQueryWrapper<SupervisoryCodeInfo> lambda = new QueryWrapper<SupervisoryCodeInfo>().lambda();
...@@ -2371,16 +2373,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2371,16 +2373,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Transactional @Transactional
public Boolean saveConstructionInfoData(IdxBizJgConstructionInfo data) { public Boolean saveConstructionInfoData(IdxBizJgConstructionInfo data) {
if (!ObjectUtils.isEmpty(data) && !ObjectUtils.isEmpty(data.getSupervisoryCode())){ if (!ObjectUtils.isEmpty(data) && !ObjectUtils.isEmpty(data.getSupervisoryCode())) {
String supervisoryCode = data.getSupervisoryCode(); String supervisoryCode = data.getSupervisoryCode();
data.setRecDate(new Date()); data.setRecDate(new Date());
if (!ObjectUtils.isEmpty(data.getSequenceNbr())){ if (!ObjectUtils.isEmpty(data.getSequenceNbr())) {
idxBizJgConstructionInfoService.updateById(data); idxBizJgConstructionInfoService.updateById(data);
}else { } else {
data.setRecord(supervisoryCode); data.setRecord(supervisoryCode);
idxBizJgConstructionInfoService.save(data); idxBizJgConstructionInfoService.save(data);
} }
}else { } else {
return false; return false;
} }
return true; return true;
...@@ -2388,16 +2390,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2388,16 +2390,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Transactional @Transactional
public Boolean saveMaintenanceRecordInfoData(IdxBizJgMaintenanceRecordInfo data) { public Boolean saveMaintenanceRecordInfoData(IdxBizJgMaintenanceRecordInfo data) {
if (!ObjectUtils.isEmpty(data) && !ObjectUtils.isEmpty(data.getSupervisoryCode())){ if (!ObjectUtils.isEmpty(data) && !ObjectUtils.isEmpty(data.getSupervisoryCode())) {
String supervisoryCode = data.getSupervisoryCode(); String supervisoryCode = data.getSupervisoryCode();
data.setRecDate(new Date()); data.setRecDate(new Date());
if (!ObjectUtils.isEmpty(data.getSequenceNbr())){ if (!ObjectUtils.isEmpty(data.getSequenceNbr())) {
idxBizJgMaintenanceRecordInfoService.updateById(data); idxBizJgMaintenanceRecordInfoService.updateById(data);
}else { } else {
data.setRecord(supervisoryCode); data.setRecord(supervisoryCode);
idxBizJgMaintenanceRecordInfoService.save(data); idxBizJgMaintenanceRecordInfoService.save(data);
} }
}else { } else {
return false; return false;
} }
return true; return true;
...@@ -2405,22 +2407,23 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2405,22 +2407,23 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Transactional @Transactional
public Boolean saveDetectionInfoData(IdxBizJgInspectionDetectionInfo data) { public Boolean saveDetectionInfoData(IdxBizJgInspectionDetectionInfo data) {
if (!ObjectUtils.isEmpty(data) && !ObjectUtils.isEmpty(data.getSupervisoryCode())){ if (!ObjectUtils.isEmpty(data) && !ObjectUtils.isEmpty(data.getSupervisoryCode())) {
String supervisoryCode = data.getSupervisoryCode(); String supervisoryCode = data.getSupervisoryCode();
data.setRecDate(new Date()); data.setRecDate(new Date());
if (!ObjectUtils.isEmpty(data.getSequenceNbr())){ if (!ObjectUtils.isEmpty(data.getSequenceNbr())) {
idxBizJgInspectionDetectionInfoService.updateById(data); idxBizJgInspectionDetectionInfoService.updateById(data);
}else { } else {
data.setRecord(supervisoryCode); data.setRecord(supervisoryCode);
idxBizJgInspectionDetectionInfoService.save(data); idxBizJgInspectionDetectionInfoService.save(data);
} }
}else { } else {
return false; return false;
} }
return true; return true;
} }
public Boolean deleteByRecord(String record) { public Boolean deleteByRecord(String record) {
if (!ObjectUtils.isEmpty(record)){ if (!ObjectUtils.isEmpty(record)) {
// 使用信息删除 // 使用信息删除
LambdaQueryWrapper<IdxBizJgUseInfo> lambda = new QueryWrapper<IdxBizJgUseInfo>().lambda(); LambdaQueryWrapper<IdxBizJgUseInfo> lambda = new QueryWrapper<IdxBizJgUseInfo>().lambda();
lambda.eq(IdxBizJgUseInfo::getRecord, record); lambda.eq(IdxBizJgUseInfo::getRecord, record);
...@@ -2461,7 +2464,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2461,7 +2464,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
LambdaQueryWrapper<IdxBizJgTechParamsElevator> lambdaPar = new QueryWrapper<IdxBizJgTechParamsElevator>().lambda(); LambdaQueryWrapper<IdxBizJgTechParamsElevator> lambdaPar = new QueryWrapper<IdxBizJgTechParamsElevator>().lambda();
lambdaPar.eq(IdxBizJgTechParamsElevator::getRecord, record); lambdaPar.eq(IdxBizJgTechParamsElevator::getRecord, record);
idxBizJgTechParamsElevatorService.getBaseMapper().delete(lambdaPar); idxBizJgTechParamsElevatorService.getBaseMapper().delete(lambdaPar);
}else { } else {
return false; return false;
} }
return true; return true;
...@@ -2469,10 +2472,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2469,10 +2472,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/** /**
* 更新ES中的数据(公共方法) * 更新ES中的数据(公共方法)
*
* @param paramMap 更新的参数 * @param paramMap 更新的参数
*/ */
public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap){ public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap) {
if(paramMap.isEmpty()){ if (paramMap.isEmpty()) {
return null; return null;
} }
String oldUscUnitCreditCode = ""; String oldUscUnitCreditCode = "";
...@@ -2481,11 +2485,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2481,11 +2485,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
for (Map.Entry<String, Map<String, Object>> entry : paramMap.entrySet()) { for (Map.Entry<String, Map<String, Object>> entry : paramMap.entrySet()) {
String record = entry.getKey(); String record = entry.getKey();
Map<String, Object> childMap = entry.getValue(); Map<String, Object> childMap = entry.getValue();
if(!childMap.isEmpty()){ if (!childMap.isEmpty()) {
ESEquipmentCategoryDto oldData = null; ESEquipmentCategoryDto oldData = null;
//获取Es中旧的数据 //获取Es中旧的数据
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record); Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
if(!ObjectUtils.isEmpty(optional)){ if (!ObjectUtils.isEmpty(optional)) {
oldData = optional.get(); oldData = optional.get();
oldUscUnitCreditCode = oldData.getUSC_UNIT_CREDIT_CODE(); oldUscUnitCreditCode = oldData.getUSC_UNIT_CREDIT_CODE();
oldUscUnitName = oldData.getUSC_UNIT_NAME(); oldUscUnitName = oldData.getUSC_UNIT_NAME();
...@@ -2501,9 +2505,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2501,9 +2505,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//整合新旧数据 //整合新旧数据
Bean.copyExistPropertis(newData, oldData); Bean.copyExistPropertis(newData, oldData);
//处理施工单位信息[去重] //处理施工单位信息[去重]
if (!StringUtils.isEmpty(oldUscUnitCreditCode)) {
if(!oldUscUnitCreditCode.contains(newUscUnitCreditCode)){ if(!oldUscUnitCreditCode.contains(newUscUnitCreditCode)){
oldData.setUSC_UNIT_CREDIT_CODE(oldUscUnitCreditCode+","+newUscUnitCreditCode); oldData.setUSC_UNIT_CREDIT_CODE(oldUscUnitCreditCode + "," + newUscUnitCreditCode);
oldData.setUSC_UNIT_NAME(oldUscUnitName+","+newUscUnitName); oldData.setUSC_UNIT_NAME(oldUscUnitName + "," + newUscUnitName);
}
}else {
oldData.setUSC_UNIT_CREDIT_CODE(newUscUnitCreditCode);
oldData.setUSC_UNIT_NAME(newUscUnitName);
} }
} }
if (!ObjectUtils.isEmpty(oldData)) { if (!ObjectUtils.isEmpty(oldData)) {
...@@ -2511,11 +2520,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2511,11 +2520,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
ESEquipmentCategoryDto saveData = esEquipmentCategory.save(oldData); ESEquipmentCategoryDto saveData = esEquipmentCategory.save(oldData);
//组装返回数据 //组装返回数据
resultMap.put(record,saveData); resultMap.put(record, saveData);
} }
} }
} }
return resultMap; return resultMap;
} }
} }
\ No newline at end of file
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