Browse Source

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

# Conflicts:
#	hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/constant/DutyRecProcessConstant.java
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java
#	hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
#	hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
#	pom.xml
zhongwei
yang_shj 3 months ago
parent
commit
c3060f73ac
  1. 1
      hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java
  2. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThirtyGenerationEntity.java
  3. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThreeGenerationEntity.java
  4. 1
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  5. 3
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java
  6. 9
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java
  7. 11
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java
  8. 8
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java
  9. 9
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java
  10. 9
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java
  11. 19
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java
  12. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java
  13. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java
  14. 171
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java
  15. 57
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  16. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  17. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java
  18. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/allTicket/fegin/TicketInfoAllClient.java
  19. 5
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java
  20. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java

1
hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java

@ -59,4 +59,5 @@ public interface CommonConstant {
*/
Long SYSTEM_USER = 1809024073316442113L;
Long SYSTEM_DEPT_ID = 20000001L;
}

3
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThirtyGenerationEntity.java

@ -40,4 +40,7 @@ public class ThirtyGenerationEntity extends TenantEntity {
@ApiModelProperty(value = "发电量")
private BigDecimal generate;
@ApiModelProperty(value = "无功电量")
private BigDecimal reactiveGenerate;
}

3
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThreeGenerationEntity.java

@ -40,4 +40,7 @@ public class ThreeGenerationEntity extends TenantEntity {
@ApiModelProperty(value = "发电量")
private BigDecimal generate;
@ApiModelProperty(value = "无功电量")
private BigDecimal reactiveGenerate;
}

1
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java

@ -173,6 +173,7 @@ public interface HomePageConstant {
// 水电站实时属性名称
String HYDROPOWER_GENERATE_POWER = "generation_capacity"; // 发电量
String HYDROPOWER_REACTIVE_GENERATE = "reactive_generate"; // 无功电量
String HYDROPOWER_ACTIVE_POWER = "active_power"; // 有功功率
String HYDROPOWER_REACTIVE_POWER = "reactive_power"; // 有功功率
String HYDROPOWER_POWERFACTOR = "index_jz_cos"; // 功率因数

3
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java

@ -96,6 +96,9 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
alarm.setCreateDept(optional.get().getCreateDept());
alarm.setStationName(optional.get().getName());
alarm.setTenantId(optional.get().getTenantId());
if(StringUtil.isNotBlank(alarm.getAlarmValue()) && alarm.getAlarmValue().length() > 2048){
alarm.setAlarmValue(alarm.getAlarmValue().substring(0,2048));
}
alarm.setStatus(0);
// 步骤4.根据站点查询配置标识
AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType());

9
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java

@ -29,18 +29,13 @@ public class FdpMqttConsumer implements SubscribeCallBack {
@Override
public void onMessage(Map<String, Object> data) {
String s = JSONObject.toJSONString(data);
log.info("监听Fdp消息 : {}" ,s);
log.error("FdpMqttConsumer监听到消息 : {}" ,s);
//消费代码
List<AlarmEntity> alarmEntities = fdpAlarmService.receiveMessage(s);
if(CollectionUtil.isEmpty(alarmEntities)){
return;
}
log.error("监听Fdp有效消息 : {}" ,alarmEntities.get(0).getAlarmId());
//统一数据处理
try {
alarmSaveService.save(alarmEntities);
}catch (Exception e){
throw new ServiceException("集中监控告警数据处理报错(FdpAlarm):"+e);
}
alarmSaveService.save(alarmEntities);
}
}

11
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java

@ -29,18 +29,13 @@ public class HZ300MqttConsumer implements SubscribeCallBack {
private AlarmSaveService alarmSaveService;
@Override
public void onMessage(Map<String, Object> data) {
log.error("HZ3000队列监听到消息 : {}",data);
log.error("HZ3000MqttConsumer监听到消息 : {}",data);
//消费代码
List<AlarmEntity> alarmEntities = systemAlarmService.receiveMessage(JSONObject.toJSONString(data));
if(CollectionUtil.isEmpty(alarmEntities)){
log.error("HZ3000消息转换数据异常");
return;
}
//统一数据处理
try {
alarmSaveService.save(alarmEntities);
}catch (Exception e){
log.error("HZ3000告警数据处理报错(HZ300Alarm):{}" , e.getMessage());
}
log.error("监听HZ3000有效消息 : {}" ,alarmEntities.get(0).getAlarmId());
alarmSaveService.save(alarmEntities);
}
}

