package cn.cecep.talroad.service.impl.analysis;

import cn.cecep.talroad.domain.analysis.BMaintenancePlan;
import cn.cecep.talroad.mapper.analysis.BMaintenancePlanMapper;
import cn.cecep.talroad.service.analysis.BMaintenancePlanService;
import cn.cecep.talroad.vo.analysis.CoPlanAllInfo;
import cn.cecep.talroad.vo.analysis.MaintenancePlanAllInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BMaintenancePlanServiceImpl extends ServiceImpl<BMaintenancePlanMapper, BMaintenancePlan> implements BMaintenancePlanService{

    @Override
    public int updateBatch(List<BMaintenancePlan> list) {
        return baseMapper.updateBatch(list);
    }
    @Override
    public int updateBatchSelective(List<BMaintenancePlan> list) {
        return baseMapper.updateBatchSelective(list);
    }
    @Override
    public int batchInsert(List<BMaintenancePlan> list) {
        return baseMapper.batchInsert(list);
    }

    @Override
    public IPage<MaintenancePlanAllInfo> selectCoAllInfoService(MaintenancePlanAllInfo info) {
        Page<CoPlanAllInfo> p=new Page<>(info.getPageNum(),info.getPageSize());
        IPage<MaintenancePlanAllInfo> coAndMaintenancePlanAllInfoIPage = baseMapper.selectCoAllInfo(p, info);
        coAndMaintenancePlanAllInfoIPage.getRecords().forEach(c->{
            if(!"正常".equals(c.getStatusSource())){
                c.setStatus("停产");
            }else {
                c.setStatus("生产");
            }
        });
        return coAndMaintenancePlanAllInfoIPage;
    }

    @Override
    public List<MaintenancePlanAllInfo> selectCoAllInfoServiceList(MaintenancePlanAllInfo info) {
        List<MaintenancePlanAllInfo> records = baseMapper.selectCoAllInfo(new Page<>(0,Integer.MAX_VALUE), info).getRecords();
        records.forEach(c->{
            if(!"正常".equals(c.getStatusSource())){
                c.setStatus("停产");
            }else {
                c.setStatus("生产");
            }
        });
        return records;
    }
}
