diff --git a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar index 8540a37a..161e160f 100644 Binary files a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar and b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar differ diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/ModelConvertController.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/ModelConvertController.java index 1eab3f47..e71d7cd2 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/ModelConvertController.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/ModelConvertController.java @@ -9,14 +9,26 @@ import com.actionsoft.bpms.server.bind.annotation.Mapping; public class ModelConvertController { @Mapping("com.actionsoft.apps.coe.pal.handle_epc_to_flowchart") - public String handleEpcToFlowChart(UserContext uc,String repositoryId,String sourceMethod,String targetMethod){ + public String handleEpcToFlowChart(UserContext uc,String repositoryId,String sourceMethod,String targetMethod,boolean duplicateName){ ModelConvertWeb modelConvertWeb = new ModelConvertWeb(uc); - return modelConvertWeb.handleEpcToFlowChart(repositoryId,sourceMethod,targetMethod); + return modelConvertWeb.handleEpcToFlowChart(repositoryId,sourceMethod,targetMethod,duplicateName); } @Mapping("com.actionsoft.apps.coe.pal.handle_epc_to_flowchart_batch") - public String handleEpcToFlowChartBatch(UserContext uc,String repositoryIds,String sourceMethod,String targetMethod){ + public String handleEpcToFlowChartBatch(UserContext uc,String repositoryIds,String sourceMethod,String targetMethod,boolean duplicateName){ ModelConvertWeb modelConvertWeb = new ModelConvertWeb(uc); - return modelConvertWeb.handleEpcToFlowChartBatch(repositoryIds,sourceMethod,targetMethod); + return modelConvertWeb.handleEpcToFlowChartBatch(repositoryIds,sourceMethod,targetMethod,duplicateName); + } + + @Mapping("com.actionsoft.apps.coe.pal.check_repository_name_exist") + public String checkRepositoryNameExist(UserContext uc,String repositoryId,String targetMethod){ + ModelConvertWeb modelConvertWeb = new ModelConvertWeb(uc); + return modelConvertWeb.checkRepositoryNameExist(repositoryId,targetMethod); + } + + @Mapping("com.actionsoft.apps.coe.pal.check_repository_name_exist_batch") + public String checkRepositoryNameExistBatch(UserContext uc,String repositoryIds,String targetMethod){ + ModelConvertWeb modelConvertWeb = new ModelConvertWeb(uc); + return modelConvertWeb.checkRepositoryNameExistBatch(repositoryIds,targetMethod); } } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/modelconvert/ModelConvertWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/modelconvert/ModelConvertWeb.java index 92e6eb44..9add4cc9 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/modelconvert/ModelConvertWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/modelconvert/ModelConvertWeb.java @@ -1,6 +1,9 @@ package com.actionsoft.apps.coe.pal.pal.modelconvert; import com.actionsoft.apps.coe.pal.pal.modelconvert.constant.ModelConvertConst; +import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl; import com.actionsoft.bpms.commons.mvc.view.ActionWeb; import com.actionsoft.bpms.commons.mvc.view.ResponseObject; import com.actionsoft.bpms.server.UserContext; @@ -8,6 +11,7 @@ import com.actionsoft.bpms.util.UUIDGener; import com.actionsoft.sdk.local.SDK; import com.alibaba.fastjson.JSONArray; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -22,17 +26,20 @@ public class ModelConvertWeb extends ActionWeb { this.uc = uc; } - public String handleEpcToFlowChart(String repositoryId,String sourceMethod,String targetMethod){ + // 单个文件处理模型EPC转FlowChart + public String handleEpcToFlowChart(String repositoryId,String sourceMethod,String targetMethod,boolean duplicateName){ Map params = new HashMap(); params.put("sid",uc.getSessionId()); params.put("repositoryId",repositoryId); params.put("sourceMethod",sourceMethod); params.put("targetMethod",targetMethod); + params.put("duplicateName",duplicateName); ResponseObject ro = SDK.getAppAPI().callASLP(SDK.getAppAPI().getAppContext(ModelConvertConst.APP_ID), ModelConvertConst.ASLP_SINGLE_CONVERT, params); return ro.toString(); } - public String handleEpcToFlowChartBatch(String repositoryIds,String sourceMethod,String targetMethod){ + // 批量处理模型EPC转FlowChart + public String handleEpcToFlowChartBatch(String repositoryIds,String sourceMethod,String targetMethod,boolean duplicateName){ JSONArray array = JSONArray.parseArray(repositoryIds); List repositoryIdList = array.stream().map(id -> (String) id).collect(Collectors.toList()); Map params = new HashMap(); @@ -40,7 +47,55 @@ public class ModelConvertWeb extends ActionWeb { params.put("repositoryId",repositoryIdList); params.put("sourceMethod",sourceMethod); params.put("targetMethod",targetMethod); + params.put("duplicateName",duplicateName); ResponseObject ro = SDK.getAppAPI().callASLP(SDK.getAppAPI().getAppContext(ModelConvertConst.APP_ID), ModelConvertConst.ASLP_SINGLE_CONVERT, params); return ro.toString(); } + + // 检查转换后的文件名是否重复 + public String checkRepositoryNameExist(String repositoryId,String targetMethod){ + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("duplicateName",false); + PALRepositoryModelImpl repositoryModel = (PALRepositoryModelImpl)CoeProcessLevelDaoFacotory + .createCoeProcessLevel().getInstance(repositoryId); + if (repositoryModel == null){ + return ResponseObject.newErrResponse("未找到被转换的模型信息").toString(); + } + List repositoryModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getAllCoeProcessLevelByWsId(repositoryModel.getWsId()); + repositoryModels = repositoryModels.stream() + .filter(model -> model.getMethodId().equals(targetMethod) && model.getName().equals(repositoryModel.getName())) + .collect(Collectors.toList()); + if (repositoryModels != null && repositoryModels.size() > 0) { + ro.put("duplicateName",true); + } + ro.put("repositoryName",repositoryModel.getName()); + return ro.toString(); + } + + // 批量检查转换后的文件名是否重复 + public String checkRepositoryNameExistBatch(String repositoryIds,String targetMethod){ + ResponseObject ro = ResponseObject.newOkResponse(); + boolean isNameExist = false; + JSONArray ids = JSONArray.parseArray(repositoryIds); + List repositoryNames = new ArrayList<>(); + for (int i = 0; i < ids.size(); i++) { + String id = ids.getString(i); + PALRepositoryModelImpl repositoryModel = (PALRepositoryModelImpl)CoeProcessLevelDaoFacotory + .createCoeProcessLevel().getInstance(id); + List repositoryModels = CoeProcessLevelDaoFacotory + .createCoeProcessLevel().getAllCoeProcessLevelByWsId(repositoryModel.getWsId()); + repositoryModels = repositoryModels.stream() + .filter(model -> model.getMethodId().equals(targetMethod) && model.getName().equals(repositoryModel.getName())) + .collect(Collectors.toList()); + if (repositoryModels != null && repositoryModels.size() > 0) { + isNameExist = true; + repositoryNames.add(repositoryModel.getName()); + } + } + if (isNameExist){ + ro.put("repositoryNames",repositoryNames); + } + ro.put("duplicateName",isNameExist); + return ro.toString(); + } } diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/action.xml b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/action.xml index 5d67390e..18515af5 100755 --- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/action.xml +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/action.xml @@ -1759,4 +1759,24 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file