瀏覽代碼

Merge remote-tracking branch 'origin/dev' into dev

hxm 3 年之前
父節點
當前提交
018a55cc27

+ 3 - 0
common/common-entity/sql记录

@ -1550,3 +1550,6 @@ CREATE TABLE `base_yunxing_channel` (
  PRIMARY KEY (`id`)
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='云信会话关联表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='云信会话关联表';
-- 2021-10-14 ysj
ALTER table wlyy_devices add column collect_num int(20) default null COMMENT '采集数据次数';
ALTER table wlyy_devices add column abnormal_num int(20) default null COMMENT '异常指标数据次数';

+ 20 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceDetail.java

@ -54,6 +54,8 @@ public class DeviceDetail extends IdEntity {
    private String imsi;//设备物联卡imsi
    private String imsi;//设备物联卡imsi
    private String categoryCode; // 设备类型 dm_device表定义
    private String categoryCode; // 设备类型 dm_device表定义
    private Long collectNum;//采集数据次数
    private Long abnormalNum;//异常指标数据次数
    //导入设备错误信息
    //导入设备错误信息
    private String errorMsg;
    private String errorMsg;
@ -376,6 +378,24 @@ public class DeviceDetail extends IdEntity {
        this.categoryCode = categoryCode;
        this.categoryCode = categoryCode;
    }
    }
    @Column(name = "collect_num")
    public Long getCollectNum() {
        return collectNum;
    }
    public void setCollectNum(Long collectNum) {
        this.collectNum = collectNum;
    }
    @Column(name = "abnormal_num")
    public Long getAbnormalNum() {
        return abnormalNum;
    }
    public void setAbnormalNum(Long abnormalNum) {
        this.abnormalNum = abnormalNum;
    }
    @Transient
    @Transient
    public String getErrorMsg() {
    public String getErrorMsg() {
        return errorMsg;
        return errorMsg;

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

@ -168,7 +168,8 @@ public class WeiXinEventProcess {
        Map<String, String> articleFamily = new HashMap<>();
        Map<String, String> articleFamily = new HashMap<>();
        // 图文URL
        // 图文URL
        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex%3Ftype%3D2&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
//        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex%3Ftype%3D2&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlFamily = urlFamily.replace("{appId}", appId);
        urlFamily = urlFamily.replace("{appId}", appId);
        articleFamily.put("Url", urlFamily);
        articleFamily.put("Url", urlFamily);
        articleFamily.put("Title", "上门预约");
        articleFamily.put("Title", "上门预约");

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

@ -877,14 +877,6 @@ public class DeviceService {
    @Async
    @Async
    public void byOnlineStatus(String device,String onlinestatu,String time_begin){
    public void byOnlineStatus(String device,String onlinestatu,String time_begin){
        try {
        try {
            if(StringUtils.isNotBlank(device)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice tmp = devicePatientDeviceDos.get(0);
                    tmp.setOnlineStatus(Integer.parseInt(onlinestatu));
                    patientDeviceDao.save(tmp);
                }
            }
            DeviceDetail deviceDetail = deviceDetailDao.findBySn(device);
            DeviceDetail deviceDetail = deviceDetailDao.findBySn(device);
            if(deviceDetail!=null){
            if(deviceDetail!=null){
                deviceDetail.setContactStatus(Integer.parseInt(onlinestatu));
                deviceDetail.setContactStatus(Integer.parseInt(onlinestatu));

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

@ -191,6 +191,9 @@ public class DeviceUploadService {
                        content_notice = content_notice.substring(0,content_notice.length()-1);
                        content_notice = content_notice.substring(0,content_notice.length()-1);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        hvDeviceService.updContactStatus(deviceSn,1,true);
                    }else{
                        hvDeviceService.updContactStatus(deviceSn,1,false);
                    }
                    }
                    patientHealthIndexDao.save(result);
                    patientHealthIndexDao.save(result);
                    systemMessageDao.save(messageDO);
                    systemMessageDao.save(messageDO);
@ -490,6 +493,7 @@ public class DeviceUploadService {
                        }
                        }
                        double dulat =Double.parseDouble(lat);
                        double dulat =Double.parseDouble(lat);
                        double dulon = Double.parseDouble(lon);
                        double dulon = Double.parseDouble(lon);
                        boolean flag = false;
                        if (!(dulat==0.0&&dulon==0.0)){//判断是否触发工单
                        if (!(dulat==0.0&&dulon==0.0)){//判断是否触发工单
                            com.alibaba.fastjson.JSONObject position = gpsUtil.Gps84_To_bd09(dulat,dulon);
                            com.alibaba.fastjson.JSONObject position = gpsUtil.Gps84_To_bd09(dulat,dulon);
                            dulat = position.getDouble("lat");
                            dulat = position.getDouble("lat");
@ -524,6 +528,7 @@ public class DeviceUploadService {
                                        addressInfo.put("lon",dulon+"");
                                        addressInfo.put("lon",dulon+"");
                                        addressInfo.put("address",LatitudeUtils.getLocationAddress(dulat+"",dulon+""));
                                        addressInfo.put("address",LatitudeUtils.getLocationAddress(dulat+"",dulon+""));
                                        orderUtil.createSecurityOrder(sn,null,null,addressInfo,8,"1","preventLost",null);
                                        orderUtil.createSecurityOrder(sn,null,null,addressInfo,8,"1","preventLost",null);
                                        flag = true;
                                    }
                                    }
                                }
                                }
                            }
                            }
@ -534,7 +539,7 @@ public class DeviceUploadService {
                        deviceIndex.setLat(dulat+"");
                        deviceIndex.setLat(dulat+"");
                        deviceIndex.setLon(dulon+"");
                        deviceIndex.setLon(dulon+"");
                        yxDeviceIndexDao.save(deviceIndex);
                        yxDeviceIndexDao.save(deviceIndex);
                        hvDeviceService.updContactStatus(sn,1);
                        hvDeviceService.updContactStatus(sn,1,flag);
                    }
                    }
                    if ("AL".equals(tmp1[0])){//触发报警 SOS
                    if ("AL".equals(tmp1[0])){//触发报警 SOS
                        String lat,lon;
                        String lat,lon;
@ -548,7 +553,7 @@ public class DeviceUploadService {
                        double dulat =Double.parseDouble(lat);
                        double dulat =Double.parseDouble(lat);
                        double dulon = Double.parseDouble(lon);
                        double dulon = Double.parseDouble(lon);
                        boolean flag = false;
                        if ((dulat==0.0&&dulon==0.0)){
                        if ((dulat==0.0&&dulon==0.0)){
                            String sql=" SELECT * FROM base_yxdevice_index WHERE sn = '"+sn+"' " +
                            String sql=" SELECT * FROM base_yxdevice_index WHERE sn = '"+sn+"' " +
                                    "AND create_time LIKE '"+DateUtil.getStringDateShort()+"%' AND lon != 0 AND lat != 0 ORDER BY create_time DESC  ";
                                    "AND create_time LIKE '"+DateUtil.getStringDateShort()+"%' AND lon != 0 AND lat != 0 ORDER BY create_time DESC  ";
@ -601,6 +606,7 @@ public class DeviceUploadService {
                            logDO.setSosLat(dulat+"");
                            logDO.setSosLat(dulat+"");
                            logDO.setSosLon(dulon+"");
                            logDO.setSosLon(dulon+"");
                            logDO.setSosAddress(LatitudeUtils.getLocationAddress(dulat+"",dulon+""));
                            logDO.setSosAddress(LatitudeUtils.getLocationAddress(dulat+"",dulon+""));
                            flag = true;
                            orderUtil.createEmeOrder(logDO,"4");
                            orderUtil.createEmeOrder(logDO,"4");
                        }
                        }
                        BaseYxDeviceIndex deviceIndex = new BaseYxDeviceIndex();
                        BaseYxDeviceIndex deviceIndex = new BaseYxDeviceIndex();
@ -608,7 +614,7 @@ public class DeviceUploadService {
                        deviceIndex.setLat(dulat+"");
                        deviceIndex.setLat(dulat+"");
                        deviceIndex.setLon(dulon+"");
                        deviceIndex.setLon(dulon+"");
                        yxDeviceIndexDao.save(deviceIndex);
                        yxDeviceIndexDao.save(deviceIndex);
                        hvDeviceService.updContactStatus(sn,1);
                        hvDeviceService.updContactStatus(sn,1,flag);
                    }
                    }
                }
                }
            }
            }

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

@ -166,7 +166,7 @@ public class HvDeviceService {
                list.add(index);
                list.add(index);
                dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"烟探测器监测信息接收");
                dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"烟探测器监测信息接收");
            }
            }
            updContactStatus(resourceSerial,1);
            updContactStatus(resourceSerial,1,false);
        }
        }
        if(list.size()>0){
        if(list.size()>0){
            deviceHealthIndexDao.save(list);
            deviceHealthIndexDao.save(list);
@ -185,17 +185,18 @@ public class HvDeviceService {
            List<HvDeviceRecord> list = hvdeviceRecordDao.findByDeviceId(deviceID);
            List<HvDeviceRecord> list = hvdeviceRecordDao.findByDeviceId(deviceID);
            dataPushLogUtil.savePushLog(deviceID,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"气感烟感探测器监测信息接收");
            dataPushLogUtil.savePushLog(deviceID,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"气感烟感探测器监测信息接收");
            if(list.size()>0){
            if(list.size()>0){
                updContactStatus(list.get(0).getDeviceSn(),Integer.valueOf(deviceStatus));
                updContactStatus(list.get(0).getDeviceSn(),Integer.valueOf(deviceStatus),null);
            }
            }
        }
        }
    }
    }
    /**
    /**
     * 更新在线状态
     * 更新在线状态 及次数
     * @param sn
     * @param sn
     * @param status
     * @param status
     * @param flag 状态 true 异常 false 正常 null其他
     */
     */
    public void updContactStatus(String sn,Integer status){
    public void updContactStatus(String sn,Integer status,Boolean flag){
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(sn);
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(sn);
        if(deviceDetail!=null){
        if(deviceDetail!=null){
            deviceDetail.setContactStatus(status);
            deviceDetail.setContactStatus(status);
@ -205,6 +206,20 @@ public class HvDeviceService {
               deviceLostMessageUtil.deviceLostMessage(sns);
               deviceLostMessageUtil.deviceLostMessage(sns);
            }
            }
            deviceDetail.setContactStatusTime(new Date());
            deviceDetail.setContactStatusTime(new Date());
            if(deviceDetail.getCollectNum()==null){
                deviceDetail.setCollectNum(0L);
            }
            if(deviceDetail.getAbnormalNum()==null){
                deviceDetail.setAbnormalNum(0L);
            }
            if(flag!=null){
                deviceDetail.setCollectNum(deviceDetail.getCollectNum()+1L);
                if(flag){
                    deviceDetail.setAbnormalNum(deviceDetail.getAbnormalNum()+1L);
                }
            }
            deviceDetailDao.save(deviceDetail);
            deviceDetailDao.save(deviceDetail);
        }
        }
    }
    }

