Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
haungxing 4 months ago
parent
commit
b511cdf1b1
  1. 3
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java
  2. 9
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java
  3. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java
  4. 5
      hzims-service-api/target/classes/META-INF/build-info.properties
  5. 29
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java
  6. 34
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmPoolManager.java
  7. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java
  8. 44
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
  9. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/MessageService.java
  10. 50
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java
  11. 14
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java
  12. 1
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java
  13. 4
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java
  14. 13
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java
  15. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java
  16. 5
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java
  17. 33
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  18. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java
  19. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java
  20. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsAnalyseExampleServiceImpl.java
  21. 44
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  22. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  23. 5
      target/classes/META-INF/build-info.properties

3
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java

@ -24,5 +24,8 @@ public class ShowQueryVo {
@ApiModelProperty(value = "告警子类")
private Integer alarmType;
@ApiModelProperty(value = "告警内容")
private String content;
}

9
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java

@ -10,12 +10,9 @@ import java.util.List;
* @author ysj
*/
@Data
@ApiModel(value = "告警弹框参数", description = "")
@ApiModel(value = "告警websocket参数", description = "")
public class AlartParamVo {
@ApiModelProperty("站点类型: 2-云服务 1-代运维")
private Integer serveType;
@ApiModelProperty("用户权限机构集合")
private List<Long> depts;
@ApiModelProperty("站点集合")
private List<String> codes;
}

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java

@ -18,6 +18,9 @@ public class RealDeviceVo implements Serializable {
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("装机容量")
private Double installedCapacity;
@ApiModelProperty("设备状态")
private Integer state;

5
hzims-service-api/target/classes/META-INF/build-info.properties

@ -1,5 +0,0 @@
build.artifact=hzims-service-api
build.group=com.hnac.hzims
build.name=hzims-service-api
build.time=2024-07-22T06\:45\:56.469Z
build.version=4.0.0-SNAPSHOT

29
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java

@ -12,6 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author ysj
*/
@ -21,6 +24,9 @@ import org.springframework.stereotype.Service;
public class AlarmListener implements IQueueConsume {
@Autowired
private ThreadPoolExecutor pool;
@Autowired
private MessageService messageService;
@Autowired
@ -34,19 +40,32 @@ public class AlarmListener implements IQueueConsume {
// 步骤1.消息对象转换
AlarmEntity alarm = JSONObject.parseObject(message,AlarmEntity.class);
// 步骤2.WEB/APP消息推送
// 步骤2.websocket消息推送
if(ObjectUtil.isNotEmpty(alarm.getIsRightTabulation()) && alarm.getIsRightTabulation() == 0){
CompletableFuture.runAsync(() -> {
messageService.webRightMessage(alarm);
},pool);
}
// 步骤3.WEB/APP消息推送
if(ObjectUtil.isNotEmpty(alarm.getIsPlatformMessage()) && alarm.getIsPlatformMessage() == 0){
CompletableFuture.runAsync(() -> {
messageService.webAppMessage(alarm);
},pool);
}
// 步骤3.短信推送
if(ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0){
// 步骤4.短信推送
if (ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0) {
CompletableFuture.runAsync(() -> {
messageService.shortMessage(alarm);
},pool);
}
// 步骤4.微信公众号发送
if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){
// 步骤5.微信公众号发送
if (ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0) {
CompletableFuture.runAsync(() -> {
messageService.weChatMessage(alarm);
},pool);
}
}
}

34
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmPoolManager.java

@ -0,0 +1,34 @@
package com.hnac.hzims.alarm.monitor.listener;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import java.util.concurrent.*;
/**
* @author: ysj
*/
@Component
public class AlarmPoolManager {
@Bean
public ThreadPoolExecutor threadPoolExecutor() {
// 核心线程数
int corePoolSize = 8;
// 最大线程数
int maximumPoolSize = 16;
// 线程空闲时的存活时间
long keepAliveTime = 60L;
// 时间单位
TimeUnit unit = TimeUnit.SECONDS;
// 任务队列
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(100);
// 线程工厂
ThreadFactory threadFactory = Executors.defaultThreadFactory();
// 等待策略
RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();
return new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,threadFactory,handler);
}
}

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java

@ -22,7 +22,7 @@ public interface AlarmService extends IService<AlarmEntity> {
List<AlarmEntity> broadcast(String startTime, String endTime,Integer serveType);
TextMessage majorAlarm(AlartParamVo param);
TextMessage majorAlarm(List<String> stations);
List<AlarmVideoVo> alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType);
}

