diff --git a/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar b/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar index 2f1ec8ae..7f4c46be 100644 Binary files a/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar and b/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar differ diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ProcessEndAfterEvent.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ProcessEndAfterEvent.java new file mode 100644 index 00000000..1bc8e505 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/ProcessEndAfterEvent.java @@ -0,0 +1,1064 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +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.TaskInstance; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.util.DBSql; +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.user.apps.integration.oa.TaskListener; +import com.awspaas.user.apps.integration.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.DocumentHelper; +import org.dom4j.Element; + +import java.io.*; +import java.sql.Connection; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; + +public class ProcessEndAfterEvent extends ExecuteListener { + private Logger logger = LogAPI.getLogger(TaskListener.class); + + @Override + public String getVersion() { + return "0.0.1"; + } + + @Override + public String getProvider() { + return "ActionSoft"; + } + + @Override + public String getDescription() { + return "流程结束后发送代阅任务"; + } + + @Override + public void execute(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())) { + + 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()).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()).detail(); + String uid = ""; + String new_uid = ""; + if(bo_act_coe_publish1!=null) { + String da = bo_act_coe_publish1.getString("SEND_SCOP"); + + if (da.equals("1")) { + List select_userid_from_orguser = DBSql.getMaps("select USERID from ORGUSER"); + for (RowMap row : select_userid_from_orguser + ) { + uid += row.getString("USERID") + ","; + } + } else { + List posts_list = new ArrayList(); + List org_list = new ArrayList(); + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_ORG"))){ + String strs[] = bo_act_coe_publish1.getString("SEND_SCOPE_ORG").split(","); + org_list= Arrays.asList(strs); + } + + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_POST"))) { + String posts[] = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + posts_list = Arrays.asList(posts); + } + List ranks_list = new ArrayList(); + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"))) { + String ranks[] = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + ranks_list = Arrays.asList(ranks); + } + + System.out.println("部门id》》》》》》》》》》》》》"+org_list ); + System.out.println("posts_list》》》》》》》》》》》》》"+posts_list); + System.out.println("ranks_list》》》》》》》》》》》》》"+ranks_list); + if (org_list.size()!=0 && org_list!=null) { + for (String depaartid : org_list + ) { + System.out.println("departid>>>>>>>>>>>>>" + depaartid); + DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentById(depaartid); + boolean existSubModelOfCache = departmentModel.isExistSubModelOfCache(); + System.out.println("是否含有下级?????????????" + existSubModelOfCache); + //判断选中的是否有下级部门 + if (existSubModelOfCache) { + List maps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + depaartid + "'"); + for (RowMap row : maps + ) { + String id = row.getString("ID"); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); + + if (model.isExistSubModelOfCache()) { + //有下级部门的选中有下级部门 + List rowMapList = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + id + "'"); + for (RowMap wo : + rowMapList) { + String ids = wo.getString("ID"); + DepartmentModel model1 = SDK.getORGAPI().getDepartmentById(ids); + if (model1.isExistSubModelOfCache()) { + List rowMapLists = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + ids + "'"); + for (RowMap wsa : + rowMapLists) { + String wsaString = wsa.getString("ID"); + DepartmentModel model2 = SDK.getORGAPI().getDepartmentById(wsaString); + if (model2.isExistSubModelOfCache()) { + List rowMapList1 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + wsaString + "'"); + for (RowMap rows : + rowMapList1) { + String rowsString = rows.getString("ID"); + DepartmentModel model3 = SDK.getORGAPI().getDepartmentById(rowsString); + if (model3.isExistSubModelOfCache()) { + List rowMapList2 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString + "'"); + for (RowMap ormap : + rowMapList2) { + String rowsString1 = ormap.getString("ID"); + DepartmentModel model4 = SDK.getORGAPI().getDepartmentById(rowsString1); + if (model4.isExistSubModelOfCache()) { + List rowMaps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString1 + "'"); + for (RowMap owmapr : + rowMaps) { + String row_id = owmapr.getString("ID"); + DepartmentModel model5 = SDK.getORGAPI().getDepartmentById(row_id); + if (model5.isExistSubModelOfCache()) { + List rowMapList3 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + row_id + "'"); + for (RowMap owzmap : + rowMapList3) { + String idsa = owzmap.getString("ID"); + DepartmentModel model6 = SDK.getORGAPI().getDepartmentById(idsa); + if (model6.isExistSubModelOfCache()) { + + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(idsa); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(row_id); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString1); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(wsaString); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(ids); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + //选中的没有下级部门 + List allUsersByDepartment = SDK.getORGAPI().getAllUsersByDepartment(depaartid); + for (UserModel user : allUsersByDepartment + ) { + System.out.println("user.getExt2())???????????" + user.getExt2()); + System.out.println("posts_list》》》》》》》》》das" + (posts_list.size() != 0)); + System.out.println("123123》》》》》》》》》》" + (ranks_list.size() != 0)); + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + + } + } + if (org_list.size()==0||org_list==null){ + String posts=""; + String levels = ""; + if (posts_list.size() !=0 &&ranks_list.size()!=0){ + String[] post = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + String[] level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + if (post.length==1){ + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + posts = "'"+post[0]+"'"; + }else { + posts = "'"+ StringUtils.join(post, "','")+"'"; + } + if (level.length==1){ + levels = "'"+level[0]+"'"; + }else { + levels = "'"+ StringUtils.join(level, "','")+"'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where POSITION_NO in(" + posts + ") and EXT2 in (" + levels + ")"); + for (RowMap map:maps + ) { + uid+=map.getString("USERID")+","; + } + } else if (posts_list.size() !=0 &&ranks_list.size()==0) { + String[] post = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + if (post.length==1){ + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + posts = "'"+post[0]+"'"; + }else { + posts = "'"+ StringUtils.join(post, "','")+"'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where POSITION_NO in(" + posts + ")"); + for (RowMap map:maps + ) { + uid+=map.getString("USERID")+","; + } + }else if (posts_list.size() ==0 &&ranks_list.size()!=0){ + String[] level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + + if (level.length==1){ + levels = "'"+level[0]+"'"; + }else { + levels = "'"+ StringUtils.join(level, "','")+"'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where EXT2 in (" + levels + ")"); + for (RowMap map:maps + ) { + uid+=map.getString("USERID")+","; + } + } + + } + } + System.out.println("userid》》》》》》》》》》》》》》》》》》》"+uid); + if (StringUtils.isNotEmpty(uid + )) { + uid = uid.substring(0, uid.length() - 1); + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + for (String userid:list + ) { + + System.out.println("当前账户======》》》》"+userid); + // BO boEuOaReson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=", userid).detail(); + // if (boEuOaReson!=null){ + new_uid+=userid+","; + // } + + } + } + } + + if (StringUtils.isNotEmpty(new_uid + )) { + new_uid = new_uid.substring(0, new_uid.length() - 1); + } + System.out.println("new_userid ==========>>>>>>>>>"+new_uid); + jsonObject.put("userList",new_uid); + + + String xmlStr = "\n" + + " " + + " " + + " " + + " " + + ""+ + " " + + " " + + " " + + ""; + System.out.println("xmlStr>>>>>>>>"+xmlStr); + String postSoap = UtilUrl.doPostSoap("http://10.105.1.59:80/services/service_lcglpt", 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 i=0;i(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + params_create.put("knwlName", map.getString("PLNAME")+map.getString("PLVER")); +//是否可以评论,必填 + 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 = "); + } + } + + for (BO bo:bo_act_coe_publish_c + ) { + 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); +//知识名称,必填 + params_create.put("knwlName", map.getString("PLNAME")+map.getString("PLVER")); +//是否可以评论,必填 + 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+"'" + ); + } + } + + 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")); + /*String sql_update = "UPDATE APP_ACT_KMS_CARD SET ISPUBLISHED = '0' WHERE ID = '"+map1.getString("EXT4")+"'"; + int update = DBSql.update(sql_update); + System.out.println(bo.getString("STOPFILENAME")+"废止文件发布的影响行数"+update);*/ + + DBSql.update( + "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '"+publishfileid_stop+"'" + ); + + } + } + + + + + }catch (Exception e){ + e.printStackTrace(); + }finally { + AttrSynAslp(processExecutionContext,wsId,filed); + open.close(); + } + } + } + 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) { + 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(); + } + } + } + + + + 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); + + } + + } + + + 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(); + } + + + 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(); + } + + + + 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(); + } + + + + 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(); + } + +}