liubing 4 lat temu
rodzic
commit
08e6bbd3f0

+ 12 - 0
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -501,6 +501,18 @@ public class HttpClientUtil {
        return ret;
    }
    public String getBodyRawForm(String url, String params) throws IOException {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        List<NameValuePair> pairs = new ArrayList<>(0);
        pairs.add(new BasicNameValuePair("object",params));
        String entityString = EntityUtils.toString(new UrlEncodedFormEntity(pairs,Consts.UTF_8));
        HttpGet httpGet = new HttpGet(url+"?"+entityString);
        CloseableHttpResponse response = httpclient.execute(httpGet);
        HttpEntity entity = response.getEntity();
        String ret = EntityUtils.toString(entity);
        return ret;
    }
    /**
     * 爱牵挂请求
     * @param url

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

@ -234,48 +234,54 @@ public class DeviceService {
            if(StringUtils.isNotBlank(deviceid)){
                if (type==4){
                    List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceid);
                    DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                    if (deviceDO.getCategoryCode().equals("4")) {
                        //获取手环最新定位信息
                        String url = cloudCareUrl+"/cloudCare/noLogin/device/getDeviceLastLocation";
                        Map map = new HashMap<String, String>();
                        map.put("deviceSn",deviceDO.getDeviceSn());
                        String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                        String postParams = AesEncryptUtils.agEncrypt(content);
                        String response = httpClientUtil.postBodyRawForm(url,postParams);
                        JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
                        JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                        Double lat = jsonObjectData.getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lat");
                        Double lon = jsonObjectData.getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lon");
                        String address = jsonObjectData.getJSONObject("obj").getJSONObject("locationdata").getString("address");
                        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`='preventLost'  and item.service_package_id = pack.id \n" +
                                "  and pack.del=1";
                        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                        if (sqlResult.size()>0){
                            map = new HashMap();
                            url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
                            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",address.replace(" ",""));
                            jsonObject.put("serveLat",lat);
                            jsonObject.put("serveLon",lon);
                            map.put("order", jsonObject.toJSONString());
                            content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                            postParams = AesEncryptUtils.agEncrypt(content);
                            response = httpClientUtil.postBodyRawForm(url,postParams);
                            result = com.alibaba.fastjson.JSONObject.parseObject(response);
                            jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                            System.out.println(jsonObjectData.toJSONString());
                    if (devicePatientDeviceDos.size()>0){
                        DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                        BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                        if (deviceDO.getCategoryCode().equals("4")) {
                            //获取手环最新定位信息
                            String url = cloudCareUrl+"/cloudCare/noLogin/device/getDeviceLastLocation";
                            Map map = new HashMap<String, String>();
                            map.put("deviceSn",deviceDO.getDeviceSn());
                            String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                            String postParams = AesEncryptUtils.agEncrypt(content);
                            String response = httpClientUtil.getBodyRawForm(url,postParams);
                            JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
                            JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                            Double lat = jsonObjectData.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lat");
                            Double lon = jsonObjectData.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lon");
                            String address = jsonObjectData.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getString("address");
                            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`='preventLost'  and item.service_package_id = pack.id \n" +
                                    "  and pack.del=1";
                            List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                            if (sqlResult.size()>0){
                                map = new HashMap();
                                url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
                                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",address.replace(" ",""));
                                jsonObject.put("serveLat",lat);
                                jsonObject.put("serveLon",lon);
                                JSONObject jsonObjectParam = new JSONObject();
                                jsonObjectParam.put("order", jsonObject);
                                map.put("jsonData", jsonObjectParam.toJSONString());
                                content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                                postParams = AesEncryptUtils.agEncrypt(content);
                                response = httpClientUtil.postBodyRawForm(url,postParams);
                                result = com.alibaba.fastjson.JSONObject.parseObject(response);
                                jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                                System.out.println(jsonObjectData.toJSONString());
                            }
                        }
                    }
                }
            }