Browse Source

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

zhongwei
liwen 4 months ago
parent
commit
903e6ab50c
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java
  2. 15
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java
  3. 19
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java
  4. 17
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java
  5. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  6. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/ObtainGenerationService.java
  7. 73
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java
  8. 190
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  9. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java
  10. 44
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  11. 5
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java

@ -11,4 +11,6 @@ public interface ScheduledConstant {
String THIRTY_DAY_POWER_GENERATION = "thirtyDayPowerGeneration";
String THIS_DAY_POWER_GENERATION = "thisDayPowerGeneration";
String LOAD_THREE_YEAR_POWER_GENERATION = "loadThreeYearPowerGeneration";
}

15
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java

@ -45,24 +45,33 @@ public class HydropowerStationVo {
@ApiModelProperty(value = "总发电负荷单位")
private String powerUnit;
@ApiModelProperty(value = "容量利用率")
private Double capacityRate;
@ApiModelProperty(value = "月计划发电量")
private Float planPowerMon;
@ApiModelProperty(value = "年计划发电量")
private Float planPowerYear;
@ApiModelProperty(value = "月发电量")
private Float powerMon;
@ApiModelProperty(value = "月发电量完成率")
private Double powerRateMon;
@ApiModelProperty(value = "年计划发电量")
private Float planPowerYear;
@ApiModelProperty(value = "年发电量")
private Float powerYear;
@ApiModelProperty(value = "年发电完成率")
private Double powerRateYear;
@ApiModelProperty(value = "今日发电量")
private Float powerDay;
@ApiModelProperty(value = "昨日发电量")
private Float powerYesterDay;
@ApiModelProperty(value = "站点实时温度")
private String temp;

19
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java

@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author ysj
@ -29,12 +28,30 @@ public class HydropowerUnitTargetVo {
@ApiModelProperty(value = "当年发电量")
private Float powerYear;
@ApiModelProperty(value = "当年发电量")
private Float powerYesterYear;
@ApiModelProperty(value = "当月发电量")
private Float powerMon;
@ApiModelProperty(value = "当日发电量")
private Float powerDay;
@ApiModelProperty(value = "昨日发电量")
private Float powerYesterDay;
@ApiModelProperty(value = "本次开机时间")
private String startTime;
@ApiModelProperty(value = "本次开机时长")
private Double startupDuration;
@ApiModelProperty(value = "年停机时长")
private Double shutDownDurationYear;
@ApiModelProperty(value = "年开机时长")
private Double startupDurationYear;
@ApiModelProperty(value = "当日机组有功功率")
private List<ActivePowerVo> activePowerVoList;

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

@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -69,4 +70,20 @@ public class GenerationScheduledTask {
return new ReturnT<>("SUCCESS");
}
/**
* 新版-近3年发电量
* @param param
* @return
*/
//@XxlJob(LOAD_THREE_YEAR_POWER_GENERATION)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadThreeYearPowerGeneration() {
String param = "";
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
service.loadThreeYearPowerGeneration(param,Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),2,3);
return new ReturnT<>("SUCCESS");
}
}

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

@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Arrays;

4
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/ObtainGenerationService.java

@ -1,5 +1,7 @@
package com.hnac.hzims.scheduled.service.operation.home;
import java.util.List;
/**
* @author ysj
*/
@ -10,4 +12,6 @@ public interface ObtainGenerationService {
void thirtyDayPowerGeneration(String param);
void thisDayPowerGeneration(String param);
void loadThreeYearPowerGeneration(String param, List<Integer> types, Integer serveType,int year);
}

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

