Forráskód Böngészése

Merge branch 'dev' of shikejing/wlyy2.0 into dev

shikejing 3 éve
szülő
commit
a2de3d451a

+ 74 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepPlan.java

@ -0,0 +1,74 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/***
 * @ClassName: BaseSleepPlan
 * @Description:    睡眠带监测计划
 * @Auther: shi kejing
 * @Date: 2021/8/23 17:17
 */
@Entity
@Table(name="base_sleep_plan")
public class BaseSleepPlan extends IdEntity {
    private String patient;
    private String deviceSn;
    private String getUpTime;
    private String napTime;
    private String nightRestTime;
    private Date createTime;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getGetUpTime() {
        return getUpTime;
    }
    public void setGetUpTime(String getUpTime) {
        this.getUpTime = getUpTime;
    }
    public String getNapTime() {
        return napTime;
    }
    public void setNapTime(String napTime) {
        this.napTime = napTime;
    }
    public String getNightRestTime() {
        return nightRestTime;
    }
    public void setNightRestTime(String nightRestTime) {
        this.nightRestTime = nightRestTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 16 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseSleepPlanDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseSleepDeviceReport;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/***
 * @ClassName: BaseSleepPlanDao
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/23 17:20
 */
public interface BaseSleepPlanDao extends PagingAndSortingRepository<BaseSleepPlan,Long>,
        JpaSpecificationExecutor<BaseSleepPlan> {
}

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

@ -13,14 +13,17 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -104,10 +107,20 @@ public class PadDeviceController extends BaseController {
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{     \"deviceId\":\"3\",     \"deviceName\":\"血压计-优瑞恩\",     \"deviceSn\":\"7052169111\",     \"categoryCode\":\"7\",     \"userType\":\"-1\", \"sosAddress\":\"福建省厦门市思明区望海路55号之1\" }")
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{     \"deviceId\":\"3\",     \"deviceName\":\"血压计-优瑞恩\",     \"deviceSn\":\"7052169111\",     \"categoryCode\":\"7\",     \"userType\":\"-1\", \"sosAddress\":\"福建省厦门市思明区望海路55号之1\" }")
                             @RequestParam(value = "json", required = true) String json,
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patientCode,
                             @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 = "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"}
                             ) {
                             ) {
        try {
        try {
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            BaseSleepPlan sleepPlan = new BaseSleepPlan();
            if (StringUtils.isNotBlank(sleepPlanJson)){
                sleepPlan = objectMapper.readValue(sleepPlanJson,BaseSleepPlan.class);
                sleepPlan.setPatient(patientCode);
            }
            // 设置患者标识
            // 设置患者标识
            device.setUser(patientCode);
            device.setUser(patientCode);
            //患者和设备是否首绑
            //患者和设备是否首绑
@ -123,7 +136,7 @@ public class PadDeviceController extends BaseController {
            device.setAgentName(doctor.getName());
            device.setAgentName(doctor.getName());
            String sn = device.getDeviceSn();
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
            synchronized (sn.intern()){
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device,safe_area,fenceNO,name,sleepPlan);
                if (flagDevice == false){
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                    return write(-1,"请填写投放地址");
                }
                }

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

@ -7,6 +7,7 @@ import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.ResponseContant;
@ -75,9 +76,19 @@ public class PatientDeviceController extends BaseController {
    @ApiOperation("设备保存接口")
    @ApiOperation("设备保存接口")
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"7052169111\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
    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) {
                             @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 {
        try {
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            BaseSleepPlan sleepPlan = new BaseSleepPlan();
            if (StringUtils.isNotBlank(sleepPlanJson)){
                sleepPlan = objectMapper.readValue(sleepPlanJson,BaseSleepPlan.class);
                sleepPlan.setPatient(getRepUID());
            }
            // 设置患者标识
            // 设置患者标识
            device.setUser(getRepUID());
            device.setUser(getRepUID());
            //患者和设备是否首绑
            //患者和设备是否首绑
@ -96,7 +107,7 @@ public class PatientDeviceController extends BaseController {
            String sn = device.getDeviceSn();
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
            synchronized (sn.intern()){
//                patientDeviceService.saveDevice(device);
//                patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device,safe_area,fenceNO,name,sleepPlan);
                if (flagDevice == false){
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                    return write(-1,"请填写投放地址");
                }
                }

+ 13 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java

@ -29,9 +29,9 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private DetectionPlatformService platformService;
    private DetectionPlatformService platformService;
    @GetMapping(value = "statisticsTotalAmount")
    @ApiOperation(value = "统计总数")
    public PageEnvelop statisticsTotalAmount(
    @GetMapping(value = "security")
    @ApiOperation(value = "体征监测/安防监护")
    public PageEnvelop security(
            @ApiParam(name="page",value = "page") @RequestParam(required = true) int page,
            @ApiParam(name="page",value = "page") @RequestParam(required = true) int page,
            @ApiParam(name="size",value = "size") @RequestParam(required = true) int size,
            @ApiParam(name="size",value = "size") @RequestParam(required = true) int size,
            @ApiParam(name="type",value = "type=1(健康监测)   type=2(安防检测)") @RequestParam(required = true) int type) {
            @ApiParam(name="type",value = "type=1(健康监测)   type=2(安防检测)") @RequestParam(required = true) int type) {
@ -42,6 +42,15 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        }
        }
    }
    }
    @GetMapping(value = "company")
    @ApiOperation(value = "设备入驻")
    public ObjEnvelop getDeviceCompany(){
        try {
            JSONObject o = platformService.getDeviceComapny();
            return success(o);
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
}
}

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

@ -4,6 +4,7 @@ package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.BaseSleepPlanDao;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
@ -14,6 +15,7 @@ import com.yihu.jw.care.util.MyJdbcTemplate;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
@ -87,6 +89,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private HttpClientUtil httpClientUtil;
    private HttpClientUtil httpClientUtil;
    @Autowired
    @Autowired
    private YsDeviceService ysDeviceService;
    private YsDeviceService ysDeviceService;
    @Autowired
    private BaseSleepPlanDao sleepPlanDao;
    @Autowired
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
    WeiXinAccessTokenUtils tokenUtils;
@ -136,13 +140,14 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    /**
    /**
     * 保存患者设备
     * 保存患者设备
     */
     */
    public boolean saveDevice(DevicePatientDevice devicePatientDevice) throws Exception {
    public boolean saveDevice(DevicePatientDevice devicePatientDevice, String safe_area, Integer fenceNO, String name, BaseSleepPlan sleepPlan) throws Exception {
        //判断sn码是否被使用
        //判断sn码是否被使用
        String sn = devicePatientDevice.getDeviceSn();
        String sn = devicePatientDevice.getDeviceSn();
        String type = devicePatientDevice.getCategoryCode();
        String type = devicePatientDevice.getCategoryCode();
        Long deviceId = devicePatientDevice.getDeviceId();
        Long deviceId = devicePatientDevice.getDeviceId();
        String userType = devicePatientDevice.getUserType();
        String userType = devicePatientDevice.getUserType();
        String sosAddress = null;
        String sosAddress = null;
        String url ="";
        if (userType == null) {
        if (userType == null) {
            userType = "-1";
            userType = "-1";
            devicePatientDevice.setUserType("-1");
            devicePatientDevice.setUserType("-1");
@ -177,6 +182,12 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        if (needVerify) {
        if (needVerify) {
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            if (device != null && !device.getId().equals(devicePatientDevice.getId()) && device.getDel() == 0) {
            if (device != null && !device.getId().equals(devicePatientDevice.getId()) && device.getDel() == 0) {
                //V1.0.0    监控器、报警器、燃气传感器 烟雾传感器支持一个设备绑定多个居民
                //监控器 12   报警器 7  14  15
                if ("12".equals(type) || "14".equals(type) || "15".equals(type) || "7".equals(type) ) {
                    System.out.println("此类设备支持多绑定");
                }
                throw new Exception("sn码" + sn + "已被使用!");
                throw new Exception("sn码" + sn + "已被使用!");
            }
            }
        }
        }
@ -186,7 +197,46 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
        BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
        devicePatientDevice.setUserIdcard(patient.getIdcard());
        devicePatientDevice.setUserIdcard(patient.getIdcard());
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(checkDeviceSn(sn)){
        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 = "请完善睡眠时间规划";
                    throw new Exception(message);
                }
                sleepPlanDao.save(sleepPlan);
            }
            patientDeviceDao.save(devicePatientDevice);
            patientDeviceDao.save(devicePatientDevice);
        }else {
        }else {
            String message = "设备不存在";
            String message = "设备不存在";

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

@ -1,5 +1,6 @@
package com.yihu.jw.care.service.statistics;
package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
@ -45,8 +46,25 @@ public class DetectionPlatformService  {
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
        }
        }
    }
    public JSONObject getDeviceComapny(){
        JSONObject object = new JSONObject();
        String deviceTypeSum = "SELECT COUNT(1) deviceTypeSum FROM dm_device where del = 1 GROUP BY brands";
        List<Map<String , Object>> deviceList = jdbcTemplate.queryForList(deviceTypeSum);
        if (deviceList.size() > 0) {
            object.put("deviceTypeCount",deviceList.size()); //设备品牌数量
        } else {
            object.put("deviceTypeCount",0);
        }
        String manufacturerSql = "";
        List<Map<String , Object>> manufacturerList = jdbcTemplate.queryForList(manufacturerSql);
        if (manufacturerList.size() > 0) {
            object.put("manufacturerCount",manufacturerList.size());
        } else {
            object.put("manufacturerCount",0);
        }
        return object;
    }
    }
}
}