44
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

@ -36,6 +36,7 @@ import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.message.fegin.IMessageClient;
@ -106,6 +107,9 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
if(!StringUtil.isEmpty(showQuery.getAlarmType())){
wrapper.eq("ALARM_TYPE",showQuery.getAlarmType());
}
if(!StringUtil.isEmpty(showQuery.getContent())){
wrapper.like("alarmContext",showQuery.getContent());
}
// 处理告警过滤 :当天处理告警
List<String> handles = alarmHandleService.handles();
@ -135,6 +139,18 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
}
/**
* 获取权限站点
* @return
*/
private List<StationEntity> stationsByCodes(List<String> stations) {
R<List<StationEntity>> result = stationClient.querySatationByCodes(stations);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
return result.getData();
}
/**
* 查询告警数量
* @return
*/
@ -186,6 +202,9 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
}).collect(Collectors.toList());
}
/**
* 播报告警
* @param startTime
@ -213,26 +232,25 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
/**
* 弹框告警
* @param param
* @param codes
* @return
*/
@Override
public TextMessage majorAlarm(AlartParamVo param) {
public TextMessage majorAlarm(List<String> codes) {
// 站点查询
List<StationEntity> stations = this.stations(param.getServeType());
if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){
return new TextMessage(new ArrayList().toString());
}
List<String> effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList());
if(CollectionUtil.isEmpty(effectives)){
List<StationEntity> stations = this.stationsByCodes(codes);
if(CollectionUtil.isEmpty(stations)){
return new TextMessage(new ArrayList().toString());
}
// 条件过滤
QueryWrapper<AlarmEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(AlarmEntity::getStationId,effectives);
queryWrapper.lambda().in(AlarmEntity::getAlarmType, Arrays.asList(AlarmConstants.FAULT,AlarmConstants.EARLY));
queryWrapper.lambda().eq(AlarmEntity::getIsShowAlert,0);
queryWrapper.lambda().eq(AlarmEntity::getStatus,0);
queryWrapper.lambda().in(AlarmEntity::getStationId,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
queryWrapper.lambda().in(AlarmEntity::getAlarmType, Arrays.asList(AlarmConstants.WARNING,AlarmConstants.FAULT,AlarmConstants.OFFSIDE,AlarmConstants.INTERRUPT,AlarmConstants.ABNORMAL,AlarmConstants.EARLY,AlarmConstants.START,AlarmConstants.STOP));
queryWrapper.lambda().eq(AlarmEntity::getIsRightTabulation,0);
queryWrapper.lambda().ge(AlarmEntity::getAlarmTime, DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00");
queryWrapper.lambda().le(AlarmEntity::getAlarmTime,DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME));
queryWrapper.lambda().orderByDesc(AlarmEntity::getAlarmTime);
//queryWrapper.lambda().eq(AlarmEntity::getStatus,0);
// 处理告警过滤 :当天处理告警
List<String> handles = alarmHandleService.handles();
if(!CollectionUtil.isEmpty(handles)){
@ -242,7 +260,7 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
if(CollectionUtil.isEmpty(alarms)){
return new TextMessage(new ArrayList().toString());
}
return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmEntity::getAlarmTime).reversed()).collect(Collectors.toList())));
return new TextMessage(JSONObject.toJSONString(alarms.stream().skip(0).limit(1000).collect(Collectors.toList())));
}
/**

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/MessageService.java

@ -7,6 +7,8 @@ import com.hnac.hzims.alarm.config.entity.AlarmEntity;
*/
public interface MessageService {
void webRightMessage(AlarmEntity alarm);
void webAppMessage(AlarmEntity entity);
void shortMessage(AlarmEntity entity);

50
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java

@ -1,8 +1,10 @@
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.source.service.MessageService;
import com.hnac.hzims.alarm.ws.alart.AlarmSessionManager;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
@ -17,13 +19,16 @@ import org.springblade.message.dto.SmsImmediatelyPushDTO;
import org.springblade.message.dto.WxMessageDTO;
import org.springblade.message.fegin.IMessageClient;
import org.springblade.system.cache.DictCache;
import org.springblade.system.feign.IDeptClient;
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.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.socket.TextMessage;
import java.io.IOException;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -44,6 +49,8 @@ public class MessageServiceImpl implements MessageService {
private final IUserClient userClient;
private final IDeptClient deptClient;
private final IMessageClient messageClient;
private final IStationClient stationClient;
@ -56,6 +63,34 @@ public class MessageServiceImpl implements MessageService {
private String wxPushTemplate;
@Value("${hzims.wxPush.enabled}")
private Boolean wxPushEnabled;
/**
* web告警展示消息推送
* @param alarm
*/
@Override
public void webRightMessage(AlarmEntity alarm) {
if(CollectionUtil.isEmpty(AlarmSessionManager.SESSION_POOL)){
return;
}
// 遍历websocket链接,拥有告警站点权限进行推送消息
AlarmSessionManager.SESSION_POOL.forEach((key, session) -> {
if(!session.getAttributes().containsKey("codes")){
return;
}
List<String> codes = (List<String>) session.getAttributes().get("codes");
if(CollectionUtil.isEmpty(codes) || !codes.contains(alarm.getStationId())){
return;
}
try {
session.sendMessage(new TextMessage(JSONObject.toJSONString(Collections.singletonList(alarm))));
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
/**
* web/app消息推送
* @param entity : 告警对象
@ -161,8 +196,6 @@ public class MessageServiceImpl implements MessageService {
return;
}
userList.addAll(result.getData());
log.info("短信发送用户列表:{}",userList);
log.info("短信发送用户列表,{}",userList);
}else {
//内测只推给对应的3个用户
List<String> phoneList = Arrays.asList("18351807087", "18163793336", "18285121497");
@ -172,9 +205,9 @@ public class MessageServiceImpl implements MessageService {
userList.add(userByPhone.getData().getUser());
}
}
}
log.info("短信发送用户列表:{}",userList);
log.info("短信发送用户列表,{}",userList);
}
String userIds = userList.stream().map(o -> String.valueOf(o.getId())).distinct().collect(Collectors.joining(","));
WxMessageDTO message = new WxMessageDTO();
// 模板Id
@ -191,8 +224,8 @@ public class MessageServiceImpl implements MessageService {
message.setTaskId(entity.getId());
// 微信参数键值对
HashMap<String,Object> map = new HashMap<>();
map.put("thing18",getTruncateString(entity.getStationName(), 20));
map.put("thing11",getTruncateString(entity.getAlarmContext(), 20));
map.put("thing18",getTruncateString(entity.getStationName()));
map.put("thing11",getTruncateString(entity.getAlarmContext()));
map.put("time2",entity.getAlarmTime());
map.put("thing14", DictCache.getValue("alarm_type", String.valueOf(entity.getAlarmType())));
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
@ -211,11 +244,12 @@ public class MessageServiceImpl implements MessageService {
message.setTenantId(station.getData().getTenantId());
messageClient.sendWxMessage(message);
}
private String getTruncateString(String ruleDefName, int maxSize) {
if (ruleDefName.length()<= maxSize){
private String getTruncateString(String ruleDefName) {
if (ruleDefName.length()<= 20){
return ruleDefName;
}else {
return ruleDefName.substring(0, maxSize - 3) + "...";
return ruleDefName.substring(0, 20 - 3) + "...";
}
}
}

14
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.business.ws.alart.vo.AlartParamVo;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -13,6 +14,8 @@ import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
/**
* @author ysj
@ -31,13 +34,11 @@ public class AlarmHandler extends TextWebSocketHandler {
session.getAttributes().put("userId", uid);
log.info("sessionId: " + session.getId());
log.info("session connection successful!");
AlarmSocketPool.pool.put(session.getId(), this);
}
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
AlarmSessionManager.removeAndClose(session.getId());
AlarmSocketPool.pool.remove(session.getId());
log.info("sessionId: " + session.getId());
log.info("uri: " + session.getUri());
log.info("session closed successful!");
@ -46,7 +47,6 @@ public class AlarmHandler extends TextWebSocketHandler {
@Override
public void handleTransportError(WebSocketSession session, Throwable exception) {
AlarmSessionManager.removeAndClose(session.getId());
AlarmSocketPool.pool.remove(session.getId());
}
@Override
@ -56,11 +56,13 @@ public class AlarmHandler extends TextWebSocketHandler {
if(StringUtil.isBlank(message)){
return;
}
AlartParamVo param = JSONObject.parseObject(message,AlartParamVo.class);
if(ObjectUtil.isEmpty(param)){
AlartParamVo param = JSONObject.parseObject(textMessage.getPayload(), AlartParamVo.class);
if(ObjectUtil.isEmpty(param) || CollectionUtil.isEmpty(param.getCodes())){
return;
}
TextMessage sendMessage = alarmService.majorAlarm(param);
session.getAttributes().put("codes", param.getCodes());
AlarmSessionManager.SESSION_POOL.put(userId,session);
TextMessage sendMessage = alarmService.majorAlarm(param.getCodes());
session.sendMessage(sendMessage);
}
}

1
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java

@ -55,7 +55,6 @@ public class AlarmSessionManager {
throw new RuntimeException("关闭ws会话失败!", ex);
}
}
SESSION_POOL.remove(uid);
}

4
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java

@ -18,11 +18,11 @@ public class AlarmSocketConfig implements WebSocketConfigurer{
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
// 集中监控弹框处理器
registry.addHandler(monitorHandler(), "/alarm/alart/{uid}").setAllowedOrigins("*");
registry.addHandler(alarmHandler(), "/alarm/alart/{uid}").setAllowedOrigins("*");
}
@Bean
public WebSocketHandler monitorHandler() {
public WebSocketHandler alarmHandler() {
return new AlarmHandler();
}

13
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java

@ -1,13 +0,0 @@
package com.hnac.hzims.alarm.ws.alart;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author ysj
*/
public class AlarmSocketPool {
public static Map<String, AlarmHandler> pool = new ConcurrentHashMap<>();
}

1
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java

@ -62,6 +62,7 @@ public class AlarmScheduledTask {
*/
@XxlJob(INTERRUPT_ALARM)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> interruption(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");

5
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java

@ -27,6 +27,7 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.mqtt.producer.IMqttSender;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@ -55,7 +56,7 @@ public class AlarmServiceImpl implements AlarmService {
private final RedisTemplate redisTemplate;
//private final IMqttSender mqttSender;
private final IMqttSender mqttSender;
private final static String start_stop_cache_final = "hzims:operation:start:stop:key";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
@ -279,7 +280,7 @@ public class AlarmServiceImpl implements AlarmService {
alarm.setContext(entity.getSoeExplain());
alarm.setState(entity.getStatus());
log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm));
//mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm));
mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm));
});
}

33
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

@ -291,6 +291,8 @@ public class MonitorServiceImpl implements MonitorService {
List<String> aborts = interruptionAlarmService.aborts(operations);
// 设备状态分类
Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_cache_final);
// 设备信息
List<EminfoAndEmParamVo> deviceParms = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference<List<EminfoAndEmParamVo>>() {});
// 按10个站点一组分割属性配置
List<Map<String, List<StationAttributeEntity>>> limit = this.limitMapChunk(attributes);
// 线程执行次数
@ -305,8 +307,8 @@ public class MonitorServiceImpl implements MonitorService {
RealStationVo realStation = new RealStationVo();
// 设备信息
List<RealDeviceVo> devices = this.monitorRealDevice(value,realTimeData);
// 设备状态
this.deviceStatus(devices,deviceClassifyMap);
// 设备状态、装机容量
this.deviceParam(devices,deviceClassifyMap,deviceParms);
realStation.setDeviceList(devices.stream().sorted(Comparator.comparing(RealDeviceVo::getDeviceName)).collect(Collectors.toList()));
// 站点基础信息: 编码、名称、限制水位、服务类型、机构、排序
this.stationBaseInfo(stations.stream().filter(station->key.equals(station.getCode())).findFirst(),sorts,realStation);
@ -330,30 +332,37 @@ public class MonitorServiceImpl implements MonitorService {
}
/**
* 设置设备状态
* 设置设备状态装机容量
* @param devices
* @param deviceClassifyMap
*/
private void deviceStatus(List<RealDeviceVo> devices, Map<String, List<String>> deviceClassifyMap) {
private void deviceParam(List<RealDeviceVo> devices, Map<String, List<String>> deviceClassifyMap,List<EminfoAndEmParamVo> deviceParams) {
if (CollectionUtil.isEmpty(devices) || MapUtils.isEmpty(deviceClassifyMap)) {
return;
}
List<String> faults = deviceClassifyMap.get(HomePageConstant.FAULT);
List<String> overhaults = deviceClassifyMap.get(HomePageConstant.OVERHAUL);
devices.forEach(device -> {
int state = -1;
device.setState(-1);
if(StringUtil.isNotBlank(device.getDeviceCode())){
// 故障
// 设备装机容量
if(CollectionUtil.isNotEmpty(deviceParams)){
Optional<EminfoAndEmParamVo> optional = deviceParams.stream().filter(param->param.getEmCode().equals(device.getDeviceCode())).findFirst();
if(optional.isPresent()){
device.setInstalledCapacity(optional.get().getInstalledCapacity());
}else{
device.setInstalledCapacity(0.0);
}
}
// 设备状态 : 故障、检修
if (CollectionUtil.isNotEmpty(faults) && faults.contains(device.getDeviceCode())) {
state = 4;
// 检修
device.setState(4);
} else if (CollectionUtil.isNotEmpty(overhaults) && overhaults.contains(device.getDeviceCode())) {
state = 0;
device.setState(0);
}
}
if(state >= 0){
device.setState(state);
}else{
// 根据有功进行判断设备状态
if(device.getState() < 0){
List<RealAttributeVo> attbts = device.getAttbtList();
// 功率属性记录
List<RealAttributeVo> powers = attbts.stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList());

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java

@ -144,7 +144,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces
if (StringUtils.isNotBlank(param)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(entity);
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(accessPlanV4DTO,DateUtil.PATTERN_DATETIME), Map.class);
}
variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId())));
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java

@ -120,13 +120,13 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProces
if (StringUtils.isNotBlank(param)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity, DateUtil.PATTERN_DATETIME), Map.class);
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(accessTaskV4DTO, DateUtil.PATTERN_DATETIME), Map.class);
}
if(ObjectUtil.isNotEmpty(accessTaskV4DTO.getCreateUser())){
variables.put("startFlowUserId",accessTaskV4DTO.getCreateUser().toString());
}
variables.put("solve",TaskUtil.getTaskUser(accessTaskV4DTO.getHandler().toString()));
R<BladeFlow> result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),dictValue,
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),dictValue,
FlowUtil.getBusinessKey("access_task_v4",
String.valueOf(accessTaskV4DTO.getId())), accessTaskV4DTO.getName(),variables);
log.error("开启检修任务流程失败{}" + result);

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsAnalyseExampleServiceImpl.java

