package cn.cecep.talroad.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import cn.cecep.talroad.domain.PcFactory;
import cn.cecep.talroad.domain.PcLabelFactory;
import cn.cecep.talroad.mapper.PcFactoryMapper;
import cn.cecep.talroad.vo.FactoryReportingRemindersVo;
import cn.cecep.talroad.vo.query.FactoryReportingRemindersQuery;
import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.cecep.talroad.domain.FactoryReportingReminders;
import cn.cecep.talroad.mapper.FactoryReportingRemindersMapper;
import cn.cecep.talroad.service.IFactoryReportingRemindersService;


/**
 * 企业信息上报提交提示Service业务层处理
 *
 * @author szhpt
 * @date 2023-05-09*/
@Service
public class FactoryReportingRemindersServiceImpl extends ServiceImpl<FactoryReportingRemindersMapper,FactoryReportingReminders> implements IFactoryReportingRemindersService
{
    @Autowired
    private FactoryReportingRemindersMapper factoryReportingRemindersMapper;
    @Autowired
    private PcFactoryMapper pcFactoryMapper;
    /**
     * 查询企业信息上报提交提示列表
     *
     * @param factoryReportingReminders 企业信息上报提交提示
     * @return 企业信息上报提交提示
     */
    @Override
    public List<FactoryReportingReminders> selectFactoryReportingRemindersList(FactoryReportingReminders factoryReportingReminders)
    {
        return factoryReportingRemindersMapper.selectFactoryReportingRemindersList(factoryReportingReminders);
    }

    @Override
    public Integer updateReminder(FactoryReportingRemindersVo factoryReportingReminders) {

        return factoryReportingRemindersMapper.updateReminder(factoryReportingReminders);
    }

    @Override
    public void factoryReportingReminders() {
        List<PcFactory> pcFactories1 = pcFactoryMapper.selectList(new QueryWrapper<>());
        List<FactoryReportingReminders> reportingReminders=new ArrayList<>();
        pcFactories1.forEach(item->{
            FactoryReportingReminders factoryReportingReminders=new FactoryReportingReminders();
            factoryReportingReminders.setFeId(UUID.randomUUID().toString().replace("-", ""));
            factoryReportingReminders.setFactoryId(item.getId());
            factoryReportingReminders.setSubmitStatus("0");
            factoryReportingReminders.setRemindersStatus("1");
            reportingReminders.add(factoryReportingReminders);
        });
        List<List<FactoryReportingReminders>> partition = ListUtil.partition(reportingReminders, 2000);
        partition.forEach(i->{
            this.saveBatch(i);
        });
    }

    @Override
    public List<FactoryReportingRemindersVo> factoryReportingRemindersList(Page<FactoryReportingRemindersVo> page, FactoryReportingRemindersQuery query) {
        List<FactoryReportingRemindersVo> vos =  baseMapper.factoryReportingRemindersList(page, query);
        page.setRecords(vos);
        return vos;
    }
}
