Browse Source

#bug修改

zhongwei
yang_shj 2 years ago
parent
commit
c5529dc9e4
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java
  2. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java
  3. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java
  4. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  6. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainTaskStatisticServiceImpl.java
  7. 135
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java

@ -15,7 +15,7 @@ import lombok.Data;
public class PhotovoltaicPowerVo {
@ApiModelProperty(value = "小时")
private String hour;
private Integer hour;
@ApiModelProperty(value = "有功功率")
private String activePower;

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java

@ -25,6 +25,9 @@ public class PhotovoltaicSubordinateAppVo {
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "机构类型:1-集团、2-省子公司、3-区域、4-站点")
private Integer type;
@ApiModelProperty(value = "天气")
private Now now;
@ -44,7 +47,7 @@ public class PhotovoltaicSubordinateAppVo {
private Double load;
@ApiModelProperty(value = "站点实时功率列表")
private List<PhotovoltaicLoadVo> stationLoads;
private List<PhotovoltaicLoadVo> loads;
@ApiModelProperty(value = "日常任务数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
@ -87,5 +90,6 @@ public class PhotovoltaicSubordinateAppVo {
private Integer workFinishCount;
@ApiModelProperty(value = "排序")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer sort;
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java

@ -58,9 +58,8 @@ public class PhotovoltaicController extends BladeController {
return R.data(service.station(deptId));
}
@ApiLog
@ApiOperation("App区域下属数据")
@ApiOperation("App集团/区域数据")
@GetMapping("/app_subordinate")
@ApiOperationSupport(order = 3)
public R app_subordinate(@ApiParam(value = "区域/站点机构编号") Long deptId) {

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java

@ -29,8 +29,8 @@ public interface PhotovoltaicService {
// 站点数据
PhotovoltaicStationVo station(Long deptId);
// app区域数据
List<PhotovoltaicSubordinateAppVo> app_subordinate(Long deptId);
// app集团/区域数据
PhotovoltaicSubordinateAppVo app_subordinate(Long deptId);
// app站点数据
PhotovoltaicStationAppVo app_station(Long deptId);

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

@ -1331,7 +1331,7 @@ public class HydropowerServiceImpl implements HydropowerService {
* @param area
*/
private void complteTask(HydropowerAreaVo area) {
String start = DateUtil.format(new Date(),"yyyy-mm") + "-01 00:00:00";
String start = DateUtil.format(new Date(),"yyyy-MM") + "-01 00:00:00";
area.setStart(start);
String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
area.setEnd(end);

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainTaskStatisticServiceImpl.java

@ -219,10 +219,10 @@ public class MainTaskStatisticServiceImpl implements IMainTaskStatisticService {
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime now = LocalDateTime.now();
// 消缺总数
List<OperDefectEntity> shortagesSumList = defectService.list(new LambdaQueryWrapper<OperDefectEntity>(){{
ge(OperDefectEntity::getCreateTime,firstDateTime);
le(OperDefectEntity::getCreateTime,now);
in(OperDefectEntity::getCreateDept,list);
List<OperPhenomenonEntity> shortagesSumList = phenomenonService.list(new LambdaQueryWrapper<OperPhenomenonEntity>(){{
ge(OperPhenomenonEntity::getCreateTime,firstDateTime);
le(OperPhenomenonEntity::getCreateTime,now);
in(OperPhenomenonEntity::getCreateDept,list);
}});
if(CollectionUtil.isEmpty(shortagesSumList)){
shortagesVo.setShortagesSum(0);
@ -231,7 +231,8 @@ public class MainTaskStatisticServiceImpl implements IMainTaskStatisticService {
}
// 消缺数
shortagesVo.setShortagesSum(shortagesSumList.size());
List<Long> shortagesList = shortagesSumList.stream().filter(o -> "1".equals(o.getHandleStatus())).map(OperDefectEntity::getId).collect(Collectors.toList());
List<Long> shortagesList = shortagesSumList.stream().filter(o -> (Func.isNotEmpty(o.getIsDefect()) && o.getIsDefect() == 0) || "1".equals(o.getConclusionStatus())).
map(OperPhenomenonEntity::getId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(shortagesList)){
shortagesVo.setShortages(0);
}

135
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

@ -24,6 +24,7 @@ import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils;
import org.jsoup.helper.DataUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
@ -309,12 +310,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
Random random = new Random();
while (start.getTime().compareTo(new Date()) <= 0){
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo();
load.setHour(DateUtil.format(start.getTime(),"yyyy-mm-dd HH"));
load.setHour(start.get(Calendar.HOUR_OF_DAY));
load.setActivePower(String.valueOf(random.nextDouble() * 500));
list.add(load);
start.add(Calendar.HOUR_OF_DAY,1);
}
return list;
return list.stream().sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());
/*String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD);
@ -324,7 +325,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return records.stream().map(record -> {
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
load.setHour(DateUtil.format(time,"yyyy-mm-dd HH"));
load.setHour(time.getHours());
load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0"));
return load;
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());*/
@ -1053,46 +1054,83 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
}
/**
* App区域下属数据
*
* APP集团/省子公司数据
* @param deptId
* @return
*/
@Override
public List<PhotovoltaicSubordinateAppVo> app_subordinate(Long deptId) {
// 获取区域或者站点map结构
Map<Dept, List<StationEntity>> map = areaService.areaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC));
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
public PhotovoltaicSubordinateAppVo app_subordinate(Long deptId) {
// 查询光伏站点
List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), HomePageConstant.HYDROPOWER_SERVETYPE);
if (CollectionUtil.isEmpty(stations)) {
return new PhotovoltaicSubordinateAppVo();
}
PhotovoltaicSubordinateAppVo subordinate = new PhotovoltaicSubordinateAppVo();
// 实时数据
List<PhotovoltaicRealVo> deviceReals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 指标数据
List<PhotovoltaicTargetVo> deviceTargets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
// 遍历数据
List<PhotovoltaicSubordinateAppVo> subordinates = new ArrayList<>();
for (Map.Entry<Dept, List<StationEntity>> entry : map.entrySet()) {
PhotovoltaicSubordinateAppVo subordinate = new PhotovoltaicSubordinateAppVo();
if (ObjectUtil.isEmpty(entry.getValue())) {
continue;
}
StationEntity station = entry.getValue().get(0);
subordinate.setDeptId(entry.getKey().getId());
subordinate.setDeptName(entry.getKey().getDeptName());
subordinate.setSort(entry.getKey().getSort());
subordinate.setAddress(station.getAddress());
// 获取区域或者站点map结构
Map<Dept, List<StationEntity>> map = areaService.areaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC));
// 集团/省子公司名称
this.subordinateDept(subordinate,deptId);
// 区域数据
this.subordinateTargetData(subordinate, stations, deviceReals, deviceTargets);
if(HomePageConstant.AREA > subordinate.getType()){
// 集团数据
this.targetArea(subordinate, map, deviceReals);
}else{
// 获取实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode()));
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(stations.get(0).getCode()));
if (MapUtils.isNotEmpty(nowWeather)) {
subordinate.setNow(nowWeather.get(station.getCode()).getNow());
subordinate.setNow(nowWeather.get(stations.get(0).getCode()).getNow());
}
}
// 容量、实时功率、今日发电量
this.subordinateTargetData(subordinate, new ArrayList<>(entry.getValue()), deviceReals, deviceTargets);
// 当月任务执行情况
this.subordinateTaskMon(subordinate, Collections.singletonList(entry.getKey().getId()));
subordinates.add(subordinate);
this.subordinateTaskMon(subordinate, map.keySet().stream().map(Dept::getId).collect(Collectors.toList()));
return subordinate;
}
/**
* 区域数据
* @param subordinate
* @param map
* @param reals
*/
private void targetArea(PhotovoltaicSubordinateAppVo subordinate, Map<Dept, List<StationEntity>> map, List<PhotovoltaicRealVo> reals) {
if(MapUtils.isEmpty(map)){
return;
}
subordinate.setLoads(map.entrySet().stream().map(entry -> {
PhotovoltaicLoadVo load = new PhotovoltaicLoadVo();
load.setDeptId(entry.getKey().getId());
load.setName(entry.getKey().getDeptName());
load.setLoad(reals.stream().filter(real -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
return load;
}).collect(Collectors.toList()));
}
/**
* 设置省子公司名称
* @param subordinate
*/
private void subordinateDept(PhotovoltaicSubordinateAppVo subordinate,Long deptId) {
R<List<Dept>> result = sysClient.getDeptByCurrentUser();
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return;
}
return subordinates;
Optional<Dept> optional;
if(ObjectUtil.isNotEmpty(deptId)){
optional = result.getData().stream().filter(dept -> dept.getId().equals(deptId)).min(Comparator.comparing(Dept::getDeptCategory));
}else{
optional = result.getData().stream().min(Comparator.comparing(Dept::getDeptCategory));
}
optional.ifPresent(dept -> {
subordinate.setDeptId(dept.getId());
subordinate.setDeptName(dept.getDeptName());
subordinate.setType(dept.getDeptCategory());
});
}
/**
@ -1101,17 +1139,15 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
* @param subordinate
*/
private void subordinateTaskMon(PhotovoltaicSubordinateAppVo subordinate, List<Long> depts) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
LocalDate firstDay = LocalDate.now().withDayOfMonth(1);
LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime endTime = LocalDateTime.now();
String start = DateUtil.format(new Date(),"yyyy-MM") + "-01 00:00:00";
String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
//监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
// 日常维护
exe.execute(() -> {
MaintainVo maintainVo = taskService.getMaintain(dtf.format(startTime), dtf.format(endTime), depts);
MaintainVo maintainVo = taskService.getMaintain(start, end, depts);
subordinate.setMaintenanceCount(maintainVo.getMaintain());
subordinate.setMaintenanceFinishCount(maintainVo.getMaintainFinish());
countDownLatch.countDown();
@ -1126,7 +1162,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
});
// 检修
exe.execute(() -> {
OverhaulVo overhaulVo = taskService.getOverhaul(dtf.format(startTime), dtf.format(endTime), depts);
OverhaulVo overhaulVo = taskService.getOverhaul(start, end, depts);
int overhaul = overhaulVo.getOverhaul();
int overhaulFinish = overhaulVo.getOverhaulFinish();
subordinate.setOverhaulCount(overhaul);
@ -1136,8 +1172,8 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// 操作票&工作票
exe.execute(() -> {
Map<String, Object> map = new HashMap<>();
map.put("startDate", dtf.format(startTime));
map.put("endDate", dtf.format(endTime));
map.put("startDate", start);
map.put("endDate", end);
map.put("deptList", depts);
R<TicketMonthVO> R = ticketInfoClient.getOperateWorkStatistic(map);
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) {
@ -1152,6 +1188,14 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
subordinate.setWorkFinishCount(ticketMonthVO.getWorkQualify());
countDownLatch.countDown();
});
// 等待所有线程执行完成
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
exe.shutdown();
}
/**
@ -1167,26 +1211,31 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
}
List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList());
List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(reals)) {
// 容量 、 实时功率
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
subordinate.setStationLoads(
if(CollectionUtil.isNotEmpty(stations) && HomePageConstant.AREA.equals(subordinate.getType())){
subordinate.setLoads(
stations.stream().map(station -> {
PhotovoltaicLoadVo load = new PhotovoltaicLoadVo();
load.setDeptId(station.getRefDept());
load.setCode(station.getCode());
load.setName(station.getName());
if(CollectionUtil.isNotEmpty(reals)){
load.setLoad(reals.stream().filter(o -> o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
}else{
load.setLoad(0.0);
}
return load;
}).sorted(Comparator.comparing(PhotovoltaicLoadVo::getLoad).reversed()).collect(Collectors.toList())
);
}
if (CollectionUtil.isNotEmpty(reals)) {
// 容量 、 实时功率
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
}
if (CollectionUtil.isNotEmpty(targets)) {
// 今日发电量
subordinate.setGenerateDay(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum());
}
}
/**

Loading…
Cancel
Save