+ 34 - 15
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/OnenetService.java

@ -93,27 +93,29 @@ public class OnenetService {
            }else if("15".equals(categoryCode)){
            }else if("15".equals(categoryCode)){
                title = "烟探测器监测信息接收";
                title = "烟探测器监测信息接收";
            }
            }
            hvDeviceService.updContactStatus(deviceSn,1);
            dataPushLogUtil.savePushLog(deviceSn,msg.toJSONString(),title);
            dataPushLogUtil.savePushLog(deviceSn,msg.toJSONString(),title);
            //未来鹰设备 类型2是设备状态(不准)
            //未来鹰设备 类型2是设备状态(不准)
            Integer type = msg.getInteger("type");
            Integer type = msg.getInteger("type");
            String value = msg.getString("value");
            String value = msg.getString("value");
            boolean flag = false;
            if("1".equals(onenetDevice.getDeviceType())){
            if("1".equals(onenetDevice.getDeviceType())){
                if ("14".equals(categoryCode)){//燃气
                if ("14".equals(categoryCode)){//燃气
                    wlyDateDelGas(categoryCode,msg);
                    flag = wlyDateDelGas(categoryCode,msg);
                }
                }
                if ("15".equals(categoryCode)){//烟雾设备
                if ("15".equals(categoryCode)){//烟雾设备
                    wlyDateDelSmoke(msg);
                    flag = wlyDateDelSmoke(msg);
                }
                }
            }else if("2".equals(onenetDevice.getDeviceType())){
            }else if("2".equals(onenetDevice.getDeviceType())){
                //海康设备
                //海康设备
                if("14".equals(onenetDevice.getCategoryCode())){
                if("14".equals(onenetDevice.getCategoryCode())){
                    hkDeviceQi(onenetDevice,msg);
                    flag = hkDeviceQi(onenetDevice,msg);
                }else if("15".equals(onenetDevice.getCategoryCode())){
                }else if("15".equals(onenetDevice.getCategoryCode())){
                    hkDeviceYan(onenetDevice,msg);
                    flag = hkDeviceYan(onenetDevice,msg);
                }
                }
            }
            }
            hvDeviceService.updContactStatus(deviceSn,1,flag);
            record.setContent(msg.toJSONString());
            record.setContent(msg.toJSONString());
            record.setStatus(1);
            record.setStatus(1);
