package com.mortals.xhx.common.utils;

import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.module.check.model.CheckAttendRecordEntity;
import com.mortals.xhx.module.check.model.vo.StaffCheckSummaryQuery;
import com.mortals.xhx.module.check.service.CheckAttendRecordService;
import com.mortals.xhx.utils.SpringUtils;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * 考勤核查后续处理线程
 *
 * @author:
 * @date: 2023/7/17 14:42
 */
@RequiredArgsConstructor
@Slf4j
public class AttendPostServiceThread implements Runnable {

    private CheckAttendRecordService checkAttendRecordService;

    @NonNull
    private CheckAttendRecordEntity entity;

    @Override
    public void run() {

        checkAttendRecordService = SpringUtils.getBean(CheckAttendRecordService.class);
        try {
            checkAttendRecordService.sendCheckDingTalk(entity);
            StaffCheckSummaryQuery query = new StaffCheckSummaryQuery();
            query.setStaffId(entity.getStaffId());
            query.setCheckTimeStart(DateUtils.getStrDate(entity.getCheckTime()));
            query.setCheckTimeEnd(query.getCheckTimeStart());
            checkAttendRecordService.summaryCheck(query);
        } catch (Exception e) {
            log.error("汇总已审核的核查记录出错", e);
        }

    }

}
