diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java index 7be1a2c..0a8e725 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java @@ -45,7 +45,7 @@ public interface AlarmConstants { Integer OFFSIDE = 5; Integer INTERRUPT = 13; Integer ABNORMAL = 14; - List HZ3000_ALARAM = Arrays.asList(WARNING,FAULT,OFFSIDE,INTERRUPT,ABNORMAL); + List HZ3000_ALARAM_LIST = Arrays.asList(WARNING,FAULT,OFFSIDE,INTERRUPT,ABNORMAL); Integer ONE_LEVEL = 21; Integer TWO_LEVEL = 22; Integer THREE_LEVEL = 23; diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java index 8554ba9..d662706 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.entity; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import io.swagger.models.auth.In; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; @@ -23,10 +24,10 @@ public class AlarmConfigDetailEntity extends TenantEntity { private Long strategyId; @ApiModelProperty(value = "告警大类") - private String alarmType; + private String alarmtype; @ApiModelProperty(value = "告警子类") - private String alarmChiledType; + private Integer alarmChiledType; @ApiModelProperty(value = "告警内容") private String alarmContext; diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java index 320fef5..7022fa3 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java @@ -18,6 +18,7 @@ import org.springblade.core.tenant.mp.TenantEntity; public class AlarmConfigEntity extends TenantEntity { private static final long serialVersionUID = 1L; + @ApiModelProperty(value = "站点编号") private String stationId; diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigVo.java new file mode 100644 index 0000000..67b0aef --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigVo.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.alarm.vo; + +import com.hnac.hzims.alarm.entity.AlarmConfigEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class AlarmConfigVo extends AlarmConfigEntity { + + @ApiModelProperty(value = "用户名称") + private String userName; + +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java index 9e71d7b..a9dd732 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java @@ -1,6 +1,7 @@ package com.hnac.hzims.alarm; import com.hnac.hzims.alarm.constants.AlarmConstants; +import org.mybatis.spring.annotation.MapperScan; import org.springblade.core.cloud.feign.EnableBladeFeign; import org.springblade.core.launch.BladeApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -15,6 +16,7 @@ import javax.annotation.Resource; */ @EnableBladeFeign @SpringCloudApplication +@MapperScan("com.hnac.hzims.**.mapper.**") @ComponentScan(basePackages = {"com.hnac.hzims.alarm.*"}) @Resource public class AlarmApplication extends SpringBootServletInitializer { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java index a4009be..5e17b6f 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java @@ -1,10 +1,10 @@ package com.hnac.hzims.alarm.config.controller; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import com.hnac.hzims.alarm.config.service.AlarmConfigService; +import com.hnac.hzims.alarm.entity.AlarmConfigEntity; +import com.hnac.hzims.alarm.vo.AlarmConfigVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; -import java.util.Map; /** * @author ysj @@ -31,11 +30,11 @@ public class AlarmConfigController extends BladeController { private final AlarmConfigService alarmConfigService; - @PostMapping("/save") + @PostMapping("/add") @ApiOperationSupport(order = 1) @ApiOperation(value = "新增", notes = "传入AlarmConfigEntity对象") - public R save(@Valid @RequestBody AlarmConfigEntity entity) { - return R.status(alarmConfigService.save(entity)); + public R add(@Valid @RequestBody AlarmConfigEntity entity) { + return R.status(alarmConfigService.add(entity)); } @PostMapping("/update") @@ -45,7 +44,6 @@ public class AlarmConfigController extends BladeController { return R.status(alarmConfigService.updateById(entity)); } - @PostMapping("/remove") @ApiOperationSupport(order = 3) @ApiOperation(value = "逻辑删除", notes = "传入ids") @@ -56,18 +54,8 @@ public class AlarmConfigController extends BladeController { @GetMapping("/list") @ApiOperationSupport(order = 4) @ApiOperation(value = "分页", notes = "传入AlarmConfigEntity对象") - public R> list(@ApiIgnore @RequestParam Map params, Query query) { - QueryWrapper queryWrapper = Condition.getQueryWrapper( params, AlarmConfigEntity.class); - IPage pages = alarmConfigService.page(Condition.getPage(query), queryWrapper); - return R.data(pages); - } - - @GetMapping("/detail") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "详情", notes = "传入AlarmConfigEntity对象") - public R detail(AlarmConfigEntity entity) { - AlarmConfigEntity detail = alarmConfigService.getOne(Condition.getQueryWrapper(entity)); - return R.data(detail); + public R> list(@ApiIgnore @RequestParam AlarmConfigEntity params, Query query) { + return R.data(alarmConfigService.pageCondition(Condition.getPage(query), params)); } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java index 9bad63c..4627afa 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java @@ -1,6 +1,7 @@ package com.hnac.hzims.alarm.config.service; import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; +import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import org.springblade.core.mp.base.BaseService; /** @@ -8,5 +9,8 @@ import org.springblade.core.mp.base.BaseService; */ public interface AlarmConfigDetailService extends BaseService { + boolean defaults(AlarmConfigEntity entity); + AlarmConfigDetailEntity isSupport(String code, Integer source, Integer type); + } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigService.java index 17ef3eb..eed0c2c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigService.java @@ -1,7 +1,12 @@ package com.hnac.hzims.alarm.config.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.entity.AlarmConfigEntity; +import com.hnac.hzims.alarm.vo.AlarmConfigVo; +import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.Query; import java.util.List; @@ -10,7 +15,11 @@ import java.util.List; */ public interface AlarmConfigService extends BaseService { + IPage pageCondition(IPage page,AlarmConfigEntity entity); + List exclude(Integer operate); boolean isSupport(String code,Integer source,Integer type,Integer operate); + + boolean add(AlarmConfigEntity entity); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java index 0edcd3f..9bb0635 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java @@ -2,12 +2,20 @@ package com.hnac.hzims.alarm.config.service.impl; import com.hnac.hzims.alarm.config.mapper.AlarmConfigDetailMapper; import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService; +import com.hnac.hzims.alarm.constants.AlarmConstants; import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; +import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * @author ysj */ @@ -17,6 +25,61 @@ import org.springframework.stereotype.Service; public class AlarmConfigDetailServiceImpl extends BaseServiceImpl implements AlarmConfigDetailService { /** + * 保存默认配置 + * @param entity + */ + @Override + public boolean defaults(AlarmConfigEntity entity) { + List batchs = new ArrayList<>(); + AlarmConstants.ALARAM_SOURCES.forEach(sources->{ + // HZ3000告警 + if(AlarmConstants.HZ3000_ALARM.equals(sources)){ + AlarmConstants.HZ3000_ALARAM_LIST.forEach(type->{ + batchs.add(this.superposition(entity,type)); + }); + // 等级告警 + }else if(AlarmConstants.LEVEL_ALARM.equals(sources)){ + AlarmConstants.LEVEL_ALARAM.forEach(type->{ + batchs.add(this.superposition(entity,type)); + }); + // 条件告警 + }else if(AlarmConstants.CONDITION_ALARM.equals(sources)){ + batchs.add(this.superposition(entity,AlarmConstants.CONDITION)); + // 智能预警 + }else if(AlarmConstants.EARLY_WARNING.equals(sources)){ + batchs.add(this.superposition(entity,AlarmConstants.EARLY)); + } + }); + if(CollectionUtil.isEmpty(batchs)){ + return false; + } + return super.saveBatch(batchs); + } + + /** + * 叠加配置详情记录 + * @param entity + * @param type + * @return + */ + private AlarmConfigDetailEntity superposition(AlarmConfigEntity entity, Integer type) { + AlarmConfigDetailEntity detail = new AlarmConfigDetailEntity(); + BeanUtils.copyProperties(entity,detail); + detail.setId(null); + detail.setStrategyId(entity.getId()); + detail.setAlarmChiledType(type); + detail.setIsRightTabulation(1); + detail.setIsShowAlert(1); + detail.setIsSmallBell(1); + detail.setIsMask(1); + detail.setIsBroadcast(1); + detail.setIsPlatformMessage(1); + detail.setIsShortMessage(1); + detail.setIsWxMessage(1); + return detail; + } + + /** * 查询告警配置对象 * @param code : 站点编码 * @param source : 告警来源 @@ -27,4 +90,5 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl pageCondition(IPage page, AlarmConfigEntity entity){ + IPage pages = super.page(page, Condition.getQueryWrapper(entity)); + pages.setRecords(AlarmConfigWrapper.build().listVO(pages.getRecords())); + return pages; + } + + /** * 排除站点 * @param operate : 操作类型 * @return @@ -87,6 +121,7 @@ public class AlarmConfigServiceImpl extends BaseServiceImpl { + + public static AlarmConfigWrapper build() { + return new AlarmConfigWrapper(); + } + + @Override + public AlarmConfigVo entityVO(AlarmConfigEntity entity) { + AlarmConfigVo config = BeanUtil.copy(entity, AlarmConfigVo.class); + User user = UserCache.getUser(entity.getCreateUser()); + config.setUserName(Optional.ofNullable(user).map(User::getName).orElse(null)); + return config; + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 69ff394..98c364c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -100,7 +100,7 @@ public class AlarmServiceImpl extends BaseServiceImpl private List childs(Integer source, List collect) { // HZ3000告警 if(AlarmConstants.HZ3000_ALARM.equals(source)){ - return AlarmConstants.HZ3000_ALARAM.stream().map(type->{ + return AlarmConstants.HZ3000_ALARAM_LIST.stream().map(type->{ ChildAlarmCountVo count = new ChildAlarmCountVo(); count.setType(type); if(CollectionUtil.isEmpty(collect)){ diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/LevelAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/LevelAlarmServiceImpl.java index e8f89e1..28412d3 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/LevelAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/LevelAlarmServiceImpl.java @@ -64,7 +64,7 @@ public class LevelAlarmServiceImpl implements LevelAlarmService { } LevelMessageVo message = new LevelMessageVo(); message.setProjectIds(result.getData().stream().map(StationEntity::getCode).collect(Collectors.joining(","))); - message.setType(AlarmConstants.HZ3000_ALARAM.stream().map(String::valueOf).collect(Collectors.joining(","))); + message.setType(AlarmConstants.HZ3000_ALARAM_LIST.stream().map(String::valueOf).collect(Collectors.joining(","))); message.setStartTime(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"); return JSONObject.toJSONString(message); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java index 5f38a60..3d98a08 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java @@ -1,7 +1,6 @@ package com.hnac.hzims.alarm.ws.condition; import com.hnac.hzims.alarm.show.service.ConditionAlarmService; -import com.hnac.hzims.alarm.show.service.LevelAlarmService; import com.hnac.hzims.alarm.ws.level.LevelAlarmWebSocket; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.ObjectUtil; @@ -27,8 +26,8 @@ public class ConditionAlarmRegular { private LevelAlarmWebSocket socket; - @Value("${hzims.condition.ws-url}") - private String level_wss_url; + @Value("${hzims.condition.wss-url}") + private String condition_wss_url; // 两分钟进行一次检查链接是否存活,不存活了重新建立链接 @Scheduled(cron = "0 0/2 * * * ?") @@ -52,7 +51,7 @@ public class ConditionAlarmRegular { // 创建websocket链接 private void createSocket() { try{ - socket = new LevelAlarmWebSocket(new URI(level_wss_url)); + socket = new LevelAlarmWebSocket(new URI(condition_wss_url)); socket.connectBlocking(); }catch (Exception e){ log.error("level create error : {}",e.getMessage()); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmRegular.java index fe347d3..f1b1e16 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmRegular.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmRegular.java @@ -25,7 +25,7 @@ public class LevelAlarmRegular { private LevelAlarmWebSocket socket; - @Value("${hzims.level.ws-url}") + @Value("${hzims.level.wss-url}") private String level_wss_url; // 两分钟进行一次检查链接是否存活,不存活了重新建立链接