@ -166,7 +168,8 @@ public class OnenetService {
    /**
    /**
     * 海康设备解析-烟感
     * 海康设备解析-烟感
     */
     */
    public void hkDeviceYan(OnenetDevice onenetDevice,JSONObject jsonObject){
    public boolean hkDeviceYan(OnenetDevice onenetDevice,JSONObject jsonObject){
        boolean flag = false;
        String value = jsonObject.getString("value");
        String value = jsonObject.getString("value");
        String byMessageId = value.substring(0,2);
        String byMessageId = value.substring(0,2);
//        String byDevType = value.substring(4,6);
//        String byDevType = value.substring(4,6);
@ -190,7 +193,7 @@ public class OnenetService {
                    addDeviceIndex(resourceSerial,monitorValue,time,"2","%");
                    addDeviceIndex(resourceSerial,monitorValue,time,"2","%");
                    dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器监测信息接收");
                    dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器监测信息接收");
                }
                }
                return;
                return flag;
            }
            }
        }
        }
@ -220,15 +223,16 @@ public class OnenetService {
                        tmp.put("smoke",monitorValue);
                        tmp.put("smoke",monitorValue);
                        orderUtil.createSecurityOrder(resourceSerial,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                        orderUtil.createSecurityOrder(resourceSerial,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                        dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"烟感探测器报警信息接收");
                        dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"烟感探测器报警信息接收");
                        flag = true;
                    }
                    }
                    addDeviceIndex(resourceSerial,monitorValue,time,"2","%");
                    addDeviceIndex(resourceSerial,monitorValue,time,"2","%");
                }
                }
                return;
                return flag;
            }
            }
        }
        }
        //其他信息暂时不处理
        //其他信息暂时不处理
        // 03消音 04自检 05故障 06信号查询 07注册 08注销 ...
        // 03消音 04自检 05故障 06信号查询 07注册 08注销 ...
        return flag;
    }
    }
    /**
    /**
@ -252,7 +256,8 @@ public class OnenetService {
    /**
    /**
     * 海康设备解析-气感
     * 海康设备解析-气感
     */
     */
    public void hkDeviceQi(OnenetDevice onenetDevice,JSONObject jsonObject){
    public boolean hkDeviceQi(OnenetDevice onenetDevice,JSONObject jsonObject){
        boolean flag = false;
        String value = jsonObject.getString("value");
        String value = jsonObject.getString("value");
        String byMessageId = value.substring(0,2);
        String byMessageId = value.substring(0,2);
//        String byDevType = value.substring(4,6);
//        String byDevType = value.substring(4,6);
@ -274,7 +279,7 @@ public class OnenetService {
                addDeviceIndex(resourceSerial,monitorValue,time,"1","%LEL");
                addDeviceIndex(resourceSerial,monitorValue,time,"1","%LEL");
                dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器监测信息接收");
                dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器监测信息接收");
            }
            }
            return;
            return flag;
        }
        }
        if("02".equals(byMessageId)){
        if("02".equals(byMessageId)){
            //报警
            //报警
@ -304,6 +309,7 @@ public class OnenetService {
                        tmp.put("gas",monitorValue);
                        tmp.put("gas",monitorValue);
                        orderUtil.createSecurityOrder(resourceSerial,null,new JSONObject(),null,6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                        orderUtil.createSecurityOrder(resourceSerial,null,new JSONObject(),null,6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                        dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器报警信息接收");
                        dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器报警信息接收");
                        flag = true;
                    }
                    }
                    addDeviceIndex(resourceSerial,monitorValue,time,"1","%LEL");
                    addDeviceIndex(resourceSerial,monitorValue,time,"1","%LEL");
                }
                }
@ -311,7 +317,7 @@ public class OnenetService {
        }
        }
        //其他信息暂时不处理
        //其他信息暂时不处理
        // 03消音 04自检 05故障 06信号查询 07注册 08注销 ...
        // 03消音 04自检 05故障 06信号查询 07注册 08注销 ...
        return flag;
    }
    }
    /**
    /**
@ -372,7 +378,8 @@ public class OnenetService {
     * 未来鹰设备烟雾数据处理
     * 未来鹰设备烟雾数据处理
     * @param msg
     * @param msg
     */
     */
    public void wlyDateDelSmoke(JSONObject msg){
    public boolean wlyDateDelSmoke(JSONObject msg){
        boolean flag = false;
        String dsId = msg.getString("ds_id");
        String dsId = msg.getString("ds_id");
        String msgId = dsId.split("_")[2];
        String msgId = dsId.split("_")[2];
        String value = msg.getString("value");
        String value = msg.getString("value");
@ -387,6 +394,7 @@ public class OnenetService {
                    JSONObject tmp = new JSONObject();
                    JSONObject tmp = new JSONObject();
                    tmp.put("smoke",value);
                    tmp.put("smoke",value);
                    orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                    orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                    flag = true;
                }
                }
            }
            }
            DeviceHealthIndex index = new DeviceHealthIndex();
            DeviceHealthIndex index = new DeviceHealthIndex();
