Commit 2c2fdba5 authored by suhuiguang's avatar suhuiguang

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

1.回滚时,删除设备
parent c51777bc
...@@ -27,6 +27,7 @@ public class EquipRequestParamsDto { ...@@ -27,6 +27,7 @@ public class EquipRequestParamsDto {
private String dataSource; private String dataSource;
private String orgBranchCode; private String orgBranchCode;
private String orgBranchName; private String orgBranchName;
private String orgCompanyCode;
private String useOrgCode; private String useOrgCode;
private String vehicleApanage; private String vehicleApanage;
private String receiveCompanyCode; private String receiveCompanyCode;
......
...@@ -39,7 +39,7 @@ public class DataDockController extends BaseController { ...@@ -39,7 +39,7 @@ public class DataDockController extends BaseController {
@PostMapping(value = "/xi-an/saveEquipmentData") @PostMapping(value = "/xi-an/saveEquipmentData")
@ApiOperation(httpMethod = "POST", value = "西安数据对接-设备批量导入", notes = "西安数据对接-导入多个设备的数据文件") @ApiOperation(httpMethod = "POST", value = "西安数据对接-设备批量导入", notes = "西安数据对接-导入多个设备的数据文件")
public ResponseModel<?> saveEquipmentData(@RequestBody List<Map<String, Object>> equLists) { 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) @TycloudOperation(ApiLevel = UserType.AGENCY)
...@@ -57,7 +57,7 @@ public class DataDockController extends BaseController { ...@@ -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))) { 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("文件类型必须是 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 { ...@@ -137,7 +137,7 @@ public class DataDockController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "台套类设备导入字段保存", notes = "台套类设备导入字段保存") @ApiOperation(httpMethod = "POST", value = "台套类设备导入字段保存", notes = "台套类设备导入字段保存")
@RestEventTrigger(value = "operateLogRestEventHandler") @RestEventTrigger(value = "operateLogRestEventHandler")
public ResponseModel<?> saveEquipImportData(@RequestBody Map<String, Object> paramMap) { 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 { ...@@ -190,32 +190,37 @@ public class DataDockServiceImpl {
/** /**
* 西安数据对接-保存设备信息 * 西安数据对接-保存设备信息
* *
* @param equLists 数据集 * @param equLists 数据集
* @param selectedOrgInfo
* @return 保存结果 * @return 保存结果
*/ */
public boolean xiAnSaveEquipmentData(List<Map<String, Object>> equLists) { @Transactional(rollbackFor = Exception.class)
RequestContextWrapper contextWrapper = RequestContextWrapper.capture(); public boolean xiAnSaveEquipmentData(List<Map<String, Object>> equLists, ReginParams selectedOrgInfo) {
Set<String> recordSet = new HashSet<>(); Set<String> recordSet = new HashSet<>();
CompletableFuture.allOf( try {
equLists.parallelStream().map(equ -> CompletableFuture.runAsync(() -> { equLists.forEach(equ ->{
contextWrapper.apply(); String record = saveEquipmentDataInTransaction(equ, "jg_his_xa", null, selectedOrgInfo);
String record = saveEquipmentDataInTransaction(equ, "jg_his_xa", null); recordSet.add(record);
recordSet.add(record); });
})).toArray(CompletableFuture[]::new) eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
).join(); return Boolean.TRUE;
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { } catch (Exception e) {
@Override if(!recordSet.isEmpty()) {
public void afterCommit() { List<ESEquipmentCategoryDto> dtoList = recordSet.stream().map(record->{
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip)); ESEquipmentCategoryDto dto = new ESEquipmentCategoryDto();
} dto.setSEQUENCE_NBR(record);
}); return dto;
return Boolean.TRUE; }).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) @Transactional(rollbackFor = Exception.class)
public String saveEquipmentDataInTransaction(Map<String, Object> equ, String dataSource, String remark) { public String saveEquipmentDataInTransaction(Map<String, Object> equ, String dataSource, String remark, ReginParams reginParams) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
String record = UUID.randomUUID().toString(); String record = UUID.randomUUID().toString();
try { try {
...@@ -657,6 +662,22 @@ public class DataDockServiceImpl { ...@@ -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 * @param equ
...@@ -684,22 +705,6 @@ public class DataDockServiceImpl { ...@@ -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 * @param equ
...@@ -866,10 +871,11 @@ public class DataDockServiceImpl { ...@@ -866,10 +871,11 @@ public class DataDockServiceImpl {
* 八大类历史设备导入 * 八大类历史设备导入
* *
* @param file * @param file
* @param selectedOrgInfo
* @return * @return
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Object dataCheckAndImportEquipmentData(String remark, MultipartFile file) { public Object dataCheckAndImportEquipmentData(String remark, MultipartFile file, ReginParams selectedOrgInfo) {
List<EquipInfoExcelDto> equipInfoExcelDtos; List<EquipInfoExcelDto> equipInfoExcelDtos;
try { try {
...@@ -880,7 +886,7 @@ public class DataDockServiceImpl { ...@@ -880,7 +886,7 @@ public class DataDockServiceImpl {
} }
// 2, 保存设备数据 // 2, 保存设备数据
this.batchSaveEquipmentData(remark, equipInfoExcelDtos); this.batchSaveEquipmentData(remark, equipInfoExcelDtos, selectedOrgInfo);
return Boolean.TRUE; return Boolean.TRUE;
} }
...@@ -1650,7 +1656,7 @@ public class DataDockServiceImpl { ...@@ -1650,7 +1656,7 @@ public class DataDockServiceImpl {
} }
@Transactional(rollbackFor = Exception.class) @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); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
String[] keys = { String[] keys = {
...@@ -1687,40 +1693,53 @@ public class DataDockServiceImpl { ...@@ -1687,40 +1693,53 @@ public class DataDockServiceImpl {
Set<String> projectContraptionSet = new HashSet<>(); Set<String> projectContraptionSet = new HashSet<>();
Map<String, Long> projectContraptionMap = new HashMap<>(); Map<String, Long> projectContraptionMap = new HashMap<>();
Set<String> projectContraptionIdSet = new HashSet<>(); Set<String> projectContraptionIdSet = new HashSet<>();
for (EquipInfoExcelDto equ : equipInfoExcelDtos) { try {
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData(); for (EquipInfoExcelDto equ : equipInfoExcelDtos) {
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class); List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
for (String key : keys) { Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class);
String camelKey = toCamelCase(key.toLowerCase()); for (String key : keys) {
equMap.put(camelKey, getUrlByKey(fileDataList, key)); String camelKey = toCamelCase(key.toLowerCase());
} equMap.put(camelKey, getUrlByKey(fileDataList, key));
equMap.put("orgBranchName", orgBranchName); }
equMap.put("orgBranchCode", orgBranchCode); equMap.put("orgBranchName", orgBranchName);
equMap.put("EQU_STATE", equipmentInfoForm.get("EQU_STATE")); equMap.put("orgBranchCode", orgBranchCode);
equMap.put("EQU_STATE", equipmentInfoForm.get("EQU_STATE"));
String projectContraptionNo = Objects.toString(equMap.get("projectContraptionNo"), "").trim();
Long projectContraptionId; String projectContraptionNo = Objects.toString(equMap.get("projectContraptionNo"), "").trim();
if (!projectContraptionSet.contains(projectContraptionNo)) { Long projectContraptionId;
projectContraptionId = this.saveProjectContraption(equMap, equList, company, dataSource); if (!projectContraptionSet.contains(projectContraptionNo)) {
projectContraptionSet.add(projectContraptionNo); projectContraptionId = this.saveProjectContraption(equMap, equList, company, dataSource);
projectContraptionMap.put(projectContraptionNo, projectContraptionId); projectContraptionSet.add(projectContraptionNo);
} else { projectContraptionMap.put(projectContraptionNo, projectContraptionId);
projectContraptionId = projectContraptionMap.get(projectContraptionNo); } 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) { if (EquipmentClassifityEnum.YLGD.getCode().equals(equList)) {
projectContraptionIdSet.add(String.valueOf(projectContraptionId)); this.updatePipelineLength(projectContraptionIdSet);
equMap.put("projectContraptionId", projectContraptionId); 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); } catch (Exception e) {
recordSet.add(record); if(!recordSet.isEmpty()) {
} List<ESEquipmentCategoryDto> dtoList = recordSet.stream().map(record->{
if (EquipmentClassifityEnum.YLGD.getCode().equals(equList)) { ESEquipmentCategoryDto dto = new ESEquipmentCategoryDto();
this.updatePipelineLength(projectContraptionIdSet); dto.setSEQUENCE_NBR(record);
this.createResumePipelineBatch(projectContraptionIdSet, String.format(pipelineRoutePath, projectContraptionIdSet), company); return dto;
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_PROJECT.name(), projectContraptionIdSet, EquipCreateOrEditEvent.EquipType.project)); }).collect(Collectors.toList());
}else{ esEquipmentCategory.deleteAll(dtoList);
this.createResumeBatch(recordSet,dataSource, equipRoutePath, company); log.warn("台套类设备导入字段保存-设备老索引数据回滚成功,删除数量:{}", dtoList.size());
eventPublisher.publish(new EquipCreateOrEditEvent(this,BusinessTypeEnum.JG_NEW_EQUIP.name(),recordSet, EquipCreateOrEditEvent.EquipType.equip)); }
throw new RuntimeException(e);
} }
} }
...@@ -1760,23 +1779,39 @@ public class DataDockServiceImpl { ...@@ -1760,23 +1779,39 @@ public class DataDockServiceImpl {
* 批量异步保存设备数据 * 批量异步保存设备数据
* *
* @param equipInfoExcelDtos * @param equipInfoExcelDtos
* @param selectedOrgInfo
*/ */
public void batchSaveEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos) { public void batchSaveEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos, ReginParams selectedOrgInfo) {
String[] keys = { String[] keys = {
"PRODUCT_PHOTO", "OTHER_ACCESSORIES_REG", "DESIGN_DOC", "DESIGN_STANDARD", "PRODUCT_PHOTO", "OTHER_ACCESSORIES_REG", "DESIGN_DOC", "DESIGN_STANDARD",
"OTHER_ACCESSORIES_DES", "PRODUCT_QUALITY_YIELD_PROVE", "FACTORY_STANDARD", "OTHER_ACCESSORIES_DES", "PRODUCT_QUALITY_YIELD_PROVE", "FACTORY_STANDARD",
"INS_USE_MAINTAIN_EXPLAIN", "OTHER_ACCESSORIES_FACT", "INS_USE_MAINTAIN_EXPLAIN", "OTHER_ACCESSORIES_FACT",
"BOILER_ENERGY_EFFICIENCY_CERTIFICATE", "FACT_SUPERVISION_INSPECTION_REPORT","INSPECT_REPORT" "BOILER_ENERGY_EFFICIENCY_CERTIFICATE", "FACT_SUPERVISION_INSPECTION_REPORT","INSPECT_REPORT"
}; };
Arrays.stream(equipInfoExcelDtos.toArray(new EquipInfoExcelDto[0])).forEach(equ -> { Set<String> recordSet = new HashSet<>();
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData(); try {
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class); equipInfoExcelDtos.forEach(equ -> {
for (String key : keys) { List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
String camelKey = toCamelCase(key.toLowerCase()); Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class);
equMap.put(camelKey, getUrlByKey(fileDataList, key)); for (String key : keys) {
} String camelKey = toCamelCase(key.toLowerCase());
this.saveEquipmentDataInTransaction(equMap, "jg_his", remark); 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) { private String getUrlByKey(List<Map<String, Object>> dataList, String key) {
...@@ -1913,7 +1948,7 @@ public class DataDockServiceImpl { ...@@ -1913,7 +1948,7 @@ public class DataDockServiceImpl {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Object saveEquipImportData(Map<String, Object> paramMap) { public Object saveEquipImportData(Map<String, Object> paramMap, ReginParams selectedOrgInfo) {
if (paramMap == null) { if (paramMap == null) {
throw new IllegalArgumentException("参数Map不能为空"); throw new IllegalArgumentException("参数Map不能为空");
} }
...@@ -1922,7 +1957,7 @@ public class DataDockServiceImpl { ...@@ -1922,7 +1957,7 @@ public class DataDockServiceImpl {
List<EquipInfoExcelDto> equipInfoExcelDtos = JSON.parseArray(toJSONString(attachmentUpload.get(EQU_LISTS)), EquipInfoExcelDto.class); List<EquipInfoExcelDto> equipInfoExcelDtos = JSON.parseArray(toJSONString(attachmentUpload.get(EQU_LISTS)), EquipInfoExcelDto.class);
// 2, 保存设备数据 // 2, 保存设备数据
this.batchSaveHisEquipmentData("", equipInfoExcelDtos,equipmentInfoForm); this.batchSaveHisEquipmentData("", equipInfoExcelDtos,equipmentInfoForm, selectedOrgInfo);
return Boolean.TRUE; return Boolean.TRUE;
} }
...@@ -1937,76 +1972,89 @@ public class DataDockServiceImpl { ...@@ -1937,76 +1972,89 @@ public class DataDockServiceImpl {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Object savePipingData(Map<String, Object> paramMap, CompanyBo company) { public Object savePipingData(Map<String, Object> paramMap, CompanyBo company) {
// 获取数据 // 获取数据
JSONObject equipInfo = JSON.parseObject(toJSONString(paramMap.get("equipInfo")), JSONObject.class); List<String> records = new ArrayList<>();
JSONObject attachmentUpload = JSON.parseObject(toJSONString(paramMap.get("attachmentUpload")), JSONObject.class); try {
JSONArray equListsJSONArr = JSONArray.parseArray(toJSONString(attachmentUpload.get("equLists"))); JSONObject equipInfo = JSON.parseObject(toJSONString(paramMap.get("equipInfo")), JSONObject.class);
List<PipingExcelDto> equLists = equListsJSONArr.toJavaList(PipingExcelDto.class); JSONObject attachmentUpload = JSON.parseObject(toJSONString(paramMap.get("attachmentUpload")), JSONObject.class);
for (int i = 0; i < equLists.size(); i++) { JSONArray equListsJSONArr = JSONArray.parseArray(toJSONString(attachmentUpload.get("equLists")));
PipingExcelDto equ = equLists.get(i); List<PipingExcelDto> equLists = equListsJSONArr.toJavaList(PipingExcelDto.class);
JSONObject equJson = JSON.parseObject(toJSONString(equListsJSONArr.get(i))); for (int i = 0; i < equLists.size(); i++) {
JSONArray fileDataArray = equJson.getJSONArray("fileData"); PipingExcelDto equ = equLists.get(i);
JSONObject equJson = JSON.parseObject(toJSONString(equListsJSONArr.get(i)));
if (fileDataArray == null || fileDataArray.isEmpty()) { JSONArray fileDataArray = equJson.getJSONArray("fileData");
continue;
} if (fileDataArray == null || fileDataArray.isEmpty()) {
for (Object arr : fileDataArray) {
JSONObject fileData = JSON.parseObject(toJSONString(arr));
if (ValidationUtil.isEmpty(fileData) || !"inspectReport".equals(fileData.getString("key"))) {
continue; continue;
} }
JSONArray value = fileData.getJSONArray("value");
if (value != null) { for (Object arr : fileDataArray) {
equ.setInspectReport(value.toJSONString()); 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);
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); // 监管——历史——管道——批量
// 监管——历史——管道——批量 String dataSource = "jg_his_gd_pl";
String dataSource = "jg_his_gd_pl"; // 公共参数提取
// 公共参数提取 EquipRequestParamsDto paramsDto = this.extractCommonData(dataSource, reginParams, equipInfo, equLists);
EquipRequestParamsDto paramsDto = this.extractCommonData(dataSource, reginParams, equipInfo, equLists); // 是否工业管道
// 是否工业管道 boolean isGYGD = "8300".equals(paramsDto.getEquCategoryCode());
boolean isGYGD = "8300".equals(paramsDto.getEquCategoryCode()); boolean haveUseRegistration = false;
boolean haveUseRegistration = false; // 确保使用登记证和工程装置在该单位下都是不存在的,方可导入数据
// 确保使用登记证和工程装置在该单位下都是不存在的,方可导入数据 if (isGYGD) {
if (isGYGD) { haveUseRegistration = this.checkTheUnitRegManageAlreadyExists(paramsDto, haveUseRegistration);
haveUseRegistration = this.checkTheUnitRegManageAlreadyExists(paramsDto, haveUseRegistration); }
} idxBizJgProjectContraptionServiceImpl.checkTheUnitProConMatching(paramsDto);
idxBizJgProjectContraptionServiceImpl.checkTheUnitProConMatching(paramsDto); this.checkTheUnitProConAlreadyExists(paramsDto);
this.checkTheUnitProConAlreadyExists(paramsDto); // 生成工程装置表信息
// 生成工程装置表信息 IdxBizJgProjectContraption proCon = this.saveProjectContraption(paramsDto);
IdxBizJgProjectContraption proCon = this.saveProjectContraption(paramsDto); // 保存管道对应的idx表数据
// 保存管道对应的idx表数据 records = this.savePipInfoToIdxTables(equLists, paramsDto, proCon);
List<String> records = this.savePipInfoToIdxTables(equLists, paramsDto, proCon); if (isGYGD) {
if (isGYGD) { // 生成使用登记表信息 + 设备关系表 + 历史表
// 生成使用登记表信息 + 设备关系表 + 历史表 JgUseRegistration useReg = this.saveUseRegAndEq(paramsDto, records, proCon);
JgUseRegistration useReg = this.saveUseRegAndEq(paramsDto, records, proCon); // 生成使用登记证表数据
// 生成使用登记证表数据 if (!haveUseRegistration) {
if (!haveUseRegistration) { JgUseRegistrationManage regManage = this.saveUseRegManage(paramsDto, useReg);
JgUseRegistrationManage regManage = this.saveUseRegManage(paramsDto, useReg); // 流水表
// 流水表 this.saveCertChangeRecord(useReg, regManage, records, paramsDto);
this.saveCertChangeRecord(useReg, regManage, records, paramsDto); } else {
} else { // 1.更新使用登记证信息
// 1.更新使用登记证信息 JgUseRegistrationManage jgUseRegistrationManage = jgUseRegistrationManageService.lambdaQuery()
JgUseRegistrationManage jgUseRegistrationManage = jgUseRegistrationManageService.lambdaQuery() .eq(JgUseRegistrationManage::getUseRegistrationCode, paramsDto.getUseOrgCode())
.eq(JgUseRegistrationManage::getUseRegistrationCode, paramsDto.getUseOrgCode()) .eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getIsDelete, 0) .one();
.one(); if (jgUseRegistrationManage != null) {
if (jgUseRegistrationManage != null) { jgUseRegistrationManage.setSuperviseOrgCode(paramsDto.getOrgBranchCode());
jgUseRegistrationManage.setSuperviseOrgCode(paramsDto.getOrgBranchCode()); jgUseRegistrationManage.setSuperviseOrgName(paramsDto.getOrgBranchName());
jgUseRegistrationManage.setSuperviseOrgName(paramsDto.getOrgBranchName()); jgUseRegistrationManage.setEquUseAddress(Stream.of(paramsDto.getProvinceName(), paramsDto.getCityName(), paramsDto.getCountyName(), paramsDto.getStreetName(), paramsDto.getAddress())
jgUseRegistrationManage.setEquUseAddress(Stream.of(paramsDto.getProvinceName(), paramsDto.getCityName(), paramsDto.getCountyName(), paramsDto.getStreetName(), paramsDto.getAddress()) .map(value -> value == null || "null".equals(value) ? "" : value)
.map(value -> value == null || "null".equals(value) ? "" : value) .collect(Collectors.joining()));
.collect(Collectors.joining())); jgUseRegistrationManage.setRecDate(new Date());
jgUseRegistrationManage.setRecDate(new Date()); jgUseRegistrationManageService.updateById(jgUseRegistrationManage);
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) { private void createResumePipeline(Long sequenceNbr, String routePath, CompanyBo company) {
...@@ -2106,6 +2154,9 @@ public class DataDockServiceImpl { ...@@ -2106,6 +2154,9 @@ public class DataDockServiceImpl {
AgencyUserModel userModel = reginParams.getUserModel(); AgencyUserModel userModel = reginParams.getUserModel();
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
String orgBranchCode = equipInfo.getString("orgBranchCode"); 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 equListCode = Objects.toString(equipInfo.get("EQU_LIST"), null);
String equCategoryCode = Objects.toString(equipInfo.get("EQU_CATEGORY"), null); String equCategoryCode = Objects.toString(equipInfo.get("EQU_CATEGORY"), null);
String equDefineCode = Objects.toString(equipInfo.get("EQU_DEFINE"), null); String equDefineCode = Objects.toString(equipInfo.get("EQU_DEFINE"), null);
...@@ -2169,7 +2220,8 @@ public class DataDockServiceImpl { ...@@ -2169,7 +2220,8 @@ public class DataDockServiceImpl {
.setStartLatitudeLongitude(toJSONString(equipInfo.get("startLatitudeLongitude"))) .setStartLatitudeLongitude(toJSONString(equipInfo.get("startLatitudeLongitude")))
.setEndLatitudeLongitude(toJSONString(equipInfo.get("endLatitudeLongitude"))) .setEndLatitudeLongitude(toJSONString(equipInfo.get("endLatitudeLongitude")))
.setEquState(equState) .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 { ...@@ -2311,10 +2363,8 @@ public class DataDockServiceImpl {
supervisionInfo.setRecord(record); supervisionInfo.setRecord(record);
supervisionInfo.setOrgBranchCode(paramsDto.getOrgBranchCode()); supervisionInfo.setOrgBranchCode(paramsDto.getOrgBranchCode());
supervisionInfo.setOrgBranchName(paramsDto.getOrgBranchName()); supervisionInfo.setOrgBranchName(paramsDto.getOrgBranchName());
HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(paramsDto.getOrgBranchCode()).getResult();
// 目前平台返回key为compnay(存在拼写错误) supervisionInfo.setCompanyOrgBranchCode(paramsDto.getOrgCompanyCode());
CompanyModel parentModel = JSON.parseObject(toJSONString(parentMessage.get("compnay")), CompanyModel.class);
supervisionInfo.setCompanyOrgBranchCode(parentModel.getCompanyCode());
supervisionInfo.setRecDate(new Date()); supervisionInfo.setRecDate(new Date());
supervisionInfo.setSequenceNbr(null); supervisionInfo.setSequenceNbr(null);
supervisionInfoList.add(supervisionInfo); supervisionInfoList.add(supervisionInfo);
...@@ -2672,8 +2722,6 @@ public class DataDockServiceImpl { ...@@ -2672,8 +2722,6 @@ public class DataDockServiceImpl {
* @param equLists 数据集 * @param equLists 数据集
* @return 保存结果 * @return 保存结果
*/ */
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public Set<String> saveElevatorData(List<Map<String, Object>> equLists) { public Set<String> saveElevatorData(List<Map<String, Object>> equLists) {
RequestContextWrapper contextWrapper = RequestContextWrapper.capture(); RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
Set<String> recordSet = Sets.newConcurrentHashSet(); Set<String> recordSet = Sets.newConcurrentHashSet();
......
...@@ -19,7 +19,6 @@ public class ElevatorDataTransactionService { ...@@ -19,7 +19,6 @@ public class ElevatorDataTransactionService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public Object saveSingleElevatorData(Map<String, Object> equ) { public Object saveSingleElevatorData(Map<String, Object> equ) {
return dataDockService.saveElevatorDataInTransaction(equ, "jg_his_xa", null); return dataDockService.saveElevatorDataInTransaction(equ, "jg_his_xa", null);
} }
......
...@@ -56,6 +56,7 @@ import com.yeejoin.amos.boot.module.ymt.api.dto.TzsUserInfoDto; ...@@ -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.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.*; import com.yeejoin.amos.boot.module.ymt.api.enums.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*; 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.model.FeignClientResult;
import com.yeejoin.amos.component.feign.utils.FeignUtil; import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
...@@ -4454,390 +4455,385 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -4454,390 +4455,385 @@ 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)); try {
LinkedHashMap attachmentUpload = (LinkedHashMap) checkAndCast(paramMap.get(ATTACHMENT_UPLOAD)); LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
EquipmentInfoDto equipInfoDto = this.createEquipmentInfoDto(equipmentInfoForm, jgVehicleInformationMapper); 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); Long changeRecordId = sequence.nextId();
// 属地监管部门 List<EquipInfoCylinderExcelDto> equipInfoCylinderExcelDtoList = JSON.parseArray(toJSONString(attachmentUpload.get(EQU_LISTS)), EquipInfoCylinderExcelDto.class);
String orgBranchCode = equipInfoDto.getOrgBranchCode(); // 属地监管部门
String orgBranchName = equipInfoDto.getOrgBranchName(); String orgBranchCode = equipInfoDto.getOrgBranchCode();
Set<String> recordSet = new HashSet<>(); String orgBranchName = equipInfoDto.getOrgBranchName();
List<DictionarieValueModel> fillingMedium = Systemctl.dictionarieClient.dictValues("FILLING_MEDIUM").getResult(); Set<String> recordSet = new HashSet<>();
Map<String, Object> fillingMediumMap = fillingMedium.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataValue, List<DictionarieValueModel> fillingMedium = Systemctl.dictionarieClient.dictValues("FILLING_MEDIUM").getResult();
DictionarieValueModel::getDictDataKey)); Map<String, Object> fillingMediumMap = fillingMedium.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataValue,
Iterator<String> supervisoryCodeIterator; DictionarieValueModel::getDictDataKey));
if ("his".equals(equipInfoDto.getDataSource())) { Iterator<String> supervisoryCodeIterator;
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("车用气瓶只能选择特种气瓶进行导入!");
}
if ("his".equals(equipInfoDto.getDataSource())) { if ("his".equals(equipInfoDto.getDataSource())) {
//使用登记证编号判断是否使用未来系统生成编号 supervisoryCodeIterator = this
this.checkUseRegistrationCode(equipInfoDto.getUseOrgCode(), "cylinder"); .getSupervisoryCodeBatch(equipInfoDto.getPossession(), equipInfoDto.getEquCategoryCode(), equipInfoCylinderExcelDtoList.size())
} .iterator();
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 { } else {
useInfo.setUseUnitCreditCode(company.getCompanyCode()); supervisoryCodeIterator = Collections.emptyIterator();
useInfo.setUseUnitName(company.getCompanyName());
} }
useInfoList.add(useInfo); equipInfoCylinderExcelDtoList.forEach(data -> {
JgUseRegistrationEq jgRelationEquip = new JgUseRegistrationEq();
// 设计信息 if ("his".equals(equipInfoDto.getDataSource()) && "1".equals(data.getWhetherVehicleCylinder())) {
IdxBizJgDesignInfo designInfo = new IdxBizJgDesignInfo(); throw new BadRequest("车用气瓶历史设备不能批量导入!");
BeanUtils.copyProperties(data, designInfo); }
designInfo.setRecord(record); if ("1".equals(data.getWhetherVehicleCylinder()) && !SPECIAL_CYLINDER.getCode().equals(equipInfoDto.getEquDefineCode())) {
designInfo.setRecDate(new Date()); throw new BadRequest("车用气瓶只能选择特种气瓶进行导入!");
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);
//监督管理信息 if ("his".equals(equipInfoDto.getDataSource())) {
setSupervisionInfo(orgBranchCode, orgBranchName, record, supervisionInfoList); //使用登记证编号判断是否使用未来系统生成编号
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(); IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = new IdxBizJgInspectionDetectionInfo();
BeanUtils.copyProperties(data, paramsVessel); BeanUtils.copyProperties(data, inspectionDetectionInfo);
paramsVessel.setRecord(record); inspectionDetectionInfo.setInspectOrgCode(data.getInspectOrgCode());
paramsVessel.setRecDate(new Date()); inspectionDetectionInfo.setRecord(record);
paramsVessel.setChargingMedium((String) fillingMediumMap.get(data.getChargingMedium())); inspectionDetectionInfo.setRecDate(new Date());
paramsVesselList.add(paramsVessel); 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()); String cylinderStampAttachment = getUrlByKey(fileDataList, "CYLINDER_STAMP_ATTACHMENT");
if (inspectionDetectionInfo.getNextInspectDate() != null) { IdxBizJgOtherInfo otherInfo = new IdxBizJgOtherInfo();
esEquipmentDto.setNEXT_INSPECT_DATE(inspectionDetectionInfo.getNextInspectDate().getTime()); BeanUtils.copyProperties(data, otherInfo);
} otherInfo.setRecord(record);
esEquipmentDto.setCREATE_DATE(System.currentTimeMillis()); otherInfo.setRecDate(new Date());
esEquipmentDto.setREC_DATE(System.currentTimeMillis()); otherInfo.setCylinderStampAttachment(cylinderStampAttachment);
esEquipmentDto.setSEQUENCE_NBR(record); if ("his".equals(equipInfoDto.getDataSource())) {
esEquipmentDto.setFACTORY_NUM(factoryInfo.getFactoryNum()); otherInfo.setSupervisoryCode(supervisoryCodeIterator.next());
esEquipmentDto.setUSE_INNER_CODE(useInfo.getUseInnerCode()); }
esEquipmentDto.setUSE_ORG_CODE(equipInfoDto.getUseOrgCode()); otherInfo.setClaimStatus("已认领");
esEquipmentDto.setIS_INTO_MANAGEMENT("his".equals(equipInfoDto.getDataSource())); otherInfoList.add(otherInfo);
esEquipmentDto.setEQU_CODE(registerInfo.getEquCode());
esEquipmentDto.setEQU_CATEGORY_CODE(equipInfoDto.getEquCategoryCode()); //监督管理信息
esEquipmentDto.setEQU_CATEGORY(equipInfoDto.getEquCategory()); setSupervisionInfo(orgBranchCode, orgBranchName, record, supervisionInfoList);
esEquipmentDto.setEQU_LIST_CODE(equipInfoDto.getEquListCode());
esEquipmentDto.setEQU_LIST(equipInfoDto.getEquList()); // 技术参数
esEquipmentDto.setEQU_DEFINE_CODE(equipInfoDto.getEquDefineCode()); IdxBizJgTechParamsVessel paramsVessel = new IdxBizJgTechParamsVessel();
esEquipmentDto.setSUPERVISORY_CODE(otherInfo.getSupervisoryCode()); BeanUtils.copyProperties(data, paramsVessel);
esEquipmentDto.setOrgBranchCode(orgBranchCode); paramsVessel.setRecord(record);
esEquipmentDto.setORG_BRANCH_NAME(orgBranchName); paramsVessel.setRecDate(new Date());
esEquipmentDto.setEQU_DEFINE(equipInfoDto.getEquDefine()); paramsVessel.setChargingMedium((String) fillingMediumMap.get(data.getChargingMedium()));
esEquipmentDto.setINFORMATION_SITUATION(otherInfo.getInformationSituation()); paramsVesselList.add(paramsVessel);
esEquipmentDto.setSTATUS("已认领");
esEquipmentDto.setEQU_STATE(Integer.valueOf(equState)); 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())) { if ("his".equals(equipInfoDto.getDataSource())) {
// 生成tzs_jg_certificate_change_record_eq记录 // 生成证书管理表记录
JgCertificateChangeRecordEq changeRecordEq = new JgCertificateChangeRecordEq(); LambdaQueryWrapper<JgUseRegistrationManage> queryWrapper = new LambdaQueryWrapper<JgUseRegistrationManage>()
changeRecordEq.setChangeRecordId(String.valueOf(changeRecordId));// 登记证记录主键 .eq(JgUseRegistrationManage::getUseRegistrationCode, equipInfoDto.getUseOrgCode())
changeRecordEq.setEquId(registerInfo.getRecord());// 设备主键 .eq(JgUseRegistrationManage::getIsDelete, 0)
changeRecordEq.setProductCode(factoryInfo.getFactoryNum());// 产品编号 .eq(JgUseRegistrationManage::getCertificateStatus, "已登记");
jgCertificateChangeRecordEqList.add(changeRecordEq); JgUseRegistrationManage jgUseRegistrationManage = jgUseRegistrationManageService.getBaseMapper().selectOne(queryWrapper);
} // 使用登记信息
String nextInspectDateStr = Optional.ofNullable(inspectionDetectionInfo.getNextInspectDate()) JgUseRegistration jgUseRegistration = new JgUseRegistration();
.map(date -> date.toInstant() //历史增补
.atZone(ZoneId.systemDefault()) if (!ValidationUtil.isEmpty(jgUseRegistrationManage)) {
.toLocalDate() jgUseRegistration.setIsAddEquip("1");
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) if (jgUseRegistrationManage.getUseUnitCreditCode().equals(company.getCompanyCode())) {
.orElse(null); jgUseRegistrationManage.setAuditPassDate(new Date());
Map<String, Object> equipMap = MapBuilder.<String, Object>create() jgUseRegistrationManage.setRegDate(new Date());
.put("factoryNum", factoryInfo.getFactoryNum()) jgUseRegistrationManage.setManageType("unit");
.put("chargingMedium", data.getChargingMedium()) jgUseRegistrationManage.setApplyNo(this.getApplicationNo());
.put("productName", data.getProductName()) jgUseRegistrationManage.setUseUnitCreditCode(company.getCompanyCode());
.put("produceUnitName", factoryInfo.getProduceUnitName()) if(!equipInfoDto.getReceiveOrgName().equals(jgUseRegistrationManage.getReceiveOrgName()) || company.getCompanyName().equals(jgUseRegistrationManage.getUseUnitName())){
.put("produceDate", esEquipmentDto.getPRODUCE_DATE()) jgUseRegistrationManage.setVersion(jgUseRegistrationManage.getVersion() + 1);
.put("nominalWorkingPressure", data.getNominalWorkingPressure()) jgUseRegistrationManage.setChangeReason(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName());
.put("singleBottleVolume", data.getSingleBottleVolume()) }
.put("inspectDate", data.getInspectDate()) jgUseRegistrationManage.setUseUnitName(company.getCompanyName());
.put("equList", equipInfoDto.getEquListCode()) jgUseRegistrationManage.setReceiveOrgName(equipInfoDto.getReceiveOrgName());
.put("equListName", equipInfoDto.getEquList()) jgUseRegistrationManage.setReceiveCompanyCode(equipInfoDto.getReceiveOrgCode());
.put("equCategory", equipInfoDto.getEquCategoryCode()) jgUseRegistrationManage.setSuperviseOrgName(orgBranchName);
.put("equCategoryName", equipInfoDto.getEquCategory()) jgUseRegistrationManage.setSuperviseOrgCode(orgBranchCode);
.put("equDefine", equipInfoDto.getEquDefineCode()) jgUseRegistrationManageService.updateById(jgUseRegistrationManage);
.put("equDefineName", equipInfoDto.getEquDefine()) } else {
.put("manageType", "unit") throw new BadRequest("该使用登记证编号系统已存在,请核对使用登记证编号后,重新上传!");
.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());
} }
jgUseRegistrationManage.setUseUnitName(company.getCompanyName());
jgUseRegistrationManage.setReceiveOrgName(equipInfoDto.getReceiveOrgName());
jgUseRegistrationManage.setReceiveCompanyCode(equipInfoDto.getReceiveOrgCode());
jgUseRegistrationManage.setSuperviseOrgName(orgBranchName);
jgUseRegistrationManage.setSuperviseOrgCode(orgBranchCode);
jgUseRegistrationManageService.updateById(jgUseRegistrationManage);
} else { } 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 { } else {
jgUseRegistration.setIsAddEquip("0"); jgResumeInfoService.saveBatchResume(
jgUseRegistrationManage = this.saveRegistrationManage(equipInfoDto, company, orgBranchCode, orgBranchName); equipmentLists.stream()
} .map(equipId -> JgResumeInfoDto.builder()
// 生成一条tzs_jg_certificate_change_record记录 .businessType(BusinessTypeEnum.JG_NEW_EQUIP.getName())
generateCertificateChangeRecord(jgUseRegistrationManage, changeRecordId); .businessId(String.valueOf(equipId.get("record")))
.equId(String.valueOf(equipId.get("record")))
jgUseRegistration.setRegDate(new Date()); .approvalUnit(reginParams.getCompany().getCompanyName())
jgUseRegistration.setReceiveCompanyCode(equipInfoDto.getReceiveOrgCode()); .approvalUnitCode(reginParams.getCompany().getCompanyCode())
jgUseRegistration.setReceiveOrgName(equipInfoDto.getReceiveOrgName()); .status("正常")
jgUseRegistration.setManageType("unit"); .changeContent(BusinessTypeEnum.JG_NEW_EQUIP.getName() + "业务办理")
jgUseRegistration.setCylinderCategory(registerInfoList.get(0).getCylinderCategory()); .routePath(String.format(equipRoutePath, equipId.get("record"), equipId.get("dataSource")))
jgUseRegistration.setReceiveCompanyOrgCode(commonService.getOneCompany(jgUseRegistration.getReceiveCompanyCode()).getOrgCode()); .build())
//使用单位提交 .collect(Collectors.toList())
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
)
); );
} }
}); 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()); return String.format("导入完成,成功导入: %d 条数据!", useInfoList.size());
} }
......
...@@ -142,8 +142,6 @@ ...@@ -142,8 +142,6 @@
ibjui."REC_DATE", ibjui."REC_DATE",
ibjui."USE_UNIT_NAME", ibjui."USE_UNIT_NAME",
ibjui."USE_UNIT_CREDIT_CODE", ibjui."USE_UNIT_CREDIT_CODE",
ibjui."USC_UNIT_NAME",
ibjui."USC_UNIT_CREDIT_CODE",
ibjri."EQU_LIST" AS "EQU_LIST_CODE", ibjri."EQU_LIST" AS "EQU_LIST_CODE",
ibjri."EQU_DEFINE" AS "EQU_DEFINE_CODE", ibjri."EQU_DEFINE" AS "EQU_DEFINE_CODE",
ibjri."PRODUCT_NAME", ibjri."PRODUCT_NAME",
...@@ -185,7 +183,13 @@ ...@@ -185,7 +183,13 @@
ibjoi."INFORMATION_SITUATION", ibjoi."INFORMATION_SITUATION",
di."DESIGN_UNIT_CREDIT_CODE", di."DESIGN_UNIT_CREDIT_CODE",
di."DESIGN_UNIT_NAME", 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 FROM
idx_biz_jg_use_info ibjui idx_biz_jg_use_info ibjui
LEFT JOIN ( 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