using ICSSoft.DataProject;
using ICSSoft.DataProject.ICSSoft.DataProject;
using ICSSoft.Entity;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using System.Web.Http.Description;
using ICSSoft.Common;
using ICSSoft.APIApproveRCV;
using ICSSoft.APIApproveIssue;
using ICSSoft.APICreateIssue;
using ICSSoft.APICreateCompRpt;
using ICSSoft.APIApproveShipment;
using ICSSoft.APIApproveMiscShip;
using ICSSoft.APIApproveMiscRcv;
using ICSSoft.APIApproveTransferIN;
using ICSSoft.APIModifyIssue;
using UFIDA.ISV.CreateBFTransferFormForItem;
using ICS.WCF.Base;
using ICS.CreateRCV;
using ICS.CreateBFMiscRcv;
using UFIDA.ISV.CreateBFMisShip;
using UFIDA.ISV.CreateBFRTN;
using UFIDA.ISV.CreateAboveIssue;
using static UFIDA.ISV.CreateAboveIssue.CustCreateAboveIssue;
using ICS.CreateIssue;
using static ICS.CreateIssue.CustCreateIssue;
using ICS.CreateCreateRcvRestNEW;
using UFIDA.ISV.CreateBFPMRecede;
using static UFIDA.ISV.CreateRcvRpt.CustCreateRcvRptSrv;
using UFIDA.ISV.CreateRcvRpt;
using UFIDA.ISV.ATWCreatePMIssue;
using Newtonsoft.Json.Linq;
using System.Configuration;
using ICS.ApproveShip;
using UFIDA.ISV.RcvRptApprove;
using UFIDA.ISV.BFRCVApprove;
using static UFIDA.ISV.BFRCVApprove.CustBFRCVApprove;
using ICS.CreateRtnTORcv;
using ICS.CreateShipPlanToShipment;
using UFIDA.ISV.ModifyLotMaster;
using UFIDA.ISV.CreateTransferINForJOB;
using UFIDA.ISV.CreateCheckDiffDoc;
using ICS.SpecialApproveTransferOut;
using ICSSoft.APICreateMaterialDelivery;
using ICSSoft.APIModifySMShipmement;
using ICSSoft.APIModifyRMAToRCV;
using ICSSoft.APIModifyMiscRcv;
using ICSSoft.APIModifyMiscShip;
using ICSSoft.APICreateOnStoreCheckDoc;
using UFIDA.U9.Cust.CreateApBillBySrcDoc;
using static UFIDA.ISV.ModifyTransferIN.CustModifyTransferIN;
using UFIDA.ISV.ModifyTransferIN;
using UFIDA.ISV.ATWApproveFCTMatrialPick;
using UFIDA.ISV.ApproveLendTrans;
using UFIDA.ISV.ApproveLendBakcTrans;
using ICSSoft.APICreateRCVByRMR;
using ICSSoft.APIModifyPMIssueDoc;
using ICS.CreateMiscShipByItemRequest;
using UFIDA.U9.Cust.ModifyLot;
using UFIDA.U9.Cust.CloseShipPlanLine;
using UFIDA.U9.Cust.ModifyRcvLine;
using UFIDA.U9.Cust.CreateMaterialDeliveryDocByMoPick;
using UFIDA.U9.Cust.CreateMaterialDeliveryDocByMoIssueApply;
using UFIDA.U9.Cust.CreateMaterialDeliveryDocByMoIssueApplyRtn;
using UFIDA.U9.Cust.CreateRcvByPoBatchForApi;
//using ICS.CreateCreateRcvRest;

namespace ICSSoft.WebAPI.Controllers
{
    public class ValuesController : ApiController
    {
        private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        #region 请购单
        /// <summary>
        /// 获取请购单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseRequisition/Get")]
        [HttpPost]

