diff --git a/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar b/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar
index 3545798e..0ff167c7 100644
Binary files a/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar and b/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar differ
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java
index a69e93cc..5bc31aef 100644
--- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java
@@ -2563,7 +2563,7 @@ public class ProcessPublishWeb extends ActionWeb {
if (model == null)
throw new AWSException("没有找到文件:" + uuid);
String taskId = "";
- if (("control.policy".equals(model.getMethodId()) || "data.form".equals(model.getMethodId()) || model.getMethodId().contains("process.")) && !"default".equals(model.getMethodId())) {
+ if (("control.policy".equals(model.getMethodId()) || "data.form".equals(model.getMethodId()) || model.getMethodId().contains("process.")) && !"default".equals(model.getMethodId()) && !"process.scheme".equals(model.getMethodId())) {
} else
throw new AWSException("文件不支持创建流程手册:" + uuid);
if (model.getMethodId().contains("process.")) {
@@ -2999,7 +2999,7 @@ public class ProcessPublishWeb extends ActionWeb {
for (UpfileModel upfileModel : fileList) {
String type = upfileModel.getType();
- if(!methodId.equals("control.policy") || methodId.contains("process")){
+ if(!methodId.equals("control.policy") && methodId.contains("process") && !methodId.equals("engineering.standard")){
if ("s".equals(upfileModel.getType())) {
JSONObject jb = new JSONObject();
@@ -3255,7 +3255,7 @@ public class ProcessPublishWeb extends ActionWeb {
if (fileList != null && fileList.size() > 0)
for (UpfileModel upfileModel : fileList){
String type = upfileModel.getType();
- if(!methodId.equals("control.policy") || methodId.contains("process")){
+ if(!methodId.equals("control.policy") && methodId.contains("process") && !methodId.equals("engineering.standard")){
if ("s".equals(upfileModel.getType())) {
JSONObject jb = new JSONObject();
//按照附件编号排序
@@ -3748,7 +3748,7 @@ public class ProcessPublishWeb extends ActionWeb {
taskId = object.getJSONObject("data").getString("taskId");
else
throw new AWSException("创建表单手册失败:" + uuid);
- } else if ("control.policy".equals(model.getMethodId())) {
+ } else if ("control.policy".equals(model.getMethodId())|| "engineering.standard".equals(model.getMethodId()) || "process.scheme".equals(model.getMethodId())) {
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, _uc.getUID(), teamId, uuid);
JSONObject object = JSONObject.parseObject(taskId);
if ("ok".equals(object.getString("result")))
@@ -3946,7 +3946,7 @@ public class ProcessPublishWeb extends ActionWeb {
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, _uc.getUID(), teamId, model2.getId());
else if ("data.form".equals(model.getMethodId()))
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportBd(wsId, _uc.getUID(), teamId, model2.getId());
- else if ("control.policy".equals(model.getMethodId()))
+ else if ("control.policy".equals(model.getMethodId()) || "engineering.standard".equals(model.getMethodId()) || "process.scheme".equals(model.getMethodId()))
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, _uc.getUID(), teamId, model2.getId());
JSONObject object2 = JSONObject.parseObject(taskId);
if ("ok".equals(object2.getString("result")))
@@ -4371,7 +4371,7 @@ public class ProcessPublishWeb extends ActionWeb {
JSONObject object = JSONObject.parseObject(taskId);
if ("ok".equals(object.getString("result")))
taskId = object.getJSONObject("data").getString("taskId");
- } else if ("control.policy".equals(model.getMethodId())) {
+ } else if ("control.policy".equals(model.getMethodId()) || "engineering.standard".equals(model.getMethodId()) || "process.scheme".equals(model.getMethodId())) {
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, userId, teamId, uuid);
JSONObject object = JSONObject.parseObject(taskId);
if ("ok".equals(object.getString("result")))
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTasAfterkComplete.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTasAfterkComplete.java
index 958dccf9..3bca054c 100644
--- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTasAfterkComplete.java
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTasAfterkComplete.java
@@ -280,7 +280,7 @@ public class ApplyTasAfterkComplete extends ExecuteListener implements ExecuteLi
if ("ok".equals(object.getString("result"))) {
taskId = object.getJSONObject("data").getString("taskId");
}
- } else if ("control.policy".equals(model.getMethodId())) {
+ } else if ("control.policy".equals(model.getMethodId()) || "engineering.standard".equals(model.getMethodId()) || "process.scheme".equals(model.getMethodId())) {
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, userId, teamId, uuid);
JSONObject object = JSONObject.parseObject(taskId);
if ("ok".equals(object.getString("result"))) {
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTaskAfterCreated.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTaskAfterCreated.java
index bf54e730..033929bf 100644
--- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTaskAfterCreated.java
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ApplyTaskAfterCreated.java
@@ -12,6 +12,7 @@ import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface;
import com.actionsoft.bpms.bpmn.engine.listener.ListenerConst;
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
import com.actionsoft.bpms.commons.database.RowMap;
+import com.actionsoft.bpms.server.Quota;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UUIDGener;
@@ -95,8 +96,8 @@ public class ApplyTaskAfterCreated extends ExecuteListener implements ExecuteLis
}else {
bo.set("DEPARTMENT_PROOFREADER", data.getString("DEAPRTMNUM"));
bo.set("PROCESS_MANAGER", data.getString("PROCESSMNUMBER"));
- bo.set("WSID", "7d3ca852-a0bd-42e6-80b1-3dcea6f55083");
- bo.set("RELEASE_INSTRUCTIONS", "
关于发布《XXXXXXXXXXXX》的通知
各事业部、分(子)公司、总部各部(室):
为xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,现下发《xxxxxxxxxxxxxxx》,请各单位遵照执行。
特此通知。
(xxxxxxxxx)单位名称
2022年7月27日
");//流程实例状态
+ bo.set("WSID", "7d3ca852-a0bd-42e6-80b1-3dcea6f55083");
+ bo.set("RELEASE_INSTRUCTIONS", "
关于发布《XXXXXXXXXXXX》的通知
各事业部、分(子)公司、总部各部(室):
为xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,现下发《xxxxxxxxxxxxxxx》,请各单位遵照执行。
特此通知。
(xxxxxxxxx)单位名称
2022年7月27日
");//流程实例状态
SDK.getBOAPI().create(PublisherConstant.BOTABLENAME, bo, ctx.getProcessInstance(), userContext);
//如果需要展示在表单上,需要调用如下代码。注意:此操作不会更新数据库中的数据
ctx.setParameter(ListenerConst.FORM_EVENT_PARAM_BODATA, bo);
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java
index a2137aee..48bd71ca 100644
--- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java
@@ -546,7 +546,7 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme
if ("ok".equals(object.getString("result"))) {
taskId = object.getJSONObject("data").getString("taskId");
}
- } else if ("control.policy".equals(model.getMethodId())) {
+ } else if ("control.policy".equals(model.getMethodId()) || "engineering.standard".equals(model.getMethodId()) || "process.scheme".equals(model.getMethodId())) {
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, userId, teamId, uuid);
JSONObject object = JSONObject.parseObject(taskId);
if ("ok".equals(object.getString("result"))) {
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_gc.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_gc.java
new file mode 100644
index 00000000..7576e0d3
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_gc.java
@@ -0,0 +1,2703 @@
+package com.actionsoft.apps.coe.pal.publisher.pubEvent;
+
+import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
+import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
+import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
+import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
+import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
+import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
+import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
+import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
+import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
+import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
+import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
+import com.actionsoft.bpms.bo.engine.BO;
+import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
+import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
+import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface;
+import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
+import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
+import com.actionsoft.bpms.commons.database.RowMap;
+import com.actionsoft.bpms.commons.login.constant.LoginConst;
+import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
+import com.actionsoft.bpms.org.model.DepartmentModel;
+import com.actionsoft.bpms.org.model.UserModel;
+import com.actionsoft.bpms.server.SSOUtil;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.bpms.server.fs.DCContext;
+import com.actionsoft.bpms.util.DBSql;
+import com.actionsoft.bpms.util.UtilString;
+import com.actionsoft.exception.AWSException;
+import com.actionsoft.sdk.local.SDK;
+import com.actionsoft.sdk.local.api.AppAPI;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang.StringUtils;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 流程结束后发送待阅数据
+ *
+ * @author wangchengye
+ * @time 2022/11/4
+ */
+@SuppressWarnings("all")
+public class ProcessEndAfterEvent_gc 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 int sendTotal;
+
+ @Override
+ public String getDescription() {
+ return "确认发布节点任务完成后推送OA/EHSQ/KMS";
+ }
+
+ @Override
+ public String getVersion() {
+ return "1.0";
+ }
+
+ @Override
+ public void execute(ProcessExecutionContext ext) throws Exception {
+
+
+ //用户点击确认发布按钮后进行触发推送任务
+ 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 {
+ 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()+"文件有失败记录,请及时处理!!!");
+ }
+
+
+ //更新任务状态
+ int r1 = DBSql.update("UPDATE BO_ACT_EXECUTIVE_TASK SET ISTASKEND='2' WHERE TASKID='" + ext.getProcessInstance().getId() + "'");
+
+
+
+ BO bo_act_coe_publish=SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").addQuery("BINDID=",ext.getProcessInstance().getId()).detail();
+
+ String whether_propaganda_plan=bo_act_coe_publish.getString("WHETHER_PROPAGANDA_PLAN");
+
+ if(whether_propaganda_plan.equals("1")){
+
+ ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_11aeee27b9a54a428aa42a05376ee81d", ext.getUserContext().getUID(), bo_act_coe_publish.getString("PROCESS_TITLE") + "文件的宣贯任务");
+
+ BO boRecordData=new BO();
+ boRecordData.set("PROCESS_NAME",bo_act_coe_publish.getString("PROCESS_TITLE"));
+ SDK.getBOAPI().create("BO_ACT_DOCUMENT_PUBLICITY_TASK", boRecordData, processInstance.getId(), "");
+
+ SDK.getProcessAPI().start(processInstance);
+
+ //发送OA待办
+ TaskInstance taskInstance= SDK.getTaskAPI().getInstanceById(processInstance.getStartTaskInstId());
+ sendOaPending(taskInstance,processInstance,ext);
+
+ String url="https://bpm.yili.com:8088/portal/r/w?sid="+ext.getUserContext().getSessionId()+"&cmd=CLIENT_BPM_FORM_MAIN_PAGE_OPEN&processInstId="+processInstance.getId()+"&openState=1&taskInstId="+processInstance.getStartTaskInstId()+"&displayToolbar=true";
+
+ int update = DBSql.update("update BO_ACT_COE_PUBLISH set XGRWLJ = '" + url + "' where BINDID = '" + 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 {
+
+ 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());
+
+
+ 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");
+
+ 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();
+ 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 = "";
+
+ 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();
+
+
+ /**
+ * 推送待阅文件到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 } }
+ */
+ /*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_f84fb9833d754c5f8703477dfc6b1a33' ";
+ 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);
+
+ 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;
+
+ 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);
+ }
+
+
+
+
+ /*int toIndex = 200;
+ int listSize = sendList.size();
+ boolean shutdown = false;
+
+ for (int i = 0; i < sendList.size(); i += 200) {
+ long startTime1 = System.currentTimeMillis();
+ if (i + 200 > listSize) {
+ toIndex = listSize - i;
+ }
+ List idList = sendList.subList(i, i + toIndex);
+ try {
+
+ BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processExecutionContext.getProcessInstance().getId()).addQuery("TASKSTATUS=",2).detail();
+ if(executiveTaskBO!=null){
+ List recordFailLists = new ArrayList();
+ String userIds = StringUtils.join(idList, ",");
+ String[] userIdsArray=userIds.split(",");
+ for(String oneuserId:userIdsArray){
+ BO bo = new BO();
+ bo.set("TITLE", processExecutionContext.getProcessInstance().getTitle());
+ bo.set("NAME", oneuserId);
+ bo.set("TYPE", "批量推送");
+ bo.set("RESULT", "待处理");
+ bo.set("PROCESSID", processExecutionContext.getProcessInstance().getId());
+ bo.set("DEPNAME", SDK.getORGAPI().getUser(oneuserId).getDepartmentId());
+ recordFailLists.add(bo);
+ //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processExecutionContext.getProcessInstance().getId(), processExecutionContext.getProcessInstance().getCreateUser());
+ }
+ SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processExecutionContext.getProcessInstance().getId(), processExecutionContext.getProcessInstance().getCreateUser());
+ return;
+ }
+
+
+ SendOARead(jsonObject, instanceById, idList, "批量推送");
+ } catch (Exception e) {
+
+ System.out.println("OA待阅推送exception======"+e);
+
+
+ // TODO: handle exception
+ }
+ long endTimes1 = System.currentTimeMillis();
+
+ System.err.println(instanceById.getTitle() + "单次300条推送单条====>" + "用时:"
+ + (endTimes1 - startTime1) / 1000 + "秒");
+
+ *//*
+ * ExecutorService cachedThreadPool = Executors.newFixedThreadPool(3); // 开启一个线程
+ * cachedThreadPool.execute(new Runnable() {
+ *
+ * @Override public void run() { try { } catch (DocumentException e) { // TODO
+ * Auto-generated catch block e.printStackTrace(); }
+ *
+ * } });
+ *//*
+ // 以下是等线程池的全部线程执行结束后,会自动执行。
+ *//*
+ * cachedThreadPool.shutdown(); while (true) { if
+ * (cachedThreadPool.isTerminated()) { long time = System.currentTimeMillis() -
+ * startTime; //System.out.println("程序结束了,总耗时:" + time + " ms(毫秒)!\n"+toIndex);
+ * break; } }
+ *//*
+
+ }*/
+
+ // 二次推送
+
+ }
+
+ }
+
+
+ /**
+ * 推送到知识库
+ */
+ if ("true".equals(isSendKMS)) {
+ try {
+ // 发布到知识库
+ int m = 0;
+ for (BO bo : bo_act_coe_publish_n) {
+ createKmsByNew(bo, wsId, filed, processExecutionContext, bo_act_coe_publish, new_uid);
+ }
+ // 更新知识库
+ for (BO bo : bo_act_coe_publish_c) {
+ CreateKmsByupdate(bo, wsId, filed, processExecutionContext, bo_act_coe_publish,
+ new_uid);
+ }
+
+ // 废止知识库文件
+ for (BO bo : bo_act_coe_publish_s) {
+ // 将旧的知识取消发布或者移动到废止发布中
+ String publishfileid_stop = bo.getString("STOPFILEID");
+ filed.add(publishfileid_stop);
+ String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_stop
+ + "'";
+ RowMap map1 = DBSql.getMap(open,sql_s);
+ if (StringUtils.isNotEmpty(map1.getString("EXT4"))) {
+ CancelPublishKnwl(processExecutionContext,
+ processExecutionContext.getUserContext().getSessionId(),
+ map1.getString("EXT4"));
+
+ DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '"
+ + publishfileid_stop + "'");
+ }
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+ /**
+ * 同步PAL文件表文件版本标识,用于部门视图
+ */
+ if(bo_act_coe_publish_n.size()>0) {
+ for (BO bo : bo_act_coe_publish_n) {
+ try {
+ String fileId = bo.getString("PUBLISHFILEID");
+ DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5='1' WHERE ID='"+fileId+"'");
+
+
+ /**
+ * 更新部门视图EXT6字段
+ */
+ List rlatRowMap=DBSql.getMaps("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT where FILEID = '"+fileId+"' and ATTRID='Issuing_department'");
+ if(rlatRowMap.size()>0){
+ // 发布部门
+ String dempId = "";
+ for(RowMap oneRowMap:rlatRowMap){
+ String relationshapetext=oneRowMap.getString("RELATIONSHAPETEXT");
+ JSONObject js=JSONObject.parseObject(relationshapetext);
+ dempId += js.getString("id") + ",";
+ }
+ dempId = dempId.substring(0, dempId.length() - 1);
+
+ int count = DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT6 = TO_CLOB('" + dempId + "') WHERE ID = '" + fileId + "'");
+
+ PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(fileId);
+ if (plModel != null) {
+ PALRepositoryCache.getCache().put(fileId, plModel);
+ }
+ }
+
+
+
+
+ /*Map queryRepositoryAttributeById = new RepositoryAttribute().queryRepositoryAttributeById(fileId);
+ if (null != queryRepositoryAttributeById && !queryRepositoryAttributeById.isEmpty()) {
+ // 发布部门
+ String dempId = "";
+ JSONObject Issuing_department = queryRepositoryAttributeById.get("Issuing_department");
+ if (null != Issuing_department && !Issuing_department.equals("")) {
+ JSONArray PUBDEPTJA = Issuing_department.getJSONArray("value");
+ SDK.getLogAPI().consoleInfo(Issuing_department.toString());
+ if (null != PUBDEPTJA && !PUBDEPTJA.isEmpty()) {
+ for (Object PUBDEPTO : PUBDEPTJA) {
+ JSONObject PUBDEPTJO = JSONObject.parseObject(String.valueOf(PUBDEPTO));
+ dempId += PUBDEPTJO.getString("id") + ",";
+ }
+ dempId = dempId.substring(0, dempId.length() - 1);
+ int count = DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT6 = TO_CLOB('" + dempId + "') WHERE ID = '" + fileId + "'");
+
+ PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(fileId);
+ if (plModel != null) {
+ PALRepositoryCache.getCache().put(fileId, plModel);
+ }
+
+
+ }
+ }
+ }*/
+
+
+ } 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+"'");
+
+
+ /**
+ * 更新部门视图EXT6字段
+ */
+ /* Map queryRepositoryAttributeById = new RepositoryAttribute().queryRepositoryAttributeById(changefileIdNew);
+ if (null != queryRepositoryAttributeById && !queryRepositoryAttributeById.isEmpty()) {
+ // 发布部门
+ String dempId = "";
+ JSONObject Issuing_department = queryRepositoryAttributeById.get("Issuing_department");
+ if (null != Issuing_department && !Issuing_department.equals("")) {
+ JSONArray PUBDEPTJA = Issuing_department.getJSONArray("value");
+ SDK.getLogAPI().consoleInfo(Issuing_department.toString());
+ if (null != PUBDEPTJA && !PUBDEPTJA.isEmpty()) {
+ for (Object PUBDEPTO : PUBDEPTJA) {
+ JSONObject PUBDEPTJO = JSONObject.parseObject(String.valueOf(PUBDEPTO));
+ dempId += PUBDEPTJO.getString("id") + ",";
+ }
+ dempId = dempId.substring(0, dempId.length() - 1);
+ int count = DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT6 = TO_CLOB('" + dempId + "') WHERE ID = '" + changefileIdNew + "'");
+ PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(changefileIdNew);
+ if (plModel != null) {
+ PALRepositoryCache.getCache().put(changefileIdNew, plModel);
+ }
+
+
+ }
+ }
+ }*/
+
+
+ /**
+ * 更新部门视图EXT6字段
+ */
+ List rlatRowMap=DBSql.getMaps("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT where FILEID = '"+changefileIdNew+"' and ATTRID='Issuing_department'");
+ if(rlatRowMap.size()>0){
+ // 发布部门
+ String dempId = "";
+ for(RowMap oneRowMap:rlatRowMap){
+ String relationshapetext=oneRowMap.getString("RELATIONSHAPETEXT");
+ JSONObject js=JSONObject.parseObject(relationshapetext);
+ dempId += js.getString("id") + ",";
+ }
+ dempId = dempId.substring(0, dempId.length() - 1);
+
+ int count = DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT6 = TO_CLOB('" + dempId + "') WHERE ID = '" + changefileIdNew + "'");
+
+ PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(changefileIdNew);
+ if (plModel != null) {
+ PALRepositoryCache.getCache().put(changefileIdNew, plModel);
+ }
+ }
+
+
+ } 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 = false;
+ String depId = processExecutionContext.getUserContext().getDepartmentModel().getId();
+ //获取EHSQ配置表判断是否发送
+ String sql = "SELECT * FROM BO_ACT_ACT_ESQ_SEND";
+ List maps = DBSql.getMaps(open,sql);
+ for (RowMap rowMap : maps) {
+ String dempet = rowMap.getString("DEMPET");
+ String issend = rowMap.getString("ISSEND");
+ DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(dempet);
+ if(departmentById!=null) {
+ String departemenId = departmentById.getId();
+ String pathIdOfCache=departmentById.getPathIdOfCache();
+ System.out.println("depId========"+depId);
+ 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) {
+ System.out.println("发送EHSQ====================");
+ 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 {
+ }
+ }
+ }
+
+
+
+ /**
+ * 创建索引
+ * @param processExecutionContext 流程实例
+ * @param contents 索引内容
+ * @return
+ */
+
+ public boolean createIndexesByContent(ProcessExecutionContext processExecutionContext,JSONArray contents) {
+// 调用App
+ String sourceAppId =processExecutionContext.getProcessInstance().getAppId() ;
+// aslp服务地址
+ String aslp = "aslp://com.actionsoft.apps.addons.es/createIndexesByContent";
+// 参数定义列表
+ Map params = new HashMap();
+//索引内容(JSONArray格式, JSONArray中包含JSONObject, JSONObject的内容同创建单个索引),必填
+ params.put("contents", contents);
+//索引名称(文档在哪存放),必填
+ params.put("index", "com.actionsoft.apps.kms_kmsdoc_card");
+//类型(索引中对数据进行逻辑分区。不同 type的文档可能有不同的字段,但最好能够非常相似,比如:存储所有产品到索引products中,但是你有许多不同的产品类别,这些产品共享一种相同的(或非常相似)的模式:他们有一个标题、描述、产品代码和价格。他们只是正好属于“产品”下的一些子类。用type表示不同的类别),必填
+ params.put("type", "kmsdoc_card");
+ AppAPI appAPI = SDK.getAppAPI();
+//入库操作,创建内容索引(多个)
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+
+ System.out.println("ro==================="+ro);
+ return ro.isOk();
+ }
+
+ /**
+ * 根据线程创建待阅日志
+ * @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
+
+ 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();
+ }
+
+ }
+ });
+ m++;
+ }
+ countDownLatch.await();
+ if (countDownLatch.getCount()==0){
+
+ 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);
+
+ 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 + "分钟");
+
+
+
+
+ } 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();
+// aslp服务地址
+ 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);
+ 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"))) {
+
+ 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());
+
+ Map params = new HashMap();
+//知识ID,必填
+ params.put("cardId", cardId);
+//sid,必填
+ params.put("sid", userContext.getSessionId());
+
+ params.put("dc", dcContext);
+ AppAPI appAPI = SDK.getAppAPI();
+//创建文件
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ System.out.println("流程手册的存入=================" + ro);
+
+ 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);
+
+ }
+ }
+
+ }
+ 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();
+//知识ID,必填
+ 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);
+
+ 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);
+
+
+ }
+
+ }
+
+ /**
+ * 取消发布知识
+ *
+ * @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);
+ if(UtilString.isNotEmpty(SDK.getORGAPI().getUser(user).getDepartmentId())){
+ 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();
+//保密级别, 0: 普通 1:秘密 2:机密,必填
+ 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);
+//是否可以评论,必填
+ params_create.put("isComment", true);
+//是否可以评分,必填
+ params_create.put("isRate", true);
+//有效期:yyyy-MM-dd,非必填
+ params_create.put("validDate", "2099-12-31");
+//只读控制,1:在线阅读和下载 0:在线阅读,必填
+ params_create.put("onlineLevel", 1);
+//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填
+ params_create.put("createUser", "admin");
+//知识内容,非必填
+ params_create.put("cardContext", "");
+//sid,必填
+ 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,只有部门则授权部门,如果包含部门,职级,岗位则授权该范围的人员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));
+
+ 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);
+ }
+ }
+
+ }
+
+ 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 = ");
+ }
+ }
+ }
+
+ /**
+ * 发布生成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();
+//保密级别, 0: 普通 1:秘密 2:机密,必填
+ 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);
+//是否可以评论,必填
+ params_create.put("isComment", true);
+//是否可以评分,必填
+ params_create.put("isRate", true);
+//有效期:yyyy-MM-dd,非必填
+ params_create.put("validDate", "2099-12-31");
+//只读控制,1:在线阅读和下载 0:在线阅读,必填
+ params_create.put("onlineLevel", 1);
+//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填
+ params_create.put("createUser", "admin");
+//知识内容,非必填
+ params_create.put("cardContext", "");
+//sid,必填
+ 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,只有部门则授权部门,如果包含部门,职级,岗位则授权该范围的人员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));
+
+ 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);
+ }
+ }
+
+ }
+ 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_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 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"));
+ }
+
+ 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(",");
+ 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);
+
+ 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("办理者的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] + ";";
+ }
+ }
+
+ 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());
+ }
+ }
+ }
+ }
+
+ 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, "','") + "'";
+
+ 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 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] + ";";
+ }
+ }
+
+ 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());
+ }
+ }
+ }
+ }
+
+
+
+ /**
+ * 发送待办
+ *
+ * @param taskInstance DD
+ * @throws DocumentException
+ */
+ public void sendOaPending(TaskInstance taskInstance, ProcessInstance processInstance, ProcessExecutionContext pe) throws IOException, DocumentException {
+ if("admin".equals(taskInstance.getTarget())) {
+ return;
+ }
+ XmlDatasUtil xmlDatasUtil = new XmlDatasUtil();
+ xmlDatasUtil.setExternal_system_ID("LCZD");
+ xmlDatasUtil.setOther_system_to_do_ID(taskInstance.getId());
+ BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_DOCUMENT_PUBLICITY_TASK", true).addQuery("BINDID=", processInstance.getId()).addQuery("PROCESS_NAME is not null",null).detail();
+ if (!processInstance.getParentTaskInstId().equals("00000000-0000-0000-0000-000000000000")){
+ if (bo_act_coe_publish!=null){
+ String title = bo_act_coe_publish.getString("PROCESS_NAME");
+ if(title.contains("&")) {
+ xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+title.replace("&", "-")+"】,点击进行处理");
+ }else {
+ xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+title+"】,点击进行处理");
+ }
+ }else {
+ xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+processInstance.getTitle()+"】,点击进行处理");
+ }
+ }else {
+ xmlDatasUtil.setProcess_title(" 您有一条草稿流程保存成功【"+processInstance.getTitle()+"】");
+ }
+
+
+ //http://localhost:8089/portal/r/or?cmd=com.yili_form_page_open&processInstId=3505e654-9217-41cd-a31d-4971846b3219&taskInstId=8a71d75e-3ee0-43a2-a226-ecb01419319c&oauthName=oauthLogin&token=admin
+ String portalUrl = SDK.getPortalAPI().getPortalUrl();
+ if (portalUrl.equals("http://10.114.11.135:8088/portal")){
+ portalUrl = "https://bpm.yili.com:8088/portal/";
+ }
+ xmlDatasUtil.setPcurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+processInstance.getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState());
+ xmlDatasUtil.setMobileurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&casaccount="+taskInstance.getTarget()+"&processInstId="+processInstance.getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState());
+ String target = taskInstance.getTarget();
+
+ //System.out.println("当前账户======》》》》"+target);
+ BO bo_eu_oa_reson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=" , target).detail();
+ //System.out.println("bo>>>>>>>>>>"+bo_eu_oa_reson);
+ if (bo_eu_oa_reson!=null){
+ xmlDatasUtil.setTo_do_login_account(bo_eu_oa_reson.getString("LOGINID"));
+ }else {
+ xmlDatasUtil.setTo_do_login_account(target);
+ }
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒
+ String str = df.format(taskInstance.getBeginTime());
+ String substring = str.substring(str.indexOf(" "), str.length());
+ xmlDatasUtil.setTo_do_creation_time(substring);
+ xmlDatasUtil.setTo_do_completion_time(substring);
+ //if (taskInstance.getState()==1){
+ xmlDatasUtil.setTo_do_status("0");
+ //}
+ xmlDatasUtil.setTo_do_official_type("0");
+// if (taskInstance.getReadState()==0){
+// xmlDatasUtil.setViewtype("0");
+// }else if (taskInstance.getReadState()==1){
+ xmlDatasUtil.setViewtype("0");
+// }
+ xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" ")));
+ xmlDatasUtil.setDonedate(str.substring(0, str.indexOf(" ")));
+ /*String der ="";
+ if (taskInstance.getReadTime()!=null){
+ der = df.format(taskInstance.getReadTime());
+ xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" ")));
+ xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length()));
+ }else {
+ der = df.format(taskInstance.getBeginTime());
+ xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" ")));
+ xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length()));
+ }*/
+ xmlDatasUtil.setReceivedate(str.substring(0, str.indexOf(" ")));
+ xmlDatasUtil.setReceivetime(substring);
+
+ xmlDatasUtil.setCurrentnodetype("0");
+ xmlDatasUtil.setRequestcode(processInstance.getId());
+ xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(processInstance.getProcessDefId(),taskInstance.getActivityDefId()).getName());
+
+ // 调用App
+ String sourceAppId = processInstance.getAppId();
+ // aslp服务地址
+ String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP";
+ // 参数定义列表
+ Map params = new HashMap();
+ //流程实例id,必填
+ params.put("processInstId", processInstance.getId());
+ //,必填
+ params.put("sid", pe.getUserContext().getSessionId());
+ AppAPI appAPI = SDK.getAppAPI();
+ //流程节点数据
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ String username = "";
+ String userid = "";
+ if (ro.isOk()){
+ List list = new ArrayList();
+ Object processBudgetModelList = ro.get("processBudgetModelList");
+ JSONArray array = JSON.parseArray(String.valueOf(processBudgetModelList));
+
+ if (!array.isEmpty()){
+ for(int i=0;i"+processInstance.getTitle()+"===>"+"状态码============》》》》》》》》》》》"+s);
+ Document document = null;
+ try {
+ document = DocumentHelper.parseText(s);
+ } catch (DocumentException e) {
+ e.printStackTrace();
+ }
+ Element rootElement = document.getRootElement();
+ //System.out.println("rootElement>>>>>>"+rootElement);
+ Element result = rootElement.element("Body").element("InsertTodoCominfoResponse").element("out");
+ String text = result.getText();
+ document = DocumentHelper.parseText(text);
+ Element rootElement2 = document.getRootElement();
+ Element statusElement = rootElement2.element("result");
+ Element messageElement = rootElement2.element("message");
+ String status = statusElement.getData().toString();
+ String message = messageElement.getData().toString();
+ if ("success".equals(status)){
+ System.out.println("发送待办成功===>"+processInstance.getTitle()+"===>"+taskInstance.getTarget()+"====>"+status+"===>"+message);
+ }else {
+ System.out.println("发送待办失败===>"+processInstance.getTitle()+"===>"+taskInstance.getTarget()+"====>"+status+"===>"+message);
+ }
+ if (s.contains("success")){
+ //System.out.println("发送待办任务完成,请去OA系统上查看是否传输完成");
+ }else {
+ //System.out.println("发送待办任务失败,请联系管理员查看是否出现错误");
+ //System.out.println("错误提示>>>>>>>>>>>>"+s);
+ BO bo_eu_faid_data = SDK.getBOAPI().query("BO_EU_FAID_DATA", true).addQuery("TASK_ID=", taskInstance.getId()).detail();
+ if (bo_eu_faid_data==null){
+ ProcessInstance processInstanceadmin = SDK.getProcessAPI().createProcessInstance("obj_ef1918ca1f9c46948f56bd5f77f4e646", "admin", pe.getUserContext().getUserName() + "失败更新待办");
+ BO bo_faid = new BO();
+ bo_faid.set("CHANGED","1");
+ bo_faid.set("TASK_ID",taskInstance.getId());
+ bo_faid.set("PROCESS_ID",processInstance.getId());
+ UserContext userContext = UserContext.fromUID("admin");
+ SDK.getBOAPI().create("BO_EU_FAID_DATA",bo_faid,processInstanceadmin,userContext);
+ SDK.getProcessAPI().start(processInstanceadmin);
+ }
+ }
+ }
+
+}
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 6ef590cb..bebcaf40 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
@@ -12,6 +12,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
+import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
import com.actionsoft.apps.coe.pal.system.util.StringUtil;
import com.actionsoft.exception.AWSDataAccessException;
import org.apache.commons.lang.StringUtils;
@@ -503,7 +504,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
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+"'");
+ DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5='1' WHERE ID='"+fileId+"'");
/**
@@ -633,6 +634,17 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
try {
String fileId = bo.getString("STOPFILEID");
DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+fileId+"'");
+
+
+ //更新作废人
+ PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
+ propertyDao.updatePropertyByPropertyId(fileId, "nullifier", processExecutionContext.getUserContext().getUID());
+
+ //作废时间
+ Date date=new Date();
+ SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd");
+ propertyDao.updatePropertyByPropertyId(fileId, "obsolescence_time", sdfs.format(date));
+
} catch (Exception e) {
}
}
@@ -847,9 +859,6 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
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 =
@@ -1029,7 +1038,6 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
// 发布知识
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
- System.out.println("知识发布============" + ro);
}