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

//import com.zzsmart.qomo.modules.demo..entity.AppSceneCostMaterial;
//import com.zzsmart.qomo.modules.demo..mapper.AppSceneCostMaterialMapper;
//import com.zzsmart.qomo.modules.demo..service.IAppSceneCostMaterialService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostMaterial;
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostPurchaseRecord;
import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostMaterialMapper;
import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostPurchaseRecordMapper;
import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: app_scene_cost_material
 * @Author: jeecg-boot
 * @Date:   2024-09-17
 * @Version: V1.0
 */
@Service
public class AppSceneCostMaterialServiceImpl extends ServiceImpl<AppSceneCostMaterialMapper, AppSceneCostMaterial> implements IAppSceneCostMaterialService {

    @Autowired
    AppSceneCostMaterialMapper appSceneCostMaterialMapper;
    @Override
    public Map<String, String> getManuTypeByMaterialNo(List<String> materialNos) {
        Map<String, String> map = new HashMap<>();
        QueryWrapper<AppSceneCostMaterial> queryWrapper = new QueryWrapper();
        if (materialNos != null && materialNos.size() > 0) {
            queryWrapper.in("material_number", materialNos);
            List<AppSceneCostMaterial> costPurchasePrices = appSceneCostMaterialMapper.selectList(queryWrapper);
            for (int i = 0; i < costPurchasePrices.size(); i++) {
                AppSceneCostMaterial costPurchasePrice = costPurchasePrices.get(i);
                String manutype = costPurchasePrice.getManufacturingType();
                String sobel = costPurchasePrice.getSobsl();
                if(manutype.equals("E")){
                    map.put(costPurchasePrice.getMaterialNumber(),"E");
                }else if(manutype.equals("F")){
                    if(sobel.equals("30")){
                        map.put(costPurchasePrice.getMaterialNumber(),"F30");
                    }else{
                        map.put(costPurchasePrice.getMaterialNumber(),"F");
                    }
                }
                //map.put(costPurchasePrice.getMaterialNumber(), costPurchasePrice.getManufacturingType()+costPurchasePrice.getSobsl());
            }
        }
        return map;
    }

    @Override
    public Map<String, String> getMaktxByMaterialNo(List<String> materialNos) {
        Map<String, String> map = new HashMap<>();
        QueryWrapper<AppSceneCostMaterial> queryWrapper = new QueryWrapper();
        if (materialNos != null && materialNos.size() > 0) {
            queryWrapper.in("material_number", materialNos);
            List<AppSceneCostMaterial> costPurchasePrices = appSceneCostMaterialMapper.selectList(queryWrapper);
            for (int i = 0; i < costPurchasePrices.size(); i++) {
                AppSceneCostMaterial costPurchasePrice = costPurchasePrices.get(i);
                map.put(costPurchasePrice.getMaterialNumber(), costPurchasePrice.getProductName());
            }
        }
        return map;
    }
}