        public HttpResponseMessage GetPurchaseRequisition([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseRequisition/Get ");
            log.Info("获取请购单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseRequisition> infos = new List<ICSPurchaseRequisition>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseRequisition>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseRequisition action = new PurchaseRequisition();
                        string resultStr = action.Get(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取请购单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 创建请购单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseRequisition/Create")]
        [HttpPost]
        public HttpResponseMessage CreatePurchaseRequisition([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseRequisition/Create ");
            log.Info("创建请购单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseRequisition> infos = new List<ICSPurchaseRequisition>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseRequisition>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());

                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        PurchaseRequisition action = new PurchaseRequisition();
                        string resultStr = action.CreatePurchaseRequisition(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;

                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建请购单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 审核请购单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseRequisition/Approve")]
        [HttpPost]
        public HttpResponseMessage ApprovePurchaseRequisition([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseRequisition/Approve");
            log.Info("审核请购单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseRequisition> infos = new List<ICSPurchaseRequisition>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseRequisition>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseRequisition action = new PurchaseRequisition();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            //res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核请购单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除到货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseRequisition/Delete")]
        [HttpPost]
        public HttpResponseMessage DeletePurchaseRequisition([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseRequisition/Delete");
            log.Info("删除到货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseRequisition> infos = new List<ICSPurchaseRequisition>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseRequisition>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseRequisition action = new PurchaseRequisition();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            //res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除到货单返回值：" + str);
            return result;
        }
        #endregion
        #region 采购订单
        /// <summary>
        /// 获取采购订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseOrder/Get")]
        [HttpPost]

        public HttpResponseMessage GetPurchaseOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseOrder/Get");
            log.Info("获取采购订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseOrder> infos = new List<ICSPurchaseOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseOrder action = new PurchaseOrder();
                        string resultStr = action.GET(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取采购订单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 创建采购订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseOrder/Create")]
        [HttpPost]
        public HttpResponseMessage CreatePurchaseOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseOrder/Create");
            log.Info("创建采购订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseOrder> infos = new List<ICSPurchaseOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());

                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        PurchaseOrder action = new PurchaseOrder();
                        string resultStr = action.CreateICSPurchaseOrder(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;

                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建采购订单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 审核采购订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseOrder/Approve")]
        [HttpPost]
        public HttpResponseMessage ApprovePurchaseOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseOrder/Approve");
            log.Info("审核采购订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseOrder> infos = new List<ICSPurchaseOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseOrder action = new PurchaseOrder();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            //res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核采购订单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除采购订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseOrder/Delete")]
        [HttpPost]
        public HttpResponseMessage DeletePurchaseOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseOrder/Delete");
            log.Info("删除采购订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseOrder> infos = new List<ICSPurchaseOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseOrder action = new PurchaseOrder();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            //res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除采购订单返回值：" + str);
            return result;
        }
        #endregion
        #region 到货单
        /// <summary>
        /// 获取到货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreatePOArrive/Get")]
        [HttpPost]

        public HttpResponseMessage Get([FromBody] object JsonData)
        {
            log.Info("接口：api/CreatePOArrive/Get");
            log.Info("获取到货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPOArrive> infos = new List<ICSPOArrive>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPOArrive>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CreatePOArrive action = new CreatePOArrive();
                        string resultStr = action.Get(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取到货单返回值：" + str);
            return result;
        }

        /// <summary>
        /// 审核到货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreatePOArrive/Approve")]
        [HttpPost]
        public HttpResponseMessage Approve([FromBody] object JsonData)
        {
            log.Info("接口：api/CreatePOArrive/Approve");
            log.Info("审核到货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPOArrive> infos = new List<ICSPOArrive>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPOArrive>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CreatePOArrive action = new CreatePOArrive();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            //res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核到货单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除到货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreatePOArrive/Delete")]
        [HttpPost]
        public HttpResponseMessage Delete([FromBody] object JsonData)
        {
            log.Info("接口：api/CreatePOArrive/Delete");
            log.Info("删除到货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPOArrive> infos = new List<ICSPOArrive>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPOArrive>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CreatePOArrive action = new CreatePOArrive();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            //res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除到货单返回值：" + str);
            return result;
        }
        #endregion
        #region 拒收单
        /// <summary>
        /// 获取拒收单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreatePuArrivalVouch/Get")]
        [HttpPost]
        public HttpResponseMessage GetPuArrivalVouch([FromBody] object JsonData)
        {
            log.Info("接口：api/CreatePuArrivalVouch/Get");
            log.Info("获取拒收单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPUArrivalVouch> infos = new List<ICSPUArrivalVouch>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPUArrivalVouch>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CreatePuArrivalVouch action = new CreatePuArrivalVouch();
                        string resultStr = action.Get(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取拒收单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 创建拒收单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreatePuArrivalVouch/Create")]
        [HttpPost]
        public HttpResponseMessage CreatePuArrivalVouch([FromBody] object JsonData)
        {
            log.Info("接口：api/CreatePuArrivalVouch/Create");
            log.Info("创建拒收单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPUArrivalVouch> infos = new List<ICSPUArrivalVouch>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPUArrivalVouch>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());

                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        CreatePuArrivalVouch action = new CreatePuArrivalVouch();
                        string resultStr = action.CreatePUArrive(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Data = resultStr;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建拒收单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 创建委外拒收单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreateWPuArrivalVouch/CreateNew")]
        [HttpPost]
        public HttpResponseMessage CreatePuArrivalVouchNEW([FromBody] object JsonData)
        {
            log.Info("接口：api/CreateWPuArrivalVouch/CreateNew");
            log.Info("创建委外拒收单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOPUArrivalVouch> infos = new List<ICSOPUArrivalVouch>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOPUArrivalVouch>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());

                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        CreatePuArrivalVouch action = new CreatePuArrivalVouch();
                        string resultStr = action.CreateWPUArrive(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Data = resultStr;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建拒收单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 审核拒收单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreatePuArrivalVouch/Approve")]
        [HttpPost]
        public HttpResponseMessage ApprovePuArrivalVouch([FromBody] object JsonData)
        {
            log.Info("接口：api/CreatePuArrivalVouch/Approve");
            log.Info("审核拒收单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPUArrivalVouch> infos = new List<ICSPUArrivalVouch>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPUArrivalVouch>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CreatePuArrivalVouch action = new CreatePuArrivalVouch();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核拒收单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除拒收单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreatePuArrivalVouch/Delete")]
        [HttpPost]
        public HttpResponseMessage DeletePuArrivalVouch([FromBody] object JsonData)
        {
            log.Info("接口：api/CreatePuArrivalVouch/Delete");
            log.Info("删除拒收单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPUArrivalVouch> infos = new List<ICSPUArrivalVouch>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPUArrivalVouch>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CreatePuArrivalVouch action = new CreatePuArrivalVouch();
                        string resultStr = action.Delete(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除拒收单返回值：" + str);
            return result;
        }
        #endregion
        #region 采购入库单
        /// <summary>
        /// 获取采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseReceiveDoc/Get")]
        [HttpPost]
        public HttpResponseMessage GetRdRecord01([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseReceiveDoc/Get");
            log.Info("获取采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseReceiveDoc action = new PurchaseReceiveDoc();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取采购入库单返回值：" + str);
            return result;
        }
        ///// <summary>
        ///// 创建采购入库单(源头单据采购订单)
        ///// </summary>
        ///// <param name="JsonData"></param>
        ///// <returns></returns>
        //[Route("api/PurchaseReceiveDoc/Create")]
        //[HttpPost]
        //public HttpResponseMessage CreateRdRecord01([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/PurchaseReceiveDoc/Create");
        //    log.Info("创建采购入库单(源头单据采购订单)传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());

        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                    throw new Exception(res.Message);
        //                }
        //                PurchaseReceiveDoc action = new PurchaseReceiveDoc();
        //                string resultStr = action.CreateRdRecord01sByPO(infos);
        //                if (!string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Data = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建采购入库单(源头单据采购订单)返回值：" + str);
        //    return result;
        //}
        /// <summary>
        /// 创建采购入库单(源头单据到货单)
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        //[Route("api/PurchaseReceiveDocPOArrive/Create")]
        //[HttpPost]
        //public HttpResponseMessage CreateRdRecord01ByPOArrive([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/PurchaseReceiveDocPOArrive/Create");
        //    log.Info("创建采购入库单(源头单据到货单)传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());

        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                    throw new Exception(res.Message);
        //                }
        //                PurchaseReceiveDoc action = new PurchaseReceiveDoc();
        //                string resultStr = action.CreateRdRecord01sByPOArrive(infos);
        //                if (!string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Data = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建采购入库单(源头单据到货单)返回值：" + str);
        //    return result;
        //}
        /// <summary>
        /// 审核采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        //[Route("api/PurchaseReceiveDoc/Approve")]
        //[HttpPost]
        //public HttpResponseMessage ApproveRdRecord01([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/PurchaseReceiveDoc/Approve");
        //    log.Info("审核采购入库单传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                PurchaseReceiveDoc action = new PurchaseReceiveDoc();
        //                string resultStr = action.Approve(infos);
        //                if (resultStr.Length > 0)
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Message = "接口调用失败";
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("审核采购入库单返回值：" + str);
        //    return result;
        //}
        /// <summary>
        /// 删除采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseReceiveDoc/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteRdRecord01([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseReceiveDoc/Delete");
            log.Info("删除采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseReceiveDoc action = new PurchaseReceiveDoc();
                        string resultStr = action.Delete(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除采购入库单返回值：" + str);
            return result;
        }
        #endregion
        #region 采购红字入库单
        /// <summary>
        /// 获取采购红字入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseReceiveDoctNegative/Get")]
        [HttpPost]
        public HttpResponseMessage GetPurchaseReceiveDoctNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseReceiveDoctNegative/Get");
            log.Info("获取采购红字入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseReceiveDoctNegative action = new PurchaseReceiveDoctNegative();
                        string resultStr = action.Get(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取采购红字入库单返回值：" + str);
            return result;
        }
        ///// <summary>
        ///// 创建采购红字入库单
        ///// </summary>
        ///// <param name="JsonData"></param>
        ///// <returns></returns>
        //[Route("api/PurchaseReceiveDoctNegative/Create")]
        //[HttpPost]
        //public HttpResponseMessage CreatePurchaseReceiveDoctNegative([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/PurchaseReceiveDoctNegative/Create");
        //    log.Info("创建采购红字入库单传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());

        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                    throw new Exception(res.Message);
        //                }
        //                PurchaseReceiveDoctNegative action = new PurchaseReceiveDoctNegative();
        //                string resultStr = action.CreatePurchaseReceiveDoctNegative(infos);
        //                if (!string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Data = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建采购红字入库单返回值：" + str);
        //    return result;
        //}
        /// <summary>
        /// 删除采购红字入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseReceiveDoctNegative/Delete")]
        [HttpPost]
        public HttpResponseMessage DeletePurchaseReceiveDoctNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseReceiveDoctNegative/Delete");
            log.Info("删除采购红字入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseReceiveDoctNegative action = new PurchaseReceiveDoctNegative();
                        string resultStr = action.Delete(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除采购红字入库单返回值：" + str);
            return result;
        }
        #endregion
        #region 生产订单
        /// <summary>
        /// 获取采购订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/ManufactureOrder/Get")]
        [HttpPost]

        public HttpResponseMessage GetManufactureOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/ManufactureOrder/Get");
            log.Info("获取采购订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSManufactureOrder> infos = new List<ICSManufactureOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSManufactureOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ManufactureOrder action = new ManufactureOrder();
                        string resultStr = action.GET(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取采购订单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 创建生产订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/ManufactureOrder/Create")]
        [HttpPost]
        public HttpResponseMessage CreateManufactureOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/ManufactureOrder/Create");
            log.Info("创建生产订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSManufactureOrder> infos = new List<ICSManufactureOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSManufactureOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());

                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        ManufactureOrder action = new ManufactureOrder();
                        string resultStr = action.CreateManufactureOrder(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;

                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建生产订单返回值：" + str);
            return result;
        }

        /// <summary>
        /// 删除生产订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/ManufactureOrder/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteManufactureOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/ManufactureOrder/Delete");
            log.Info("删除生产订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSManufactureOrder> infos = new List<ICSManufactureOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSManufactureOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ManufactureOrder action = new ManufactureOrder();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            //res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除生产订单返回值：" + str);
            return result;
        }
        #endregion
        #region 生产订单备料表

        #endregion
        #region 领料申请单
        /// <summary>
        /// 创建入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MOIssueApplyDoc/Get")]
        [HttpPost]
        public HttpResponseMessage GetMOIssueApplyDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/MOIssueApplyDoc/Get");
            log.Info("创建入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSMaterialAppVouch> infos = new List<ICSMaterialAppVouch>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSMaterialAppVouch>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        MOIssueApplyDoc action = new MOIssueApplyDoc();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建入库单返回值：" + str);
            return result;
        }
        #endregion
        #region 材料出库
        /// <summary>
        /// 获取材料出库
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MOIssueDoc/Get")]
        [HttpPost]
        public HttpResponseMessage GetMOIssueDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/MOIssueDoc/Get");
            log.Info("获取材料出库传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSRdrecord11> infos = new List<ICSRdrecord11>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSRdrecord11>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        MOIssueDoc action = new MOIssueDoc();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取材料出库返回值：" + str);
            return result;
        }
        /// <summary>
        /// 创建材料出库(生产订单)
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>

        /// <summary>
        /// 创建材料出库(领料申请)
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        //[Route("api/MOIssueDocByPU/Create")]
        //[HttpPost]
        //public HttpResponseMessage CreateMOIssueDocBYPU([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/MOIssueDocByPU/Create");
        //    log.Info("创建材料出库(领料申请)传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSRdrecord11> infos = new List<ICSRdrecord11>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSRdrecord11>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                MOIssueDoc action = new MOIssueDoc();
        //                string resultStr = action.MaterialAppVouchs(infos);
        //                if (!string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Message = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建材料出库(领料申请)返回值：" + str);
        //    return result;
        //}
        /// <summary>
        /// 审核材料出库(生产订单)
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        //[Route("api/MOIssueDoc/Approve")]
        //[HttpPost]
        //public HttpResponseMessage ApproveMOIssueDoc([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/MOIssueDoc/Approve");
        //    log.Info("审核材料出库(生产订单)传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSRdrecord11> infos = new List<ICSRdrecord11>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSRdrecord11>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                MOIssueDoc action = new MOIssueDoc();
        //                string resultStr = action.Approve(infos);
        //                if (string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Message = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("审核材料出库(生产订单)返回值：" + str);
        //    return result;
        //}
        /// <summary>
        /// 删除材料出库(备料表)
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MOIssueDoc/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteMOIssueDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/MOIssueDoc/Delete");
            log.Info("删除材料出库(备料表)传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSRdrecord11> infos = new List<ICSRdrecord11>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSRdrecord11>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        MOIssueDoc action = new MOIssueDoc();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除材料出库(备料表)返回值：" + str);
            return result;
        }
        #endregion
        #region 生产退料单(红字材料出库)
        /// <summary>
        /// 获取生产退料单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MOIssueDocNegative/Get")]
        [HttpPost]
        public HttpResponseMessage GetMOIssueDocNegatives([FromBody] object JsonData)
        {
            log.Info("接口：api/MOIssueDocNegative/Get");
            log.Info("获取生产退料单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSMOIssueDocNegative> infos = new List<ICSMOIssueDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSMOIssueDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        MOIssueDocNegatives action = new MOIssueDocNegatives();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取生产退料单返回值：" + str);
            return result;
        }
        ///// <summary>
        ///// 创建生产退料单
        ///// </summary>
        ///// <param name="JsonData"></param>
        ///// <returns></returns>
        //[Route("api/MOIssueDocNegative/Create")]
        //[HttpPost]
        //public HttpResponseMessage CreateMOIssueDocNegatives([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/MOIssueDocNegative/Create");
        //    log.Info("创建生产退料单传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSMOIssueDocNegative> infos = new List<ICSMOIssueDocNegative>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSMOIssueDocNegative>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                MOIssueDocNegatives action = new MOIssueDocNegatives();
        //                string resultStr = action.CreateRd11(infos);
        //                if (!string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Message = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建生产退料单返回值：" + str);
        //    return result;
        //}

        /// <summary>
        /// 审核生产退料单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MOIssueDocNegative/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveMOIssueDocNegatives([FromBody] object JsonData)
        {
            log.Info("接口：api/MOIssueDocNegative/Approve");
            log.Info("审核生产退料单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSMOIssueDocNegative> infos = new List<ICSMOIssueDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSMOIssueDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        MOIssueDocNegatives action = new MOIssueDocNegatives();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核生产退料单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除生产退料单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MOIssueDocNegative/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteMOIssueDocNegatives([FromBody] object JsonData)
        {
            log.Info("接口：api/MOIssueDocNegative/Delete");
            log.Info("删除生产退料单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSMOIssueDocNegative> infos = new List<ICSMOIssueDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSMOIssueDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        MOIssueDocNegatives action = new MOIssueDocNegatives();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除生产退料单返回值：" + str);
            return result;
        }
        #endregion
        #region 委外订单
        /// <summary>
        /// 获取委外订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingOrder/Get")]
        [HttpPost]
        public HttpResponseMessage GetOutsourcingOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingOrder/Get");
            log.Info("获取委外订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingOrder> infos = new List<ICSOutsourcingOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingOrder action = new OutsourcingOrder();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取委外订单返回值：" + str);
            return result;
        }
        #endregion
        #region 委外订单备料表
        /// <summary>
        /// 获取委外订单备料表
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingOrderPick/Get")]
        [HttpPost]
        public HttpResponseMessage GetOutsourcingOrderPick([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingOrderPick/Get");
            log.Info("获取委外订单备料表传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingOrderPick> infos = new List<ICSOutsourcingOrderPick>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingOrderPick>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingOrderPick action = new OutsourcingOrderPick();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取委外订单备料表返回值：" + str);
            return result;
        }
        #endregion
        #region 委外发料
        /// <summary>
        /// 获取委外发料
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingIssueDoc/Get")]
        [HttpPost]
        public HttpResponseMessage GetOutsourcingIssueDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingIssueDoc/Get");
            log.Info("获取委外发料传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingIssueDoc> infos = new List<ICSOutsourcingIssueDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingIssueDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingIssueDoc action = new OutsourcingIssueDoc();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取委外发料返回值：" + str);
            return result;
        }

        /// <summary>
        /// 审核委外发料单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingIssueDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveOutsourcingIssueDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingIssueDoc/Approve");
            log.Info("审核委外发料单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingIssueDoc> infos = new List<ICSOutsourcingIssueDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingIssueDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingIssueDoc action = new OutsourcingIssueDoc();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核委外发料单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除委外发料单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingIssueDoc/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteOutsourcingIssueDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingIssueDoc/Delete");
            log.Info("删除委外发料单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingIssueDoc> infos = new List<ICSOutsourcingIssueDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingIssueDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingIssueDoc action = new OutsourcingIssueDoc();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除委外发料单返回值：" + str);
            return result;
        }
        #endregion
        #region 委外退料
        /// <summary>
        /// 获取委外退料
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingIssueDoNegative/Get")]
        [HttpPost]
        public HttpResponseMessage GetOutsourcingIssueDoNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingIssueDoNegative/Get");
            log.Info("获取委外退料传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingIssueDoc> infos = new List<ICSOutsourcingIssueDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingIssueDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingIssueDoNegative action = new OutsourcingIssueDoNegative();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取委外退料返回值：" + str);
            return result;
        }


        /// <summary>
        /// 审核委外退料
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingIssueDoNegative/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveOutsourcingIssueDoNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingIssueDoNegative/Approve");
            log.Info("审核委外退料传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingIssueDoc> infos = new List<ICSOutsourcingIssueDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingIssueDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingIssueDoNegative action = new OutsourcingIssueDoNegative();
                        string resultStr = action.Approve(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核委外退料返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除委外退料
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingIssueDoNegative/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteOutsourcingIssueDoNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingIssueDoNegative/Delete");
            log.Info("删除委外退料传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingIssueDoc> infos = new List<ICSOutsourcingIssueDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingIssueDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingIssueDoNegative action = new OutsourcingIssueDoNegative();
                        string resultStr = action.Delete(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除委外退料返回值：" + str);
            return result;
        }
        #endregion
        #region 委外到货单
        /// <summary>
        /// 获取委外到货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/DeliveryNotice/Get")]
        [HttpPost]
        public HttpResponseMessage GetDeliveryNotice([FromBody] object JsonData)
        {
            log.Info("接口：api/DeliveryNotice/Get");
            log.Info("获取委外到货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSDeliveryNotice> infos = new List<ICSDeliveryNotice>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSDeliveryNotice>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        DeliveryNotice action = new DeliveryNotice();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取委外到货单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 创建委外到货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/DeliveryNotice/Create")]
        [HttpPost]
        public HttpResponseMessage CreateDeliveryNotice([FromBody] object JsonData)
        {
            log.Info("接口：api/DeliveryNotice/Create");
            log.Info("创建委外到货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSDeliveryNotice> infos = new List<ICSDeliveryNotice>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSDeliveryNotice>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        DeliveryNotice action = new DeliveryNotice();
                        string resultStr = action.CreatePUArrive(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建委外到货单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 审核委外到货
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/DeliveryNotice/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveDeliveryNotice([FromBody] object JsonData)
        {
            log.Info("接口：api/DeliveryNotice/Approve");
            log.Info("审核委外到货传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSDeliveryNotice> infos = new List<ICSDeliveryNotice>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSDeliveryNotice>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        DeliveryNotice action = new DeliveryNotice();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核委外到货返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除委外到货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/DeliveryNotice/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteDeliveryNotice([FromBody] object JsonData)
        {
            log.Info("接口：api/DeliveryNotice/Delete");
            log.Info("删除委外到货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSDeliveryNotice> infos = new List<ICSDeliveryNotice>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSDeliveryNotice>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        DeliveryNotice action = new DeliveryNotice();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除委外到货单返回值：" + str);
            return result;
        }
        #endregion
        #region 委外采购入库单
        /// <summary>
        /// 获取委外采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReceiveDoc/Get")]
        [HttpPost]
        public HttpResponseMessage GetOutsourcingReceiveDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingReceiveDoc/Get");
            log.Info("获取委外采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingReceiveDoc> infos = new List<ICSOutsourcingReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingReceiveDoc action = new OutsourcingReceiveDoc();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取委外采购入库单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 审核委外采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReceiveDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveOutsourcingReceiveDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingReceiveDoc/Approve");
            log.Info("审核委外采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingReceiveDoc> infos = new List<ICSOutsourcingReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingReceiveDoc action = new OutsourcingReceiveDoc();
                        string resultStr = action.Approve(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核委外采购入库单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseReceiveDoc/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteOutsourcingReceiveDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/PurchaseReceiveDoc/Delete");
            log.Info("删除采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        PurchaseReceiveDoc action = new PurchaseReceiveDoc();
                        string resultStr = action.Delete(infos);
                        if (resultStr.Length > 0)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除采购入库单返回值：" + str);
            return result;
        }
        #endregion
        #region 委外采购退货单
        /// <summary>
        /// 获取委外采购退货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReturnBack/Get")]
        [HttpPost]
        public HttpResponseMessage GETOutsourcingReturnBack([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingReturnBack/Get");
            log.Info("获取委外采购退货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingReturnBack> infos = new List<ICSOutsourcingReturnBack>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingReturnBack>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingReturnBack action = new OutsourcingReturnBack();
                        string resultStr = action.Get(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取委外采购退货单返回值：" + str);
            return result;
        }
        #endregion
        #region 委外采购入库红字
        /// <summary>
        /// 获取委外采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReceiveDocNegative/Get")]
        [HttpPost]
        public HttpResponseMessage GetOutsourcingReceiveDocNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingReceiveDocNegative/Get");
            log.Info("获取委外采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingReceiveDocNegative> infos = new List<ICSOutsourcingReceiveDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingReceiveDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingReceiveDocNegative action = new OutsourcingReceiveDocNegative();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取委外采购入库单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 创建委外采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReceiveDocNegative/Create")]
        [HttpPost]
        public HttpResponseMessage CreateOutsourcingReceiveDocNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingReceiveDocNegative/Create");
            log.Info("创建委外采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "委外退货-委外退货单");


                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingReceiveDocNegative> infos = new List<ICSOutsourcingReceiveDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingReceiveDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());

                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        //OutsourcingReceiveDocNegative action = new OutsourcingReceiveDocNegative();
                        //string resultStr = action.CreateOutsourcingReceiveDocNegative(infos);
                        CreateRtnToRCV action = new CreateRtnToRCV();
                        string resultStr = action.CustOutCreateRtnToRcv(infos);

                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }



                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建委外采购入库单返回值：" + str);

            DBHelper.WriteLogFile("返回报文：" + str, "委外退货-委外退货单");
            return result;
        }

        /// <summary>
        /// 删除采购入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReceiveDocNegative/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteOutsourcingReceiveDocNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingReceiveDocNegative/Delete");
            log.Info("删除采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSOutsourcingReceiveDocNegative> infos = new List<ICSOutsourcingReceiveDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSOutsourcingReceiveDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        OutsourcingReceiveDocNegative action = new OutsourcingReceiveDocNegative();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrEmpty(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除采购入库单返回值：" + str);
            return result;
        }
        #endregion
        #region 成品入库单

        /// <summary>
        /// 获取成品入库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/ManufactureReceiveDoc/Get")]
        [HttpPost]
        public HttpResponseMessage GetManufactureReceiveDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/ManufactureReceiveDoc/Get");
            log.Info("获取成品入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSManufactureReceiveDoc> infos = new List<ICSManufactureReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSManufactureReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ManufactureReceiveDoc action = new ManufactureReceiveDoc();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取成品入库单返回值：" + str);
            return result;
        }

        ///// <summary>
        ///// 创建成品入库单
        ///// </summary>
        ///// <param name="JsonData"></param>
        ///// <returns></returns>
        //[Route("api/ManufactureReceiveDoc/Create")]
        //[HttpPost]
        //public HttpResponseMessage CreateManufactureReceiveDoc([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/ManufactureReceiveDoc/Create");
        //    log.Info("创建成品入库单传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSManufactureReceiveDoc> infos = new List<ICSManufactureReceiveDoc>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSManufactureReceiveDoc>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                ManufactureReceiveDoc action = new ManufactureReceiveDoc();
        //                string resultStr = action.CreateManufactureReceiveDoc(infos);
        //                if (!string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Message = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建成品入库单返回值：" + str);
        //    return result;
        //}




        /// <summary>
        /// 删除委外退料单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/ManufactureReceiveDoc/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteManufactureReceiveDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/ManufactureReceiveDoc/Delete");
            log.Info("删除委外退料单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSManufactureReceiveDoc> infos = new List<ICSManufactureReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSManufactureReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ManufactureReceiveDoc action = new ManufactureReceiveDoc();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除委外退料单返回值：" + str);
            return result;
        }

        #endregion
        #region 销售出库

        /// <summary>
        /// 获取销售出库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesShipmentDoc/Get")]
        [HttpPost]
        public HttpResponseMessage GetSalesShipmentDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesShipmentDoc/Get");
            log.Info("获取销售出库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesShipmentDoc> infos = new List<ICSSalesShipmentDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesShipmentDoc action = new SalesShipmentDoc();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取销售出库单返回值：" + str);
            return result;
        }

        ///// <summary>
        ///// 创建销售出库单
        ///// </summary>
        ///// <param name="JsonData"></param>
        ///// <returns></returns>
        //[Route("api/SalesShipmentDoc/Create")]
        //[HttpPost]
        //public HttpResponseMessage CreateSalesShipmentDoc([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/SalesShipmentDoc/Create");
        //    log.Info("创建销售出库单传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSSalesShipmentDoc> infos = new List<ICSSalesShipmentDoc>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDoc>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                SalesShipmentDoc action = new SalesShipmentDoc();
        //                string resultStr = action.CreateSalesShipmentDoc(infos);
        //                if (!string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Message = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建销售出库单返回值：" + str);
        //    return result;
        //}
        /// <summary>
        /// 删除销售出库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesShipmentDoc/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteSalesShipmentDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesShipmentDoc/Delete");
            log.Info("删除销售出库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesShipmentDoc> infos = new List<ICSSalesShipmentDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesShipmentDoc action = new SalesShipmentDoc();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除销售出库单返回值：" + str);
            return result;
        }

        #endregion
        #region 销售出库红字

        /// <summary>
        /// 获取销售出库单红字
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesShipmentDocNegative/Get")]
        [HttpPost]
        public HttpResponseMessage GetSalesShipmentDocNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesShipmentDocNegative/Get");
            log.Info("获取销售出库单红字传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesShipmentDocNegative> infos = new List<ICSSalesShipmentDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesShipmentDocNegative action = new SalesShipmentDocNegative();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取销售出库单红字返回值：" + str);
            return result;
        }

        ///// <summary>
        ///// 创建销售出库单
        ///// </summary>
        ///// <param name="JsonData"></param>
        ///// <returns></returns>
        //[Route("api/SalesShipmentDocNegative/Create")]
        //[HttpPost]
        //public HttpResponseMessage CreateSalesShipmentDocNegative([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/SalesShipmentDocNegative/Create,");
        //    log.Info("创建销售出库单传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSSalesShipmentDocNegative> infos = new List<ICSSalesShipmentDocNegative>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDocNegative>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                SalesShipmentDocNegative action = new SalesShipmentDocNegative();
        //                string resultStr = action.CreateSalesShipmentDocNegative(infos);
        //                if (!string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                    res.Data = resultStr;
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Message = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建销售出库单返回值：" + str);
        //    return result;
        //}
        ///// <summary>
        ///// 审核销售出库单红字
        ///// </summary>
        ///// <param name="JsonData"></param>
        ///// <returns></returns>
        //[Route("api/SalesShipmentDocNegative/Approve")]
        //[HttpPost]
        //public HttpResponseMessage ApproveSalesShipmentDocNegative([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/SalesShipmentDocNegative/Approve");
        //    log.Info("审核销售出库单红字传入值：" + JsonData);
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<ICSSalesShipmentDocNegative> infos = new List<ICSSalesShipmentDocNegative>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDocNegative>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                SalesShipmentDocNegative action = new SalesShipmentDocNegative();
        //                string resultStr = action.Approve(infos);
        //                if (string.IsNullOrWhiteSpace(resultStr))
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                }
        //                else
        //                {
        //                    res.Success = false;
        //                    res.Message = resultStr;
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("审核销售出库单红字返回值：" + str);
        //    return result;
        //}
        /// <summary>
        /// 删除销售出库单红字
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesShipmentDocNegative/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteSalesShipmentDocNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesShipmentDocNegative/Delete");
            log.Info("删除销售出库单红字传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesShipmentDocNegative> infos = new List<ICSSalesShipmentDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesShipmentDocNegative action = new SalesShipmentDocNegative();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除销售出库单红字返回值：" + str);
            return result;
        }

        #endregion
        #region 销售订单

        /// <summary>
        /// 获取销售订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesOrder/Get")]
        [HttpPost]
        public HttpResponseMessage GetSalesOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesOrder/Get");
            log.Info("获取销售订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesOrder> infos = new List<ICSSalesOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesOrder action = new SalesOrder();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取销售订单返回值：" + str);
            return result;
        }

        /// <summary>
        /// 创建销售订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesOrder/Create")]
        [HttpPost]
        public HttpResponseMessage CreateSalesOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesOrder/Create");
            log.Info("创建销售订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesOrder> infos = new List<ICSSalesOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesOrder action = new SalesOrder();
                        string resultStr = action.CerateSalesOrder(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建销售订单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 审核销售订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesOrder/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveSalesOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesOrder/Approve");
            log.Info("审核销售订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesOrder> infos = new List<ICSSalesOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesOrder action = new SalesOrder();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核销售订单返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除销售订单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesOrder/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteSalesOrder([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesOrder/Delete");
            log.Info("删除销售订单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesOrder> infos = new List<ICSSalesOrder>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesOrder>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesOrder action = new SalesOrder();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除销售订单返回值：" + str);
            return result;
        }

        #endregion
        #region 销售发货

        /// <summary>
        /// 获取销售发货
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesDeliveryNotice/Get")]
        [HttpPost]
        public HttpResponseMessage GetSalesDeliveryNotice([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesDeliveryNotice/Get");
            log.Info("获取销售发货传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesDeliveryNotice> infos = new List<ICSSalesDeliveryNotice>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesDeliveryNotice>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesDeliveryNotice action = new SalesDeliveryNotice();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取销售发货返回值：" + str);
            return result;
        }

        /// <summary>
        /// 创建销售发货
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesDeliveryNotice/Create")]
        [HttpPost]
        public HttpResponseMessage CreateSalesDeliveryNotice([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesDeliveryNotice/Create");
            log.Info("创建销售发货传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesDeliveryNotice> infos = new List<ICSSalesDeliveryNotice>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesDeliveryNotice>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesDeliveryNotice action = new SalesDeliveryNotice();
                        string resultStr = action.CerateSalesDeliveryNotice(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建销售发货返回值：" + str);
            return result;
        }
        /// <summary>
        /// 审核销售发货
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesDeliveryNotice/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveSalesDeliveryNotice([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesDeliveryNotice/Approve");
            log.Info("审核销售发货传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesDeliveryNotice> infos = new List<ICSSalesDeliveryNotice>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesDeliveryNotice>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesDeliveryNotice action = new SalesDeliveryNotice();
                        string resultStr = action.Approve(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核销售发货返回值：" + str);
            return result;
        }
        /// <summary>
        /// 删除销售发货
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesDeliveryNotice/Delete")]
        [HttpPost]
        public HttpResponseMessage DeleteSalesDeliveryNotice([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesDeliveryNotice/Delete");
            log.Info("删除销售发货传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesDeliveryNotice> infos = new List<ICSSalesDeliveryNotice>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesDeliveryNotice>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesDeliveryNotice action = new SalesDeliveryNotice();
                        string resultStr = action.Delete(infos);
                        if (string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("删除销售发货返回值：" + str);
            return result;
        }

        #endregion
        #region 销售退货
        /// <summary>
        /// 获取销售退货
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesReturnBack/Get")]
        [HttpPost]
        public HttpResponseMessage GetSalesReturnBack([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesReturnBack/Get");
            log.Info("获取销售退货传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesReturnBack> infos = new List<ICSSalesReturnBack>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesReturnBack>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        SalesReturnBack action = new SalesReturnBack();
                        string resultStr = action.Get(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("获取销售退货返回值：" + str);
            return result;
        }
        #endregion
        #region 调拨
        ///// <summary>
        ///// 审核拆卸单
        ///// </summary>
        ///// <param name="JsonData"></param>
        ///// <returns></returns>
        //[Route("api/OneStepTransferDocIn/Approve")]
        //[HttpPost]
        //public HttpResponseMessage TransferDoc([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/OneStepTransferDocIn/Approve");
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            log.Info("\r\n 审核拆卸单 JSON数据：" + JsonData + "\r\n");
        //            try
        //            {
        //                List<ICSTransferDoc> Bills = new List<ICSTransferDoc>();
        //                try
        //                {
        //                    Bills = JsonConvert.DeserializeObject<List<ICSTransferDoc>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                TransferDoc action = new TransferDoc();
        //                bool flag = action.ConfirmTrans(Bills);
        //                if (flag == false)
        //                {
        //                    res.Success = false;
        //                    res.Message = "接口调用失败！";
        //                }
        //                else
        //                {
        //                    res.Success = true;
        //                    res.Message = "接口调用成功！";
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
        //        log.Debug("返回值：" + str);
        //        return result;
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //        log.Debug("返回值：" + str);
        //        return result;
        //    }
        //}

        #endregion



        #region 齐套检验接口
        /// <summary>
        /// 齐套检验接口
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/Complete/Approve")]
        [HttpPost]
        public HttpResponseMessage CompleteCreate([FromBody] object JsonData)
        {
            log.Info("接口：api/ReturnDoc/Approve");
            log.Info("齐套检验接口传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                Appconfig.WriteLogFile(JsonData.ToString(), "查询齐套接口");
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        Complete infos = new Complete();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<Complete>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ISComplete action = new ISComplete();
                        ISComplete.QtyModel resultStr = action.ConfirmRd08(infos);
                        res.Success = true;
                        res.Message = "U9";
                        res.Data = resultStr;
                        //ISComplete action = new ISComplete();
                        //string resultStr = action.ConfirmRd08(infos);
                        //if (!string.IsNullOrWhiteSpace(resultStr))
                        //{
                        //    res.Success = true;
                        //    res.Message = "接口调用成功！";
                        //    res.Data = resultStr;
                        //}
                        //else
                        //{
                        //    res.Success = false;
                        //    res.Data = resultStr;
                        //}
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
                str = JsonConvert.SerializeObject(res);
                Appconfig.WriteLogFile(str, "查询齐套接口");
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("返回值：" + str);
                return result;
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
                str = JsonConvert.SerializeObject(res);
                Appconfig.WriteLogFile(str, "查询齐套接口");
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("齐套检验返回值：" + str);
                return result;
            }
        }
        #endregion




        #region U9入库单相关

        #region 创建标准收货单（采购入库）
        [Route("api/PurchaseReceiveDocPOArrive/Create")]
        [HttpPost]
        public HttpResponseMessage CreateRCV([FromBody] object JsonData)
        {
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "采购上架-采购到货单");
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();

                infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());

                CustCreateBFRcvSrvSubForApi action = new CustCreateBFRcvSrvSubForApi();
                res = action.CustCreateCGDHRCVForApi(infos, "采购上架-采购到货单");
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            DBHelper.WriteLogFile("返回报文：" + str, "采购上架-采购到货单");
            return result;
        }
        #endregion



        #region 创建标准收货单（采购入库）
        [Route("api/PurchaseReceiveDoc/Create")]
        [HttpPost]
        public HttpResponseMessage CreateRCVpo([FromBody] object JsonData)
        {
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "采购上架-采购订单");

            HttpResponseMessage result = new HttpResponseMessage();

            Result res = new Result();
            try
            {
                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();

                infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());

                CustCreateBFRcvSrvSubForApi action = new CustCreateBFRcvSrvSubForApi();
                res = action.CustCreateBFRCVForApi(infos, "采购上架-采购订单");
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "采购上架-采购订单");
            return result;
        }
        #endregion


        #region 创建标准收货单（采购入库）
        [Route("api/PurchaseReceiveDocForApiBatch/Create")]
        [HttpPost]
        public HttpResponseMessage CreateRCVByPOBatchApi([FromBody] object JsonData)
        {
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "采购上架-采购订单(退补退扣)");

            HttpResponseMessage result = new HttpResponseMessage();

            Result res = new Result();
            try
            {
                List<CreateRcvByPoBatchForApiModel> infos = new List<CreateRcvByPoBatchForApiModel>();

                infos = JsonConvert.DeserializeObject<List<CreateRcvByPoBatchForApiModel>>(JsonData.ToString());

                CreateRcvByPoBatchForApiSrv action = new CreateRcvByPoBatchForApiSrv();
                res = action.Action(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "采购上架-采购订单(退补退扣)");
            return result;
        }
        #endregion


        #region 审核入库单（采购退货）
        [Route("api/PurchaseReceiveDoctNegative/Approve")]
        [HttpPost]
        public HttpResponseMessage ApprovePurchaseReceiveDoctNegative([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "采购退货-红字采购入库单");

                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();

                infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());

                ApproveRCV action = new ApproveRCV();
                res = action.Approve(infos);

            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "采购退货-红字采购入库单");
            return result;
        }
        #endregion
        #region 创建入库单（采购退货）
        [Route("api/PurchaseReceiveDoctNegative/Create")]
        [HttpPost]
        public HttpResponseMessage CreatePurchaseReceiveDoctNegative([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "采购退货-采购退货单");


                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
                infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());

                #region 调用接口前判断单据是退货单还是退货申请
                ApproveRCV actionApprove = new ApproveRCV();
                string DocKind = actionApprove.CheckERPRcvOrRtn(infos[0].DNRTCode, infos[0].WorkPoint);
                #endregion
                if (DocKind == "退货单")
                {
                    res = actionApprove.Approve(infos);
                }
                else
                {
                    CreateRtnToRCV action = new CreateRtnToRCV();
                    res = action.CustCreateRtnToRcv(infos, "采购");
                }
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "采购退货-采购退货单");
            return result;
        }
        #endregion
        #region 创建入库单（采购退货/委外退货）
        [Route("api/ReceiveDoctNegative/Create")]
        [HttpPost]
        public HttpResponseMessage CreateReceiveDoctNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/ReceiveDoctNegative/Create");
            log.Info("创建入库（退货）单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<rCVhead> infos = new List<rCVhead>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<rCVhead>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());

                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        CreateRCV action = new CreateRCV();
                        ICS.CreateCreateRcvRestNEW.ReturnValue resultInfo = action.CustCreatePR(infos);
                        if (resultInfo != null)
                        {
                            res.Success = resultInfo.IsSuccess;
                            res.Message = resultInfo.Message;
                            res.Data = resultInfo.Data;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建入库（退货）单返回值：" + str);
            return result;
        }
        #endregion
        #region 销售退货（审核入库单/根据退回处理单创建并审核入库单/根据退回申请单创建并审核入库单）
        [Route("api/SalesShipmentDocNegative/Create")]
        [HttpPost]
        public HttpResponseMessage CreateSalesShipmentDocNegative([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "销售退货-销售退货单");

                List<ICSSalesShipmentDocNegative> infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDocNegative>>(JsonData.ToString());

                ApproveRCV action = new ApproveRCV();
                res = action.ActionCreateRMAToRCV(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }


            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "销售退货-销售退货单");

            return result;
        }
        #endregion
        #region 创建完工报告（成品入库）
        [Route("api/ManufactureReceiveDoc/Create")]
        [HttpPost]
        public HttpResponseMessage CreateManufactureReceiveDoc([FromBody] object JsonData)
        {
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "产成品入库-生产订单");

            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            try
            {
                List<ICSManufactureReceiveDoc> infos = JsonConvert.DeserializeObject<List<ICSManufactureReceiveDoc>>(JsonData.ToString());
                CreateCompRpt action = new CreateCompRpt();
                res = action.Create(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "产成品入库-生产订单");

            return result;
        }
        #endregion


        #region 完工申报创建成品入库
        [Route("api/CompleteReport/Create")]
        [HttpPost]
        public HttpResponseMessage CreateCompleteReport([FromBody] object JsonData)
        {
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "产成品入库-完工申报");

            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            try
            {
                List<ICSManufactureReceiveDocComRcvRpt> infos = JsonConvert.DeserializeObject<List<ICSManufactureReceiveDocComRcvRpt>>(JsonData.ToString());
                CreateCompRpt action = new CreateCompRpt();
                res = action.CreateRcvRptByCompleteApplyDoc(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "产成品入库-完工申报");

            return result;
        }
        #endregion


        #region 审核杂收单（其他入库）
        [Route("api/OtherInDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage APIConfirmRdrecord08([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "杂收");

            try
            {
                List<ICSOtherInDoc> Bills = JsonConvert.DeserializeObject<List<ICSOtherInDoc>>(JsonData.ToString());

                ApproveMiscRcv action = new ApproveMiscRcv();
                res = action.Approve(Bills);

            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");


            DBHelper.WriteLogFile("返回报文：" + str, "杂收");
            return result;

        }
        #endregion
        #endregion


        #region U9领料相关

        #region 生产领料单（修改并审核生产领料单/根据领料申请单创建材料出库单）
        [Route("api/MOIssueDocByPU/Create")]
        [HttpPost]
        public HttpResponseMessage ApproveIssue([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "材料出库-领料申请单");

                List<ICSRdrecord11> infos = JsonConvert.DeserializeObject<List<ICSRdrecord11>>(JsonData.ToString());

                ModifyIssue action = new ModifyIssue();


                res = action.ActionCreateMaterialDelivery(infos);

                //CreateMaterialDelivery createaction = new CreateMaterialDelivery();
                //#region 先调用判断方法来确认U9单据是生产领料单还是领料申请单
                //string DocKind = action.CheckERPDocKind(infos[0].SourceCode, infos[0].WorkPoint);
                //#endregion
                //if (DocKind == "生产领料单")
                //{
                //    bool approveresult = action.ActionModifyIssue(infos);
                //    if (approveresult == true)
                //    {
                //        res.Success = true;
                //        res.Message = "接口调用成功！";
                //    }
                //    else
                //    {
                //        res.Success = false;
                //        res.Message = "接口调用失败";
                //    }
                //}
                //else
                //{

                //}

            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "材料出库-领料申请单");

            return result;
        }

        ///  生产领料（无备料领料，创建领料单的同时创建备料单）
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreateMOPickList/Create")]
        [HttpPost]
        public HttpResponseMessage CreateMOPickList(List<CustCreateAboveIssue.IssueWithOutPickListData> modellist)
        {
            //string  SODonNo = DateTime.Now.Year.ToString().Substring(2) + "0476"; ;
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.CreateAboveIssue.CustCreateAboveIssue.OperationResultForNoSrc res = new UFIDA.ISV.CreateAboveIssue.CustCreateAboveIssue.OperationResultForNoSrc();
            try
            {
                try
                {
                    str = JsonConvert.SerializeObject(modellist);
                    log.Info("接口：api/CreateMOPickList/Create");
                    log.Info("无备料领料接口传入值：" + str);
                    CustCreateAboveIssue action = new CustCreateAboveIssue();
                    res = action.CreateIssueWithOutPickList(modellist);
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.Success = false;
                }
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }

        [Route("api/U9MOIssueDocByPU/Create")]
        [HttpPost]
        public HttpResponseMessage ApproveU9Issue([FromBody] object JsonData)
        {
            log.Info("接口：api/U9MOIssueDocByPU/Create");
            log.Info("审核入库单传入值：" + JsonData);
            Appconfig.WriteLogFile(JsonData.ToString(), "审核超额领料单");

            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSRdrecord11> infos = new List<ICSRdrecord11>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSRdrecord11>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        List<string> DocList = new List<string>();
                        foreach (var item in infos)
                        {
                            DocList.Add(item.SourceCode);
                        }
                        ApproveIssue approve = new ApproveIssue();
                        bool ApproveResult = approve.Approve(DocList, infos[0].WorkPoint);

                        if (ApproveResult == true)
                        {
                            res.Success = true;
                            res.Message = "审核超额领料单成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "审核超额领料单失败";
                        }

                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核生产领料单返回值：" + str);
            Appconfig.WriteLogFile(str, "审核超额领料单");

            return result;
        }
        #endregion

        #region 创建生产退料单(分根据生产备料单创建材料入库单与根据领料申请单创建材料入库单与生产领料单创建材料入库单)
        [Route("api/MOIssueDocNegative/Create")]
        [HttpPost]
        public HttpResponseMessage CreateRecedeIssue(object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result rtnres = new Result();
            string str = "";
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "材料入库-工单备料（领料申请）");

                if (JsonData.ToString().Contains("领料申请单"))
                {
                    List<CreateMaterialDeliveryDocByMoIssueApplyModel> d = JsonConvert.DeserializeObject<List<CreateMaterialDeliveryDocByMoIssueApplyModel>>(JsonData.ToString());
                    CreateMaterialDeliveryDocByMoIssueApplySrv action = new CreateMaterialDeliveryDocByMoIssueApplySrv();
                    rtnres = action.Action(d);
                }
                else if (JsonData.ToString().Contains("生产订单"))
                {
                    List<IssueData> d = JsonConvert.DeserializeObject<List<IssueData>>(JsonData.ToString());
                    CreateMaterialDeliveryDocByMoPickSrv action = new CreateMaterialDeliveryDocByMoPickSrv();
                    rtnres = action.Action(d);
                }
                else
                {
                    //List<CreateMaterialDeliveryDocByMoIssueApplyRtnModel> d = JsonConvert.DeserializeObject<List<CreateMaterialDeliveryDocByMoIssueApplyRtnModel>>(JsonData.ToString());
                    //CreateMaterialDeliveryDocByMoIssueApplyRtnSrv action = new CreateMaterialDeliveryDocByMoIssueApplyRtnSrv();
                    //rtnres = action.Action(d);

                    List<IssueData> d = JsonConvert.DeserializeObject<List<IssueData>>(JsonData.ToString());
                    CustCreateIssue action = new CustCreateIssue();
                    rtnres = action.CreateIssue(d);
                }
            }
            catch (Exception ex)
            {
                rtnres.Message = ex.Message;
                rtnres.Success = false;
            }

            str = JsonConvert.SerializeObject(rtnres);
            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "材料入库-工单备料（领料申请）");
            return result;
        }
        #endregion

        #endregion


        #region U9出库相关

        #region 审核标准出货单（销售出库）(创建接口用作审核，已被注释,维卓上线需要新增审核接口)
        [Route("api/SalesShipmentDoc/Save")]
        [HttpPost]
        public HttpResponseMessage SaveSalesShipmentDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesShipmentDoc/Save");
            log.Info("审核销售出库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesShipmentDoc> infos = new List<ICSSalesShipmentDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ApproveShipment action = new ApproveShipment();
                        bool ApproveResult = action.Approve(infos);
                        if (ApproveResult == true)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核销售出库单返回值：" + str);
            return result;
        }
        #endregion

        #region 创建销售出库单
        /// <summary>
        /// 创建销售出库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesShipmentDoc/Create")]
        [HttpPost]
        public HttpResponseMessage CreateSalesShipmentDoc([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "销售发货-销售发货单");

                List<ICSSalesShipmentDoc> infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDoc>>(JsonData.ToString());

                CreateShipmentByShipPlan action = new CreateShipmentByShipPlan();
                res = action.CreateShipmentByShipPlanAPI(infos);

            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "销售发货-销售发货单");
            return result;
        }

        #endregion

        #region 创建标准出货单
        /// 创建标准出货单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/SalesShipDoc/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateOutShip([FromBody] object ListJson)
        {
            log.Info("接口：api/SalesShipDoc/Create");
            log.Info("创建销售出库单传入值：" + ListJson);
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            List<UFIDA.ISV.CreateBFStandardShip.rtnRcvInfo> res = new List<UFIDA.ISV.CreateBFStandardShip.rtnRcvInfo>();
            UFIDA.ISV.CreateBFStandardShip.rtnRcvInfo ress = new UFIDA.ISV.CreateBFStandardShip.rtnRcvInfo();

            CreateSMShipOperationResult _result = new CreateSMShipOperationResult();
            try
            {
                Appconfig.WriteLogFile(ListJson.ToString(), "创建标准出货单传入日志");

                List<ICSSoft.Entity.SMShip> SMShipList = JsonConvert.DeserializeObject<List<ICSSoft.Entity.SMShip>>(ListJson.ToString());
                if (SMShipList == null)
                {
                    _result.Message = "请传入信息";
                    _result.Success = false;
                    str = JsonConvert.SerializeObject(_result);
                    result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                    Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");
                    return result;
                }
                List<SMShip> _SOFileList = new List<SMShip>();
                if (SMShipList != null && SMShipList.Count > 0)
                {
                    foreach (var d in SMShipList)
                    {
                        //if (string.IsNullOrEmpty(d.ItemCode))
                        //{
                        //string SrcID = Appconfig.GetSOLineID(d.SDNCode, d.Sequence, d.SrcDocSubLineNo);
                        string SrcID = Appconfig.GetSOLineID(d.SDNCode, d.SrcDocSubLineNo);

                        string OrgID = Appconfig.GetOrgID(d.SDNCode, d.SrcDocSubLineNo);
                        SMShip model = new SMShip();
                        if (!string.IsNullOrEmpty(Appconfig.GetSmshipTYPE(d.ShipDocTypeCode, OrgID)))
                        {
                            model.ShipDocTypeID = Appconfig.GetSmshipTYPE(d.ShipDocTypeCode, OrgID);
                            model.ShipDocTypeCode = d.ShipDocTypeCode;
                        }
                        else
                        {
                            model.ShipDocTypeCode = "";
                            model.ShipDocTypeID = "0";
                        }
                        model.CurShipQty1 = d.Quantity;
                        model.CurShipQty2 = d.CurShipQty2;
                        model.DocStatus = 2;// d.DocStatus;
                        model.Locations = new List<Location>();
                        model.OptionalSplitTerm = new OptionalSplitTerm[] { };
                        model.ShipDate = d.ShipDate;
                        model.ShipMemo = d.ShipMemo;
                        model.SOIsConsign = d.SOIsConsign;
                        model.FinallyPriceTC = d.FinallyPriceTC;
                        model.SrcDocSubLineNo = d.SrcDocSubLineNo;

                        //if (d.DescFlexField != null)
                        //{
                        model.DescFlexField = new SHPurDS();
                        //model.DescFlexField.PubDescSeg1 = d.DescFlexField.PubDescSeg1;
                        //model.DescFlexField.PubDescSeg2 = d.DescFlexField.PubDescSeg2;
                        //model.DescFlexField.PubDescSeg3 = d.DescFlexField.PubDescSeg3;
                        //model.DescFlexField.PubDescSeg4 = d.DescFlexField.PubDescSeg4;
                        //model.DescFlexField.PubDescSeg5 = d.DescFlexField.PubDescSeg5;
                        //model.DescFlexField.PubDescSeg6 = d.DescFlexField.PubDescSeg6;
                        //model.DescFlexField.PubDescSeg7 = d.DescFlexField.PubDescSeg7;
                        //model.DescFlexField.PubDescSeg8 = d.DescFlexField.PubDescSeg8;
                        //model.DescFlexField.PubDescSeg9 = d.DescFlexField.PubDescSeg9;
                        //model.DescFlexField.PubDescSeg10 = d.DescFlexField.PubDescSeg10;
                        //model.DescFlexField.PrivateDescSeg1 = d.DescFlexField.PrivateDescSeg1;
                        //model.DescFlexField.PrivateDescSeg2 = d.DescFlexField.PrivateDescSeg2;
                        //model.DescFlexField.PrivateDescSeg3 = d.DescFlexField.PrivateDescSeg3;
                        //model.DescFlexField.PrivateDescSeg4 = d.DescFlexField.PrivateDescSeg4;
                        //model.DescFlexField.PrivateDescSeg5 = d.DescFlexField.PrivateDescSeg5;
                        //model.DescFlexField.PrivateDescSeg6 = d.DescFlexField.PrivateDescSeg6;
                        //model.DescFlexField.PrivateDescSeg7 = d.DescFlexField.PrivateDescSeg7;
                        //model.DescFlexField.PrivateDescSeg8 = d.DescFlexField.PrivateDescSeg8;
                        //model.DescFlexField.PrivateDescSeg9 = d.DescFlexField.PrivateDescSeg9;
                        //model.DescFlexField.PrivateDescSeg10 = d.DescFlexField.PrivateDescSeg10;

                        model.DescFlexField.PubDescSeg1 = d.PubDescSeg1;
                        model.DescFlexField.PubDescSeg2 = d.PubDescSeg2;
                        model.DescFlexField.PubDescSeg3 = d.PubDescSeg3;
                        model.DescFlexField.PubDescSeg4 = d.PubDescSeg4;
                        model.DescFlexField.PubDescSeg5 = d.PubDescSeg5;
                        model.DescFlexField.PubDescSeg6 = d.PubDescSeg6;
                        model.DescFlexField.PubDescSeg7 = d.PubDescSeg7;
                        model.DescFlexField.PubDescSeg8 = d.PubDescSeg8;
                        model.DescFlexField.PubDescSeg9 = d.PubDescSeg9;
                        model.DescFlexField.PubDescSeg10 = d.PubDescSeg10;
                        model.DescFlexField.PrivateDescSeg1 = d.PrivateDescSeg1;
                        model.DescFlexField.PrivateDescSeg2 = d.PrivateDescSeg2;
                        model.DescFlexField.PrivateDescSeg3 = d.PrivateDescSeg3;
                        model.DescFlexField.PrivateDescSeg4 = d.PrivateDescSeg4;
                        model.DescFlexField.PrivateDescSeg5 = d.PrivateDescSeg5;
                        model.DescFlexField.PrivateDescSeg6 = d.PrivateDescSeg6;
                        model.DescFlexField.PrivateDescSeg7 = d.PrivateDescSeg7;
                        model.DescFlexField.PrivateDescSeg8 = d.PrivateDescSeg8;
                        model.DescFlexField.PrivateDescSeg9 = d.PrivateDescSeg9;
                        model.DescFlexField.PrivateDescSeg10 = d.PrivateDescSeg10;
                        //}

                        DataTable sodt = Appconfig.GetSO(d.SDNCode);
                        if (sodt != null && sodt.Rows.Count > 0)
                        {
                            model.LineDescFlexField = new SHLinePurDS();
                            model.LineDescFlexField.PubDescSeg2 = sodt.Rows[0][0].ToString();
                            model.LineDescFlexField.PubDescSeg3 = sodt.Rows[0][1].ToString();
                        }

                        if (!string.IsNullOrWhiteSpace(SrcID))
                        {
                            model.SrcDocLineID = long.Parse(SrcID);
                        }
                        else
                        {
                            _result.Message = "传入销售订单信息有误，请核对";
                            _result.Success = false;
                            str = JsonConvert.SerializeObject(_result);
                            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                            Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");
                            return result;
                        }
                        model.SrcDocSubLineNo = 10;
                        model.SrcDocNo = d.SDNCode;
                        model.SrcDocLineNo = d.SrcDocSubLineNo;

                        model.SrcDocType = 1;
                        string WHID = Appconfig.GetWhIDByCode(d.WHCode, OrgID);
                        model.WH = WHID;
                        bool IsLot = Appconfig.GetWhLotControl(d.WHCode, OrgID);
                        if (IsLot == true)
                        {
                            model.LotCode = d.BatchCode;
                        }
                        else
                        {
                            model.LotCode = "";
                        }
                        //model.LotCode = d.LotCode;
                        _SOFileList.Add(model);
                        //}
                    }
                    str = JsonConvert.SerializeObject(_SOFileList);

                    string url = "http://{2}/u9c/webapi/OAuth2/GetAuthorizeCode?clientid={0}&clientsecret={1}";
                    url = string.Format(url, ConfigurationManager.AppSettings["clientid"].ToString(), ConfigurationManager.AppSettings["clientsecret"].ToString(), ConfigurationManager.AppSettings["U9IP"].ToString());
                    string resultuu = PostData.GetInfo("", url);

                    JObject objuu = new JObject();
                    objuu = JObject.Parse(resultuu);

                    string keyCode = objuu["Data"].ToString();
                    if (!string.IsNullOrWhiteSpace(keyCode))
                    {
                        string ToeknUrl = "http://{4}/u9c/webapi/OAuth2/Login?userCode={0}&entcode={1}&orgcode={2}&code={3}";
                        ToeknUrl = string.Format(ToeknUrl, ConfigurationManager.AppSettings["userCode"].ToString(), ConfigurationManager.AppSettings["enterpriseID"].ToString(), ConfigurationManager.AppSettings["orgCode"].ToString(), keyCode, ConfigurationManager.AppSettings["U9IP"].ToString());
                        string resultToken = PostData.GetInfo("", ToeknUrl);

                        JObject objToken = new JObject();
                        objuu = JObject.Parse(resultToken);
                        string TokenCode = objuu["Data"].ToString();
                        if (!string.IsNullOrWhiteSpace(TokenCode))
                        {
                            string CreatePOUrl = "http://{0}/u9c/webapi/Ship/CreateBySrcDoc";
                            CreatePOUrl = string.Format(CreatePOUrl, ConfigurationManager.AppSettings["U9IP"].ToString());

                            //_SOFileList.Add(model);// = model;
                            string postData = JsonConvert.SerializeObject(_SOFileList);

                            Appconfig.WriteLogFile(postData.ToString(), "创建标准出货单传入日志");

                            string resultCreateSoFile = PostData.APT(CreatePOUrl, postData, TokenCode);
                            bool IsSucess = false;

                            if (objuu["ResCode"].ToString() != "0")
                            {
                                IsSucess = false;
                            }
                            else
                            {
                                IsSucess = true;
                                JObject objTokennew = new JObject();
                                objTokennew = JObject.Parse(resultCreateSoFile);
                                if (objTokennew["ResCode"].ToString().Contains("502"))
                                {
                                    _result.Data = "";
                                    _result.Message = resultCreateSoFile;
                                    _result.Success = false;
                                    str = JsonConvert.SerializeObject(_result);
                                    result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

                                    Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");

                                    return result;
                                }
                                else
                                {
                                    if (objTokennew["Success"].ToString() == "True")
                                    {
                                        IsSucess = true;
                                    }
                                }
                                Appconfig.WriteLogFile(objTokennew.ToString(), "创建标准出货单传入日志");

                                foreach (JObject item in objTokennew["Data"])
                                {
                                    //string ccode = item["m_code"].ToString();
                                    string m_errorMsg = item["m_errorMsg"].ToString();

                                    if (!string.IsNullOrWhiteSpace(m_errorMsg))
                                    {
                                        _result.Data = "";
                                        _result.Message = m_errorMsg;
                                        _result.Success = false;
                                        str = JsonConvert.SerializeObject(_result);
                                        result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

                                        Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");

                                        return result;
                                    }
                                    //if (!string.IsNullOrWhiteSpace(ccode))
                                    //{

                                    //Appconfig.WriteLogFile(ccode, "创建标准出货单传入日志");

                                    //ApproveShip aship = new ApproveShip();
                                    //AppShipReturnModel po = aship.Approve(ccode);
                                    //if (!po.IsSuccess)
                                    //    throw new Exception("单据：" + ccode + "审核错误，错误提示：" + po.Message + "！");
                                    //}
                                }
                            }
                            _result.Data = "";
                            _result.Message = resultCreateSoFile;
                            _result.Success = IsSucess;
                            str = JsonConvert.SerializeObject(_result);
                            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

                            Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");

                            return result;
                        }
                        else
                        {
                            string returnMessage = objuu["ResMsg"].ToString();
                            _result.Message = objuu["ResMsg"].ToString();
                            _result.Success = false;
                            _result.Data = "";
                            str = JsonConvert.SerializeObject(_result);
                            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

                            Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");

                            return result;
                        }
                    }
                    else
                    {
                        _result.Message = "获取授权码为空";
                        _result.Success = false;
                        _result.Data = "";
                        str = JsonConvert.SerializeObject(_result);
                        result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

                        Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");
                        return result;
                    }
                }
                str = JsonConvert.SerializeObject(_result);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

                Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");

                return result;
            }
            catch (Exception ex)
            {
                _result.Message = ex.ToString();
                _result.Success = false;
                _result.Data = "";
                str = JsonConvert.SerializeObject(_result);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                Appconfig.WriteLogFile(str.ToString(), "创建标准出货单传入日志");

                return result;
            }

        }

        #endregion

        #region 审核杂发单（其他出库）
        [Route("api/OtherOutDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage APIConfirmRdrecord09([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "杂发");

                List<ICSOtherOutDoc> Bills = JsonConvert.DeserializeObject<List<ICSOtherOutDoc>>(JsonData.ToString());

                ApproveMiscShip action = new ApproveMiscShip();
                res = action.Approve(Bills);

            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
            DBHelper.WriteLogFile("返回报文：" + str, "杂发");

            return result;

        }
        #endregion

        #endregion


        #region U9库内作业

        #region 无源头生成调拨单
        /// 无源头生成调拨单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OneStepNoTransferDocIn/Create")]
        [HttpPost]
        public HttpResponseMessage TransferDocNOIn([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "无源头调拨");

            try
            {
                List<ICSTransfer> Bills = JsonConvert.DeserializeObject<List<ICSTransfer>>(JsonData.ToString());

                CustCreateTransferINForJOB action = new CustCreateTransferINForJOB();
                res = action.NOConfirmTransIN(Bills);

            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "无源头调拨");
            return result;

        }

        #endregion

        #region 审核调入单（一步调入）
        [Route("api/OneStepTransferDocIn/Approve")]
        [HttpPost]
        public HttpResponseMessage TransferDoc([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData, "一步调入");

                List<ICSTransferDoc> Bills = JsonConvert.DeserializeObject<List<ICSTransferDoc>>(JsonData.ToString());

                ApproveTransferIN action = new ApproveTransferIN();
                res = action.Approve(Bills);

            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "一步调入");

            return result;
        }
        #endregion

        #region 形态转换单
        /// <summary>
        /// 形态转换单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MorphologicalTransformationDoc/Create")]
        [HttpPost]
        public HttpResponseMessage MorphologicalTransformationDocCreate([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "形态转换单");

                List<ICSAssemVouch> infos = JsonConvert.DeserializeObject<List<ICSAssemVouch>>(JsonData.ToString());

                CustCreateBFFormTransferSrvSub action = new CustCreateBFFormTransferSrvSub();
                res = action.CustCreateBFFormTransfer(infos);
            }
            catch (Exception ex)
            {

                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "形态转换单");

            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            return result;

        }

        /// <summary>
        /// 形态转换单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MorphologicalTransformationToFreezeDoc/Create")]
        [HttpPost]
        public HttpResponseMessage MorphologicalTransformationToFreezeDocCreate([FromBody] object JsonData)
        {

            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "形态转换单");

                List<ICSAssemVouch> infos = JsonConvert.DeserializeObject<List<ICSAssemVouch>>(JsonData.ToString());

                CustCreateBFFormTransferSrvSub action = new CustCreateBFFormTransferSrvSub();
                res = action.CustCreateTransferFormForFreeze(infos);
            }
            catch (Exception ex)
            {

                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "形态转换单");

            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            return result;
        }
        #endregion

        #endregion

        #region 创建标准收货单
        ///  创建标准收货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreatePOArrive/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateRCV([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();

            Result res = new Result();

            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "采购到货");

                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();

                infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
                CustCreateBFRcvSrvSubForApi srv = new CustCreateBFRcvSrvSubForApi();
                res = srv.CustCreateBFRCVForApi(infos, "采购到货");

            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
            }

            string str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "采购到货");

            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
            return result;
        }
        #endregion


        #region 创建杂收单
        /// 创建杂收单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/OtherInDoc/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateMiscRcv(List<CustCreateBFMiscRcv.rCVhead> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            //ICS.CreateBFMiscRcv.rtnRcvInfo res = new ICS.CreateBFMiscRcv.rtnRcvInfo();
            ICS.CreateBFMiscRcv.rtnRcvInfo res = new ICS.CreateBFMiscRcv.rtnRcvInfo();

            try
            {

                try
                {
                    str = JsonConvert.SerializeObject(d);
                    Appconfig.WriteLogFile(str.ToString(), "创建杂收单传入参数");
                    CustCreateBFMiscRcv action = new CustCreateBFMiscRcv();
                    res = action.CreateBFMisRcv(d);
                    //foreach (var item in action.CreateBFMisRcv(d))
                    //{
                    //    res = item;
                    //}
                    //res = action.CreateBFMisRcv(d);
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);
                Appconfig.WriteLogFile(str, "创建杂收单返回");
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }

        #endregion

        #region 创建杂发单
        /// 创建杂发单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/OtherOutDoc/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateMisShip(List<CustCreateBFMisShipSrvSub.rCVhead> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.CreateBFMisShip.rtnRcvInfo res = new UFIDA.ISV.CreateBFMisShip.rtnRcvInfo();
            //List<UFIDA.ISV.CreateBFMisShip.rtnRcvInfo> resList = new List<UFIDA.ISV.CreateBFMisShip.rtnRcvInfo>();
            //UFIDA.ISV.CreateBFMisShip.rtnRcvInfo resList = new UFIDA.ISV.CreateBFMisShip.rtnRcvInfo();

            try
            {

                try
                {
                    str = JsonConvert.SerializeObject(d);
                    Appconfig.WriteLogFile(str.ToString(), "创建杂发单");
                    CustCreateBFMisShipSrvSub action = new CustCreateBFMisShipSrvSub();
                    res = action.CustCreateBFMisShip(d);
                    //foreach (var item in action.CustCreateBFMisShip(d))
                    //{
                    //    res= item;
                    //    resList.Add(item);
                    //}
                    //res = action.CustCreateBFMisShip(d);
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }
        #endregion

        #region 创建委外收货单
        /// 创建委外收货单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("DeliveryNotice/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateWWRCV(List<CustCreateBFRTNSrvSub.rCVhead> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.CreateBFRTN.rtnRcvInfo res = new UFIDA.ISV.CreateBFRTN.rtnRcvInfo();
            try
            {

                try
                {
                    str = JsonConvert.SerializeObject(d);
                    Appconfig.WriteLogFile(str.ToString(), "创建委外收货单");
                    CustCreateBFRTNSrvSub action = new CustCreateBFRTNSrvSub();
                    foreach (var item in action.CustCreateBFRTN(d))
                    {
                        res = item;
                    }
                    //res = action.CreateBFStandardShip(d); 
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.IsSuccess = false;
                }

                str = JsonConvert.SerializeObject(res);
                Appconfig.WriteLogFile(str, "创建委外收货单返回");
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.IsSuccess = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

                Appconfig.WriteLogFile(str, "创建委外收货单返回异常");

                return result;
            }
        }
        #endregion

        #region 创建生产领料单
        /// 创建生产领料单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("MOIssueDoc/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateIssue(List<IssueAboveData> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();

            try
            {
                string data = JsonConvert.SerializeObject(d);
                DBHelper.WriteLogFile("传入报文：" + data, "材料出库-备料表");
                CustCreateAboveIssue action = new CustCreateAboveIssue();
                res = action.CreateAboveIssue(d);
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
            }

            string str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "材料出库-备料表");

            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
            return result;

        }
        #endregion

        #region 创建超额领料单
        /// 创建超额领料单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/U9MOIssueDoc/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateIssueMore(List<UFIDA.ISV.CreateAboveIssueMore.CustCreateAboveIssue.IssueAboveData> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.CreateAboveIssueMore.CustCreateAboveIssue.OperationResult res = new UFIDA.ISV.CreateAboveIssueMore.CustCreateAboveIssue.OperationResult();
            try
            {
                try
                {
                    str = JsonConvert.SerializeObject(d);
                    Appconfig.WriteLogFile(str.ToString(), "创建超额生产领料单");
                    UFIDA.ISV.CreateAboveIssueMore.CustCreateAboveIssue action = new UFIDA.ISV.CreateAboveIssueMore.CustCreateAboveIssue();
                    res = action.CreateAboveIssue(d);
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);

                StringBuilder strlog = new StringBuilder();
                strlog.AppendLine("接口返回数据：" + str);
                strlog.AppendLine("*****************************************************");
                Appconfig.WriteLogFile(strlog.ToString(), "创建超额生产领料单");

                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

                StringBuilder strlog = new StringBuilder();
                strlog.AppendLine("接口返回数据：" + str);
                strlog.AppendLine("*****************************************************");
                Appconfig.WriteLogFile(strlog.ToString(), "创建超额生产领料单");

                return result;
            }
        }
        #endregion

        #region 创建生产退料单
        /// 创建生产退料单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/U9MOIssueDocNegative/Create")]
        //[Route("api/MOIssueDocNegative/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateRecedeIssue(List<IssueData> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            Result res = new Result();
            try
            {

                try
                {
                    str = JsonConvert.SerializeObject(d);
                    Appconfig.WriteLogFile(str.ToString(), "创建生产退料单");
                    CustCreateIssue action = new CustCreateIssue();
                    res = action.CreateIssue(d);
                    //res = action.CreateBFStandardShip(d); 
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");

                StringBuilder strlog = new StringBuilder();
                strlog.AppendLine("接口返回数据：" + str);
                strlog.AppendLine("*****************************************************");
                Appconfig.WriteLogFile(strlog.ToString(), "创建生产退料单");

                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                StringBuilder strlog = new StringBuilder();
                strlog.AppendLine("接口返回数据：" + str);
                strlog.AppendLine("*****************************************************");
                Appconfig.WriteLogFile(strlog.ToString(), "创建生产退料单异常");

                return result;
            }
        }
        #endregion


        #region 创建委外发料
        /// 创建委外发料
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/U9OutsourcingIssueDoc/Create")]
        //[Route("api/U9OutsourcingIssueDoc/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateSoSrvSub(List<PMIssueData> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.ATWCreatePMIssue.CustCreatePMIssue.OperationResult res = new UFIDA.ISV.ATWCreatePMIssue.CustCreatePMIssue.OperationResult();
            try
            {
                try
                {
                    str = JsonConvert.SerializeObject(d);
                    Appconfig.WriteLogFile(str.ToString(), "创建委外发料日志");
                    CustCreatePMIssue action = new CustCreatePMIssue();
                    res = action.CreatePMIssue(d);

                }
                catch (Exception ex)
                {
                    res.LLCode = null;
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.LLCode = null;
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }
        #endregion

        #region 创建委外发料
        /// 创建委外发料
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/OutsourcingIssueDoc/Create")]
        //[Route("api/OutsourcingIssueDoc/Create")]
        [HttpPost]
        public HttpResponseMessage APICreateOutSourcingIssue(List<PMIssueData> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.ATWCreatePMIssue.CustCreatePMIssue.OperationResult res = new UFIDA.ISV.ATWCreatePMIssue.CustCreatePMIssue.OperationResult();
            try
            {
                try
                {
                    str = JsonConvert.SerializeObject(d);
                    log.Info("接口：api/OutsourcingIssueDoc/Create");
                    log.Info("创建委外发料单传入值：" + str);
                    DBHelper.WriteLogFile(str.ToString(), "委外发料-备料表");
                    CustCreatePMIssue action = new CustCreatePMIssue();
                    res = action.CreatePMIssue(d);

                }
                catch (Exception ex)
                {
                    res.LLCode = null;
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);
                log.Debug("返回值：" + str);
                DBHelper.WriteLogFile("返回报文：" + str, "委外发料-备料表");
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.LLCode = null;
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }
        #endregion

        #region 创建非成套领料单
        /// 创建非成套领料单  
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        //[Route("api/MOIssueDoc/Create")]
        [Route("api/MOIssueDoc/Create")]
        [HttpPost]
        public HttpResponseMessage APIWWCreateIssue(List<IssueAboveData> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();


            try
            {
                string data = JsonConvert.SerializeObject(d);
                DBHelper.WriteLogFile("传入报文：" + data, "材料出库-备料表");
                CustCreateAboveIssue action = new CustCreateAboveIssue();
                res = action.CreateAboveIssue(d);
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
            }

            string str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "材料出库-备料表");

            result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
            return result;


        }
        #endregion

        #region 审核委外退货单
        /// <summary>
        /// 审核委外退货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReceiveDocNegative/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveOutsourcingReceiveDocNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/OutsourcingReceiveDocNegative/Approve");
            log.Info("审核委外采购入库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "委外入库-委外入库单");

                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CustBFRCVApprove action = new CustBFRCVApprove();
                        bool resultStr = action.Approve(infos);
                        if (resultStr == true)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核委外采购入库单返回值：" + str);

            DBHelper.WriteLogFile("返回报文：" + str, "委外入库-委外入库单");
            return result;
        }
        #endregion

        #region 审核委外退货
        ///// 审核委外退货
        ///// </summary>
        ///// <param name="d"></param>
        ///// <returns></returns>
        [Route("api/U9OutsourcingReceiveDocNegative/Approve")]
        //[Route("api/OutsourcingReceiveDocNegative/Approve")]
        [HttpPost]
        public HttpResponseMessage APICreatWWOUT([FromBody] object ListJson)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            //ICS.CreateCreateRcvRestNEW.ReturnValue res = new ICS.CreateCreateRcvRestNEW.ReturnValue();
            ApproveReturnValue res = new ApproveReturnValue();

            try
            {
                try
                {
                    Appconfig.WriteLogFile(ListJson.ToString(), "审核委外退货单");
                    List<ITEMREQDATA> List = JsonConvert.DeserializeObject<List<ITEMREQDATA>>(ListJson.ToString());
                    if (List != null && List.Count > 0)
                    {
                        foreach (var item in List)
                        {
                            string ORGID = "";
                            string ORGCode = item.WorkPoint;

                            ORGID = Appconfig.IsExistsCode(ORGCode, "Base_Organization");

                            UFIDA.ISV.BFRCVApprove.CustBFRCVApprove.ReturnValue1 TJ = CustBFRCVApprove.CustApproveRec(item.SourceCode, ORGCode, "审核");
                            if (TJ != null)
                            {
                                res.Message = TJ.Mes;
                                res.Success = TJ.IsSuccess;
                            }
                        }
                    }
                    //List<ITEMREQDATA> List = JsonConvert.DeserializeObject<List<ITEMREQDATA>>(ListJson.ToString());
                    //ICS.CreateCreateRcvRestNEW.CreateRCV newrcv = new ICS.CreateCreateRcvRestNEW.CreateRCV();
                    //res = newrcv.CustCreatePR(List);
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);

                StringBuilder strlog = new StringBuilder();
                strlog.AppendLine("接口返回数据：" + str);
                strlog.AppendLine("*****************************************************");
                Appconfig.WriteLogFile(strlog.ToString(), "创建委外退货单");


                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

                StringBuilder strlog = new StringBuilder();
                strlog.AppendLine("接口返回数据：" + str);
                strlog.AppendLine("*****************************************************");
                Appconfig.WriteLogFile(strlog.ToString(), "创建委外退货单异常");

                return result;
            }
        }
        #endregion

        #region 创建委外退料单
        /// 创建委外退料单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/OutsourcingIssueDoNegative/Create")]
        //[Route("api/OutsourcingIssueDoNegative/Create")]
        [HttpPost]
        public HttpResponseMessage APICreatPMRecede(List<CustCreateBFPMRecedeSrvSub.rCVhead> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.CreateBFPMRecede.rtnRcvInfo res = new UFIDA.ISV.CreateBFPMRecede.rtnRcvInfo();
            try
            {

                try
                {
                    str = JsonConvert.SerializeObject(d);
                    log.Info("接口：api/OutsourcingIssueDoNegative/Create");
                    log.Info("创建委外退料单传入值：" + str);
                    DBHelper.WriteLogFile("传入报文：" + str.ToString(), "委外退料-备料表");
                    CustCreateBFPMRecedeSrvSub action = new CustCreateBFPMRecedeSrvSub();
                    res = action.CustCreatePMRecede(d);
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);

                DBHelper.WriteLogFile("返回报文：" + str, "委外退料-备料表");
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }
        #endregion

        #region 创建委外退料单(东辉)
        /// 创建委外退料单(东辉)
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/U9OutsourcingIssueDoNegative/Create")]
        //[Route("api/OutsourcingIssueDoNegative/Create")]
        [HttpPost]
        public HttpResponseMessage APICreatBFPMRecede(List<CustCreateBFPMRecedeSrvSub.rCVhead> d)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.CreateBFPMRecede.rtnRcvInfo res = new UFIDA.ISV.CreateBFPMRecede.rtnRcvInfo();
            try
            {

                try
                {
                    str = JsonConvert.SerializeObject(d);
                    log.Info("接口：api/U9OutsourcingIssueDoNegative/Create");
                    log.Info("创建委外退料单传入值：" + str);
                    Appconfig.WriteLogFile(str.ToString(), "创建委外退料单");
                    CustCreateBFPMRecedeSrvSub action = new CustCreateBFPMRecedeSrvSub();
                    foreach (var item in action.CustCreateBFPMRecede(d))
                    {
                        res = item;
                    }
                    //res = action.CreateBFStandardShip(d); 
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                    res.Success = false;
                }

                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Success = false;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }
        #endregion

        #region 创建并审核U9联副产品入库单（基础版）
        /// <summary>
        /// 创建并审核U9联副产品入库单（基础版）
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        //[Route("api/ManufactureLFReceiveDoc/Create")]
        ////[Route("api/ManufactureLFReceiveDoc/Create")]
        //[HttpPost]
        //public HttpResponseMessage ManufactureLFReceiveDocCreate([FromBody] object JsonData)
        //{
        //    log.Info("接口：api/ManufactureLFReceiveDoc/Create");
        //    log.Info("创建联副成品入库单传入值：" + JsonData);

        //    DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "副产品入库-生产订单");

        //    string LFCPCompRptType = ConfigurationManager.AppSettings["LFCPCompRptType"]?.ToString();
        //    HttpResponseMessage result = new HttpResponseMessage();
        //    Result res = new Result();
        //    string str = string.Empty;
        //    try
        //    {
        //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
        //        {
        //            try
        //            {
        //                List<RcvRptInfo> infos = new List<RcvRptInfo>();
        //                List<FCPRcvRptInfo> fcpinfos = new List<FCPRcvRptInfo>();
        //                try
        //                {
        //                    infos = JsonConvert.DeserializeObject<List<RcvRptInfo>>(JsonData.ToString());
        //                    fcpinfos = JsonConvert.DeserializeObject<List<FCPRcvRptInfo>>(JsonData.ToString());
        //                }
        //                catch (Exception ex)
        //                {
        //                    log.Error("转换失败：" + ex.ToString());
        //                    res.Success = false;
        //                    res.Message = "JSON格式不正确！";
        //                }
        //                if (string.IsNullOrEmpty(LFCPCompRptType) || LFCPCompRptType == "0")
        //                {
        //                    CustCreateRcvRptSrv action = new CustCreateRcvRptSrv();
        //                    UFIDA.ISV.CreateRcvRpt.rtnRcvInfo resultStr = action.CustCreateRcvRpt(infos);
        //                    if (resultStr.IsSuccess)
        //                    {
        //                        res.Success = true;
        //                        res.Message = "接口调用成功！" + resultStr.DocNo;
        //                        res.Data = null;
        //                    }
        //                    else
        //                    {
        //                        res.Success = false;
        //                        res.Message = resultStr.Message;
        //                    }
        //                }
        //                else
        //                {
        //                    CreateCompRpt action = new CreateCompRpt();
        //                    string resultStr = action.CreateFCPCompleteRpt(fcpinfos);
        //                    if (!string.IsNullOrWhiteSpace(resultStr))
        //                    {
        //                        res.Success = true;
        //                        res.Message = "接口调用成功！";
        //                        res.Data = resultStr;
        //                    }
        //                    else
        //                    {
        //                        res.Success = false;
        //                        res.Message = resultStr;
        //                    }
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("调用后台失败：" + ex.ToString());
        //                res.Success = false;
        //                res.Message = ex.Message;
        //            }
        //        }
        //        else
        //        {
        //            res.Success = false;
        //            res.Message = "请传入参数";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("参数检验失败：" + ex.ToString());
        //        res.Success = false;
        //        res.Message = ex.Message;
        //    }
        //    finally
        //    {
        //        str = JsonConvert.SerializeObject(res);
        //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
        //    }
        //    log.Debug("创建联副产品入库单返回值：" + str);

        //    DBHelper.WriteLogFile("返回报文：" + str, "副产品入库-生产订单");

        //    return result;
        //}
        #endregion


        [Route("api/ManufactureReceiveDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage ManufactureLF([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "产成品入库-入库单（审核）");
                List<RcvRptApproveModel> infos = JsonConvert.DeserializeObject<List<RcvRptApproveModel>>(JsonData.ToString());

                CustRcvRptApprove rptapprove = new CustRcvRptApprove();
                res = rptapprove.CustApproveRcvRpt(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }

            DBHelper.WriteLogFile("返回报文：" + str, "产成品入库-入库单（审核）");
            return result;
        }


        #region 调入单
        /// 调入单
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [Route("api/U9OneStepTransferDocIn/Create")]
        //[Route("api/OneStepTransferDocIn/Create")]
        [HttpPost]
        public HttpResponseMessage CreateTranIN([FromBody] object ListJson)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            UFIDA.ISV.CreateTransferINForJOB.CustCreateTransferINForJOB.OperationResult res = new UFIDA.ISV.CreateTransferINForJOB.CustCreateTransferINForJOB.OperationResult();
            try
            {

                try
                {
                    Appconfig.WriteLogFile(ListJson.ToString(), "调入单");
                    List<UFIDA.ISV.CreateTransferINForJOB.CustCreateTransferINForJOB.TransferINHead> List = JsonConvert.DeserializeObject<List<UFIDA.ISV.CreateTransferINForJOB.CustCreateTransferINForJOB.TransferINHead>>(ListJson.ToString());
                    UFIDA.ISV.CreateTransferINForJOB.CustCreateTransferINForJOB tranin = new UFIDA.ISV.CreateTransferINForJOB.CustCreateTransferINForJOB();
                    res = tranin.CreateTransferINForJOB(List);
                }
                catch (Exception ex)
                {
                    res.Message = ex.Message;
                }

                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }
        #endregion


        [Route("api/GetU9DocType")]
        [HttpPost]
        public HttpResponseMessage U9DocType([FromBody] object ListJson)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            //Appconfig.OperationResult _result = new Appconfig.OperationResult();
            string ErrorMessage = string.Empty;
            DataTable dt = new DataTable();
            try
            {
                try
                {
                    Appconfig.DocTypeModel model = JsonConvert.DeserializeObject<Appconfig.DocTypeModel>(ListJson.ToString());
                    Appconfig.WriteLogFile(ListJson.ToString(), "获取U9单据类型");
                    dt = Appconfig.GetDocType(model.TypeName, model.OrgCode);
                }
                catch (Exception ex)
                {
                    ErrorMessage = ex.Message;
                }

                str = JsonConvert.SerializeObject(dt);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                str = JsonConvert.SerializeObject(dt);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }


        #region 获取U9信息（基础版）
        /// <summary>
        /// 获取U9信息（基础版）
        /// </summary>
        /// <param name="ListJson"></param>
        /// <returns></returns>

        [Route("api/GetU9Information")]
        [HttpPost]
        public HttpResponseMessage GetU9Information([FromBody] object ListJson)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            //Appconfig.OperationResult _result = new Appconfig.OperationResult();
            string ErrorMessage = string.Empty;
            DataTable dt = new DataTable();
            try
            {
                try
                {
                    Appconfig.DocTypeModel model = JsonConvert.DeserializeObject<Appconfig.DocTypeModel>(ListJson.ToString());
                    Appconfig.WriteLogFile(ListJson.ToString(), "获取U9单据类型");
                    dt = Appconfig.GetU9Information(model.TypeName, model.OrgCode);
                }
                catch (Exception ex)
                {
                    ErrorMessage = ex.Message;
                }

                str = JsonConvert.SerializeObject(dt);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                str = JsonConvert.SerializeObject(dt);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                return result;
            }
        }
        #endregion


        #region U9审核标准收货单
        /// <summary>
        /// U9审核标准收货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/PurchaseReceiveDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveRdRecord01([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "采购上架-采购入库单");

                List<ICSPurchaseReceiveDoc> infos = new List<ICSPurchaseReceiveDoc>();
                infos = JsonConvert.DeserializeObject<List<ICSPurchaseReceiveDoc>>(JsonData.ToString());

                ApproveRCV action = new ApproveRCV();
                res = action.Approve(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "采购上架-采购入库单");

            return result;
        }
        #endregion


        #region 审核材料出库(生产订单)
        /// <summary>
        /// 审核材料出库(生产订单)
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/MOIssueDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveMOIssueDoc([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "材料出库-材料出库单");

            try
            {
                List<ICSRdrecord11> infos = JsonConvert.DeserializeObject<List<ICSRdrecord11>>(JsonData.ToString());

                ApproveIssue approve = new ApproveIssue();
                res = approve.Approve(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");


            DBHelper.WriteLogFile("返回报文：" + str, "材料出库-材料出库单");

            return result;
        }
        #endregion

        #region 创建委外收货单（PDA需要先扫描到货--条码源头为委外送货单）
        /// <summary>
        /// 创建委外收货单（PDA需要先扫描到货--条码源头为委外送货单）
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReceiveDoc/Create")]
        [HttpPost]
        public HttpResponseMessage CreateOutsourcingReceiveDocPO([FromBody] object JsonData)
        {
            return new HttpResponseMessage();

            //    log.Info("接口：api/OutsourcingReceiveDoc/Create");
            //    log.Info("创建委外采购入(委外到货单)传入值：" + JsonData);
            //    HttpResponseMessage result = new HttpResponseMessage();
            //    List<ICS.CreateRCV.rtnRcvInfo> resultlist = new List<ICS.CreateRCV.rtnRcvInfo>();
            //    Result res = new Result();
            //    string str = string.Empty;
            //    string data = string.Empty;
            //    try
            //    {
            //        DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "委外入库-委外订单");

            //        if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
            //        {
            //            try
            //            {
            //                List<ICSOutsourcingReceiveDoc> infos = new List<ICSOutsourcingReceiveDoc>();
            //                try
            //                {
            //                    infos = JsonConvert.DeserializeObject<List<ICSOutsourcingReceiveDoc>>(JsonData.ToString());
            //                }
            //                catch (Exception ex)
            //                {
            //                    log.Error("转换失败：" + ex.ToString());

            //                    res.Success = false;
            //                    res.Message = "JSON格式不正确！";
            //                    throw new Exception(res.Message);
            //                }
            //                CustCreateBFRcvSrvSubForApi action = new CustCreateBFRcvSrvSubForApi();
            //                resultlist = action.CustCreateWWRCVForApi(infos);
            //                foreach (ICS.CreateRCV.rtnRcvInfo __result in resultlist)
            //                {
            //                    if (__result.IsSuccess)
            //                    {
            //                        res.Success = __result.IsSuccess;
            //                        data = JsonConvert.SerializeObject(__result.Data);
            //                    }
            //                    else
            //                    {
            //                        res.Success = __result.IsSuccess;
            //                    }
            //                    res.Message = __result.Message;
            //                    res.Data = data;
            //                }
            //            }
            //            catch (Exception ex)
            //            {
            //                log.Error("调用后台失败：" + ex.ToString());
            //                res.Success = false;
            //                res.Message = ex.Message;
            //            }
            //        }
            //        else
            //        {
            //            res.Success = false;
            //            res.Message = "请传入参数";
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        log.Error("参数检验失败：" + ex.ToString());
            //        res.Success = false;
            //        res.Message = ex.Message;
            //    }
            //    finally
            //    {
            //        str = JsonConvert.SerializeObject(res);
            //        result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            //    }
            //    log.Debug("创建委外采购入库单返回值：" + str);
            //    DBHelper.WriteLogFile("返回报文：" + str, "委外入库-委外订单");
            //    return result;
        }
        #endregion


        #region 创建委外收货单（PDA不扫描到货--条码源头为外协采购订单）
        /// <summary>
        /// 创建委外收货单（PDA不扫描到货--条码源头为外协采购订单）
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OutsourcingReceiveDocPOArrive/Create")]
        [HttpPost]
        public HttpResponseMessage CreateOutsourcingReceiveDoc([FromBody] object JsonData)
        {

            return new HttpResponseMessage();

            //log.Info("接口：api/OutsourcingReceiveDocPOArrive/Create");
            //log.Info("创建委外采购入库单传入值：" + JsonData);
            //HttpResponseMessage result = new HttpResponseMessage();
            //List<ICS.CreateRCV.rtnRcvInfo> resultlist = new List<ICS.CreateRCV.rtnRcvInfo>();
            //Result res = new Result();
            //string str = string.Empty;
            //string data = string.Empty;
            //try
            //{
            //    DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "委外入库-委外到货单");


            //    if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
            //    {
            //        try
            //        {
            //            List<ICSOutsourcingReceiveDoc> infos = new List<ICSOutsourcingReceiveDoc>();
            //            try
            //            {
            //                infos = JsonConvert.DeserializeObject<List<ICSOutsourcingReceiveDoc>>(JsonData.ToString());
            //            }
            //            catch (Exception ex)
            //            {
            //                log.Error("转换失败：" + ex.ToString());

            //                res.Success = false;
            //                res.Message = "JSON格式不正确！";
            //                throw new Exception(res.Message);
            //            }
            //            CustCreateBFRcvSrvSubForApi action = new CustCreateBFRcvSrvSubForApi();
            //            resultlist = action.CustCreateWWRCVForApi(infos);
            //            foreach (ICS.CreateRCV.rtnRcvInfo __result in resultlist)
            //            {
            //                if (__result.IsSuccess)
            //                {
            //                    res.Success = __result.IsSuccess;
            //                    data = JsonConvert.SerializeObject(__result.Data);
            //                }
            //                else
            //                {
            //                    res.Success = __result.IsSuccess;
            //                }
            //                res.Message = __result.Message;
            //                res.Data = data;
            //            }
            //        }
            //        catch (Exception ex)
            //        {
            //            log.Error("调用后台失败：" + ex.ToString());
            //            res.Success = false;
            //            res.Message = ex.Message;
            //        }
            //    }
            //    else
            //    {
            //        res.Success = false;
            //        res.Message = "请传入参数";
            //    }
            //}
            //catch (Exception ex)
            //{
            //    log.Error("参数检验失败：" + ex.ToString());
            //    res.Success = false;
            //    res.Message = ex.Message;
            //}
            //finally
            //{
            //    str = JsonConvert.SerializeObject(res);
            //    result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            //}
            //log.Debug("创建委外采购入库单返回值：" + str);

            //DBHelper.WriteLogFile("返回报文：" + str, "委外入库-委外到货单");
            //return result;
        }
        #endregion


        #region U9审核销售出库单
        /// <summary>
        /// U9审核销售出库单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesShipmentDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveSalesShipmentDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesShipmentDoc/Approve");
            log.Info("审核销售出库单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "销售发货-销售出库单");

                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesShipmentDoc> infos = new List<ICSSalesShipmentDoc>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDoc>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        AppShipReturnModel Result = new AppShipReturnModel();
                        ApproveShip action = new ApproveShip();
                        Result = action.Approve(infos[0].ID, infos[0].WorkPoint, infos[0].User);
                        if (Result.IsSuccess == true)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = Result.Message;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("审核销售出库单返回值：" + str);
            DBHelper.WriteLogFile("返回报文：" + str, "销售发货-销售出库单");
            return result;
        }
        #endregion


        #region U9审核销售退货单
        /// <summary>
        /// U9审核销售退货单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/SalesShipmentDocNegative/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveSalesShipmentDocNegative([FromBody] object JsonData)
        {
            log.Info("接口：api/SalesShipmentDocNegative/Approve");
            log.Info("审核销售出库单红字传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSSalesShipmentDocNegative> infos = new List<ICSSalesShipmentDocNegative>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSSalesShipmentDocNegative>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ApproveRCV action = new ApproveRCV();
                        bool approveresult = action.Approve(infos);
                        if (approveresult == true)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建销售出库单返回值：" + str);
            return result;
        }
        #endregion

        #region U9修改批号有效期接口
        /// <summary>
        /// U9修改批号有效期接口
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/ModifyBatch/Modify")]
        [HttpPost]
        public HttpResponseMessage ModifyBatch([FromBody] object JsonData)
        {
            log.Info("接口：api/ModifyBatch/Modify");
            log.Info("U9修改批号有效期接口：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        ModifyLotMasterModel infos = new ModifyLotMasterModel();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<ModifyLotMasterModel>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CustModifyLot action = new CustModifyLot();
                        ModifyLotMasterReturnModel Modifyresult = action.Modify(infos);
                        if (Modifyresult.IsSuccess == true)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = Modifyresult.Message;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("U9修改批号有效期接口返回值：" + str);
            return result;
        }
        #endregion

        #region U9修改批号有效期接口(派纳JOB调用，根据已审核的质检单来更新)
        /// <summary>
        /// U9修改批号有效期接口(派纳JOB调用，根据已审核的质检单来更新)
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/ModifyBatchByQCDoc/Modify")]
        [HttpPost]
        public HttpResponseMessage ModifyBatchByQCDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/ModifyBatchByQCDoc/Modify");
            log.Info("U9修改批号有效期接口：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        ModifyLotMasterJobModel infos = new ModifyLotMasterJobModel();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<ModifyLotMasterJobModel>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CustModifyLot action = new CustModifyLot();
                        ModifyLotMasterReturnModel Modifyresult = action.ModifyByJob(infos);
                        if (Modifyresult.IsSuccess == true)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = Modifyresult.Message;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("U9修改批号有效期接口返回值：" + str);
            return result;
        }
        #endregion

        #region U9创建盘点差异单
        /// <summary>
        /// U9创建盘点差异单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CheckDiffDoc/Create")]
        [HttpPost]
        public HttpResponseMessage CreateCheckDiff([FromBody] object JsonData)
        {
            log.Info("接口：api/CheckDiffDoc/Create");
            log.Info("创建盘点差异单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            CustCreateCheckDiffDoc.rtnChkInfo resultInfo = new CustCreateCheckDiffDoc.rtnChkInfo();
            Result res = new Result();
            string str = string.Empty;
            string data = "";
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<CustCreateCheckDiffDoc.CheckDiffInfo> infos = new List<CustCreateCheckDiffDoc.CheckDiffInfo>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<CustCreateCheckDiffDoc.CheckDiffInfo>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CustCreateCheckDiffDoc action = new CustCreateCheckDiffDoc();
                        resultInfo = action.CreateByOpenAPI(infos);
                        if (resultInfo.Success == false)
                        {
                            throw new Exception(resultInfo.Message);
                        }
                        res.Success = true;
                        res.Message = "接口调用成功！";
                        res.Data = resultInfo.Data;
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建盘点差异单返回值：" + str);
            return result;
        }
        #endregion

        #region 审核调出单
        [Route("api/TransferOutDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage TransferOutDoc([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "一步调出审核");

                List<ICSTransferDoc> Bills = JsonConvert.DeserializeObject<List<ICSTransferDoc>>(JsonData.ToString());

                ApproveSpecialTransferOutDoc action = new ApproveSpecialTransferOutDoc();
                res = action.ApproveTransferOut(Bills);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "一步调出审核");

            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            return result;
        }
        #endregion


        #region 审核两步调出单
        [Route("api/SpecialTransferOutDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage SpecialTransferOutDoc([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "两步调出审核");

                List<ICSTransferDoc> Bills = JsonConvert.DeserializeObject<List<ICSTransferDoc>>(JsonData.ToString());

                ApproveSpecialTransferOutDoc action = new ApproveSpecialTransferOutDoc();
                res = action.SpecialApproveTransferOut(Bills);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "两步调出审核");

            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            return result;
        }
        #endregion


        #region U9期初现存量获取
        /// <summary>
        /// U9期初现存量获取
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CurrentStock/Get")]
        [HttpPost]
        public HttpResponseMessage CurrentStockGet([FromBody] object JsonData)
        {
            log.Info("接口：api/CurrentStock/Get");
            log.Info("期初现存量获取传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ISComplete.Curr> infos = new List<ISComplete.Curr>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ISComplete.Curr>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ISComplete action = new ISComplete();
                        string resultStr = action.CurrentStock(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("返回值：" + str);
                return result;
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("齐套检验返回值：" + str);
                return result;
            }
        }
        #endregion

        #region  根据调拨申请创建并审核调出单
        /// <summary>
        /// 根据调拨申请创建并审核调出单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OneStepTransferDoc/Create")]
        [HttpPost]
        public HttpResponseMessage TransferDocSIn([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "物料调拨-调拨申请单");


                List<ICSTransferApplyDoc> Bills = JsonConvert.DeserializeObject<List<ICSTransferApplyDoc>>(JsonData.ToString());

                TransferDoc action = new TransferDoc();
                res = action.CreateTransferOut(Bills);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "物料调拨-调拨申请单");

            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            return result;
        }
        #endregion

        #region 修改并审核标准出货单
        [Route("api/SMShip/UpdateAndApprove")]
        [HttpPost]
        public HttpResponseMessage ModifyAndApproveSMShip([FromBody] object JsonData)
        {
            log.Info("接口：api/SMShip/UpdateAndApprove");
            log.Info("修改并审核标准出货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSShipmentUpdateHead> infos = new List<ICSShipmentUpdateHead>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSShipmentUpdateHead>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        //根据传入的IsEND参数来判断，如果是False，只修改U9出货行私有字段3，不审核单据
                        ModifySMShipmement action = new ModifySMShipmement();
                        string approveresult = "";
                        if (infos[0].IsEnd == true)
                        {
                            approveresult = action.ActionModifyShipmement(infos);
                        }
                        else
                        {
                            approveresult = action.UpdateSMShipPrivateDescSeg(infos);
                        }
                        if (!string.IsNullOrWhiteSpace(approveresult))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = approveresult;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                            res.Data = approveresult;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("修改并审核标准出货单返回值：" + str);
            return result;
        }
        #endregion

        #region 修改并审核销售退回收货
        [Route("api/RMAToRCV/UpdateAndApprove")]
        [HttpPost]
        public HttpResponseMessage ModifyAndApproveRMAToRCV([FromBody] object JsonData)
        {
            log.Info("接口：api/RMAToRCV/UpdateAndApprove");
            log.Info("修改并审核销售退回收货单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSRcvUpdateHead> infos = new List<ICSRcvUpdateHead>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSRcvUpdateHead>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ModifyRMAToRCV action = new ModifyRMAToRCV();
                        string approveresult = action.ActionModifyRMAToRCV(infos);
                        if (!string.IsNullOrWhiteSpace(approveresult))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = approveresult;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                            res.Data = approveresult;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("修改并审核销售退回收货返回值：" + str);
            return result;
        }
        #endregion

        #region 修改并审核杂收单
        [Route("api/MiscRcv/UpdateAndApprove")]
        [HttpPost]
        public HttpResponseMessage ModifyAndApproveMiscRcv([FromBody] object JsonData)
        {
            log.Info("接口：api/MiscRcv/UpdateAndApprove");
            log.Info("修改并审核杂收单：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSMiscRcvUpdateHead> infos = new List<ICSMiscRcvUpdateHead>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSMiscRcvUpdateHead>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ModifyMiscRcv action = new ModifyMiscRcv();
                        string approveresult = action.ActionModifyMiscRcv(infos);
                        if (!string.IsNullOrWhiteSpace(approveresult))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = approveresult;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                            res.Data = approveresult;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("修改并审核杂收单返回值：" + str);
            return result;
        }
        #endregion

        #region 修改并审核杂发单
        [Route("api/MiscShip/UpdateAndApprove")]
        [HttpPost]
        public HttpResponseMessage ModifyAndApproveMiscShip([FromBody] object JsonData)
        {
            log.Info("接口：api/MiscShip/UpdateAndApprove");
            log.Info("修改并审核杂发单：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSMiscShipUpdateHead> infos = new List<ICSMiscShipUpdateHead>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSMiscShipUpdateHead>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ModifyMiscShip action = new ModifyMiscShip();
                        string approveresult = action.ActionModifyMiscShip(infos);
                        if (!string.IsNullOrWhiteSpace(approveresult))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = approveresult;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                            res.Data = approveresult;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("修改并审核杂发单返回值：" + str);
            return result;
        }
        #endregion

        #region 修改并审核非成套领料单
        [Route("api/PMIssue/UpdateAndApprove")]
        [HttpPost]
        public HttpResponseMessage ModifyAndApprovePMIssueDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/PMIssue/UpdateAndApprove");
            log.Info("修改并审核非成套领料单：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSPMIssueDocUpdateHead> infos = new List<ICSPMIssueDocUpdateHead>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSPMIssueDocUpdateHead>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ModifyPMIssueDoc action = new ModifyPMIssueDoc();
                        string approveresult = action.ActionModifyPMIssueDoc(infos);
                        if (!string.IsNullOrWhiteSpace(approveresult))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = approveresult;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                            res.Data = approveresult;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("修改并审核非成套领料单返回值：" + str);
            return result;
        }
        #endregion

        #region 创建并审核在库检验申请单
        [Route("api/OnStoreCheckDoc/CreateAndApprove")]
        [HttpPost]
        public HttpResponseMessage CreateAndApproveOnStoreCheck([FromBody] object JsonData)
        {
            log.Info("接口：api/OnStoreCheckDoc/CreateAndApprove");
            log.Info("创建并审核在库检验申请单：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        ICSCreateOnStoreCheckHead infos = new ICSCreateOnStoreCheckHead();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<ICSCreateOnStoreCheckHead>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CreateOnStoreCheckDoc action = new CreateOnStoreCheckDoc();
                        string createresult = action.ActionCreateOnStoreCheckDoc(infos);
                        if (!string.IsNullOrWhiteSpace(createresult))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = createresult;
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                            res.Data = createresult;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建并审核在库检验申请单返回值：" + str);
            return result;
        }
        #endregion

        #region 创建并审核应付单
        [Route("api/PurBillVouch/Create")]
        [HttpPost]
        public HttpResponseMessage CreateAPBillDoc([FromBody] object JsonData)
        {
            log.Info("接口：api/APBill/Create");
            log.Info("创建并审核应付单：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        CustCreateApBySrcDocSrv action = new CustCreateApBySrcDocSrv();
                        CustCreateApBySrcDocSrv.ReturnNEWModel createresult = action.Create(JsonData);
                        if (createresult.IsSuccess == true)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            res.Success = false;
                            res.Message = createresult.MESSAGE;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("创建并审核应付单返回值：" + str);
            return result;
        }
        #endregion

        #region 修改采购订单行私有段/公有段
        [Route("api/CDEFIND/UPDATE")]
        [HttpPost]
        public HttpResponseMessage UpdatePOLineDesc([FromBody] object JsonData)
        {
            log.Info("接口：api/CDEFIND/UPDATE");
            log.Info("修改采购订单行私有段/公有段：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            UpdateDescReturn updateresult = new UpdateDescReturn();
            string str = string.Empty;
            string data = "";
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<UPDATECDEFIND> infos = new List<UPDATECDEFIND>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<UPDATECDEFIND>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());

                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                            throw new Exception(res.Message);
                        }
                        CustBFRCVApprove action = new CustBFRCVApprove();
                        updateresult = action.UpdatePOLineDesc(infos);
                        if (updateresult.Success == true)
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                        else
                        {
                            throw new Exception(updateresult.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
            }
            finally
            {
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            }
            log.Debug("修改采购订单行私有段/公有段：" + str);
            return result;
        }
        #endregion

        #region 修改并审核调入单（一步调入）
        [Route("api/OneStepTransferDocIn/Modify")]
        [HttpPost]
        public HttpResponseMessage ModifyOneSetpTransfer([FromBody] object JsonData)
        {
            log.Info("接口：api/OneStepTransferDocIn/Modify");
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    log.Info("\r\n 修改并审核一步调入单 JSON数据：" + JsonData + "\r\n");
                    try
                    {
                        List<TransferINInfo> Bills = new List<TransferINInfo>();
                        try
                        {
                            Bills = JsonConvert.DeserializeObject<List<TransferINInfo>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        CustModifyTransferIN action = new CustModifyTransferIN();
                        bool flag = action.ModifyTransferINDoc(Bills);
                        if (flag == false)
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                        }
                        else
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("返回值：" + str);
                return result;
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("返回值：" + str);
                return result;
            }
        }
        #endregion

        #region 委外领料（U9非成套领料单）
        /// <summary>
        /// 审核非成套领料单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/OOIssueDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage MOIssueDocApprove([FromBody] object JsonData)
        {
            log.Info("接口：api/OOIssueDoc/Approve");
            log.Info("审核材料出库传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "委外发料-材料出库单");
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        List<ICSMOIssueDocApprove> infos = new List<ICSMOIssueDocApprove>();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<List<ICSMOIssueDocApprove>>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ATWFCTMatrialPick action = new ATWFCTMatrialPick();
                        bool flag = action.CustLLState(infos);
                        if (flag == false)
                        {
                            res.Success = false;
                            res.Message = "接口调用失败！";
                        }
                        else
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("返回值：" + str);

                DBHelper.WriteLogFile("返回报文：" + str, "委外发料-材料出库单");
                return result;
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("审核材料出库返回值：" + str);
                return result;
            }
        }
        #endregion

        #region U9审核借出单
        /// <summary>
        /// U9审核借出单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/BrrowOut/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveBrrowOutDoc([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "借出");

                List<ICSBrrowOutDocApprove> info = JsonConvert.DeserializeObject<List<ICSBrrowOutDocApprove>>(JsonData.ToString());

                CustCallApproveLendTrans action = new CustCallApproveLendTrans();
                res = action.CustApproveLendTrans(info);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "借出");

            return result;
        }
        #endregion


        #region U9审核还入单
        /// <summary>
        /// U9审核还入单
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/ApproveReturnBackDoc/Approve")]
        [HttpPost]
        public HttpResponseMessage ApproveReturnBackDoc([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "归还");


                List<ICSReturnInDocApprove> info = JsonConvert.DeserializeObject<List<ICSReturnInDocApprove>>(JsonData.ToString());

                CustCallApproveLendBackTrans action = new CustCallApproveLendBackTrans();
                res = action.ApproveLendBackTrans(info);

            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }

            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");


            DBHelper.WriteLogFile("返回报文：" + str, "归还");
            return result;
        }
        #endregion

        #region 根据料号批号获取U9现存量
        /// <summary>
        /// 根据料号批号获取U9现存量
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/GetU9WHQty/Get")]
        [HttpPost]
        public HttpResponseMessage GetU9WHQty([FromBody] object JsonData)
        {
            log.Info("接口：api/GetU9WHQty/Get");
            log.Info("审核还入单传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        ICSGetU9WhQty.SearchInfo infos = new ICSGetU9WhQty.SearchInfo();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<ICSGetU9WhQty.SearchInfo>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ICSGetU9WhQty action = new ICSGetU9WhQty();
                        string resultStr = action.CurrentStock(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("返回值：" + str);
                return result;
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("齐套检验返回值：" + str);
                return result;
            }
            log.Debug("审核还入单返回值：" + str);
            return result;
        }
        #endregion

        #region 根据物料名称及规格型号模糊查询U9现存量
        /// <summary>
        /// 根据物料名称及规格型号模糊查询U9现存量
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/GetU9WHQtyByInvNameAndINVStd/Get")]
        [HttpPost]
        public HttpResponseMessage GetU9WHQtyByInvNameAndINVStd([FromBody] object JsonData)
        {
            log.Info("接口：api/GetU9WHQtyByInvNameAndINVStd/Get");
            log.Info("现存量获取接口传入值：" + JsonData);
            HttpResponseMessage result = new HttpResponseMessage();
            Result res = new Result();
            string str = string.Empty;
            try
            {
                if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
                {
                    try
                    {
                        ICSGetU9WhQty.SearchInfoByNameAndSpec infos = new ICSGetU9WhQty.SearchInfoByNameAndSpec();
                        try
                        {
                            infos = JsonConvert.DeserializeObject<ICSGetU9WhQty.SearchInfoByNameAndSpec>(JsonData.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Error("转换失败：" + ex.ToString());
                            res.Success = false;
                            res.Message = "JSON格式不正确！";
                        }
                        ICSGetU9WhQty action = new ICSGetU9WhQty();
                        string resultStr = action.GetCurrentStockByNameAndSpec(infos);
                        if (!string.IsNullOrWhiteSpace(resultStr))
                        {
                            res.Success = true;
                            res.Message = "接口调用成功！";
                            res.Data = resultStr;
                        }
                        else
                        {
                            res.Success = false;
                            res.Data = resultStr;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("调用后台失败：" + ex.ToString());
                        res.Success = false;
                        res.Message = ex.Message;
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message = "请传入参数";
                }
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("返回值：" + str);
                return result;
            }
            catch (Exception ex)
            {
                log.Error("参数检验失败：" + ex.ToString());
                res.Success = false;
                res.Message = ex.Message;
                str = JsonConvert.SerializeObject(res);
                result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
                log.Debug("现存量获取接口返回：" + str);
                return result;
            }
            return result;
        }
        #endregion

        #region 料品需求转杂发
        /// <summary>
        /// 料品需求转杂发
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CreateMiscShipByItemRequest")]
        [HttpPost]
        public HttpResponseMessage CreateMiscShipByItemRequest([FromBody] object JsonData)
        {
            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            Result res = new Result();
            try
            {
                DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "料品需求转杂发");

                List<CreateMiscHeadModel> infos = JsonConvert.DeserializeObject<List<CreateMiscHeadModel>>(JsonData.ToString());

                CreateMiscShipByItemRequestSrv action = new CreateMiscShipByItemRequestSrv();
                res = action.Create(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            return result;
        }
        #endregion


        /// <summary>
        /// 修改批号
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/LotMaster/Modify")]
        [HttpPost]
        public HttpResponseMessage LotMasterModify([FromBody] object JsonData)
        {
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "修改批号");

            HttpResponseMessage result = new HttpResponseMessage();

            Result res = new Result();
            try
            {
                List<ModifyLotModel> infos = new List<ModifyLotModel>();

                infos = JsonConvert.DeserializeObject<List<ModifyLotModel>>(JsonData.ToString());

                ModifyLotSrv action = new ModifyLotSrv();
                res = action.Action(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "修改批号");
            return result;
        }


        /// <summary>
        /// 关闭出货计划行
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/CloseShipPlanLine")]
        [HttpPost]
        public HttpResponseMessage CloseShipPlanLine([FromBody] object JsonData)
        {
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "关闭出货计划行");

            HttpResponseMessage result = new HttpResponseMessage();
            string str = string.Empty;
            CloseShipPlanLineRtnModel res = new CloseShipPlanLineRtnModel();
            try
            {
                List<CloseShipPlanLineModel> infos = JsonConvert.DeserializeObject<List<CloseShipPlanLineModel>>(JsonData.ToString());

                CloseShipPlanLineSrv action = new CloseShipPlanLineSrv();
                res = action.Action(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            str = JsonConvert.SerializeObject(res);

            DBHelper.WriteLogFile("返回报文：" + str, "关闭出货计划行");

            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
            return result;
        }


        /// <summary>
        /// 修改收货行
        /// </summary>
        /// <param name="JsonData"></param>
        /// <returns></returns>
        [Route("api/RcvLine/Modify")]
        [HttpPost]
        public HttpResponseMessage RcvLineModify([FromBody] object JsonData)
        {
            DBHelper.WriteLogFile("传入报文：" + JsonData.ToString(), "修改出货行");

            HttpResponseMessage result = new HttpResponseMessage();

            Result res = new Result();
            try
            {
                List<ModifyRcvLineModel> infos = new List<ModifyRcvLineModel>();

                infos = JsonConvert.DeserializeObject<List<ModifyRcvLineModel>>(JsonData.ToString());

                ModifyRcvLineSrv action = new ModifyRcvLineSrv();
                res = action.Action(infos);
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message = ex.Message;
            }
            string str = JsonConvert.SerializeObject(res);
            result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");

            DBHelper.WriteLogFile("返回报文：" + str, "修改出货行");
            return result;
        }
    }
}
