Ver código fonte

优化危急值发布

hurugang 5 anos atrás
pai
commit
2897c83902

+ 16 - 0
src/main/java/cn/hnthyy/thmz/entity/his/ZdDeptAll.java

@@ -0,0 +1,16 @@
+package cn.hnthyy.thmz.entity.his;
+
+import lombok.Data;
+
+/**
+ * 大科室与小科室的关系
+ */
+@Data
+public class ZdDeptAll {
+    //病区  病室
+    private String dept;
+    //小科室
+    private String smallDept;
+    //科室id
+    private String deptId;
+}

+ 17 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/ZdDeptAllMapper.java

@@ -0,0 +1,17 @@
+package cn.hnthyy.thmz.mapper.his;
+
+import cn.hnthyy.thmz.entity.his.ZdDeptAll;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+public interface ZdDeptAllMapper {
+    /**
+     * 根据小科室id查询病区id
+     * @param smallDept
+     * @return
+     */
+    @Select("select rtrim(dept) dept,rtrim(small_dept) small_dept,rtrim(dept_id) dept_id from zd_dept_all where small_dept =#{smallDept}")
+    List<ZdDeptAll>  selectBySmallDept(@Param(value = "smallDept") String smallDept);
+}

+ 13 - 0
src/main/java/cn/hnthyy/thmz/service/his/ZdDeptAllService.java

@@ -0,0 +1,13 @@
+package cn.hnthyy.thmz.service.his;
+
+import cn.hnthyy.thmz.entity.his.ZdDeptAll;
+import java.util.List;
+
+public interface ZdDeptAllService {
+    /**
+     * 根据小科室id查询病区id
+     * @param smallDept
+     * @return
+     */
+    List<ZdDeptAll>  queryBySmallDept(String smallDept);
+}

+ 19 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/ZdDeptAllServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.hnthyy.thmz.service.impl.his;
+
+import cn.hnthyy.thmz.entity.his.ZdDeptAll;
+import cn.hnthyy.thmz.mapper.his.ZdDeptAllMapper;
+import cn.hnthyy.thmz.service.his.ZdDeptAllService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+@Service
+public class ZdDeptAllServiceImpl implements ZdDeptAllService {
+    @SuppressWarnings("all")
+    @Autowired
+    private ZdDeptAllMapper zdDeptAllMapper;
+    @Override
+    public List<ZdDeptAll> queryBySmallDept(String smallDept) {
+        return zdDeptAllMapper.selectBySmallDept(smallDept);
+    }
+}

+ 28 - 12
src/main/java/cn/hnthyy/thmz/webservice/impl/CriticalWebServiceImpl.java

@@ -3,6 +3,8 @@ package cn.hnthyy.thmz.webservice.impl;
 
 import cn.hnthyy.thmz.Utils.SpringBeanUtils;
 import cn.hnthyy.thmz.entity.his.Employee;
+import cn.hnthyy.thmz.entity.his.ZdDeptAll;
+import cn.hnthyy.thmz.mapper.his.ZdDeptAllMapper;
 import cn.hnthyy.thmz.service.his.EmployeeService;
 import cn.hnthyy.thmz.service.his.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.impl.his.EmployeeServiceImpl;
@@ -13,6 +15,7 @@ import cn.hnthyy.thmz.webservice.CriticalWebService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.json.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -25,7 +28,9 @@ public class CriticalWebServiceImpl implements CriticalWebService {
     MessageService messageService = null;
     EmployeeService employeeService = null;
     ZdUnitCodeService zdUnitCodeService = null;
-
+    @SuppressWarnings("all")
+    @Autowired
+    private ZdDeptAllMapper zdDeptAllMapper;
     @Override
     public String criticalAccept(String accessToken, String msg) {
         log.info("收到危急值信息:----->" + msg + "<-------");
@@ -106,6 +111,19 @@ public class CriticalWebServiceImpl implements CriticalWebService {
             }
         }
         List<Employee> employees = employeeService.queryEmployeeByDept(zkWard != null ? zkWard : targetDeptCode.trim());
+        List<ZdDeptAll> zdDeptAlls = zdDeptAllMapper.selectBySmallDept(zkWard != null ? zkWard : targetDeptCode.trim());
+        if(zdDeptAlls!=null && zdDeptAlls.size()>0){
+            for (ZdDeptAll zdDeptAll:zdDeptAlls){
+                if(StringUtils.isBlank(zdDeptAll.getDept())){
+                    continue;
+                }
+                List<Employee> tempList = employeeService.queryEmployeeByDept(zdDeptAll.getDept());
+                if(tempList==null || tempList.size()<=0){
+                    continue;
+                }
+                employees.addAll(tempList);
+            }
+        }
         String codes = null;
         Set<String> tempSet = new HashSet<>();
         if (StringUtils.isNotBlank(referPhysician)) {
@@ -120,21 +138,19 @@ public class CriticalWebServiceImpl implements CriticalWebService {
         if (tempSet.size() > 0) {
             List<Employee> tempsEmps = employeeService.queryByCodes(new ArrayList<>(tempSet));
             if (tempsEmps != null && tempsEmps.size() > 0) {
-                for (Employee emp : tempsEmps) {
-                    if (codes == null) {
-                        codes = emp.getCodeRs();
-                    } else {
-                        codes += "," + emp.getCodeRs();
-                    }
-                }
+                employees.addAll(tempsEmps);
             }
         }
         if (employees != null) {
+            Set<String> fullCodes = new HashSet<>();
             for (Employee employee : employees) {
-                if (codes == null) {
-                    codes = employee.getCodeRs();
-                } else {
-                    codes += "," + employee.getCodeRs();
+                if(!fullCodes.contains(employee.getCodeRs())){
+                    if (codes == null) {
+                        codes = employee.getCodeRs();
+                    } else {
+                        codes += "," + employee.getCodeRs();
+                    }
+                    fullCodes.add(employee.getCodeRs());
                 }
             }
         }