Browse Source

Merge branch 'master' of ssh://10.10.100.21/source/uas-office-integration

RaoMeng 6 years ago
parent
commit
177d11d889

+ 116 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/entity/JProcandOrProcess.java

@@ -0,0 +1,116 @@
+package com.usoftchina.uas.office.qywx.entity;
+
+/**
+ * @author wuyx
+ * @date 2020/3/11
+ */
+public class JProcandOrProcess {
+    private Integer jp_id;
+    private String jp_name;
+    private String jp_launcherid;
+    private String jp_launchername;
+    private String jp_nodedealman;
+    private String jp_caller;
+    private String jp_table;
+    private Integer jp_keyvalue;
+    private String jp_url;
+    private String jp_codevalue;
+    private String jp_nodeid;
+    private String jptype;
+
+    public Integer getJp_id() {
+        return jp_id;
+    }
+
+    public void setJp_id(Integer jp_id) {
+        this.jp_id = jp_id;
+    }
+
+    public String getJp_name() {
+        return jp_name;
+    }
+
+    public void setJp_name(String jp_name) {
+        this.jp_name = jp_name;
+    }
+
+    public String getJp_nodedealman() {
+        return jp_nodedealman;
+    }
+
+    public void setJp_nodedealman(String jp_nodedealman) {
+        this.jp_nodedealman = jp_nodedealman;
+    }
+
+    public String getJp_launcherid() {
+        return jp_launcherid;
+    }
+
+    public void setJp_launcherid(String jp_launcherid) {
+        this.jp_launcherid = jp_launcherid;
+    }
+
+    public String getJp_launchername() {
+        return jp_launchername;
+    }
+
+    public void setJp_launchername(String jp_launchername) {
+        this.jp_launchername = jp_launchername;
+    }
+
+    public String getJp_caller() {
+        return jp_caller;
+    }
+
+    public void setJp_caller(String jp_caller) {
+        this.jp_caller = jp_caller;
+    }
+
+    public String getJp_table() {
+        return jp_table;
+    }
+
+    public void setJp_table(String jp_table) {
+        this.jp_table = jp_table;
+    }
+
+    public Integer getJp_keyvalue() {
+        return jp_keyvalue;
+    }
+
+    public void setJp_keyvalue(Integer jp_keyvalue) {
+        this.jp_keyvalue = jp_keyvalue;
+    }
+
+    public String getJp_url() {
+        return jp_url;
+    }
+
+    public void setJp_url(String jp_url) {
+        this.jp_url = jp_url;
+    }
+
+    public String getJp_codevalue() {
+        return jp_codevalue;
+    }
+
+    public void setJp_codevalue(String jp_codevalue) {
+        this.jp_codevalue = jp_codevalue;
+    }
+
+    public String getJp_nodeid() {
+        return jp_nodeid;
+    }
+
+    public void setJp_nodeid(String jp_nodeid) {
+        this.jp_nodeid = jp_nodeid;
+    }
+
+    public String getJptype() {
+        return jptype;
+    }
+
+    public void setJptype(String jptype) {
+        this.jptype = jptype;
+    }
+}

+ 8 - 8
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/listener/UasProcessListener.java

@@ -9,6 +9,7 @@ import com.usoftchina.uas.office.entity.DataCenter;
 import com.usoftchina.uas.office.jdbc.DataSourceHolder;
 import com.usoftchina.uas.office.listener.UasEventListener;
 import com.usoftchina.uas.office.qywx.entity.Employee;
+import com.usoftchina.uas.office.qywx.entity.JProcandOrProcess;
 import com.usoftchina.uas.office.qywx.entity.JProcess;
 import com.usoftchina.uas.office.qywx.manage.entity.QywxAgent;
 import com.usoftchina.uas.office.qywx.manage.service.QywxAgentService;
@@ -108,19 +109,19 @@ public class UasProcessListener {
             logger.error("send process message error", e);
         }
     }
