From 8f751bbc9deb4c144baffc390007245500408e73 Mon Sep 17 00:00:00 2001 From: lihongyu <504404568@qq.com> Date: Sat, 29 Oct 2022 17:01:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=8F=91=E5=B8=83=E5=8F=91?= =?UTF-8?q?=E8=B5=B7=E4=BA=BA=E6=8F=90=E4=BA=A4=E5=90=8E=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=89=8B=E5=86=8C=20=E6=B5=81=E7=A8=8B=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=94=9F=E6=95=88=E6=97=A5=E6=9C=9F=E6=A0=BC=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/util/ProcesNumberUtil.java | 15 ++ .../event/ApplyTasAfterkComplete.java | 251 +++++++++++++++++- .../event/ApplyTaskAfterCreated.java | 1 + .../PublishExecuteListenerInterfaceImpl.java | 10 +- 4 files changed, 272 insertions(+), 5 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/ProcesNumberUtil.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/ProcesNumberUtil.java index 9cc6cba2..6b0fc153 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/ProcesNumberUtil.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/ProcesNumberUtil.java @@ -1,13 +1,28 @@ package com.actionsoft.apps.coe.pal.publisher.client.util; +import java.sql.Timestamp; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishHistory; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishHistoryModel; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; +import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant; import com.actionsoft.bpms.bo.engine.BO; import com.actionsoft.bpms.commons.database.RowMap; import com.actionsoft.bpms.util.DBSql; import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.bpms.util.UtilDate; import com.actionsoft.bpms.util.UtilString; import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSONObject; import com.sun.org.apache.xalan.internal.xsltc.compiler.sym; /** diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTasAfterkComplete.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTasAfterkComplete.java index 2e6771f5..2f50a1f9 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTasAfterkComplete.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTasAfterkComplete.java @@ -1,8 +1,16 @@ package com.actionsoft.apps.coe.pal.publisher.event; +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishHistory; import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishListHistory; import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishHistoryModel; import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishListHistoryModel; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; import com.actionsoft.apps.coe.pal.publisher.client.util.ProcesNumberUtil; import com.actionsoft.apps.coe.pal.publisher.client.util.ProcessStatusAPIManager; import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant; @@ -13,9 +21,15 @@ import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface; import com.actionsoft.bpms.commons.database.RowMap; import com.actionsoft.bpms.util.DBSql; import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.bpms.util.UtilDate; +import com.actionsoft.bpms.util.UtilString; import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSONObject; +import java.sql.Timestamp; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class ApplyTasAfterkComplete extends ExecuteListener implements ExecuteListenerInterface { @@ -39,6 +53,241 @@ public class ApplyTasAfterkComplete extends ExecuteListener implements ExecuteLi new ProcesNumberUtil().getNumber(processInstId); SDK.getLogAPI().consoleInfo("[任务事件]任务结束,涉及流程状态变为审批中-->" + ctx.getTaskInstance().getTitle()); ProcessStatusAPIManager.getInstance().batchUpdateApprovalStatus(ctx.getTaskInstance().getProcessInstId(), true); - + + + //任务提交后重新生成手册 + List bolistN = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N).bindId(processInstId).list(); + List bolistC = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C).bindId(processInstId).list(); + Timestamp nowTime = new Timestamp(System.currentTimeMillis()); + BO bo = SDK.getBOAPI().query(PublisherConstant.BOTABLENAME).detailByBindId(processInstId); + updateEffectiveDateProperty(processInstId, bo, nowTime, bolistN, bolistC); } + + + + 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); + 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; + } + // 重新创建手册 + service.execute(new Runnable() { + @Override + public void run() { + updateProcessReport(model.getId(), processInstId, "N", applyUser); + } + }); + /* + * // 新增模型时间 if (updatePropertyEffectiveDate(model, date, propertyDao)) { } + */ + } + } + 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)) { + // 重新创建手册 + service.execute(new Runnable() { + @Override + public void run() { + updateProcessReport(model.getId(), processInstId, "C", applyUser); + } + }); + } + } + } + } + /** + * 更新文件属性(生效日期) + * + * @param model + * @param date + * @param propertyDao + */ + private boolean updatePropertyEffectiveDate(PALRepositoryModel model, String date, PALRepositoryPropertyDao propertyDao) { + // 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())) { + propertyDao.updatePropertyByPropertyId(model.getId(), attrId, date); + SDK.getLogAPI().consoleInfo("[更新模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + date + "]"); + 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(date); + propertyDao.insert(property); + SDK.getLogAPI().consoleInfo("[新增模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + date + "]"); + } + return true; + } + + /** + * 新生成流程手册,编号进行处理 + * @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; + } + } diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTaskAfterCreated.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTaskAfterCreated.java index 33237624..0489a8c1 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTaskAfterCreated.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTaskAfterCreated.java @@ -43,6 +43,7 @@ public class ApplyTaskAfterCreated extends ExecuteListener implements ExecuteLis } } } + public void saveData(ProcessExecutionContext ctx) { UserContext userContext = ctx.getUserContext(); Date date=new Date();//此时date为当前的时间 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 f9a27728..68ba075e 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 @@ -546,6 +546,8 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme * @param propertyDao */ private boolean updatePropertyEffectiveDate(PALRepositoryModel model, String date, PALRepositoryPropertyDao propertyDao) { + 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 @@ -567,8 +569,8 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme List list = propertyDao.getPropertysByPlid(model.getId(), attrId); for (PALRepositoryPropertyModel propertyModel : list) { if (attrId.equals(propertyModel.getPropertyId())) { - propertyDao.updatePropertyByPropertyId(model.getId(), attrId, date); - SDK.getLogAPI().consoleInfo("[更新模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + date + "]"); + propertyDao.updatePropertyByPropertyId(model.getId(), attrId, time); + SDK.getLogAPI().consoleInfo("[更新模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + time + "]"); existProp = true; } } @@ -580,9 +582,9 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme property.setPlId(model.getId()); property.setPropertyId(attrId); property.setPropertyName("生效时间"); - property.setPropertyValue(date); + property.setPropertyValue(time); propertyDao.insert(property); - SDK.getLogAPI().consoleInfo("[新增模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + date + "]"); + SDK.getLogAPI().consoleInfo("[新增模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + time + "]"); } return true; }