Commit 76ec7b63 authored by zhangzhenbang's avatar zhangzhenbang

定时30s审批通过

parent 6f1a92e0
package com.yingxin.beijingvehicleflow.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* 异步相关定义
*
* @author zhangzhenbang
* @version 1.0
* @date 2020/1/8
*/
@Configuration
public class AsyncConfig implements AsyncConfigurer {
@Value("${async-Config.MAX-POOL-SIZE}")
private int maxPoolSize;
@Value("${async-Config.CORE-POOL-SIZE}")
private int corePoolSize;
@Bean("asyncTaskExecutor")
public AsyncTaskExecutor asyncTaskExecutor() {
ThreadPoolTaskExecutor asyncTaskExecutor = new ThreadPoolTaskExecutor();
asyncTaskExecutor.setMaxPoolSize(maxPoolSize);
asyncTaskExecutor.setCorePoolSize(corePoolSize);
asyncTaskExecutor.setThreadNamePrefix("async-task-thread-pool-");
asyncTaskExecutor.initialize();
return asyncTaskExecutor;
}
}
...@@ -19,7 +19,7 @@ import java.util.Date; ...@@ -19,7 +19,7 @@ import java.util.Date;
*/ */
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/api/v1") @RequestMapping("/bjapi/v1")
public class FloatingPopulationController { public class FloatingPopulationController {
@Autowired @Autowired
......
...@@ -33,7 +33,7 @@ import java.util.List; ...@@ -33,7 +33,7 @@ import java.util.List;
*/ */
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/api/v1") @RequestMapping("/bjapi/v1")
public class IdentityInfoController { public class IdentityInfoController {
private static Logger LOGGER = LoggerFactory.getLogger(IdentityInfoController.class); private static Logger LOGGER = LoggerFactory.getLogger(IdentityInfoController.class);
......
...@@ -21,7 +21,7 @@ import java.util.List; ...@@ -21,7 +21,7 @@ import java.util.List;
*/ */
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/api/v1") @RequestMapping("/bjapi/v1")
public class ReservationController { public class ReservationController {
private static Logger LOGGER = LoggerFactory.getLogger(ReservationController.class); private static Logger LOGGER = LoggerFactory.getLogger(ReservationController.class);
......
...@@ -42,4 +42,8 @@ public interface ReservationMapper { ...@@ -42,4 +42,8 @@ public interface ReservationMapper {
@Select("select * from reservation where verify_state=0 and identity_id=#{id}") @Select("select * from reservation where verify_state=0 and identity_id=#{id}")
List<Reservation> selectNotVerifyReservatinsByIdentityId(IdentityInformation info); List<Reservation> selectNotVerifyReservatinsByIdentityId(IdentityInformation info);
@Update("update reservation set verify_state=1")
int updateAllVerifyState();
} }
...@@ -23,4 +23,6 @@ public interface ReservationService { ...@@ -23,4 +23,6 @@ public interface ReservationService {
boolean isUpdateAuthInfoSucc(Reservation reservation); boolean isUpdateAuthInfoSucc(Reservation reservation);
List<Reservation> selectNotVerifyReservatinsByIdentityId(IdentityInformation info); List<Reservation> selectNotVerifyReservatinsByIdentityId(IdentityInformation info);
int updateAllVerifyState();
} }
package com.yingxin.beijingvehicleflow.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 月初更新信息修改次数
*
* @author 226
* @version 1.0
* @date 2020/2/19
*/
@Component
@EnableScheduling
@EnableAsync
public class ScheduleTask {
private static Logger LOGGER = LoggerFactory.getLogger(ScheduleTask.class);
@Autowired
private ReservationService reservationService;
/**
* 定时任务
*
* 表达式有六位,秒、分、时、日、月、星期
* 下面表示每个月的一号执行定时任务
*
* @date 2020/2/19
*/
@Async("asyncTaskExecutor")
@Scheduled(cron = "*/30 * * * * ?")
public void tasks() {
try {
reservationService.updateAllVerifyState();
} catch (Exception e) {
LOGGER.error("异步认证次数发放异常:", e);
}
}
}
\ No newline at end of file
...@@ -83,4 +83,9 @@ public class ReservationServiceImpl implements ReservationService { ...@@ -83,4 +83,9 @@ public class ReservationServiceImpl implements ReservationService {
public List<Reservation> selectNotVerifyReservatinsByIdentityId(IdentityInformation info) { public List<Reservation> selectNotVerifyReservatinsByIdentityId(IdentityInformation info) {
return reservationMapper.selectNotVerifyReservatinsByIdentityId(info); return reservationMapper.selectNotVerifyReservatinsByIdentityId(info);
} }
@Override
public int updateAllVerifyState() {
return reservationMapper.updateAllVerifyState();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment