Commit d4477419 authored by hezhuozhi's avatar hezhuozhi

处理历史数据生成登记表,并优化代码

parent 35d548ff
...@@ -275,4 +275,7 @@ public class JgVehicleInformationVo implements Serializable { ...@@ -275,4 +275,7 @@ public class JgVehicleInformationVo implements Serializable {
@ApiModelProperty("使用登记表附件") @ApiModelProperty("使用登记表附件")
private JSONArray useRegistrationFormFile; private JSONArray useRegistrationFormFile;
@ApiModelProperty(value = "创建人名称")
private String createUserName;
} }
...@@ -147,4 +147,15 @@ public class DataHandlerController extends BaseController { ...@@ -147,4 +147,15 @@ public class DataHandlerController extends BaseController {
public ResponseModel<String> ordinaryGasCylinderWriteEquState() { public ResponseModel<String> ordinaryGasCylinderWriteEquState() {
return ResponseHelper.buildResponse(dataHandlerService.ordinaryGasCylinderWriteEquState()); return ResponseHelper.buildResponse(dataHandlerService.ordinaryGasCylinderWriteEquState());
} }
/**
* 使用登记、车用气瓶登记历史单据使用登记表生成
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "使用登记、车用气瓶登记历史单据使用登记表生成", notes = "使用登记、车用气瓶登记历史单据使用登记表生成")
@GetMapping(value = "/initFormUrl")
public void initFormUrl() {
dataHandlerService.initFormUrl();
ResponseHelper.buildResponse(true);
}
} }
...@@ -2286,8 +2286,8 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2286,8 +2286,8 @@ public class CommonServiceImpl implements ICommonService {
if (!CollectionUtils.isEmpty(equips)){ if (!CollectionUtils.isEmpty(equips)){
formData.put("gasNum",equips.size()); formData.put("gasNum",equips.size());
formData.put("equDefineName",equips.get(0).get("equDefineName")); formData.put("equDefineName",equips.get(0).get("equDefineName"));
formData.put("workPressure", equips.stream().mapToDouble(e -> Double.valueOf(e.get("nominalWorkingPressure").toString())).sum()); formData.put("workPressure", equips.stream().mapToDouble(e -> Objects.isNull(e.get("nominalWorkingPressure"))? 0 : Double.valueOf(e.get("nominalWorkingPressure").toString())).sum());
formData.put("volume", equips.stream().mapToDouble(e -> Double.valueOf(e.get("singleBottleVolume").toString())).sum()); formData.put("volume", equips.stream().mapToDouble(e -> Objects.isNull(e.get("singleBottleVolume"))? 0 : Double.valueOf(e.get("singleBottleVolume").toString())).sum());
Set<String> chargingMedium = equips.stream().map(e -> String.valueOf(e.get("chargingMedium"))).collect(Collectors.toSet()); Set<String> chargingMedium = equips.stream().map(e -> String.valueOf(e.get("chargingMedium"))).collect(Collectors.toSet());
if (chargingMedium.size()>1){ if (chargingMedium.size()>1){
throw new BadRequest("充装介质仅可选择同一类型"); throw new BadRequest("充装介质仅可选择同一类型");
......
...@@ -63,6 +63,7 @@ public class DataHandlerServiceImpl { ...@@ -63,6 +63,7 @@ public class DataHandlerServiceImpl {
private final JgRegistrationHistoryServiceImpl registrationHistoryService; private final JgRegistrationHistoryServiceImpl registrationHistoryService;
private final JgInstallationNoticeServiceImpl installationNoticeService; private final JgInstallationNoticeServiceImpl installationNoticeService;
private final JgUseRegistrationServiceImpl useRegistrationService; private final JgUseRegistrationServiceImpl useRegistrationService;
private final JgVehicleInformationServiceImpl jgVehicleInformationService;
private final JgUseRegistrationEqServiceImpl useRegistrationEqService; private final JgUseRegistrationEqServiceImpl useRegistrationEqService;
private final JgInstallationNoticeEqServiceImpl installationNoticeEqService; private final JgInstallationNoticeEqServiceImpl installationNoticeEqService;
private final IdxBizJgUseInfoServiceImpl useInfoService; private final IdxBizJgUseInfoServiceImpl useInfoService;
...@@ -974,4 +975,8 @@ public class DataHandlerServiceImpl { ...@@ -974,4 +975,8 @@ public class DataHandlerServiceImpl {
return String.format("刷入数据%s条,耗时:%s秒", allHisRecords.size() + allRecords.size(), stopWatch.getTotalTimeSeconds()); return String.format("刷入数据%s条,耗时:%s秒", allHisRecords.size() + allRecords.size(), stopWatch.getTotalTimeSeconds());
} }
public void initFormUrl() {
jgVehicleInformationService.initVehicleFormUrl();
}
} }
...@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; ...@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
...@@ -221,6 +222,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -221,6 +222,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
Optional.ofNullable(map.get("useRegistrationFormFile")) Optional.ofNullable(map.get("useRegistrationFormFile"))
.map(JSONObject::toJSONString) .map(JSONObject::toJSONString)
.ifPresent(vehicleInfoDto::setUseRegistrationFormFile); .ifPresent(vehicleInfoDto::setUseRegistrationFormFile);
map.put("userName",reginParams.getUserModel().getRealName());
Map<String, Object> vehicle = commonService.getRegistrationFormUrl("vehicle", map); Map<String, Object> vehicle = commonService.getRegistrationFormUrl("vehicle", map);
if(Objects.nonNull(vehicle)){ if(Objects.nonNull(vehicle)){
vehicleInfoDto.setUseRegistrationFormUrl(String.valueOf(vehicle.get("useRegistrationFormUrl"))); vehicleInfoDto.setUseRegistrationFormUrl(String.valueOf(vehicle.get("useRegistrationFormUrl")));
...@@ -647,35 +649,38 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -647,35 +649,38 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
// 非完成、非已作废时显示实时数据 // 非完成、非已作废时显示实时数据
if (!(dto.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) || dto.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName()))) { if (!(dto.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) || dto.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName()))) {
vo.setEquipmentLists( List<String> records = vehicleInformationEqList.stream()
this.baseMapper.queryForUnitVesselEquipment(sequenceNbr, .map(JgVehicleInformationEq::getEquId)
vehicleInformationEqList.stream() .collect(Collectors.toList());
.map(JgVehicleInformationEq::getEquId) if(CollUtil.isNotEmpty(records)){
.collect(Collectors.toList()) vo.setEquipmentLists(this.baseMapper.queryForUnitVesselEquipment(sequenceNbr,records).stream()
).stream() .peek(v -> v.put("chargingMedium", getFillingMediumMap().get(v.getOrDefault("chargingMedium", "") + "")))
.peek(v -> v.put("chargingMedium", getFillingMediumMap().get(v.getOrDefault("chargingMedium", "") + ""))) .collect(Collectors.toList()));
.collect(Collectors.toList()) }
);
} else { } else {
// 完成及已作废时显示历史数据详情 // 完成及已作废时显示历史数据详情
JSONArray objects = commonService.queryHistoryDataObj(dto.getSequenceNbr()); JSONArray objects = commonService.queryHistoryDataObj(dto.getSequenceNbr());
// 兼容老数据 // 兼容老数据
if (objects.isEmpty()) { if (objects.isEmpty()) {
vo.setEquipmentLists( List<String> records = vehicleInformationEqList.stream()
this.baseMapper.queryForUnitVesselEquipment(sequenceNbr, .map(JgVehicleInformationEq::getEquId)
vehicleInformationEqList.stream() .collect(Collectors.toList());
.map(JgVehicleInformationEq::getEquId) if(CollUtil.isNotEmpty(records)){
.collect(Collectors.toList()) vo.setEquipmentLists(
).stream() this.baseMapper.queryForUnitVesselEquipment(sequenceNbr,records).stream()
.peek(v -> v.put("chargingMedium", getFillingMediumMap().get(v.getOrDefault("chargingMedium", "") + ""))) .peek(v -> v.put("chargingMedium", getFillingMediumMap().get(v.getOrDefault("chargingMedium", "") + "")))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
}
} else { } else {
List equList = objects.toJavaList(Map.class); List equList = objects.toJavaList(Map.class);
vo.setEquipmentLists(equList); vo.setEquipmentLists(equList);
} }
} }
if(Objects.isNull(vo.getEquipmentLists())){
vo.setEquipmentLists(new ArrayList<>());
}
vo.setEquDefineCode( vo.setEquDefineCode(
vo.getEquipmentLists().stream() vo.getEquipmentLists().stream()
.findFirst() .findFirst()
...@@ -689,10 +694,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -689,10 +694,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
lambda.eq(IdxBizJgUseInfo::getRecord, firstEqu.get().get("record")); lambda.eq(IdxBizJgUseInfo::getRecord, firstEqu.get().get("record"));
lambda.select(TzsBaseEntity::getSequenceNbr, IdxBizJgUseInfo::getOldUseRegistrationCertificate,IdxBizJgUseInfo::getOldUseRegistrationTable,IdxBizJgUseInfo::getORegDate,IdxBizJgUseInfo::getORegUnit); lambda.select(TzsBaseEntity::getSequenceNbr, IdxBizJgUseInfo::getOldUseRegistrationCertificate,IdxBizJgUseInfo::getOldUseRegistrationTable,IdxBizJgUseInfo::getORegDate,IdxBizJgUseInfo::getORegUnit);
IdxBizJgUseInfo useInfo = useInfoMapper.selectOne(lambda); IdxBizJgUseInfo useInfo = useInfoMapper.selectOne(lambda);
vo.setORegDate(useInfo.getORegDate()); if(Objects.nonNull(useInfo)){
vo.setORegUnit(useInfo.getORegUnit()); vo.setORegDate(useInfo.getORegDate());
vo.setOldUseRegistrationTable(JSONArray.parseArray(useInfo.getOldUseRegistrationTable())); vo.setORegUnit(useInfo.getORegUnit());
vo.setOldUseRegistrationCertificate(JSONArray.parseArray(useInfo.getOldUseRegistrationCertificate())); vo.setOldUseRegistrationTable(JSONArray.parseArray(useInfo.getOldUseRegistrationTable()));
vo.setOldUseRegistrationCertificate(JSONArray.parseArray(useInfo.getOldUseRegistrationCertificate()));
}
} }
String companyType = selectedOrgInfo.getCompany().getCompanyType(); String companyType = selectedOrgInfo.getCompany().getCompanyType();
if ("个人主体".equals(companyType)) { if ("个人主体".equals(companyType)) {
...@@ -2366,4 +2373,28 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -2366,4 +2373,28 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
commonService.saveExecuteFlowData2Redis(jgVehicleInformation.getInstanceId(), this.buildInstanceRuntimeData(jgVehicleInformation)); commonService.saveExecuteFlowData2Redis(jgVehicleInformation.getInstanceId(), this.buildInstanceRuntimeData(jgVehicleInformation));
} }
@Transactional(rollbackFor = Exception.class)
public void initVehicleFormUrl() {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class);
LambdaQueryWrapper<JgVehicleInformation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgVehicleInformation::getIsDelete, false)
.isNull(JgVehicleInformation::getUseRegistrationFormUrl)
.ne(JgVehicleInformation::getStatus, "已作废");
List<JgVehicleInformation> vehicleInformations = this.list(queryWrapper);
if(CollUtil.isNotEmpty(vehicleInformations)){
for (JgVehicleInformation vehicleInformation : vehicleInformations) {
JgVehicleInformationVo jgVehicleInformationVo = this.queryBySequenceNbr(vehicleInformation.getSequenceNbr(), reginParams);
String jsonString = JSONObject.toJSONString(jgVehicleInformationVo);
JSONObject jsonObject = JSONObject.parseObject(jsonString);
jsonObject.put("userName",jgVehicleInformationVo.getCreateUserName());
Map<String, Object> vehicle = commonService.getRegistrationFormUrl("vehicle", jsonObject);
if(Objects.nonNull(vehicle)){
LambdaUpdateWrapper<JgVehicleInformation> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(JgVehicleInformation::getUseRegistrationFormUrl,String.valueOf(vehicle.get("useRegistrationFormUrl")))
.eq(JgVehicleInformation::getSequenceNbr,jgVehicleInformationVo.getSequenceNbr());
this.update(wrapper);
}
}
}
}
} }
\ No newline at end of file
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