Commit 6fcaa970 authored by tianbo's avatar tianbo

refactor(jg): 优化设备代码生成和车辆信息保存逻辑- 修改设备代码生成条件,支持新提交或暂存后提交- 优化车辆 VIN 码校验逻辑,增加对空值的处理

- 移除设备检验检测信息的完整性校验 - 修复设备总容积计算,增加对空值和空字符串的处理 - 增加设备创建或编辑事件发布
parent c3d3f1f4
......@@ -4172,7 +4172,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if (registerInfo != null) {
registerInfo.setUseOrgCode(jgUseRegistration.getUseRegistrationCode());
registerInfo.setEquCodeType(String.valueOf(map.get("equCodeType")));
if(submitType.equals("tempSubmit")){
// 新提交或暂存后提交需生成设备代码
if(ValidationUtil.isEmpty(submitType) || "tempSubmit".equals(submitType)){
equCode = ObjectUtils.isEmpty(map.get("equCode")) && !StringUtils.isEmpty(jgUseRegistration.getReceiveCompanyCode())
? this.getEquCode(registerInfo, jgUseRegistration.getReceiveCompanyCode())
: String.valueOf(map.get("equCode"));
......@@ -4335,6 +4336,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.build());
}
}
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), Sets.newHashSet(equipId), EquipCreateOrEditEvent.EquipType.equip));
return this.baseMapper.getDetailById(jgUseRegistration.getSequenceNbr());
} catch (BadRequest | LocalBadRequest e) {
log.error(e.getMessage(), e);
......
......@@ -1872,7 +1872,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
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);
boolean isVinConsistent = "null".equals(identificationCode) && ValidationUtil.isEmpty(firstVin) || identificationCode.equals(firstVin);
return isSameChargingMedium && isSameVin && isOrgCodeConsistent && isVinConsistent;
})
.orElseThrow(() -> new BadRequest("使用登记证号、车辆VIN码与所选设备不一致,请重新选择设备!"));
......@@ -1890,11 +1890,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
.collect(Collectors.toList())
);
if (inspectionDetectionInfoList.stream().anyMatch(info ->
ObjectUtils.isEmpty(info) || ObjectUtils.isEmpty(info.getInspectType()) ||
ObjectUtils.isEmpty(info.getInspectConclusion()) || ObjectUtils.isEmpty(info.getInspectOrgCode()))) {
throw new BadRequest("请补充设备检验检测信息后提交!");
}
// if (inspectionDetectionInfoList.stream().anyMatch(info ->
// ObjectUtils.isEmpty(info) || ObjectUtils.isEmpty(info.getInspectType()) ||
// ObjectUtils.isEmpty(info.getInspectConclusion()) || ObjectUtils.isEmpty(info.getInspectOrgCode()))) {
// throw new BadRequest("请补充设备检验检测信息后提交!");
// }
vehicleInfoDto.setNextInspectionDate(inspectionDetectionInfoList.stream()
.map(IdxBizJgInspectionDetectionInfo::getNextInspectDate)
......@@ -2008,8 +2008,14 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
vehicleInformation.setRegDate(new Date());
vehicleInformation.setCreateUserName(reginParams.getUserModel().getRealName());
vehicleInformation.setGasNum(equipmentLists.size());
BigDecimal totalVolume = equipmentLists.stream()
.map(x -> new BigDecimal(String.valueOf(x.get("singleBottleVolume"))))
BigDecimal totalVolume = Optional.ofNullable(equipmentLists)
.orElse(Collections.emptyList())
.stream()
.map(x -> x.get("singleBottleVolume"))
.filter(Objects::nonNull) // 过滤 null 值
.map(Object::toString)
.filter(s -> !s.trim().isEmpty()) // 过滤空字符串
.map(BigDecimal::new)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vehicleInformation.setVolume(totalVolume.toPlainString());
vehicleInformation.setFillingMedium(equipmentLists.stream()
......@@ -2138,7 +2144,10 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
// 保存关联设备信息
jgVehicleInformationEqService.saveBatch(equipList);
}
Set<String> recordSet = equipmentLists.stream()
.map(v -> (String) v.get("record"))
.collect(Collectors.toSet());
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
return Collections.singletonList(vehicleInformation);
}
......
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