Commit bb070893 authored by suhuiguang's avatar suhuiguang

1.注销报废 + 停用启用 + 维保 + 设备移交详情修改

2.公共设备详情,增加处理维保附件 字符串转json,个各业务无需再单独处理,附件字符串转 json
parent d4d70fa8
...@@ -56,15 +56,14 @@ public class JgScrapCancelController extends BaseController { ...@@ -56,15 +56,14 @@ public class JgScrapCancelController extends BaseController {
public ResponseModel<JgScrapCancelDto> updateInfo(@RequestParam String submitType, public ResponseModel<JgScrapCancelDto> updateInfo(@RequestParam String submitType,
@RequestBody Map<String, Object> model, @RequestBody Map<String, Object> model,
@RequestParam(value = "op", required = false) String op) { @RequestParam(value = "op", required = false) String op) {
JgScrapCancelDto jgScrapCancelDto = BeanUtil.mapToBean(((LinkedHashMap) model.get("jgScrapCancelAdd")), JgScrapCancelDto.class, true);
JgScrapCancelDto jgScrapCancelDto = JSON.parseObject(JSON.toJSONString(model.get("jgScrapCancelAdd")), JgScrapCancelDto.class);
if (Objects.isNull(jgScrapCancelDto)) { if (Objects.isNull(jgScrapCancelDto)) {
throw new IllegalArgumentException("参数jgScrapCancelAdd不能为空"); throw new IllegalArgumentException("参数jgScrapCancelAdd不能为空");
} }
Object o = ((LinkedHashMap<?, ?>) model.get("jgScrapCancelAdd")).get("cancelCertificateList");
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(model.get("jgScrapCancelAdd"))); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(model.get("jgScrapCancelAdd")));
jgScrapCancelDto.setCancelCertificateList((List<Map<String, Object>>) o);
jgScrapCancelDto.setSEQUENCE_NBR(String.valueOf(jsonObject.get("record"))); jgScrapCancelDto.setSEQUENCE_NBR(String.valueOf(jsonObject.get("record")));
return ResponseHelper.buildResponse(jgScrapCancelService.updateInfo(submitType, jgScrapCancelDto, op)); return ResponseHelper.buildResponse(jgScrapCancelService.updateInfo(submitType, jgScrapCancelDto, op, jsonObject));
} }
......
...@@ -1570,7 +1570,6 @@ public class CommonServiceImpl implements ICommonService { ...@@ -1570,7 +1570,6 @@ public class CommonServiceImpl implements ICommonService {
JgRegistrationHistory jgRegistrationHistory = new JgRegistrationHistory(); JgRegistrationHistory jgRegistrationHistory = new JgRegistrationHistory();
LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda(); LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda();
lambda.eq(JgRegistrationHistory::getCurrentDocumentId, currentDocumentId); lambda.eq(JgRegistrationHistory::getCurrentDocumentId, currentDocumentId);
lambda.eq(JgRegistrationHistory::getRegistrationClass, registrationClass);
Integer integer = jgRegistrationHistoryService.getBaseMapper().selectCount(lambda); Integer integer = jgRegistrationHistoryService.getBaseMapper().selectCount(lambda);
if (integer > 0) { if (integer > 0) {
jgRegistrationHistory.setChangeData(JSON.toJSONString(json)); jgRegistrationHistory.setChangeData(JSON.toJSONString(json));
......
...@@ -634,11 +634,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -634,11 +634,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
IdxBizJgMaintenanceRecordInfo maintenanceRecordInfo = iIdxBizJgMaintenanceRecordInfoService.queryNewestDetailByRecord(record); IdxBizJgMaintenanceRecordInfo maintenanceRecordInfo = iIdxBizJgMaintenanceRecordInfoService.queryNewestDetailByRecord(record);
if (!ValidationUtil.isEmpty(maintenanceRecordInfo)) { if (!ValidationUtil.isEmpty(maintenanceRecordInfo)) {
Map<String, Object> maintenanceRecordInfoMap; Map<String, Object> maintenanceRecordInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) { if (!ValidationUtil.isEmpty(fieldType)) {
maintenanceRecordInfoMap = Bean.BeantoMap(maintenanceRecordInfo); maintenanceRecordInfoMap = Bean.BeantoMap(maintenanceRecordInfo);
maintenanceRecordInfoMap.put("repairInform", JSON.parse(maintenanceRecordInfo.getRepairInform()));
maintenanceRecordInfoMap.put("maintenancerecordinfoSeq", maintenanceRecordInfo.getSequenceNbr()); maintenanceRecordInfoMap.put("maintenancerecordinfoSeq", maintenanceRecordInfo.getSequenceNbr());
} else { } else {
maintenanceRecordInfoMap = convertCamelToUnderscore(maintenanceRecordInfo, null); String[] toArrayFields = {"repairInform"};
maintenanceRecordInfoMap = convertCamelToUnderscore(maintenanceRecordInfo, toArrayFields);
maintenanceRecordInfoMap.put("MAINTENANCERECORDINFO_SEQ", maintenanceRecordInfo.getSequenceNbr()); maintenanceRecordInfoMap.put("MAINTENANCERECORDINFO_SEQ", maintenanceRecordInfo.getSequenceNbr());
} }
if (!maintenanceRecordInfoMap.isEmpty()) { if (!maintenanceRecordInfoMap.isEmpty()) {
......
...@@ -613,7 +613,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg ...@@ -613,7 +613,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
private void updateHistoryAsync(List<JgChangeRegistrationUnitEq> jgRelationEquipList) { private void updateHistoryAsync(List<JgChangeRegistrationUnitEq> jgRelationEquipList) {
jgRelationEquipList.forEach(j->{ jgRelationEquipList.forEach(j->{
commonService.saveOrUpdateHistory(null,getEquipInfoJson(j.getUnitChangeRegistrationId()) , j.getEquId(), j.getUnitChangeRegistrationId()); commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_COMPANY_CHANGE_REGISTRATION.getName(),getEquipInfoJson(j.getUnitChangeRegistrationId()) , j.getEquId(), j.getUnitChangeRegistrationId());
}); });
} }
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl; package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
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;
...@@ -112,7 +113,6 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -112,7 +113,6 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
WorkflowResultDto workflowResultDto = new WorkflowResultDto(); WorkflowResultDto workflowResultDto = new WorkflowResultDto();
List<ProcessTaskDTO> processTaskDTOS = new ArrayList<>(); List<ProcessTaskDTO> processTaskDTOS = new ArrayList<>();
String instanceId = "";
jgEnableDisable.setEquList("null".equals(record) ? "null" : map.get("equListDesc").toString()); jgEnableDisable.setEquList("null".equals(record) ? "null" : map.get("equListDesc").toString());
jgEnableDisable.setSupervisoryCode("null".equals(record) ? "null" : map.get("supervisoryCode").toString()); jgEnableDisable.setSupervisoryCode("null".equals(record) ? "null" : map.get("supervisoryCode").toString());
...@@ -224,9 +224,20 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -224,9 +224,20 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
jgEnableDisableEq.setEnableDisableApplyId(jgEnableDisable.getSequenceNbr().toString()); jgEnableDisableEq.setEnableDisableApplyId(jgEnableDisable.getSequenceNbr().toString());
jgEnableDisableEqService.saveOrUpdate(jgEnableDisableEq); jgEnableDisableEqService.saveOrUpdate(jgEnableDisableEq);
} }
// 保存历史表
commonService.saveOrUpdateHistory(this.getRegistrationClass(jgEnableDisable), map, record, jgEnableDisable.getSequenceNbr().toString());
return Collections.singletonList(jgEnableDisable); return Collections.singletonList(jgEnableDisable);
} }
private String getRegistrationClass(JgEnableDisable jgEnableDisable){
// 1启用,0停用
if("1".equals(jgEnableDisable.getApplyType())){
return BusinessTypeEnum.JG_EQUIPMENT_START.getName();
} else {
return BusinessTypeEnum.JG_EQUIPMENT_STOP.getName();
}
}
/** /**
* 暂存任务生成待办 * 暂存任务生成待办
* @param jgEnableDisable 业务信息 * @param jgEnableDisable 业务信息
...@@ -649,21 +660,36 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -649,21 +660,36 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
} }
public Map<String, Object> getDetail(Long sequenceNbr) { public Map<String, Object> getDetail(Long sequenceNbr) {
Map<String,Object> resultMap = this.baseMapper.getDetail(sequenceNbr); Map<String, Object> resultMap = new HashMap<>();
JgEnableDisableEq jgEnableDisableEq = jgEnableDisableEqMapper.selectOne(new LambdaQueryWrapper<JgEnableDisableEq>().eq(JgEnableDisableEq::getEnableDisableApplyId, sequenceNbr)); JgEnableDisable enableDisable = this.getById(sequenceNbr);
if(!ObjectUtils.isEmpty(jgEnableDisableEq)){ Map<String, Object> beanMap = BeanUtil.beanToMap(enableDisable, false, true);
Map<String, Object> map = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(jgEnableDisableEq.getEquId()); if(enableDisable.getAuditStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName())){
String[] fields = {"productPhoto", "designDoc", "designStandard", "factoryStandard", "productQualityYieldProve", // 完成状态查询历史表
"insUseMaintainExplain", "inspectReport", "proxyStatementAttachment", "installContractAttachment"}; JSONObject jsonObject = commonService.queryHistoryData(sequenceNbr);
for (String s : fields) { // 兼容老业务
if (map.containsKey(s) && !ObjectUtils.isEmpty(map.get(s))) if(jsonObject == null){
map.put(s, JSON.parseArray(map.get(s).toString())); // 老数据逻辑
fillRuntimeEquipInfoData(sequenceNbr, resultMap);
} else {
// 新数据逻辑
resultMap.putAll(jsonObject);
} }
resultMap.putAll(map); resultMap.putAll(beanMap);
} else {
// 其他状态显示实时数据
fillRuntimeEquipInfoData(sequenceNbr, resultMap);
resultMap.putAll(beanMap);
} }
resultMap.put("sequenceNbr", sequenceNbr); resultMap.put("receiveOrgCode", enableDisable.getReceiveCompanyCode() + '_' + enableDisable.getReceiveOrgName());
return resultMap; return resultMap;
}
private void fillRuntimeEquipInfoData(Long sequenceNbr, Map<String, Object> resultMap) {
JgEnableDisableEq jgEnableDisableEq = jgEnableDisableEqMapper.selectOne(new LambdaQueryWrapper<JgEnableDisableEq>().eq(JgEnableDisableEq::getEnableDisableApplyId, sequenceNbr));
if (!ObjectUtils.isEmpty(jgEnableDisableEq)) {
Map<String, Object> map = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(jgEnableDisableEq.getEquId());
resultMap.putAll(map);
}
} }
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapBuilder; import cn.hutool.core.map.MapBuilder;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.util.StringUtil; import com.github.pagehelper.util.StringUtil;
...@@ -12,6 +13,7 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams; ...@@ -12,6 +13,7 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; 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.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.*; import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationUnitEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransfer; import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransfer;
import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransferEq; import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransferEq;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
...@@ -138,9 +140,24 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto, ...@@ -138,9 +140,24 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
List<JgEquipTransferEq> jgEquipTransferEqList = this.buildJgEquipTransferEqList(equipTransferEqList, transferList); List<JgEquipTransferEq> jgEquipTransferEqList = this.buildJgEquipTransferEqList(equipTransferEqList, transferList);
jgEquipTransferEqMapper.insertBatchSomeColumn(jgEquipTransferEqList); jgEquipTransferEqMapper.insertBatchSomeColumn(jgEquipTransferEqList);
this.updateRedisBatch(transferList); this.updateRedisBatch(transferList);
// 创建历史数据
this.saveOrUpdateHisDataBatch(jgEquipTransferEqList);
return transferList; return transferList;
} }
private void saveOrUpdateHisDataBatch(List<JgEquipTransferEq> jgEquipTransferEqList) {
jgEquipTransferEqList.forEach(j->{
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_EQUIPMENT_HANDOVER.getName(),getEquipInfoJson(j.getEquId()) , j.getEquId(), j.getEquipTransferId());
});
}
private JSON getEquipInfoJson(String record) {
Map<String, Object> equipMap = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(record);;
equipMap.remove("useUnitCreditCode");
return new JSONObject(equipMap);
}
private void updateRedisBatch(List<JgEquipTransfer> transferList) { private void updateRedisBatch(List<JgEquipTransfer> transferList) {
transferList.stream().filter(n -> StringUtil.isNotEmpty(n.getInstanceId())).forEach(jgEquipTransfer -> { transferList.stream().filter(n -> StringUtil.isNotEmpty(n.getInstanceId())).forEach(jgEquipTransfer -> {
commonService.saveExecuteFlowData2Redis(jgEquipTransfer.getInstanceId(), this.buildInstanceRuntimeData(jgEquipTransfer)); commonService.saveExecuteFlowData2Redis(jgEquipTransfer.getInstanceId(), this.buildInstanceRuntimeData(jgEquipTransfer));
...@@ -352,9 +369,14 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto, ...@@ -352,9 +369,14 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
BeanUtils.copyProperties(equipTransferDto, equipTransfer); BeanUtils.copyProperties(equipTransferDto, equipTransfer);
updateById(equipTransfer); updateById(equipTransfer);
} }
this.updateHistorySingle(equipTransferDto.getSequenceNbr());
return equipTransferDto; return equipTransferDto;
} }
private void updateHistorySingle(Long seq){
List<JgEquipTransferEq> eqs = jgEquipTransferEqMapper.selectList(new LambdaQueryWrapper<JgEquipTransferEq>().eq(JgEquipTransferEq::getEquipTransferId,seq));
this.saveOrUpdateHisDataBatch(eqs);
}
/** /**
* 通过和驳回 * 通过和驳回
* *
...@@ -549,15 +571,37 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto, ...@@ -549,15 +571,37 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
@Override @Override
public Map<String, Object> queryBySequenceNbr(Long sequenceNbr) { public Map<String, Object> queryBySequenceNbr(Long sequenceNbr) {
JgEquipTransfer equipTransfer = baseMapper.selectById(sequenceNbr); JgEquipTransfer equipTransfer = baseMapper.selectById(sequenceNbr);
if (Objects.isNull(equipTransfer)) { if (Objects.isNull(equipTransfer)) {
return null; return null;
} }
Map<String, Object> equipTransferInfo = createEquipTransferInfo(equipTransfer);
if(FlowStatusEnum.TO_BE_FINISHED.getCode() == Integer.parseInt(equipTransfer.getApplyStatus())){
// 已完成状态显示历史数据
// 1.设备历史信息
JSONObject his = commonService.queryHistoryData(sequenceNbr);
// 兼容老数据
if(his == null){
// 1.设备信息
Map<String, Object> equipMap = getEquipInfonNew(sequenceNbr);
// 2.移交业务字段信息
equipMap.putAll(equipTransferInfo);
return equipMap;
} else {
// 2.移交业务字段信息
his.putAll(equipTransferInfo);
return his;
}
} else {
Map<String, Object> equipMap = getEquipInfonNew(sequenceNbr);
return Stream.concat(equipTransferInfo.entrySet().stream(),
equipMap.entrySet().stream())
.filter(entry -> entry.getValue() != null)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (existing, replacement) -> existing));
}
String[] fields = {"productPhoto", "designDoc", "designStandard", "factoryStandard", }
"productQualityYieldProve", "insUseMaintainExplain", "inspectReport",
"proxyStatementAttachment", "installContractAttachment"};
private Map<String, Object> getEquipInfonNew(Long sequenceNbr) {
List<Map<String, Object>> equipmentInfos = this.baseMapper.queryEquipInformation(sequenceNbr); List<Map<String, Object>> equipmentInfos = this.baseMapper.queryEquipInformation(sequenceNbr);
Map<String, Object> equipMap = null; Map<String, Object> equipMap = null;
if (equipmentInfos != null && !equipmentInfos.isEmpty()) { if (equipmentInfos != null && !equipmentInfos.isEmpty()) {
...@@ -566,22 +610,7 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto, ...@@ -566,22 +610,7 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
equipMap = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(equId); equipMap = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(equId);
} }
} }
return equipMap;
Map<String, Object> equipTransferInfo = createEquipTransferInfo(equipTransfer);
handleJsonArrayFields(equipTransferInfo, fields);
handleJsonArrayFields(equipMap, fields);
return Stream.concat(equipTransferInfo.entrySet().stream(),
equipMap.entrySet().stream())
.filter(entry -> entry.getValue() != null)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (existing, replacement) -> existing));
}
private void handleJsonArrayFields(Map<String, Object> map, String[] fields) {
for (String field : fields) {
map.computeIfPresent(field, (key, value) -> JSON.parseArray(value.toString()));
}
} }
/** /**
...@@ -711,7 +740,7 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto, ...@@ -711,7 +740,7 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
} }
private Map<String, Object> createEquipTransferInfo(JgEquipTransfer equipTransfer) { private Map<String, Object> createEquipTransferInfo(JgEquipTransfer equipTransfer) {
Map<String, Object> equipTransferInfo = new HashMap<>(BeanUtil.beanToMap(equipTransfer)); Map<String, Object> equipTransferInfo = new HashMap<>(BeanUtil.beanToMap(equipTransfer ,false , true));
equipTransferInfo.put("installUnitCreditCode", equipTransfer.getInstallUnitCreditCode() + "_" + equipTransfer.getInstallUnitName()); equipTransferInfo.put("installUnitCreditCode", equipTransfer.getInstallUnitCreditCode() + "_" + equipTransfer.getInstallUnitName());
return equipTransferInfo; return equipTransferInfo;
} }
......
...@@ -522,7 +522,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -522,7 +522,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
} }
updateById(contract); updateById(contract);
// 设备数据存历史数据,在流程完成时使用 // 设备数据存历史数据,在流程完成时使用
commonService.saveOrUpdateHistory(null, JSON.parseArray(JSON.toJSONString(equipmentLists)), null, contract.getSequenceNbr().toString()); commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MAINTENANCE_RECORD.getName(), JSON.parseArray(JSON.toJSONString(equipmentLists)), null, contract.getSequenceNbr().toString());
return Collections.singletonList(contract); return Collections.singletonList(contract);
} }
......
...@@ -160,7 +160,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -160,7 +160,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public JgScrapCancel save(String submitType, Map<String, Object> mapParams) { public JgScrapCancel save(String submitType, Map<String, Object> mapParams) {
ReginParams reginParams = this.getSelectedOrgInfo(); ReginParams reginParams = this.getSelectedOrgInfo();
Map<?, ?> noticeParams = (Map) mapParams.get(PAGE_KEY); Map<String, Object> noticeParams = (Map) mapParams.get(PAGE_KEY);
String equipId = String.valueOf(noticeParams.get("record")); String equipId = String.valueOf(noticeParams.get("record"));
String[] receiveOrg = String.valueOf(noticeParams.get("receiveOrgCreditCode")).split("_"); String[] receiveOrg = String.valueOf(noticeParams.get("receiveOrgCreditCode")).split("_");
noticeParams.remove("record"); noticeParams.remove("record");
...@@ -254,12 +254,18 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -254,12 +254,18 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
jgScrapCancelEqService.save(jgRelationEquip); jgScrapCancelEqService.save(jgRelationEquip);
String equListName = EquipmentClassifityEnum.getNameByCode(jgScrapCancel.getEquList()); String equListName = EquipmentClassifityEnum.getNameByCode(jgScrapCancel.getEquList());
jgScrapCancel.setEquListDesc(equListName); jgScrapCancel.setEquListDesc(equListName);
jgScrapCancel.setCancelTypeDesc("1".equals(jgScrapCancel.getCancelType()) ? "报废注销" : "移装注销"); jgScrapCancel.setCancelTypeDesc(getRegistrationClass(jgScrapCancel.getCancelType()));
commonService.saveExecuteFlowData2Redis(instanceId, buildInstanceRuntimeData(jgScrapCancel)); commonService.saveExecuteFlowData2Redis(instanceId, buildInstanceRuntimeData(jgScrapCancel));
save2HisData(noticeParams, equipId, jgRelationEquip, jgScrapCancel);
return jgScrapCancel; return jgScrapCancel;
} }
private void save2HisData(Map<String, Object> noticeParams, String equipId, JgScrapCancelEq jgRelationEquip, JgScrapCancel jgScrapCancel) {
noticeParams.put("record", equipId);
commonService.saveOrUpdateHistory(jgScrapCancel.getCancelTypeDesc(), new JSONObject(noticeParams), jgRelationEquip.getEquId(), jgScrapCancel.getSequenceNbr().toString());
}
private void createTaskModel(JgScrapCancel scrapCancel, String taskName, String submitType, String nextUserIds) { private void createTaskModel(JgScrapCancel scrapCancel, String taskName, String submitType, String nextUserIds) {
ReginParams reginParams = this.getSelectedOrgInfo(); ReginParams reginParams = this.getSelectedOrgInfo();
TaskModelDto taskModelDto = new TaskModelDto(); TaskModelDto taskModelDto = new TaskModelDto();
...@@ -337,7 +343,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -337,7 +343,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
} }
} }
public JgScrapCancelDto updateInfo(String submitType, JgScrapCancelDto jgScrapCancelDto, String op) { public JgScrapCancelDto updateInfo(String submitType, JgScrapCancelDto jgScrapCancelDto, String op, JSONObject pageData) {
if (Objects.isNull(jgScrapCancelDto) || StringUtils.isEmpty(submitType)) { if (Objects.isNull(jgScrapCancelDto) || StringUtils.isEmpty(submitType)) {
throw new IllegalArgumentException("参数不能为空"); throw new IllegalArgumentException("参数不能为空");
...@@ -436,9 +442,14 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -436,9 +442,14 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
jgScrapCancelEq.setEquId(jgScrapCancelDto.getRecord()); jgScrapCancelEq.setEquId(jgScrapCancelDto.getRecord());
jgScrapCancelEqMapper.update(jgScrapCancelEq, updateWrapper); jgScrapCancelEqMapper.update(jgScrapCancelEq, updateWrapper);
} }
commonService.saveOrUpdateHistory(getRegistrationClass(jgScrapCancelDto.getCancelType()), pageData, jgScrapCancelDto.getRecord(), jgScrapCancelDto.getSequenceNbr().toString());
return jgScrapCancelDto; return jgScrapCancelDto;
} }
private String getRegistrationClass (String cancelType){
return "1".equals(cancelType) ? "报废注销" : "移装注销";
}
private void executeOneStep(JgScrapCancelDto jgScrapCancelDto, String taskName, String nextUserIds, String operate) { private void executeOneStep(JgScrapCancelDto jgScrapCancelDto, String taskName, String nextUserIds, String operate) {
// 先更新之前的待办 // 先更新之前的待办
TaskV2Model taskV2Model = updateTaskModel(jgScrapCancelDto, operate); TaskV2Model taskV2Model = updateTaskModel(jgScrapCancelDto, operate);
...@@ -520,47 +531,44 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -520,47 +531,44 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
return cmWorkflowService.completeOrReject(jgScrapCancelDto.getNextTaskId(), dto, op); return cmWorkflowService.completeOrReject(jgScrapCancelDto.getNextTaskId(), dto, op);
} }
public Map<String, Object> queryBySequenceNbr(Long sequenceNbr) { public Map<String, Object> queryBySequenceNbr(Long sequenceNbr) {
// 安装告知信息 Map<String, Object> resultMap = new HashMap<>();
JgScrapCancel notice = this.baseMapper.selectById(sequenceNbr); JgScrapCancel scrapCancel = this.baseMapper.selectById(sequenceNbr);
if (Objects.isNull(notice)) { Map<String, Object> beanMap = BeanUtil.beanToMap(scrapCancel, false, true);
return null; beanMap.put("cancelCertificateList", JSON.parse(scrapCancel.getCancelCertificate()));
} beanMap.put("otherAccessories", JSON.parse(scrapCancel.getOtherAccessories()));
Map<String, Object> installationInfo = BeanUtil.beanToMap(notice); if(scrapCancel.getAuditStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName())){
installationInfo.put("receiveOrgCode", notice.getReceiveCompanyCode() + "_" + notice.getReceiveOrgName()); // 完成状态查询历史表
installationInfo.put("cancelCertificateList", JSON.parseArray(String.valueOf(installationInfo.get("cancelCertificate")))); JSONObject jsonObject = commonService.queryHistoryData(sequenceNbr);
installationInfo.put("otherAccessories", JSON.parseArray(JSONObject.toJSONString(installationInfo.get("otherAccessories")))); // 兼容老业务
LambdaQueryWrapper<JgScrapCancelEq> lambdaEq = new QueryWrapper<JgScrapCancelEq>().lambda(); if(jsonObject == null){
lambdaEq.eq(JgScrapCancelEq::getEquipTransferId, sequenceNbr); // 老数据逻辑
JgScrapCancelEq jgScrapCancelEq = jgScrapCancelEqMapper.selectOne(lambdaEq); fillRuntimeData(sequenceNbr, resultMap);
if (!ValidationUtil.isNull(jgScrapCancelEq.getEquId()) && !"null".equals(jgScrapCancelEq.getEquId())) { } else {
// 设备信息 // 新数据逻辑
installationInfo.put("record", jgScrapCancelEq.getEquId()); resultMap.putAll(jsonObject);
}
LambdaQueryWrapper<IdxBizJgRegisterInfo> queryWrapper = new LambdaQueryWrapper<>(); resultMap.putAll(beanMap);
queryWrapper.eq(IdxBizJgRegisterInfo::getRecord, jgScrapCancelEq.getEquId()); } else {
queryWrapper.last("limit 1"); // 其他状态显示实时数据
IdxBizJgRegisterInfo one = idxBizJgRegisterInfoMapper.selectOne(queryWrapper); fillRuntimeData(sequenceNbr, resultMap);
installationInfo.put("equCode", one.getEquCode()); resultMap.putAll(beanMap);
Map<String, Object> detailFieldCamelCaseByRecord = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(jgScrapCancelEq.getEquId());
String equList = String.valueOf(detailFieldCamelCaseByRecord.getOrDefault("equList", ""));
Map<String, Object> collect = Stream.concat(
installationInfo.entrySet().stream(),
detailFieldCamelCaseByRecord.entrySet().stream()
)
.filter(entry -> entry.getValue() != null)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (existing, replacement) -> existing));
collect.put("equList", equList);
// collect.put("EQU_LIST_CODE", equList);
return new HashMap<String, Object>() {{
this.put(PAGE_KEY, collect);
}};
} }
resultMap.put("receiveOrgCode", scrapCancel.getReceiveCompanyCode() + '_' + scrapCancel.getReceiveOrgName());
return new HashMap<String, Object>() {{ return new HashMap<String, Object>() {{
this.put(PAGE_KEY, installationInfo); this.put(PAGE_KEY, resultMap);
}}; }};
} }
private void fillRuntimeData(Long sequenceNbr, Map<String, Object> resultMap) {
JgScrapCancelEq jgScrapCancelEq = jgScrapCancelEqMapper.selectOne(new LambdaQueryWrapper<JgScrapCancelEq>().eq(JgScrapCancelEq::getEquipTransferId, sequenceNbr));
if (!ObjectUtils.isEmpty(jgScrapCancelEq)) {
Map<String, Object> map = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(jgScrapCancelEq.getEquId());
resultMap.putAll(map);
}
}
@Transactional @Transactional
public void revocation(String instanceId, String nextTaskId) { public void revocation(String instanceId, String nextTaskId) {
...@@ -569,7 +577,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -569,7 +577,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
try { try {
boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回) // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if(!isLocked){ if (!isLocked) {
throw new BadRequest("当前流程已经被执行!请重新打开页面查看并执行!"); throw new BadRequest("当前流程已经被执行!请重新打开页面查看并执行!");
} }
// 流程执行时,状态及权限校验 // 流程执行时,状态及权限校验
...@@ -609,7 +617,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -609,7 +617,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if(lock.isHeldByCurrentThread()){ if (lock.isHeldByCurrentThread()) {
lock.unlock(); lock.unlock();
} }
} }
...@@ -634,7 +642,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -634,7 +642,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
try { try {
boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回) // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if(!isLocked){ if (!isLocked) {
throw new BadRequest("当前流程已经被执行!请重新打开页面查看并执行!"); throw new BadRequest("当前流程已经被执行!请重新打开页面查看并执行!");
} }
// 流程执行时,状态及权限校验 // 流程执行时,状态及权限校验
...@@ -665,7 +673,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -665,7 +673,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if(lock.isHeldByCurrentThread()){ if (lock.isHeldByCurrentThread()) {
lock.unlock(); lock.unlock();
} }
} }
......
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