|
@@ -1,46 +1,95 @@
|
|
|
package cn.hnthyy.thmz.webservice.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hnthyy.thmz.Utils.SpringBeanUtils;
|
|
|
+import cn.hnthyy.thmz.entity.his.Employee;
|
|
|
+import cn.hnthyy.thmz.service.his.EmployeeService;
|
|
|
+import cn.hnthyy.thmz.service.impl.his.EmployeeServiceImpl;
|
|
|
+import cn.hnthyy.thmz.service.impl.thmz.MessageServiceImpl;
|
|
|
+import cn.hnthyy.thmz.service.thmz.MessageService;
|
|
|
import cn.hnthyy.thmz.webservice.service.CriticalWebService;
|
|
|
-import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import javax.jws.WebService;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
@WebService
|
|
|
public class CriticalWebServiceImpl implements CriticalWebService {
|
|
|
- private String token ="oI9#ur02cbBHdop87e6Y728Ax30IIlgd";
|
|
|
+ private String token = "oI9#ur02cbBHdop87e6Y728Ax30IIlgd";
|
|
|
+ MessageService messageService =(MessageServiceImpl)SpringBeanUtils.getBean(MessageServiceImpl.class);
|
|
|
+ EmployeeService employeeService=(EmployeeServiceImpl)SpringBeanUtils.getBean(EmployeeServiceImpl.class);
|
|
|
@Override
|
|
|
public String criticalAccept(String accessToken, String msg) {
|
|
|
- Map<String,String> resultMap=new HashMap<>();
|
|
|
- if(StringUtils.isBlank(accessToken)){
|
|
|
- resultMap.put("Code","false");
|
|
|
- resultMap.put("Message","token不能为空");
|
|
|
+ Map<String, String> resultMap = new HashMap<>();
|
|
|
+ if (StringUtils.isBlank(accessToken)) {
|
|
|
+ resultMap.put("Code", "false");
|
|
|
+ resultMap.put("Message", "token不能为空");
|
|
|
log.error("token不能为空");
|
|
|
- JSONObject jsonObj=new JSONObject(resultMap);
|
|
|
+ JSONObject jsonObj = new JSONObject(resultMap);
|
|
|
return jsonObj.toString();
|
|
|
}
|
|
|
- if(StringUtils.isBlank(msg)){
|
|
|
- resultMap.put("Code","false");
|
|
|
- resultMap.put("Message","msg为空");
|
|
|
+ if (StringUtils.isBlank(msg)) {
|
|
|
+ resultMap.put("Code", "false");
|
|
|
+ resultMap.put("Message", "msg为空");
|
|
|
log.error("msg为空");
|
|
|
- JSONObject jsonObj=new JSONObject(resultMap);
|
|
|
+ JSONObject jsonObj = new JSONObject(resultMap);
|
|
|
return jsonObj.toString();
|
|
|
}
|
|
|
- if(!token.equals(accessToken)){
|
|
|
- resultMap.put("Code","false");
|
|
|
- resultMap.put("Message","token校验失败");
|
|
|
+ if (!token.equals(accessToken)) {
|
|
|
+ resultMap.put("Code", "false");
|
|
|
+ resultMap.put("Message", "token校验失败");
|
|
|
log.error("token校验失败");
|
|
|
- JSONObject jsonObj=new JSONObject(resultMap);
|
|
|
+ JSONObject jsonObj = new JSONObject(resultMap);
|
|
|
return jsonObj.toString();
|
|
|
}
|
|
|
JSONObject myJsonObject = new JSONObject(msg);
|
|
|
-
|
|
|
- return null;
|
|
|
+ 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");
|
|
|
+ resultMap.put("Message", "目标科室为空");
|
|
|
+ log.error("目标科室为空");
|
|
|
+ JSONObject jsonObj = new JSONObject(resultMap);
|
|
|
+ return jsonObj.toString();
|
|
|
+ }
|
|
|
+ String content = myJsonObject.getString("Content");
|
|
|
+ if(StringUtils.isBlank(content)){
|
|
|
+ resultMap.put("Code", "false");
|
|
|
+ resultMap.put("Message", "消息内容为空");
|
|
|
+ log.error("消息内容为空");
|
|
|
+ JSONObject jsonObj = new JSONObject(resultMap);
|
|
|
+ return jsonObj.toString();
|
|
|
+ }
|
|
|
+ List<Employee> employees=employeeService.queryEmployeeByDept(targetDeptCode.trim());
|
|
|
+ if(employees!=null){
|
|
|
+ String codes=null;
|
|
|
+ for (Employee employee:employees){
|
|
|
+ if(codes==null){
|
|
|
+ codes= employee.getCodeRs();
|
|
|
+ }else {
|
|
|
+ codes+=","+employee.getCodeRs();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(codes!=null){
|
|
|
+ //messageService.sendWxMessage(codes, content.replaceAll("=",":").replaceAll(" ",""));
|
|
|
+ messageService.sendWxMessage("3210", content.replaceAll("=",":").replaceAll(" ",""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultMap.put("Code", "true");
|
|
|
+ resultMap.put("Message", "");
|
|
|
+ log.info("危机值消息发布成功");
|
|
|
+ JSONObject jsonObj = new JSONObject(resultMap);
|
|
|
+ return jsonObj.toString();
|
|
|
}
|
|
|
}
|