Browse Source

发送通知

DESKTOP-0GD05B0\Administrator 2 years ago
parent
commit
e1622f8e10

+ 2 - 2
src/main/java/thyyxxk/webserver/constants/Message.java

@@ -14,7 +14,6 @@ public enum Message {
      * 进度条消息
      */
     JDT_MESSAGE("jdtMessage"),
-
     /**
      * 系统消息
      */
@@ -26,7 +25,8 @@ public enum Message {
 
     SCROLLING_MESSAGES("scrollingMessages"),
 
-    UPDATED_ORDER("updatedOrder"),;
+    UPDATED_ORDER("updatedOrder"),
+    AVATAR_NOTIFICATION("avatarNotification");
 
     private final String name;
 

+ 2 - 2
src/main/java/thyyxxk/webserver/controller/casefrontsheet/HuiZhenShenQingController.java → src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/HuiZhenShenQingController.java

@@ -1,4 +1,4 @@
-package thyyxxk.webserver.controller.casefrontsheet;
+package thyyxxk.webserver.controller.zhuyuanyizheng;
 
 import com.alibaba.fastjson.JSONArray;
 import org.springframework.web.bind.annotation.*;
@@ -7,7 +7,7 @@ import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.login.UserInfo;
-import thyyxxk.webserver.service.casefrontsheet.HuiZhenShenQingService;
+import thyyxxk.webserver.service.zhuyuanyisheng.HuiZhenShenQingService;
 
 import java.math.BigDecimal;
 import java.util.List;

+ 2 - 2
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/YizhuLuRuController.java

@@ -70,9 +70,9 @@ public class YizhuLuRuController {
     }
 
     @GetMapping("/correctSubOrders")
-    public void correctSubOrders(@RequestParam("patNo") String patNo,
+    public ResultVo<String> correctSubOrders(@RequestParam("patNo") String patNo,
                                              @RequestParam("times") Integer times) {
-        server.correctSubOrders(patNo, times);
+        return server.correctSubOrders(patNo, times);
     }
 
 

+ 2 - 1
src/main/java/thyyxxk/webserver/dao/his/PublicDao.java

@@ -244,7 +244,8 @@ public interface PublicDao {
     @Select("select code " +
             "from a_employee_mi " +
             "where dept_code = #{wardCode} " +
-            "  and isnull(del_flag, 0) <> 1 " + " and emp_tit_code in ('010') ")
+            "  and isnull(del_flag, 0) <> 1 " +
+            "  and emp_tit_code = '010' ")
     List<String> huoQuHuanZheBingFangDeHuShi(String wardCode);
 
 

+ 1 - 1
src/main/java/thyyxxk/webserver/dao/his/casefrontsheet/HuiZhenShenQingDao.java → src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/HuiZhenShenQingDao.java

@@ -1,4 +1,4 @@
-package thyyxxk.webserver.dao.his.casefrontsheet;
+package thyyxxk.webserver.dao.his.zhuyuanyisheng;
 
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.*;

+ 34 - 17
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -1,6 +1,5 @@
 package thyyxxk.webserver.service;
 
-import cn.xfyun.exception.BusinessException;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
@@ -606,12 +605,29 @@ public class PublicServer {
         sendDoctorNotification(huanZheXinXi, Collections.singletonList(content), title, sender, userCodeList);
     }
 
+
+    /**
+     * @param huanZheXinXi 患者信息
+     * @param content      内容
+     * @param title        标题
+     * @param userCode     发送人id
+     */
+    @Async
+    public void faSongXiaoXi(XinZhenYiZhu huanZheXinXi, List<String> content, String title, String userCode) {
+        List<String> huShiBianMa = dao.huoQuHuanZheBingFangDeHuShi(huanZheXinXi.getDeptCode());
+        sendDoctorNotification(huanZheXinXi, content, title, userCode, huShiBianMa);
+    }
+
+    /**
+     * @param huanZheXinXi 患者信息
+     * @param content      内容
+     * @param title        标题
+     * @param sender       发送人  TokenUtil.getTokenUserId() 不能使用这个因为用的 异步的方法 会导致 okenUtil.getTokenUserId() 为 99999
+     * @param userCodeList 接收方
+     */
     @Async
     public void sendDoctorNotification(XinZhenYiZhu huanZheXinXi, List<String> content, String title, String sender, List<String> userCodeList) {
-        JSONObject obj = new JSONObject();
-        obj.put("message", title);
-        // 消息数量
-        obj.put("count", content.size());
+        int count = content.size();
         // 发送通知类
         List<SocketMessage> socketMessage1 = new ArrayList<>();
         List<SocketMessage> socketMessage2 = new ArrayList<>();
@@ -640,21 +656,22 @@ public class PublicServer {
         for (List<SocketMessage> item : fenGeJieShouFang) {
             dao.chaRuJieShouShuJu(item);
         }
-        userCodeList.forEach(code -> WebSocketServer.sendMessageByUserCode(code, SocketMsg.socketVo(Message.SYSTEM_NOTIFICATION, obj)));
-    }
+        JSONObject json = new JSONObject();
+        UserInfo userInfo = redisLikeService.getUserInfoByCode(sender);
+        json.put("avatar", userInfo.getAvatar());
+        json.put("deptName", userInfo.getDeptName());
+        json.put("name", userInfo.getName());
+        json.put("msg", title + "患者:【" + huanZheXinXi.getName() + "】" + "新增数据:" + count + "条");
+        json.put("title", title);
+        json.put("count", count);
+
+        userCodeList.forEach(code -> {
+            WebSocketServer.sendMessageByUserCode(code, SocketMsg.socketVo(Message.AVATAR_NOTIFICATION, json));
+        });
 
-    /**
-     * @param huanZheXinXi 患者信息
-     * @param content      内容
-     * @param title        标题
-     * @param userCode     发送人id
-     */
-    @Async
-    public void faSongXiaoXi(XinZhenYiZhu huanZheXinXi, List<String> content, String title, String userCode) {
-        List<String> huShiBianMa = dao.huoQuHuanZheBingFangDeHuShi(huanZheXinXi.getDeptCode());
-        sendDoctorNotification(huanZheXinXi, content, title, userCode, huShiBianMa);
     }
 
+
     public ResultVo<String> makePyCode(String tableName, String idColumn, String nameColumn, String pyColumn) {
         List<CodeName> list = dao.originalList(tableName, idColumn, nameColumn, pyColumn);
         if (null == list || list.isEmpty()) {

+ 1 - 3
src/main/java/thyyxxk/webserver/service/casefrontsheet/JieShouHuiZhenService.java

@@ -1,10 +1,8 @@
 package thyyxxk.webserver.service.casefrontsheet;
 
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -16,9 +14,9 @@ import thyyxxk.webserver.entity.casefrontsheet.JieShouHuiZhenPojo;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.service.zhuyuanyisheng.HuiZhenShenQingService;
 import thyyxxk.webserver.utils.*;
 
-import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.List;
 

+ 2 - 2
src/main/java/thyyxxk/webserver/service/casefrontsheet/HuiZhenShenQingService.java → src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/HuiZhenShenQingService.java

@@ -1,4 +1,4 @@
-package thyyxxk.webserver.service.casefrontsheet;
+package thyyxxk.webserver.service.zhuyuanyisheng;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSON;
@@ -8,7 +8,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
-import thyyxxk.webserver.dao.his.casefrontsheet.HuiZhenShenQingDao;
+import thyyxxk.webserver.dao.his.zhuyuanyisheng.HuiZhenShenQingDao;
 import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord;

+ 24 - 26
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -223,7 +223,7 @@ public class YiZhuLuRuServer {
         return ResultVoUtil.success(dao.getParentOrders(patNo, times));
     }
 
-    public void correctSubOrders(String patNo, Integer times) {
+    public ResultVo<String> correctSubOrders(String patNo, Integer times) {
         QueryWrapper<?> qw = new QueryWrapper<>();
         qw.eq("a.inpatient_no", patNo)
                 .eq("a.admiss_times", times)
@@ -231,7 +231,7 @@ public class YiZhuLuRuServer {
                 .eq("a.enter_oper", TokenUtil.getTokenUserId());
         List<XinZhenYzActOrder> list = dao.huoQuYiZhuShuJu(qw);
         if (ListUtil.isBlank(list)) {
-            return;
+            return ResultVoUtil.success();
         }
         // 父医嘱
         Map<BigDecimal, XinZhenYzActOrder> parentOrder = new HashMap<>(list.size());
@@ -245,6 +245,7 @@ public class YiZhuLuRuServer {
                 }
             }
         });
+        return ResultVoUtil.success();
     }
 
     private boolean updateSubOrders(XinZhenYzActOrder parent, XinZhenYzActOrder children) {
@@ -361,15 +362,13 @@ public class YiZhuLuRuServer {
             if (count > 0) {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "有未确认和未执行的长期医嘱,无法确认全排斥医嘱,请先确认其他医嘱。");
             }
-
-
             dao.stopOrder(param.getInpatientNo(), param.getAdmissTimes(), excludeOrders, userCode, orderNo);
         }
         for (BigDecimal decimal : confirmOrderInformation) {
             dao.confirmOrders(decimal, userCode, new Date());
         }
         getThis().drgOrderUpdate(patInfo.getInpatientNo() + "_" + patInfo.getAdmissTimes());
-        log.info("确认的医嘱:{}", JSON.toJSONString(yiZhuList));
+        sendAMessageToTheNurse(param, userCode, patInfo, "新增医嘱");
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
     }
 
@@ -413,6 +412,23 @@ public class YiZhuLuRuServer {
         }
     }
 
+    private void sendAMessageToTheNurse(XinZhenYiZhu param, String inputCode, XinZhenYiZhu patInfo, String name) {
+        List<String> content = new ArrayList<>();
+        for (XinZhenYzActOrder item : param.getList()) {
+            String sb = notificationStyle("医嘱名", "409eff", item.getOrderName()) +
+                    notificationStyle("医嘱时间", "409eff", DateUtil.formatDatetime(item.getStartTime())) +
+                    notificationStyle("床位", "409eff", patInfo.getBedNo()) +
+                    notificationStyle("患者姓名", "409eff", patInfo.getName()) +
+                    notificationStyle("频次", "409eff", item.getFrequCode());
+            content.add(sb);
+        }
+        publicServer.faSongXiaoXi(patInfo, content, name, inputCode);
+    }
+
+    private String notificationStyle(String name, String color, String content) {
+        return String.format("%s:<span style='color: #%s'>%s</span><br>", name, color, content);
+    }
+
     /**
      * 录入单条医嘱  新的 下面的保存医嘱的都无效了
      *
@@ -1174,25 +1190,6 @@ public class YiZhuLuRuServer {
     }
 
 
-    private void sendAMessageToTheNurse(XinZhenYiZhu param, String inputCode, XinZhenYiZhu huanZheXinXi, String groupNo) {
-        List<String> content = new ArrayList<>();
-        for (XinZhenYzActOrder item : param.getList()) {
-            if (StringUtil.isBlank(item.getDrugFlag())) {
-                item.setDrugFlag("o");
-            }
-            if ("00".equals(item.getSerial().trim())) {
-                item.setGroupNo("00");
-            } else if ("01".equals(item.getSerial().trim()) || "99".equals(item.getSerial().trim())) {
-                item.setGroupNo(groupNo);
-            }
-            if (item.getEndTime() != null) {
-                item.setModifier(inputCode);
-            }
-            content.add(String.format("医嘱名:<span style='color:#409eff'>【%s】</span><br>" + "医嘱时间:<span style='color:#409eff'>【%tF %<tT】</span><br>" + "患者姓名:<span style='color:#409eff'>【%s】</span><br>" + "床位:<span style='color:#409eff'>【%s】</span><br>" + "频次:<span style='color:#409eff'>【%s】</span>", item.getOrderName(), item.getOrderTime(), huanZheXinXi.getName(), huanZheXinXi.getBedNo(), item.getFrequCode()));
-        }
-        publicServer.faSongXiaoXi(huanZheXinXi, content, "新增医嘱", inputCode);
-    }
-
     /**
      * 获取医嘱录入的模板1
      *
@@ -1541,8 +1538,8 @@ public class YiZhuLuRuServer {
     /**
      * 确认出院带药医嘱
      *
-     * @param patNo
-     * @param times
+     * @param patNo 住院号
+     * @param times 住院次数
      * @return
      */
     public ResultVo<Map<String, Object>> confirmTheDoctorSOrderWithMedicine(String patNo, Integer times) {
@@ -1612,6 +1609,7 @@ public class YiZhuLuRuServer {
             for (int i = 0; i < takeTheMedicineList.size(); i++) {
                 pageNoList.add(publicServer.getTheDrugListNo());
             }
+            sendAMessageToTheNurse(patInfo, userCode, dao.huoQuHuanZheXinXi(patNo, times), "出院带药");
             return getThis().getMapResultVo(patInfo, userCode, takeTheMedicineList, pageNoList);
         } else {
             return ResultVoUtil.fail(ExceptionEnum.ERROR_MESSAGE, "请修改有错误的医嘱。", check);