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 {
/**
......
......@@ -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));
}
}
// 更新首次登记日期
......
......@@ -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