|
|
@@ -1,6 +1,8 @@
|
|
|
package com.xunmei.iot.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.xunmei.common.core.constant.CacheConstants;
|
|
|
@@ -17,15 +19,21 @@ import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
|
|
|
import com.xunmei.iot.mapper.DiagnoseThresholdChMapper;
|
|
|
import com.xunmei.iot.service.DiagnoseThresholdService;
|
|
|
import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
|
|
|
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdAddVo;
|
|
|
import com.xunmei.iot.vo.sensor.DiagnoseThresholdBindVo;
|
|
|
import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.vo.SysOrgVO;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.DigestUtils;
|
|
|
+
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -39,7 +47,7 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
private DiagnoseThresholdChMapper diagnoseThresholdChMapper;
|
|
|
|
|
|
@Override
|
|
|
- public TableDataInfo<DiagnoseThresholdPageVo> selectDiagnoseThresholdPage(DiagnoseThresholdPageDto request) {
|
|
|
+ public TableDataInfo<DiagnoseThresholdPageVo> selectCameraThresholdPage(DiagnoseThresholdPageDto request) {
|
|
|
final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
|
|
|
if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {
|
|
|
request.setOrgPath(sysOrg.getPath());
|
|
|
@@ -69,7 +77,7 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
for(IotDeviceDiagnoseThreshold threshold:thresholds){
|
|
|
if(threshold.getThresholdCode().equals(code)){
|
|
|
buffer.append(threshold.getThresholdName()).append("【")
|
|
|
- .append(threshold.getValiditybegintime()).append("--").append(threshold.getValidityendtime())
|
|
|
+ .append(threshold.getBeginTime()).append("--").append(threshold.getEndTime())
|
|
|
.append("】").append(",");
|
|
|
isMatch = true;
|
|
|
}
|
|
|
@@ -133,7 +141,7 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
}
|
|
|
//获取涉及阈值配置,并修改设备数量
|
|
|
for (String bindThresholdCode:bindThresholdCodes) {
|
|
|
- diagnoseThresholdChMapper.updateDignoseNumber(bindThresholdCode);
|
|
|
+ diagnoseThresholdChMapper.updateDiagnoseNumber(bindThresholdCode);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -182,11 +190,106 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
}
|
|
|
//获取涉及阈值配置,并修改设备数量
|
|
|
for (String bindThresholdCode:unbindThresholdCodes) {
|
|
|
- diagnoseThresholdChMapper.updateDignoseNumber(bindThresholdCode);
|
|
|
+ diagnoseThresholdChMapper.updateDiagnoseNumber(bindThresholdCode);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IotDeviceDiagnoseThreshold> selectThresholdPage(){
|
|
|
+ return diagnoseThresholdChMapper.selectList(Wrappers.emptyWrapper());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void deleteThreshold(String thresholdCode){
|
|
|
+ IotDeviceDiagnoseThreshold system = diagnoseThresholdChMapper.selectById(thresholdCode);
|
|
|
+ if (system == null) {
|
|
|
+ String errorMsg = "当前阈值不存在!";
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
+ }
|
|
|
+ if (system.getType() == 1) {
|
|
|
+ String errorMsg = "默认阈值不能删除!";
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
+ }
|
|
|
+ //删除阈值
|
|
|
+ diagnoseThresholdChMapper.deleteById(thresholdCode);
|
|
|
+ //删除关联视频通道
|
|
|
+ diagnoseThresholdChMapper.deleteCamerasByThresholdCode(thresholdCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addThreshold(DiagnoseThresholdAddVo request){
|
|
|
+ String nosignal=request.getNosignal().replace(">",">").replace("<","<");
|
|
|
+ String covered=request.getCovered().replace(">",">").replace("<","<");
|
|
|
+ request.setNosignal(nosignal);
|
|
|
+ request.setCovered(covered);
|
|
|
+
|
|
|
+ String thresholdCode = DigestUtils.md5DigestAsHex(getThresholdGuid(request).getBytes());
|
|
|
+
|
|
|
+ QueryWrapper<IotDeviceDiagnoseThreshold> queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("threshold_code", thresholdCode);
|
|
|
+ List<IotDeviceDiagnoseThreshold> list = diagnoseThresholdChMapper.selectList(queryWrapper);
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ String errorMsg = "已存在相同参数的阈值配置'" + list.get(0).getThresholdName() + "'!";
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("threshold_name", request.getThresholdName());
|
|
|
+ long nameCount = diagnoseThresholdChMapper.selectCount(queryWrapper);
|
|
|
+ if (nameCount > 0) {
|
|
|
+ String errorMsg = "已存在相同名称的阈值配置";
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ IotDeviceDiagnoseThreshold threshold = new IotDeviceDiagnoseThreshold();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(request, threshold);
|
|
|
+ threshold.setBeginTime(request.getTimeRange()[0]);
|
|
|
+ threshold.setEndTime(request.getTimeRange()[1]);
|
|
|
+
|
|
|
+ threshold.setThresholdCode(thresholdCode);
|
|
|
+ threshold.setCreateTime(LocalDateTime.now());
|
|
|
+ threshold.setDiagnoseNumber(0);
|
|
|
+ threshold.setType(0L);
|
|
|
+
|
|
|
+ diagnoseThresholdChMapper.insert(threshold);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void editThreshold(DiagnoseThresholdAddVo request){
|
|
|
+ //todo:
|
|
|
+ String thresholdCode = DigestUtils.md5DigestAsHex(getThresholdGuid(request).getBytes());
|
|
|
+
|
|
|
+ QueryWrapper<IotDeviceDiagnoseThreshold> queryWrapper = new QueryWrapper();
|
|
|
+// queryWrapper.eq("threshold_code", thresholdCode);
|
|
|
+// List<IotDeviceDiagnoseThreshold> list = diagnoseThresholdChMapper.selectList(queryWrapper);
|
|
|
+// if (!list.isEmpty()) {
|
|
|
+// String errorMsg = "已存在相同参数的阈值配置'" + list.get(0).getThresholdName() + "'!";
|
|
|
+// throw new ServiceException(errorMsg);
|
|
|
+// }
|
|
|
+
|
|
|
+ queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("threshold_name", request.getThresholdName()).ne("threshold_code", thresholdCode);
|
|
|
+ long nameCount = diagnoseThresholdChMapper.selectCount(queryWrapper);
|
|
|
+ if (nameCount > 0) {
|
|
|
+ String errorMsg = "已存在相同名称的阈值配置";
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ IotDeviceDiagnoseThreshold threshold = new IotDeviceDiagnoseThreshold();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(request, threshold);
|
|
|
+ threshold.setBeginTime(request.getTimeRange()[0]);
|
|
|
+ threshold.setEndTime(request.getTimeRange()[1]);
|
|
|
+
|
|
|
+ threshold.setThresholdCode(thresholdCode);
|
|
|
+ threshold.setCreateTime(LocalDateTime.now());
|
|
|
+ threshold.setType(0L);
|
|
|
+
|
|
|
+ diagnoseThresholdChMapper.updateById(threshold);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<AlarmTypeSelectedVO> thresholdTypeList() {
|
|
|
@@ -200,7 +303,7 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
|
|
|
buffer = new StringBuffer();
|
|
|
buffer.append(threshold.getThresholdName()).append("【")
|
|
|
- .append(threshold.getValiditybegintime()).append("--").append(threshold.getValidityendtime())
|
|
|
+ .append(threshold.getBeginTime()).append("--").append(threshold.getEndTime())
|
|
|
.append("】");
|
|
|
|
|
|
bean.setValue(threshold.getThresholdCode());
|
|
|
@@ -210,4 +313,43 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ private String getThresholdGuid(IotDeviceDiagnoseThreshold threshold) {
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ String color = "@value>=150";
|
|
|
+ threshold.setColor(color);
|
|
|
+ sb.append(color);
|
|
|
+
|
|
|
+ String contrast = "@value<=0";
|
|
|
+ threshold.setContrast(contrast);
|
|
|
+ sb.append(contrast);
|
|
|
+
|
|
|
+ String covered = threshold.getCovered();
|
|
|
+ sb.append(covered);
|
|
|
+
|
|
|
+ String freeze = "@value>=250";
|
|
|
+ threshold.setFreeze(freeze);
|
|
|
+ sb.append(freeze);
|
|
|
+
|
|
|
+ String fuzzy = "@value>=253";
|
|
|
+ threshold.setFuzzy(fuzzy);
|
|
|
+ sb.append(fuzzy);
|
|
|
+
|
|
|
+ String luminance = "@value>=225";
|
|
|
+ threshold.setLuminance(luminance);
|
|
|
+ sb.append(luminance);
|
|
|
+
|
|
|
+ String nosignal = threshold.getNosignal();
|
|
|
+ sb.append(nosignal);
|
|
|
+
|
|
|
+ String roll = "@value>=140";
|
|
|
+ threshold.setRoll(roll);
|
|
|
+ sb.append(roll);
|
|
|
+
|
|
|
+ String snow = "@value>=7";
|
|
|
+ threshold.setSnow(snow);
|
|
|
+ sb.append(snow);
|
|
|
+
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
}
|