Commit c8027751 authored by 韩桐桐's avatar 韩桐桐

fix(jg):历史车用气瓶设备新增及登记处理使用登记证重复无法录入的问题

parent d6fbde09
......@@ -203,5 +203,25 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
*/
Integer countBizNumAfterUseReg(@Param("record") String record);
/**
* 车用气瓶-使用登记证编号全库唯一校验
*
* @param useRegistrationCode 使用登记证编号
* @param record 设备record
* @return 匹配到的数据,包含设备的企业信息
*/
List<Map<String, String>> useRegCertAccountUniqueWithVehGasCyl(@Param("useRegistrationCode") String useRegistrationCode,
@Param("record") String record);
/**
* 车用气瓶-车辆VIN全库唯一校验
*
* @param VIN 车辆VIN码
* @param record 设备record
* @return 匹配到的数据,包含设备的企业信息
*/
List<Map<String, String>> VINAccountUniqueWithVehGasCyl(@Param("VIN") String VIN,
@Param("record") String record);
}
......@@ -2516,4 +2516,38 @@
ne.record = #{record}
)
</select>
<select id="useRegCertAccountUniqueWithVehGasCyl" resultType="java.util.Map">
SELECT jui."USE_UNIT_CREDIT_CODE" as useUnitCreditCode
FROM idx_biz_jg_register_info jri
LEFT JOIN idx_biz_jg_other_info joi ON joi."RECORD" = jri."RECORD"
LEFT JOIN idx_biz_jg_use_info jui ON jui."RECORD" = jri."RECORD"
<where>
<if test="useRegistrationCode != null and useRegistrationCode != ''">
jri."USE_ORG_CODE" = #{useRegistrationCode}
</if>
<if test="record != null and record != ''">
AND jri."RECORD" != #{record}
</if>
AND joi.CLAIM_STATUS = '已认领'
</where>
</select>
<select id="VINAccountUniqueWithVehGasCyl" resultType="java.util.Map">
SELECT jui."USE_UNIT_CREDIT_CODE" as useUnitCreditCode
FROM idx_biz_jg_register_info jri
LEFT JOIN idx_biz_jg_use_info jui ON jui."RECORD" = jri."RECORD"
LEFT JOIN idx_biz_jg_other_info joi ON joi."RECORD" = jri."RECORD"
LEFT JOIN idx_biz_jg_tech_params_vessel jtpv ON jtpv."RECORD" = jri."RECORD"
<where>
<if test="VIN != null and VIN != ''">
AND jtpv."VIN" = #{VIN}
</if>
<if test="record != null and record != ''">
AND jri."RECORD" != #{record}
</if>
AND joi.CLAIM_STATUS = '已认领'
</where>
</select>
</mapper>
......@@ -677,6 +677,7 @@
ui."USE_INNER_CODE" useInnerCode,
ri."EQU_CODE" equCode,
ri."EQU_LIST" equList,
ri."USE_ORG_CODE" useOrgCode,
(select name from tz_equipment_category where code = ri."EQU_LIST") equListName,
ri."EQU_CATEGORY" equCategory,
(select name from tz_equipment_category where code = ri."EQU_CATEGORY") equCategoryName,
......@@ -691,6 +692,7 @@
(select name from cb_data_dictionary where code = pv."CHARGING_MEDIUM" and type = 'FILLING_MEDIUM') chargingMedium,
pv."NOMINAL_WORKING_PRESSURE" nominalWorkingPressure,
pv."SINGLE_BOTTLE_VOLUME" singleBottleVolume,
pv."VIN" vin,
to_char((select INSPECT_DATE from idx_biz_jg_inspection_detection_info where "RECORD" = ui."RECORD" ORDER BY REC_DATE DESC limit 1), 'YYYY-MM-DD') inspectDate,
to_char((select NEXT_INSPECT_DATE from idx_biz_jg_inspection_detection_info where "RECORD" = ui."RECORD" ORDER BY REC_DATE DESC limit 1), 'YYYY-MM-DD') nextInspectDate
FROM
......@@ -749,6 +751,12 @@
<if test="jsonObject.record != null and jsonObject.record != ''">
and ui."RECORD" = #{jsonObject.record}
</if>
<if test="jsonObject.useRegistrationCode != null and jsonObject.useRegistrationCode != ''">
and ri."USE_ORG_CODE" = #{jsonObject.useRegistrationCode}
</if>
<if test="jsonObject.identificationCode != null and jsonObject.identificationCode != ''">
and pv."VIN" = #{jsonObject.identificationCode}
</if>
<if test="jsonObject.record == null">
and not exists(SELECT 1 FROM tzs_jg_vehicle_information v, tzs_jg_vehicle_information_eq ve WHERE
v.sequence_nbr = ve.vehicle_id AND ve.equ_id = ui."RECORD" and v.status !='使用单位待提交' and v.status
......
......@@ -398,8 +398,8 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
check96333Code(equipmentInfoForm);
// 气瓶 校验制造单位统一信用代码与出场编码唯一
checkFactoryNumUniqueWithGasCylinder(equipmentInfoForm, record);
// 历史(车用气瓶)设备校验使用登记证编号全库唯一
hisEquCheckUseRegistrationCodeUniqueness(equipmentInfoForm);
// 历史(车用气瓶)设备校验使用登记证编号 VIN 全库唯一
hisEquCheckUseRegCodeAndVINUniqueness(equipmentInfoForm, record);
// 检测是否三环系统中的车用气瓶数据 不让三环系统数据通过设备新增方式进来
// checkIsSanHanData(equipmentInfoForm);
} catch (Exception e) {
......@@ -452,6 +452,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
/**
* 检测是否三环系统中的车用气瓶数据 不让三环系统数据通过设备新增方式进来
*
* @param equipmentInfoForm 入参
*/
private void checkIsSanHanData(LinkedHashMap<?, ?> equipmentInfoForm) {
......@@ -512,15 +513,36 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
}
private void hisEquCheckUseRegistrationCodeUniqueness(LinkedHashMap<?, ?> equipmentInfoForm) {
// 历史(车用气瓶)设备校验使用登记证编号全库唯一
String dataSource = (String) equipmentInfoForm.get(DATA_SOURCE);
String record = (String) equipmentInfoForm.get(RECORD);
String useRegistrationCode = (String) equipmentInfoForm.get("useRegistrationCode");
if (!ValidationUtil.isEmpty(dataSource) && dataSource.contains("his") && !ValidationUtil.isEmpty(useRegistrationCode)) {
Boolean unique = commonService.useRegistrationCertificateAccountUnique(useRegistrationCode, ValidationUtil.isEmpty(record) ? null : record);
if (unique) {
throw new BadRequest("使用登记证编号已存在,请重新输入!");
private void hisEquCheckUseRegCodeAndVINUniqueness(LinkedHashMap<?, ?> equipmentInfoForm, String record) {
// 历史(车用气瓶)设备校验使用登记证编号 VIN 全库唯一
if ("2000".equals(equipmentInfoForm.get(EQU_LIST)) && "2300".equals(equipmentInfoForm.get(EQU_CATEGORY)) && "23T0".equals(equipmentInfoForm.get(EQU_DEFINE)) && "1".equals(equipmentInfoForm.get(WHETHER_VEHICLE_CYLINDER))) {
String dataSource = (String) equipmentInfoForm.get(DATA_SOURCE);
String VIN = (String) equipmentInfoForm.get("identificationCode");
String useRegistrationCode = (String) equipmentInfoForm.get("useRegistrationCode");
if (ValidationUtil.isEmpty(dataSource) || ValidationUtil.isEmpty(VIN) || ValidationUtil.isEmpty(useRegistrationCode)) {
throw new BadRequest("参数异常!");
}
if (dataSource.contains("his")) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String companyType = reginParams.getCompany().getCompanyType();
String companyCode = "个人主体".equals(companyType) ? reginParams.getCompany().getCompanyCode().split("_")[1] : reginParams.getCompany().getCompanyCode();
// 匹配使用登记证编号
List<Map<String, String>> useRegMapList = commonMapper.useRegCertAccountUniqueWithVehGasCyl(useRegistrationCode, record);
boolean hasUseReg = !useRegMapList.isEmpty();
boolean certificateOfTheEnterprise = hasUseReg ? JSON.toJSONString(useRegMapList).contains(companyCode) : Boolean.FALSE;
// 匹配车辆VIN码
List<Map<String, String>> VINMapList = commonMapper.VINAccountUniqueWithVehGasCyl(VIN, record);
boolean hasVIN = !VINMapList.isEmpty();
boolean VINOfTheEnterprise = hasVIN ? JSON.toJSONString(useRegMapList).contains(companyCode) : Boolean.FALSE;
// 无证无VIN 和 本企业的证本企业的VIN 两种情况可以放行
if (!((!hasUseReg && !hasVIN) || (certificateOfTheEnterprise && VINOfTheEnterprise))) {
if (log.isDebugEnabled()) {
log.info("历史车用气瓶==输入的==>使用登记证编号:{},车辆VIN码:{}", useRegistrationCode, VIN);
log.info("历史车用气瓶==匹配到的==>使用登记证编号:{},车辆VIN码:{}", JSON.toJSONString(useRegMapList), JSON.toJSONString(VINMapList));
log.info("历史车用气瓶====>是否本企业使用登记证编号:{},是否本企业车辆VIN码:{}", certificateOfTheEnterprise, VINOfTheEnterprise);
}
throw new BadRequest("使用登记证证号和车辆VIN码不匹配,请联系管理员!");
}
}
}
}
......@@ -544,7 +566,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
throw new BadRequest(e.getMessage());
}
private void checkForEquipEdit(String record) {
private void checkForEquipEdit(String record) {
// 标识编辑
if (!ValidationUtil.isEmpty(record)) {
Integer inUseTime = commonService.countEquipInUseTimesForEdit(record);
......@@ -935,7 +957,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
useInfoMap.put("USE_ADDRESS", useInfo.getAddress());
useInfoMap.put("FULL_ADDRESS", useInfo.getAddress());
}
//bug--22325 一码通过来的数据去掉【DATA_SOURCE】,保存设备时 【batchSubmitOrUpdate方法】 会对 DATA_SOURCE字段进行处理
// bug--22325 一码通过来的数据去掉【DATA_SOURCE】,保存设备时 【batchSubmitOrUpdate方法】 会对 DATA_SOURCE字段进行处理
// 一码通数据:"must": [
// {
// "term": {
......@@ -1599,7 +1621,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
// 历史设备且做过历史登记
BoolQueryBuilder hisBuilder = QueryBuilders.boolQuery();
hisBuilder.must(QueryBuilders.prefixQuery("DATA_SOURCE", "jg_his"));
hisBuilder.mustNot(QueryBuilders.prefixQuery("DATA_SOURCE", "jg_his_ymt"));//排除一码通设备
hisBuilder.mustNot(QueryBuilders.prefixQuery("DATA_SOURCE", "jg_his_ymt"));// 排除一码通设备
hisBuilder.must(QueryBuilders.termQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
dBuilder.should(hisBuilder);
// 或新设备
......@@ -1635,7 +1657,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
// 查询 使用登记【可选设备列表】【(EQU_STATUS=== null || "" ) && (USE_ORG_CODE(使用登记证编号) ==="" || null)】
BoolQueryBuilder syBuilder = QueryBuilders.boolQuery();
syBuilder.mustNot(QueryBuilders.existsQuery("EQU_STATE"));
//syBuilder.mustNot(QueryBuilders.wildcardQuery("USE_ORG_CODE", "*"));
// syBuilder.mustNot(QueryBuilders.wildcardQuery("USE_ORG_CODE", "*"));
boolMust.must(syBuilder);
this.setRepeatUsedCheckFilterParam(boolMust, companyCode, "useRegistration");
} else if (ValidationUtil.equals(queryType, "FINISH_SY")) {
......@@ -2416,7 +2438,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
inspectionDetectionInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("INSPECTIONDETECTIONINFO_SEQ")));
iIdxBizJgInspectionDetectionInfoService.saveOrUpdateData(inspectionDetectionInfo);
}
} else {//更新时 固定式压力容器(2100)和 气瓶(2300)工业管道(8300) 可以更新检验检测信息
} else {// 更新时 固定式压力容器(2100)和 气瓶(2300)工业管道(8300) 可以更新检验检测信息
if (CylinderTypeEnum.CYLINDER.getCode().equals(equCategory) || "2100".equals(equCategory) || "8300".equals(equCategory)) {
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgInspectionDetectionInfo.class);
List<Map<String, Object>> inspectionAndTestingInstitutions = commonService.getUnitListByType("inspection", "gasCylindersForCars");
......@@ -2812,6 +2834,8 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Override
public Page<JSONObject> queryEquipCanUsedByVesselPageHistory(JSONObject jsonObject) {
Optional.ofNullable(jsonObject).filter(obj -> !ValidationUtil.isEmpty(obj.get("identificationCode"))).filter(obj -> !ValidationUtil.isEmpty(obj.get("useRegistrationCode"))).orElseThrow(() -> new BadRequest("请先填写使用登记证编号和车辆VIN码!"));
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String useUnitCreditCode = reginParams.getCompany().getCompanyCode();
// 使用单位为个人时候 特殊处理
......@@ -2823,6 +2847,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
List<DictionarieValueModel> fillingMedium = Systemctl.dictionarieClient.dictValues("FILLING_MEDIUM").getResult();
Map<String, Object> fillingMediumMap = fillingMedium.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataKey, DictionarieValueModel::getDictDataValue));
Page<JSONObject> result = jgUseRegistrationMapper.queryForEquipUsedByVehiclePageHistory(page, jsonObject);
if (result.getRecords().isEmpty()) throw new BadRequest("请检查使用登记证编号和车辆VIN码是否填写正确!");
result.getRecords().forEach(i -> {
i.put("chargingMedium", fillingMediumMap.get(i.get("chargingMedium")));
});
......
......@@ -8,8 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
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.entity.DataDictionary;
......@@ -17,6 +18,7 @@ import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
......@@ -1767,25 +1769,44 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
@GlobalTransactional(rollbackFor = Exception.class)
public List<JgVehicleInformation> saveOrUpdateHisData(JSONObject map) {
// 使用登记证编号
String useRegistrationCode1 = String.valueOf(map.get("useRegistrationCode")).trim();
String useRegistrationCode = String.valueOf(map.get("useRegistrationCode")).trim();
// 车辆VIN码
String identificationCode = String.valueOf(map.get("identificationCode")).trim();
String equipId = String.valueOf(map.get("equipId"));
//校验使用登记证编号的唯一性
Boolean used = commonService.useRegistrationCertificateAccountUnique(useRegistrationCode1, equipId);
if (used){
throw new BadRequest("使用登记证编号已存在!");
}
// 表单设备列表
List<Map<String, Object>> equipmentLists = new ObjectMapper()
.convertValue(map.get("equipmentLists"), new TypeReference<List<Map<String, Object>>>() {
});
// 设备列表判空 + 选择同一充装介质的设备
Optional.ofNullable(equipmentLists)
.filter(list -> !list.isEmpty())
.filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1)
.orElseThrow(() -> new BadRequest(CollectionUtils.isEmpty(equipmentLists) ? "请选择设备信息!" : "请选择相同充装介质设备!"));
// 确保车用气瓶使用信息中填写的【使用登记证编号】【车辆VIN】与列表所选择设备的一致
Optional.of(equipmentLists)
.filter(eqLists -> {
boolean isSameChargingMedium = eqLists.stream().map(v -> (String) v.get("useOrgCode")).distinct().count() == 1;
boolean isSameVin = eqLists.stream().map(v -> (String) v.get("vin")).distinct().count() == 1;
String firstUseOrgCode = (String) eqLists.stream().findFirst().orElseThrow(() -> new BadRequest("设备列表为空,无法获取第一个设备信息")).get("useOrgCode");
String firstVin = (String) eqLists.stream().findFirst().orElseThrow(() -> new BadRequest("设备列表为空,无法获取第一个设备信息")).get("vin");
boolean isOrgCodeConsistent = useRegistrationCode.equals(firstUseOrgCode);
boolean isVinConsistent = identificationCode.equals(firstVin);
return isSameChargingMedium && isSameVin && isOrgCodeConsistent && isVinConsistent;
})
.orElseThrow(() -> new BadRequest("使用登记证号、车辆VIN码与所选设备不一致,请重新选择设备!"));
// 校验使用登记证编号的唯一性 ====> 20241202 任务ID 32776 将校验前置到了新增历史设备阶段
// Boolean used = commonService.useRegistrationCertificateAccountUnique(useRegistrationCode, equipId);
// if (used){
// throw new BadRequest("使用登记证编号已存在!");
// }
// 检测是否三环系统中的车用气瓶数据 不让三环系统数据通过设备新增方式进来
// this.checkIsSanSystemHanData(map);
//使用登记证编号判断是否使用未来系统生成编号
idxBizJgRegisterInfoService.checkUseRegistrationCode(useRegistrationCode1,"vehicle");
idxBizJgRegisterInfoService.checkUseRegistrationCode(useRegistrationCode, "vehicle");
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class);
JgVehicleInformationDto vehicleInfoDto = JSON.parseObject(JSON.toJSONString(map), JgVehicleInformationDto.class);
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists");
if (CollectionUtils.isEmpty(equipmentLists) ||
equipmentLists.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() != 1) {
throw new BadRequest(CollectionUtils.isEmpty(equipmentLists) ? "请选择设备信息!" : "请选择相同充装介质设备!");
}
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList = idxBizJgInspectionDetectionInfoService.checkInspectionInfo(
equipmentLists.stream()
......@@ -1932,13 +1953,13 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
lambda.eq(JgVehicleInformationEq::getVehicleId, vehicleInformation.getSequenceNbr());
jgVehicleInformationEqService.getBaseMapper().delete(lambda);
this.getBaseMapper().updateById(vehicleInformation);
JgUseRegistrationManage useRegistrationCode = jgUseRegistrationManageService.lambdaQuery()
JgUseRegistrationManage useRegistrationManage = jgUseRegistrationManageService.lambdaQuery()
.eq(JgUseRegistrationManage::getUseRegistrationCode, vehicleInformation.getUseRegistrationCode())
.eq(JgUseRegistrationManage::getIsDelete, 0)
.one();
if (useRegistrationCode != null) {
useRegistrationCode.setCarNumber(vehicleInformation.getCarNumber());
jgUseRegistrationManageService.updateById(useRegistrationCode);
if (useRegistrationManage != null) {
useRegistrationManage.setCarNumber(vehicleInformation.getCarNumber());
jgUseRegistrationManageService.updateById(useRegistrationManage);
}
}
......
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