|
|
@@ -19,9 +19,11 @@ import com.sckw.slope.detection.model.dos.mysql.*;
|
|
|
import com.sckw.slope.detection.model.dos.tdengine.Devices;
|
|
|
import com.sckw.slope.detection.model.dto.*;
|
|
|
import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
|
|
|
+import com.sckw.slope.detection.model.param.ProjectThresholdSettingParam;
|
|
|
import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
|
|
|
import com.sckw.slope.detection.model.param.ThresholdQuery;
|
|
|
import com.sckw.slope.detection.model.vo.ProjectAndDeviceVo;
|
|
|
+import com.sckw.slope.detection.model.vo.ProjectThresholdSettingVO;
|
|
|
import com.sckw.slope.detection.model.vo.ThresholdDetailVO;
|
|
|
import com.sckw.slope.detection.service.repository.KwsThresholdRepository;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
@@ -61,6 +63,9 @@ public class ThresholdService {
|
|
|
@Autowired
|
|
|
DevicesMapper devicesMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ KwsProjectDeviceMapper projectDeviceMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
KwsDeviceIntegrationMapper deviceIntegrationMapper;
|
|
|
|
|
|
@@ -326,88 +331,168 @@ public class ThresholdService {
|
|
|
if (twoKwsThreshold != null) {
|
|
|
String min = twoKwsThreshold.getMin();
|
|
|
if (min.contains("-")) {
|
|
|
- min = StringUtils.deleteCharString(min, "-");
|
|
|
+// min = StringUtils.deleteCharString(min, "-");
|
|
|
+ if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("一级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("一级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
String max = twoKwsThreshold.getMax();
|
|
|
- if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
- }
|
|
|
- if (Long.parseLong(thresholdBean.getMin()) > Long.parseLong(min)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ if (max.contains("-")) {
|
|
|
+ if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("一级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("一级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (threeKwsThreshold != null) {
|
|
|
String min = threeKwsThreshold.getMin();
|
|
|
if (min.contains("-")) {
|
|
|
- min = StringUtils.deleteCharString(min, "-");
|
|
|
+ if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("一级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("一级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
String max = threeKwsThreshold.getMax();
|
|
|
- if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
- }
|
|
|
- if (Long.parseLong(thresholdBean.getMin()) > Long.parseLong(min)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ if (max.contains("-")) {
|
|
|
+ if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("一级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("一级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else if (2 == level) {
|
|
|
KwsThreshold oneKwsThreshold = thresholdSelect(1, headerData, deviceId, itemName);
|
|
|
KwsThreshold threeKwsThreshold = thresholdSelect(3, headerData, deviceId, itemName);
|
|
|
if (oneKwsThreshold != null) {
|
|
|
- String max = oneKwsThreshold.getMax();
|
|
|
String min = oneKwsThreshold.getMin();
|
|
|
if (min.contains("-")) {
|
|
|
- min = StringUtils.deleteCharString(min, "-");
|
|
|
- }
|
|
|
- if (Long.parseLong(thresholdBean.getMax()) < Long.parseLong(max)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+// min = StringUtils.deleteCharString(min, "-");
|
|
|
+ if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("二级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
- if (Long.parseLong(thresholdBean.getMin()) < Long.parseLong(min)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ String max = oneKwsThreshold.getMax();
|
|
|
+ if (max.contains("-")) {
|
|
|
+// min = StringUtils.deleteCharString(min, "-");
|
|
|
+ if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (threeKwsThreshold != null) {
|
|
|
- String max = threeKwsThreshold.getMax();
|
|
|
String min = threeKwsThreshold.getMin();
|
|
|
if (min.contains("-")) {
|
|
|
- min = StringUtils.deleteCharString(min, "-");
|
|
|
- }
|
|
|
- if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("二级最小级阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("二级最小级阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
- if (Long.parseLong(thresholdBean.getMin()) > Long.parseLong(min)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ String max = threeKwsThreshold.getMax();
|
|
|
+ if (max.contains("-")) {
|
|
|
+ if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("二级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("二级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else if (3 == level) {
|
|
|
KwsThreshold oneKwsThreshold = thresholdSelect(1, headerData, deviceId, itemName);
|
|
|
KwsThreshold twoKwsThreshold = thresholdSelect(2, headerData, deviceId, itemName);
|
|
|
if (oneKwsThreshold != null) {
|
|
|
- String max = oneKwsThreshold.getMax();
|
|
|
String min = oneKwsThreshold.getMin();
|
|
|
if (min.contains("-")) {
|
|
|
- min = StringUtils.deleteCharString(min, "-");
|
|
|
- }
|
|
|
- if (Long.parseLong(thresholdBean.getMax()) < Long.parseLong(max)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("三级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("三级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
- if (Long.parseLong(thresholdBean.getMin()) < Long.parseLong(min)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ String max = oneKwsThreshold.getMax();
|
|
|
+ if (max.contains("-")) {
|
|
|
+ if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("三级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("三级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (twoKwsThreshold != null) {
|
|
|
- String max = twoKwsThreshold.getMax();
|
|
|
String min = twoKwsThreshold.getMin();
|
|
|
if (min.contains("-")) {
|
|
|
- min = StringUtils.deleteCharString(min, "-");
|
|
|
- }
|
|
|
- if (Long.parseLong(thresholdBean.getMax()) < Long.parseLong(max)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("三级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
|
|
|
+ throw new BusinessException("三级最小值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
- if (Long.parseLong(thresholdBean.getMin()) < Long.parseLong(min)) {
|
|
|
- throw new BusinessException("阈值设置数据填写错误");
|
|
|
+ String max = twoKwsThreshold.getMax();
|
|
|
+ if (max.contains("-")) {
|
|
|
+ if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("三级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
|
|
|
+ log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
|
|
|
+ throw new BusinessException("三级最大值阈值设置数据填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -416,7 +501,7 @@ public class ThresholdService {
|
|
|
.eq(KwsThreshold::getMountainId, headerData.getMountainId())
|
|
|
.eq(KwsThreshold::getDeviceId, deviceId)
|
|
|
.eq(KwsThreshold::getItemName, itemName)
|
|
|
- .eq(KwsThreshold::getLevel, 2)
|
|
|
+ .eq(KwsThreshold::getLevel, level)
|
|
|
.eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
|
|
|
);
|
|
|
return threshold;
|
|
|
@@ -429,53 +514,87 @@ public class ThresholdService {
|
|
|
ThresholdBean thresholdBeanTwo = maps.get(2);
|
|
|
ThresholdBean thresholdBeanThree = maps.get(3);
|
|
|
if (thresholdBeanTwo != null) {
|
|
|
- String min = thresholdBeanTwo.getMin();
|
|
|
- if (min.contains("-")) {
|
|
|
- min = com.sckw.core.utils.StringUtils.deleteCharString(min, "-");
|
|
|
- }
|
|
|
- String max = thresholdBeanTwo.getMax();
|
|
|
+ String min = thresholdBeanTwo.getMin();//10
|
|
|
+ String max = thresholdBeanTwo.getMax();//90
|
|
|
if (thresholdBeanThree != null) {
|
|
|
- String minThree = thresholdBeanThree.getMin();
|
|
|
- if (minThree.contains("-")) {
|
|
|
- minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");
|
|
|
- }
|
|
|
- String maxThree = thresholdBeanThree.getMax();
|
|
|
- if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) > 0) {
|
|
|
+ String minThree = thresholdBeanThree.getMin();//8
|
|
|
+// if (minThree.contains("-")) {
|
|
|
+// minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");//-8
|
|
|
+// }
|
|
|
+ String maxThree = thresholdBeanThree.getMax();//80
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
|
|
|
throw new BusinessException("阈值填写错误");
|
|
|
}
|
|
|
- if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) < 0) {
|
|
|
- throw new BusinessException("阈值填写错误");
|
|
|
+ if (min.contains("-")) {
|
|
|
+// min = com.sckw.core.utils.StringUtils.deleteCharString(min, "-");//-10
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
|
|
|
+ throw new BusinessException("阈值填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
|
|
|
+ throw new BusinessException("阈值填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
if (thresholdBeanOne != null) {
|
|
|
- String minOne = thresholdBeanOne.getMin();
|
|
|
- if (minOne.contains("-")) {
|
|
|
- minOne = com.sckw.core.utils.StringUtils.deleteCharString(minOne, "-");
|
|
|
- }
|
|
|
- String maxThree = thresholdBeanOne.getMax();
|
|
|
- if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
|
|
|
+ String minOne = thresholdBeanOne.getMin(); //15
|
|
|
+ String maxThree = thresholdBeanOne.getMax();//100
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) > 0) {
|
|
|
throw new BusinessException("阈值填写错误");
|
|
|
}
|
|
|
- if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minOne))) > 0) {
|
|
|
- throw new BusinessException("阈值填写错误");
|
|
|
+ if (minOne.contains("-")) {
|
|
|
+// minOne = com.sckw.core.utils.StringUtils.deleteCharString(minOne, "-");//-15
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minOne))) < 0) {
|
|
|
+ throw new BusinessException("阈值填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minOne))) < 0) {
|
|
|
+ throw new BusinessException("阈值填写错误");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (thresholdBeanThree != null) {
|
|
|
- String minThree = thresholdBeanThree.getMin();
|
|
|
- if (minThree.contains("-")) {
|
|
|
- minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");
|
|
|
- }
|
|
|
- String maxThree = thresholdBeanThree.getMax();
|
|
|
+ String minThree = thresholdBeanThree.getMin();//8
|
|
|
+ String maxThree = thresholdBeanThree.getMax();//80
|
|
|
if (thresholdBeanTwo != null) {
|
|
|
- String twoMax = thresholdBeanTwo.getMax();
|
|
|
- String twoMin = thresholdBeanTwo.getMin();
|
|
|
- if (BigDecimal.valueOf(Long.parseLong(twoMax)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) > 0) {
|
|
|
+ String twoMax = thresholdBeanTwo.getMax();//90
|
|
|
+ String twoMin = thresholdBeanTwo.getMin();//-10
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(twoMax)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
|
|
|
throw new BusinessException("阈值填写错误");
|
|
|
}
|
|
|
- if (BigDecimal.valueOf(Long.parseLong(twoMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
|
|
|
+ if (minThree.contains("-")) {
|
|
|
+// minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");//-8
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(twoMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
|
|
|
+ throw new BusinessException("阈值填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(twoMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
|
|
|
+ throw new BusinessException("阈值填写错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+// if (twoMin.contains("-")) {
|
|
|
+// twoMin = com.sckw.core.utils.StringUtils.deleteCharString(twoMin, "-");//-8
|
|
|
+// }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (thresholdBeanOne != null) {
|
|
|
+ String oneMax = thresholdBeanOne.getMax();//100
|
|
|
+ String oneMin = thresholdBeanOne.getMin();//-15
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(oneMax)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
|
|
|
throw new BusinessException("阈值填写错误");
|
|
|
}
|
|
|
+ if (oneMin.contains("-")) {
|
|
|
+// oneMin = com.sckw.core.utils.StringUtils.deleteCharString(oneMin, "-");//-8
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(oneMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
|
|
|
+ throw new BusinessException("阈值填写错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (BigDecimal.valueOf(Long.parseLong(oneMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
|
|
|
+ throw new BusinessException("阈值填写错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -708,4 +827,211 @@ public class ThresholdService {
|
|
|
}
|
|
|
return HttpResult.ok(vo);
|
|
|
}
|
|
|
+
|
|
|
+ public HttpResult selectSetting(ProjectThresholdSettingParam param, HttpServletRequest request) {
|
|
|
+ HeaderData headerData = commonService.getHeaderData(request);
|
|
|
+ String projectId = param.getProjectId();
|
|
|
+ //100 全部 0未设置 1 部分设置 2 已设置
|
|
|
+ String type = param.getType();
|
|
|
+ if ("100".equals(type)) {
|
|
|
+ return getDeviceAll(projectId, headerData,param);
|
|
|
+ } else {
|
|
|
+ List<ProjectThresholdSettingVO> returnList = new ArrayList<>();
|
|
|
+ List<KwsProjectDevice> selectList = projectDeviceMapper.selectList(new LambdaQueryWrapper<KwsProjectDevice>()
|
|
|
+ .eq(KwsProjectDevice::getDelFlag, 0)
|
|
|
+ .eq(KwsProjectDevice::getProjectId, Long.parseLong(projectId))
|
|
|
+ );
|
|
|
+ if (CollectionUtils.isEmpty(selectList)) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+ List<Long> deviceIds = selectList.stream().map(KwsProjectDevice::getDeviceId).distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(deviceIds)) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+ List<String> typeSetting = new ArrayList<>();
|
|
|
+ typeSetting.add("0");
|
|
|
+ typeSetting.add("1");
|
|
|
+ typeSetting.add("2");
|
|
|
+ LambdaQueryWrapper<KwsThreshold> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
|
|
|
+ .eq(KwsThreshold::getStatus, NumberConstant.ZERO)
|
|
|
+ .eq(KwsThreshold::getMountainId, headerData.getMountainId())
|
|
|
+ .in(KwsThreshold::getDeviceId, deviceIds)
|
|
|
+ ;
|
|
|
+ KwsProject project = projectMapper.selectById(Long.parseLong(projectId));
|
|
|
+ if (typeSetting.contains(type)) {
|
|
|
+ wrapper.eq(KwsThreshold::getSetting, type);
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(wrapper);
|
|
|
+ if (CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+ deviceIds = kwsThresholds.stream().map(KwsThreshold::getDeviceId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long deviceId : deviceIds) {
|
|
|
+ ProjectThresholdSettingVO vo = new ProjectThresholdSettingVO();
|
|
|
+ vo.setProjectId(projectId);
|
|
|
+ vo.setProjectName(project == null ? null : project.getName());
|
|
|
+ vo.setDeviceId(deviceId.toString());
|
|
|
+ KwsDevice kwsDevice = deviceMapper.selectById(deviceId);
|
|
|
+ vo.setDeviceName(kwsDevice == null ? null : kwsDevice.getName());
|
|
|
+ List<Integer> status = new ArrayList<>();
|
|
|
+ status.add(DeviceEnum.ALREADY_REFERRED_TO.getCode());
|
|
|
+ //基本要素
|
|
|
+ List<DeviceElementDTO> basiclElementList = deviceModelPartMapper.selectElementList(projectId,
|
|
|
+ headerData.getMountainId(), status, deviceId);
|
|
|
+ Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
+ StringBuilder itemNames = new StringBuilder();
|
|
|
+ List<String> itemNameList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(basiclElementList)) {
|
|
|
+ for (DeviceElementDTO deviceElementDTO : basiclElementList) {
|
|
|
+ String itemNameLabel = deviceElementDTO.getElement() == null ? null : (
|
|
|
+ dictByDictCode == null ? deviceElementDTO.getElement() : (dictByDictCode.get(deviceElementDTO.getElement()) == null ? deviceElementDTO.getElement() :
|
|
|
+ (dictByDictCode.get(deviceElementDTO.getElement()).getLabel())
|
|
|
+ )
|
|
|
+ );
|
|
|
+ if (Objects.nonNull(itemNameLabel)) {
|
|
|
+ itemNameList.add(itemNameLabel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //集成要素
|
|
|
+ List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
|
|
|
+ headerData.getMountainId(), status, deviceId);
|
|
|
+ if (!CollectionUtils.isEmpty(integratedElementList)) {
|
|
|
+ List<String> integratedItemName = integratedElementList.stream().map(DeviceElementDTO::getIntegrationElement).distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(integratedItemName)) {
|
|
|
+ itemNameList.addAll(integratedItemName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(itemNameList)) {
|
|
|
+ for (int i = 0; i < itemNameList.size(); i++) {
|
|
|
+ if (i != (itemNameList.size() - 1)) {
|
|
|
+ itemNames.append(itemNameList.get(i)).append(",");
|
|
|
+ } else {
|
|
|
+ itemNames.append(itemNameList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setItemNames(itemNames == null ? null : itemNames.toString());
|
|
|
+ //阈值联系人
|
|
|
+ List<KwsThreshold> thresholdList = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
+ .eq(KwsThreshold::getStatus, NumberConstant.ZERO)
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
+ .eq(KwsThreshold::getMountainId, headerData.getMountainId())
|
|
|
+ .orderByDesc(KwsThreshold::getCreateTime)
|
|
|
+ );
|
|
|
+ StringBuilder phoneList = new StringBuilder();
|
|
|
+ if (!CollectionUtils.isEmpty(thresholdList)) {
|
|
|
+ List<String> phones = thresholdList.stream().map(KwsThreshold::getPhones).distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(phones)) {
|
|
|
+ for (int i = 0; i < phones.size(); i++) {
|
|
|
+ if (i != (phones.size() - 1)) {
|
|
|
+ phoneList.append(phones.get(i)).append(",");
|
|
|
+ } else {
|
|
|
+ phoneList.append(phones.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setPhones(phoneList == null ? null : phoneList.toString());
|
|
|
+ vo.setUpdateTime(thresholdList.get(0).getCreateTime());
|
|
|
+ }
|
|
|
+ returnList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(returnList)){
|
|
|
+ returnList = returnList.stream().skip((param.getPage() - 1) * param.getPageSize()).limit(param.getPageSize()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return HttpResult.ok(returnList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private HttpResult getDeviceAll(String projectId, HeaderData headerData,ProjectThresholdSettingParam param) {
|
|
|
+ List<ProjectThresholdSettingVO> returnList = new ArrayList<>();
|
|
|
+ List<KwsProjectDevice> selectList = projectDeviceMapper.selectList(new LambdaQueryWrapper<KwsProjectDevice>()
|
|
|
+ .eq(KwsProjectDevice::getDelFlag, 0)
|
|
|
+ .eq(KwsProjectDevice::getProjectId, Long.parseLong(projectId))
|
|
|
+ );
|
|
|
+ if (CollectionUtils.isEmpty(selectList)) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+ List<Long> deviceIds = selectList.stream().map(KwsProjectDevice::getDeviceId).distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(deviceIds)) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+ ProjectThresholdSettingVO returnData = new ProjectThresholdSettingVO();
|
|
|
+ KwsProject project = projectMapper.selectById(Long.parseLong(projectId));
|
|
|
+ for (Long deviceId : deviceIds) {
|
|
|
+ returnData.setProjectId(projectId);
|
|
|
+ returnData.setProjectName(project == null ? null : project.getName());
|
|
|
+ returnData.setDeviceId(deviceId.toString());
|
|
|
+ KwsDevice kwsDevice = deviceMapper.selectById(deviceId);
|
|
|
+ returnData.setDeviceName(kwsDevice == null ? null : kwsDevice.getName());
|
|
|
+ List<Integer> status = new ArrayList<>();
|
|
|
+ status.add(DeviceEnum.ALREADY_REFERRED_TO.getCode());
|
|
|
+ //基本要素
|
|
|
+ List<DeviceElementDTO> basiclElementList = deviceModelPartMapper.selectElementList(projectId,
|
|
|
+ headerData.getMountainId(), status, deviceId);
|
|
|
+ Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
+ StringBuilder itemNames = new StringBuilder();
|
|
|
+ List<String> itemNameList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(basiclElementList)) {
|
|
|
+ for (DeviceElementDTO deviceElementDTO : basiclElementList) {
|
|
|
+ String itemNameLabel = deviceElementDTO.getElement() == null ? null : (
|
|
|
+ dictByDictCode == null ? deviceElementDTO.getElement() : (dictByDictCode.get(deviceElementDTO.getElement()) == null ? deviceElementDTO.getElement() :
|
|
|
+ (dictByDictCode.get(deviceElementDTO.getElement()).getLabel())
|
|
|
+ )
|
|
|
+ );
|
|
|
+ if (Objects.nonNull(itemNameLabel)) {
|
|
|
+ itemNameList.add(itemNameLabel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //集成要素
|
|
|
+ List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
|
|
|
+ headerData.getMountainId(), status, deviceId);
|
|
|
+ if (!CollectionUtils.isEmpty(integratedElementList)) {
|
|
|
+ List<String> integratedItemName = integratedElementList.stream().map(DeviceElementDTO::getIntegrationElement).distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(integratedItemName)) {
|
|
|
+ itemNameList.addAll(integratedItemName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(itemNameList)) {
|
|
|
+ for (int i = 0; i < itemNameList.size(); i++) {
|
|
|
+ if (i != (itemNameList.size() - 1)) {
|
|
|
+ itemNames.append(itemNameList.get(i)).append(",");
|
|
|
+ } else {
|
|
|
+ itemNames.append(itemNameList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ returnData.setItemNames(itemNames == null ? null : itemNames.toString());
|
|
|
+ //阈值联系人
|
|
|
+ List<KwsThreshold> thresholdList = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
+ .eq(KwsThreshold::getStatus, NumberConstant.ZERO)
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
+ .eq(KwsThreshold::getMountainId, headerData.getMountainId())
|
|
|
+ .orderByDesc(KwsThreshold::getCreateTime)
|
|
|
+ );
|
|
|
+ StringBuilder phoneList = new StringBuilder();
|
|
|
+ if (!CollectionUtils.isEmpty(thresholdList)) {
|
|
|
+ List<String> phones = thresholdList.stream().map(KwsThreshold::getPhones).distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(phones)) {
|
|
|
+ for (int i = 0; i < phones.size(); i++) {
|
|
|
+ if (i != (phones.size() - 1)) {
|
|
|
+ phoneList.append(phones.get(i)).append(",");
|
|
|
+ } else {
|
|
|
+ phoneList.append(phones.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ returnData.setUpdateTime(thresholdList.get(0).getCreateTime());
|
|
|
+ }
|
|
|
+ returnData.setPhones(phoneList == null ? null : phoneList.toString());
|
|
|
+ returnList.add(returnData);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(returnList)){
|
|
|
+ returnList = returnList.stream().skip((param.getPage() - 1) * param.getPageSize()).limit(param.getPageSize()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return HttpResult.ok(returnList);
|
|
|
+ }
|
|
|
}
|