| 
					
				 | 
			
			
				@@ -1,15 +1,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package cn.hnthyy.thmz.webservice.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hnthyy.thmz.Utils.HttpUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cn.hnthyy.thmz.entity.his.mz.Employee; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cn.hnthyy.thmz.entity.his.zd.ZdDeptAll; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cn.hnthyy.thmz.entity.thmz.CriticalValue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hnthyy.thmz.mapper.his.zd.ZdDeptAllMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cn.hnthyy.thmz.service.his.mz.EmployeeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cn.hnthyy.thmz.service.thmz.CriticalValueService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cn.hnthyy.thmz.service.thmz.MessageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hnthyy.thmz.webservice.CriticalWebService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -26,14 +18,6 @@ import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class CriticalWebServiceImpl implements CriticalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private String token = "oI9#ur02cbBHdop87e6Y728Ax30IIlgd"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private MessageService messageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private EmployeeService employeeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private ZdUnitCodeService zdUnitCodeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private CriticalValueService criticalValueService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @SuppressWarnings("all") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ZdDeptAllMapper zdDeptAllMapper; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,15 +28,6 @@ public class CriticalWebServiceImpl implements CriticalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String criticalAccept(String accessToken, String msg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("收到危急值信息:----->" + msg + "<-------"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        if(messageService==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            messageService = SpringBeanUtils.getBean(MessageServiceImpl.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        if(employeeService==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            employeeService= SpringBeanUtils.getBean(EmployeeServiceImpl.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        if(zdUnitCodeService==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            zdUnitCodeService = SpringBeanUtils.getBean(ZdUnitCodeServiceImpl.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, String> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (StringUtils.isBlank(accessToken)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("Code", "false"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -75,14 +50,8 @@ public class CriticalWebServiceImpl implements CriticalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             JSONObject jsonObj = new JSONObject(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return jsonObj.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         JSONObject myJsonObject = new JSONObject(msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (myJsonObject == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            resultMap.put("Code", "false"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            resultMap.put("Message", "消息读取失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.error("消息读取失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            JSONObject jsonObj = new JSONObject(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return jsonObj.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String targetDeptCode = myJsonObject.getString("TargetDeptCode"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (StringUtils.isBlank(targetDeptCode)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("Code", "false"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -99,88 +68,7 @@ public class CriticalWebServiceImpl implements CriticalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             JSONObject jsonObj = new JSONObject(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return jsonObj.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //住院科室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String zkWard = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //管床医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String referPhysician = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //主治医师 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String consultPhysician = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //主任医师 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String deptDirector = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (content.indexOf("住院号") > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            senMessage(msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //住院病人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String inpatientNo = content.substring(content.indexOf("住院号") + 4, content.indexOf(",姓名")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (StringUtils.isNotBlank(inpatientNo)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Map<String, String> map = zdUnitCodeService.queryZkWardByInpatientNo(inpatientNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (map != null && map.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    zkWard = map.get("zkWard"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    referPhysician = map.get("refer_physician"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    consultPhysician = map.get("consult_physician"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    deptDirector = map.get("dept_director"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        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)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            tempSet.add(referPhysician); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (StringUtils.isNotBlank(referPhysician)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            tempSet.add(consultPhysician); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (StringUtils.isNotBlank(deptDirector)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            tempSet.add(deptDirector); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (tempSet.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<Employee> tempsEmps = employeeService.queryByCodes(new ArrayList<>(tempSet)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (tempsEmps != null && tempsEmps.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                employees.addAll(tempsEmps); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (employees != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Set<String> fullCodes = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (Employee employee : employees) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (!fullCodes.contains(employee.getCodeRs())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (codes == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        codes = employee.getCodeRs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        codes += "," + employee.getCodeRs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    fullCodes.add(employee.getCodeRs()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (codes != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String MsgID = (String) myJsonObject.get("MsgID"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            content = content.replaceAll("=", ":").replaceAll(" ", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            messageService.sendWxMessage(codes, content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.info("消息id=【" + MsgID + "】的危机值消息发布成功,接收人codes=【" + codes + "】"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //messageService.sendWxMessage("01387,3210", content.replaceAll("=", ":").replaceAll(" ", "")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                CriticalValue criticalValue = new CriticalValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                criticalValue.setContent(content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                criticalValue.setEmployeeCodes(codes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                criticalValue.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                criticalValueService.saveCriticalValue(criticalValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        acceptCriticalValues(msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         resultMap.put("Code", "true"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         resultMap.put("Message", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         JSONObject jsonObj = new JSONObject(resultMap); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -192,12 +80,13 @@ public class CriticalWebServiceImpl implements CriticalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 向住院系统推送危急值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param message 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private void senMessage(String message){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void acceptCriticalValues(String message){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(StringUtils.isBlank(message)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            HttpUtil.sendHttpGet(wxPayOrderServiceUrl+"/criticalValue/pushMessage" + "?message=" + URLEncoder.encode(message, "UTF-8"), "utf-8", 3000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HttpUtil.sendHttpGet(wxPayOrderServiceUrl+"/criticalValue/acceptCriticalValues" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    "?message=" + URLEncoder.encode(message, "UTF-8"), "utf-8", 3000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             log.error("向住院系统推送危急值失败!"); 
			 |