|
@@ -0,0 +1,298 @@
|
|
|
+package com.miniframe.bisiness.es;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import com.miniframe.core.ExecProcessFlow;
|
|
|
+import com.miniframe.core.ext.UtilTools;
|
|
|
+import com.miniframe.generate.business.es.model.ES0028BaseModel;
|
|
|
+import com.miniframe.model.es.*;
|
|
|
+import com.miniframe.model.es.dao.*;
|
|
|
+import com.miniframe.tools.XIFileUtils;
|
|
|
+import tk.mybatis.mapper.entity.Example;
|
|
|
+
|
|
|
+import javax.naming.directory.InvalidAttributeIdentifierException;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 无锡发动机,“项目克隆”逻辑处理(重新生成不覆盖)。
|
|
|
+ */
|
|
|
+public class ES0028Service extends ES0028BaseModel implements ExecProcessFlow {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = -7051358269847459502L;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无锡发动机,“项目克隆”业务核心处理
|
|
|
+ */
|
|
|
+ public void transExecute() throws Exception {
|
|
|
+ String uid = this.getA_es0028().getUid();
|
|
|
+ String pid = this.getA_es0028().getPid();
|
|
|
+ EsProSQLBuilder esProSQLBuilder = new EsProSQLBuilder();
|
|
|
+ EsProSQLBuilder.Criteria esProSQLBuilderCriteria = esProSQLBuilder.createCriteria();
|
|
|
+ esProSQLBuilderCriteria.andUidEqualTo(uid);
|
|
|
+ esProSQLBuilderCriteria.andPidEqualTo(pid);
|
|
|
+ EsProMapper esProMapper = UtilTools.getBean(EsProMapper.class);
|
|
|
+ EsPro esPro = esProMapper.selectOneByExample(esProSQLBuilder);
|
|
|
+
|
|
|
+ String pid_new = UtilTools.getUUid();
|
|
|
+ EsPro esProNew = new EsPro();
|
|
|
+ esProNew.setPid(pid_new);
|
|
|
+ esProNew.setUid(uid);
|
|
|
+ esProNew.setName(esPro.getName());
|
|
|
+ esProNew.setRemark(esPro.getRemark());
|
|
|
+ esProNew.setCreateTime(esPro.getCreateTime());
|
|
|
+ Date updateTime = new Date();
|
|
|
+ esProNew.setUpdateTime(updateTime);
|
|
|
+ esProNew.setFlow(esPro.getFlow());
|
|
|
+ esProNew.setUname(esPro.getUname());
|
|
|
+ esProNew.setSize(esPro.getSize());
|
|
|
+ esProNew.setKeywords(esPro.getKeywords());
|
|
|
+ esProMapper.insert(esProNew);
|
|
|
+
|
|
|
+ //创建文件路径
|
|
|
+ XIFileUtils.mkdir(XIFileUtils.getRootPathStr());
|
|
|
+ XIFileUtils.mkdir(XIFileUtils.getRootPathStr()+"/es");
|
|
|
+ XIFileUtils.mkdir(XIFileUtils.getRootPathStr()+"/es/"+pid_new);
|
|
|
+ XIFileUtils.mkdir(XIFileUtils.getRootPathStr()+"/es/"+pid_new+"/Calculate");
|
|
|
+ XIFileUtils.mkdir(XIFileUtils.getRootPathStr()+"/es/"+pid_new+"/Calculate/Geometry");//几何路径
|
|
|
+
|
|
|
+ List<String> pcIdList = new ArrayList<String>();
|
|
|
+ List<String> pcIdListNew = new ArrayList<String>();
|
|
|
+ selectAndSaveEsProCom(pid,pid_new,pcIdList,pcIdListNew);
|
|
|
+
|
|
|
+ Map<String,List<String>> pcaIdMap = new HashMap<>();
|
|
|
+ Map<String,List<String>> newPcaIdMap = new HashMap<>();
|
|
|
+ selectAndSaveEsProComAtt(pid,pid_new,pcIdList,pcIdListNew,pcaIdMap,newPcaIdMap);
|
|
|
+
|
|
|
+ //构造pcid和newpcid对照的map
|
|
|
+ Map<String, String> pcIdAndPcIdNewMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < pcIdList.size(); i++) {
|
|
|
+ pcIdAndPcIdNewMap.put(pcIdList.get(i), pcIdListNew.get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ selectAndSaveEsProComAttData(pid,pid_new,pcIdAndPcIdNewMap,pcaIdMap,newPcaIdMap);
|
|
|
+
|
|
|
+ selectAndSaveEsProComCon(pid,pid_new,pcIdList,pcIdListNew);
|
|
|
+
|
|
|
+ //todo
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找并修改es_pro_com表记录
|
|
|
+ * @param[in] pid
|
|
|
+ * @param[in] pidNew
|
|
|
+ * @param[out] pcIdList
|
|
|
+ * @param[out] newPcIdList
|
|
|
+ */
|
|
|
+ public void selectAndSaveEsProCom(String pid,String pidNew,List<String> pcIdList,List<String> newPcIdList)
|
|
|
+ {
|
|
|
+ EsProComMapper esProComMapper = UtilTools.getBean(EsProComMapper.class);
|
|
|
+ EsProComSQLBuilder esProComSQLBuilder = new EsProComSQLBuilder();
|
|
|
+ EsProComSQLBuilder.Criteria esProComSQLBuilderCriteria = esProComSQLBuilder.createCriteria();
|
|
|
+ esProComSQLBuilderCriteria.andUidEqualTo(this.getA_es0028().getUid());
|
|
|
+ esProComSQLBuilderCriteria.andPidEqualTo(pid);
|
|
|
+ List<EsProCom> esProComList = esProComMapper.selectByExample(esProComSQLBuilder);
|
|
|
+ for (EsProCom esProCom : esProComList){
|
|
|
+ String pcId = esProCom.getPcId();
|
|
|
+ pcIdList.add(pcId);
|
|
|
+
|
|
|
+ String pcIdNew = UtilTools.getUUid();
|
|
|
+ newPcIdList.add(pcIdNew);
|
|
|
+
|
|
|
+ EsProCom esProComNew = new EsProCom();
|
|
|
+ esProComNew.setPcId(pcIdNew);
|
|
|
+ esProComNew.setComId(esProCom.getComId());
|
|
|
+ esProComNew.setUid(this.getA_es0028().getUid());
|
|
|
+ esProComNew.setRemark(esProCom.getRemark());
|
|
|
+ esProComNew.setCreateTime(esProCom.getCreateTime());
|
|
|
+ Date updateTime = new Date();
|
|
|
+ esProComNew.setUpdateTime(updateTime);
|
|
|
+ esProComNew.setPid(pidNew);
|
|
|
+ esProComNew.setSer(esProCom.getSer());
|
|
|
+ esProComNew.setIdCode(esProCom.getIdCode());
|
|
|
+ esProComMapper.insert(esProComNew);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找并修改es_pro_com_att表记录
|
|
|
+ * @param[in] pid
|
|
|
+ * @param[in] pidNew
|
|
|
+ * @param[in] pcIdList
|
|
|
+ * @param[in] newPcIdList
|
|
|
+ * @param[out] pcaIdMap
|
|
|
+ * @param[out] newPcaIdMap
|
|
|
+ */
|
|
|
+ public void selectAndSaveEsProComAtt(String pid,
|
|
|
+ String pidNew,
|
|
|
+ List<String> pcIdList,
|
|
|
+ List<String> newPcIdList,
|
|
|
+ Map<String,List<String>> pcaIdMap,
|
|
|
+ Map<String,List<String>> newPcaIdMap){
|
|
|
+ EsProComAttMapper esProComAttMapper = UtilTools.getBean(EsProComAttMapper.class);
|
|
|
+ for(int i=0;i<pcIdList.size();i++){
|
|
|
+ if (pcIdList.get(i) == null || pcIdList.get(i).isEmpty()) {
|
|
|
+ continue; // 跳过空值
|
|
|
+ }
|
|
|
+ Example example = new Example(EsProComAtt.class);
|
|
|
+ example.createCriteria()
|
|
|
+ .andEqualTo("pcId", pcIdList.get(i))
|
|
|
+ .andEqualTo("pid", pid)
|
|
|
+ .andEqualTo("uid", this.getA_es0028().getUid());
|
|
|
+ List<EsProComAtt> esProComAttList = esProComAttMapper.selectByExample(example);
|
|
|
+ for (EsProComAtt esProComAtt : esProComAttList){
|
|
|
+ String pcaId = esProComAtt.getPcId();
|
|
|
+ pcaIdMap.computeIfAbsent(pcIdList.get(i), k -> new ArrayList<>()).add(pcaId);
|
|
|
+
|
|
|
+ String pcaIdNew = UtilTools.getUUid();
|
|
|
+ newPcaIdMap.computeIfAbsent(newPcIdList.get(i), k -> new ArrayList<>()).add(pcaIdNew);
|
|
|
+
|
|
|
+ EsProComAtt esProComAttNew = new EsProComAtt();
|
|
|
+ esProComAttNew.setPcaId(pcaIdNew);
|
|
|
+ esProComAttNew.setPid(pidNew);
|
|
|
+ esProComAttNew.setPcId(newPcIdList.get(i));
|
|
|
+ esProComAttNew.setComId(esProComAtt.getComId());
|
|
|
+ esProComAttNew.setAttId(esProComAtt.getAttId());
|
|
|
+ esProComAttNew.setValue(esProComAtt.getValue());
|
|
|
+ esProComAttNew.setUnit(esProComAtt.getUnit());
|
|
|
+ esProComAttNew.setUid(this.getA_es0028().getUid());
|
|
|
+ esProComAttNew.setRemark(esProComAtt.getRemark());
|
|
|
+ esProComAttNew.setCreateTime(esProComAtt.getCreateTime());
|
|
|
+ Date updateTime = new Date();
|
|
|
+ esProComAttNew.setUpdateTime(updateTime);
|
|
|
+ esProComAttMapper.insert(esProComAttNew);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找并修改es_pro_com_att_data
|
|
|
+ * @param[in] pid
|
|
|
+ * @param[in] newPid
|
|
|
+ * @param[in] pcIdAndPcIdNewMap
|
|
|
+ * @param[in] pcaIdMap
|
|
|
+ * @param[in] newPcaIdMap
|
|
|
+ */
|
|
|
+ public void selectAndSaveEsProComAttData(String pid,
|
|
|
+ String newPid,
|
|
|
+ Map<String,String> pcIdAndPcIdNewMap,
|
|
|
+ Map<String,List<String>> pcaIdMap,
|
|
|
+ Map<String,List<String>> newPcaIdMap)
|
|
|
+ {
|
|
|
+ EsProComAttDataMapper esProComAttDataMapper = UtilTools.getBean(EsProComAttDataMapper.class);
|
|
|
+ if (esProComAttDataMapper == null) {
|
|
|
+ throw new IllegalStateException("Mapper not initialized");
|
|
|
+ }
|
|
|
+ if (pcIdAndPcIdNewMap == null || pcaIdMap == null || newPcaIdMap == null) {
|
|
|
+ throw new IllegalArgumentException("Input maps cannot be null");
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, String> entry : pcIdAndPcIdNewMap.entrySet()) {
|
|
|
+ String pcId = entry.getKey();
|
|
|
+ String newPcId = entry.getValue();
|
|
|
+ List<String> pcaIdList = pcaIdMap.get(pcId);
|
|
|
+ List<String> newPcaIdList = newPcaIdMap.get(newPcId);
|
|
|
+ if (pcaIdList.isEmpty() || newPcaIdList.isEmpty()||pcaIdList==null || newPcaIdList==null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for(int i=0;i<pcaIdList.size();i++){
|
|
|
+ Example example = new Example(EsProComAttData.class);
|
|
|
+ example.createCriteria()
|
|
|
+ .andEqualTo("pid", pid)
|
|
|
+ .andEqualTo("pcId", pcId)
|
|
|
+ .andEqualTo("pcaId", pcaIdList.get(i))
|
|
|
+ .andEqualTo("uid", this.getA_es0028().getUid());
|
|
|
+ List<EsProComAttData> esProComAttDataList = esProComAttDataMapper.selectByExample(example);
|
|
|
+ for (EsProComAttData esProComAttData : esProComAttDataList){
|
|
|
+ EsProComAttData esProComAttDataNew = new EsProComAttData();
|
|
|
+ String pcad_id = UtilTools.getUUid();
|
|
|
+ esProComAttDataNew.setPcadId(pcad_id);
|
|
|
+ esProComAttDataNew.setPcadgId(esProComAttData.getPcadgId());
|
|
|
+ esProComAttDataNew.setPid(newPid);
|
|
|
+ esProComAttDataNew.setComId(esProComAttData.getComId());
|
|
|
+ esProComAttDataNew.setAttId(esProComAttData.getAttId());
|
|
|
+ esProComAttDataNew.setPcId(newPcId);
|
|
|
+ esProComAttDataNew.setPcaId(newPcaIdList.get(i));
|
|
|
+ esProComAttDataNew.setCdId(esProComAttData.getCdId());
|
|
|
+ esProComAttDataNew.setCdvId(esProComAttData.getCdvId());
|
|
|
+ esProComAttDataNew.setValue(esProComAttData.getValue());
|
|
|
+ esProComAttDataNew.setUnit(esProComAttData.getUnit());
|
|
|
+ esProComAttDataNew.setSer(esProComAttData.getSer());
|
|
|
+ esProComAttDataNew.setUid(this.getA_es0028().getUid());
|
|
|
+ esProComAttDataNew.setRemark(esProComAttData.getRemark());
|
|
|
+ esProComAttDataNew.setCreateTime(esProComAttData.getCreateTime());
|
|
|
+ Date updateTime = new Date();
|
|
|
+ esProComAttDataNew.setUpdateTime(updateTime);
|
|
|
+ esProComAttDataMapper.insert(esProComAttDataNew);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找并修改es_pro_com_con
|
|
|
+ * @param[in] pid
|
|
|
+ * @param[in] newPid
|
|
|
+ * @param[in] pcIdList
|
|
|
+ * @param[in] newPcIdList
|
|
|
+ */
|
|
|
+ public void selectAndSaveEsProComCon(String pid,
|
|
|
+ String newPid,
|
|
|
+ List<String> pcIdList,
|
|
|
+ List<String> newPcIdList)
|
|
|
+ {
|
|
|
+ EsProComConMapper esProComConMapper = UtilTools.getBean(EsProComConMapper.class);
|
|
|
+ Example example = new Example(EsProComCon.class);
|
|
|
+ example.createCriteria()
|
|
|
+ .andEqualTo("pid", pid)
|
|
|
+ .andEqualTo("uid", this.getA_es0028().getUid());
|
|
|
+ List<EsProComCon> esProComConList = esProComConMapper.selectByExample(example);
|
|
|
+ for (EsProComCon esProComCon : esProComConList){
|
|
|
+ EsProComCon esProComConNew = new EsProComCon();
|
|
|
+ String pccId = UtilTools.getUUid();
|
|
|
+ esProComConNew.setPccId(pccId);
|
|
|
+ esProComConNew.setPid(newPid);
|
|
|
+ esProComConNew.setType(esProComCon.getType());
|
|
|
+
|
|
|
+ int indexNpc = pcIdList.indexOf(esProComCon.getNpcId());
|
|
|
+ String npcId = newPcIdList.get(indexNpc);
|
|
|
+ esProComConNew.setNpcId(npcId);
|
|
|
+
|
|
|
+ int indexPc = pcIdList.indexOf(esProComCon.getPcId());
|
|
|
+ String pcId = newPcIdList.get(indexPc);
|
|
|
+ esProComConNew.setPcId(pcId);
|
|
|
+
|
|
|
+ esProComConNew.setUid(this.getA_es0028().getUid());
|
|
|
+ esProComConNew.setRemark(esProComCon.getRemark());
|
|
|
+ esProComConNew.setCreateTime(esProComCon.getCreateTime());
|
|
|
+ Date updateTime = new Date();
|
|
|
+ esProComConNew.setUpdateTime(updateTime);
|
|
|
+ esProComConMapper.insert(esProComConNew);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无锡发动机,“项目克隆”业务前处理
|
|
|
+ */
|
|
|
+ public void preTransFlow() throws Exception {
|
|
|
+ this.validater();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无锡发动机,“项目克隆”业务后处理
|
|
|
+ */
|
|
|
+ public void afterTransFlow() throws Exception {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无锡发动机,“项目克隆”逻辑入口处理方法
|
|
|
+ */
|
|
|
+ @SuppressWarnings("rawtypes")
|
|
|
+ @Override
|
|
|
+ public Map execute(Map vars) throws Exception {
|
|
|
+ this.setTransMap(vars);
|
|
|
+ preTransFlow();// 执行业务开始的规则检查和校验
|
|
|
+ transExecute();// 执行核心业务段
|
|
|
+ afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
|
|
|
+ return this.getTransMap();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|