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.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostMaterialBom;
import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostMaterialBomMapper;
import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostMaterialBomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

import java.util.List;

/**
 * @Description: app_scene_cost_material_bom
 * @Author: jeecg-boot
 * @Date: 2024-08-02
 * @Version: V1.0
 */
@Service
public class AppSceneCostMaterialBomServiceImpl extends ServiceImpl<AppSceneCostMaterialBomMapper, AppSceneCostMaterialBom> implements IAppSceneCostMaterialBomService {
    @Autowired
    AppSceneCostMaterialBomMapper costMaterialBomMapper;

    /**
     * 分页查询
     *
     * @param materialNumber
     * @return
     */
    @Override
    public List<AppSceneCostMaterialBom> queryListResult(String materialNumber) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (StrUtil.isNotEmpty(materialNumber)) {
            // 物料号
            queryWrapper.like("material_code", materialNumber);
        }
        List list = costMaterialBomMapper.selectList(queryWrapper);
        return list;
    }

    /**
     * 查询最顶层物料编号下所有的物料
     *
     * @param topMaterialCode
     * @return
     */
    @Override
    public List<AppSceneCostMaterialBom> queryAllBomInfoBytopMaterialCode(String topMaterialCode) {
        QueryWrapper queryWrapper = new QueryWrapper();
        //TODO 循环遍历查出所有的物料下的物料（包含最上层的物料）
//        if (StrUtil.isNotEmpty(topMaterialCode)) {
//            // 物料号
//            queryWrapper.like("material_code", topMaterialCode);
//        }
        List list = costMaterialBomMapper.selectList(queryWrapper);
        return list;
    }
}
