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);
}
}
...@@ -191,31 +191,36 @@ public class DataDockServiceImpl { ...@@ -191,31 +191,36 @@ 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)
).join();
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
}
}); });
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
return Boolean.TRUE; 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) @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,6 +1693,7 @@ public class DataDockServiceImpl { ...@@ -1687,6 +1693,7 @@ 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<>();
try {
for (EquipInfoExcelDto equ : equipInfoExcelDtos) { for (EquipInfoExcelDto equ : equipInfoExcelDtos) {
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData(); List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class); Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class);
...@@ -1711,7 +1718,7 @@ public class DataDockServiceImpl { ...@@ -1711,7 +1718,7 @@ public class DataDockServiceImpl {
projectContraptionIdSet.add(String.valueOf(projectContraptionId)); projectContraptionIdSet.add(String.valueOf(projectContraptionId));
equMap.put("projectContraptionId", projectContraptionId); equMap.put("projectContraptionId", projectContraptionId);
} }
String record = this.saveEquipmentDataInTransaction(equMap, dataSource, remark); String record = this.saveEquipmentDataInTransaction(equMap, dataSource, remark, selectedOrgInfo);
recordSet.add(record); recordSet.add(record);
} }
if (EquipmentClassifityEnum.YLGD.getCode().equals(equList)) { if (EquipmentClassifityEnum.YLGD.getCode().equals(equList)) {
...@@ -1722,6 +1729,18 @@ public class DataDockServiceImpl { ...@@ -1722,6 +1729,18 @@ public class DataDockServiceImpl {
this.createResumeBatch(recordSet,dataSource, equipRoutePath, company); this.createResumeBatch(recordSet,dataSource, equipRoutePath, company);
eventPublisher.publish(new EquipCreateOrEditEvent(this,BusinessTypeEnum.JG_NEW_EQUIP.name(),recordSet, EquipCreateOrEditEvent.EquipType.equip)); 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);
}
} }
private void updatePipelineLength(Set<String> projectContraptionIdSet) { private void updatePipelineLength(Set<String> projectContraptionIdSet) {
...@@ -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<>();
try {
equipInfoExcelDtos.forEach(equ -> {
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData(); List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class); Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(toJSONString(equ), Map.class);
for (String key : keys) { for (String key : keys) {
String camelKey = toCamelCase(key.toLowerCase()); String camelKey = toCamelCase(key.toLowerCase());
equMap.put(camelKey, getUrlByKey(fileDataList, key)); equMap.put(camelKey, getUrlByKey(fileDataList, key));
} }
this.saveEquipmentDataInTransaction(equMap, "jg_his", remark); 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,6 +1972,8 @@ public class DataDockServiceImpl { ...@@ -1937,6 +1972,8 @@ 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) {
// 获取数据 // 获取数据
List<String> records = new ArrayList<>();
try {
JSONObject equipInfo = JSON.parseObject(toJSONString(paramMap.get("equipInfo")), JSONObject.class); JSONObject equipInfo = JSON.parseObject(toJSONString(paramMap.get("equipInfo")), JSONObject.class);
JSONObject attachmentUpload = JSON.parseObject(toJSONString(paramMap.get("attachmentUpload")), JSONObject.class); JSONObject attachmentUpload = JSON.parseObject(toJSONString(paramMap.get("attachmentUpload")), JSONObject.class);
JSONArray equListsJSONArr = JSONArray.parseArray(toJSONString(attachmentUpload.get("equLists"))); JSONArray equListsJSONArr = JSONArray.parseArray(toJSONString(attachmentUpload.get("equLists")));
...@@ -1978,7 +2015,7 @@ public class DataDockServiceImpl { ...@@ -1978,7 +2015,7 @@ public class DataDockServiceImpl {
// 生成工程装置表信息 // 生成工程装置表信息
IdxBizJgProjectContraption proCon = this.saveProjectContraption(paramsDto); IdxBizJgProjectContraption proCon = this.saveProjectContraption(paramsDto);
// 保存管道对应的idx表数据 // 保存管道对应的idx表数据
List<String> records = this.savePipInfoToIdxTables(equLists, paramsDto, proCon); records = this.savePipInfoToIdxTables(equLists, paramsDto, proCon);
if (isGYGD) { if (isGYGD) {
// 生成使用登记表信息 + 设备关系表 + 历史表 // 生成使用登记表信息 + 设备关系表 + 历史表
JgUseRegistration useReg = this.saveUseRegAndEq(paramsDto, records, proCon); JgUseRegistration useReg = this.saveUseRegAndEq(paramsDto, records, proCon);
...@@ -2007,6 +2044,17 @@ public class DataDockServiceImpl { ...@@ -2007,6 +2044,17 @@ public class DataDockServiceImpl {
this.createResumePipeline(proCon.getSequenceNbr(), String.format(pipelineRoutePath, proCon.getSequenceNbr() + ""), company); 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)); eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_PROJECT.name(), Sets.newHashSet(proCon.getSequenceNbr() + ""), EquipCreateOrEditEvent.EquipType.project));
return Boolean.TRUE; 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;
}
} }
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,6 +4455,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -4454,6 +4455,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
if (paramMap == null) { if (paramMap == null) {
throw new IllegalArgumentException("参数Map不能为空"); throw new IllegalArgumentException("参数Map不能为空");
} }
try {
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID)); LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
LinkedHashMap attachmentUpload = (LinkedHashMap) checkAndCast(paramMap.get(ATTACHMENT_UPLOAD)); LinkedHashMap attachmentUpload = (LinkedHashMap) checkAndCast(paramMap.get(ATTACHMENT_UPLOAD));
EquipmentInfoDto equipInfoDto = this.createEquipmentInfoDto(equipmentInfoForm, jgVehicleInformationMapper); EquipmentInfoDto equipInfoDto = this.createEquipmentInfoDto(equipmentInfoForm, jgVehicleInformationMapper);
...@@ -4603,16 +4605,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -4603,16 +4605,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
.map(s -> DateUtil.parse(s, "yyyy-MM-dd")) .map(s -> DateUtil.parse(s, "yyyy-MM-dd"))
.ifPresent(inspectionDetectionInfo::setNextInspectDate); .ifPresent(inspectionDetectionInfo::setNextInspectDate);
// 根据条件确定增加的年数(杨生元说监管让去掉,企业自己输入) // 根据条件确定增加的年数(杨生元说监管让去掉,企业自己输入)
// Optional.ofNullable(data.getInspectDate()) // Optional.ofNullable(data.getInspectDate())
// .filter(s -> !s.trim().isEmpty()) // .filter(s -> !s.trim().isEmpty())
// .map(dateStr -> LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"))) // .map(dateStr -> LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .ifPresent(inspectDate -> { // .ifPresent(inspectDate -> {
// inspectionDetectionInfo.setInspectDate(Date.from(inspectDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); // inspectionDetectionInfo.setInspectDate(Date.from(inspectDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
// // 计算下次检测日期(加 3 年或 4 年) // // 计算下次检测日期(加 3 年或 4 年)
// int plusYears = SPECIAL_CYLINDER.getCode().equals(equipInfoDto.getEquDefineCode()) ? 3 : 4; // int plusYears = SPECIAL_CYLINDER.getCode().equals(equipInfoDto.getEquDefineCode()) ? 3 : 4;
// LocalDate nextInspectDate = inspectDate.plusYears(plusYears); // LocalDate nextInspectDate = inspectDate.plusYears(plusYears);
// inspectionDetectionInfo.setNextInspectDate(Date.from(nextInspectDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); // inspectionDetectionInfo.setNextInspectDate(Date.from(nextInspectDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
// }); // });
inspectionDetectionInfoList.add(inspectionDetectionInfo); inspectionDetectionInfoList.add(inspectionDetectionInfo);
// 其他信息 // 其他信息
...@@ -4824,20 +4826,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -4824,20 +4826,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
batchInsert(idxBizJgInspectionDetectionInfoMapper, inspectionDetectionInfoList, "检验检测信息"); batchInsert(idxBizJgInspectionDetectionInfoMapper, inspectionDetectionInfoList, "检验检测信息");
batchInsert(certificateChangeRecordEqMapper, jgCertificateChangeRecordEqList, "登记证关系信息"); batchInsert(certificateChangeRecordEqMapper, jgCertificateChangeRecordEqList, "登记证关系信息");
esEquipmentCategory.saveAll(esEquipmentCategoryList); esEquipmentCategory.saveAll(esEquipmentCategoryList);
// 使用事务同步回调确保事件在事务提交后发送 // 事务提交成功后,发送消息
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
@Override } catch (Exception e) {
public void afterCommit() { if(!esEquipmentCategoryList.isEmpty()){
eventPublisher.publish( esEquipmentCategory.deleteAll(esEquipmentCategoryList);
new EquipCreateOrEditEvent( }
this, throw e;
BusinessTypeEnum.JG_NEW_EQUIP.name(),
recordSet,
EquipCreateOrEditEvent.EquipType.equip
)
);
} }
});
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