package cn.iocoder.yudao.module.pms.job.qhse;

import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.safe.QhseSafeDayDO;
import cn.iocoder.yudao.module.pms.dal.mysql.qhse.safe.QhseSafeDayMapper;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SafeDayJob implements JobHandler {
    private final QhseSafeDayMapper qhseSafeDayMapper;

    public SafeDayJob(QhseSafeDayMapper qhseSafeDayMapper) {
        this.qhseSafeDayMapper = qhseSafeDayMapper;
    }

    @Override
    @TenantIgnore
    public String execute(String param) throws Exception {
        List<QhseSafeDayDO> qhseSafeDayDOS = qhseSafeDayMapper.selectList();
        //遍历更新
        qhseSafeDayDOS.forEach(qhseSafeDayDO -> {
            qhseSafeDayDO.setDayNumber(qhseSafeDayDO.getDayNumber() + 1);
            qhseSafeDayMapper.insertOrUpdate(qhseSafeDayDO);
        });
        return "";
    }
}