8
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java

@ -71,10 +71,10 @@ public class MqttConfigHzims {
MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer);
log.info(hz3000Client.toString()+hz3000Client.getClientId());
//视频
SoeSubscribe subscribe = new SoeSubscribe();
MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig,"+" , Collections.singletonList("+"), videoMqttConsumer);
log.info(videoClient.toString()+videoClient.getClientId());
}catch (Exception e){
/*SoeSubscribe subscribe = new SoeSubscribe();
MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, "+" ,Collections.singletonList("#"), videoMqttConsumer);
log.info(videoClient.toString()+videoClient.getClientId());*/
}catch (MqttException e){
log.error(e.toString()) ;
}
}

9
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java

@ -27,15 +27,12 @@ public class SoeMqttConsumer implements SubscribeCallBack {
private AlarmSaveService alarmSaveService;
@Override
public void onMessage(Map<String, Object> data) {
log.info("SoeMqttConsumer监听到消息"+data.toString());
log.error("SoeMqttConsumer监听到消息"+data.toString());
String s = JSONObject.toJSONString(data);
//消费代码
List<AlarmEntity> alarmEntities = soeAlarmService.receiveMessage(s);
log.error("监听设备实例有效消息 : {}" ,alarmEntities.get(0).getAlarmId());
//统一数据处理
try {
alarmSaveService.save(alarmEntities);
}catch (Exception e){
log.error("条件告警数据处理报错(SoeAlarm):"+e);
}
alarmSaveService.save(alarmEntities);
}
}

9
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java

@ -26,15 +26,12 @@ public class VideoMqttConsumer implements SubscribeCallBack {
private AlarmSaveService alarmSaveService;
@Override
public void onMessage(Map<String, Object> data) {
log.info("VideoMqttConsumer队列监听到消息 : {}",data);
log.error("VideoMqttConsumer监听到消息 : {}",data);
String s = JSONObject.toJSONString(data);
//消费代码
List<AlarmEntity> alarmEntities = videoAlarmService.receiveMessage(s);
log.error("监听视频告警有效消息 : {}" ,alarmEntities.get(0).getAlarmId());
//统一数据处理
try {
alarmSaveService.save(alarmEntities);
}catch (Exception e){
log.error("HZ3000告警数据处理报错(HZ300Alarm):"+e);
}
alarmSaveService.save(alarmEntities);
}
}

19
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java

