Commit 894f98fe authored by suhuiguang's avatar suhuiguang

fix(设备创建) : 事务回滚

1.压力管道多证时报错,健壮处理
parent a9806080
......@@ -20,6 +20,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.*;
import com.yeejoin.amos.boot.module.common.api.converter.CommonCustomConverter;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
......@@ -2003,10 +2004,10 @@ public class DataDockServiceImpl {
EquipRequestParamsDto paramsDto = this.extractCommonData(dataSource, reginParams, equipInfo, equLists);
// 是否工业管道
boolean isGYGD = "8300".equals(paramsDto.getEquCategoryCode());
boolean haveUseRegistration = false;
List<JgUseRegistrationManage> jgUseRegistrationManages = new ArrayList<>();
// 确保使用登记证和工程装置在该单位下都是不存在的,方可导入数据
if (isGYGD) {
haveUseRegistration = this.checkTheUnitRegManageAlreadyExists(paramsDto, haveUseRegistration);
jgUseRegistrationManages = this.checkTheUnitRegManageAlreadyExists(paramsDto);
}
idxBizJgProjectContraptionServiceImpl.checkTheUnitProConMatching(paramsDto);
this.checkTheUnitProConAlreadyExists(paramsDto);
......@@ -2018,25 +2019,21 @@ public class DataDockServiceImpl {
// 生成使用登记表信息 + 设备关系表 + 历史表
JgUseRegistration useReg = this.saveUseRegAndEq(paramsDto, records, proCon);
// 生成使用登记证表数据
if (!haveUseRegistration) {
if (jgUseRegistrationManages.isEmpty()) {
JgUseRegistrationManage regManage = this.saveUseRegManage(paramsDto, useReg);
// 流水表
this.saveCertChangeRecord(useReg, regManage, records, paramsDto);
} else {
// 1.更新使用登记证信息
JgUseRegistrationManage jgUseRegistrationManage = jgUseRegistrationManageService.lambdaQuery()
.eq(JgUseRegistrationManage::getUseRegistrationCode, paramsDto.getUseOrgCode())
.eq(JgUseRegistrationManage::getIsDelete, 0)
.one();
if (jgUseRegistrationManage != null) {
jgUseRegistrationManage.setSuperviseOrgCode(paramsDto.getOrgBranchCode());
jgUseRegistrationManage.setSuperviseOrgName(paramsDto.getOrgBranchName());
jgUseRegistrationManage.setEquUseAddress(Stream.of(paramsDto.getProvinceName(), paramsDto.getCityName(), paramsDto.getCountyName(), paramsDto.getStreetName(), paramsDto.getAddress())
.map(value -> value == null || "null".equals(value) ? "" : value)
.collect(Collectors.joining()));
jgUseRegistrationManage.setRecDate(new Date());
jgUseRegistrationManageService.updateById(jgUseRegistrationManage);
}
// 1.更新使用登记证信息,健壮处理,系统业务限制一个证号只能有一个证管理表
LambdaUpdateWrapper<JgUseRegistrationManage> manageLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
manageLambdaUpdateWrapper.set(JgUseRegistrationManage::getSuperviseOrgCode, paramsDto.getOrgBranchCode());
manageLambdaUpdateWrapper.set(JgUseRegistrationManage::getSuperviseOrgName, paramsDto.getOrgBranchName());
manageLambdaUpdateWrapper.set(JgUseRegistrationManage::getEquUseAddress, Stream.of(paramsDto.getProvinceName(), paramsDto.getCityName(), paramsDto.getCountyName(), paramsDto.getStreetName(), paramsDto.getAddress())
.map(value -> value == null || "null".equals(value) ? "" : value)
.collect(Collectors.joining()));
manageLambdaUpdateWrapper.set(JgUseRegistrationManage::getRecDate, new Date());
manageLambdaUpdateWrapper.eq(BaseEntity::getSequenceNbr, jgUseRegistrationManages.stream().map(BaseEntity::getSequenceNbr).collect(Collectors.toList()));
jgUseRegistrationManageService.update(manageLambdaUpdateWrapper);
}
}
this.createResumePipeline(proCon.getSequenceNbr(), String.format(pipelineRoutePath, proCon.getSequenceNbr() + ""), reginParams.getCompany());
......@@ -2111,17 +2108,9 @@ public class DataDockServiceImpl {
*
* @param paramsDto 设备请求参数
*/
public boolean checkTheUnitRegManageAlreadyExists(EquipRequestParamsDto paramsDto, boolean haveUseRegistration) {
public List<JgUseRegistrationManage> checkTheUnitRegManageAlreadyExists(EquipRequestParamsDto paramsDto) {
// 1. 判断是否使用未来系统生成编号
idxBizJgRegisterInfoServiceImpl.checkUseRegistrationCode(paramsDto.getUseOrgCode(), "unit");
// 2. 获取使用登记管理列表
// List<JgUseRegistration> useRegistrationList = jgUseRegistrationMapper.selectList(
// new LambdaQueryWrapper<JgUseRegistration>()
// .eq(JgUseRegistration::getUseRegistrationCode, paramsDto.getUseOrgCode())
// .eq(JgUseRegistration::getIsDelete, 0)
// .eq(JgUseRegistration::getStatus, "已完成")
// .orderByDesc(JgUseRegistration::getRecDate)
// .last("limit 1"));
List<JgUseRegistrationManage> useRegistrationManageList = jgUseRegistrationManageMapper.selectList(
new LambdaQueryWrapper<JgUseRegistrationManage>()
.eq(JgUseRegistrationManage::getUseRegistrationCode, paramsDto.getUseOrgCode())
......@@ -2130,15 +2119,11 @@ public class DataDockServiceImpl {
.orderByDesc(JgUseRegistrationManage::getRecDate));
if (!useRegistrationManageList.isEmpty()) {
// if (useRegistrationList.stream().filter(map -> !"1".equals(map.getRegType())).count() > 1) {
// throw new BadRequest("该使用登记证编号已由系统自动生成,不能导入,请确认使用登记证编号是否正确!");
// }
if (useRegistrationManageList.stream().anyMatch(map -> !paramsDto.getCompanyCode().equals(map.getUseUnitCreditCode()))) {
throw new BadRequest("该使用登记证编号在其他企业使用,不能导入,请确认使用登记证编号是否正确!");
}
haveUseRegistration = true;
}
return haveUseRegistration;
return useRegistrationManageList;
}
/**
......
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