@ -2,6 +2,7 @@ package com.hnac.hzims.scheduled.service.operation.home.impl;
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.equipment.entity.ThirtyGenerationEntity;
@ -59,8 +60,11 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
@Value("${hzims.equipment.emInfo.emInfoList}")
public String device_cache_cofig_final;
private final static String recent_year_power_data = "hzims:operation:key:power:data";
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("obtain-generation-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy());
/**
* 设备近3年发电量数据 : 按月分割
* @param param
@ -131,8 +135,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
CountDownLatch countDownLatch = new CountDownLatch(limits.size());
List<ThirtyGenerationEntity> saves = new CopyOnWriteArrayList<>();
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());
@ -175,10 +179,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){
log.error("save_generation_execute_complete_error : {}" ,e.getMessage());
}
}catch (Exception e){
countDownLatch.countDown();
log.error("save_generation_execute_complete_error : {}" ,e.getMessage());
}
});
}
// 等待所有线程执行完成
try {
@ -216,9 +221,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3);
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
stations.forEach(station->{
this.threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end));
});
stations.forEach(station-> this.threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end)));
}
/**
@ -306,6 +309,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
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());
}
}
@ -378,6 +382,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
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());
}
}
@ -437,4 +442,54 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
private static Integer countStep(Integer size) {
return (size + 3 - 1) / 3;
}
/**
* 新版-近3年发电量
* @param param
*/
@Override
public void loadThreeYearPowerGeneration(String param, List<Integer> types, Integer serveType,int year) {
// 站点查询
List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
if (CollectionUtil.isNotEmpty(types)) {
in(StationEntity::getType, types);
}
}});
// 开始时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
// 结束日期
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year);
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
List<ThreeGenerationEntity> generations = threeGenerateService.list(Wrappers.<ThreeGenerationEntity>lambdaQuery()
.in(ThreeGenerationEntity::getStationId,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.ge(ThreeGenerationEntity::getStrMonth,start)
.le(ThreeGenerationEntity::getStrMonth,end)
);
if(CollectionUtil.isEmpty(generations)){
return;
}
Map<String,List<ThreeGenerationEntity>> map = generations.stream().collect(Collectors.groupingBy(ThreeGenerationEntity::getStationId));
// 定义接收参数
Map<String, Map<String, Float>> container = new HashMap<>();
map.forEach((key, value) -> {
Optional<StationEntity> optional = stations.stream().filter(o -> o.getCode().equals(key)).findFirst();
if (!optional.isPresent()) {
return;
}
// 根据月份分组
Map<String, List<ThreeGenerationEntity>> months = value.stream().collect(Collectors.groupingBy(ThreeGenerationEntity::getStrMonth));
// 接收月份发电量对象
Map<String, Float> son = new HashMap<>();
// 遍历月份数据
months.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(iter -> son.put(iter.getKey(), (float) iter.getValue().stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()));
container.put(optional.get().getCode(), son);
});
redisTemplate.opsForValue().set(recent_year_power_data, container);
}
}

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

@ -7,6 +7,8 @@ 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.entity.ThirtyGenerationEntity;
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient;
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo;
@ -19,6 +21,8 @@ import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.service.equipment.DeviceParamService;
import com.hnac.hzims.scheduled.service.equipment.DeviceService;
import com.hnac.hzims.scheduled.service.equipment.ThirtyGenerateService;
import com.hnac.hzims.scheduled.service.equipment.ThreeGenerateService;
import com.hnac.hzims.scheduled.service.operation.fill.*;
import com.hnac.hzims.scheduled.service.operation.home.ModelStationService;
import com.hnac.hzims.scheduled.service.operation.home.RealTargetService;
@ -92,6 +96,10 @@ public class RealTargetServiceImpl implements RealTargetService {
private final ModelStationService modelStationService;
private final ThreeGenerateService threeGenerateService;
private final ThirtyGenerateService thirtyGenerateService;
private final RedisTemplate redisTemplate;
private final IHeWeatherWeatherClient heWeatherWeatherClient;
@ -102,6 +110,7 @@ public class RealTargetServiceImpl implements RealTargetService {
private final DeviceDataClient deviceDataClient;
@Value("${hzims.equipment.emInfo.emInfoList}")
public String device_cache_cofig_final;
@ -272,6 +281,12 @@ public class RealTargetServiceImpl implements RealTargetService {
if(CollectionUtil.isEmpty(stations)){
return;
}
// 设备30日发电量
List<ThirtyGenerationEntity> generations = this.thirtyGenerations(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 设备当年发电量
List<ThreeGenerationEntity> generationYears = this.threeGenerations(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 设备去年发电量
List<ThreeGenerationEntity> generationYesterYears = this.threeYesterGenerations(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 补充填补发电指标
List<HydropowerUnitTargetVo> targets = this.generteFill(stations);
// 水电站设备
@ -283,19 +298,24 @@ public class RealTargetServiceImpl implements RealTargetService {
try{
HydropowerUnitTargetVo target = new HydropowerUnitTargetVo();
target.setDeptId(device.getCreateDept());
Optional<StationEntity> station = stations.stream().filter(o->o.getRefDept().equals(device.getCreateDept())).findFirst();
station.ifPresent(stationEntity -> target.setDeptName(stationEntity.getName()));
target.setDeviceCode(device.getEmCode());
target.setDeviceName(device.getName());
target.setDeptName(device.getName());
// 当年发电量
target.setPowerYear(this.getGenerationPower(device, 0));
target.setPowerYear(this.devicePowerYear(generationYears,device));
// 去年发电量
target.setPowerYesterYear(this.devicePowerYesterYear(generationYesterYears,device));
// 当月发电量
target.setPowerMon(this.getGenerationPower(device, 1));
target.setPowerMon(this.devicePowerMon(generationYears,device));
// 当日发电量
target.setPowerDay(this.getGenerationPower(device, 2));
target.setPowerDay(this.devicePowerDay(generations,device));
// 昨日发电量
target.setPowerYesterDay(this.devicePowerYesterDay(generations,device));
// 当天有功功率
target.setActivePowerVoList(this.getLoadsByDay(device));
// 30天发电量
target.setGenerationPowerVoList(this.getGenerationPowerList(device));
target.setGenerationPowerVoList(this.getGenerationPowerList(generations,device));
targets.add(target);
countDownLatch.countDown();
}catch (Exception exception){
@ -317,6 +337,75 @@ public class RealTargetServiceImpl implements RealTargetService {
redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets);
}
/**
* 去年发电量
* @param generations
* @param device
* @return
*/
private Float devicePowerYesterYear(List<ThreeGenerationEntity> generations, EminfoAndEmParamVo device) {
if(CollectionUtil.isEmpty(generations)){
return 0f;
}
return (float) generations.stream().filter(o -> StringUtil.isNotBlank(o.getDeviceCode()) && o.getDeviceCode().equals(device.getEmCode())).mapToDouble(o->o.getGenerate().doubleValue()).sum();
}
/**
* 当年发电量
* @param generations
* @param device
* @return
*/
private Float devicePowerYear(List<ThreeGenerationEntity> generations, EminfoAndEmParamVo device) {
if(CollectionUtil.isEmpty(generations)){
return 0f;
}
return (float) generations.stream().filter(o -> StringUtil.isNotBlank(o.getDeviceCode()) && o.getDeviceCode().equals(device.getEmCode())).mapToDouble(o->o.getGenerate().doubleValue()).sum();
}
/**
* 当月发电量
* @param generations
* @param device
* @return
*/
private Float devicePowerMon(List<ThreeGenerationEntity> generations, EminfoAndEmParamVo device) {
if(CollectionUtil.isEmpty(generations)){
return 0f;
}
return (float) generations.stream().filter(o-> StringUtil.isNotBlank(o.getDeviceCode()) && o.getDeviceCode().equals(device.getEmCode()) && o.getStrMonth().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(o->o.getGenerate().doubleValue()).sum();
}
/**
* 设备当日发电量
* @param generations
* @param device
* @return
*/
private Float devicePowerDay(List<ThirtyGenerationEntity> generations, EminfoAndEmParamVo device) {
if(CollectionUtil.isEmpty(generations)){
return 0f;
}
return (float) generations.stream().filter(o->o.getDeviceCode().equals(device.getEmCode()) && o.getStrDay().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(o->o.getGenerate().doubleValue()).sum();
}
/**
* 设备昨日发电量
* @param generations
* @param device
* @return
*/
private Float devicePowerYesterDay(List<ThirtyGenerationEntity> generations, EminfoAndEmParamVo device) {
if(CollectionUtil.isEmpty(generations)){
return 0f;
}
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-1);
return (float) generations.stream().filter(o->o.getDeviceCode().equals(device.getEmCode()) && o.getStrDay().contains(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE))).mapToDouble(o->o.getGenerate().doubleValue()).sum();
}
/**
* 水利-泵组实时加载
* @param param
@ -1392,7 +1481,7 @@ public class RealTargetServiceImpl implements RealTargetService {
}
return records.stream().map(record -> {
ActivePowerVo load = new ActivePowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss");
load.setStrHour(DateUtil.format(time,"yyyy-MM-dd HH"));
load.setHour(time.getHours());
if(StringUtil.isNotBlank(record.getVal())){
@ -1469,10 +1558,14 @@ public class RealTargetServiceImpl implements RealTargetService {
target.setDeptName(station.getName());
// 当年发电量
target.setPowerYear(generateService.generate(year,station.getCode()));
// FIXME 去年发电量
target.setPowerYesterYear(0f);
// 当月发电量
target.setPowerMon(generateService.generate(mon,station.getCode()));
// 当日发电量
target.setPowerDay(generateService.generate(day,station.getCode()));
// FIXME 昨日发电量
target.setPowerYesterDay(0f);
// 30天发电量
target.setGenerationPowerVoList(generateService.generate30Day(day,station.getCode()));
return target;
@ -1875,33 +1968,78 @@ public class RealTargetServiceImpl implements RealTargetService {
return dataService.periodTargetFloat(start,end,5,accessRules,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
}
/**
* 近30天发电量
* @param device
* 站点设备近30天发电量
* @param stations
* @return
*/
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) {
private List<ThirtyGenerationEntity> thirtyGenerations(List<String> stations) {
Calendar calendar = Calendar.getInstance();
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.DAY_OF_MONTH,-29);
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));
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){
return new ArrayList<>();
}
return records.stream().map(record -> {
GenerationPowerVo generate = new GenerationPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE));
if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(0f);
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE);
return thirtyGenerateService.list(Wrappers.<ThirtyGenerationEntity>lambdaQuery()
.in(ThirtyGenerationEntity::getStationId,stations)
.ge(ThirtyGenerationEntity::getStrDay,start)
.le(ThirtyGenerationEntity::getStrDay,end)
);
}
/**
* 站点设备今年发电量
* @param stations
* @return
*/
private List<ThreeGenerationEntity> threeGenerations(List<String> stations) {
return threeGenerateService.list(Wrappers.<ThreeGenerationEntity>lambdaQuery()
.in(ThreeGenerationEntity::getStationId,stations)
.like(ThreeGenerationEntity::getStrMonth,DateUtil.format(new Date(),"yyyy"))
);
}
/**
* 查询设备去年发电量
* @param stations
* @return
*/
private List<ThreeGenerationEntity> threeYesterGenerations(List<String> stations) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.YEAR,-1);
return threeGenerateService.list(Wrappers.<ThreeGenerationEntity>lambdaQuery()
.in(ThreeGenerationEntity::getStationId,stations)
.like(ThreeGenerationEntity::getStrMonth,DateUtil.format(calendar.getTime(),"yyyy"))
);
}
/**
* 设备近30天发电量组装
* @param generations
* @param device
* @return
*/
private List<GenerationPowerVo> getGenerationPowerList(List<ThirtyGenerationEntity> generations,EminfoAndEmParamVo device) {
Calendar calendar = Calendar.getInstance();
Date end = calendar.getTime();
calendar.add(Calendar.DAY_OF_MONTH,-29);
Date start = calendar.getTime();
List<GenerationPowerVo> powers = new ArrayList<>();
while (end.compareTo(start) >= 0){
GenerationPowerVo power = new GenerationPowerVo();
if (CollectionUtil.isEmpty(generations)) {
power.setDate(DateUtil.format(start,DateUtil.PATTERN_DATE));
power.setGenerate(0f);
}else{
generate.setGenerate(Float.parseFloat(String.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount())));
String date = DateUtil.format(start,DateUtil.PATTERN_DATE);
power.setDate(date);
power.setGenerate((float) generations.stream().filter(iter->iter.getDeviceCode().equals(device.getEmCode()) && iter.getStrDay().contains(date)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
}
return generate;
}).collect(Collectors.toList());
calendar.add(Calendar.DAY_OF_MONTH,1);
powers.add(power);
start = calendar.getTime();
}
return powers;
}
}

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java

