Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 8 months ago
parent
commit
19237795c2
  1. 53
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmDefaultConfigEntity.java
  2. 42
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/DroolsAlarmVo.java
  3. 36
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/SoeAlarmVo.java
  4. 23
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/vo/HazardWorkVO.java
  5. 10
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.java
  6. 5
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.xml
  7. 80
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java
  8. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java
  9. 42
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java
  10. 14
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/SoeAlarmService.java
  11. 27
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java
  12. 27
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java
  13. 88
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java
  14. 25
      hzims-service/hzims-alarm/src/main/resources/db/2.0.0.sql
  15. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java
  16. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java
  17. 47
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java

53
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;
}

42
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;
}

36
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;
}

23
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;
}

10
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<AlarmDefaultConfigEntity> {
}

5
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmDefaultConfigMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.alarm.config.mapper.AlarmDefaultConfigMapper">
</mapper>

80
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; 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.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.AlarmConfigDetailMapper;
import com.hnac.hzims.alarm.config.mapper.AlarmDefaultConfigMapper;
import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService; import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService;
import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity; 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.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -29,7 +34,8 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class AlarmConfigDetailServiceImpl extends BaseServiceImpl<AlarmConfigDetailMapper, AlarmConfigDetailEntity> implements AlarmConfigDetailService { public class AlarmConfigDetailServiceImpl extends BaseServiceImpl<AlarmConfigDetailMapper, AlarmConfigDetailEntity> implements AlarmConfigDetailService {
@Autowired
private AlarmDefaultConfigMapper alarmDefaultConfigMapper;
/** /**
* 保存默认配置 * 保存默认配置
* @param entity * @param entity
@ -67,20 +73,37 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl<AlarmConfigDet
*/ */
@Override @Override
public AlarmHandleMarkVo defaultMark(Integer source,Integer type) { public AlarmHandleMarkVo defaultMark(Integer source,Integer type) {
// HZ3000告警 // 告警来源 : 0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 4-视频预警 5-开关机告警
if(AlarmConstants.HZ3000_ALARM.equals(source)){ // 子类告警
return this.hz3000Marik(type); // HZ3000告警 : 2-告警 3-故障 5-遥测越限 13-通讯中断 14-数据异常
// 等级告警 // 等级告警 : 21-一级告警 22-二级告警 23-三级告警
}else if(AlarmConstants.LEVEL_ALARM.equals(source)){ // 智能预警 : 30-智能预警
return this.levelMark(type); // 条件告警 : 40-条件告警
// 条件告警 // 开关机告警 : 50-开机告警 51-关机告警
}else if(AlarmConstants.CONDITION_ALARM.equals(source)){ AlarmDefaultConfigEntity alarmDefaultConfigEntity = alarmDefaultConfigMapper.selectOne(new LambdaQueryWrapper<AlarmDefaultConfigEntity>() {{
return this.conditionMark(type); eq(AlarmDefaultConfigEntity::getSource, source);
// 智能预警 eq(AlarmDefaultConfigEntity::getAlarmChiledType, type);
}else if(AlarmConstants.EARLY_WARNING.equals(source)){ last("limit 1;");
return this.earlyMark(type); }});
if (ObjectUtils.isNotEmpty(alarmDefaultConfigEntity)){
AlarmHandleMarkVo alarmHandleMarkVo = new AlarmHandleMarkVo();
BeanUtils.copyProperties(alarmDefaultConfigEntity,alarmHandleMarkVo);
return alarmHandleMarkVo;
} }
return null; 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<AlarmConfigDet
*/ */
private AlarmConfigDetailEntity superposition(AlarmConfigEntity entity,Integer source, Integer type) { private AlarmConfigDetailEntity superposition(AlarmConfigEntity entity,Integer source, Integer type) {
AlarmConfigDetailEntity detail = new AlarmConfigDetailEntity(); AlarmConfigDetailEntity detail = new AlarmConfigDetailEntity();
BeanUtils.copyProperties(entity,detail); AlarmDefaultConfigEntity alarmDefaultConfigEntity = alarmDefaultConfigMapper.selectOne(new LambdaQueryWrapper<AlarmDefaultConfigEntity>() {{
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.setId(null);
detail.setStrategyId(entity.getId()); 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; return detail;
} }

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java

@ -30,6 +30,8 @@ public class MqttConfig {
HZ300MqttConsumer hz300MqttConsumer; HZ300MqttConsumer hz300MqttConsumer;
@Autowired @Autowired
VideoMqttConsumer videoMqttConsumer; VideoMqttConsumer videoMqttConsumer;
@Autowired
SoeMqttConsumer soeMqttConsumer;
@Value("${hzims.mqtt.url}") @Value("${hzims.mqtt.url}")
private String mqtt_fdp_url; private String mqtt_fdp_url;
@ -61,6 +63,10 @@ public class MqttConfig {
DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe();
MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer);
log.info(droolsClient.toString()); log.info(droolsClient.toString());
//Soe
SoeSubscribe soeSubscribe = new SoeSubscribe();
MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer);
log.info(soeClient.toString());
//hz3000 //hz3000
HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe();
MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer);

42
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<String, Object> data) {
System.out.println("监听到消息"+data.toString());
String s = JSONObject.toJSONString(data);
//消费代码
List<AlarmEntity> alarmEntities = soeAlarmService.receiveMessage(s);
//统一数据处理
try {
alarmSaveService.save(alarmEntities);
}catch (Exception e){
log.error("条件告警数据处理报错(SoeAlarm):"+e);
System.out.println("规则引擎告警数据处理报错(SoeAlarm):"+e);
}
}
}

14
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<AlarmEntity> receiveMessage(String message);
}

27
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.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.config.vo.ConditionAlarmVo; 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.show.service.AlarmService;
import com.hnac.hzims.alarm.source.service.DroolsAlarmService; import com.hnac.hzims.alarm.source.service.DroolsAlarmService;
import com.hnac.hzims.alarm.source.service.MessageService; 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.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -17,6 +19,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -48,7 +51,8 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService {
@Override @Override
public List<AlarmEntity> receiveMessage(String message) { public List<AlarmEntity> receiveMessage(String message) {
// 对象转换 // 对象转换
List<ConditionAlarmVo> alarms = JSONObject.parseArray(message, ConditionAlarmVo.class); DroolsAlarmVo parseObject= JSONObject.parseObject(message, DroolsAlarmVo.class);
List<DroolsAlarmVo> alarms = Arrays.asList(parseObject);
if (CollectionUtil.isEmpty(alarms)) { if (CollectionUtil.isEmpty(alarms)) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -59,17 +63,22 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService {
return res; return res;
} }
private AlarmEntity getAlarmEntity(ConditionAlarmVo item) { private AlarmEntity getAlarmEntity(DroolsAlarmVo item) {
AlarmEntity entity = new AlarmEntity(); AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getFaultId()); String format = DateUtil.format(item.getTs(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI);
entity.setAlarmTime(item.getCreateTime()); entity.setAlarmId(format+"-"+item.getDeviceCode());
entity.setAlarmContext(item.getFinfo());
entity.setAlarmType(CONDITION);
entity.setAlarmStatus(Integer.valueOf(String.valueOf(item.getStatus())));
entity.setStationId(item.getStation());
entity.setAlarmSource(CONDITION_ALARM); 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"); entity.setTenantId("200000");
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getStation()); entity.setStationId(item.getProjectId());
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getProjectId());
if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){
entity.setCreateDept(stationByCode.getData().getCreateDept()); entity.setCreateDept(stationByCode.getData().getCreateDept());
entity.setStationName(stationByCode.getData().getName()); entity.setStationName(stationByCode.getData().getName());

27
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.cache.DictCache;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.entity.UserInfo;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.hnac.hzims.operational.main.constant.MainConstants.PROJECT_MANAGER; import static com.hnac.hzims.operational.main.constant.MainConstants.PROJECT_MANAGER;
@ -101,12 +99,23 @@ public class MessageServiceImpl implements MessageService {
log.error("短信发送失败:站点code获取失败 : {}",entity); log.error("短信发送失败:站点code获取失败 : {}",entity);
return; return;
} }
//通知站点项目经理这个角色 List<User> users =new ArrayList<>();
List<User> users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData(); // //通知站点项目经理这个角色
if(CollectionUtil.isEmpty(users)){ // users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData();
log.error("短信发送失败:获取站点项目经理用户失败 : {}",entity); // if(CollectionUtil.isEmpty(users)){
return; // log.error("短信发送失败:获取站点项目经理用户失败 : {}",entity);
// return;
// }
//写死传给固定用户
// List<String> phoneList=Arrays.asList("18351807087","18163793336","13725599914");
List<String> phoneList=Arrays.asList("18351807087","18163793336");
for (String phone : phoneList) {
R<UserInfo> userByPhone = userClient.getUserByPhone("200000", phone);
if (userByPhone.isSuccess()&&ObjectUtils.isNotEmpty(userByPhone.getData())){
users.add(userByPhone.getData().getUser());
}
} }
SmsImmediatelyPushDTO push = SmsImmediatelyPushDTO.builder() SmsImmediatelyPushDTO push = SmsImmediatelyPushDTO.builder()
.deptId(entity.getCreateDept()) .deptId(entity.getCreateDept())
.taskId(entity.getId()) .taskId(entity.getId())

88
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<AlarmEntity> receiveMessage(String message) {
// 对象转换
SoeAlarmVo parseObject = JSONObject.parseObject(message, SoeAlarmVo.class);
List<SoeAlarmVo> alarms = Arrays.asList(parseObject);
if (CollectionUtil.isEmpty(alarms)) {
return new ArrayList<>();
}
List<AlarmEntity> 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<StationEntity> stationByCode = stationClient.getStationByCode(item.getStation());
if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){
entity.setCreateDept(stationByCode.getData().getCreateDept());
entity.setStationName(stationByCode.getData().getName());
}
return entity;
}
}

25
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;

10
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; package com.hnac.hzims.safeproduct.risk.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; 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.entity.HazardWork;
import com.hnac.hzims.safeproduct.risk.service.HazardWorkService; 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.PersonalCheckItemVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -68,15 +67,16 @@ public class HazardWorkController {
return R.data(service.getById(id)); return R.data(service.getById(id));
} }
/** /**
* 分页 * 分页
*/ */
@GetMapping("/pageList") @GetMapping("/pageList")
@ApiOperationSupport(order = 60) @ApiOperationSupport(order = 60)
@ApiOperation(value = "分页", notes = "查询条件:item") @ApiOperation(value = "分页", notes = "查询条件:item")
public R<IPage<HazardWork>> page(HazardWork entity, Query query) { public R<IPage<HazardWorkVO>> page(HazardWork entity, Query query) {
return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(entity))); IPage<HazardWorkVO> page = service.getHazardWorkPage(entity, query);
return R.data(page);
// return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(entity)));
} }
@GetMapping("/getCheckItemByDutyPerson") @GetMapping("/getCheckItemByDutyPerson")

