ToolUtils.java 3.29 KB
package com.ruoyi.utils;

import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.domain.DriverScheduling;
import com.ruoyi.domain.RuleAttendanceMain;
import com.ruoyi.pojo.dto.RuleSchedulingDto;
import com.ruoyi.scheduling.domain.RuleScheduling;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.Objects;

import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN;
import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_TIME_OUT_EX_NUM;
import static com.ruoyi.common.RuleSchedulingProperties.TOMORROW_NO;
import static com.ruoyi.common.SignStatusEnum.SIGN_STATUS_DELAY_ENUM;
import static com.ruoyi.common.SignStatusEnum.SIGN_STATUS_ZONE_ENUM;

public class ToolUtils {

    public static String getUUID() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }

    public static void copyRule(RuleScheduling dto, RuleAttendanceMain main) {
        if (dto.getSecondFlag().equals(TOMORROW_NO)) {
            BeanUtils.copyProperties(dto, main, "secondWorkSignInTime", "secondSignInWorkingRange", "secondQuittingSignInTime", "secondSignInQuittingRange", "secondSignDayTomorrow");
        } else {
            BeanUtils.copyProperties(dto, main);
        }
    }

    public static void copyRule(RuleSchedulingDto dto, RuleAttendanceMain main) {
        if (dto.getSecondFlag().equals(TOMORROW_NO)) {
            BeanUtils.copyProperties(dto, main, "secondWorkSignInTime", "secondSignInWorkingRange", "secondQuittingSignInTime", "secondSignInQuittingRange", "secondSignDayTomorrow");
        } else {
            BeanUtils.copyProperties(dto, main);
        }
    }

    /**
     * 更新报表记录
     * @param scheduling
     */
    public static void updateReport(DriverScheduling scheduling) {
        // TODO UPDATE 这里是特殊处理 青浦后续修改了签到规则
        // 原先正负一小时内  修改为计划签到前一小时内超过就迟到,业主很急就不修改签到规则改为直接修改报表数据
        // 签到
        if (BC_TYPE_OUT.equals(scheduling.getBcType()) && !Objects.isNull(scheduling.getSignTime()) && SIGN_STATUS_ZONE_ENUM.getStatus().equals(scheduling.getExType())) {
            // 实际签到时间
            Date date = scheduling.getSignTime();
            // 计划签到时间
            Long fcsjT = scheduling.getFcsjT();
            if (date.getTime() > fcsjT) {
                scheduling.setExType(SIGN_TIME_OUT_EX_NUM);
                scheduling.setRemark(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType()));
            }
        }
        // 签退客户说把时间约定在正负一小时以内
        // 签退
        if (BC_TYPE_IN.equals(scheduling.getBcType()) && !Objects.isNull(scheduling.getSignTime()) && SIGN_STATUS_ZONE_ENUM.getStatus().equals(scheduling.getExType())) {
            // 实际签退时间
            Date date = scheduling.getSignTime();
            // 计划签退时间
            Long zdsjT = scheduling.getZdsjT();
            // 一小时内约束
            if ( date.getTime() - zdsjT > 60 * 60 * 1000 ) {
                scheduling.setExType(SIGN_TIME_OUT_EX_NUM);
                scheduling.setRemark(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType()));
            }
        }
    }


}