@ -3,27 +3,24 @@ 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.constant.CommonConstant;
import com.hnac.hzims.common.utils.CommonUtil;
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.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static com.hnac.hzims.alarm.config.constants.AlarmConstants.*;
@ -60,10 +57,9 @@ public class SoeAlarmServiceImpl implements SoeAlarmService {
private AlarmEntity getAlarmEntity(SoeAlarmVo item) {
AlarmEntity entity = new AlarmEntity();
String format = DateUtil.format(item.getTs(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI);
entity.setAlarmId(format+"-"+item.getDeviceCode());
String format = DateUtil.format(item.getTs(),DateUtil.PATTERN_DATETIME_MINI);
entity.setAlarmId(format);
entity.setAlarmSource(LEVEL_ALARM);
entity.setAlarmType(ONE_LEVEL);
entity.setAlarmContext(item.getName());
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(item.getTs().toInstant(), zoneId);
@ -71,6 +67,13 @@ public class SoeAlarmServiceImpl implements SoeAlarmService {
entity.setAlarmValue(item.getCurrentValue());
entity.setAlarmSignage(item.getSignage());
entity.setAlarmLevel(Integer.valueOf(item.getLevel()));
if(entity.getAlarmLevel() == 0){
entity.setAlarmType(ONE_LEVEL);
}else if (entity.getAlarmLevel() == 1){
entity.setAlarmType(TWO_LEVEL);
}else {
entity.setAlarmType(THREE_LEVEL);
}
entity.setAlarmStatus(1);
entity.setDeviceCode(item.getDeviceCode());
entity.setTenantId(CommonConstant.TENANT_ID);

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java

@ -21,7 +21,7 @@ import javax.annotation.Resource;
@EnableFeignClients(basePackages = {"org.springblade", "com.hnac"})
public class ScheduledApplication {
public static void main(String[] args) {
BladeApplication.run("hzims-scheduled", ScheduledApplication.class, args);
BladeApplication.run("hzims-scheduled-ysj", ScheduledApplication.class, args);
}
}

3
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java

@ -34,6 +34,7 @@ public class GenerationScheduledTask {
* @return
*/
@XxlJob(THREE_YEAR_POWER_GENERATION)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> threeYearPowerGeneration(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
@ -48,6 +49,7 @@ public class GenerationScheduledTask {
* @return
*/
@XxlJob(THIRTY_DAY_POWER_GENERATION)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> thirtyDayPowerGeneration(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
@ -62,6 +64,7 @@ public class GenerationScheduledTask {
* @return
*/
@XxlJob(THIS_DAY_POWER_GENERATION)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> thisDayPowerGeneration(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");

171
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java

@ -146,13 +146,24 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
if(CollectionUtil.isEmpty(records)){
return;
}
List<AnalyseDataTaosVO> reactives = dataService.periodTargetData(start,end,5,3,device.getEmCode(),HomePageConstant.HYDROPOWER_REACTIVE_GENERATE);
// 是否包含今日累计发电量数据
Optional<ThirtyGenerationEntity> optional = generations.stream().filter(o->o.getStationId().equals(station.getCode()) && o.getDeviceCode().equals(device.getEmCode())).findFirst();
if(optional.isPresent()){
if(StringUtil.isEmpty(records.get(0).getVal())){
optional.get().setGenerate(BigDecimal.ZERO);
}else{
optional.get().setGenerate(BigDecimal.valueOf(Double.parseDouble(records.get(0).getVal()) * device.getRideCount()));
optional.get().setGenerate(BigDecimal.valueOf(Double.parseDouble(records.get(0).getVal()) * device.getRideCount()).setScale(2, RoundingMode.HALF_UP));
}
// 无功电量
if(CollectionUtil.isEmpty(reactives)){
optional.get().setReactiveGenerate(BigDecimal.ZERO);
}else{
if(StringUtil.isEmpty(reactives.get(0).getVal())){
optional.get().setReactiveGenerate(BigDecimal.ZERO);
}else{
optional.get().setReactiveGenerate(BigDecimal.valueOf(Double.parseDouble(reactives.get(0).getVal())));
}
}
saves.add(optional.get());
}else{
@ -165,7 +176,12 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
generate.setCreateDept(station.getRefDept());
generate.setCreateUser(station.getCreateUser());
generate.setUpdateUser(station.getUpdateUser());
Date time = DateUtil.parse(records.get(0).getTs(), "yyyy-MM-dd HH:mm:ss.s");
Date time;
if(records.get(0).getTs().contains(".0")){
time = DateUtil.parse(records.get(0).getTs(), "yyyy-MM-dd HH:mm:ss.s");
}else{
time = DateUtil.parse(records.get(0).getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s");
}
generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME));
generate.setDay(time.getDate());
if(StringUtil.isEmpty(records.get(0).getVal())){
@ -173,6 +189,16 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
}else{
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(records.get(0).getVal()) * device.getRideCount()));
}
// 无功电量
if(CollectionUtil.isEmpty(reactives)){
generate.setReactiveGenerate(BigDecimal.ZERO);
}else{
if(StringUtil.isEmpty(reactives.get(0).getVal())){
generate.setReactiveGenerate(BigDecimal.ZERO);
}else{
generate.setReactiveGenerate(BigDecimal.valueOf(Double.parseDouble(reactives.get(0).getVal())));
}
}
saves.add(generate);
}
});
@ -271,8 +297,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList());
CountDownLatch countDownLatch = new CountDownLatch(limits.size());
for(List<StationEntity> item : limits){
try{
pool.submit(()->{
pool.submit(()->{
try{
item.forEach(station->{
// 站点设备集合
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
@ -282,6 +308,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
if(CollectionUtil.isEmpty(records)){
return;
}
List<AnalyseDataTaosVO> reactives = dataService.periodTargetData(start,end,5,3,device.getEmCode(),HomePageConstant.HYDROPOWER_REACTIVE_GENERATE);
// 保存设备发电量
thirtyGenerateService.saveBatch(records.stream().map(record -> {
ThirtyGenerationEntity generate = new ThirtyGenerationEntity();
@ -293,13 +320,33 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
generate.setCreateDept(station.getRefDept());
generate.setCreateUser(station.getCreateUser());
generate.setUpdateUser(station.getUpdateUser());
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
Date time;
if(record.getTs().contains(".0")){
time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
}else{
time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s");
}
generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME));
generate.setDay(time.getDate());
if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(BigDecimal.ZERO);
}else{
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount()));
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount()).setScale(2, RoundingMode.HALF_UP));
}
// 无功电量
if(CollectionUtil.isEmpty(reactives)){
generate.setReactiveGenerate(BigDecimal.ZERO);
}else{
Optional<AnalyseDataTaosVO> optional = reactives.stream().filter(reactive-> record.getTs().equals(reactive.getTs())).findFirst();
if(optional.isPresent()){
if(StringUtil.isEmpty(optional.get().getVal())){
generate.setReactiveGenerate(BigDecimal.ZERO);
}else{
generate.setReactiveGenerate(BigDecimal.valueOf(Double.parseDouble(optional.get().getVal())));
}
}else{
generate.setReactiveGenerate(BigDecimal.ZERO);
}
}
return generate;
}).collect(Collectors.toList()));
@ -307,11 +354,11 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
});
countDownLatch.countDown();
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
});
}catch (Exception e){
countDownLatch.countDown();
log.error("save_generation_execute_complete_error : {}" ,e.getMessage());
}
}catch (Exception e){
countDownLatch.countDown();
log.error("save_generation_execute_complete_error : {}" ,e.getMessage());
}
});
}
// 等待所有线程执行完成
try {
@ -342,49 +389,70 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList());
CountDownLatch countDownLatch = new CountDownLatch(limits.size());
for(List<StationEntity> item : limits){
try{
pool.submit(()->{
item.forEach(station->{
// 站点设备集合
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
// 遍历查询发电量
eminfos.forEach(device->{
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){
return;
}
// 保存设备发电量
threeGenerateService.saveBatch(records.stream().map(record -> {
ThreeGenerationEntity generate = new ThreeGenerationEntity();
generate.setStationId(station.getCode());
generate.setStationName(station.getName());
generate.setDeviceCode(device.getEmCode());
generate.setDeviceName(device.getName());
generate.setTenantId(station.getTenantId());
generate.setCreateDept(station.getRefDept());
generate.setCreateUser(station.getCreateUser());
generate.setUpdateUser(station.getUpdateUser());
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setMonth(time.getMonth() + 1);
if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(BigDecimal.ZERO);
}else{
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount()));
try{
item.forEach(station->{
// 站点设备集合
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
// 遍历查询发电量
eminfos.forEach(device->{
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){
return;
}
return generate;
}).collect(Collectors.toList()));
List<AnalyseDataTaosVO> reactives = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_REACTIVE_GENERATE);
// 保存设备发电量
threeGenerateService.saveBatch(records.stream().map(record -> {
ThreeGenerationEntity generate = new ThreeGenerationEntity();
generate.setStationId(station.getCode());
generate.setStationName(station.getName());
generate.setDeviceCode(device.getEmCode());
generate.setDeviceName(device.getName());
generate.setTenantId(station.getTenantId());
generate.setCreateDept(station.getRefDept());
generate.setCreateUser(station.getCreateUser());
generate.setUpdateUser(station.getUpdateUser());
Date time;
if(record.getTs().contains(".0")){
time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
}else{
time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s");
}
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setMonth(time.getMonth() + 1);
if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(BigDecimal.ZERO);
}else{
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount()).setScale(2, RoundingMode.HALF_UP));
}
// 无功电量
if(CollectionUtil.isEmpty(reactives)){
generate.setReactiveGenerate(BigDecimal.ZERO);
}else{
Optional<AnalyseDataTaosVO> optional = reactives.stream().filter(reactive-> record.getTs().equals(reactive.getTs())).findFirst();
if(optional.isPresent()){
if(StringUtil.isEmpty(optional.get().getVal())){
generate.setReactiveGenerate(BigDecimal.ZERO);
}else{
generate.setReactiveGenerate(BigDecimal.valueOf(Double.parseDouble(optional.get().getVal())));
}
}else{
generate.setReactiveGenerate(BigDecimal.ZERO);
}
}
return generate;
}).collect(Collectors.toList()));
});
// 填报发电量保存
threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end));
});
// 填报发电量保存
threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end));
});
countDownLatch.countDown();
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
countDownLatch.countDown();
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
}catch (Exception e){
countDownLatch.countDown();
log.error("save_generation_execute_complete_error : {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
}
});
}catch (Exception e){
countDownLatch.countDown();
log.error("save_generation_execute_complete_error : {}" ,e.getMessage());
}
}
// 等待所有线程执行完成
try {
@ -432,6 +500,9 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
}else{
generation.setGenerate(BigDecimal.valueOf(Double.parseDouble(power.getPower().toString())).setScale(2, RoundingMode.HALF_UP));
}
generation.setReactiveGenerate(BigDecimal.ZERO
);
return generation;
}).collect(Collectors.toList());
}

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

@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.equipment.entity.WorkshopInfoEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.config.enume.ConfigStatus;
import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
import com.hnac.hzims.operational.main.vo.RealAttributeVo;
import com.hnac.hzims.operational.main.vo.RealDeviceVo;
import com.hnac.hzims.operational.main.vo.RealStationVo;
@ -76,10 +78,13 @@ public class MonitorServiceImpl implements MonitorService {
private final RedisClient redisClient;
private final IPushMsgClient pushMsgClient;
private final IAnalyseDataSearchClient analyseDataSearchClient;
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
private static final ExecutorService pool = new ThreadPoolExecutor(20, 20, 2L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
private static boolean isSendMail = true;
@Value("${hzims.equipment.emInfo.emInfoList}")
public String device_cache_final;
@ -225,18 +230,19 @@ public class MonitorServiceImpl implements MonitorService {
try {
// 等待所有线程执行完成(至多等待三秒,超过三秒任务认为线程发生阻塞)
boolean flag = countDownLatch.await(3,TimeUnit.SECONDS);
if(!flag){
// 清空线程任务
pool.shutdownNow();
if(!flag && isSendMail){
log.error("实时数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME));
isSendMail = false;
// 发生邮件
this.sendMonthReport("实时数据运行堵塞");
}else if(flag){
// redis 存储
redisTemplate.opsForValue().set(real_cache_final,JSONObject.toJSONString(valueMap));
redisTemplate.opsForValue().set(real_gather_cache_final,JSONObject.toJSONString(keyMap));
}
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
// redis 存储
redisTemplate.opsForValue().set(real_cache_final,JSONObject.toJSONString(valueMap));
redisTemplate.opsForValue().set(real_gather_cache_final,JSONObject.toJSONString(keyMap));
}
/**
@ -305,7 +311,7 @@ public class MonitorServiceImpl implements MonitorService {
// 切割数据遍历
for(Map<String, List<StationAttributeEntity>> item : limit){
// 提交线程任务
pool.submit(()->{
pool.execute(()->{
item.forEach((key,value)->{
RealStationVo realStation = new RealStationVo();
// 设备信息
@ -327,11 +333,14 @@ public class MonitorServiceImpl implements MonitorService {
// 等待所有线程执行完成
try {
// 等待所有线程执行完成(至多等待二秒,超过二秒任务认为线程发生阻塞)
boolean flag = countDownLatch.await(2,TimeUnit.SECONDS);
if(!flag){
// 清空线程任务
pool.shutdownNow();
boolean flag = countDownLatch.await(3,TimeUnit.SECONDS);
if(!flag && isSendMail){
log.error("集中监控数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME));
isSendMail = false;
// 发生邮件
this.sendMonthReport("集中监控数据运行堵塞");
}else if(flag){
redisTemplate.opsForValue().set(moniter_station_cache_final, realStations);
}
} catch (InterruptedException e) {
e.printStackTrace();
@ -379,7 +388,7 @@ public class MonitorServiceImpl implements MonitorService {
device.setState(-1);
return;
}
if("0.000000".equals(powers.get(0).getValue()) || "-".equals(powers.get(0).getValue()) || HomePageConstant.ON.equals(powers.get(0).getValue())){
if("0.000000".equals(powers.get(0).getValue()) || "0.000005".equals(powers.get(0).getValue()) || "-".equals(powers.get(0).getValue()) || HomePageConstant.ON.equals(powers.get(0).getValue())){
device.setState(-1);
return;
}
@ -756,4 +765,24 @@ public class MonitorServiceImpl implements MonitorService {
}
return result;
}
/**
* 推送当月月报
*/
private void sendMonthReport(String text) {
// 发送邮件
MailPushDto pushDto = new MailPushDto();
pushDto.setBusinessClassify("system");
pushDto.setBusinessKey("Run_Blocking");
pushDto.setSubject(text);
pushDto.setText(text);
pushDto.setToAccount(Collections.singletonList("1069818635@qq.com").toArray(new String[0]));
pushDto.setHtml(false);
pushDto.setCreateUser(CommonConstant.SYSTEM_USER);
pushDto.setTenantId(CommonConstant.TENANT_ID);
pushDto.setCreateDept(CommonConstant.SYSTEM_DEPT_ID);
pushDto.setMailType(0);
pushDto.setFromAccount("huangxing951023@163.com");
pushMsgClient.sendMail(pushDto);
}
}

7
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java

@ -992,7 +992,12 @@ public class ReportServiceImpl implements ReportService {
}
analyseDatas.addAll(data.getList().stream().peek(item->{
item.setSignage(data.getSignage());
Date date = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s");
Date date;
if(item.getTs().contains(".0")){
date = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s");
}else{
date = DateUtil.parse(item.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s");
}
day.setTime(date);
item.setTs(String.valueOf(day.get(Calendar.DAY_OF_MONTH)));
}).collect(Collectors.toList()));

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java

@ -419,7 +419,12 @@ public class HzimsDataServiceImpl implements HzimsDataService {
}
datas.forEach(data->{
ConverElectricityVo electricity = new ConverElectricityVo();
Date date = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s");
Date date;
if(data.getTs().contains(".0")){
date = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s");
}else{
date = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss");
}
electricity.setTime(DateUtil.format(date,DateUtil.PATTERN_DATE));
if(StringUtil.isEmpty(data.getVal())){
electricity.setElectricity(0.0);

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/allTicket/fegin/TicketInfoAllClient.java

@ -74,7 +74,7 @@ public class TicketInfoAllClient implements ITicketInfoAllClient {
int completeNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoCompleteNum).sum();
int invalidatedNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoInvalidatedNum).sum();
int qualifiedNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoQualifiedNum).sum();
Double proportion = new BigDecimal(qualifiedNum).divide(new BigDecimal(sum),2, RoundingMode.UP)
Double proportion = new BigDecimal(qualifiedNum).divide(new BigDecimal(sum),4, RoundingMode.UP)
.multiply(new BigDecimal(100)).setScale(2, RoundingMode.UP).doubleValue();
ticketInfoStatisticVO.setTicketInfoNumber(sum);
ticketInfoStatisticVO.setTicketInfoCompleteNum(completeNum);

5
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java

@ -706,7 +706,10 @@ public class StandardTicketInfoServiceImpl extends ServiceImpl<StandardTicketInf
//废票数量
int ticketInfoInvalidatedNum = typeOperateTicket.getValue().stream().filter(item -> "作废".equals(item.getFlowTaskName())).collect(Collectors.toList()).size();
//计算合格率
double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) operateTicketReportStatistic.size() * 100).setScale(2, RoundingMode.HALF_DOWN).doubleValue();
Double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum)
.divide(new BigDecimal(typeOperateTicket.getValue().size()),4, RoundingMode.HALF_UP)
.multiply(new BigDecimal(100))
.setScale(2, RoundingMode.HALF_UP).doubleValue();
TicketInfoStatisticVO ticketInfoStatisticVO = TicketInfoStatisticVO.builder().ticketInfoType(type)
.ticketInfoNumber(typeOperateTicket.getValue().size())
.ticketInfoCompleteNum(ticketInfoCompleteNum)

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java

@ -1153,7 +1153,9 @@ public class FirstWorkTicketServiceImpl extends ServiceImpl<WorkTicketInfoMapper
int ticketInfoQualifiedNum = typeWorkTicket.getValue().stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && ticket.getEvaluation().intValue() == 1)
.collect(Collectors.toList()).size();
//计算合格率
Double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) workTicketReportStatistic.size() *100)
Double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum)
.divide(new BigDecimal(typeWorkTicket.getValue().size()),4, RoundingMode.HALF_UP)
.multiply(new BigDecimal(100))
.setScale(2, RoundingMode.HALF_UP).doubleValue();
TicketInfoStatisticVO workTicketStatistic = TicketInfoStatisticVO.builder()
.ticketInfoType(ticketInfoType)

Loading…
Cancel
Save