Browse Source

有VIP挂号时发送企业微信通知给体检中心员工

lighter 1 year ago
parent
commit
493e168f7c

+ 3 - 22
src/main/java/thyyxxk/webserver/dao/his/outpatient/triage/TriageDao.java

@@ -165,19 +165,6 @@ public interface TriageDao {
     IPage<MzfzPatientOrder> getAllPatients(IPage<MzfzPatientOrder> iPage, @Param("deptCodes") String[] deptCodes,
                                            @Param("content") String content);
 
-    // 获取病人分诊信息(用于通知)
-    @Select("select " +
-            "rtrim(a.gh_no) gh_no, " +
-            "rtrim(a.name) name, " +
-            "rtrim(a.fz_no) fz_no, " +
-            "rtrim(a.room_code) room_code, " +
-            "serial_no=#{serialNo}, " +
-            "dept_name=(select rtrim(name) from zd_unit_code where code=b.dept_code), " +
-            "rtrim(b.room_no) room_no " +
-            "from mzfz_patient_order a, mzfz_zd_dept_room b where serial_no=#{serialNo} " +
-            "and a.room_code = b.room_code")
-    MzfzPatientOrder getPatientTriageInfo(@Param("serialNo") Integer serialNo);
-
     @Select("select * from mz_ysh_tzxx where patient_id=#{patientId} and datediff(day, visit_date, getdate())=0")
     MzYshTzxx getMzVitalSigns(@Param("patientId") String patientId);
 
@@ -192,9 +179,6 @@ public interface TriageDao {
             "#{valueHx},#{valueSsy},#{valueSzy},#{visitRemark})")
     void insertMzVitalSigns(MzYshTzxx param);
 
-    @Update("update mzfz_patient_order set status_flag=3 where serial_no=#{serial}")
-    void updateStatus(@Param("serial") int serial);
-
     @Select("select dept_code,rtrim(room_code) as room_code,serial_no,rtrim(name) as name,fz_no, " +
             "deptName=(select rtrim(name) from zd_unit_code where code=dept_code), " +
             "roomNo=(select room_no from mzfz_zd_dept_room where " +
@@ -202,12 +186,6 @@ public interface TriageDao {
             "from mzfz_patient_order where serial_no=#{serialNo}")
     MessageForPush selectMessageForPush(@Param("serialNo") int serialNo);
 
-    @Select("select a.serial_no as serialNo, socket_sid as socketSid, a.room_code as roomCode from " +
-            "t_triage_notify_relation a, mzfz_patient_order b " +
-            "where datediff(day,a.create_datetime,getdate())=0 and a.notify_datetime is null " +
-            "and isnull(b.status_flag,0)>1 and a.serial_no=b.serial_no")
-    List<TriageNotifyRelation> selectUnNotifiedList();
-
     @Update("update t_triage_notify_relation set notify_datetime=getdate() where serial_no=#{serialNo}")
     void updateNotifyDatetime(@Param("serialNo") int serialNo);
 
@@ -226,4 +204,7 @@ public interface TriageDao {
     @Select("select code from t_triage_user_depts where isnull(del_flag,0)=0 " +
             "and chosen_dept like '%\"1060000\"%'")
     List<String> selectVipTriageUser();
+
+    @Select("select rtrim(code_rs) from a_employee_mi where dept_code='2080000' and isnull(del_flag,'0')!='1'")
+    List<String> selectCodeRsList();
 }

+ 19 - 12
src/main/java/thyyxxk/webserver/service/outpatient/triage/TriageService.java

@@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.client.RestTemplate;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.Capacity;
 import thyyxxk.webserver.dao.his.outpatient.triage.TriageDao;
@@ -17,6 +16,7 @@ import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.outpatient.triage.*;
 import thyyxxk.webserver.entity.socketmessage.ApiMessageBody;
 import thyyxxk.webserver.service.externalhttp.WebSocketService;
+import thyyxxk.webserver.service.outpatient.wxapi.SendWxInfoService;
 import thyyxxk.webserver.utils.DateUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.StringUtil;
@@ -34,10 +34,12 @@ public class TriageService {
     @Value("${triage-notify-url}")
     private String triageNotifyUrl;
     private final WebSocketService socketService;
+    private final SendWxInfoService sendWxInfoService;
 
-    public TriageService(TriageDao dao, WebSocketService socketService) {
+    public TriageService(TriageDao dao, WebSocketService socketService, SendWxInfoService sendWxInfoService) {
         this.dao = dao;
         this.socketService = socketService;
+        this.sendWxInfoService = sendWxInfoService;
     }
 
     public ResultVo<Map<String, Object>> getUnTriagedPatients(Integer currentPage, Integer pageSize) {
@@ -242,8 +244,7 @@ public class TriageService {
 
     private ResultVo<String> notifyVipReq(int serialNo) {
         MessageForPush vipRegMessage = dao.selectVipRegMessage(serialNo);
-        String message = String.format("患者<span style=\"color:red;font-weight:bold\">%s</span>" +
-                        "预约了国际医疗部,预约就诊时间为<span style=\"font-weight:bold;color: red\">%s</span>",
+        String message = String.format("患者【%s】预约了国际医疗部,预约就诊时间为【%s】",
                 vipRegMessage.getName(), DateUtil.formatDatetime(vipRegMessage.getVisitDate()));
         JSONObject messageWrapper = new JSONObject();
         messageWrapper.put("name", "systemNotification");
@@ -251,16 +252,22 @@ public class TriageService {
         messageBody.put("title", "提醒");
         messageBody.put("message", message);
         messageWrapper.put("message", messageBody);
-
         List<String> vipTriageUsers = dao.selectVipTriageUser();
-        if (vipTriageUsers.isEmpty()) {
-            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有国际医疗部的分诊人员。");
+        if (!vipTriageUsers.isEmpty()) {
+            ApiMessageBody body = new ApiMessageBody(messageWrapper.toJSONString());
+            for (String userCode : vipTriageUsers) {
+                body.setUserCode(userCode);
+                socketService.sendMessageByUserCode(body);
+            }
         }
-
-        ApiMessageBody body = new ApiMessageBody(messageWrapper.toJSONString());
-        for (String userCode : vipTriageUsers) {
-            body.setUserCode(userCode);
-            socketService.sendMessageByUserCode(body);
+        List<String> codeRsList = dao.selectCodeRsList();
+        if (!codeRsList.isEmpty()) {
+            StringBuilder sb = new StringBuilder();
+            for (String codeRs : codeRsList) {
+                sb.append("|").append(codeRs);
+            }
+            String touser = sb.substring(1);
+            sendWxInfoService.sendCorpWxMsg(touser, message);
         }
         return ResultVoUtil.success();
     }