xuhy
2023-05-22 e93c5d64b16a7b3271e81937f1df1b37ff5919cc
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java
@@ -84,14 +84,23 @@
            for (TAppUser tAppUser : appUserList) {
                TOrder tOrder = orderService.selectOne(new EntityWrapper<TOrder>()
                        .eq("userId", tAppUser.getId())
                        .orderBy("createTime",false)
                        .last("LIMIT 1"));
                int day;
                if(Objects.nonNull(tOrder)){
                    // 客户一个月未下单,状态异常
                    Period period = Period.between(DateUtil.dateToLocalDate(tOrder.getCreateTime()), LocalDate.now());
                    int month = Math.abs(period.getMonths());
                    if(month > 0){
                        tAppUser.setIsException(2);
                    }
                    day = Math.abs(period.getDays());
                }else {
                    Period period = Period.between(DateUtil.dateToLocalDate(tAppUser.getCreateTime()), LocalDate.now());
                    int month = Math.abs(period.getMonths());
                    if(month > 0){
                        tAppUser.setIsException(2);
                    }
                    day = Math.abs(period.getDays());
                }
                if(day > 29){
@@ -105,20 +114,14 @@
    }
    /**
     * 每半天检测司机是否有异常
     * 每半天检测司机未上线天数是否有异常
     */
    @Scheduled(cron = "0 0 9,21 * * ? ")
    public void queryDriverIsException(){
        try {
            List<TDriver> driverList = driverService.selectList(new EntityWrapper<TDriver>().ne("status", 3));
            List<TDriver> driverList = driverService.selectList(new EntityWrapper<TDriver>().ne("status", 3)
                    .eq("approvalStatus",2));
            for (TDriver driver : driverList) {
                // 15天未上线异常,当月有效订单低于30单,异常
                Integer count = orderService.getValidOrderCount(driver.getId(),new BigDecimal(14),new SimpleDateFormat("yyyy-MM").format(new Date()));
                if(count < 30){
                    driver.setIsException(2);
                }else {
                    driver.setIsException(1);
                }
                TDriverWork tDriverWork = tDriverWorkService.selectOne(new EntityWrapper<TDriverWork>()
                        .eq("driverId", driver.getId())
                        .orderBy("workTime", false)
@@ -127,6 +130,10 @@
                    // 如果是下班状态,计算未上线天数,,如果为上班状态,则设置为0
                    if(tDriverWork.getStatus() == 2){
                        Period period = Period.between(DateUtil.dateToLocalDate(tDriverWork.getOffWorkTime()), LocalDate.now());
                        int month = Math.abs(period.getMonths());
                        if(month > 0){
                            driver.setIsException(2);
                        }
                        int day = Math.abs(period.getDays());
                        if(day>14){
                            driver.setIsException(2);
@@ -136,6 +143,10 @@
                    if(Objects.nonNull(driver.getApprovalTime())){
                        // 没有上班记录,计算审核时间
                        Period period = Period.between(DateUtil.dateToLocalDate(driver.getApprovalTime()), LocalDate.now());
                        int month = Math.abs(period.getMonths());
                        if(month > 0){
                            driver.setIsException(2);
                        }
                        int day = Math.abs(period.getDays());
                        if(day>14){
                            driver.setIsException(2);
@@ -149,4 +160,28 @@
        }
    }
    /**
     * 每月检测司机有效订单是否有异常
     * 每月最后一天中午12点检测
     */
    @Scheduled(cron = "0 0 12 L * ? ")
    public void queryDriverIsExceptionMonth(){
        try {
            List<TDriver> driverList = driverService.selectList(new EntityWrapper<TDriver>().ne("status", 3)
                    .eq("approvalStatus",2));
            for (TDriver driver : driverList) {
                // 15天未上线异常,当月有效订单低于30单,异常
                Integer count = orderService.getValidOrderCount(driver.getId(),new BigDecimal(14),new SimpleDateFormat("yyyy-MM").format(new Date()));
                if(count < 30){
                    driver.setIsException(2);
                }else {
                    driver.setIsException(1);
                }
            }
            driverService.updateBatchById(driverList);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}