Commit 83f1b480 authored by tianbo's avatar tianbo

feat(jg): 优化设备数据对接与历史登记更新逻辑

- 修改ChangeEquipImpactCertListener中的接收单位名称转换器 - 重构CommonCustomConverter中的公司代码转换器,优化缓存和查找逻辑 - 新增设备使用次数统计查询接口countEquipInUseTimesForXaElevator - 优化DataDockServiceImpl中的设备信息保存逻辑,支持更新已有数据 - 增加设备是否已使用的校验逻辑,防止重复业务处理 - 添加属地监管部门信息的自动处理逻辑 - 优化线程池使用,提升数据处理性能 - 完善设备信息保存时的字段处理和数据完整性校验
parent 64072c71
......@@ -56,7 +56,7 @@ public class XiAnDataDockController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/importElevatorData")
@ApiOperation(httpMethod = "POST", value = "西安电梯历史设备以及业务数据批量导入", notes = "西安电梯历史设备以及业务数据批量导入")
public Object importElevatorData(@RequestParam MultipartFile file) {
public Object importElevatorData(@RequestParam MultipartFile file, @RequestParam(required = false, defaultValue = "true") Boolean isRegistration) {
if (file.isEmpty()) {
return ResponseHelper.buildResponse("文件不能为空");
}
......@@ -67,7 +67,7 @@ public class XiAnDataDockController {
!("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension))) {
return ResponseHelper.buildResponse("文件类型必须是 Excel 文件");
}
return xiAnDataDockService.importElevatorData(file);
return xiAnDataDockService.importElevatorData(file, isRegistration);
}
}
......@@ -13,6 +13,8 @@ public class DictParamsConverter implements Converter<String> {
private static final Map<String, String> dictMap = new HashMap<>();
private static final Map<String, Map<String, String>> feildDictMap = new HashMap<>();
static {
// 填充映射关系
dictMap.put("油", "5961");
......@@ -22,10 +24,10 @@ public class DictParamsConverter implements Converter<String> {
dictMap.put("生物质", "5965");
dictMap.put("余热", "5966");
dictMap.put("其他", "5967");
dictMap.put("射线", "5969");
dictMap.put("超声", "5970");
dictMap.put("磁粉", "5971");
dictMap.put("渗透", "5972");
// dictMap.put("射线", "5969");
// dictMap.put("超声", "5970");
// dictMap.put("磁粉", "5971");
// dictMap.put("渗透", "5972");
dictMap.put("固定式", "5990");
dictMap.put("半挂式", "5991");
dictMap.put("公用管道", "5992");
......@@ -75,12 +77,26 @@ public class DictParamsConverter implements Converter<String> {
dictMap.put("液化天然气", "LIQUEFIED_NATURAL_GAS");
dictMap.put("液化石油气", "LIQUEFIED_PETROLEUM_GAS");
dictMap.put("氢气", "HYDROGEN");
dictMap.put("集选", "1");
dictMap.put("并联", "2");
dictMap.put("按钮", "3");
dictMap.put("其他", "4");
// dictMap.put("集选", "1");
// dictMap.put("并联", "2");
// dictMap.put("按钮", "3");
// dictMap.put("其他", "4");
dictMap.put("直接顶升", "1");
dictMap.put("间接顶升", "2");
// HashMap<String, String> controlModeMap = new HashMap<>();
// controlModeMap.put("集选", "1");
// controlModeMap.put("并联", "2");
// controlModeMap.put("按钮", "3");
// controlModeMap.put("其他", "4");
// feildDictMap.put("controlMode", controlModeMap);
HashMap<String, String> nonDestructiveTestingMethodsForPressurePartsMap = new HashMap<>();
nonDestructiveTestingMethodsForPressurePartsMap.put("磁粉", "5988");
nonDestructiveTestingMethodsForPressurePartsMap.put("射线", "5986");
nonDestructiveTestingMethodsForPressurePartsMap.put("超声", "5987");
nonDestructiveTestingMethodsForPressurePartsMap.put("渗透", "5989");
feildDictMap.put("nonDestructiveTestingMethodsForPressureParts", nonDestructiveTestingMethodsForPressurePartsMap);
}
@Override
......@@ -100,7 +116,8 @@ public class DictParamsConverter implements Converter<String> {
// 从Cell中读取数据
String cellValue = cellData.getStringValue();
// 判断Excel中的值,将其转换为预期的数值
return dictMap.getOrDefault(cellValue, null);
// return dictMap.getOrDefault(cellValue, null);
return feildDictMap.getOrDefault(excelContentProperty.getField().getName(), dictMap).getOrDefault(cellValue, null);
}
@Override
......
......@@ -5,10 +5,12 @@ import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.yeejoin.amos.api.openapi.converter.*;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.common.api.converter.CommonCustomConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
@Data
......@@ -64,10 +66,27 @@ public class XiAnElevatorExcelDto extends BaseDto {
@ExcelProperty(value = "使用登记证编号")
private String useOrgCode;
@ApiModelProperty(value = "登记机关")
@ExcelProperty(value = "登记机关", converter = CommonCustomConverter.CompanyCodeConverter.class)
private String oRegUnit;
@ApiModelProperty(value = "登记日期")
@ExcelProperty(value = "登记日期")
@DateTimeFormat("yyyy-MM-dd")
private String oRegDate;
@ApiModelProperty(value = "注册代码")
@ExcelProperty(value = "注册代码")
private String record;
@ApiModelProperty(value = "属地监管部门")
@ExcelProperty(value = "属地监管部门")
private String orgBranchName;
@ApiModelProperty(value = "属地监管部门code")
@ExcelIgnore
private String orgBranchCode;
//-----------------------------------------------------------------------使用信息
@ApiModelProperty(value = "使用单位统一社会信用代码")
@ExcelProperty(value = "使用单位统一社会信用代码")
......@@ -125,6 +144,10 @@ public class XiAnElevatorExcelDto extends BaseDto {
@ExcelProperty(value = "安全管理员身份证号")
private String safetyManagerIDNumber;
@ApiModelProperty(value = "投用日期")
@ExcelProperty(value = "投用日期")
@DateTimeFormat("yyyy-MM-dd")
private String useDate;
//---------------------------------------------------------------制造信息
@ApiModelProperty(value = "制造单位统一社会信用代码")
......@@ -404,4 +427,20 @@ public class XiAnElevatorExcelDto extends BaseDto {
@ApiModelProperty(value = "市场监管所代码")
@ExcelProperty(value = "市场监管所代码")
private String supervisionOfficeCode;
public void setoRegUnit(String oRegUnit) {
this.oRegUnit = oRegUnit;
}
public void setoRegDate(String oRegDate) {
this.oRegDate = oRegDate;
}
public String getoRegUnit() {
return oRegUnit;
}
public String getoRegDate() {
return oRegDate;
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
@FeignClient(name = "TZS-JG", path = "/jg", configuration = {FeignConfiguration.class})
@FeignClient(name = "TZS-JG-tb", path = "/jg", configuration = {FeignConfiguration.class})
public interface TzsJgServiceFeignClient {
/**
......
......@@ -20,7 +20,6 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -29,6 +28,7 @@ import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import java.util.stream.Stream;
@Slf4j
......@@ -52,6 +52,7 @@ public class XiAnDataDockServiceImpl {
List<String> equCodeList = new ArrayList<>();// 设备代码集合
List<String> factoryNumList = new ArrayList<>();// 出厂编码集合
List<String> recordList = new ArrayList<>();// 注册代码集合
List<String> useOrgCodeList = new ArrayList<>();// 使用登记证号集合
/**
......@@ -552,10 +553,17 @@ public class XiAnDataDockServiceImpl {
private void KYSDTechnicalParamsCheck(XiAnEquipInfoExcelDto data, StringBuffer rowError) {
}
public Object importElevatorData(MultipartFile file) {
/**
* 批量保存设备信息
*
* @param file excel文件
* @param isRegistration 是否登记数据
*
*/
public Object importElevatorData(MultipartFile file, Boolean isRegistration) {
List<XiAnElevatorExcelDto> elevatorExcelDtos;
try {
elevatorExcelDtos = this.dataHandlerElevator(file);
elevatorExcelDtos = this.dataHandlerElevator(file, isRegistration);
} catch (Exception e) {
return ResponseHelper.buildFailureResponse(e.getMessage(), "参数校验失败,详细请看返回信息", HttpStatus.BAD_REQUEST);
}
......@@ -566,17 +574,19 @@ public class XiAnDataDockServiceImpl {
/**
* excel 文件读取,字段校验
*
* @param file excel 文件
* @param file excel 文件
* @param isRegistration 是否登记数据
* @return 设备数据
* @throws Exception 异常信息
*/
public List<XiAnElevatorExcelDto> dataHandlerElevator(MultipartFile file) {
public List<XiAnElevatorExcelDto> dataHandlerElevator(MultipartFile file, Boolean isRegistration) {
List<XiAnElevatorExcelDto> dataList = new ArrayList<>();
resultError.clear();
useInnerCodeList.clear();
equCodeList.clear();
factoryNumList.clear();
recordList.clear();
useOrgCodeList.clear();
try {
InputStream inputStream = file.getInputStream();
ExcelReader excelReader = EasyExcel.read(inputStream).build();
......@@ -592,10 +602,11 @@ public class XiAnDataDockServiceImpl {
EasyExcel.read(file.getInputStream(), XiAnElevatorExcelDto.class, new AnalysisEventListener<XiAnElevatorExcelDto>() {
@Override
public void invoke(XiAnElevatorExcelDto data, AnalysisContext context) {
checkElevatorExcelData(sheetName, data, context, sheetError);
useInnerCodeList.add(data.getUseInnerCode());
equCodeList.add(data.getEquCode());
checkElevatorExcelData(sheetName, data, context, sheetError, isRegistration);
// useInnerCodeList.add(data.getUseInnerCode());
// equCodeList.add(data.getEquCode());
recordList.add(data.getRecord());
useOrgCodeList.add(data.getUseOrgCode());
dataList.add(data);
}
......@@ -624,18 +635,19 @@ public class XiAnDataDockServiceImpl {
/**
* excel数据字段校验
*
* @param sheetName sheet页名称
* @param data excel数据
* @param sheetName sheet页名称
* @param data excel数据
* @param context
* @param isRegistration 是否登记数据
*/
public void checkElevatorExcelData(String sheetName, XiAnElevatorExcelDto data, AnalysisContext context, Map<String, Object> sheetError) {
public void checkElevatorExcelData(String sheetName, XiAnElevatorExcelDto data, AnalysisContext context, Map<String, Object> sheetError, Boolean isRegistration) {
ReadRowHolder readRowHolder = context.readRowHolder();
int rowIndex = readRowHolder.getRowIndex() + 1;
StringBuffer rowError = new StringBuffer();
try {
log.info("解析第{}行数据:{}", rowIndex, JSON.toJSONString(data));
if (data.getEquList() != null && !data.getEquList().isEmpty()) {
checkCommonInfo(data, rowError);
checkXaElevatorCommonInfo(data, rowError, isRegistration);
} else if (data.getBusinessId() != null && !data.getBusinessId().isEmpty()){
checkResumeInfo(data, rowError);
}else{
......@@ -667,57 +679,47 @@ public class XiAnDataDockServiceImpl {
// Optional.ofNullable(data.getApprovalDate()).ifPresent(v -> checkDateFormatCorrect(v, "审批通过时间格式不正确;", rowError));
}
private void checkCommonInfo(XiAnElevatorExcelDto data, StringBuffer rowError) {
/**
* 西安电梯excel数据字段校验
*
* @param data excel数据
* @param rowError 行错误信息
* @param isRegistration 是否登记数据
*/
private void checkXaElevatorCommonInfo(XiAnElevatorExcelDto data, StringBuffer rowError, Boolean isRegistration) {
// 基本信息
checkNotBlank(data.getEquList(), "设备种类不能为空;", rowError);
checkNotBlank(data.getEquCategory(), "设备类别不能为空;", rowError);
// checkNotBlank(data.getEquDefine(), "设备品种不能为空;", rowError);
// checkNotBlank(data.getUseInnerCode(), "单位内编号不能为空;", rowError);
// if (useInnerCodeList.contains(data.getUseInnerCode())) {
// rowError.append("单位内编号不能重复;");
// }
checkNotBlank(data.getEquDefine(), "设备品种不能为空;", rowError);
checkNotBlank(data.getRecord(), "注册代码不能为空;", rowError);
if (recordList.contains(data.getRecord())) {
rowError.append("模板中注册代码不能重复;").append(data.getRecord());
}
if (this.checkRecordUniqueness(data.getRecord())){
rowError.append("系统中存在注册代码;").append(data.getRecord());
}
// checkNotBlank(data.getEquType(), "设备型号不能为空;", rowError);
checkNotBlank(data.getEquCodeType(), "有无设备代码不能为空;", rowError);
// if ("1".equals(data.getEquCodeType())) {
// checkNotBlank(data.getEquCode(), "设备代码不能为空;", rowError);
// String equCode = data.getEquCode();
// if (equCode.matches("[a-zA-Z0-9]+")) {
// if (equCode.length() <= 17) {
// rowError.append("设备代码不能小于17位;");
// }
// if (equCode.length() >= 20) {
// rowError.append("设备代码不能大于20位;");
// }
// } else {
// rowError.append("设备代码不能包含特殊字符;");
// }
// if (equCodeList.contains(data.getEquCode())) {
// data.setOriginalEquCode(data.getEquCode());
// data.setEquCodeType("2");
// data.setEquCode("");
// }
// if (this.checkEquCodeUniqueness(data.getEquCode())) {
// data.setOriginalEquCode(data.getEquCode());
// data.setEquCodeType("2");
// data.setEquCode("");
// }
// } else {
// data.setEquCode("");
// 注掉以下代码逻辑是因为西安电梯数据会存在更新操作,西安系统的注册代码在平台作为设备主键进行插入或更新
// if (this.checkRecordUniqueness(data.getRecord())){
// rowError.append("系统中存在注册代码;").append(data.getRecord());
// }
// checkNotBlank(data.getCode96333(), "96333码不能为空;", rowError);
// checkNotBlank(data.getUseOrgCode(), "使用登记证编号不能为空;", rowError);
checkNotBlank(data.getRecord(), "注册代码不能为空;", rowError);
checkNotBlank(data.getEquCodeType(), "有无设备代码不能为空;", rowError);
// 需要历史登记数据,使用登记证编号不能为空
if (isRegistration) {
checkNotBlank(data.getCode96333(), "96333码不能为空;", rowError);
checkNotBlank(data.getUseOrgCode(), "使用登记证编号不能为空;", rowError);
if (useOrgCodeList.contains(data.getUseOrgCode())) {
rowError.append("使用登记证编号不能重复;").append(data.getUseOrgCode());
}
checkNotBlank(data.getoRegUnit(), "登记机关不能为空;", rowError);
checkNotBlank(data.getoRegDate(), "登记日期不能为空;", rowError);
}
// 监管信息
checkNotBlank(data.getOrgBranchName(), "属地监管部门不能为空;", rowError);
// 使用信息
// checkNotBlank(data.getUseUnitCode(), "使用单位统一社会信用代码不能为空;", rowError);
checkNotBlank(data.getUseUnitCode(), "使用单位统一社会信用代码不能为空;", rowError);
// Optional.ofNullable(data.getUseUnitCode()).ifPresent(v -> checkCreditCode(v, "使用单位统一社会信用代码格式不正确;", rowError));
// checkNotBlank(data.getUseUnit(), "使用单位名称不能为空;", rowError);
checkNotBlank(data.getUseUnit(), "使用单位名称不能为空;", rowError);
checkNotBlank(data.getProvinceName(), "使用地点-省不能为空;", rowError);
checkNotBlank(data.getCityName(), "使用地点-市不能为空;", rowError);
checkNotBlank(data.getCountyName(), "使用地点-区/县不能为空;", rowError);
......@@ -778,24 +780,25 @@ public class XiAnDataDockServiceImpl {
*/
public void batchSaveElevatorData(List<XiAnElevatorExcelDto> elevatorExcelDtos) {
log.info("解析成功,准备上传数据,条数:{}", elevatorExcelDtos.size());
int batchSize = 1000;
int batchSize = 5000;
int totalSize = elevatorExcelDtos.size();
// 主线程中获取登录信息传递到异步线程中
String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct();
String token = RequestContext.getToken();
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
// 分批处理,但限制同时运行的批次数
int maxConcurrentBatches = 5; // 最大并发批次数
Semaphore semaphore = new Semaphore(maxConcurrentBatches);
List<CompletableFuture<Void>> futures = new ArrayList<>();
for (int i = 0; i < totalSize; i += batchSize) {
List<XiAnElevatorExcelDto> batch = elevatorExcelDtos.subList(i, Math.min(totalSize, i + batchSize));
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
try {
RequestContext.setAppKey(appKey);
RequestContext.setProduct(product);
RequestContext.setToken(token);
contextWrapper.apply();
jgServiceFeignClient.saveElevatorData(batch);
} catch (Exception e) {
log.error("西安数据上传,保存数据失败: ", e);
} finally {
semaphore.release(); // 释放许可
}
}, executorService);
futures.add(future);
......
......@@ -10,11 +10,10 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 通用的自定义字段转换器
......@@ -59,10 +58,9 @@ public class CommonCustomConverter {
}
}
public static class ReceiveCompanyCodeConverter implements Converter<String> {
public static class CompanyCodeConverter implements Converter<String> {
public static Map<String, String> receiveCompanyCodeMap = new ConcurrentHashMap<>();
public static List<LinkedHashMap<String, Object>> result = Lists.newArrayList();
public static List<LinkedHashMap<String, Object>> cacheResult = Lists.newArrayList();
// 使用静态初始化块加载数据字典
static {
......@@ -74,7 +72,7 @@ public class CommonCustomConverter {
*/
@SuppressWarnings("unchecked")
public static void refreshCache() {
result = (List<LinkedHashMap<String, Object>>) redisUtils.get("REGULATOR_UNIT_TREE");
cacheResult = (List<LinkedHashMap<String, Object>>) redisUtils.get("REGULATOR_UNIT_TREE");
}
@SuppressWarnings("unchecked")
......@@ -93,6 +91,82 @@ public class CommonCustomConverter {
return null;
}
private static LinkedHashMap<String, Object> findCompanyByPath(String path) {
String[] pathElements = path.split("#");
return findCompanyByPathRecursive(cacheResult, pathElements, 0);
}
@SuppressWarnings("unchecked")
private static LinkedHashMap<String, Object> findCompanyByPathRecursive(List<LinkedHashMap<String, Object>> tree, String[] pathElements, int index) {
if (index >= pathElements.length) {
return null;
}
String currentName = pathElements[index];
for (LinkedHashMap<String, Object> node : tree) {
if (currentName.equals(node.get("companyName"))) {
// 如果是路径的最后一个元素,直接返回该节点
if (index == pathElements.length - 1) {
return node;
}
// 如果不是最后一个元素,继续在子节点中查找
if (node.containsKey("children") && node.get("children") instanceof List) {
return findCompanyByPathRecursive((List<LinkedHashMap<String, Object>>) node.get("children"), pathElements, index + 1);
}
return null;
}
}
return null;
}
private static LinkedHashMap<String, Object> findAllCompaniesByPartialPath(String path) {
List<LinkedHashMap<String, Object>> result = new ArrayList<>();
String[] pathElements = path.split("#");
findAllCompaniesByPartialPathRecursive(cacheResult, pathElements, 0, result);
return !result.isEmpty() ? result.get(0) : null;
}
@SuppressWarnings("unchecked")
private static void findAllCompaniesByPartialPathRecursive(List<LinkedHashMap<String, Object>> tree, String[] pathElements, int index, List<LinkedHashMap<String, Object>> result) {
if (index >= pathElements.length) {
return;
}
String currentName = pathElements[index];
for (LinkedHashMap<String, Object> node : tree) {
if (currentName.equals(node.get("companyName"))) {
// 如果是路径的最后一个元素,添加该节点到结果中
if (index == pathElements.length - 1) {
result.add(node);
}
// 如果不是最后一个元素,继续在子节点中查找
if (node.containsKey("children") && node.get("children") instanceof List) {
findAllCompaniesByPartialPathRecursive((List<LinkedHashMap<String, Object>>) node.get("children"), pathElements, index + 1, result);
}
}
// 继续在子节点中查找起始路径
if (node.containsKey("children") && node.get("children") instanceof List) {
findAllCompaniesByPartialPathRecursive((List<LinkedHashMap<String, Object>>) node.get("children"), pathElements, index, result);
}
}
}
public static String getCompanyCodeByName(String name) {
LinkedHashMap<String, Object> company = findAllCompaniesByPartialPath(name);
if (company == null) {
return "";
}
return company.get("companyCode").toString();
}
public static String getCompanyOrgCodeByName(String name) {
LinkedHashMap<String, Object> company = findAllCompaniesByPartialPath(name);
if (company == null) {
return "";
}
return company.get("orgCode").toString();
}
@Override
public Class<?> supportJavaTypeKey() {
return String.class;
......@@ -106,7 +180,8 @@ public class CommonCustomConverter {
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return null;
String cellDataStr = cellData.getStringValue();
return CompanyCodeConverter.getCompanyCodeByName(cellDataStr);
}
@Override
......@@ -116,7 +191,7 @@ public class CommonCustomConverter {
}
public static String getNameByCode(String code) {
LinkedHashMap<String, Object> company = findCompanyByCode(result, code);
LinkedHashMap<String, Object> company = findCompanyByCode(cacheResult, code);
if (company == null) {
return "";
}
......
......@@ -395,58 +395,6 @@ public class EquipFieldCustomConverter {
}
/**
* 【技术参数】【区域防爆等级】类型转换器
*/
public static class EplosionproofGradeConverter implements Converter<String> {
private static final Map<String, String> CODE_TO_NAME_MAP = new ConcurrentHashMap<>();
private static final Map<String, String> NAME_TO_CODE_MAP = new ConcurrentHashMap<>();
// 使用静态初始化块加载数据字典
static {
refreshDictionaryCache();
}
/**
* 刷新数据字典缓存
*/
public static void refreshDictionaryCache() {
List<DataDictionary> dictionaries = dataDictionaryService.getByType("FBDJ");
CODE_TO_NAME_MAP.clear();
NAME_TO_CODE_MAP.clear();
dictionaries.forEach(dictionary -> {
CODE_TO_NAME_MAP.put(dictionary.getCode(), dictionary.getName());
NAME_TO_CODE_MAP.put(dictionary.getName(), dictionary.getCode());
});
}
@Override
public Class<?> supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
String cellValue = cellData.getStringValue();
return NAME_TO_CODE_MAP.getOrDefault(cellValue, cellValue);
}
@Override
public CellData convertToExcelData(String value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
String displayValue = CODE_TO_NAME_MAP.getOrDefault(value, value);
return new CellData(displayValue);
}
}
/**
* 【技术参数】【受压部件名称】类型转换器
*/
public static class NameOfPressurePartsConverter implements Converter<String> {
......@@ -809,5 +757,4 @@ public class EquipFieldCustomConverter {
return new CellData(displayValue);
}
}
}
\ No newline at end of file
......@@ -350,5 +350,7 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
* @return
*/
List<Map<String, String>> queryRecentlyReceiveCompanyCode(String record);
Integer countEquipInUseTimesForXaElevator();
}
......@@ -3216,4 +3216,117 @@
and (a.status = '已完成')
)
</select>
<select id="countEquipInUseTimesForXaElevator" resultType="java.lang.Integer">
select
sum(inUseNumber)
from (
select
count(1) as inUseNumber
from
tzs_jg_change_registration_reform a,
tzs_jg_change_registration_reform_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '一级受理已驳回' and a.audit_status <![CDATA[ <> ]]> '使用单位已撤回' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_change_registration_transfer a,
tzs_jg_change_registration_transfer_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '一级受理已驳回' and a.audit_status <![CDATA[ <> ]]> '使用单位已撤回' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_change_registration_unit a,
tzs_jg_change_registration_unit_eq b
where
a.sequence_nbr = b.unit_change_registration_id
and b.equ_id = #{record}
and (a.status <![CDATA[ <> ]]> '使用单位待提交' and a.status <![CDATA[ <> ]]> '一级受理已驳回' and a.status <![CDATA[ <> ]]> '使用单位已撤回' and a.status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_enable_disable a,
tzs_jg_enable_disable_eq b
where
a.sequence_nbr = b.enable_disable_apply_id
and b.equ_id = #{record}
and (a.audit_status <![CDATA[ <> ]]> '已驳回' and a.audit_status <![CDATA[ <> ]]> '已撤回' and a.audit_status <![CDATA[ <> ]]> '待提交' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_maintain_notice a,
tzs_jg_maintain_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.notice_status <![CDATA[ <> ]]> '6614' and a.notice_status <![CDATA[ <> ]]> '6615' and a.notice_status <![CDATA[ <> ]]> '6610' and a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
count(1) as inUseNumber
from
tzs_jg_maintenance_contract a,
tzs_jg_maintenance_contract_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.status <![CDATA[ <> ]]> '已作废' and a.status <![CDATA[ <> ]]> '维保单位已驳回' and a.status <![CDATA[ <> ]]> '使用单位已撤回' and a.status <![CDATA[ <> ]]> '使用单位待提交')
UNION
select
count(1) as inUseNumber
from
tzs_jg_reform_notice a,
tzs_jg_reform_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.notice_status <![CDATA[ <> ]]> '6614' and a.notice_status <![CDATA[ <> ]]> '6615' and a.notice_status <![CDATA[ <> ]]> '6610' and a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
count(1) as inUseNumber
from
tzs_jg_scrap_cancel a,
tzs_jg_scrap_cancel_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.audit_status <![CDATA[ <> ]]> '使用单位已撤回' and a.audit_status <![CDATA[ <> ]]> '一级受理已驳回' and a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_transfer_notice a,
tzs_jg_transfer_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.notice_status <![CDATA[ <> ]]> '6614' and a.notice_status <![CDATA[ <> ]]> '6615' and a.notice_status <![CDATA[ <> ]]> '6610' and a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
count(1) as inUseNumber
from
tzs_jg_certificate_replenish a,
tzs_jg_certificate_replenish_eq b
where
a.sequence_nbr = b.certificate_replenish_id
and b.equ_id = #{record}
and (a.apply_status <![CDATA[ <> ]]> '6614' and a.apply_status <![CDATA[ <> ]]> '6615' and a.apply_status <![CDATA[ <> ]]> '6610' and a.apply_status <![CDATA[ <> ]]> '6617')
union
select
count(1) as inUseNumber
from
tzs_jg_resume_info
where
equ_id = #{record} and change_content = '设备编辑'
) a
</select>
</mapper>
......@@ -162,7 +162,7 @@ public class ChangeEquipImpactCertListener {
break;
case "receiveCompanyCode":
manage.setReceiveCompanyCode(afterValue);
manage.setReceiveOrgName(CommonCustomConverter.ReceiveCompanyCodeConverter.getNameByCode(afterValue));
manage.setReceiveOrgName(CommonCustomConverter.CompanyCodeConverter.getNameByCode(afterValue));
break;
default:
log.warn("未处理的USE_CERT字段:[{}]", columnKey);
......
......@@ -114,7 +114,7 @@ public class UseRegisterUpdateService {
String receiveCompanyCode = meta.getColumnNewValue();
if (receiveCompanyCode != null) {
jgUseRegistration.setReceiveCompanyCode(receiveCompanyCode);
jgUseRegistration.setReceiveOrgName(CommonCustomConverter.ReceiveCompanyCodeConverter.getNameByCode(receiveCompanyCode));
jgUseRegistration.setReceiveOrgName(CommonCustomConverter.CompanyCodeConverter.getNameByCode(receiveCompanyCode));
}
}
// 更新首次登记日期
......
......@@ -21,6 +21,7 @@ import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.*;
import com.yeejoin.amos.boot.module.common.api.converter.CommonCustomConverter;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dao.ExcelImportErrorLogDao;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
......@@ -34,7 +35,10 @@ import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CertificateStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationManageMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgVehicleInformationMapper;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
......@@ -80,6 +84,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -132,6 +138,7 @@ public class DataDockServiceImpl {
private final JgResumeInfoServiceImpl jgResumeInfoService;
private final IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService;
private final Map<String, Object> resultError = new HashMap<>();
private final String inUseError = "设备已经做过除历史登记外的其他业务或被用户编辑过!";
List<String> useInnerCodeList = new ArrayList<>();// 单位内部编号集合
List<String> equCodeList = new ArrayList<>();// 设备代码集合
List<String> factoryNumList = new ArrayList<>();// 出厂编码集合
......@@ -168,6 +175,8 @@ public class DataDockServiceImpl {
@Value("${pipeline.detail.path:/mixuap?appId=1742358052905971713&id=1867406434120003586&formType=detail&sequenceNbr=%s}")
private String pipelineRoutePath;
private final ExecutorService executorService = Executors.newFixedThreadPool(10);
/**
* 西安数据对接-保存设备信息
*
......@@ -349,10 +358,18 @@ public class DataDockServiceImpl {
* @param record
*/
private void saveUseInfo(Map<String, Object> equ, String record, String dataSource, String remark,CompanyBo company) {
log.error("数据===>{}", toJSONString(equ));
log.info("数据===>{}", toJSONString(equ));
IdxBizJgUseInfo oldUseInfo = idxBizJgUseInfoService.lambdaQuery()
.eq(IdxBizJgUseInfo::getRecord, record).one();
IdxBizJgUseInfo useInfo = JSON.parseObject(toJSONString(equ), IdxBizJgUseInfo.class);
if (!ValidationUtil.isEmpty(useInfo)) {
String provinceName = Objects.toString(equ.get("provinceName"),"");
if (!ValidationUtil.isEmpty(oldUseInfo)) {
useInfo.setSequenceNbr(oldUseInfo.getSequenceNbr());
}
if (ValidationUtil.isEmpty(oldUseInfo)) {
useInfo.setCreateDate(new Date());
}
String provinceName = Objects.toString(equ.get("provinceName"),"陕西省");
String provinceCode = "610000";
String cityName = Objects.toString(equ.get("cityName"),"");
String cityCode = "";
......@@ -391,6 +408,7 @@ public class DataDockServiceImpl {
equ.put("city",useInfo.getCity());
equ.put("county",useInfo.getCounty());
equ.put("factoryUseSiteStreet", streetCode);
equ.put("streetName", streetName);
equ.put("isXixian", "0");
if (!ValidationUtil.isEmpty(Objects.toString(equ.get("longitudeLatitude")))) {
String[] parts = Objects.toString(equ.get("longitudeLatitude"), "").split(",", -1);
......@@ -399,7 +417,6 @@ public class DataDockServiceImpl {
useInfo.setLongitudeLatitude(String.format("{\"latitude\":\"%s\",\"longitude\":\"%s\"}", latitude, longitude));
}
useInfo.setRecDate(new Date());
useInfo.setCreateDate(new Date());
useInfo.setRecord(record);
useInfo.setDataSource(dataSource);
useInfo.setIsNotEs("1");
......@@ -413,7 +430,7 @@ public class DataDockServiceImpl {
}
useInfo.setProjectContraptionId(Objects.toString(equ.get("projectContraptionId"), ""));
useInfo.setIsNotXiXian("0");
idxBizJgUseInfoService.save(useInfo);
idxBizJgUseInfoService.saveOrUpdate(useInfo);
equ.put("longitudeLatitude", useInfo.getLongitudeLatitude());
equ.put("useUnitCreditCode", useInfo.getUseUnitCreditCode());
equ.put("useUnitName", useInfo.getUseUnitName());
......@@ -430,12 +447,17 @@ public class DataDockServiceImpl {
*/
private void saveDesignInfo(Map<String, Object> equ, String record) {
log.error("数据===>{}", toJSONString(equ));
IdxBizJgDesignInfo oldDesignInfo = idxBizJgDesignInfoService.lambdaQuery()
.eq(IdxBizJgDesignInfo::getRecord, record).one();
IdxBizJgDesignInfo designInfo = JSON.parseObject(toJSONString(equ), IdxBizJgDesignInfo.class);
if (!ValidationUtil.isEmpty(designInfo)) {
if (!ValidationUtil.isEmpty(oldDesignInfo)) {
designInfo.setSequenceNbr(oldDesignInfo.getSequenceNbr());
}
designInfo.setRecord(record);
designInfo.setRecDate(new Date());
designInfo.setDesignIsComplete("2");
idxBizJgDesignInfoService.save(designInfo);
idxBizJgDesignInfoService.saveOrUpdate(designInfo);
}
}
......@@ -447,12 +469,17 @@ public class DataDockServiceImpl {
*/
private void saveFactoryInfo(Map<String, Object> equ, String record) {
log.error("数据===>{}", toJSONString(equ));
IdxBizJgFactoryInfo oldFactoryInfo = idxBizJgFactoryInfoService.lambdaQuery()
.eq(IdxBizJgFactoryInfo::getRecord, record).one();
IdxBizJgFactoryInfo factoryInfo = JSON.parseObject(toJSONString(equ), IdxBizJgFactoryInfo.class);
if (!ValidationUtil.isEmpty(factoryInfo)) {
if (!ValidationUtil.isEmpty(oldFactoryInfo)) {
factoryInfo.setSequenceNbr(oldFactoryInfo.getSequenceNbr());
}
factoryInfo.setRecord(record);
factoryInfo.setRecDate(new Date());
factoryInfo.setFactoryIsComplete("2");
idxBizJgFactoryInfoService.save(factoryInfo);
idxBizJgFactoryInfoService.saveOrUpdate(factoryInfo);
}
}
......@@ -462,17 +489,23 @@ public class DataDockServiceImpl {
* @param equ
* @param record
*/
private void saveRegisterInfo(Map<String, Object> equ, String record, String equList) {
private IdxBizJgRegisterInfo saveRegisterInfo(Map<String, Object> equ, String record, String equList) {
log.error("数据===>{}", toJSONString(equ));
IdxBizJgRegisterInfo oldRegisterInfo = idxBizJgRegisterInfoServiceImpl.lambdaQuery()
.eq(IdxBizJgRegisterInfo::getRecord, record).one();
IdxBizJgRegisterInfo registerInfo = JSON.parseObject(toJSONString(equ), IdxBizJgRegisterInfo.class);
if (!ValidationUtil.isEmpty(registerInfo)) {
if (!ValidationUtil.isEmpty(oldRegisterInfo)) {
registerInfo.setSequenceNbr(oldRegisterInfo.getSequenceNbr());
}
registerInfo.setRecord(record);
registerInfo.setRecDate(new Date());
registerInfo.setRegisterState("6045");
registerInfo.setIsCompleteXa("1");
registerInfo.setInInspectionPeriod("1");
idxBizJgRegisterInfoServiceImpl.save(registerInfo);
idxBizJgRegisterInfoServiceImpl.saveOrUpdateData(registerInfo);
}
return registerInfo;
}
/**
......@@ -483,71 +516,77 @@ public class DataDockServiceImpl {
*/
private void saveSupervisionInfo(Map<String, Object> equ, String record) {
log.error("数据===>{}", toJSONString(equ));
IdxBizJgSupervisionInfo oldSupervisionInfo = idxBizJgSupervisionInfoService.lambdaQuery()
.eq(IdxBizJgSupervisionInfo::getRecord, record).one();
IdxBizJgSupervisionInfo supervisionInfo = JSON.parseObject(toJSONString(equ), IdxBizJgSupervisionInfo.class);
log.error("数据===hou>{}", toJSONString(supervisionInfo));
// if (ObjectUtils.isEmpty(supervisionInfo)) return;
supervisionInfo.setRecord(record);
supervisionInfo.setRecDate(new Date());
if (!ValidationUtil.isEmpty(equ.get("orgBranchCode"))){
supervisionInfo.setOrgBranchCode(String.valueOf(equ.get("orgBranchCode")));
supervisionInfo.setOrgBranchName(String.valueOf(equ.get("orgBranchName")));
} else {
// 获取符合条件的公司 Map
Map<String, Map<String, String>> countyMap;
try {
countyMap = Optional.ofNullable(Privilege.companyClient.queryAgencyList("county").getResult())
.orElse(Collections.emptyList())
.stream()
.filter(v -> "1442687786065854466".equals(String.valueOf(v.getParentId())))
.collect(Collectors.toMap(
CompanyModel::getCompanyCode,
v -> Stream.of(new AbstractMap.SimpleEntry<>("companyName", v.getCompanyName()),
new AbstractMap.SimpleEntry<>("orgCode", v.getOrgCode()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
(a, b) -> a
));
} catch (Exception e) {
countyMap = Collections.emptyMap();
}
String companyCode = "1".equals(equ.get("equCodeType"))
? String.valueOf(equ.get("equCode"))
: String.valueOf(equ.get("originalEquCode"));
companyCode = companyCode.trim();
if (companyCode.length() > 9) {
companyCode = companyCode.substring(4, 10);
}
Map<String, String> companyInfo = countyMap.get(companyCode);
if (companyInfo != null) {
String companyName = companyInfo.get("companyName");
String orgCode = companyInfo.get("orgCode");
if (companyName != null && !companyName.trim().isEmpty()) {
supervisionInfo.setOrgBranchCode(orgCode);
supervisionInfo.setOrgBranchName(companyName);
}
if (!ValidationUtil.isEmpty(supervisionInfo)) {
if (!ValidationUtil.isEmpty(oldSupervisionInfo)) {
supervisionInfo.setSequenceNbr(oldSupervisionInfo.getSequenceNbr());
}
supervisionInfo.setRecord(record);
supervisionInfo.setRecDate(new Date());
if (!ValidationUtil.isEmpty(equ.get("orgBranchCode"))){
supervisionInfo.setOrgBranchCode(String.valueOf(equ.get("orgBranchCode")));
supervisionInfo.setOrgBranchName(String.valueOf(equ.get("orgBranchName")));
} else {
// 通过 useUnitCode 查询属地监管部门
String useUnitCode = String.valueOf(equ.get("useUnitCode")).trim();
CompanyModel companyModel = Privilege.companyClient.queryByCompanyCode(useUnitCode).getResult();
if (companyModel != null) {
String orgCode = companyModel.getOrgCode();
if (orgCode != null && orgCode.contains("*")) {
String superOrgCode = orgCode.substring(0, orgCode.lastIndexOf("*"));
supervisionInfo.setOrgBranchCode(superOrgCode);
Optional.ofNullable(Privilege.companyClient.queryByOrgcode(superOrgCode).getResult())
.map(result -> JSON.parseObject(toJSONString(result)).getString("compnay"))
.map(json -> JSON.parseObject(json, CompanyModel.class))
.map(CompanyModel::getCompanyName)
.ifPresent(supervisionInfo::setOrgBranchName);
// 获取符合条件的公司 Map
Map<String, Map<String, String>> countyMap;
try {
countyMap = Optional.ofNullable(Privilege.companyClient.queryAgencyList("county").getResult())
.orElse(Collections.emptyList())
.stream()
.filter(v -> "1442687786065854466".equals(String.valueOf(v.getParentId())))
.collect(Collectors.toMap(
CompanyModel::getCompanyCode,
v -> Stream.of(new AbstractMap.SimpleEntry<>("companyName", v.getCompanyName()),
new AbstractMap.SimpleEntry<>("orgCode", v.getOrgCode()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
(a, b) -> a
));
} catch (Exception e) {
countyMap = Collections.emptyMap();
}
String companyCode = "1".equals(equ.get("equCodeType"))
? String.valueOf(equ.get("equCode"))
: String.valueOf(equ.get("originalEquCode"));
companyCode = companyCode.trim();
if (companyCode.length() > 9) {
companyCode = companyCode.substring(4, 10);
}
Map<String, String> companyInfo = countyMap.get(companyCode);
if (companyInfo != null) {
String companyName = companyInfo.get("companyName");
String orgCode = companyInfo.get("orgCode");
if (companyName != null && !companyName.trim().isEmpty()) {
supervisionInfo.setOrgBranchCode(orgCode);
supervisionInfo.setOrgBranchName(companyName);
}
} else {
supervisionInfo.setOrgBranchCode("50*52");
supervisionInfo.setOrgBranchName("西安市市场监督管理局");
// 通过 useUnitCode 查询属地监管部门
String useUnitCode = String.valueOf(equ.get("useUnitCode")).trim();
CompanyModel companyModel = Privilege.companyClient.queryByCompanyCode(useUnitCode).getResult();
if (companyModel != null) {
String orgCode = companyModel.getOrgCode();
if (orgCode != null && orgCode.contains("*")) {
String superOrgCode = orgCode.substring(0, orgCode.lastIndexOf("*"));
supervisionInfo.setOrgBranchCode(superOrgCode);
Optional.ofNullable(Privilege.companyClient.queryByOrgcode(superOrgCode).getResult())
.map(result -> JSON.parseObject(toJSONString(result)).getString("compnay"))
.map(json -> JSON.parseObject(json, CompanyModel.class))
.map(CompanyModel::getCompanyName)
.ifPresent(supervisionInfo::setOrgBranchName);
}
} else {
supervisionInfo.setOrgBranchCode("50*52");
supervisionInfo.setOrgBranchName("西安市市场监督管理局");
}
}
}
}
idxBizJgSupervisionInfoService.save(supervisionInfo);
idxBizJgSupervisionInfoService.saveOrUpdate(supervisionInfo);
equ.put("orgBranchCode", supervisionInfo.getOrgBranchCode() + "_" + supervisionInfo.getOrgBranchName());
}
......@@ -559,15 +598,20 @@ public class DataDockServiceImpl {
*/
private void saveOtherInfo(Map<String, Object> equ, String record, String equList) {
log.error("数据===>{}", toJSONString(equ));
IdxBizJgOtherInfo oldOtherInfo = idxBizJgOtherInfoService.lambdaQuery()
.eq(IdxBizJgOtherInfo::getRecord, record).one();
IdxBizJgOtherInfo otherInfo = JSON.parseObject(toJSONString(equ), IdxBizJgOtherInfo.class);
if (!ValidationUtil.isEmpty(otherInfo)) {
if (!ValidationUtil.isEmpty(oldOtherInfo)) {
otherInfo.setSequenceNbr(oldOtherInfo.getSequenceNbr());
}
otherInfo.setRecord(record);
otherInfo.setClaimStatus("已认领");
otherInfo.setRecDate(new Date());
if (EquipmentClassifityEnum.DT.getCode().equals(equList)) {
otherInfo.setCode96333Type(ValidationUtil.isEmpty(equ.get("code96333")) ? "2" : "1");
}
idxBizJgOtherInfoService.save(otherInfo);
idxBizJgOtherInfoService.saveOrUpdate(otherInfo);
}
}
......@@ -730,11 +774,17 @@ public class DataDockServiceImpl {
*/
private void saveElevatorParams(Map<String, Object> equ, String record) {
log.error("数据===>{}", toJSONString(equ));
IdxBizJgTechParamsElevator oldTechParams = iIdxBizJgTechParamsElevatorService.lambdaQuery()
.eq(IdxBizJgTechParamsElevator::getRecord, record)
.one();
IdxBizJgTechParamsElevator equipTechParamElevator = JSON.parseObject(toJSONString(equ), IdxBizJgTechParamsElevator.class);
if (!ValidationUtil.isEmpty(equipTechParamElevator)) {
if (!ValidationUtil.isEmpty(oldTechParams)) {
equipTechParamElevator.setSequenceNbr(oldTechParams.getSequenceNbr());
}
equipTechParamElevator.setRecord(record);
equipTechParamElevator.setRecDate(new Date());
iIdxBizJgTechParamsElevatorService.saveOrUpdateData(equipTechParamElevator);
iIdxBizJgTechParamsElevatorService.saveOrUpdate(equipTechParamElevator);
}
}
......@@ -2576,29 +2626,32 @@ public class DataDockServiceImpl {
*/
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public boolean saveElevatorData(List<Map<String, Object>> equLists) {
String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct();
String token = RequestContext.getToken();
String exeUserId = RequestContext.getExeUserId();
public Set<String> saveElevatorData(List<Map<String, Object>> equLists) {
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
Set<String> recordSet = new HashSet<>();
CompletableFuture.allOf(
equLists.parallelStream().map(equ -> CompletableFuture.runAsync(() -> {
RequestContext.setAppKey(appKey);
RequestContext.setProduct(product);
RequestContext.setToken(token);
RequestContext.setExeUserId(exeUserId);
String record = saveElevatorDataInTransaction(equ, "jg_his_xa", null);
recordSet.add(record);
})).toArray(CompletableFuture[]::new)
).join();
Set<String> inUseRecordSet = new HashSet<>();
try {
CompletableFuture.allOf(
equLists.parallelStream().map(equ -> CompletableFuture.runAsync(() -> {
contextWrapper.apply();
String record = saveElevatorDataInTransaction(equ, "jg_his_xa", null);
if (inUseError.equals(record)) {
inUseRecordSet.add(record);
} else {
recordSet.add(record);
}
}, executorService)).toArray(CompletableFuture[]::new)
).join();
} catch (Exception e) {
throw new RuntimeException(e);
}
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
}
});
return Boolean.TRUE;
return inUseRecordSet;
}
@GlobalTransactional(rollbackFor = Exception.class)
......@@ -2610,10 +2663,18 @@ public class DataDockServiceImpl {
String useRegistrationCode = Optional.ofNullable(equ.get("useOrgCode")).map(String::valueOf).orElse("").trim();
try {
if (!equList.isEmpty()) {
// 判断设备是否已经做过除历史登记外的其他业务,如果做了其他业务则不能更新并记录反馈
Integer useCount = commonMapper.countEquipInUseTimesForXaElevator();
if (useCount > 0) {
return inUseError;
}
IdxBizJgUseInfo oldUseInfo = idxBizJgUseInfoService.getOne(new QueryWrapper<IdxBizJgUseInfo>().eq("record", record));
saveUseInfo(equ, record, dataSource, remark, null);
saveDesignInfo(equ, record);
saveFactoryInfo(equ, record);
saveRegisterInfo(equ, record, equList);
IdxBizJgRegisterInfo registerInfo = saveRegisterInfo(equ, record, equList);
// 西安导入电梯属地监管部门处理
handleSupervisionOffice(equ);
saveSupervisionInfo(equ, record);
saveOtherInfo(equ, record, equList);
saveInspectInfo(equ, record);
......@@ -2621,14 +2682,19 @@ public class DataDockServiceImpl {
saveEquInfoToEs(record, isCompleteXa);
this.saveInstallInfo(equ);//安装信息
this.historyEquUpdateMaintenanceInfo(equ);//维保信息
if (!useRegistrationCode.isEmpty()){
// oldUseInfo为空表示是新设备,新设备如果有使用登记证号则做历史登记,否则只进行上面的设备信息更新
if (!useRegistrationCode.isEmpty() && ValidationUtil.isEmpty(oldUseInfo)) {
this.handleHistoryEquip(equ);//历史登记
}
} else if (!businessId.isEmpty()){
// oldUseInfo不为空表示是平台已有设备,已有历史设备则更新历史单据信息。
if (!ValidationUtil.isEmpty(oldUseInfo)) {
updateHistoryInfo(equ, oldUseInfo, registerInfo);
}
} else if (!businessId.isEmpty()) {
this.saveResumeInfo(equ);
equ.put("record", equ.get("resumeSeq"));
equ.put("xaSerial", equ.get("resumeSeq"));
}else{
} else {
String orgBranchName = (String) Optional.ofNullable(equ.get("supervisionOffice"))
.orElseGet(() -> equ.get("supervisionDepartment"));
String orgBranchCode = (String) Optional.ofNullable(equ.get("supervisionOfficeCode"))
......@@ -2648,6 +2714,110 @@ public class DataDockServiceImpl {
}
}
private void updateHistoryInfo(Map<String, Object> equ, IdxBizJgUseInfo oldUseInfo, IdxBizJgRegisterInfo registerInfo) {
// 更新历史登记单数据、登记单对应历史表数据
// 安全管理员
if (equ.containsKey("safetyManager")) {
equ.put("safetyManagerName", equ.get("safetyManager"));
}
equ.put("equCode", registerInfo.getEquCode());
JgUseRegistration jgUseRegistration = jgUseRegistrationServiceImpl.lambdaQuery().eq(JgUseRegistration::getUseRegistrationCode, equ.get("useOrgCode")).eq(JgUseRegistration::getIsDelete, Boolean.FALSE).one();
if (!ObjectUtils.isEmpty(equ.get("inspectOrgCode"))) {
jgUseRegistration.setInspectUnitCreditCode(equ.get("inspectOrgCode").toString());
}
if (!ObjectUtils.isEmpty(equ.get("inspectOrgName"))) {
jgUseRegistration.setInspectUnitName(equ.get("inspectOrgName").toString());
}
jgUseRegistration.setUseAddress(
Stream.of("provinceName", "cityName", "countyName", "streetName", "address")
.map(key -> Objects.toString(equ.get(key), ""))
.collect(Collectors.joining())
);
jgUseRegistration.setRegDate(DateUtil.parse((String) equ.get("oRegDate"), DatePattern.NORM_DATE_PATTERN));
jgUseRegistration.setSupervisionOrgCode(equ.get("orgBranchCode").toString());
jgUseRegistration.setReceiveCompanyCode(equ.get("oRegUnit").toString());
String receiveCompanyName = CommonCustomConverter.CompanyCodeConverter.getNameByCode(equ.get("oRegUnit").toString());
jgUseRegistration.setReceiveOrgName(receiveCompanyName);
equ.put("receiveOrgName", receiveCompanyName);
jgUseRegistrationServiceImpl.saveOrUpdate(jgUseRegistration);
this.updateRegistrationManagementInfo(equ, jgUseRegistration.getSupervisoryCode());
this.updateHistory(equ, equ.get("record").toString(), String.valueOf(jgUseRegistration.getSequenceNbr()), jgUseRegistration.getSupervisoryCode());
}
private void updateRegistrationManagementInfo(Map<String, Object> equ, String supervisoryCode) {
JgUseRegistrationManage jgUseRegistrationManagement = jgUseRegistrationManageService.lambdaQuery().
eq(JgUseRegistrationManage::getUseRegistrationCode, supervisoryCode).
eq(JgUseRegistrationManage::getIsDelete, Boolean.FALSE).one();
if (!ValidationUtil.isEmpty(jgUseRegistrationManagement)) {
// 更新证表使用信息
jgUseRegistrationManagement.setReceiveOrgName(equ.get("receiveOrgName").toString());
jgUseRegistrationManagement.setReceiveCompanyCode(equ.get("oRegUnit").toString());
jgUseRegistrationManagement.setUseUnitName(equ.get("useUnitName").toString());
jgUseRegistrationManagement.setUseUnitCreditCode(equ.get("useUnitCode").toString());
jgUseRegistrationManagement.setSuperviseOrgCode(equ.get("orgBranchCode").toString());
jgUseRegistrationManagement.setSuperviseOrgName(equ.get("orgBranchName").toString().split("_", 2)[1]);
jgUseRegistrationManagement.setIsDoBusiness("1");
jgUseRegistrationManageService.saveOrUpdate(jgUseRegistrationManagement);
// 更新证表记录信息
JgCertificateChangeRecord jgUseRegistrationRecord = certificateChangeRecordService.lambdaQuery().
eq(JgCertificateChangeRecord::getUseRegistrationCode, supervisoryCode).
eq(JgCertificateChangeRecord::getRegType, "使用登记").
eq(JgCertificateChangeRecord::getIsDelete, Boolean.FALSE).one();
if (!ValidationUtil.isEmpty(jgUseRegistrationRecord)) {
jgUseRegistrationRecord.setReceiveOrgName(equ.get("receiveOrgName").toString());
jgUseRegistrationRecord.setReceiveCompanyCode(equ.get("oRegUnit").toString());
jgUseRegistrationRecord.setUseUnitName(equ.get("useUnitName").toString());
jgUseRegistrationRecord.setUseUnitCreditCode(equ.get("useUnitCode").toString());
certificateChangeRecordService.saveOrUpdate(jgUseRegistrationRecord);
}
}
}
private void handleSupervisionOffice(Map<String, Object> equ) {
Optional.ofNullable(equ.get("orgBranchName")).ifPresent(orgBranchName -> {
String companyOrgCode = CommonCustomConverter.CompanyCodeConverter.getCompanyOrgCodeByName(orgBranchName.toString());
List<String> orgBranchNames = Arrays.asList(orgBranchName.toString().split("#"));
if (!ValidationUtil.isEmpty(orgBranchNames)) {
equ.put("orgBranchName", orgBranchNames.get(orgBranchNames.size() - 1));
equ.put("orgBranchCode", companyOrgCode);
}
});
}
/**
* 根据公司名称递归查找机构代码
* @param nodeList 节点列表
* @param companyName 公司名称
* @return 机构代码,未找到返回null
*/
private String findOrgCodeByCompanyName(List<LinkedHashMap> nodeList, String companyName) {
if (nodeList == null || companyName == null) {
return null;
}
for (LinkedHashMap node : nodeList) {
String name = (String) node.get("companyName");
String orgCode = (String) node.get("orgCode");
// 如果找到匹配的公司名称,返回对应的机构代码
if (companyName.equals(name) && orgCode != null) {
return orgCode;
}
// 递归查找子节点
List<LinkedHashMap> children = (List<LinkedHashMap>) node.get("children");
if (children != null && !children.isEmpty()) {
String result = findOrgCodeByCompanyName(children, companyName);
if (result != null) {
return result;
}
}
}
return null;
}
@GlobalTransactional(rollbackFor = Exception.class)
public void updateOrgBranchInfo(String record, String orgBranchName, String orgBranchCode) {
this.updateSupervisionInfo(record, orgBranchName, orgBranchCode);
......@@ -2668,7 +2838,6 @@ public class DataDockServiceImpl {
.set(JgUseRegistrationManage::getSuperviseOrgCode, orgBranchCode)
.set(JgUseRegistrationManage::getSuperviseOrgName, orgBranchName)
.eq(JgUseRegistrationManage::getUseRegistrationCode, useOrgCode)
.eq(JgUseRegistrationManage::getIsDoBusiness, 0)
));
Optional.ofNullable(
jgRelationEquipMapper.selectOne(
......@@ -2720,7 +2889,7 @@ public class DataDockServiceImpl {
log.info("date转化失败");
}
info.setRepairInform(ValidationUtil.isEmpty(map.get("maintenanceContract")) ? null : toJSONString(map.get("maintenanceContract")));
idxBizJgMaintenanceRecordInfoService.save(info);
idxBizJgMaintenanceRecordInfoService.saveOrUpdate(info);
}
/**
......@@ -2741,7 +2910,7 @@ public class DataDockServiceImpl {
//使用登记证编号判断是否使用未来系统生成编号
idxBizJgRegisterInfoService.checkUseRegistrationCode(useRegistrationCode, "set");
JgUseRegistration jgUseRegistration = new JgUseRegistration();
jgUseRegistration.setRegDate(new Date());
jgUseRegistration.setRegDate(DateUtil.parse((String) map.get("oRegDate"), DatePattern.NORM_DATE_PATTERN));
if (map.containsKey("orgBranchCode")) {
// 监察处置机构代码
......@@ -2808,6 +2977,8 @@ public class DataDockServiceImpl {
jgUseRegistrationServiceImpl.save(jgUseRegistration);
jgRelationEquip.setEquipTransferId(jgUseRegistration.getSequenceNbr() + "");
jgRelationEquipMapper.insert(jgRelationEquip);
// 做完历史登记设备改为已纳管
idxBizJgUseInfoService.lambdaUpdate().eq(IdxBizJgUseInfo::getRecord, equipId).set(IdxBizJgUseInfo::getIsIntoManagement, Boolean.TRUE);
// 暂存历史表
updateHistory(map, map.get("record").toString(), String.valueOf(jgUseRegistration.getSequenceNbr()), jgUseRegistration.getSupervisoryCode());
// 历史设备
......@@ -2915,7 +3086,7 @@ public class DataDockServiceImpl {
manage.setUseUnitCreditCode(jgUseRegistration.getUseUnitCreditCode());
manage.setReceiveCompanyCode(jgUseRegistration.getReceiveCompanyCode());
manage.setManageType(jgUseRegistration.getManageType());
manage.setIsDoBusiness("0"); // 不可做业务
manage.setIsDoBusiness("1"); // 1可做业务
// 生成证书编号
equType.put("equDefineCode",Objects.toString(map.get("equDefine")));
manage.setCertificateNo(commonService.generateCertificateNo(equType, new Date(), (String) map.get("county")));
......@@ -3014,18 +3185,24 @@ public class DataDockServiceImpl {
}
private void saveInstallInfo(Map<String, Object> equ) {
IdxBizJgConstructionInfo oldConstructionInfo = idxBizJgConstructionInfoService.lambdaQuery().eq(IdxBizJgConstructionInfo::getRecord, equ.get("record")).one();
IdxBizJgConstructionInfo constructionInfo = JSON.parseObject(toJSONString(equ), IdxBizJgConstructionInfo.class);
constructionInfo.setUscUnitName(ValidationUtil.isEmpty(equ.get("installUnitName")) ? null : String.valueOf(equ.get("installUnitName")));
constructionInfo.setUscUnitCreditCode(ValidationUtil.isEmpty(equ.get("installUnitCreditCode")) ? null : String.valueOf(equ.get("installUnitCreditCode")));
constructionInfo.setConstructionLeaderName(ValidationUtil.isEmpty(equ.get("installLeaderName")) ? null : String.valueOf(equ.get("installLeaderName")));
constructionInfo.setConstructionLeaderPhone(ValidationUtil.isEmpty(equ.get("installLeaderPhone")) ? null : String.valueOf(equ.get("installLeaderPhone")));
try {
constructionInfo.setUscDate(ValidationUtil.isEmpty(equ.get("installStartDate")) ? null : DateUtils.dateParse((String) equ.get("installStartDate"), DateUtils.DATE_PATTERN));
} catch (ParseException e) {
log.error(e.getMessage(), e);
throw new BadRequest("安装日期时间转化错误");
if (!ValidationUtil.isEmpty(constructionInfo)) {
if (!ValidationUtil.isEmpty(oldConstructionInfo)) {
constructionInfo.setSequenceNbr(oldConstructionInfo.getSequenceNbr());
}
constructionInfo.setUscUnitName(ValidationUtil.isEmpty(equ.get("installUnitName")) ? null : String.valueOf(equ.get("installUnitName")));
constructionInfo.setUscUnitCreditCode(ValidationUtil.isEmpty(equ.get("installUnitCreditCode")) ? null : String.valueOf(equ.get("installUnitCreditCode")));
constructionInfo.setConstructionLeaderName(ValidationUtil.isEmpty(equ.get("installLeaderName")) ? null : String.valueOf(equ.get("installLeaderName")));
constructionInfo.setConstructionLeaderPhone(ValidationUtil.isEmpty(equ.get("installLeaderPhone")) ? null : String.valueOf(equ.get("installLeaderPhone")));
try {
constructionInfo.setUscDate(ValidationUtil.isEmpty(equ.get("installStartDate")) ? null : DateUtils.dateParse((String) equ.get("installStartDate"), DateUtils.DATE_PATTERN));
} catch (ParseException e) {
log.error(e.getMessage(), e);
throw new BadRequest("安装日期时间转化错误");
}
idxBizJgConstructionInfoService.saveOrUpdate(constructionInfo);
}
idxBizJgConstructionInfoService.getBaseMapper().insert(constructionInfo);
}
private void saveInspectInfo(Map<String, Object> equ, String record) {
......
......@@ -5680,4 +5680,8 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
public void updateBatchByRecord(List<IdxBizJgRegisterInfo> toUpdateRegisterInfoList) {
toUpdateRegisterInfoList.forEach(info -> super.update(info, new LambdaUpdateWrapper<IdxBizJgRegisterInfo>().eq(IdxBizJgRegisterInfo::getRecord, info.getRecord())));
}
public boolean saveOrUpdateData(IdxBizJgRegisterInfo registerInfo) {
return super.saveOrUpdateWithNull(registerInfo);
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
......@@ -309,7 +310,7 @@ public class SafetyProblemTracingServiceImpl extends BaseService<SafetyProblemTr
// 如果设备存在并且没有新的问题,则更新Other表和ES状态
if (!ValidationUtil.isEmpty(detail) && ValidationUtil.isEmpty(newSafetyProblemTracings)) {
// 获取设备问题源记录
Set<String> records = newSafetyProblemTracings.stream().map(SafetyProblemTracing::getSourceId).collect(Collectors.toSet());
Set<String> records = Sets.newHashSet(detail.get("SEQUENCE_NBR").toString());
// 更新Other表和ES状态
updateOtherTableAndES(records);
}
......
......@@ -393,7 +393,7 @@ public class EquipInfoVo {
private String chargingMedium;
@ExcelProperty(value = {"技术参数", "燃烧方式"})
private String combustionMode;
@ExcelProperty(value = {"技术参数", "设备保护等级(防爆)"}, converter = EquipFieldCustomConverter.EplosionproofGradeConverter.class)
@ExcelProperty(value = {"技术参数", "设备保护等级(防爆)"}, converter = EquipFieldCustomConverter.ExplosionProofGradeConverter.class)
private String protectGrade;
@ExcelProperty(value = {"技术参数", "自由端高度"})
private String heightFreeEnd;
......@@ -433,7 +433,7 @@ public class EquipInfoVo {
private String designThermalEfficiency;
@ExcelProperty(value = {"技术参数", "运载索"}, converter = EquipFieldCustomConverter.CarrierLineConverter.class)
private String carrierLine;
@ExcelProperty(value = {"技术参数", "区域防爆等级"}, converter = EquipFieldCustomConverter.EplosionproofGradeConverter.class)
@ExcelProperty(value = {"技术参数", "区域防爆等级"}, converter = EquipFieldCustomConverter.ExplosionProofGradeConverter.class)
private String explosionproofGrade;
@ExcelProperty(value = {"技术参数", "支架数目"})
private String supportsCount;
......
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