@ -406,12 +414,21 @@ public class OnenetService {
                    JSONObject tmp = new JSONObject();
                    JSONObject tmp = new JSONObject();
                    tmp.put("smoke","100");
                    tmp.put("smoke","100");
                    orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                    orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                    flag = true;
                }
                }
            }
            }
        }
        }
        return flag;
    }
    }
    public void wlyDateDelGas(String categoryCode,JSONObject msg){
    /**
     * 返回数据是否异常 true异常
     * @param categoryCode
     * @param msg
     * @return
     */
    public boolean wlyDateDelGas(String categoryCode,JSONObject msg){
        boolean flag = false;
        String deviceSn = msg.getString("imei");
        String deviceSn = msg.getString("imei");
        Integer type = msg.getInteger("type");
        Integer type = msg.getInteger("type");
        String value = msg.getString("value");
        String value = msg.getString("value");
@ -422,7 +439,6 @@ public class OnenetService {
            Integer gas = Integer.parseInt(gas_Level, 16);
            Integer gas = Integer.parseInt(gas_Level, 16);
            if(gas>0){
            if(gas>0){
                //气体浓度大于0触发报警
                //气体浓度大于0触发报警
                String sql = "select count(*) from base_device_health_index where device_sn = '"+deviceSn+"'" +
                String sql = "select count(*) from base_device_health_index where device_sn = '"+deviceSn+"'" +
                        " and value>0 and create_time>='"+DateUtil.getNextMinute(-60)+"' ";
                        " and value>0 and create_time>='"+DateUtil.getNextMinute(-60)+"' ";
                Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
                Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
@ -432,6 +448,7 @@ public class OnenetService {
                    JSONObject tmp = new JSONObject();
                    JSONObject tmp = new JSONObject();
                    tmp.put("gas",gas);
                    tmp.put("gas",gas);
                    orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                    orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                    flag = true;
                }
                }
            }
            }
            DeviceHealthIndex index = new DeviceHealthIndex();
            DeviceHealthIndex index = new DeviceHealthIndex();
@ -448,5 +465,7 @@ public class OnenetService {
            index.setRecordTime(DateUtil.getStringDate());
            index.setRecordTime(DateUtil.getStringDate());
            deviceHealthIndexDao.save(index);
            deviceHealthIndexDao.save(index);
        }
        }
        return flag;
    }
    }
}
}

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

