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

fix(jg):历史数据处理=》使用登记流程中的单子添加安装信息和维保信息;附件转化统一处理

parent 75161075
......@@ -1620,4 +1620,30 @@ public class CommonServiceImpl implements ICommonService {
return commonMapper.countEquipInUseTimesForDel(record);
}
/**
* string转化为jsonObject
* @param obj jsonobject/map对象
* @param jsonFields 要转化的字段数据
*/
public void convertStringToJsonobject(Object obj, String[] jsonFields) {
if (obj instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) obj;
for (String field : jsonFields) {
if (jsonObject.get(field) != null && jsonObject.get(field) instanceof String) {
jsonObject.put(field, JSON.parse(jsonObject.get(field).toString()));
}
}
} else if (obj instanceof Map) {
Map<String, Object> map = (Map<String, Object>) obj;
for (String field : jsonFields) {
if (map.containsKey(field) && map.get(field) instanceof String) {
map.put(field, JSON.parse(map.get(field).toString()));
}
}
} else {
// 处理其他类型
System.out.println("Unsupported Object Type");
}
}
}
\ No newline at end of file
......@@ -89,6 +89,11 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
@Autowired
DataDictionaryServiceImpl iDataDictionaryService;
String[] jsonFields = {"proDuctPhoto", "factoryStandard", "productQualityYieldProve", "insUseMaintainExplain",
"inspectReport", "designStandard", "designDoc", "longitudeLatitude", "otherAccessoriesDes", "otherAccessoriesFact",
"otherAccessoriesReg", "installProxyStatementAttachment", "installContractAttachment", "insOtherAccessories",
"maintenanceContract", "maintOtherAccessories", "installProxyStatementAttachment", "installContractAttachment",
"insOtherAccessories", "maintenanceContract"};
@Autowired
private IdxBizJgUseInfoMapper useInfoMapper;
@Autowired
......@@ -103,13 +108,28 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
private IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
private IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService;
@Autowired
private RedissonClient redissonClient;
/**
* @param auditPassDate 通过时间
* @param exportParamsMap 参数map
*/
public static void getAuditPassedDate(Date auditPassDate, Map<String, Object> exportParamsMap) {
LocalDate today;
if (ValidationUtil.isEmpty(auditPassDate)) {
// 发证日期为空取当前时间
today = LocalDate.now();
} else {
today = auditPassDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
exportParamsMap.put("giveOutYear", today.getYear());
exportParamsMap.put("giveOutMonth", today.getMonthValue());
exportParamsMap.put("giveOutDay", today.getDayOfMonth());
}
public Page<Map<String, Object>> getList(JgUseRegistrationDto dto, Page<Map<String, Object>> page, List<String> roleIds) {
return this.baseMapper.getListPage(page, dto, roleIds);
}
......@@ -235,7 +255,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
return "";
}
/**
* 获取类型为ZC的“已注册”的字典值
*
......@@ -289,7 +308,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
jgUseRegistration.setSupervisoryCode(supervisoryCode);
jgUseRegistration.setUseUnitName(String.valueOf(map.get("useUnitName")));
jgUseRegistration.setUseUnitCreditCode(String.valueOf(map.get("useUnitCreditCode")));
if (!ObjectUtils.isEmpty(map.get("otherAccessories"))){
if (!ObjectUtils.isEmpty(map.get("otherAccessories"))) {
jgUseRegistration.setOtherAccessories(JSONObject.toJSONString(map.get("otherAccessories")));
}
String equType = this.baseMapper.getEquType(String.valueOf(map.get("equipId")));
......@@ -407,14 +426,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
List<WorkflowResultDto> resultDto = commonServiceImpl.buildWorkFlowInfo(processTaskDTOS);
if (!ObjectUtils.isEmpty(resultDto) && !ObjectUtils.isEmpty(resultDto.get(0))) {
WorkflowResultDto workflowResultDto = resultDto.get(0);
updateData(jgUseRegistration.getSequenceNbr(), "0", workflowResultDto, Boolean.TRUE,"");
updateData(jgUseRegistration.getSequenceNbr(), "0", workflowResultDto, Boolean.TRUE, "");
}
}
if (!ObjectUtils.isEmpty(instanceId)) {
// 执行流程
flowExecute(jgUseRegistration.getSequenceNbr(), instanceId, "0", "","", String.valueOf(map.get("nextTaskId")));
flowExecute(jgUseRegistration.getSequenceNbr(), instanceId, "0", "", "", String.valueOf(map.get("nextTaskId")));
}
} else {
ArrayList<TaskModelDto> list = new ArrayList<>();
......@@ -439,7 +458,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
return this.baseMapper.getDetailById(jgUseRegistration.getSequenceNbr());
}
public JgUseRegistration updateData(Long sequenceNbr, String operate, WorkflowResultDto workflowResultDto, Boolean isFirst,String carNumber) {
public JgUseRegistration updateData(Long sequenceNbr, String operate, WorkflowResultDto workflowResultDto, Boolean isFirst, String carNumber) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String role = workflowResultDto.getNextExecutorRoleIds();
String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName();
......@@ -456,13 +475,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
jgUseRegistration.setInstanceStatus(workflowResultDto.getExecutorRoleIds());
jgUseRegistration.setInstanceId(workflowResultDto.getInstanceId());
}
if (!ObjectUtils.isEmpty(carNumber)){
//更新安全追溯-场内车辆中的“车牌号字段”
if (!ObjectUtils.isEmpty(carNumber)) {
// 更新安全追溯-场内车辆中的“车牌号字段”
LambdaUpdateWrapper<IdxBizJgRegisterInfo> wrapper = new UpdateWrapper<IdxBizJgRegisterInfo>().lambda()
.eq(IdxBizJgRegisterInfo::getRecord, jgUseRegistrationEq.getEquId());
IdxBizJgRegisterInfo idxBizJgRegisterInfo = new IdxBizJgRegisterInfo();
idxBizJgRegisterInfo.setCarNumber(carNumber);
idxBizJgRegisterInfoMapper.update(idxBizJgRegisterInfo,wrapper);
idxBizJgRegisterInfoMapper.update(idxBizJgRegisterInfo, wrapper);
}
if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(taskCode)) {
jgUseRegistration.setNextExecuteIds(role);
......@@ -637,14 +656,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
commonServiceImpl.buildTaskModel(list);
}
public void flowExecute(Long id, String instanceId, String operate, String comment, String carNumber, String nextTaskId) {
String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
RLock lock = redissonClient.getLock(lockKey);
try {
boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if(!isLocked){
if (!isLocked) {
throw new BadRequest("当前流程已经被执行!请重新打开页面查看并执行!");
}
// 流程执行时,状态及权限校验
......@@ -675,25 +693,24 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
List<WorkflowResultDto> resultDto = commonServiceImpl.buildWorkFlowInfo(processTaskDTOS);
if (!ObjectUtils.isEmpty(resultDto) && !ObjectUtils.isEmpty(resultDto.get(0))) {
WorkflowResultDto workflowResultDto = resultDto.get(0);
updateData(jgUseRegistration.getSequenceNbr(), operate, workflowResultDto, Boolean.FALSE,carNumber);
updateData(jgUseRegistration.getSequenceNbr(), operate, workflowResultDto, Boolean.FALSE, carNumber);
}
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
public void withdraw(String instanceId, String nextTaskId) {
String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
RLock lock = redissonClient.getLock(lockKey);
try {
boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if(!isLocked){
if (!isLocked) {
throw new BadRequest("当前流程已经被执行!请重新打开页面查看并执行!");
}
// 撤回校验
......@@ -745,7 +762,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
......@@ -769,7 +786,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryService.getBaseMapper().selectOne(lambda);
JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
// 需求:当申请信息由于设备信息错误被驳回及撤回时显示的数据还是旧设备数据,导致该申请单无法使用
// 解决方案:设备基本信息、制造信息、设计信息,已完成时显示历史数据、非完成时显示最新设备数据
// 解决方案:设备基本信息、制造信息、设计信息、安装信息、维保信息,已完成时显示历史数据、非完成时显示最新设备数据
this.fillHistoryDataWithNewEquip(jsonObject, jgUseRegistration, record);
jsonObject.put("receiveOrgCode", jgUseRegistration.getReceiveCompanyCode() + "_" + jgUseRegistration.getReceiveOrgName());
jsonObject.put("status", jgUseRegistration.getStatus());
......@@ -779,32 +796,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 补充"车牌号"字段
LambdaQueryWrapper<IdxBizJgRegisterInfo> wrapper = new QueryWrapper<IdxBizJgRegisterInfo>().lambda().eq(IdxBizJgRegisterInfo::getRecord, record);
IdxBizJgRegisterInfo idxBizJgRegisterInfo = idxBizJgRegisterInfoMapper.selectOne(wrapper);
jsonObject.put("carNumber",idxBizJgRegisterInfo.getCarNumber());
jsonObject.put("carNumber", idxBizJgRegisterInfo.getCarNumber());
// 转化 附件 字段
if (!ObjectUtils.isEmpty(jsonObject.get("otherAccessoriesDes"))){
jsonObject.put("otherAccessoriesDes", JSON.parse(String.valueOf(jsonObject.get("otherAccessoriesDes"))));
}
if (!ObjectUtils.isEmpty(jsonObject.get("otherAccessoriesFact"))){
jsonObject.put("otherAccessoriesFact", JSON.parse(String.valueOf(jsonObject.get("otherAccessoriesFact"))));
}
if (!ObjectUtils.isEmpty(jsonObject.get("otherAccessoriesReg"))){
jsonObject.put("otherAccessoriesReg", JSON.parse(String.valueOf(jsonObject.get("otherAccessoriesReg"))));
}
if (!ObjectUtils.isEmpty(jsonObject.get("maintOtherAccessories"))){
jsonObject.put("maintOtherAccessories", JSON.parse(String.valueOf(jsonObject.get("maintOtherAccessories"))));
}
if (!ObjectUtils.isEmpty(jsonObject.get("insOtherAccessories"))){
jsonObject.put("maintenanceContract", JSON.parse(String.valueOf(jsonObject.get("maintenanceContract"))));
}
if (!ObjectUtils.isEmpty(jsonObject.get("insOtherAccessories"))){
jsonObject.put("insOtherAccessories", JSON.parse(String.valueOf(jsonObject.get("insOtherAccessories"))));
}
if (!ObjectUtils.isEmpty(jsonObject.get("installContractAttachment"))){
jsonObject.put("installContractAttachment", JSON.parse(String.valueOf(jsonObject.get("installContractAttachment"))));
}
if (!ObjectUtils.isEmpty(jsonObject.get("installProxyStatementAttachment"))){
jsonObject.put("installProxyStatementAttachment", JSON.parse(String.valueOf(jsonObject.get("installProxyStatementAttachment"))));
}
commonServiceImpl.convertStringToJsonobject(jsonObject, jsonFields);
return jsonObject;
}
// 基本信息 + 制造信息
......@@ -835,35 +829,22 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
detail.putAll(installDetail);
}
detail.remove("safetyManager");
detail.put("proDuctPhoto", JSON.parse(String.valueOf(detail.get("proDuctPhoto"))));
detail.put("factoryStandard", JSON.parse(String.valueOf(detail.get("factoryStandard"))));
detail.put("productQualityYieldProve", JSON.parse(String.valueOf(detail.get("productQualityYieldProve"))));
detail.put("insUseMaintainExplain", JSON.parse(String.valueOf(detail.get("insUseMaintainExplain"))));
detail.put("inspectReport", JSON.parse(String.valueOf(detail.get("inspectReport"))));
detail.put("designStandard", JSON.parse(String.valueOf(detail.get("designStandard"))));
detail.put("designDoc", JSON.parse(String.valueOf(detail.get("designDoc"))));
detail.put("longitudeLatitude", JSON.parse(String.valueOf(detail.get("longitudeLatitude"))));
detail.put("otherAccessoriesDes", JSON.parse(String.valueOf(detail.get("otherAccessoriesDes"))));
detail.put("otherAccessoriesFact", JSON.parse(String.valueOf(detail.get("otherAccessoriesFact"))));
detail.put("otherAccessoriesReg", JSON.parse(String.valueOf(detail.get("otherAccessoriesReg"))));
detail.put("installProxyStatementAttachment", JSON.parse(String.valueOf(detail.get("installProxyStatementAttachment"))));
detail.put("installContractAttachment", JSON.parse(String.valueOf(detail.get("installContractAttachment"))));
detail.put("insOtherAccessories", JSON.parse(String.valueOf(detail.get("insOtherAccessories"))));
detail.put("maintenanceContract", JSON.parse(String.valueOf(detail.get("maintenanceContract"))));
detail.put("maintOtherAccessories", JSON.parse(String.valueOf(detail.get("maintOtherAccessories"))));
// 附件解析
commonServiceImpl.convertStringToJsonobject(detail, jsonFields);
detail.put("province", "610000");
return detail;
}
/**
* 填充设备最新的数据至历史json
* @param jsonObject 历史json
*
* @param jsonObject 历史json
* @param jgUseRegistration 使用信息
* @param record 设备唯一标识
* @param record 设备唯一标识
*/
private void fillHistoryDataWithNewEquip(JSONObject jsonObject, JgUseRegistration jgUseRegistration, String record) {
// 非已完成时显示设备最新信息。前置需求:一个设备只能同时发起一个流程
if(!jgUseRegistration.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName())){
if (!jgUseRegistration.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName())) {
// 基本信息 + 制造信息
Map<String, Object> detail = this.baseMapper.getDetail(record);
// 设计信息
......@@ -871,15 +852,16 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if (!ObjectUtils.isEmpty(desDetail)) {
detail.putAll(desDetail);
}
// 将字符串数据转为对象
detail.put("proDuctPhoto", JSON.parse(String.valueOf(detail.get("proDuctPhoto"))));
detail.put("factoryStandard", JSON.parse(String.valueOf(detail.get("factoryStandard"))));
detail.put("productQualityYieldProve", JSON.parse(String.valueOf(detail.get("productQualityYieldProve"))));
detail.put("insUseMaintainExplain", JSON.parse(String.valueOf(detail.get("insUseMaintainExplain"))));
detail.put("designStandard", JSON.parse(String.valueOf(detail.get("designStandard"))));
detail.put("designDoc", JSON.parse(String.valueOf(detail.get("designDoc"))));
// 格式化必要字段,当前页面的字段,来源his
detail.put("longitudeLatitude", JSON.parse(String.valueOf(jsonObject.get("longitudeLatitude"))));
// 安装信息
Map<String, Object> installDetail = this.baseMapper.getiInstallDetail(record);
// 维保信息
Map<String, Object> maintenanceDetail = this.baseMapper.getMaintenanceDetail(record);
if (!ObjectUtils.isEmpty(maintenanceDetail)) {
detail.putAll(maintenanceDetail);
}
if (!ObjectUtils.isEmpty(installDetail)) {
detail.putAll(installDetail);
}
jsonObject.putAll(detail);
}
}
......@@ -1010,35 +992,18 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if ("0".equals(printType)) {
// 调用生成使用登记证
commonService.generateCertificateReport(exportParamsMap, response);
} else if("1".equals(printType)) {
} else if ("1".equals(printType)) {
// 套打
commonService.generatePdfPrint(exportParamsMap, response);
} else if("2".equals(printType)){
} else if ("2".equals(printType)) {
// 使用标志普通打印
commonService.useFlagGenerate(this.buildUseFlagParamDto(useRegistration, registerInfo, factoryInfo, exportParamsMap), response);
} else if("3".equals(printType)){
// 使用标志套打
} else if ("3".equals(printType)) {
// 使用标志套打
log.info("套打待开发");
}
}
/**
* @param auditPassDate 通过时间
* @param exportParamsMap 参数map
* */
public static void getAuditPassedDate(Date auditPassDate, Map<String, Object> exportParamsMap) {
LocalDate today;
if (ValidationUtil.isEmpty(auditPassDate)) {
// 发证日期为空取当前时间
today = LocalDate.now();
} else {
today = auditPassDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
exportParamsMap.put("giveOutYear", today.getYear());
exportParamsMap.put("giveOutMonth", today.getMonthValue());
exportParamsMap.put("giveOutDay", today.getDayOfMonth());
}
private UseFlagParamDto buildUseFlagParamDto(JgUseRegistration useRegistration, IdxBizJgRegisterInfo registerInfo, IdxBizJgFactoryInfo factoryInfo, Map<String, Object> exportParamsMap) {
UseFlagParamDto useFlagParamDto = new UseFlagParamDto();
useFlagParamDto.setReceiveCompanyCode(useRegistration.getReceiveCompanyCode());
......@@ -1067,7 +1032,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
private void setInspectFidld(IdxBizJgRegisterInfo registerInfo, UseFlagParamDto useFlagParamDto) {
Map<String, Object> inspectDetail = this.baseMapper.getInspectDetail(registerInfo.getRecord());
useFlagParamDto.setInspectionUnitName(inspectDetail.get("inspectOrgName") == null ? "" : inspectDetail.get("inspectOrgName").toString());
useFlagParamDto.setNextInspectionDate(inspectDetail.get("nextInspectDate") == null ? null : (Date)inspectDetail.get("nextInspectDate"));
useFlagParamDto.setNextInspectionDate(inspectDetail.get("nextInspectDate") == null ? null : (Date) inspectDetail.get("nextInspectDate"));
}
private void setMainInfoField(IdxBizJgRegisterInfo registerInfo, UseFlagParamDto useFlagParamDto) {
......@@ -1078,8 +1043,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
private String buildEmergencyTel(IdxBizJgMaintenanceRecordInfo idxBizJgMaintenanceRecordInfo) {
if(StringUtil.isNotEmpty(idxBizJgMaintenanceRecordInfo.getMeMasterPhone()) && StringUtil.isNotEmpty(idxBizJgMaintenanceRecordInfo.getMeMaster1Phone())){
return idxBizJgMaintenanceRecordInfo.getMeMasterPhone() + "/" + idxBizJgMaintenanceRecordInfo.getMeMaster1Phone();
if (StringUtil.isNotEmpty(idxBizJgMaintenanceRecordInfo.getMeMasterPhone()) && StringUtil.isNotEmpty(idxBizJgMaintenanceRecordInfo.getMeMaster1Phone())) {
return idxBizJgMaintenanceRecordInfo.getMeMasterPhone() + "/" + idxBizJgMaintenanceRecordInfo.getMeMaster1Phone();
}
return StringUtil.isNotEmpty(idxBizJgMaintenanceRecordInfo.getMeMasterPhone()) ? idxBizJgMaintenanceRecordInfo.getMeMasterPhone() : StringUtil.isNotEmpty(idxBizJgMaintenanceRecordInfo.getMeMaster1Phone()) ? idxBizJgMaintenanceRecordInfo.getMeMaster1Phone() : "";
}
......
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