Selaa lähdekoodia

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

Shi Kejing 3 vuotta sitten
vanhempi
commit
e6baec7859

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

@ -1346,9 +1346,6 @@ CREATE TABLE `base_hvdevice_sos_log` (
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='烟感气感设备报警日志记录表';
ALTER table `base`.`wlyy_devices` add column `device_type` tinyint(2) DEFAULT NULL COMMENT '设备种类 0健康设备 1安防设备'
-- 20210819
alter table wlyy_devices add COLUMN device_type TINYINT(2) default null COMMENT '设备种类 0健康设备 1安防设备';
alter table wlyy_patient_device add COLUMN device_type TINYINT(2) default null COMMENT '设备种类 0健康设备 1安防设备';

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepNightRecord.java

@ -16,7 +16,7 @@ public class BaseSleepNightRecord extends IdEntity {
    private String patient ;
    private String deviceSn;
    private String outTime;//离床时长 秒
    private Integer status;//是否回床 0否,1是
    private Integer status;//是否回床 -1否 0否,1是
    private String day;//监控日期
    private Date createTime;// 创建日期 即起床时间
    private Date updateTime;// 更新日期

+ 4 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepPlanDetail.java

@ -18,13 +18,13 @@ public class BaseSleepPlanDetail extends IdEntity {
    private String  patient;
    private String  deviceSn;
    private String  day; //睡眠监控日期
    private Integer  upStatus; //起床状态 0未起床 1起床
    private Integer  upStatus; //起床状态 0起床 1未起床
    private Date  upTime; //起床时间
    private Integer  siestaStatus; //午睡状态 0未入床 1已入床
    private Integer  siestaStatus; //午睡状态 0未上床 1已上床
    private Date  siestaTimeBegin; //午睡开始时间
    private Date  siestaTimeEnd;  //午睡结束时间
    private String  siestaLong; //午睡时长 单位秒
    private Integer  inStatus; //睡觉状态 0未入床 1已入床,2无午睡计划
    private Integer  inStatus; //睡觉状态 0未上床 1已上床
    private Date  inTimeBegin; //夜眠开始时间
    private Date  inTimeEnd; //夜眠结束时间
    private Date createTime;
@ -32,7 +32,7 @@ public class BaseSleepPlanDetail extends IdEntity {
    private List<BaseSleepNightRecord> sleepNightRecordList;
    private String heartRate;
    private String breath;
    private Integer bedStatus;
    private Integer bedStatus; //0未在床 1在床
    public String getPatient() {
        return patient;

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

@ -412,10 +412,12 @@ public class PatientDeviceController extends BaseController {
    public String getPatientDeviceDetail(@ApiParam(name="patient")
                                         @RequestParam(value = "patient")String patient,
                                         @ApiParam(name="deviceSN")
                                         @RequestParam(value = "deviceSN")String deviceSn){
                                         @RequestParam(value = "deviceSN")String deviceSn,
                                         @ApiParam(name="day",value = "yyyy-mm-dd")
                                         @RequestParam(value = "day",required = false)String day){
        try {
            JSONObject result = patientDeviceService.getPatientDeviceDetail(patient,deviceSn);
            JSONObject result = patientDeviceService.getPatientDeviceDetail(patient,deviceSn,day);
            if (result.getInt(ResponseContant.resultFlag)==ResponseContant.success){
                return write(200,"获取成功","data", JSON.parseObject(result.getString(ResponseContant.resultMsg)));
            }else {

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -178,7 +178,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "servicePackageByTopicType")
    @ApiOperation(value = "根据服务专题获取服务项目")
    @ApiOperation(value = "根据服务专题获取服务项目--存在绑定设备的专题")
    public ObjEnvelop servicePackageByTopicType (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient,

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

@ -884,7 +884,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
     * @param deviceSn 设备sn码
     * @return
     */
    public JSONObject getPatientDeviceDetail(String patient,String deviceSn) throws Exception {
    public JSONObject getPatientDeviceDetail(String patient,String deviceSn,String day) throws Exception {
        JSONObject result = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patient);
        if (null==patientDO){
@ -903,7 +903,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            }else {
                String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime " +
                        "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
                        "where 1=1 and  pd.del=0 and pd.device_sn ='"+deviceSn+"' ";
                        "where 1=1 and  pd.del=0 and pd.device_sn ='"+deviceSn+"' group by pd.user";
                Map<String,Object> devInfo = jdbcTemplate.queryForMap(sql);
                devInfo.put("patient",patient);
                devInfo.put("patientName",patientDO.getName());
@ -935,12 +935,15 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                        }
                        break;
                    case "13"://睡眠带 获取当天睡眠详情
                        securityMonitoringOrderService.preventOutOfBed(devInfoObj,patient,false);
                        securityMonitoringOrderService.preventOutOfBed(devInfoObj,patient,false,day);
                        break;
                    case "14"://气感报警器 当天监测记录以及最新浓度
                        List<Map<String,Object>> listTmp = gasConcentration(patient,DateUtil.getStringDateShort());
                        if (StringUtils.isBlank(day)){
                            day = DateUtil.getStringDateShort();
                        }
                        List<Map<String,Object>> listTmp = gasConcentration(patient,day);
                        devInfoObj.put("monitorInfo",listTmp);
                        devInfoObj.put("day",DateUtil.getStringDateShort());
                        devInfoObj.put("day",day);
                        securityMonitoringOrderService.preventGasLeakage(devInfoObj,patient,false);
                        break;
                    case "15"://烟感报警器 获取最新浓度
@ -990,7 +993,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    public JSONObject getHealthIndex(JSONObject result,String deviceSn,String patient,Integer page,Integer pageSize){
        String sqlCount = "select count(id) from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
                " and del=1 ";
        String sql = "select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) sign_status from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
        String sql = "select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) record_date from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
                " and del=1 order by record_date desc limit "+page*pageSize+","+pageSize;
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);

+ 3 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -172,8 +172,9 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
                res.put("capAssRecordDO",recordDO);
            }
        }
        JSONObject tmp = res.getJSONObject("patient");
        tmp.put("deviceType",deviceService.getPatientDeviceCategoryCode(patientId));
        res.put("patient",tmp);
        return res;
    }

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

@ -460,14 +460,14 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                if (StringUtils.isBlank(doc.getDoctorLat()) || StringUtils.isBlank(doc.getDoctorLon())) {
                    continue;
                }
                double distanceTmp = countDistance.getDistance(Double.parseDouble(orderDO.getServeLat()),Double.parseDouble(orderDO.getServeLon()),Double.parseDouble(doc.getDoctorLat()),Double.parseDouble(doc.getDoctorLon()));
                //double distanceTmp = countDistance.getDistance(Double.parseDouble(orderDO.getServeLat()),Double.parseDouble(orderDO.getServeLon()),Double.parseDouble(doc.getDoctorLat()),Double.parseDouble(doc.getDoctorLon()));
                otherDoctorDistanceObj = new JSONObject();
                otherDoctorDistanceObj.put("doctor",doc.getId());
                otherDoctorDistanceObj.put("doctorName",doc.getName());
                otherDoctorDistanceObj.put("doctorAddress",doc.getDoctorLocateAddress());
                otherDoctorDistanceObj.put("doctorLon",doc.getDoctorLon());
                otherDoctorDistanceObj.put("doctorLat",doc.getDoctorLat());
                otherDoctorDistanceObj.put("distance",distanceTmp);//两点距离
                otherDoctorDistanceObj.put("distance",null);//两点距离
                otherDoctorDistance.add(otherDoctorDistanceObj);
            }
            emergencyOrderVO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
@ -1238,7 +1238,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        result.put("monitorInfo",null);
        String sql = " select dict.code,count(ord.id) total from base_system_dict_entry dict LEFT JOIN base_security_monitoring_order ord " +
                " on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status="+SecurityMonitoringOrderDO.Status.apply.getType()+" where dict.dict_code='service_item' " +
                "and dict.remark='security'  GROUP BY dict.code ";
                "and dict.remark='security' and ord.patient='"+patient+"' GROUP BY dict.code ";
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
        for (Map<String,Object>tmp:sqlResult){
            switch (tmp.get("code").toString()){
@ -1336,7 +1336,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
    }
    public void preventOutOfBed(JSONObject result,String patient,boolean video){
    public void preventOutOfBed(JSONObject result,String patient,boolean video,String dayTime){
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"13");
        if (devicePatientDeviceDos.size()==0){}
        else {
@ -1349,7 +1349,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                    result.put("sleepStatus",true);
                    JSONObject tmp = objInfo.getJSONObject(0);
                    JSONObject sleepInfo = new JSONObject();
                    String dayTime = getSleepMonitoringDay(new Date(),patient);
                    if (StringUtils.isBlank(dayTime)){
                        dayTime = getSleepMonitoringDay(new Date(),patient);
                    }
                    List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByPatientAndDay(patient,dayTime);
                    if (planDetails.size()>0){
                        BaseSleepPlanDetail planDetail =  planDetails.get(0);
@ -1487,7 +1489,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            monitorInfo(result, patient);
        }
        if ("preventOutOfBed".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventOutOfBed(result, patient,true);
            preventOutOfBed(result, patient,true,null);
        }
        if ("preventFire".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventFire(result, patient,true);

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -579,6 +579,23 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                " and pack.del=1 and  item.topic_item='"+topicType+"' and re.sign_id in (\n" +
                "select rd.id from base_service_package_sign_record rd  where rd.patient='"+patient+"' and rd.status=1) GROUP BY item.code; ";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        Iterator<Map<String, Object>> iterator = result.iterator();
        while (iterator.hasNext()){
            Map<String, Object> map = iterator.next();
            String item = map.get("serverItem").toString();
            sql = " select count(pd.device_sn) from dm_device dd INNER JOIN wlyy_patient_device " +
                    "pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model" +
                    " and pd.device_sn = wd.device_code \n" +
                    "where 1=1 and  pd.del=0  and  pd.`user`='"+patient+"'  and dd.service_topic " +
                    "like '%"+item+"%'   ";
            Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
            if (count>0){
            }else {
                iterator.remove();
            }
        }
        return result;
    }

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

@ -606,10 +606,10 @@ public class DeviceService {
                        planDetail.setDeviceSn(device);
                        /***起床***/
                        Long timeDiffer = timeDate.getTime() - bedUp.getTime();
                        if(DateUtil.isInArea(timeDate,bedUpBegin,bedUpEnd)){//起床时间内
                        if(DateUtil.isInArea(timeDate,bedUpBegin,SiestaBegin)){//起床时间内
                            if ("0".equals(bed_status)){//起床
                                if (null==planDetail.getUpStatus()){
                                    planDetail.setUpStatus(1);
                                if (null==planDetail.getUpStatus()||1==planDetail.getUpStatus()){
                                    planDetail.setUpStatus(0);
                                    planDetail.setUpTime(timeDate);
                                }
                            }
@ -617,7 +617,7 @@ public class DeviceService {
                        else if (3600*upLongWarn*1000<timeDiffer){//距离起床超过三个小时还在床
                            if ("1".equals(bed_status)){//还在床
                                if (null==planDetail.getUpStatus()) {
                                    planDetail.setUpStatus(0);
                                    planDetail.setUpStatus(1);
                                    planDetail.setBedStatus(1);
                                    planDetail.setBreath(breath);
                                    planDetail.setHeartRate(heartrate);
@ -629,7 +629,7 @@ public class DeviceService {
                        /***午睡***/
                        if(needSiesta&&DateUtil.isInArea(timeDate,SiestaBegin,bedIn)){//午睡时段
                            if ("0".equals(bed_status)){
                                if (null==planDetail.getSiestaStatus()){//超时未午睡午睡
                                if (null==planDetail.getSiestaStatus()){//超时未午睡
                                    timeDiffer = timeDate.getTime() - SiestaTime.getTime();
                                    if (timeDiffer>3600*siestaLongWarn*1000){
                                        planDetail.setSiestaStatus(0);
@ -646,7 +646,7 @@ public class DeviceService {
                            }
                            if ("1".equals(bed_status)){
                                if (null==planDetail.getSiestaStatus()){
                                if (null==planDetail.getSiestaStatus()||0==planDetail.getSiestaStatus()){
                                    planDetail.setSiestaStatus(1);
                                    planDetail.setSiestaTimeBegin(timeDate);
                                }
@ -655,6 +655,7 @@ public class DeviceService {
                                    if(3600*siestaLongWarn*1000<timeDiffer){//午睡超时未起床
                                        if (planDetail.getSiestaStatus()==1){
                                            planDetail.setBedStatus(1);
                                            planDetail.setSiestaTimeEnd(timeDate);//设置临时结束时间但不计算时长 避免重复发起工单
                                            planDetail.setBreath(breath);
                                            planDetail.setHeartRate(heartrate);
                                            outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"午睡超时未起床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
@ -669,13 +670,16 @@ public class DeviceService {
                        if (timeDiffer>0&&timeDate.after(bedBegin)){ //起夜记录
                            BaseSleepNightRecord record = new BaseSleepNightRecord();
                            if ("1".equals(bed_status)){
                                if (null==planDetail.getInStatus()){
                                if (null==planDetail.getInStatus()||0==planDetail.getInStatus()){
                                    planDetail.setInStatus(1);
                                    planDetail.setInTimeBegin(timeDate);
                                }
                                else if (1==planDetail.getInStatus()){//在床记录起夜时长
                                    List<BaseSleepNightRecord> records = nightRecord.findBySnStaPaTime(device,patient,0,bedBegin,dayTime);
                                    if (records.size()>0){//
                                    if (records.size()==0){
                                        records = nightRecord.findBySnStaPaTime(device,patient,-1,bedBegin,dayTime);//超时未归的起夜记录
                                    }
                                    if (records.size()>0){//已经晚休了 但是存在起夜未归
                                        record = records.get(0);
                                        record.setStatus(1);
                                        record.setUpdateTime(timeDate);
@ -709,7 +713,7 @@ public class DeviceService {
                                    }else {//是否触发工单
                                        record = records.get(0);
                                        timeDiffer = timeDate.getTime()-record.getCreateTime().getTime();
                                        if (timeDiffer>3600*nightLongWarn*1000){//超过2未回床小时 触发工单
                                        if (timeDiffer>3600*nightLongWarn*1000&&0==records.get(0).getStatus()){//超过2未回床小时 触发工单
                                            planDetail.setSleepNightRecordList(records);
                                            planDetail.setBedStatus(0);
                                            outBedOrder(records.get(0),timeDate,devicePatientDeviceDos.get(0),patient,device,"起夜超时未回床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
@ -812,9 +816,6 @@ public class DeviceService {
            }
            if (null!=record){
                record.setStatus(-1);
                record.setUpdateTime(time_date);
                Long timeDiffer = (time_date.getTime() - record.getCreateTime().getTime())/1000;
                record.setOutTime(timeDiffer+"");
                nightRecord.save(record);
            }
    }

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

@ -168,11 +168,15 @@ public class YsDeviceService {
                String  url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
                Map map = new HashMap<String, String>();
                map = new HashMap();
                String sql ="select DISTINCT item.org_code,item.org_name\n" +
                        " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
                        "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id \tand  item.`code`='preventFall'  and item.service_package_id = pack.id \n" +
                String hospital = "";
                String sql ="select DISTINCT pack.org_code,pack.org_name " +
                        " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack " +
                        "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id and  item.`code`='"+topicItem+"'  and item.service_package_id = pack.id " +
                        "  and pack.del=1";
                List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                if(sqlResult.size()>0){
                    hospital = sqlResult.get(0).get("org_code")+"";
                }
                String serveDesc = "";
                String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict'";

+ 39 - 14
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/ArtemisPostTest.java

@ -121,8 +121,8 @@ public class ArtemisPostTest {
		//回调URL	postUrl	String	是
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("msgType", msgType);
		jsonBody.put("postUrl", "http://ehr.yihu.com/wlyy/aqg/hvdevice/messageNotification");
		//http://ehr.yihu.com/wlyy/aqg/device/byOnlineStatus
		jsonBody.put("postUrl", "https://zhyzh.gongshu.gov.cn/device/hvdevice/messageNotification");
		//https://zhyzh.gongshu.gov.cn/device
		//http://ehr.yihu.com/wlyy/aqg
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
@ -132,11 +132,11 @@ public class ArtemisPostTest {
	/**
	 * 修改订阅
	 */
	public void subscription_update(){
	public static void subscription_update(String msgType){
		String url = "/api/firepro/v1/subscription/update";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 3);
		jsonBody.put("msgType", msgType);
		jsonBody.put("postUrl", "https://zhyzh.gongshu.gov.cn/device/hvdevice/messageNotification");
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
@ -213,6 +213,20 @@ public class ArtemisPostTest {
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * type 1烟感 2气感
	 * @param deviceName
	 * @param deviceSerial
	 * @param type
     */
	public static void addDevice(String deviceName,String deviceSerial,int type){
		if(type ==1){
			addDevice(deviceName,deviceSerial,"800022","600002");
		}else{
			addDevice(deviceName,deviceSerial,"800056","600006");
		}
	}
	/**
	 * 查询订阅
	 */
@ -237,14 +251,25 @@ public class ArtemisPostTest {
//		callPostImgStringApi();
//		getDevice();
		getMonitor();
//		subscription_info("980001");
//		subscription_info("980002");
//		subscription_info("980003");
//		subscription_info("980004");
//		subscription_info("980005");
//		subscription_info("980006");
//		subscription_info("980007");
//		subscription_info("980008");
//		getMonitor();
//		subscription_update("980001");
		subscription_update("980002");
		subscription_update("980003");
		subscription_update("980004");
		subscription_update("980005");
		subscription_update("980006");
		subscription_update("980007");
		subscription_update("980008");
//		addDevice("可燃气体探测器","867070036127251",2);
//		addDevice("可燃气体探测器","867070036223175",2);
//		addDevice("可燃气体探测器","867070036131121",2);
//		addDevice("可燃气体探测器","867070036312564",2);
//
//		addDevice("火灾探测报警器","863409057775073",1);
//		addDevice("火灾探测报警器","863409057781162",1);
//		addDevice("火灾探测报警器","863409057781261",1);
//		addDevice("火灾探测报警器","863409057781113",1);
	}
}

+ 1 - 1
svr/svr-cloud-device/src/main/resources/application.yml

@ -325,7 +325,7 @@ wechat:
  flag: false #演示环境  true走Mysql数据库  false走Oracle
im:
  im_list_get: http://127.0.0.0:3000/
  im_list_get: http://127.0.0.1:3000/
  data_base_name: im_internet_hospital
es:
  pwflag: 1 # 1需要密码,2不需要密码