@ -248,7 +248,7 @@ public class PatientDeviceService {
            List<String> lostSN = new ArrayList<>();
            List<String> lostSN = new ArrayList<>();
            List<String> onContact = new ArrayList<>();
            List<String> onContact = new ArrayList<>();
            /*******************未失联**/
            /*******************未失联**/
            //血糖仪,血压计。30天内有数据上传,则改为未失联
/*            //血糖仪,血压计。30天内有数据上传,则改为未失联
            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and EXISTS ( " +
            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and EXISTS ( " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
@ -265,13 +265,13 @@ public class PatientDeviceService {
            devices = jdbcTemplate.queryForList(sql,String.class) ;
            devices = jdbcTemplate.queryForList(sql,String.class) ;
            if (devices.size() > 0) {
            if (devices.size() > 0) {
                onContact.addAll(devices);
                onContact.addAll(devices);
            }
            }*/
            /***************失联**/
            /***************失联**/
            //血糖仪、血压**/
            //血糖仪、血压**/
            sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " +
            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
            devices = jdbcTemplate.queryForList(sql,String.class) ;
            List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
            if (devices.size() > 0) {
            if (devices.size() > 0) {
                lostSN.addAll(devices);
                lostSN.addAll(devices);
            }
            }

+ 152 - 0
svr/svr-cloud-transfor/pom.xml

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yihu.jw</groupId>
        <artifactId>wlyy-parent-pom</artifactId>
        <version>2.0.0</version>
        <relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.jw</groupId>
    <artifactId>svr-cloud-transfor</artifactId>
    <packaging>jar</packaging>
    <version>${parent.version}</version>
    <dependencies>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
<!--            <scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>swagger-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <!-- SPRINGSIDE -->
        <dependency>
            <groupId>org.springside</groupId>
            <artifactId>springside-core</artifactId>
            <version>4.2.3-GA</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>svr-cloud-transfor</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <!-- 是否要把第三方jar加入到类构建路径 -->
                            <addClasspath>true</addClasspath>
                            <!-- 外部依赖jar包的最终位置 -->
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.yihu.SvrCloudTransforApplication</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!--拷贝依赖到jar外面的lib目录-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-lib</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!-- 依赖包输出目录,将来不打进jar包里 -->
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <excludeTransitive>false</excludeTransitive>
                            <stripVersion>false</stripVersion>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--指定配置文件,将resources打成外部resource-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- 指定配置文件目录,这样jar运行时会去找到同目录下的resources文件夹下查找 -->
                        <manifestEntries>
                            <Class-Path>resources/</Class-Path>
                        </manifestEntries>
                    </archive>
                    <!-- 打包时忽略的文件(也就是不打进jar包里的文件) -->
                    <excludes>
                        <exclude>**/*.yml</exclude>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <!-- 拷贝资源文件 外面的resource目录-->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <!-- 资源文件输出目录 -->
                            <outputDirectory>${project.build.directory}/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

+ 24 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/SvrCloudTransforApplication.java

@ -0,0 +1,24 @@
package com.yihu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
/**
 * Created by yeshijie on 2021/10/14.
 */
@SpringBootApplication
@ComponentScan("com.yihu")
public class SvrCloudTransforApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {
        SpringApplication.run(SvrCloudTransforApplication.class, args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SvrCloudTransforApplication.class);
    }
}

+ 430 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/TransforController.java

@ -0,0 +1,430 @@
package com.yihu.jw.care.controller;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.service.AqgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by yeshijie on 2021/10/14.
 */
