Ver código fonte

更新需求

yangjingjing 5 anos atrás
pai
commit
ba81b58ce4

+ 1 - 0
febs-common/febs-common-core/src/main/java/cc/mrbird/febs/common/core/utils/FebsUtil.java

@@ -189,6 +189,7 @@ public class FebsUtil {
         return data;
     }
 
+
     /**
      * 获取HttpServletRequest
      *

+ 92 - 92
febs-server/gbd-demp-data-exchange/src/main/java/com/gbd/demp/data/exchange/task/LiveDataTask.java

@@ -27,7 +27,7 @@ import java.util.concurrent.Future;
  * 实时数据异步处理
  * 1.告警规则判断
  * 2.存储数据到数据库
- * 3.如有告警,推送告警并且存入告警事件表
+ * 3.如有告警,推送告警并且存入告警事件表,8小时内同一设备(传感器)只生成一条告警信息,如果告警级别升级,则再次推送
  */
 @Slf4j
 @Component
@@ -51,7 +51,7 @@ public class LiveDataTask {
 
 
     //获取异步结果
-    //处理案件平台数据
+    //处理安监平台数据
     @Transactional(rollbackFor = Exception.class)
     public Future<String> alarmTask(String liveData) {
         try {
@@ -76,29 +76,29 @@ public class LiveDataTask {
             String endTime = deviceInfo.getWorkTimeTo();
             SimpleDateFormat sf = new SimpleDateFormat("HH:mm:ss");
             String now = sf.format(new Date());//获取当前时间
-            //如果未设置时间或者当前时间在工作范围内
-            if (CommonUtils.isEffectiveDate(sf.parse(now), sf.parse(startTime), sf.parse(endTime))) {
-                for (int i = 0; i < len; i++) {
-                    String seq = oldData[12 + 6 * i] + oldData[13 + 6 * i];// 设备类型+编号(传感器编号)
-                    String str = oldData[14 + 6 * i];// 03 第一位0正数 1负数;第二位表示有几位小数
-                    String num = str.substring(0, 1);
-                    String num2 = str.substring(1, 2);
-                    String value = oldData[15 + 6 * i] + oldData[16 + 6 * i] + oldData[17 + 6 * i];// 对应参数值 00 00 68
-                    double val = Double.parseDouble(value.substring(0, (value.length() - Integer.parseInt(num2))) + "."
-                            + value.substring((value.length() - Integer.parseInt(num2)), value.length()));
-                    if ("1".equals(num)) {
-                        val = -val;
-                    }
-                    LiveData data = new LiveData();
-                    data.setDeviceId(deviceId);
-                    data.setReportTime(reportTime);
-                    data.setSensorId(seq);
-                    data.setDataValue(val);
-                    HistoryData data1 = new HistoryData();
-                    data1.setDeviceId(deviceId);
-                    data1.setReportTime(reportTime);
-                    data1.setSensorId(seq);
-                    data1.setDataValue(val);
+            for (int i = 0; i < len; i++) {
+                String seq = oldData[12 + 6 * i] + oldData[13 + 6 * i];// 设备类型+编号(传感器编号)
+                String str = oldData[14 + 6 * i];// 03 第一位0正数 1负数;第二位表示有几位小数
+                String num = str.substring(0, 1);
+                String num2 = str.substring(1, 2);
+                String value = oldData[15 + 6 * i] + oldData[16 + 6 * i] + oldData[17 + 6 * i];// 对应参数值 00 00 68
+                double val = Double.parseDouble(value.substring(0, (value.length() - Integer.parseInt(num2))) + "."
+                        + value.substring((value.length() - Integer.parseInt(num2)), value.length()));
+                if ("1".equals(num)) {
+                    val = -val;
+                }
+                LiveData data = new LiveData();
+                data.setDeviceId(deviceId);
+                data.setReportTime(reportTime);
+                data.setSensorId(seq);
+                data.setDataValue(val);
+                HistoryData data1 = new HistoryData();
+                data1.setDeviceId(deviceId);
+                data1.setReportTime(reportTime);
+                data1.setSensorId(seq);
+                data1.setDataValue(val);
+                //如果当前时间在工作范围内,判断异常以及推送。如果不在工作时间段,则标记数据
+                if (CommonUtils.isEffectiveDate(sf.parse(now), sf.parse(startTime), sf.parse(endTime))) {
                     List<DeviceThreshold> thresholds = deviceThresholdService.getThresholdsBySensorID(seq);//根据传感器编号获取传感器阈值信息
                     SensorInfo sensorInfo = sensorInfoService.getBySensorId(seq, deviceId);//获取传感器信息
                     if (thresholds.size() > 0) {
@@ -222,14 +222,14 @@ public class LiveDataTask {
                             data.setStatus(4);
                             data1.setStatus(4);
                         }
-                    } else {
-                        data.setStatus(0);
-                        data1.setStatus(0);
                     }
-                    liveDataService.acceptLiveData(data);
-                    historyDataService.save(data1);
-
+                } else {
+                    data.setStatus(5);
+                    data1.setStatus(5);
                 }
+                liveDataService.acceptLiveData(data);
+                historyDataService.save(data1);
+
             }
         } catch (Exception e) {
             log.error(e.getMessage());
@@ -332,47 +332,47 @@ public class LiveDataTask {
 //                    if (count > 0) {
 //                        for (int i = 0; i < count; i++) {//循环插入数据库
 //                            String seq = "m" + (i + 1);//传感器编号
-                            String seq = "m1";//传感器编号
-                            double val = Double.valueOf(deviceData.get(seq) + "");
-                            LiveData data = new LiveData();
-                            data.setDeviceId(deviceId);
-                            data.setReportTime(reportTime);
-                            data.setSensorId(seq);
-                            data.setDataValue(val);
-                            HistoryData data1 = new HistoryData();
-                            data1.setDeviceId(deviceId);
-                            data1.setReportTime(reportTime);
-                            data1.setSensorId(seq);
-                            data1.setDataValue(val);
+                    String seq = "m1";//传感器编号
+                    double val = Double.valueOf(deviceData.get(seq) + "");
+                    LiveData data = new LiveData();
+                    data.setDeviceId(deviceId);
+                    data.setReportTime(reportTime);
+                    data.setSensorId(seq);
+                    data.setDataValue(val);
+                    HistoryData data1 = new HistoryData();
+                    data1.setDeviceId(deviceId);
+                    data1.setReportTime(reportTime);
+                    data1.setSensorId(seq);
+                    data1.setDataValue(val);
 //                        String dateTime = (String) liveData.get("CreateDataTime");
-                            List<DeviceThreshold> thresholds = deviceThresholdService.getThresholdsBySensorID(seq);//根据传感器编号获取传感器阈值信息
-                            SensorInfo sensorInfo = sensorInfoService.getBySensorId(seq, deviceId);//获取传感器信息
-                            if (thresholds.size() > 0) {
-                                //code:0
-                                DeviceThreshold thresholds_0 = thresholds.get(0);
-                                double low_0 = thresholds_0.getLowValue();
-                                double high_0 = thresholds_0.getHighValue();
-                                //code:1
-                                DeviceThreshold thresholds_1 = thresholds.get(1);
-                                double low_1 = thresholds_1.getLowValue();
-                                double high_1 = thresholds_1.getHighValue();
-                                //code:2
-                                DeviceThreshold thresholds_2 = thresholds.get(2);
-                                double low_2 = thresholds_2.getLowValue();
-                                double high_2 = thresholds_2.getHighValue();
-                                //code:3
-                                DeviceThreshold thresholds_3 = thresholds.get(3);
-                                double low_3 = thresholds_3.getLowValue();
-                                double high_3 = thresholds_3.getHighValue();
-                                //code:4
-                                DeviceThreshold thresholds_4 = thresholds.get(4);
-                                double low_4 = thresholds_4.getLowValue();
-                                double high_4 = thresholds_4.getHighValue();
-                                if (val >= low_0 && val <= high_0) {//状态0
-                                    data.setStatus(0);
-                                    data1.setStatus(0);
-                                }
-                                if ((val < low_0 && val >= low_1) || (val > high_0 && val <= high_1)) {//状态1
+                    List<DeviceThreshold> thresholds = deviceThresholdService.getThresholdsBySensorID(seq);//根据传感器编号获取传感器阈值信息
+                    SensorInfo sensorInfo = sensorInfoService.getBySensorId(seq, deviceId);//获取传感器信息
+                    if (thresholds.size() > 0) {
+                        //code:0
+                        DeviceThreshold thresholds_0 = thresholds.get(0);
+                        double low_0 = thresholds_0.getLowValue();
+                        double high_0 = thresholds_0.getHighValue();
+                        //code:1
+                        DeviceThreshold thresholds_1 = thresholds.get(1);
+                        double low_1 = thresholds_1.getLowValue();
+                        double high_1 = thresholds_1.getHighValue();
+                        //code:2
+                        DeviceThreshold thresholds_2 = thresholds.get(2);
+                        double low_2 = thresholds_2.getLowValue();
+                        double high_2 = thresholds_2.getHighValue();
+                        //code:3
+                        DeviceThreshold thresholds_3 = thresholds.get(3);
+                        double low_3 = thresholds_3.getLowValue();
+                        double high_3 = thresholds_3.getHighValue();
+                        //code:4
+                        DeviceThreshold thresholds_4 = thresholds.get(4);
+                        double low_4 = thresholds_4.getLowValue();
+                        double high_4 = thresholds_4.getHighValue();
+                        if (val >= low_0 && val <= high_0) {//状态0
+                            data.setStatus(0);
+                            data1.setStatus(0);
+                        }
+                        if ((val < low_0 && val >= low_1) || (val > high_0 && val <= high_1)) {//状态1
 //                                ServerAlarm alarm = new ServerAlarm();
 //                                alarm.setToken(token);
 //                                alarm.setCompanyId(deviceInfo.getCompanyId());
@@ -393,10 +393,10 @@ public class LiveDataTask {
 //                                event.setIsreport(1);
 //                                event.setThirdPartyId(thirdPartyId);
 //                                alarmEventService.save(event);
-                                    data.setStatus(1);
-                                    data1.setStatus(1);
-                                }
-                                if ((val < low_1 && val >= low_2) || (val > high_1 && val <= high_2)) {//状态2
+                            data.setStatus(1);
+                            data1.setStatus(1);
+                        }
+                        if ((val < low_1 && val >= low_2) || (val > high_1 && val <= high_2)) {//状态2
 //                                ServerAlarm alarm = new ServerAlarm();
 //                                alarm.setToken(token);
 //                                alarm.setCompanyId(deviceInfo.getCompanyId());
@@ -417,10 +417,10 @@ public class LiveDataTask {
 //                                event.setIsreport(1);
 //                                event.setThirdPartyId(thirdPartyId);
 //                                alarmEventService.save(event);
-                                    data.setStatus(2);
-                                    data1.setStatus(2);
-                                }
-                                if ((val < low_2 && val >= low_3) || (val > high_2 && val <= high_3)) {//状态3
+                            data.setStatus(2);
+                            data1.setStatus(2);
+                        }
+                        if ((val < low_2 && val >= low_3) || (val > high_2 && val <= high_3)) {//状态3
 //                                ServerAlarm alarm = new ServerAlarm();
 //                                alarm.setToken(token);
 //                                alarm.setCompanyId(deviceInfo.getCompanyId());
@@ -441,10 +441,10 @@ public class LiveDataTask {
 //                                event.setIsreport(1);
 //                                event.setThirdPartyId(thirdPartyId);
 //                                alarmEventService.save(event);
-                                    data.setStatus(3);
-                                    data1.setStatus(3);
-                                }
-                                if ((val < low_3 && val >= low_4) || (val > high_3 && val <= high_4)) {//状态4
+                            data.setStatus(3);
+                            data1.setStatus(3);
+                        }
+                        if ((val < low_3 && val >= low_4) || (val > high_3 && val <= high_4)) {//状态4
 //                                ServerAlarm alarm = new ServerAlarm();
 //                                alarm.setToken(token);
 //                                alarm.setCompanyId(deviceInfo.getCompanyId());
@@ -465,16 +465,16 @@ public class LiveDataTask {
 //                                event.setIsreport(1);
 //                                event.setThirdPartyId(thirdPartyId);
 //                                alarmEventService.save(event);
-                                    data.setStatus(4);
-                                    data1.setStatus(4);
-                                }
-                            } else {
-                                data.setStatus(0);
-                                data1.setStatus(0);
-                            }
-                            liveDataService.acceptLiveData(data);
-                            historyDataService.save(data1);
+                            data.setStatus(4);
+                            data1.setStatus(4);
                         }
+                    } else {
+                        data.setStatus(0);
+                        data1.setStatus(0);
+                    }
+                    liveDataService.acceptLiveData(data);
+                    historyDataService.save(data1);
+                }
 //
 //                    }
 //

+ 58 - 0
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/controller/DeviceInfoController.java

@@ -178,4 +178,62 @@ public class DeviceInfoController {
         }
 
     }
+
+
+    /**
+     * APP端获取可编辑的设备信息
+     *
+     * @param token
+     * @param request    pageNum pageSize
+     * @param deviceInfo
+     * @return
+     */
+    @RequestMapping("/getDeviceInfo")
+    public FebsResponse getDeviceInfo(String token, QueryRequest request, DeviceInfo deviceInfo) {
+        ThirdPartyUser u = ThirdPartyUtils.getThirdPartyUserInfo(token);
+        Map<String, Object> dataTable = null;
+        if (u.getUserId() != null) {
+            deviceInfo.setCompanyName(u.getEnterpriseName());
+            deviceInfo.setEditable(1);
+//            dataTable = FebsUtil.getDataTable(this.deviceInfoService.findDeviceInfos(request, deviceInfo));
+            return new FebsResponse().data(this.deviceInfoService.findDeviceInfos(request, deviceInfo));
+        } else
+            return new FebsResponse().code(HttpStatus.FORBIDDEN);
+    }
+
+    /**
+     * APP修改设备信息
+     *
+     * @param deviceInfo
+     * @throws FebsException
+     */
+    @RequestMapping("/updateDeviceInfo")
+    public FebsResponse appUpdateDeviceInfo(String token, DeviceInfo deviceInfo) throws FebsException {
+        ThirdPartyUser u = ThirdPartyUtils.getThirdPartyUserInfo(token);
+        if (u.getUserId() != null) {
+            try {
+                deviceInfo.setEditable(1);
+                this.deviceInfoService.updateDeviceInfo(deviceInfo);
+                return new FebsResponse().code(HttpStatus.OK);
+            } catch (Exception e) {
+                String message = "修改失败";
+                log.error(message, e);
+                throw new FebsException(message);
+            }
+        } else
+            return new FebsResponse().code(HttpStatus.FORBIDDEN);
+    }
+
+
+    /**
+     * 获取所有设备信息,用于同步
+     *
+     * @return
+     */
+    @RequestMapping("/getAllDeviceInfo")
+    public FebsResponse getAllDeviceInfo() {
+        return new FebsResponse().data(this.deviceInfoService.getAllDeviceInfo());
+    }
+
+
 }

+ 64 - 0
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/controller/DeviceThresholdController.java

@@ -4,13 +4,16 @@ import cc.mrbird.febs.common.core.entity.constant.StringConstant;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.gbd.demp.info.entity.DeviceThreshold;
+import com.gbd.demp.info.entity.ThirdPartyUser;
 import com.gbd.demp.info.service.IDeviceThresholdService;
 import cc.mrbird.febs.common.core.entity.FebsResponse;
 import cc.mrbird.febs.common.core.entity.QueryRequest;
 import cc.mrbird.febs.common.core.exception.FebsException;
 import cc.mrbird.febs.common.core.utils.FebsUtil;
+import com.gbd.demp.info.utils.ThirdPartyUtils;
 import lombok.extern.slf4j.Slf4j;
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -109,4 +112,65 @@ public class DeviceThresholdController {
             throw new FebsException(message);
         }
     }
+
+
+    /***
+     * 获取阈值信息接口,需要传sensorId
+     * @param deviceThreshold
+     * @return
+     */
+    @GetMapping("/getDeviceThresholdList")
+    public FebsResponse getDeviceThresholdList(String token, DeviceThreshold deviceThreshold) {
+        ThirdPartyUser u = ThirdPartyUtils.getThirdPartyUserInfo(token);
+        if (u.getUserId() != null) {
+            return new FebsResponse().data(this.deviceThresholdService.getDeviceThresholds(deviceThreshold));
+        } else
+            return new FebsResponse().code(HttpStatus.FORBIDDEN);
+    }
+
+
+    /**
+     * APP新增
+     *
+     * @param deviceThresholds
+     * @throws FebsException
+     */
+    @RequestMapping("/addDeviceThreshold")
+    public void createDeviceThreshold(String token, @RequestParam String deviceThresholds) throws FebsException {
+        ThirdPartyUser u = ThirdPartyUtils.getThirdPartyUserInfo(token);
+        if (u.getUserId() != null) {
+            try {
+                List<DeviceThreshold> dts = JSONObject.parseArray(deviceThresholds, DeviceThreshold.class);
+                this.deviceThresholdService.createDeviceThreshold(dts);
+            } catch (Exception e) {
+                String message = "新增DeviceThreshold失败";
+                log.error(message, e);
+                throw new FebsException(message);
+            }
+        } else
+            throw new FebsException("无权限");
+    }
+
+
+    /**
+     * APP修改
+     *
+     * @param deviceThreshold
+     * @throws FebsException
+     */
+    @RequestMapping("/updateDeviceThreshold")
+    public void modifyDeviceThreshold(String token, DeviceThreshold deviceThreshold) throws FebsException {
+        ThirdPartyUser u = ThirdPartyUtils.getThirdPartyUserInfo(token);
+        if (u.getUserId() != null) {
+            try {
+                this.deviceThresholdService.updateDeviceThreshold(deviceThreshold);
+            } catch (Exception e) {
+                String message = "修改DeviceThreshold失败";
+                log.error(message, e);
+                throw new FebsException(message);
+            }
+        } else
+            throw new FebsException("无权限");
+    }
+
 }

+ 26 - 4
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/controller/SensorInfoController.java

@@ -48,17 +48,17 @@ public class SensorInfoController {
      */
     @GetMapping("list")
     @PreAuthorize("hasAuthority('sensorInfo:view')")
-    public FebsResponse sensorInfoList(@RequestHeader(value = "thirdPartyToken") String thirdPartyToken,QueryRequest request, SensorInfo sensorInfo) {
+    public FebsResponse sensorInfoList(@RequestHeader(value = "thirdPartyToken") String thirdPartyToken, QueryRequest request, SensorInfo sensorInfo) {
         ThirdPartyUser u = ThirdPartyUtils.getThirdPartyUserInfo(thirdPartyToken);
         Map<String, Object> dataTable = null;
         if (u.getUserId() != null) {
             if (u.getEnterpriseId() != null) {//企业
                 sensorInfo.setCompanyName(u.getEnterpriseName());
-                dataTable = FebsUtil.getDataTable(this.sensorInfoService.findSensorInfos(request, sensorInfo,u.getPossession()));
+                dataTable = FebsUtil.getDataTable(this.sensorInfoService.findSensorInfos(request, sensorInfo, u.getPossession()));
             } else if (u.getPossession() != null) {//功能区
-                dataTable = FebsUtil.getDataTable(this.sensorInfoService.findSensorInfos(request, sensorInfo,u.getPossession()));
+                dataTable = FebsUtil.getDataTable(this.sensorInfoService.findSensorInfos(request, sensorInfo, u.getPossession()));
             } else //监管人员
-                dataTable = FebsUtil.getDataTable(this.sensorInfoService.findSensorInfos(request, sensorInfo,u.getPossession()));
+                dataTable = FebsUtil.getDataTable(this.sensorInfoService.findSensorInfos(request, sensorInfo, u.getPossession()));
             return new FebsResponse().data(dataTable);
         } else
             return new FebsResponse().code(HttpStatus.FORBIDDEN);
@@ -117,4 +117,26 @@ public class SensorInfoController {
             throw new FebsException(message);
         }
     }
+
+
+    /**
+     * APP获取所有传感器信息
+     *
+     * @param request
+     * @param sensorInfo 根据设备编号获取
+     * @return
+     */
+    @RequestMapping("/getSensorList")
+    public FebsResponse getSensorList(String token, QueryRequest request, SensorInfo sensorInfo) {
+        ThirdPartyUser u = ThirdPartyUtils.getThirdPartyUserInfo(token);//校验token是否合法
+        if (u.getUserId() != null) {
+            sensorInfo.setCompanyName(u.getEnterpriseName());
+            return new FebsResponse().data(this.sensorInfoService.findSensorInfos(request, sensorInfo, u.getPossession()));
+        } else
+            return new FebsResponse().code(HttpStatus.FORBIDDEN);
+    }
+
+
+
+
 }

+ 12 - 0
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/entity/DeviceThreshold.java

@@ -43,6 +43,12 @@ public class DeviceThreshold {
     @TableField("code")
     private String code;
 
+    /**
+     * 状态值
+     */
+    @TableField(exist = false)
+    private String codeValue;
+
     /**
      * 低值
      */
@@ -55,4 +61,10 @@ public class DeviceThreshold {
     @TableField("high_value")
     private Double highValue;
 
+    /**
+     * 是否可编辑
+     */
+    @TableField("editable")
+    private int editable;
+
 }

+ 11 - 0
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/mapper/DeviceThresholdMapper.java

@@ -7,6 +7,8 @@ import com.gbd.demp.info.entity.DeviceThreshold;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 设备(传感器)阈值设置 Mapper
  *
@@ -17,6 +19,14 @@ public interface DeviceThresholdMapper extends BaseMapper<DeviceThreshold> {
 
     <T> IPage<DeviceThreshold> findDeviceThresholds(Page<T> page, @Param("deviceThreshold") DeviceThreshold deviceThreshold);
 
+    /**
+     * APP获取传感器阈值
+     *
+     * @param deviceThreshold
+     * @return
+     */
+    List<DeviceThreshold> getDeviceThresholds(@Param("deviceThreshold") DeviceThreshold deviceThreshold);
+
     /**
      * 修改阈值
      *
@@ -27,6 +37,7 @@ public interface DeviceThresholdMapper extends BaseMapper<DeviceThreshold> {
 
     /**
      * 查询阈值是否存在
+     *
      * @param deviceThreshold
      * @return
      */

+ 2 - 0
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/service/IDeviceInfoService.java

@@ -70,4 +70,6 @@ public interface IDeviceInfoService extends IService<DeviceInfo> {
      *  3.监测图层点击详情
      */
     List<DeviceEventRespone> getMonitorLayerClickMap(String companyid, String alarmid, String deviceid);
+
+    List<DeviceInfo> getAllDeviceInfo();
 }

+ 2 - 0
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/service/IDeviceThresholdService.java

@@ -52,4 +52,6 @@ public interface IDeviceThresholdService extends IService<DeviceThreshold> {
      * @param deviceThreshold deviceThreshold
      */
     void deleteDeviceThreshold(String[] ids_);
+
+    List<DeviceThreshold> getDeviceThresholds(DeviceThreshold deviceThreshold);
 }

+ 7 - 0
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/service/impl/DeviceInfoServiceImpl.java

@@ -198,4 +198,11 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         return null;
     }
 
+
+
+    @Override
+    public List<DeviceInfo> getAllDeviceInfo() {
+        return baseMapper.findAll();
+    }
+
 }

+ 13 - 0
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/service/impl/DeviceThresholdServiceImpl.java

@@ -72,4 +72,17 @@ public class DeviceThresholdServiceImpl extends ServiceImpl<DeviceThresholdMappe
         this.baseMapper.delete(new LambdaQueryWrapper<DeviceThreshold>().in(DeviceThreshold::getId, list));
     }
 
+    /**
+     * APP获取阈值信息
+     *
+     * @param deviceThreshold
+     * @return
+     */
+    @Override
+    public List<DeviceThreshold> getDeviceThresholds(DeviceThreshold deviceThreshold) {
+        // TODO 设置查询条件
+        deviceThreshold.setEditable(1);
+        return this.baseMapper.getDeviceThresholds(deviceThreshold);
+    }
+
 }

+ 6 - 1
febs-server/gbd-demp-info/src/main/resources/mapper/DeviceInfoMapper.xml

@@ -19,6 +19,7 @@
         <result column="work_time_to" jdbcType="VARCHAR" property="workTimeTo"/>
         <result column="longitude" jdbcType="DOUBLE" property="longitude"/>
         <result column="latitude" jdbcType="DOUBLE" property="latitude"/>
+        <result column="editable" jdbcType="INTEGER" property="editable"/>
     </resultMap>
 
     <resultMap id="sensorInfo" type="com.gbd.demp.info.entity.SensorInfo">
@@ -60,7 +61,8 @@
         work_time_from,
         work_time_to,
         longitude,
-        latitude
+        latitude,
+        editable
         FROM
         t_device_info t
         left join t_code_industry t1 on t.industry_code=t1.code
@@ -87,6 +89,9 @@
         <if test="deviceInfo.companyName != null and deviceInfo.companyName != ''">
             AND t.company_name like CONCAT('%', #{deviceInfo.companyName}, '%')
         </if>
+        <if test="deviceInfo.editable != null and deviceInfo.editable != 0">
+            AND t.editable = #{deviceInfo.editable}
+        </if>
         group by
         t.device_id,
         t.device_name,

+ 37 - 6
febs-server/gbd-demp-info/src/main/resources/mapper/DeviceThresholdMapper.xml

@@ -6,12 +6,14 @@
         <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
         <result column="sensor_id" jdbcType="VARCHAR" property="sensorId"/>
         <result column="code" jdbcType="VARCHAR" property="code"/>
+        <result column="code_value" jdbcType="VARCHAR" property="codeValue"/>
         <result column="low_value" jdbcType="DATE" property="lowValue"/>
         <result column="high_value" jdbcType="VARCHAR" property="highValue"/>
+        <result column="editable" jdbcType="INTEGER" property="editable"/>
     </resultMap>
 
     <sql id="findDeviceThresholdSql">
-        SELECT id,device_id,sensor_id,t1.value code, low_value, high_value
+        SELECT id,device_id,sensor_id,t1.value code, low_value, high_value,editable
         FROM t_device_threshold t
         left join t_code_alarm_rules t1 on t.code=t1.code
         where 1=1
@@ -27,7 +29,8 @@
         t.sensor_id,
         t.code,
         t.low_value,
-        t.high_value
+        t.high_value,
+        t.editable
         order by t.code
     </sql>
 
@@ -35,15 +38,43 @@
         <include refid="findDeviceThresholdSql"/>
     </select>
 
+    <select id="getDeviceThresholds" resultMap="deviceThreshold">
+        SELECT id,device_id,sensor_id,t1.code code,t1.value code_value, low_value, high_value,editable
+        FROM t_device_threshold t
+        left join t_code_alarm_rules t1 on t.code=t1.code
+        where 1=1
+        <if test="deviceThreshold.deviceId != null and deviceThreshold.deviceId != ''">
+            AND t.device_id = #{deviceThreshold.deviceId}
+        </if>
+        <if test="deviceThreshold.sensorId != null and deviceThreshold.sensorId != ''">
+            AND t.sensor_id = #{deviceThreshold.sensorId}
+        </if>
+        group by
+        t.id,
+        t.device_id,
+        t.sensor_id,
+        t.code,
+        t.low_value,
+        t.high_value,
+        t.editable
+        order by t.code
+    </select>
+
     <update id="updateDeviceThresholds">
         update t_device_threshold
-        set low_value=#{deviceThreshold.lowValue},high_value=#{deviceThreshold.highValue}
-        where device_id=#{deviceThreshold.deviceId} and sensor_id=#{deviceThreshold.sensorId} and code=#{deviceThreshold.code}
+        set low_value=#{deviceThreshold.lowValue},
+            high_value=#{deviceThreshold.highValue}
+        where device_id = #{deviceThreshold.deviceId}
+          and sensor_id = #{deviceThreshold.sensorId}
+          and code = #{deviceThreshold.code}
     </update>
 
     <select id="isDeviceThresholdsExist" resultType="INTEGER">
-        select count(*) from t_device_threshold
-        where device_id=#{deviceThreshold.deviceId} and sensor_id=#{deviceThreshold.sensorId} and code=#{deviceThreshold.code}
+        select count(*)
+        from t_device_threshold
+        where device_id = #{deviceThreshold.deviceId}
+          and sensor_id = #{deviceThreshold.sensorId}
+          and code = #{deviceThreshold.code}
     </select>
 
 </mapper>