diff --git a/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar b/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar index cb93c652..ff93f755 100644 Binary files a/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar and b/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar differ diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/Plugins.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/Plugins.java index ecbe89d4..d115705a 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/Plugins.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/Plugins.java @@ -5,6 +5,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.actionsoft.apps.coe.pal.publisher.alsp.SendEHSQAlsp; +import com.actionsoft.apps.coe.pal.publisher.alsp.SendKMSAlsp; +import com.actionsoft.apps.coe.pal.publisher.alsp.SendOAAlsp; import com.actionsoft.apps.coe.pal.publisher.at.*; import com.actionsoft.apps.coe.pal.publisher.client.web.ProcessPublishClientWeb; import com.actionsoft.apps.coe.pal.publisher.client.web.ProcessPublishWeb; @@ -163,6 +166,13 @@ public class Plugins implements PluginListener { list.add(new AtFormulaPluginProfile("依据任务接收时间与意见回复期限返回小时数", "@getConsultHour(*bindid,*taskId,*deadline)", getConsultHour.class.getName(), "依据任务接收时间与意见回复期限返回小时数", "依据任务接收时间与意见回复期限返回小时数")); + list.add(new ASLPPluginProfile("SendOAAlsp", SendOAAlsp.class.getName(), "OA系统请求调用请求调用", new HttpASLP(HttpASLP.AUTH_AWS_SID))); + + list.add(new ASLPPluginProfile("SendKMSAlsp", SendKMSAlsp.class.getName(), "KMS调用", new HttpASLP(HttpASLP.AUTH_AWS_SID))); + + list.add(new ASLPPluginProfile("SendEHSQAlsp", SendEHSQAlsp.class.getName(), "EHSQ调用", new HttpASLP(HttpASLP.AUTH_AWS_SID))); + + return list; } diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendEHSQAlsp.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendEHSQAlsp.java new file mode 100644 index 00000000..6baf95ac --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendEHSQAlsp.java @@ -0,0 +1,100 @@ +package com.actionsoft.apps.coe.pal.publisher.alsp; + +import com.actionsoft.apps.coe.pal.publisher.pubEvent.ProcessEndAfterEvent_new; +import com.actionsoft.apps.resource.interop.aslp.ASLP; +import com.actionsoft.apps.resource.interop.aslp.Meta; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; + +import java.sql.Connection; +import java.util.List; +import java.util.Map; + +public class SendEHSQAlsp implements ASLP { + + + @Override + @Meta(parameter = {"name:'processId',required:true,desc:'流程ID'", + "name:'taskId',required:true,desc:'任务ID'", + "name:'sid',required:true,desc:'sid'", + "name:'isSendEHSQ',required:true,desc:'isSendEHSQ'", + }) + public ResponseObject call(Map map) { + String processId = String.valueOf(map.get("processId")); + String taskId = String.valueOf(map.get("taskId")); + String sid = String.valueOf(map.get("sid")); + String isSendEHSQ = String.valueOf(map.get("isSendEHSQ")); + Connection open = DBSql.open(); + + + // 流程发布的新增发布 + List bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).connection(open) + .addQuery("BINDID=", processId).list(); + // 流程发布的变更发布 + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).connection(open) + .addQuery("BINDID=",processId).list(); + // 流程发布的废止变更 + List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).connection(open) + .addQuery("BINDID=", processId).list(); + + ProcessInstance processInstance = SDK.getProcessAPI().getInstanceById(processId); + TaskInstance taskInstance=SDK.getTaskAPI().getInstanceById(taskId); + + + ProcessEndAfterEvent_new processEndAfterEventNew=new ProcessEndAfterEvent_new(); + + boolean sendEhqs = false; + String depId = UserContext.fromSessionId(sid).getDepartmentModel().getId(); + //获取EHSQ配置表判断是否发送 + String sql = "SELECT * FROM BO_ACT_ACT_ESQ_SEND"; + List maps = DBSql.getMaps(open,sql); + for (RowMap rowMap : maps) { + String dempet = rowMap.getString("DEMPET"); + String issend = rowMap.getString("ISSEND"); + DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(dempet); + if(departmentById!=null) { + String departemenId = departmentById.getId(); + String pathIdOfCache=departmentById.getPathIdOfCache(); + if(departemenId.equals(depId)&&"是".equals(issend)) { + sendEhqs = true; + } else { + List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); + for (DepartmentModel departmentModel : subDepartments) { + String subDeartmentId = departmentModel.getId(); + if (subDeartmentId.equals(depId) && "是".equals(issend)) { + sendEhqs = true; + } + } + + } + + } + } + if(!sendEhqs) { + System.err.println("本次发文不推送EHSQ====>"+processInstance.getTitle()); + } + if ("true".equals(isSendEHSQ)&&sendEhqs) { + try { + // 推送EHSQ + if(bo_act_coe_publish_n.size()>0) { + processEndAfterEventNew.sendEHSQ(processInstance, bo_act_coe_publish_n,taskInstance,sid); + } + // 更新EHSQ + if(bo_act_coe_publish_c.size()>0) { + processEndAfterEventNew.updateEHSQ(processInstance, bo_act_coe_publish_c,taskInstance,sid); + } + } catch (Exception e) { + // TODO: handle exception + } + } + + return null; + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendKMSAlsp.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendKMSAlsp.java new file mode 100644 index 00000000..9024bf62 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendKMSAlsp.java @@ -0,0 +1,174 @@ +package com.actionsoft.apps.coe.pal.publisher.alsp; + +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.publisher.pubEvent.DownloadUtil; +import com.actionsoft.apps.coe.pal.publisher.pubEvent.ProcessEndAfterEvent_new; +import com.actionsoft.apps.coe.pal.publisher.utils.DeleteGptFilesUtils; +import com.actionsoft.apps.resource.interop.aslp.ASLP; +import com.actionsoft.apps.resource.interop.aslp.Meta; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.constant.ProcessRuntimeConst; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang.StringUtils; + +import java.sql.Connection; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; + +public class SendKMSAlsp implements ASLP { + + + @Override + @Meta(parameter = {"name:'processId',required:true,desc:'流程实例ID'", + "name:'sid',required:true,desc:'sid'"}) + public ResponseObject call(Map map) { + ResponseObject ro = ResponseObject.newWarnResponse("结果未知"); + try { + String processId = String.valueOf(map.get("processId")); + Connection open = DBSql.open(); + + String sid = String.valueOf(map.get("sid")); + //查询发布表数据 + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + .addQuery("BINDID=", processId) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + + // 流程发布的新增发布 + List bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).connection(open) + .addQuery("BINDID=", processId).list(); + // 流程发布的变更发布 + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).connection(open) + .addQuery("BINDID=", processId).list(); + // 流程发布的废止变更 + List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).connection(open) + .addQuery("BINDID=", processId).list(); + JSONArray filed = new JSONArray(new LinkedList<>()); + String wsId = ""; + ProcessInstance processInstance = SDK.getProcessAPI().getInstanceById(processId); + ProcessEndAfterEvent_new processEndAfterEvent_new = new ProcessEndAfterEvent_new(); + + + JSONObject jsonObject = new JSONObject(); + + String new_uid = ""; + ArrayList sendList = new ArrayList(); + // 发送全集团 + if ("1".equals(bo_act_coe_publish.getString("SEND_SCOP"))) { + // 系统人员 + ArrayList userList1 = new ArrayList(); + try { + userList1 = processEndAfterEvent_new.getUser(jsonObject, "5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe", "0", + processId); + } catch (Exception e) { + // TODO: handle exception + } + //System.err.println("系统人员=====>" + userList1); + // 项目开发人员 + ArrayList userList2 = new ArrayList(); + try { + userList2 = processEndAfterEvent_new.getUser(jsonObject, "e79281b1-2f81-4895-b30e-9f96e9ad0e2c", "0", + processId); + } catch (Exception e) { + // TODO: handle exception + } + //System.err.println("项目开发人员=====>" + userList2); + // 离退人员 + ArrayList userList3 = new ArrayList(); + try { + userList3 = processEndAfterEvent_new.getUser(jsonObject, "65048aee-157f-49f2-a2dc-5903dd26f519", "0", + processId); + } catch (Exception e) { + // TODO: handle exception + } + //System.err.println("离退人员=====>" + userList3); + List mapsl = DBSql.getMaps(open, "SELECT * FROM ORGUSER WHERE CLOSED = '0'"); + for (RowMap rowMap : mapsl) { + String userId = rowMap.getString("USERID"); + // RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" + // + instanceById.getId() + "' AND USER_ID = '" + userId + "'"); + if (!"10033643".equals(userId) && !userList1.contains(userId) + && !userList2.contains(userId) && !userList3.contains(userId)) { + sendList.add(userId); + } + } + } else { + // 发送组织岗位职级 + sendList = processEndAfterEvent_new.getSendList(processInstance, bo_act_coe_publish, jsonObject); + } + + + new_uid = new_uid.join(",", sendList); + + try { + // 发布到知识库 + int m = 0; + for (BO bo : bo_act_coe_publish_n) { + processEndAfterEvent_new.createKmsByNew(bo, wsId, filed, processInstance, bo_act_coe_publish, new_uid, sid); + } + // 更新知识库 + for (BO bo : bo_act_coe_publish_c) { + processEndAfterEvent_new.CreateKmsByupdate(bo, wsId, filed, processInstance, bo_act_coe_publish, + new_uid, sid); + } + + // 废止知识库文件 + for (BO bo : bo_act_coe_publish_s) { + // 将旧的知识取消发布或者移动到废止发布中 + String publishfileid_stop = bo.getString("STOPFILEID"); + filed.add(publishfileid_stop); + String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_stop + + "'"; + RowMap map1 = DBSql.getMap(open, sql_s); + if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { + processEndAfterEvent_new.CancelPublishKnwl(processInstance, + sid, + map1.getString("EXT4")); + + DBSql.update(open, "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + + publishfileid_stop + "'"); + } + } + } catch (Exception e) { + System.out.println("KMS知识库创建异常====" + bo_act_coe_publish_n); + // TODO: handle exception + e.printStackTrace(); + + } + } catch (Exception e) { + e.printStackTrace(); + ro = ResponseObject.newErrResponse(e.getMessage()); + } + + + return ro; + + + + } + + + + + + + + + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendOAAlsp.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendOAAlsp.java new file mode 100644 index 00000000..21d34a10 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendOAAlsp.java @@ -0,0 +1,68 @@ +package com.actionsoft.apps.coe.pal.publisher.alsp; + +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.publisher.pubEvent.DownloadUtil; +import com.actionsoft.apps.coe.pal.publisher.pubEvent.ProcessEndAfterEvent_new; +import com.actionsoft.apps.coe.pal.publisher.utils.DeleteGptFilesUtils; +import com.actionsoft.apps.resource.interop.aslp.ASLP; +import com.actionsoft.apps.resource.interop.aslp.Meta; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.constant.ProcessRuntimeConst; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang.StringUtils; + +import java.sql.Connection; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; + +public class SendOAAlsp implements ASLP { + + + @Override + @Meta(parameter = {"name:'processId',required:true,desc:'流程ID'", + "name:'taskId',required:true,desc:'任务ID'"}) + public ResponseObject call(Map map) { + ResponseObject ro = ResponseObject.newWarnResponse("结果未知"); + try { + String processId = String.valueOf(map.get("processId")); + String taskId = String.valueOf(map.get("taskId")); + String sid = String.valueOf(map.get("sid")); + Connection open = DBSql.open(); + + ProcessEndAfterEvent_new processEndAfterEventNew = new ProcessEndAfterEvent_new(); + + ProcessInstance processInstance = SDK.getProcessAPI().getInstanceById(processId); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(taskId); + if (processInstance != null && processInstance.getControlState().equals(ProcessRuntimeConst.INST_STATE_END) && taskInstance != null) { + processEndAfterEventNew.ProcessData(processInstance, taskInstance, open, sid); + } + + } catch (Exception e) { + e.printStackTrace(); + ro = ResponseObject.newErrResponse(e.getMessage()); + } + return ro; + } + + + + + +} 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 8a2f8ee5..d98c6dba 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 @@ -38,6 +38,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyMod import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb; import com.actionsoft.apps.coe.pal.publisher.client.util.ProcessStatusAPIManager; import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant; +import com.actionsoft.apps.coe.pal.publisher.utils.DeleteGptFilesUtils; import com.actionsoft.bpms.bo.engine.BO; import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener; @@ -244,7 +245,7 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme //更新部门视图 - updateDeptView(bolistN, bolistC, bolistS); + updateDeptView(bolistN, bolistC, bolistS,param); } @@ -254,11 +255,15 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme * @param bolistC * @param bolistS */ - public void updateDeptView(List bolistN, List bolistC, List bolistS){ + public void updateDeptView(List bolistN, List bolistC, List bolistS, ProcessExecutionContext param){ if (bolistN != null) { for (BO boN : bolistN) { String fileId = boN.getString("PUBLISHFILEID"); - DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5='1' WHERE ID='" + fileId + "'"); + int countEXT5=DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5='1' WHERE ID='" + fileId + "'"); + if(countEXT5==0){ + System.out.println("发布新增表模型id为="+fileId); + } + /** * 更新部门视图EXT6字段 */ @@ -292,7 +297,6 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5='0' WHERE ID='"+changefileId+"'"); DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5='1' WHERE ID='"+changefileIdNew+"'"); - /** * 更新部门视图EXT6字段 */ @@ -322,6 +326,39 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme String fileId = boS.get("STOPFILEID").toString(); DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5='0' WHERE ID='"+fileId+"'"); + + + + PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(fileId); + + DesignerShapeRelationModel designerShapeRelationModel=new DesignerShapeRelationModel(); + designerShapeRelationModel.setId(UUIDGener.getUUID()); + designerShapeRelationModel.setFileId(fileId); + designerShapeRelationModel.setAttrId("nullifier"); + designerShapeRelationModel.setRelationFileId("00000000-0000-0000-0000-000000000000"); + designerShapeRelationModel.setRelationShapeId("00000000-0000-0000-0000-000000000000"); + + JSONObject js=new JSONObject(); + js.put("name", param.getUserContext().getUserName()); + js.put("id",param.getUserContext().getUID()); + js.put("type", "user"); + + designerShapeRelationModel.setRelationShapeText(js.toString()); + + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + dao.insert(designerShapeRelationModel); + + PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao(); + //作废时间 + Date date=new Date(); + SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd"); + propertyDao.updatePropertyByPropertyId(fileId, "obsolescence_time", sdfs.format(date)); + + if (plModel != null) { + PALRepositoryCache.getCache().put(fileId, plModel); + } + + } } diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java index e3f7cb64..df108054 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java @@ -104,7 +104,6 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute Connection open = DBSql.open(); try { - if(isConfirmRelease==true){ ProcessInstance boProcessInstance = SDK.getProcessAPI() .createBOProcessInstance("obj_7946c848674f422fbe2817ad5d047337", ext.getUserContext().getUID(), "OA任务状态记录"); @@ -114,7 +113,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute executiveTaskBO.set("TASKSTATUS",1); executiveTaskBO.set("ISTASKEND",1); SDK.getBOAPI().create("BO_ACT_EXECUTIVE_TASK",executiveTaskBO,boProcessInstance.getId(),""); - ExecutorService service = Executors.newFixedThreadPool(1); + /* ExecutorService service = Executors.newFixedThreadPool(1); service.execute(new Runnable() { @Override public void run() { @@ -125,7 +124,37 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute e.printStackTrace(); } } - }); + });*/ + + + // 调用方 + String sourceAppId = "com.actionsoft.apps.coe.pal.publisher"; + // 服务地址 + String aslp = "aslp://com.actionsoft.apps.coe.pal.publisher/SendOAAlsp"; + Map params = new HashMap(); + // 给定必填参数 + params.put("processId", ext.getProcessInstance().getId()); + params.put("taskId", ext.getTaskInstance().getId()); + + AppAPI appApi = SDK.getAppAPI(); + //统一接口中心请求调用 + appApi.asynCallASLP(appApi.getAppContext(sourceAppId), aslp, params); + + + + + // 服务地址 + String kmsaslp = "aslp://com.actionsoft.apps.coe.pal.publisher/SendKMSAlsp"; + Map kmsparams = new HashMap(); + // 给定必填参数 + kmsparams.put("processId", ext.getProcessInstance().getId()); + kmsparams.put("sid", ext.getUserContext().getSessionId()); + + AppAPI kmsappApi = SDK.getAppAPI(); + //统一接口中心请求调用 + appApi.asynCallASLP(kmsappApi.getAppContext(sourceAppId), kmsaslp, params); + + } }catch (Exception e){ e.printStackTrace(); @@ -176,13 +205,12 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } - public void ProcessData(ProcessExecutionContext processExecutionContext,Connection open) throws Exception { - System.err.println(processExecutionContext.getTaskInstance().getTitle() + "_推送文件开始========>"); + public void ProcessData(ProcessInstance processInstance,TaskInstance taskInstance,Connection open,String sid) throws Exception { // http://localhost:8089/portal/r/or?cmd=com.hy_client_bpm_form_main_page_open&oauthName=oauthLogin&processInstId=3505e654-9217-41cd-a31d-4971846b3219 /** * 当流程不等于终止的时候往下走 */ - if (!"terminate".equals(processExecutionContext.getProcessInstance().getControlState())) { + if (!"terminate".equals(processInstance.getControlState())) { DownloadUtil downloadUtil = new DownloadUtil(); String wsId = ""; JSONArray filed = new JSONArray(new LinkedList<>()); @@ -194,21 +222,23 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute */ try { + //构建PC地址 String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" - + processExecutionContext.getProcessInstance().getId() + "&taskInstId=" - + processExecutionContext.getTaskInstance().getId(); + + processInstance.getId() + "&taskInstId=" + + taskInstance.getId(); + //构建移动端地址 String mobileurl = "https://bpm.yili.com:8088/portal" + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" - + processExecutionContext.getProcessInstance().getId() + "&taskInstId=" - + processExecutionContext.getTaskInstance().getId(); + + processInstance.getId() + "&taskInstId=" + + taskInstance.getId(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - //Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime(); + //Timestamp endTime = taskInstance.getBeginTime(); Timestamp endTime = new Timestamp(System.currentTimeMillis()); BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).connection(open) - .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) + .addQuery("BINDID=", processInstance.getId()) .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); // ProcessExecutionContext processExecutionContext,String fileCreateName,String @@ -216,49 +246,55 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // fileCreateDate,String relationProcessinstId,String readingScope_post,String // readingScope_level,String fileid String not_url = "/w?cmd=com.yili_process_page&processInstId=" - + processExecutionContext.getProcessInstance().getId() + "&taskInstId=" - + processExecutionContext.getTaskInstance().getId(); - execute(processExecutionContext, boActCoePublish.getString("APPLYUSERNAME"), + + processInstance.getId() + "&taskInstId=" + + taskInstance.getId(); + + //创建XPage页面上的待阅文件 + execute(processInstance, boActCoePublish.getString("APPLYUSERNAME"), boActCoePublish.getString("PROCESS_TITLE"), not_url, boActCoePublish.getString("SEND_SCOPE_ORG"), boActCoePublish.getString("SEND_SCOP"), - boActCoePublish.getString("APPLYDATE"), processExecutionContext.getProcessInstance().getId(), + boActCoePublish.getString("APPLYDATE"), processInstance.getId(), boActCoePublish.getString("SEND_SCOPE_POST"), boActCoePublish.getString("SEND_SCOPE_LEVEL"), "1"); + //开始构建OA待阅请求体 JSONObject jsonObject = new JSONObject(new LinkedHashMap()); jsonObject.put("action", "read"); jsonObject.put("title", " " + "" + boActCoePublish.getString("PROCESS_TITLE") + ""); jsonObject.put("dept", SDK.getORGAPI() - .getDepartmentByUser(processExecutionContext.getTaskInstance().getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() - String target = processExecutionContext.getTaskInstance().getTarget(); - target = processExecutionContext.getTaskInstance().getTarget(); + .getDepartmentByUser(taskInstance.getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processInstance.getCreateUser()).getNo() + String target = taskInstance.getTarget(); + target = taskInstance.getTarget(); jsonObject.put("user", target); - // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + // jsonObject.put("user",);//processInstance.getCreateUser() jsonObject.put("date", sdf.format(endTime)); jsonObject.put("remark", boActCoePublish.getString("PROCESS_TITLE")); jsonObject.put("status", "0"); - jsonObject.put("dataid", processExecutionContext.getProcessInstance().getId()); + jsonObject.put("dataid", processInstance.getId()); jsonObject.put("pcurl", url); jsonObject.put("mobileurl", mobileurl); // list.add(1,"00352394"); // list.add(2,"00352394"); BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).connection(open) - .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) + .addQuery("BINDID=", processInstance.getId()) .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); String crateUserId = target; String new_uid = ""; + //查询发布表数据 BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) - .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) + .addQuery("BINDID=", processInstance.getId()) .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); // 流程发布的新增发布 List bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).connection(open) - .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list(); + .addQuery("BINDID=", processInstance.getId()).list(); + // 流程发布的变更发布 List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).connection(open) - .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list(); + .addQuery("BINDID=", processInstance.getId()).list(); + // 流程发布的废止变更 List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).connection(open) - .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list(); + .addQuery("BINDID=", processInstance.getId()).list(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); JSONArray jsonArray = new JSONArray(); @@ -268,7 +304,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * 推送待阅文件到OA */ if ("true".equals(isSendOA)) { - ProcessInstance instanceById = processExecutionContext.getProcessInstance(); + ProcessInstance instanceById = processInstance; if (bo_act_coe_publish1 != null && instanceById != null) { long sendUserstartTime = System.currentTimeMillis(); ArrayList sendList = new ArrayList(); @@ -329,7 +365,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute for (BO uid:bo_eu_oa_read_test) { sendLists.add(uid.getString("USER_ID")); }*/ - String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + processExecutionContext.getProcessInstance().getId() + String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + processInstance.getId() + "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' "; String taskInd = DBSql.getString(sql); @@ -341,7 +377,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute for (String uid: users) { BO bo = new BO(); bo.set("USER_ID",uid); - bo.set("PROCESSID",processExecutionContext.getProcessInstance().getId()); + bo.set("PROCESSID",processInstance.getId()); bo.set("USERID",ta.getTarget()); bo.set("DEPARTMENT",UserContext.fromUID(ta.getTarget()).getDepartmentModel().getId()); bo.set("PROCESS_TITLE",bo_act_coe_publish1.getString("PROCESS_TITLE")); @@ -372,7 +408,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 创建线程发送待阅数据 */ - course(list,startTime,jsonObject,processExecutionContext,sendList); + course(list,startTime,jsonObject,processInstance,sendList,sid); //System.out.println("发送人员数据>>>>>>>>>>>>>>"+list); }else { int size = users.length/length; @@ -391,371 +427,22 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 创建线程发送待阅数据 */ - course(list,startTime,jsonObject,processExecutionContext,sendList); + course(list,startTime,jsonObject,processInstance,sendList,sid); //System.out.println("发送人员数据>>>>>>>>>>>>>>"+list); } - - - - /*int toIndex = 200; - int listSize = sendList.size(); - boolean shutdown = false; - - for (int i = 0; i < sendList.size(); i += 200) { - long startTime1 = System.currentTimeMillis(); - if (i + 200 > listSize) { - toIndex = listSize - i; - } - List idList = sendList.subList(i, i + toIndex); - try { - - BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processExecutionContext.getProcessInstance().getId()).addQuery("TASKSTATUS=",2).detail(); - if(executiveTaskBO!=null){ - List recordFailLists = new ArrayList(); - String userIds = StringUtils.join(idList, ","); - String[] userIdsArray=userIds.split(","); - for(String oneuserId:userIdsArray){ - BO bo = new BO(); - bo.set("TITLE", processExecutionContext.getProcessInstance().getTitle()); - bo.set("NAME", oneuserId); - bo.set("TYPE", "批量推送"); - bo.set("RESULT", "待处理"); - bo.set("PROCESSID", processExecutionContext.getProcessInstance().getId()); - bo.set("DEPNAME", SDK.getORGAPI().getUser(oneuserId).getDepartmentId()); - recordFailLists.add(bo); - //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processExecutionContext.getProcessInstance().getId(), processExecutionContext.getProcessInstance().getCreateUser()); - } - SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processExecutionContext.getProcessInstance().getId(), processExecutionContext.getProcessInstance().getCreateUser()); - return; - } - - - SendOARead(jsonObject, instanceById, idList, "批量推送"); - } catch (Exception e) { - - System.out.println("OA待阅推送exception======"+e); - - - // TODO: handle exception - } - long endTimes1 = System.currentTimeMillis(); - - System.err.println(instanceById.getTitle() + "单次300条推送单条====>" + "用时:" - + (endTimes1 - startTime1) / 1000 + "秒"); - - *//* - * ExecutorService cachedThreadPool = Executors.newFixedThreadPool(3); // 开启一个线程 - * cachedThreadPool.execute(new Runnable() { - * - * @Override public void run() { try { } catch (DocumentException e) { // TODO - * Auto-generated catch block e.printStackTrace(); } - * - * } }); - *//* - // 以下是等线程池的全部线程执行结束后,会自动执行。 - *//* - * cachedThreadPool.shutdown(); while (true) { if - * (cachedThreadPool.isTerminated()) { long time = System.currentTimeMillis() - - * startTime; //System.out.println("程序结束了,总耗时:" + time + " ms(毫秒)!\n"+toIndex); - * break; } } - *//* - - }*/ - } } - /** - * 推送到知识库 - */ - if ("true".equals(isSendKMS)) { - try { - // 发布到知识库 - int m = 0; - for (BO bo : bo_act_coe_publish_n) { - createKmsByNew(bo, wsId, filed, processExecutionContext, bo_act_coe_publish, new_uid); - } - // 更新知识库 - for (BO bo : bo_act_coe_publish_c) { - CreateKmsByupdate(bo, wsId, filed, processExecutionContext, bo_act_coe_publish, - new_uid); - } - - // 废止知识库文件 - for (BO bo : bo_act_coe_publish_s) { - // 将旧的知识取消发布或者移动到废止发布中 - String publishfileid_stop = bo.getString("STOPFILEID"); - filed.add(publishfileid_stop); - String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_stop - + "'"; - RowMap map1 = DBSql.getMap(open,sql_s); - if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { - CancelPublishKnwl(processExecutionContext, - processExecutionContext.getUserContext().getSessionId(), - map1.getString("EXT4")); - - DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" - + publishfileid_stop + "'"); - } - } - } catch (Exception e) { - // TODO: handle exception - } - } - - /** - * 同步PAL文件表文件版本标识,用于部门视图 - */ - if(bo_act_coe_publish_n.size()>0) { - for (BO bo : bo_act_coe_publish_n) { - try { - String fileId = bo.getString("PUBLISHFILEID"); - - /*RowMap rowMap = DBSql - .getMap("SELECT * FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID=" +fileId+""); - - OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); - if (model != null) { - OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); - if (appProfile == null) { - throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); - } - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), - OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException( - "Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - String sql_lever = sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" - + rowMap.getString("PUBLISHFILEID") + "'"; - String lever = DBSql.getString(sql_lever); - if (lever.length() == 5 && lever.substring(4).equals("0")) { - lever.substring(0, 3); - } else if (lever.length() == 1) { - lever = lever + ".0"; - } - String filename = rowMap.getString("PUBLISHFILENAME"); - - DCContext dcContext = new DCContext(processExecutionContext.getUserContext(), dcProfile, appProfile.getAppContext().getId(), - model.getWsId(), rowMap.getString("TASKID"), filename + "_" + lever + ".doc"); - String filepath = dcContext.getFilePath(); - String finalFilePath = filepath.replace("bin\\..\\", ""); - - - JSONObject result=JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl,appkey,requestCode,dcContext.getFilePath())); - - if(result.getString("msg").equals("success")){ - String data=result.getString("data"); - //插入模型ID与DOCID对应表中 - BO gptBO=new BO(); - gptBO.set("plid",fileId); - gptBO.set("docid",data); - - ProcessInstance boProcessInstance = SDK.getProcessAPI() - .createBOProcessInstance("obj_08d91b102a514d49b5b42ed439de94c4", processExecutionContext.getUserContext().getUID(), "GPT文件"); - - SDK.getBOAPI().create("BO_EU_GPT_DOCFILE", gptBO, boProcessInstance.getId(), processExecutionContext.getProcessInstance().getCreateUser()); - } - }*/ - - - - - } catch (Exception e) { - } - } - } - if(bo_act_coe_publish_c.size()>0) { - for (BO bo : bo_act_coe_publish_c) { - try { - String changefileId = bo.getString("CHANGEFILEID"); - String changefileIdNew = bo.getString("CHANGEDFILEIDNEW"); - - //先查找旧文件 - /*BO docfile= SDK.getBOAPI().query("BO_EU_GPT_DOCFILE").addQuery("PLID=", changefileId).detail(); - if(docfile!=null){ - String docid=docfile.getString("DOCID"); - - JSONObject jsonRequest=new JSONObject(); - - jsonRequest.put("requestCode",requestCode); - jsonRequest.put("docId",docid); - - String deleteResult=DeleteGptFilesUtils.deleteGptFiles(deleteGptUrl,jsonRequest.toJSONString(),appkey); - - SDK.getBOAPI().remove("BO_EU_GPT_DOCFILE",docfile.getId()); - - - RowMap rowMap = DBSql - .getMap("SELECT * FROM BO_ACT_COE_PUBLISH_C WHERE PUBLISHFILEID=" +changefileIdNew+""); - - OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); - if (model != null) { - OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); - if (appProfile == null) { - throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); - } - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), - OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException( - "Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - String sql_lever = sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" - + rowMap.getString("CHANGEDFILEIDNEW") + "'"; - - String lever = DBSql.getString(sql_lever); - // lever = lever.substring(0,3); - if (lever.length() == 5 && lever.substring(4).equals("0")) { - lever.substring(0, 3); - } else if (lever.length() == 1) { - lever = lever + ".0"; - } - String filename = rowMap.getString("CHANGEDFILENAMENEW"); - DCContext dcContext = new DCContext(processExecutionContext.getUserContext(), dcProfile, appProfile.getAppContext().getId(), - model.getWsId(), rowMap.getString("TASKID"), filename + "_" + lever + ".doc"); - - - String filepath = dcContext.getFilePath(); - String finalFilePath = filepath.replace("bin\\..\\", ""); - - JSONObject result=JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl,appkey,requestCode,dcContext.getFilePath())); - - if(result.getString("msg").equals("success")){ - String data=result.getString("data"); - //插入模型ID与DOCID对应表中 - BO gptBO=new BO(); - gptBO.set("plid",changefileIdNew); - gptBO.set("docid",data); - - ProcessInstance boProcessInstance = SDK.getProcessAPI() - .createBOProcessInstance("obj_08d91b102a514d49b5b42ed439de94c4", processExecutionContext.getUserContext().getUID(), "GPT文件"); - - - SDK.getBOAPI().create("BO_EU_GPT_DOCFILE", gptBO, boProcessInstance.getId(), processExecutionContext.getProcessInstance().getCreateUser()); - } - - } - - - }*/ - - - } catch (Exception e) { - } - } - } - - if(bo_act_coe_publish_s.size()>0) { - for (BO bo : bo_act_coe_publish_s) { - try { - String fileId = bo.getString("STOPFILEID"); - - - PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(fileId); - - DesignerShapeRelationModel designerShapeRelationModel=new DesignerShapeRelationModel(); - designerShapeRelationModel.setId(UUIDGener.getUUID()); - designerShapeRelationModel.setFileId(fileId); - designerShapeRelationModel.setAttrId("nullifier"); - designerShapeRelationModel.setRelationFileId("00000000-0000-0000-0000-000000000000"); - designerShapeRelationModel.setRelationShapeId("00000000-0000-0000-0000-000000000000"); - - JSONObject js=new JSONObject(); - js.put("name", processExecutionContext.getUserContext().getUserName()); - js.put("id",processExecutionContext.getUserContext().getUID()); - js.put("type", "user"); - - designerShapeRelationModel.setRelationShapeText(js.toString()); - - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - dao.insert(designerShapeRelationModel); - - PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao(); - //作废时间 - Date date=new Date(); - SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd"); - propertyDao.updatePropertyByPropertyId(fileId, "obsolescence_time", sdfs.format(date)); - - if (plModel != null) { - PALRepositoryCache.getCache().put(fileId, plModel); - } - - - BO docfile= SDK.getBOAPI().query("BO_EU_GPT_DOCFILE").addQuery("PLID=", fileId).detail(); - if(docfile!=null) { - String docid = docfile.getString("DOCID"); - JSONObject jsonRequest=new JSONObject(); - jsonRequest.put("requestCode",requestCode); - jsonRequest.put("docId",docid); - DeleteGptFilesUtils.deleteGptFiles(deleteGptUrl,jsonRequest.toJSONString(),appkey); - - SDK.getBOAPI().remove("BO_EU_GPT_DOCFILE",docfile.getId()); - } - - - - } catch (Exception e) { - } - } - } - - - /** - * 推送到EHSQ - */ - boolean sendEhqs = false; - String depId = processExecutionContext.getUserContext().getDepartmentModel().getId(); - //获取EHSQ配置表判断是否发送 - String sql = "SELECT * FROM BO_ACT_ACT_ESQ_SEND"; - List maps = DBSql.getMaps(open,sql); - for (RowMap rowMap : maps) { - String dempet = rowMap.getString("DEMPET"); - String issend = rowMap.getString("ISSEND"); - DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(dempet); - if(departmentById!=null) { - String departemenId = departmentById.getId(); - String pathIdOfCache=departmentById.getPathIdOfCache(); - if(departemenId.equals(depId)&&"是".equals(issend)) { - sendEhqs = true; - } else { - List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); - for (DepartmentModel departmentModel : subDepartments) { - String subDeartmentId = departmentModel.getId(); - if (subDeartmentId.equals(depId) && "是".equals(issend)) { - sendEhqs = true; - } - } - - } - - } - } - if(!sendEhqs) { - System.err.println("本次发文不推送EHSQ====>"+processExecutionContext.getProcessInstance().getTitle()); - } - if ("true".equals(isSendEHSQ)&&sendEhqs) { - try { - // 推送EHSQ - if(bo_act_coe_publish_n.size()>0) { - sendEHSQ(processExecutionContext, bo_act_coe_publish_n); - } - // 更新EHSQ - if(bo_act_coe_publish_c.size()>0) { - updateEHSQ(processExecutionContext, bo_act_coe_publish_c); - } - } catch (Exception e) { - // TODO: handle exception - } - } /** * 更新数据看板底表 */ try { - AttrSynAslp(processExecutionContext, wsId, filed); + AttrSynAslp(processInstance, wsId, filed); } catch (Exception e) { } @@ -776,9 +463,9 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @return */ - public boolean createIndexesByContent(ProcessExecutionContext processExecutionContext,JSONArray contents) { + public boolean createIndexesByContent(ProcessInstance processInstance,JSONArray contents) { // 调用App - String sourceAppId =processExecutionContext.getProcessInstance().getAppId() ; + String sourceAppId =processInstance.getAppId() ; // aslp服务地址 String aslp = "aslp://com.actionsoft.apps.addons.es/createIndexesByContent"; // 参数定义列表 @@ -803,9 +490,9 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param jsonObject * @param processExecutionContext */ - public void course(List list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext,ArrayList sendList) throws InterruptedException { + public void course(List list,long startTime,JSONObject jsonObject,ProcessInstance processInstance,ArrayList sendList,String sid) throws InterruptedException { // 创建线程来实现为每100人为一个的线程跑待阅 - ProcessInstance instanceById = processExecutionContext.getProcessInstance(); + ProcessInstance instanceById = processInstance; CountDownLatch countDownLatch = new CountDownLatch(list.size()); ExecutorService service = Executors.newFixedThreadPool(4); int m = 0; @@ -819,7 +506,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute String userIds = ""; userIds = StringUtils.join(resrt, ","); try { - SendOARead( processExecutionContext.getProcessInstance(), userIds,"批量推送"); + SendOARead(processInstance, userIds,"批量推送"); countDownLatch.countDown(); } catch (DocumentException e) { e.printStackTrace(); @@ -842,24 +529,24 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute ArrayList secondUserList = new ArrayList(); secondUserList.add(rowMap.getString("NAME")); - BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processExecutionContext.getProcessInstance().getId()).addQuery("TASKSTATUS=",2).detail(); + BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processInstance.getId()).addQuery("TASKSTATUS=",2).detail(); if(executiveTaskBO!=null){ List recordFailLists = new ArrayList(); for(RowMap oneuserId:List){ BO bo = new BO(); - bo.set("TITLE", processExecutionContext.getProcessInstance().getTitle()); + bo.set("TITLE", processInstance.getTitle()); bo.set("NAME", oneuserId.getString("NAME")); bo.set("TYPE", "批量推送"); bo.set("RESULT", "待处理"); - bo.set("PROCESSID", processExecutionContext.getProcessInstance().getId()); + bo.set("PROCESSID", processInstance.getId()); bo.set("DEPNAME", SDK.getORGAPI().getUser(oneuserId.getString("NAME")).getDepartmentId()); recordFailLists.add(bo); } - SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processExecutionContext.getProcessInstance().getId(), processExecutionContext.getProcessInstance().getCreateUser()); + SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processInstance.getId(), processInstance.getCreateUser()); return; } - secondSendOARead(processExecutionContext.getProcessInstance(), secondUserList, "单个账号推送"); + secondSendOARead(processInstance, secondUserList, "单个账号推送"); } catch (Exception e) { // TODO: handle exception } } @@ -868,7 +555,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute long endTimes = System.currentTimeMillis(); // 存入日志 - createReadLog(processExecutionContext, jsonObject, sendList, startTime, endTimes); + createReadLog(processInstance, jsonObject, sendList, startTime, endTimes,sid); System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:" + (endTimes - startTime) / 1000 / 60 + "分钟"); @@ -893,12 +580,12 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param cardId * @param fileid */ - public void creadteFile(ProcessExecutionContext processExecutionContext, String bo_name, UserContext userContext, + public void creadteFile(ProcessInstance processInstance, String bo_name, UserContext userContext, String cardId, String fileid) { /** * 这个主要是负责对流程手册进行相关的文件的生成 */ - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + String sourceAppId =processInstance.getAppId(); // aslp服务地址 String aslp = "aslp://com.actionsoft.apps.kms/CreateFile"; @@ -968,7 +655,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute jsonObject.put("abstract", dcContext);//信息摘要 jsonObject.put("title", dcContext.getFileName().substring(0,dcContext.getFileName().indexOf(".")));//信息标题 coontest.add(jsonObject); - createIndexesByContent(processExecutionContext,coontest); + createIndexesByContent(processInstance,coontest); } } @@ -1016,14 +703,14 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute jsonObject.put("abstract", dcContexts);//信息摘要 jsonObject.put("title", dcContexts.getFileName().substring(0,dcContexts.getFileName().indexOf(".")));//信息标题 coontest.add(jsonObject); - createIndexesByContent(processExecutionContext,coontest); + createIndexesByContent(processInstance,coontest); } } } try { - PublishKnow(processExecutionContext, userContext, cardId); + PublishKnow(processInstance, userContext, cardId); } catch (Exception e) { e.printStackTrace(); } @@ -1037,7 +724,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param userContext * @param id */ - public void PublishKnow(ProcessExecutionContext processExecutionContext, UserContext userContext, String id) { + public void PublishKnow(ProcessInstance processInstance, UserContext userContext, String id) { String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '" + id + "')"; @@ -1064,7 +751,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute if (!jsonArray_das.isEmpty() && !jsonArray.isEmpty()) { // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + String sourceAppId = processInstance.getAppId(); // aslp服务地址 String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; // 参数定义列表 @@ -1094,9 +781,9 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param knwlId * @return */ - public boolean CancelPublishKnwl(ProcessExecutionContext processExecutionContext, String sid, String knwlId) { + public boolean CancelPublishKnwl(ProcessInstance processInstance, String sid, String knwlId) { // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + String sourceAppId = processInstance.getAppId(); // aslp服务地址 String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl"; // 参数定义列表 @@ -1127,11 +814,11 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param fileid * @return */ - public boolean execute(ProcessExecutionContext processExecutionContext, String fileCreateName, String fileName, + public boolean execute(ProcessInstance processInstance, String fileCreateName, String fileName, String fileurl, String readingScope_org, String isFullCompany, String fileCreateDate, String relationProcessinstId, String readingScope_post, String readingScope_level, String fileid) { // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + String sourceAppId = processInstance.getAppId(); // aslp服务地址 String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage"; // 参数定义列表 @@ -1171,11 +858,11 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param knwlId * @return */ - public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid, + public boolean AddKnwlAC(ProcessInstance processInstance, JSONArray jsonArray, String sid, String knwlId) { // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + String sourceAppId =processInstance.getAppId(); // aslp服务地址 String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; // 参数定义列表 @@ -1200,10 +887,10 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param fileId * @return */ - public boolean AttrSynAslp(ProcessExecutionContext processExecutionContext, String wsId, JSONArray fileId) { + public boolean AttrSynAslp(ProcessInstance processInstance, String wsId, JSONArray fileId) { System.out.println(""); // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + String sourceAppId = processInstance.getAppId(); // aslp服务地址 String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp"; // 参数定义列表 @@ -1259,7 +946,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute + taskInd; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - //Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime(); + //Timestamp endTime = taskInstance.getBeginTime(); Timestamp endTime = new Timestamp(System.currentTimeMillis()); JSONObject jsonObjects = new JSONObject(new LinkedHashMap()); @@ -1464,7 +1151,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute + taskInd; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - //Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime(); + //Timestamp endTime = taskInstance.getBeginTime(); Timestamp endTime = new Timestamp(System.currentTimeMillis()); JSONObject jsonObjects = new JSONObject(new LinkedHashMap()); @@ -1906,13 +1593,14 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param startTime */ - public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject, - ArrayList arr, long startTime, long endTimes) { + public void createReadLog(ProcessInstance processInstance, JSONObject jsonObject, + ArrayList arr, long startTime, long endTimes,String sid) { + UserContext uc=UserContext.fromSessionId(sid); BO bo_Read_log = new BO(); - String processInstId = processExecutionContext.getProcessInstance().getId(); - bo_Read_log.set("USREID", processExecutionContext.getUserContext().getUID()); - bo_Read_log.set("DEPID", processExecutionContext.getUserContext().getDepartmentModel().getId()); - bo_Read_log.set("BUNAME", processExecutionContext.getUserContext().getUserModel().getExt4()); + String processInstId =processInstance.getId(); + bo_Read_log.set("USREID", uc.getUID()); + bo_Read_log.set("DEPID", uc.getDepartmentModel().getId()); + bo_Read_log.set("BUNAME", uc.getUserModel().getExt4()); bo_Read_log.set("TITLE", jsonObject.get("title")); bo_Read_log.set("PROCESSID", processInstId); bo_Read_log.set("SENDNUM", arr.size()); @@ -1990,8 +1678,8 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param bo_act_coe_publish 发布表 * @param uid 账户合计 */ - public void createKmsByNew(BO bo, String wsId, JSONArray filed, ProcessExecutionContext processExecutionContext, - BO bo_act_coe_publish, String uid) { + public void createKmsByNew(BO bo, String wsId, JSONArray filed, ProcessInstance processInstance, + BO bo_act_coe_publish, String uid,String sid) { { OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); wsId = model.getWsId(); @@ -2036,11 +1724,11 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute //知识内容,非必填 params_create.put("cardContext", ""); //sid,必填 - params_create.put("sid", processExecutionContext.getUserContext().getSessionId()); + params_create.put("sid", sid); AppAPI appAPI_create = SDK.getAppAPI(); //创建知识 ResponseObject ro_create = appAPI_create.callASLP( - appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), + appAPI_create.getAppContext(processInstance.getAppId()), aslps_create, params_create); String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); JSONArray jsonArray1 = new JSONArray(); @@ -2081,7 +1769,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } - AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), + AddKnwlAC(processInstance, jsonArray1, sid, cardId); String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " @@ -2095,8 +1783,9 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'"; int update = DBSql.update(update_sql); + System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update); - creadteFile(processExecutionContext, "BO_ACT_COE_PUBLISH_N", processExecutionContext.getUserContext(), + creadteFile(processInstance, "BO_ACT_COE_PUBLISH_N",UserContext.fromSessionId(sid), cardId, "PUBLISHFILEID = "); } } @@ -2112,8 +1801,8 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param bo_act_coe_publish 发布表 * @param uid 账户集合 */ - public void CreateKmsByupdate(BO bo, String wsId, JSONArray filed, ProcessExecutionContext processExecutionContext, - BO bo_act_coe_publish, String uid) { + public void CreateKmsByupdate(BO bo, String wsId, JSONArray filed, ProcessInstance processInstance, + BO bo_act_coe_publish, String uid,String sid) { { OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); wsId = model.getWsId(); @@ -2159,11 +1848,11 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute //知识内容,非必填 params_create.put("cardContext", ""); //sid,必填 - params_create.put("sid", processExecutionContext.getUserContext().getSessionId()); + params_create.put("sid", sid); AppAPI appAPI_create = SDK.getAppAPI(); //创建知识 ResponseObject ro_create = appAPI_create.callASLP( - appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), + appAPI_create.getAppContext(processInstance.getAppId()), aslps_create, params_create); // System.out.println("ro_create================" + ro_create); String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); @@ -2205,7 +1894,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } } - AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), + AddKnwlAC(processInstance, jsonArray1, sid, cardId); String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " @@ -2220,7 +1909,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'"; int update = DBSql.update(update_sql); System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update); - creadteFile(processExecutionContext, "BO_ACT_COE_PUBLISH_C", processExecutionContext.getUserContext(), + creadteFile(processInstance, "BO_ACT_COE_PUBLISH_C", UserContext.fromSessionId(sid), cardId, " CHANGEDFILEIDNEW="); } // 将旧的知识取消发布或者移动到废止发布中 @@ -2228,7 +1917,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute String sql_c = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_old + "'"; RowMap map1 = DBSql.getMap(sql_c); if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { - CancelPublishKnwl(processExecutionContext, processExecutionContext.getUserContext().getSessionId(), + CancelPublishKnwl(processInstance, sid, map1.getString("EXT4")); DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_old + "'"); } @@ -2249,7 +1938,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG", bo, UserContext.fromUID("admin")); } - public void sendEHSQ(ProcessExecutionContext processExecutionContext, List bo_act_coe_publish_n) { + public void sendEHSQ(ProcessInstance processInstance, List bo_act_coe_publish_n,TaskInstance taskInstance,String sid) { for (BO bo : bo_act_coe_publish_n) { DownloadUtil downloadUtil = new DownloadUtil(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); @@ -2259,7 +1948,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute String wsId = model.getWsId(); String publishfileid = bo.getString("PUBLISHFILEID"); LinkedHashMap downloadurl = downloadUtil.outputReportDownload( - UserContext.fromUID(processExecutionContext.getProcessInstance().getCreateUser()), + UserContext.fromUID(processInstance.getCreateUser()), bo.getString("TASKID"), publishfileid); jsonObject_ehsq.put("fileid", bo.getString("TASKID")); String plName = bo.getString("PUBLISHFILENAME"); @@ -2271,7 +1960,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute RowMap map = DBSql.getMap(sql_n); PALRepositoryModel palRepositoryModel = PALRepositoryCache.getCache().get(publishfileid); jsonObject_ehsq.put("version", "V"+palRepositoryModel.getVersion()+""); - BO byProcess = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", processExecutionContext.getProcessInstance().getId()); + BO byProcess = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", processInstance.getId()); String cdeDate = byProcess.getString("CHOICEEFFECTIVEDATE"); if("1".equals(cdeDate)) { jsonObject_ehsq.put("releasedate", byProcess.getString("EFFECTIVEDATE")); @@ -2280,15 +1969,15 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute jsonObject_ehsq.put("releasedate", simpleDateFormat.format(new Date())); jsonObject_ehsq.put("effectivedate", simpleDateFormat.format(new Date())); } - jsonObject_ehsq.put("authorcode", processExecutionContext.getTaskInstance().getTarget()); // jsonObject_ehsq.put("authorcode","00116465"); + jsonObject_ehsq.put("authorcode", taskInstance.getTarget()); // jsonObject_ehsq.put("authorcode","00116465"); jsonObject_ehsq.put("authorname", - UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + UserContext.fromUID(taskInstance.getTarget()).getUserName()); // jsonObject_ehsq.put("authorname","毛鹏程"); jsonObject_ehsq.put("companycode", UserContext - .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + .fromUID(taskInstance.getTarget()).getDepartmentModel().getNo()); // jsonObject_ehsq.put("companycode","00000013"); jsonObject_ehsq.put("authorcompany", UserContext - .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); // jsonObject_ehsq.put("authorcompany","总部质量管理部"); + .fromUID(taskInstance.getTarget()).getDepartmentModel().getName()); // jsonObject_ehsq.put("authorcompany","总部质量管理部"); // // BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) .addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); @@ -2323,7 +2012,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute //System.out.println("任务办理者>>>>>>>>>>>" + processExecutionContext.getTaskInstance().getTarget()); String sessionId = new SSOUtil().registerClientSessionNoPassword( - processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", + taskInstance.getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); //System.out.println("办理者的sessionid>>>>>>>>>>>" + sessionId); @@ -2365,13 +2054,13 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute Date date = new Date(); SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - UserContext uc = processExecutionContext.getUserContext(); + UserContext uc = UserContext.fromSessionId(sid); String userName = uc.getUserName(); try { String sql = "SELECT ID FROM BO_EU_PAL_SEND_EHSQ_JOB WHERE PLID = '"+publishfileid+"' AND USERNAMES = '"+userName+"'"; String id = DBSql.getString(sql); String sendEHSQFile = SendEHSQFile(plName,jsonArray_EHSQ); - System.err.println("EHSQ流程发布推送结果====>"+processExecutionContext.getProcessInstance().getTitle()+"=========>"+sendEHSQFile); + System.err.println("EHSQ流程发布推送结果====>"+processInstance.getTitle()+"=========>"+sendEHSQFile); if(UtilString.isNotEmpty(id)) { BO bos = SDK.getBOAPI().get("BO_EU_PAL_SEND_EHSQ_JOB", id); updateSendLog(bos,userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布推送", sendEHSQFile); @@ -2410,7 +2099,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute bo.set("SENDRESULT", sendResult); SDK.getBOAPI().update("BO_EU_PAL_SEND_EHSQ_JOB", bo); } - public void updateEHSQ(ProcessExecutionContext processExecutionContext, List bo_act_coe_publish_c) { + public void updateEHSQ(ProcessInstance processInstance, List bo_act_coe_publish_c,TaskInstance taskInstance,String sid) { DownloadUtil downloadUtil = new DownloadUtil(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); for (BO bo : bo_act_coe_publish_c) { @@ -2420,7 +2109,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute String wsId = model.getWsId(); String publishfileid = bo.getString("CHANGEDFILEIDNEW"); LinkedHashMap downloadurl = downloadUtil.outputReportDownload( - UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), bo.getString("TASKID"), + UserContext.fromUID(taskInstance.getTarget()), bo.getString("TASKID"), publishfileid); jsonObject_ehsq.put("fileid", bo.getString("TASKID")); String plName = bo.getString("CHANGEDFILENAMENEW"); @@ -2432,7 +2121,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute RowMap map = DBSql.getMap(sql_n); PALRepositoryModel palRepositoryModel = PALRepositoryCache.getCache().get(publishfileid); jsonObject_ehsq.put("version", "V"+palRepositoryModel.getVersion()+""); - BO byProcess = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", processExecutionContext.getProcessInstance().getId()); + BO byProcess = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", processInstance.getId()); String cdeDate = byProcess.getString("CHOICEEFFECTIVEDATE"); if("1".equals(cdeDate)) { jsonObject_ehsq.put("releasedate", byProcess.getString("EFFECTIVEDATE")); @@ -2441,13 +2130,13 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute jsonObject_ehsq.put("releasedate", simpleDateFormat.format(new Date())); jsonObject_ehsq.put("effectivedate", simpleDateFormat.format(new Date())); } - jsonObject_ehsq.put("authorcode", processExecutionContext.getTaskInstance().getTarget()); + jsonObject_ehsq.put("authorcode", taskInstance.getTarget()); jsonObject_ehsq.put("authorname", - UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + UserContext.fromUID(taskInstance.getTarget()).getUserName()); jsonObject_ehsq.put("companycode", UserContext - .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + .fromUID(taskInstance.getTarget()).getDepartmentModel().getNo()); jsonObject_ehsq.put("authorcompany", UserContext - .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + .fromUID(taskInstance.getTarget()).getDepartmentModel().getName()); BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) .addQuery("PALNAME=", bo.getString("CHANGEDFILENAMENEW")).detail(); if (bo1 != null) { @@ -2479,7 +2168,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } String sessionId = new SSOUtil().registerClientSessionNoPassword( - processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", + taskInstance.getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), @@ -2519,13 +2208,13 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute jsonArray_EHSQ.add(jsonObject_ehsq); Date date = new Date(); SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - UserContext uc = processExecutionContext.getUserContext(); + UserContext uc = UserContext.fromSessionId(sid); String userName = uc.getUserName(); try { String sql = "SELECT ID FROM BO_EU_PAL_SEND_EHSQ_JOB WHERE PLID = '"+publishfileid+"' AND USERNAMES = '"+userName+"'"; String id = DBSql.getString(sql); String sendEHSQFile = SendEHSQFile(plName,jsonArray_EHSQ); - System.err.println("EHSQ流程发布更新===>"+processExecutionContext.getProcessInstance().getTitle()+"==========>"+sendEHSQFile); + System.err.println("EHSQ流程发布更新===>"+processInstance.getTitle()+"==========>"+sendEHSQFile); if(UtilString.isNotEmpty(id)) { BO bos = SDK.getBOAPI().get("BO_EU_PAL_SEND_EHSQ_JOB", id); updateSendLog(bos,userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布更新", sendEHSQFile); @@ -2749,4 +2438,6 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } } + + }