Преглед на файлове

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

liubing преди 3 години
родител
ревизия
25e1f6427e

+ 4 - 0
svr/svr-cloud-care/pom.xml

@ -219,6 +219,10 @@
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.his.hesb</groupId>
                    <artifactId>mqSdk</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>

+ 1 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java

@ -117,9 +117,6 @@ public class PadDeviceController extends BaseController {
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patientCode,
                             @ApiParam(name = "doctorCode", value = "管理员code") @RequestParam(value = "doctorCode", required = false) String doctorCode,
                             @ApiParam(name = "safe_area",value = "lon1,lat1;lon2,lat2; 5个坐标 形成一个封闭区域  A;B;C;D;A ")  @RequestParam(value = "safe_area",required = false)String safe_area,
                             @ApiParam(name = "name",value = "安全区名称") @RequestParam(value = "name",required = false)String name,
                             @ApiParam(name = "fenceNO",value = "安全区编号") @RequestParam(value = "fenceNO",required = false)Integer fenceNO,
                             @ApiParam(name = "sleepPlanJson", value = "睡眠计划json") @RequestParam(value = "sleepPlanJson", required = false) String sleepPlanJson
                             //{"deviceSn": "7052169111","getUpTime": "07:00","napTime": "13:00","nightRestTime": "21:30"}
                             ) {
@ -145,7 +142,7 @@ public class PadDeviceController extends BaseController {
            device.setAgentName(doctor.getName());
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                Boolean flagDevice = patientDeviceService.saveDevice(device,safe_area,fenceNO,name,sleepPlan);
                Boolean flagDevice = patientDeviceService.saveDevice(device,sleepPlan);
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }

+ 14 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -68,6 +68,19 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("燃气浓度")
    @RequestMapping(value = "gasConcentration", method = RequestMethod.GET)
    public String gasConcentration(@ApiParam(name = "patientId", value = "居民id", defaultValue = "808080eb7917a3be017918a979380055")
                             @RequestParam(value = "patientId", required = true) String patientId,
                                   @ApiParam(name = "date", value = "日期", defaultValue = "2021-08-24")
                                   @RequestParam(value = "date", required = true) String date){
        try {
            return write(200,"获取成功","data",patientDeviceService.gasConcentration(patientId,date));
        } catch (Exception ex) {
            return errorResult(ex);
        }
    }
    @ApiOperation("环境信息")
    @RequestMapping(value = "envMessage", method = RequestMethod.GET)
    public String envMessage(@ApiParam(name = "patientId", value = "居民id", defaultValue = "1")
@ -87,9 +100,6 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"7052169111\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "safe_area",value = "lon1,lat1;lon2,lat2; 5个坐标 形成一个封闭区域  A;B;C;D;A ") @RequestParam(value = "safe_area",required = false)String safe_area,
                             @ApiParam(name = "name",value = "安全区名称") @RequestParam(value = "name",required = false)String name,
                             @ApiParam(name = "fenceNO",value = "安全区编号") @RequestParam(value = "fenceNO",required = false)Integer fenceNO,
                             @ApiParam(name = "sleepPlanJson", value = "睡眠计划json") @RequestParam(value = "sleepPlanJson", required = false) String sleepPlanJson){
        //{"deviceSn": "7052169111","getUpTime": "07:00","napTime": "13:00","nightRestTime": "21:30"})
        try {
@ -117,7 +127,7 @@ public class PatientDeviceController extends BaseController {
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
//                patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device,safe_area,fenceNO,name,sleepPlan);
                Boolean flagDevice = patientDeviceService.saveDevice(device,sleepPlan);
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }

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

@ -163,6 +163,19 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return jsonObject;
    }
    /**
     * 燃气浓度
     * @param patient
     */
    public List<Map<String,Object>> gasConcentration(String patient,String date){
        String sql = "SELECT r.value,r.create_time from wlyy_patient_device pd,base_device_health_index r " +
                "WHERE pd.device_sn = r.device_sn and pd.`user` = '"+patient+"' ";
        sql += " and pd.category_code='14' and r.create_time>'"+date+" 00:00:00' and r.create_time<'"+date+" 23:59:59'  ORDER BY r.create_time desc ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    /**
     * 验证sn码 先调总部接口 未注册才查询本地数据库,如果也没有才不能绑定
@ -183,7 +196,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    /**
     * 保存患者设备
     */
    public boolean saveDevice(DevicePatientDevice devicePatientDevice, String safe_area, Integer fenceNO, String name, BaseSleepPlan sleepPlan) throws Exception {
    public boolean saveDevice(DevicePatientDevice devicePatientDevice, BaseSleepPlan sleepPlan) throws Exception {
        //判断sn码是否被使用
        String sn = devicePatientDevice.getDeviceSn();
        String type = devicePatientDevice.getCategoryCode();
@ -243,35 +256,6 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(checkDeviceSn(sn)){
            //V1.0.0 添加手表的时候需要设置围栏
            if ("4".equals(type)){
                Device device = deviceDao.findOne(new Long (type));
                if (device!=null){
                    if ("X1".equals(device.getModel())){
                        url = MessageFormat.format(AqgConfig.X1fence_area, sn,fenceNO);
                    }
                }
                param.add("name", name);
                param.add("freq", "1"); //"0,触发一天;1,每日触发 "
                param.add("enable","1");
                param.add("time_begin", "0");
                param.add("time_end", "86400");
                param.add("safe_area", safe_area);
                HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie());
                com.alibaba.fastjson.JSONObject object = response.getBody();
                if (object.get("success").equals("true")){
                    System.out.println("围栏地址添加成功");
                } else {
                    System.out.println("添加失败");
                    String message = "围栏设置失败";
                    throw new Exception(message);
                }
            }
            if ("16".equals(type)){ //智能拐杖
            }
            if ("13".equals(type)){ //睡眠带
                if (StringUtils.isBlank(sleepPlan.getGetUpTime()) || StringUtils.isBlank(sleepPlan.getNightRestTime())) {
                    String message = "请完善睡眠时间规划";

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

@ -18,32 +18,31 @@ import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.care.device.BasePatientOutBed;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.emergency.EmergencyOrderVO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.*;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.EntityUtils;
import com.yihu.mysql.query.BaseJpaService;
import jdk.management.resource.internal.inst.FileOutputStreamRMHooks;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -1217,145 +1216,170 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    public JSONObject patientSignTopicInfo(JSONObject result,String patient,String topicItem){
        if (null==result){
            result = new JSONObject();
    public void preventLost(JSONObject result,String patient){
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
        if (devicePatientDeviceDos.size()==0){
            return;
        }
        if ("preventLost".equals(topicItem)||StringUtils.isBlank(topicItem)){
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
            if (devicePatientDeviceDos.size()==0){}
            else {
                DevicePatientDevice device = devicePatientDeviceDos.get(0);
                result.put("deviceSn",device.getDeviceSn());
                try {
                    JSONObject response= patientDeviceService.getAqgDeviceInfo(device.getDeviceSn());
                    if (response!=null){
                        //定位信息
                        if (response.containsKey("last_location")&&response.get("last_location")!=null){
                            JSONObject locationTmp = response.getJSONObject("last_location");
                            Double lon = locationTmp.getJSONArray("coordinates").getDouble(0);
                            Double lat = locationTmp.getJSONArray("coordinates").getDouble(1);
                            JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon);
                            tmp.put("city",response.getString("last_city"));
                            tmp.put("province",response.getString("last_province"));
                            tmp.put("address",response.getString("last_address"));
                            result.put("location",tmp);
                        }
                        //围栏信息
                        if (response.containsKey("fences")&&response.get("fences")!=null){
                            JSONArray fencesArr = response.getJSONArray("fences");
                            JSONArray fencesEnables = new JSONArray();
                            for (int i=0;i<fencesArr.size();i++){
                                JSONObject tmp = fencesArr.getJSONObject(i);
                                if (tmp.getBooleanValue("enable")){//围栏生效
                                    JSONObject fenceTmp = new JSONObject();
                                    fenceTmp.put("fenceNO",tmp.getInteger("seqid").toString());
                                    fenceTmp.put("name",tmp.getString("name"));
                                    JSONArray fenceLocationTmp = tmp.getJSONObject("safe_area").getJSONArray("coordinates").getJSONArray(0);
                                    JSONArray fenceLocation = new JSONArray();
                                    for (int j=0;j<fenceLocationTmp.size();j++){
                                        Double lon = fenceLocationTmp.getJSONArray(j).getDouble(0);
                                        Double lat = fenceLocationTmp.getJSONArray(j).getDouble(1);
                                        JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
                                        fenceLocation.add(positionTmp);
                                    }
                                    fenceTmp.put("location",fenceLocation);
                                    fenceTmp.put("inFenceStatus",countDistance.isInPolygon(result.getJSONObject("location").getDouble("lon"),result.getJSONObject("location").getDouble("lat"),fenceLocation));
                                    fencesEnables.add(fenceTmp);
                                }
                            }
                            if (fencesEnables.size()>0){
                                result.put("fences",fencesEnables);
        DevicePatientDevice device = devicePatientDeviceDos.get(0);
        result.put("deviceSn",device.getDeviceSn());
        try {
            JSONObject response= patientDeviceService.getAqgDeviceInfo(device.getDeviceSn());
            if (response!=null){
                //定位信息
                if (response.containsKey("last_location")&&response.get("last_location")!=null){
                    JSONObject locationTmp = response.getJSONObject("last_location");
                    Double lon = locationTmp.getJSONArray("coordinates").getDouble(0);
                    Double lat = locationTmp.getJSONArray("coordinates").getDouble(1);
                    JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon);
                    tmp.put("city",response.getString("last_city"));
                    tmp.put("province",response.getString("last_province"));
                    tmp.put("address",response.getString("last_address"));
                    result.put("location",tmp);
                }
                //围栏信息
                if (response.containsKey("fences")&&response.get("fences")!=null){
                    JSONArray fencesArr = response.getJSONArray("fences");
                    JSONArray fencesEnables = new JSONArray();
                    for (int i=0;i<fencesArr.size();i++){
                        JSONObject tmp = fencesArr.getJSONObject(i);
                        if (tmp.getBooleanValue("enable")){//围栏生效
                            JSONObject fenceTmp = new JSONObject();
                            fenceTmp.put("fenceNO",tmp.getInteger("seqid").toString());
                            fenceTmp.put("name",tmp.getString("name"));
                            JSONArray fenceLocationTmp = tmp.getJSONObject("safe_area").getJSONArray("coordinates").getJSONArray(0);
                            JSONArray fenceLocation = new JSONArray();
                            for (int j=0;j<fenceLocationTmp.size();j++){
                                Double lon = fenceLocationTmp.getJSONArray(j).getDouble(0);
                                Double lat = fenceLocationTmp.getJSONArray(j).getDouble(1);
                                JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
                                fenceLocation.add(positionTmp);
                            }
                            fenceTmp.put("location",fenceLocation);
                            fenceTmp.put("inFenceStatus",countDistance.isInPolygon(result.getJSONObject("location").getDouble("lon"),result.getJSONObject("location").getDouble("lat"),fenceLocation));
                            fencesEnables.add(fenceTmp);
                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                    result.put("location",null);
                }
            }
        }
        if ("preventFall".equals(topicItem)||StringUtils.isBlank(topicItem)){
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
            if (devicePatientDeviceDos.size()==0){}
            else{
                try {
                    DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
                    JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,deviceDo.getDeviceSn(),1,null);
                    result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
                    result.put("patientAddress",deviceDo.getSosAddress());
                    if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                        result.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
                    }
                    else {
                        result.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
                    if (fencesEnables.size()>0){
                        result.put("fences",fencesEnables);
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            result.put("location",null);
        }
        if ("preventOutOfBed".equals(topicItem)||StringUtils.isBlank(topicItem)){
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"13");
            if (devicePatientDeviceDos.size()==0){}
            else {
                DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
                JSONObject deviceInfo =  patientDeviceService.getSleepDeviceInfo(deviceDo.getDeviceSn());
                if(deviceInfo.getBooleanValue("success")){
                    result.put("patientAddress",deviceDo.getSosAddress());
                    JSONArray objInfo = deviceInfo.getJSONArray("objs");
                    if (objInfo.size()>0){
                        result.put("sleepStatus",true);
                        JSONObject tmp = objInfo.getJSONObject(0);
                        JSONObject sleepInfo = new JSONObject();
                        sleepInfo.put("online",tmp.getBooleanValue("online"));
                        sleepInfo.put("onbed",tmp.getBooleanValue("onbed"));
                        sleepInfo.put("heartrate",tmp.getString("heartrate"));
                        sleepInfo.put("breathrate",tmp.getString("breathrate"));
                        BasePatientOutBed outBed = outBedDao.findByPatientAndDeviceSnAndStatus(patient,deviceDo.getDeviceSn(),0);
                        if (null!=outBed){
                            String outBedTime = "";
                            Date date = new Date();
                            long millisecondsDiff = date.getTime() - outBed.getCreateTime().getTime();
                            long minutesDiff = millisecondsDiff / TimeUnit.MINUTES.toMillis(1L);
                            long hoursDiff = millisecondsDiff / TimeUnit.HOURS.toMillis(1L);
                            long minuteFieldDiff = minutesDiff - TimeUnit.HOURS.toMinutes(hoursDiff);
                            if (hoursDiff > 0L) {
                                outBedTime += String.format("%d小时", hoursDiff);
                            }
                            if (minuteFieldDiff>0){
                                outBedTime +=String.format("%d分钟", minuteFieldDiff);
                            }
                            sleepInfo.put("outBedTime",outBedTime);
                        }else {
                            sleepInfo.put("outBedTime","无");
    }
    public void preventOutOfBed(JSONObject result,String patient){
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"13");
        if (devicePatientDeviceDos.size()==0){}
        else {
            DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
            JSONObject deviceInfo =  patientDeviceService.getSleepDeviceInfo(deviceDo.getDeviceSn());
            if(deviceInfo.getBooleanValue("success")){
                result.put("patientAddress",deviceDo.getSosAddress());
                JSONArray objInfo = deviceInfo.getJSONArray("objs");
                if (objInfo.size()>0){
                    result.put("sleepStatus",true);
                    JSONObject tmp = objInfo.getJSONObject(0);
                    JSONObject sleepInfo = new JSONObject();
                    sleepInfo.put("online",tmp.getBooleanValue("online"));
                    sleepInfo.put("onbed",tmp.getBooleanValue("onbed"));
                    sleepInfo.put("heartrate",tmp.getString("heartrate"));
                    sleepInfo.put("breathrate",tmp.getString("breathrate"));
                    BasePatientOutBed outBed = outBedDao.findByPatientAndDeviceSnAndStatus(patient,deviceDo.getDeviceSn(),0);
                    if (null!=outBed){
                        String outBedTime = "";
                        Date date = new Date();
                        long millisecondsDiff = date.getTime() - outBed.getCreateTime().getTime();
                        long minutesDiff = millisecondsDiff / TimeUnit.MINUTES.toMillis(1L);
                        long hoursDiff = millisecondsDiff / TimeUnit.HOURS.toMillis(1L);
                        long minuteFieldDiff = minutesDiff - TimeUnit.HOURS.toMinutes(hoursDiff);
                        if (hoursDiff > 0L) {
                            outBedTime += String.format("%d小时", hoursDiff);
                        }
                        if (minuteFieldDiff>0){
                            outBedTime +=String.format("%d分钟", minuteFieldDiff);
                        }
                        result.put("sleepInfo",sleepInfo);
                        sleepInfo.put("outBedTime",outBedTime);
                    }else {
                        sleepInfo.put("outBedTime","无");
                    }
                }else {
                    result.put("sleepStatus",false);
                    result.put("sleepInfo","获取睡眠带数据失败");
                    result.put("sleepInfo",sleepInfo);
                }
            }else {
                result.put("sleepStatus",false);
                result.put("sleepInfo","获取睡眠带数据失败");
            }
            //监控
            devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
            if (devicePatientDeviceDos.size()==0){}
            else{
                try {
                    DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
                    JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,deviceDo.getDeviceSn(),1,null);
                    result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
                    result.put("patientAddress",deviceDo.getSosAddress());
                    if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                        result.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
                    }
                    else {
                        result.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
        }
        monitorInfo(result, patient);
    }
    public void preventFire(JSONObject result,String patient){
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"15");
        if (devicePatientDeviceDos.size()==0){}
        else {
            DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
        }
        monitorInfo(result, patient);
    }
    public void preventGasLeakage(JSONObject result,String patient){
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"14");
        if (devicePatientDeviceDos.size()==0){}
        else {
            DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
        }
        monitorInfo(result, patient);
    }
    public void monitorInfo(JSONObject result,String patient){
        //监控
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
        if (devicePatientDeviceDos.size()==0){
            return;
        }
        try {
            DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
            JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,deviceDo.getDeviceSn(),1,null);
            result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
            result.put("patientAddress",deviceDo.getSosAddress());
            if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                result.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
            }
            else {
                result.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public JSONObject patientSignTopicInfo(JSONObject result,String patient,String topicItem){
        if (null==result){
            result = new JSONObject();
        }
        if ("preventLost".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventLost(result, patient);
        }
        if ("preventFall".equals(topicItem)||StringUtils.isBlank(topicItem)){
            monitorInfo(result, patient);
        }
        if ("preventOutOfBed".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventOutOfBed(result, patient);
        }
        if ("preventFire".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventFire(result, patient);
        }
        if ("preventGasLeakage".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventGasLeakage(result, patient);
        }
        return result;
    }

+ 50 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java

@ -2,12 +2,14 @@ package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.restmodel.web.PageEnvelop;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;
@ -50,21 +52,66 @@ public class DetectionPlatformService  {
    public JSONObject getDeviceComapny(){
        JSONObject object = new JSONObject();
        String deviceTypeSum = "SELECT COUNT(1) deviceTypeSum FROM dm_device where del = 1 GROUP BY brands";
        String deviceTypeSum = "SELECT * FROM wlyy_devices WHERE device_name IS NOT NULL AND device_name != '' GROUP BY device_name";
        List<Map<String , Object>> deviceList = jdbcTemplate.queryForList(deviceTypeSum);
        if (deviceList.size() > 0) {
            object.put("deviceTypeCount",deviceList.size()); //设备品牌数量
        } else {
            object.put("deviceTypeCount",0);
        }
        String manufacturerSql = "";
        String manufacturerSql = "SELECT * FROM wlyy_devices WHERE manufacturer IS NOT NULL AND manufacturer != '' GROUP BY manufacturer ;";
        List<Map<String , Object>> manufacturerList = jdbcTemplate.queryForList(manufacturerSql);
        if (manufacturerList.size() > 0) {
            object.put("manufacturerCount",manufacturerList.size());
            object.put("manufacturerCount",manufacturerList.size()); //入驻厂商数量
        } else {
            object.put("manufacturerCount",0);
        }
        String securitySql = "SELECT allCount,isUse,(allCount - isUse) inventory FROM \n" +
                "(SELECT COUNT(1) allCount FROM wlyy_devices WHERE device_type = 1) allCount,\n" +
                "(SELECT COUNT(1) isUse FROM wlyy_devices WHERE device_type = 1 AND is_binding = 1) isUse";
        List<Map<String , Object>> securityList = jdbcTemplate.queryForList(securitySql);
        if (securityList.size() > 0) {
            object.put("securityAllCount",securityList.get(0).get("allCount")); //安防设备总量
            object.put("securityIsUseCount",securityList.get(0).get("isUse"));//安防设备使用中数量
            object.put("securityInventoryCount",securityList.get(0).get("inventory"));//安防设备库存量
        } else {
            object.put("securityAllCount",0); //安防设备总量
            object.put("securityIsUseCount",0);//安防设备使用中数量
            object.put("securityInventoryCount",0);//安防设备库存量
        }
        String healthSql = "SELECT allCount,isUse,(allCount - isUse) inventory FROM \n" +
                "(SELECT COUNT(1) allCount FROM wlyy_devices WHERE device_type = 0) allCount,\n" +
                "(SELECT COUNT(1) isUse FROM wlyy_devices WHERE device_type = 0 AND is_binding = 1) isUse";
        List<Map<String , Object>> healthList = jdbcTemplate.queryForList(healthSql);
        if (healthList.size() > 0) {
            object.put("healthAllCount",securityList.get(0).get("allCount"));//健康设备总量
            object.put("healthIsUseCount",securityList.get(0).get("isUse"));//健康设备使用中数量
            object.put("healthInventoryCount",securityList.get(0).get("inventory"));//健康设备库存量
        } else {
            object.put("healthAllCount",0);//健康设备总量
            object.put("healthIsUseCount",0);//健康设备使用中数量
            object.put("healthInventoryCount",0);//健康设备库存量
        }
        //物联率
        object.put("lawOfIOT",getRange( ((Integer)securityList.get(0).get("isUse") + (Integer) healthList.get(0).get("isUser")),( (Integer) securityList.get(0).get("allCount") + (Integer) healthList.get(0).get("allCount") ) ));
        object.put("isUseAllIot",((Integer)securityList.get(0).get("isUse") + (Integer) healthList.get(0).get("isUser")));//已发放设备
        object.put("allIot",(Integer) securityList.get(0).get("allCount") + (Integer) healthList.get(0).get("allCount"));//总设备
        return object;
    }
    public String getRange(int first, int second) {
        if (second == 0 && first > 0) {
            //如果分母为0 分子不为0 返回100%
            return "100%";
        } else if (second == 0 && first == 0) {
            //如果分母为0 分子为0 返回0%
            return "0%";
        }
        float size = (float) (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        String filesize = df.format(size);
        return filesize + "%";
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name:  svr-cloud-care-ysj
    name:  svr-cloud-care
  cloud:
    config:
      failFast: true