修改定时任务

master
吴顺杰 1 year ago
parent 2075881c93
commit 4a8f144421

@ -5,6 +5,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -14,11 +16,11 @@ import java.net.UnknownHostException;
* *
* @author ruoyi * @author ruoyi
*/ */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class RuoYiApplication @EnableScheduling
{ @EnableAsync
public static void main(String[] args) public class RuoYiApplication {
{ public static void main(String[] args) {
// System.setProperty("spring.devtools.restart.enabled", "false"); // System.setProperty("spring.devtools.restart.enabled", "false");
ConfigurableApplicationContext run = SpringApplication.run(RuoYiApplication.class, args); ConfigurableApplicationContext run = SpringApplication.run(RuoYiApplication.class, args);
Environment env = run.getEnvironment(); Environment env = run.getEnvironment();

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -85,14 +86,16 @@ public class RemoteCallsController extends BaseController {
@ApiOperation(value = "更新算法数据并推送") @ApiOperation(value = "更新算法数据并推送")
@GetMapping("/pushDate") @GetMapping("/pushDate")
public AjaxResult pushData() { public AjaxResult pushData(@RequestParam("type") Integer type) {
// 获取社会治理中心增量事件保存到events_import表 // 获取社会治理中心增量事件保存到events_import表
remoteCallsService.getEventDate(); remoteCallsService.getEventDate();
// 获取昨天的数据 // 获取昨天的数据
LocalDate localDate = LocalDate.now(); LocalDate localDate = LocalDate.now();
LocalDate yesterday = localDate.minusDays(1); if (type == 0){
localDate = localDate.minusDays(1);
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String yesterdayStr = yesterday.format(formatter); String yesterdayStr = localDate.format(formatter);
// 紧急事件接口 // 紧急事件接口
remoteCallsService.urgentAlgorithm(yesterdayStr); remoteCallsService.urgentAlgorithm(yesterdayStr);
// 群体事件接口 // 群体事件接口

@ -52,6 +52,10 @@ public class CasesImport implements Serializable {
@Alias("eventExt") @Alias("eventExt")
private String eventExt; private String eventExt;
@TableField(value = "scenceName")
@Alias("scenceName")
private String scenceName;
/** /**
* *
*/ */

@ -3,9 +3,10 @@ package com.ruoyi.pt.quartz;
import com.ruoyi.pt.service.RemoteCallsService; import com.ruoyi.pt.service.RemoteCallsService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDate; import java.time.LocalDate;
@ -18,15 +19,16 @@ import java.time.format.DateTimeFormatter;
* @author wu * @author wu
* @since 2023/12/26 16:19 * @since 2023/12/26 16:19
*/ */
@Configuration @Component
@EnableScheduling @EnableScheduling
@Async
public class PushQuartz { public class PushQuartz {
public static final Logger log = LoggerFactory.getLogger(PushQuartz.class); public static final Logger log = LoggerFactory.getLogger(PushQuartz.class);
@Resource @Resource
private RemoteCallsService remoteCallsService; private RemoteCallsService remoteCallsService;
@Scheduled(cron = "0 0 1 * * ? ") @Scheduled(cron = "0 0 1 * * ?")
public synchronized void pushData() { public synchronized void pushData() {
log.info("==============开始定时任务" + LocalDateTime.now() + "============"); log.info("==============开始定时任务" + LocalDateTime.now() + "============");
// 获取社会治理中心增量事件保存到events_import表 // 获取社会治理中心增量事件保存到events_import表
@ -46,7 +48,7 @@ public class PushQuartz {
log.info("==============推送同人事件接口" + LocalDateTime.now() + "============"); log.info("==============推送同人事件接口" + LocalDateTime.now() + "============");
remoteCallsService.onepersonAlgorithm(); remoteCallsService.onepersonAlgorithm();
// 推送 // 推送
// log.info("==============推送到预警平台接口" + LocalDateTime.now() + "============"); log.info("==============推送到预警平台接口" + LocalDateTime.now() + "============");
// remoteCallsService.imports(null); remoteCallsService.imports(null);
} }
} }

@ -111,7 +111,7 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
queryWrapper.isNotNull("innerEventId") queryWrapper.isNotNull("innerEventId")
.and(wrapper -> wrapper.ne("innerEventId", "")) .and(wrapper -> wrapper.ne("innerEventId", ""))
.and(wrapper -> wrapper .and(wrapper -> wrapper
.nested(i -> i.eq("scenceType", "3").gt("urgentPercent", 0.994)) .nested(i -> i.eq("scenceType", "3").gt("urgentPercent", 0.9))
.or() .or()
.ne("scenceType", "3") .ne("scenceType", "3")
); );
@ -122,6 +122,7 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
IPage<Events> dataPage = eventsService.page(page, queryWrapper); IPage<Events> dataPage = eventsService.page(page, queryWrapper);
List<Events> data = dataPage.getRecords(); List<Events> data = dataPage.getRecords();
List<RemoteCallsDTO> dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class); List<RemoteCallsDTO> dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class);
log.info("==========推送数据条数=========> " + dtos.size());
dtos.forEach(x -> { dtos.forEach(x -> {
x.setContent(x.getTitle()); x.setContent(x.getTitle());
// 使用SimpleDateFormat对象将Date对象格式化为字符串 // 使用SimpleDateFormat对象将Date对象格式化为字符串
@ -171,6 +172,7 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
IPage<EventsCopy> dataPage = eventsCopyService.page(page, queryWrapper); IPage<EventsCopy> dataPage = eventsCopyService.page(page, queryWrapper);
List<EventsCopy> data = dataPage.getRecords(); List<EventsCopy> data = dataPage.getRecords();
List<RemoteCallsDTO> dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class); List<RemoteCallsDTO> dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class);
log.info("==========推送数据条数=========> " + dtos.size());
dtos.forEach(x -> { dtos.forEach(x -> {
x.setContent(x.getTitle()); x.setContent(x.getTitle());
// 使用SimpleDateFormat对象将Date对象格式化为字符串 // 使用SimpleDateFormat对象将Date对象格式化为字符串

@ -6,7 +6,7 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://localhost:3307/public_platform?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://39.101.188.84:3307/public_platform?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: Admin123@ password: Admin123@
# 从库数据源 # 从库数据源

Loading…
Cancel
Save