diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java index 8f24e14b..d810226b 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java @@ -56,948 +56,955 @@ import com.alibaba.fastjson.JSONObject; public class PublishExecuteListenerInterfaceImpl extends ExecuteListener implements ExecuteListenerInterface { - @Override - public String getDescription() { - return "将发布信息保存至CoE中。"; - } - - @Override - public String getProvider() { - return "aws-coe"; - } - - @Override - public String getVersion() { - return "V6.0"; - } - - @Override - public void execute(ProcessExecutionContext param) throws Exception { - //将发布信息保存至coe的发布表中 - PublishHistoryModel model = new PublishHistoryModel(); - String processInstId = param.getProcessInstance().getId(); - if ("terminate".equals(param.getProcessInstance().getControlState())) { - // 流程实例中止,取消审批中状态 - ProcessStatusAPIManager.getInstance().batchUpdateApprovalStatus(processInstId, false); - return; - } - BO bo = SDK.getBOAPI().query(PublisherConstant.BOTABLENAME).detailByBindId(processInstId); - Timestamp nowTime = new Timestamp(System.currentTimeMillis()); - String publishDateType = bo.getString("CHOICEEFFECTIVEDATE"); - String publishDate = bo.getString("EFFECTIVEDATE"); - if("1".equals(publishDateType)) { - Date date = new SimpleDateFormat("yyyy-MM-dd").parse(publishDate); - Timestamp stamp = new Timestamp(date.getTime()); - model.setPublishDate(stamp); - }else { - model.setPublishDate(nowTime); - } - model.setId(UUIDGener.getUUID()); - model.setProcessInstId(processInstId); - model.setWsId(bo.get("WSID").toString()); - model.setUserId(bo.get("APPLYUSERID").toString()); - String auditorId = ""; - if (bo.get("AUDITOR3") != null && !"".equals(bo.get("AUDITOR3").toString())) { - auditorId = bo.get("AUDITOR3").toString(); - } else if (bo.get("AUDITOR2") != null && !"".equals(bo.get("AUDITOR2").toString())) { - auditorId = bo.get("AUDITOR2").toString(); - } else { - auditorId = bo.get("AUDITOR1").toString(); - } - model.setAuditorId(auditorId); - model.setPublishDesc(bo.get("PUBLISHDESC") == null ? "" : bo.get("PUBLISHDESC").toString()); - model.setTeamId(bo.get("TEAMID").toString()); - - List bolistN = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N).bindId(processInstId).list(); - model.setPublishNew(bolistN == null ? 0 : bolistN.size()); - List bolistC = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C).bindId(processInstId).list(); - model.setPublishChange(bolistC == null ? 0 : bolistC.size()); - List bolistS = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_S).bindId(processInstId).list(); - model.setPublishStop(bolistS == null ? 0 : bolistS.size()); - - PublishHistory dao = new PublishHistory(); - dao.insert(model); - - PublishListHistory listDao = new PublishListHistory(); - PALRepository repositoryDao = new PALRepository(); - //将发布信息保存至coe的发布子表中 - if (bolistN != null) { - for (BO boN : bolistN) { - PublishListHistoryModel publishListHistoryModelN = new PublishListHistoryModel(); - publishListHistoryModelN.setId(UUIDGener.getUUID()); - publishListHistoryModelN.setActionType("N"); - publishListHistoryModelN.setpId(model.getId()); - publishListHistoryModelN.setPublishDate(model.getPublishDate()); - publishListHistoryModelN.setPalRepositoryId(boN.get("PUBLISHFILEID").toString()); - publishListHistoryModelN.setPublishDesc(boN.get("PUBLISHDESC") == null ? "" : boN.get("PUBLISHDESC").toString()); - if (boN.get("TASKID") != null && !"".equals(boN.get("TASKID"))) { - publishListHistoryModelN.setTaskId(boN.get("TASKID").toString()); - } else { - publishListHistoryModelN.setTaskId(""); - } - listDao.insert(publishListHistoryModelN); - //修改流程文件的发布属性和发布时间 - repositoryDao.updatePublishStatusAndDate("N", boN.get("PUBLISHFILEID").toString(), null, model.getPublishDate()); - - //修改关联角色、绩效发布状态 - updateRoleAndPerformance(boN.get("PUBLISHFILEID").toString(),model.getPublishDate(),"N"); - - //绩效模型中数据模型回填流程编号 - updateProcessNumber(boN.get("PUBLISHFILEID").toString(),param.getUserContext(),bo.get("WSID").toString(),boN.getString("PUBLISH_NUMBER"),model.getPublishDate()); - - - } - //by bzp 测试编号生成 - //new ProcesNumberUtil().getNumber(processInstId); - } - if (bolistC != null) { - for (BO boC : bolistC) { - PublishListHistoryModel publishListHistoryModelC = new PublishListHistoryModel(); - publishListHistoryModelC.setId(UUIDGener.getUUID()); - publishListHistoryModelC.setActionType("C"); - publishListHistoryModelC.setpId(model.getId()); - publishListHistoryModelC.setPublishDate(model.getPublishDate()); - publishListHistoryModelC.setPalRepositoryId(boC.get("CHANGEDFILEIDNEW").toString()); - publishListHistoryModelC.setPublishDesc(boC.get("CHANGEDDESC") == null ? "" : boC.get("CHANGEDDESC").toString()); - if (boC.get("TASKID") != null && !"".equals(boC.get("TASKID"))) { - publishListHistoryModelC.setTaskId(boC.get("TASKID").toString()); - } else { - publishListHistoryModelC.setTaskId(""); - } - listDao.insert(publishListHistoryModelC); - //修改流程文件的发布属性 - repositoryDao.updatePublishStatusAndDate("C", boC.get("CHANGEDFILEIDNEW").toString(), boC.get("CHANGEFILEID").toString(), model.getPublishDate()); - - - //修改关联角色、绩效发布状态 - updateRoleAndPerformance(boC.get("CHANGEDFILEIDNEW").toString(),model.getPublishDate(),"C"); - - //绩效模型中数据模型回填流程编号 - updateProcessNumber(boC.get("CHANGEDFILEIDNEW").toString(),param.getUserContext(),bo.get("WSID").toString(),boC.getString("PUBLISH_NUMBER"),model.getPublishDate()); - - } - } - if (bolistS != null) { - for (BO boS : bolistS) { - PublishListHistoryModel publishListHistoryModelS = new PublishListHistoryModel(); - publishListHistoryModelS.setId(UUIDGener.getUUID()); - publishListHistoryModelS.setActionType("S"); - publishListHistoryModelS.setpId(model.getId()); - publishListHistoryModelS.setPublishDate(model.getPublishDate()); - publishListHistoryModelS.setPalRepositoryId(boS.get("STOPFILEID").toString()); - publishListHistoryModelS.setPublishDesc(boS.get("STOPDESC") == null ? "" : boS.get("STOPDESC").toString()); - if (boS.get("TASKID") != null && !"".equals(boS.get("TASKID"))) { - publishListHistoryModelS.setTaskId(boS.get("TASKID").toString()); - } else { - publishListHistoryModelS.setTaskId(""); - } - listDao.insert(publishListHistoryModelS); - //修改流程文件的发布属性 - repositoryDao.updatePublishStatusAndDate("S", boS.get("STOPFILEID").toString(), null, model.getPublishDate()); - } - } - // 将发布相关的流程作为前后置流程的流程接口名称调整 - updatePublishRepositoryRelationRearLeadhape(param.getUserContext(), bo, bolistN, bolistC, bolistS); - // 生效日期信息处理&并创建手册 - updateEffectiveDateProperty(processInstId, bo, nowTime, bolistN, bolistC); - // 流程发布范围权限单独存储 - savePublishScope(bo, bolistN, bolistC, bolistS); - //发布待阅,推送知识库,推送EHSQ 改为确认发布节点任务完成后执行 - //new ProcessEndAfterEvent().ProcessData(param); - - } - - /** - * 以当前发布、变更、停用的流程作为前后置流程的流程,对其流程接口的文本进行调整 - * @param bo - * @param bolistN - * @param bolistC - * @param bolistS - */ - private void updatePublishRepositoryRelationRearLeadhape(UserContext uc, BO bo, List bolistN, List bolistC, List bolistS) { - Set newSet = new HashSet<>(); - Set changeSet = new HashSet<>(); - Set stopSet= new HashSet<>(); - if (bolistN != null) { - for (BO boN : bolistN) { - String palId = boN.get("PUBLISHFILEID").toString(); - newSet.add(palId); - } - } - if (bolistC != null) { - for (BO boC : bolistC) { - String palId = boC.get("CHANGEDFILEIDNEW").toString(); - changeSet.add(palId); - } - } - if (bolistS != null) { - for (BO boS : bolistS) { - String palId = boS.get("STOPFILEID").toString(); - stopSet.add(palId); - } - } - DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); - updateLeadRear(uc, newSet, relationDao, "new"); - updateLeadRear(uc, changeSet, relationDao, "change"); - updateLeadRear(uc, stopSet, relationDao, "stop"); - } - - private void updateLeadRear(UserContext uc, Set set, DesignerShapeRelationDao relationDao, String type) { - for (String id : set) { - PALRepositoryModel model = PALRepositoryCache.getCache().get(id); - if (model == null) { - continue; - } - Set rearSet = new HashSet<>(); - Set leadSet = new HashSet<>(); - List list1 = relationDao.query(null, null, null, model.getVersionId(), null); - for (DesignerShapeRelationModel m1 : list1) { - if (UtilString.isEmpty(m1.getRelationShapeId())) { - // 伊利前后置流程的数据处理 by sunlh 20221025 - if ("rear_process".equals(m1.getAttrId())) {// 后置流程 - rearSet.add(m1.getFileId()); - } else if ("lead_process".equals(m1.getAttrId())) {// 前置流程 - leadSet.add(m1.getFileId()); - } - } - } - // 更新将该模型作为前后置流程相关模型 伊利 by sunlh 20221025 - updateLeadRearRepositoryDesigner(uc, leadSet, "top", model, type); - updateLeadRearRepositoryDesigner(uc, rearSet, "bottom", model, type); - } - } - - /** - * 更新将该模型作为前后置流程相关模型 伊利 by sunlh 20221025 - */ - private void updateLeadRearRepositoryDesigner(UserContext uc, Set set, String position, PALRepositoryModel pubilshModel, String type) { - - for (String uuid : set) { - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - if (model != null) { - String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, uuid); - try { - boolean update = false; - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - JSONArray procedureShapeArr= getProcedureShapeArr(elements); - for (int i = 0; i < procedureShapeArr.size(); i++) { - JSONObject shape = procedureShapeArr.getJSONObject(i); - if (matchProcedureObj(shape, pubilshModel.getVersionId(), pubilshModel.getName(), position)) { - update = true; - String id = shape.getString("id"); - elements.getJSONObject(id).put("text", ("new".equals(type) || "change".equals(type)) ? pubilshModel.getName() : pubilshModel.getName() + "(已废止)"); - } - } - if (update) { - // 保存 - BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); - if (defineModel == null) { - defineModel = CoeDesignerUtil.createModel(uuid, 0); - defineModel.setCreateHistory(false); - } - definition.put("elements", elements); - defineModel.setDefinition(definition.toString()); - defineModel.setUpdateTime(new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date())); - // 保存文件 - CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 - // 记录操作行为日志 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_UPDATE, CoEOpLogConst.INFO_REPOSITORY_DESIGNER_UPDATE + ",文件属性["+ ("top".equals(position) ? "前置" : "后置") +"流程]触发流程接口形状更新"); - SDK.getLogAPI().consoleInfo("[成功][" + pubilshModel.getName() + "]被"+ ("new".equals(type) ? "发布" : "change".equals(type) ? "变更" : "废止") +",文件属性["+ ("top".equals(position) ? "前置" : "后置") +"流程]触发流程[" + model.getName() + "][" + model.getId() + "]流程接口形状更新"); - } - } - } catch (Exception e) { - e.printStackTrace(); - SDK.getLogAPI().consoleErr("模型["+ model.getName() +"][" + model.getId() + "]模型文件转换JSON异常"); - continue; - } - } - } - - } - - private boolean matchProcedureObj(JSONObject shape, String versionId, String name, String position) { - if (shape.containsKey("attrMark") && shape.getJSONObject("attrMark") != null) { - return versionId.equals(shape.getJSONObject("attrMark").getString("versionId")) && !name.equals(shape.getString("shapeText")); - } - return false; - } - - private JSONArray getProcedureShapeArr(JSONObject elements) { - JSONArray result = new JSONArray(); - Iterator it = elements.keySet().iterator(); - while (it.hasNext()) { - String key = it.next(); - JSONObject shape = elements.getJSONObject(key); - String name = shape.getString("name"); - if ("procedure".equals(name)) {// 流程接口 - JSONObject obj = new JSONObject(); - String shapeText = shape.getString("text"); - JSONArray fromLinkerArr = new JSONArray(); - JSONArray toLinkerArr = new JSONArray(); - JSONObject attrMark = shape.getJSONObject("attrMark"); - obj.put("id", key); - obj.put("shapeText", shapeText); - obj.put("fromLinkerArr", fromLinkerArr); - obj.put("toLinkerArr", toLinkerArr); - obj.put("attrMark", attrMark); - getInterfaceShapeLink(obj, elements); - result.add(obj); - } - } - return result; - } - - private void getInterfaceShapeLink(JSONObject obj, JSONObject elements) { - Iterator it = elements.keySet().iterator(); - while (it.hasNext()) { - String key = it.next(); - JSONObject shape = elements.getJSONObject(key); - String name = shape.getString("name"); - if ("linker".equals(name)) {// 连线 - // 出线 - JSONObject from = shape.getJSONObject("from"); - // 入线 - JSONObject to = shape.getJSONObject("to"); - if (from != null && to != null) { - String fromId = from.getString("id"); - String toId = to.getString("id"); - if (obj.getString("id").equals(fromId)) { - obj.getJSONArray("fromLinkerArr").add(key); - } - if (obj.getString("id").equals(toId)) { - obj.getJSONArray("toLinkerArr").add(key); - } - } - } - } - } - - private void updateEffectiveDateProperty(String processInstId, BO bo, Timestamp publishDate, List bolistN, List bolistC) { - // 对epc、表单、制度图进行生效日期更新和手册重新生成 - // epc:process.epc effective_date - // 表单:data.form form_effective_date - // 制度:control.policy effective_date - String applyUser = bo.getString("APPLYUSERID");// 以申请人身份创建流程手册 - String date = UtilDate.datetimeFormat(publishDate); - String publishDateType = bo.getString("CHOICEEFFECTIVEDATE"); - String publishDatet = bo.getString("EFFECTIVEDATE"); - PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao(); - // 创建线程池进行流程手册的处理 - ExecutorService service = Executors.newFixedThreadPool(4); - //将发布范围权限信息保存至范围权限表 - if (bolistN != null) { - for (BO boN : bolistN) { - String palId = boN.get("PUBLISHFILEID").toString(); - PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); - if (model == null) { - SDK.getLogAPI().consoleErr("[更新生效日期和创建手册]更新失败,模型不存在,模型[" + palId + "]"); - continue; - } - // 新增模型时间 - if (updatePropertyEffectiveDate(model, date, propertyDao,publishDateType,publishDatet)) { - // 重新创建手册 - service.execute(new Runnable() { - @Override - public void run() { - updateProcessReport(model.getId(), processInstId, "N", applyUser); - } - }); - } - } - } - if (bolistC != null) { - for (BO boC : bolistC) { - String palId = boC.get("CHANGEDFILEIDNEW").toString(); - PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); - if (model == null) { - SDK.getLogAPI().consoleErr("[更新生效日期和创建手册]更新失败,模型不存在,模型[" + palId + "]"); - continue; - } - // 新增模型时间 - if (updatePropertyEffectiveDate(model, date, propertyDao,publishDateType,publishDatet)) { - // 重新创建手册 - service.execute(new Runnable() { - @Override - public void run() { - updateProcessReport(model.getId(), processInstId, "C", applyUser); - } - }); - } - } - } - } - - /** - * 新生成流程手册,编号进行处理 - * @param uuid - */ - private void updateProcessReport(String uuid, String processInstId, String type, String appUser) { - // epc:process.epc effective_date - // 表单:data.form form_effective_date - // 制度:control.policy effective_date - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - String category = model.getMethodCategory(); - if ("default".equals(model.getMethodId())) { - return; - } - // 校验流程手册是否安装并启动 - if (model.getMethodId().contains("process.") && !SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.output.pr")) { - SDK.getLogAPI().consoleErr("[流程手册未安装]流程手册更新失败"); - return; - } - if ("data.form".equals(model.getMethodId()) && !SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.bd")) { - SDK.getLogAPI().consoleErr("[表单手册未安装]流程手册更新失败"); - return; - } - if ("control.policy".equals(model.getMethodId()) && !SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.zd")) { - SDK.getLogAPI().consoleErr("[表单手册未安装]流程手册更新失败"); - return; - } - - if ("N".equals(type)) { - BO nBo = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N, true) - .bindId(processInstId) - .addQuery("PUBLISHFILEID=", uuid) - .detail(); - if (nBo != null) { - String boId = nBo.getId(); - // 创建流程手册 - String oldTaskId = nBo.getString("TASKID"); - // 获取报告类型 - OutputTaskModel taskModel = new OutputTask().getTaskReportById(oldTaskId); - if (taskModel != null) { - String taskId = createOutputReport(model, model.getWsId(), appUser, "", model.getId()); - if (UtilString.isNotEmpty(taskId)) { - // 更新流程发布表 - SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "],taskId:" + taskId + " 成功"); - // 更新BO表taskId字段 - int r1 = DBSql.update("UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE ID ='" + boId + "'"); - PublishHistory dao = new PublishHistory();// 发布结果主表 - PublishHistoryModel history = dao.queryBy("PROCESSINSTID = ?", processInstId); - int r2 = -1; - if (history != null) { - r2 = DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PID ='" + history.getId() + "' AND PALREPOSITORYID='" + uuid + "'"); - } - SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后更新数据库taskId,流程名称:" + model.getName() + "[" + model.getId() + "],影响结果数量:BO_ACT_COE_PUBLISH_N[" + r1 + "],APP_ACT_COE_PAL_PUBLISH_LIST[" + r2 + "]"); - } else { - SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "] 失败"); - } - } - } - } - if ("C".equals(type)) { - BO cBo = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C, true) - .bindId(processInstId) - .addQuery("CHANGEDFILEIDNEW=", uuid) - .detail(); - if (cBo != null) { - String boId = cBo.getId(); - // 创建流程手册 - String oldTaskId = cBo.getString("TASKID"); - // 获取报告类型 - OutputTaskModel taskModel = new OutputTask().getTaskReportById(oldTaskId); - if (taskModel != null) { - String taskId = createOutputReport(model, model.getWsId(), appUser, "", model.getId()); - if (UtilString.isNotEmpty(taskId)) { - // 更新流程发布表 - SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "],taskId:" + taskId + " 成功"); - // 更新BO表taskId字段 - int r1 = DBSql.update("UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + taskId + "'WHERE ID ='" + boId + "'"); - PublishHistory dao = new PublishHistory();// 发布结果主表 - PublishHistoryModel history = dao.queryBy("PROCESSINSTID = ?", processInstId); - int r2 = -1; - if (history != null) { - r2 = DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PID ='" + history.getId() + "' AND PALREPOSITORYID='" + uuid + "'"); - } - SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后更新数据库taskId,流程名称:" + model.getName() + "[" + model.getId() + "],影响结果数量:BO_ACT_COE_PUBLISH_C[" + r1 + "],APP_ACT_COE_PAL_PUBLISH_LIST[" + r2 + "]"); - } else { - SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "] 失败"); - } - } - } - } - } - - /** - * 创建手册 - * @param model - * @param wsId - * @param userId - * @param teamId - * @param uuid - * @return - */ - private String createOutputReport(PALRepositoryModel model, String wsId, String userId, String teamId, String uuid) { - String taskId = ""; - if (model.getMethodId().contains("process.")) { - taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, userId, teamId, uuid); - JSONObject object = JSONObject.parseObject(taskId); - if ("ok".equals(object.getString("result"))) { - taskId = object.getJSONObject("data").getString("taskId"); - } - } else if ("data.form".equals(model.getMethodId())) { - taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportBd(wsId, userId, teamId, uuid); - JSONObject object = JSONObject.parseObject(taskId); - if ("ok".equals(object.getString("result"))) { - taskId = object.getJSONObject("data").getString("taskId"); - } - } else if ("control.policy".equals(model.getMethodId())) { - taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, userId, teamId, uuid); - JSONObject object = JSONObject.parseObject(taskId); - if ("ok".equals(object.getString("result"))) { - taskId = object.getJSONObject("data").getString("taskId"); - } - } - return taskId; - } - - /** - * 更新文件属性(生效日期) - * - * @param model - * @param date - * @param propertyDao - */ - private boolean updatePropertyEffectiveDate(PALRepositoryModel model, String date, PALRepositoryPropertyDao propertyDao,String publishDateType,String publishDate) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - String time= df.format(new Date()); - // epc:process.epc effective_date - // 表单:data.form form_effective_date - // 制度:control.policy effective_date - String method = model.getMethodId(); - // - - String attrId = ""; - if ("process.epc".equals(method)) { - attrId = "effective_date"; - } else if ("data.form".equals(method)) { - attrId = "form_effective_date"; - } else if ("control.policy".equals(method)) { - attrId = "effective_date"; - } - if (UtilString.isEmpty(attrId)) { - return false; - } - - // 更新生效时间 - boolean existProp = false; - List list = propertyDao.getPropertysByPlid(model.getId(), attrId); - for (PALRepositoryPropertyModel propertyModel : list) { - if (attrId.equals(propertyModel.getPropertyId())) { - if("1".equals(publishDateType)) { - propertyDao.updatePropertyByPropertyId(model.getId(), attrId, publishDate); - }else { - propertyDao.updatePropertyByPropertyId(model.getId(), attrId, time); - - } - SDK.getLogAPI().consoleInfo("[更新模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + time + "]"); - existProp = true; - } - } - if (!existProp) { - // 属性不存在,新增一个 - PALRepositoryPropertyModel property = new PALRepositoryPropertyModel(); - property.setId(UUIDGener.getUUID()); - property.setOrderIndex(0); - property.setPlId(model.getId()); - property.setPropertyId(attrId); - property.setPropertyName("生效时间"); - property.setPropertyValue(time); - propertyDao.insert(property); - SDK.getLogAPI().consoleInfo("[新增模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + time + "]"); - } - return true; - } - - /** - * 流程发布范围权限单独存储 - * @param publish 流程发布bo主表 - * @param bolistN 新增发布流程信息 - * @param bolistC 变更发布流程信息,需要将已存在的相应流程权限信息进行删除,再进行权限存储 - * @param bolistS 停用发布流程信息,删除相应流程权限信息 - */ - private void savePublishScope(BO publish, List bolistN, List bolistC, List bolistS) { - String bindId = publish.getBindId(); - String wsId = publish.getString("WSID"); - String applyUser = publish.getString("APPLYUSERID"); - String sendScope = publish.getString("SEND_SCOP"); - String sendScopeOrg = publish.getString("SEND_SCOPE_ORG"); - String sendScopePost = publish.getString("SEND_SCOPE_POST"); - String sendScopeLevel = publish.getString("SEND_SCOPE_LEVEL"); - Set removeVerIds = new HashSet<>(); - Map addVerMap = new HashMap<>(); - //将发布范围权限信息保存至范围权限表 - if (bolistN != null) { - for (BO boN : bolistN) { - String palId = boN.get("PUBLISHFILEID").toString(); - PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); - if (model == null) { - SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]"); - continue; - } - addVerMap.put(model.getVersionId(), model.getName()); - removeVerIds.add(model.getVersionId()); - } - } - if (bolistC != null) { - for (BO boC : bolistC) { - String palId = boC.get("CHANGEDFILEIDNEW").toString(); - PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); - if (model == null) { - SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]"); - continue; - } - addVerMap.put(model.getVersionId(), model.getName()); - removeVerIds.add(model.getVersionId()); - } - } - if (bolistS != null) { - for (BO boS : bolistS) { - String palId = boS.get("STOPFILEID").toString(); - PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); - if (model == null) { - SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]"); - continue; - } - removeVerIds.add(model.getVersionId()); - } - } - - String newBoName = "BO_ACT_PUBLISH_PERM_SCOPE"; - // 先删除相应原有权限数据,再进行数据更新 - Set removeIds = new HashSet<>(); - for (String removeVerId : removeVerIds) { - List delList = SDK.getBOAPI().query(newBoName).addQuery("PALVERSIONID=", removeVerId).list(); - if (delList != null && delList.size() > 0) { - for (BO del : delList) { - removeIds.add(del.getId()); - } - } - } - for (String removeId : removeIds) { - SDK.getBOAPI().remove(newBoName, removeId); - } - - // 重新添加权限 - List list = new ArrayList<>(); - for (Map.Entry entry : addVerMap.entrySet()) { - String verId = entry.getKey(); - String name = entry.getValue(); - BO bo = new BO(); - bo.set("PERMID", UUIDGener.getUUID()); - bo.set("WSID", wsId); - bo.set("PALVERSIONID", verId); - bo.set("PALNAME", name); - bo.set("PERMTYPE", sendScope); - bo.set("ORGPERM", "1".equals(sendScope) ? SDK.getORGAPI().getCompanyByUser(applyUser).getId() : sendScopeOrg); - bo.set("POSTPERM", "1".equals(sendScope) ? "" : sendScopePost); - bo.set("LEVELPERM", "1".equals(sendScope) ? "" : sendScopeLevel); - list.add(bo); - } - if (list.size() > 0) { - SDK.getBOAPI().create(newBoName, list, bindId, applyUser); - SDK.getLogAPI().consoleInfo("[发布范围权限信息保存至范围权限表]更新成功"); - } - } - - - /**** - * 发布明细如果关联角色、绩效图,不显示在发布界面,在流程结束后同步发布 - */ - public void updateRoleAndPerformance(String publishFileId,Timestamp publishDate,String type){ - try { - List roleList = new ArrayList(); - roleList.add(0, "org.role"); - roleList.add(1, publishFileId); - PALRepository repositoryDao = new PALRepository(); - RowMap rolerowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", roleList.toString()); - - if (rolerowMap != null) { - //修改流程文件的发布属性 - repositoryDao.updatePublishStatusAndDate(type, rolerowMap.getString("ID"), null, publishDate); - } - List performanceList = new ArrayList(); - performanceList.add(0, "control.kpi"); - performanceList.add(1, publishFileId); - - RowMap performrowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", performanceList.toString()); - - if (performrowMap != null) { - //修改流程文件的发布属性 - repositoryDao.updatePublishStatusAndDate(type, performrowMap.getString("ID"), null, publishDate); - } - } catch (AWSDataAccessException e) { - e.printStackTrace(); - } - - } - - /** - * 1、发布结束后获取关联绩效模型填充流程编号 - * 2、获取信息插入绩效指标库 - * @param publishFileId - * @param publishDate - */ - public void updateProcessNumber(String publishFileId, UserContext uc, String wsId, String processNumber,Timestamp publishDate) { - try { - //获取关联绩效模型数据 - List performanceList = new ArrayList(); - performanceList.add(0, "control.kpi"); - performanceList.add(1, publishFileId); - - RowMap performrowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", performanceList.toString()); - - ProcessInstance processInst = SDK.getProcessAPI().createBOProcessInstance("obj_1ffbc1e73b99427ca64469e466f97dbe", uc.getUID(), "指标绩效数据插入"); - - - ProcessInstance performNumberProcess = SDK.getProcessAPI().createBOProcessInstance("obj_b92c1343b4914e969ead13db62f360f2", uc.getUID(), "绩效编号插入"); - - if (performrowMap != null) { - - PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(performrowMap.getString("ID")); - - String id = performrowMap.getString("ID"); - - - Map> methodAttrsMap = new HashMap<>();// 属性存储 - - Map methodValueAttrsMap = new HashMap<>();// 属性存储 - - //查询对应绩效模型中数据模型进行填充数据 - BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0); - - CoeProcessLevelWeb coeProcessLevelWeb = new CoeProcessLevelWeb(uc); - - String define = defineModel.getDefinition(); - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - - coeProcessLevelWeb.handleShapeDefaultAttr(wsId, parentModel, elements, methodAttrsMap); - - - if(UtilString.isNotEmpty(processNumber)){ - //编号规则为: MP(流程编号是:08.01.05.05/P05V1.0-YLYYYY,对应的流程绩效编号MP-08.01.05.05-YLYYYY.AA(AA=1~99顺序排号)对流程编号,去除"/P05V1.0) - - //去掉 /P05V1.0- - String before = null; - String after = null; - try { - before = processNumber.substring(0, processNumber.indexOf("/")); - after = processNumber.substring(processNumber.lastIndexOf("-"), processNumber.length()); - } catch (Exception e) { - e.printStackTrace(); - } - - //拿去流程数据填充绩效模型中数据属性 - for (String key : elements.keySet()) { - - JSONObject shape1 = elements.getJSONObject(key); - if ("linker".equals(shape1.getString("name"))) { - continue; - } - String shapeText = shape1.getString("text"); - JSONArray dataAttributes = shape1.getJSONArray("dataAttributes"); - if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) { - - - - for (Object attribute : dataAttributes) { - JSONObject obj = (JSONObject) attribute; - if (obj.containsKey("attributesJsonArray")) { - JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray"); - BO recordBO = new BO(); - boolean insertFlag=false; - if (attributesJsonArray.size() > 0) { - - //事前循环jsonarry,判断绩效编号是否填写 - for (int c=0;c bolistN = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N).bindId(processInstId).list(); + model.setPublishNew(bolistN == null ? 0 : bolistN.size()); + List bolistC = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C).bindId(processInstId).list(); + model.setPublishChange(bolistC == null ? 0 : bolistC.size()); + List bolistS = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_S).bindId(processInstId).list(); + model.setPublishStop(bolistS == null ? 0 : bolistS.size()); + + PublishHistory dao = new PublishHistory(); + dao.insert(model); + + PublishListHistory listDao = new PublishListHistory(); + PALRepository repositoryDao = new PALRepository(); + //将发布信息保存至coe的发布子表中 + if (bolistN != null) { + for (BO boN : bolistN) { + PublishListHistoryModel publishListHistoryModelN = new PublishListHistoryModel(); + publishListHistoryModelN.setId(UUIDGener.getUUID()); + publishListHistoryModelN.setActionType("N"); + publishListHistoryModelN.setpId(model.getId()); + publishListHistoryModelN.setPublishDate(model.getPublishDate()); + publishListHistoryModelN.setPalRepositoryId(boN.get("PUBLISHFILEID").toString()); + publishListHistoryModelN.setPublishDesc(boN.get("PUBLISHDESC") == null ? "" : boN.get("PUBLISHDESC").toString()); + if (boN.get("TASKID") != null && !"".equals(boN.get("TASKID"))) { + publishListHistoryModelN.setTaskId(boN.get("TASKID").toString()); + } else { + publishListHistoryModelN.setTaskId(""); + } + listDao.insert(publishListHistoryModelN); + //修改流程文件的发布属性和发布时间 + repositoryDao.updatePublishStatusAndDate("N", boN.get("PUBLISHFILEID").toString(), null, model.getPublishDate()); + + //修改关联角色、绩效发布状态 + updateRoleAndPerformance(boN.get("PUBLISHFILEID").toString(), model.getPublishDate(), "N"); + + //绩效模型中数据模型回填流程编号 + updateProcessNumber(boN.get("PUBLISHFILEID").toString(), param.getUserContext(), bo.get("WSID").toString(), boN.getString("PUBLISH_NUMBER"), model.getPublishDate()); + + + } + //by bzp 测试编号生成 + //new ProcesNumberUtil().getNumber(processInstId); + } + if (bolistC != null) { + for (BO boC : bolistC) { + PublishListHistoryModel publishListHistoryModelC = new PublishListHistoryModel(); + publishListHistoryModelC.setId(UUIDGener.getUUID()); + publishListHistoryModelC.setActionType("C"); + publishListHistoryModelC.setpId(model.getId()); + publishListHistoryModelC.setPublishDate(model.getPublishDate()); + publishListHistoryModelC.setPalRepositoryId(boC.get("CHANGEDFILEIDNEW").toString()); + publishListHistoryModelC.setPublishDesc(boC.get("CHANGEDDESC") == null ? "" : boC.get("CHANGEDDESC").toString()); + if (boC.get("TASKID") != null && !"".equals(boC.get("TASKID"))) { + publishListHistoryModelC.setTaskId(boC.get("TASKID").toString()); + } else { + publishListHistoryModelC.setTaskId(""); + } + listDao.insert(publishListHistoryModelC); + //修改流程文件的发布属性 + repositoryDao.updatePublishStatusAndDate("C", boC.get("CHANGEDFILEIDNEW").toString(), boC.get("CHANGEFILEID").toString(), model.getPublishDate()); + + + //修改关联角色、绩效发布状态 + updateRoleAndPerformance(boC.get("CHANGEDFILEIDNEW").toString(), model.getPublishDate(), "C"); + + //绩效模型中数据模型回填流程编号 + updateProcessNumber(boC.get("CHANGEDFILEIDNEW").toString(), param.getUserContext(), bo.get("WSID").toString(), boC.getString("PUBLISH_NUMBER"), model.getPublishDate()); + + } + } + if (bolistS != null) { + for (BO boS : bolistS) { + PublishListHistoryModel publishListHistoryModelS = new PublishListHistoryModel(); + publishListHistoryModelS.setId(UUIDGener.getUUID()); + publishListHistoryModelS.setActionType("S"); + publishListHistoryModelS.setpId(model.getId()); + publishListHistoryModelS.setPublishDate(model.getPublishDate()); + publishListHistoryModelS.setPalRepositoryId(boS.get("STOPFILEID").toString()); + publishListHistoryModelS.setPublishDesc(boS.get("STOPDESC") == null ? "" : boS.get("STOPDESC").toString()); + if (boS.get("TASKID") != null && !"".equals(boS.get("TASKID"))) { + publishListHistoryModelS.setTaskId(boS.get("TASKID").toString()); + } else { + publishListHistoryModelS.setTaskId(""); + } + listDao.insert(publishListHistoryModelS); + //修改流程文件的发布属性 + repositoryDao.updatePublishStatusAndDate("S", boS.get("STOPFILEID").toString(), null, model.getPublishDate()); + } + } + // 将发布相关的流程作为前后置流程的流程接口名称调整 + updatePublishRepositoryRelationRearLeadhape(param.getUserContext(), bo, bolistN, bolistC, bolistS); + // 生效日期信息处理&并创建手册 + updateEffectiveDateProperty(processInstId, bo, nowTime, bolistN, bolistC); + // 流程发布范围权限单独存储 + savePublishScope(bo, bolistN, bolistC, bolistS); + //发布待阅,推送知识库,推送EHSQ 改为确认发布节点任务完成后执行 + //new ProcessEndAfterEvent().ProcessData(param); + + } + + /** + * 以当前发布、变更、停用的流程作为前后置流程的流程,对其流程接口的文本进行调整 + * + * @param bo + * @param bolistN + * @param bolistC + * @param bolistS + */ + private void updatePublishRepositoryRelationRearLeadhape(UserContext uc, BO bo, List bolistN, List bolistC, List bolistS) { + Set newSet = new HashSet<>(); + Set changeSet = new HashSet<>(); + Set stopSet = new HashSet<>(); + if (bolistN != null) { + for (BO boN : bolistN) { + String palId = boN.get("PUBLISHFILEID").toString(); + newSet.add(palId); + } + } + if (bolistC != null) { + for (BO boC : bolistC) { + String palId = boC.get("CHANGEDFILEIDNEW").toString(); + changeSet.add(palId); + } + } + if (bolistS != null) { + for (BO boS : bolistS) { + String palId = boS.get("STOPFILEID").toString(); + stopSet.add(palId); + } + } + DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); + updateLeadRear(uc, newSet, relationDao, "new"); + updateLeadRear(uc, changeSet, relationDao, "change"); + updateLeadRear(uc, stopSet, relationDao, "stop"); + } + + private void updateLeadRear(UserContext uc, Set set, DesignerShapeRelationDao relationDao, String type) { + for (String id : set) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model == null) { + continue; + } + Set rearSet = new HashSet<>(); + Set leadSet = new HashSet<>(); + List list1 = relationDao.query(null, null, null, model.getVersionId(), null); + for (DesignerShapeRelationModel m1 : list1) { + if (UtilString.isEmpty(m1.getRelationShapeId())) { + // 伊利前后置流程的数据处理 by sunlh 20221025 + if ("rear_process".equals(m1.getAttrId())) {// 后置流程 + rearSet.add(m1.getFileId()); + } else if ("lead_process".equals(m1.getAttrId())) {// 前置流程 + leadSet.add(m1.getFileId()); + } + } + } + // 更新将该模型作为前后置流程相关模型 伊利 by sunlh 20221025 + updateLeadRearRepositoryDesigner(uc, leadSet, "top", model, type); + updateLeadRearRepositoryDesigner(uc, rearSet, "bottom", model, type); + } + } + + /** + * 更新将该模型作为前后置流程相关模型 伊利 by sunlh 20221025 + */ + private void updateLeadRearRepositoryDesigner(UserContext uc, Set set, String position, PALRepositoryModel pubilshModel, String type) { + + for (String uuid : set) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model != null) { + String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, uuid); + try { + boolean update = false; + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + JSONArray procedureShapeArr = getProcedureShapeArr(elements); + for (int i = 0; i < procedureShapeArr.size(); i++) { + JSONObject shape = procedureShapeArr.getJSONObject(i); + if (matchProcedureObj(shape, pubilshModel.getVersionId(), pubilshModel.getName(), position)) { + update = true; + String id = shape.getString("id"); + elements.getJSONObject(id).put("text", ("new".equals(type) || "change".equals(type)) ? pubilshModel.getName() : pubilshModel.getName() + "(已废止)"); + } + } + if (update) { + // 保存 + BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); + if (defineModel == null) { + defineModel = CoeDesignerUtil.createModel(uuid, 0); + defineModel.setCreateHistory(false); + } + definition.put("elements", elements); + defineModel.setDefinition(definition.toString()); + defineModel.setUpdateTime(new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date())); + // 保存文件 + CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 + // 记录操作行为日志 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_UPDATE, CoEOpLogConst.INFO_REPOSITORY_DESIGNER_UPDATE + ",文件属性[" + ("top".equals(position) ? "前置" : "后置") + "流程]触发流程接口形状更新"); + SDK.getLogAPI().consoleInfo("[成功][" + pubilshModel.getName() + "]被" + ("new".equals(type) ? "发布" : "change".equals(type) ? "变更" : "废止") + ",文件属性[" + ("top".equals(position) ? "前置" : "后置") + "流程]触发流程[" + model.getName() + "][" + model.getId() + "]流程接口形状更新"); + } + } + } catch (Exception e) { + e.printStackTrace(); + SDK.getLogAPI().consoleErr("模型[" + model.getName() + "][" + model.getId() + "]模型文件转换JSON异常"); + continue; + } + } + } + + } + + private boolean matchProcedureObj(JSONObject shape, String versionId, String name, String position) { + if (shape.containsKey("attrMark") && shape.getJSONObject("attrMark") != null) { + return versionId.equals(shape.getJSONObject("attrMark").getString("versionId")) && !name.equals(shape.getString("shapeText")); + } + return false; + } + + private JSONArray getProcedureShapeArr(JSONObject elements) { + JSONArray result = new JSONArray(); + Iterator it = elements.keySet().iterator(); + while (it.hasNext()) { + String key = it.next(); + JSONObject shape = elements.getJSONObject(key); + String name = shape.getString("name"); + if ("procedure".equals(name)) {// 流程接口 + JSONObject obj = new JSONObject(); + String shapeText = shape.getString("text"); + JSONArray fromLinkerArr = new JSONArray(); + JSONArray toLinkerArr = new JSONArray(); + JSONObject attrMark = shape.getJSONObject("attrMark"); + obj.put("id", key); + obj.put("shapeText", shapeText); + obj.put("fromLinkerArr", fromLinkerArr); + obj.put("toLinkerArr", toLinkerArr); + obj.put("attrMark", attrMark); + getInterfaceShapeLink(obj, elements); + result.add(obj); + } + } + return result; + } + + private void getInterfaceShapeLink(JSONObject obj, JSONObject elements) { + Iterator it = elements.keySet().iterator(); + while (it.hasNext()) { + String key = it.next(); + JSONObject shape = elements.getJSONObject(key); + String name = shape.getString("name"); + if ("linker".equals(name)) {// 连线 + // 出线 + JSONObject from = shape.getJSONObject("from"); + // 入线 + JSONObject to = shape.getJSONObject("to"); + if (from != null && to != null) { + String fromId = from.getString("id"); + String toId = to.getString("id"); + if (obj.getString("id").equals(fromId)) { + obj.getJSONArray("fromLinkerArr").add(key); + } + if (obj.getString("id").equals(toId)) { + obj.getJSONArray("toLinkerArr").add(key); + } + } + } + } + } + + private void updateEffectiveDateProperty(String processInstId, BO bo, Timestamp publishDate, List bolistN, List bolistC) { + // 对epc、表单、制度图进行生效日期更新和手册重新生成 + // epc:process.epc effective_date + // 表单:data.form form_effective_date + // 制度:control.policy effective_date + String applyUser = bo.getString("APPLYUSERID");// 以申请人身份创建流程手册 + String date = UtilDate.datetimeFormat(publishDate); + String publishDateType = bo.getString("CHOICEEFFECTIVEDATE"); + String publishDatet = bo.getString("EFFECTIVEDATE"); + PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao(); + // 创建线程池进行流程手册的处理 + ExecutorService service = Executors.newFixedThreadPool(4); + //将发布范围权限信息保存至范围权限表 + if (bolistN != null) { + for (BO boN : bolistN) { + String palId = boN.get("PUBLISHFILEID").toString(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); + if (model == null) { + SDK.getLogAPI().consoleErr("[更新生效日期和创建手册]更新失败,模型不存在,模型[" + palId + "]"); + continue; + } + // 新增模型时间 + if (updatePropertyEffectiveDate(model, date, propertyDao, publishDateType, publishDatet)) { + // 重新创建手册 + service.execute(new Runnable() { + @Override + public void run() { + updateProcessReport(model.getId(), processInstId, "N", applyUser); + } + }); + } + } + } + if (bolistC != null) { + for (BO boC : bolistC) { + String palId = boC.get("CHANGEDFILEIDNEW").toString(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); + if (model == null) { + SDK.getLogAPI().consoleErr("[更新生效日期和创建手册]更新失败,模型不存在,模型[" + palId + "]"); + continue; + } + // 新增模型时间 + if (updatePropertyEffectiveDate(model, date, propertyDao, publishDateType, publishDatet)) { + // 重新创建手册 + service.execute(new Runnable() { + @Override + public void run() { + updateProcessReport(model.getId(), processInstId, "C", applyUser); + } + }); + } + } + } + } + + /** + * 新生成流程手册,编号进行处理 + * + * @param uuid + */ + private void updateProcessReport(String uuid, String processInstId, String type, String appUser) { + // epc:process.epc effective_date + // 表单:data.form form_effective_date + // 制度:control.policy effective_date + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + String category = model.getMethodCategory(); + if ("default".equals(model.getMethodId())) { + return; + } + // 校验流程手册是否安装并启动 + if (model.getMethodId().contains("process.") && !SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.output.pr")) { + SDK.getLogAPI().consoleErr("[流程手册未安装]流程手册更新失败"); + return; + } + if ("data.form".equals(model.getMethodId()) && !SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.bd")) { + SDK.getLogAPI().consoleErr("[表单手册未安装]流程手册更新失败"); + return; + } + if ("control.policy".equals(model.getMethodId()) && !SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.zd")) { + SDK.getLogAPI().consoleErr("[表单手册未安装]流程手册更新失败"); + return; + } + + if ("N".equals(type)) { + BO nBo = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N, true) + .bindId(processInstId) + .addQuery("PUBLISHFILEID=", uuid) + .detail(); + if (nBo != null) { + String boId = nBo.getId(); + // 创建流程手册 + String oldTaskId = nBo.getString("TASKID"); + // 获取报告类型 + OutputTaskModel taskModel = new OutputTask().getTaskReportById(oldTaskId); + if (taskModel != null) { + String taskId = createOutputReport(model, model.getWsId(), appUser, "", model.getId()); + if (UtilString.isNotEmpty(taskId)) { + // 更新流程发布表 + SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "],taskId:" + taskId + " 成功"); + // 更新BO表taskId字段 + int r1 = DBSql.update("UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE ID ='" + boId + "'"); + PublishHistory dao = new PublishHistory();// 发布结果主表 + PublishHistoryModel history = dao.queryBy("PROCESSINSTID = ?", processInstId); + int r2 = -1; + if (history != null) { + r2 = DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PID ='" + history.getId() + "' AND PALREPOSITORYID='" + uuid + "'"); + } + SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后更新数据库taskId,流程名称:" + model.getName() + "[" + model.getId() + "],影响结果数量:BO_ACT_COE_PUBLISH_N[" + r1 + "],APP_ACT_COE_PAL_PUBLISH_LIST[" + r2 + "]"); + } else { + SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "] 失败"); + } + } + } + } + if ("C".equals(type)) { + BO cBo = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C, true) + .bindId(processInstId) + .addQuery("CHANGEDFILEIDNEW=", uuid) + .detail(); + if (cBo != null) { + String boId = cBo.getId(); + // 创建流程手册 + String oldTaskId = cBo.getString("TASKID"); + // 获取报告类型 + OutputTaskModel taskModel = new OutputTask().getTaskReportById(oldTaskId); + if (taskModel != null) { + String taskId = createOutputReport(model, model.getWsId(), appUser, "", model.getId()); + if (UtilString.isNotEmpty(taskId)) { + // 更新流程发布表 + SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "],taskId:" + taskId + " 成功"); + // 更新BO表taskId字段 + int r1 = DBSql.update("UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + taskId + "'WHERE ID ='" + boId + "'"); + PublishHistory dao = new PublishHistory();// 发布结果主表 + PublishHistoryModel history = dao.queryBy("PROCESSINSTID = ?", processInstId); + int r2 = -1; + if (history != null) { + r2 = DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PID ='" + history.getId() + "' AND PALREPOSITORYID='" + uuid + "'"); + } + SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后更新数据库taskId,流程名称:" + model.getName() + "[" + model.getId() + "],影响结果数量:BO_ACT_COE_PUBLISH_C[" + r1 + "],APP_ACT_COE_PAL_PUBLISH_LIST[" + r2 + "]"); + } else { + SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "] 失败"); + } + } + } + } + } + + /** + * 创建手册 + * + * @param model + * @param wsId + * @param userId + * @param teamId + * @param uuid + * @return + */ + private String createOutputReport(PALRepositoryModel model, String wsId, String userId, String teamId, String uuid) { + String taskId = ""; + if (model.getMethodId().contains("process.")) { + taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, userId, teamId, uuid); + JSONObject object = JSONObject.parseObject(taskId); + if ("ok".equals(object.getString("result"))) { + taskId = object.getJSONObject("data").getString("taskId"); + } + } else if ("data.form".equals(model.getMethodId())) { + taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportBd(wsId, userId, teamId, uuid); + JSONObject object = JSONObject.parseObject(taskId); + if ("ok".equals(object.getString("result"))) { + taskId = object.getJSONObject("data").getString("taskId"); + } + } else if ("control.policy".equals(model.getMethodId())) { + taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, userId, teamId, uuid); + JSONObject object = JSONObject.parseObject(taskId); + if ("ok".equals(object.getString("result"))) { + taskId = object.getJSONObject("data").getString("taskId"); + } + } + return taskId; + } + + /** + * 更新文件属性(生效日期) + * + * @param model + * @param date + * @param propertyDao + */ + private boolean updatePropertyEffectiveDate(PALRepositoryModel model, String date, PALRepositoryPropertyDao propertyDao, String publishDateType, String publishDate) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String time = df.format(new Date()); + // epc:process.epc effective_date + // 表单:data.form form_effective_date + // 制度:control.policy effective_date + String method = model.getMethodId(); + // + + String attrId = ""; + if ("process.epc".equals(method)) { + attrId = "effective_date"; + } else if ("data.form".equals(method)) { + attrId = "form_effective_date"; + } else if ("control.policy".equals(method)) { + attrId = "effective_date"; + } + if (UtilString.isEmpty(attrId)) { + return false; + } + + // 更新生效时间 + boolean existProp = false; + List list = propertyDao.getPropertysByPlid(model.getId(), attrId); + for (PALRepositoryPropertyModel propertyModel : list) { + if (attrId.equals(propertyModel.getPropertyId())) { + if ("1".equals(publishDateType)) { + propertyDao.updatePropertyByPropertyId(model.getId(), attrId, publishDate); + } else { + propertyDao.updatePropertyByPropertyId(model.getId(), attrId, time); + + } + SDK.getLogAPI().consoleInfo("[更新模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + time + "]"); + existProp = true; + } + } + if (!existProp) { + // 属性不存在,新增一个 + PALRepositoryPropertyModel property = new PALRepositoryPropertyModel(); + property.setId(UUIDGener.getUUID()); + property.setOrderIndex(0); + property.setPlId(model.getId()); + property.setPropertyId(attrId); + property.setPropertyName("生效时间"); + property.setPropertyValue(time); + propertyDao.insert(property); + SDK.getLogAPI().consoleInfo("[新增模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + time + "]"); + } + return true; + } + + /** + * 流程发布范围权限单独存储 + * + * @param publish 流程发布bo主表 + * @param bolistN 新增发布流程信息 + * @param bolistC 变更发布流程信息,需要将已存在的相应流程权限信息进行删除,再进行权限存储 + * @param bolistS 停用发布流程信息,删除相应流程权限信息 + */ + private void savePublishScope(BO publish, List bolistN, List bolistC, List bolistS) { + String bindId = publish.getBindId(); + String wsId = publish.getString("WSID"); + String applyUser = publish.getString("APPLYUSERID"); + String sendScope = publish.getString("SEND_SCOP"); + String sendScopeOrg = publish.getString("SEND_SCOPE_ORG"); + String sendScopePost = publish.getString("SEND_SCOPE_POST"); + String sendScopeLevel = publish.getString("SEND_SCOPE_LEVEL"); + Set removeVerIds = new HashSet<>(); + Map addVerMap = new HashMap<>(); + //将发布范围权限信息保存至范围权限表 + if (bolistN != null) { + for (BO boN : bolistN) { + String palId = boN.get("PUBLISHFILEID").toString(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); + if (model == null) { + SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]"); + continue; + } + addVerMap.put(model.getVersionId(), model.getName()); + removeVerIds.add(model.getVersionId()); + } + } + if (bolistC != null) { + for (BO boC : bolistC) { + String palId = boC.get("CHANGEDFILEIDNEW").toString(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); + if (model == null) { + SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]"); + continue; + } + addVerMap.put(model.getVersionId(), model.getName()); + removeVerIds.add(model.getVersionId()); + } + } + if (bolistS != null) { + for (BO boS : bolistS) { + String palId = boS.get("STOPFILEID").toString(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(palId); + if (model == null) { + SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]"); + continue; + } + removeVerIds.add(model.getVersionId()); + } + } + + String newBoName = "BO_ACT_PUBLISH_PERM_SCOPE"; + // 先删除相应原有权限数据,再进行数据更新 + Set removeIds = new HashSet<>(); + for (String removeVerId : removeVerIds) { + List delList = SDK.getBOAPI().query(newBoName).addQuery("PALVERSIONID=", removeVerId).list(); + if (delList != null && delList.size() > 0) { + for (BO del : delList) { + removeIds.add(del.getId()); + } + } + } + for (String removeId : removeIds) { + SDK.getBOAPI().remove(newBoName, removeId); + } + + // 重新添加权限 + //List list = new ArrayList<>(); + for (Map.Entry entry : addVerMap.entrySet()) { + String verId = entry.getKey(); + String name = entry.getValue(); + BO bo = new BO(); + bo.set("PERMID", UUIDGener.getUUID()); + bo.set("WSID", wsId); + bo.set("PALVERSIONID", verId); + bo.set("PALNAME", name); + bo.set("PERMTYPE", sendScope); + bo.set("ORGPERM", "1".equals(sendScope) ? SDK.getORGAPI().getCompanyByUser(applyUser).getId() : sendScopeOrg); + bo.set("POSTPERM", "1".equals(sendScope) ? "" : sendScopePost); + bo.set("LEVELPERM", "1".equals(sendScope) ? "" : sendScopeLevel); + + ProcessInstance boProcessInstance = SDK.getProcessAPI() + .createBOProcessInstance("obj_e076b01bd0d04bc39e5af12e2c8c188c", applyUser, "权限阅览"); + SDK.getBOAPI().create(newBoName, bo, boProcessInstance.getId(), applyUser); + +// list.add(bo); + } +// if (list.size() > 0) { +// SDK.getBOAPI().create(newBoName, list, bindId, applyUser); +// SDK.getLogAPI().consoleInfo("[发布范围权限信息保存至范围权限表]更新成功"); +// } + SDK.getLogAPI().consoleInfo("[发布范围权限信息保存至范围权限表]更新成功"); + } + + + /**** + * 发布明细如果关联角色、绩效图,不显示在发布界面,在流程结束后同步发布 + */ + public void updateRoleAndPerformance(String publishFileId, Timestamp publishDate, String type) { + try { + List roleList = new ArrayList(); + roleList.add(0, "org.role"); + roleList.add(1, publishFileId); + PALRepository repositoryDao = new PALRepository(); + RowMap rolerowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", roleList.toString()); + + if (rolerowMap != null) { + //修改流程文件的发布属性 + repositoryDao.updatePublishStatusAndDate(type, rolerowMap.getString("ID"), null, publishDate); + } + List performanceList = new ArrayList(); + performanceList.add(0, "control.kpi"); + performanceList.add(1, publishFileId); + + RowMap performrowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", performanceList.toString()); + + if (performrowMap != null) { + //修改流程文件的发布属性 + repositoryDao.updatePublishStatusAndDate(type, performrowMap.getString("ID"), null, publishDate); + } + } catch (AWSDataAccessException e) { + e.printStackTrace(); + } + + } + + /** + * 1、发布结束后获取关联绩效模型填充流程编号 + * 2、获取信息插入绩效指标库 + * + * @param publishFileId + * @param publishDate + */ + public void updateProcessNumber(String publishFileId, UserContext uc, String wsId, String processNumber, Timestamp publishDate) { + try { + //获取关联绩效模型数据 + List performanceList = new ArrayList(); + performanceList.add(0, "control.kpi"); + performanceList.add(1, publishFileId); + + RowMap performrowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", performanceList.toString()); + + ProcessInstance processInst = SDK.getProcessAPI().createBOProcessInstance("obj_1ffbc1e73b99427ca64469e466f97dbe", uc.getUID(), "指标绩效数据插入"); + + + ProcessInstance performNumberProcess = SDK.getProcessAPI().createBOProcessInstance("obj_b92c1343b4914e969ead13db62f360f2", uc.getUID(), "绩效编号插入"); + + if (performrowMap != null) { + + PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(performrowMap.getString("ID")); + + String id = performrowMap.getString("ID"); + + + Map> methodAttrsMap = new HashMap<>();// 属性存储 + + Map methodValueAttrsMap = new HashMap<>();// 属性存储 + + //查询对应绩效模型中数据模型进行填充数据 + BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0); + + CoeProcessLevelWeb coeProcessLevelWeb = new CoeProcessLevelWeb(uc); + + String define = defineModel.getDefinition(); + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + + coeProcessLevelWeb.handleShapeDefaultAttr(wsId, parentModel, elements, methodAttrsMap); + + + if (UtilString.isNotEmpty(processNumber)) { + //编号规则为: MP(流程编号是:08.01.05.05/P05V1.0-YLYYYY,对应的流程绩效编号MP-08.01.05.05-YLYYYY.AA(AA=1~99顺序排号)对流程编号,去除"/P05V1.0) + + //去掉 /P05V1.0- + String before = null; + String after = null; + try { + before = processNumber.substring(0, processNumber.indexOf("/")); + after = processNumber.substring(processNumber.lastIndexOf("-"), processNumber.length()); + } catch (Exception e) { + e.printStackTrace(); + } + + //拿去流程数据填充绩效模型中数据属性 + for (String key : elements.keySet()) { + + JSONObject shape1 = elements.getJSONObject(key); + if ("linker".equals(shape1.getString("name"))) { + continue; + } + String shapeText = shape1.getString("text"); + JSONArray dataAttributes = shape1.getJSONArray("dataAttributes"); + if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) { + + + for (Object attribute : dataAttributes) { + JSONObject obj = (JSONObject) attribute; + if (obj.containsKey("attributesJsonArray")) { + JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray"); + BO recordBO = new BO(); + boolean insertFlag = false; + if (attributesJsonArray.size() > 0) { + + //事前循环jsonarry,判断绩效编号是否填写 + for (int c = 0; c < attributesJsonArray.size(); c++) { + if (attributesJsonArray.getJSONObject(c).containsKey("id")) { + String getid1 = attributesJsonArray.getJSONObject(c).getString("id"); + String value1 = attributesJsonArray.getJSONObject(c).getString("value"); + if (getid1.equals("Process_performance_indicator_Number")) { + if (UtilString.isEmpty(value1) || !value1.contains("MP")) { + insertFlag = true; + } + } + } + } + for (int i = 0; i < attributesJsonArray.size(); i++) { + if (attributesJsonArray.getJSONObject(i).containsKey("id")) { + String getid = attributesJsonArray.getJSONObject(i).getString("id"); + String value = attributesJsonArray.getJSONObject(i).getString("value"); + + + if (insertFlag == true) { + //回填绩效编号操作 + if (getid.equals("Process_performance_indicator_Number")) { + if (UtilString.isEmpty(value)) { + + //获取当前MP绩效最新排序数值 + BO performanceNumberBO = SDK.getBOAPI().query("BO_EU_PERFORMANCE_NUMBER").addQuery("PERFORMANCE_TYPE=", "control.kpi").addQuery("PROCESS_NUMBER=", processNumber).detail(); + + int currentnumber; + + if (performanceNumberBO != null) { + currentnumber = Integer.valueOf(performanceNumberBO.getString("CURRENTNUMBER")); + } else { + BO performanceBo = new BO(); + performanceBo.set("PROCESS_NUMBER", processNumber); + performanceBo.set("CURRENTNUMBER", 1); + performanceBo.set("PERFORMANCE_TYPE", "control.kpi"); + SDK.getBOAPI().create("BO_EU_PERFORMANCE_NUMBER", performanceBo, performNumberProcess.getId(), ""); + currentnumber = 0; } + currentnumber++; - } - if (getid.equals("Downstream_target")) {//下游指标 - if (UtilString.isNotEmpty(value)) { - String Downstream_target = value.substring(value.indexOf('"') + 1, value.lastIndexOf('"')); - RowMap rowMap = DBSql.getMap("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT WHERE FILEID=? AND RELATIONSHAPEID=?", id, Downstream_target); - recordBO.set("DOWNSTREAM_TARGET_ID", Downstream_target); - if (rowMap != null) { - recordBO.set("DOWNSTREAM_TARGET", rowMap.getString("RELATIONSHAPETEXT")); - } + attributesJsonArray.getJSONObject(i).put("value", "MP." + before + after + "." + currentnumber); + + recordBO.set("PROCESS_PERFORMANCE_IND_NUM", "MP." + before + after + "." + currentnumber); + + + if (performanceNumberBO != null) { + performanceNumberBO.set("CURRENTNUMBER", currentnumber); + } else { + performanceNumberBO = SDK.getBOAPI().query("BO_EU_PERFORMANCE_NUMBER").addQuery("PERFORMANCE_TYPE=", "control.kpi").addQuery("PROCESS_NUMBER=", processNumber).detail(); } - + SDK.getBOAPI().update("BO_EU_PERFORMANCE_NUMBER", performanceNumberBO); } - recordBO.set("PERFORMANCE_TYPE", "末级流程绩效"); - if (getid.equals("element")) {//元素 - JSONObject getvalue = attributesJsonArray.getJSONObject(i).getJSONObject("value"); - if (getvalue != null) { - JSONArray elejsonArray = attributesJsonArray.getJSONObject(i).getJSONObject("value").getJSONArray("table"); - for (int k = 1; k < elejsonArray.size(); k++) { - String name = elejsonArray.getJSONObject(k).get("name").toString(); - String desc = elejsonArray.getJSONObject(k).get("desc").toString(); - BO eleBO = new BO(); - eleBO.set("ELEMENT", name); - eleBO.set("DATASOURCES", desc); - SDK.getBOAPI().create("BO_EU_ELEMENT", eleBO, processInst.getId(), ""); - } + } + //回填流程编号到绩效模型 + if (getid.equals("Number_of_the_associated_flow_file")) { + attributesJsonArray.getJSONObject(i).put("value", processNumber); + } + + //插入绩效指标库操作 + if (getid.equals("Process_Architecture_L1")) {//L1 + recordBO.set("PROCESS_ARCHITECTURE_L1", value); + } + if (getid.equals("Process_Architecture_L2")) {//L2 + recordBO.set("PROCESS_ARCHITECTURE_L2", value); + } + if (getid.equals("Process_Architecture_L3")) {//L3 + recordBO.set("PROCESS_ARCHITECTURE_L3", value); + } + if (getid.equals("Number_of_the_associated_flow_file")) {//关联流程文件编号 + recordBO.set("NUMBER_OF_THE_ASSO_FLOW_FILE", value); + } + if (getid.equals("Associated_process_name")) {//关联流程名称 + recordBO.set("ASSOCIATED_PROCESS_NAME", value); + } + if (getid.equals("Name_process_performance_indicator")) {//流程绩效指标名称 + recordBO.set("PERFORMANCE_INDICATOR_NAME", shape1.getString("text")); + } + + if (getid.equals("Index_properties")) {//指标性质 + recordBO.set("INDEX_PROPERTIES", value); + } + if (getid.equals("ndicator_User_defined_label")) {//指标自定义标签 + recordBO.set("NDICATOR_USER_DEFINED_LABEL", value); + } + if (getid.equals("Index_definition")) {//指标定义 + recordBO.set("INDEX_DEFINITION", value); + } + if (getid.equals("unit_measurement")) {//计量单位 + recordBO.set("UNIT_MEASUREMENT", value); + } + if (getid.equals("statistical_period")) {//统计周期 + recordBO.set("STATISTICAL_PERIOD", value); + } + + if (getid.equals("computational_formula")) {//计算公式 + recordBO.set("COMPUTATIONAL_FORMULA", value); + } + if (getid.equals("Data_fetch_logic")) {//数据取数逻辑 + recordBO.set("DATA_FETCH_LOGIC", value); + } + if (getid.equals("Take_the_number_aperture")) {//取数口径 + recordBO.set("TAKE_THE_NUMBER_APERTURE", value); + } + if (getid.equals("remark")) {//备注 + recordBO.set("REMARK", value); + } + if (getid.equals("oa_process")) {//OA流程 + recordBO.set("OA_PROCESS", value); + } + + if (getid.equals("The_upstream_indicators")) {//上游指标 + if (UtilString.isNotEmpty(value)) { + String The_upstream_indicatorsValue = value.substring(value.indexOf('"') + 1, value.lastIndexOf('"')); + RowMap rowMap = DBSql.getMap("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT WHERE FILEID=? AND RELATIONSHAPEID=?", id, The_upstream_indicatorsValue); + recordBO.set("THE_UPSTREAM_INDICATORS_ID", The_upstream_indicatorsValue); + if (rowMap != null) { + recordBO.set("THE_UPSTREAM_INDICATORS", rowMap.getString("RELATIONSHAPETEXT")); } } - //发布时间 - recordBO.set("PUBDATE", publishDate); - } - } + } + if (getid.equals("Downstream_target")) {//下游指标 + if (UtilString.isNotEmpty(value)) { + String Downstream_target = value.substring(value.indexOf('"') + 1, value.lastIndexOf('"')); + RowMap rowMap = DBSql.getMap("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT WHERE FILEID=? AND RELATIONSHAPEID=?", id, Downstream_target); + recordBO.set("DOWNSTREAM_TARGET_ID", Downstream_target); + if (rowMap != null) { + recordBO.set("DOWNSTREAM_TARGET", rowMap.getString("RELATIONSHAPETEXT")); + } + } - } - if (insertFlag == true) { - SDK.getBOAPI().create("BO_EU_PER_IND_LIB", recordBO, processInst.getId(), ""); - } - } - } - } + } - } + recordBO.set("PERFORMANCE_TYPE", "末级流程绩效"); - } + if (getid.equals("element")) {//元素 + JSONObject getvalue = attributesJsonArray.getJSONObject(i).getJSONObject("value"); + if (getvalue != null) { + JSONArray elejsonArray = attributesJsonArray.getJSONObject(i).getJSONObject("value").getJSONArray("table"); + for (int k = 1; k < elejsonArray.size(); k++) { + String name = elejsonArray.getJSONObject(k).get("name").toString(); + String desc = elejsonArray.getJSONObject(k).get("desc").toString(); + BO eleBO = new BO(); + eleBO.set("ELEMENT", name); + eleBO.set("DATASOURCES", desc); + SDK.getBOAPI().create("BO_EU_ELEMENT", eleBO, processInst.getId(), ""); + } + } + } + //发布时间 + recordBO.set("PUBDATE", publishDate); + } + + } + + } + if (insertFlag == true) { + SDK.getBOAPI().create("BO_EU_PER_IND_LIB", recordBO, processInst.getId(), ""); + } + } + } + } + + } + + } - defineModel.setDefinition(definition.toString()); - // 保存文件 - CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 + defineModel.setDefinition(definition.toString()); + // 保存文件 + CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 - } + } + } + } catch (AWSDataAccessException e) { + e.printStackTrace(); + } finally { + } - } - } catch (AWSDataAccessException e) { - e.printStackTrace(); - } finally { - } - - } - - + } }