فهرست منبع

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

liubing 3 سال پیش
والد
کامیت
247b351a63

+ 7 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java

@ -55,7 +55,10 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    @Query("select a from DevicePatientDevice a where a.categoryCode = ?1")
    @Query("select a from DevicePatientDevice a group by a.user")
    List<DevicePatientDevice> findAllGroupUser();
    @Query("select a from DevicePatientDevice a where a.categoryCode = ?1 and a.del=0 group by a.user")
    List<DevicePatientDevice> findAllByCategoryCode(String categoryCode);
    @Modifying
@ -65,6 +68,9 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findAllByUserAndCategoryCode(String user,String categoryCode);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findByUserAndCategoryCode(String user,String categoryCode);
}

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

@ -155,6 +155,8 @@ public class PadDeviceController extends BaseController {
                    return write(-1,"sn码已被使用");
                } else if (flagDevice == -4) {
                    return write(-1,"不存在该条记录");
                } else if (flagDevice == -5) {
                    return write(-1,"请勿重复绑定设备");
                }
                //注册设备地址
                deviceDetailService.registerToWlyy(device);

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

@ -142,6 +142,8 @@ public class PatientDeviceController extends BaseController {
                    return write(-1,"sn码已被使用");
                } else if (flagDevice == -4) {
                    return write(-1,"不存在该条记录");
                } else if (flagDevice == -5) {
                    return write(-1,"请勿重复绑定设备");
                }
                //注册设备地址
                deviceDetailService.registerToWlyy(device);

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

