From 98544e49b761dc6fbc75327e3da4152317642d99 Mon Sep 17 00:00:00 2001 From: zhal <15900249928@163.com> Date: Wed, 18 Oct 2023 15:18:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E7=9F=A5=E8=AF=86=E5=BA=93=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=AD=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=91=E9=80=81=E5=85=A8?= =?UTF-8?q?=E5=85=AC=E5=8F=B8=E5=88=99=E6=8E=88=E6=9D=83=E5=85=AC=E5=8F=B8?= =?UTF-8?q?id=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pubEvent/ProcessEndAfterEvent_new.java | 4156 +++++++++-------- 1 file changed, 2083 insertions(+), 2073 deletions(-) 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 07ec752a..ff4e07cf 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 @@ -60,297 +60,297 @@ import org.xml.sax.InputSource; */ @SuppressWarnings("all") public class ProcessEndAfterEvent_new extends ExecuteListener implements ExecuteListenerInterface { - private String isSendEHSQ = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendEHSQ"); - private String isSendOA = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendOA"); - private String isSendKMS = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendKMS"); + private String isSendEHSQ = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendEHSQ"); + private String isSendOA = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendOA"); + private String isSendKMS = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendKMS"); - private int sendTotal; + private int sendTotal; - @Override - public String getDescription() { - return "确认发布节点任务完成后推送OA/EHSQ/KMS"; - } + @Override + public String getDescription() { + return "确认发布节点任务完成后推送OA/EHSQ/KMS"; + } - @Override - public String getVersion() { - return "1.0"; - } + @Override + public String getVersion() { + return "1.0"; + } - @Override - public void execute(ProcessExecutionContext ext) throws Exception { + @Override + public void execute(ProcessExecutionContext ext) throws Exception { - //用户点击确认发布按钮后进行触发推送任务 - Boolean isConfirmRelease = SDK.getTaskAPI().isChoiceActionMenu(ext.getTaskInstance(), "确认发布"); - Connection open = DBSql.open(); - try { + //用户点击确认发布按钮后进行触发推送任务 + Boolean isConfirmRelease = SDK.getTaskAPI().isChoiceActionMenu(ext.getTaskInstance(), "确认发布"); + Connection open = DBSql.open(); + try { - if(isConfirmRelease==true){ - ProcessInstance boProcessInstance = SDK.getProcessAPI() - .createBOProcessInstance("obj_7946c848674f422fbe2817ad5d047337", ext.getUserContext().getUID(), "OA任务状态记录"); - BO executiveTaskBO=new BO(); - executiveTaskBO.set("TASKTITLE",ext.getProcessInstance().getTitle()); - executiveTaskBO.set("TASKID",ext.getProcessInstance().getId()); - executiveTaskBO.set("TASKSTATUS",1); - executiveTaskBO.set("ISTASKEND",1); - SDK.getBOAPI().create("BO_ACT_EXECUTIVE_TASK",executiveTaskBO,boProcessInstance.getId(),""); - ExecutorService service = Executors.newFixedThreadPool(1); - service.execute(new Runnable() { - @Override - public void run() { - try { - System.out.println("进入方法==============="); - ProcessData(ext,open); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - } - }catch (Exception e){ - e.printStackTrace(); - } + if(isConfirmRelease==true){ + ProcessInstance boProcessInstance = SDK.getProcessAPI() + .createBOProcessInstance("obj_7946c848674f422fbe2817ad5d047337", ext.getUserContext().getUID(), "OA任务状态记录"); + BO executiveTaskBO=new BO(); + executiveTaskBO.set("TASKTITLE",ext.getProcessInstance().getTitle()); + executiveTaskBO.set("TASKID",ext.getProcessInstance().getId()); + executiveTaskBO.set("TASKSTATUS",1); + executiveTaskBO.set("ISTASKEND",1); + SDK.getBOAPI().create("BO_ACT_EXECUTIVE_TASK",executiveTaskBO,boProcessInstance.getId(),""); + ExecutorService service = Executors.newFixedThreadPool(1); + service.execute(new Runnable() { + @Override + public void run() { + try { + System.out.println("进入方法==============="); + ProcessData(ext,open); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + } + }catch (Exception e){ + e.printStackTrace(); + } - //发送消息通知 - List readCountBO=SDK.getBOAPI().query("BO_EU_READ_COUNT").addQuery("PROCESSID=",ext.getProcessInstance().getId()).addQuery("RESULT=","待处理").list(); - if(readCountBO.size()>0){ - SDK.getNotificationAPI().sendMessage("admin", "admin", "文件名称:"+ext.getProcessInstance().getTitle()+"文件有失败记录,请及时处理!!!"); - } + //发送消息通知 + List readCountBO=SDK.getBOAPI().query("BO_EU_READ_COUNT").addQuery("PROCESSID=",ext.getProcessInstance().getId()).addQuery("RESULT=","待处理").list(); + if(readCountBO.size()>0){ + SDK.getNotificationAPI().sendMessage("admin", "admin", "文件名称:"+ext.getProcessInstance().getTitle()+"文件有失败记录,请及时处理!!!"); + } - //更新任务状态 - int r1 = DBSql.update("UPDATE BO_ACT_EXECUTIVE_TASK SET ISTASKEND='2' WHERE TASKID='" + ext.getProcessInstance().getId() + "'"); + //更新任务状态 + int r1 = DBSql.update("UPDATE BO_ACT_EXECUTIVE_TASK SET ISTASKEND='2' WHERE TASKID='" + ext.getProcessInstance().getId() + "'"); - } + } - public void ProcessData(ProcessExecutionContext processExecutionContext,Connection open) throws Exception { - System.err.println(processExecutionContext.getTaskInstance().getTitle() + "_推送文件开始========>"); - // 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())) { - DownloadUtil downloadUtil = new DownloadUtil(); - String wsId = ""; - JSONArray filed = new JSONArray(new LinkedList<>()); - String portalUrl = SDK.getPortalAPI().getPortalUrl(); - // System.out.println("portal======>>>>" + portalUrl); - /* - * if (portalUrl.equals("http://10.114.11.135:8088/portal")){ portalUrl = - * "http://bpm.yili.com:8088/portal/"; } - */ - try { + public void ProcessData(ProcessExecutionContext processExecutionContext,Connection open) throws Exception { + System.err.println(processExecutionContext.getTaskInstance().getTitle() + "_推送文件开始========>"); + // 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())) { + DownloadUtil downloadUtil = new DownloadUtil(); + String wsId = ""; + JSONArray filed = new JSONArray(new LinkedList<>()); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + // System.out.println("portal======>>>>" + portalUrl); + /* + * if (portalUrl.equals("http://10.114.11.135:8088/portal")){ portalUrl = + * "http://bpm.yili.com:8088/portal/"; } + */ + try { - String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" - + processExecutionContext.getProcessInstance().getId() + "&taskInstId=" - + processExecutionContext.getTaskInstance().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(); + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + + processExecutionContext.getProcessInstance().getId() + "&taskInstId=" + + processExecutionContext.getTaskInstance().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(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - //Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime(); - Timestamp endTime = new Timestamp(System.currentTimeMillis()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //Timestamp endTime = processExecutionContext.getTaskInstance().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("OPTIONTYPE IS NOT NULL", null).detail(); + BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).connection(open) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); - // ProcessExecutionContext processExecutionContext,String fileCreateName,String - // fileName,String fileurl,String readingScope_org,String isFullCompany,String - // 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"), - boActCoePublish.getString("PROCESS_TITLE"), not_url, - boActCoePublish.getString("SEND_SCOPE_ORG"), boActCoePublish.getString("SEND_SCOP"), - boActCoePublish.getString("APPLYDATE"), processExecutionContext.getProcessInstance().getId(), - boActCoePublish.getString("SEND_SCOPE_POST"), boActCoePublish.getString("SEND_SCOPE_LEVEL"), - "1"); + // ProcessExecutionContext processExecutionContext,String fileCreateName,String + // fileName,String fileurl,String readingScope_org,String isFullCompany,String + // 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"), + boActCoePublish.getString("PROCESS_TITLE"), not_url, + boActCoePublish.getString("SEND_SCOPE_ORG"), boActCoePublish.getString("SEND_SCOP"), + boActCoePublish.getString("APPLYDATE"), processExecutionContext.getProcessInstance().getId(), + boActCoePublish.getString("SEND_SCOPE_POST"), boActCoePublish.getString("SEND_SCOPE_LEVEL"), + "1"); - 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() - System.out.println("processExecutionContext.getTaskInstance().getTarget()).getNo()==========="+SDK.getORGAPI() - .getDepartmentByUser(processExecutionContext.getTaskInstance().getTarget()).getNo()); - String target = processExecutionContext.getTaskInstance().getTarget(); - System.out.println("target============"+target); - target = processExecutionContext.getTaskInstance().getTarget(); + 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() + System.out.println("processExecutionContext.getTaskInstance().getTarget()).getNo()==========="+SDK.getORGAPI() + .getDepartmentByUser(processExecutionContext.getTaskInstance().getTarget()).getNo()); + String target = processExecutionContext.getTaskInstance().getTarget(); + System.out.println("target============"+target); + target = processExecutionContext.getTaskInstance().getTarget(); - jsonObject.put("user", target); - // jsonObject.put("user",);//processExecutionContext.getProcessInstance().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("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("OPTIONTYPE IS NOT NULL", null).detail(); - String crateUserId = target; - String new_uid = ""; + jsonObject.put("user", target); + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().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("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("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("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(); - List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).connection(open) - .addQuery("BINDID=", processExecutionContext.getProcessInstance().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(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().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(); + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).connection(open) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().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(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - JSONArray jsonArray = new JSONArray(); + JSONArray jsonArray = new JSONArray(); - /** - * 推送待阅文件到OA - */ - if ("true".equals(isSendOA)) { - ProcessInstance instanceById = processExecutionContext.getProcessInstance(); - if (bo_act_coe_publish1 != null && instanceById != null) { - System.err.println(instanceById.getTitle() + "推送OA待阅执行开始====>"); - long sendUserstartTime = System.currentTimeMillis(); - ArrayList sendList = new ArrayList(); - // 发送全集团 - if ("1".equals(bo_act_coe_publish1.getString("SEND_SCOP"))) { - // 系统人员 - ArrayList userList1 = new ArrayList(); - try { - userList1 = getUser(jsonObject, "5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe", "0", - instanceById.getId()); - } catch (Exception e) { - // TODO: handle exception - } - //System.err.println("系统人员=====>" + userList1); - // 项目开发人员 - ArrayList userList2 = new ArrayList(); - try { - userList2 = getUser(jsonObject, "e79281b1-2f81-4895-b30e-9f96e9ad0e2c", "0", - instanceById.getId()); - } catch (Exception e) { - // TODO: handle exception - } - //System.err.println("项目开发人员=====>" + userList2); - // 离退人员 - ArrayList userList3 = new ArrayList(); - try { - userList3 = getUser(jsonObject, "65048aee-157f-49f2-a2dc-5903dd26f519", "0", - instanceById.getId()); - } 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 = getSendList(instanceById, bo_act_coe_publish1, jsonObject); - } + /** + * 推送待阅文件到OA + */ + if ("true".equals(isSendOA)) { + ProcessInstance instanceById = processExecutionContext.getProcessInstance(); + if (bo_act_coe_publish1 != null && instanceById != null) { + System.err.println(instanceById.getTitle() + "推送OA待阅执行开始====>"); + long sendUserstartTime = System.currentTimeMillis(); + ArrayList sendList = new ArrayList(); + // 发送全集团 + if ("1".equals(bo_act_coe_publish1.getString("SEND_SCOP"))) { + // 系统人员 + ArrayList userList1 = new ArrayList(); + try { + userList1 = getUser(jsonObject, "5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe", "0", + instanceById.getId()); + } catch (Exception e) { + // TODO: handle exception + } + //System.err.println("系统人员=====>" + userList1); + // 项目开发人员 + ArrayList userList2 = new ArrayList(); + try { + userList2 = getUser(jsonObject, "e79281b1-2f81-4895-b30e-9f96e9ad0e2c", "0", + instanceById.getId()); + } catch (Exception e) { + // TODO: handle exception + } + //System.err.println("项目开发人员=====>" + userList2); + // 离退人员 + ArrayList userList3 = new ArrayList(); + try { + userList3 = getUser(jsonObject, "65048aee-157f-49f2-a2dc-5903dd26f519", "0", + instanceById.getId()); + } 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 = getSendList(instanceById, bo_act_coe_publish1, jsonObject); + } - long countTime = System.currentTimeMillis(); - System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size() + " 计算用时===>" - + (countTime - sendUserstartTime) + "毫秒"); - /* - * for (String user : sendList) { try { SendOARead(jsonObject, instanceById, - * user, "批量推送"); } catch (Exception e) { // TODO: handle exception } } - */ + long countTime = System.currentTimeMillis(); + System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size() + " 计算用时===>" + + (countTime - sendUserstartTime) + "毫秒"); + /* + * for (String user : sendList) { try { SendOARead(jsonObject, instanceById, + * user, "批量推送"); } catch (Exception e) { // TODO: handle exception } } + */ /*List bo_eu_oa_read_test = SDK.getBOAPI().query("BO_EU_OA_READ_TEST").connection(open).list(); ArrayList sendLists = new ArrayList(); 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() - + "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' "; - String taskInd = DBSql.getString(sql); + String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + processExecutionContext.getProcessInstance().getId() + + "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' "; + String taskInd = DBSql.getString(sql); - TaskInstance ta = SDK.getTaskAPI().getInstanceById(taskInd); - new_uid = new_uid.join(",", sendList); - long startTimes = System.currentTimeMillis(); - String[] users = new_uid.split(","); - for (String uid: users) { - BO bo = new BO(); - bo.set("USER_ID",uid); - bo.set("PROCESSID",processExecutionContext.getProcessInstance().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")); - bo.set("PUBLISH_DATE",sdf.format(endTime)); - SDK.getBOAPI().createDataBO("BO_EU__OA_MONITOR",bo,UserContext.fromUID(ta.getTarget())); - } - System.out.println("new_uid>>>>>>>>>>>>>>"+users.length); + TaskInstance ta = SDK.getTaskAPI().getInstanceById(taskInd); + new_uid = new_uid.join(",", sendList); + long startTimes = System.currentTimeMillis(); + String[] users = new_uid.split(","); + for (String uid: users) { + BO bo = new BO(); + bo.set("USER_ID",uid); + bo.set("PROCESSID",processExecutionContext.getProcessInstance().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")); + bo.set("PUBLISH_DATE",sdf.format(endTime)); + SDK.getBOAPI().createDataBO("BO_EU__OA_MONITOR",bo,UserContext.fromUID(ta.getTarget())); + } + System.out.println("new_uid>>>>>>>>>>>>>>"+users.length); - long startTime = System.currentTimeMillis(); + long startTime = System.currentTimeMillis(); - int length = 200; - int ys = users.length%length; - /** - * 这个是以300人作为一个发送单位去放到list中并发送待阅数据 - */ - if (ys==0) { - int size = users.length/length; - int flag = 0; + int length = 200; + int ys = users.length%length; + /** + * 这个是以300人作为一个发送单位去放到list中并发送待阅数据 + */ + if (ys==0) { + int size = users.length/length; + int flag = 0; - List list = new LinkedList(); + List list = new LinkedList(); - for (int i=0;i>>>>>>>>>>>>>"+list); - }else { - int size = users.length/length; - int flag = 0; - List list = new LinkedList(); - for (int i=0;i>>>>>>>>>>>>>"+list); + }else { + int size = users.length/length; + int flag = 0; + List list = new LinkedList(); + for (int i=0;i>>>>>>>>>>>>>"+list); - } + /** + * 创建线程发送待阅数据 + */ + course(list,startTime,jsonObject,processExecutionContext,sendList); + //System.out.println("发送人员数据>>>>>>>>>>>>>>"+list); + } @@ -402,1708 +402,1717 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute + (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(); } - * - * } }); - *//* + * 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; } } - *//* + * 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); - } + /** + * 推送到知识库 + */ + 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")); + // 废止知识库文件 + 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 - } - } + 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"); - DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+fileId+"'"); - } 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"); - DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+changefileId+"'"); - DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+changefileIdNew+"'"); - } catch (Exception e) { - } - } - } + /** + * 同步PAL文件表文件版本标识,用于部门视图 + */ + if(bo_act_coe_publish_n.size()>0) { + for (BO bo : bo_act_coe_publish_n) { + try { + String fileId = bo.getString("PUBLISHFILEID"); + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+fileId+"'"); + } 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"); + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+changefileId+"'"); + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+changefileIdNew+"'"); + } 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"); - DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+fileId+"'"); - } catch (Exception e) { - } - } - } - /** - * 推送到EHSQ - */ - boolean sendEhqs = true; - 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(); - 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); - } 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"); + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+fileId+"'"); + } catch (Exception e) { + } + } + } + /** + * 推送到EHSQ + */ + boolean sendEhqs = true; + 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(); + 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); + } catch (Exception e) { + } - } catch (Exception e) { - e.printStackTrace(); - } finally { - } - } - } + } catch (Exception e) { + e.printStackTrace(); + } finally { + } + } + } - /** - * 创建索引 - * @param processExecutionContext 流程实例 - * @param index 索引名称 (随便填写,aslp那边已经有固定的) - * @param type 类型(随便填写,aslp中也是有固定的) - * @param documentPath dc全路径 - * @param fileNames 文件名称 - */ - public void createIndexByFile(ProcessExecutionContext processExecutionContext,String index,String type,String documentPath,JSONObject fileNames) { + /** + * 创建索引 + * @param processExecutionContext 流程实例 + * @param contents 索引内容 + * @return + */ + + public boolean createIndexesByContent(ProcessExecutionContext processExecutionContext,JSONArray contents) { // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + String sourceAppId =processExecutionContext.getProcessInstance().getAppId() ; // aslp服务地址 - String aslp = "aslp://com.actionsoft.apps.addons.es/createIndexByFile"; + String aslp = "aslp://com.actionsoft.apps.addons.es/createIndexesByContent"; // 参数定义列表 - Map params = new HashMap(); + Map params = new HashMap(); +//索引内容(JSONArray格式, JSONArray中包含JSONObject, JSONObject的内容同创建单个索引),必填 + params.put("contents", contents); //索引名称(文档在哪存放),必填 - params.put("index", index); + params.put("index", "com.actionsoft.apps.kms_kmsdoc_card"); //类型(索引中对数据进行逻辑分区。不同 type的文档可能有不同的字段,但最好能够非常相似,比如:存储所有产品到索引products中,但是你有许多不同的产品类别,这些产品共享一种相同的(或非常相似)的模式:他们有一个标题、描述、产品代码和价格。他们只是正好属于“产品”下的一些子类。用type表示不同的类别),必填 - params.put("type", type); -//要入库的文件全路径,必填 - params.put("documentPath", documentPath); -//文件实际名称, jsonObject,非必填 - params.put("fileNames", fileNames); - AppAPI appAPI = SDK.getAppAPI(); -//入库操作,从文件创建内容索引 - ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); - System.out.println("ro===================="+ro); - } + params.put("type", "kmsdoc_card"); + AppAPI appAPI = SDK.getAppAPI(); +//入库操作,创建内容索引(多个) + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); - /** - * 根据线程创建待阅日志 - * @param list - * @param startTime - * @param jsonObject - * @param processExecutionContext - */ - public void course(List list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext,ArrayList sendList) throws InterruptedException { - // 创建线程来实现为每100人为一个的线程跑待阅 - ProcessInstance instanceById = processExecutionContext.getProcessInstance(); - CountDownLatch countDownLatch = new CountDownLatch(list.size()); - ExecutorService service = Executors.newFixedThreadPool(4); - int m = 0; - for (String[] resrt:list - ) { - int finalM = m; - service.execute(new Runnable() { - @Override + System.out.println("ro==================="+ro); + return ro.isOk(); + } - public void run() { - System.out.println("最后一个数组是什么>>>>>>>"+Arrays.asList(resrt).size()); - String userIds = ""; - userIds = StringUtils.join(resrt, ","); - System.out.println("userIDs>>>>>>>>>>>>>>>"+userIds); - try { - SendOARead( processExecutionContext.getProcessInstance(), userIds,"批量推送"); - countDownLatch.countDown(); - } catch (DocumentException e) { - e.printStackTrace(); - } + /** + * 根据线程创建待阅日志 + * @param list + * @param startTime + * @param jsonObject + * @param processExecutionContext + */ + public void course(List list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext,ArrayList sendList) throws InterruptedException { + // 创建线程来实现为每100人为一个的线程跑待阅 + ProcessInstance instanceById = processExecutionContext.getProcessInstance(); + CountDownLatch countDownLatch = new CountDownLatch(list.size()); + ExecutorService service = Executors.newFixedThreadPool(4); + int m = 0; + for (String[] resrt:list + ) { + int finalM = m; + service.execute(new Runnable() { + @Override - } - }); - m++; - } - countDownLatch.await(); - if (countDownLatch.getCount()==0){ + public void run() { + System.out.println("最后一个数组是什么>>>>>>>"+Arrays.asList(resrt).size()); + String userIds = ""; + userIds = StringUtils.join(resrt, ","); + System.out.println("userIDs>>>>>>>>>>>>>>>"+userIds); + try { + SendOARead( processExecutionContext.getProcessInstance(), userIds,"批量推送"); + countDownLatch.countDown(); + } catch (DocumentException e) { + e.printStackTrace(); + } - try { - // 等待所有的任务执行完毕,最多等待1小时 - List List = DBSql.getMaps("SELECT NAME FROM BO_EU_READ_COUNT WHERE PROCESSID = '" - + instanceById.getId() + "' AND RESULT = '待处理'"); - if (List.size() != 0) { - System.err.println(instanceById.getTitle() + "批量推送失败后执行二次推送=======>" + List.size()); - for (RowMap rowMap : List) { - try { - ArrayList secondUserList = new ArrayList(); - secondUserList.add(rowMap.getString("NAME")); - System.err.println(instanceById.getTitle() + "二次推送账号=======>" + secondUserList); + } + }); + m++; + } + countDownLatch.await(); + if (countDownLatch.getCount()==0){ - 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(); - for(RowMap oneuserId:List){ - BO bo = new BO(); - bo.set("TITLE", processExecutionContext.getProcessInstance().getTitle()); - bo.set("NAME", oneuserId.getString("NAME")); - bo.set("TYPE", "批量推送"); - bo.set("RESULT", "待处理"); - bo.set("PROCESSID", processExecutionContext.getProcessInstance().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()); - return; - } + try { + // 等待所有的任务执行完毕,最多等待1小时 + List List = DBSql.getMaps("SELECT NAME FROM BO_EU_READ_COUNT WHERE PROCESSID = '" + + instanceById.getId() + "' AND RESULT = '待处理'"); + if (List.size() != 0) { + System.err.println(instanceById.getTitle() + "批量推送失败后执行二次推送=======>" + List.size()); + for (RowMap rowMap : List) { + try { + ArrayList secondUserList = new ArrayList(); + secondUserList.add(rowMap.getString("NAME")); + System.err.println(instanceById.getTitle() + "二次推送账号=======>" + secondUserList); - secondSendOARead(processExecutionContext.getProcessInstance(), secondUserList, "单个账号推送"); - } catch (Exception e) { // TODO: handle exception - } - } + 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(); + for(RowMap oneuserId:List){ + BO bo = new BO(); + bo.set("TITLE", processExecutionContext.getProcessInstance().getTitle()); + bo.set("NAME", oneuserId.getString("NAME")); + bo.set("TYPE", "批量推送"); + bo.set("RESULT", "待处理"); + bo.set("PROCESSID", processExecutionContext.getProcessInstance().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()); + return; + } - } + secondSendOARead(processExecutionContext.getProcessInstance(), secondUserList, "单个账号推送"); + } catch (Exception e) { // TODO: handle exception + } + } - long endTimes = System.currentTimeMillis(); - // 存入日志 - createReadLog(processExecutionContext, jsonObject, sendList, startTime, endTimes); - System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:" - + (endTimes - startTime) / 1000 / 60 + "分钟"); + } + + long endTimes = System.currentTimeMillis(); + // 存入日志 + createReadLog(processExecutionContext, jsonObject, sendList, startTime, endTimes); + System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:" + + (endTimes - startTime) / 1000 / 60 + "分钟"); - //发送消息通知 - List readCountBO=SDK.getBOAPI().query("BO_EU_READ_COUNT").addQuery("PROCESSID=",processExecutionContext.getProcessInstance().getId()).addQuery("RESULT=","待处理").list(); - if(readCountBO.size()>0){ - SDK.getNotificationAPI().sendMessage("admin", "admin", "文件名称:"+processExecutionContext.getProcessInstance().getTitle()+"文件有失败记录,请及时处理!!!"); - } - //更新任务状态 - int r1 = DBSql.update("UPDATE BO_ACT_EXECUTIVE_TASK SET ISTASKEND='2' WHERE TASKID ='" + processExecutionContext.getProcessInstance().getId() + "'"); + } catch (Exception e) { + System.out.println("等待中断异常"); + } + } else { + System.out.println("超过等待时间,部分任务未执行完毕"); + } + } - } catch (Exception e) { - System.out.println("等待中断异常"); - } - } else { - System.out.println("超过等待时间,部分任务未执行完毕"); - } - - } - - /** - * 创建附件及文件 - * - * @param processExecutionContext - * @param bo_name - * @param userContext - * @param cardId - * @param fileid - */ - public void creadteFile(ProcessExecutionContext processExecutionContext, String bo_name, UserContext userContext, - String cardId, String fileid) { - /** - * 这个主要是负责对流程手册进行相关的文件的生成 - */ - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + /** + * 创建附件及文件 + * + * @param processExecutionContext + * @param bo_name + * @param userContext + * @param cardId + * @param fileid + */ + public void creadteFile(ProcessExecutionContext processExecutionContext, String bo_name, UserContext userContext, + String cardId, String fileid) { + /** + * 这个主要是负责对流程手册进行相关的文件的生成 + */ + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); // aslp服务地址 - String aslp = "aslp://com.actionsoft.apps.kms/CreateFile"; + String aslp = "aslp://com.actionsoft.apps.kms/CreateFile"; - if (StringUtils.isNotEmpty(cardId)) { - String sql_ext4 = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '" + cardId + "'"; - RowMap map = DBSql.getMap(sql_ext4); - System.out.println("maps======>>>>>>>" + map); - System.out.println("fileid==》》》》" + fileid); - System.out.println("id==》》》》" + map.getString("ID")); - RowMap rowMap = DBSql - .getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'"); - // BO bos = - // SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail(); - if (rowMap != null) { + if (StringUtils.isNotEmpty(cardId)) { + String sql_ext4 = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '" + cardId + "'"; + RowMap map = DBSql.getMap(sql_ext4); + System.out.println("maps======>>>>>>>" + map); + System.out.println("fileid==》》》》" + fileid); + System.out.println("id==》》》》" + map.getString("ID")); + RowMap rowMap = DBSql + .getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'"); + // BO bos = + // SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail(); + if (rowMap != null) { - if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) { + if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) { - OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); - if (model != null) { - // System.out.println(",pdel============" + model); - 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 = ""; - if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { - sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" - + rowMap.getString("PUBLISHFILEID") + "'"; + OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); + if (model != null) { + // System.out.println(",pdel============" + model); + 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 = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + + rowMap.getString("PUBLISHFILEID") + "'"; - } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { - sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" - + rowMap.getString("CHANGEDFILEIDNEW") + "'"; - } - String lever = DBSql.getString(sql_lever); - System.out.println("版本号::::::::::::" + 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 = ""; - if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { - filename = rowMap.getString("PUBLISHFILENAME"); - } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { - filename = rowMap.getString("CHANGEDFILENAMENEW"); - } - DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), - model.getWsId(), rowMap.getString("TASKID"), filename + "_" + lever + ".doc"); - // UtilFile file = new UtilFile(dcContext.getPath()); + } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + + rowMap.getString("CHANGEDFILEIDNEW") + "'"; + } + String lever = DBSql.getString(sql_lever); + System.out.println("版本号::::::::::::" + 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 = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { + filename = rowMap.getString("PUBLISHFILENAME"); + } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { + filename = rowMap.getString("CHANGEDFILENAMENEW"); + } + DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), + model.getWsId(), rowMap.getString("TASKID"), filename + "_" + lever + ".doc"); + // UtilFile file = new UtilFile(dcContext.getPath()); - Map params = new HashMap(); + Map params = new HashMap(); //知识ID,必填 - params.put("cardId", cardId); + params.put("cardId", cardId); //sid,必填 - params.put("sid", userContext.getSessionId()); + params.put("sid", userContext.getSessionId()); - params.put("dc", dcContext); - AppAPI appAPI = SDK.getAppAPI(); + params.put("dc", dcContext); + AppAPI appAPI = SDK.getAppAPI(); //创建文件 - ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); - System.out.println("流程手册的存入=================" + ro); - createIndexByFile(processExecutionContext, dcContext.getFileName(),"process",dcContext.getFilePath(),new JSONObject()); - } - } + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("流程手册的存入=================" + ro); - } - String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '" + map.getString("ID") - + "' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)"; - List rows = DBSql.getMaps(sql_A); + JSONArray coontest = new JSONArray(new LinkedList<>()); + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("documentId", cardId); + jsonObject.put("content", "");//信息附件 + jsonObject.put("abstract", dcContext);//信息摘要 + jsonObject.put("title", dcContext.getFileName().substring(0,dcContext.getFileName().indexOf(".")));//信息标题 + coontest.add(jsonObject); + //createIndexesByContent(processExecutionContext,coontest); - for (RowMap bo : rows) { + } + } - /** - * 这个是模型中的附件获取的并插入的数据信息,需要做修改 - */ - // 调用App + } + String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '" + map.getString("ID") + + "' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)"; + List rows = DBSql.getMaps(sql_A); + + for (RowMap bo : rows) { + + /** + * 这个是模型中的附件获取的并插入的数据信息,需要做修改 + */ + // 调用App // 参数定义列表 - Map paramss = new HashMap(); + Map paramss = new HashMap(); //知识ID,必填 - paramss.put("cardId", cardId); + paramss.put("cardId", cardId); //sid,必填 - paramss.put("sid", userContext.getSessionId()); - - UpfileWeb upfileWeb = new UpfileWeb(userContext); - - String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '" - + map.getString("ID") + "'" + ") ORDER BY FILENAME ASC"; - List maps = DBSql.getMaps(sql_upfile); - for (RowMap row : maps) { - if (!row.getString("FILENAME").contains(".xml")) { - UpfileModel upfileModel = new UpfileModel(); - upfileModel.setType(row.getString("FILETYPE")); - upfileModel.setFileName(row.getString("FILENAME")); - upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); - upfileModel.setShape_uuid(row.getString("SHAPEID")); - DCContext dcContexts = upfileWeb.getDCContext(upfileModel); - paramss.put("dc", dcContexts); - AppAPI appAPIs = SDK.getAppAPI(); - ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss); - //createIndexByFile(processExecutionContext, dcContexts.getFileName(),"process",dcContexts.getFilePath(),new JSONObject()); - } - } - } - try { - - PublishKnow(processExecutionContext, userContext, cardId); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - /** - * 发布知识 - * - * @param processExecutionContext - * @param userContext - * @param id - */ - public void PublishKnow(ProcessExecutionContext processExecutionContext, 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 + "')"; - List maps = DBSql.getMaps(sql); - String ids = ""; - for (RowMap rowmap : maps) { - ids += rowmap.getString("EXT4") + ","; - } - String[] deptSplit_id = ids.split(","); - - JSONArray jsonArray = new JSONArray(); - for (String id_names : deptSplit_id) { - jsonArray.add(id_names); - } - // jsonObject.put(deptSplit_id); - id += ","; - String[] deptSplit_das = id.split(","); - JSONArray jsonArray_das = new JSONArray(); - for (String das : deptSplit_das) { - jsonArray_das.add(das); - } - // jsonObject.put(deptSplit_id); - - if (!jsonArray_das.isEmpty() && !jsonArray.isEmpty()) { - - // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); - // aslp服务地址 - String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; - // 参数定义列表 - Map params = new HashMap(); - // 要发布到的维度ID的JSON数组字符串,必填 - params.put("dimensionIDArray", jsonArray.toString()); - // 要发布的知识ID的JSON数组字符串,必填 - params.put("knwlIDArray", jsonArray_das.toString()); - // 标签的JSON数组字符串,非必填 - - // sid,必填 - params.put("sid", userContext.getSessionId()); - AppAPI appAPI = SDK.getAppAPI(); - // 发布知识 - ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); - - System.out.println("知识发布============" + ro); - - } - - } - - /** - * 取消发布知识 - * - * @param processExecutionContext - * @param sid - * @param knwlId - * @return - */ - public boolean CancelPublishKnwl(ProcessExecutionContext processExecutionContext, String sid, String knwlId) { - // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); - // aslp服务地址 - String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl"; - // 参数定义列表 - Map params = new HashMap(); - // sid,如果为空,则需要传createUser参数,非必填 - params.put("sid", sid); - // 知识ID,必填 - params.put("knwlId", knwlId); - AppAPI appAPI = SDK.getAppAPI(); - // 取消发布知识(全部维度) - ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); - System.out.println("取消发布的ro=====>>>>" + ro); - return ro.isOk(); - } - - /** - * 创建XPage页面上的待阅文件 - * - * @param processExecutionContext - * @param fileCreateName - * @param fileName - * @param fileurl - * @param readingScope_org - * @param isFullCompany - * @param fileCreateDate - * @param relationProcessinstId - * @param readingScope_post - * @param readingScope_level - * @param fileid - * @return - */ - public boolean execute(ProcessExecutionContext processExecutionContext, 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(); - // aslp服务地址 - String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage"; - // 参数定义列表 - Map params = new HashMap(); - // 发布人,不允许空值,必填 - params.put("fileCreateName", fileCreateName); - // 待阅文件标题名称,不允许空值,必填 - params.put("fileName", fileName); - // 阅读范围_组织,不允许空值,非必填 - params.put("readingScope_org", readingScope_org); - // 是否全公司可见,不允许空值,必填 - params.put("isFullCompany", isFullCompany); - // 待阅文件Url,不允许空值,必填 - params.put("fileurl", fileurl); - // 发布日期,不允许空值,必填 - params.put("fileCreateDate", fileCreateDate); - // 发布流程ID,不允许空值,必填 - params.put("relationProcessinstId", relationProcessinstId); - // 阅读范围_岗位,不允许空值,非必填 - params.put("readingScope_post", readingScope_post); - // 阅读范围_职级,不允许空值,非必填 - params.put("readingScope_level", readingScope_level); - // 待阅文件ID,多个逗号隔开,不允许空值,必填 - params.put("fileid", fileid); - AppAPI appAPI = SDK.getAppAPI(); - // 推送待阅文件到xpage门户 - ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); - System.out.println("ros++++++++=====待阅》》》》》》》》》》" + ro); - return ro.isOk(); - } - - /** - * 给知识授权 - * - * @param processExecutionContext - * @param jsonArray - * @param sid - * @param knwlId - * @return - */ - public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid, - String knwlId) { - - // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); - // aslp服务地址 - String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; - // 参数定义列表 - Map params = new HashMap(); - // [{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 - params.put("acList", jsonArray); - // sid,如果为空,则需要传createUser参数,非必填 - params.put("sid", sid); - // 知识ID,必填 - params.put("knwlId", knwlId); - AppAPI appAPI = SDK.getAppAPI(); - // 给知识授权 - ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); - return ro.isOk(); - } - - /** - * 柱军的ASLP - * - * @param processExecutionContext - * @param wsId - * @param fileId - * @return - */ - public boolean AttrSynAslp(ProcessExecutionContext processExecutionContext, String wsId, JSONArray fileId) { - System.out.println(""); - // 调用App - String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); - // aslp服务地址 - String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp"; - // 参数定义列表 - Map params = new HashMap(); - // 资产内容库id,必填 - params.put("wsId", wsId); - // 文件id;json数组[id1,id2,id3],必填 - params.put("fileId", fileId); - AppAPI appAPI = SDK.getAppAPI(); - // 增量同步数据 - ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); - System.out.println("同步数据看板底表结果>>>>>>>>>>>>>" + ro); - return ro.isOk(); - } - - /** - * 发送OA待阅数据 - * - * @param jsonObject - * @param processInstance - * @param results - * @throws DocumentException - */ - public void SendOARead( ProcessInstance processInstance, String userIds,String type) - throws DocumentException { - - - - String processInstId = processInstance.getId(); - // System.err.println(processInstance.getTitle() + "开始发送:" + userId); - - /* - * if ("".equals(userId) || UtilString.isEmpty(userId)) { return; } - */ - - - BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) - .addQuery("BINDID=", processInstance.getId()) - .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); - - String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + processInstance.getId() - + "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' "; - String taskInd = DBSql.getString(sql); - - TaskInstance ta = SDK.getTaskAPI().getInstanceById(taskInd); - String portalUrl = SDK.getPortalAPI().getPortalUrl(); - - String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" - + processInstance.getId() + "&taskInstId=" - + taskInd; - String mobileurl = "https://bpm.yili.com:8088/portal" - + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" - + processInstance.getId() + "&taskInstId=" - + taskInd; - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - //Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime(); - Timestamp endTime = new Timestamp(System.currentTimeMillis()); - - JSONObject jsonObjects = new JSONObject(new LinkedHashMap()); - jsonObjects.put("action", "read"); - jsonObjects.put("title", " " + "" + bo_act_coe_publish1.getString("PROCESS_TITLE") + ""); - jsonObjects.put("dept", SDK.getORGAPI() - .getDepartmentByUser(ta.getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() - String target = ta.getTarget(); - - jsonObjects.put("user", target); - // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() - jsonObjects.put("date", sdf.format(endTime)); - jsonObjects.put("remark", bo_act_coe_publish1.getString("PROCESS_TITLE")); - jsonObjects.put("status", "0"); - jsonObjects.put("dataid", processInstance.getId()); - jsonObjects.put("pcurl", url); - jsonObjects.put("mobileurl", mobileurl); - - String[] resrt = userIds.split(","); - long start_time = System.currentTimeMillis(); - System.out.println("待阅推送开始时间>>>>>>>>>>>>"+start_time); - BO bo_OA_read = new BO(); - bo_OA_read.set("FIR_NUMS",resrt.length); - bo_OA_read.set("START_TIME",start_time); - jsonObjects.put("userList", userIds); - String xmlStr = "\n" - + " " + " " + " " + " " - + "" + " " + " " - + " " + ""; - // System.out.println("xmlStr>>>>>>>>" + xmlStr); - String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); - UtilUrl uc=new UtilUrl(); - String postSoap =uc.doPostSoap(readurl, xmlStr, ""); - Document document = DocumentHelper.parseText(postSoap); - Element rootElement = document.getRootElement(); - Element result = rootElement.element("Body").element("serviceResponse").element("out"); - String resultString = result.getData().toString(); - JSONObject jsonObject1 = JSON.parseObject(resultString); - System.out.println("jsonObject1==============="+jsonObject1); - String datas = jsonObject1.getString("data"); - long have_time = System.currentTimeMillis(); - System.out.println("接收到返回的待阅ID时间>>>>>>>>>>>>>>>>"+have_time); - bo_OA_read.set("HAVE_TIME",have_time); - System.out.println("接收到返回的待阅耗时时间>>>>>>>>>>>>"+(have_time-start_time)); - bo_OA_read.set("SUM_TIME",(have_time-start_time)); - System.out.println("data================="+datas); - String status = jsonObject1.getString("status"); - System.out.println("推送》》》》》》》》》》》" + status); - - - if ("true".equals(status)) { - JSONArray resultArray = JSONObject.parseArray(datas); - //System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人"); - //批量入库操作 - //加入时间戳 - long set_start_time = System.currentTimeMillis(); - bo_OA_read.set("SET_TIME",set_start_time); - if(resultArray.size()>0){ - List recordLists = new ArrayList(); - long startTime2 = System.currentTimeMillis(); - for (int j = 0; j < resultArray.size(); j++) { - - JSONObject jsonObject2 = resultArray.getJSONObject(j); - String user = jsonObject2.get("user").toString(); - String dataid = jsonObject2.get("dataid").toString(); - BO bo = new BO(); - bo.set("TITLE", processInstance.getTitle()); - bo.set("PROCESSID", processInstance.getId()); - bo.set("USER_ID", user); - //bo.set("USERDEP", SDK.getORGAPI().getUser(user).getDepartmentId()); - bo.set("DATAID", dataid); - bo.set("RESULT", status); - bo.set("SENDTYPE", "1"); - bo.set("READSTATE", "未读"); - bo.set("TYPE", type); - recordLists.add(bo); - - - } - SDK.getBOAPI().create("BO_ACT_DATAID",recordLists, processInstance, UserContext.fromUID(processInstance.getCreateUser())); - - long endTime2 = System.currentTimeMillis(); - System.err.println(processInstance.getTitle() + "批量插入OA待阅数据====>" + "用时:" - + (endTime2 - startTime2) / 1000 + "秒"); - - - BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",processInstance.getId()).detail(); - - String sqly = "SELECT COUNT(1) FROM BO_ACT_DATAID WHERE PROCESSID=? AND SENDTYPE='1'"; - int mapsy = DBSql.getInt(sqly, new Object[]{processInstance.getId()}); - - if(oa_real_time!=null){ - int r1 = DBSql.update("UPDATE BO_ACT_OA_REAL_TIME SET SENDNUMSJ='" +mapsy + "'WHERE PROCESSID ='" + processInstance.getId() + "'"); - }else{ - BO publishbo=SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").bindId(processInstance.getId()).detail(); - String user=publishbo.getString("APPLYUSERNAME"); - //插入实时更新人数表 - BO realTimeBO=new BO(); - realTimeBO.set("USREID", user); - realTimeBO.set("DEPID", ""); - realTimeBO.set("BUNAME",""); - realTimeBO.set("TITLE", processInstance.getTitle()); - realTimeBO.set("PROCESSID", processInstance.getId()); - realTimeBO.set("SENDNUMSJ", 1); - realTimeBO.set("SENDNUM",sendTotal); - SDK.getBOAPI().create("BO_ACT_OA_REAL_TIME", realTimeBO, processInstance, UserContext.fromUID(processInstance.getCreateUser())); - } - } - long set_end_time = System.currentTimeMillis(); - bo_OA_read.set("SET_END_TIME",set_end_time); - bo_OA_read.set("SET_SUM_TIME",(set_end_time-set_start_time)); - bo_OA_read.set("PROCESS_ID",processInstance.getId()); - SDK.getBOAPI().create("BO_EU_OA_READ_LOG", bo_OA_read, processInstance, UserContext.fromUID(processInstance.getCreateUser())); - if("单个账号推送".equals(type)) { - DBSql.update("UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '"+processInstId+"' AND NAME = '"+resrt+"'"); - } - } else { - List idList = Arrays.asList(resrt); - BO bo = null; - List recordFailLists = new ArrayList(); - if(idList.size()>0){ - for (String userId : idList) { - System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId); - try { - bo= new BO(); - bo.set("TITLE", processInstance.getTitle()); - bo.set("NAME", userId); - bo.set("TYPE", type); - bo.set("RESULT", "待处理"); - bo.set("PROCESSID", processInstId); - bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId()); - //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); - recordFailLists.add(bo); - } catch (Exception e) { - bo= new BO(); - bo.set("TITLE", processInstance.getTitle()); - bo.set("NAME", userIds); - bo.set("TYPE", type); - bo.set("RESULT", "待处理"); - bo.set("PROCESSID", processInstId); - bo.set("DEPNAME", SDK.getORGAPI().getUser(userIds).getDepartmentId()); - //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); - recordFailLists.add(bo); - } - } - System.out.println("recordFailLists========="+recordFailLists.size()); - SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processInstance, UserContext.fromUID(processInstance.getCreateUser())); - } - - - - - - - } - - } - - - - /** - * 发送OA待阅数据 - * - * @param jsonObject - * @param processInstance - * @param results - * @throws DocumentException - */ - public void secondSendOARead(ProcessInstance processInstance, List idList,String type) - throws DocumentException { - - - System.out.println("idList========="+idList.toString()); - String processInstId = processInstance.getId(); - // System.err.println(processInstance.getTitle() + "开始发送:" + userId); - - /* - * if ("".equals(userId) || UtilString.isEmpty(userId)) { return; } - */ - if (idList.size() == 0) { - return; - } - - // System.err.println(processInstance.getTitle() + "开始发送:" + userId); - - /* - * if ("".equals(userId) || UtilString.isEmpty(userId)) { return; } - */ - - - BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) - .addQuery("BINDID=", processInstance.getId()) - .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); - - String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + processInstance.getId() - + "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' "; - String taskInd = DBSql.getString(sql); - - TaskInstance ta = SDK.getTaskAPI().getInstanceById(taskInd); - String portalUrl = SDK.getPortalAPI().getPortalUrl(); - - String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" - + processInstance.getId() + "&taskInstId=" - + taskInd; - String mobileurl = "https://bpm.yili.com:8088/portal" - + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" - + processInstance.getId() + "&taskInstId=" - + taskInd; - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - //Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime(); - Timestamp endTime = new Timestamp(System.currentTimeMillis()); - - JSONObject jsonObjects = new JSONObject(new LinkedHashMap()); - jsonObjects.put("action", "read"); - jsonObjects.put("title", " " + "" + bo_act_coe_publish1.getString("PROCESS_TITLE") + ""); - jsonObjects.put("dept", SDK.getORGAPI() - .getDepartmentByUser(ta.getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() - String target = ta.getTarget(); - - jsonObjects.put("user", target); - // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() - jsonObjects.put("date", sdf.format(endTime)); - jsonObjects.put("remark", bo_act_coe_publish1.getString("PROCESS_TITLE")); - jsonObjects.put("status", "0"); - jsonObjects.put("dataid", processInstance.getId()); - jsonObjects.put("pcurl", url); - jsonObjects.put("mobileurl", mobileurl); - - String userIds = StringUtils.join(idList, ","); - jsonObjects.put("userList", userIds); - String xmlStr = "\n" - + " " + " " + " " + " " - + "" + " " + " " - + " " + ""; - // System.out.println("xmlStr>>>>>>>>" + xmlStr); - String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); - UtilUrl uc=new UtilUrl(); - String postSoap = uc.doPostSoap(readurl, xmlStr, ""); - Document document = DocumentHelper.parseText(postSoap); - Element rootElement = document.getRootElement(); - Element result = rootElement.element("Body").element("serviceResponse").element("out"); - String resultString = result.getData().toString(); - JSONObject jsonObject1 = JSON.parseObject(resultString); - System.out.println("jsonObject1==============="+jsonObject1); - String datas = jsonObject1.getString("data"); - System.out.println("data================="+datas); - String status = jsonObject1.getString("status"); - System.out.println("推送》》》》》》》》》》》" + status); - - - if ("true".equals(status)) { - JSONArray resultArray = JSONObject.parseArray(datas); - System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人"); - //批量入库操作 - //加入时间戳 - if(resultArray.size()>0){ - List recordLists = new ArrayList(); - long startTime2 = System.currentTimeMillis(); - for (int j = 0; j < resultArray.size(); j++) { - - JSONObject jsonObject2 = resultArray.getJSONObject(j); - String user = jsonObject2.get("user").toString(); - String dataid = jsonObject2.get("dataid").toString(); - BO bo = new BO(); - bo.set("TITLE", processInstance.getTitle()); - bo.set("PROCESSID", processInstance.getId()); - bo.set("USER_ID", user); - bo.set("USERDEP", SDK.getORGAPI().getUser(user).getDepartmentId()); - bo.set("DATAID", dataid); - bo.set("RESULT", status); - bo.set("SENDTYPE", "1"); - bo.set("READSTATE", "未读"); - bo.set("TYPE", type); - recordLists.add(bo); - - BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",processInstance.getId()).detail(); - - } - SDK.getBOAPI().create("BO_ACT_DATAID",recordLists, processInstance.getId(), processInstance.getCreateUser()); - - long endTime2 = System.currentTimeMillis(); - System.err.println(processInstance.getTitle() + "二次批量插入OA待阅数据====>" + "用时:" - + (endTime2 - startTime2) / 1000 + "秒"); - - - BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",processInstance.getId()).detail(); - - String sqly = "SELECT COUNT(1) FROM BO_ACT_DATAID WHERE PROCESSID=? AND SENDTYPE='1'"; - int mapsy = DBSql.getInt(sqly, new Object[]{processInstance.getId()}); - - if(oa_real_time!=null){ - int r1 = DBSql.update("UPDATE BO_ACT_OA_REAL_TIME SET SENDNUMSJ='" +mapsy + "'WHERE PROCESSID ='" + processInstance.getId() + "'"); - } - - } - - if("单个账号推送".equals(type)) { - DBSql.update("UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '"+processInstId+"' AND NAME = '"+userIds+"'"); - } - } - - } - - /** - * 发送EHSQ数据 - * - * @param jsonArray - * @return - * @throws Exception - */ - public String SendEHSQFile(String plName,JSONArray jsonArray) throws Exception { - /** - * 首先需要将传过来的参数进行加密操作,并设置 - */ - AesUtil aesUtil = new AesUtil(); - String system = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "system"); - String AES = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "AES"); - String EHSQUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "EHSQUrl"); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String date = sdf.format(new Date()); - String s1 = date.replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""); - - //System.out.println("时间>>>>>>>>>>>>" + s1); - String data = system + "##" + s1; - String encrypt = aesUtil.encrypt(data, AES); // 获取加密之后的秘钥 - JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); - jsonObject.put("system", system); - jsonObject.put("token", encrypt); - jsonObject.put("infos", jsonArray); - HttpUtil httpUtil = new HttpUtil(); - //System.out.println(plName+"发送EHSQ参数>>>>>" + jsonObject); - String s = httpUtil.sendPost(jsonObject, EHSQUrl); - //System.out.println(plName+"发送EHSQ结果>>>>>" + s); - - return s; - } - - public ArrayList getSendList(ProcessInstance instanceById, BO bo_act_coe_publish1, JSONObject jsonObject) { - String sendType = bo_act_coe_publish1.getString("SEND_SCOP"); - String org = bo_act_coe_publish1.getString("SEND_SCOPE_ORG"); - String post = bo_act_coe_publish1.getString("SEND_SCOPE_POST"); - String level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"); - ArrayList userList = new ArrayList<>(); - if ("1".equals(sendType)) { - //System.err.println("发送全集团=====>" + instanceById.getTitle()); - userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, sendType); - - } else { - /** - * 先组织和职级取交集,然后再和岗位取并集 - */ - if (UtilString.isNotEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isNotEmpty(level)) { - //System.err.println("发送组织/岗位/职级=====>" + instanceById.getTitle()); - ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, - sendType); - ArrayList sendLevel = sendLevel(level, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject); - userList = sendPost(post, sendLevel, instanceById, bo_act_coe_publish1, - jsonObject); - } - // 如果职级为空,组织/岗位取并集 - if (UtilString.isNotEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) { - //System.err.println("发送组织/岗位=====>" + instanceById.getTitle()); - ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, - sendType); - userList = sendPost(post, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject); - } - // 如果岗位为空,组织/职级取交集 - if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) { - //System.err.println("发送组织/职级=====>" + instanceById.getTitle()); - ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, - sendType); - userList = sendLevel(level, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject); - } - - /** - * 组织为空 岗位和职级取并集 - */ - if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isNotEmpty(level)) { - //System.err.println("发送岗位/职级=====>" + instanceById.getTitle()); - ArrayList sendLevel2 = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject); - userList = sendPost(post, sendLevel2, instanceById, bo_act_coe_publish1, - jsonObject); - } - // 如果只有组织不为空 - if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isEmpty(level)) { - //System.err.println("发送组织=====>" + instanceById.getTitle()); - userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, sendType); - } - // 如果只有岗位不为空 - if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) { - //System.err.println("发送岗位=====>" + instanceById.getTitle()); - userList = sendPost(post, userList, instanceById, bo_act_coe_publish1, jsonObject); - } - // 如果只有职级不为空 - if (UtilString.isEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) { - //System.err.println("发送职级=====>" + instanceById.getTitle()); - userList = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject); - } - - } - - return userList; - - } - - // 发送组织 - public ArrayList sendOrg(String org, ArrayList userList, ProcessInstance instanceById, - BO bo_act_coe_publish1, JSONObject jsonObject, String sendType) { - String processid = instanceById.getId(); - // 获取组织 - if (StringUtils.isNotEmpty(org) || "1".equals(sendType)) { - long startTime = System.currentTimeMillis(); - userList = getUser(jsonObject, org, sendType, processid); - long endTimes = System.currentTimeMillis(); - // System.out.println(instanceById.getTitle()+"_根据部门获取人员用时===>"+(endTimes-startTime)/1000); - } - - return userList; - } - - // 发送岗位 - public ArrayList sendPost(String post, ArrayList userList, ProcessInstance instanceById, - BO bo_act_coe_publish1, JSONObject jsonObject) { - String processid = instanceById.getId(); - // 获取岗位 - if (StringUtils.isNotEmpty(post)) { - String posts[] = post.split(","); - // 取并集 - String postss = ""; - if (posts.length == 1) { - // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); - postss = "'" + posts[0] + "'"; - } else { - postss = "'" + StringUtils.join(posts, "','") + "'"; - } - String sql = "select * from ORGUSER where POSITION_NO in (" + postss + ") and userno is not null"; - List maps1 = DBSql.getMaps(sql); - for (RowMap rowMap : maps1) { - String userId = rowMap.getString("USERID"); - if (!userList.contains(userId)) { - boolean closed = SDK.getORGAPI().getUser(userId).isClosed(); - if(!closed) { - userList.add(userId); - } - } - - } - } - - return userList; - } - - // 发送职级 - public ArrayList sendLevel(String level, ArrayList userList, ProcessInstance instanceById, - BO bo_act_coe_publish1, JSONObject jsonObject) { - String processid = instanceById.getId(); - ArrayList userList_level = new ArrayList(); - // 获取职级 - if (StringUtils.isNotEmpty(level)) { - String ranks[] = level.split(","); - String rankss = ""; - if (ranks.length == 1) { - // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); - rankss = "'" + ranks[0] + "'"; - } else { - rankss = "'" + StringUtils.join(ranks, "','") + "'"; - } - // 取交集 - String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; - List maps2 = DBSql.getMaps(sql2); - for (RowMap rowMap : maps2) { - String userId = rowMap.getString("USERID"); - if (userList.contains(userId)) { - boolean closed = SDK.getORGAPI().getUser(userId).isClosed(); - if(!closed) { - userList_level.add(userId); - } - } - - } - } - - return userList_level; - } - - // 只发送职级 - public ArrayList sendLevel2(String level, ArrayList userList, ProcessInstance instanceById, - BO bo_act_coe_publish1, JSONObject jsonObject) { - String processid = instanceById.getId(); - ArrayList userList_level = new ArrayList(); - // 获取职级 - if (StringUtils.isNotEmpty(level)) { - String ranks[] = level.split(","); - String rankss = ""; - if (ranks.length == 1) { - // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); - rankss = "'" + ranks[0] + "'"; - } else { - rankss = "'" + StringUtils.join(ranks, "','") + "'"; - } - // 取交集 - String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; - List maps2 = DBSql.getMaps(sql2); - for (RowMap rowMap : maps2) { - String userId = rowMap.getString("USERID"); - boolean closed = SDK.getORGAPI().getUser(userId).isClosed(); - if(!closed) { - userList_level.add(userId); - } - } - } - return userList_level; - } - - /** - * 根据部门id获取当前部门以及下级部门的人员信息 - * - * @param processid - * @return - */ - - public ArrayList getUser(JSONObject jsonObject, String depIds, String sendType, String processid) { - ArrayList arr = new ArrayList(); - ArrayList arr_test = new ArrayList(); - // 全集团 - if ("1".equals(sendType)) { - List departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1, - "8911e732-b42a-4556-853f-ad32761bcbee"); - for (DepartmentModel departmentModel : departmentsByCompanyId) { - String id = departmentModel.getId(); - // 查询未注销的部门并且去掉系统部门 - if (!departmentModel.isClosed() && !"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id) - && !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id) - && !"65048aee-157f-49f2-a2dc-5903dd26f519".equals(id)) { - getUserList(jsonObject, arr_test, arr, id, processid); - - } - } - } else { - if (UtilString.isNotEmpty(depIds)) { - String[] split = depIds.split(","); - for (String depId : split) { - getUserList(jsonObject, arr_test, arr, depId, processid); - } - } - } - - // System.err.println(SDK.getProcessAPI().getInstanceById(processid) + - // "_得到的总人数为:" + arr_test.size()); - // System.err.println(SDK.getProcessAPI().getInstanceById(processid) + - // "_得到的过滤后的人数为:" + arr.size()); - return arr; - } - - public void getUserList(JSONObject jsonObject, ArrayList arr_test, ArrayList arr, - String departmentId, String processid) { - // 获取当前部门下人员 - List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId); - for (UserModel userModel : userModelList) { - if (!userModel.isClosed()) { - String uid = userModel.getUID(); - if (!arr.contains(uid)) { - if (!"10033643".equals(uid)) { - // System.err.println("发送人员======>" + uid); } - arr.add(uid); - - } - /* - * RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" - * + processid + "' AND USER_ID = '" + uid + "'"); if (map == null) { - * //System.err.println("发送人员======>" + uid); } - */ - } - } - } - // 获取当前部门的子部门人员 - DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId); - if (departmentById.isExistSubModelOfCache()) { - getSubDepartments(jsonObject, arr_test, arr, departmentById, processid); - } - - } - - // 获取子部门人员 - public void getSubDepartments(JSONObject jsonObject, ArrayList arr_test, ArrayList arr, - DepartmentModel departmentById, String processid) { - if (!departmentById.isClosed()) { - List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); - for (DepartmentModel departmentModel : subDepartments) { - if (!departmentModel.isClosed()) { - String id = departmentModel.getId(); - List userModelList = SDK.getORGAPI().getAllUsersByDepartment(id); - for (UserModel userModel : userModelList) { - if (!userModel.isClosed()) { - String uid = userModel.getUID(); - if (!arr.contains(uid)) { - if (!"10033643".equals(uid)) { - // System.err.println("发送人员======>" + uid); } - arr.add(uid); - } - // System.err.println(SDK.getProcessAPI().getInstanceById(processid) + - // "_发送人员======>" + uid); - - } - } - } - // 递归获取子部门下的子部门 - if (SDK.getORGAPI().isExistSubDepartment(id)) { - getSubDepartments(jsonObject, arr_test, arr, SDK.getORGAPI().getDepartmentById(id), processid); - } - - } - - } - } - } - /** - * 创建线程发送待阅 - * - * @param list 人员集合 - * @param startTime 开始时间 - * @param jsonObject 发送的json串 - * @param processExecutionContext 流程数据 - */ - /* - * public void course(List list,long startTime,JSONObject - * jsonObject,ProcessExecutionContext processExecutionContext){ // - * 创建线程来实现为每300人为一个的线程跑待阅 ExecutorService service = - * Executors.newFixedThreadPool(4); service.execute(new Runnable() { - * - * @Override public void run() { int i=0; for (String[] resrt:list ) { - * - * if ((list.size()-1)==i){ long endTime = System.currentTimeMillis(); - * - * long time = endTime - startTime; long itmes = time/1000/60/60; BO - * bo_eu_pal_read_log = SDK.getBOAPI().query("BO_EU_PAL_READ_LOG", - * true).addQuery("PROCESSID = ", - * processExecutionContext.getProcessInstance().getId()).detail(); - * bo_eu_pal_read_log.set("ENDTIMES",endTime); - * bo_eu_pal_read_log.set("TIMECOUNT",itmes); - * SDK.getBOAPI().update("BO_EU_PAL_READ_LOG",bo_eu_pal_read_log); } try { - * SendOARead(jsonObject,processExecutionContext,resrt); } catch - * (DocumentException e) { e.printStackTrace(); } i++; } } }); } - */ - - /** - * 创建待阅日志 - * - * @param processExecutionContext - * @param jsonObject - * @param users - * @param startTime - */ - - public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject, - ArrayList arr, long startTime, long endTimes) { - 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()); - bo_Read_log.set("TITLE", jsonObject.get("title")); - bo_Read_log.set("PROCESSID", processInstId); - bo_Read_log.set("SENDNUM", arr.size()); - //应发人数 - String num = DBSql.getString("select count(user_id) AS NUMBERS from BO_ACT_DATAID where 1=1 AND PROCESSID='" + processInstId + "'"); - String read_num = DBSql.getString("select count(user_id) AS NUMBERS from BO_ACT_ALREADY_DATAID where 1=1 AND PROCESSID='" + processInstId + "'"); - Integer data = Integer.parseInt(num)+Integer.parseInt(read_num); - bo_Read_log.set("SENDNUMSJ", data); - - //去重漏发人数 - String disnum = DBSql.getString("SELECT COUNT(DISTINCT user_id) AS NUMBERS from BO_ACT_DATAID where 1=1 AND PROCESSID='" + processInstId + "'"); - String disread_num = DBSql.getString("SELECT COUNT(DISTINCT user_id) AS NUMBERS from BO_ACT_ALREADY_DATAID where 1=1 AND PROCESSID='" + processInstId + "'"); - Integer dis_data = Integer.parseInt(disnum)+Integer.parseInt(disread_num); - bo_Read_log.set("DISTINCTSUM", dis_data); - - - BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId) - .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); - String send_scop = bo_act_coe_publishs.getString("SEND_SCOP"); - bo_Read_log.set("SEND_SCOP", send_scop); - String SEND_SCOPE_ORG = bo_act_coe_publishs.getString("SEND_SCOPE_ORG"); - if (UtilString.isNotEmpty(SEND_SCOPE_ORG)) { - String[] resulr = SEND_SCOPE_ORG.split(","); - bo_Read_log.set("SEND_SCOPE_ORGNUM", resulr.length); - } - String SEND_SCOPE_POST = bo_act_coe_publishs.getString("SEND_SCOPE_POST"); - if (UtilString.isNotEmpty(SEND_SCOPE_POST)) { - String[] resulr = SEND_SCOPE_POST.split(","); - bo_Read_log.set("SEND_SCOPE_POST_NUM", resulr.length); - } - String SEND_SCOPE_LEVEL = bo_act_coe_publishs.getString("SEND_SCOPE_LEVEL"); - if (UtilString.isNotEmpty(SEND_SCOPE_LEVEL)) { - String[] resulr = SEND_SCOPE_LEVEL.split(","); - bo_Read_log.set("SEND_SCOPE_LEVEL_NUM", resulr.length); - } - - bo_Read_log.set("STARTTIMES", startTime); - bo_Read_log.set("ENDTIMES", endTimes); - long time = endTimes - startTime; - long diffSeconds = time / 1000 % 60; - long diffMinutes = time / (60 * 1000) % 60; - long diffHours = time / (60 * 60 * 1000) % 24; - long diffDays = time / (24 * 60 * 60 * 1000); - String remainTime = ""; - if (diffDays != 0 && diffHours != 0) { - remainTime = diffDays + "天" + diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒"; - } else if (diffDays == 0 && diffHours != 0 && diffMinutes != 0) { - remainTime = diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒"; - } else if (diffDays == 0 && diffHours == 0 && diffMinutes != 0) { - remainTime = diffMinutes + "分钟" + diffSeconds + "秒"; - } else if (diffDays == 0 && diffHours == 0 && diffMinutes == 0) { - remainTime = diffSeconds + "秒"; - } - bo_Read_log.set("TIMECOUNT", remainTime); - // 文件发布成功回执流程 - String titltes = jsonObject.get("title") + "成功发布回执单"; - ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance("obj_b4700f89a7a144c086d047de0cfe9531", - "admin", titltes); - BO bo = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", processInstId); - SDK.getBOAPI().create("BO_EU_PAL_PULBISH_SUCCESS", bo_Read_log, processInst, UserContext.fromUID("admin")); - TaskInstance taskInst = SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0); - SDK.getTaskAPI().completeTask(taskInst.getId(), "admin"); - SDK.getTaskAPI().createUserCCTaskInstance(processInst, taskInst, UserContext.fromUID("admin"), - bo.getString("PROCESS_MANAGER"), titltes); - - } - - /** - * 通过发布知识创建知识 - * - * @param bo 发布清单表数据 - * @param wsId 知识库id - * @param filed 文件集合JsonArray格式 - * @param processExecutionContext 流程数据 - * @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) { - { - OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); - wsId = model.getWsId(); - String publishfileid = bo.getString("PUBLISHFILEID"); - filed.add(publishfileid); - String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; - RowMap map = DBSql.getMap(sql_n); - if (StringUtils.isEmpty(map.getString("EXT4"))) { - // aslp服务地址 - String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; + paramss.put("sid", userContext.getSessionId()); + + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '" + + map.getString("ID") + "'" + ") ORDER BY FILENAME ASC"; + List maps = DBSql.getMaps(sql_upfile); + for (RowMap row : maps) { + if (!row.getString("FILENAME").contains(".xml")) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + paramss.put("dc", dcContexts); + AppAPI appAPIs = SDK.getAppAPI(); + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss); + + JSONArray coontest = new JSONArray(new LinkedList<>()); + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("documentId", cardId); + jsonObject.put("content", "");//信息附件 + jsonObject.put("abstract", dcContexts);//信息摘要 + jsonObject.put("title", dcContexts.getFileName().substring(0,dcContexts.getFileName().indexOf(".")));//信息标题 + coontest.add(jsonObject); + //createIndexesByContent(processExecutionContext,coontest); + + } + } + } + try { + + PublishKnow(processExecutionContext, userContext, cardId); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * 发布知识 + * + * @param processExecutionContext + * @param userContext + * @param id + */ + public void PublishKnow(ProcessExecutionContext processExecutionContext, 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 + "')"; + List maps = DBSql.getMaps(sql); + String ids = ""; + for (RowMap rowmap : maps) { + ids += rowmap.getString("EXT4") + ","; + } + String[] deptSplit_id = ids.split(","); + + JSONArray jsonArray = new JSONArray(); + for (String id_names : deptSplit_id) { + jsonArray.add(id_names); + } + // jsonObject.put(deptSplit_id); + id += ","; + String[] deptSplit_das = id.split(","); + JSONArray jsonArray_das = new JSONArray(); + for (String das : deptSplit_das) { + jsonArray_das.add(das); + } + // jsonObject.put(deptSplit_id); + + if (!jsonArray_das.isEmpty() && !jsonArray.isEmpty()) { + + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; + // 参数定义列表 + Map params = new HashMap(); + // 要发布到的维度ID的JSON数组字符串,必填 + params.put("dimensionIDArray", jsonArray.toString()); + // 要发布的知识ID的JSON数组字符串,必填 + params.put("knwlIDArray", jsonArray_das.toString()); + // 标签的JSON数组字符串,非必填 + + // sid,必填 + params.put("sid", userContext.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); + // 发布知识 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + + System.out.println("知识发布============" + ro); + + } + + } + + /** + * 取消发布知识 + * + * @param processExecutionContext + * @param sid + * @param knwlId + * @return + */ + public boolean CancelPublishKnwl(ProcessExecutionContext processExecutionContext, String sid, String knwlId) { + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl"; + // 参数定义列表 + Map params = new HashMap(); + // sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); + // 知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); + // 取消发布知识(全部维度) + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("取消发布的ro=====>>>>" + ro); + return ro.isOk(); + } + + /** + * 创建XPage页面上的待阅文件 + * + * @param processExecutionContext + * @param fileCreateName + * @param fileName + * @param fileurl + * @param readingScope_org + * @param isFullCompany + * @param fileCreateDate + * @param relationProcessinstId + * @param readingScope_post + * @param readingScope_level + * @param fileid + * @return + */ + public boolean execute(ProcessExecutionContext processExecutionContext, 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(); + // aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage"; + // 参数定义列表 + Map params = new HashMap(); + // 发布人,不允许空值,必填 + params.put("fileCreateName", fileCreateName); + // 待阅文件标题名称,不允许空值,必填 + params.put("fileName", fileName); + // 阅读范围_组织,不允许空值,非必填 + params.put("readingScope_org", readingScope_org); + // 是否全公司可见,不允许空值,必填 + params.put("isFullCompany", isFullCompany); + // 待阅文件Url,不允许空值,必填 + params.put("fileurl", fileurl); + // 发布日期,不允许空值,必填 + params.put("fileCreateDate", fileCreateDate); + // 发布流程ID,不允许空值,必填 + params.put("relationProcessinstId", relationProcessinstId); + // 阅读范围_岗位,不允许空值,非必填 + params.put("readingScope_post", readingScope_post); + // 阅读范围_职级,不允许空值,非必填 + params.put("readingScope_level", readingScope_level); + // 待阅文件ID,多个逗号隔开,不允许空值,必填 + params.put("fileid", fileid); + AppAPI appAPI = SDK.getAppAPI(); + // 推送待阅文件到xpage门户 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("ros++++++++=====待阅》》》》》》》》》》" + ro); + return ro.isOk(); + } + + /** + * 给知识授权 + * + * @param processExecutionContext + * @param jsonArray + * @param sid + * @param knwlId + * @return + */ + public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid, + String knwlId) { + + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; + // 参数定义列表 + Map params = new HashMap(); + // [{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 + params.put("acList", jsonArray); + // sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); + // 知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); + // 给知识授权 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + return ro.isOk(); + } + + /** + * 柱军的ASLP + * + * @param processExecutionContext + * @param wsId + * @param fileId + * @return + */ + public boolean AttrSynAslp(ProcessExecutionContext processExecutionContext, String wsId, JSONArray fileId) { + System.out.println(""); + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp"; + // 参数定义列表 + Map params = new HashMap(); + // 资产内容库id,必填 + params.put("wsId", wsId); + // 文件id;json数组[id1,id2,id3],必填 + params.put("fileId", fileId); + AppAPI appAPI = SDK.getAppAPI(); + // 增量同步数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("同步数据看板底表结果>>>>>>>>>>>>>" + ro); + return ro.isOk(); + } + + /** + * 发送OA待阅数据 + * + * @param jsonObject + * @param processInstance + * @param results + * @throws DocumentException + */ + public void SendOARead( ProcessInstance processInstance, String userIds,String type) + throws DocumentException { + + + + String processInstId = processInstance.getId(); + // System.err.println(processInstance.getTitle() + "开始发送:" + userId); + + /* + * if ("".equals(userId) || UtilString.isEmpty(userId)) { return; } + */ + + + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + .addQuery("BINDID=", processInstance.getId()) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + + String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + processInstance.getId() + + "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' "; + String taskInd = DBSql.getString(sql); + + TaskInstance ta = SDK.getTaskAPI().getInstanceById(taskInd); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + + processInstance.getId() + "&taskInstId=" + + taskInd; + String mobileurl = "https://bpm.yili.com:8088/portal" + + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + + processInstance.getId() + "&taskInstId=" + + taskInd; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime(); + Timestamp endTime = new Timestamp(System.currentTimeMillis()); + + JSONObject jsonObjects = new JSONObject(new LinkedHashMap()); + jsonObjects.put("action", "read"); + jsonObjects.put("title", " " + "" + bo_act_coe_publish1.getString("PROCESS_TITLE") + ""); + jsonObjects.put("dept", SDK.getORGAPI() + .getDepartmentByUser(ta.getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + String target = ta.getTarget(); + + jsonObjects.put("user", target); + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + jsonObjects.put("date", sdf.format(endTime)); + jsonObjects.put("remark", bo_act_coe_publish1.getString("PROCESS_TITLE")); + jsonObjects.put("status", "0"); + jsonObjects.put("dataid", processInstance.getId()); + jsonObjects.put("pcurl", url); + jsonObjects.put("mobileurl", mobileurl); + + String[] resrt = userIds.split(","); + long start_time = System.currentTimeMillis(); + System.out.println("待阅推送开始时间>>>>>>>>>>>>"+start_time); + BO bo_OA_read = new BO(); + bo_OA_read.set("FIR_NUMS",resrt.length); + bo_OA_read.set("START_TIME",start_time); + jsonObjects.put("userList", userIds); + String xmlStr = "\n" + + " " + " " + " " + " " + + "" + " " + " " + + " " + ""; + // System.out.println("xmlStr>>>>>>>>" + xmlStr); + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + UtilUrl uc=new UtilUrl(); + String postSoap =uc.doPostSoap(readurl, xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + System.out.println("jsonObject1==============="+jsonObject1); + String datas = jsonObject1.getString("data"); + long have_time = System.currentTimeMillis(); + System.out.println("接收到返回的待阅ID时间>>>>>>>>>>>>>>>>"+have_time); + bo_OA_read.set("HAVE_TIME",have_time); + System.out.println("接收到返回的待阅耗时时间>>>>>>>>>>>>"+(have_time-start_time)); + bo_OA_read.set("SUM_TIME",(have_time-start_time)); + System.out.println("data================="+datas); + String status = jsonObject1.getString("status"); + System.out.println("推送》》》》》》》》》》》" + status); + + + if ("true".equals(status)) { + JSONArray resultArray = JSONObject.parseArray(datas); + //System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人"); + //批量入库操作 + //加入时间戳 + long set_start_time = System.currentTimeMillis(); + bo_OA_read.set("SET_TIME",set_start_time); + if(resultArray.size()>0){ + List recordLists = new ArrayList(); + long startTime2 = System.currentTimeMillis(); + for (int j = 0; j < resultArray.size(); j++) { + + JSONObject jsonObject2 = resultArray.getJSONObject(j); + String user = jsonObject2.get("user").toString(); + String dataid = jsonObject2.get("dataid").toString(); + BO bo = new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("PROCESSID", processInstance.getId()); + bo.set("USER_ID", user); + //bo.set("USERDEP", SDK.getORGAPI().getUser(user).getDepartmentId()); + bo.set("DATAID", dataid); + bo.set("RESULT", status); + bo.set("SENDTYPE", "1"); + bo.set("READSTATE", "未读"); + bo.set("TYPE", type); + recordLists.add(bo); + + + } + SDK.getBOAPI().create("BO_ACT_DATAID",recordLists, processInstance, UserContext.fromUID(processInstance.getCreateUser())); + + long endTime2 = System.currentTimeMillis(); + System.err.println(processInstance.getTitle() + "批量插入OA待阅数据====>" + "用时:" + + (endTime2 - startTime2) / 1000 + "秒"); + + + BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",processInstance.getId()).detail(); + + String sqly = "SELECT COUNT(1) FROM BO_ACT_DATAID WHERE PROCESSID=? AND SENDTYPE='1'"; + int mapsy = DBSql.getInt(sqly, new Object[]{processInstance.getId()}); + + if(oa_real_time!=null){ + int r1 = DBSql.update("UPDATE BO_ACT_OA_REAL_TIME SET SENDNUMSJ='" +mapsy + "'WHERE PROCESSID ='" + processInstance.getId() + "'"); + }else{ + BO publishbo=SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").bindId(processInstance.getId()).detail(); + String user=publishbo.getString("APPLYUSERNAME"); + //插入实时更新人数表 + BO realTimeBO=new BO(); + realTimeBO.set("USREID", user); + realTimeBO.set("DEPID", ""); + realTimeBO.set("BUNAME",""); + realTimeBO.set("TITLE", processInstance.getTitle()); + realTimeBO.set("PROCESSID", processInstance.getId()); + realTimeBO.set("SENDNUMSJ", 1); + realTimeBO.set("SENDNUM",sendTotal); + SDK.getBOAPI().create("BO_ACT_OA_REAL_TIME", realTimeBO, processInstance, UserContext.fromUID(processInstance.getCreateUser())); + } + } + long set_end_time = System.currentTimeMillis(); + bo_OA_read.set("SET_END_TIME",set_end_time); + bo_OA_read.set("SET_SUM_TIME",(set_end_time-set_start_time)); + bo_OA_read.set("PROCESS_ID",processInstance.getId()); + SDK.getBOAPI().create("BO_EU_OA_READ_LOG", bo_OA_read, processInstance, UserContext.fromUID(processInstance.getCreateUser())); + if("单个账号推送".equals(type)) { + DBSql.update("UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '"+processInstId+"' AND NAME = '"+resrt+"'"); + } + } else { + List idList = Arrays.asList(resrt); + BO bo = null; + List recordFailLists = new ArrayList(); + if(idList.size()>0){ + for (String userId : idList) { + System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId); + try { + bo= new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("NAME", userId); + bo.set("TYPE", type); + bo.set("RESULT", "待处理"); + bo.set("PROCESSID", processInstId); + bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId()); + //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); + recordFailLists.add(bo); + } catch (Exception e) { + bo= new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("NAME", userIds); + bo.set("TYPE", type); + bo.set("RESULT", "待处理"); + bo.set("PROCESSID", processInstId); + bo.set("DEPNAME", SDK.getORGAPI().getUser(userIds).getDepartmentId()); + //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); + recordFailLists.add(bo); + } + } + System.out.println("recordFailLists========="+recordFailLists.size()); + SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processInstance, UserContext.fromUID(processInstance.getCreateUser())); + } + + + + + + + } + + } + + + + /** + * 发送OA待阅数据 + * + * @param jsonObject + * @param processInstance + * @param results + * @throws DocumentException + */ + public void secondSendOARead(ProcessInstance processInstance, List idList,String type) + throws DocumentException { + + + System.out.println("idList========="+idList.toString()); + String processInstId = processInstance.getId(); + // System.err.println(processInstance.getTitle() + "开始发送:" + userId); + + /* + * if ("".equals(userId) || UtilString.isEmpty(userId)) { return; } + */ + if (idList.size() == 0) { + return; + } + + // System.err.println(processInstance.getTitle() + "开始发送:" + userId); + + /* + * if ("".equals(userId) || UtilString.isEmpty(userId)) { return; } + */ + + + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + .addQuery("BINDID=", processInstance.getId()) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + + String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + processInstance.getId() + + "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' "; + String taskInd = DBSql.getString(sql); + + TaskInstance ta = SDK.getTaskAPI().getInstanceById(taskInd); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + + processInstance.getId() + "&taskInstId=" + + taskInd; + String mobileurl = "https://bpm.yili.com:8088/portal" + + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + + processInstance.getId() + "&taskInstId=" + + taskInd; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime(); + Timestamp endTime = new Timestamp(System.currentTimeMillis()); + + JSONObject jsonObjects = new JSONObject(new LinkedHashMap()); + jsonObjects.put("action", "read"); + jsonObjects.put("title", " " + "" + bo_act_coe_publish1.getString("PROCESS_TITLE") + ""); + jsonObjects.put("dept", SDK.getORGAPI() + .getDepartmentByUser(ta.getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + String target = ta.getTarget(); + + jsonObjects.put("user", target); + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + jsonObjects.put("date", sdf.format(endTime)); + jsonObjects.put("remark", bo_act_coe_publish1.getString("PROCESS_TITLE")); + jsonObjects.put("status", "0"); + jsonObjects.put("dataid", processInstance.getId()); + jsonObjects.put("pcurl", url); + jsonObjects.put("mobileurl", mobileurl); + + String userIds = StringUtils.join(idList, ","); + jsonObjects.put("userList", userIds); + String xmlStr = "\n" + + " " + " " + " " + " " + + "" + " " + " " + + " " + ""; + // System.out.println("xmlStr>>>>>>>>" + xmlStr); + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + UtilUrl uc=new UtilUrl(); + String postSoap = uc.doPostSoap(readurl, xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + System.out.println("jsonObject1==============="+jsonObject1); + String datas = jsonObject1.getString("data"); + System.out.println("data================="+datas); + String status = jsonObject1.getString("status"); + System.out.println("推送》》》》》》》》》》》" + status); + + + if ("true".equals(status)) { + JSONArray resultArray = JSONObject.parseArray(datas); + System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人"); + //批量入库操作 + //加入时间戳 + if(resultArray.size()>0){ + List recordLists = new ArrayList(); + long startTime2 = System.currentTimeMillis(); + for (int j = 0; j < resultArray.size(); j++) { + + JSONObject jsonObject2 = resultArray.getJSONObject(j); + String user = jsonObject2.get("user").toString(); + String dataid = jsonObject2.get("dataid").toString(); + BO bo = new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("PROCESSID", processInstance.getId()); + bo.set("USER_ID", user); + bo.set("USERDEP", SDK.getORGAPI().getUser(user).getDepartmentId()); + bo.set("DATAID", dataid); + bo.set("RESULT", status); + bo.set("SENDTYPE", "1"); + bo.set("READSTATE", "未读"); + bo.set("TYPE", type); + recordLists.add(bo); + + BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",processInstance.getId()).detail(); + + } + SDK.getBOAPI().create("BO_ACT_DATAID",recordLists, processInstance.getId(), processInstance.getCreateUser()); + + long endTime2 = System.currentTimeMillis(); + System.err.println(processInstance.getTitle() + "二次批量插入OA待阅数据====>" + "用时:" + + (endTime2 - startTime2) / 1000 + "秒"); + + + BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",processInstance.getId()).detail(); + + String sqly = "SELECT COUNT(1) FROM BO_ACT_DATAID WHERE PROCESSID=? AND SENDTYPE='1'"; + int mapsy = DBSql.getInt(sqly, new Object[]{processInstance.getId()}); + + if(oa_real_time!=null){ + int r1 = DBSql.update("UPDATE BO_ACT_OA_REAL_TIME SET SENDNUMSJ='" +mapsy + "'WHERE PROCESSID ='" + processInstance.getId() + "'"); + } + + } + + if("单个账号推送".equals(type)) { + DBSql.update("UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '"+processInstId+"' AND NAME = '"+userIds+"'"); + } + } + + } + + /** + * 发送EHSQ数据 + * + * @param jsonArray + * @return + * @throws Exception + */ + public String SendEHSQFile(String plName,JSONArray jsonArray) throws Exception { + /** + * 首先需要将传过来的参数进行加密操作,并设置 + */ + AesUtil aesUtil = new AesUtil(); + String system = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "system"); + String AES = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "AES"); + String EHSQUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "EHSQUrl"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date = sdf.format(new Date()); + String s1 = date.replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""); + + //System.out.println("时间>>>>>>>>>>>>" + s1); + String data = system + "##" + s1; + String encrypt = aesUtil.encrypt(data, AES); // 获取加密之后的秘钥 + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("system", system); + jsonObject.put("token", encrypt); + jsonObject.put("infos", jsonArray); + HttpUtil httpUtil = new HttpUtil(); + //System.out.println(plName+"发送EHSQ参数>>>>>" + jsonObject); + String s = httpUtil.sendPost(jsonObject, EHSQUrl); + //System.out.println(plName+"发送EHSQ结果>>>>>" + s); + + return s; + } + + public ArrayList getSendList(ProcessInstance instanceById, BO bo_act_coe_publish1, JSONObject jsonObject) { + String sendType = bo_act_coe_publish1.getString("SEND_SCOP"); + String org = bo_act_coe_publish1.getString("SEND_SCOPE_ORG"); + String post = bo_act_coe_publish1.getString("SEND_SCOPE_POST"); + String level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"); + ArrayList userList = new ArrayList<>(); + if ("1".equals(sendType)) { + //System.err.println("发送全集团=====>" + instanceById.getTitle()); + userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, sendType); + + } else { + /** + * 先组织和职级取交集,然后再和岗位取并集 + */ + if (UtilString.isNotEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isNotEmpty(level)) { + //System.err.println("发送组织/岗位/职级=====>" + instanceById.getTitle()); + ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, + sendType); + ArrayList sendLevel = sendLevel(level, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject); + userList = sendPost(post, sendLevel, instanceById, bo_act_coe_publish1, + jsonObject); + } + // 如果职级为空,组织/岗位取并集 + if (UtilString.isNotEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) { + //System.err.println("发送组织/岗位=====>" + instanceById.getTitle()); + ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, + sendType); + userList = sendPost(post, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject); + } + // 如果岗位为空,组织/职级取交集 + if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) { + //System.err.println("发送组织/职级=====>" + instanceById.getTitle()); + ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, + sendType); + userList = sendLevel(level, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject); + } + + /** + * 组织为空 岗位和职级取并集 + */ + if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isNotEmpty(level)) { + //System.err.println("发送岗位/职级=====>" + instanceById.getTitle()); + ArrayList sendLevel2 = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject); + userList = sendPost(post, sendLevel2, instanceById, bo_act_coe_publish1, + jsonObject); + } + // 如果只有组织不为空 + if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isEmpty(level)) { + //System.err.println("发送组织=====>" + instanceById.getTitle()); + userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, sendType); + } + // 如果只有岗位不为空 + if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) { + //System.err.println("发送岗位=====>" + instanceById.getTitle()); + userList = sendPost(post, userList, instanceById, bo_act_coe_publish1, jsonObject); + } + // 如果只有职级不为空 + if (UtilString.isEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) { + //System.err.println("发送职级=====>" + instanceById.getTitle()); + userList = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject); + } + + } + + return userList; + + } + + // 发送组织 + public ArrayList sendOrg(String org, ArrayList userList, ProcessInstance instanceById, + BO bo_act_coe_publish1, JSONObject jsonObject, String sendType) { + String processid = instanceById.getId(); + // 获取组织 + if (StringUtils.isNotEmpty(org) || "1".equals(sendType)) { + long startTime = System.currentTimeMillis(); + userList = getUser(jsonObject, org, sendType, processid); + long endTimes = System.currentTimeMillis(); + // System.out.println(instanceById.getTitle()+"_根据部门获取人员用时===>"+(endTimes-startTime)/1000); + } + + return userList; + } + + // 发送岗位 + public ArrayList sendPost(String post, ArrayList userList, ProcessInstance instanceById, + BO bo_act_coe_publish1, JSONObject jsonObject) { + String processid = instanceById.getId(); + // 获取岗位 + if (StringUtils.isNotEmpty(post)) { + String posts[] = post.split(","); + // 取并集 + String postss = ""; + if (posts.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + postss = "'" + posts[0] + "'"; + } else { + postss = "'" + StringUtils.join(posts, "','") + "'"; + } + String sql = "select * from ORGUSER where POSITION_NO in (" + postss + ") and userno is not null"; + List maps1 = DBSql.getMaps(sql); + for (RowMap rowMap : maps1) { + String userId = rowMap.getString("USERID"); + if (!userList.contains(userId)) { + boolean closed = SDK.getORGAPI().getUser(userId).isClosed(); + if(!closed) { + userList.add(userId); + } + } + + } + } + + return userList; + } + + // 发送职级 + public ArrayList sendLevel(String level, ArrayList userList, ProcessInstance instanceById, + BO bo_act_coe_publish1, JSONObject jsonObject) { + String processid = instanceById.getId(); + ArrayList userList_level = new ArrayList(); + // 获取职级 + if (StringUtils.isNotEmpty(level)) { + String ranks[] = level.split(","); + String rankss = ""; + if (ranks.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + rankss = "'" + ranks[0] + "'"; + } else { + rankss = "'" + StringUtils.join(ranks, "','") + "'"; + } + // 取交集 + String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; + List maps2 = DBSql.getMaps(sql2); + for (RowMap rowMap : maps2) { + String userId = rowMap.getString("USERID"); + if (userList.contains(userId)) { + boolean closed = SDK.getORGAPI().getUser(userId).isClosed(); + if(!closed) { + userList_level.add(userId); + } + } + + } + } + + return userList_level; + } + + // 只发送职级 + public ArrayList sendLevel2(String level, ArrayList userList, ProcessInstance instanceById, + BO bo_act_coe_publish1, JSONObject jsonObject) { + String processid = instanceById.getId(); + ArrayList userList_level = new ArrayList(); + // 获取职级 + if (StringUtils.isNotEmpty(level)) { + String ranks[] = level.split(","); + String rankss = ""; + if (ranks.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + rankss = "'" + ranks[0] + "'"; + } else { + rankss = "'" + StringUtils.join(ranks, "','") + "'"; + } + // 取交集 + String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; + List maps2 = DBSql.getMaps(sql2); + for (RowMap rowMap : maps2) { + String userId = rowMap.getString("USERID"); + boolean closed = SDK.getORGAPI().getUser(userId).isClosed(); + if(!closed) { + userList_level.add(userId); + } + } + } + return userList_level; + } + + /** + * 根据部门id获取当前部门以及下级部门的人员信息 + * + * @param processid + * @return + */ + + public ArrayList getUser(JSONObject jsonObject, String depIds, String sendType, String processid) { + ArrayList arr = new ArrayList(); + ArrayList arr_test = new ArrayList(); + // 全集团 + if ("1".equals(sendType)) { + List departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1, + "8911e732-b42a-4556-853f-ad32761bcbee"); + for (DepartmentModel departmentModel : departmentsByCompanyId) { + String id = departmentModel.getId(); + // 查询未注销的部门并且去掉系统部门 + if (!departmentModel.isClosed() && !"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id) + && !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id) + && !"65048aee-157f-49f2-a2dc-5903dd26f519".equals(id)) { + getUserList(jsonObject, arr_test, arr, id, processid); + + } + } + } else { + if (UtilString.isNotEmpty(depIds)) { + String[] split = depIds.split(","); + for (String depId : split) { + getUserList(jsonObject, arr_test, arr, depId, processid); + } + } + } + + // System.err.println(SDK.getProcessAPI().getInstanceById(processid) + + // "_得到的总人数为:" + arr_test.size()); + // System.err.println(SDK.getProcessAPI().getInstanceById(processid) + + // "_得到的过滤后的人数为:" + arr.size()); + return arr; + } + + public void getUserList(JSONObject jsonObject, ArrayList arr_test, ArrayList arr, + String departmentId, String processid) { + // 获取当前部门下人员 + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + String uid = userModel.getUID(); + if (!arr.contains(uid)) { + if (!"10033643".equals(uid)) { + // System.err.println("发送人员======>" + uid); } + arr.add(uid); + + } + /* + * RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" + * + processid + "' AND USER_ID = '" + uid + "'"); if (map == null) { + * //System.err.println("发送人员======>" + uid); } + */ + } + } + } + // 获取当前部门的子部门人员 + DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId); + if (departmentById.isExistSubModelOfCache()) { + getSubDepartments(jsonObject, arr_test, arr, departmentById, processid); + } + + } + + // 获取子部门人员 + public void getSubDepartments(JSONObject jsonObject, ArrayList arr_test, ArrayList arr, + DepartmentModel departmentById, String processid) { + if (!departmentById.isClosed()) { + List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); + for (DepartmentModel departmentModel : subDepartments) { + if (!departmentModel.isClosed()) { + String id = departmentModel.getId(); + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + String uid = userModel.getUID(); + if (!arr.contains(uid)) { + if (!"10033643".equals(uid)) { + // System.err.println("发送人员======>" + uid); } + arr.add(uid); + } + // System.err.println(SDK.getProcessAPI().getInstanceById(processid) + + // "_发送人员======>" + uid); + + } + } + } + // 递归获取子部门下的子部门 + if (SDK.getORGAPI().isExistSubDepartment(id)) { + getSubDepartments(jsonObject, arr_test, arr, SDK.getORGAPI().getDepartmentById(id), processid); + } + + } + + } + } + } + /** + * 创建线程发送待阅 + * + * @param list 人员集合 + * @param startTime 开始时间 + * @param jsonObject 发送的json串 + * @param processExecutionContext 流程数据 + */ + /* + * public void course(List list,long startTime,JSONObject + * jsonObject,ProcessExecutionContext processExecutionContext){ // + * 创建线程来实现为每300人为一个的线程跑待阅 ExecutorService service = + * Executors.newFixedThreadPool(4); service.execute(new Runnable() { + * + * @Override public void run() { int i=0; for (String[] resrt:list ) { + * + * if ((list.size()-1)==i){ long endTime = System.currentTimeMillis(); + * + * long time = endTime - startTime; long itmes = time/1000/60/60; BO + * bo_eu_pal_read_log = SDK.getBOAPI().query("BO_EU_PAL_READ_LOG", + * true).addQuery("PROCESSID = ", + * processExecutionContext.getProcessInstance().getId()).detail(); + * bo_eu_pal_read_log.set("ENDTIMES",endTime); + * bo_eu_pal_read_log.set("TIMECOUNT",itmes); + * SDK.getBOAPI().update("BO_EU_PAL_READ_LOG",bo_eu_pal_read_log); } try { + * SendOARead(jsonObject,processExecutionContext,resrt); } catch + * (DocumentException e) { e.printStackTrace(); } i++; } } }); } + */ + + /** + * 创建待阅日志 + * + * @param processExecutionContext + * @param jsonObject + * @param users + * @param startTime + */ + + public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject, + ArrayList arr, long startTime, long endTimes) { + 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()); + bo_Read_log.set("TITLE", jsonObject.get("title")); + bo_Read_log.set("PROCESSID", processInstId); + bo_Read_log.set("SENDNUM", arr.size()); + //应发人数 + String num = DBSql.getString("select count(user_id) AS NUMBERS from BO_ACT_DATAID where 1=1 AND PROCESSID='" + processInstId + "'"); + String read_num = DBSql.getString("select count(user_id) AS NUMBERS from BO_ACT_ALREADY_DATAID where 1=1 AND PROCESSID='" + processInstId + "'"); + Integer data = Integer.parseInt(num)+Integer.parseInt(read_num); + bo_Read_log.set("SENDNUMSJ", data); + + //去重漏发人数 + String disnum = DBSql.getString("SELECT COUNT(DISTINCT user_id) AS NUMBERS from BO_ACT_DATAID where 1=1 AND PROCESSID='" + processInstId + "'"); + String disread_num = DBSql.getString("SELECT COUNT(DISTINCT user_id) AS NUMBERS from BO_ACT_ALREADY_DATAID where 1=1 AND PROCESSID='" + processInstId + "'"); + Integer dis_data = Integer.parseInt(disnum)+Integer.parseInt(disread_num); + bo_Read_log.set("DISTINCTSUM", dis_data); + + + BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + String send_scop = bo_act_coe_publishs.getString("SEND_SCOP"); + bo_Read_log.set("SEND_SCOP", send_scop); + String SEND_SCOPE_ORG = bo_act_coe_publishs.getString("SEND_SCOPE_ORG"); + if (UtilString.isNotEmpty(SEND_SCOPE_ORG)) { + String[] resulr = SEND_SCOPE_ORG.split(","); + bo_Read_log.set("SEND_SCOPE_ORGNUM", resulr.length); + } + String SEND_SCOPE_POST = bo_act_coe_publishs.getString("SEND_SCOPE_POST"); + if (UtilString.isNotEmpty(SEND_SCOPE_POST)) { + String[] resulr = SEND_SCOPE_POST.split(","); + bo_Read_log.set("SEND_SCOPE_POST_NUM", resulr.length); + } + String SEND_SCOPE_LEVEL = bo_act_coe_publishs.getString("SEND_SCOPE_LEVEL"); + if (UtilString.isNotEmpty(SEND_SCOPE_LEVEL)) { + String[] resulr = SEND_SCOPE_LEVEL.split(","); + bo_Read_log.set("SEND_SCOPE_LEVEL_NUM", resulr.length); + } + + bo_Read_log.set("STARTTIMES", startTime); + bo_Read_log.set("ENDTIMES", endTimes); + long time = endTimes - startTime; + long diffSeconds = time / 1000 % 60; + long diffMinutes = time / (60 * 1000) % 60; + long diffHours = time / (60 * 60 * 1000) % 24; + long diffDays = time / (24 * 60 * 60 * 1000); + String remainTime = ""; + if (diffDays != 0 && diffHours != 0) { + remainTime = diffDays + "天" + diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒"; + } else if (diffDays == 0 && diffHours != 0 && diffMinutes != 0) { + remainTime = diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒"; + } else if (diffDays == 0 && diffHours == 0 && diffMinutes != 0) { + remainTime = diffMinutes + "分钟" + diffSeconds + "秒"; + } else if (diffDays == 0 && diffHours == 0 && diffMinutes == 0) { + remainTime = diffSeconds + "秒"; + } + bo_Read_log.set("TIMECOUNT", remainTime); + // 文件发布成功回执流程 + String titltes = jsonObject.get("title") + "成功发布回执单"; + ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance("obj_b4700f89a7a144c086d047de0cfe9531", + "admin", titltes); + BO bo = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", processInstId); + SDK.getBOAPI().create("BO_EU_PAL_PULBISH_SUCCESS", bo_Read_log, processInst, UserContext.fromUID("admin")); + TaskInstance taskInst = SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0); + SDK.getTaskAPI().completeTask(taskInst.getId(), "admin"); + SDK.getTaskAPI().createUserCCTaskInstance(processInst, taskInst, UserContext.fromUID("admin"), + bo.getString("PROCESS_MANAGER"), titltes); + + } + + /** + * 通过发布知识创建知识 + * + * @param bo 发布清单表数据 + * @param wsId 知识库id + * @param filed 文件集合JsonArray格式 + * @param processExecutionContext 流程数据 + * @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) { + { + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + filed.add(publishfileid); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))) { + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; // 参数定义列表 - Map params_create = new HashMap(); + Map params_create = new HashMap(); //保密级别, 0: 普通 1:秘密 2:机密,必填 - params_create.put("securityLevel", 0); + params_create.put("securityLevel", 0); //知识名称,必填 - String level = ""; - if (map != null) { - String pver = map.getString("PLVER"); - if (UtilString.isNotEmpty(pver)) { - if (pver.contains(".00")) { - String levels = pver; - String[] plvers = levels.split("\\."); - plvers[1] = plvers[1].replaceAll("0", ""); - level = plvers[0] + "." + plvers[1]; - } else { - level = pver + ".0"; - } - } - } - params_create.put("knwlName", map.getString("PLNAME") + "V" + level); + String level = ""; + if (map != null) { + String pver = map.getString("PLVER"); + if (UtilString.isNotEmpty(pver)) { + if (pver.contains(".00")) { + String levels = pver; + String[] plvers = levels.split("\\."); + plvers[1] = plvers[1].replaceAll("0", ""); + level = plvers[0] + "." + plvers[1]; + } else { + level = pver + ".0"; + } + } + } + params_create.put("knwlName", map.getString("PLNAME") + "V" + level); //是否可以评论,必填 - params_create.put("isComment", true); + params_create.put("isComment", true); //是否可以评分,必填 - params_create.put("isRate", true); + params_create.put("isRate", true); //有效期:yyyy-MM-dd,非必填 - params_create.put("validDate", "2099-12-31"); + params_create.put("validDate", "2099-12-31"); //只读控制,1:在线阅读和下载 0:在线阅读,必填 - params_create.put("onlineLevel", 1); + params_create.put("onlineLevel", 1); //知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 - params_create.put("createUser", "admin"); + params_create.put("createUser", "admin"); //知识内容,非必填 - params_create.put("cardContext", ""); + params_create.put("cardContext", ""); //sid,必填 - params_create.put("sid", processExecutionContext.getUserContext().getSessionId()); - AppAPI appAPI_create = SDK.getAppAPI(); + params_create.put("sid", processExecutionContext.getUserContext().getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); //创建知识 - ResponseObject ro_create = appAPI_create.callASLP( - appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), - aslps_create, params_create); - String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); - JSONArray jsonArray1 = new JSONArray(); - //判断是否发送全公司,1为全公司0为部分人员,如果是全公司的授权公司id,如果是部门并且其他两个字段为空,授权部门,否则就授权人员 - if (bo_act_coe_publish.getString("SEND_SCOP").equals("1")) { - JSONObject jsonObjecta = new JSONObject(); - jsonObjecta.put("assignmentType", "company"); - jsonObjecta.put("assignmentId", "8911e732-b42a-4556-853f-ad32761bcbee"); - jsonArray1.add(jsonObjecta); - } else { - String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); - if (StringUtils.isNotEmpty(departId) - && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) - && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { - String strs[] = departId.split(","); - for (String departmentid : strs) { - JSONObject jsonObjecta = new JSONObject(); - jsonObjecta.put("assignmentType", "department"); - jsonObjecta.put("assignmentId", departmentid); - jsonArray1.add(jsonObjecta); - } - } else { - String[] split = uid.split(","); + ResponseObject ro_create = appAPI_create.callASLP( + appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), + aslps_create, params_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + //根据表单字段判断是否发送全公司,1为全公司,0为部分人员,发送全公司的则授权公司id,只有部门则授权部门,如果包含部门,职级,岗位则授权该范围的人员id + if (bo_act_coe_publish.getString("SEND_SCOP").equals("1")) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "company"); + jsonObjecta.put("assignmentId", "8911e732-b42a-4556-853f-ad32761bcbee"); + jsonArray1.add(jsonObjecta); + } else { + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) + && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) + && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + } else { + String[] split = uid.split(","); - List list = new ArrayList(Arrays.asList(split)); + List list = new ArrayList(Arrays.asList(split)); - HashSet h = new HashSet(list); - list.clear(); - list.addAll(h); + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); - for (String user_id : list) { - JSONObject jsonObjecta = new JSONObject(); - jsonObjecta.put("assignmentType", "user"); - jsonObjecta.put("assignmentId", user_id); - jsonArray1.add(jsonObjecta); - } - } + for (String user_id : list) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray1.add(jsonObjecta); + } + } - } + } - AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), - cardId); + AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), + cardId); - String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " - + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " - + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" - + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" - + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," - + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," - + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," - + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," - + " '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(), - cardId, "PUBLISHFILEID = "); - } - } - } + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '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(), + cardId, "PUBLISHFILEID = "); + } + } + } - /** - * 发布生成kms知识 - * - * @param bo 更新发布清单表 - * @param wsId 知识库id - * @param filed 发布清单的发布id - * @param processExecutionContext 流程数据 - * @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) { - { - OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); - wsId = model.getWsId(); - String publishfileid = bo.getString("CHANGEDFILEIDNEW"); - filed.add(publishfileid); - DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where id = '" + publishfileid + "'"); - String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; - RowMap map = DBSql.getMap(sql_n); - if (StringUtils.isEmpty(map.getString("EXT4"))) { - // aslp服务地址 - String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; + /** + * 发布生成kms知识 + * + * @param bo 更新发布清单表 + * @param wsId 知识库id + * @param filed 发布清单的发布id + * @param processExecutionContext 流程数据 + * @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) { + { + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + filed.add(publishfileid); + DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where id = '" + publishfileid + "'"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))) { + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; // 参数定义列表 - Map params_create = new HashMap(); + Map params_create = new HashMap(); //保密级别, 0: 普通 1:秘密 2:机密,必填 - params_create.put("securityLevel", 0); + params_create.put("securityLevel", 0); //知识名称,必填 - String level = ""; - if (map != null) { - String pver = map.getString("PLVER"); - if (UtilString.isNotEmpty(pver)) { - if (pver.contains(".00")) { - String levels = pver; - String[] plvers = levels.split("\\."); - plvers[1] = plvers[1].replaceAll("0", ""); - level = plvers[0] + "." + plvers[1]; - } else { - level = pver + ".0"; - } - } - } + String level = ""; + if (map != null) { + String pver = map.getString("PLVER"); + if (UtilString.isNotEmpty(pver)) { + if (pver.contains(".00")) { + String levels = pver; + String[] plvers = levels.split("\\."); + plvers[1] = plvers[1].replaceAll("0", ""); + level = plvers[0] + "." + plvers[1]; + } else { + level = pver + ".0"; + } + } + } - params_create.put("knwlName", map.getString("PLNAME") + "V" + level); + params_create.put("knwlName", map.getString("PLNAME") + "V" + level); //是否可以评论,必填 - params_create.put("isComment", true); + params_create.put("isComment", true); //是否可以评分,必填 - params_create.put("isRate", true); + params_create.put("isRate", true); //有效期:yyyy-MM-dd,非必填 - params_create.put("validDate", "2099-12-31"); + params_create.put("validDate", "2099-12-31"); //只读控制,1:在线阅读和下载 0:在线阅读,必填 - params_create.put("onlineLevel", 1); + params_create.put("onlineLevel", 1); //知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 - params_create.put("createUser", "admin"); + params_create.put("createUser", "admin"); //知识内容,非必填 - params_create.put("cardContext", ""); + params_create.put("cardContext", ""); //sid,必填 - params_create.put("sid", processExecutionContext.getUserContext().getSessionId()); - AppAPI appAPI_create = SDK.getAppAPI(); + params_create.put("sid", processExecutionContext.getUserContext().getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); //创建知识 - ResponseObject ro_create = appAPI_create.callASLP( - appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), - aslps_create, params_create); - // System.out.println("ro_create================" + ro_create); - String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); - JSONArray jsonArray1 = new JSONArray(); - //判断是否发送全公司,1为全公司0为部分人员,如果是全公司的授权公司id,如果是部门并且其他两个字段为空,授权部门,否则就授权人员 - if (bo_act_coe_publish.getString("SEND_SCOP").equals("1")) { - JSONObject jsonObjecta = new JSONObject(); - jsonObjecta.put("assignmentType", "company"); - jsonObjecta.put("assignmentId", "8911e732-b42a-4556-853f-ad32761bcbee"); - jsonArray1.add(jsonObjecta); - } else { - String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); - if (StringUtils.isNotEmpty(departId) - && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) - && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { - String strs[] = departId.split(","); - for (String departmentid : strs) { - JSONObject jsonObjecta = new JSONObject(); - jsonObjecta.put("assignmentType", "department"); - jsonObjecta.put("assignmentId", departmentid); - jsonArray1.add(jsonObjecta); - } - } else { - String[] split = uid.split(","); + ResponseObject ro_create = appAPI_create.callASLP( + appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), + aslps_create, params_create); + // System.out.println("ro_create================" + ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + //根据表单字段判断是否发送全公司,1为全公司,0为部分人员,发送全公司的则授权公司id,只有部门则授权部门,如果包含部门,职级,岗位则授权该范围的人员id - List list = new ArrayList(Arrays.asList(split)); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("1")) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "company"); + jsonObjecta.put("assignmentId", "8911e732-b42a-4556-853f-ad32761bcbee"); + jsonArray1.add(jsonObjecta); + } else { + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) + && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) + && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + } else { + String[] split = uid.split(","); - HashSet h = new HashSet(list); - list.clear(); - list.addAll(h); + List list = new ArrayList(Arrays.asList(split)); - for (String user_id : list) { - JSONObject jsonObjecta = new JSONObject(); - jsonObjecta.put("assignmentType", "user"); - jsonObjecta.put("assignmentId", user_id); - jsonArray1.add(jsonObjecta); - } - } + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); - } - AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), - cardId); + for (String user_id : list) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray1.add(jsonObjecta); + } + } - String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " - + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " - + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" - + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" - + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," - + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," - + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," - + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," - + " '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_C", processExecutionContext.getUserContext(), - cardId, " CHANGEDFILEIDNEW="); - } - // 将旧的知识取消发布或者移动到废止发布中 - String publishfileid_old = bo.getString("CHANGEFILEID"); - 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(), - map1.getString("EXT4")); - DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_old + "'"); - } - } - } + } + AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), + cardId); - // 创建推送日志 - public void createLog(ProcessInstance instanceById, String uids) { - BO bo = new BO();// BO_EU_PAL_SEND_LOG - bo.set("USREID", instanceById.getCreateUser()); - bo.set("TITLE", instanceById.getTitle()); - bo.set("SENDTIME", instanceById.getEndTime()); - bo.set("PROCESSID", instanceById.getId()); - bo.set("USERNAMES", uids); - bo.set("DEPID", UserContext.fromUID(uids).getDepartmentModel().getId()); - bo.set("POSTNAME", UserContext.fromUID(uids).getUserModel().getPositionName()); - bo.set("BUNAME", UserContext.fromUID(uids).getUserModel().getExt2()); - SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG", bo, UserContext.fromUID("admin")); - } + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '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_C", processExecutionContext.getUserContext(), + cardId, " CHANGEDFILEIDNEW="); + } + // 将旧的知识取消发布或者移动到废止发布中 + String publishfileid_old = bo.getString("CHANGEFILEID"); + 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(), + map1.getString("EXT4")); + DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_old + "'"); + } + } + } - public void sendEHSQ(ProcessExecutionContext processExecutionContext, List bo_act_coe_publish_n) { - for (BO bo : bo_act_coe_publish_n) { - DownloadUtil downloadUtil = new DownloadUtil(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - JSONArray jsonArray_EHSQ = new JSONArray(); - JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); - OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); - String wsId = model.getWsId(); - String publishfileid = bo.getString("PUBLISHFILEID"); - LinkedHashMap downloadurl = downloadUtil.outputReportDownload( - UserContext.fromUID(processExecutionContext.getProcessInstance().getCreateUser()), - bo.getString("TASKID"), publishfileid); - jsonObject_ehsq.put("fileid", bo.getString("TASKID")); - String plName = bo.getString("PUBLISHFILENAME"); - jsonObject_ehsq.put("filename", bo.getString("PUBLISHFILENAME")); - String plNumer = bo.getString("PUBLISH_NUMBER"); - jsonObject_ehsq.put("filecode",bo.getString("PUBLISH_NUMBER")); - //jsonObject_ehsq.put("filecode", "123456"); - String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; - 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()); - String cdeDate = byProcess.getString("CHOICEEFFECTIVEDATE"); - if("1".equals(cdeDate)) { - jsonObject_ehsq.put("releasedate", byProcess.getString("EFFECTIVEDATE")); - jsonObject_ehsq.put("effectivedate", byProcess.getString("EFFECTIVEDATE")); - }else { - 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("authorname", - UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); - // jsonObject_ehsq.put("authorname","毛鹏程"); - jsonObject_ehsq.put("companycode", UserContext - .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); - // jsonObject_ehsq.put("companycode","00000013"); - jsonObject_ehsq.put("authorcompany", UserContext - .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); // jsonObject_ehsq.put("authorcompany","总部质量管理部"); - // // - BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) - .addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); - if (bo1 != null) { - if (bo1.getString("PERMTYPE").equals("1")) { - jsonObject_ehsq.put("releasescope", "内蒙古伊利实业集团股份有限公司"); - } else { + // 创建推送日志 + public void createLog(ProcessInstance instanceById, String uids) { + BO bo = new BO();// BO_EU_PAL_SEND_LOG + bo.set("USREID", instanceById.getCreateUser()); + bo.set("TITLE", instanceById.getTitle()); + bo.set("SENDTIME", instanceById.getEndTime()); + bo.set("PROCESSID", instanceById.getId()); + bo.set("USERNAMES", uids); + bo.set("DEPID", UserContext.fromUID(uids).getDepartmentModel().getId()); + bo.set("POSTNAME", UserContext.fromUID(uids).getUserModel().getPositionName()); + bo.set("BUNAME", UserContext.fromUID(uids).getUserModel().getExt2()); + SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG", bo, UserContext.fromUID("admin")); + } - String departname = ""; + public void sendEHSQ(ProcessExecutionContext processExecutionContext, List bo_act_coe_publish_n) { + for (BO bo : bo_act_coe_publish_n) { + DownloadUtil downloadUtil = new DownloadUtil(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + JSONArray jsonArray_EHSQ = new JSONArray(); + JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + String wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload( + UserContext.fromUID(processExecutionContext.getProcessInstance().getCreateUser()), + bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid", bo.getString("TASKID")); + String plName = bo.getString("PUBLISHFILENAME"); + jsonObject_ehsq.put("filename", bo.getString("PUBLISHFILENAME")); + String plNumer = bo.getString("PUBLISH_NUMBER"); + jsonObject_ehsq.put("filecode",bo.getString("PUBLISH_NUMBER")); + //jsonObject_ehsq.put("filecode", "123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + 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()); + String cdeDate = byProcess.getString("CHOICEEFFECTIVEDATE"); + if("1".equals(cdeDate)) { + jsonObject_ehsq.put("releasedate", byProcess.getString("EFFECTIVEDATE")); + jsonObject_ehsq.put("effectivedate", byProcess.getString("EFFECTIVEDATE")); + }else { + 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("authorname", + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + // jsonObject_ehsq.put("authorname","毛鹏程"); + jsonObject_ehsq.put("companycode", UserContext + .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + // jsonObject_ehsq.put("companycode","00000013"); + jsonObject_ehsq.put("authorcompany", UserContext + .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); // jsonObject_ehsq.put("authorcompany","总部质量管理部"); + // // + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) + .addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1 != null) { + if (bo1.getString("PERMTYPE").equals("1")) { + jsonObject_ehsq.put("releasescope", "内蒙古伊利实业集团股份有限公司"); + } else { + + /*String departname = ""; String orgperm = bo1.getString("ORGPERM"); String dleass = ""; String[] deptSplit = orgperm.split(","); @@ -2120,234 +2129,235 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute if(UtilString.isNotEmpty(departname)&&departname.length()>500) { String substring = departname.substring(0, 500); departname = substring.substring(0,substring.lastIndexOf(";")); - } - jsonObject_ehsq.put("releasescope", departname); + }*/ + //jsonObject_ehsq.put("releasescope", departname); - } - } + jsonObject_ehsq.put("releasescope", byProcess.getString("IS_THE_UNIT")); + } + } - //System.out.println("任务办理者>>>>>>>>>>>" + processExecutionContext.getTaskInstance().getTarget()); - String sessionId = new SSOUtil().registerClientSessionNoPassword( - processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", - LoginConst.DEVICE_PC); + //System.out.println("任务办理者>>>>>>>>>>>" + processExecutionContext.getTaskInstance().getTarget()); + String sessionId = new SSOUtil().registerClientSessionNoPassword( + processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", + LoginConst.DEVICE_PC); - //System.out.println("办理者的sessionid>>>>>>>>>>>" + sessionId); - String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), bo.getString("PUBLISHFILENAME")); - // jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1)); - String recordfiles = ""; - String recordurls = ""; - Set keys = downloadurl.keySet(); - for (String key : keys) { - recordfiles += key + ";"; - String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"), - downloadurl.get(key).length()); - String fileDownurl = "http://bpm.yili.com:8088/portal/r" + cent_url; - recordurls += fileDownurl + ";"; - } - String new_name = ""; - String[] split = recordfiles.split(";"); - if (split.length > 0) { + //System.out.println("办理者的sessionid>>>>>>>>>>>" + sessionId); + String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), bo.getString("PUBLISHFILENAME")); + // jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1)); + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for (String key : keys) { + recordfiles += key + ";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"), + downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r" + cent_url; + recordurls += fileDownurl + ";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length > 0) { - for (int i = 1; i < split.length; i++) { - new_name += split[i] + ";"; - } - } + for (int i = 1; i < split.length; i++) { + new_name += split[i] + ";"; + } + } - String new_url = ""; - String[] urls = recordurls.split(";"); - if (urls.length > 0) { - String loadurl = urls[0].replaceAll("&sid=null", "&sid=" + sessionId); - System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<" + loadurl); - jsonObject_ehsq.put("downloadurl", loadurl); - for (int i = 1; i < urls.length; i++) { - String data_url = urls[i].replaceAll("&sid=null", "&sid=" + sessionId); - new_url += data_url + ";"; - } - } - jsonObject_ehsq.put("recordfiles", new_name); - jsonObject_ehsq.put("recordurls", new_url); - jsonArray_EHSQ.add(jsonObject_ehsq); + String new_url = ""; + String[] urls = recordurls.split(";"); + if (urls.length > 0) { + String loadurl = urls[0].replaceAll("&sid=null", "&sid=" + sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<" + loadurl); + jsonObject_ehsq.put("downloadurl", loadurl); + for (int i = 1; i < urls.length; i++) { + String data_url = urls[i].replaceAll("&sid=null", "&sid=" + sessionId); + new_url += data_url + ";"; + } + } + jsonObject_ehsq.put("recordfiles", new_name); + jsonObject_ehsq.put("recordurls", new_url); + jsonArray_EHSQ.add(jsonObject_ehsq); - Date date = new Date(); - SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - UserContext uc = processExecutionContext.getUserContext(); - 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); - 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); - }else { - createSendLog(userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布推送", sendEHSQFile); - } - } catch (Exception e) { - String sql = "SELECT ID FROM BO_EU_PAL_SEND_EHSQ_JOB WHERE PLID = '"+publishfileid+"' AND USERNAMES = '"+userName+"'"; - String id = DBSql.getString(sql); - 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), "流程发布推送", e.getMessage()); - }else { - createSendLog(userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布推送", e.getMessage()); - } - } - } - } + Date date = new Date(); + SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + UserContext uc = processExecutionContext.getUserContext(); + 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); + 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); + }else { + createSendLog(userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布推送", sendEHSQFile); + } + } catch (Exception e) { + String sql = "SELECT ID FROM BO_EU_PAL_SEND_EHSQ_JOB WHERE PLID = '"+publishfileid+"' AND USERNAMES = '"+userName+"'"; + String id = DBSql.getString(sql); + 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), "流程发布推送", e.getMessage()); + }else { + createSendLog(userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布推送", e.getMessage()); + } + } + } + } - public void createSendLog(String username,String userDempet,String plId,String plName,String plNumer,String sendTime,String sendType,String sendResult) { - BO bo = new BO(); - bo.set("PLID", plId); - bo.set("PLNAME", plName); - bo.set("PLNUMER", plNumer); - bo.set("SENDTIME", sendTime); - bo.set("SENDTYPE", sendType); - bo.set("SENDRESULT", sendResult); - bo.set("USERNAMES", username); - bo.set("USERDEMPET", userDempet); - SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_EHSQ_JOB", bo, UserContext.fromUID("admin")); - } - public void updateSendLog(BO bo,String username,String userDempet,String plId,String plName,String plNumer,String sendTime,String sendType,String sendResult) { - bo.set("PLNUMER", plNumer); - bo.set("SENDTIME", sendTime); - bo.set("SENDTYPE", sendType); - 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) { - DownloadUtil downloadUtil = new DownloadUtil(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - for (BO bo : bo_act_coe_publish_c) { - JSONArray jsonArray_EHSQ = new JSONArray(); - JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); - OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); - String wsId = model.getWsId(); - String publishfileid = bo.getString("CHANGEDFILEIDNEW"); - LinkedHashMap downloadurl = downloadUtil.outputReportDownload( - UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), bo.getString("TASKID"), - publishfileid); - jsonObject_ehsq.put("fileid", bo.getString("TASKID")); - String plName = bo.getString("CHANGEDFILENAMENEW"); - String plNumer = bo.getString("CHANGE_NUMBER"); - jsonObject_ehsq.put("filename", plName); - jsonObject_ehsq.put("filecode",plNumer); - //jsonObject_ehsq.put("filecode", "123456"); - String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; - 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()); - String cdeDate = byProcess.getString("CHOICEEFFECTIVEDATE"); - if("1".equals(cdeDate)) { - jsonObject_ehsq.put("releasedate", byProcess.getString("EFFECTIVEDATE")); - jsonObject_ehsq.put("effectivedate", byProcess.getString("EFFECTIVEDATE")); - }else { - 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("authorname", - UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); - jsonObject_ehsq.put("companycode", UserContext - .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); - jsonObject_ehsq.put("authorcompany", UserContext - .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); - BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) - .addQuery("PALNAME=", bo.getString("CHANGEDFILENAMENEW")).detail(); - if (bo1 != null) { - if (bo1.getString("PERMTYPE").equals("1")) { - jsonObject_ehsq.put("releasescope", "内蒙古伊利实业集团股份有限公司"); - } else { + public void createSendLog(String username,String userDempet,String plId,String plName,String plNumer,String sendTime,String sendType,String sendResult) { + BO bo = new BO(); + bo.set("PLID", plId); + bo.set("PLNAME", plName); + bo.set("PLNUMER", plNumer); + bo.set("SENDTIME", sendTime); + bo.set("SENDTYPE", sendType); + bo.set("SENDRESULT", sendResult); + bo.set("USERNAMES", username); + bo.set("USERDEMPET", userDempet); + SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_EHSQ_JOB", bo, UserContext.fromUID("admin")); + } + public void updateSendLog(BO bo,String username,String userDempet,String plId,String plName,String plNumer,String sendTime,String sendType,String sendResult) { + bo.set("PLNUMER", plNumer); + bo.set("SENDTIME", sendTime); + bo.set("SENDTYPE", sendType); + 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) { + DownloadUtil downloadUtil = new DownloadUtil(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + for (BO bo : bo_act_coe_publish_c) { + JSONArray jsonArray_EHSQ = new JSONArray(); + JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + String wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload( + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), bo.getString("TASKID"), + publishfileid); + jsonObject_ehsq.put("fileid", bo.getString("TASKID")); + String plName = bo.getString("CHANGEDFILENAMENEW"); + String plNumer = bo.getString("CHANGE_NUMBER"); + jsonObject_ehsq.put("filename", plName); + jsonObject_ehsq.put("filecode",plNumer); + //jsonObject_ehsq.put("filecode", "123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + 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()); + String cdeDate = byProcess.getString("CHOICEEFFECTIVEDATE"); + if("1".equals(cdeDate)) { + jsonObject_ehsq.put("releasedate", byProcess.getString("EFFECTIVEDATE")); + jsonObject_ehsq.put("effectivedate", byProcess.getString("EFFECTIVEDATE")); + }else { + 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("authorname", + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + jsonObject_ehsq.put("companycode", UserContext + .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + jsonObject_ehsq.put("authorcompany", UserContext + .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) + .addQuery("PALNAME=", bo.getString("CHANGEDFILENAMENEW")).detail(); + if (bo1 != null) { + if (bo1.getString("PERMTYPE").equals("1")) { + jsonObject_ehsq.put("releasescope", "内蒙古伊利实业集团股份有限公司"); + } else { - String departname = ""; - String orgperm = bo1.getString("ORGPERM"); - String dleass = ""; - String[] deptSplit = orgperm.split(","); - if (deptSplit.length == 1) { - dleass = "'" + deptSplit[0] + "'"; - } - dleass = "'" + StringUtils.join(deptSplit, "','") + "'"; + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if (deptSplit.length == 1) { + dleass = "'" + deptSplit[0] + "'"; + } + dleass = "'" + StringUtils.join(deptSplit, "','") + "'"; - List maps = DBSql - .getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); - for (RowMap rowmas : maps) { - departname += rowmas.getString("DEPARTMENTNAME") + ";"; - } - if(UtilString.isNotEmpty(departname)&&departname.length()>500) { - String substring = departname.substring(0, 500); - departname = substring.substring(0,substring.lastIndexOf(";")); - } - jsonObject_ehsq.put("releasescope", departname); + List maps = DBSql + .getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas : maps) { + departname += rowmas.getString("DEPARTMENTNAME") + ";"; + } + if(UtilString.isNotEmpty(departname)&&departname.length()>500) { + String substring = departname.substring(0, 500); + departname = substring.substring(0,substring.lastIndexOf(";")); + } + jsonObject_ehsq.put("releasescope", departname); - } - } + } + } - String sessionId = new SSOUtil().registerClientSessionNoPassword( - processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", - LoginConst.DEVICE_PC); + String sessionId = new SSOUtil().registerClientSessionNoPassword( + processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", + LoginConst.DEVICE_PC); - String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), - bo.getString("CHANGEDFILENAMENEW")); - String recordfiles = ""; - String recordurls = ""; - Set keys = downloadurl.keySet(); - for (String key : keys) { - recordfiles += key + ";"; - String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"), - downloadurl.get(key).length()); - String fileDownurl = "http://bpm.yili.com:8088/portal/r" + cent_url; - recordurls += fileDownurl + ";"; - } - String new_name = ""; - String[] split = recordfiles.split(";"); - if (split.length > 0) { + String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), + bo.getString("CHANGEDFILENAMENEW")); + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for (String key : keys) { + recordfiles += key + ";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"), + downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r" + cent_url; + recordurls += fileDownurl + ";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length > 0) { - for (int i = 1; i < split.length; i++) { - new_name += split[i] + ";"; - } - } + for (int i = 1; i < split.length; i++) { + new_name += split[i] + ";"; + } + } - String new_url = ""; - String[] urls = recordurls.split(";"); - if (urls.length > 0) { - String loadurl = urls[0].replaceAll("&sid=null", "&sid=" + sessionId); - System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<" + loadurl); - jsonObject_ehsq.put("downloadurl", loadurl); - for (int i = 1; i < urls.length; i++) { - String data_url = urls[i].replaceAll("&sid=null", "&sid=" + sessionId); - new_url += data_url + ";"; - } - } - jsonObject_ehsq.put("recordfiles", new_name); - jsonObject_ehsq.put("recordurls", new_url); - jsonArray_EHSQ.add(jsonObject_ehsq); - Date date = new Date(); - SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - UserContext uc = processExecutionContext.getUserContext(); - 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); - 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); - }else { - createSendLog(userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布更新", sendEHSQFile); - } - } catch (Exception e) { - String sql = "SELECT ID FROM BO_EU_PAL_SEND_EHSQ_JOB WHERE PLID = '"+publishfileid+"' AND USERNAMES = '"+userName+"'"; - String id = DBSql.getString(sql); - 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), "流程发布更新", e.getMessage()); - }else { - createSendLog(userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布更新", e.getMessage()); - } - } - } - } + String new_url = ""; + String[] urls = recordurls.split(";"); + if (urls.length > 0) { + String loadurl = urls[0].replaceAll("&sid=null", "&sid=" + sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<" + loadurl); + jsonObject_ehsq.put("downloadurl", loadurl); + for (int i = 1; i < urls.length; i++) { + String data_url = urls[i].replaceAll("&sid=null", "&sid=" + sessionId); + new_url += data_url + ";"; + } + } + jsonObject_ehsq.put("recordfiles", new_name); + jsonObject_ehsq.put("recordurls", new_url); + jsonArray_EHSQ.add(jsonObject_ehsq); + Date date = new Date(); + SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + UserContext uc = processExecutionContext.getUserContext(); + 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); + 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); + }else { + createSendLog(userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布更新", sendEHSQFile); + } + } catch (Exception e) { + String sql = "SELECT ID FROM BO_EU_PAL_SEND_EHSQ_JOB WHERE PLID = '"+publishfileid+"' AND USERNAMES = '"+userName+"'"; + String id = DBSql.getString(sql); + 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), "流程发布更新", e.getMessage()); + }else { + createSendLog(userName, uc.getDepartmentModel().getName(), publishfileid, plName, plNumer, dateFormat.format(date), "流程发布更新", e.getMessage()); + } + } + } + } }