From 6536e70b36a357ff37f978343cbe6f47450593aa Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 15 Jun 2023 15:06:11 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=8A=BD?= =?UTF-8?q?=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/hzims-scheduled/pom.xml | 9 +- .../hnac/hzims/scheduled/ScheduledApplication.java | 23 ++- .../scheduled/mapper/equipment/DeviceMapper.java | 15 ++ .../mapper/equipment/DeviceParamMapper.java | 16 ++ .../scheduled/scheduled/MonitorScheduledTask.java | 1 + .../scheduled/RealTargetScheduledTask.java | 12 ++ .../scheduled/scheduled/ShowScheduledTask.java | 2 + .../service/equipment/DeviceParamService.java | 14 ++ .../scheduled/service/equipment/DeviceService.java | 15 ++ .../equipment/impl/DeviceParamServiceImpl.java | 28 ++++ .../service/equipment/impl/DeviceServiceImpl.java | 28 ++++ .../service/equipment/impl/PlanServiceImpl.java | 2 +- .../equipment/impl/WorkshopInfoServiceImpl.java | 2 +- .../service/operation/AnalyseDataService.java | 22 --- .../scheduled/service/operation/DataService.java | 27 ++++ .../service/operation/RealTargetService.java | 3 + .../operation/impl/AnalyseDataServiceImpl.java | 139 ------------------ .../service/operation/impl/DataServiceImpl.java | 162 +++++++++++++++++++++ .../service/operation/impl/MonitorServiceImpl.java | 3 + .../operation/impl/RealTargetServiceImpl.java | 136 ++++++++++++----- .../service/operation/impl/ShowServiceImpl.java | 6 +- .../resources/mapper/equipment/DeviceMapper.xml | 19 +++ .../mapper/equipment/DeviceParamMapper.xml | 15 ++ hzims-service/inspect/pom.xml | 5 - .../config/scheduled/StAlamRecordTask.java | 14 +- .../main/scheduled/ScheduledCreateTask.java | 7 +- 26 files changed, 497 insertions(+), 228 deletions(-) create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceParamMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceParamService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceParamServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceServiceImpl.java delete mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AnalyseDataService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DataService.java delete mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AnalyseDataServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DataServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceMapper.xml create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceParamMapper.xml diff --git a/hzims-service/hzims-scheduled/pom.xml b/hzims-service/hzims-scheduled/pom.xml index 87e3691..3bc836b 100644 --- a/hzims-service/hzims-scheduled/pom.xml +++ b/hzims-service/hzims-scheduled/pom.xml @@ -12,9 +12,9 @@ hzims-scheduled jar - 8 - 8 UTF-8 + 1.0.3 + 1.9.6 @@ -52,6 +52,11 @@ blade-starter-swagger + com.baomidou + dynamic-datasource-spring-boot-starter + 2.5.6 + + com.hnac.hzims hzims-operational-api diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java index 63fb110..15db15a 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java @@ -1,11 +1,16 @@ package com.hnac.hzims.scheduled; +import com.hnac.hzims.operational.OperationalConstants; import org.mybatis.spring.annotation.MapperScan; import org.springblade.core.cloud.feign.EnableBladeFeign; +import org.springblade.core.launch.BladeApplication; import org.springframework.boot.Banner; import org.springframework.boot.SpringApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.cloud.client.SpringCloudApplication; import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; import javax.annotation.Resource; @@ -15,17 +20,19 @@ import javax.annotation.Resource; * @Serial 1.0 * @Date 2023/5/19 9:05 */ -@EnableBladeFeign +@EnableBladeFeign(basePackages = {"org.springblade","com.hnac"}) @SpringCloudApplication -@MapperScan("com.hnac.hzims.scheduled.**.mapper.**") -@ComponentScan(basePackages = {"com.hnac.*","org.springblade.core"}) +@MapperScan("com.hnac.hzims.scheduled.mapper.**.**") +@EnableScheduling +@ComponentScan(basePackages = {"com.hnac.hzims.scheduled.*","org.springblade.core"}) @Resource -public class ScheduledApplication { +public class ScheduledApplication extends SpringBootServletInitializer { public static void main(String[] args) { - // BladeApplication.run(ScheduledConstants.APP_NAME, ScheduledApplication.class, args); - SpringApplication springApplication = new SpringApplication(ScheduledApplication.class); - springApplication.setBannerMode(Banner.Mode.OFF); - springApplication.run(args); + BladeApplication.run("hzims-scheduled", ScheduledApplication.class, args); } + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled", ScheduledApplication.class); + } } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceMapper.java new file mode 100644 index 0000000..55ca3e2 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.scheduled.mapper.equipment; + +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +import java.util.List; + +/** + * @author ysj + */ +public interface DeviceMapper extends UserDataScopeBaseMapper { + + List device(); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceParamMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceParamMapper.java new file mode 100644 index 0000000..f5bb375 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceParamMapper.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.scheduled.mapper.equipment; + +import com.hnac.hzims.equipment.entity.EmParamEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +import java.util.List; + +/** + * Mapper 接口 + * + * @author Chill + */ +public interface DeviceParamMapper extends UserDataScopeBaseMapper { + + List params(); +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java index 6e5a0e9..ee4a1a1 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java @@ -7,6 +7,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.Date; diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java index b589578..a0c235e 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java @@ -8,11 +8,13 @@ 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; import java.util.Date; +import static com.hnac.hzims.fdp.constants.ScheduledConstant.LOAD_EM_INFO; import static com.hnac.hzims.operational.main.constant.MainConstants.*; @@ -26,6 +28,16 @@ public class RealTargetScheduledTask { @Autowired private RealTargetService service; + /** + * 设备信息缓存 + * @return + * @throws Exception + */ + @XxlJob(LOAD_EM_INFO) + public ReturnT loadEmInfo(String param) { + service.loadEmInfo(); + return new ReturnT<>("SUCCESS"); + } /** * 水电站-机组实时加载 diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java index ee07df0..a65d1da 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java @@ -7,6 +7,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.Date; @@ -28,6 +29,7 @@ public class ShowScheduledTask { * 首页-指标数据加载 */ @XxlJob(LOAD_HOME_TARGET) + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadHomeTarget(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceParamService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceParamService.java new file mode 100644 index 0000000..bfd7201 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceParamService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.scheduled.service.equipment; + +import com.hnac.hzims.equipment.entity.EmParamEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface DeviceParamService extends BaseService { + + List params(); +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceService.java new file mode 100644 index 0000000..5b08d88 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceService.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.scheduled.service.equipment; + +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface DeviceService extends BaseService { + + List device(); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceParamServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceParamServiceImpl.java new file mode 100644 index 0000000..dbc8332 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceParamServiceImpl.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.scheduled.service.equipment.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.hzims.equipment.entity.EmParamEntity; +import com.hnac.hzims.scheduled.mapper.equipment.DeviceParamMapper; +import com.hnac.hzims.scheduled.service.equipment.DeviceParamService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +@DS("equipment") +public class DeviceParamServiceImpl extends BaseServiceImpl implements DeviceParamService { + + + @Override + public List params() { + return this.baseMapper.params(); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceServiceImpl.java new file mode 100644 index 0000000..a93fb52 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceServiceImpl.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.scheduled.service.equipment.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.scheduled.mapper.equipment.DeviceMapper; +import com.hnac.hzims.scheduled.service.equipment.DeviceService; +import com.sun.org.apache.regexp.internal.RE; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +@DS("equipment") +public class DeviceServiceImpl extends BaseServiceImpl implements DeviceService { + @Override + public List device() { + return this.baseMapper.device(); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java index 56cc7ca..56c94bc 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java @@ -14,9 +14,9 @@ import java.util.List; /** * @author ysj */ +@AllArgsConstructor @Service @Slf4j -@AllArgsConstructor @DS("equipment") public class PlanServiceImpl extends BaseServiceImpl implements PlanService { diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/WorkshopInfoServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/WorkshopInfoServiceImpl.java index a82c6dc..fc1d94b 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/WorkshopInfoServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/WorkshopInfoServiceImpl.java @@ -12,8 +12,8 @@ import org.springframework.stereotype.Service; /** * @author hx */ -@Service @AllArgsConstructor +@Service @Slf4j @DS("equipment") public class WorkshopInfoServiceImpl extends BaseServiceImpl implements WorkshopInfoService { diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AnalyseDataService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AnalyseDataService.java deleted file mode 100644 index 7f2fb5c..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AnalyseDataService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.scheduled.service.operation; - -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; -import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; - -import java.util.List; -import java.util.function.Function; - - -/** - * @author ysj - */ -public interface AnalyseDataService { - - List getAnalyzeCodeBySignages(Function convert, T resource); - - - List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); - - Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DataService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DataService.java new file mode 100644 index 0000000..166658f --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DataService.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; +import org.springblade.core.tool.api.R; + +import java.util.List; +import java.util.function.Function; + + +/** + * @author ysj + */ +public interface DataService { + + List getAnalyzeCodeBySignages(Function convert, T resource); + + List analyzeCodeBySignages(List list); + + List getRealDataByAnalyzeCode(String instanceCode, List signages); + + List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); + + Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RealTargetService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RealTargetService.java index 43afd9e..042f5d2 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RealTargetService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RealTargetService.java @@ -8,6 +8,9 @@ import java.util.List; */ public interface RealTargetService { + + void loadEmInfo(); + // 水电站实时数据加载 void loadHydropowerReal(String param); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AnalyseDataServiceImpl.java deleted file mode 100644 index b469c8a..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AnalyseDataServiceImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.hnac.hzims.scheduled.service.operation.impl; - -import com.google.common.collect.Lists; -import com.hnac.hzims.scheduled.service.operation.AnalyseDataService; -import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; -import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; -import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; -import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Service; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * @author hx - */ -@Service -@AllArgsConstructor -@Slf4j -public class AnalyseDataServiceImpl implements AnalyseDataService { - - private final IAnalyseDataSearchClient analyseDataSearchClient; - - @Override - public List getAnalyzeCodeBySignages(Function convert, T resource) { - List result = Lists.newArrayList(); - List multiAnalyzeCodePOList = Lists.newArrayList(resource).stream().map(convert).collect(Collectors.toList()); - R> analyzeCodeBySignResult = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); - if(analyzeCodeBySignResult.isSuccess() && CollectionUtil.isNotEmpty(analyzeCodeBySignResult.getData())) { - result = analyzeCodeBySignResult.getData(); - } - return result; - } - - /*** - * 指标数据列表查询 - * @param startTime 开始时间 - * @param endTime 结束时间 - * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 - * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 - * @param deviceCode 设备编号 - * @param signages 指标 - * @return - */ - @Override - public List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages) { - AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); - List signboardConditions = new ArrayList<>(); - AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); - analyzeDataConditionPO.setFull(1); - po.setDeviceCode(deviceCode); - analyzeDataConditionPO.setSignages(signages); - analyzeDataConditionPO.setKeepFigures(2); - analyzeDataConditionPO.setAccessRules(accessRules); - analyzeDataConditionPO.setSaveTimeType(cycleType); - // 间隔 - analyzeDataConditionPO.setTimeInterval(1); - analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); - analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); - signboardConditions.add(analyzeDataConditionPO); - po.setSignboardConditions(signboardConditions); - log.error("period_target_data_request {}",po); - R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); - if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { - return new ArrayList<>(); - } - log.error("period_target_data_resp {}",result); - return result.getData().get(0).getList(); - } - - /*** - * 指标数据列表查询 - * @param startTime 开始时间 - * @param endTime 结束时间 - * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 - * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 - * @param deviceCode 设备编号 - * @param ride 配电比 - * @param signages 指标 - * @return - */ - @Override - public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) { - AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); - List signboardConditions = new ArrayList<>(); - AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); - analyzeDataConditionPO.setFull(1); - po.setDeviceCode(deviceCode); - analyzeDataConditionPO.setSignages(signages); - analyzeDataConditionPO.setKeepFigures(2); - analyzeDataConditionPO.setAccessRules(accessRules); - analyzeDataConditionPO.setSaveTimeType(cycleType); - // 间隔 - analyzeDataConditionPO.setTimeInterval(1); - analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); - analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); - signboardConditions.add(analyzeDataConditionPO); - po.setSignboardConditions(signboardConditions); - R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); - if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { - return 0f; - } - List records = result.getData(); - if(CollectionUtil.isEmpty(records)){ - return 0f; - } - AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0); - if (ObjectUtil.isEmpty(analyzeDataConditionVO)) { - return 0f; - } - List analyseDataTaosVOList = analyzeDataConditionVO.getList(); - if (CollectionUtil.isEmpty(analyseDataTaosVOList)) { - return 0f; - } - AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0); - if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { - return 0f; - } - return Float.parseFloat(Optional.ofNullable(analyseDataTaosVO.getVal()).orElse("0")) * ride; - } - - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DataServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DataServiceImpl.java new file mode 100644 index 0000000..c9b3847 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DataServiceImpl.java @@ -0,0 +1,162 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.google.common.collect.Lists; +import com.hnac.hzims.scheduled.service.operation.DataService; +import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; +import com.sun.org.apache.regexp.internal.RE; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @author hx + */ +@Service +@AllArgsConstructor +@Slf4j +public class DataServiceImpl implements DataService { + + private final IAnalyseDataSearchClient analyseDataSearchClient; + + @Override + public List getAnalyzeCodeBySignages(Function convert, T resource) { + List result = Lists.newArrayList(); + List multiAnalyzeCodePOList = Lists.newArrayList(resource).stream().map(convert).collect(Collectors.toList()); + R> analyzeCodeBySignResult = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); + if(analyzeCodeBySignResult.isSuccess() && CollectionUtil.isNotEmpty(analyzeCodeBySignResult.getData())) { + result = analyzeCodeBySignResult.getData(); + } + return result; + } + + @Override + public List analyzeCodeBySignages(List list) { + R> result = analyseDataSearchClient.getAnalyzeCodeBySignages(list); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + @Override + public List getRealDataByAnalyzeCode(String instanceCode, List signages) { + RealDataSearchPO realData = new RealDataSearchPO(); + realData.setAnalyzeCode(instanceCode); + realData.setSignages(signages); + // 调用fegin接口查询实时数据 + R> result = analyseDataSearchClient.getRealDataByAnalyzeCode(realData); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param signages 指标 + * @return + */ + @Override + public List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setSignages(signages); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + po.setSignboardConditions(signboardConditions); + log.error("period_target_data_request {}",po); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return new ArrayList<>(); + } + log.error("period_target_data_resp {}",result); + return result.getData().get(0).getList(); + } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param ride 配电比 + * @param signages 指标 + * @return + */ + @Override + public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setSignages(signages); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + po.setSignboardConditions(signboardConditions); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return 0f; + } + List records = result.getData(); + if(CollectionUtil.isEmpty(records)){ + return 0f; + } + AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0); + if (ObjectUtil.isEmpty(analyzeDataConditionVO)) { + return 0f; + } + List analyseDataTaosVOList = analyzeDataConditionVO.getList(); + if (CollectionUtil.isEmpty(analyseDataTaosVOList)) { + return 0f; + } + AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0); + if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { + return 0f; + } + return Float.parseFloat(Optional.ofNullable(analyseDataTaosVO.getVal()).orElse("0")) * ride; + } + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MonitorServiceImpl.java index 06145f6..07df760 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MonitorServiceImpl.java @@ -737,6 +737,9 @@ public class MonitorServiceImpl implements MonitorService { // 遍历设备 List result = new ArrayList<>(); for(EminfoAndEmParamVo device : filters){ + if(CollectionUtil.isEmpty(device.getPoint())){ + continue; + } result.addAll(device.getPoint().values()); } return result; diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RealTargetServiceImpl.java index 6e08365..88794fc 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RealTargetServiceImpl.java @@ -5,15 +5,17 @@ import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.EquipmentConstants; +import com.hnac.hzims.equipment.entity.EmParamEntity; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.station.StationConstants; 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.operation.*; import com.hnac.hzinfo.datasearch.PointData; -import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; @@ -40,6 +42,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * APP首页实现类 @@ -52,13 +55,17 @@ public class RealTargetServiceImpl implements RealTargetService { private final UseService useService; + private final DataService dataService; + private final PowerService powerService; + private final DeviceService deviceService; + private final StationService stationService; private final GenerateService generateService; - private final AnalyseDataService analyseDataService; + private final DeviceParamService deviceParamService; private final StationAttributeService attributeService; @@ -66,8 +73,6 @@ public class RealTargetServiceImpl implements RealTargetService { private final RedisTemplate redisTemplate; - private final IAnalyseDataSearchClient analyseDataSearchClient; - private final IHistoryDataSearchClient historyDataSearchClient; @Value("${hzims.equipment.emInfo.emInfoList}") @@ -86,6 +91,71 @@ public class RealTargetServiceImpl implements RealTargetService { private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; + @Override + public void loadEmInfo() { + // 查询所有首页展示/状态非删除设备 + List devices = deviceService.device(); + // 查询所有设备(ct、pt、installedCapacity)配置参数 + List paramList = deviceParamService.params(); + // 获取设备监测点位:未配置监测点位不进行统计设备 + List multiAnalyzeCodePOList = devices.stream().map(o->{ + MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); + multiAnalyzeCodePO.setDeviceCode(o.getEmCode()); + multiAnalyzeCodePO.setSignages(HomePageConstant.SIGNAGES); + return multiAnalyzeCodePO; + }).collect(Collectors.toList()); + // 切割 + int limit = countStep(multiAnalyzeCodePOList.size()); + List> lists = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> multiAnalyzeCodePOList.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList()); + // 接收数据 + List analys = new ArrayList<>(); + lists.forEach(list->{ + List result = dataService.analyzeCodeBySignages(list); + if(CollectionUtil.isEmpty(result)){ + return; + } + analys.addAll(result); + }); + // 设备遍历 + devices.forEach(item->{ + item.setRideCount(1); + item.setInstalledCapacity(0.0); + List signages = analys.stream().filter(o-> item.getEmCode().equals(o.getDeviceCode()) && !StringUtil.isEmpty(o.getSignage()) && !StringUtil.isEmpty(o.getRealId())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(signages)){ + // list -> map + item.setPoint(signages.stream().collect(Collectors.toMap(AnalyzeCodeBySignagesVO::getSignage,AnalyzeCodeBySignagesVO::getRealId))); + } + // 寻找设备配置参数 + List itemParamList = paramList.stream().filter(o->item.getId().equals(o.getInfoId())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(itemParamList)){ + // 遍历设备配置参数 + for(EmParamEntity param : itemParamList){ + String param_name = param.getParamName(); + switch (param_name){ + case "ct": + item.setCt(Integer.valueOf(param.getParamValue())); + break; + case "pt": + item.setPt(Integer.valueOf(param.getParamValue())); + break; + case "installedCapacity": + item.setInstalledCapacity(Double.valueOf(param.getParamValue())); + break; + default: + break; + } + } + // 设置ct * pt + if(null != item.getCt() && null != item.getPt()){ + item.setRideCount(item.getCt() * item.getPt()); + } + } + }); + // 设置缓存 + redisTemplate.opsForValue().set(device_cache_cofig_final, JSONObject.toJSONString(devices.stream().filter(o-> Math.abs(o.getInstalledCapacity()) > 0 || MapUtils.isNotEmpty(o.getPoint())).collect(Collectors.toList()))); + } + + /** * 加载水电站机组实时数据 * @param param @@ -297,15 +367,6 @@ public class RealTargetServiceImpl implements RealTargetService { } List list = new ArrayList<>(); modelList.forEach(item -> { - List multiAnalyzeCodePOList = new ArrayList<>(); - MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); - multiAnalyzeCodePO.setDeviceCode(item.getInstanceCode()); - multiAnalyzeCodePO.setSignages(Collections.singletonList(HomePageConstant.FRONT_WATER_LEVEL)); - multiAnalyzeCodePOList.add(multiAnalyzeCodePO); - R> result = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); - if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ - return; - } WaterLevelVo waterLevelVo = new WaterLevelVo(); waterLevelVo.setStationCode(item.getStationId()); // 前水位 @@ -540,7 +601,7 @@ public class RealTargetServiceImpl implements RealTargetService { private float getUsrPowerDay(EminfoAndEmParamVo device) { String time = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); // 当日用电量 - return analyseDataService.periodTargetFloat(time + " 00:00:00",time + " 23:59:59",5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); + return dataService.periodTargetFloat(time + " 00:00:00",time + " 23:59:59",5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); } @@ -553,7 +614,7 @@ public class RealTargetServiceImpl implements RealTargetService { String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); // 当月用电量 - return analyseDataService.periodTargetFloat(start,end,5,5,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); + return dataService.periodTargetFloat(start,end,5,5,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); } /** @@ -569,7 +630,7 @@ public class RealTargetServiceImpl implements RealTargetService { calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); // 当年用电量 - return analyseDataService.periodTargetFloat(start,end,5,6,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); + return dataService.periodTargetFloat(start,end,5,6,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); } /** @@ -580,7 +641,7 @@ public class RealTargetServiceImpl implements RealTargetService { public List getActivePowerVoList(EminfoAndEmParamVo device) { String startTime = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"); String endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); - List datas = analyseDataService.periodTargetData(startTime,endTime,2,6,device.getEmCode(),HomePageConstant.ACTIVE_POWER); + List datas = dataService.periodTargetData(startTime,endTime,2,6,device.getEmCode(),HomePageConstant.ACTIVE_POWER); if(CollectionUtil.isEmpty(datas)){ return new ArrayList<>(); } @@ -607,7 +668,7 @@ public class RealTargetServiceImpl implements RealTargetService { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH,-29); String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); - List records = analyseDataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION); + List records = dataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION); if(CollectionUtil.isEmpty(records)){ return new ArrayList<>(); } @@ -637,7 +698,7 @@ 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"; // 查询数据 - List records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION); + List records = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION); if(CollectionUtil.isEmpty(records)){ return new HashMap<>(); } @@ -843,12 +904,12 @@ public class RealTargetServiceImpl implements RealTargetService { List signages = Collections.singletonList(signage); realData.setSignages(signages); // 调用fegin接口查询实时数据 - R> R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData); - if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ + List fields = dataService.getRealDataByAnalyzeCode(instanceCode,signages); + if(CollectionUtil.isEmpty(fields)){ return 0.0; } // 时间限制 - String time = R.getData().get(0).getTime(); + String time = fields.get(0).getTime(); if(StringUtil.isEmpty(time) || "-".equals(time)){ return 0.0; } @@ -856,7 +917,7 @@ public class RealTargetServiceImpl implements RealTargetService { if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ return 0.0; } - return Double.parseDouble(R.getData().get(0).getValue()); + return Double.parseDouble(fields.get(0).getValue()); } /** @@ -869,7 +930,7 @@ public class RealTargetServiceImpl implements RealTargetService { String beginTime = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; String endTime = DateUtil.format(new Date(), DateUtil.PATTERN_DATE); AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); - List datas = analyseDataService.periodTargetData(beginTime, endTime,2, 6,instanceCode,signage); + List datas = dataService.periodTargetData(beginTime, endTime,2, 6,instanceCode,signage); if(CollectionUtil.isEmpty(datas)){ return new HashMap<>(); } @@ -1027,7 +1088,7 @@ public class RealTargetServiceImpl implements RealTargetService { private List getLoadsByDay(EminfoAndEmParamVo device) { String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); - List records = analyseDataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); + List records = dataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); if (CollectionUtil.isEmpty(records)) { return new ArrayList<>(); } @@ -1052,7 +1113,7 @@ public class RealTargetServiceImpl implements RealTargetService { // 设备采集发电量 if(CollectionUtil.isNotEmpty(devices)){ devices.forEach(device->{ - List records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + List records = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); if(CollectionUtil.isEmpty(records)){ return; } @@ -1260,7 +1321,7 @@ public class RealTargetServiceImpl implements RealTargetService { default: throw new ServiceException("无效查询类型!"); } - return analyseDataService.periodTargetFloat(start, end, 5, cycleType, deviceCode, rideCount, HomePageConstant.PV_GENERATION_CAPACITY); + return dataService.periodTargetFloat(start, end, 5, cycleType, deviceCode, rideCount, HomePageConstant.PV_GENERATION_CAPACITY); } /** @@ -1272,7 +1333,7 @@ public class RealTargetServiceImpl implements RealTargetService { private List photovoltaicLoadsByDay(EminfoAndEmParamVo device) { String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); - List records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD); + List records = dataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD); if (CollectionUtil.isEmpty(records)) { return new ArrayList<>(); } @@ -1299,7 +1360,7 @@ public class RealTargetServiceImpl implements RealTargetService { 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 records = analyseDataService.periodTargetData(start, end, 5, 3, device.getEmCode(), HomePageConstant.PV_GENERATION_CAPACITY); + List records = dataService.periodTargetData(start, end, 5, 3, device.getEmCode(), HomePageConstant.PV_GENERATION_CAPACITY); if (CollectionUtil.isEmpty(records)) { return new ArrayList<>(); } @@ -1350,6 +1411,13 @@ public class RealTargetServiceImpl implements RealTargetService { } /** + * 计算切分次数 + */ + private static Integer countStep(Integer size) { + return (size + 3 - 1) / 3; + } + + /** * 泵站设备 * @param stations * @return @@ -1358,11 +1426,7 @@ public class RealTargetServiceImpl implements RealTargetService { if(CollectionUtil.isEmpty(stations)){ return new ArrayList<>(); } - List devices = null; - Object json = redisTemplate.opsForValue().get(device_cache_cofig_final); - if (ObjectUtil.isNotEmpty(json)) { - devices = JSONObject.parseObject(json.toString(),new TypeReference>() {}); - } + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(),new TypeReference>() {}); if(CollectionUtil.isEmpty(devices)){ return new ArrayList<>(); } @@ -1484,7 +1548,7 @@ public class RealTargetServiceImpl implements RealTargetService { default: throw new IllegalStateException("Unexpected value: " + scope); } - return analyseDataService.periodTargetFloat(start,end,5,accessRules,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + return dataService.periodTargetFloat(start,end,5,accessRules,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); } /** @@ -1495,7 +1559,7 @@ public class RealTargetServiceImpl implements RealTargetService { private List getGenerationPowerList(EminfoAndEmParamVo device) { String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); - List records = analyseDataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + List records = dataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); if(CollectionUtil.isEmpty(records)){ return new ArrayList<>(); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java index 52a9617..9d2f707 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java @@ -81,7 +81,7 @@ public class ShowServiceImpl implements ShowService { private final OverDetailsService detailsService; private final WorkTicketService workTicketService; private final PhenomenonService phenomenonService; - private final AnalyseDataService analyseDataService; + private final DataService dataService; private final MaintenanceService maintenanceService; private final RedisTemplate redisTemplate; private final ISysClient sysClient; @@ -100,7 +100,7 @@ public class ShowServiceImpl implements ShowService { @Value("${hzims.equipment.emInfo.emInfoList}") public String device_cache_cofig_final; - @Value("${hzims.operation.region.areaDutyInfoKey}") + @Value("${hzims.operation.region.areaDutyInfoKey}") private String area_duty_cache_final; @Value("${hzims.operation.region.deviceClassifyKey}") @@ -1138,7 +1138,7 @@ public class ShowServiceImpl implements ShowService { return generate; } for(EminfoAndEmParamVo device : devices ){ - generate += analyseDataService.periodTargetFloat(DateUtil.format(start,DateUtil.PATTERN_DATETIME),DateUtil.format(end,DateUtil.PATTERN_DATETIME),5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + generate += dataService.periodTargetFloat(DateUtil.format(start,DateUtil.PATTERN_DATETIME),DateUtil.format(end,DateUtil.PATTERN_DATETIME),5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); } return generate; } diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceMapper.xml new file mode 100644 index 0000000..ccb91d3 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceMapper.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceParamMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceParamMapper.xml new file mode 100644 index 0000000..92ab12c --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceParamMapper.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/hzims-service/inspect/pom.xml b/hzims-service/inspect/pom.xml index f3610b8..dd981a8 100644 --- a/hzims-service/inspect/pom.xml +++ b/hzims-service/inspect/pom.xml @@ -137,11 +137,6 @@ 6.0.7 - org.springblade - blade-starter-oss-minio - 2.7.3.RELEASE - - com.hnac.hzims message-api ${hzims.project.version} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/scheduled/StAlamRecordTask.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/scheduled/StAlamRecordTask.java index 06a5712..1355aa1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/scheduled/StAlamRecordTask.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/scheduled/StAlamRecordTask.java @@ -53,10 +53,9 @@ public class StAlamRecordTask { * realId获取 * @return ReturnT */ - //@XxlJob(REAL_ID_DATA) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT realIdData() throws Exception { - String param = ""; + @XxlJob(REAL_ID_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT realIdData(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -68,10 +67,9 @@ public class StAlamRecordTask { * 站点实时数据 * @return ReturnT */ - //@XxlJob(REAL_TIME_DATA) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT realTimeData() throws Exception { - String param = ""; + @XxlJob(REAL_TIME_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT realTimeData(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java index b66f01f..f7c04b5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java @@ -280,9 +280,10 @@ public class ScheduledCreateTask { * 水电站-机组实时加载 * @return ReturnT */ - @XxlJob(LOAD_HYDROPOWER_UNIT_REAL) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadHydropowerUnitReal(String param) throws Exception { + //@XxlJob(LOAD_HYDROPOWER_UNIT_REAL) + @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadHydropowerUnitReal() throws Exception { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); }