Browse Source

修改定时任务的文件

zhongwei
段飞宇 2 years ago
parent
commit
ccdbae9ad7
  1. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java
  2. 118
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/config/XxlJobConfig.java
  3. 10
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HistoryAbnormalAlarmMapper.xml
  4. 26
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationMapper.xml
  5. 10
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ScheduledCreateTask.java
  6. 23
      hzims-service/hzims-scheduled/src/main/resources/application.yml
  7. 0
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AbnormalAlarmMapper.xml
  8. 0
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StAlarmRecordMapper.xml

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

@ -18,7 +18,7 @@ import javax.annotation.Resource;
@EnableBladeFeign @EnableBladeFeign
@SpringCloudApplication @SpringCloudApplication
@MapperScan("com.hnac.hzims.scheduled.**.mapper.**") @MapperScan("com.hnac.hzims.scheduled.**.mapper.**")
@ComponentScan(basePackages = {"com.hnac.*","org.springblade.core.*"}) @ComponentScan(basePackages = {"com.hnac.*","org.springblade.core"})
@Resource @Resource
public class ScheduledApplication { public class ScheduledApplication {
public static void main(String[] args) { public static void main(String[] args) {

118
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/config/XxlJobConfig.java

@ -1,59 +1,59 @@
package com.hnac.hzims.scheduled.config; // package com.hnac.hzims.scheduled.config;
//
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; // import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.extern.slf4j.Slf4j; // import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; // import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; // import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; // import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; // import org.springframework.context.annotation.Configuration;
//
/** // /**
* @Author WL // * @Author WL
* @Version v1.0 // * @Version v1.0
* @Serial 1.0 // * @Serial 1.0
* @Date 2022/1/8 10:23 // * @Date 2022/1/8 10:23
*/ // */
@Slf4j // @Slf4j
@Configuration // @Configuration
//指定任务Handler所在包路径 // //指定任务Handler所在包路径
public class XxlJobConfig { // public class XxlJobConfig {
//
//
@Value("${xxl.job.admin.addresses}") // @Value("${xxl.job.admin.addresses}")
private String adminAddresses; // private String adminAddresses;
//
@Value("${xxl.job.executor.appname}") // @Value("${xxl.job.executor.appname}")
private String appName; // private String appName;
//
@Value("${xxl.job.executor.ip}") // @Value("${xxl.job.executor.ip}")
private String ip; // private String ip;
//
@Value("${xxl.job.executor.port}") // @Value("${xxl.job.executor.port}")
private int port; // private int port;
//
@Value("${xxl.job.accessToken}") // @Value("${xxl.job.accessToken}")
private String accessToken; // private String accessToken;
//
@Value("${xxl.job.executor.logpath}") // @Value("${xxl.job.executor.logpath}")
private String logPath; // private String logPath;
//
@Value("${xxl.job.executor.logretentiondays}") // @Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays; // private int logRetentionDays;
//
//
@Bean(initMethod = "start", destroyMethod = "destroy") // @Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() { // public XxlJobSpringExecutor xxlJobExecutor() {
log.info("====xxl-job config init===="); // log.info("====xxl-job config init====");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); // XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses); // xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appName); // xxlJobSpringExecutor.setAppName(appName);
xxlJobSpringExecutor.setIp(ip); // xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port); // xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken); // xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath); // xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); // xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor; // return xxlJobSpringExecutor;
} // }
//
} // }
//

10
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HistoryAbnormalAlarmMapper.xml

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.HistoryAbnormalAlarmMapper">
<select id="getHistoryAbnormalAlarm" resultType="com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity">
select * from hzims_history_abnormal_alarm
where station_id = #{stationId}
and type = #{type}
and status = 0
</select>
</mapper>

26
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationMapper.xml

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.StationMapper">
<select id="selectStationByType" resultType="com.hnac.hzims.operational.station.entity.StationEntity">
select * from hzims_station where IS_DELETED = 0 and REF_DEPT IS NOT NULL and `TYPE` IS NOT NULL
<if test="serveType != null">
AND SERVE_TYPE = #{serveType}
</if>
<if test="stationType != null">
AND `TYPE` = #{stationType}
</if>
</select>
<select id="selectAll" resultType="com.hnac.hzims.operational.station.entity.StationEntity">
select * from hzims_station where IS_DELETED = 0 and REF_DEPT IS NOT NULL AND REF_DOMAIN IS NOT NULL AND `TYPE` IS NOT NULL
</select>
<select id="selectStationByInCode" resultType="com.hnac.hzims.operational.station.entity.StationEntity">
SELECT * FROM hzims_station WHERE IS_DELETED = 0 and `CODE` IN
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>

10
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ScheduledCreateTask.java

@ -31,7 +31,6 @@ public class ScheduledCreateTask {
* @return ReturnT<String> * @return ReturnT<String>
*/ */
@XxlJob(LOAD_WATER_LEVEL) @XxlJob(LOAD_WATER_LEVEL)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadWaterLevel(String param) throws Exception { public ReturnT<String> loadWaterLevel(String param) throws Exception {
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM"); param = DateUtil.format(new Date(), "yyyy-MM");
@ -42,5 +41,14 @@ public class ScheduledCreateTask {
/**
* 水利-站点水位数据
* @return ReturnT<String>
*/
@XxlJob("cheshi")
public ReturnT<String> cheshi(String param) throws Exception {
System.out.println("执行呢方法");
return new ReturnT<>("SUCCESS");
}
} }

23
hzims-service/hzims-scheduled/src/main/resources/application.yml

@ -36,23 +36,38 @@ spring:
# redis访问密码(默认为空) # redis访问密码(默认为空)
password: 1qaz2WSX@redis password: 1qaz2WSX@redis
#xxl:
# job:
# accessToken: ''
# admin:
# addresses: http://192.168.1.3:7009/xxl-job-admin
# executor:
# appname: hzims-operational
# ip: 192.168.1.3
# logpath: /data/applogs/xxl-job/jobhandler
# logretentiondays: -1
# port: 28501
xxl: xxl:
job: job:
accessToken: '' accessToken: ''
admin: admin:
addresses: http://192.168.1.3:7009/xxl-job-admin addresses: http://192.168.5.128:9080/xxl-job-admin
executor: executor:
appname: hzims-operational appname: hzims-operational
ip: 192.168.1.3 ip: 192.168.18.232
logpath: /data/applogs/xxl-job/jobhandler logpath: /data/applogs/xxl-job/jobhandler
logretentiondays: -1 logretentiondays: -1
port: 28501 port: 28501
#mybatis-plus配置 #mybatis-plus配置
mybatis-plus: mybatis-plus:
mapper-locations: classpath:com/hnac/hzims/**/mapper/*Mapper.xml mapper-locations: classpath*:/mapper/**/*.xml
#实体扫描,多个package用逗号或者分号分隔 #实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.hnac.hzims.**.entity # typeAliasesPackage: com.hnac.hzims.**.entity
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#swagger扫描路径配置 #swagger扫描路径配置
swagger: swagger:

0
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AbnormalAlarmMapper.xml → hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AbnormalAlarmMapper.xml

0
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StAlarmRecordMapper.xml → hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StAlarmRecordMapper.xml

Loading…
Cancel
Save