Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 1 year ago
parent
commit
671fb42e79
  1. 1
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java
  2. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/WindEntity.java
  3. 20
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java
  4. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/WindServiceImpl.java
  5. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java
  6. 41
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java

1
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java

@ -2,7 +2,6 @@ package com.hnac.hzims.operational.access.feign;
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/WindEntity.java

@ -29,9 +29,6 @@ public class WindEntity extends TenantEntity implements Serializable {
@ApiModelProperty("填报日期")
private String fillDate;
@ApiModelProperty("计划发电量")
private Double plan;
@ApiModelProperty("发电量")
private Double power;

20
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java

@ -5,11 +5,12 @@ import com.hnac.hzims.operational.data.service.HzimsDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
@AllArgsConstructor
@RequestMapping("/hzims_data")
@Api(value = "hzims_data", tags = "hzims数据获取")
@Slf4j
public class HzimsDataController {
private final HzimsDataService service;
@ -44,4 +46,16 @@ public class HzimsDataController {
public R saveStation() {
return R.data(service.saveStation());
}
/**
* 测试动作模板回调接口
*/
@ApiLog
@PostMapping("/test")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "测试动作模板回调接口", notes = "map接收参数")
public R test(@RequestBody Map<String, Object> params) {
log.error("动作模板回调接口参数: {}",params.toString());
return R.data(params);
}
}

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/WindServiceImpl.java

@ -17,6 +17,8 @@ import com.hnac.hzims.operational.fill.wrapper.GenerateWrapper;
import com.hnac.hzims.operational.fill.wrapper.WindWrapper;
import com.hnac.hzims.operational.main.vo.GenerationPowerVo;
import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
@ -45,6 +47,8 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class WindServiceImpl extends BaseServiceImpl<WindMapper, WindEntity> implements WindService {
private final IStationService stationService;
/**
* 分页查询风电填报数据
* @param filter
@ -77,6 +81,14 @@ public class WindServiceImpl extends BaseServiceImpl<WindMapper, WindEntity> imp
*/
@Override
public boolean saveUpdate(WindEntity entity) {
// 查询站点所属机构
StationEntity station = stationService.getOne(new LambdaQueryWrapper<StationEntity>(){{
eq(StationEntity::getCode, entity.getStationCode());
}});
if(ObjectUtil.isEmpty(station)){
throw new ServiceException("风电站点不存在!");
}
entity.setCreateDept(station.getRefDept());
// 查询是否存在历史记录
WindEntity query = this.getOne(new LambdaQueryWrapper<WindEntity>(){{
eq(WindEntity::getStationCode, entity.getStationCode());

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java

@ -79,6 +79,8 @@ public class HomeServiceImpl implements HomeService {
private final ITicketInfoAllClient ticketClient;
private final IPlanGenertionClient planClient;
private final RedisTemplate redisTemplate;
private final static String charge = "hzims:operation:key:charge";
@ -139,7 +141,7 @@ public class HomeServiceImpl implements HomeService {
@Override
public List<StationCountVo> count(boolean make) {
// 查询全部站点
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.<StationEntity>lambdaQuery();
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.lambdaQuery();
if(make){
wrapper.ne(StationEntity::getStatus,2);
}
@ -244,13 +246,16 @@ public class HomeServiceImpl implements HomeService {
if(CollectionUtil.isEmpty(stations)){
return target;
}
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null, DateUtil.format(new Date(),"yyyy"));
// 填报信息
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery()
.in(WindEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.likeRight(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy")));
if(CollectionUtil.isEmpty(winds)){
return target;
}
double plan = winds.stream().mapToDouble(WindEntity::getPlan).sum();
double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
double power = winds.stream().mapToDouble(WindEntity::getPower).sum();
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
// 装机容量

41
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java

@ -5,6 +5,8 @@ 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.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
@ -92,6 +94,7 @@ public class WindHomeServiceImpl implements WindHomeService {
private final ITicketInfoClient ticketInfoClient;
private final IPlanGenertionClient planClient;
private final IInspectTaskReportClient inspectTaskReportClient;
@ -130,7 +133,8 @@ public class WindHomeServiceImpl implements WindHomeService {
// 年发电量
score.setGenerateYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPower).sum());
// 年计划发电量
score.setPlanYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum());
List<PlanGenerationEntity> yearPlans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,DateUtil.format(new Date(),"yyyy"));
score.setPlanYear(yearPlans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 年发电完成率
if(Math.abs(score.getGenerateYear()) > 0 && Math.abs(score.getPlanYear()) > 0){
score.setCompleteRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
@ -138,7 +142,7 @@ public class WindHomeServiceImpl implements WindHomeService {
// 月发电量
score.setGenerateMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPower).sum());
// 月计划发电量
score.setPlanMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPlan).sum());
score.setPlanMon(yearPlans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 月发电量完成率
if(Math.abs(score.getGenerateMon()) > 0 && Math.abs(score.getPlanMon()) > 0){
score.setCompleteMonRate(BigDecimal.valueOf(score.getGenerateMon() / score.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
@ -191,12 +195,13 @@ public class WindHomeServiceImpl implements WindHomeService {
*/
private List<PowerMonthVo> currentGenerateCurve(List<WindEntity> winds) {
List<String> mons = this.mons(0,12,false);
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(winds.stream().map(WindEntity::getStationCode).distinct().collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy"));
return mons.stream().map(mon->{
PowerMonthVo power = new PowerMonthVo();
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
power.setYear(localDate.getYear());
power.setStrMonth(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
power.setPlanPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPlan).sum());
power.setPlanPower((float) plans.stream().filter(o->o.getDateTime().contains(power.getYear() + power.getStrMonth())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
power.setPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPower).sum());
return power;
}).collect(Collectors.toList());
@ -257,8 +262,10 @@ public class WindHomeServiceImpl implements WindHomeService {
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(winds.stream().mapToDouble(WindEntity::getPower).sum()) > 0){
subordinate.setGenerationRate(BigDecimal.valueOf(subordinate.getGeneration() / winds.stream().mapToDouble(WindEntity::getPower).sum() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
// 计划发电量查询
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy"));
double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
// 发电完成率
double plan = piece.stream().mapToDouble(WindEntity::getPlan).sum();
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(plan) > 0){
subordinate.setGenerationComplete(BigDecimal.valueOf(subordinate.getGeneration() / plan * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
@ -311,9 +318,9 @@ public class WindHomeServiceImpl implements WindHomeService {
}
// 装机容量
kpi.setCapacity(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
// 计划发电量
kpi.setPlan(winds.stream().mapToDouble(WindEntity::getPlan).sum());
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy"));
kpi.setPlan(plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 实际发电量
kpi.setGenerate(winds.stream().mapToDouble(WindEntity::getPower).sum());
// 发电量完成率
@ -366,12 +373,14 @@ public class WindHomeServiceImpl implements WindHomeService {
in(WindEntity::getStationCode,codes)
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy"));
}});
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(codes, null,DateUtil.format(new Date(),"yyyy"));
return areas.entrySet().stream().map(entry -> {
WindAreaVo area = new WindAreaVo();
area.setDeptId(entry.getKey().getId());
area.setDeptName(entry.getKey().getDeptName());
List<String> stationCodes = entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList());
area.setPlan(winds.stream().filter(o-> stationCodes.contains(o.getStationCode())).mapToDouble(WindEntity::getPlan).sum());
area.setPlan(plans.stream().filter(o-> stationCodes.contains(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
area.setGenerate(winds.stream().filter(o-> stationCodes.contains(o.getStationCode())).mapToDouble(WindEntity::getPower).sum());
if(Math.abs(area.getPlan()) > 0 && Math.abs(area.getGenerate()) > 0){
area.setGenerateComplete(BigDecimal.valueOf(area.getGenerate() / area.getPlan() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
@ -500,14 +509,17 @@ public class WindHomeServiceImpl implements WindHomeService {
areaDuty.setPeakPower(winds.stream().mapToDouble(WindEntity::getPeakPower).average().orElse(0.0));
areaDuty.setFaultHours(winds.stream().mapToDouble(WindEntity::getFaultHours).average().orElse(0.0));
}
// 填报发电量
List<WindEntity> windMons = windService.list(new LambdaQueryWrapper<WindEntity>() {{
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy-MM"));
}});
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy-MM"));
if(CollectionUtil.isNotEmpty(windMons)){
areaDuty.setGenerateMon(windMons.stream().mapToDouble(WindEntity::getPower).sum());
// 月计划发电量
areaDuty.setPlanMon(windMons.stream().mapToDouble(WindEntity::getPlan).sum());
areaDuty.setPlanMon(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 月发电量完成率
if(Math.abs(areaDuty.getGenerateMon()) > 0 && Math.abs(areaDuty.getPlanMon()) > 0){
areaDuty.setCompleteMonRate(BigDecimal.valueOf(areaDuty.getGenerateMon() / areaDuty.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
@ -521,7 +533,7 @@ public class WindHomeServiceImpl implements WindHomeService {
if(CollectionUtil.isEmpty(windYears)){
return;
}
areaDuty.setPlan(windYears.stream().mapToDouble(WindEntity::getPlan).sum());
areaDuty.setPlan(plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
areaDuty.setGenerate(windYears.stream().mapToDouble(WindEntity::getPower).sum());
// 发电量完成率
if(Math.abs(areaDuty.getPlan()) > 0 && Math.abs(areaDuty.getGenerate()) > 0){
@ -806,13 +818,15 @@ public class WindHomeServiceImpl implements WindHomeService {
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy"));
}});
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy"));
// 设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
subordinate.setStations(stations.stream().map(station -> {
WindStationGenerateVo generate = new WindStationGenerateVo();
generate.setDeptId(station.getRefDept());
generate.setDeptName(station.getName());
generate.setPlan(winds.stream().filter(o-> o.getStationCode().equals(station.getCode())).mapToDouble(WindEntity::getPlan).sum());
generate.setPlan(plans.stream().filter(o-> o.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
generate.setGenerate(winds.stream().filter(o-> o.getStationCode().equals(station.getCode())).mapToDouble(WindEntity::getPower).sum());
// 发电量完成率
if(Math.abs(generate.getPlan()) > 0 && Math.abs(generate.getGenerate()) > 0){
@ -918,11 +932,13 @@ public class WindHomeServiceImpl implements WindHomeService {
List<WindEntity> all = windService.list(Wrappers.<WindEntity>lambdaQuery()
.eq(WindEntity::getStationCode,station.getCode())
);
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(Collections.singletonList(station.getCode()), null,DateUtil.format(new Date(),"yyyy"));
if(CollectionUtil.isNotEmpty(all)){
// 年计划发电量
wind.setPlanYear(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum());
wind.setPlanYear(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 月计划发电量
wind.setPlanMon(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPlan).sum());
wind.setPlanMon(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 总发电量
wind.setGeneration(all.stream().mapToDouble(WindEntity::getPower).sum());
// 日上网电量
@ -965,7 +981,6 @@ public class WindHomeServiceImpl implements WindHomeService {
WindGenerationVo generation = new WindGenerationVo();
generation.setYear(localDate.getYear());
generation.setMon(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
generation.setPlan(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPlan).sum());
generation.setGeneration(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPower).sum());
return generation;
}).collect(Collectors.toList());

Loading…
Cancel
Save