@ -248,6 +248,10 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                //V1.0.0    监控器、报警器、燃气传感器 烟雾传感器支持一个设备绑定多个居民
                //监控器 12   报警器 7  14  15
                if ("12".equals(type) || "14".equals(type) || "15".equals(type) || "7".equals(type) ) {
                    if (devicePatientDevice.getUser().equals(device.getUser())) {
                        System.out.println("居民已经绑定此sn码:"+sn);
                        return -5;
                    }
                    System.out.println("此类设备支持多绑定");
                } else {
                    System.out.println("sn码" + sn + "已被使用!");

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

@ -15,6 +15,7 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -146,59 +147,67 @@ public class DetectionPlatformService  {
    }
    public List<Map<String , Object>> getDeviceType(){
        String sql = "SELECT category_code,device_name FROM wlyy_patient_device GROUP BY category_code";
        String sql = "SELECT category_code categoryCode,name FROM dm_device GROUP BY category_code";
        return jdbcTemplate.queryForList(sql);
    }
    public JSONArray getDeviceByCondition(String categoryCode , String user){
        JSONArray jsonArray = new JSONArray();
        List<DevicePatientDevice> patientDevices = patientDeviceDao.findAll();
        List<DevicePatientDevice> patientDevices = patientDeviceDao.findAllGroupUser();
        if (StringUtils.isNotBlank(categoryCode)) {  //categoryCode != null   根据设备类型查询
            patientDevices = patientDeviceDao.findAllByCategoryCode(categoryCode);
        }
        Map<String, List<DevicePatientDevice>> byUser = patientDevices.stream().collect(Collectors.groupingBy(DevicePatientDevice::getUser));
        List<BasePatientDO> patientDOS = patientDao.findAllByDel();
        if (StringUtils.isNotBlank(user)) {
            patientDOS = patientDao.findAllByDelAndId(user);  //user != null   根据居民查询
        if (StringUtils.isNotBlank(user)) {  //categoryCode != null   根据设备类型查询
            String sql = "select a.* from wlyy_patient_device a where a.user='"+user+"' and a.del=0 LIMIT 1";
            patientDevices = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DevicePatientDevice.class));
        }
        List<BasePatientDO> patientDOS = patientDao.findAllByDel();
//        if (StringUtils.isNotBlank(user)) {
//            patientDOS = patientDao.findAllByDelAndId(user);  //user != null   根据居民查询
//        }
        Map<String, List<BasePatientDO>> byId = patientDOS.stream().collect(Collectors.groupingBy(BasePatientDO::getId));
        //首页默认根据居民展示  绑定设备的居民
        String userSql = "SELECT `user` FROM wlyy_patient_device WHERE del = 0 GROUP BY `user`";
        List<Map<String , Object>> userList = jdbcTemplate.queryForList(userSql);
        if (userList.size() > 0) {
            JSONObject userObj = new JSONObject();
            for (int i=0;i<userList.size();i++) {
//        String userSql = "SELECT `user` FROM wlyy_patient_device WHERE del = 0 GROUP BY `user`";
//        List<Map<String , Object>> userList = jdbcTemplate.queryForList(userSql);
        if (patientDevices.size() > 0) {
            for (int i=0;i<patientDevices.size();i++) {
                JSONArray arrayAll = new JSONArray();
                JSONArray array = new JSONArray();
                userObj.put("patient",userList.get(i).get("user"));
                userObj.put("patientName",byId.get(userList.get(i).get("user")).get(0).getName());
                userObj.put("patientType",byId.get(userList.get(i).get("user")).get(0).getArchiveType());
                userObj.put("latLon",byId.get(userList.get(i).get("user")).get(0).getLatLon());
                List<DevicePatientDevice> deviceList = byUser.get(userList.get(i).get("user"));
                if (deviceList.size() > 1) {    //居民绑定多台设备
                    for (int j=0;j<deviceList.size();j++) {
                        JSONObject obj = new JSONObject();
                        obj.put("deviceSn",deviceList.get(j).getDeviceSn());
                        obj.put("deviceName",deviceList.get(j).getDeviceName());
                        obj.put("categoryCode",deviceList.get(j).getCategoryCode());
                        array.add(obj);
                    }
                    userObj.put("deviceCount",deviceList.size());
                    userObj.put("deviceInfo",array);
                    arrayAll.add(userObj);
                } else {    //居民只绑定一台设备
                    for (int j=0;j<deviceList.size();j++) {
                        JSONObject obj = new JSONObject();
                        obj.put("deviceSn",deviceList.get(j).getDeviceSn());
                        obj.put("deviceName",deviceList.get(j).getDeviceName());
                        obj.put("categoryCode",deviceList.get(j).getCategoryCode());
                        array.add(obj);
                JSONObject userObj = new JSONObject();
                userObj.put("patient",patientDevices.get(i).getUser());
                userObj.put("patientName",byId.get(patientDevices.get(i).getUser()).get(0).getName());
                userObj.put("patientType",byId.get(patientDevices.get(i).getUser()).get(0).getArchiveType());
                userObj.put("latLon",byId.get(patientDevices.get(i).getUser()).get(0).getLatLon());
                List<DevicePatientDevice> deviceList = patientDeviceDao.findAllByUser(patientDevices.get(i).getUser());
                if (StringUtils.isNotBlank(categoryCode)) {
                    deviceList = patientDeviceDao.findAllByUserAndCategoryCode(patientDevices.get(i).getUser(),categoryCode);
                }
                if (deviceList != null) {
                    if (deviceList.size() > 1) {    //居民绑定多台设备
                        for (int j=0;j<deviceList.size();j++) {
                            JSONObject obj = new JSONObject();
                            obj.put("deviceSn",deviceList.get(j).getDeviceSn());
                            obj.put("deviceName",deviceList.get(j).getDeviceName());
                            obj.put("categoryCode",deviceList.get(j).getCategoryCode());
                            array.add(obj);
                        }
                        userObj.put("deviceCount",deviceList.size());
                        userObj.put("deviceInfo",array);
                        arrayAll.add(userObj);
                    } else {    //居民只绑定一台设备
                        for (int j=0;j<deviceList.size();j++) {
                            JSONObject obj = new JSONObject();
                            obj.put("deviceSn",deviceList.get(j).getDeviceSn());
                            obj.put("deviceName",deviceList.get(j).getDeviceName());
                            obj.put("categoryCode",deviceList.get(j).getCategoryCode());
                            array.add(obj);
                        }
                        userObj.put("deviceCount",deviceList.size());
                        userObj.put("deviceInfo",array);
                        arrayAll.add(userObj);
                    }
                    userObj.put("deviceCount",deviceList.size());
                    userObj.put("deviceInfo",array);
                    arrayAll.add(userObj);
                    jsonArray.add(arrayAll);
                }
                jsonArray.add(arrayAll);
            }
        } else {
            return jsonArray;