Kaynağa Gözat

代码修改

liubing 3 yıl önce
ebeveyn
işleme
38fdb0889b

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

@ -151,4 +151,5 @@ public class DoctorDeviceController extends BaseController {
		}
		}
	}
	}
}
}

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

@ -308,4 +308,25 @@ public class PadDeviceController extends BaseController {
        }
        }
    }
    }
    @RequestMapping(value ="addPatientSosContacts",method = RequestMethod.POST)
    @ApiOperation(value = "设备绑定添加联系人")
    public String addPatientSosContacts(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                           @RequestParam(value = "patient", required = true) String patient,
                                        @ApiParam(name = "jsonStr", value = "patient", defaultValue = "patient")
                                        @RequestParam(value = "jsonStr", required = true) String jsonStr){
        try {
            JSONObject result = contactsService.addPatientSosContacts(patient,jsonStr);
            if (ResponseContant.success == result.getInteger(ResponseContant.resultFlag)){
                return success("添加成功");
            }
            else {
                return error(-1,result.getString(ResponseContant.resultMsg));
            }
        }catch (Exception e){
            return errorResult(e);
        }
    }
}
}

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

@ -429,7 +429,7 @@ public class PatientDeviceController extends BaseController {
        }
        }
    }
    }
    @ApiOperation("获取设备详情信息")
    @ApiOperation("获取设备详情数据 --设备可多人绑定查询数据时与patient无关")
    @RequestMapping(value = "getPatientDeviceData",method = RequestMethod.GET)
    @RequestMapping(value = "getPatientDeviceData",method = RequestMethod.GET)
    public String getPatientDeviceData(@ApiParam(name="patient")
    public String getPatientDeviceData(@ApiParam(name="patient")
                                       @RequestParam(value = "patient")String patient,
                                       @RequestParam(value = "patient")String patient,

+ 45 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java

@ -290,6 +290,51 @@ public class ContactsService {
    }
    }
    /**
     *设备绑定添加居民紧急联系人
     */
    public JSONObject addPatientSosContacts(String patient,String jsonStr) throws Exception {
        JSONObject result = new JSONObject();
        List<PatientSosContactsDO> list = sosContactsDao.findByPatientOrderByUpdateTimeDesc(patient);
        JSONArray jsonArray = JSONArray.parseArray(jsonStr);
        for (int i=0;i<jsonArray.size();i++){
            list = sosContactsDao.findByPatientAndDel(patient,1);
            JSONObject obj = jsonArray.getJSONObject(i);
            String num = obj.getString("num");
            String name = obj.getString("name");
            String relation = obj.getString("relation");
            Integer seqid=0;
            if (list.size()>=2){
                List<String> sosContacts =list.stream().map(PatientSosContactsDO::getSosPhone).collect(Collectors.toList());
                if (!sosContacts.contains(num)){
                    result.put(ResponseContant.resultFlag,ResponseContant.fail);
                    result.put(ResponseContant.resultMsg,"该用户紧急联系人已上限");
                    return result;
                }
            }
            if (list.size()>0){
                seqid = list.get(0).getPhoneSeqid();
            }
            PatientSosContactsDO contactsDO = sosContactsDao.findByPatientAndSosPhone(patient,num);
            if(null==contactsDO){
                contactsDO = new PatientSosContactsDO();
                contactsDO.setPhoneSeqid(1==seqid?2:1);
            }
            contactsDO.setDel(1);
            contactsDO.setPatient(patient);
            contactsDO.setSosName(name);
            contactsDO.setSosPhone(num);
            contactsDO.setRelation(Integer.parseInt(relation));
            contactsDO.setSuccessFlag(0);
            sosContactsDao.save(contactsDO);
        }
        result.put(ResponseContant.resultFlag,ResponseContant.success);
        result.put(ResponseContant.resultMsg,"修改成功");
        return result;
    }
    public void delSosNumber(List<Map<String,Object>> sims,String patient,String[] numTmp) {
    public void delSosNumber(List<Map<String,Object>> sims,String patient,String[] numTmp) {
        String delSuccess = "";//白名单删除号码
        String delSuccess = "";//白名单删除号码
        for (Map<String,Object> simTmp : sims) {
        for (Map<String,Object> simTmp : sims) {

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

@ -61,6 +61,7 @@ import javax.annotation.PostConstruct;
import java.text.MessageFormat;
import java.text.MessageFormat;
import java.util.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Component
@Component
@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
@ -247,7 +248,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                //V1.0.0    监控器、报警器、燃气传感器 烟雾传感器支持一个设备绑定多个居民
                //V1.0.0    监控器、报警器、燃气传感器 烟雾传感器支持一个设备绑定多个居民
                //监控器 12   报警器 7  14  15
                //监控器 12   报警器 7  14  15
                if ("12".equals(type) || "14".equals(type) || "15".equals(type) || "7".equals(type) ) {
                if ("12".equals(type) || "14".equals(type) || "15".equals(type)) {
                    if (devicePatientDevice.getUser().equals(device.getUser())) {
                    if (devicePatientDevice.getUser().equals(device.getUser())) {
                        System.out.println("居民已经绑定此sn码:"+sn);
                        System.out.println("居民已经绑定此sn码:"+sn);
                        return -5;
                        return -5;
@ -902,12 +903,11 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"居民未绑定该设备");
                result.put(ResponseContant.resultMsg,"居民未绑定该设备");
            }else {
            }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+"' group by pd.user";
                String sql = "select dd.photo,GROUP_CONCAT( p.name) as patientName,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 base_patient p on p.id = pd.user \n" +
                        "where 1=1 and  pd.del=0 and pd.device_sn ='"+deviceSn+"' group by pd.device_sn";
                Map<String,Object> devInfo = jdbcTemplate.queryForMap(sql);
                Map<String,Object> devInfo = jdbcTemplate.queryForMap(sql);
                devInfo.put("patient",patient);
                devInfo.put("patient",patient);
                devInfo.put("patientName",patientDO.getName());
                devInfo.put("sosContactsDOS",new ArrayList<>());
                devInfo.put("sosContactsDOS",new ArrayList<>());
                if ("4".equals(device.getCategoryCode())||"7".equals(device.getCategoryCode())){
                if ("4".equals(device.getCategoryCode())||"7".equals(device.getCategoryCode())){
                    devInfo.put("sosContactsDOS",contactsService.getPatientSosContacts(patient));
                    devInfo.put("sosContactsDOS",contactsService.getPatientSosContacts(patient));
@ -975,13 +975,13 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            }else{
            }else{
                switch (device.getCategoryCode()){
                switch (device.getCategoryCode()){
                    case "1"://血压设备
                    case "1"://血压设备
                        result = getHealthIndex(result,deviceSn,patient,page,pageSize);
                        result = getHealthIndex(result,deviceSn,null,page,pageSize);
                        break;
                        break;
                    case "2"://血糖设备
                    case "2"://血糖设备
                        result = getHealthIndex(result,deviceSn,patient,page,pageSize);
                        result = getHealthIndex(result,deviceSn,null,page,pageSize);
                        break;
                        break;
                    default://安防设备
                    default://安防设备
                        result  = getEmeWarn(result,deviceSn,patient,page,pageSize);
                        result  = getEmeWarn(result,deviceSn,null,page,pageSize);
                        break;
                        break;
                }
                }
            }
            }
@ -1024,15 +1024,23 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                " and ord.patient='"+patient+"' " +
                " and ord.patient='"+patient+"' " +
                "UNION All " +
                "UNION All " +
                "select count(ord.id)  as total from base_security_monitoring_order ord  where ord.device_sn='"+deviceSn+"' " +
                "select count(ord.id)  as total from base_security_monitoring_order ord  where ord.device_sn='"+deviceSn+"' " +
                " and ord.patient='"+patient+"' )A ";
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
                " {{patient}} )A ";
        String sql = "select '20' as OrderType,ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
        String sql = "select '20' as OrderType,ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
                "'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_emergency_assistance_order ord  where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"' " +
                "from base_emergency_assistance_order ord  where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"' " +
                "UNION " +
                "UNION " +
                "select  '22' as 'OrderType',ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
                "select  '22' as 'OrderType',ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
                "ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order ord " +
                "ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order ord " +
                " where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"'  order by create_time desc limit "+page*pageSize+","+pageSize;
                " where ord.device_sn='"+deviceSn+"' {{patient}}  order by create_time desc limit "+page*pageSize+","+pageSize;
        if (StringUtils.isNotBlank(patient)){
            sqlCount = sqlCount.replace("{{patient}}","and ord.patient='"+patient+"' ");
            sql = sql.replace("{{patient}}","and ord.patient='"+patient+"' ");
        }else {
            sqlCount = sqlCount.replace("{{patient}}"," ");
            sql = sql.replace("{{patient}}"," ");
        }
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        result.put("total",count);
        result.put("total",count);
        result.put("page",page+1);
        result.put("page",page+1);
@ -1202,7 +1210,9 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
     * @param time_begin YYYYMMDD 日期
     * @param time_begin YYYYMMDD 日期
     * @return
     * @return
     */
     */
    public com.alibaba.fastjson.JSONObject getX1Locations(String deviceSn,String time_begin){
    public JSONArray getX1Locations(String deviceSn,String time_begin){
        JSONArray result = new JSONArray();
        String url = AqgConfig.X1_locations+"?device="+deviceSn+"&depth="+1+"&rows_per_page="+300;
        String url = AqgConfig.X1_locations+"?device="+deviceSn+"&depth="+1+"&rows_per_page="+300;
        if (StringUtils.isNotBlank(time_begin)){
        if (StringUtils.isNotBlank(time_begin)){
@ -1212,8 +1222,20 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        headers.put("Accept", MediaType.APPLICATION_JSON.toString());
        headers.put("Accept", MediaType.APPLICATION_JSON.toString());
        headers.put("Cookie", getCookie());
        headers.put("Cookie", getCookie());
        String  responseStr = httpClientUtil.get(url,"utf-8",headers);
        String  responseStr = httpClientUtil.get(url,"utf-8",headers);
        com.alibaba.fastjson.JSONObject result = JSON.parseObject(responseStr);
        com.alibaba.fastjson.JSONObject resObj = JSON.parseObject(responseStr);
        if (resObj.getBooleanValue("success")){
            com.alibaba.fastjson.JSONArray arr = resObj.getJSONArray("objs");
            arr.sort(Comparator.comparing(obj -> ((JSONObject) obj).getLong("created_at")));
            for (int i=0;i<arr.size();i++){
                com.alibaba.fastjson.JSONObject obj = arr.getJSONObject(i);
                com.alibaba.fastjson.JSONArray pointArr = obj.getJSONObject("point").getJSONArray("coordinates");
                Double lon = pointArr.getDouble(0);
                Double lat = pointArr.getDouble(1);
                com.alibaba.fastjson.JSONObject pointJson = gpsUtil.gcj02_To_Bd09(lat,lon);
                result.put(pointJson);
            }
        }
        return result;
        return result;
    }
    }