Browse Source

Merge branch 'dev' of liubing/wlyy2.0 into dev

liubing 3 years ago
parent
commit
acf267b196

+ 4 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java

@ -35,9 +35,11 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop createOrder(@ApiParam(name="jsonData",value = "json数据",required = true)
                               @RequestParam(value = "jsonData")String jsonData,
                               @ApiParam(name="orderSource",value = "工单来源工单发起来源状态 1APP 2手环 3居家报警")
                               @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource){
                               @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource,
                               @ApiParam(name="warnStr",value = "紧急预警弹框字段")
                               @RequestParam(value = "warnStr",defaultValue = "疑似离开安全区域",required = false) String warnStr){
        try {
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource);
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource,warnStr);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }

+ 4 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/securrity/SecuMonOrderEndpoint.java

@ -31,9 +31,11 @@ public class SecuMonOrderEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop createOrder(@ApiParam(name="jsonData",value = "json数据",required = true)
                                  @RequestParam(value = "jsonData")String jsonData,
                                  @ApiParam(name="orderSource",value = "工单来源工单发起来源状态 1APP 2手环 3居家报警")
                                  @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource){
                                  @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource,
                                  @ApiParam(name="warnStr",value = "紧急预警弹框字段")
                                  @RequestParam(value = "warnStr",defaultValue = "疑似离开安全区域",required = false) String warnStr){
        try {
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource);
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource,warnStr);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -105,7 +105,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
    public JSONObject createOrder(String jsonData,Integer orderSource) throws Exception {
    public JSONObject createOrder(String jsonData,Integer orderSource,String warnStr) throws Exception {
        logger.info("创建安防工单jsonData参数:" + jsonData);
        JSONObject result = new JSONObject();
@ -209,7 +209,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            JSONObject message = new JSONObject();
            message.put("session_id",sessionId);
            message.put("sender_name",orderDO.getPatientName());
            message.put("content_notice",orderDO.getPatientName()+" 疑似离开安全区域!");
            message.put("content_notice",orderDO.getPatientName()+" "+warnStr+"!");
            message.put("sender_code",orderDO.getPatient());
            message.put("OrderType",22);
            message.put("order_id",orderDO.getId());

+ 2 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -263,7 +263,7 @@ public class DeviceService {
                                jsonObject.put("patient",patientDO.getId());
                                jsonObject.put("patientName",patientDO.getName());
                                jsonObject.put("patientPhone",patientDO.getMobile());
                                jsonObject.put("serveDesc","疑似离开安全区域");
                                jsonObject.put("serveDesc","疑似离开安全区域!");
                                jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                                jsonObject.put("serveAddress",address.replace(" ",""));
                                jsonObject.put("serveLat",lat);
@ -273,6 +273,7 @@ public class DeviceService {
                                jsonObjectParam.put("order", jsonObject);
                                map.put("jsonData", jsonObjectParam.toJSONString());
                                map.put("orderSource", 2);
                                map.put("warnStr", "疑似离开安全区域");
                                content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                                postParams = AesEncryptUtils.agEncrypt(content);

+ 87 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java

@ -3,17 +3,27 @@ package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.YsConfig;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.encode.Base64;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
import java.security.Security;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -24,6 +34,16 @@ public class YsDeviceService {
    private static Logger logger = LoggerFactory.getLogger(YsDeviceService.class);
    private Map<String,String> msgType = new HashMap<>();
    @Value("${cloudCare.url}")
    private String cloudCareUrl;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 消息推送
@ -53,12 +73,79 @@ public class YsDeviceService {
            String decodeStr = messageDecrypt(message,YsConfig.msgDataKey);
            result = JSONObject.parseObject(decodeStr);
            JSONArray tmpArr = result.getJSONObject("eps").getJSONArray("alert");
            boolean fallFlag = false;
            String deviceSN = null;
            for (int i=0;i<tmpArr.size();i++){
                JSONObject tmpObj = tmpArr.getJSONObject(i);
                String msgType = tmpObj.getString("msgType");
                if (this.msgType.containsKey(msgType)){
                    tmpObj.put("msgTypeName",this.msgType.get(msgType));
                }
                if ("10005".equals(msgType)){//报警消息
                    String bodyStr = tmpObj.getString("body");
                    if (StringUtils.isNotBlank(bodyStr)){
                        JSONObject bodyJsonObj = JSONObject.parseObject(bodyStr);
                        if (bodyJsonObj!=null&&bodyJsonObj.containsKey("body")){
                            JSONObject bodyJsonObj2 = bodyJsonObj.getJSONObject("body");
                            if (bodyJsonObj2!=null&&bodyJsonObj2.containsKey("alarmType")){
                                String alarmType = bodyJsonObj2.getString("alarmType");
                                if ("tumble_detection".equals(alarmType)){//tumble_detection跌倒类型    //有人出现SmartHumanDet
                                    fallFlag = true;
                                    deviceSN = bodyJsonObj2.getString("devSerial");//设备SN
                                }
                            }
                        }
                    }
                }
            }
            if (fallFlag){//发起安防工单
                String lat = "";
                String lon = "";
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceSN);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                    Map<String, String> json = null;
                    if (org.apache.commons.lang.StringUtils.isNotBlank(deviceDO.getSosAddress())) {
                        json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
                    }
                    if (json != null) {
                        lat = json.get("lat").toString();
                        lon = json.get("lng").toString();
                    }
                    BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                    String  url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
                    Map map = new HashMap<String, String>();
                    map = new HashMap();
                    String sql ="select DISTINCT item.org_code,item.org_name\n" +
                            " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
                            "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id \tand  item.`code`='preventFall'  and item.service_package_id = pack.id \n" +
                            "  and pack.del=1";
                    List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("patient",patientDO.getId());
                    jsonObject.put("patientName",patientDO.getName());
                    jsonObject.put("patientPhone",patientDO.getMobile());
                    jsonObject.put("serveDesc","疑似跌倒!");
                    jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                    jsonObject.put("serveAddress",deviceDO.getAddress());
                    jsonObject.put("serveLat",lat);
                    jsonObject.put("serveLon",lon);
                    jsonObject.put("topicItem","preventFall");
                    JSONObject jsonObjectParam = new JSONObject();
                    jsonObjectParam.put("order", jsonObject);
                    map.put("jsonData", jsonObjectParam.toJSONString());
                    map.put("orderSource", 2);
                    map.put("warnStr", "疑似跌倒");
                    String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                    String postParams = AesEncryptUtils.agEncrypt(content);
                    String response = httpClientUtil.postBodyRawForm(url,postParams);
                    result = com.alibaba.fastjson.JSONObject.parseObject(response);
                    JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                    System.out.println(jsonObjectData.toJSONString());
                }
            }
        }catch (Exception e){
        }