Commit bd585e9c authored by 刘林's avatar 刘林

fix(jg):车用气瓶暂存功能开发

parent e63ee483
......@@ -1503,7 +1503,9 @@ public class CommonServiceImpl implements ICommonService {
@Override
public Object updateHistory(Map<String, Object> map) {
String historyEquType = (String) map.get(HISTORY_EQU_TYPE);
String historySubmitType = (String) map.get(HISTORY_SUBMIT_TYPE);
JSONObject jsonObject = new JSONObject(map);
jsonObject.put("historySubmitType", historySubmitType);
switch (historyEquType) {
case "unit":
// return jgUseRegistrationServiceImpl.handleUnitHistoryEquip(jsonObject);
......
......@@ -689,9 +689,19 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
.map(JgVehicleInformationEq::getEquId)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(records)) {
vo.setEquipmentLists(this.baseMapper.queryForUnitVesselEquipment(sequenceNbr, records).stream()
.peek(v -> v.put("chargingMedium", getFillingMediumMap().get(v.getOrDefault("chargingMedium", "") + "")))
.collect(Collectors.toList()));
Map<String, Object> mediumMap = getFillingMediumMap();
List<Map<String, Object>> equipmentList = this.baseMapper
.queryForUnitVesselEquipment(sequenceNbr, records)
.stream()
.peek(item -> {
String key = Objects.toString(item.get("chargingMedium"), "");
mediumMap.getOrDefault(key, null); // 提前获取映射
if (mediumMap.containsKey(key)) {
item.put("chargingMedium", mediumMap.get(key));
}
})
.collect(Collectors.toList());
vo.setEquipmentLists(equipmentList);
}
} else {
// 完成及已作废时显示历史数据详情
......@@ -702,11 +712,19 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
.map(JgVehicleInformationEq::getEquId)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(records)) {
vo.setEquipmentLists(
this.baseMapper.queryForUnitVesselEquipment(sequenceNbr, records).stream()
.peek(v -> v.put("chargingMedium", getFillingMediumMap().get(v.getOrDefault("chargingMedium", "") + "")))
.collect(Collectors.toList())
);
Map<String, Object> mediumMap = getFillingMediumMap(); // 假设返回的是 Map<String, String>
List<Map<String, Object>> equipmentList = this.baseMapper
.queryForUnitVesselEquipment(sequenceNbr, records)
.stream()
.peek(item -> {
String key = Objects.toString(item.get("chargingMedium"), "");
mediumMap.getOrDefault(key, null); // 提前获取映射
if (mediumMap.containsKey(key)) {
item.put("chargingMedium", mediumMap.get(key));
}
})
.collect(Collectors.toList());
vo.setEquipmentLists(equipmentList);
}
} else {
List equList = objects.toJavaList(Map.class);
......@@ -1854,7 +1872,6 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
String useRegistrationCode = String.valueOf(map.get("useRegistrationCode")).trim();
// 车辆VIN码
String identificationCode = String.valueOf(map.get("identificationCode")).trim();
String equipId = String.valueOf(map.get("equipId"));
// 表单设备列表
List<Map<String, Object>> equipmentLists = new ObjectMapper()
.convertValue(map.get("equipmentLists"), new TypeReference<List<Map<String, Object>>>() {
......@@ -2027,7 +2044,10 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
// 登记证记录表主键
Long changeRecordId = sequence.nextId();
//新增
Object submitType = map.get("historySubmitType");
if (StringUtils.isEmpty(vehicleInfoDto.getSequenceNbr())) {
//暂存或者提交
if(!Arrays.asList("tempSubmit", "tempEdit").contains(submitType)){
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.SYDJ.getCode(), 1);
if (!ObjectUtils.isEmpty(listResponseModel) && listResponseModel.getStatus() != HttpStatus.OK.value()) {
log.error("车用气瓶使用登记申请单单号获取失败!");
......@@ -2035,10 +2055,14 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
}
String applyNo = listResponseModel.getResult().get(0);
vehicleInformation.setApplyNo(applyNo);
vehicleInformation.setStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
String status = "temp".equals(submitType)
? FlowStatusEnum.TO_BE_SUBMITTED.getName()
: FlowStatusEnum.TO_BE_FINISHED.getName();
vehicleInformation.setStatus(status);
vehicleInformation.setRegType("1");//历史登记
this.save(vehicleInformation);
if (!"temp".equals(submitType)){
// 取第一条设备的注册消息--用来获取这一批设备的设备种类/类别/品种
LambdaQueryWrapper<IdxBizJgRegisterInfo> lambdaReg = new QueryWrapper<IdxBizJgRegisterInfo>().lambda();
lambdaReg.eq(IdxBizJgRegisterInfo::getRecord, String.valueOf(equipmentLists.get(0).get("record")));
......@@ -2047,9 +2071,21 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
generateRegistrationManage(vehicleInformation, registerInfo);
// 生成一条tzs_jg_certificate_change_record记录
generateCertificateChangeRecord(vehicleInformation, registerInfo, changeRecordId, null);
}
} else {
// 删除以前设备关联关系
//暂存编辑或暂存提交
String status = "tempEdit".equals(submitType)
? FlowStatusEnum.TO_BE_SUBMITTED.getName()
: FlowStatusEnum.TO_BE_FINISHED.getName();
vehicleInformation.setStatus(status);
LambdaQueryWrapper<JgVehicleInformationEq> lambda = new QueryWrapper<JgVehicleInformationEq>().lambda();
lambda.eq(JgVehicleInformationEq::getVehicleId, vehicleInformation.getSequenceNbr());
jgVehicleInformationEqService.getBaseMapper().delete(lambda);
this.getBaseMapper().updateById(vehicleInformation);
}
} else {
// 编辑
// 删除以前设备关联关系
LambdaQueryWrapper<JgVehicleInformationEq> lambda = new QueryWrapper<JgVehicleInformationEq>().lambda();
lambda.eq(JgVehicleInformationEq::getVehicleId, vehicleInformation.getSequenceNbr());
jgVehicleInformationEqService.getBaseMapper().delete(lambda);
......@@ -2098,8 +2134,8 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
IdxBizJgUseInfo useInfo = useInfoMapper.selectOne(useInfoLambdaQueryWrapper);
useInfo.setOldUseRegistrationTable(JSON.toJSONString(map.get("oldUseRegistrationTable")));
useInfo.setOldUseRegistrationCertificate(JSON.toJSONString(map.get("oldUseRegistrationCertificate")));
useInfo.setORegDate(String.valueOf(map.get("oRegDate")));
useInfo.setORegUnit(String.valueOf(map.get("oRegUnit")));
useInfo.setORegDate(Objects.toString(map.get("oRegDate"), null));
useInfo.setORegUnit(Objects.toString(map.get("oRegUnit"), null));
useInfo.setEstateUnitCreditCode(vehicleInformation.getEstateUnitCreditCode());
useInfo.setEstateUnitName(vehicleInformation.getEstateUnitName());
useInfo.setSafetyManagerId(vehicleInformation.getSafetyManagerId());
......@@ -2124,9 +2160,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
IdxBizJgOtherInfo otherInfo = otherInfoMapper.selectOne(otherInfoWrapper);
// 更新设备信息
if(!Arrays.asList("temp", "tempEdit").contains(submitType)){
this.updateEquipInfo(vehicleInformation, registerInfo, otherInfo, String.valueOf(x.get("record")));
// 更新es
this.updateEquipEsData(vehicleInformation, otherInfo, registerInfo, String.valueOf(x.get("record")));
}
// 查询设备制造信息
LambdaQueryWrapper<IdxBizJgFactoryInfo> factoryInfoWrapper = new LambdaQueryWrapper<>();
factoryInfoWrapper.eq(IdxBizJgFactoryInfo::getRecord, String.valueOf(x.get("record")));
......@@ -2191,6 +2229,10 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
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");
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) ? "请选择设备信息!" : "请选择相同充装介质设备!"));
CompanyBo company = reginParams.getCompany();
vehicleInfoDto.setCreateDate(new Date());
......@@ -2284,13 +2326,24 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
vehicleInformation.setCreateUserName(reginParams.getUserModel().getRealName());
vehicleInformation.setGasNum(equipmentLists.size());
BigDecimal totalVolume = equipmentLists.stream()
.map(x -> new BigDecimal(String.valueOf(x.get("singleBottleVolume"))))
.map(x -> {
Object val = x.get("singleBottleVolume");
try {
return new BigDecimal(String.valueOf(val));
} catch (Exception e) {
return BigDecimal.ZERO;
}
})
.reduce(BigDecimal.ZERO, BigDecimal::add);
vehicleInformation.setVolume(totalVolume.toPlainString());
vehicleInformation.setAuditPassDate(new Date());
// 登记证记录表主键
Long changeRecordId = sequence.nextId();
String status = "tempEdit".equals(map.get("historySubmitType"))
? FlowStatusEnum.TO_BE_SUBMITTED.getName()
: FlowStatusEnum.TO_BE_FINISHED.getName();
vehicleInformation.setStatus(status);
this.getBaseMapper().updateById(vehicleInformation);
JgUseRegistrationManage jgUseRegistrationManage = jgUseRegistrationManageService.lambdaQuery()
.eq(JgUseRegistrationManage::getUseRegistrationCode, vehicleInformation.getUseRegistrationCode())
......@@ -2350,11 +2403,13 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
IdxBizJgFactoryInfo idxBizJgFactoryInfo = idxBizJgFactoryInfoMapper.selectOne(factoryInfoWrapper);
// 生成tzs_jg_certificate_change_record_eq记录
if (!"tempEdit".equals(map.get("historySubmitType"))){
JgCertificateChangeRecordEq changeRecordEq = new JgCertificateChangeRecordEq();
changeRecordEq.setChangeRecordId(String.valueOf(changeRecordId));//登记证记录主键
changeRecordEq.setEquId(registerInfo.getRecord());//设备主键
changeRecordEq.setProductCode(idxBizJgFactoryInfo.getFactoryNum());//产品编号
certificateChangeRecordEqService.save(changeRecordEq);
}
});
}
......
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