| | |
| | | import com.taoke.autopay.utils.Constant; |
| | | import com.taoke.autopay.utils.StringUtil; |
| | | import com.taoke.autopay.utils.order.DYOrderApi; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | @Configuration |
| | | @EnableScheduling |
| | | public class KeyOrderDistributeTask { |
| | | |
| | | @Value("${task-enable}") |
| | | private boolean taskEnable; |
| | | |
| | | @Resource |
| | | private KeyOrderService keyOrderService; |
| | | |
| | | |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | private void distribute() { |
| | | if(!taskEnable){ |
| | | return; |
| | | } |
| | | try { |
| | | List<KeyOrder> results = keyOrderService.listNotDistributed(1, 20); |
| | | if (results != null) { |
| | |
| | | **/ |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | private void repaireProcessedOrders() { |
| | | if(!taskEnable){ |
| | | return; |
| | | } |
| | | // TODO 待完成 |
| | | KeyOrderMapper.DaoQuery query = new KeyOrderMapper.DaoQuery(); |
| | | // 修正1分钟到1小时的数据之前执行的数据 |
| | |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | private void processPayFail() { |
| | | if(!taskEnable){ |
| | | return; |
| | | } |
| | | for (int i = 0; i < 10; i++) { |
| | | // 一次最多处理10条数据 |
| | | orderPayFailProcessor.processFromQueue(); |
| | |
| | | |
| | | @Scheduled(cron = "0 0 3 * * ? ") |
| | | private void clearProcessPayFailCache() { |
| | | if(!taskEnable){ |
| | | return; |
| | | } |
| | | orderPayFailProcessor.clearCacheData(); |
| | | } |
| | | |
| | |
| | | // 处理设备下线 |
| | | @Scheduled(cron = "0 0/1 * * * ? ") |
| | | private void processPayClientOffLine() { |
| | | if(!taskEnable){ |
| | | return; |
| | | } |
| | | KeyOrderMapper.DaoQuery daoQuery = new KeyOrderMapper.DaoQuery(); |
| | | // 分配时间在最近5分钟到最近30分钟的,状态为未处理的需要重新分配 |
| | | daoQuery.stateList = Arrays.asList(new Integer[]{KeyOrder.STATE_NOT_PAY, KeyOrder.STATE_NOT_PROCESS}); |