Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 9 months ago
parent
commit
c4b6e4ad1e
  1. 4
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java
  2. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java
  3. 6
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java
  4. 38
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  5. 29
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  6. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

4
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java

@ -42,7 +42,8 @@ public interface AlarmConstants {
// 等级告警 : 21-一级告警 22-二级告警 23-三级告警
// 智能预警 : 30-智能预警
// 条件告警 : 40-条件告警
// 开关机告警 : 50-开机告警 51-关机告警
// AI告警 : 50-AI告警
// 开关机告警 : 60-开机告警 61-停机告警
Integer WARNING = 2;
Integer FAULT = 3;
Integer OFFSIDE = 5;
@ -59,7 +60,6 @@ public interface AlarmConstants {
Integer START = 60;
Integer STOP = 61;
List<Integer> START_STOP_ALARAM = Arrays.asList(START,STOP);
String VIDEO_SCHEDULED_TASK= "VideoScheduledTask";
List<String> HZ3000_TYPES = Arrays.asList("0","1","2","3","4","5","6","7","8","9","10","11","12");

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java

@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tenant.mp.TenantEntity;
/**
* @author ysj
@ -14,7 +15,7 @@ import org.springblade.core.mp.base.BaseEntity;
@EqualsAndHashCode(callSuper = true)
@TableName("hzims_run_month_report")
@ApiModel(value = "运行月报告表", description = "运行月报告实体类")
public class RunMonthEntity extends BaseEntity {
public class RunMonthEntity extends TenantEntity {
@ApiModelProperty("站点编码")
private String stationCode;

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

@ -80,11 +80,11 @@ public class AlarmServiceImpl implements AlarmService {
// 查询开关机默认告警配置
AlarmDefaultConfigEntity start = defaulConfigService.getOne(Wrappers.<AlarmDefaultConfigEntity>lambdaQuery()
.eq(AlarmDefaultConfigEntity::getSource,5)
.eq(AlarmDefaultConfigEntity::getAlarmChiledType,50)
.eq(AlarmDefaultConfigEntity::getAlarmChiledType,60)
);
AlarmDefaultConfigEntity stop = defaulConfigService.getOne(Wrappers.<AlarmDefaultConfigEntity>lambdaQuery()
.eq(AlarmDefaultConfigEntity::getSource,5)
.eq(AlarmDefaultConfigEntity::getAlarmChiledType,51)
.eq(AlarmDefaultConfigEntity::getAlarmChiledType,61)
);
// 获取站点设备实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
@ -156,7 +156,7 @@ public class AlarmServiceImpl implements AlarmService {
alarm.setDeviceCode(real.getDeviceCode());
alarm.setDeviceName(real.getDeviceName());
alarm.setAlarmId(station.getCode() + "_" + Func.randomUUID());
alarm.setAlarmContext(station.getName() + "." + real.getDeviceName() + "_机");
alarm.setAlarmContext(station.getName() + "." + real.getDeviceName() + "_机");
alarm.setAlarmSource(AlarmConstants.START_STOP_WARNING);
alarm.setAlarmType(AlarmConstants.STOP);
if(state == 1){

38
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.EmParamEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient;
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo;
import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.fill.entity.RainfallEntity;
import com.hnac.hzims.operational.home.wind.RainMon;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
@ -111,6 +113,9 @@ public class RealTargetServiceImpl implements RealTargetService {
@Value("${hzims.operation.realIdKey}")
public String real_id_cofig_final;
// 创建线程池
ExecutorService pool = new ThreadPoolExecutor(8, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build(), new ThreadPoolExecutor.AbortPolicy());
private final static String recent_year_power_data = "hzims:operation:key:power:data";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
@ -1220,11 +1225,9 @@ public class RealTargetServiceImpl implements RealTargetService {
*/
@Override
public void loadPowerData(String param, List<Integer> types, Integer serveType, int year) {
Long time=System.currentTimeMillis();
System.out.println("近年发电量接口耗时测试开始=======================");
log.info("近年发电量接口耗时测试开始=======================");
// 站点查询
List<StationEntity> stationList = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
eq(StationEntity::getDataOrigin,HomePageConstant.DATA_ORIGIN);
if (ObjectUtil.isNotEmpty(serveType)) {
eq(StationEntity::getServeType, serveType);
}
@ -1245,22 +1248,35 @@ public class RealTargetServiceImpl implements RealTargetService {
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 存储数据map :<站点id,<月份,发电量>>
Map<Long, Map<String, Float>> powerMap = new HashMap<>();
Long time2=System.currentTimeMillis();
log.info("近年发电量接口,数据组装"+(time2-time));
stationList.forEach(station -> {
Map<Long, Map<String, Float>> powerMap = new ConcurrentHashMap<>();
// 将站点切割
int limit = countStep(stations.size());
List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 5).limit(5).parallel().collect(Collectors.toList())).collect(Collectors.toList());
// 线程数量
CountDownLatch countDownLatch = new CountDownLatch(limits.size());
pool.execute(()->{
for(List<StationEntity> item : limits){
item.forEach(station->{
// 站点设备集合
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
log.error("load_power_data station :" + station.getCode() + "==== device :" + stationDevices );
Map<String, Float> generateMap = this.getGenerateYear(station,stationDevices,start,end);
if(MapUtils.isEmpty(generateMap)){
return;
}
powerMap.put(station.getId(),generateMap);
});
countDownLatch.countDown();
}
});
// 等待所有线程执行完成
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
pool.shutdown();
redisTemplate.opsForValue().set(recent_year_power_data, powerMap);
Long time3=System.currentTimeMillis();
log.info("近年发电量数据接口,总耗时:"+(time3-time));
}
@Override

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

@ -624,14 +624,17 @@ public class ReportServiceImpl implements ReportService {
List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy"));
// 查询站点设备
List<RideDeviceVo> devices = deviceService.rideDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
List<RunMonthEntity> runs = new ArrayList<>();
stations.forEach(station->{
RunMonthEntity run = new RunMonthEntity();
run.setTenantId(station.getTenantId());
run.setCreateDept(station.getRefDept());
run.setCreateUser(station.getCreateUser());
run.setUpdateUser(station.getUpdateUser());
run.setStationCode(station.getCode());
run.setStationName(station.getName());
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-04-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.add(Calendar.DAY_OF_MONTH,-1);
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH,-1);
run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM"));
List<RideDeviceVo> stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationDevices)){
@ -645,9 +648,9 @@ public class ReportServiceImpl implements ReportService {
run.setCurveData(this.curveData(stationDevices));
// TODO 运行数据分析
// TODO 运行建议及其他
runs.add(run);
runMonService.save(run);
});
runMonService.saveBatch(runs);
}
/**
@ -686,8 +689,7 @@ public class ReportServiceImpl implements ReportService {
*/
private Double generate(int type,String deviceCode,double ride) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-04-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(new Date());
calendar.setTime(new Date());
String end = null,start = null;
int cycleType = 5;
switch (type){
@ -723,8 +725,7 @@ public class ReportServiceImpl implements ReportService {
*/
private Double planGenerate(int type, String stationCode,List<PlanGenerationEntity> plans) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-04-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(new Date());
calendar.setTime(new Date());
if(type == 0){
calendar.add(Calendar.DAY_OF_MONTH,-1);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY) + 1);
@ -761,8 +762,7 @@ public class ReportServiceImpl implements ReportService {
// 确定查询时间范围: 年、月
Date startDate,endDate;
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-04-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(new Date());
calendar.setTime(new Date());
endDate = calendar.getTime();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
@ -835,8 +835,7 @@ public class ReportServiceImpl implements ReportService {
*/
private String alarmData(String code) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-04-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(new Date());
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1);
@ -943,12 +942,10 @@ public class ReportServiceImpl implements ReportService {
*/
private List<EchartVo> curve(List<AttributeVo> attributes, String deviceCode) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-04-01 23:59:59",DateUtil.PATTERN_DATETIME));
//calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME));
calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1);
calendar.add(Calendar.DAY_OF_MONTH,1);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

@ -342,7 +342,7 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
CellRangeAddress region2 = new CellRangeAddress(rowNumber, rowNumber, (short) 0, (short) 7);
sheet.addMergedRegion(region2);
}
rowNumber += 1;
for(int i = 0; i < 4;i++){
// 运行数据分析赋值
Row row = sheet.createRow(rowNumber + i);

Loading…
Cancel
Save