Commit 2c2fdba5 authored by suhuiguang's avatar suhuiguang

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

1.回滚时,删除设备
parent c51777bc
......@@ -27,6 +27,7 @@ public class EquipRequestParamsDto {
private String dataSource;
private String orgBranchCode;
private String orgBranchName;
private String orgCompanyCode;
private String useOrgCode;
private String vehicleApanage;
private String receiveCompanyCode;
......
......@@ -39,7 +39,7 @@ public class DataDockController extends BaseController {
@PostMapping(value = "/xi-an/saveEquipmentData")
@ApiOperation(httpMethod = "POST", value = "西安数据对接-设备批量导入", notes = "西安数据对接-导入多个设备的数据文件")
public ResponseModel<?> saveEquipmentData(@RequestBody List<Map<String, Object>> equLists) {
return ResponseHelper.buildResponse(dataDockService.xiAnSaveEquipmentData(equLists));
return ResponseHelper.buildResponse(dataDockService.xiAnSaveEquipmentData(equLists, getSelectedOrgInfo()));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -57,7 +57,7 @@ public class DataDockController extends BaseController {
if (!("application/vnd.ms-excel".equals(contentType) || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType)) || !("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension))) {
return ResponseHelper.buildResponse("文件类型必须是 Excel 文件");
}
return ResponseHelper.buildResponse(dataDockService.dataCheckAndImportEquipmentData(remark, file));
return ResponseHelper.buildResponse(dataDockService.dataCheckAndImportEquipmentData(remark, file, getSelectedOrgInfo()));
}
/**
......@@ -137,7 +137,7 @@ public class DataDockController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "台套类设备导入字段保存", notes = "台套类设备导入字段保存")
@RestEventTrigger(value = "operateLogRestEventHandler")
public ResponseModel<?> saveEquipImportData(@RequestBody Map<String, Object> paramMap) {
return ResponseHelper.buildResponse(dataDockService.saveEquipImportData(paramMap));
return ResponseHelper.buildResponse(dataDockService.saveEquipImportData(paramMap, getSelectedOrgInfo()));
}
/**
......
package com.yeejoin.amos.boot.module.jg.biz.hook;
import io.seata.tm.api.transaction.TransactionHook;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class EsSyncTransactionHook implements TransactionHook {
private final String xid; // final保证构造后不变
public EsSyncTransactionHook(String xid) {
this.xid = xid;
}
@Override
public void beforeBegin() {
log.info("beforeBegin:{}", xid);
}
@Override
public void afterBegin() {
log.info("afterBegin:{}", xid);
}
@Override
public void beforeCommit() {
log.info("beforeCommit:{}", xid);
}
@Override
public void afterCommit() {
log.info("afterCommit:{}", xid);
}
@Override
public void beforeRollback() {
log.info("beforeRollback:{}", xid);
}
@Override
public void afterRollback() {
log.info("afterRollback:{}", xid);
}
@Override
public void afterCompletion() {
log.info("afterCompletion:{}", xid);
}
}
......@@ -190,32 +190,37 @@ public class DataDockServiceImpl {
/**
* 西安数据对接-保存设备信息
*
* @param equLists 数据集
* @param equLists 数据集
* @param selectedOrgInfo
* @return 保存结果
*/
public boolean xiAnSaveEquipmentData(List<Map<String, Object>> equLists) {
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
@Transactional(rollbackFor = Exception.class)
public boolean xiAnSaveEquipmentData(List<Map<String, Object>> equLists, ReginParams selectedOrgInfo) {
Set<String> recordSet = new HashSet<>();
CompletableFuture.allOf(
equLists.parallelStream().map(equ -> CompletableFuture.runAsync(() -> {
contextWrapper.apply();
String record = saveEquipmentDataInTransaction(equ, "jg_his_xa", null);
recordSet.add(record);
})).toArray(CompletableFuture[]::new)
).join();
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
}
});
return Boolean.TRUE;
try {
equLists.forEach(equ ->{
String record = saveEquipmentDataInTransaction(equ, "jg_his_xa", null, selectedOrgInfo);
recordSet.add(record);
});
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
return Boolean.TRUE;
} catch (Exception e) {
if(!recordSet.isEmpty()) {
List<ESEquipmentCategoryDto> dtoList = recordSet.stream().map(record->{
ESEquipmentCategoryDto dto = new ESEquipmentCategoryDto();
dto.setSEQUENCE_NBR(record);
return dto;
}).collect(Collectors.toList());
esEquipmentCategory.deleteAll(dtoList);
log.warn("西安数据对接-设备老索引数据回滚成功,删除数量:{}", dtoList.size());
}
log.error("西安数据对接保存失败,{}", e.getMessage(), e);
throw new RuntimeException(e);
}
}
@GlobalTransactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public String saveEquipmentDataInTransaction(Map<String, Object> equ, String dataSource, String remark) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
public String saveEquipmentDataInTransaction(Map<String, Object> equ, String dataSource, String remark, ReginParams reginParams) {
CompanyBo company = reginParams.getCompany();
String record = UUID.randomUUID().toString();
try {
......@@ -657,6 +662,22 @@ public class DataDockServiceImpl {
}
/**
* 保存起重机械技术参数
*
* @param equ
* @param record
*/
private void saveLiftingParams(Map<String, Object> equ, String record) {
log.error("数据===>{}", toJSONString(equ));
IdxBizJgTechParamsLifting equipTechParamLifting = JSON.parseObject(toJSONString(equ), IdxBizJgTechParamsLifting.class);
if (!ValidationUtil.isEmpty(equipTechParamLifting)) {
equipTechParamLifting.setRecord(record);
equipTechParamLifting.setRecDate(new Date());
iIdxBizJgTechParamsLiftingService.saveOrUpdateData(equipTechParamLifting);
}
}
/**
* 保存技术参数
*
* @param equ
......@@ -684,22 +705,6 @@ public class DataDockServiceImpl {
}
/**
* 保存起重机械技术参数
*
* @param equ
* @param record
*/
private void saveLiftingParams(Map<String, Object> equ, String record) {
log.error("数据===>{}", toJSONString(equ));
IdxBizJgTechParamsLifting equipTechParamLifting = JSON.parseObject(toJSONString(equ), IdxBizJgTechParamsLifting.class);
if (!ValidationUtil.isEmpty(equipTechParamLifting)) {
equipTechParamLifting.setRecord(record);
equipTechParamLifting.setRecDate(new Date());
iIdxBizJgTechParamsLiftingService.saveOrUpdateData(equipTechParamLifting);
}
}
/**
* 保存场内机动车辆技术参数
*
* @param equ
......@@ -866,10 +871,11 @@ public class DataDockServiceImpl {
* 八大类历史设备导入
*
* @param file
* @param selectedOrgInfo
* @return
*/
@Transactional(rollbackFor = Exception.class)
public Object dataCheckAndImportEquipmentData(String remark, MultipartFile file) {
public Object dataCheckAndImportEquipmentData(String remark, MultipartFile file, ReginParams selectedOrgInfo) {
List<EquipInfoExcelDto> equipInfoExcelDtos;
try {
......@@ -880,7 +886,7 @@ public class DataDockServiceImpl {
}
// 2, 保存设备数据
this.batchSaveEquipmentData(remark, equipInfoExcelDtos);
this.batchSaveEquipmentData(remark, equipInfoExcelDtos, selectedOrgInfo);
return Boolean.TRUE;
}
......@@ -1650,7 +1656,7 @@ public class DataDockServiceImpl {
}
@Transactional(rollbackFor = Exception.class)
public void batchSaveHisEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos, LinkedHashMap equipmentInfoForm) {
public void batchSaveHisEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos, LinkedHashMap equipmentInfoForm, ReginParams selectedOrgInfo) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany();
String[] keys = {
......@@ -1687,40 +1693,53 @@ public class DataDockServiceImpl {
Set<String> projectContraptionSet = new HashSet<>();
Map<String, Long> projectContraptionMap = new HashMap<>();
Set<String> projectContraptionIdSet = new HashSet<>();
for (EquipInfoExcelDto equ : equipInfoExcelDtos) {
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class);
for (String key : keys) {
String camelKey = toCamelCase(key.toLowerCase());
equMap.put(camelKey, getUrlByKey(fileDataList, key));
}
equMap.put("orgBranchName", orgBranchName);
equMap.put("orgBranchCode", orgBranchCode);
equMap.put("EQU_STATE", equipmentInfoForm.get("EQU_STATE"));
String projectContraptionNo = Objects.toString(equMap.get("projectContraptionNo"), "").trim();
Long projectContraptionId;
if (!projectContraptionSet.contains(projectContraptionNo)) {
projectContraptionId = this.saveProjectContraption(equMap, equList, company, dataSource);
projectContraptionSet.add(projectContraptionNo);
projectContraptionMap.put(projectContraptionNo, projectContraptionId);
} else {
projectContraptionId = projectContraptionMap.get(projectContraptionNo);
try {
for (EquipInfoExcelDto equ : equipInfoExcelDtos) {
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class);
for (String key : keys) {
String camelKey = toCamelCase(key.toLowerCase());
equMap.put(camelKey, getUrlByKey(fileDataList, key));
}
equMap.put("orgBranchName", orgBranchName);
equMap.put("orgBranchCode", orgBranchCode);
equMap.put("EQU_STATE", equipmentInfoForm.get("EQU_STATE"));
String projectContraptionNo = Objects.toString(equMap.get("projectContraptionNo"), "").trim();
Long projectContraptionId;
if (!projectContraptionSet.contains(projectContraptionNo)) {
projectContraptionId = this.saveProjectContraption(equMap, equList, company, dataSource);
projectContraptionSet.add(projectContraptionNo);
projectContraptionMap.put(projectContraptionNo, projectContraptionId);
} else {
projectContraptionId = projectContraptionMap.get(projectContraptionNo);
}
if (projectContraptionId != null) {
projectContraptionIdSet.add(String.valueOf(projectContraptionId));
equMap.put("projectContraptionId", projectContraptionId);
}
String record = this.saveEquipmentDataInTransaction(equMap, dataSource, remark, selectedOrgInfo);
recordSet.add(record);
}
if (projectContraptionId != null) {
projectContraptionIdSet.add(String.valueOf(projectContraptionId));
equMap.put("projectContraptionId", projectContraptionId);
if (EquipmentClassifityEnum.YLGD.getCode().equals(equList)) {
this.updatePipelineLength(projectContraptionIdSet);
this.createResumePipelineBatch(projectContraptionIdSet, String.format(pipelineRoutePath, projectContraptionIdSet), company);
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_PROJECT.name(), projectContraptionIdSet, EquipCreateOrEditEvent.EquipType.project));
}else{
this.createResumeBatch(recordSet,dataSource, equipRoutePath, company);
eventPublisher.publish(new EquipCreateOrEditEvent(this,BusinessTypeEnum.JG_NEW_EQUIP.name(),recordSet, EquipCreateOrEditEvent.EquipType.equip));
}
String record = this.saveEquipmentDataInTransaction(equMap, dataSource, remark);
recordSet.add(record);
}
if (EquipmentClassifityEnum.YLGD.getCode().equals(equList)) {
this.updatePipelineLength(projectContraptionIdSet);
this.createResumePipelineBatch(projectContraptionIdSet, String.format(pipelineRoutePath, projectContraptionIdSet), company);
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_PROJECT.name(), projectContraptionIdSet, EquipCreateOrEditEvent.EquipType.project));
}else{
this.createResumeBatch(recordSet,dataSource, equipRoutePath, company);
eventPublisher.publish(new EquipCreateOrEditEvent(this,BusinessTypeEnum.JG_NEW_EQUIP.name(),recordSet, EquipCreateOrEditEvent.EquipType.equip));
} catch (Exception e) {
if(!recordSet.isEmpty()) {
List<ESEquipmentCategoryDto> dtoList = recordSet.stream().map(record->{
ESEquipmentCategoryDto dto = new ESEquipmentCategoryDto();
dto.setSEQUENCE_NBR(record);
return dto;
}).collect(Collectors.toList());
esEquipmentCategory.deleteAll(dtoList);
log.warn("台套类设备导入字段保存-设备老索引数据回滚成功,删除数量:{}", dtoList.size());
}
throw new RuntimeException(e);
}
}
......@@ -1760,23 +1779,39 @@ public class DataDockServiceImpl {
* 批量异步保存设备数据
*
* @param equipInfoExcelDtos
* @param selectedOrgInfo
*/
public void batchSaveEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos) {
public void batchSaveEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos, ReginParams selectedOrgInfo) {
String[] keys = {
"PRODUCT_PHOTO", "OTHER_ACCESSORIES_REG", "DESIGN_DOC", "DESIGN_STANDARD",
"OTHER_ACCESSORIES_DES", "PRODUCT_QUALITY_YIELD_PROVE", "FACTORY_STANDARD",
"INS_USE_MAINTAIN_EXPLAIN", "OTHER_ACCESSORIES_FACT",
"BOILER_ENERGY_EFFICIENCY_CERTIFICATE", "FACT_SUPERVISION_INSPECTION_REPORT","INSPECT_REPORT"
};
Arrays.stream(equipInfoExcelDtos.toArray(new EquipInfoExcelDto[0])).forEach(equ -> {
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class);
for (String key : keys) {
String camelKey = toCamelCase(key.toLowerCase());
equMap.put(camelKey, getUrlByKey(fileDataList, key));
}
this.saveEquipmentDataInTransaction(equMap, "jg_his", remark);
});
Set<String> recordSet = new HashSet<>();
try {
equipInfoExcelDtos.forEach(equ -> {
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class);
for (String key : keys) {
String camelKey = toCamelCase(key.toLowerCase());
equMap.put(camelKey, getUrlByKey(fileDataList, key));
}
String record = saveEquipmentDataInTransaction(equMap, "jg_his", remark, selectedOrgInfo);
recordSet.add(record);
});
} catch (Exception e) {
if(!recordSet.isEmpty()) {
List<ESEquipmentCategoryDto> dtoList = recordSet.stream().map(record->{
ESEquipmentCategoryDto dto = new ESEquipmentCategoryDto();
dto.setSEQUENCE_NBR(record);
return dto;
}).collect(Collectors.toList());
esEquipmentCategory.deleteAll(dtoList);
log.warn("八大类历史设备导入,设备老索引数据回滚成功,删除数量:{}", dtoList.size());
}
throw new RuntimeException(e);
}
}
private String getUrlByKey(List<Map<String, Object>> dataList, String key) {
......@@ -1913,7 +1948,7 @@ public class DataDockServiceImpl {
}
@Transactional(rollbackFor = Exception.class)
public Object saveEquipImportData(Map<String, Object> paramMap) {
public Object saveEquipImportData(Map<String, Object> paramMap, ReginParams selectedOrgInfo) {
if (paramMap == null) {
throw new IllegalArgumentException("参数Map不能为空");
}
......@@ -1922,7 +1957,7 @@ public class DataDockServiceImpl {
List<EquipInfoExcelDto> equipInfoExcelDtos = JSON.parseArray(toJSONString(attachmentUpload.get(EQU_LISTS)), EquipInfoExcelDto.class);
// 2, 保存设备数据
this.batchSaveHisEquipmentData("", equipInfoExcelDtos,equipmentInfoForm);
this.batchSaveHisEquipmentData("", equipInfoExcelDtos,equipmentInfoForm, selectedOrgInfo);
return Boolean.TRUE;
}
......@@ -1937,76 +1972,89 @@ public class DataDockServiceImpl {
@Transactional(rollbackFor = Exception.class)
public Object savePipingData(Map<String, Object> paramMap, CompanyBo company) {
// 获取数据
JSONObject equipInfo = JSON.parseObject(toJSONString(paramMap.get("equipInfo")), JSONObject.class);
JSONObject attachmentUpload = JSON.parseObject(toJSONString(paramMap.get("attachmentUpload")), JSONObject.class);
JSONArray equListsJSONArr = JSONArray.parseArray(toJSONString(attachmentUpload.get("equLists")));
List<PipingExcelDto> equLists = equListsJSONArr.toJavaList(PipingExcelDto.class);
for (int i = 0; i < equLists.size(); i++) {
PipingExcelDto equ = equLists.get(i);
JSONObject equJson = JSON.parseObject(toJSONString(equListsJSONArr.get(i)));
JSONArray fileDataArray = equJson.getJSONArray("fileData");
if (fileDataArray == null || fileDataArray.isEmpty()) {
continue;
}
for (Object arr : fileDataArray) {
JSONObject fileData = JSON.parseObject(toJSONString(arr));
if (ValidationUtil.isEmpty(fileData) || !"inspectReport".equals(fileData.getString("key"))) {
List<String> records = new ArrayList<>();
try {
JSONObject equipInfo = JSON.parseObject(toJSONString(paramMap.get("equipInfo")), JSONObject.class);
JSONObject attachmentUpload = JSON.parseObject(toJSONString(paramMap.get("attachmentUpload")), JSONObject.class);
JSONArray equListsJSONArr = JSONArray.parseArray(toJSONString(attachmentUpload.get("equLists")));
List<PipingExcelDto> equLists = equListsJSONArr.toJavaList(PipingExcelDto.class);
for (int i = 0; i < equLists.size(); i++) {
PipingExcelDto equ = equLists.get(i);
JSONObject equJson = JSON.parseObject(toJSONString(equListsJSONArr.get(i)));
JSONArray fileDataArray = equJson.getJSONArray("fileData");
if (fileDataArray == null || fileDataArray.isEmpty()) {
continue;
}
JSONArray value = fileData.getJSONArray("value");
if (value != null) {
equ.setInspectReport(value.toJSONString());
for (Object arr : fileDataArray) {
JSONObject fileData = JSON.parseObject(toJSONString(arr));
if (ValidationUtil.isEmpty(fileData) || !"inspectReport".equals(fileData.getString("key"))) {
continue;
}
JSONArray value = fileData.getJSONArray("value");
if (value != null) {
equ.setInspectReport(value.toJSONString());
}
}
}
}
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
// 监管——历史——管道——批量
String dataSource = "jg_his_gd_pl";
// 公共参数提取
EquipRequestParamsDto paramsDto = this.extractCommonData(dataSource, reginParams, equipInfo, equLists);
// 是否工业管道
boolean isGYGD = "8300".equals(paramsDto.getEquCategoryCode());
boolean haveUseRegistration = false;
// 确保使用登记证和工程装置在该单位下都是不存在的,方可导入数据
if (isGYGD) {
haveUseRegistration = this.checkTheUnitRegManageAlreadyExists(paramsDto, haveUseRegistration);
}
idxBizJgProjectContraptionServiceImpl.checkTheUnitProConMatching(paramsDto);
this.checkTheUnitProConAlreadyExists(paramsDto);
// 生成工程装置表信息
IdxBizJgProjectContraption proCon = this.saveProjectContraption(paramsDto);
// 保存管道对应的idx表数据
List<String> records = this.savePipInfoToIdxTables(equLists, paramsDto, proCon);
if (isGYGD) {
// 生成使用登记表信息 + 设备关系表 + 历史表
JgUseRegistration useReg = this.saveUseRegAndEq(paramsDto, records, proCon);
// 生成使用登记证表数据
if (!haveUseRegistration) {
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);
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
// 监管——历史——管道——批量
String dataSource = "jg_his_gd_pl";
// 公共参数提取
EquipRequestParamsDto paramsDto = this.extractCommonData(dataSource, reginParams, equipInfo, equLists);
// 是否工业管道
boolean isGYGD = "8300".equals(paramsDto.getEquCategoryCode());
boolean haveUseRegistration = false;
// 确保使用登记证和工程装置在该单位下都是不存在的,方可导入数据
if (isGYGD) {
haveUseRegistration = this.checkTheUnitRegManageAlreadyExists(paramsDto, haveUseRegistration);
}
idxBizJgProjectContraptionServiceImpl.checkTheUnitProConMatching(paramsDto);
this.checkTheUnitProConAlreadyExists(paramsDto);
// 生成工程装置表信息
IdxBizJgProjectContraption proCon = this.saveProjectContraption(paramsDto);
// 保存管道对应的idx表数据
records = this.savePipInfoToIdxTables(equLists, paramsDto, proCon);
if (isGYGD) {
// 生成使用登记表信息 + 设备关系表 + 历史表
JgUseRegistration useReg = this.saveUseRegAndEq(paramsDto, records, proCon);
// 生成使用登记证表数据
if (!haveUseRegistration) {
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);
}
}
}
this.createResumePipeline(proCon.getSequenceNbr(), String.format(pipelineRoutePath, proCon.getSequenceNbr() + ""), company);
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_PROJECT.name(), Sets.newHashSet(proCon.getSequenceNbr() + ""), EquipCreateOrEditEvent.EquipType.project));
return Boolean.TRUE;
} catch (Exception e) {
if(!records.isEmpty()){
List<ESEquipmentCategoryDto> dtoList = records.stream().map(record->{
ESEquipmentCategoryDto equipmentCategoryDto = new ESEquipmentCategoryDto();
equipmentCategoryDto.setSEQUENCE_NBR(record);
return equipmentCategoryDto;
}).collect(Collectors.toList());
esEquipmentCategory.deleteAll(dtoList);
}
throw e;
}
this.createResumePipeline(proCon.getSequenceNbr(), String.format(pipelineRoutePath, proCon.getSequenceNbr() + ""), company);
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_PROJECT.name(), Sets.newHashSet(proCon.getSequenceNbr() + ""), EquipCreateOrEditEvent.EquipType.project));
return Boolean.TRUE;
}
private void createResumePipeline(Long sequenceNbr, String routePath, CompanyBo company) {
......@@ -2106,6 +2154,9 @@ public class DataDockServiceImpl {
AgencyUserModel userModel = reginParams.getUserModel();
CompanyBo company = reginParams.getCompany();
String orgBranchCode = equipInfo.getString("orgBranchCode");
HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(orgBranchCode).getResult();
// 目前平台返回key为compnay(存在拼写错误)
CompanyModel parentModel = JSON.parseObject(toJSONString(parentMessage.get("compnay")), CompanyModel.class);
String equListCode = Objects.toString(equipInfo.get("EQU_LIST"), null);
String equCategoryCode = Objects.toString(equipInfo.get("EQU_CATEGORY"), null);
String equDefineCode = Objects.toString(equipInfo.get("EQU_DEFINE"), null);
......@@ -2169,7 +2220,8 @@ public class DataDockServiceImpl {
.setStartLatitudeLongitude(toJSONString(equipInfo.get("startLatitudeLongitude")))
.setEndLatitudeLongitude(toJSONString(equipInfo.get("endLatitudeLongitude")))
.setEquState(equState)
.setEquCode(installationNoticeService.generateEquCode(equListCode, equCategoryCode, equDefineCode, new Date(), _receiveCompanyCode));
.setEquCode(installationNoticeService.generateEquCode(equListCode, equCategoryCode, equDefineCode, new Date(), _receiveCompanyCode))
.setOrgCompanyCode(parentModel.getCompanyCode());
}
/**
......@@ -2311,10 +2363,8 @@ public class DataDockServiceImpl {
supervisionInfo.setRecord(record);
supervisionInfo.setOrgBranchCode(paramsDto.getOrgBranchCode());
supervisionInfo.setOrgBranchName(paramsDto.getOrgBranchName());
HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(paramsDto.getOrgBranchCode()).getResult();
// 目前平台返回key为compnay(存在拼写错误)
CompanyModel parentModel = JSON.parseObject(toJSONString(parentMessage.get("compnay")), CompanyModel.class);
supervisionInfo.setCompanyOrgBranchCode(parentModel.getCompanyCode());
supervisionInfo.setCompanyOrgBranchCode(paramsDto.getOrgCompanyCode());
supervisionInfo.setRecDate(new Date());
supervisionInfo.setSequenceNbr(null);
supervisionInfoList.add(supervisionInfo);
......@@ -2672,8 +2722,6 @@ public class DataDockServiceImpl {
* @param equLists 数据集
* @return 保存结果
*/
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public Set<String> saveElevatorData(List<Map<String, Object>> equLists) {
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
Set<String> recordSet = Sets.newConcurrentHashSet();
......
......@@ -19,7 +19,6 @@ public class ElevatorDataTransactionService {
}
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public Object saveSingleElevatorData(Map<String, Object> equ) {
return dataDockService.saveElevatorDataInTransaction(equ, "jg_his_xa", null);
}
......
......@@ -56,6 +56,7 @@ import com.yeejoin.amos.boot.module.ymt.api.dto.TzsUserInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl;
......@@ -4454,390 +4455,385 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
if (paramMap == null) {
throw new IllegalArgumentException("参数Map不能为空");
}
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
LinkedHashMap attachmentUpload = (LinkedHashMap) checkAndCast(paramMap.get(ATTACHMENT_UPLOAD));
EquipmentInfoDto equipInfoDto = this.createEquipmentInfoDto(equipmentInfoForm, jgVehicleInformationMapper);
// 登记证记录表主键
Long changeRecordId = sequence.nextId();
List<EquipInfoCylinderExcelDto> equipInfoCylinderExcelDtoList = JSON.parseArray(toJSONString(attachmentUpload.get(EQU_LISTS)), EquipInfoCylinderExcelDto.class);
// 属地监管部门
String orgBranchCode = equipInfoDto.getOrgBranchCode();
String orgBranchName = equipInfoDto.getOrgBranchName();
Set<String> recordSet = new HashSet<>();
List<DictionarieValueModel> fillingMedium = Systemctl.dictionarieClient.dictValues("FILLING_MEDIUM").getResult();
Map<String, Object> fillingMediumMap = fillingMedium.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataValue,
DictionarieValueModel::getDictDataKey));
Iterator<String> supervisoryCodeIterator;
if ("his".equals(equipInfoDto.getDataSource())) {
supervisoryCodeIterator = this
.getSupervisoryCodeBatch(equipInfoDto.getPossession(), equipInfoDto.getEquCategoryCode(), equipInfoCylinderExcelDtoList.size())
.iterator();
} else {
supervisoryCodeIterator = Collections.emptyIterator();
}
equipInfoCylinderExcelDtoList.forEach(data -> {
JgUseRegistrationEq jgRelationEquip = new JgUseRegistrationEq();
if ("his".equals(equipInfoDto.getDataSource()) && "1".equals(data.getWhetherVehicleCylinder())) {
throw new BadRequest("车用气瓶历史设备不能批量导入!");
}
if ("1".equals(data.getWhetherVehicleCylinder()) && !SPECIAL_CYLINDER.getCode().equals(equipInfoDto.getEquDefineCode())) {
throw new BadRequest("车用气瓶只能选择特种气瓶进行导入!");
}
try {
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
LinkedHashMap attachmentUpload = (LinkedHashMap) checkAndCast(paramMap.get(ATTACHMENT_UPLOAD));
EquipmentInfoDto equipInfoDto = this.createEquipmentInfoDto(equipmentInfoForm, jgVehicleInformationMapper);
// 登记证记录表主键
Long changeRecordId = sequence.nextId();
List<EquipInfoCylinderExcelDto> equipInfoCylinderExcelDtoList = JSON.parseArray(toJSONString(attachmentUpload.get(EQU_LISTS)), EquipInfoCylinderExcelDto.class);
// 属地监管部门
String orgBranchCode = equipInfoDto.getOrgBranchCode();
String orgBranchName = equipInfoDto.getOrgBranchName();
Set<String> recordSet = new HashSet<>();
List<DictionarieValueModel> fillingMedium = Systemctl.dictionarieClient.dictValues("FILLING_MEDIUM").getResult();
Map<String, Object> fillingMediumMap = fillingMedium.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataValue,
DictionarieValueModel::getDictDataKey));
Iterator<String> supervisoryCodeIterator;
if ("his".equals(equipInfoDto.getDataSource())) {
//使用登记证编号判断是否使用未来系统生成编号
this.checkUseRegistrationCode(equipInfoDto.getUseOrgCode(), "cylinder");
}
String record = UUID.randomUUID().toString();
recordSet.add(record);
jgRelationEquip.setEquId(record);
jgRelationEquip.setSequenceNbr(sequence.nextId());
jgRelationEquipList.add(jgRelationEquip);
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) (data.getFileData());
String productPhoto = getUrlByKey(fileDataList, "PRODUCT_PHOTO");
String otherAccessoriesReg = getUrlByKey(fileDataList, "OTHER_ACCESSORIES_REG");
String designDoc = getUrlByKey(fileDataList, "DESIGN_DOC");
String designStandard = getUrlByKey(fileDataList, "DESIGN_STANDARD");
String otherAccessoriesDes = getUrlByKey(fileDataList, "OTHER_ACCESSORIES_DES");
String productQualityYieldProve = getUrlByKey(fileDataList, "PRODUCT_QUALITY_YIELD_PROVE");
String factoryStandard = getUrlByKey(fileDataList, "FACTORY_STANDARD");
String insUseMaintainExplain = getUrlByKey(fileDataList, "INS_USE_MAINTAIN_EXPLAIN");
String otherAccessoriesFact = getUrlByKey(fileDataList, "OTHER_ACCESSORIES_FACT");
String factSupervisionInspectionReport = getUrlByKey(fileDataList, "FACT_SUPERVISION_INSPECTION_REPORT");
// 使用信息
IdxBizJgUseInfo useInfo = new IdxBizJgUseInfo();
BeanUtils.copyProperties(data, useInfo);
useInfo.setRecord(record);
useInfo.setRecDate(new Date());
useInfo.setCreateDate(new Date());
String source = equipInfoDto.getDataSource();
useInfo.setDataSource("his".equals(source) ? "jg_his_pl" : "black".equals(source) ? "jg_his_black_pl" : "jg_pl");// 区分历史设备和新增设备
useInfo.setIsIntoManagement("his".equals(equipInfoDto.getDataSource()));// 历史气瓶导入为已纳管设备
// 历史气瓶导入设备状态为在用
String equState = "his".equals(equipInfoDto.getDataSource())
? (Optional.ofNullable(equipInfoDto.getEquState())
.filter(s -> !s.isEmpty())
.orElse(String.valueOf(EquipmentEnum.ZAIYONG.getCode())))
: String.valueOf(EquipmentEnum.WEIDENGJI.getCode());
useInfo.setEquState(equState);
useInfo.setDataQualityScore(StringUtils.isEmpty(equipInfoDto.getUseOrgCode()) ? 3 : 1);
// 使用单位信息
if ("个人主体".equals(company.getCompanyType())) {
useInfo.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]);
useInfo.setUseUnitName(company.getCompanyName().split("_")[1]);
supervisoryCodeIterator = this
.getSupervisoryCodeBatch(equipInfoDto.getPossession(), equipInfoDto.getEquCategoryCode(), equipInfoCylinderExcelDtoList.size())
.iterator();
} else {
useInfo.setUseUnitCreditCode(company.getCompanyCode());
useInfo.setUseUnitName(company.getCompanyName());
supervisoryCodeIterator = Collections.emptyIterator();
}
useInfoList.add(useInfo);
// 设计信息
IdxBizJgDesignInfo designInfo = new IdxBizJgDesignInfo();
BeanUtils.copyProperties(data, designInfo);
designInfo.setRecord(record);
designInfo.setRecDate(new Date());
if (data.getDesignDate() != null) {
designInfo.setDesignDate(DateUtil.parse(data.getDesignDate(), "yyyy-MM-dd"));
}
designInfo.setDesignDoc(designDoc);
designInfo.setDesignStandard(designStandard);
designInfo.setDesignIsComplete("2");
designInfo.setOtherAccessoriesDes(otherAccessoriesDes);
designInfoList.add(designInfo);
// 制造信息
IdxBizJgFactoryInfo factoryInfo = new IdxBizJgFactoryInfo();
BeanUtils.copyProperties(data, factoryInfo);
factoryInfo.setRecord(record);
factoryInfo.setRecDate(new Date());
factoryInfo.setProductQualityYieldProve(productQualityYieldProve);
factoryInfo.setFactoryStandard(factoryStandard);
factoryInfo.setInsUseMaintainExplain(insUseMaintainExplain);
factoryInfo.setOtherAccessoriesFact(otherAccessoriesFact);
factoryInfo.setFactSupervisionInspectionReport(factSupervisionInspectionReport);
Optional.ofNullable(data.getProduceDate())
.filter(s -> !s.trim().isEmpty())
.map(d -> DateUtil.parse(d, "yyyy-MM-dd"))
.ifPresent(factoryInfo::setProduceDate);
factoryInfo.setImported(Optional.ofNullable(data.getImported()).orElse("0"));
factoryInfo.setFactoryIsComplete("2");
factoryInfoList.add(factoryInfo);
// 注册登记
IdxBizJgRegisterInfo registerInfo = new IdxBizJgRegisterInfo();
BeanUtils.copyProperties(data, registerInfo);
registerInfo.setEquCode("2".equals(data.getEquCodeType()) ? "" : registerInfo.getEquCode());
registerInfo.setRecord(record);
registerInfo.setRecDate(new Date());
registerInfo.setEquCategory(equipInfoDto.getEquCategoryCode());
registerInfo.setEquDefine(equipInfoDto.getEquDefineCode());
registerInfo.setEquList(equipInfoDto.getEquListCode());
registerInfo.setRegisterState("his".equals(equipInfoDto.getDataSource()) ? "6045":"6046");
registerInfo.setProductPhoto(productPhoto);
registerInfo.setOtherAccessoriesReg(otherAccessoriesReg);
registerInfo.setUseOrgCode(equipInfoDto.getUseOrgCode());
registerInfo.setCylinderCategory(data.getCylinderCategory());
registerInfo.setInInspectionPeriod("1");
if ("his".equals(equipInfoDto.getDataSource())) {
registerInfo.setStatus("在用");
registerInfo.setEquCode(this.getEquCode(registerInfo, factoryInfo, equipInfoDto.getReceiveOrgCode()));
}
registerInfoList.add(registerInfo);
// 检验检测
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = new IdxBizJgInspectionDetectionInfo();
BeanUtils.copyProperties(data, inspectionDetectionInfo);
inspectionDetectionInfo.setInspectOrgCode(data.getInspectOrgCode());
inspectionDetectionInfo.setRecord(record);
inspectionDetectionInfo.setRecDate(new Date());
inspectionDetectionInfo.setInspectType("ZZJDJY");
inspectionDetectionInfo.setInspectConclusion("6040");// 默认合格
Optional.ofNullable(data.getInspectDate())
.filter(StrUtil::isNotBlank)
.map(s -> DateUtil.parse(s, "yyyy-MM-dd"))
.ifPresent(inspectionDetectionInfo::setInspectDate);
Optional.ofNullable(data.getNextInspectDate())
.filter(StrUtil::isNotBlank)
.map(s -> DateUtil.parse(s, "yyyy-MM-dd"))
.ifPresent(inspectionDetectionInfo::setNextInspectDate);
// 根据条件确定增加的年数(杨生元说监管让去掉,企业自己输入)
// Optional.ofNullable(data.getInspectDate())
// .filter(s -> !s.trim().isEmpty())
// .map(dateStr -> LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .ifPresent(inspectDate -> {
// inspectionDetectionInfo.setInspectDate(Date.from(inspectDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
// // 计算下次检测日期(加 3 年或 4 年)
// int plusYears = SPECIAL_CYLINDER.getCode().equals(equipInfoDto.getEquDefineCode()) ? 3 : 4;
// LocalDate nextInspectDate = inspectDate.plusYears(plusYears);
// inspectionDetectionInfo.setNextInspectDate(Date.from(nextInspectDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
// });
inspectionDetectionInfoList.add(inspectionDetectionInfo);
// 其他信息
String cylinderStampAttachment = getUrlByKey(fileDataList, "CYLINDER_STAMP_ATTACHMENT");
IdxBizJgOtherInfo otherInfo = new IdxBizJgOtherInfo();
BeanUtils.copyProperties(data, otherInfo);
otherInfo.setRecord(record);
otherInfo.setRecDate(new Date());
otherInfo.setCylinderStampAttachment(cylinderStampAttachment);
if ("his".equals(equipInfoDto.getDataSource())) {
otherInfo.setSupervisoryCode(supervisoryCodeIterator.next());
}
otherInfo.setClaimStatus("已认领");
otherInfoList.add(otherInfo);
equipInfoCylinderExcelDtoList.forEach(data -> {
JgUseRegistrationEq jgRelationEquip = new JgUseRegistrationEq();
if ("his".equals(equipInfoDto.getDataSource()) && "1".equals(data.getWhetherVehicleCylinder())) {
throw new BadRequest("车用气瓶历史设备不能批量导入!");
}
if ("1".equals(data.getWhetherVehicleCylinder()) && !SPECIAL_CYLINDER.getCode().equals(equipInfoDto.getEquDefineCode())) {
throw new BadRequest("车用气瓶只能选择特种气瓶进行导入!");
}
//监督管理信息
setSupervisionInfo(orgBranchCode, orgBranchName, record, supervisionInfoList);
if ("his".equals(equipInfoDto.getDataSource())) {
//使用登记证编号判断是否使用未来系统生成编号
this.checkUseRegistrationCode(equipInfoDto.getUseOrgCode(), "cylinder");
}
String record = UUID.randomUUID().toString();
recordSet.add(record);
jgRelationEquip.setEquId(record);
jgRelationEquip.setSequenceNbr(sequence.nextId());
jgRelationEquipList.add(jgRelationEquip);
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) (data.getFileData());
String productPhoto = getUrlByKey(fileDataList, "PRODUCT_PHOTO");
String otherAccessoriesReg = getUrlByKey(fileDataList, "OTHER_ACCESSORIES_REG");
String designDoc = getUrlByKey(fileDataList, "DESIGN_DOC");
String designStandard = getUrlByKey(fileDataList, "DESIGN_STANDARD");
String otherAccessoriesDes = getUrlByKey(fileDataList, "OTHER_ACCESSORIES_DES");
String productQualityYieldProve = getUrlByKey(fileDataList, "PRODUCT_QUALITY_YIELD_PROVE");
String factoryStandard = getUrlByKey(fileDataList, "FACTORY_STANDARD");
String insUseMaintainExplain = getUrlByKey(fileDataList, "INS_USE_MAINTAIN_EXPLAIN");
String otherAccessoriesFact = getUrlByKey(fileDataList, "OTHER_ACCESSORIES_FACT");
String factSupervisionInspectionReport = getUrlByKey(fileDataList, "FACT_SUPERVISION_INSPECTION_REPORT");
// 使用信息
IdxBizJgUseInfo useInfo = new IdxBizJgUseInfo();
BeanUtils.copyProperties(data, useInfo);
useInfo.setRecord(record);
useInfo.setRecDate(new Date());
useInfo.setCreateDate(new Date());
String source = equipInfoDto.getDataSource();
useInfo.setDataSource("his".equals(source) ? "jg_his_pl" : "black".equals(source) ? "jg_his_black_pl" : "jg_pl");// 区分历史设备和新增设备
useInfo.setIsIntoManagement("his".equals(equipInfoDto.getDataSource()));// 历史气瓶导入为已纳管设备
// 历史气瓶导入设备状态为在用
String equState = "his".equals(equipInfoDto.getDataSource())
? (Optional.ofNullable(equipInfoDto.getEquState())
.filter(s -> !s.isEmpty())
.orElse(String.valueOf(EquipmentEnum.ZAIYONG.getCode())))
: String.valueOf(EquipmentEnum.WEIDENGJI.getCode());
useInfo.setEquState(equState);
useInfo.setDataQualityScore(StringUtils.isEmpty(equipInfoDto.getUseOrgCode()) ? 3 : 1);
// 使用单位信息
if ("个人主体".equals(company.getCompanyType())) {
useInfo.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]);
useInfo.setUseUnitName(company.getCompanyName().split("_")[1]);
} else {
useInfo.setUseUnitCreditCode(company.getCompanyCode());
useInfo.setUseUnitName(company.getCompanyName());
}
useInfoList.add(useInfo);
// 设计信息
IdxBizJgDesignInfo designInfo = new IdxBizJgDesignInfo();
BeanUtils.copyProperties(data, designInfo);
designInfo.setRecord(record);
designInfo.setRecDate(new Date());
if (data.getDesignDate() != null) {
designInfo.setDesignDate(DateUtil.parse(data.getDesignDate(), "yyyy-MM-dd"));
}
designInfo.setDesignDoc(designDoc);
designInfo.setDesignStandard(designStandard);
designInfo.setDesignIsComplete("2");
designInfo.setOtherAccessoriesDes(otherAccessoriesDes);
designInfoList.add(designInfo);
// 制造信息
IdxBizJgFactoryInfo factoryInfo = new IdxBizJgFactoryInfo();
BeanUtils.copyProperties(data, factoryInfo);
factoryInfo.setRecord(record);
factoryInfo.setRecDate(new Date());
factoryInfo.setProductQualityYieldProve(productQualityYieldProve);
factoryInfo.setFactoryStandard(factoryStandard);
factoryInfo.setInsUseMaintainExplain(insUseMaintainExplain);
factoryInfo.setOtherAccessoriesFact(otherAccessoriesFact);
factoryInfo.setFactSupervisionInspectionReport(factSupervisionInspectionReport);
Optional.ofNullable(data.getProduceDate())
.filter(s -> !s.trim().isEmpty())
.map(d -> DateUtil.parse(d, "yyyy-MM-dd"))
.ifPresent(factoryInfo::setProduceDate);
factoryInfo.setImported(Optional.ofNullable(data.getImported()).orElse("0"));
factoryInfo.setFactoryIsComplete("2");
factoryInfoList.add(factoryInfo);
// 注册登记
IdxBizJgRegisterInfo registerInfo = new IdxBizJgRegisterInfo();
BeanUtils.copyProperties(data, registerInfo);
registerInfo.setEquCode("2".equals(data.getEquCodeType()) ? "" : registerInfo.getEquCode());
registerInfo.setRecord(record);
registerInfo.setRecDate(new Date());
registerInfo.setEquCategory(equipInfoDto.getEquCategoryCode());
registerInfo.setEquDefine(equipInfoDto.getEquDefineCode());
registerInfo.setEquList(equipInfoDto.getEquListCode());
registerInfo.setRegisterState("his".equals(equipInfoDto.getDataSource()) ? "6045":"6046");
registerInfo.setProductPhoto(productPhoto);
registerInfo.setOtherAccessoriesReg(otherAccessoriesReg);
registerInfo.setUseOrgCode(equipInfoDto.getUseOrgCode());
registerInfo.setCylinderCategory(data.getCylinderCategory());
registerInfo.setInInspectionPeriod("1");
if ("his".equals(equipInfoDto.getDataSource())) {
registerInfo.setStatus("在用");
registerInfo.setEquCode(this.getEquCode(registerInfo, factoryInfo, equipInfoDto.getReceiveOrgCode()));
}
registerInfoList.add(registerInfo);
// 技术参数
IdxBizJgTechParamsVessel paramsVessel = new IdxBizJgTechParamsVessel();
BeanUtils.copyProperties(data, paramsVessel);
paramsVessel.setRecord(record);
paramsVessel.setRecDate(new Date());
paramsVessel.setChargingMedium((String) fillingMediumMap.get(data.getChargingMedium()));
paramsVesselList.add(paramsVessel);
// 检验检测
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = new IdxBizJgInspectionDetectionInfo();
BeanUtils.copyProperties(data, inspectionDetectionInfo);
inspectionDetectionInfo.setInspectOrgCode(data.getInspectOrgCode());
inspectionDetectionInfo.setRecord(record);
inspectionDetectionInfo.setRecDate(new Date());
inspectionDetectionInfo.setInspectType("ZZJDJY");
inspectionDetectionInfo.setInspectConclusion("6040");// 默认合格
Optional.ofNullable(data.getInspectDate())
.filter(StrUtil::isNotBlank)
.map(s -> DateUtil.parse(s, "yyyy-MM-dd"))
.ifPresent(inspectionDetectionInfo::setInspectDate);
Optional.ofNullable(data.getNextInspectDate())
.filter(StrUtil::isNotBlank)
.map(s -> DateUtil.parse(s, "yyyy-MM-dd"))
.ifPresent(inspectionDetectionInfo::setNextInspectDate);
// 根据条件确定增加的年数(杨生元说监管让去掉,企业自己输入)
// Optional.ofNullable(data.getInspectDate())
// .filter(s -> !s.trim().isEmpty())
// .map(dateStr -> LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .ifPresent(inspectDate -> {
// inspectionDetectionInfo.setInspectDate(Date.from(inspectDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
// // 计算下次检测日期(加 3 年或 4 年)
// int plusYears = SPECIAL_CYLINDER.getCode().equals(equipInfoDto.getEquDefineCode()) ? 3 : 4;
// LocalDate nextInspectDate = inspectDate.plusYears(plusYears);
// inspectionDetectionInfo.setNextInspectDate(Date.from(nextInspectDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
// });
inspectionDetectionInfoList.add(inspectionDetectionInfo);
ESEquipmentCategoryDto esEquipmentDto = JSON.parseObject(toJSONString(data), ESEquipmentCategoryDto.class);
esEquipmentDto.setDATA_SOURCE(useInfo.getDataSource());
if (inspectionDetectionInfo.getNextInspectDate() != null) {
esEquipmentDto.setNEXT_INSPECT_DATE(inspectionDetectionInfo.getNextInspectDate().getTime());
}
esEquipmentDto.setCREATE_DATE(System.currentTimeMillis());
esEquipmentDto.setREC_DATE(System.currentTimeMillis());
esEquipmentDto.setSEQUENCE_NBR(record);
esEquipmentDto.setFACTORY_NUM(factoryInfo.getFactoryNum());
esEquipmentDto.setUSE_INNER_CODE(useInfo.getUseInnerCode());
esEquipmentDto.setUSE_ORG_CODE(equipInfoDto.getUseOrgCode());
esEquipmentDto.setIS_INTO_MANAGEMENT("his".equals(equipInfoDto.getDataSource()));
esEquipmentDto.setEQU_CODE(registerInfo.getEquCode());
esEquipmentDto.setEQU_CATEGORY_CODE(equipInfoDto.getEquCategoryCode());
esEquipmentDto.setEQU_CATEGORY(equipInfoDto.getEquCategory());
esEquipmentDto.setEQU_LIST_CODE(equipInfoDto.getEquListCode());
esEquipmentDto.setEQU_LIST(equipInfoDto.getEquList());
esEquipmentDto.setEQU_DEFINE_CODE(equipInfoDto.getEquDefineCode());
esEquipmentDto.setSUPERVISORY_CODE(otherInfo.getSupervisoryCode());
esEquipmentDto.setOrgBranchCode(orgBranchCode);
esEquipmentDto.setORG_BRANCH_NAME(orgBranchName);
esEquipmentDto.setEQU_DEFINE(equipInfoDto.getEquDefine());
esEquipmentDto.setINFORMATION_SITUATION(otherInfo.getInformationSituation());
esEquipmentDto.setSTATUS("已认领");
esEquipmentDto.setEQU_STATE(Integer.valueOf(equState));
// 其他信息
String cylinderStampAttachment = getUrlByKey(fileDataList, "CYLINDER_STAMP_ATTACHMENT");
IdxBizJgOtherInfo otherInfo = new IdxBizJgOtherInfo();
BeanUtils.copyProperties(data, otherInfo);
otherInfo.setRecord(record);
otherInfo.setRecDate(new Date());
otherInfo.setCylinderStampAttachment(cylinderStampAttachment);
if ("his".equals(equipInfoDto.getDataSource())) {
otherInfo.setSupervisoryCode(supervisoryCodeIterator.next());
}
otherInfo.setClaimStatus("已认领");
otherInfoList.add(otherInfo);
//监督管理信息
setSupervisionInfo(orgBranchCode, orgBranchName, record, supervisionInfoList);
// 技术参数
IdxBizJgTechParamsVessel paramsVessel = new IdxBizJgTechParamsVessel();
BeanUtils.copyProperties(data, paramsVessel);
paramsVessel.setRecord(record);
paramsVessel.setRecDate(new Date());
paramsVessel.setChargingMedium((String) fillingMediumMap.get(data.getChargingMedium()));
paramsVesselList.add(paramsVessel);
ESEquipmentCategoryDto esEquipmentDto = JSON.parseObject(toJSONString(data), ESEquipmentCategoryDto.class);
esEquipmentDto.setDATA_SOURCE(useInfo.getDataSource());
if (inspectionDetectionInfo.getNextInspectDate() != null) {
esEquipmentDto.setNEXT_INSPECT_DATE(inspectionDetectionInfo.getNextInspectDate().getTime());
}
esEquipmentDto.setCREATE_DATE(System.currentTimeMillis());
esEquipmentDto.setREC_DATE(System.currentTimeMillis());
esEquipmentDto.setSEQUENCE_NBR(record);
esEquipmentDto.setFACTORY_NUM(factoryInfo.getFactoryNum());
esEquipmentDto.setUSE_INNER_CODE(useInfo.getUseInnerCode());
esEquipmentDto.setUSE_ORG_CODE(equipInfoDto.getUseOrgCode());
esEquipmentDto.setIS_INTO_MANAGEMENT("his".equals(equipInfoDto.getDataSource()));
esEquipmentDto.setEQU_CODE(registerInfo.getEquCode());
esEquipmentDto.setEQU_CATEGORY_CODE(equipInfoDto.getEquCategoryCode());
esEquipmentDto.setEQU_CATEGORY(equipInfoDto.getEquCategory());
esEquipmentDto.setEQU_LIST_CODE(equipInfoDto.getEquListCode());
esEquipmentDto.setEQU_LIST(equipInfoDto.getEquList());
esEquipmentDto.setEQU_DEFINE_CODE(equipInfoDto.getEquDefineCode());
esEquipmentDto.setSUPERVISORY_CODE(otherInfo.getSupervisoryCode());
esEquipmentDto.setOrgBranchCode(orgBranchCode);
esEquipmentDto.setORG_BRANCH_NAME(orgBranchName);
esEquipmentDto.setEQU_DEFINE(equipInfoDto.getEquDefine());
esEquipmentDto.setINFORMATION_SITUATION(otherInfo.getInformationSituation());
esEquipmentDto.setSTATUS("已认领");
esEquipmentDto.setEQU_STATE(Integer.valueOf(equState));
// 使用单位信息
if ("个人主体".equals(company.getCompanyType())) {
esEquipmentDto.setUSE_UNIT_CREDIT_CODE(company.getCompanyCode().split("_")[1]);
esEquipmentDto.setUSE_UNIT_NAME(company.getCompanyName().split("_")[1]);
} else {
esEquipmentDto.setUSE_UNIT_CREDIT_CODE(company.getCompanyCode());
esEquipmentDto.setUSE_UNIT_NAME(company.getCompanyName());
}
esEquipmentCategoryList.add(esEquipmentDto);
if ("his".equals(equipInfoDto.getDataSource())) {
// 生成tzs_jg_certificate_change_record_eq记录
JgCertificateChangeRecordEq changeRecordEq = new JgCertificateChangeRecordEq();
changeRecordEq.setChangeRecordId(String.valueOf(changeRecordId));// 登记证记录主键
changeRecordEq.setEquId(registerInfo.getRecord());// 设备主键
changeRecordEq.setProductCode(factoryInfo.getFactoryNum());// 产品编号
jgCertificateChangeRecordEqList.add(changeRecordEq);
}
String nextInspectDateStr = Optional.ofNullable(inspectionDetectionInfo.getNextInspectDate())
.map(date -> date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.orElse(null);
Map<String, Object> equipMap = MapBuilder.<String, Object>create()
.put("factoryNum", factoryInfo.getFactoryNum())
.put("chargingMedium", data.getChargingMedium())
.put("productName", data.getProductName())
.put("produceUnitName", factoryInfo.getProduceUnitName())
.put("produceDate", esEquipmentDto.getPRODUCE_DATE())
.put("nominalWorkingPressure", data.getNominalWorkingPressure())
.put("singleBottleVolume", data.getSingleBottleVolume())
.put("inspectDate", data.getInspectDate())
.put("equList", equipInfoDto.getEquListCode())
.put("equListName", equipInfoDto.getEquList())
.put("equCategory", equipInfoDto.getEquCategoryCode())
.put("equCategoryName", equipInfoDto.getEquCategory())
.put("equDefine", equipInfoDto.getEquDefineCode())
.put("equDefineName", equipInfoDto.getEquDefine())
.put("manageType", "unit")
.put("record", esEquipmentDto.getSEQUENCE_NBR())
.put("nextInspectDate", nextInspectDateStr)
.put("useInnerCode", useInfo.getUseInnerCode())
.put("informationSituation", data.getInformationSituation())
.put("dataSource", useInfo.getDataSource())
.build();
equipmentLists.add(equipMap);
});
// 使用单位信息
if ("个人主体".equals(company.getCompanyType())) {
esEquipmentDto.setUSE_UNIT_CREDIT_CODE(company.getCompanyCode().split("_")[1]);
esEquipmentDto.setUSE_UNIT_NAME(company.getCompanyName().split("_")[1]);
} else {
esEquipmentDto.setUSE_UNIT_CREDIT_CODE(company.getCompanyCode());
esEquipmentDto.setUSE_UNIT_NAME(company.getCompanyName());
}
esEquipmentCategoryList.add(esEquipmentDto);
if ("his".equals(equipInfoDto.getDataSource())) {
// 生成tzs_jg_certificate_change_record_eq记录
JgCertificateChangeRecordEq changeRecordEq = new JgCertificateChangeRecordEq();
changeRecordEq.setChangeRecordId(String.valueOf(changeRecordId));// 登记证记录主键
changeRecordEq.setEquId(registerInfo.getRecord());// 设备主键
changeRecordEq.setProductCode(factoryInfo.getFactoryNum());// 产品编号
jgCertificateChangeRecordEqList.add(changeRecordEq);
}
String nextInspectDateStr = Optional.ofNullable(inspectionDetectionInfo.getNextInspectDate())
.map(date -> date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.orElse(null);
Map<String, Object> equipMap = MapBuilder.<String, Object>create()
.put("factoryNum", factoryInfo.getFactoryNum())
.put("chargingMedium", data.getChargingMedium())
.put("productName", data.getProductName())
.put("produceUnitName", factoryInfo.getProduceUnitName())
.put("produceDate", esEquipmentDto.getPRODUCE_DATE())
.put("nominalWorkingPressure", data.getNominalWorkingPressure())
.put("singleBottleVolume", data.getSingleBottleVolume())
.put("inspectDate", data.getInspectDate())
.put("equList", equipInfoDto.getEquListCode())
.put("equListName", equipInfoDto.getEquList())
.put("equCategory", equipInfoDto.getEquCategoryCode())
.put("equCategoryName", equipInfoDto.getEquCategory())
.put("equDefine", equipInfoDto.getEquDefineCode())
.put("equDefineName", equipInfoDto.getEquDefine())
.put("manageType", "unit")
.put("record", esEquipmentDto.getSEQUENCE_NBR())
.put("nextInspectDate", nextInspectDateStr)
.put("useInnerCode", useInfo.getUseInnerCode())
.put("informationSituation", data.getInformationSituation())
.put("dataSource", useInfo.getDataSource())
.build();
equipmentLists.add(equipMap);
});
if ("his".equals(equipInfoDto.getDataSource())) {
// 生成证书管理表记录
LambdaQueryWrapper<JgUseRegistrationManage> queryWrapper = new LambdaQueryWrapper<JgUseRegistrationManage>()
.eq(JgUseRegistrationManage::getUseRegistrationCode, equipInfoDto.getUseOrgCode())
.eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus, "已登记");
JgUseRegistrationManage jgUseRegistrationManage = jgUseRegistrationManageService.getBaseMapper().selectOne(queryWrapper);
// 使用登记信息
JgUseRegistration jgUseRegistration = new JgUseRegistration();
//历史增补
if (!ValidationUtil.isEmpty(jgUseRegistrationManage)) {
jgUseRegistration.setIsAddEquip("1");
if (jgUseRegistrationManage.getUseUnitCreditCode().equals(company.getCompanyCode())) {
jgUseRegistrationManage.setAuditPassDate(new Date());
jgUseRegistrationManage.setRegDate(new Date());
jgUseRegistrationManage.setManageType("unit");
jgUseRegistrationManage.setApplyNo(this.getApplicationNo());
jgUseRegistrationManage.setUseUnitCreditCode(company.getCompanyCode());
if(!equipInfoDto.getReceiveOrgName().equals(jgUseRegistrationManage.getReceiveOrgName()) || company.getCompanyName().equals(jgUseRegistrationManage.getUseUnitName())){
jgUseRegistrationManage.setVersion(jgUseRegistrationManage.getVersion() + 1);
jgUseRegistrationManage.setChangeReason(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName());
// 生成证书管理表记录
LambdaQueryWrapper<JgUseRegistrationManage> queryWrapper = new LambdaQueryWrapper<JgUseRegistrationManage>()
.eq(JgUseRegistrationManage::getUseRegistrationCode, equipInfoDto.getUseOrgCode())
.eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus, "已登记");
JgUseRegistrationManage jgUseRegistrationManage = jgUseRegistrationManageService.getBaseMapper().selectOne(queryWrapper);
// 使用登记信息
JgUseRegistration jgUseRegistration = new JgUseRegistration();
//历史增补
if (!ValidationUtil.isEmpty(jgUseRegistrationManage)) {
jgUseRegistration.setIsAddEquip("1");
if (jgUseRegistrationManage.getUseUnitCreditCode().equals(company.getCompanyCode())) {
jgUseRegistrationManage.setAuditPassDate(new Date());
jgUseRegistrationManage.setRegDate(new Date());
jgUseRegistrationManage.setManageType("unit");
jgUseRegistrationManage.setApplyNo(this.getApplicationNo());
jgUseRegistrationManage.setUseUnitCreditCode(company.getCompanyCode());
if(!equipInfoDto.getReceiveOrgName().equals(jgUseRegistrationManage.getReceiveOrgName()) || company.getCompanyName().equals(jgUseRegistrationManage.getUseUnitName())){
jgUseRegistrationManage.setVersion(jgUseRegistrationManage.getVersion() + 1);
jgUseRegistrationManage.setChangeReason(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName());
}
jgUseRegistrationManage.setUseUnitName(company.getCompanyName());
jgUseRegistrationManage.setReceiveOrgName(equipInfoDto.getReceiveOrgName());
jgUseRegistrationManage.setReceiveCompanyCode(equipInfoDto.getReceiveOrgCode());
jgUseRegistrationManage.setSuperviseOrgName(orgBranchName);
jgUseRegistrationManage.setSuperviseOrgCode(orgBranchCode);
jgUseRegistrationManageService.updateById(jgUseRegistrationManage);
} else {
throw new BadRequest("该使用登记证编号系统已存在,请核对使用登记证编号后,重新上传!");
}
jgUseRegistrationManage.setUseUnitName(company.getCompanyName());
jgUseRegistrationManage.setReceiveOrgName(equipInfoDto.getReceiveOrgName());
jgUseRegistrationManage.setReceiveCompanyCode(equipInfoDto.getReceiveOrgCode());
jgUseRegistrationManage.setSuperviseOrgName(orgBranchName);
jgUseRegistrationManage.setSuperviseOrgCode(orgBranchCode);
jgUseRegistrationManageService.updateById(jgUseRegistrationManage);
} else {
throw new BadRequest("该使用登记证编号系统已存在,请核对使用登记证编号后,重新上传!");
jgUseRegistration.setIsAddEquip("0");
jgUseRegistrationManage = this.saveRegistrationManage(equipInfoDto, company, orgBranchCode, orgBranchName);
}
// 生成一条tzs_jg_certificate_change_record记录
generateCertificateChangeRecord(jgUseRegistrationManage, changeRecordId);
jgUseRegistration.setRegDate(new Date());
jgUseRegistration.setReceiveCompanyCode(equipInfoDto.getReceiveOrgCode());
jgUseRegistration.setReceiveOrgName(equipInfoDto.getReceiveOrgName());
jgUseRegistration.setManageType("unit");
jgUseRegistration.setCylinderCategory(registerInfoList.get(0).getCylinderCategory());
jgUseRegistration.setReceiveCompanyOrgCode(commonService.getOneCompany(jgUseRegistration.getReceiveCompanyCode()).getOrgCode());
//使用单位提交
jgUseRegistration.setUseUnitName(CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType()) ?
company.getCompanyName().split("_")[1] : company.getCompanyName());
jgUseRegistration.setUseUnitCreditCode(CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType()) ?
company.getCompanyCode().split("_")[1] : company.getCompanyCode());
jgUseRegistration.setCreateUserId(reginParams.getUserModel().getUserId());
jgUseRegistration.setCreateUserName(reginParams.getUserModel().getRealName());
jgUseRegistration.setApplyNo(jgUseRegistrationManage.getApplyNo());
jgUseRegistration.setAuditPassDate(new Date());
jgUseRegistration.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
jgUseRegistration.setStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
jgUseRegistration.setUseRegistrationCode(jgUseRegistrationManage.getUseRegistrationCode());
jgUseRegistration.setRegType("1");//历史登记
jgUseRegistration.setSupervisionOrgCode(orgBranchCode);
jgUseRegistration.setCreateDate(new Date());
jgUseRegistrationService.save(jgUseRegistration);
jgRelationEquipMapper.batchInsert(String.valueOf(jgUseRegistration.getSequenceNbr()), jgRelationEquipList);
JSONObject objectHashMap = new JSONObject();
BeanUtil.beanToMap(jgUseRegistration, objectHashMap, false, false);
objectHashMap.put("equipmentLists", equipmentLists);
objectHashMap.put("EQU_CATEGORY_CODE", equipInfoDto.getEquCategoryCode());
objectHashMap.put("orgBranchCode", equipInfoDto.getOrgBranchCode());
updateHistory(objectHashMap, String.valueOf(jgUseRegistration.getSequenceNbr()));
String routePath = this.buildTaskModel(jgUseRegistration, equipInfoDto.getEquListCode());
jgResumeInfoService.saveBatchResume(
equipmentLists.stream()
.map(equipId -> JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName())
.businessId(String.valueOf(jgUseRegistration.getSequenceNbr()))
.equId(String.valueOf(equipId.get("record")))
.approvalUnit(jgUseRegistration.getReceiveOrgName())
.approvalUnitCode(jgUseRegistration.getReceiveCompanyCode())
.status("正常")
.changeContent(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName() + "业务办理")
.routePath(routePath)
.build())
.collect(Collectors.toList())
);
} else {
jgUseRegistration.setIsAddEquip("0");
jgUseRegistrationManage = this.saveRegistrationManage(equipInfoDto, company, orgBranchCode, orgBranchName);
}
// 生成一条tzs_jg_certificate_change_record记录
generateCertificateChangeRecord(jgUseRegistrationManage, changeRecordId);
jgUseRegistration.setRegDate(new Date());
jgUseRegistration.setReceiveCompanyCode(equipInfoDto.getReceiveOrgCode());
jgUseRegistration.setReceiveOrgName(equipInfoDto.getReceiveOrgName());
jgUseRegistration.setManageType("unit");
jgUseRegistration.setCylinderCategory(registerInfoList.get(0).getCylinderCategory());
jgUseRegistration.setReceiveCompanyOrgCode(commonService.getOneCompany(jgUseRegistration.getReceiveCompanyCode()).getOrgCode());
//使用单位提交
jgUseRegistration.setUseUnitName(CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType()) ?
company.getCompanyName().split("_")[1] : company.getCompanyName());
jgUseRegistration.setUseUnitCreditCode(CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType()) ?
company.getCompanyCode().split("_")[1] : company.getCompanyCode());
jgUseRegistration.setCreateUserId(reginParams.getUserModel().getUserId());
jgUseRegistration.setCreateUserName(reginParams.getUserModel().getRealName());
jgUseRegistration.setApplyNo(jgUseRegistrationManage.getApplyNo());
jgUseRegistration.setAuditPassDate(new Date());
jgUseRegistration.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
jgUseRegistration.setStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
jgUseRegistration.setUseRegistrationCode(jgUseRegistrationManage.getUseRegistrationCode());
jgUseRegistration.setRegType("1");//历史登记
jgUseRegistration.setSupervisionOrgCode(orgBranchCode);
jgUseRegistration.setCreateDate(new Date());
jgUseRegistrationService.save(jgUseRegistration);
jgRelationEquipMapper.batchInsert(String.valueOf(jgUseRegistration.getSequenceNbr()), jgRelationEquipList);
JSONObject objectHashMap = new JSONObject();
BeanUtil.beanToMap(jgUseRegistration, objectHashMap, false, false);
objectHashMap.put("equipmentLists", equipmentLists);
objectHashMap.put("EQU_CATEGORY_CODE", equipInfoDto.getEquCategoryCode());
objectHashMap.put("orgBranchCode", equipInfoDto.getOrgBranchCode());
updateHistory(objectHashMap, String.valueOf(jgUseRegistration.getSequenceNbr()));
String routePath = this.buildTaskModel(jgUseRegistration, equipInfoDto.getEquListCode());
jgResumeInfoService.saveBatchResume(
equipmentLists.stream()
.map(equipId -> JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName())
.businessId(String.valueOf(jgUseRegistration.getSequenceNbr()))
.equId(String.valueOf(equipId.get("record")))
.approvalUnit(jgUseRegistration.getReceiveOrgName())
.approvalUnitCode(jgUseRegistration.getReceiveCompanyCode())
.status("正常")
.changeContent(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName() + "业务办理")
.routePath(routePath)
.build())
.collect(Collectors.toList())
);
} else {
jgResumeInfoService.saveBatchResume(
equipmentLists.stream()
.map(equipId -> JgResumeInfoDto.builder()
.businessType(BusinessTypeEnum.JG_NEW_EQUIP.getName())
.businessId(String.valueOf(equipId.get("record")))
.equId(String.valueOf(equipId.get("record")))
.approvalUnit(reginParams.getCompany().getCompanyName())
.approvalUnitCode(reginParams.getCompany().getCompanyCode())
.status("正常")
.changeContent(BusinessTypeEnum.JG_NEW_EQUIP.getName() + "业务办理")
.routePath(String.format(equipRoutePath, equipId.get("record"), equipId.get("dataSource")))
.build())
.collect(Collectors.toList())
);
}
batchInsert(idxBizJgUseInfoMapper, useInfoList, "使用信息");
batchInsert(idxBizJgRegisterInfoMapper, registerInfoList, "注册信息");
batchInsert(idxBizJgSupervisionInfoMapper, supervisionInfoList, "监督信息");
batchInsert(idxBizJgDesignInfoMapper, designInfoList, "设计信息");
batchInsert(idxBizJgFactoryInfoMapper, factoryInfoList, "制造信息");
batchInsert(otherInfoMapper, otherInfoList, "其他信息");
batchInsert(idxBizJgTechParamsVesselMapper, paramsVesselList, "容器参数信息");
batchInsert(idxBizJgInspectionDetectionInfoMapper, inspectionDetectionInfoList, "检验检测信息");
batchInsert(certificateChangeRecordEqMapper, jgCertificateChangeRecordEqList, "登记证关系信息");
esEquipmentCategory.saveAll(esEquipmentCategoryList);
// 使用事务同步回调确保事件在事务提交后发送
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(
new EquipCreateOrEditEvent(
this,
BusinessTypeEnum.JG_NEW_EQUIP.name(),
recordSet,
EquipCreateOrEditEvent.EquipType.equip
)
jgResumeInfoService.saveBatchResume(
equipmentLists.stream()
.map(equipId -> JgResumeInfoDto.builder()
.businessType(BusinessTypeEnum.JG_NEW_EQUIP.getName())
.businessId(String.valueOf(equipId.get("record")))
.equId(String.valueOf(equipId.get("record")))
.approvalUnit(reginParams.getCompany().getCompanyName())
.approvalUnitCode(reginParams.getCompany().getCompanyCode())
.status("正常")
.changeContent(BusinessTypeEnum.JG_NEW_EQUIP.getName() + "业务办理")
.routePath(String.format(equipRoutePath, equipId.get("record"), equipId.get("dataSource")))
.build())
.collect(Collectors.toList())
);
}
});
batchInsert(idxBizJgUseInfoMapper, useInfoList, "使用信息");
batchInsert(idxBizJgRegisterInfoMapper, registerInfoList, "注册信息");
batchInsert(idxBizJgSupervisionInfoMapper, supervisionInfoList, "监督信息");
batchInsert(idxBizJgDesignInfoMapper, designInfoList, "设计信息");
batchInsert(idxBizJgFactoryInfoMapper, factoryInfoList, "制造信息");
batchInsert(otherInfoMapper, otherInfoList, "其他信息");
batchInsert(idxBizJgTechParamsVesselMapper, paramsVesselList, "容器参数信息");
batchInsert(idxBizJgInspectionDetectionInfoMapper, inspectionDetectionInfoList, "检验检测信息");
batchInsert(certificateChangeRecordEqMapper, jgCertificateChangeRecordEqList, "登记证关系信息");
esEquipmentCategory.saveAll(esEquipmentCategoryList);
// 事务提交成功后,发送消息
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
} catch (Exception e) {
if(!esEquipmentCategoryList.isEmpty()){
esEquipmentCategory.deleteAll(esEquipmentCategoryList);
}
throw e;
}
return String.format("导入完成,成功导入: %d 条数据!", useInfoList.size());
}
......
......@@ -142,8 +142,6 @@
ibjui."REC_DATE",
ibjui."USE_UNIT_NAME",
ibjui."USE_UNIT_CREDIT_CODE",
ibjui."USC_UNIT_NAME",
ibjui."USC_UNIT_CREDIT_CODE",
ibjri."EQU_LIST" AS "EQU_LIST_CODE",
ibjri."EQU_DEFINE" AS "EQU_DEFINE_CODE",
ibjri."PRODUCT_NAME",
......@@ -185,7 +183,13 @@
ibjoi."INFORMATION_SITUATION",
di."DESIGN_UNIT_CREDIT_CODE",
di."DESIGN_UNIT_NAME",
di."DESIGN_DATE"
di."DESIGN_DATE",
construction_info."USC_UNIT_CREDIT_CODE",
construction_info."USC_UNIT_NAME",
construction_info."CONSTRUCTION_TYPE",
construction_info."USC_DATE",
inspection_info."INSPECT_REPORT",
inspection_info."NEXT_INSPECT_DATE"
FROM
idx_biz_jg_use_info ibjui
LEFT JOIN (
......
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