123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637 |
- package com.gyee.alarm.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.gyee.alarm.init.CacheContext;
- import com.gyee.alarm.model.auto.*;
- import com.gyee.alarm.model.vo.*;
- import com.gyee.alarm.service.AlarmRuleService;
- import com.gyee.alarm.service.TokenService;
- import com.gyee.alarm.service.auto.IProEconAlarmTypeService;
- import com.gyee.alarm.util.ExcelUtils;
- import com.gyee.alarm.util.SnowflakeGenerator;
- import com.gyee.alarm.util.StringUtils;
- import com.gyee.common.util.DateUtils;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.context.request.RequestContextHolder;
- import org.springframework.web.context.request.ServletRequestAttributes;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.util.*;
- @Slf4j
- @RestController
- @RequestMapping("/alertrule")
- @CrossOrigin
- @Api(value = "自定义报警规则", tags = "自定义报警规则")
- public class AlertRuleController {
- @Autowired
- private AlarmRuleService alarmRuleService;
- @Resource
- private IProEconAlarmTypeService proEconAlarmTypeService;
- @Resource
- private TokenService tokenService;
- @GetMapping(value = "/querywtalarmdesclist")
- @ApiOperation(value = "通过场站、型号和部件查询报警描述信息", notes = "通过场站、型号和部件查询报警描述信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "modelId", value = "型号", required = true, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "components", value = "部件", required = true, dataType = "string", paramType = "query")})
- public AjaxResult queryWtAlarmDescList(String wpId, String modelId,String components) {
- List<AlarmConfigurationVo> vos=new ArrayList<>();
- if (StringUtils.notEmp(wpId) && StringUtils.notEmp(modelId) && StringUtils.notEmp(components)) {
- vos= alarmRuleService.queryWtAlarmDescList(wpId, modelId,components);
- }
- if (StringUtils.notEmp(vos)) {
- return AjaxResult.successData(AjaxStatus.success.code, vos);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/querymodellist")
- @ApiOperation(value = "查询型号信息", notes = "查询型号信息")
- public AjaxResult queryModelList(String wpId) {
- List<String> modells=new ArrayList<>();
- if(StringUtils.notEmp( wpId) && CacheContext.wpwtmap.containsKey(wpId))
- {
- List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(wpId);
- for(ProBasicEquipment wt:wtls)
- {
- if(!modells.contains(wt.getModelId()))
- {
- modells.add(wt.getModelId());
- }
- }
- }else if(StringUtils.notEmp( wpId) && CacheContext.subWtsMap.containsKey(wpId))
- {
- List<ProBasicEquipment> wtls=CacheContext.subWtsMap.get(wpId);
- for(ProBasicEquipment wt:wtls)
- {
- if(!modells.contains(wt.getModelId()))
- {
- modells.add(wt.getModelId());
- }
- }
- }else
- {
- List<ProEconEquipmentmodel> wtls=CacheContext.equipmentmodels;
- for(ProEconEquipmentmodel wt:wtls)
- {
- if(!modells.contains(wt.getId()))
- {
- modells.add(wt.getId());
- }
- }
- }
- if (StringUtils.notEmp(modells)) {
- return AjaxResult.successData(AjaxStatus.success.code, modells);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/list")
- @ApiOperation(value = "查询报警关联部件名称", notes = "查询报警关联部件名称")
- public AjaxResult queryTree() {
- List<AlarmRuleVo> alertrules = alarmRuleService.queryTree();
- if (StringUtils.notEmp(alertrules)) {
- return AjaxResult.successData(AjaxStatus.success.code, alertrules);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/queryalarmswitchllist")
- @ApiOperation(value = "查询报警开关", notes = "查询报警开关")
- public AjaxResult queryAlarmSwitchlList() {
- List<ProEconAlarmSwitch> vos = CacheContext.asls;
- if (StringUtils.notEmp(vos)) {
- return AjaxResult.successData(AjaxStatus.success.code, vos);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/queryalarmtypellist")
- @ApiOperation(value = "查询报警类型和预警类型", notes = "查询报警类型和预警类型")
- public AjaxResult queryalAarmTypelList() {
- Map<String, List<ProEconAlarmType>> map = new HashMap<>();
- List<ProEconAlarmType> typels = proEconAlarmTypeService.list();
- List<ProEconAlarmType> fjbjls = new ArrayList<>();
- List<ProEconAlarmType> gfbjls = new ArrayList<>();
- List<ProEconAlarmType> yjls = new ArrayList<>();
- List<ProEconAlarmType> sdls = new ArrayList<>();
- if (!typels.isEmpty()) {
- for (ProEconAlarmType type : typels) {
- if (type.getCategory().equals(AlarmType.FJBJ.getCode())) {
- fjbjls.add(type);
- }else if (type.getCategory().equals(AlarmType.GFBJ.getCode())) {
- gfbjls.add(type);
- } else if (type.getCategory().equals(AlarmType.YJ.getCode())) {
- yjls.add(type);
- } else if (type.getCategory().equals(AlarmType.SD.getCode())) {
- sdls.add(type);
- }
- }
- }
- map.put("fjbj", fjbjls);
- map.put("gfbj", gfbjls);
- map.put("yj", yjls);
- map.put("sd", sdls);
- if (StringUtils.notEmp(map)) {
- return AjaxResult.successData(AjaxStatus.success.code, map);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/querywpllist")
- @ApiOperation(value = "查询场站列表", notes = "查询场站列表")
- public AjaxResult queryWplList(String types) {
- HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
- List<ProBasicPowerstation> wpls = tokenService.getWpls(request);
- List<ProBasicPowerstation> vos = new ArrayList<>();
- if(!wpls.isEmpty())
- {
- for(ProBasicPowerstation wp:wpls)
- {
- if(StringUtils.notEmp(types))
- {
- if(types.equals(AlarmTypeValue.WT.getCode()) && wp.getId().contains("FDC"))
- {
- vos.add(wp);
- }else if(types.equals(AlarmTypeValue.IN.getCode()) && wp.getId().contains("GDC"))
- {
- vos.add(wp);
- }else if(types.equals(AlarmTypeValue.BT.getCode()))
- {
- List<ProBasicSubStation> subwpls = tokenService.getSubwpls(request);
- return AjaxResult.successData(AjaxStatus.success.code, subwpls);
- }
- }else
- {
- vos =wpls;
- }
- }
- }
- if (StringUtils.notEmp(vos)) {
- return AjaxResult.successData(AjaxStatus.success.code, vos);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/querywtlist")
- @ApiOperation(value = "通过场站获得设备信息", notes = "通过场站获得设备信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")})
- public AjaxResult queryWtList(String wpId) {
- List<ProBasicEquipment> wtls = new ArrayList<>();
- if (StringUtils.notEmp(wpId) && CacheContext.wpwtmap.containsKey(wpId)) {
- wtls = CacheContext.wpwtmap.get(wpId);
- }
- if (StringUtils.notEmp(wtls)) {
- return AjaxResult.successData(AjaxStatus.success.code, wtls);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/querywtpointlist")
- @ApiOperation(value = "通过场站和型号查询测点信息", notes = "通过场站和型号查询测点信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "modelId", value = "型号", required = true, dataType = "string", paramType = "query")})
- public AjaxResult queryWtPointlList(String wpId, String modelId) {
- Map<String, List<ProBasicEquipmentPoint>> map = new HashMap<>();
- if (StringUtils.notEmp(wpId) && StringUtils.notEmp(modelId) && CacheContext.wpwtmap.containsKey(wpId)) {
- List<ProBasicEquipment> wtls = CacheContext.wpwtmap.get(wpId);
- List<ProBasicEquipmentPoint> ailist = new ArrayList<>();
- List<ProBasicEquipmentPoint> dilist = new ArrayList<>();
- List<ProBasicEquipmentPoint> list = new ArrayList<>();
- for (ProBasicEquipment wt : wtls) {
- if (wt.getModelId().equals(modelId) && CacheContext.wtpAimap.containsKey(wt.getId())) {
- Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wt.getId());
- for (Map.Entry<String, ProBasicEquipmentPoint> entry : wtpointmap.entrySet()) {
- if (entry.getKey().contains("AI")) {
- ailist.add(entry.getValue());
- } else if (entry.getKey().contains("DI")) {
- dilist.add(entry.getValue());
- }
- list.add(entry.getValue());
- }
- break;
- }
- }
- map.put("ai", ailist);
- map.put("di", dilist);
- map.put("total", list);
- }
- if (StringUtils.notEmp(map)) {
- return AjaxResult.successData(AjaxStatus.success.code, map);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/querysubllist")
- @ApiOperation(value = "获得升压站列表信息", notes = "获得升压站列表信息")
- public AjaxResult querySublList() {
- HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
- List<ProBasicSubStation> subwpls = tokenService.getSubwpls(request);
- if (StringUtils.notEmp(subwpls)) {
- return AjaxResult.successData(AjaxStatus.success.code, subwpls);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/queryalarmrule")
- @ApiOperation(value = "根据主键获得报警规则", notes = "根据主键获得报警规则")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "报警规则主键", required = true, dataType = "string", paramType = "query")})
- public AjaxResult queryAlarmRule(String id) {
- ProEconAlarmRule alarmRule = null;
- if (StringUtils.notEmp(id)) {
- alarmRule = alarmRuleService.selectByAlertruleId(id);
- }
- if (StringUtils.notEmp(alarmRule)) {
- return AjaxResult.successData(AjaxStatus.success.code, alarmRule);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/querysubpointllist")
- @ApiOperation(value = "获得升压站主键获得测点信息", notes = "获得升压站主键获得测点信息")
- 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<>();
- List<ProBasicPowerstationPoint> list = 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());
- }
- list.add(entry.getValue());
- }
- map.put("ai", ailist);
- map.put("di", dilist);
- map.put("total", list);
- }
- if (StringUtils.notEmp(map)) {
- return AjaxResult.successData(AjaxStatus.success.code, map);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @GetMapping(value = "/querywpbyymodellist")
- @ApiOperation(value = "通过场站编号获得型号下拉列表", notes = "通过场站编号获得型号下拉列表")
- 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");
- }
- }
- @GetMapping(value = "/queryctalarmdesclist")
- @ApiOperation(value = "通过场站、型号和部件查询报警描述信息", notes = "通过场站、型号和部件查询报警描述信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "modelId", value = "型号", required = true, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "components", value = "部件", required = true, dataType = "string", paramType = "query")})
- public AjaxResult queryCtAlarmDescList(String wpId, String modelId,String components) {
- List<AlarmConfigurationVo> vos=new ArrayList<>();
- if (StringUtils.notEmp(wpId) && StringUtils.notEmp(modelId) && StringUtils.notEmp(components)) {
- vos= alarmRuleService.queryCtAlarmDescList(wpId, modelId,components);
- }
- if (StringUtils.notEmp(vos)) {
- return AjaxResult.successData(AjaxStatus.success.code, vos);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- //@UserLoginToken
- @PostMapping(value = "/save")
- @ResponseBody
- @ApiOperation(value = "进行修改和保存", notes = "进行修改和保存")
- public AjaxResult saveAndUpdateAlertrule(HttpServletRequest request, @RequestBody ProEconAlarmRule alarmRule) throws Exception {
- if (StringUtils.notEmp(alarmRule)) {
- int result = alarmRuleService.saveAndUpdateAlertrule(alarmRule);
- return AjaxResult.successData(AjaxStatus.success.code, result);
- } else {
- return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
- }
- }
- @DeleteMapping(value = "/delete")
- @ApiOperation(value = "删除", notes = "删除")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "自定义报警主键", required = true, dataType = "string", paramType = "query")})
- public AjaxResult deleteAlertrule(String id) {
- int i = alarmRuleService.deleteAlertrule(id);
- if (StringUtils.notEmp(i)) {
- return AjaxResult.successData(AjaxStatus.success.code, i);
- } else {
- return AjaxResult.successData(AjaxStatus.error.code, "error");
- }
- }
- //@UserLoginToken
- @GetMapping(value = "/page")
- @ApiOperation(value = "分页查询", notes = "分页查询")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "pageNum", value = "页号", required = true, dataType = "Integer", paramType = "query"),
- @ApiImplicitParam(name = "pageSize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
- @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "wpId", value = "风场编号", required = false, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "modelId", value = "型号编号", required = false, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "rank", value = "级别", required = false, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "category", value = "类别(booststation:升压站报警,windturbine:风机报警,inverter:逆变器)", required = false, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "enabled", value = "是否可用", required = false, dataType = "string", paramType = "query"),
- @ApiImplicitParam(name = "relatedparts", value = "部件", required = false, dataType = "string", paramType = "query")})
- public AjaxResult queryByPage(HttpServletRequest request,
- @RequestParam(value = "pageNum") Integer pageNum,
- @RequestParam(value = "pageSize") Integer pageSize,
- @RequestParam(value = "name", required = false) String name,
- @RequestParam(value = "wpId", required = false) String wpId,
- @RequestParam(value = "modelId", required = false) String modelId,
- @RequestParam(value = "rank", required = false) Integer rank,
- @RequestParam(value = "category", required = false) String category,
- @RequestParam(value = "enabled", required = false) Boolean enabled,
- @RequestParam(value = "relatedparts", required = false) String relatedparts
- ) {
- Page<ProEconAlarmRule> page = new Page(pageNum, pageSize);
- IPage<ProEconAlarmRule> pageResult = alarmRuleService.pageQueryAll(page, name, wpId, modelId, rank, category, enabled, relatedparts);
- if (StringUtils.notEmp(pageResult)) {
- return AjaxResult.successData(AjaxStatus.success.code, pageResult);
- } else {
- return AjaxResult.successData(AjaxStatus.error.code, "error");
- }
- }
- //@UserLoginToken
- @PostMapping(value = "/save-batch")
- @ResponseBody
- @ApiOperation(value = "批量保存", notes = "分页查询")
- public AjaxResult saveAlertruleBatch(HttpServletRequest request, @RequestBody List<ProEconAlarmRule> lst) throws Exception {
- boolean allCheck = true;
- for (ProEconAlarmRule alertrule : lst) {
- 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;
- } else if (StringUtils.isBlank(alertrule.getUniformCode())) {
- msg = "统一编码不能为空";
- result = false;
- }
- if (alertrule.getCategory().equals(AlarmCustomType.WT.getCode())) {
- if (StringUtils.isBlank(alertrule.getModelId())) {
- msg = "风机型号不能为空";
- result = false;
- }
- }
- if (result != true) {
- allCheck = false;
- if (!result) {
- return AjaxResult.successData(AjaxStatus.error.code, msg);
- }
- }
- }
- if (allCheck) {
- for (ProEconAlarmRule alertRule : lst) {
- int result = alarmRuleService.saveAndUpdateAlertrule(alertRule);
- if (result <= 0) {
- return AjaxResult.successData(AjaxStatus.error.code, alertRule.getName() + ":" + "操作数据库失败");
- }
- }
- return AjaxResult.successData(AjaxStatus.success.code, "ok");
- } else {
- return AjaxResult.successData(AjaxStatus.error.code, "error");
- }
- }
- @GetMapping("/get-import-template")
- @ApiOperation(value = "获得导入模板")
- public void importTemplate(HttpServletResponse response) throws IOException {
- // 手动创建导出 demo
- Date current = com.gyee.common.util.DateUtils.getCurrentDate();
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(current);
- calendar.add(Calendar.DAY_OF_MONTH, -1);
- Date previousDay = calendar.getTime();
- List<ProEconAlarmRule> list = Arrays.asList(
- ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度1温度传感器异常值").description("温度等于850度或者温度小于零下40度")
- .expression("AI242 == 850 || AI242 <-40").tag("").rank(4).modelId("UP2000")
- .category("windturbine").range("parts")
- .stationId("SXJ_KGDL_GJY_FDC_STA").projectId("SXJ_KGDL_GJYF01_EG").lineId("SXJ_KGDL_GJYF01_LN").deviceId("SXJ_KGDL_GJY_F_WT_0001_EQ")
- .electricalId("").relatedParts("BJXT").createTime(DateUtils.truncate(previousDay))
- .enable(true).uniformCode("AI091")
- .build(),
- ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度1温度传感器异常值").description("温度等于850度或者温度小于零下40度")
- .expression("AI242 == 850 || AI242 <-40").tag("").rank(4).modelId("UP2000")
- .category("windturbine").range("parts")
- .stationId("SXJ_KGDL_GJY_FDC_STA").projectId("SXJ_KGDL_GJYF01_EG").lineId("SXJ_KGDL_GJYF01_LN").deviceId("SXJ_KGDL_GJY_F_WT_0001_EQ")
- .electricalId("").relatedParts("BJXT").createTime(DateUtils.truncate(previousDay))
- .enable(true).uniformCode("AI091")
- .build()
- );
- // 输出
- ExcelUtils.write(response, "导入模板.xls", "导入模板", ProEconAlarmRule.class, list);
- }
- @PostMapping("/import")
- @ApiOperation(value = "导入", notes = "导入")
- public AjaxResult importExcel(@RequestParam("file") MultipartFile file) throws Exception {
- List<ProEconAlarmRule> list = ExcelUtils.read(file, ProEconAlarmRule.class);
- if (com.gyee.common.model.StringUtils.notEmp(list) && !list.isEmpty()) {
- boolean allCheck = true;
- for (ProEconAlarmRule alertrule : list) {
- 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;
- } else if (StringUtils.isBlank(alertrule.getUniformCode())) {
- msg = "统一编码不能为空";
- result = false;
- }
- if (alertrule.getCategory().equals(AlarmCustomType.WT.getCode())) {
- if (StringUtils.isBlank(alertrule.getModelId())) {
- msg = "风机型号不能为空";
- result = false;
- }
- }
- if (result != true) {
- allCheck = false;
- if (!result) {
- return AjaxResult.successData(AjaxStatus.error.code, msg);
- }
- }
- if (allCheck) {
- alarmRuleService.saveAndUpdateAlertrule(alertrule);
- }
- }
- }
- if (com.gyee.common.model.StringUtils.isNotNull(list)) {
- return AjaxResult.successData(AjaxStatus.success.code, list);
- } else {
- return AjaxResult.successData(AjaxStatus.error.code, "error");
- }
- }
- }
|