package cn.cecep.talroad.service.impl;

import cn.cecep.talroad.domain.BMainPollDis;
import cn.cecep.talroad.mapper.BMainPollDisMapper;
import cn.cecep.talroad.service.IBMainPollDisService;
import cn.cecep.talroad.util.ConvertNumber;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;




/**
 * 排污许可Service业务层处理
 *
 * @author szhpt
 * @date 2023-01-18*/
@Service
public class BMainPollDisServiceImpl extends ServiceImpl<BMainPollDisMapper,BMainPollDis> implements IBMainPollDisService
{
    @Autowired
    private BMainPollDisMapper bMainPollDisMapper;

    /**
     * 查询排污许可列表
     *
     * @param bMainPollDis 排污许可
     * @return 排污许可
     */
    @Override
    public List<BMainPollDis> selectBMainPollDisList(BMainPollDis bMainPollDis)
    {
        return bMainPollDisMapper.selectBMainPollDisList(bMainPollDis);
    }

    @Override
    public List<BMainPollDis> pullXkzList(String factoryId) {
        List<BMainPollDis> bMainPollDis = bMainPollDisMapper.selectList(new QueryWrapper<BMainPollDis>().eq("factory_id", factoryId).orderByDesc("completion_time"));
        if(!CollectionUtils.isEmpty(bMainPollDis)){
            bMainPollDis.forEach(item->{
                item.setBusinessType(BMainPollDis.PwxkzType.getByCode(item.getBusinessType()).desc);
                item.setEditionCode(ConvertNumber.chineseNumToArabicNum(item.getEditionCode().replaceAll("第","").replaceAll("版","")).toString());
            });
        }
        return bMainPollDis;
    }

    @Override
    public List<BMainPollDis> selectDisPermitData(String businessType,String currDay, String deadLineDay) {
        return bMainPollDisMapper.selectDisPermitData(businessType,currDay,deadLineDay);
    }

}
