13 changed files with 332 additions and 46 deletions
@ -0,0 +1,41 @@ |
|||||
|
package com.zdxt.enforcementcode.quartz.job; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.service.IEfcodeCpReserveService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 预约超期自动取消 - 定时任务 |
||||
|
* <p>定期扫描待确认状态的预约记录,超过配置天数未处理的自动设置为超期取消</p> |
||||
|
* |
||||
|
* @author zrb |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
@RequiredArgsConstructor |
||||
|
public class CpReserveOverdueCancelJob { |
||||
|
|
||||
|
private final IEfcodeCpReserveService cpReserveService; |
||||
|
|
||||
|
/** |
||||
|
* 任务执行入口(public,供 JobInvokeUtil 通过反射调用) |
||||
|
* <p>按配置的超期天数取消手动预约和系统匹配中超期未处理的待确认记录</p> |
||||
|
*/ |
||||
|
public void execute() { |
||||
|
log.info("[CpReserveOverdueCancelJob] 定时任务触发:预约超期自动取消"); |
||||
|
int manualCount = cpReserveService.cancelOverdueManualReserves(false); |
||||
|
int systemCount = cpReserveService.cancelOverdueSystemReserves(false); |
||||
|
log.info("[CpReserveOverdueCancelJob] 执行完成:手动预约取消{}条,系统匹配取消{}条", manualCount, systemCount); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 强制取消入口(忽略时间限制,将所有待处理记录全部取消) |
||||
|
*/ |
||||
|
public void executeForce() { |
||||
|
log.info("[CpReserveOverdueCancelJob] 强制触发:预约全部取消"); |
||||
|
int manualCount = cpReserveService.cancelOverdueManualReserves(true); |
||||
|
int systemCount = cpReserveService.cancelOverdueSystemReserves(true); |
||||
|
log.info("[CpReserveOverdueCancelJob] 强制执行完成:手动预约取消{}条,系统匹配取消{}条", manualCount, systemCount); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,56 @@ |
|||||
|
package com.zdxt.rest.test.cp; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.service.IEfcodeCpReserveService; |
||||
|
import org.dromara.ZdxtAdminApplication; |
||||
|
import org.junit.jupiter.api.*; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.springframework.test.context.ActiveProfiles; |
||||
|
|
||||
|
/** |
||||
|
* 预约超期取消测试 |
||||
|
* <p> |
||||
|
* 调用 ignoreTime=true 模式,将所有待处理的手动预约和系统匹配记录全部设置为超期取消(opStatus=4)。 |
||||
|
* </p> |
||||
|
*/ |
||||
|
@SpringBootTest(classes = ZdxtAdminApplication.class) |
||||
|
@ActiveProfiles({"dev", "dev-cust-zrb"}) |
||||
|
@DisplayName("预约超期取消测试") |
||||
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) |
||||
|
public class AppEnfCpReserveOverdueCancelTest { |
||||
|
|
||||
|
@Autowired |
||||
|
private IEfcodeCpReserveService cpReserveService; |
||||
|
|
||||
|
/** |
||||
|
* 忽略时间 - 手动预约全部取消 |
||||
|
* <p>将所有手动预约(resFrom=0)中待确认(opStatus=3)的记录全部设置为超期取消</p> |
||||
|
*/ |
||||
|
@DisplayName("忽略时间 - 手动预约全部取消") |
||||
|
@Test |
||||
|
@Order(1) |
||||
|
public void testCancelOverdueManual_ignoreTime() { |
||||
|
System.out.println("========== 开始执行手动预约超期取消(忽略时间) =========="); |
||||
|
|
||||
|
int cancelCount = cpReserveService.cancelOverdueManualReserves(true); |
||||
|
|
||||
|
System.out.println("手动预约取消记录数: " + cancelCount); |
||||
|
System.out.println("========== 手动预约超期取消完毕 =========="); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 忽略时间 - 系统匹配全部取消 |
||||
|
* <p>将所有系统匹配(resFrom=1)中待确认(opStatus=3)的记录全部设置为超期取消</p> |
||||
|
*/ |
||||
|
@DisplayName("忽略时间 - 系统匹配全部取消") |
||||
|
@Test |
||||
|
@Order(2) |
||||
|
public void testCancelOverdueSystem_ignoreTime() { |
||||
|
System.out.println("========== 开始执行系统匹配超期取消(忽略时间) =========="); |
||||
|
|
||||
|
int cancelCount = cpReserveService.cancelOverdueSystemReserves(true); |
||||
|
|
||||
|
System.out.println("系统匹配取消记录数: " + cancelCount); |
||||
|
System.out.println("========== 系统匹配超期取消完毕 =========="); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue