package com.youchain.utils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.youchain.basicdata.domain.Point;
import com.youchain.modules.system.domain.Dept;

public class UrlApi {
    /**
     * 料箱任务下发
     */
    public static String submitMission = "http://localhost:8000/interfaces/api/amr/submitMission";

    /**
     * 容器入场
     */
    public static String containerIn = "http://localhost:8000/interfaces/api/amr/containerIn";

    /**
     * 容器相关操作，出场
     */
    public static String containerOut = "http://localhost:8000/interfaces/api/amr/containerOut";

    /**
     * 容器相关操作，查询容器信息
     */
    public static String containerQuery = "http://10.177.202.230:10870/interfaces/api/amr/containerQuery";

    /**
     * 输送线点位查询
     */
    public static String querypoint="http://10.177.188.11:4080/webapi/mes/querypoint";

    /**
     * 输送线点位查询
     */
    public static String QueryCount="http://10.177.188.11:4080/webapi/mes/QueryCount";
    public static String sapIpPort="http://192.168.0.201:8092";
    /** 入库单反馈*/
    public static String asnBack = UrlApi.asnBack = sapIpPort+"/synq/expected-receipts/check-in-confirmation";
    /**
     * 入库完成反馈
     * @param owner 货主
     * @param expectedReceiptId 登记单号
     * @param lineNumber 行号
     * @param productId sku
     * @param quantityExpected 期望数量
     * @param quantityReceived 收货数量
     * */
    public static void asnBackSap(String owner,String expectedReceiptId,String productId,String lineNumber
    ,String quantityExpected,String quantityReceived) {
        JSONObject paramsJson=new JSONObject();
        JSONArray erLine=new JSONArray();
            JSONObject er = new JSONObject();
            er.put("lineNumber", lineNumber);
            er.put("quantityExpected", quantityExpected);
            er.put("quantityReceived", quantityReceived);
            er.put("productId", productId);
        erLine.add(er);
        paramsJson.put("erLine",erLine);
        String res = HttpPutUtil.sendPutReq(asnBack+"/"+owner+"/"+expectedReceiptId,paramsJson.toString());
    }
    /** 出库单反馈*/
    public static String ptBack = sapIpPort+"/synq/orders/pick-confirmation";
    /**
     * 出库完成反馈
     * @param owner 货主
     * @param expectedReceiptId 登记单号
     * @param orderLineNumber 行号
     * @param productId sku
     * @param quantity 出库数量
     * @param ztBidNameValue 中标批次名称
     * @param prodMtrlNoValue 成品物料编码
     * */
    public static void ptBackSap(String owner,String expectedReceiptId,String productId,String orderLineNumber
            ,String quantity,String ztBidNameValue,String prodMtrlNoValue) {
        JSONObject paramsJson=new JSONObject();
        JSONArray orderLine=new JSONArray();
            JSONObject order = new JSONObject();
            order.put("orderLineNumber", orderLineNumber);
            order.put("quantity", quantity);
            order.put("productId", productId);
                JSONArray attributeValue=new JSONArray();
                JSONObject ztBidName=new JSONObject();
                ztBidName.put("name", "ztBidName");
                ztBidName.put("value", ztBidNameValue);
                attributeValue.add(ztBidName);
                JSONObject prodMtrlNo=new JSONObject();
                prodMtrlNo.put("name", "prodMtrlNo");
                prodMtrlNo.put("value", prodMtrlNoValue);
                attributeValue.add(prodMtrlNo);

        order.put("attributeValue",attributeValue);
        orderLine.add(order);
        paramsJson.put("orderLine",orderLine);
        String res = HttpPutUtil.sendPutReq(ptBack+"/"+owner+"/"+expectedReceiptId,paramsJson.toString());
    }
    /** 库存调整反馈*/
    public static String invBack = UrlApi.asnBack = sapIpPort+"/synq/load-units/batch-update";

    /**
     * 库存调整反馈
     * @param owner 货主
     * @param productId sku
     * @param quantity 调整后数量
     * @param quantityed 调整前数量
     * @param ztBidNameValue 中标批次名称
     * @param prodMtrlNoValue 成品物料编码
     * @param reason 备注
     */
    public static void invBackSap(String owner,String productId
            ,String quantity,String quantityed,String ztBidNameValue
            ,String prodMtrlNoValue,String reason){
        JSONObject paramsJson=new JSONObject();
        JSONArray loadUnit=new JSONArray();
            JSONObject load = new JSONObject();
            load.put("productId",productId);
            load.put("productOwner",owner);
            load.put("quantityOnHand",quantity);
            load.put("prevQuantityOnHand",quantityed);
            load.put("reasonCode",reason);
                JSONArray attributeValue=new JSONArray();
                JSONObject ztBidName=new JSONObject();
                ztBidName.put("name", "ztBidName");
                ztBidName.put("value", ztBidNameValue);
                attributeValue.add(ztBidName);
                JSONObject prodMtrlNo=new JSONObject();
                prodMtrlNo.put("name", "prodMtrlNo");
                prodMtrlNo.put("value", prodMtrlNoValue);
                attributeValue.add(prodMtrlNo);
            load.put("attributeValue",attributeValue);
        loadUnit.add(load);
        paramsJson.put("loadUnit",loadUnit);
        String res = HttpPutUtil.sendPutReq(ptBack,paramsJson.toString());
    }
    public static Point DoorPoint;
}
