diff --git a/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java b/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java index 957c962b..ee058308 100644 --- a/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java +++ b/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java @@ -65,7 +65,12 @@ public class AddAgentSaveCmd extends AbstractCommonCommand>{ //当开启了代理原有待办时,对接门户,删除被代理人的待办,增加代理人的待办,部分流转 1 if(isPendThing == 1){ + //单独 处理待办的 DealPortalTodoAndDone(agentuid,bagentuid,workflowids); + //单独 处理抄送的 + DealPortalChaoSong(agentuid,bagentuid,workflowids); + //单独 处理转发的 + DealPortalForward(agentuid,bagentuid,workflowids); } agentresult = agentManager.batchAddAgent(workflowids, bean, overlapMethod); if(!"success".equals(agentresult)) { @@ -127,13 +132,13 @@ public class AddAgentSaveCmd extends AbstractCommonCommand>{ String cus_staff = PropBean.getUfPropValue("cus_staff") ; String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); - String sql = " select distinct t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " + + String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " + " from workflow_base t " + " left join workflow_requestbase t1 on t.id=t1.workflowid " + " left join workflow_currentoperator t2 on t1.requestid = t2.requestid " + " left join hrmresource h1 on h1.id = t1.creater "+ " where t2.usertype=0 and t2.userid in (" + beagenterid +") and t.id in (" + workflowids +") "+ - " and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('1','5','9','7','8','9','11') ) " + + " and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('5','9','7','11') ) " + " and t2.islasttimes=1 " + " and (t.isvalid=3 or t.isvalid=1) "; @@ -143,6 +148,7 @@ public class AddAgentSaveCmd extends AbstractCommonCommand>{ String taskType = "0"; rs1.executeQuery(sql); while (rs1.next()) { + String userid = Util.null2String(rs1.getString("userid")); String requestid = Util.null2String(rs1.getString("requestid")); String workflowname = ""; @@ -250,6 +256,338 @@ public class AddAgentSaveCmd extends AbstractCommonCommand>{ } } + /** + * 单独处理 抄送 的 + * 先查询出被代理人的待办,然后一一推送给门户,代理人待办增加,被代理人待办删除 + * @param agenterid 代理人 + * @param beagenterid 被代理人 + * @param workflowids 指定流程id + */ + public void DealPortalChaoSong(int agenterid, int beagenterid, String workflowids){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + JSONArray taskObjectList = new JSONArray(); + String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; + Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT); + JSONObject taskObject = new JSONObject(); + rs.writeLog("==================== AddAgentSaveCmd DealPortalChaoSong ==================="); + + try { + taskObject.put("objectAction", "0"); + taskObject.put("objectType", "0"); + taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid))); + taskObject.put("objectId", getStaffId(agenterid)); + taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid))); + taskObjectList.add(taskObject); + + HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); + SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); + SendMailUtil sendMailUtil = new SendMailUtil(); + + String scopeid = "-1"; + String scope = "HrmCustomFieldByInfoType" ; + + String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl"); + String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl"); + String portal_todourl = PropBean.getUfPropValue("portal_todourl"); + String username = PropBean.getUfPropValue("username"); + String passwd = PropBean.getUfPropValue("passwd"); + String center = PropBean.getUfPropValue("center"); + String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl"); + String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); + String cus_staff = PropBean.getUfPropValue("cus_staff") ; + String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); + + String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " + + " from workflow_base t " + + " left join workflow_requestbase t1 on t.id=t1.workflowid " + + " left join workflow_currentoperator t2 on t1.requestid = t2.requestid " + + " left join hrmresource h1 on h1.id = t1.creater "+ + " where t2.usertype=0 and t2.userid in (" + beagenterid +") and t.id in (" + workflowids +") "+ + " and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('8','9') " + + " and t2.islasttimes=1 " + + " and (t.isvalid=3 or t.isvalid=1) "; + + String zhjkbs = "com.engine.workflow.cmd.agent.AddAgentSaveCmd.DealPortalChaoSong"; + String actionType = "1"; + String terminal = "1"; + String taskType = "0"; + rs1.executeQuery(sql); + while (rs1.next()) { + String userid = Util.null2String(rs1.getString("userid")); + String requestid = Util.null2String(rs1.getString("requestid")); + + String workflowname = ""; + String nodeId = ""; + String nodeName = ""; + JSONObject requestObject = new JSONObject(); + String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid; + String replace = bpm_app_workflowurl.replace("/bpm", ""); + String urlDing = replace + bpm_app_requesturl + requestid; + String urlApp = replace + bpm_app_requesturl + requestid; + if (StringUtils.isNotEmpty(mobileJumpUrl)) { + urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + } + + String msgdata = ""; + String requestname = ""; + String lastname = ""; + String userids = ""; + String loginid = ""; + String emailArray = ""; + + sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " + + " from workflow_requestbase t1\n" + + " inner join workflow_base t3 on t1.workflowid = t3.id\n" + + " left join workflow_nodebase d1 on d1.id = t1.currentnodeid " + + " left join (select id,lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h2 on h2.id = t1.creater \n" + + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + + " and t1.requestid = " + requestid; + + rs.writeLog("AddAgentSaveCmd DealPortalChaoSong -- sql:" + sql); + + rs.executeQuery(sql); + if (rs.next()) { + requestname = Util.null2String(rs.getString("requestname")); + workflowname = Util.null2String(rs.getString("workflowname")); + nodeId = Util.null2String(rs.getString("nodeid") + user.getUID()); + nodeName = Util.null2String(rs.getString("nodeName")); + lastname = Util.null2String(rs.getString("lastname")); + loginid = Util.null2String(rs.getString("loginid")); + } + requestObject.put("center", center); + requestObject.put("title", requestname); + requestObject.put("creator", loginid); + requestObject.put("taskCode", requestid+"_cs_"+ userid); + requestObject.put("nodeId", nodeId); + requestObject.put("taskType", taskType); + requestObject.put("actionType", actionType); + requestObject.put("createDate", processTime); + requestObject.put("messageTitle", getShortMessageTitle(requestname)); + requestObject.put("messageContent", requestname); + requestObject.put("terminal", terminal); + requestObject.put("urlPc", urlPc); + requestObject.put("urlApp", urlApp); + requestObject.put("urlDing", urlDing); + requestObject.put("nodeName", nodeName); + requestObject.put("ticketType", workflowname); + + JSONObject taskObject1 = new JSONObject(); + taskObject1.put("objectAction", "1"); + taskObject1.put("objectType", "0"); + taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid))); + taskObject1.put("objectId", getStaffId(beagenterid)); + taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid))); + taskObjectList.add(taskObject1); + + if (taskObjectList.size() > 0) { + requestObject.put("taskObjectList", taskObjectList); + } else { + requestObject.put("actionType", "3"); + } + String auth = username + ":" + passwd; + + rs.writeLog("================== AddAgentSaveCmd DealPortalChaoSong ======================== "+requestObject.toJSONString()); + + msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth); + if (!"".equals(msgdata)) { + JSONObject msgObject = JSONObject.parseObject(msgdata); + if (msgObject.containsKey("resultCode")) { + String resultCode = msgObject.getString("resultCode"); + if ("0".equals(resultCode)) { + + rs.writeLog("AddAgentSaveCmd emailArray:" + emailArray); + if (StringUtils.isNotEmpty(emailArray)) { + + Map templateMap = getEmailTemplate(requestname, lastname, processTime); + String notificationSubject = templateMap.get("notificationSubject"); + String notificationContent = templateMap.get("notificationContent"); + + sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent); + } + + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, "",zhjkbs,String.valueOf(agenterid)); + + } else { + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs,String.valueOf(agenterid)); + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + } + + /** + * 单独处理 转发 的 + * 先查询出被代理人的待办,然后一一推送给门户,代理人待办增加,被代理人待办删除 + * @param agenterid 代理人 + * @param beagenterid 被代理人 + * @param workflowids 指定流程id + */ + public void DealPortalForward(int agenterid, int beagenterid, String workflowids){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + JSONArray taskObjectList = new JSONArray(); + String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; + Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT); + JSONObject taskObject = new JSONObject(); + rs.writeLog("==================== AddAgentSaveCmd DealPortalForward ==================="); + + try { + taskObject.put("objectAction", "0"); + taskObject.put("objectType", "0"); + taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid))); + taskObject.put("objectId", getStaffId(agenterid)); + taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid))); + taskObjectList.add(taskObject); + + HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); + SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); + SendMailUtil sendMailUtil = new SendMailUtil(); + + String scopeid = "-1"; + String scope = "HrmCustomFieldByInfoType" ; + + String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl"); + String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl"); + String portal_todourl = PropBean.getUfPropValue("portal_todourl"); + String username = PropBean.getUfPropValue("username"); + String passwd = PropBean.getUfPropValue("passwd"); + String center = PropBean.getUfPropValue("center"); + String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl"); + String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); + String cus_staff = PropBean.getUfPropValue("cus_staff") ; + String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); + + String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " + + " from workflow_base t " + + " left join workflow_requestbase t1 on t.id=t1.workflowid " + + " left join workflow_currentoperator t2 on t1.requestid = t2.requestid " + + " left join hrmresource h1 on h1.id = t1.creater "+ + " where t2.usertype=0 and t2.userid in (" + beagenterid +") and t.id in (" + workflowids +") "+ + " and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('1') " + + " and t2.islasttimes=1 " + + " and (t.isvalid=3 or t.isvalid=1) "; + + String zhjkbs = "com.engine.workflow.cmd.agent.AddAgentSaveCmd.DealPortalForward"; + String actionType = "1"; + String terminal = "1"; + String taskType = "0"; + rs1.executeQuery(sql); + while (rs1.next()) { + String userid = Util.null2String(rs1.getString("userid")); + String requestid = Util.null2String(rs1.getString("requestid")); + + String workflowname = ""; + String nodeId = ""; + String nodeName = ""; + JSONObject requestObject = new JSONObject(); + String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid; + String replace = bpm_app_workflowurl.replace("/bpm", ""); + String urlDing = replace + bpm_app_requesturl + requestid; + String urlApp = replace + bpm_app_requesturl + requestid; + if (StringUtils.isNotEmpty(mobileJumpUrl)) { + urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + } + + String msgdata = ""; + String requestname = ""; + String lastname = ""; + String userids = ""; + String loginid = ""; + String emailArray = ""; + + sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " + + " from workflow_requestbase t1\n" + + " inner join workflow_base t3 on t1.workflowid = t3.id\n" + + " left join workflow_nodebase d1 on d1.id = t1.currentnodeid " + + " left join (select id,lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h2 on h2.id = t1.creater \n" + + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + + " and t1.requestid = " + requestid; + + rs.writeLog("AddAgentSaveCmd DealPortalForward -- sql:" + sql); + + rs.executeQuery(sql); + if (rs.next()) { + requestname = Util.null2String(rs.getString("requestname")); + workflowname = Util.null2String(rs.getString("workflowname")); + nodeId = Util.null2String(rs.getString("nodeid") + user.getUID()); + nodeName = Util.null2String(rs.getString("nodeName")); + lastname = Util.null2String(rs.getString("lastname")); + loginid = Util.null2String(rs.getString("loginid")); + } + requestObject.put("center", center); + requestObject.put("title", requestname); + requestObject.put("creator", loginid); + requestObject.put("taskCode", "weaver" + requestid+"_zf_"+ userid); + requestObject.put("nodeId", nodeId); + requestObject.put("taskType", taskType); + requestObject.put("actionType", actionType); + requestObject.put("createDate", processTime); + requestObject.put("messageTitle", getShortMessageTitle(requestname)); + requestObject.put("messageContent", requestname); + requestObject.put("terminal", terminal); + requestObject.put("urlPc", urlPc); + requestObject.put("urlApp", urlApp); + requestObject.put("urlDing", urlDing); + requestObject.put("nodeName", nodeName); + requestObject.put("ticketType", workflowname); + + JSONObject taskObject1 = new JSONObject(); + taskObject1.put("objectAction", "1"); + taskObject1.put("objectType", "0"); + taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid))); + taskObject1.put("objectId", getStaffId(beagenterid)); + taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid))); + taskObjectList.add(taskObject1); + + if (taskObjectList.size() > 0) { + requestObject.put("taskObjectList", taskObjectList); + } else { + requestObject.put("actionType", "3"); + } + String auth = username + ":" + passwd; + + rs.writeLog("================== AddAgentSaveCmd DealPortalForward ======================== "+requestObject.toJSONString()); + + msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth); + if (!"".equals(msgdata)) { + JSONObject msgObject = JSONObject.parseObject(msgdata); + if (msgObject.containsKey("resultCode")) { + String resultCode = msgObject.getString("resultCode"); + if ("0".equals(resultCode)) { + + rs.writeLog("AddAgentSaveCmd emailArray:" + emailArray); + if (StringUtils.isNotEmpty(emailArray)) { + + Map templateMap = getEmailTemplate(requestname, lastname, processTime); + String notificationSubject = templateMap.get("notificationSubject"); + String notificationContent = templateMap.get("notificationContent"); + + sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent); + } + + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, "",zhjkbs,String.valueOf(agenterid)); + + } else { + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs,String.valueOf(agenterid)); + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + } + public String getShortMessageTitle(String messageTitle) { if (messageTitle.length() > 20) { messageTitle = messageTitle.substring(0, 17) + "..."; diff --git a/src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java b/src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java index c193b78a..ca947a9c 100644 --- a/src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java +++ b/src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java @@ -119,7 +119,12 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ beagenterid = Util.getIntValue(rs.getString("beagenterid")); workflowids = Util.null2String(rs.getString("workflowid")); + //单独 处理待办的 DealPortalTodoAndDone(agenterid,beagenterid,workflowids); + //单独 处理抄送的 + DealPortalChaoSong(agenterid,beagenterid,workflowids); + //单独 处理转发的 + DealPortalForward(agenterid,beagenterid,workflowids); } } @@ -167,13 +172,13 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ String cus_staff = PropBean.getUfPropValue("cus_staff") ; String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); - String sql = " select distinct t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " + + String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " + " from workflow_base t " + " left join workflow_requestbase t1 on t.id=t1.workflowid " + " left join workflow_currentoperator t2 on t1.requestid = t2.requestid " + " left join hrmresource h1 on h1.id = t1.creater "+ " where t2.usertype=0 and t2.userid in (" + agenterid +") and t.id in (" + workflowids +") "+ - " and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('1','5','9','7','8','9','11') ) " + + " and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('5','9','7','11') ) " + " and t2.islasttimes=1 " + " and (t.isvalid=3 or t.isvalid=1) and t2.agenttype = 2 "; @@ -183,6 +188,7 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ String taskType = "0"; rs1.executeQuery(sql); while (rs1.next()) { + String userid = Util.null2String(rs1.getString("userid")); String requestid = Util.null2String(rs1.getString("requestid")); String workflowname = ""; @@ -290,6 +296,344 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ } } + /** + * 单独处理 抄送 的 + * 先查询出被代理人的待办,然后一一推送给门户,代理人待办增加,被代理人待办删除 + * @param agenterid 代理人 + * @param beagenterid 被代理人 + * @param workflowids 指定流程id + */ + public void DealPortalChaoSong(int agenterid, int beagenterid, String workflowids){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + JSONArray taskObjectList = new JSONArray(); + String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; + Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT); + JSONObject taskObject = new JSONObject(); + rs.writeLog("==================== TakeBackAgentCmd DealPortalChaoSong ==================="); + rs.writeLog("==================== TakeBackAgentCmd DealPortalChaoSong agenterid ==================="+agenterid); + rs.writeLog("==================== TakeBackAgentCmd DealPortalChaoSong beagenterid ==================="+ beagenterid); + rs.writeLog("==================== TakeBackAgentCmd DealPortalChaoSong workflowids ==================="+ workflowids); + try { + + taskObject.put("objectAction", "0"); + taskObject.put("objectType", "0"); + taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid))); + taskObject.put("objectId", getStaffId(beagenterid)); + taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid))); + taskObjectList.add(taskObject); + + HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); + SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); + SendMailUtil sendMailUtil = new SendMailUtil(); + + String scopeid = "-1"; + String scope = "HrmCustomFieldByInfoType" ; + + String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl"); + String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl"); + String portal_todourl = PropBean.getUfPropValue("portal_todourl"); + String username = PropBean.getUfPropValue("username"); + String passwd = PropBean.getUfPropValue("passwd"); + String center = PropBean.getUfPropValue("center"); + String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl"); + String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); + String cus_staff = PropBean.getUfPropValue("cus_staff") ; + String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); + + String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " + + " from workflow_base t " + + " left join workflow_requestbase t1 on t.id=t1.workflowid " + + " left join workflow_currentoperator t2 on t1.requestid = t2.requestid " + + " left join hrmresource h1 on h1.id = t1.creater "+ + " where t2.usertype=0 and t2.userid in (" + agenterid +") and t.id in (" + workflowids +") "+ + " and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('8','9') ) " + + " and t2.islasttimes=1 " + + " and (t.isvalid=3 or t.isvalid=1) and t2.agenttype = 2 "; + + String zhjkbs = "com.engine.workflow.cmd.agent.TakeBackAgentCmd.DealPortalChaoSong"; + String actionType = "1"; + String terminal = "1"; + String taskType = "0"; + rs1.executeQuery(sql); + while (rs1.next()) { + String userid = Util.null2String(rs1.getString("userid")); + String requestid = Util.null2String(rs1.getString("requestid")); + + String workflowname = ""; + String nodeId = ""; + String nodeName = ""; + JSONObject requestObject = new JSONObject(); + String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid; + String replace = bpm_app_workflowurl.replace("/bpm", ""); + String urlDing = replace + bpm_app_requesturl + requestid; + String urlApp = replace + bpm_app_requesturl + requestid; + if (StringUtils.isNotEmpty(mobileJumpUrl)) { + urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + } + + String msgdata = ""; + String requestname = ""; + String lastname = ""; + String userids = ""; + String loginid = ""; + String emailArray = ""; + + sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " + + " from workflow_requestbase t1\n" + + " inner join workflow_base t3 on t1.workflowid = t3.id\n" + + " left join workflow_nodebase d1 on d1.id = t1.currentnodeid " + + " left join (select id,lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h2 on h2.id = t1.creater \n" + + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + + " and t1.requestid = " + requestid; + + rs.writeLog("TakeBackAgentCmd DealPortalChaoSong -- sql:" + sql); + + rs.executeQuery(sql); + if (rs.next()) { + requestname = Util.null2String(rs.getString("requestname")); + workflowname = Util.null2String(rs.getString("workflowname")); + nodeId = Util.null2String(rs.getString("nodeid") + user.getUID()); + nodeName = Util.null2String(rs.getString("nodeName")); + lastname = Util.null2String(rs.getString("lastname")); + loginid = Util.null2String(rs.getString("loginid")); + } + requestObject.put("center", center); + requestObject.put("title", requestname); + requestObject.put("creator", loginid); + requestObject.put("taskCode", requestid +"_cs_"+ userid); + requestObject.put("nodeId", nodeId); + requestObject.put("taskType", taskType); + requestObject.put("actionType", actionType); + requestObject.put("createDate", processTime); + requestObject.put("messageTitle", getShortMessageTitle(requestname)); + requestObject.put("messageContent", requestname); + requestObject.put("terminal", terminal); + requestObject.put("urlPc", urlPc); + requestObject.put("urlApp", urlApp); + requestObject.put("urlDing", urlDing); + requestObject.put("nodeName", nodeName); + requestObject.put("ticketType", workflowname); + + JSONObject taskObject1 = new JSONObject(); + taskObject1.put("objectAction", "1"); + taskObject1.put("objectType", "0"); + taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid))); + taskObject1.put("objectId", getStaffId(agenterid)); + taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid))); + taskObjectList.add(taskObject1); + + if (taskObjectList.size() > 0) { + requestObject.put("taskObjectList", taskObjectList); + } else { + requestObject.put("actionType", "3"); + } + String auth = username + ":" + passwd; + + rs.writeLog("================== TakeBackAgentCmd DealPortalChaoSong ======================== "+requestObject.toJSONString()); + + msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth); + if (!"".equals(msgdata)) { + JSONObject msgObject = JSONObject.parseObject(msgdata); + if (msgObject.containsKey("resultCode")) { + String resultCode = msgObject.getString("resultCode"); + if ("0".equals(resultCode)) { + + rs.writeLog("TakeBackAgentCmd emailArray:" + emailArray); + if (StringUtils.isNotEmpty(emailArray)) { + + Map templateMap = getEmailTemplate(requestname, lastname, processTime); + String notificationSubject = templateMap.get("notificationSubject"); + String notificationContent = templateMap.get("notificationContent"); + + sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent); + } + + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, "",zhjkbs,String.valueOf(agenterid)); + + } else { + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs,String.valueOf(agenterid)); + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + } + + /** + * 单独处理 转发 的 + * 先查询出被代理人的待办,然后一一推送给门户,代理人待办增加,被代理人待办删除 + * @param agenterid 代理人 + * @param beagenterid 被代理人 + * @param workflowids 指定流程id + */ + public void DealPortalForward(int agenterid, int beagenterid, String workflowids){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + JSONArray taskObjectList = new JSONArray(); + String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; + Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT); + JSONObject taskObject = new JSONObject(); + rs.writeLog("==================== TakeBackAgentCmd DealPortalForward ==================="); + rs.writeLog("==================== TakeBackAgentCmd DealPortalForward agenterid ==================="+agenterid); + rs.writeLog("==================== TakeBackAgentCmd DealPortalForward beagenterid ==================="+ beagenterid); + rs.writeLog("==================== TakeBackAgentCmd DealPortalForward workflowids ==================="+ workflowids); + try { + + taskObject.put("objectAction", "0"); + taskObject.put("objectType", "0"); + taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid))); + taskObject.put("objectId", getStaffId(beagenterid)); + taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid))); + taskObjectList.add(taskObject); + + HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); + SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); + SendMailUtil sendMailUtil = new SendMailUtil(); + + String scopeid = "-1"; + String scope = "HrmCustomFieldByInfoType" ; + + String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl"); + String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl"); + String portal_todourl = PropBean.getUfPropValue("portal_todourl"); + String username = PropBean.getUfPropValue("username"); + String passwd = PropBean.getUfPropValue("passwd"); + String center = PropBean.getUfPropValue("center"); + String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl"); + String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); + String cus_staff = PropBean.getUfPropValue("cus_staff") ; + String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); + + String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " + + " from workflow_base t " + + " left join workflow_requestbase t1 on t.id=t1.workflowid " + + " left join workflow_currentoperator t2 on t1.requestid = t2.requestid " + + " left join hrmresource h1 on h1.id = t1.creater "+ + " where t2.usertype=0 and t2.userid in (" + agenterid +") and t.id in (" + workflowids +") "+ + " and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('1') ) " + + " and t2.islasttimes=1 " + + " and (t.isvalid=3 or t.isvalid=1) and t2.agenttype = 2 "; + + String zhjkbs = "com.engine.workflow.cmd.agent.TakeBackAgentCmd.DealPortalForward"; + String actionType = "1"; + String terminal = "1"; + String taskType = "0"; + rs1.executeQuery(sql); + while (rs1.next()) { + String userid = Util.null2String(rs1.getString("userid")); + String requestid = Util.null2String(rs1.getString("requestid")); + + String workflowname = ""; + String nodeId = ""; + String nodeName = ""; + JSONObject requestObject = new JSONObject(); + String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid; + String replace = bpm_app_workflowurl.replace("/bpm", ""); + String urlDing = replace + bpm_app_requesturl + requestid; + String urlApp = replace + bpm_app_requesturl + requestid; + if (StringUtils.isNotEmpty(mobileJumpUrl)) { + urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + } + + String msgdata = ""; + String requestname = ""; + String lastname = ""; + String userids = ""; + String loginid = ""; + String emailArray = ""; + + sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " + + " from workflow_requestbase t1\n" + + " inner join workflow_base t3 on t1.workflowid = t3.id\n" + + " left join workflow_nodebase d1 on d1.id = t1.currentnodeid " + + " left join (select id,lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h2 on h2.id = t1.creater \n" + + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + + " and t1.requestid = " + requestid; + + rs.writeLog("TakeBackAgentCmd DealPortalForward -- sql:" + sql); + + rs.executeQuery(sql); + if (rs.next()) { + requestname = Util.null2String(rs.getString("requestname")); + workflowname = Util.null2String(rs.getString("workflowname")); + nodeId = Util.null2String(rs.getString("nodeid") + user.getUID()); + nodeName = Util.null2String(rs.getString("nodeName")); + lastname = Util.null2String(rs.getString("lastname")); + loginid = Util.null2String(rs.getString("loginid")); + } + requestObject.put("center", center); + requestObject.put("title", requestname); + requestObject.put("creator", loginid); + requestObject.put("taskCode", "weaver" + requestid +"_zf_"+ userid); + requestObject.put("nodeId", nodeId); + requestObject.put("taskType", taskType); + requestObject.put("actionType", actionType); + requestObject.put("createDate", processTime); + requestObject.put("messageTitle", getShortMessageTitle(requestname)); + requestObject.put("messageContent", requestname); + requestObject.put("terminal", terminal); + requestObject.put("urlPc", urlPc); + requestObject.put("urlApp", urlApp); + requestObject.put("urlDing", urlDing); + requestObject.put("nodeName", nodeName); + requestObject.put("ticketType", workflowname); + + JSONObject taskObject1 = new JSONObject(); + taskObject1.put("objectAction", "1"); + taskObject1.put("objectType", "0"); + taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid))); + taskObject1.put("objectId", getStaffId(agenterid)); + taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid))); + taskObjectList.add(taskObject1); + + if (taskObjectList.size() > 0) { + requestObject.put("taskObjectList", taskObjectList); + } else { + requestObject.put("actionType", "3"); + } + String auth = username + ":" + passwd; + + rs.writeLog("================== TakeBackAgentCmd DealPortalForward ======================== "+requestObject.toJSONString()); + + msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth); + if (!"".equals(msgdata)) { + JSONObject msgObject = JSONObject.parseObject(msgdata); + if (msgObject.containsKey("resultCode")) { + String resultCode = msgObject.getString("resultCode"); + if ("0".equals(resultCode)) { + + rs.writeLog("TakeBackAgentCmd emailArray:" + emailArray); + if (StringUtils.isNotEmpty(emailArray)) { + + Map templateMap = getEmailTemplate(requestname, lastname, processTime); + String notificationSubject = templateMap.get("notificationSubject"); + String notificationContent = templateMap.get("notificationContent"); + + sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent); + } + + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, "",zhjkbs,String.valueOf(agenterid)); + + } else { + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs,String.valueOf(agenterid)); + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + } + public String getShortMessageTitle(String messageTitle) { if (messageTitle.length() > 20) { messageTitle = messageTitle.substring(0, 17) + "..."; diff --git a/src/weaver/interfaces/dito/mq/RocketmqUtil.java b/src/weaver/interfaces/dito/mq/RocketmqUtil.java index 7a794234..1fe240d0 100644 --- a/src/weaver/interfaces/dito/mq/RocketmqUtil.java +++ b/src/weaver/interfaces/dito/mq/RocketmqUtil.java @@ -11,13 +11,17 @@ import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.formmode.setup.ModeRightInfo; import weaver.general.BaseBean; +import weaver.general.LabelUtil; import weaver.general.TimeUtil; import weaver.general.Util; import weaver.hrm.cachecenter.bean.RolemembersComInfo; import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.hrm.job.JobTitlesComInfo; import weaver.hrm.resource.ResourceComInfo; import weaver.hrm.roles.RolesComInfo; import weaver.interfaces.dito.comInfo.PropBean; +import weaver.matrix.MatrixUtil; import weaver.systeminfo.systemright.CheckUserRight; import java.io.IOException; @@ -955,14 +959,14 @@ public class RocketmqUtil { } String userId = ""; String jobtitlesId = ""; - String departmentId = ""; + String departmentId = "-1"; try { if(StringUtils.isNotEmpty(orgCode)){ String querDepartmentIdSql = " select id from hrmdepartment where departmentcode=? "; bb.writeLog("querDepartmentIdSql:"+querDepartmentIdSql); rs.executeQuery(querDepartmentIdSql,new Object[]{orgCode}); if (rs.next()){ - departmentId = rs.getString("id"); + departmentId = Util.null2String(rs.getString("id"),"null"); } } if(StringUtils.isNotEmpty(departmentId) && StringUtils.isNotEmpty(systemUserCode)) @@ -989,10 +993,27 @@ public class RocketmqUtil { if("A".equals(actType) || "M".equals(actType)) { if(StringUtils.isNotEmpty(postName)) { - postName = postName.toLowerCase().replaceAll("\\s+", ""); + postName = postName.toLowerCase().replaceAll("\\s+", "").replaceAll("_", ""); if(stringSet.contains(postName)){ String sql = "update matrixtable_2 set "+postName+"=? where id=?"; - rs.executeUpdate(sql,new Object[]{userId,departmentId}); + boolean bool = rs.executeUpdate(sql,new Object[]{userId,departmentId}); + if(bool){ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","更新人员岗位同步到部门矩阵执行成功"); + dataMapp.put("staffcode",systemUserCode); + recordErrorData(dataMapp); + }else{ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","更新人员岗位同步到部门矩阵执行错误"); + dataMapp.put("staffcode",systemUserCode); + recordErrorData(dataMapp); + } } } //当岗位为主岗位时才更新,1:主岗位 @@ -1025,7 +1046,24 @@ public class RocketmqUtil { postName = postName.toLowerCase().replaceAll("\\s+", ""); if(stringSet.contains(postName)){ String sql = "update matrixtable_2 set "+postName+"=null where id=?"; - rs.executeUpdate(sql,new Object[]{departmentId}); + boolean bool = rs.executeUpdate(sql,new Object[]{departmentId}); + if(bool){ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","删除人员岗位同步到部门矩阵执行成功"); + dataMapp.put("staffcode",systemUserCode); + recordErrorData(dataMapp); + }else{ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","删除人员岗位同步到部门矩阵执行错误"); + dataMapp.put("staffcode",systemUserCode); + recordErrorData(dataMapp); + } } } jobtitlesId = null; @@ -1061,6 +1099,14 @@ public class RocketmqUtil { dataMap.put("systable",tableName); dataMap.put("staffcode",systemUserCode); recordErrorData(dataMap); + + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","人员岗位中岗位或者人员ID在系统中不存在同步到部门矩阵执行错误"); + dataMapp.put("staffcode",systemUserCode); + recordErrorData(dataMapp); } }catch (Exception e){ Map dataMap = new HashMap(); @@ -1339,12 +1385,12 @@ public class RocketmqUtil { String jobtitlename = sysPostName; try { - String departmentId = ""; + String departmentId = "-1"; if(StringUtils.isNotEmpty(orgCode)){ String querDepartmentIdSql = "select id from hrmdepartment where departmentcode=?"; rs.executeQuery(querDepartmentIdSql, new Object[]{orgCode}); if (rs.next()) { - departmentId = rs.getString("id"); + departmentId = String.valueOf(Util.getIntValue(rs.getString("id"),-1)); } } @@ -1379,6 +1425,11 @@ public class RocketmqUtil { if (StringUtils.isNotEmpty(jobtitleid)) { if ("M".equals(actType)) { //修改 + + rs.executeQuery("select * from hrmjobtitles where id=?",jobtitleid); + rs.next(); + String oldjobtitlename = Util.null2String(rs.getString("jobtitlename")); + String updateHrmjobactivitiesSql = "update hrmjobtitles set jobtitlemark=?,jobtitlename=?,modified=?,modifier=? where id=?"; Object[] objects = new Object[]{jobtitlemark, jobtitlename, modified, modifier, jobtitleid} ; @@ -1391,8 +1442,36 @@ public class RocketmqUtil { dataMap.put("systable",tableName); if (!flag) { dataMap.put("errmessage","系统岗位更新SQL执行错误"); + + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","修改岗位同步到部门自定义字段以及部门矩阵执行错误"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); }else { dataMap.put("errmessage","系统岗位更新SQL执行成功"); + + //岗位修改同步到部门自定义字段以及部门矩阵 + boolean bool = updateDeptMatrix(oldjobtitlename,jobtitlename); + if(bool){ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","修改岗位同步到部门自定义字段以及部门矩阵执行成功"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); + }else{ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","修改岗位同步到部门自定义字段以及部门矩阵执行错误"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); + } } dataMap.put("zxyj",updateHrmjobactivitiesSql); @@ -1414,8 +1493,36 @@ public class RocketmqUtil { dataMap.put("systable",tableName); if (!flag) { dataMap.put("errmessage","系统岗位封存SQL执行错误"); + + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","删除岗位同步到部门自定义字段以及部门矩阵执行错误"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); }else { dataMap.put("errmessage","系统岗位封存SQL执行成功"); + + //岗位删除同步到部门自定义字段以及部门矩阵 + boolean bool = deleteDeptMatrix(jobtitlename); + if(bool){ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","删除岗位同步到部门自定义字段以及部门矩阵执行成功"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); + }else{ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","删除岗位同步到部门自定义字段以及部门矩阵执行错误"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); + } } dataMap.put("zxyj",updateHrmjobactivitiesSql); @@ -1423,6 +1530,7 @@ public class RocketmqUtil { dataMap.put("staffcode",sysPostCode); recordErrorData(dataMap); + }else{ Map dataMap = new HashMap(); dataMap.put("syndate",nowDateTime); @@ -1431,6 +1539,14 @@ public class RocketmqUtil { dataMap.put("systable",tableName); dataMap.put("staffcode",sysPostCode); recordErrorData(dataMap); + + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","系统岗位不存在无法修改或者删除部门矩阵"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); } }else{ if ("A".equals(actType)) { //新增 @@ -1447,8 +1563,37 @@ public class RocketmqUtil { dataMap.put("systable",tableName); if (!flag) { dataMap.put("errmessage","系统岗位新增SQL执行错误"); + + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","新增岗位同步到部门自定义字段以及部门矩阵执行错误"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); }else { dataMap.put("errmessage","系统岗位新增SQL执行成功"); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + jobTitlesComInfo.addCache(jobtitleid); + //岗位新增同步到部门自定义字段以及部门矩阵 + boolean bool = insertDeptMatrix(jobtitlename); + if(bool){ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","新增岗位同步到部门自定义字段以及部门矩阵执行成功"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); + }else{ + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","新增岗位同步到部门自定义字段以及部门矩阵执行错误"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); + } } dataMap.put("staffcode",sysPostCode); @@ -1456,6 +1601,7 @@ public class RocketmqUtil { dataMap.put("zxcs",convertObject2String(objects)); recordErrorData(dataMap); + }else{ Map dataMap = new HashMap(); dataMap.put("syndate",nowDateTime); @@ -1464,6 +1610,14 @@ public class RocketmqUtil { dataMap.put("systable",tableName); dataMap.put("staffcode",sysPostCode); recordErrorData(dataMap); + + Map dataMapp = new HashMap(); + dataMapp.put("syndate",nowDateTime); + dataMapp.put("reqmessage",jsonObject.toJSONString()); + dataMapp.put("systable",tableName); + dataMapp.put("errmessage","系统岗位不存在无法修改或者删除部门矩阵"); + dataMapp.put("staffcode",sysPostCode); + recordErrorData(dataMapp); } } }catch (Exception e) { @@ -2253,4 +2407,146 @@ public class RocketmqUtil { return set; } + /** + * 修改岗位同步到部门自定义字段以及部门矩阵 + * @param oldjobtitlename + * @param newjobtitlename + * @return + */ + public static boolean updateDeptMatrix(String oldjobtitlename,String newjobtitlename){ + boolean bool = false; + RecordSet rs = new RecordSet(); + try { + rs.executeUpdate("update htmllabelinfo set labelname='"+ newjobtitlename +"' where labelname='"+ oldjobtitlename +"'"); + + oldjobtitlename = oldjobtitlename.toLowerCase().replaceAll("\\s+", "").replaceAll("_", ""); + newjobtitlename = newjobtitlename.toLowerCase().replaceAll("\\s+", "").replaceAll("_", ""); + + rs.executeQuery("select * from hrm_formfield where fieldname=?",oldjobtitlename); + rs.next(); + String fieldid = Util.null2String(rs.getString("fieldid")); + + if(!oldjobtitlename.equals(newjobtitlename)){ + + rs.writeLog("============ RocketmqUtil deleteDeptMatrix oldjobtitlename 111 ====================== " + oldjobtitlename); + rs.writeLog("============ RocketmqUtil deleteDeptMatrix oldjobtitlename 222 ====================== " + newjobtitlename); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + + rs.executeUpdate("UPDATE hrm_formfield SET fieldname=? where fieldid=?",newjobtitlename,fieldid); + + rs.execute("ALTER TABLE hrmdepartmentdefined CHANGE "+ oldjobtitlename + " "+ newjobtitlename +" TEXT"); + + HrmFieldComInfo.removeFieldCache(); + //同步部门数据到矩阵 + MatrixUtil.sysDepartmentData(); + + bool = true; + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + bool = false; + } + return bool; + } + + /** + * 删除岗位同步到部门自定义字段以及部门矩阵 + * @param jobtitlename + * @return + */ + public static boolean deleteDeptMatrix(String jobtitlename){ + boolean bool = false; + RecordSet rs = new RecordSet(); + try { + jobtitlename = jobtitlename.toLowerCase().replaceAll("\\s+", "").replaceAll("_", ""); + + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + rs.writeLog("============ RocketmqUtil deleteDeptMatrix jobtitlename 111 ====================== " + jobtitlename); + + String htmlLabelInfoSql = "delete from htmllabelinfo where labelname=?"; + rs.executeUpdate(htmlLabelInfoSql, new Object[]{jobtitlename}); + + String hrmFormFieldSql = "delete from hrm_formfield where fieldname=?"; + rs.executeUpdate(hrmFormFieldSql, new Object[]{jobtitlename}); + + rs.execute("UPDATE hrmdepartmentdefined set "+ jobtitlename +"=null"); + rs.execute("ALTER TABLE hrmdepartmentdefined DROP COLUMN " + jobtitlename + " "); + + HrmFieldComInfo.removeFieldCache(); + //同步部门数据到矩阵 + MatrixUtil.sysDepartmentData(); + + bool = true; + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + bool = false; + } + return bool; + } + + /** + * 新增岗位同步到部门自定义字段以及部门矩阵 + * @param jobtitlename + * @return + */ + public static boolean insertDeptMatrix(String jobtitlename){ + boolean bool = false; + RecordSet rs = new RecordSet(); + try { + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + rs.writeLog("============ RocketmqUtil InsertDeptMatrix jobtitlename 111 ====================== " + jobtitlename); + + int lableid = new LabelUtil().getLabelId(jobtitlename); + + int hrmfieldid = getMaxFieldId(); + rs.writeLog("============ RocketmqUtil InsertDeptMatrix hrmfieldid ====================== " + hrmfieldid); + + int hrmfieldorder = getMaxOrder(); + rs.writeLog("============ RocketmqUtil InsertDeptMatrix hrmfieldorder ====================== " + hrmfieldorder); + + jobtitlename = jobtitlename.toLowerCase().replaceAll("\\s+", "").replaceAll("_", ""); + rs.writeLog("============ RocketmqUtil InsertDeptMatrix jobtitlename 222 ====================== " + jobtitlename); + + String hrmFormFieldSql = "insert into hrm_formfield(fieldid,fielddbtype,fieldname,fieldlabel,fieldhtmltype,type,fieldorder,ismand,isuse,groupid,allowhide) " + + "values(?,?,?,?,?,?,?,?,?,?,?)"; + rs.executeUpdate(hrmFormFieldSql, new Object[]{hrmfieldid, "text", jobtitlename, "" + lableid, "3", "17", hrmfieldorder, "0", "1", "7", "1"}); + + rs.execute("ALTER TABLE hrmdepartmentdefined ADD COLUMN " + jobtitlename + " TEXT "); + + HrmFieldComInfo.removeFieldCache(); + //同步部门数据到矩阵 + MatrixUtil.sysDepartmentData(); + + bool = true; + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + bool = false; + } + return bool; + } + + public static int getMaxFieldId(){ + RecordSet rs = new RecordSet(); + rs.executeQuery("select max(fieldid)as ordee from hrm_formfield"); + rs.next(); + return rs.getInt("ordee") + 1; + } + + public static int getMaxOrder(){ + RecordSet rs = new RecordSet(); + rs.executeQuery("select max(fieldorder)as ordee from hrm_formfield"); + rs.next(); + return rs.getInt("ordee") + 1; + } + + public static int getMinLabelIndexId(){ + RecordSet rs = new RecordSet(); + rs.executeQuery("select min(indexid)as ordee from htmllabelinfo"); + rs.next(); + return rs.getInt("ordee") - 1; + } + }