From b0b79143ec0d731de19e03851611cd2ae1d71a90 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 17 Apr 2024 23:30:49 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E4=BF=AE=E6=AD=A3=EF=BC=9A=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E5=88=86=E7=BB=84"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7ee6670802cd410afd9d1baf7168be1df5a258e3. --- .../operation/home/impl/RealTargetServiceImpl.java | 42 ++++++---------------- .../duty/service/impl/ImsDutyGroupServiceImpl.java | 9 ----- 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index 4e2e6f0..5ada884 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -35,7 +35,6 @@ import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; -import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -54,7 +53,6 @@ import java.math.RoundingMode; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -114,12 +112,8 @@ public class RealTargetServiceImpl implements RealTargetService { private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; - @Getter - private static final ThreadPoolExecutor fixedThreadExecutor; - static { - ThreadFactory threadFactory = Executors.defaultThreadFactory(); - fixedThreadExecutor = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingDeque(), threadFactory); - } + + @Override public void loadEmInfo(String param) { List stations = stationService.list(Wrappers.lambdaQuery() @@ -1213,9 +1207,6 @@ public class RealTargetServiceImpl implements RealTargetService { */ @Override public void loadPowerData(String param, List types, Integer serveType, int year) { - Long time=System.currentTimeMillis(); - System.out.println("近年发电量接口耗时测试开始======================="); - log.info("近年发电量接口耗时测试开始======================="); // 站点查询 List stationList = stationService.list(new LambdaQueryWrapper() {{ eq(StationEntity::getDataOrigin,"0"); @@ -1240,23 +1231,17 @@ public class RealTargetServiceImpl implements RealTargetService { String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; // 存储数据map :<站点id,<月份,发电量>> Map> powerMap = new HashMap<>(); - Long time2=System.currentTimeMillis(); - log.info("近年发电量接口,数据组装"+(time2-time)); stationList.forEach(station -> { - fixedThreadExecutor.execute(()->{ - // 站点设备集合 - List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); - log.error("load_power_data station :" + station.getCode() + "==== device :" + stationDevices ); - Map generateMap = this.getGenerateYear(station,stationDevices,start,end); - if(MapUtils.isEmpty(generateMap)){ - return; - } - powerMap.put(station.getId(),generateMap); - }); + // 站点设备集合 + List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + log.error("load_power_data station :" + station.getCode() + "==== device :" + stationDevices ); + Map generateMap = this.getGenerateYear(station,stationDevices,start,end); + if(MapUtils.isEmpty(generateMap)){ + return; + } + powerMap.put(station.getId(),generateMap); }); redisTemplate.opsForValue().set(recent_year_power_data, powerMap); - Long time3=System.currentTimeMillis(); - log.info("近年发电量数据接口,总耗时:"+(time3-time)); } /** @@ -1333,7 +1318,6 @@ public class RealTargetServiceImpl implements RealTargetService { */ private Map getGenerateYear(StationEntity station,List devices, String start, String end) { List datas = new ArrayList<>(); - long l = System.currentTimeMillis(); // 设备采集发电量 if(CollectionUtil.isNotEmpty(devices)){ devices.forEach(device->{ @@ -1350,17 +1334,11 @@ public class RealTargetServiceImpl implements RealTargetService { }).collect(Collectors.toList())); }); } - long l2 = System.currentTimeMillis(); - log.info("getGenerateYear接口,"+station.getName()+"-设备采集发电量数据耗时:"+(l2-l)); // 补充填报数据 datas.addAll(this.generateFill(station,start,end)); - long l3 = System.currentTimeMillis(); - log.info("getGenerateYear接口,"+station.getName()+":补充填报数据"+(l3-l2)); if(CollectionUtil.isEmpty(datas)){ return null; } - long l4 = System.currentTimeMillis(); - log.info("getGenerateYear接口,"+station.getName()+":接口总耗时"+(l4-l)); return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum)); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java index 0977941..75c2498 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java @@ -2,7 +2,6 @@ package com.hnac.hzims.operational.duty.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.duty.entity.*; import com.hnac.hzims.operational.duty.mapper.ImsDutyGroupMapper; @@ -344,14 +343,6 @@ public class ImsDutyGroupServiceImpl extends BaseServiceImpllambdaUpdate().set(ImsDutyGroupEntity::getManagerId,null) - .eq(ImsDutyGroupEntity::getId,imsDutyGroupEntity.getId())); - } - } - } Map> collect = list.stream().collect(Collectors.groupingBy(ImsDutyGroupPEntity::getGroupId)); if (updateDuty) { for (Long aLong : collect.keySet()) {