记得上下班打卡 | git大法好,push需谨慎

Commit 4f43d8cc authored by 胡佳晨's avatar 胡佳晨

定时任务 接口调用成功

待测 job传参调用
parent 1a588188
...@@ -21,5 +21,5 @@ public interface FeignPlatformTaskClient { ...@@ -21,5 +21,5 @@ public interface FeignPlatformTaskClient {
ResponseDto<String> checkPerformanceTime(); ResponseDto<String> checkPerformanceTime();
@PostMapping("platform/performance/checkTransferOrder") @PostMapping("platform/performance/checkTransferOrder")
ResponseDto<Boolean> checkTransferOrder(); ResponseDto<Boolean> checkTransferOrder(Integer minute);
} }
...@@ -8,6 +8,7 @@ import org.slf4j.Logger; ...@@ -8,6 +8,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
/** /**
* XxlJob开发示例(Bean模式) * XxlJob开发示例(Bean模式)
...@@ -47,9 +48,9 @@ public class KylinTaskHandler { ...@@ -47,9 +48,9 @@ public class KylinTaskHandler {
} }
@XxlJob(value = "sev-platform:checkTransferOrderHandler") @XxlJob(value = "sev-platform:checkTransferOrderHandler")
public ReturnT<String> checkTransferOrderHandler() { public ReturnT<String> checkTransferOrderHandler(@RequestParam Integer minute) {
try { try {
boolean result = feignPlatformTaskClient.checkTransferOrder().getData(); boolean result = feignPlatformTaskClient.checkTransferOrder(minute).getData();
log.info("checkTransferOrderHandler:结果:"+result); log.info("checkTransferOrderHandler:结果:"+result);
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
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;
/** /**
...@@ -39,7 +40,7 @@ public class KylinOrderTicketsController { ...@@ -39,7 +40,7 @@ public class KylinOrderTicketsController {
@PostMapping("checkTransferOrder") @PostMapping("checkTransferOrder")
@ApiOperation("转赠订单失效脚本") @ApiOperation("转赠订单失效脚本")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<Boolean> checkTransferOrder() { public ResponseDto<Boolean> checkTransferOrder(@RequestParam Integer minute) {
return ResponseDto.success(kylinCheckOrderTime.checkTransferOrder()); return ResponseDto.success(kylinCheckOrderTime.checkTransferOrder(minute));
} }
} }
...@@ -146,16 +146,20 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K ...@@ -146,16 +146,20 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
return true; return true;
} }
public boolean checkTransferOrder() { public boolean checkTransferOrder(Integer minute) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
List<KylinOrderTask> task = orderTaskMapper.selectList( List<KylinOrderTask> task = orderTaskMapper.selectList(
Wrappers.lambdaQuery(KylinOrderTask.class).eq(KylinOrderTask::getStatus, 10).ge(KylinOrderTask::getCreatedAt,now.plusHours(2)) Wrappers.lambdaQuery(KylinOrderTask.class).eq(KylinOrderTask::getStatus, 10).last("and NOW() > DATE_SUB(created_at,INTERVAL -("+minute+") MINUTE)")
); );
ArrayList<String> orderIdList = CollectionUtil.arrayListString(); ArrayList<String> orderIdList = CollectionUtil.arrayListString();
for (KylinOrderTask item : task) { for (KylinOrderTask item : task) {
orderIdList.add(item.getOrderId()); orderIdList.add(item.getOrderId());
} }
if (orderIdList.size() == 0) {
return true;
}
//处理原订单mongo //处理原订单mongo
HashMap<String, Object> mapMongo = new HashMap<>(); HashMap<String, Object> mapMongo = new HashMap<>();
mapMongo.put("transferStatus", 0); mapMongo.put("transferStatus", 0);
...@@ -176,7 +180,7 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K ...@@ -176,7 +180,7 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
orderTicketRelations.setUpdatedAt(now); orderTicketRelations.setUpdatedAt(now);
orderTicketRelationsMapper.update(orderTicketRelations, new UpdateWrapper<KylinOrderTicketRelations>().in("order_id", orderIdList)); orderTicketRelationsMapper.update(orderTicketRelations, new UpdateWrapper<KylinOrderTicketRelations>().in("order_id", orderIdList));
//mysql 删除持久化数据 //mysql 删除持久化数据
orderTaskMapper.delete(Wrappers.lambdaQuery(KylinOrderTask.class).eq(KylinOrderTask::getStatus, 10).ge(KylinOrderTask::getCreatedAt,now.plusHours(2))); orderTaskMapper.delete(Wrappers.lambdaQuery(KylinOrderTask.class).eq(KylinOrderTask::getStatus, 10).ge(KylinOrderTask::getCreatedAt, now.plusHours(2)));
//处理原订单redis //处理原订单redis
int forSize = 500; int forSize = 500;
int forCount = orderIdList.size() % forSize == 0 ? orderIdList.size() / forSize : (orderIdList.size() / forSize) + 1; int forCount = orderIdList.size() % forSize == 0 ? orderIdList.size() / forSize : (orderIdList.size() / forSize) + 1;
......
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