diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index 0b4e8ce..bd44327 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -5,20 +5,22 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.context.ConfigurableApplicationContext; 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.UnknownHostException; /** * 启动程序 - * + * * @author ruoyi */ -@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) -public class RuoYiApplication -{ - public static void main(String[] args) - { +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +@EnableScheduling +@EnableAsync +public class RuoYiApplication { + public static void main(String[] args) { // System.setProperty("spring.devtools.restart.enabled", "false"); ConfigurableApplicationContext run = SpringApplication.run(RuoYiApplication.class, args); Environment env = run.getEnvironment(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/pt/controller/RemoteCallsController.java b/ruoyi-admin/src/main/java/com/ruoyi/pt/controller/RemoteCallsController.java index f8d4ec2..bf7fba3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/pt/controller/RemoteCallsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/pt/controller/RemoteCallsController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; @@ -85,14 +86,16 @@ public class RemoteCallsController extends BaseController { @ApiOperation(value = "更新算法数据并推送") @GetMapping("/pushDate") - public AjaxResult pushData() { + public AjaxResult pushData(@RequestParam("type") Integer type) { // 获取社会治理中心增量事件保存到events_import表 remoteCallsService.getEventDate(); // 获取昨天的数据 LocalDate localDate = LocalDate.now(); - LocalDate yesterday = localDate.minusDays(1); + if (type == 0){ + localDate = localDate.minusDays(1); + } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - String yesterdayStr = yesterday.format(formatter); + String yesterdayStr = localDate.format(formatter); // 紧急事件接口 remoteCallsService.urgentAlgorithm(yesterdayStr); // 群体事件接口 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/pt/entity/CasesImport.java b/ruoyi-admin/src/main/java/com/ruoyi/pt/entity/CasesImport.java index 3153702..880c121 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/pt/entity/CasesImport.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/pt/entity/CasesImport.java @@ -52,6 +52,10 @@ public class CasesImport implements Serializable { @Alias("eventExt") private String eventExt; + @TableField(value = "scenceName") + @Alias("scenceName") + private String scenceName; + /** * 案件类型 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/pt/quartz/PushQuartz.java b/ruoyi-admin/src/main/java/com/ruoyi/pt/quartz/PushQuartz.java index 295bf6c..77312df 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/pt/quartz/PushQuartz.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/pt/quartz/PushQuartz.java @@ -3,9 +3,10 @@ package com.ruoyi.pt.quartz; import com.ruoyi.pt.service.RemoteCallsService; import org.slf4j.Logger; 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.Scheduled; +import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.time.LocalDate; @@ -18,15 +19,16 @@ import java.time.format.DateTimeFormatter; * @author wu * @since 2023/12/26 16:19 */ -@Configuration +@Component @EnableScheduling +@Async public class PushQuartz { public static final Logger log = LoggerFactory.getLogger(PushQuartz.class); @Resource private RemoteCallsService remoteCallsService; - @Scheduled(cron = "0 0 1 * * ? ") + @Scheduled(cron = "0 0 1 * * ?") public synchronized void pushData() { log.info("==============开始定时任务" + LocalDateTime.now() + "============"); // 获取社会治理中心增量事件保存到events_import表 @@ -46,7 +48,7 @@ public class PushQuartz { log.info("==============推送同人事件接口" + LocalDateTime.now() + "============"); remoteCallsService.onepersonAlgorithm(); // 推送 -// log.info("==============推送到预警平台接口" + LocalDateTime.now() + "============"); -// remoteCallsService.imports(null); + log.info("==============推送到预警平台接口" + LocalDateTime.now() + "============"); + remoteCallsService.imports(null); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/RemoteCallsServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/RemoteCallsServiceImpl.java index 9f2828f..0060ea7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/RemoteCallsServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/RemoteCallsServiceImpl.java @@ -111,7 +111,7 @@ public class RemoteCallsServiceImpl implements RemoteCallsService { queryWrapper.isNotNull("innerEventId") .and(wrapper -> wrapper.ne("innerEventId", "")) .and(wrapper -> wrapper - .nested(i -> i.eq("scenceType", "3").gt("urgentPercent", 0.994)) + .nested(i -> i.eq("scenceType", "3").gt("urgentPercent", 0.9)) .or() .ne("scenceType", "3") ); @@ -122,6 +122,7 @@ public class RemoteCallsServiceImpl implements RemoteCallsService { IPage dataPage = eventsService.page(page, queryWrapper); List data = dataPage.getRecords(); List dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class); + log.info("==========推送数据条数=========> " + dtos.size()); dtos.forEach(x -> { x.setContent(x.getTitle()); // 使用SimpleDateFormat对象将Date对象格式化为字符串 @@ -171,6 +172,7 @@ public class RemoteCallsServiceImpl implements RemoteCallsService { IPage dataPage = eventsCopyService.page(page, queryWrapper); List data = dataPage.getRecords(); List dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class); + log.info("==========推送数据条数=========> " + dtos.size()); dtos.forEach(x -> { x.setContent(x.getTitle()); // 使用SimpleDateFormat对象将Date对象格式化为字符串 diff --git a/ruoyi-admin/src/main/resources/application-test.yml b/ruoyi-admin/src/main/resources/application-test.yml index 172a950..342a477 100644 --- a/ruoyi-admin/src/main/resources/application-test.yml +++ b/ruoyi-admin/src/main/resources/application-test.yml @@ -6,7 +6,7 @@ spring: druid: # 主库数据源 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 password: Admin123@ # 从库数据源