|
@@ -3,12 +3,15 @@ package com.gyee.alarm.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
-import com.gyee.alarm.model.auto.ProEconAlarmRule;
|
|
|
|
|
|
+import com.gyee.alarm.init.CacheContext;
|
|
|
|
+import com.gyee.alarm.model.auto.*;
|
|
import com.gyee.alarm.model.vo.AjaxResult;
|
|
import com.gyee.alarm.model.vo.AjaxResult;
|
|
import com.gyee.alarm.model.vo.AjaxStatus;
|
|
import com.gyee.alarm.model.vo.AjaxStatus;
|
|
|
|
+import com.gyee.alarm.model.vo.AlarmCustomType;
|
|
import com.gyee.alarm.model.vo.AlarmRuleVo;
|
|
import com.gyee.alarm.model.vo.AlarmRuleVo;
|
|
import com.gyee.alarm.service.AlarmRuleService;
|
|
import com.gyee.alarm.service.AlarmRuleService;
|
|
|
|
|
|
|
|
+import com.gyee.alarm.service.TokenService;
|
|
import com.gyee.alarm.util.ExcelUtils;
|
|
import com.gyee.alarm.util.ExcelUtils;
|
|
import com.gyee.alarm.util.SnowflakeGenerator;
|
|
import com.gyee.alarm.util.SnowflakeGenerator;
|
|
import com.gyee.alarm.util.StringUtils;
|
|
import com.gyee.alarm.util.StringUtils;
|
|
@@ -19,9 +22,11 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.codehaus.groovy.syntax.TokenUtil;
|
|
import org.codehaus.groovy.syntax.TokenUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -35,17 +40,134 @@ import java.util.*;
|
|
@CrossOrigin
|
|
@CrossOrigin
|
|
public class AlertRuleController {
|
|
public class AlertRuleController {
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private AlarmRuleService alarmRuleService;
|
|
private AlarmRuleService alarmRuleService;
|
|
|
|
|
|
-
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private TokenService tokenService;
|
|
@GetMapping(value = "/list")
|
|
@GetMapping(value = "/list")
|
|
- public List<AlarmRuleVo> queryTree() {
|
|
|
|
|
|
+ public AjaxResult queryTree() {
|
|
List<AlarmRuleVo> alertrules = alarmRuleService.queryTree();
|
|
List<AlarmRuleVo> alertrules = alarmRuleService.queryTree();
|
|
- return alertrules;
|
|
|
|
|
|
+ if (StringUtils.notEmp(alertrules)) {
|
|
|
|
+
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, alertrules);
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/querywpllist")
|
|
|
|
+ public AjaxResult queryWplList() {
|
|
|
|
+
|
|
|
|
+ List<ProBasicPowerstation> wpls= CacheContext.wpls;
|
|
|
|
+
|
|
|
|
+ if (StringUtils.notEmp(wpls)) {
|
|
|
|
+
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, wpls);
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ @GetMapping(value = "/querywtpointllist")
|
|
|
|
+ public AjaxResult queryWtPointlList(String wpId,String modelId) {
|
|
|
|
+
|
|
|
|
+ Map<String,List<ProBasicPowerstationPoint>> map=new HashMap<>();
|
|
|
|
+ if(StringUtils.notEmp(wpId) && StringUtils.notEmp(modelId) && CacheContext.wppointmap.containsKey(wpId))
|
|
|
|
+ {
|
|
|
|
+ Map<String, ProBasicPowerstationPoint> submap= CacheContext.wppointmap.get(wpId);
|
|
|
|
+
|
|
|
|
+ List<ProBasicPowerstationPoint> ailist=new ArrayList<>();
|
|
|
|
+ List<ProBasicPowerstationPoint> dilist=new ArrayList<>();
|
|
|
|
+ for(Map.Entry<String,ProBasicPowerstationPoint> entry:submap.entrySet()){
|
|
|
|
+
|
|
|
|
+ if(entry.getValue().getModelId().equals(modelId))
|
|
|
|
+ {
|
|
|
|
+ if(entry.getKey().contains("AI"))
|
|
|
|
+ {
|
|
|
|
+ ailist.add(entry.getValue());
|
|
|
|
+ }else if(entry.getKey().contains("DI"))
|
|
|
|
+ {
|
|
|
|
+ dilist.add(entry.getValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ map.put("ai",ailist);
|
|
|
|
+ map.put("di",dilist);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.notEmp(map)) {
|
|
|
|
+
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, map);
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ @GetMapping(value = "/querysubllist")
|
|
|
|
+ public AjaxResult querySublList() {
|
|
|
|
+
|
|
|
|
+ List<ProBasicSubStation> subwpls= CacheContext.subwpls;
|
|
|
|
+
|
|
|
|
+ if (StringUtils.notEmp(subwpls)) {
|
|
|
|
+
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, subwpls);
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @GetMapping(value = "/querysubpointllist")
|
|
|
|
+ public AjaxResult querySubPointlList(String subId) {
|
|
|
|
+
|
|
|
|
+ Map<String,List<ProBasicPowerstationPoint>> map=new HashMap<>();
|
|
|
|
+ if(StringUtils.notEmp(subId) && CacheContext.subwppointmap.containsKey(subId))
|
|
|
|
+ {
|
|
|
|
+ Map<String, ProBasicPowerstationPoint> submap= CacheContext.subwppointmap.get(subId);
|
|
|
|
+
|
|
|
|
+ List<ProBasicPowerstationPoint> ailist=new ArrayList<>();
|
|
|
|
+ List<ProBasicPowerstationPoint> dilist=new ArrayList<>();
|
|
|
|
+ for(Map.Entry<String,ProBasicPowerstationPoint> entry:submap.entrySet()){
|
|
|
|
|
|
|
|
+ if(entry.getKey().contains("AI"))
|
|
|
|
+ {
|
|
|
|
+ ailist.add(entry.getValue());
|
|
|
|
+ }else if(entry.getKey().contains("DI"))
|
|
|
|
+ {
|
|
|
|
+ dilist.add(entry.getValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ map.put("ai",ailist);
|
|
|
|
+ map.put("di",dilist);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.notEmp(map)) {
|
|
|
|
+
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, map);
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/querywpbyymodellist")
|
|
|
|
+ public AjaxResult queryWpByModelList() {
|
|
|
|
+
|
|
|
|
+ Map<String,Set<ProEconEquipmentmodel>> wpByEmMap=CacheContext.wpByEmMap;
|
|
|
|
+
|
|
|
|
+ if (StringUtils.notEmp(wpByEmMap)) {
|
|
|
|
+
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, wpByEmMap);
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//@UserLoginToken
|
|
//@UserLoginToken
|
|
@PostMapping(value = "/save")
|
|
@PostMapping(value = "/save")
|
|
@@ -53,28 +175,38 @@ public class AlertRuleController {
|
|
|
|
|
|
public AjaxResult saveAlertrule(HttpServletRequest request, @RequestBody ProEconAlarmRule alarmRule) throws Exception {
|
|
public AjaxResult saveAlertrule(HttpServletRequest request, @RequestBody ProEconAlarmRule alarmRule) throws Exception {
|
|
|
|
|
|
- int result = alarmRuleService.saveAndUpdateAlertrule(alarmRule);
|
|
|
|
|
|
|
|
- return AjaxResult.successData(AjaxStatus.success.code, result);
|
|
|
|
|
|
+ String token = request.getHeader("token");
|
|
|
|
|
|
- }
|
|
|
|
- @PostMapping(value = "/update")
|
|
|
|
- @ResponseBody
|
|
|
|
|
|
+ if (StringUtils.notEmp(token) && tokenService.sessionMap.containsKey(token)) {
|
|
|
|
+
|
|
|
|
+ int result = alarmRuleService.saveAndUpdateAlertrule(alarmRule);
|
|
|
|
+
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, result);
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
|
|
|
|
+ }
|
|
|
|
|
|
- public AjaxResult updateAlertrule(HttpServletRequest request, @RequestBody ProEconAlarmRule alarmRule) throws Exception {
|
|
|
|
|
|
|
|
- int result = alarmRuleService.saveAndUpdateAlertrule(alarmRule);
|
|
|
|
- return AjaxResult.successData(AjaxStatus.success.code, result);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
@DeleteMapping(value = "/delete")
|
|
@DeleteMapping(value = "/delete")
|
|
- public int deleteAlertrule(ProEconAlarmRule alarmRule) {
|
|
|
|
- return alarmRuleService.deleteAlertrule(alarmRule);
|
|
|
|
|
|
+ public AjaxResult deleteAlertrule(ProEconAlarmRule alarmRule) {
|
|
|
|
+
|
|
|
|
+ int i= alarmRuleService.deleteAlertrule(alarmRule);
|
|
|
|
+
|
|
|
|
+ if (StringUtils.notEmp(i)) {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, i);
|
|
|
|
+ } else {
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.error.code, "error");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//@UserLoginToken
|
|
//@UserLoginToken
|
|
@GetMapping(value = "/page")
|
|
@GetMapping(value = "/page")
|
|
- public IPage<ProEconAlarmRule> queryByPage(HttpServletRequest request,
|
|
|
|
|
|
+ public AjaxResult queryByPage(HttpServletRequest request,
|
|
@RequestParam(value = "pagenum") Integer pageNum,
|
|
@RequestParam(value = "pagenum") Integer pageNum,
|
|
@RequestParam(value = "pagesize") Integer pageSize,
|
|
@RequestParam(value = "pagesize") Integer pageSize,
|
|
@RequestParam(value = "name", required = false) String name,
|
|
@RequestParam(value = "name", required = false) String name,
|
|
@@ -89,47 +221,18 @@ public class AlertRuleController {
|
|
|
|
|
|
IPage<ProEconAlarmRule> pageResult = alarmRuleService.pageQueryAll(page, name,station,modelId,rank,category,enabled,relatedparts);
|
|
IPage<ProEconAlarmRule> pageResult = alarmRuleService.pageQueryAll(page, name,station,modelId,rank,category,enabled,relatedparts);
|
|
|
|
|
|
- return pageResult;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- private AjaxResult dataCheck(ProEconAlarmRule alertrule) {
|
|
|
|
-
|
|
|
|
- String msg = "";
|
|
|
|
- boolean result = true;
|
|
|
|
- if (StringUtils.isBlank(alertrule.getName())) {
|
|
|
|
- msg = "报警名称不能为空";
|
|
|
|
- result = false;
|
|
|
|
- } else if (StringUtils.isBlank(alertrule.getDescription())) {
|
|
|
|
- msg = "规则描述不能为空";
|
|
|
|
- result = false;
|
|
|
|
- } else if (StringUtils.isBlank(alertrule.getExpression())) {
|
|
|
|
- msg = "报警规则不能为空";
|
|
|
|
- result = false;
|
|
|
|
- } else if (StringUtils.empty(alertrule.getRank())) {
|
|
|
|
- msg = "报警级别不能为空";
|
|
|
|
- result = false;
|
|
|
|
- }
|
|
|
|
- else if (StringUtils.isBlank(alertrule.getStationId())) {
|
|
|
|
- msg = "风场不能为空";
|
|
|
|
- result = false;
|
|
|
|
- } else if (StringUtils.isBlank(alertrule.getCategory())) {
|
|
|
|
- msg = "报警类别不能为空";
|
|
|
|
- result = false;
|
|
|
|
- }
|
|
|
|
- if (alertrule.getCategory().equals("1")) {
|
|
|
|
- if (StringUtils.isBlank(alertrule.getModelId())) {
|
|
|
|
- msg = "风机型号不能为空";
|
|
|
|
- result = false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (result) {
|
|
|
|
- return AjaxResult.successData(AjaxStatus.success.code, result);
|
|
|
|
|
|
+ if (StringUtils.notEmp(pageResult)) {
|
|
|
|
+
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, pageResult);
|
|
} else {
|
|
} else {
|
|
- return AjaxResult.successData(AjaxStatus.error.code, result);
|
|
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.error.code, "error");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
//@UserLoginToken
|
|
//@UserLoginToken
|
|
@PostMapping(value = "/save-batch")
|
|
@PostMapping(value = "/save-batch")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@@ -161,7 +264,11 @@ public class AlertRuleController {
|
|
msg = "报警类别不能为空";
|
|
msg = "报警类别不能为空";
|
|
result = false;
|
|
result = false;
|
|
}
|
|
}
|
|
- if (alertrule.getCategory().equals("1")) {
|
|
|
|
|
|
+ else if (StringUtils.isBlank(alertrule.getUniformCode())) {
|
|
|
|
+ msg = "统一编码不能为空";
|
|
|
|
+ result = false;
|
|
|
|
+ }
|
|
|
|
+ if (alertrule.getCategory().equals(AlarmCustomType.WT.getCode())) {
|
|
if (StringUtils.isBlank(alertrule.getModelId())) {
|
|
if (StringUtils.isBlank(alertrule.getModelId())) {
|
|
msg = "风机型号不能为空";
|
|
msg = "风机型号不能为空";
|
|
result = false;
|
|
result = false;
|
|
@@ -184,7 +291,7 @@ public class AlertRuleController {
|
|
}
|
|
}
|
|
return AjaxResult.successData(AjaxStatus.success.code, "ok");
|
|
return AjaxResult.successData(AjaxStatus.success.code, "ok");
|
|
} else {
|
|
} else {
|
|
- return AjaxResult.successData(AjaxStatus.success.code, "ok");
|
|
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.error.code, "error");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -207,7 +314,7 @@ public class AlertRuleController {
|
|
.category("1").range("0")
|
|
.category("1").range("0")
|
|
.stationId("ZK_FDC").projectId("ZK_FDC").lineId("ZK_FDC").deviceId("ZK_FDC")
|
|
.stationId("ZK_FDC").projectId("ZK_FDC").lineId("ZK_FDC").deviceId("ZK_FDC")
|
|
.electricalId("").relatedParts("BJ").createTime(DateUtils.truncate(previousDay))
|
|
.electricalId("").relatedParts("BJ").createTime(DateUtils.truncate(previousDay))
|
|
- .enable(true)
|
|
|
|
|
|
+ .enable(true).uniformCode("AI091")
|
|
.build(),
|
|
.build(),
|
|
|
|
|
|
ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度2超限报警").description("温度等于850度或者温度小于零下40度")
|
|
ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度2超限报警").description("温度等于850度或者温度小于零下40度")
|
|
@@ -215,7 +322,7 @@ public class AlertRuleController {
|
|
.category("1").range("0")
|
|
.category("1").range("0")
|
|
.stationId("ZK_FDC").projectId("ZK_FDC").lineId("ZK_FDC").deviceId("ZK_FDC")
|
|
.stationId("ZK_FDC").projectId("ZK_FDC").lineId("ZK_FDC").deviceId("ZK_FDC")
|
|
.electricalId("").relatedParts("BJ").createTime(DateUtils.truncate(previousDay))
|
|
.electricalId("").relatedParts("BJ").createTime(DateUtils.truncate(previousDay))
|
|
- .enable(true)
|
|
|
|
|
|
+ .enable(true).uniformCode("AI091")
|
|
.build()
|
|
.build()
|
|
|
|
|
|
);
|
|
);
|
|
@@ -255,8 +362,11 @@ public class AlertRuleController {
|
|
} else if (StringUtils.isBlank(alertrule.getCategory())) {
|
|
} else if (StringUtils.isBlank(alertrule.getCategory())) {
|
|
msg = "报警类别不能为空";
|
|
msg = "报警类别不能为空";
|
|
result = false;
|
|
result = false;
|
|
|
|
+ }else if (StringUtils.isBlank(alertrule.getUniformCode())) {
|
|
|
|
+ msg = "统一编码不能为空";
|
|
|
|
+ result = false;
|
|
}
|
|
}
|
|
- if (alertrule.getCategory().equals("1")) {
|
|
|
|
|
|
+ if (alertrule.getCategory().equals(AlarmCustomType.WT.getCode())) {
|
|
if (StringUtils.isBlank(alertrule.getModelId())) {
|
|
if (StringUtils.isBlank(alertrule.getModelId())) {
|
|
msg = "风机型号不能为空";
|
|
msg = "风机型号不能为空";
|
|
result = false;
|
|
result = false;
|
|
@@ -282,7 +392,7 @@ public class AlertRuleController {
|
|
if (com.gyee.common.model.StringUtils.isNotNull(list)) {
|
|
if (com.gyee.common.model.StringUtils.isNotNull(list)) {
|
|
return AjaxResult.successData(AjaxStatus.success.code, list);
|
|
return AjaxResult.successData(AjaxStatus.success.code, list);
|
|
} else {
|
|
} else {
|
|
- return AjaxResult.successData(AjaxStatus.error.code, "ok");
|
|
|
|
|
|
+ return AjaxResult.successData(AjaxStatus.error.code, "error");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|