12
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; 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.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.PersonalCheckItemVO;
import com.hnac.hzims.safeproduct.risk.vo.StationRiskLevelVo;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
import java.util.List; import java.util.List;
@ -15,4 +17,12 @@ public interface HazardWorkService extends BaseService<HazardWork> {
boolean deleteBacth(List<Long> workIds); boolean deleteBacth(List<Long> workIds);
List<PersonalCheckItemVO> getCheckItemByDutyPerson(Long userId,Long categoryId); List<PersonalCheckItemVO> getCheckItemByDutyPerson(Long userId,Long categoryId);
/**
* 查询作业区域页面数据
* @param entity 入参
* @param query 分页类
* @return 作业区域页面
*/
IPage<HazardWorkVO> getHazardWorkPage(HazardWork entity, Query query);
} }

47
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; 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.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.Correlation;
import com.hnac.hzims.safeproduct.risk.entity.HazardCategory; import com.hnac.hzims.safeproduct.risk.entity.HazardCategory;
import com.hnac.hzims.safeproduct.risk.entity.HazardSource; 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.HazardCategoryService;
import com.hnac.hzims.safeproduct.risk.service.HazardSourceService; import com.hnac.hzims.safeproduct.risk.service.HazardSourceService;
import com.hnac.hzims.safeproduct.risk.service.HazardWorkService; 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.PersonalCheckItemVO;
import com.hnac.hzims.safeproduct.risk.vo.StationRiskLevelVo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl; 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.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -38,6 +45,8 @@ public class HazardWorkServiceImpl extends BaseServiceImpl<HazardWorkMapper, Haz
private final HazardSourceService hazardSourceService; private final HazardSourceService hazardSourceService;
private final HazardCategoryService hazardCategoryService; private final HazardCategoryService hazardCategoryService;
private final IUserClient userClient;
/** /**
* 作业区域删除 * 作业区域删除
* @param workIds * @param workIds
@ -79,4 +88,40 @@ public class HazardWorkServiceImpl extends BaseServiceImpl<HazardWorkMapper, Haz
}); });
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
/**
* 查询作业区域页面数据
*/
@Override
public IPage<HazardWorkVO> getHazardWorkPage(HazardWork entity, Query query) {
IPage<HazardWork> hazardWorkPage = this.page(Condition.getPage(query), Condition.getQueryWrapper(entity));
List<HazardWork> records = hazardWorkPage.getRecords();
List<HazardWorkVO> res = new ArrayList<>();
// 遍历获取负责人和分管领导名称
for (HazardWork record : records) {
HazardWorkVO hazardWorkVO = new HazardWorkVO();
BeanUtil.copyProperties(record, hazardWorkVO);
Long headId = record.getHead();
if (headId != null) {
R<User> header = userClient.userInfoById(headId);
if (header.isSuccess()) {
hazardWorkVO.setHeadName(header.getData().getRealName());
}
}
Long manageId = record.getManage();
if (manageId != null) {
R<User> manager = userClient.userInfoById(manageId);
if (manager.isSuccess()) {
hazardWorkVO.setManagerName(manager.getData().getRealName());
}
}
res.add(hazardWorkVO);
}
// 分页
IPage<HazardWorkVO> page = new Page<>(query.getCurrent(), query.getSize());
page.setRecords(res);
page.setTotal(hazardWorkPage.getTotal());
page.setPages(hazardWorkPage.getPages());
return page;
}
} }

Loading…
Cancel
Save