package com.zzsmart.qomo.kn.cost.manage.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandard;
import com.zzsmart.qomo.kn.cost.manage.mapper.CostStandardMapper;
import com.zzsmart.qomo.kn.cost.manage.service.ICostStandardService;
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @Description: 标准成本
 * @Author: wangqiong
 * @Date:   2024-06-13
 * @Version: V1.0
 */
@Service
public class CostStandardServiceImpl extends ServiceImpl<CostStandardMapper, CostStandard> implements ICostStandardService {
    @Autowired
    private CostStandardMapper costStandardMapper;

    @Override
    public IPage<CostStandardVO> pageList(Page<CostStandardVO> page, CostStandardVO costStandard) {
        // 查询条件组装
        QueryWrapper queryWrapper = new QueryWrapper();

        if(costStandard != null){
            if(StrUtil.isNotEmpty(costStandard.getVersionYear()) ){
                // 年份
                queryWrapper.eq("c2.version_year",costStandard.getVersionYear());
            }
            if(StrUtil.isNotEmpty(costStandard.getStage()) ){
                // 阶段
                queryWrapper.eq("c2.stage",costStandard.getStage());
            }
            if(StrUtil.isNotEmpty(costStandard.getMaterialNumber()) ){
                // 物料号
                queryWrapper.like("c1.material_number",costStandard.getMaterialNumber());
            }
            if(StrUtil.isNotEmpty(costStandard.getVersionNumber()) ){
                // 版本号
                queryWrapper.like("c2.version_number",costStandard.getVersionNumber());
            }
            if(StrUtil.isNotEmpty(costStandard.getVersionStatus()) ){
                // 版本状态
                queryWrapper.eq("c2.version_status",costStandard.getVersionStatus());
            }
        }
        return (IPage<CostStandardVO>) costStandardMapper.pageList(page,queryWrapper);
    }
}
