Browse Source

#定时任务抽离

zhongwei
yang_shj 1 year ago
parent
commit
089c487e1c
  1. 75
      hzims-service/hzims-scheduled/pom.xml
  2. 17
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java
  3. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  4. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java
  5. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RealTargetServiceImpl.java
  6. 19
      hzims-service/hzims-scheduled/src/main/resources/banner.txt
  7. 2
      hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/PlanMapper.xml

75
hzims-service/hzims-scheduled/pom.xml

@ -25,24 +25,11 @@
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-core-boot</artifactId> <artifactId>blade-core-boot</artifactId>
<exclusions>
<exclusion>
<groupId>org.springblade</groupId>
<artifactId>blade-core-cloud</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-core-cloud</artifactId> <artifactId>blade-core-cloud</artifactId>
<exclusions>
<exclusion>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-common</artifactId> <artifactId>blade-common</artifactId>
@ -52,11 +39,6 @@
<artifactId>blade-starter-swagger</artifactId> <artifactId>blade-starter-swagger</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<artifactId>hzims-operational-api</artifactId> <artifactId>hzims-operational-api</artifactId>
</dependency> </dependency>
@ -87,26 +69,48 @@
<artifactId>xxl-job-core</artifactId> <artifactId>xxl-job-core</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.24</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<artifactId>equipment-api</artifactId> <artifactId>equipment-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<artifactId>message-api</artifactId> <artifactId>message-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<artifactId>ticket-api</artifactId> <artifactId>ticket-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<artifactId>assets-api</artifactId> <artifactId>assets-api</artifactId>
</dependency> </dependency>
<!-- -->
<dependency> <dependency>
<groupId>com.google.zxing</groupId> <groupId>com.google.zxing</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
@ -124,6 +128,16 @@
<artifactId>commons-collections4</artifactId> <artifactId>commons-collections4</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-http</artifactId> <artifactId>hutool-http</artifactId>
</dependency> </dependency>
@ -132,6 +146,10 @@
<artifactId>hutool-core</artifactId> <artifactId>hutool-core</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-resource-api</artifactId> <artifactId>blade-resource-api</artifactId>
</dependency> </dependency>
@ -159,7 +177,16 @@
<groupId>com.hnac.hzinfo.data</groupId> <groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId> <artifactId>hzinfo-data-sdk</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>2.5.6</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

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

@ -1,30 +1,23 @@
package com.hnac.hzims.scheduled; package com.hnac.hzims.scheduled;
import com.hnac.hzims.operational.OperationalConstants;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springblade.core.cloud.feign.EnableBladeFeign; import org.springblade.core.cloud.feign.EnableBladeFeign;
import org.springblade.core.launch.BladeApplication; 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.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.SpringCloudApplication; import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import javax.annotation.Resource; import javax.annotation.Resource;
/** /**
* @Author dfy * @author ysj
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/19 9:05
*/ */
@EnableBladeFeign(basePackages = {"org.springblade","com.hnac"}) @EnableBladeFeign
@SpringCloudApplication @SpringCloudApplication
@MapperScan("com.hnac.hzims.scheduled.mapper.**.**") @MapperScan("com.hnac.hzims.**.mapper.**")
@EnableScheduling @ComponentScan(basePackages = {"com.hnac.*"})
@ComponentScan(basePackages = {"com.hnac.hzims.scheduled.*","org.springblade.core"})
@Resource @Resource
public class ScheduledApplication extends SpringBootServletInitializer { public class ScheduledApplication extends SpringBootServletInitializer {
public static void main(String[] args) { public static void main(String[] args) {

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

@ -34,6 +34,7 @@ public class RealTargetScheduledTask {
* @throws Exception * @throws Exception
*/ */
@XxlJob(LOAD_EM_INFO) @XxlJob(LOAD_EM_INFO)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadEmInfo(String param) { public ReturnT<String> loadEmInfo(String param) {
service.loadEmInfo(); service.loadEmInfo();
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");

1
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java

@ -20,7 +20,6 @@ import java.util.List;
@DS("equipment") @DS("equipment")
public class PlanServiceImpl extends BaseServiceImpl<PlanMapper, PlanGenerationEntity> implements PlanService { public class PlanServiceImpl extends BaseServiceImpl<PlanMapper, PlanGenerationEntity> implements PlanService {
/** /**
* 查询计划发电量 * 查询计划发电量
* @param stationIds * @param stationIds

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

@ -30,7 +30,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
@ -928,7 +927,7 @@ public class RealTargetServiceImpl implements RealTargetService {
*/ */
private Map<Integer, String> getWaterLevelMap(String instanceCode, String signage) { private Map<Integer, String> getWaterLevelMap(String instanceCode, String signage) {
String beginTime = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; String beginTime = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
String endTime = DateUtil.format(new Date(), DateUtil.PATTERN_DATE); String endTime = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyseDataTaosVO> datas = dataService.periodTargetData(beginTime, endTime,2, 6,instanceCode,signage); List<AnalyseDataTaosVO> datas = dataService.periodTargetData(beginTime, endTime,2, 6,instanceCode,signage);
if(CollectionUtil.isEmpty(datas)){ if(CollectionUtil.isEmpty(datas)){

19
hzims-service/hzims-scheduled/src/main/resources/banner.txt

@ -0,0 +1,19 @@
.::::.
.::::::::.
:::::::::::
':::::::::::..
:::::::::::::::'
':::::::::::.
.::::::::::::::'
.:::::::::::...
::::::::::::::''
.:::. '::::::::''::::
.::::::::. ':::::' '::::
.::::':::::::. ::::: '::::.
.:::::' ':::::::::. ::::: ':::.
.:::::' ':::::::::.::::: '::.
.::::'' ':::::::::::::: '::.
.::'' ':::::::::::: :::...
..:::: ':::::::::' .:' ''''
..''''':' ':::::.'

2
hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/PlanMapper.xml

@ -16,7 +16,7 @@
<result column="CREATE_DEPT" property="createDept" jdbcType="BIGINT"/> <result column="CREATE_DEPT" property="createDept" jdbcType="BIGINT"/>
</resultMap> </resultMap>
<select id="selectPlanGenerationByParam" resultType="com.hnac.hzims.equipment.entity.PlanGenerationEntity"> <select id="planGeneration" resultType="com.hnac.hzims.equipment.entity.PlanGenerationEntity">
select * from hz_ims_plan_generation select * from hz_ims_plan_generation
where IS_DELETED = 0 where IS_DELETED = 0
<if test="stationIds != null"> <if test="stationIds != null">

Loading…
Cancel
Save