@RestController
@RequestMapping(value = "/device",produces = "application/json")
@Api(value = "请求转发相关服务", description = "请求转发相关服务")
public class TransforController {
    private static Logger logger = LoggerFactory.getLogger(TransforController.class);
    @Autowired
    private AqgService aqgService;
    @ApiOperation("爱牵挂设备sos数据接收")
    @RequestMapping(value = "aqgsos", method = {RequestMethod.POST,RequestMethod.GET})
    public String aqgsos(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = false) String imei,
            @ApiParam(name="label_mac",required = false,value="只有主机下有绑定标贴才会发送这个参数,按哪个标贴就报哪个标贴Mac,按主机报警则不会发送",defaultValue = "")
            @RequestParam(value = "label_mac",required = false) String label_mac,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS",defaultValue = "1")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/aqgsos?imei="+imei+"&label_mac="+label_mac+"&time_begin="+time_begin;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备sos数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂设备开关机数据接收")
    @RequestMapping(value = "aqgSwitch", method = {RequestMethod.POST,RequestMethod.GET})
    public String aqgSwitch(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = false) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS",defaultValue = "1")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="remaining_power",required = false,value="剩余电量(%) ",defaultValue = "")
            @RequestParam(value = "remaining_power",required = false) String remaining_power,
            @ApiParam(name="type",required = false,value=" 开/关机类型  0开机 2普通  3低电 ",defaultValue = "")
            @RequestParam(value = "type",required = false) String type,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/aqgSwitch?imei="+imei+"&remaining_power="+remaining_power+"&time_begin="+time_begin+"&type="+type;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备开关机数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂设备消息通知数据接收")
    @RequestMapping(value = "pushdata", method = {RequestMethod.POST,RequestMethod.GET})
    public String pushdata(
            @ApiParam(name="type",required = false,value="根据type来定义给用户推送提示  type=1 SOS,type=5 设备低电, 其他类型非本机型所有",defaultValue = "")
            @RequestParam(value = "type",required = false) int type,
            @ApiParam(name="deviceid",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "deviceid",required = false) String deviceid,
            @ApiParam(name="communityid",required = false,value="机构ID",defaultValue = "1")
            @RequestParam(value = "communityid",required = false) String communityid,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/pushdata?deviceid="+deviceid+"&communityid="+communityid+"&type="+type;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备消息通知数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂位置接收")
    @RequestMapping(value = "byLocation", method = {RequestMethod.POST,RequestMethod.GET})
    public String byLocation(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS",defaultValue = "1")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="is_reply",required = false,value="是否为响应")
            @RequestParam(value = "is_reply",required = false) boolean is_reply,
            @ApiParam(name="is_track",required = false,value="是否轨迹")
            @RequestParam(value = "is_track",required = false) boolean is_track,
            @ApiParam(name="city",required = false,value="城市")
            @RequestParam(value = "city",required = false) String city,
            @ApiParam(name="address",required = false,value="地址")
            @RequestParam(value = "address",required = false) String address,
            @ApiParam(name="lon",required = false,value="经度")
            @RequestParam(value = "lon",required = false) double lon,
            @ApiParam(name="lat",required = false,value="纬度")
            @RequestParam(value = "lat",required = false) double lat,
            @ApiParam(name="type",required = false,value="类型  0:Gps定位; 1:基站定位")
            @RequestParam(value = "type",required = false) String type,
            HttpServletRequest request){
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byLocation?imei="+imei+"&is_reply="+is_reply+"&is_track="+is_track+"&city="+city
                    +"&address="+address+"&lon="+lon+"&lat="+lat+"&time_begin="+time_begin+"&type="+type;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂位置接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂心率数据接收")
    @RequestMapping(value = "byHeartRate",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byHeartRate(
            @ApiParam(name = "imei", value = "15位设备唯一序号")
            @RequestParam(value = "imei",required = true)String imei,
            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false)String time_begin,
            @ApiParam(name = "heartrate", value = "心率")
            @RequestParam(value = "heartrate",required = false)int heartrate,
            @ApiParam(name = "theshold_heartrate_h", value = "心率阈值上限")
            @RequestParam(value = "theshold_heartrate_h",required = false)int theshold_heartrate_h,
            @ApiParam(name = "theshold_heartrate_l", value = "心率阈值下限")
            @RequestParam(value = "theshold_heartrate_l",required = false)int theshold_heartrate_l,
            HttpServletRequest request){
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byHeartRate?imei="+imei+"&heartrate="+heartrate+"&time_begin="+time_begin+"&theshold_heartrate_h="+theshold_heartrate_h+"&theshold_heartrate_l="+theshold_heartrate_l;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂心率数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂血压数据接收")
    @RequestMapping(value = "byBloodPressure",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byBloodPressure(
            @ApiParam(name = "imei", value = "15位设备唯一序号", required = true)
            @RequestParam(value = "imei",required = true)String imei,
            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS", required = true)
            @RequestParam(value = "time_begin",required = false)String time_begin,
            @ApiParam(name = "dbp", value = "舒张压", required = true)
            @RequestParam(value = "dbp",required = false)int dbp,
            @ApiParam(name = "dbp_l", value = "舒张压报警下限", required = true)
            @RequestParam(value = "dbp_l",required = false)int dbp_l,
            @ApiParam(name = "sbp", value = "收缩压", required = true)
            @RequestParam(value = "sbp",required = false)int sbp,
            @ApiParam(name = "sbp_h", value = "收缩压报警上限", required = true)
            @RequestParam(value = "sbp_h",required = false)int sbp_h,
            HttpServletRequest request){
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byBloodPressure?imei="+imei+"&dbp="+dbp+"&time_begin="+time_begin+"&dbp_l="+dbp_l+"&sbp="+sbp+"&sbp_h="+sbp_h;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂血压数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂跌倒数据接收")
    @RequestMapping(value = "byFall",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byFall(
            @ApiParam(name = "imei", value = "15位设备唯一序号", required = true)
            @RequestParam(value = "imei",required = true)String imei,
            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS", required = true)
            @RequestParam(value = "time_begin",required = false)String time_begin,
            @ApiParam(name = "city", value = "城市", required = false)
            @RequestParam(value = "city",required = false)String city,
            @ApiParam(name = "address", value = "地址", required = false)
            @RequestParam(value = "address",required = false)String address,
            @ApiParam(name = "lon", value = "经度", required = false)
            @RequestParam(value = "lon",required = false)double lon,
            @ApiParam(name = "lat", value = "纬度", required = false)
            @RequestParam(value = "lat",required = false)double lat,
            @ApiParam(name = "type", value = "纬度", required = false)
            @RequestParam(value = "type",required = false)String type,
            HttpServletRequest request){
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byFall?imei="+imei+"&city="+city+"&address="+address+"&lon="+lon+"&lat="+lat+"&time_begin="+time_begin+"&type="+type;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂跌倒数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("设备步数接收")
    @RequestMapping(value = "bySteps",  method = {RequestMethod.POST,RequestMethod.GET})
    public String bySteps(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="value",required = false,value="步数")
            @RequestParam(value = "value",required = false) int value,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/bySteps?imei="+imei+"&value="+value+"&time_begin="+time_begin;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("设备步数接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /*******************************************睡眠带begin****************************************************************/
    @ApiOperation("爱牵挂-睡眠带睡眠接收")
    @RequestMapping(value = "bySleep",  method = {RequestMethod.POST,RequestMethod.GET})
    public String bySleep(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
            @RequestParam(value = "device",required = true) String device,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="heartrate",required = false,value="心率数据(离床或翻身测量失败时为0)")
            @RequestParam(value = "heartrate",required = false) String heartrate,
            @ApiParam(name="breath",required = false,value="呼吸率(离床或翻身测量失败时为0)")
            @RequestParam(value = "breath",required = false) String breath,
            @ApiParam(name="bed_status",required = false,value="在离床状态(0 离床,1 在床) ")
            @RequestParam(value = "bed_status",required = false) String bed_status,
            @ApiParam(name="turn_over",required = false,value="翻身状态(0 没翻身,1 在翻身)")
            @RequestParam(value = "turn_over",required = false)String turn_over,
            @ApiParam(name="is_warn",required = false,value="是否为离床报警(0 否 默认,1 是)")
            @RequestParam(value = "is_warn",required = false)String is_warn,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/bySleep?device="+device+"&heartrate="+heartrate+"&time_begin="+time_begin
                    +"&breath="+breath+"&bed_status="+bed_status+"&turn_over="+turn_over+"&is_warn="+is_warn;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带睡眠接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂-睡眠带睡眠报告接收")
    @RequestMapping(value = "bySleepReport",  method = {RequestMethod.POST,RequestMethod.GET})
    public String bySleep(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
            @RequestParam(value = "device",required = true) String device,
            @ApiParam(name="date",required = false,value="产生日期 YYYYMMDD")
            @RequestParam(value = "date",required = false) String date,
            @ApiParam(name="fallasleep",required = false,value="入睡时长 (分钟)")
            @RequestParam(value = "fallasleep",required = false) String fallasleep,
            @ApiParam(name="sleepTime",required = false,value="睡眠时长 (分钟)")
            @RequestParam(value = "sleepTime",required = false) String sleepTime,
            @ApiParam(name="restTime",required = false,value="休息时长 (分钟)")
            @RequestParam(value = "restTime",required = false) String restTime,
            @ApiParam(name="bed_status",required = false,value="在离床状态(0 离床,1 在床) ")
            @RequestParam(value = "bed_status",required = false) String bed_status,
            @ApiParam(name="awakeTime",required = false,value="清醒时长 (分钟)")
            @RequestParam(value = "awakeTime",required = false)String awakeTime,
            @ApiParam(name="lightTime",required = false,value="浅睡时长 (分钟)")
            @RequestParam(value = "lightTime",required = false)String lightTime,
            @ApiParam(name="remTime",required = false,value="rem时长  (分钟)")
            @RequestParam(value = "remTime",required = false)String remTime,
            @ApiParam(name="deepTime",required = false,value="深睡时长 (分钟) ")
            @RequestParam(value = "deepTime",required = false)String deepTime,
            @ApiParam(name="bucket",required = false,value="睡眠时段 ['18:00-18:21', '21:30-07:09'] ")
            @RequestParam(value = "bucket",required = false)String[] bucket,
            @ApiParam(name="avghr",required = false,value="平均心率 ")
            @RequestParam(value = "avghr",required = false)String avghr,
            @ApiParam(name="avgbr",required = false,value="平均呼吸率 ")
            @RequestParam(value = "avgbr",required = false)String avgbr,
            @ApiParam(name="awakePer",required = false,value="清醒百分比")
            @RequestParam(value = "awakePer",required = false)String awakePer,
            @ApiParam(name="remPer",required = false,value="rem百分比")
            @RequestParam(value = "remPer",required = false)String remPer,
            @ApiParam(name="lightPer",required = false,value="浅睡百分比")
            @RequestParam(value = "lightPer",required = false)String lightPer,
            @ApiParam(name="deepPer",required = false,value="深睡百分比")
            @RequestParam(value = "deepPer",required = false)String deepPer,
            @ApiParam(name="efficiency",required = false,value="睡眠效率")
            @RequestParam(value = "efficiency",required = false)String efficiency,
            @ApiParam(name="score",required = false,value="睡眠评分 <=0无睡眠数据,<60待改善,<70一般,<85良好 其他,非常好")
            @RequestParam(value = "score",required = false)String score,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/bySleep?device="+device+"&date="+date+"&fallasleep="+fallasleep+"&sleepTime="+sleepTime
                    +"&restTime="+restTime+"&bed_status="+bed_status+"&awakeTime="+awakeTime+"&lightTime="+lightTime
                    +"&remTime="+remTime+"&deepTime="+deepTime+"&bucket="+bucket+"&avghr="+avghr
                    +"&avgbr="+avgbr+"&awakePer="+awakePer+"&remPer="+remPer+"&lightPer="+lightPer
                    +"&deepPer="+deepPer+"&efficiency="+efficiency+"&score="+score;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带睡眠报告接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂-睡眠带wifi在线状态接收")
    @RequestMapping(value = "byOnlineStatus",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byOnlineStatus(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
            @RequestParam(value = "device",required = true) String device,
            @ApiParam(name="onlinestatu",required = false,value="在线状态(0不在线,1在线)")
            @RequestParam(value = "onlinestatu",required = false) String onlinestatu,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byOnlineStatus?device="+device+"&onlinestatu="+onlinestatu+"&time_begin="+time_begin;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带wifi在线状态接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /*******************************************睡眠带end****************************************************************/
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put("success", false);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 接口处理成功
     * @return
     */
    public String success() {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", 200);
            map.put("success", true);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put("success", true);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

+ 63 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/service/AqgService.java

@ -0,0 +1,63 @@
package com.yihu.jw.care.service;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.net.URLDecoder;
/**
 * Created with IntelliJ IDEA.
 * 爱牵挂转发
 * @Author: yeshijie
 * @Date: 2021/8/31
 * @Description:
 */
@Service
public class AqgService {
    private Logger logger = LoggerFactory.getLogger(AqgService.class);
    private static final RestTemplate restTemplate = new RestTemplate();
    private static final String baseUrl = "https://zhyzh.gongshu.gov.cn/device/";
//    private static final String baseUrl = "http://ehr.yihu.com/wlyy/aqg";
    public String aqgForward(String method,String body,String uri){
        String res = "";
        try {
            String url;
            if(StringUtils.isBlank(body)){
                uri = URLDecoder.decode(uri,"UTF-8");
                url = baseUrl+uri;
            }else{
                url = baseUrl+method+"?"+body;
            }
            ResponseEntity<String> responseEntity = null;
            logger.info("推送爱牵挂数据给医养项目url="+ url);
            responseEntity = restTemplate.getForEntity(url, String.class);
            res = responseEntity.getBody();
            logger.info("推送爱牵挂数据给医养项目res="+ res);
        }catch (Exception e){
            e.printStackTrace();
        }
        return res;
    }
    public String aqgForward(String url){
        String res = "";
        try {
            ResponseEntity<String> responseEntity = null;
            logger.info("推送爱牵挂数据给医养项目url="+ baseUrl+url);
            responseEntity = restTemplate.getForEntity(baseUrl+url, String.class);
            res = responseEntity.getBody();
            logger.info("推送爱牵挂数据给医养项目res="+ res);
        }catch (Exception e){
            e.printStackTrace();
        }
        return res;
    }
}

+ 97 - 0
svr/svr-cloud-transfor/src/main/resources/application.yml

@ -0,0 +1,97 @@
#通用的配置不用区分环境变量
server:
  port: 10303
spring:
  datasource:
    max-active: 200
    max-idle: 200 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 20000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 200 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  http:
    multipart:
      max-file-size: 30MB
      max-request-size: 100MB
#      location: D:/work/soft_dev/IdeaWorkSpace/wlyy2.0/svr/svr-patient/temp_file/
#      resolve-lazily: true
es:
  index:
    servicePackLog: base_service_package_log
  type:
    servicePackLog: base_service_package_log
fast-dfs:
  connect-timeout: 2 #链接超时时间
  network-timeout: 30
  charset: ISO8859-1 #编码
  http:
    tracker-http-port: 80
    anti-steal-token: no
    secret-key: FastDFS1234567890
  pool: #连接池大小
    init-size: 5
    max-size: 20
    wait-time: 500
configDefault: # 默认配置
  saasId: xmjkzl_saasId
---
spring:
  profiles: jwdev
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://172.26.0.114/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    username: root
    password: jkzlehr
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
#    client-transport-sniff: false
#    jest:
#      uris: http://172.26.0.112:9200,http://172.26.0.112:9200
#      connection-timeout: 60000 # Connection timeout in milliseconds.
#      multi-threaded: true # Enable connection requests from multiple execution threads.
base:
  url: http://172.17.110.212:10020/
  hospitalUrl: http://172.26.0.107:10022/
cloudCare:
  deviceUrl: http://172.26.0.107:9112/
---
spring:
  profiles: prod
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://172.26.0.104/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: ssgg
    password: ssgg@jkzl2019
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
#    client-transport-sniff: false
#    jest:
#      uris: http://172.26.0.112:9200,http://172.26.0.112:9200
#      connection-timeout: 60000 # Connection timeout in milliseconds.
#      multi-threaded: true # Enable connection requests from multiple execution threads.
base:
  url: http://172.17.110.212:10020/
  hospitalUrl: http://172.26.0.107:10022/
cloudCare:
  deviceUrl: http://172.26.0.107:9112/