package com.yem.wm.es.Util;

import com.yem.wm.utils.RequestCmmp;
import com.yem.wm.utils.YEM;
import kd.bos.context.RequestContext;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author xwudd
 * @date 14:19
 * @Description
 **/
public class MaterialVehicleNoCMMP {
    public final static String productCode = "product_code";//资源号编码
    public final static String productName = "product_name";//产品名称
    public final static String planPin = "plan_pin";//整机编号
    public final static String productColor = "product_color";//产品颜色编码
    public final static String productModel = "product_model";//机型
    public final static String planName = "plan_name";//计划类型
    public final static String publishDate = "publish_date";//发布日期
    public final static String stockNum = "stock_num";//库存数量
    public final static String canuseNum = "canuse_num";//可用数量

    public static List<Map> materialVehicleNo(Map<String,Object> map,Long id){
        String sql = "select product_code,product_name,plan_pin,product_color,product_model,plan_name,publish_date,stock_num,canuse_num from VIEW_PLAN_PIN_WM ";
        long orgId = RequestContext.get().getOrgId();
        String product = (String)map.get(productCode);//物料编码
        if(YEM.isEmpty(product)){
            return new ArrayList<>();
        }
        StringBuffer where = new StringBuffer(String.format("where %s = '%s'",productCode,product));
        sql = sql + where.toString();
        List<Map> fromCmmp = RequestCmmp.getFromCmmp(orgId, sql,id);
        return fromCmmp;
    }
}
