diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmDefaultConfigEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmDefaultConfigEntity.java new file mode 100644 index 0000000..7f3a618 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmDefaultConfigEntity.java @@ -0,0 +1,53 @@ +package com.hnac.hzims.alarm.config.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + + +/** + * @author ysj + */ +@Data +@TableName("hzims_alarm_defaul_config") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "站点告警配置详情对象", description = "站点告警配置详情对象") +public class AlarmDefaultConfigEntity extends TenantEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "告警源类型") + private Integer source; + + @ApiModelProperty(value = "告警子类") + private Integer alarmChiledType; + + + @ApiModelProperty(value = "是否集中监控右侧列表展示 : 0-展示 1-不展示") + private Integer isRightTabulation; + + @ApiModelProperty(value = "是否集中监控弹窗展示 : 0-展示 1-不展示") + private Integer isShowAlert; + + @ApiModelProperty(value = "是否集中监控铃铛展示 : 0-展示 1-不展示") + private Integer isSmallBell; + + @ApiModelProperty(value = "是否集中监控遮罩展示 : 0-展示 1-不展示") + private Integer isMask; + + @ApiModelProperty(value = "是否语音播报 : 0-播报 1-不播报") + private Integer isBroadcast; + + @ApiModelProperty(value = "是否进行平台消息推送 : 0-推送 1-不推送") + private Integer isPlatformMessage; + + @ApiModelProperty(value = "是否短信推送 :0-推送 1-不推送") + private Integer isShortMessage; + + @ApiModelProperty(value = "是否微信公众号消息推送 :0-推送 1-不推送") + private Integer isWxMessage; +} + diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/DroolsAlarmVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/DroolsAlarmVo.java new file mode 100644 index 0000000..b335193 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/DroolsAlarmVo.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.alarm.config.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.Date; + + +/** + * @author ty + */ +@Data +@ApiModel(value = "规则预警对象", description = "规则预警对象") +public class DroolsAlarmVo { + private static final long serialVersionUID = 1L; + + private String excitationvoltage; + + private String deviceCode; + + private String level; + + private String type; + + private String deviceName; + + private String tenantId; + + private String name; + + private String context; + + private String guideopening; + + private String signage; + + private String projectId; + + private String currentValue; + + private Date ts; +} \ No newline at end of file diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/SoeAlarmVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/SoeAlarmVo.java new file mode 100644 index 0000000..209ef6d --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/SoeAlarmVo.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.alarm.config.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.Date; + + +/** + * @author ty + */ +@Data +@ApiModel(value = "规则预警对象", description = "规则预警对象") +public class SoeAlarmVo { + private static final long serialVersionUID = 1L; + + + private String ts; + + private String station; + + private String sid; + private String id; + private String realId; + private String type; + private String kind; + private String level; + private String state; + private String stateLabel; + private String context; + private String opvalue; + private String trace; + private String duration; + private String traceCount; + +} \ No newline at end of file diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/vo/HazardWorkVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/vo/HazardWorkVO.java new file mode 100644 index 0000000..6d6312b --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/vo/HazardWorkVO.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.safeproduct.risk.vo; + +import com.hnac.hzims.safeproduct.risk.entity.HazardWork; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author liwen + * @date 2024-04-09 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "作业区域管理页面VO类") +public class HazardWorkVO extends HazardWork { + + @ApiModelProperty("负责人名称") + private String headName; + + @ApiModelProperty("分管领导名称") + private String managerName; +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.java new file mode 100644 index 0000000..0b33965 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.alarm.config.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; +/** + * @author ysj + */ +public interface AlarmDefaultConfigMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.xml new file mode 100644 index 0000000..d87cbf5 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.xml @@ -0,0 +1,5 @@ + + + + + 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 deed511..3d14633 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 @@ -1,7 +1,11 @@ package com.hnac.hzims.alarm.config.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; import com.hnac.hzims.alarm.config.mapper.AlarmConfigDetailMapper; +import com.hnac.hzims.alarm.config.mapper.AlarmDefaultConfigMapper; import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService; import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity; @@ -16,6 +20,7 @@ import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -29,7 +34,8 @@ import java.util.stream.Collectors; @Service @Slf4j public class AlarmConfigDetailServiceImpl extends BaseServiceImpl implements AlarmConfigDetailService { - + @Autowired + private AlarmDefaultConfigMapper alarmDefaultConfigMapper; /** * 保存默认配置 * @param entity @@ -67,20 +73,37 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl() {{ + eq(AlarmDefaultConfigEntity::getSource, source); + eq(AlarmDefaultConfigEntity::getAlarmChiledType, type); + last("limit 1;"); + }}); + if (ObjectUtils.isNotEmpty(alarmDefaultConfigEntity)){ + AlarmHandleMarkVo alarmHandleMarkVo = new AlarmHandleMarkVo(); + BeanUtils.copyProperties(alarmDefaultConfigEntity,alarmHandleMarkVo); + return alarmHandleMarkVo; } return null; +// // HZ3000告警 +// if(AlarmConstants.HZ3000_ALARM.equals(source)){ +// return this.hz3000Marik(type); +// // 等级告警 +// }else if(AlarmConstants.LEVEL_ALARM.equals(source)){ +// return this.levelMark(type); +// // 条件告警 +// }else if(AlarmConstants.CONDITION_ALARM.equals(source)){ +// return this.conditionMark(type); +// // 智能预警 +// }else if(AlarmConstants.EARLY_WARNING.equals(source)){ +// return this.earlyMark(type); +// } } /** @@ -203,19 +226,28 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl() {{ + eq(AlarmDefaultConfigEntity::getSource, source); + eq(AlarmDefaultConfigEntity::getAlarmChiledType, type); + last("limit 1;"); + }}); + //赋值默认配置。无默认配置则全不发 + if (ObjectUtils.isNotEmpty(alarmDefaultConfigEntity)){ + BeanUtils.copyProperties(alarmDefaultConfigEntity,detail); + }else { + detail.setAlarmType(source); + 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); + } detail.setId(null); detail.setStrategyId(entity.getId()); - detail.setAlarmType(source); - 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; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java index 9e8c483..09651fd 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java @@ -30,6 +30,8 @@ public class MqttConfig { HZ300MqttConsumer hz300MqttConsumer; @Autowired VideoMqttConsumer videoMqttConsumer; + @Autowired + SoeMqttConsumer soeMqttConsumer; @Value("${hzims.mqtt.url}") private String mqtt_fdp_url; @@ -61,6 +63,10 @@ public class MqttConfig { DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); log.info(droolsClient.toString()); + //Soe + SoeSubscribe soeSubscribe = new SoeSubscribe(); + MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer); + log.info(soeClient.toString()); //hz3000 HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java new file mode 100644 index 0000000..5a29fff --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.alarm.mqtt; + +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.alarm.config.entity.AlarmEntity; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzims.alarm.source.service.DroolsAlarmService; +import com.hnac.hzims.alarm.source.service.SoeAlarmService; +import com.hnac.hzinfo.subscribe.SubscribeCallBack; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * + * @Author: ty + */ + +@Service +@Slf4j +public class SoeMqttConsumer implements SubscribeCallBack { + @Autowired + private SoeAlarmService soeAlarmService; + @Autowired + private AlarmSaveService alarmSaveService; + @Override + public void onMessage(Map data) { + System.out.println("监听到消息"+data.toString()); + String s = JSONObject.toJSONString(data); + //消费代码 + List alarmEntities = soeAlarmService.receiveMessage(s); + //统一数据处理 + try { + alarmSaveService.save(alarmEntities); + }catch (Exception e){ + log.error("条件告警数据处理报错(SoeAlarm):"+e); + System.out.println("规则引擎告警数据处理报错(SoeAlarm):"+e); + } + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/SoeAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/SoeAlarmService.java new file mode 100644 index 0000000..5c7a6fc --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/SoeAlarmService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.alarm.source.service; + +import com.hnac.hzims.alarm.config.entity.AlarmEntity; + +import java.util.List; + +/** + * 等级处理接口 + * @author ysj + */ +public interface SoeAlarmService { + + List receiveMessage(String message); +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java index 8667adc..f4b756a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java @@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.vo.ConditionAlarmVo; +import com.hnac.hzims.alarm.config.vo.DroolsAlarmVo; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.source.service.DroolsAlarmService; import com.hnac.hzims.alarm.source.service.MessageService; +import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import lombok.RequiredArgsConstructor; @@ -17,6 +19,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -48,7 +51,8 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService { @Override public List receiveMessage(String message) { // 对象转换 - List alarms = JSONObject.parseArray(message, ConditionAlarmVo.class); + DroolsAlarmVo parseObject= JSONObject.parseObject(message, DroolsAlarmVo.class); + List alarms = Arrays.asList(parseObject); if (CollectionUtil.isEmpty(alarms)) { return new ArrayList<>(); } @@ -59,17 +63,22 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService { return res; } - private AlarmEntity getAlarmEntity(ConditionAlarmVo item) { + private AlarmEntity getAlarmEntity(DroolsAlarmVo item) { AlarmEntity entity = new AlarmEntity(); - entity.setAlarmId(item.getFaultId()); - entity.setAlarmTime(item.getCreateTime()); - entity.setAlarmContext(item.getFinfo()); - entity.setAlarmType(CONDITION); - entity.setAlarmStatus(Integer.valueOf(String.valueOf(item.getStatus()))); - entity.setStationId(item.getStation()); + String format = DateUtil.format(item.getTs(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI); + entity.setAlarmId(format+"-"+item.getDeviceCode()); entity.setAlarmSource(CONDITION_ALARM); + entity.setAlarmType(CONDITION); + entity.setAlarmContext(item.getName()); + entity.setAlarmTime(item.getTs()); + entity.setAlarmValue(item.getCurrentValue()); + entity.setAlarmSignage(item.getSignage()); + entity.setAlarmLevel(Integer.valueOf(item.getLevel())); + entity.setAlarmStatus(1); + entity.setDeviceCode(item.getDeviceCode()); entity.setTenantId("200000"); - R stationByCode = stationClient.getStationByCode(item.getStation()); + entity.setStationId(item.getProjectId()); + R stationByCode = stationClient.getStationByCode(item.getProjectId()); if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ entity.setCreateDept(stationByCode.getData().getCreateDept()); entity.setStationName(stationByCode.getData().getName()); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index 3415705..c8007f0 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -25,13 +25,11 @@ import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.cache.DictCache; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.User; +import org.springblade.system.user.entity.UserInfo; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; import static com.hnac.hzims.operational.main.constant.MainConstants.PROJECT_MANAGER; @@ -101,12 +99,23 @@ public class MessageServiceImpl implements MessageService { log.error("短信发送失败:站点code获取失败 : {}",entity); return; } - //通知站点项目经理这个角色 - List users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData(); - if(CollectionUtil.isEmpty(users)){ - log.error("短信发送失败:获取站点项目经理用户失败 : {}",entity); - return; + List users =new ArrayList<>(); +// //通知站点项目经理这个角色 +// users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData(); +// if(CollectionUtil.isEmpty(users)){ +// log.error("短信发送失败:获取站点项目经理用户失败 : {}",entity); +// return; +// } + //写死传给固定用户 +// List phoneList=Arrays.asList("18351807087","18163793336","13725599914"); + List phoneList=Arrays.asList("18351807087","18163793336"); + for (String phone : phoneList) { + R userByPhone = userClient.getUserByPhone("200000", phone); + if (userByPhone.isSuccess()&&ObjectUtils.isNotEmpty(userByPhone.getData())){ + users.add(userByPhone.getData().getUser()); + } } + SmsImmediatelyPushDTO push = SmsImmediatelyPushDTO.builder() .deptId(entity.getCreateDept()) .taskId(entity.getId()) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java new file mode 100644 index 0000000..a3b44fe --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java @@ -0,0 +1,88 @@ +package com.hnac.hzims.alarm.source.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.hnac.hzims.alarm.config.entity.AlarmEntity; +import com.hnac.hzims.alarm.config.vo.DroolsAlarmVo; +import com.hnac.hzims.alarm.config.vo.SoeAlarmVo; +import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.source.service.DroolsAlarmService; +import com.hnac.hzims.alarm.source.service.MessageService; +import com.hnac.hzims.alarm.source.service.SoeAlarmService; +import com.hnac.hzims.common.utils.DateUtil; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import static com.hnac.hzims.alarm.config.constants.AlarmConstants.*; + +/** + * 等级告警实现类 + * @author ysj + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class SoeAlarmServiceImpl implements SoeAlarmService { + + private final AlarmService alarmService; + + private final MessageService messageService; + + private final RedisTemplate redisTemplate; + + private final IStationClient stationClient; + + + /** + * 转换接收服务推送消息 + * @param message + */ + @Override + public List receiveMessage(String message) { + // 对象转换 + SoeAlarmVo parseObject = JSONObject.parseObject(message, SoeAlarmVo.class); + List alarms = Arrays.asList(parseObject); + if (CollectionUtil.isEmpty(alarms)) { + return new ArrayList<>(); + } + List res = alarms.stream().map(s -> { + AlarmEntity entity = getAlarmEntity(s); + return entity; + }).collect(Collectors.toList()); + return res; + } + + private AlarmEntity getAlarmEntity(SoeAlarmVo item) { + AlarmEntity entity = new AlarmEntity(); + entity.setAlarmSource(LEVEL_ALARM); + entity.setAlarmType(ONE_LEVEL); + entity.setAlarmContext(item.getContext()); + Date date = new Date(Long.valueOf(item.getTs())); + entity.setAlarmTime(date); + entity.setAlarmValue(item.getOpvalue()); + entity.setAlarmSignage(item.getSid()); + entity.setAlarmLevel(Integer.valueOf(item.getLevel())); + entity.setAlarmCount(Integer.valueOf(item.getTraceCount())); + entity.setAlarmStatus(1); + entity.setDeviceCode(item.getRealId()); + entity.setTenantId("200000"); + R stationByCode = stationClient.getStationByCode(item.getStation()); + if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ + entity.setCreateDept(stationByCode.getData().getCreateDept()); + entity.setStationName(stationByCode.getData().getName()); + } + return entity; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/resources/db/2.0.0.sql b/hzims-service/hzims-alarm/src/main/resources/db/2.0.0.sql new file mode 100644 index 0000000..f149e2a --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/resources/db/2.0.0.sql @@ -0,0 +1,25 @@ + +DROP TABLE IF EXISTS `BLADE_MODULE_VERSION`; +CREATE TABLE `hzims_alarm_defaul_config` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `SOURCE` bigint(4) DEFAULT NULL COMMENT '告警来源', + `ALARM_CHILED_TYPE` bigint(4) DEFAULT NULL COMMENT '告警子类', + `IS_RIGHT_TABULATION` tinyint(4) DEFAULT NULL COMMENT '是否集中监控右侧列表展示 : 0-展示 1-不展示', + `IS_SHOW_ALERT` tinyint(4) DEFAULT NULL COMMENT '是否集中监控弹窗展示 : 0-展示 1-不展示', + `IS_SMALL_BELL` tinyint(4) DEFAULT NULL COMMENT '是否集中监控铃铛展示 : 0-展示 1-不展示', + `IS_MASK` tinyint(4) DEFAULT NULL COMMENT '是否集中监控遮罩展示 : 0-展示 1-不展示', + `IS_BROADCAST` tinyint(4) DEFAULT NULL COMMENT '是否语音播报 : 0-播报 1-不播报', + `IS_PLATFORM_MESSAGE` tinyint(4) DEFAULT NULL COMMENT '是否进行平台消息推送 : 0-推送 1-不推送', + `IS_SHORT_MESSAGE` tinyint(4) DEFAULT NULL COMMENT '是否短信推送 :0-推送 1-不推送', + `IS_WX_MESSAGE` tinyint(4) DEFAULT NULL COMMENT '是否微信公众号消息推送 :0-推送 1-不推送', + `TENANT_ID` varchar(12) NOT NULL COMMENT '租户ID', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建部门ID', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '更新人', + `IS_DELETED` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除', + `STATUS` tinyint(4) DEFAULT NULL COMMENT '状态', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java index cad2485..4203b1b 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java @@ -1,11 +1,10 @@ package com.hnac.hzims.safeproduct.risk.controller; - import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.safeproduct.risk.dto.CorrelationDTO; import com.hnac.hzims.safeproduct.risk.entity.HazardWork; import com.hnac.hzims.safeproduct.risk.service.HazardWorkService; +import com.hnac.hzims.safeproduct.risk.vo.HazardWorkVO; import com.hnac.hzims.safeproduct.risk.vo.PersonalCheckItemVO; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -68,15 +67,16 @@ public class HazardWorkController { return R.data(service.getById(id)); } - /** * 分页 */ @GetMapping("/pageList") @ApiOperationSupport(order = 60) @ApiOperation(value = "分页", notes = "查询条件:item") - public R> page(HazardWork entity, Query query) { - return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(entity))); + public R> page(HazardWork entity, Query query) { + IPage page = service.getHazardWorkPage(entity, query); + return R.data(page); +// return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(entity))); } @GetMapping("/getCheckItemByDutyPerson") diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java index 35cfefa..545d6d3 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java @@ -1,9 +1,11 @@ package com.hnac.hzims.safeproduct.risk.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.safeproduct.risk.entity.HazardWork; +import com.hnac.hzims.safeproduct.risk.vo.HazardWorkVO; import com.hnac.hzims.safeproduct.risk.vo.PersonalCheckItemVO; -import com.hnac.hzims.safeproduct.risk.vo.StationRiskLevelVo; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.Query; import java.util.List; @@ -15,4 +17,12 @@ public interface HazardWorkService extends BaseService { boolean deleteBacth(List workIds); List getCheckItemByDutyPerson(Long userId,Long categoryId); + + /** + * 查询作业区域页面数据 + * @param entity 入参 + * @param query 分页类 + * @return 作业区域页面 + */ + IPage getHazardWorkPage(HazardWork entity, Query query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java index f013a4f..03688b7 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java @@ -1,6 +1,8 @@ package com.hnac.hzims.safeproduct.risk.service.impl; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.safeproduct.risk.entity.Correlation; import com.hnac.hzims.safeproduct.risk.entity.HazardCategory; import com.hnac.hzims.safeproduct.risk.entity.HazardSource; @@ -10,18 +12,23 @@ import com.hnac.hzims.safeproduct.risk.service.CorrelationService; import com.hnac.hzims.safeproduct.risk.service.HazardCategoryService; import com.hnac.hzims.safeproduct.risk.service.HazardSourceService; import com.hnac.hzims.safeproduct.risk.service.HazardWorkService; +import com.hnac.hzims.safeproduct.risk.vo.HazardWorkVO; import com.hnac.hzims.safeproduct.risk.vo.PersonalCheckItemVO; -import com.hnac.hzims.safeproduct.risk.vo.StationRiskLevelVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -38,6 +45,8 @@ public class HazardWorkServiceImpl extends BaseServiceImpl getHazardWorkPage(HazardWork entity, Query query) { + IPage hazardWorkPage = this.page(Condition.getPage(query), Condition.getQueryWrapper(entity)); + List records = hazardWorkPage.getRecords(); + List res = new ArrayList<>(); + // 遍历获取负责人和分管领导名称 + for (HazardWork record : records) { + HazardWorkVO hazardWorkVO = new HazardWorkVO(); + BeanUtil.copyProperties(record, hazardWorkVO); + Long headId = record.getHead(); + if (headId != null) { + R header = userClient.userInfoById(headId); + if (header.isSuccess()) { + hazardWorkVO.setHeadName(header.getData().getRealName()); + } + } + Long manageId = record.getManage(); + if (manageId != null) { + R manager = userClient.userInfoById(manageId); + if (manager.isSuccess()) { + hazardWorkVO.setManagerName(manager.getData().getRealName()); + } + } + res.add(hazardWorkVO); + } + // 分页 + IPage page = new Page<>(query.getCurrent(), query.getSize()); + page.setRecords(res); + page.setTotal(hazardWorkPage.getTotal()); + page.setPages(hazardWorkPage.getPages()); + return page; + } }