package weaver.interfaces.recruit.cronjob;

import com.engine.recruit.conn.RecruitRecordSet;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;

import java.util.List;
import java.util.Map;

/**
 * 若当前日期大于失效日期，状态变为“逾期未回复”
 *
 * @author:dxfeng
 * @createTime: 2023/11/15
 * @version: 1.0
 */
public class RecruitRefreshOfferJob extends BaseCronJob {
    @Override
    public void execute() {
        // 查询已发送待反馈的offer数据
        RecordSet rs = new RecordSet();
        rs.executeQuery("select id,zt,sxrq from uf_jcl_offer where zt =1");
        List<Map<String, Object>> dataList = RecruitRecordSet.getRecordMapList(rs);
        String currentDate = DateUtil.getCurrentDate();
        for (Map<String, Object> data : dataList) {
            String sxrq = Util.null2String(data.get("sxrq"));
            String id = Util.null2String(data.get("id"));
            int compDate = DateUtil.compDate(currentDate, sxrq);
            // 当前日期>失效日期，更新状态为逾期未回复
            if (compDate < 0) {
                rs.executeUpdate("update uf_jcl_offer set zt = 5 where id = ?", id);
            }
        }

    }
}
