|
|
@@ -200,13 +200,18 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
|
|
|
@Override
|
|
|
public List<IotDeviceDiagnoseThreshold> selectThresholdPage(){
|
|
|
- return diagnoseThresholdChMapper.selectList(Wrappers.emptyWrapper());
|
|
|
+ QueryWrapper<IotDeviceDiagnoseThreshold> queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.orderByAsc("create_time");
|
|
|
+ return diagnoseThresholdChMapper.selectList(queryWrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void deleteThreshold(String thresholdCode){
|
|
|
- IotDeviceDiagnoseThreshold system = diagnoseThresholdChMapper.selectById(thresholdCode);
|
|
|
+ QueryWrapper<IotDeviceDiagnoseThreshold> queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("threshold_code",thresholdCode);
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
+ IotDeviceDiagnoseThreshold system = diagnoseThresholdChMapper.selectOne(queryWrapper);
|
|
|
if (system == null) {
|
|
|
String errorMsg = "当前阈值不存在!";
|
|
|
throw new ServiceException(errorMsg);
|
|
|
@@ -216,7 +221,7 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
throw new ServiceException(errorMsg);
|
|
|
}
|
|
|
//删除阈值
|
|
|
- diagnoseThresholdChMapper.deleteById(thresholdCode);
|
|
|
+ diagnoseThresholdChMapper.delete(queryWrapper);
|
|
|
//删除关联视频通道
|
|
|
diagnoseThresholdChMapper.deleteCamerasByThresholdCode(thresholdCode);
|
|
|
}
|
|
|
@@ -252,6 +257,7 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
threshold.setBeginTime(request.getTimeRange()[0]);
|
|
|
threshold.setEndTime(request.getTimeRange()[1]);
|
|
|
|
|
|
+ threshold.setThresholdId(IDHelper.id());
|
|
|
threshold.setThresholdCode(thresholdCode);
|
|
|
threshold.setCreateTime(DateUtils.getTime());
|
|
|
threshold.setDiagnoseNumber(0);
|
|
|
@@ -262,19 +268,23 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
|
|
|
@Override
|
|
|
public void editThreshold(DiagnoseThresholdAddVo request){
|
|
|
- //todo:
|
|
|
+ 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.eq("threshold_code", thresholdCode).ne("threshold_id", request.getThresholdId());
|
|
|
+ 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);
|
|
|
+ queryWrapper.eq("threshold_name", request.getThresholdName()).ne("threshold_id", request.getThresholdId());
|
|
|
long nameCount = diagnoseThresholdChMapper.selectCount(queryWrapper);
|
|
|
if (nameCount > 0) {
|
|
|
String errorMsg = "已存在相同名称的阈值配置";
|