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 0489a8c1..72e1f8ee 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
@@ -35,10 +35,8 @@ public class ApplyTaskAfterCreated extends ExecuteListener implements ExecuteLis
if("00000000-0000-0000-0000-000000000000".equals(ctx.getTaskInstance().getParentTaskInstId())) {
BO boData = (BO) ctx.getParameter(ListenerConst.FORM_EVENT_PARAM_BODATA);
Object variable = SDK.getProcessAPI().getVariable(ctx.getProcessInstance(), "createType");
- System.err.println("=====boData1=====>"+boData);
- System.err.println("====variable1======>"+variable);
if(boData==null&&variable==null) {
- System.err.println("===任务创建后创建====>");
+ System.err.println("任务创建后执行====>");
saveData(ctx);
}
}
@@ -106,7 +104,7 @@ public class ApplyTaskAfterCreated extends ExecuteListener implements ExecuteLis
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("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 68ba075e..d04babaf 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
@@ -2,7 +2,14 @@ package com.actionsoft.apps.coe.pal.publisher.event;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -36,20 +43,16 @@ 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.commons.database.RowMap;
-import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilDate;
import com.actionsoft.bpms.util.UtilString;
-import com.actionsoft.exception.AWSAPIException;
import com.actionsoft.exception.AWSDataAccessException;
-import com.actionsoft.exception.AWSException;
-import com.actionsoft.exception.BPMNError;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.awspaas.yili.publishevent.event.ProcessEndAfterEvent;
+
public class PublishExecuteListenerInterfaceImpl extends ExecuteListener implements ExecuteListenerInterface {
@@ -189,8 +192,8 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme
updateEffectiveDateProperty(processInstId, bo, nowTime, bolistN, bolistC);
// 流程发布范围权限单独存储
savePublishScope(bo, bolistN, bolistC, bolistS);
- //发布待阅,推送知识库,推送EHSQ
- new ProcessEndAfterEvent().ProcessData(param);
+ //发布待阅,推送知识库,推送EHSQ 改为确认发布节点任务完成后执行
+ //new ProcessEndAfterEvent().ProcessData(param);
}
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishLoadBefore.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishLoadBefore.java
index ba22bf23..f29c4c32 100644
--- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishLoadBefore.java
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishLoadBefore.java
@@ -36,8 +36,6 @@ public class PublishLoadBefore extends ExecuteListener {
// BO表记录,注意:该记录的数据如果被修改,将会体现到表单上,修改后不会直接持久化到数据库中
BO boData = (BO) ctx.getParameter(ListenerConst.FORM_EVENT_PARAM_BODATA);
Object variable = SDK.getProcessAPI().getVariable(ctx.getProcessInstance(), "createType");
- System.err.println("====boData2====>"+boData);
- System.err.println("====variable2====>"+variable);
if (null == boData) {
} else {
// 如果有值就不再去计算了
@@ -47,7 +45,7 @@ public class PublishLoadBefore extends ExecuteListener {
}
//如果是1是从oa创建,就不用再获取
if ("pal".equals(variable)) {
- System.err.println("===表单加载前创建====>");
+ System.err.println("表单加载前执行pal====>");
// 根据部门名称 和单位 计算出 内部校对人 和流程经理
UserContext me = ctx.getUserContext();
String departmentId = me.getUserModel().getDepartmentId();
@@ -75,7 +73,7 @@ public class PublishLoadBefore extends ExecuteListener {
boData.set("DEPARTMENT_PROOFREADER", data.getString("DEAPRTMNUM"));
boData.set("PROCESS_MANAGER", data.getString("PROCESSMNUMBER"));
boData.set("RELEASE_INSTRUCTIONS",
- "关于发布《XXXXXXXXXXXX》的通知
各事业部、分(子)公司、总部各部(室):
为xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,现下发《xxxxxxxxxxxxxxx》,请各单位遵照执行。
特此通知。
(xxxxxxxxx)单位名称
2022年7月27日
");// 流程实例状态
+ "
关于发布《XXXXXXXXXXXX》的通知
各事业部、分(子)公司、总部各部(室):
为xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,现下发《xxxxxxxxxxxxxxx》,请各单位遵照执行。
特此通知。
(xxxxxxxxx)单位名称
2022年7月27日
");// 流程实例状态
// 如果需要展示在表单上,需要调用如下代码。注意:此操作不会更新数据库中的数据
ctx.setParameter(ListenerConst.FORM_EVENT_PARAM_BODATA, boData);
}
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/CreateProcessController.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/CreateProcessController.java
index e88f0c24..6e2a8aa9 100644
--- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/CreateProcessController.java
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/CreateProcessController.java
@@ -146,7 +146,7 @@ public class CreateProcessController {
}
-
+ //批量导入权限
@Mapping("com.awspaas.user.apps.xitongfankui.createPrem")
public JSONObject createPrem(String sid,String processDefId) {
JSONObject result = new JSONObject();
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/PublisherGetManagerController.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/PublisherGetManagerController.java
new file mode 100644
index 00000000..225eea75
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/PublisherGetManagerController.java
@@ -0,0 +1,52 @@
+package com.actionsoft.apps.coe.pal.publisher.extend;
+
+import java.sql.Connection;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.actionsoft.bpms.commons.database.RowMap;
+import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.bpms.server.bind.annotation.Controller;
+import com.actionsoft.bpms.server.bind.annotation.Mapping;
+import com.actionsoft.bpms.util.DBSql;
+import com.actionsoft.sdk.local.SDK;
+/**
+ * 表单加载前获取内部校对人和流程经理
+ * @author lihongyu
+ *
+ */
+@Controller
+public class PublisherGetManagerController {
+ private static Logger logger = LoggerFactory.getLogger(PublisherGetManagerController.class);
+ // 修改文件发布状态
+ @Mapping("com.actionsoft.apps.coe.pal.publisher.PublisherGetManagerController")
+ public ResponseObject checkIsSend(String sid) {
+ ResponseObject ro = ResponseObject.newOkResponse();
+ //根据部门名称 和单位 计算出 内部校对人 和流程经理
+ UserContext me = UserContext.fromSessionId(sid);
+ String departmentId = me.getUserModel().getDepartmentId();
+ String allpath = SDK.getORGAPI().getDepartmentById(departmentId).getPathNameOfCache();
+ String[] patharr = allpath.split("/");
+ StringBuffer sb = new StringBuffer();
+ for (String str : patharr) {
+ sb.append("'").append(str).append("'").append(",");
+ }
+ String substring = sb.substring(0, sb.length()-1);
+ // 可以为boData中的字段进行赋值
+ Connection open = DBSql.open();
+ RowMap data = DBSql.getMap(open,"select DEAPRTMNUM,PROCESSMNUMBER from BO_ACT_PROCESSMANAGER where ORGDEPART in ("+substring+")");
+ if(null==data) {
+ ro.put("result","error");
+ }else {
+ ro.put("result","ok");
+ ro.put("DEAPRTMNUM",data.getString("DEAPRTMNUM"));
+ ro.put("PROCESSMNUMBER",data.getString("PROCESSMNUMBER"));
+ }
+ return ro;
+ }
+
+
+
+}
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/UpateFileStateController.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/UpateFileStateController.java
index c0f8b56f..048cb229 100644
--- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/UpateFileStateController.java
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/extend/UpateFileStateController.java
@@ -36,8 +36,13 @@ public class UpateFileStateController {
count += DBSql.update(updataSql);
String sqlt = "UPDATE BO_EU_PAL_FILE1 SET FILESTATE = '" + state + "' WHERE FILEID = '" + plId + "'";
DBSql.update(sqlt);
+
+
PALRepositoryModel model = PALRepositoryCache.getCache().get(plId);
String taskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin", "", plId);
+ //刷新预览加载的表
+ String sqlr = "UPDATE BO_EU_PAL_OUTPUTREPORT SET TASKID = '" + taskId + "' WHERE PLID = '" + plId + "'";
+ DBSql.update(sqlr);
System.err.println("重新生成手册:" + model.getName() + "--->taskId" + taskId);
DBSql.update(
"UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE PUBLISHFILEID ='" + plId + "'");
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/AesUtil.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/AesUtil.java
new file mode 100644
index 00000000..a5857892
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/AesUtil.java
@@ -0,0 +1,90 @@
+package com.actionsoft.apps.coe.pal.publisher.pubEvent;
+
+import java.net.URLEncoder;
+import java.security.Key;
+import java.security.SecureRandom;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+/**
+ * AES加密解密工具类
+ *
+ * @author M-Y
+ */
+public class AesUtil {
+
+ public static String DES = "AES"; // optional value AES/DES/DESede
+
+ public static String CIPHER_ALGORITHM = "AES"; // optional value
+ // AES/DES/DESede
+
+ public Key getKey(String strKey) {
+ try {
+ if (strKey == null) {
+ strKey = "";
+ }
+ KeyGenerator _generator = KeyGenerator.getInstance("AES");
+ SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
+ secureRandom.setSeed(strKey.getBytes());
+ _generator.init(128, secureRandom);
+ return _generator.generateKey();
+ } catch (Exception e) {
+ throw new RuntimeException(" 初始化密钥出现异常 ");
+ }
+ }
+
+ public String encrypt(String data, String key) throws Exception {
+ SecureRandom sr = new SecureRandom();
+ Key secureKey = getKey(key);
+ Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
+ cipher.init(Cipher.ENCRYPT_MODE, secureKey, sr);
+ byte[] bt = cipher.doFinal(data.getBytes());
+ String strS = new BASE64Encoder().encode(bt);
+ return strS;
+ }
+
+ public String decrypt(String message, String key) {
+ try {
+ SecureRandom sr = new SecureRandom();
+ Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
+ Key secureKey = getKey(key);
+ cipher.init(Cipher.DECRYPT_MODE, secureKey, sr);
+ byte[] res = new BASE64Decoder().decodeBuffer(message);
+ res = cipher.doFinal(res);
+ return new String(res);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public String DecryptedMsg(String message, String key) throws Exception, Exception {
+ String Msg1 = encrypt(message, key);
+ System.out.println("message is :" + Msg1);
+ String encryptMsg1 = URLEncoder.encode(encrypt(message, key), "UTF-8");
+ System.out.println("encrypted message is :" + encryptMsg1);
+ return encryptMsg1;
+
+ }
+
+ public static void main(String[] args) throws Exception {
+ String data = "AUDIT##202210181611";
+ String key = "auditY809kUih23";
+ String url = "http://10.60.143.183:8088/portal/r/df?groupValue=7d3ca852-a0bd-42e6-80b1-3dcea6f55083&fileValue=d1135309-e376-4ec6-bd27-51947abe26ea&sid=null&repositoryName=output&appId=com.actionsoft.apps.coe.pal.output.pr&attachment=true&fileName=%E5%B9%BF%E5%91%8A%E5%88%9B%E6%84%8F%E7%94%9F%E6%88%90%E6%B5%81%E7%A8%8B_1.0.doc&lastModified=1666352134000";
+ String str1 = url.substring(0, url.indexOf("/df"));
+
+ System.out.println("str1>"+str1);
+ //String encryptMsg1 = AesUtil.encrypt(data, key);
+ //System.out.println("加密后:" + encryptMsg1);
+ /*message = "YPS5F%2F%2BVmdbVj0iuxrSINw%3D%3D";
+ System.out.println("解密后:" + AesUtil.decrypt(URLDecoder.decode(message), key));*/
+ }
+
+
+
+
+}
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/DownloadUtil.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/DownloadUtil.java
new file mode 100644
index 00000000..cbcea2f0
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/DownloadUtil.java
@@ -0,0 +1,135 @@
+package com.actionsoft.apps.coe.pal.publisher.pubEvent;
+
+import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
+import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
+import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
+import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
+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.bpms.commons.database.RowMap;
+import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.bpms.server.fs.DCContext;
+import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
+import com.actionsoft.bpms.util.DBSql;
+import com.actionsoft.bpms.util.UUIDGener;
+import com.actionsoft.bpms.util.UtilFile;
+import com.actionsoft.sdk.local.SDK;
+import com.alibaba.fastjson.JSONObject;
+import com.awspaas.yili.publishevent.event.OutputDCFileProcessor;
+
+import java.io.File;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+public class DownloadUtil {
+
+ /**
+ * 流程手册下载
+ * @param _uc
+ * @param taskId
+ * @return
+ */
+ public LinkedHashMap outputReportDownload(UserContext _uc, String taskId, String ruuid) {
+ System.out.println("usercontext>>>>>>>>>>>"+_uc.getUID());
+ System.out.println("sid>>>>>>>>>>>"+_uc.getSessionId());
+ LinkedHashMap map = new LinkedHashMap<>();
+ OutputTaskModel model = new OutputTask().getTaskReportById(taskId);
+ ResponseObject result = ResponseObject.newOkResponse();
+ if (model != null) {
+ try {
+ UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId());
+ if (file.exists()) {
+ File[] fileList = file.listFiles();
+ if (fileList.length > 0) {
+ File docFile = null;
+ for (File file2 : fileList) {
+ if (file2.isFile() && "doc".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) {
+ docFile = file2;
+ break;
+ }
+ }
+ if (docFile == null) {
+ // return ResponseObject.newErrResponse("没有找到文件").toString();
+ }
+
+ PALRepositoryModel plmodel = PALRepositoryCache.getCache().get(ruuid);
+ if(plmodel!=null) {
+ String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr";
+ String methodId = plmodel.getMethodId();
+ if(methodId.contains("control")) {
+ sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd";
+ }else if(methodId.contains("data")) {
+ sourceAppId = "com.awspaas.user.apps.coe.pal.output.bd";
+ }
+ String filename = docFile.getName();
+ DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename);
+ String downUrl= SDK.getConfAPI().getPortalUrl() + "/r/" + sourceDc.getDownloadURL().replace("./", "");
+ // result.put("url",downUrl);
+ map.put(filename,downUrl);
+ }
+
+ String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"+ruuid+"'" +
+ ")";
+ List maps = DBSql.getMaps(sql_upfile);
+ UpfileWeb upfileWeb = new UpfileWeb(_uc);
+
+ for (RowMap row : maps) {
+ 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);
+ String downUrl= SDK.getConfAPI().getPortalUrl() + "/r/" + dcContexts.getDownloadURL().replace("./", "");
+ map.put(row.getString("FILENAME"),downUrl);
+ }
+
+ }
+ }else{
+ result = ResponseObject.newErrResponse("没有可预览文件");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ // return ResponseObject.newErrResponse().toString();
+ }
+ }
+ return map;
+ }
+
+
+ public String getzipURL(String sid,String taskId,String title){
+ System.out.println("taskid》》》》》》》》》》"+taskId);
+ System.out.println("fileName》》》》》》》》》》"+title);
+ String reportDownloadURL = "";
+ UserContext me = UserContext.fromSessionId(sid);
+ OutputTaskModel model = new OutputTask().getTaskReportById(taskId);
+ JSONObject result = new JSONObject();
+ if (model != null) {
+ //三员管理,步骤横表下载重新生成手册
+
+ String taskName = model.getTaskName();
+ if ("步骤横表".equals(taskName)){
+ // 重新设置生成id,与用户id
+ String uuid = UUIDGener.getUUID();
+ model.setUserId(me.getUID());
+
+ // 重新生成手册文件
+ OutputAPIManager.getInstance().reGennerReport(me,model,uuid);
+
+ // 重新构建手册下载URL
+ taskId = uuid;
+ }
+
+ try {
+ reportDownloadURL = OutputDCFileProcessor.getReportDownloadURL(model.getWsId(), taskId, model.getProfileId(), me, title+model.getTaskName());
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+ }
+ return reportDownloadURL;
+ }
+
+}
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/HttpUtil.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/HttpUtil.java
new file mode 100644
index 00000000..b37a4922
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/HttpUtil.java
@@ -0,0 +1,65 @@
+package com.actionsoft.apps.coe.pal.publisher.pubEvent;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.protocol.HTTP;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * http请求⼯具
+ * @Author wangcy
+ */
+public class HttpUtil {
+ private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
+ /**
+ * 发送post请求
+ * @param json
+ * @param URL
+ * @return
+ */
+ public String sendPost(JSONObject json,String URL) {
+ CloseableHttpClient client = HttpClients.createDefault();
+ HttpPost post = new HttpPost(URL);
+ post.setHeader("Content-Type", "application/json");
+ //post.addHeader("Authorization", "Basic YWRtaW46");
+ String result;
+ try {
+ StringEntity s = new StringEntity(json.toString(), "utf-8");
+ s.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
+ "application/json"));
+ post.setEntity(s);
+// 发送请求
+ HttpResponse httpResponse = client.execute(post);
+// 获取响应输⼊流
+ InputStream inStream = httpResponse.getEntity().getContent();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ inStream, "utf-8"));
+ StringBuilder strber = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null)
+ strber.append(line + "\n");
+ inStream.close();
+ result = strber.toString();
+ if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+ System.out.println("请求服务器成功,做相应处理");
+ } else {
+ System.out.println("请求服务端失败");
+ }
+ } catch (Exception e) {
+ logger.error("请求异常:"+e.getMessage());
+ throw new RuntimeException(e);
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/OutputDCFileProcessor.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/OutputDCFileProcessor.java
new file mode 100644
index 00000000..11c2526a
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/OutputDCFileProcessor.java
@@ -0,0 +1,123 @@
+package com.actionsoft.apps.coe.pal.publisher.pubEvent;
+
+import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI;
+import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
+import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.bpms.server.fs.AbstFileProcessor;
+import com.actionsoft.bpms.server.fs.DCContext;
+import com.actionsoft.bpms.server.fs.FileProcessorListener;
+import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
+import com.actionsoft.bpms.server.fs.dc.DCUtil;
+import com.actionsoft.bpms.util.UtilFile;
+import com.actionsoft.sdk.local.SDK;
+import com.actionsoft.sdk.local.api.AppAPI;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+public class OutputDCFileProcessor extends AbstFileProcessor implements FileProcessorListener {
+ public OutputDCFileProcessor() {
+ }
+
+ public static String getReportDownloadURL(String wsId, String id, String profileId, UserContext _uc, String taskName) throws Exception {
+ UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
+ if (file.exists()) {
+ DCContext dcContext = null;
+ DCUtil.getInstance();
+ dcContext = DCUtil.createTempFileContext("com.actionsoft.apps.coe.pal.output.pr", "output", id, "zip");
+ dcContext.setFileName(taskName + ".zip");
+ File ff = new File(dcContext.getFilePath());
+ UtilFile.zipCompressExcludeName(file.getPath(), ff, "log,**/config.txt");
+ dcContext.setSession(_uc);
+ if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
+ CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "download", "下载报告手册文档");
+ }
+
+ return dcContext.getDownloadURL();
+ } else {
+ return "";
+ }
+ }
+
+ public static String doPreviewReport(String wsId, String id, String profileId, UserContext _uc) throws Exception {
+ UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
+ ResponseObject result = ResponseObject.newOkResponse();
+ if (file.exists()) {
+ File[] fileList = file.listFiles();
+ if (fileList.length > 0) {
+ File docFile = null;
+ File[] var8 = fileList;
+ int var9 = fileList.length;
+
+ for(int var10 = 0; var10 < var9; ++var10) {
+ File file2 = var8[var10];
+ if (file2.isFile() && "doc".equals(file2.getName().substring(file2.getName().lastIndexOf(".") + 1))) {
+ docFile = file2;
+ break;
+ }
+ }
+
+ if (docFile == null) {
+ return ResponseObject.newErrResponse("没有找到文件").toString();
+ }
+
+ if (SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) {
+ String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr";
+ String filename = docFile.getName();
+ DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, id, filename);
+ Map aslpParams = new HashMap();
+ aslpParams.put("sid", _uc.getSessionId());
+ aslpParams.put("fileNameOriginal", filename);
+ aslpParams.put("sourceDc", sourceDc);
+ aslpParams.put("isShowDefaultToolbar", "false");
+ aslpParams.put("isEncrypt", true);
+ aslpParams.put("isCopy", "true");
+ aslpParams.put("isPrint", "false");
+ aslpParams.put("isDownload", "false");
+ AppAPI appAPI = SDK.getAppAPI();
+ ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext(sourceAppId), "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview", aslpParams);
+ if (responseObject != null) {
+ if (responseObject.isOk()) {
+ String url = responseObject.get("url").toString();
+ result.put("url", url);
+ result.put("filename", filename);
+ if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
+ CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "access", "访问报告手册文档");
+ }
+ } else {
+ result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
+ }
+ }
+ } else {
+ result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
+ }
+ }
+ } else {
+ result = ResponseObject.newErrResponse("没有可预览文件");
+ }
+
+ return result.toString();
+ }
+
+ public static String getReportLogDownloadURL(String wsId, String id, String profileId, UserContext _uc, String taskName) throws Exception {
+ UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
+ if (file.exists()) {
+ DCContext dcContext = null;
+ DCUtil.getInstance();
+ dcContext = DCUtil.createTempFileContext("com.actionsoft.apps.coe.pal.output.pr", "output", id, "zip");
+ dcContext.setFileName("log.zip");
+ File ff = new File(dcContext.getFilePath());
+ UtilFile.zipCompress(file.getPath(), ff, "log");
+ dcContext.setSession(_uc);
+ if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
+ CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "download", "下载报告手册文档日志");
+ }
+
+ return dcContext.getDownloadURL();
+ } else {
+ return "";
+ }
+ }
+}
\ No newline at end of file
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent.java
new file mode 100644
index 00000000..a7e18dcc
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent.java
@@ -0,0 +1,1510 @@
+package com.actionsoft.apps.coe.pal.publisher.pubEvent;
+
+import java.sql.Connection;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.commons.lang.StringUtils;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+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.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.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;
+
+/**
+ * 流程结束后发送待阅数据
+ *
+ * @author wangchengye
+ * @time 2022/11/4
+ */
+@SuppressWarnings("all")
+public class ProcessEndAfterEvent 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");
+
+ @Override
+ public String getDescription() {
+ return "确认发布节点任务完成后推送OA/EHSQ/KMS";
+ }
+
+ @Override
+ public String getVersion() {
+ return "1.0";
+ }
+ @Override
+ public void execute(ProcessExecutionContext ext) throws Exception {
+ ExecutorService service = Executors.newFixedThreadPool(1);
+ service.execute(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ProcessData(ext);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ public void ProcessData(ProcessExecutionContext processExecutionContext) throws Exception {
+ System.err.println(processExecutionContext.getTaskInstance().getTitle()+"_推送文件开始========>");
+ Connection open = DBSql.open();
+ // 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.getProcessInstance().getStartTime();
+ BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true)
+ .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()
+ 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)
+ .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)
+ .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
+ List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true)
+ .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
+ List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true)
+ .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+ JSONArray jsonArray = new JSONArray();
+ /**
+ * 推送到知识库
+ */
+ 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, crateUserId);
+ }
+ // 更新知识库
+ for (BO bo : bo_act_coe_publish_c) {
+ CreateKmsByupdate(bo, wsId, filed, processExecutionContext, bo_act_coe_publish, crateUserId);
+ }
+
+ // 废止知识库文件
+ 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(sql_s);
+ 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_stop
+ + "'");
+ }
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+ /**
+ * 更新数据看板底表
+ */
+ try {
+ AttrSynAslp(processExecutionContext, wsId, filed);
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+
+ /**
+ * 推送待阅文件到OA
+ */
+ if("true".equals(isSendOA)) {
+ ProcessInstance instanceById = processExecutionContext.getProcessInstance();
+ if (bo_act_coe_publish1 != null && instanceById != null) {
+ System.err.println(instanceById.getTitle() + "推送OA待阅执行开始====>");
+ long startTime = System.currentTimeMillis();
+ ArrayList sendList = getSendList(instanceById, bo_act_coe_publish1, jsonObject);
+ System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size());
+ for (String uid : sendList) {
+ try {
+ SendOARead(jsonObject, instanceById, uid);
+ } catch (Exception e) {
+ }
+ }
+ long endTimes = System.currentTimeMillis();
+ //存入日志
+ createReadLog(processExecutionContext, jsonObject, sendList, startTime,endTimes);
+ System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:"+(endTimes-startTime)/1000/60+"分钟");
+ }
+
+ }
+ /**
+ * 推送到EHSQ
+ */
+ if("true".equals(isSendEHSQ)) {
+ try {
+ //推送EHSQ
+ sendEHSQ(processExecutionContext, bo_act_coe_publish_n);
+ //更新EHSQ
+ updateEHSQ(processExecutionContext, bo_act_coe_publish_c);
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+
+
+ open.close();
+ }
+ }
+ }
+
+ /**
+ * 创建附件及文件
+ *
+ * @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);
+ System.out.println("maps======>>>>>>>" + map);
+ System.out.println("fileid==》》》》" + fileid);
+ System.out.println("id==》》》》" + map.getString("ID"));
+ RowMap rowMap = DBSql
+ .getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'");
+ // BO bos =
+ // SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail();
+ if (rowMap != null) {
+
+ if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) {
+
+ OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID"));
+ if (model != null) {
+ System.out.println(",pdel============" + model);
+ System.out.println("123313123123123==========" + model.getProfileId());
+ OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
+ System.out.println("dajadfas======" + appProfile);
+ 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);
+ }
+ }
+
+ }
+ 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") + "'" + ")";
+ List maps = DBSql.getMaps(sql_upfile);
+ for (RowMap row : maps) {
+ System.out.println("附件名称>>>>>>" + row.getString("FILENAME"));
+ 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);
+ System.out.println("流程模型附件的生成=============" + ros);
+ }
+ }
+
+//DCContext对象,必填
+
+//创建文件
+ }
+ try {
+
+ PublishKnow(processExecutionContext, userContext, cardId);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 发布知识
+ *
+ * @param processExecutionContext
+ * @param userContext
+ * @param id
+ */
+ public void PublishKnow(ProcessExecutionContext processExecutionContext, UserContext userContext, String id) {
+
+ String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"
+ + id + "')";
+ List maps = DBSql.getMaps(sql);
+ String ids = "";
+ for (RowMap rowmap : maps) {
+ ids += rowmap.getString("EXT4") + ",";
+ }
+ String[] deptSplit_id = ids.split(",");
+
+ JSONArray jsonArray = new JSONArray();
+ for (String id_names : deptSplit_id) {
+ jsonArray.add(id_names);
+ }
+ // jsonObject.put(deptSplit_id);
+ id += ",";
+ String[] deptSplit_das = id.split(",");
+ JSONArray jsonArray_das = new JSONArray();
+ for (String das : deptSplit_das) {
+ jsonArray_das.add(das);
+ }
+ // jsonObject.put(deptSplit_id);
+
+ if (!jsonArray_das.isEmpty() && !jsonArray.isEmpty()) {
+
+ // 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+ // aslp服务地址
+ String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl";
+ // 参数定义列表
+ Map params = new HashMap();
+ //要发布到的维度ID的JSON数组字符串,必填
+ params.put("dimensionIDArray", jsonArray.toString());
+ //要发布的知识ID的JSON数组字符串,必填
+ params.put("knwlIDArray", jsonArray_das.toString());
+ //标签的JSON数组字符串,非必填
+
+ //sid,必填
+ params.put("sid", userContext.getSessionId());
+ AppAPI appAPI = SDK.getAppAPI();
+ //发布知识
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+
+ System.out.println("知识发布============" + ro);
+
+ }
+
+ }
+
+ /**
+ * 取消发布知识
+ *
+ * @param processExecutionContext
+ * @param sid
+ * @param knwlId
+ * @return
+ */
+ public boolean CancelPublishKnwl(ProcessExecutionContext processExecutionContext, String sid, String knwlId) {
+ // 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+ // aslp服务地址
+ String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl";
+ // 参数定义列表
+ Map params = new HashMap();
+ //sid,如果为空,则需要传createUser参数,非必填
+ params.put("sid", sid);
+ //知识ID,必填
+ params.put("knwlId", knwlId);
+ AppAPI appAPI = SDK.getAppAPI();
+ //取消发布知识(全部维度)
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ System.out.println("取消发布的ro=====>>>>" + ro);
+ return ro.isOk();
+ }
+
+ /**
+ * 创建XPage页面上的待阅文件
+ *
+ * @param processExecutionContext
+ * @param fileCreateName
+ * @param fileName
+ * @param fileurl
+ * @param readingScope_org
+ * @param isFullCompany
+ * @param fileCreateDate
+ * @param relationProcessinstId
+ * @param readingScope_post
+ * @param readingScope_level
+ * @param fileid
+ * @return
+ */
+ public boolean execute(ProcessExecutionContext processExecutionContext, String fileCreateName, String fileName,
+ String fileurl, String readingScope_org, String isFullCompany, String fileCreateDate,
+ String relationProcessinstId, String readingScope_post, String readingScope_level, String fileid) {
+ // 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+ // aslp服务地址
+ String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage";
+ // 参数定义列表
+ Map params = new HashMap();
+ //发布人,不允许空值,必填
+ params.put("fileCreateName", fileCreateName);
+ //待阅文件标题名称,不允许空值,必填
+ params.put("fileName", fileName);
+ //阅读范围_组织,不允许空值,非必填
+ params.put("readingScope_org", readingScope_org);
+ //是否全公司可见,不允许空值,必填
+ params.put("isFullCompany", isFullCompany);
+ //待阅文件Url,不允许空值,必填
+ params.put("fileurl", fileurl);
+ //发布日期,不允许空值,必填
+ params.put("fileCreateDate", fileCreateDate);
+ //发布流程ID,不允许空值,必填
+ params.put("relationProcessinstId", relationProcessinstId);
+ //阅读范围_岗位,不允许空值,非必填
+ params.put("readingScope_post", readingScope_post);
+ //阅读范围_职级,不允许空值,非必填
+ params.put("readingScope_level", readingScope_level);
+ //待阅文件ID,多个逗号隔开,不允许空值,必填
+ params.put("fileid", fileid);
+ AppAPI appAPI = SDK.getAppAPI();
+ //推送待阅文件到xpage门户
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ System.out.println("ros++++++++=====待阅》》》》》》》》》》" + ro);
+ return ro.isOk();
+ }
+
+ /**
+ * 给知识授权
+ *
+ * @param processExecutionContext
+ * @param jsonArray
+ * @param sid
+ * @param knwlId
+ * @return
+ */
+ public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid,
+ String knwlId) {
+ // 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+ // aslp服务地址
+ String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC";
+ // 参数定义列表
+ Map params = new HashMap();
+ //[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填
+ params.put("acList", jsonArray);
+ //sid,如果为空,则需要传createUser参数,非必填
+ params.put("sid", sid);
+ //知识ID,必填
+ params.put("knwlId", knwlId);
+ AppAPI appAPI = SDK.getAppAPI();
+ //给知识授权
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ return ro.isOk();
+ }
+
+ /**
+ * 柱军的ASLP
+ *
+ * @param processExecutionContext
+ * @param wsId
+ * @param fileId
+ * @return
+ */
+ public boolean AttrSynAslp(ProcessExecutionContext processExecutionContext, String wsId, JSONArray fileId) {
+ System.out.println("");
+ // 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+ // aslp服务地址
+ String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp";
+ // 参数定义列表
+ Map params = new HashMap();
+ //资产内容库id,必填
+ params.put("wsId", wsId);
+ //文件id;json数组[id1,id2,id3],必填
+ params.put("fileId", fileId);
+ AppAPI appAPI = SDK.getAppAPI();
+ //增量同步数据
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ System.out.println("同步数据看板底表结果>>>>>>>>>>>>>" + ro);
+ return ro.isOk();
+ }
+
+ /**
+ * 发送OA待阅数据
+ *
+ * @param jsonObject
+ * @param processInstance
+ * @param results
+ * @throws DocumentException
+ */
+ public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String userId)
+ throws DocumentException {
+ //System.err.println(processInstance.getTitle() + "开始发送:" + userId);
+ if ("".equals(userId) || UtilString.isEmpty(userId)) {
+ return;
+ }
+ jsonObject.put("userList", userId);
+ String xmlStr = "\n"
+ + " " + " " + " " + " "
+ + "" + " " + " "
+ + " " + "";
+ //System.out.println("xmlStr>>>>>>>>" + xmlStr);
+ String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
+
+ String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, "");
+ Document document = DocumentHelper.parseText(postSoap);
+ Element rootElement = document.getRootElement();
+ //System.out.println("rootElement>>>>>>" + rootElement);
+ Element result = rootElement.element("Body").element("serviceResponse").element("out");
+ String resultString = result.getData().toString();
+ JSONObject jsonObject1 = JSON.parseObject(resultString);
+ String datas = jsonObject1.getString("data");
+ String status = jsonObject1.getString("status");
+ //System.out.println("推送》》》》》》》》》》》" + status);
+ if ("false".equals(status)) {
+ System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId);
+ try {
+ BO bo = new BO();
+ bo.set("TITLE", processInstance.getTitle());
+ bo.set("NAME", userId);
+ bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId());
+ SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser());
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ } else {
+ //System.out.println(processInstance.getTitle() + "待阅推送成功:" + userId);
+ JSONArray resultArray = JSONObject.parseArray(datas);
+ 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("DATAID", dataid);
+ bo.set("RESULT", status);
+ SDK.getBOAPI().create("BO_ACT_DATAID", bo, processInstance.getId(), processInstance.getCreateUser());
+ }
+ }
+ }
+
+ /**
+ * 发送EHSQ数据
+ *
+ * @param jsonArray
+ * @return
+ * @throws Exception
+ */
+ public String SendEHSQFile(JSONArray jsonArray) throws Exception {
+ System.out.println("===jsonArray===" + jsonArray);
+ /**
+ * 首先需要将传过来的参数进行加密操作,并设置
+ */
+ 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("jsonobject>>>>>>>>>>>>>>>>>>>" + jsonObject);
+ String s = httpUtil.sendPost(jsonObject, EHSQUrl);
+ System.out.println("发送到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 sendPostList = sendPost(post, sendOrgList, instanceById, bo_act_coe_publish1,
+ jsonObject);
+ userList = sendLevel(level, sendPostList, 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 sendPostList = sendPost(post, userList, instanceById, bo_act_coe_publish1,
+ jsonObject);
+ userList = sendLevel(level, sendPostList, 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)) {
+ 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)) {
+ 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");
+ 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() && !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".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)) {
+ arr_test.add(uid);
+ arr.add(userModel.getUID());
+ /*
+ * 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)) {
+ arr_test.add(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();
+ 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", processExecutionContext.getProcessInstance().getId());
+ bo_Read_log.set("SENDNUM", arr.size());
+ BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true)
+ .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId())
+ .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);
+ bo_Read_log.set("TIMECOUNT", (endTimes-startTime)/1000/60+"分钟");
+ SDK.getBOAPI().createDataBO("BO_EU_PAL_READ_LOG", bo_Read_log, processExecutionContext.getUserContext());
+
+ }
+
+ /**
+ * 通过发布知识创建知识
+ *
+ * @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.getString("PLVER").contains(".00")) {
+ String[] plvers = map.getString("PLVER").split("\\.");
+ plvers[1] = plvers[1].replaceAll("0", "");
+ level = plvers[0] + "." + plvers[1];
+ } else {
+ level = map.getString("PLVER");
+ }
+
+ 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();
+ if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) {
+ 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);
+ }
+ }
+ } else {
+ List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT");
+ for (RowMap depaid : select_id_from_orgdepartment) {
+ String id = depaid.getString("ID");
+ JSONObject jsonObjecta = new JSONObject();
+ jsonObjecta.put("assignmentType", "department");
+ jsonObjecta.put("assignmentId", 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) {
+ if (map.getString("PLVER").contains(".00")) {
+ String[] plvers = map.getString("PLVER").split("\\.");
+ plvers[1] = plvers[1].replaceAll("0", "");
+ level = plvers[0] + "." + plvers[1];
+ } else {
+ level = map.getString("PLVER");
+ }
+ }
+
+ 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();
+ if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) {
+ 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);
+ }
+ }
+
+ } else {
+ List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT");
+ for (RowMap depaid : select_id_from_orgdepartment) {
+ String id = depaid.getString("ID");
+ JSONObject jsonObjecta = new JSONObject();
+ jsonObjecta.put("assignmentType", "department");
+ jsonObjecta.put("assignmentId", 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"));
+ jsonObject_ehsq.put("filename", bo.getString("PUBLISHFILENAME"));
+ // 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);
+ jsonObject_ehsq.put("version", map.getString("PLVER"));
+ 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","总部质量管理部");
+ // //
+ jsonObject_ehsq.put("releasescope", "总部质量管理部");
+ 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")) {
+ } 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") + ";";
+ }
+ jsonObject_ehsq.put("releasescope", "总部质量管理部");
+
+ }
+ }
+
+ 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);
+ try {
+ SendEHSQFile(jsonArray_EHSQ);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ 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"));
+ jsonObject_ehsq.put("filename", bo.getString("CHANGEDFILENAMENEW"));
+ // jsonObject_ehsq.put("filecode",bo.getString("CHANGE_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);
+ jsonObject_ehsq.put("verion", map.getString("PLVER"));
+ 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("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") + ";";
+ }
+ 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);
+ try {
+ SendEHSQFile(jsonArray_EHSQ);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+}
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent2.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent2.java
new file mode 100644
index 00000000..9a5ea1a8
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent2.java
@@ -0,0 +1,1328 @@
+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.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.ProcessAPIManager;
+import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
+import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
+import com.actionsoft.bpms.bpmn.engine.model.run.TaskCommentModel;
+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.emm.util.AesUtil;
+import com.actionsoft.exception.AWSException;
+import com.actionsoft.sdk.local.SDK;
+import com.actionsoft.sdk.local.api.AppAPI;
+import com.actionsoft.sdk.local.api.LogAPI;
+import com.actionsoft.sdk.local.api.Logger;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.awspaas.yili.publishevent.util.DownloadUtil;
+import com.awspaas.yili.publishevent.util.HttpUtil;
+import com.awspaas.yili.publishevent.util.UtilUrl;
+import com.google.common.io.ByteStreams;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+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.*;
+import java.sql.Connection;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 流程结束后发送待阅数据
+ * @author wangchengye
+ * @time 2022/11/4
+ */
+@SuppressWarnings("all")
+public class ProcessEndAfterEvent2 {
+
+
+ public void ProcessData(ProcessExecutionContext processExecutionContext) throws Exception {
+ Connection open = DBSql.open();
+ //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.getProcessInstance().getStartTime();
+ BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).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")+"");
+ System.out.println("部门庄户》》》》》》》"+SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getTaskInstance().getTarget()).getNo());
+ jsonObject.put("dept",SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getTaskInstance().getTarget()).getNo());//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
+ String target = processExecutionContext.getTaskInstance().getTarget();
+ target = processExecutionContext.getTaskInstance().getTarget();
+
+ System.out.println("当前账户======》》》》"+target);
+
+ 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).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).addQuery("OPTIONTYPE IS NOT NULL",null).detail();
+ String uid = "";
+ String new_uid = "";
+ /**
+ * 这个判断是将获取到的人员信息汇总到uid中并去重并且赋值到新的字段中
+ */
+ if(bo_act_coe_publish1!=null) {
+ String da = bo_act_coe_publish1.getString("SEND_SCOP");
+
+ ArrayList userList = new ArrayList<>();
+ ArrayList userList2 = new ArrayList();
+
+ if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_ORG"))||"1".equals(da)) {
+ long startTime = System.currentTimeMillis();
+ userList = getUser(bo_act_coe_publish1.getString("SEND_SCOPE_ORG"), da, processExecutionContext.getProcessInstance().getId());
+ long endTimes = System.currentTimeMillis();
+ System.out.println(processExecutionContext.getProcessInstance().getTitle()+"_根据部门获取人员用时===>"+(endTimes-startTime)/1000);
+ }
+
+ if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_POST"))) {
+ String posts[] = bo_act_coe_publish1.getString("SEND_SCOPE_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)) {
+ userList.add(userId);
+ }
+
+ }
+ }
+ if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"))) {
+ String ranks[] = bo_act_coe_publish1.getString("SEND_SCOPE_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)) {
+ userList2.add(userId);
+ }
+
+ }
+ }
+
+ if (StringUtils.isEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"))) {
+
+ for (String uids : userList
+ ) {
+ uid += uids + ",";
+
+ }
+
+
+ } else {
+ for (String uids : userList2
+ ) {
+ uid += uids + ",";
+ }
+ }
+ //System.out.println("部门id》》》》》》》》》》》》》"+org_list );
+ //System.out.println("posts_list》》》》》》》》》》》》》"+posts_list);
+ //System.out.println("ranks_list》》》》》》》》》》》》》"+ranks_list);
+ //System.out.println("部门数量》》》》》》》》》》》》》"+org_list.size() );
+ //System.out.println("岗位数量》》》》》》》》》》》》》"+posts_list.size());
+ //System.out.println("职级数量》》》》》》》》》》》》》"+ranks_list.size());
+
+ }
+
+ /**
+ * 这个是将字符串截取
+ */
+ if (StringUtils.isNotEmpty(new_uid
+ )) {
+ new_uid = new_uid.substring(0, new_uid.length() - 1);
+ }
+ long startTime = System.currentTimeMillis();
+ System.out.println("new_userid ==========>>>>>>>>>"+new_uid);
+ String[] users = new_uid.split(",");
+ int length = 300;
+ 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 = new LinkedList();
+ for (int i=0;i bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
+ List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
+ List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+ JSONArray jsonArray = new JSONArray();
+
+
+/**
+ * 这里是去生成EHSQ相关数据
+ */
+ /* for (BO bo:bo_act_coe_publish_n
+ ) {
+ JSONArray jsonArray_EHSQ = new JSONArray();
+ JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>());
+ OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
+ 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"));
+ jsonObject_ehsq.put("filename",bo.getString("PUBLISHFILENAME"));
+ //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);
+ jsonObject_ehsq.put("version",map.getString("PLVER"));
+ 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","总部质量管理部");
+ // jsonObject_ehsq.put("releasescope","总部质量管理部");
+ 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")){
+ }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")+";";
+ }
+ jsonObject_ehsq.put("releasescope","总部质量管理部");
+
+ }
+ }
+
+ 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;i0){
+ String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId);
+ System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl);
+ jsonObject_ehsq.put("downloadurl",loadurl);
+ for (int i =1;i());
+ OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
+ 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"));
+ jsonObject_ehsq.put("filename",bo.getString("CHANGEDFILENAMENEW"));
+ //jsonObject_ehsq.put("filecode",bo.getString("CHANGE_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);
+ jsonObject_ehsq.put("verion",map.getString("PLVER"));
+ 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("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")+";";
+ }
+ 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;i0){
+ String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId);
+ System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl);
+ jsonObject_ehsq.put("downloadurl",loadurl);
+ for (int i =1;i>>>>>>"+map);
+ System.out.println("fileid==》》》》"+fileid);
+ System.out.println("id==》》》》"+map.getString("ID"));
+ RowMap rowMap = DBSql.getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'");
+ //BO bos = SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail();
+ if (rowMap!=null){
+
+ if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) {
+
+ OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID"));
+ if (model != null) {
+ System.out.println(",pdel============" + model);
+ System.out.println("123313123123123==========" + model.getProfileId());
+ OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
+ System.out.println("dajadfas======" + appProfile);
+ 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);
+ }
+ }
+
+ }
+ 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")+"'" +
+ ")";
+ List maps = DBSql.getMaps(sql_upfile);
+ for (RowMap row : maps) {
+ System.out.println("附件名称>>>>>>"+row.getString("FILENAME"));
+ 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);
+ System.out.println("流程模型附件的生成============="+ros);
+ }
+ }
+
+//DCContext对象,必填
+
+//创建文件
+ }
+ try {
+
+ PublishKnow(processExecutionContext,userContext,cardId);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+ /**
+ * 发布知识
+ * @param processExecutionContext
+ * @param userContext
+ * @param id
+ */
+ public void PublishKnow(ProcessExecutionContext processExecutionContext,UserContext userContext,String id){
+
+ String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+id +"')";
+ List maps = DBSql.getMaps(sql);
+ String ids = "";
+ for (RowMap rowmap:maps
+ ) {
+ ids+=rowmap.getString("EXT4")+",";
+ }
+ String[] deptSplit_id = ids.split(",");
+
+ JSONArray jsonArray = new JSONArray();
+ for (String id_names:deptSplit_id
+ ) {
+ jsonArray.add(id_names);
+ }
+ //jsonObject.put(deptSplit_id);
+ id+=",";
+ String[] deptSplit_das = id.split(",");
+ JSONArray jsonArray_das = new JSONArray();
+ for (String das:deptSplit_das
+ ) {
+ jsonArray_das.add(das);
+ }
+ //jsonObject.put(deptSplit_id);
+
+ if (!jsonArray_das.isEmpty()&&!jsonArray.isEmpty()){
+
+ // 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+// aslp服务地址
+ String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl";
+// 参数定义列表
+ Map params = new HashMap();
+//要发布到的维度ID的JSON数组字符串,必填
+ params.put("dimensionIDArray", jsonArray.toString());
+//要发布的知识ID的JSON数组字符串,必填
+ params.put("knwlIDArray", jsonArray_das.toString());
+//标签的JSON数组字符串,非必填
+
+//sid,必填
+ params.put("sid", userContext.getSessionId());
+ AppAPI appAPI = SDK.getAppAPI();
+//发布知识
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+
+ System.out.println("知识发布============"+ro);
+
+ }
+
+ }
+
+ /**
+ * 取消发布知识
+ * @param processExecutionContext
+ * @param sid
+ * @param knwlId
+ * @return
+ */
+ public boolean CancelPublishKnwl(ProcessExecutionContext processExecutionContext,String sid,String knwlId) {
+// 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+// aslp服务地址
+ String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl";
+// 参数定义列表
+ Map params = new HashMap();
+//sid,如果为空,则需要传createUser参数,非必填
+ params.put("sid", sid);
+//知识ID,必填
+ params.put("knwlId", knwlId);
+ AppAPI appAPI = SDK.getAppAPI();
+//取消发布知识(全部维度)
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ System.out.println("取消发布的ro=====>>>>"+ro);
+ return ro.isOk();
+ }
+
+ /**
+ * 创建XPage页面上的待阅文件
+ * @param processExecutionContext
+ * @param fileCreateName
+ * @param fileName
+ * @param fileurl
+ * @param readingScope_org
+ * @param isFullCompany
+ * @param fileCreateDate
+ * @param relationProcessinstId
+ * @param readingScope_post
+ * @param readingScope_level
+ * @param fileid
+ * @return
+ */
+ public boolean execute(ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid) {
+// 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+// aslp服务地址
+ String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage";
+// 参数定义列表
+ Map params = new HashMap();
+//发布人,不允许空值,必填
+ params.put("fileCreateName", fileCreateName);
+//待阅文件标题名称,不允许空值,必填
+ params.put("fileName", fileName);
+//阅读范围_组织,不允许空值,非必填
+ params.put("readingScope_org", readingScope_org);
+//是否全公司可见,不允许空值,必填
+ params.put("isFullCompany", isFullCompany);
+//待阅文件Url,不允许空值,必填
+ params.put("fileurl", fileurl);
+//发布日期,不允许空值,必填
+ params.put("fileCreateDate", fileCreateDate);
+//发布流程ID,不允许空值,必填
+ params.put("relationProcessinstId", relationProcessinstId);
+//阅读范围_岗位,不允许空值,非必填
+ params.put("readingScope_post", readingScope_post);
+//阅读范围_职级,不允许空值,非必填
+ params.put("readingScope_level", readingScope_level);
+//待阅文件ID,多个逗号隔开,不允许空值,必填
+ params.put("fileid", fileid);
+ AppAPI appAPI = SDK.getAppAPI();
+//推送待阅文件到xpage门户
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ System.out.println("ros++++++++=====待阅》》》》》》》》》》"+ro);
+ return ro.isOk();
+ }
+
+
+ /**
+ * 给知识授权
+ * @param processExecutionContext
+ * @param jsonArray
+ * @param sid
+ * @param knwlId
+ * @return
+ */
+ public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext,JSONArray jsonArray,String sid,String knwlId) {
+// 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+// aslp服务地址
+ String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC";
+// 参数定义列表
+ Map params = new HashMap();
+//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填
+ params.put("acList", jsonArray);
+//sid,如果为空,则需要传createUser参数,非必填
+ params.put("sid", sid);
+//知识ID,必填
+ params.put("knwlId", knwlId);
+ AppAPI appAPI = SDK.getAppAPI();
+//给知识授权
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ return ro.isOk();
+ }
+
+
+ /**
+ * 柱军的ASLP
+ * @param processExecutionContext
+ * @param wsId
+ * @param fileId
+ * @return
+ */
+ public boolean AttrSynAslp(ProcessExecutionContext processExecutionContext,String wsId,JSONArray fileId){
+ System.out.println("");
+ // 调用App
+ String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
+// aslp服务地址
+ String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp";
+// 参数定义列表
+ Map params = new HashMap();
+//资产内容库id,必填
+ params.put("wsId", wsId);
+//文件id;json数组[id1,id2,id3],必填
+ params.put("fileId", fileId);
+ AppAPI appAPI = SDK.getAppAPI();
+//增量同步数据
+ ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
+ System.out.println("ro>>>>>>>>>>>>>"+ro);
+ return ro.isOk();
+ }
+
+ /**
+ * 发送OA待阅数据信息
+ * @param jsonObject 待阅参数
+ * @param processExecutionContext 流程数据
+ * @param results 人员的集合
+ * @throws DocumentException
+ */
+ public void SendOARead(JSONObject jsonObject,ProcessExecutionContext processExecutionContext,String[] results) throws DocumentException {
+ String userId = "";
+ userId = StringUtils.join(results, ",");
+ jsonObject.put("userList",userId);
+
+
+ String xmlStr = "\n" +
+ " " +
+ " " +
+ " " +
+ " " +
+ ""+
+ " " +
+ " " +
+ " " +
+ "";
+ System.out.println("xmlStr>>>>>>>>"+xmlStr);
+ String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
+
+ String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, "");
+ Document document = DocumentHelper.parseText(postSoap);
+ Element rootElement = document.getRootElement();
+ System.out.println("rootElement>>>>>>"+rootElement);
+ Element result = rootElement.element("Body").element("serviceResponse").element("out");
+ String resultString = result.getData().toString();
+ JSONObject jsonObject1 = JSON.parseObject(resultString);
+ String datas = jsonObject1.getString("data");
+ String status = jsonObject1.getString("status");
+ System.out.println("状态是什么》》》》》》》》》》》"+status);
+ JSONArray resultArray = JSONObject.parseArray(datas);
+ for (int j=0;j>>>>>>>>>>>"+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("jsonobject>>>>>>>>>>>>>>>>>>>"+jsonObject);
+ String s = httpUtil.sendPost(jsonObject, EHSQUrl);
+ System.out.println("发送到EHSQ是否是正确的>>>>>>>>>"+s);
+
+ return s;
+ }
+ /**
+ * 根据部门id获取当前部门以及下级部门的人员信息
+ *
+ * @param processid
+ * @return
+ */
+
+ public ArrayList getUser(String depIds, String sendType, String processid) {
+ System.err.println("sendType=====>"+sendType);
+ 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()&&!"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id)&&!"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id)) {
+ System.err.println("==depName=====>"+departmentModel.getName());
+ getUserList(arr_test,arr,id, processid);
+
+ }
+ }
+ } else {
+ if(UtilString.isNotEmpty(depIds)) {
+ //具体部门
+ String[] split = depIds.split(",");
+ for (String depId : split) {
+ getUserList(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(ArrayList arr_test,ArrayList arr, String departmentId, String processid) {
+ // 获取当前部门下人员
+ List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId);
+ for (UserModel userModel : userModelList) {
+ if (!userModel.isClosed()) {
+ if (!arr.contains(userModel.getUID())) {
+ arr_test.add(userModel.getUID());
+ BO boList = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processid).addQuery("USER_ID=", userModel.getUID()).detail();
+ if (boList == null) {
+ arr.add(userModel.getUID());
+ }
+ }
+ }
+ }
+ // 获取当前部门的子部门人员
+ DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId);
+ if (departmentById.isExistSubModelOfCache()) {
+ getSubDepartments(arr_test,arr, departmentById, processid);
+ }
+
+ }
+
+ //获取子部门人员
+ public void getSubDepartments(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()) {
+ if (!arr.contains(userModel.getUID())) {
+ arr_test.add(userModel.getUID());
+ BO boList = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processid).addQuery("USER_ID=", userModel.getUID()).detail();
+ if (boList == null) {
+ arr.add(userModel.getUID());
+ }
+ }
+ }
+ }
+ //递归获取子部门下的子部门
+ if (SDK.getORGAPI().isExistSubDepartment(id)) {
+ getSubDepartments(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, String[] users,long startTime){
+ BO bo_Read_log = new BO();
+ 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",processExecutionContext.getProcessInstance().getId());
+ bo_Read_log.set("SENDNUM",users.length);
+ BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).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);
+ SDK.getBOAPI().createDataBO("BO_EU_PAL_READ_LOG",bo_Read_log,processExecutionContext.getUserContext());
+
+ }
+
+ /**
+ * 通过发布知识创建知识
+ * @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.getString("PLVER").contains(".00")){
+ String[] plvers = map.getString("PLVER").split("\\.");
+ plvers[1] = plvers[1].replaceAll("0","");
+ level = plvers[0]+"."+plvers[1];
+ }else {
+ level = map.getString("PLVER");
+ }
+
+ 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();
+ if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")){
+ 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);
+ }
+ }
+ }else{
+ List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT");
+ for (RowMap depaid:
+ select_id_from_orgdepartment) {
+ String id = depaid.getString("ID");
+ JSONObject jsonObjecta = new JSONObject();
+ jsonObjecta.put("assignmentType","department");
+ jsonObjecta.put("assignmentId",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){
+ if (map.getString("PLVER").contains(".00")){
+ String[] plvers = map.getString("PLVER").split("\\.");
+ plvers[1] = plvers[1].replaceAll("0","");
+ level = plvers[0]+"."+plvers[1];
+ }else {
+ level = map.getString("PLVER");
+ }
+ }
+
+
+ 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();
+ if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")){
+ 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);
+ }
+ }
+
+ }else{
+ List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT");
+ for (RowMap depaid:
+ select_id_from_orgdepartment) {
+ String id = depaid.getString("ID");
+ JSONObject jsonObjecta = new JSONObject();
+ jsonObjecta.put("assignmentType","department");
+ jsonObjecta.put("assignmentId",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+"'"
+ );
+ }
+ }
+ }
+}
diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/UtilUrl.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/UtilUrl.java
new file mode 100644
index 00000000..9015667e
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/UtilUrl.java
@@ -0,0 +1,51 @@
+package com.actionsoft.apps.coe.pal.publisher.pubEvent;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import java.nio.charset.Charset;
+
+/**
+ * @PackageName: com.awspaas.user.apps.yili.integration.util
+ * @ClassName: UtilUrl
+ * @author: yujh
+ * @date: 2022/5/18 21:41
+ */
+public class UtilUrl {
+
+ //使用SOAP1.1发送消息
+ public static String doPostSoap(String postUrl, String soapXml, String soapAction) {
+ String retStr = "";
+ // 创建HttpClientBuilder
+ HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
+ // HttpClient
+ CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
+ HttpPost httpPost = new HttpPost(postUrl);
+ // 设置请求和传输超时时间
+ RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(600000)
+ .setConnectTimeout(600000).build();
+ httpPost.setConfig(requestConfig);
+ try {
+ httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
+ httpPost.setHeader("SOAPAction", soapAction);
+ StringEntity data = new StringEntity(soapXml, Charset.forName("UTF-8"));
+ httpPost.setEntity(data);
+ CloseableHttpResponse response = closeableHttpClient.execute(httpPost);
+ HttpEntity httpEntity = response.getEntity();
+ if (httpEntity != null) {
+ // 打印响应内容
+ retStr = EntityUtils.toString(httpEntity, "UTF-8");
+ }
+ // 释放资源
+ closeableHttpClient.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return retStr;
+ }
+}