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