@ -86,8 +86,12 @@ public class OperAccessLibraryServiceImpl extends ServiceImpl<OperAccessLibraryM
}
@Override
public R<OperAccessLibraryVO> detail(Long id) {
public R<OperAccessLibraryVO>
detail(Long id) {
OperAccessLibraryVO detail = OperAccessLibraryWrapper.build(emInfoClient).entityVO(super.getById(id));
if(StringUtils.isEmpty(detail.getSafeInfos())){
R.data(detail);
}
detail.setDangerSources(dangerSourceClient.details(detail.getSafeInfos().split(",")));
return R.data(detail);
}

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

@ -161,6 +161,8 @@ public class HydropowerServiceImpl implements HydropowerService {
response.setPowerSum(this.getPowerSum(realList,station.getRefDept()));
// 总有功单位
response.setPowerUnit(this.getPowerUnit(realList,station.getRefDept()));
// 容量利用率
response.setCapacityRate(this.getCapacityRate(response));
// 月计划发电量
response.setPlanPowerMon(this.getPlanPowerrMon(station.getCode()));
// 年计划发电量
@ -169,7 +171,9 @@ public class HydropowerServiceImpl implements HydropowerService {
this.stationMonthPower(station.getCode(),map,response);
// 水位、水位曲线
this.handleWaterLeve(station.getCode(),response);
// 年发电量完成百分比
// 今日,昨日发电量
this.powerDay(station,targetList,response);
// 年发电量完成百分比曲线
response.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map));
// 设备信息
response.setDeviceList(this.getDevices(station,realList,targetList));
@ -177,6 +181,38 @@ public class HydropowerServiceImpl implements HydropowerService {
}
/**
* 容量利用率
* @param response
* @return
*/
private double getCapacityRate(HydropowerStationVo response) {
if(response.getInstalledCapacity() > 0 && response.getPowerSum() > 0){
return BigDecimal.valueOf(response.getPowerSum() / response.getInstalledCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
return 0.0;
}
/**
* 今日昨日发电量
* @param station
* @param targetList
* @param response
*/
private void powerDay(StationEntity station, List<HydropowerUnitTargetVo> targetList, HydropowerStationVo response) {
response.setPowerDay(0f);
response.setPowerYesterDay(0f);
if(CollectionUtil.isEmpty(targetList)){
return;
}
List<HydropowerUnitTargetVo> valids = targetList.stream().filter(o-> null != station.getRefDept() && station.getRefDept().equals(o.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(valids)){
return;
}
response.setPowerDay((float)valids.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum());
response.setPowerYesterDay((float)valids.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYesterDay).sum());
}
/**
* 水电站-机组列表
* @param deptId
* @return
@ -223,10 +259,8 @@ public class HydropowerServiceImpl implements HydropowerService {
hydropowerUnitVo.setHydropowerPumpRealVo(real);
// 指标数据
if(CollectionUtil.isNotEmpty(validTargetList)){
List<HydropowerUnitTargetVo> target = targetList.stream().filter(o->real.getDeviceCode().equals(o.getDeviceCode())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(target)){
hydropowerUnitVo.setHydropowerPumpTargetVo(target.get(0));
}
Optional<HydropowerUnitTargetVo> optional = targetList.stream().filter(o->real.getDeviceCode().equals(o.getDeviceCode())).findFirst();
optional.ifPresent(hydropowerUnitVo::setHydropowerPumpTargetVo);
}
list.add(hydropowerUnitVo);
}

5
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml

@ -4,7 +4,7 @@
<select id="selectCarByYear" resultType="com.hnac.hzims.safeproduct.vo.CarMilesYearVO">
SELECT
DISTINCT t1.unit, t1.car_brand, t1.plate_number, t1.create_time
DISTINCT t1.unit, t1.car_brand, t1.plate_number, t1.create_time, t1.create_user, t1.create_dept
FROM
hzims_car t1
LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id
@ -22,7 +22,8 @@
<select id="selectMilesByCar" resultType="com.hnac.hzims.safeproduct.dto.CarMilesYearDTO">
SELECT
t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles
t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles,
t1.create_user, t1.create_dept
FROM
hzims_car t1
LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id

Loading…
Cancel
Save