Browse Source

代码修改

liubing 3 years ago
parent
commit
560cb25c01

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java

@ -67,7 +67,7 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private Date completeTime;//完成时间
    private String teamCode;
    private Integer type; //发起类型(1本人发起 2家人待预约 3医生代预约)
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警,4拐杖发起
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String deviceSn;//设备sn  设备触发是才有该字段值

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -318,7 +318,7 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private String serviceStatus;//服务类型 1-预约项目 2-即时项目
    private String orderInfo;//工单详情 0-未推送 1-未确认 2-已确认
    private String doctorConfirmFinishImg;
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起 5睡眠带 6气感报警器 7 烟感报警器
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起 5睡眠带 6气感报警器 7 烟感报警器 8拐杖发起
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String topicItem;//安防工单所属专题 base_system_dict_entry表service_item
    private String sceneImg;//现场照片

+ 23 - 1
common/common-util/src/main/java/com/yihu/jw/util/common/GpsUtil.java

@ -104,15 +104,37 @@ public class GpsUtil {
     * @param bd_lon
     * @return
     */
    public  JSONObject bd09_To_Gps84(double bd_lat, double bd_lon) {
    public JSONObject bd09_To_Gps84(double bd_lat, double bd_lon) {
        JSONObject gcj02 = bd09_To_Gcj02(bd_lat, bd_lon);
        JSONObject map84 = gcj_To_Gps84(gcj02.getDouble("lat"),
                gcj02.getDouble("lon"));
        return map84;
    }
    public JSONObject Gps84_To_bd09(double bd_lat, double bd_lon) {
        JSONObject gcj02 = gps84_To_Gcj02(bd_lat, bd_lon);
        JSONObject map84 = gcj02_To_Bd09(gcj02.getDouble("lat"),
                gcj02.getDouble("lon"));
        return map84;
    }
//    /**
//     * (BD-09)-->84
//     * @param bd_lat
//     * @param bd_lon
//     * @return
//     */
//    public  JSONObject bd09_To_Gps84(double bd_lat, double bd_lon) {
//
//        JSONObject gcj02 = bd09_To_Gcj02(bd_lat, bd_lon);
//        JSONObject map84 = gcj_To_Gps84(gcj02.getDouble("lat"),
//                gcj02.getDouble("lon"));
//        return map84;
//
//    }
    /**
     * is or not outOfChina
     * @param lat

+ 43 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java

@ -1,13 +1,20 @@
package com.yihu.jw.util.common;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import org.apache.http.client.HttpClient;
import org.omg.CORBA.WStringSeqHelper;
import org.springframework.util.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@ -108,6 +115,42 @@ public class LatitudeUtils {
        return distanceStr;
    }
    public static String getLocationAddress(String lat, String lng)
    {
        BufferedReader in = null;
        try {
            String location = MessageFormat.format("{0},{1}", lat, lng);
            URL tirc = null;
            tirc = new URL("https://api.map.baidu.com/geocoder/v2/?location="+location+"&output=json&ak="+ak);
            in = new BufferedReader(new InputStreamReader(tirc.openStream(),"UTF-8"));
            String res;
            StringBuilder sb = new StringBuilder("");
            while((res = in.readLine())!=null){
                sb.append(res.trim());
            }
            String str = sb.toString();
            JSONObject obj = JSONObject.parseObject(str);
            if (0==obj.getInteger("status")){
                JSONObject tmp = obj.getJSONObject("result");
                if (null!=tmp){
                    return tmp.getString("formatted_address");
                }
            }
        }catch (Exception e) {
            e.printStackTrace();
        }finally{
            try {
                if(in!=null){
                    in.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
    public static void main(String args[]){
        try {
            Map<String, String> json = LatitudeUtils.getGeocoderLatitude("厦门海沧区新阳海新阳光公寓15梯304");

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

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.*;
import com.yihu.jw.care.util.SecurityOrderUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
@ -84,6 +85,8 @@ public class DeviceService {
    private BaseSleepPlanDetailDao sleepPlanDetailDao;
    @Autowired
    private BaseSleepPlanDao sleepPlanDao;
    @Autowired
    private SecurityOrderUtil orderUtil;
    /**
     * 获取爱牵挂管理员cookie
@ -186,17 +189,15 @@ public class DeviceService {
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("jsonData", jsonObject.toJSONString()));
                    params.add(new BasicNameValuePair("patientId", logDO.getPatient()));
                    String orderSource=null;
                    if (deviceDO.getCategoryCode().equals("4")) {
                        params.add(new BasicNameValuePair("orderSource", "2"));//工单来源工单发起来源状态 1APP 2手环 3居家报警
                        orderSource="2";
                    }
                    if (deviceDO.getCategoryCode().equals("7")) {
                        params.add(new BasicNameValuePair("orderSource", "3"));
                        orderSource="3";
                    }
                    String response = httpClientUtil.post(url, params,"UTF-8");
                    System.out.println(response);
                    orderUtil.createEmeOrder(logDO,orderSource);
                }
                sosLogDao.save(logDO);
            }
        }catch(Exception e){
                e.printStackTrace();

+ 137 - 28
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java

@ -6,12 +6,16 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.*;
import com.yihu.jw.care.endpoint.Result;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.care.util.SecurityOrderUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import com.yihu.jw.utils.StringUtil;
@ -55,6 +59,14 @@ public class DeviceUploadService {
    private BaseYxDeviceIndexDao yxDeviceIndexDao;
    @Autowired
    private HvDeviceService hvDeviceService;
    @Autowired
    private CountDistance countDistance;
    @Autowired
    private YsDeviceService ysDeviceService;
    @Autowired
    private SecurityOrderUtil orderUtil;
    @Autowired
    private GpsUtil gpsUtil;
    public Result uploadDevicesData(String dataJson)throws Exception {
        try {
@ -433,38 +445,135 @@ public class DeviceUploadService {
     * @return
     */
    public void parsingInstruction(String instructions){
        if(StringUtils.isBlank(instructions)){
            return;
        }
        String res = "";
        //位置[434036bb95761faaf8771d10029ae8eaIC*860314001160427*0113*UD,210826,093829,V,0.000000,N,0.000000,E,0.00,0.0,100.0,0,62,31,0,0,00000000,1,1,460,0,22831,259001902,62,6,wifi0,20:6b:e7:67:bf:1f,-63,wifi1,d4:9e:05:a7:60:a6,-65,wifi2,e0:d4:62:2d:67:9c,-71,wifi3,54:75:95:b9:4f:8e,-73,wifi4,e4:72:e2:aa:73:0c,-73,wifi5,e0:d4:62:2d:67:a1,-73]
        String instruct[] = instructions.split("]");
        for (int i=0;i<instruct.length;i++){
            String inst = instruct[i];
            String tmp[] = inst.split("\\*");
            String sn = tmp[1];
            String order = tmp[3];
            if(order.contains(",")){
                String tmp1[] = order.split(",");
                if("UD".equals(tmp1[0])||"CRUD".equals(tmp1[0])){
                    //处理位置信息
                    String lat,lon;
                    if("A".equals(tmp1[4])){
                        lat = tmp1[5];
                        lon = tmp1[7];
                    }else{
                        lat = tmp1[4];
                        lon = tmp1[6];
        try {
            if(StringUtils.isBlank(instructions)){
                return;
            }
            String res = "";
            //位置[434036bb95761faaf8771d10029ae8eaIC*860314001160427*0113*UD,210826,093829,V,0.000000,N,0.000000,E,0.00,0.0,100.0,0,62,31,0,0,00000000,1,1,460,0,22831,259001902,62,6,wifi0,20:6b:e7:67:bf:1f,-63,wifi1,d4:9e:05:a7:60:a6,-65,wifi2,e0:d4:62:2d:67:9c,-71,wifi3,54:75:95:b9:4f:8e,-73,wifi4,e4:72:e2:aa:73:0c,-73,wifi5,e0:d4:62:2d:67:a1,-73]
            String instruct[] = instructions.split("]");
            for (int i=0;i<instruct.length;i++){
                String inst = instruct[i];
                String tmp[] = inst.split("\\*");
                String sn = tmp[1];
                String order = tmp[3];
                if(order.contains(",")){
                    String tmp1[] = order.split(",");
                    if("UD".equals(tmp1[0])||"CRUD".equals(tmp1[0])){
                        //处理位置信息
                        String lat,lon;
                        if("A".equals(tmp1[4])){
                            lat = tmp1[5];
                            lon = tmp1[7];
                            //判断是否超出围栏,
                        }else{
                            lat = tmp1[4];
                            lon = tmp1[6];
                        }
                        double dulat =Double.parseDouble(lat);
                        double dulon = Double.parseDouble(lon);
                        if (!(dulat==0.0&&dulon==0.0)){//判断是否触发工单
                            List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(sn);
                            DevicePatientDevice patientDevice = null;
                            if (patientDeviceList.size()>0){
                                for (DevicePatientDevice pd2:patientDeviceList){
                                    if (StringUtils.isNotBlank(pd2.getSafeAreaGz())){
                                        patientDevice = pd2;
                                        break;
                                    }
                                }
                            }
                            if (null!=patientDevice){//存在围栏地址
                                String safeArea = patientDevice.getSafeAreaGz();
                                String[] safeAreas = safeArea.split(";");
                                JSONArray fenceLocation = new JSONArray();
                                for (String area:safeAreas){
                                    String[] areaPoint = area.split(",");
                                    JSONObject positionTmp = new JSONObject();
                                    Double areaLon = Double.parseDouble( areaPoint[0]);
                                    Double areaLat = Double.parseDouble( areaPoint[1]);
//                                com.alibaba.fastjson.JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
                                    positionTmp.put("lat",areaLat);
                                    positionTmp.put("lon",areaLon);
                                    fenceLocation.add(positionTmp);
                                }
                                if (!countDistance.isInPolygon(dulon,dulat,fenceLocation)){
                                    orderUtil.createSecurityOrder(sn,null,null,8,"1","yslkaqqy",null);
                                }
                            }
                        }
                        BaseYxDeviceIndex deviceIndex = new BaseYxDeviceIndex();
                        deviceIndex.setSn(sn);
                        deviceIndex.setLat(lat);
                        deviceIndex.setLon(lon);
                        yxDeviceIndexDao.save(deviceIndex);
                        hvDeviceService.updContactStatus(sn,1);
                    }
                    if ("AL".equals(equals(tmp1[0]))){//触发报警
                        String lat,lon;
                        if("A".equals(tmp1[4])){
                            lat = tmp1[5];
                            lon = tmp1[7];
                            //判断是否超出围栏,
                        }else{
                            lat = tmp1[4];
                            lon = tmp1[6];
                        }
                        double dulat =Double.parseDouble(lat);
                        double dulon = Double.parseDouble(lon);
                        List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(sn);
                        if (patientDeviceList.size()>0){
                            DevicePatientDevice deviceDO = patientDeviceList.get(0);
                            BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                            //发起救助工单
                            //获取居民坐标
                            //如果没获取取居民坐标
                            if ((dulat==0.0&&dulon==0.0)){
                                String points = patientDO.getLatLon();
                                if (StringUtils.isNotBlank(points)){
                                    String[] pointss = points.split(",");
                                    if (2==pointss.length){
                                        if (StringUtils.isNotBlank(pointss[0])){
                                            dulat = Double.parseDouble(pointss[0]);
                                        }
                                        if (StringUtils.isNotBlank(pointss[1])){
                                            dulat = Double.parseDouble(pointss[1]);
                                        }
                                    }
                                }else {
                                    return;
                                }
                            }
                            if ((dulat==0.0&&dulon==0.0)){
                                return;
                            }
                            DeviceSosLogDO logDO = new DeviceSosLogDO();
                            logDO.setPatient(patientDO.getId());
                            logDO.setPatientName(patientDO.getName());
                            logDO.setIdcard(patientDO.getIdcard());
                            logDO.setCategoryCode(deviceDO.getCategoryCode());
                            logDO.setDeviceSn(deviceDO.getDeviceSn());
                            logDO.setCreateTime(new Date());
                            com.alibaba.fastjson.JSONObject position = gpsUtil.Gps84_To_bd09(dulat,dulon);
                            //坐标
                            logDO.setSosLat(position.getDouble("lat")+"");
                            logDO.setSosLon(position.getDouble("lon")+"");
                            logDO.setSosAddress(LatitudeUtils.getLocationAddress(position.getDouble("lat")+"",position.getDouble("lon")+""));
                            orderUtil.createEmeOrder(logDO,"4");
                        }
                    }
                    BaseYxDeviceIndex deviceIndex = new BaseYxDeviceIndex();
                    deviceIndex.setSn(sn);
                    deviceIndex.setLat(lat);
                    deviceIndex.setLon(lon);
                    yxDeviceIndexDao.save(deviceIndex);
                    hvDeviceService.updContactStatus(sn,1);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 4 - 3
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/HvDeviceService.java

@ -9,6 +9,7 @@ import com.yihu.jw.care.dao.device.DeviceHealthIndexDao;
import com.yihu.jw.care.dao.device.HvDeviceRecordDao;
import com.yihu.jw.care.dao.device.HvDeviceSosLogDao;
import com.yihu.jw.care.util.ArtemisPostTest;
import com.yihu.jw.care.util.SecurityOrderUtil;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DeviceHealthIndex;
import com.yihu.jw.entity.care.device.HvDeviceRecord;
@ -36,7 +37,7 @@ public class HvDeviceService {
    @Autowired
    private DeviceHealthIndexDao deviceHealthIndexDao;
    @Autowired
    private YsDeviceService ysDeviceService;
    private SecurityOrderUtil orderUtil;
    @Autowired
    private HvDeviceSosLogDao hvdeviceSosLogDao;
    @Autowired
@ -108,14 +109,14 @@ public class HvDeviceService {
                //独立式可燃气体探测器(NB)
                JSONObject tmp = new JSONObject();
                tmp.put("gas",monitorValue);
                ysDeviceService.createOrder(resourceSerial,null,new JSONObject(),6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                orderUtil.createSecurityOrder(resourceSerial,null,new JSONObject(),6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
            }
            if("600002".equals(deviceType)){
                //独立式光电感烟探测器(NB)
                JSONObject tmp = new JSONObject();
                tmp.put("smoke",monitorValue);
                ysDeviceService.createOrder(resourceSerial,null,new JSONObject(),7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                orderUtil.createSecurityOrder(resourceSerial,null,new JSONObject(),7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
            }
        }

File diff suppressed because it is too large
+ 5 - 113
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java


+ 86 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/CountDistance.java

@ -0,0 +1,86 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
@Component
public class CountDistance {
    private static double EARTH_RADIUS = 6378.137;// 6378.137赤道半径6378137
    private static double rad(double d) {
        return d * Math.PI / 180.0;
    }
    /**
     * 通过经纬度计算两点之间的距离(单位:千米)
     * @param latone
     * @param lngone
     * @param lattwo
     * @param lngtwo
     * @return
     */
    public  double getDistance(double latone, double lngone, double lattwo, double lngtwo) {
        double radlatone = rad(latone);
        double radlattwo = rad(lattwo);
        double a = radlatone - radlattwo;
        double b = rad(lngone) - rad(lngtwo);
        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
                + Math.cos(radlatone) * Math.cos(radlattwo)
                * Math.pow(Math.sin(b / 2), 2)));
        s = s * EARTH_RADIUS;
        s = Math.round(s * 10000d) / 10000d;
        s = s;
        return s;
    }
    /**
     * 判断坐标是否在多边形区域内
     * @param pointLon
     * @param pointLat
     * @param rangePositions 多边形坐标 [{"lon":118.19302036660137,"lat":24.494515439791996},{"lon":118.19401849369201,"lat":24.49606682685256}]
     * @return
     */
    public boolean isInPolygon(double pointLon, double pointLat, JSONArray rangePositions) {
        // 将要判断的横纵坐标组成一个点
        double[] lon =  rangePositions.stream().mapToDouble(item->((JSONObject)item).getDouble("lon")).toArray();
        double[] lat =  rangePositions.stream().mapToDouble(item->((JSONObject)item).getDouble("lat")).toArray();;
        Point2D.Double point = new Point2D.Double(pointLon, pointLat);
        // 将区域各顶点的横纵坐标放到一个点集合里面
        List<Point2D.Double> pointList = new ArrayList<Point2D.Double>();
        double polygonPoint_x = 0.0, polygonPoint_y = 0.0;
        for (int i = 0; i < lon.length; i++) {
            polygonPoint_x = lon[i];
            polygonPoint_y = lat[i];
            Point2D.Double polygonPoint = new Point2D.Double(polygonPoint_x, polygonPoint_y);
            pointList.add(polygonPoint);
        }
        return check(point, pointList);
    }
    private static boolean check(Point2D.Double point, List<Point2D.Double> polygon) {
        java.awt.geom.GeneralPath peneralPath = new java.awt.geom.GeneralPath();
        Point2D.Double first = polygon.get(0);
        // 通过移动到指定坐标(以双精度指定),将一个点添加到路径中
        peneralPath.moveTo(first.x, first.y);
        polygon.remove(0);
        for (Point2D.Double d : polygon) {
            // 通过绘制一条从当前坐标到新指定坐标(以双精度指定)的直线,将一个点添加到路径中。
            peneralPath.lineTo(d.x, d.y);
        }
        // 将几何多边形封闭
        peneralPath.lineTo(first.x, first.y);
        peneralPath.closePath();
        // 测试指定的 Point2D 是否在 Shape 的边界内。
        return peneralPath.contains(point);
    }
}

+ 197 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java

@ -0,0 +1,197 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.care.dao.device.DeviceSosLogDao;
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.care.device.DeviceSosLogDO;
import com.yihu.jw.exception.business.file_upload.*;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.csource.common.MyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/8/28.
 */
@Component
public class SecurityOrderUtil {
    @Value("${cloudCare.url}")
    private String cloudCareUrl;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private DeviceSosLogDao sosLogDao;
    /***创建安防工单***/
    public JSONObject createSecurityOrder(String deviceSN, String sceneUrl, JSONObject result, Integer orderSource, String dictCode, String topicItem, String warnInfo){
        try {
            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";
                String hospital = "";
                String sql ="select DISTINCT pack.org_code,pack.org_name " +
                        " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack " +
                        "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id and  item.`code`='"+topicItem+"'  and item.service_package_id = pack.id " +
                        "  and pack.del=1";
                List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                if(sqlResult.size()>0){
                    hospital = sqlResult.get(0).get("org_code")+"";
                }
                String serveDesc = "";
                String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict'";
                List<Map<String,Object>> listTmp = jdbcTemplate.queryForList(sqlDesc);
                if (listTmp!=null&&listTmp.size()>0){
                    serveDesc = listTmp.get(0).get("dict_value")+"";
                }
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("patient",patientDO.getId());
                jsonObject.put("patientName",patientDO.getName());
                jsonObject.put("patientPhone",patientDO.getMobile());
                jsonObject.put("serveDesc",serveDesc);
                jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                jsonObject.put("serveAddress",deviceDO.getSosAddress());
                jsonObject.put("serveLat",lat);
                jsonObject.put("serveLon",lon);
                jsonObject.put("topicItem",topicItem);
                jsonObject.put("deviceSn",deviceSN);
                jsonObject.put("warnInfo",warnInfo);
                if (StringUtils.isNotBlank(sceneUrl)){
                    jsonObject.put("sceneImg",sceneUrl);
                }
                JSONObject jsonObjectParam = new JSONObject();
                jsonObjectParam.put("order", jsonObject);
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("jsonData", jsonObjectParam.toJSONString()));
                params.add(new BasicNameValuePair("warnStr", serveDesc));
                params.add(new BasicNameValuePair("orderSource", orderSource+""));
                String response = httpClientUtil.post(url, params,"UTF-8");
                System.out.println(response);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
    /***创建紧急工单****/
    public void createEmeOrder(DeviceSosLogDO logDO, String orderSource){
        String sql =" select Distinct pack.org_code,pack.org_name\n" +
                "from base_service_package_sign_record sr INNER JOIN base_service_package_record pr\n" +
                "on sr.id = pr.sign_id and sr.status=1 INNER JOIN base_service_package_item item on pr.service_package_id = item.service_package_id and item.del=1 \n" +
                "INNER JOIN base_service_package pack on pr.service_package_id = pack.id where item.code='emergencyAssistance' and sr.patient='"+logDO.getPatient()+"'";
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
        if (sqlResult.size()>0){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("serveAddress",logDO.getSosAddress());
            jsonObject.put("serveLon",logDO.getSosLon());
            jsonObject.put("serveLat",logDO.getSosLat());
            jsonObject.put("orgCode",sqlResult.get(0).get("org_code").toString());
            jsonObject.put("orgName",sqlResult.get(0).get("org_name").toString());
            jsonObject.put("patient",logDO.getPatient());
            jsonObject.put("patientName",logDO.getPatientName());
            jsonObject.put("deviceSn",logDO.getDeviceSn());
            String url = cloudCareUrl+"cloudCare/noLogin/emergency_assistance/newOrder";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("jsonData", jsonObject.toJSONString()));
            params.add(new BasicNameValuePair("patientId", logDO.getPatient()));
            params.add(new BasicNameValuePair("orderSource", orderSource));//工单来源工单发起来源状态 1APP 2手环 3居家报警 4拐杖
            String response = httpClientUtil.post(url, params,"UTF-8");
            System.out.println(response);
        }
        sosLogDao.save(logDO);
    }
    public UploadVO uploadImg(MultipartFile file)throws Exception{
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = uploadImg2(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return uploadVO;
    }
    public UploadVO uploadImg2(InputStream inputStream, String originalFileName,long fileSize,String fastdfs_file_url) throws NoSuchAlgorithmException, IOException, MyException {
        // 得到文件的完整名称  xxx.txt
        if( null == inputStream){
            throw new FileInputStreamEmptyException("图片文件流不可为空!");
        }
        if(StringUtils.isBlank(originalFileName)){
            throw new FileNameEmptyException("图片文件名不可为空!");
        }
        if(StringUtils.isBlank(fastdfs_file_url)){
            throw new FastfdsFileURLEmptyException("fastdfs url不可为空!");
        }
        //得到文件类型
        String fileType = originalFileName.substring(originalFileName.lastIndexOf(".") + 1).toLowerCase();
        if(StringUtils.isBlank(fileType)||!"jpg,jpeg,png".contains(fileType)){
            throw new FileWrongFormatException("图片文件格式不正确,请上传jpg,jpeg,png等任一格式!");
        }
        long max = 5*1024*1024;
        if(fileSize > max){
            throw new FileTooLargeSizeException("图片文件过大,请不要超过5M!");
        }
        String fileName = originalFileName.substring(0, originalFileName.lastIndexOf("."));
        //上传到fastdfs
        ObjectNode objectNode = fastDFSHelper.upload(inputStream, fileType, "");
        //解析返回的objectNode
        UploadVO uploadVO = new UploadVO();
        uploadVO.setFileName(fileName);
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        return uploadVO;
    }
}

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -1601,7 +1601,7 @@ public class MonitorPlatformService  {
        String allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where 1=1 ";
        int i = 0;
        if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("1")){
            allCountSql+= " and ( device_name like '%血糖仪%' ";
            allCountSql+= "   ";
            i = 1;
        }
        if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("2")){