package com.dayou.service.impl;

import com.dayou.common.BaseEntity;
import com.dayou.entity.BusinessProductionChoiceLog;
import com.dayou.mapper.BusinessProductionChoiceLogMapper;
import com.dayou.service.IBusinessProductionChoiceLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.dayou.utils.ExcelUtil;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.ArrayList;
import org.springframework.transaction.annotation.Transactional;
import com.dayou.enums.BatchTaskTypeEnum;

/**
 * <p>
 * 产品选择记录 服务实现类
 * </p>
 *
 * @author wucl
 * @since 2024-05-16
 */
@Service
public class BusinessProductionChoiceLogServiceImpl extends ServiceImpl<BusinessProductionChoiceLogMapper, BusinessProductionChoiceLog> implements IBusinessProductionChoiceLogService {


    @Override
    @SuppressWarnings("unchecked")
    public Page<BusinessProductionChoiceLog> selectPage(Page page,BusinessProductionChoiceLog businessProductionChoiceLog){
        return this.page(page, new QueryWrapper<BusinessProductionChoiceLog>(businessProductionChoiceLog));
    }


    @Override
    public BusinessProductionChoiceLog detail(Long id){
        return this.getById(id);
    }

    @Override
    public Boolean add(BusinessProductionChoiceLog businessProductionChoiceLog){
        return  this.save(businessProductionChoiceLog);
    }

    @Override
    public Boolean update(BusinessProductionChoiceLog businessProductionChoiceLog){
        return  this.updateById(businessProductionChoiceLog);
    }

    @Override
    public Boolean delete(Long id){
        //逻辑删除
        return this.removeById(id);
    }

    /**
     * 查询产品选择记录
     * @param selectDto 查询条件
     * @return BusinessProductionChoiceLog
     */
    @Override
    public BusinessProductionChoiceLog getChoiceLog(BusinessProductionChoiceLog selectDto) {
        return this.getOne(new LambdaQueryWrapper<BusinessProductionChoiceLog>()
                .eq(BusinessProductionChoiceLog::getBusinessType, selectDto.getBusinessType())
                .eq(BusinessProductionChoiceLog::getBusinessId, selectDto.getBusinessId())
                .eq(BusinessProductionChoiceLog::getTargetId, selectDto.getTargetId())
                .eq(BaseEntity::getDeleted, 0)
                .eq(BusinessProductionChoiceLog::getTakeNoStatus, 0));
    }
}
