1.生成编号时排序生成

2.推送oa待阅改为每次推送300条
This commit is contained in:
lihongyu 2022-11-23 12:58:46 +08:00
parent b093205609
commit bba471fc4e
2 changed files with 184 additions and 153 deletions

View File

@ -120,9 +120,9 @@ public class ProcesNumberUtil {
System.out.println("生成编号并写入数据库==============="); System.out.println("生成编号并写入数据库===============");
// 查询出所有的发布流程 // 查询出所有的发布流程
List<BO> dataList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindId).list(); List<BO> dataList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindId).orderByCreated().asc().list();
// 查询出所有的变更流程 // 查询出所有的变更流程
List<BO> changList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", bindId).list(); List<BO> changList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", bindId).orderByCreated().asc().list();
if (changList.size() != 0) { if (changList.size() != 0) {
for (BO changData : changList) { for (BO changData : changList) {
String change_numner = changData.getString("CHANGE_NUMBER"); String change_numner = changData.getString("CHANGE_NUMBER");

View File

@ -64,34 +64,35 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
private String isSendEHSQ = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendEHSQ"); 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 isSendOA = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendOA");
private String isSendKMS = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendKMS"); private String isSendKMS = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isSendKMS");
@Override
public String getDescription() {
return "确认发布节点任务完成后推送OA/EHSQ/KMS";
}
@Override @Override
public String getVersion() { public String getDescription() {
return "1.0"; return "确认发布节点任务完成后推送OA/EHSQ/KMS";
} }
@Override
public String getVersion() {
return "1.0";
}
@Override @Override
public void execute(ProcessExecutionContext ext) throws Exception { public void execute(ProcessExecutionContext ext) throws Exception {
ExecutorService service = Executors.newFixedThreadPool(1); ExecutorService service = Executors.newFixedThreadPool(1);
service.execute(new Runnable() { service.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
ProcessData(ext); ProcessData(ext);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
}
} }
} });
});
} }
public void ProcessData(ProcessExecutionContext processExecutionContext) throws Exception { public void ProcessData(ProcessExecutionContext processExecutionContext) throws Exception {
System.err.println(processExecutionContext.getTaskInstance().getTitle()+"_推送文件开始========>"); System.err.println(processExecutionContext.getTaskInstance().getTitle() + "_推送文件开始========>");
Connection open = DBSql.open(); 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 // http://localhost:8089/portal/r/or?cmd=com.hy_client_bpm_form_main_page_open&oauthName=oauthLogin&processInstId=3505e654-9217-41cd-a31d-4971846b3219
/** /**
@ -102,7 +103,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String wsId = ""; String wsId = "";
JSONArray filed = new JSONArray(new LinkedList<>()); JSONArray filed = new JSONArray(new LinkedList<>());
String portalUrl = SDK.getPortalAPI().getPortalUrl(); String portalUrl = SDK.getPortalAPI().getPortalUrl();
System.out.println("portal======>>>>" + portalUrl); //System.out.println("portal======>>>>" + portalUrl);
/* /*
* if (portalUrl.equals("http://10.114.11.135:8088/portal")){ portalUrl = * if (portalUrl.equals("http://10.114.11.135:8088/portal")){ portalUrl =
* "http://bpm.yili.com:8088/portal/"; } * "http://bpm.yili.com:8088/portal/"; }
@ -176,7 +177,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
/** /**
* 推送到知识库 * 推送到知识库
*/ */
if("true".equals(isSendKMS)) { if ("true".equals(isSendKMS)) {
try { try {
// 发布到知识库 // 发布到知识库
int m = 0; int m = 0;
@ -185,29 +186,32 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
} }
// 更新知识库 // 更新知识库
for (BO bo : bo_act_coe_publish_c) { for (BO bo : bo_act_coe_publish_c) {
CreateKmsByupdate(bo, wsId, filed, processExecutionContext, bo_act_coe_publish, crateUserId); CreateKmsByupdate(bo, wsId, filed, processExecutionContext, bo_act_coe_publish,
crateUserId);
} }
// 废止知识库文件 // 废止知识库文件
for (BO bo : bo_act_coe_publish_s) { for (BO bo : bo_act_coe_publish_s) {
// 将旧的知识取消发布或者移动到废止发布中 // 将旧的知识取消发布或者移动到废止发布中
String publishfileid_stop = bo.getString("STOPFILEID"); String publishfileid_stop = bo.getString("STOPFILEID");
filed.add(publishfileid_stop); filed.add(publishfileid_stop);
String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_stop + "'"; String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_stop
+ "'";
RowMap map1 = DBSql.getMap(sql_s); RowMap map1 = DBSql.getMap(sql_s);
if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { if (StringUtils.isNotEmpty(map1.getString("EXT4"))) {
CancelPublishKnwl(processExecutionContext, CancelPublishKnwl(processExecutionContext,
processExecutionContext.getUserContext().getSessionId(), map1.getString("EXT4")); processExecutionContext.getUserContext().getSessionId(),
map1.getString("EXT4"));
DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_stop
+ "'"); DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '"
+ publishfileid_stop + "'");
} }
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
} }
/** /**
* 更新数据看板底表 * 更新数据看板底表
*/ */
@ -216,58 +220,76 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
/** /**
* 推送待阅文件到OA * 推送待阅文件到OA
*/ */
if("true".equals(isSendOA)) { if ("true".equals(isSendOA)) {
ProcessInstance instanceById = processExecutionContext.getProcessInstance(); ProcessInstance instanceById = processExecutionContext.getProcessInstance();
if (bo_act_coe_publish1 != null && instanceById != null) { if (bo_act_coe_publish1 != null && instanceById != null) {
System.err.println(instanceById.getTitle() + "推送OA待阅执行开始====>"); System.err.println(instanceById.getTitle() + "推送OA待阅执行开始====>");
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
ArrayList<String> sendList = getSendList(instanceById, bo_act_coe_publish1, jsonObject); ArrayList<String> sendList = getSendList(instanceById, bo_act_coe_publish1, jsonObject);
System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size()); System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size());
for (String uid : sendList) { int toIndex = 300;
try { int listSize = sendList.size();
SendOARead(jsonObject, instanceById, uid); boolean shutdown = false;
/* for (int i = 0; i < sendList.size(); i += 300) {
* ExecutorService service = Executors.newFixedThreadPool(5); if (i + 300 > listSize) {
* service.execute(new Runnable() { toIndex = listSize - i;
*
* @Override public void run() { try { } catch (Exception e) { // TODO
* Auto-generated catch block e.printStackTrace(); } } });
*/
} catch (Exception e) {
} }
List<String> idList = sendList.subList(i, i + toIndex);
SendOARead(jsonObject, instanceById, idList);
/*
* ExecutorService service = Executors.newFixedThreadPool(3);
* service.execute(new Runnable() {
*
* @Override public void run() { try { } catch (Exception e) { // TODO
* Auto-generated catch block e.printStackTrace(); } } });
*/
} }
/*
* for (String uid : sendList) { try { SendOARead(jsonObject, instanceById,
* uid);
*
* ExecutorService service = Executors.newFixedThreadPool(5);
* service.execute(new Runnable() {
*
* @Override public void run() { try { } catch (Exception e) { // TODO
* Auto-generated catch block e.printStackTrace(); } } });
*
*
* } catch (Exception e) { } }
*/
long endTimes = System.currentTimeMillis(); long endTimes = System.currentTimeMillis();
//存入日志 // 存入日志
createReadLog(processExecutionContext, jsonObject, sendList, startTime,endTimes); createReadLog(processExecutionContext, jsonObject, sendList, startTime, endTimes);
System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:"+(endTimes-startTime)/1000/60+"分钟"); System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:"
+ (endTimes - startTime) / 1000 / 60 + "分钟");
} }
} }
/** /**
* 推送到EHSQ * 推送到EHSQ
*/ */
if("true".equals(isSendEHSQ)) { if ("true".equals(isSendEHSQ)) {
try { try {
//推送EHSQ // 推送EHSQ
sendEHSQ(processExecutionContext, bo_act_coe_publish_n); sendEHSQ(processExecutionContext, bo_act_coe_publish_n);
//更新EHSQ // 更新EHSQ
updateEHSQ(processExecutionContext, bo_act_coe_publish_c); updateEHSQ(processExecutionContext, bo_act_coe_publish_c);
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
open.close(); open.close();
} }
} }
@ -307,7 +329,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID"));
if (model != null) { if (model != null) {
//System.out.println("pdel============" + model); // System.out.println("pdel============" + model);
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
if (appProfile == null) { if (appProfile == null) {
throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId());
@ -450,16 +472,16 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl";
// 参数定义列表 // 参数定义列表
Map params = new HashMap<String, Object>(); Map params = new HashMap<String, Object>();
//要发布到的维度ID的JSON数组字符串,必填 // 要发布到的维度ID的JSON数组字符串,必填
params.put("dimensionIDArray", jsonArray.toString()); params.put("dimensionIDArray", jsonArray.toString());
//要发布的知识ID的JSON数组字符串,必填 // 要发布的知识ID的JSON数组字符串,必填
params.put("knwlIDArray", jsonArray_das.toString()); params.put("knwlIDArray", jsonArray_das.toString());
//标签的JSON数组字符串,非必填 // 标签的JSON数组字符串,非必填
//sid,必填 // sid,必填
params.put("sid", userContext.getSessionId()); params.put("sid", userContext.getSessionId());
AppAPI appAPI = SDK.getAppAPI(); AppAPI appAPI = SDK.getAppAPI();
//发布知识 // 发布知识
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
System.out.println("知识发布============" + ro); System.out.println("知识发布============" + ro);
@ -483,12 +505,12 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl"; String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl";
// 参数定义列表 // 参数定义列表
Map params = new HashMap<String, Object>(); Map params = new HashMap<String, Object>();
//sid如果为空则需要传createUser参数,非必填 // sid如果为空则需要传createUser参数,非必填
params.put("sid", sid); params.put("sid", sid);
//知识ID,必填 // 知识ID,必填
params.put("knwlId", knwlId); params.put("knwlId", knwlId);
AppAPI appAPI = SDK.getAppAPI(); AppAPI appAPI = SDK.getAppAPI();
//取消发布知识全部维度 // 取消发布知识全部维度
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
System.out.println("取消发布的ro=====>>>>" + ro); System.out.println("取消发布的ro=====>>>>" + ro);
return ro.isOk(); return ro.isOk();
@ -510,7 +532,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
* @param fileid * @param fileid
* @return * @return
*/ */
public boolean execute(ProcessExecutionContext processExecutionContext, String fileCreateName, String fileName,String fileurl, String readingScope_org, String isFullCompany, String fileCreateDate, 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) { String relationProcessinstId, String readingScope_post, String readingScope_level, String fileid) {
// 调用App // 调用App
String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
@ -518,28 +541,28 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage"; String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage";
// 参数定义列表 // 参数定义列表
Map params = new HashMap<String, Object>(); Map params = new HashMap<String, Object>();
//发布人不允许空值,必填 // 发布人不允许空值,必填
params.put("fileCreateName", fileCreateName); params.put("fileCreateName", fileCreateName);
//待阅文件标题名称不允许空值,必填 // 待阅文件标题名称不允许空值,必填
params.put("fileName", fileName); params.put("fileName", fileName);
//阅读范围_组织不允许空值,非必填 // 阅读范围_组织不允许空值,非必填
params.put("readingScope_org", readingScope_org); params.put("readingScope_org", readingScope_org);
//是否全公司可见不允许空值,必填 // 是否全公司可见不允许空值,必填
params.put("isFullCompany", isFullCompany); params.put("isFullCompany", isFullCompany);
//待阅文件Url不允许空值,必填 // 待阅文件Url不允许空值,必填
params.put("fileurl", fileurl); params.put("fileurl", fileurl);
//发布日期不允许空值,必填 // 发布日期不允许空值,必填
params.put("fileCreateDate", fileCreateDate); params.put("fileCreateDate", fileCreateDate);
//发布流程ID不允许空值,必填 // 发布流程ID不允许空值,必填
params.put("relationProcessinstId", relationProcessinstId); params.put("relationProcessinstId", relationProcessinstId);
//阅读范围_岗位不允许空值,非必填 // 阅读范围_岗位不允许空值,非必填
params.put("readingScope_post", readingScope_post); params.put("readingScope_post", readingScope_post);
//阅读范围_职级不允许空值,非必填 // 阅读范围_职级不允许空值,非必填
params.put("readingScope_level", readingScope_level); params.put("readingScope_level", readingScope_level);
//待阅文件ID,多个逗号隔开不允许空值,必填 // 待阅文件ID,多个逗号隔开不允许空值,必填
params.put("fileid", fileid); params.put("fileid", fileid);
AppAPI appAPI = SDK.getAppAPI(); AppAPI appAPI = SDK.getAppAPI();
//推送待阅文件到xpage门户 // 推送待阅文件到xpage门户
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
System.out.println("ros++++++++=====待阅》》》》》》》》》》" + ro); System.out.println("ros++++++++=====待阅》》》》》》》》》》" + ro);
return ro.isOk(); return ro.isOk();
@ -554,22 +577,23 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
* @param knwlId * @param knwlId
* @return * @return
*/ */
public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid,String knwlId) { public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid,
String knwlId) {
// 调用App // 调用App
String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
// aslp服务地址 // aslp服务地址
String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC";
// 参数定义列表 // 参数定义列表
Map params = new HashMap<String, Object>(); Map params = new HashMap<String, Object>();
//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 // [{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填
params.put("acList", jsonArray); params.put("acList", jsonArray);
//sid如果为空则需要传createUser参数,非必填 // sid如果为空则需要传createUser参数,非必填
params.put("sid", sid); params.put("sid", sid);
//知识ID,必填 // 知识ID,必填
params.put("knwlId", knwlId); params.put("knwlId", knwlId);
AppAPI appAPI = SDK.getAppAPI(); AppAPI appAPI = SDK.getAppAPI();
//给知识授权 // 给知识授权
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
return ro.isOk(); return ro.isOk();
} }
@ -590,12 +614,12 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp"; String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp";
// 参数定义列表 // 参数定义列表
Map params = new HashMap<String, Object>(); Map params = new HashMap<String, Object>();
//资产内容库id,必填 // 资产内容库id,必填
params.put("wsId", wsId); params.put("wsId", wsId);
//文件idjson数组[id1,id2,id3],必填 // 文件idjson数组[id1,id2,id3],必填
params.put("fileId", fileId); params.put("fileId", fileId);
AppAPI appAPI = SDK.getAppAPI(); AppAPI appAPI = SDK.getAppAPI();
//增量同步数据 // 增量同步数据
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
System.out.println("同步数据看板底表结果>>>>>>>>>>>>>" + ro); System.out.println("同步数据看板底表结果>>>>>>>>>>>>>" + ro);
return ro.isOk(); return ro.isOk();
@ -609,44 +633,50 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
* @param results * @param results
* @throws DocumentException * @throws DocumentException
*/ */
public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String userId) public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, List<String> idList)
throws DocumentException { throws DocumentException {
//System.err.println(processInstance.getTitle() + "开始发送:" + userId); // System.err.println(processInstance.getTitle() + "开始发送:" + userId);
if ("".equals(userId) || UtilString.isEmpty(userId)) {
/*
* if ("".equals(userId) || UtilString.isEmpty(userId)) { return; }
*/
if (idList.size() == 0) {
return; return;
} }
jsonObject.put("userList", userId); String userIds = StringUtils.join(idList, ",");
jsonObject.put("userList", userIds);
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n" String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>" + " <web:in0>" + " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>" + " <web:in0>"
+ "<![CDATA[" + jsonObject + "]]>" + " </web:in0>" + " </web:service>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>" + " </web:service>"
+ " </soapenv:Body>" + "</soapenv:Envelope>"; + " </soapenv:Body>" + "</soapenv:Envelope>";
//System.out.println("xmlStr>>>>>>>>" + xmlStr); // System.out.println("xmlStr>>>>>>>>" + xmlStr);
String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, ""); String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, "");
Document document = DocumentHelper.parseText(postSoap); Document document = DocumentHelper.parseText(postSoap);
Element rootElement = document.getRootElement(); Element rootElement = document.getRootElement();
//System.out.println("rootElement>>>>>>" + rootElement); // System.out.println("rootElement>>>>>>" + rootElement);
Element result = rootElement.element("Body").element("serviceResponse").element("out"); Element result = rootElement.element("Body").element("serviceResponse").element("out");
String resultString = result.getData().toString(); String resultString = result.getData().toString();
JSONObject jsonObject1 = JSON.parseObject(resultString); JSONObject jsonObject1 = JSON.parseObject(resultString);
String datas = jsonObject1.getString("data"); String datas = jsonObject1.getString("data");
String status = jsonObject1.getString("status"); String status = jsonObject1.getString("status");
//System.out.println("推送》》》》》》》》》》》" + status); // System.out.println("推送》》》》》》》》》》》" + status);
if ("false".equals(status)) { if ("false".equals(status)) {
System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId); for (String userId : idList) {
try { System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId);
BO bo = new BO(); try {
bo.set("TITLE", processInstance.getTitle()); BO bo = new BO();
bo.set("NAME", userId); bo.set("TITLE", processInstance.getTitle());
bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId()); bo.set("NAME", userId);
SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId());
} catch (Exception e) { SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser());
// TODO: handle exception } catch (Exception e) {
// TODO: handle exception
}
} }
} else { } else {
//System.out.println(processInstance.getTitle() + "待阅推送成功:" + userId);
JSONArray resultArray = JSONObject.parseArray(datas); JSONArray resultArray = JSONObject.parseArray(datas);
System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList);
for (int j = 0; j < resultArray.size(); j++) { for (int j = 0; j < resultArray.size(); j++) {
JSONObject jsonObject2 = resultArray.getJSONObject(j); JSONObject jsonObject2 = resultArray.getJSONObject(j);
String user = jsonObject2.get("user").toString(); String user = jsonObject2.get("user").toString();
@ -745,19 +775,18 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
// 如果只有组织不为空 // 如果只有组织不为空
if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isEmpty(level)) { if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isEmpty(level)) {
System.err.println("发送组织=====>" + instanceById.getTitle()); System.err.println("发送组织=====>" + instanceById.getTitle());
userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject,sendType); userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, sendType);
} }
// 如果只有岗位不为空 // 如果只有岗位不为空
if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) { if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) {
System.err.println("发送岗位=====>" + instanceById.getTitle()); System.err.println("发送岗位=====>" + instanceById.getTitle());
userList = sendPost(post, userList, instanceById, bo_act_coe_publish1,jsonObject); userList = sendPost(post, userList, instanceById, bo_act_coe_publish1, jsonObject);
} }
// 如果只有职级不为空 // 如果只有职级不为空
if (UtilString.isEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) { if (UtilString.isEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) {
System.err.println("发送职级=====>" + instanceById.getTitle()); System.err.println("发送职级=====>" + instanceById.getTitle());
userList = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject); userList = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject);
} }
} }
@ -838,7 +867,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
return userList_level; return userList_level;
} }
// 只发送职级 // 只发送职级
public ArrayList<String> sendLevel2(String level, ArrayList<String> userList, ProcessInstance instanceById, public ArrayList<String> sendLevel2(String level, ArrayList<String> userList, ProcessInstance instanceById,
BO bo_act_coe_publish1, JSONObject jsonObject) { BO bo_act_coe_publish1, JSONObject jsonObject) {
@ -882,7 +911,9 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
for (DepartmentModel departmentModel : departmentsByCompanyId) { for (DepartmentModel departmentModel : departmentsByCompanyId) {
String id = departmentModel.getId(); String id = departmentModel.getId();
// 查询未注销的部门并且去掉系统部门 // 查询未注销的部门并且去掉系统部门
if (!departmentModel.isClosed() && !"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id)&&!"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id)&&!"65048aee-157f-49f2-a2dc-5903dd26f519".equals(id)) { if (!departmentModel.isClosed() && !"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id)
&& !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id)
&& !"65048aee-157f-49f2-a2dc-5903dd26f519".equals(id)) {
getUserList(jsonObject, arr_test, arr, id, processid); getUserList(jsonObject, arr_test, arr, id, processid);
} }
@ -911,8 +942,10 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
if (!userModel.isClosed()) { if (!userModel.isClosed()) {
String uid = userModel.getUID(); String uid = userModel.getUID();
if (!arr.contains(uid)) { if (!arr.contains(uid)) {
arr_test.add(uid); if(!"10033643".equals(uid)) {
arr.add(userModel.getUID()); //arr_test.add(uid);
arr.add(uid);
}
/* /*
* RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" * RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"
* + processid + "' AND USER_ID = '" + uid + "'"); if (map == null) { * + processid + "' AND USER_ID = '" + uid + "'"); if (map == null) {
@ -942,23 +975,27 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
if (!userModel.isClosed()) { if (!userModel.isClosed()) {
String uid = userModel.getUID(); String uid = userModel.getUID();
if (!arr.contains(uid)) { if (!arr.contains(uid)) {
arr_test.add(uid); if (!"10033643".equals(uid)) {
arr.add(uid); // arr_test.add(uid);
//System.err.println(SDK.getProcessAPI().getInstanceById(processid) + "_发送人员======>" + 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); if (SDK.getORGAPI().isExistSubDepartment(id)) {
} getSubDepartments(jsonObject, arr_test, arr, SDK.getORGAPI().getDepartmentById(id), processid);
} }
} }
} }
} }
}
/** /**
* 创建线程发送待阅 * 创建线程发送待阅
* *
@ -997,8 +1034,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
* @param startTime * @param startTime
*/ */
public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject, ArrayList<String> arr, public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject,
long startTime,long endTimes) { ArrayList<String> arr, long startTime, long endTimes) {
BO bo_Read_log = new BO(); BO bo_Read_log = new BO();
String processInstId = processExecutionContext.getProcessInstance().getId(); String processInstId = processExecutionContext.getProcessInstance().getId();
bo_Read_log.set("USREID", processExecutionContext.getUserContext().getUID()); bo_Read_log.set("USREID", processExecutionContext.getUserContext().getUID());
@ -1007,11 +1044,10 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
bo_Read_log.set("TITLE", jsonObject.get("title")); bo_Read_log.set("TITLE", jsonObject.get("title"));
bo_Read_log.set("PROCESSID", processInstId); bo_Read_log.set("PROCESSID", processInstId);
bo_Read_log.set("SENDNUM", arr.size()); bo_Read_log.set("SENDNUM", arr.size());
String sqly ="SELECT * FROM BO_ACT_DATAID WHERE PROCESSID = '"+processInstId+"' AND SENDTYPE = '1'"; String sqly = "SELECT * FROM BO_ACT_DATAID WHERE PROCESSID = '" + processInstId + "' AND SENDTYPE = '1'";
List<RowMap> mapsy = DBSql.getMaps(sqly); List<RowMap> mapsy = DBSql.getMaps(sqly);
bo_Read_log.set("SENDNUMSJ", mapsy.size()); bo_Read_log.set("SENDNUMSJ", mapsy.size());
BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId)
.addQuery("BINDID=", processInstId)
.addQuery("OPTIONTYPE IS NOT NULL", null).detail(); .addQuery("OPTIONTYPE IS NOT NULL", null).detail();
String send_scop = bo_act_coe_publishs.getString("SEND_SCOP"); String send_scop = bo_act_coe_publishs.getString("SEND_SCOP");
bo_Read_log.set("SEND_SCOP", send_scop); bo_Read_log.set("SEND_SCOP", send_scop);
@ -1033,10 +1069,11 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
bo_Read_log.set("STARTTIMES", startTime); bo_Read_log.set("STARTTIMES", startTime);
bo_Read_log.set("ENDTIMES", endTimes); bo_Read_log.set("ENDTIMES", endTimes);
bo_Read_log.set("TIMECOUNT", (endTimes-startTime)/1000/60+"分钟"); bo_Read_log.set("TIMECOUNT", (endTimes - startTime) / 1000 / 60 + "分钟");
//文件发布成功回执流程 // 文件发布成功回执流程
ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance("obj_b4700f89a7a144c086d047de0cfe9531", "admin", jsonObject.get("title")+"成功发布回执单"); ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance("obj_b4700f89a7a144c086d047de0cfe9531",
SDK.getBOAPI().create("BO_EU_PAL_PULBISH_SUCCESS", bo_Read_log, processInst,UserContext.fromUID("admin")); "admin", jsonObject.get("title") + "成功发布回执单");
SDK.getBOAPI().create("BO_EU_PAL_PULBISH_SUCCESS", bo_Read_log, processInst, UserContext.fromUID("admin"));
TaskInstance taskInst = SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0); TaskInstance taskInst = SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0);
SDK.getTaskAPI().completeTask(taskInst.getId(), "admin"); SDK.getTaskAPI().completeTask(taskInst.getId(), "admin");
@ -1223,7 +1260,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
ResponseObject ro_create = appAPI_create.callASLP( ResponseObject ro_create = appAPI_create.callASLP(
appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()),
aslps_create, params_create); aslps_create, params_create);
System.out.println("ro_create================" + ro_create); //System.out.println("ro_create================" + ro_create);
String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString();
JSONArray jsonArray1 = new JSONArray(); JSONArray jsonArray1 = new JSONArray();
if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) { if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) {
@ -1308,8 +1345,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
bo.set("BUNAME", UserContext.fromUID(uids).getUserModel().getExt2()); bo.set("BUNAME", UserContext.fromUID(uids).getUserModel().getExt2());
SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG", bo, UserContext.fromUID("admin")); SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG", bo, UserContext.fromUID("admin"));
} }
public void sendEHSQ(ProcessExecutionContext processExecutionContext,List<BO> bo_act_coe_publish_n) { public void sendEHSQ(ProcessExecutionContext processExecutionContext, List<BO> bo_act_coe_publish_n) {
for (BO bo : bo_act_coe_publish_n) { for (BO bo : bo_act_coe_publish_n) {
DownloadUtil downloadUtil = new DownloadUtil(); DownloadUtil downloadUtil = new DownloadUtil();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@ -1334,14 +1371,12 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
jsonObject_ehsq.put("authorname", jsonObject_ehsq.put("authorname",
UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName());
// jsonObject_ehsq.put("authorname","毛鹏程"); // jsonObject_ehsq.put("authorname","毛鹏程");
jsonObject_ehsq.put("companycode", jsonObject_ehsq.put("companycode", UserContext
UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()) .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo());
.getDepartmentModel().getNo());
// jsonObject_ehsq.put("companycode","00000013"); // jsonObject_ehsq.put("companycode","00000013");
jsonObject_ehsq.put("authorcompany", jsonObject_ehsq.put("authorcompany", UserContext
UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()) .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); // jsonObject_ehsq.put("authorcompany","总部质量管理部");
.getDepartmentModel().getName()); // jsonObject_ehsq.put("authorcompany","总部质量管理部"); // //
// //
jsonObject_ehsq.put("releasescope", "总部质量管理部"); jsonObject_ehsq.put("releasescope", "总部质量管理部");
BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true)
.addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); .addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail();
@ -1374,8 +1409,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
LoginConst.DEVICE_PC); LoginConst.DEVICE_PC);
System.out.println("办理者的sessionid>>>>>>>>>>>" + sessionId); System.out.println("办理者的sessionid>>>>>>>>>>>" + sessionId);
String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), bo.getString("PUBLISHFILENAME"));
bo.getString("PUBLISHFILENAME"));
// jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1)); // jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1));
String recordfiles = ""; String recordfiles = "";
String recordurls = ""; String recordurls = "";
@ -1418,8 +1452,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
} }
} }
} }
public void updateEHSQ(ProcessExecutionContext processExecutionContext,List<BO> bo_act_coe_publish_c) { public void updateEHSQ(ProcessExecutionContext processExecutionContext, List<BO> bo_act_coe_publish_c) {
DownloadUtil downloadUtil = new DownloadUtil(); DownloadUtil downloadUtil = new DownloadUtil();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (BO bo : bo_act_coe_publish_c) { for (BO bo : bo_act_coe_publish_c) {
@ -1429,8 +1463,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String wsId = model.getWsId(); String wsId = model.getWsId();
String publishfileid = bo.getString("CHANGEDFILEIDNEW"); String publishfileid = bo.getString("CHANGEDFILEIDNEW");
LinkedHashMap<String, String> downloadurl = downloadUtil.outputReportDownload( LinkedHashMap<String, String> downloadurl = downloadUtil.outputReportDownload(
UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), bo.getString("TASKID"),
bo.getString("TASKID"), publishfileid); publishfileid);
jsonObject_ehsq.put("fileid", bo.getString("TASKID")); jsonObject_ehsq.put("fileid", bo.getString("TASKID"));
jsonObject_ehsq.put("filename", bo.getString("CHANGEDFILENAMENEW")); jsonObject_ehsq.put("filename", bo.getString("CHANGEDFILENAMENEW"));
// jsonObject_ehsq.put("filecode",bo.getString("CHANGE_NUMBER")); // jsonObject_ehsq.put("filecode",bo.getString("CHANGE_NUMBER"));
@ -1443,12 +1477,10 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
jsonObject_ehsq.put("authorcode", processExecutionContext.getTaskInstance().getTarget()); jsonObject_ehsq.put("authorcode", processExecutionContext.getTaskInstance().getTarget());
jsonObject_ehsq.put("authorname", jsonObject_ehsq.put("authorname",
UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName());
jsonObject_ehsq.put("companycode", jsonObject_ehsq.put("companycode", UserContext
UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()) .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo());
.getDepartmentModel().getNo()); jsonObject_ehsq.put("authorcompany", UserContext
jsonObject_ehsq.put("authorcompany", .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName());
UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget())
.getDepartmentModel().getName());
BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true)
.addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); .addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail();
if (bo1 != null) { if (bo1 != null) {
@ -1523,5 +1555,4 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
} }
} }
} }