package com.rongwei.bscommon.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rongwei.bscommon.sys.dao.EquMaintenancePartDao;
import com.rongwei.bscommon.sys.service.EquMaintenancePartService;
import com.rongwei.bsentity.domain.EquMaintenancePartDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shangmi
 * @title EquMaintenancePartServiceImpl
 * @date 2023/11/27 15:55
 * @description 设备维护部位业务实现
 */
@Service
public class EquMaintenancePartServiceImpl extends ServiceImpl<EquMaintenancePartDao,EquMaintenancePartDo> implements EquMaintenancePartService {

    @Autowired
    private EquMaintenancePartDao maintenancePartDao;


    @Override
    public List<EquMaintenancePartDo> getMasterIdAndMonthByList(String id, Integer month, Integer year) {
        LambdaQueryWrapper<EquMaintenancePartDo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(id!=null,EquMaintenancePartDo::getMasterid,id)
                .eq(EquMaintenancePartDo::getDeleted,0)
                .eq(month==1,EquMaintenancePartDo::getJan,1)
                .eq(month==2,EquMaintenancePartDo::getFeb,1)
                .eq(month==3,EquMaintenancePartDo::getMar,1)
                .eq(month==4,EquMaintenancePartDo::getApr,1)
                .eq(month==5,EquMaintenancePartDo::getMay,1)
                .eq(month==6,EquMaintenancePartDo::getJun,1)
                .eq(month==7,EquMaintenancePartDo::getJul,1)
                .eq(month==8,EquMaintenancePartDo::getAug,1)
                .eq(month==9,EquMaintenancePartDo::getSep,1)
                .eq(month==10,EquMaintenancePartDo::getOct,1)
                .eq(month==11,EquMaintenancePartDo::getNov,1)
                .eq(month==12,EquMaintenancePartDo::getDecember,1);
        return maintenancePartDao.selectList(queryWrapper);
    }

    @Override
    public void saveBatchList(List<EquMaintenancePartDo> equMaintenancePartList) {
        maintenancePartDao.saveBatchList(equMaintenancePartList);
    }

    @Override
    public List<EquMaintenancePartDo> getMasterIdByList(List<String> collect) {
        LambdaQueryWrapper<EquMaintenancePartDo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(EquMaintenancePartDo::getDeleted,0)
                .in(EquMaintenancePartDo::getMasterid,collect);
        return maintenancePartDao.selectList(queryWrapper);
    }
}
