Commit 36062b76 authored by suhuiguang's avatar suhuiguang

refactor(大编辑):代码重构

1.安装告知编辑功能开发
parent e086c80b
package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.installNotice;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
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.edit.process.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
@Component
public class InstallNoticeDataChangeHandler extends DefaultBizDataChangeHandler<BaseBizDataChangeEvent> {
protected InstallNoticeDataChangeHandler(RouterEventPublisher routerEventPublisher, ApplicationContext applicationContext) {
private final InstallNoticeEditUpdateService installNoticeEditUpdateService;
protected InstallNoticeDataChangeHandler(InstallNoticeEditUpdateService installNoticeEditUpdateService, RouterEventPublisher routerEventPublisher, ApplicationContext applicationContext) {
super(routerEventPublisher, applicationContext);
this.installNoticeEditUpdateService = installNoticeEditUpdateService;
}
@Override
......@@ -31,12 +36,12 @@ public class InstallNoticeDataChangeHandler extends DefaultBizDataChangeHandler<
@Override
public Boolean beforeCheck(String bizId, String applyNo, ModelType model, Map<String, Object> changeData) {
return null;
return true;
}
@Override
public Set<String> getEqs(String applyNo) {
return Collections.emptySet();
return installNoticeEditUpdateService.getEqsByApplyNo(applyNo);
}
@Override
......@@ -46,11 +51,17 @@ public class InstallNoticeDataChangeHandler extends DefaultBizDataChangeHandler<
@Override
public Boolean bizIsFinished(String applyNo, ModelType model, Map<String, Object> changeData) {
return null;
JgInstallationNotice installationNotice = installNoticeEditUpdateService.getInstallationNoticeService().getOne(new LambdaQueryWrapper<JgInstallationNotice>().eq(JgInstallationNotice::getApplyNo, applyNo).select(BaseEntity::getSequenceNbr, JgInstallationNotice::getNoticeStatus));
return installationNotice.getNoticeStatus().equals(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
}
@Override
public Set<String> getProjectContraptionIds(String applyNo) {
return Collections.emptySet();
JgInstallationNotice installationNotice = installNoticeEditUpdateService.getOneByApplyNo(applyNo);
Set<String> projectContraptionIds = new HashSet<>();
projectContraptionIds.add(installationNotice.getProjectContraptionId());
projectContraptionIds.remove(null);
projectContraptionIds.remove("");
return projectContraptionIds;
}
}
package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.installNotice;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeEqServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@Getter
public class InstallNoticeEditUpdateService {
private final JgInstallationNoticeServiceImpl installationNoticeService;
private final JgInstallationNoticeEqServiceImpl installationNoticeEqService;
public Set<String> getEqsByApplyNo(String applyNo) {
JgInstallationNotice jgInstallationNotice = installationNoticeService.getOne(new LambdaQueryWrapper<JgInstallationNotice>().eq(JgInstallationNotice::getApplyNo, applyNo).select(BaseEntity::getSequenceNbr));
List<JgInstallationNoticeEq> eqs = installationNoticeEqService.list(new LambdaQueryWrapper<JgInstallationNoticeEq>().eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr()).select(JgInstallationNoticeEq::getEquId));
return eqs.stream().map(JgInstallationNoticeEq::getEquId).collect(Collectors.toSet());
}
public JgInstallationNotice getOneByApplyNo(String applyNo) {
return installationNoticeService.getOne(new LambdaQueryWrapper<JgInstallationNotice>().eq(JgInstallationNotice::getApplyNo, applyNo));
}
}
package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.useRegister;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
......@@ -43,27 +42,6 @@ public class UseRegisterUpdateService {
private final JgUseRegistrationEqServiceImpl useRegistrationEqService;
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.toJSONString(jsonObject.get(field))));
}
}
} 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((String) map.get(field)));
}
}
} else {
// 处理其他类型
System.out.println("Unsupported Object Type");
}
}
public void updateBizInfo(Map<String, Object> changeData) {
}
......
......@@ -131,6 +131,7 @@ public class CommonEquipDataProcessService {
throw new RuntimeException(e);
}
}
public static <T extends IBaseChangeData> void castMap2Bean(Map<String, Object> map, T target) {
BeanUtil.copyProperties(JSON.parse(JSONObject.toJSONString(map)), target, true);
}
......@@ -844,16 +845,35 @@ public class CommonEquipDataProcessService {
}
public Map<String, ?> getProjectContraptionBySeq(String projectContraptionId, Set<String> records) {
JSONObject jsonObject = new JSONObject();
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionServiceImpl.getById(projectContraptionId);
jsonObject.put("pipelineLength", projectContraption.getPipelineLength());
jsonObject.put("projectContraption", projectContraption.getProjectContraption());
jsonObject.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
Map<String, Object> re = BeanUtil.beanToMap(projectContraption);
this.convertStringToJsonObject(re, IdxBizJgProjectContraptionServiceImpl.getJsonFieldsCamel());
List<Map<String, Object>> equList = jgUseRegistrationService.getBaseMapper().queryForUnitPipelineEquipment(new ArrayList<>(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);
return jsonObject;
re.put("tableData", equList);
return re;
}
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");
}
}
public IPage<?> getProjectContraptionsBySeqs(Set<String> projectContraptionIds, JSONObject params) {
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -130,6 +131,14 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
return this.saveOrUpdate(projectContraption);
}
public static String[] getJsonFieldsCamel(){
List<String> camelFields = new ArrayList<>();
for(String field : jsonFields) {
camelFields.add(CharSequenceUtil.toCamelCase(field));
}
return camelFields.toArray(new String[0]);
}
/**
* 根据工程装置seq物理删除装置表数据和对应设备信息(数据库+es)
*
......
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