@ -70,7 +70,8 @@ public class ImsAnalyseExampleServiceImpl extends ServiceImpl<ImsAnalyseExampleM
// if(DataResultCode.ANALYZE_INSTANCE_UNDEFINE.getCode()==analyzeDataByAnalyzeCode.getCode()){
// throw new ServiceException("找不到对应的分析实例,请检查好配置后重试!");
// }
throw new ServiceException("设备数据查询异常,请检查好配置后重试!");
log.error("getAnalyzeDataByAnalyzeCode接口请求失败:{},请求参数为:{}",JSON.toJSONString(analyzeDataByAnalyzeCode),JSON.toJSONString(analyzeDataCondition));
return R.fail("设备数据查询异常,请检查分析实例相关配置后重试!");
}
return analyzeDataByAnalyzeCode;
}

44
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

@ -17,6 +17,7 @@ import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo;
import com.hnac.hzims.operational.fill.entity.GenerateEntity;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.service.*;
@ -800,7 +801,7 @@ public class HydropowerServiceImpl implements HydropowerService {
private List<PowerYearVo> generateThreeYear(List<String> stations,Map<String, Map<String, Float>> map) {
List<Map<String, Float>> filter = map.entrySet().stream().filter(entry -> stations.contains(entry.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
if (CollectionUtil.isEmpty(filter)) {
return new ArrayList<>();
return this.defaultThreeYear();
}
// 根据月份分组
List<PowerMonthVo> powerMonthVos = new ArrayList<>();
@ -837,6 +838,47 @@ public class HydropowerServiceImpl implements HydropowerService {
}
/**
* 默认结构
* @return
*/
private List<PowerYearVo> defaultThreeYear() {
List<String> mons = this.mons(2,12,false);
// 返回结果
// 根据月份分组
List<PowerMonthVo> powerMonthVos = new ArrayList<>();
mons.forEach(item -> {
PowerMonthVo powerMonthVo = new PowerMonthVo();
powerMonthVo.setStrMonth(item);
powerMonthVo.setPower(0f);
powerMonthVos.add(powerMonthVo);
});
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth));
// 总和所有相同月份的发电量
List<PowerMonthVo> powerMonthVoList = months.entrySet().stream().map(entry -> {
PowerMonthVo powerMonth = new PowerMonthVo();
powerMonth.setStrMonth(entry.getKey());
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
powerMonth.setYear(localDate.getYear());
powerMonth.setMonth(localDate.getMonthValue());
powerMonth.setPower((float) entry.getValue().stream().mapToDouble(PowerMonthVo::getPower).sum());
return powerMonth;
}).collect(Collectors.toList());
// 根据年份分组
Map<Integer, List<PowerMonthVo>> year = powerMonthVoList.stream().collect(Collectors.groupingBy(PowerMonthVo::getYear));
// 返回结果集
return year.entrySet().stream().map(entry -> {
PowerYearVo powerYearVo = new PowerYearVo();
powerYearVo.setYear(entry.getKey());
List<PowerMonthVo> sortValue = entry.getValue().stream().sorted(Comparator.comparing(PowerMonthVo::getMonth)).collect(Collectors.toList());
powerYearVo.setPowerMonthVoList(sortValue);
return powerYearVo;
}).collect(Collectors.toList());
}
/*=====================================================app=====================================================*/
/**

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -113,14 +113,14 @@ public class StationServiceImpl extends ServiceImpl<StationMapper, StationEntity
// 删除数据平台项目
Result dataDelete = projectClient.delete(stationEntity.getCode());
if(dataDelete.isSuccess()) {
log.error("hzims-operational:station:removeStation", stationEntity.getCode() + "删除失败,报错信息为:" + dataDelete.getMsg());
log.error("hzims-operational:station:removeStation : {}", stationEntity.getCode() + "删除失败,报错信息为:" + dataDelete.getMsg());
}
// 删除所属机构
R<Dept> deptResult = sysClient.getDept(stationEntity.getRefDept());
if (deptResult.isSuccess() && ObjectUtil.isNotEmpty(deptResult.getData())) {
R<Void> projectResult = deptClient.deleteDeptById(stationEntity.getRefDept());
if (!projectResult.isSuccess()) {
log.info("hzims-operational:station:removeStation", stationEntity.getRefDept() + "所属机构删除失败,报错信息为:" + projectResult.getMsg());
log.info("hzims-operational:station:removeStation : {}", stationEntity.getRefDept() + "所属机构删除失败,报错信息为:" + projectResult.getMsg());
}
}
}
@ -144,6 +144,9 @@ public class StationServiceImpl extends ServiceImpl<StationMapper, StationEntity
if (StringUtil.isNotBlank(req.getName())) {
like(StationEntity::getName, "%".concat(req.getName()).concat("%"));
}
if (ObjectUtil.isNotEmpty(req.getId())) {
eq(StationEntity::getId, req.getId());
}
if (ObjectUtil.isNotEmpty(req.getType())) {
eq(StationEntity::getType, req.getType());
}

5
target/classes/META-INF/build-info.properties

@ -1,5 +0,0 @@
build.artifact=hzims-back
build.group=com.hnac.hzims
build.name=hzims-back
build.time=2024-07-22T06\:45\:56.469Z
build.version=4.0.0-SNAPSHOT
Loading…
Cancel
Save