Commit 3201f058 authored by suhuiguang's avatar suhuiguang

1.编辑代码公共代码开发

parent 1c4eed00
......@@ -63,8 +63,7 @@ public class BizDataChangeController {
@ApiOperation(value = "查询可业务变更的字段及默认值--通用", httpMethod = "GET")
public ResponseModel<Map<String, ?>> getDetailV2(@RequestParam(required = false) String applyNo,
@RequestParam(required = false) String bizId,
@PathVariable String bizType,
DefaultBizDataChangeHandler.ModelType model) {
return ResponseHelper.buildResponse(bizDataChangeService.queryDetail(applyNo, bizType, model, bizId));
@PathVariable String bizType) {
return ResponseHelper.buildResponse(bizDataChangeService.queryDetail(applyNo, bizType, bizId));
}
}
......@@ -45,6 +45,9 @@ public class RequestChangeData extends JSONObject {
if (!this.containsKey(changeReasonKey) || !this.containsKey(changeReasonAttachmentKey)) {
throw new BadRequest("变更说明和变更说明附件不能为空!");
}
if (!this.containsKey(modelTypeKey)) {
throw new BadRequest("解析处理器不能为空!");
}
}
}
......@@ -28,9 +28,9 @@ public class BizDataChangeServiceImpl {
handleStrategy.doSave(applyNo, changeData.getModelType(), changeData);
}
public Map<String, ?> queryDetail(String applyNo, String bizType, DefaultBizDataChangeHandler.ModelType model, String bizId) {
public Map<String, ?> queryDetail(String applyNo, String bizType, String bizId) {
IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
return handleStrategy.getDetail(applyNo, model, bizId);
return handleStrategy.getDetail(applyNo, bizId);
}
}
......@@ -27,7 +27,7 @@ public class InstallNoticeDataChangeHandler extends DefaultBizDataChangeHandler<
}
@Override
public Map<String, ?> getDetail(String applyNo, ModelType model, String bizId) {
public Map<String, ?> getDetail(String applyNo, String bizId) {
return Collections.emptyMap();
}
......
package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration;
import com.yeejoin.amos.boot.module.jg.biz.edit.core.RouterEventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.BaseBizDataChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -66,8 +73,15 @@ public class UseRegisterDataChangeHandler extends DefaultBizDataChangeHandler<Ba
@Override
public Map<String, ?> getDetail(String applyNo, ModelType model, String bizId) {
return null;
public Map<String, ?> getDetail(String applyNo, String bizId) {
Map<String, Object> detail = new HashMap<>();
JgUseRegistration useRegistration = useRegisterUpdateService.useRegistrationService.getOne(new LambdaQueryWrapper<JgUseRegistration>().eq(JgUseRegistration::getApplyNo, applyNo));
JSONObject lastDetailDataForEdit = useRegisterUpdateService.getLastDetailDataForEdit(useRegistration);
BeanUtil.copyProperties(lastDetailDataForEdit, detail);
BeanUtil.copyProperties(useRegistration, detail);
// 转化 附件 字段
useRegisterUpdateService.convertStringToJsonObject(detail, JgUseRegistrationServiceImpl.jsonFields);
return detail;
}
@Override
......
......@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration;
import com.yeejoin.amos.boot.module.jg.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgProjectContraptionServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgRegistrationHistoryServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl;
......@@ -17,6 +18,7 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.InformationManageTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -27,23 +29,19 @@ import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList;
@Service
@RequiredArgsConstructor
public class UseRegisterUpdateService {
private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
private final JgUseRegistrationServiceImpl useRegistrationService;
final JgUseRegistrationServiceImpl useRegistrationService;
final JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
private final JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
final CommonServiceImpl commonService;
private final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionService;
final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionService;
public UseRegisterUpdateService(IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper, JgUseRegistrationServiceImpl useRegistrationService, JgRegistrationHistoryServiceImpl jgRegistrationHistoryService, IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionService) {
this.idxBizJgRegisterInfoMapper = idxBizJgRegisterInfoMapper;
this.useRegistrationService = useRegistrationService;
this.jgRegistrationHistoryService = jgRegistrationHistoryService;
this.idxBizJgProjectContraptionService = idxBizJgProjectContraptionService;
}
public void updateHisData(String applyNo) {
JgUseRegistration jgUseRegistration = useRegistrationService.getOne(new LambdaQueryWrapper<JgUseRegistration>().eq(JgUseRegistration::getApplyNo, applyNo));
......@@ -54,10 +52,7 @@ public class UseRegisterUpdateService {
}
public JSONObject buildLastDetailData(JgUseRegistration jgUseRegistration) {
LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda();
lambda.eq(JgRegistrationHistory::getCurrentDocumentId, jgUseRegistration.getSequenceNbr());
lambda.eq(JgRegistrationHistory::getIsDelete, false);
JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryService.getBaseMapper().selectOne(lambda);
JgRegistrationHistory jgRegistrationHistory = getJgRegistrationHistory(jgUseRegistration);
JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
jsonObject.put("receiveOrgCode", jgUseRegistration.getReceiveCompanyCode() + "_" + jgUseRegistration.getReceiveOrgName());
jsonObject.put("status", jgUseRegistration.getStatus());
......@@ -111,6 +106,66 @@ public class UseRegisterUpdateService {
return jsonObject;
}
public JSONObject getLastDetailDataForEdit(JgUseRegistration jgUseRegistration) {
JgRegistrationHistory jgRegistrationHistory = getJgRegistrationHistory(jgUseRegistration);
JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
jsonObject.put("receiveOrgCode", jgUseRegistration.getReceiveCompanyCode() + "_" + jgUseRegistration.getReceiveOrgName());
jsonObject.put("status", jgUseRegistration.getStatus());
jsonObject.put("applyNo", jgUseRegistration.getApplyNo());
jsonObject.remove("submit");
jsonObject.remove("instanceId");
if (!ObjectUtils.isEmpty(jsonObject.get("factoryUseSiteStreet"))) {
jsonObject.put("factoryUseSiteStreet", String.valueOf(Long.valueOf(jsonObject.get("factoryUseSiteStreet").toString())));
}
if (!"unit".equals(jgUseRegistration.getManageType())) {
// 台套逻辑
String record = useRegistrationService.setDefaultRecord(jgUseRegistration, null);
// 更新 设计、制造、基本信息json
useRegistrationService.fillLastEquipBaseInfo(jsonObject, record);
// 补充"车牌号"字段
LambdaQueryWrapper<IdxBizJgRegisterInfo> wrapper = new QueryWrapper<IdxBizJgRegisterInfo>().lambda().eq(IdxBizJgRegisterInfo::getRecord, record);
IdxBizJgRegisterInfo idxBizJgRegisterInfo = idxBizJgRegisterInfoMapper.selectOne(wrapper);
jsonObject.put("carNumber", idxBizJgRegisterInfo.getCarNumber());
jsonObject.put("regType", jgUseRegistration.getRegType());
} else {
// 单位办理逻辑
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) jsonObject.get("equipmentLists");
List<String> records = equipmentLists.stream().map(v -> (String) v.get("record")).collect(toList());
jsonObject.remove("equipmentLists");
if (CylinderTypeEnum.CYLINDER.getCode().equals(jsonObject.get("EQU_CATEGORY_CODE"))) {
List<DictionarieValueModel> fillingMedium = Systemctl.dictionarieClient.dictValues("FILLING_MEDIUM").getResult();
Map<String, Object> fillingMediumMap = fillingMedium.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataKey, DictionarieValueModel::getDictDataValue));
List<Map<String, Object>> result = useRegistrationService.getBaseMapper().queryForUnitVesselEquipment(records);
result.forEach(i -> {
i.put("chargingMedium", fillingMediumMap.get(i.get("chargingMedium")));
i.put("productPhoto", JSONArray.parseArray((String) i.get("productPhoto")));
i.put("cylinderStampAttachment", JSONArray.parseArray((String) i.get("cylinderStampAttachment")));
i.put("informationSituation", InformationManageTypeEnum.getName((String) i.get("informationSituation")));
});
jsonObject.put("tableData", result);
} else {
// 管道逻辑 更新装置、管道有关数据
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionService.getById(jgUseRegistration.getProjectContraptionId());
jsonObject.put("pipelineLength", projectContraption.getPipelineLength());
jsonObject.put("projectContraption",projectContraption.getProjectContraption());
jsonObject.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
List<Map<String, Object>> equList = useRegistrationService.getBaseMapper().queryForUnitPipelineEquipment(records);
// 检验报告数据格式化 转json
equList.stream().filter(e-> e.get("inspectReport") != null).forEach(item-> item.put("inspectReport", JSON.parse(item.get("inspectReport").toString())));
jsonObject.put("tableData", equList);
}
}
jsonObject.put("useRegistrationCode", jgUseRegistration.getUseRegistrationCode());
return jsonObject;
}
public JgRegistrationHistory getJgRegistrationHistory(JgUseRegistration jgUseRegistration) {
LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda();
lambda.eq(JgRegistrationHistory::getCurrentDocumentId, jgUseRegistration.getSequenceNbr());
lambda.eq(JgRegistrationHistory::getIsDelete, false);
return jgRegistrationHistoryService.getBaseMapper().selectOne(lambda);
}
public void convertStringToJsonObject(Object obj, String[] jsonFields) {
if (obj instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) obj;
......@@ -123,7 +178,7 @@ public class UseRegisterUpdateService {
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(JSONObject.toJSONString(map.get(field))));
map.put(field, JSON.parse((String) map.get(field)));
}
}
} else {
......
......@@ -18,11 +18,10 @@ public interface IBizDataChangeHandleStrategy {
* 获取变更信息详情
*
* @param applyNo 单据编号
* @param model single, batch
* @param bizId 设备record
* @return 变更信息详情
*/
Map<String, ?> getDetail(String applyNo, ModelType model, String bizId);
Map<String, ?> getDetail(String applyNo, String bizId);
/**
* 保存
......
......@@ -164,7 +164,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired
DataDictionaryServiceImpl iDataDictionaryService;
public static final String[] jsonFields = {"productPhoto", "factoryStandard", "productQualityYieldProve", "insUseMaintainExplain",
public static final String[] jsonFields = {"useRegistrationFormFile", "productPhoto", "factoryStandard", "productQualityYieldProve", "insUseMaintainExplain",
"inspectReport", "designStandard", "designDoc", "longitudeLatitude", "otherAccessoriesDes", "otherAccessoriesFact",
"otherAccessoriesReg", "installProxyStatementAttachment", "installContractAttachment", "insOtherAccessories",
"maintenanceContract", "maintOtherAccessories", "installProxyStatementAttachment", "installContractAttachment",
......
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