package org.jeecg.modules.fbsInventory.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.fbsInventory.entity.FbsInventory;
import org.jeecg.modules.fbsInventory.mapper.FbsInventoryMapper;
import org.jeecg.modules.fbsInventory.service.IFbsInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 存库档案
 * @author： jeecg-boot
 * @date：   2020-10-16
 * @version： V1.0
 */
@Service
@DS("multi-datasource1")
public class FbsInventoryServiceImpl extends ServiceImpl<FbsInventoryMapper, FbsInventory> implements IFbsInventoryService {

    @Resource
    FbsInventoryMapper fbsInventoryMapper;


    @Override
    public List<FbsInventory> getInventoryGetByOrderId(String moId) {
        return fbsInventoryMapper.getInventoryGetByOrderId(moId);
    }

    @Override
    public List<Map<String,Object>> getStockList(){
        return fbsInventoryMapper.getStockList();
    }

    @Override
    public Map<String,Object> getAllStockList(){
        List<Map<String,Object>> mapList = fbsInventoryMapper.getAllStockList();
        Map<String,Object> map = new HashMap<>();
        if(mapList.size() > 0){
            for (Map<String,Object> m:mapList){
                map.put(m.get("materialName").toString(),m.get("realStockSum"));
            }
        }
        return map;
    }

    @Override
    public List<FbsInventory> getListByIds(List<String> stringList) {
        LambdaQueryWrapper<FbsInventory> fbsInventoryLambdaQueryWrapper=new LambdaQueryWrapper<>();
        fbsInventoryLambdaQueryWrapper.in(FbsInventory::getCinvcode,stringList);
        return fbsInventoryMapper.selectList(fbsInventoryLambdaQueryWrapper);
    }
}
