yingp 6 سال پیش
والد
کامیت
d4bbc5d734

+ 0 - 9
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/entity/JProcess.java

@@ -16,7 +16,6 @@ public class JProcess {
     private String jp_url;
     private String jp_url;
     private String jp_codevalue;
     private String jp_codevalue;
     private String jp_nodeid;
     private String jp_nodeid;
-    private String em_qywx;
 
 
     public Integer getJp_id() {
     public Integer getJp_id() {
         return jp_id;
         return jp_id;
@@ -105,12 +104,4 @@ public class JProcess {
     public void setJp_nodeid(String jp_nodeid) {
     public void setJp_nodeid(String jp_nodeid) {
         this.jp_nodeid = jp_nodeid;
         this.jp_nodeid = jp_nodeid;
     }
     }
-
-    public String getEm_qywx() {
-        return em_qywx;
-    }
-
-    public void setEm_qywx(String em_qywx) {
-        this.em_qywx = em_qywx;
-    }
 }
 }

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

@@ -3,12 +3,16 @@ package com.usoftchina.uas.office.qywx.listener;
 import com.usoftchina.qywx.sdk.MessageSdk;
 import com.usoftchina.qywx.sdk.MessageSdk;
 import com.usoftchina.qywx.sdk.dto.SendMessageReq;
 import com.usoftchina.qywx.sdk.dto.SendMessageReq;
 import com.usoftchina.qywx.sdk.util.UrlUtils;
 import com.usoftchina.qywx.sdk.util.UrlUtils;
+import com.usoftchina.uas.office.context.MasterHolder;
 import com.usoftchina.uas.office.dto.UasEvent;
 import com.usoftchina.uas.office.dto.UasEvent;
 import com.usoftchina.uas.office.entity.DataCenter;
 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.listener.UasEventListener;
+import com.usoftchina.uas.office.qywx.entity.Employee;
 import com.usoftchina.uas.office.qywx.entity.JProcess;
 import com.usoftchina.uas.office.qywx.entity.JProcess;
 import com.usoftchina.uas.office.qywx.manage.entity.QywxAgent;
 import com.usoftchina.uas.office.qywx.manage.entity.QywxAgent;
 import com.usoftchina.uas.office.qywx.manage.service.QywxAgentService;
 import com.usoftchina.uas.office.qywx.manage.service.QywxAgentService;
+import com.usoftchina.uas.office.qywx.service.UasEmployeeService;
 import com.usoftchina.uas.office.qywx.service.UasJProcessService;
 import com.usoftchina.uas.office.qywx.service.UasJProcessService;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
@@ -36,6 +40,9 @@ public class UasProcessListener {
     @Autowired
     @Autowired
     private QywxAgentService agentService;
     private QywxAgentService agentService;
 
 
+    @Autowired
+    private UasEmployeeService employeeService;
+
     /**
     /**
      * uas保存审批任务,发送消息到企业微信
      * uas保存审批任务,发送消息到企业微信
      *
      *
@@ -58,6 +65,10 @@ public class UasProcessListener {
 
 
     private void sendProcessMessage(UasEvent event, Integer jpId) {
     private void sendProcessMessage(UasEvent event, Integer jpId) {
         JProcess process = jProcessService.getById(jpId);
         JProcess process = jProcessService.getById(jpId);
+        Employee employee = getDealMan(process);
+        if (null == employee) {
+            return;
+        }
         DataCenter dataCenter = DataCenter.INSTANCE;
         DataCenter dataCenter = DataCenter.INSTANCE;
         String title = process.getJp_launchername() + "的" + process.getJp_name();
         String title = process.getJp_launchername() + "的" + process.getJp_name();
         String description = "单据编号:" + process.getJp_codevalue();
         String description = "单据编号:" + process.getJp_codevalue();
@@ -68,9 +79,22 @@ public class UasProcessListener {
                     dataCenter.getOuterUrl() + "/api/authorize", "uas/approval/" + URLEncoder.encode(paramsStr, "utf-8"));
                     dataCenter.getOuterUrl() + "/api/authorize", "uas/approval/" + URLEncoder.encode(paramsStr, "utf-8"));
             messageSdk.send("Uas", new SendMessageReq()
             messageSdk.send("Uas", new SendMessageReq()
                     .textCard(title, description, msgUrl, "查看详情")
                     .textCard(title, description, msgUrl, "查看详情")
-                    .toUser(process.getEm_qywx()));
+                    .toUser(employee.getEm_qywx()));
         } catch (Exception e) {
         } catch (Exception e) {
             logger.error("send process message error", e);
             logger.error("send process message error", e);
         }
         }
     }
     }
+
+    public Employee getDealMan(JProcess process) {
+        try {
+            DataSourceHolder.set(DataCenter.INSTANCE);
+            Employee employee = employeeService.getByCode(process.getJp_nodedealman());
+            if (null == employee || null == employee.getEm_qywx()) {
+                return null;
+            }
+            return employee;
+        } finally {
+            DataSourceHolder.set(MasterHolder.get());
+        }
+    }
 }
 }

+ 4 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/service/UasEmployeeService.java

@@ -54,6 +54,10 @@ public class UasEmployeeService extends AbstractService {
         return queryForBean("select * from employee where em_email=? and em_class<>'离职'", Employee.class, email);
         return queryForBean("select * from employee where em_email=? and em_class<>'离职'", Employee.class, email);
     }
     }
 
 
+    public Employee getByCode(String code) {
+        return queryForBean("select * from employee where em_code=? and em_class<>'离职'", Employee.class, code);
+    }
+
     public void setQywx(Employee employee) {
     public void setQywx(Employee employee) {
         jdbcTemplate.update("update employee set em_qywx=? where em_id=?", employee.getEm_qywx(), employee.getEm_id());
         jdbcTemplate.update("update employee set em_qywx=? where em_id=?", employee.getEm_qywx(), employee.getEm_id());
     }
     }

+ 1 - 2
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/service/UasJProcessService.java

@@ -12,7 +12,6 @@ import org.springframework.stereotype.Service;
 public class UasJProcessService extends AbstractService {
 public class UasJProcessService extends AbstractService {
 
 
     public JProcess getById(Integer id) {
     public JProcess getById(Integer id) {
-        return queryForBean("select JProcess.*,em_qywx from JProcess,employee where jp_nodedealman=em_code and jp_id=? and em_qywx is not null",
-                JProcess.class, id);
+        return queryForBean("select * from JProcess where jp_id=?", JProcess.class, id);
     }
     }
 }
 }