-    private void sendProcessMessage(UasEvent event, Integer jpId,String msg) {
-        JProcess process = Try.call(() -> jProcessService.getById(jpId), 10);
+    private void sendProcessMessage(UasEvent event, Integer nodeId,String msg) {
+        JProcandOrProcess process = Try.call(() -> jProcessService.getJProcandOrProcessById(nodeId), 10);
         if (null == process) {
-            logger.warn("can not find process {}, {}", jpId, event);
+            logger.warn("can not find process {}, {}", nodeId, event);
             return;
         }
-        Employee employee = getDealMan(process);
-        if (null == employee) {
+        String[] emList = jProcessService.getDealManById(nodeId);
+        if (null == emList) {
             return;
         }
         DataCenter dataCenter = DataCenter.INSTANCE;
         String title = process.getJp_launchername() + "的" + process.getJp_name()+msg;
-        String description = "单据编号:" + process.getJp_codevalue()+"请您尽快处理";
+        String description = "单据编号:" + process.getJp_codevalue()+"请您尽快";
         try {
             // 根据UAS配置的外部地址发送 开通U审批用U审批推送 没开通用UAS应用推送
             QywxAgent agent = getUasAgent();
@@ -129,7 +130,7 @@ public class UasProcessListener {
                     dataCenter.getOuterUrl() + "api/authorize", "uas/approval/" + URLEncoder.encode(paramsStr, "utf-8"));
             messageSdk.send((!messageSdk.isAgentEnabled("UasAudit")) ? "Uas":"UasAudit", new SendMessageReq()
                     .textCard(title, description, msgUrl, "查看详情")
-                    .toUser(employee.getEm_qywx()));
+                    .toUser(emList));
         } catch (Exception e) {
             logger.error("send process message error", e);
         }
@@ -146,7 +147,6 @@ public class UasProcessListener {
             DataSourceHolder.set(MasterHolder.get());
         }
     }
-
     public QywxAgent getUasAgent() {
         try {
             DataSourceHolder.set(DataCenter.INSTANCE);

+ 23 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/service/UasJProcessService.java

@@ -1,9 +1,13 @@
 package com.usoftchina.uas.office.qywx.service;
 
+import com.usoftchina.uas.office.qywx.entity.JProcandOrProcess;
 import com.usoftchina.uas.office.qywx.entity.JProcess;
 import com.usoftchina.uas.office.service.AbstractService;
+import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author yingp
  * @date 2020/2/16
@@ -14,4 +18,23 @@ public class UasJProcessService extends AbstractService {
     public JProcess getById(Integer id) {
         return queryForBean("select * from JProcess where jp_id=?", JProcess.class, id);
     }
+    public JProcandOrProcess getJProcandOrProcessById(Integer id) {
+        return queryForBean("SELECT JPTYPE, MAX(JP_ID) JP_ID, JP_NAME, JP_LAUNCHERID, JP_LAUNCHERNAME,  JP_CALLER, JP_TABLE, JP_KEYVALUE, JP_URL, JP_CODEVALUE, JP_NODEID  FROM ( " +
+                "SELECT 'JPROCESS' JPTYPE,JP_ID,JP_NAME,JP_LAUNCHERID,JP_LAUNCHERNAME,JP_CALLER,JP_TABLE,JP_KEYVALUE,JP_URL,JP_CODEVALUE,JP_NODEID FROM JPROCESS " +
+                "UNION ALL " +
+                "SELECT 'JPROCAND' JPTYPE,JP_ID,JP_NAME,JP_LAUNCHERID,JP_LAUNCHERNAME,JP_CALLER,JP_TABLE,JP_KEYVALUE,JP_URL,JP_CODEVALUE,JP_NODEID  FROM JPROCAND WHERE JP_FLAG=1) " +
+                " WHERE JP_NODEID=? GROUP BY JPTYPE, JP_NAME, JP_LAUNCHERID, JP_LAUNCHERNAME,JP_CALLER, JP_TABLE, JP_KEYVALUE, JP_URL, JP_CODEVALUE, JP_NODEID", JProcandOrProcess.class, id);
+    }
+    public String[] getDealManById(Integer id) {
+        try{
+        List<String> emList =  queryForList("SELECT EM_QYWX FROM ( " +
+                "SELECT JP_NODEDEALMAN,JP_NODEID FROM JPROCESS UNION ALL " +
+                "SELECT JP_CANDIDATE JP_NODEDEALMAN,JP_NODEID FROM JPROCAND WHERE JP_FLAG=1 " +
+                ") LEFT JOIN EMPLOYEE ON EM_CODE = JP_NODEDEALMAN " +
+                " where JP_NODEID=? AND EM_CLASS <> '离职' AND EM_QYWX IS NOT NULL GROUP BY EM_QYWX", String.class, id);
+            return emList.toArray(new String[emList.size()]);
+        } catch (EmptyResultDataAccessException e) {
+            return null;
+        }
+    }
 }