/*
 * 预发货库存明细
 */

using System;
using System.Web;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MySystem.Models;
using Library;
using LitJson;
using MySystemLib;

namespace MySystem.Areas.Admin.Controllers
{
    [Area("Admin")]
    [Route("Admin/[controller]/[action]")]
    public class PreSendStockDetailController : BaseController
    {
        public PreSendStockDetailController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
        {
            OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
        }

        #region 预发货库存明细列表

        /// <summary>
        /// 根据条件查询预发货库存明细列表
        /// </summary>
        /// <returns></returns>
        public IActionResult Index(PreSendStockDetail data, string right, string StoreId)
        {
            ViewBag.RightInfo = RightInfo;
            ViewBag.right = right;
            ViewBag.StoreId = StoreId;


            return View();
        }

        #endregion

        #region 根据条件查询预发货库存明细列表

        /// <summary>
        /// 预发货库存明细列表
        /// </summary>
        /// <returns></returns>
        public JsonResult IndexData(PreSendStockDetail data, string StoreIdStoreName, string StoreIdStoreNo, string BrandIdSelect, string ToUserIdMakerCode, string ToUserIdRealName, string ToStoreIdStoreNo, string ToStoreIdStoreName, string SourceStoreIdStoreNo, string SourceStoreIdStoreName, string FromUserIdMakerCode, string FromUserIdRealName, string FromStoreIdStoreNo, string FromStoreIdStoreName, int page = 1, int limit = 30)
        {

            Dictionary<string, string> Fields = new Dictionary<string, string>();
            Fields.Add("StoreId", "1");

            Fields.Add("CreateDate", "3"); //时间
            Fields.Add("SnNo", "1"); //SN编号
            Fields.Add("ApplyDate", "3"); //申请时间


            string condition = " and Status>-1";
            //仓库仓库名称
            if (!string.IsNullOrEmpty(StoreIdStoreName))
            {
                condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreName where StoreName='" + StoreIdStoreName + "')";
            }
            //仓库仓库编号
            if (!string.IsNullOrEmpty(StoreIdStoreNo))
            {
                condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreNo where StoreNo='" + StoreIdStoreNo + "')";
            }
            //产品类型
            if (!string.IsNullOrEmpty(BrandIdSelect))
            {
                condition += " and BrandId=" + BrandIdSelect;
            }
            //收货人创客编号
            if (!string.IsNullOrEmpty(ToUserIdMakerCode))
            {
                condition += " and ToUserId in (select ToUserId from UsersForMakerCode where MakerCode='" + ToUserIdMakerCode + "')";
            }
            //收货人真实姓名
            if (!string.IsNullOrEmpty(ToUserIdRealName))
            {
                condition += " and ToUserId in (select ToUserId from UsersForRealName where RealName='" + ToUserIdRealName + "')";
            }
            //收货仓库仓库编号
            if (!string.IsNullOrEmpty(ToStoreIdStoreNo))
            {
                condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreNo where StoreNo='" + ToStoreIdStoreNo + "')";
            }
            //收货仓库仓库名称
            if (!string.IsNullOrEmpty(ToStoreIdStoreName))
            {
                condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreName where StoreName='" + ToStoreIdStoreName + "')";
            }
            //源仓库编号仓库编号
            if (!string.IsNullOrEmpty(SourceStoreIdStoreNo))
            {
                condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreNo where StoreNo='" + SourceStoreIdStoreNo + "')";
            }
            //源仓库编号仓库名称
            if (!string.IsNullOrEmpty(SourceStoreIdStoreName))
            {
                condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreName where StoreName='" + SourceStoreIdStoreName + "')";
            }
            //出货创客创客编号
            if (!string.IsNullOrEmpty(FromUserIdMakerCode))
            {
                condition += " and FromUserId in (select FromUserId from UsersForMakerCode where MakerCode='" + FromUserIdMakerCode + "')";
            }
            //出货创客真实姓名
            if (!string.IsNullOrEmpty(FromUserIdRealName))
            {
                condition += " and FromUserId in (select FromUserId from UsersForRealName where RealName='" + FromUserIdRealName + "')";
            }
            //出货仓库仓库编号
            if (!string.IsNullOrEmpty(FromStoreIdStoreNo))
            {
                condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreNo where StoreNo='" + FromStoreIdStoreNo + "')";
            }
            //出货仓库仓库名称
            if (!string.IsNullOrEmpty(FromStoreIdStoreName))
            {
                condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreName where StoreName='" + FromStoreIdStoreName + "')";
            }


            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreSendStockDetail", Fields, "Id desc", "0", page, limit, condition);
            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
            foreach (Dictionary<string, object> dic in diclist)
            {
                //仓库
                int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
                SmallStoreHouse storeid_SmallStoreHouse = db.SmallStoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new SmallStoreHouse();
                dic["StoreIdStoreName"] = storeid_SmallStoreHouse.StoreName;
                dic["StoreIdStoreNo"] = storeid_SmallStoreHouse.StoreNo;
                dic.Remove("StoreId");
                //产品类型
                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
                //SNID
                dic["SnId"] = RelationClass.GetPosMachinesTwoInfo(int.Parse(dic["SnId"].ToString()));
                //收货人
                int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
                Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
                dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
                dic["ToUserIdRealName"] = touserid_Users.RealName;
                dic.Remove("ToUserId");
                //收货仓库
                int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
                StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
                dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
                dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
                dic.Remove("ToStoreId");
                //源仓库编号
                int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
                StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
                dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
                dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
                dic.Remove("SourceStoreId");
                dic["ApplyFlagName"] = dic["ApplyFlag"].ToString() == "1" ? "是" : "否";
                //出货创客
                int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
                Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
                dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
                dic["FromUserIdRealName"] = fromuserid_Users.RealName;
                dic.Remove("FromUserId");
                //出货仓库
                int FromStoreId = int.Parse(function.CheckInt(dic["FromStoreId"].ToString()));
                StoreHouse fromstoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId) ?? new StoreHouse();
                dic["FromStoreIdStoreNo"] = fromstoreid_StoreHouse.StoreNo;
                dic["FromStoreIdStoreName"] = fromstoreid_StoreHouse.StoreName;
                dic.Remove("FromStoreId");
                dic["CancelFlagName"] = dic["CancelFlag"].ToString() == "1" ? "是" : "否";

            }
            return Json(obj);
        }

        #endregion

        #region 增加预发货库存明细

        /// <summary>
        /// 增加或修改预发货库存明细信息
        /// </summary>
        /// <returns></returns>
        public IActionResult Add(string right, string StoreId)
        {
            ViewBag.RightInfo = RightInfo;
            ViewBag.right = right;
            ViewBag.StoreId = StoreId;


            return View();
        }

        #endregion

        #region 增加预发货库存明细

        /// <summary>
        /// 增加或修改预发货库存明细信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Add(PreSendStockDetail data)
        {
            Dictionary<string, object> Fields = new Dictionary<string, object>();
            Fields.Add("StoreId", data.StoreId);

            Fields.Add("StoreId", data.StoreId); //仓库
            Fields.Add("BrandId", data.BrandId); //产品类型
            Fields.Add("SnId", data.SnId); //SNID
            Fields.Add("ToUserId", data.ToUserId); //收货人
            Fields.Add("ToStoreId", data.ToStoreId); //收货仓库
            Fields.Add("SourceStoreId", data.SourceStoreId); //源仓库编号
            Fields.Add("ApplyFlag", data.ApplyFlag); //申请标记
            Fields.Add("ApplyDate", data.ApplyDate); //申请时间
            Fields.Add("FromUserId", data.FromUserId); //出货创客
            Fields.Add("FromStoreId", data.FromStoreId); //出货仓库
            Fields.Add("CancelFlag", data.CancelFlag); //撤回标记
            Fields.Add("CancelDate", data.CancelDate); //撤回时间

            Fields.Add("SeoTitle", data.SeoTitle);
            Fields.Add("SeoKeyword", data.SeoKeyword);
            Fields.Add("SeoDescription", data.SeoDescription);
            int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("PreSendStockDetail", Fields, 0);
            AddSysLog(data.Id.ToString(), "PreSendStockDetail", "add");
            db.SaveChanges();

            return "success";
        }

        #endregion

        #region 修改预发货库存明细

        /// <summary>
        /// 增加或修改预发货库存明细信息
        /// </summary>
        /// <returns></returns>
        public IActionResult Edit(string right, string StoreId, int Id = 0)
        {
            ViewBag.RightInfo = RightInfo;
            ViewBag.right = right;
            ViewBag.StoreId = StoreId;


            PreSendStockDetail editData = db.PreSendStockDetail.FirstOrDefault(m => m.Id == Id) ?? new PreSendStockDetail();
            ViewBag.data = editData;
            return View();
        }

        #endregion

        #region 修改预发货库存明细

        /// <summary>
        /// 增加或修改预发货库存明细信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Edit(PreSendStockDetail data)
        {
            Dictionary<string, object> Fields = new Dictionary<string, object>();
            Fields.Add("StoreId", data.StoreId);

            Fields.Add("StoreId", data.StoreId); //仓库
            Fields.Add("BrandId", data.BrandId); //产品类型
            Fields.Add("SnId", data.SnId); //SNID
            Fields.Add("ToUserId", data.ToUserId); //收货人
            Fields.Add("ToStoreId", data.ToStoreId); //收货仓库
            Fields.Add("SourceStoreId", data.SourceStoreId); //源仓库编号
            Fields.Add("ApplyFlag", data.ApplyFlag); //申请标记
            Fields.Add("ApplyDate", data.ApplyDate); //申请时间
            Fields.Add("FromUserId", data.FromUserId); //出货创客
            Fields.Add("FromStoreId", data.FromStoreId); //出货仓库
            Fields.Add("CancelFlag", data.CancelFlag); //撤回标记
            Fields.Add("CancelDate", data.CancelDate); //撤回时间

            Fields.Add("SeoTitle", data.SeoTitle);
            Fields.Add("SeoKeyword", data.SeoKeyword);
            Fields.Add("SeoDescription", data.SeoDescription);
            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, data.Id);
            AddSysLog(data.Id.ToString(), "PreSendStockDetail", "update");
            db.SaveChanges();

            return "success";
        }

        #endregion

        #region 删除预发货库存明细信息

        /// <summary>
        /// 删除预发货库存明细信息
        /// </summary>
        /// <returns></returns>
        public string Delete(string Id)
        {
            string[] idlist = Id.Split(new char[] { ',' });
            AddSysLog(Id, "PreSendStockDetail", "del");
            foreach (string subid in idlist)
            {
                int id = int.Parse(subid);
                Dictionary<string, object> Fields = new Dictionary<string, object>();
                Fields.Add("Status", -1);
                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
            }
            db.SaveChanges();

            return "success";
        }

        #endregion

        #region 开启

        /// <summary>
        /// 开启
        /// </summary>
        /// <returns></returns>
        public string Open(string Id)
        {
            string[] idlist = Id.Split(new char[] { ',' });
            AddSysLog(Id, "PreSendStockDetail", "open");
            foreach (string subid in idlist)
            {
                int id = int.Parse(subid);
                Dictionary<string, object> Fields = new Dictionary<string, object>();
                Fields.Add("Status", 1);
                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
            }
            db.SaveChanges();
            return "success";
        }

        #endregion

        #region 关闭

        /// <summary>
        /// 关闭
        /// </summary>
        /// <returns></returns>
        public string Close(string Id)
        {
            string[] idlist = Id.Split(new char[] { ',' });
            AddSysLog(Id, "PreSendStockDetail", "close");
            foreach (string subid in idlist)
            {
                int id = int.Parse(subid);
                Dictionary<string, object> Fields = new Dictionary<string, object>();
                Fields.Add("Status", 0);
                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
            }
            db.SaveChanges();
            return "success";
        }

        #endregion

        #region 排序
        /// <summary>
        /// 排序
        /// </summary>
        /// <param name="Id"></param>
        public string Sort(int Id, int Sort)
        {
            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("PreSendStockDetail", Sort, Id);

            AddSysLog(Id.ToString(), "PreSendStockDetail", "sort");
            return "success";
        }
        #endregion

        #region 导入数据
        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="ExcelData"></param>
        public string Import(string ExcelData)
        {
            ExcelData = HttpUtility.UrlDecode(ExcelData);
            JsonData list = JsonMapper.ToObject(ExcelData);
            for (int i = 1; i < list.Count; i++)
            {
                JsonData dr = list[i];

                db.PreSendStockDetail.Add(new PreSendStockDetail()
                {
                    CreateDate = DateTime.Now,
                    UpdateDate = DateTime.Now,

                });
                db.SaveChanges();
            }
            AddSysLog("0", "PreSendStockDetail", "Import");
            return "success";
        }
        #endregion

        #region 导出Excel

        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <returns></returns>
        public JsonResult ExportExcel(PreSendStockDetail data, string StoreIdStoreName, string StoreIdStoreNo, string BrandIdSelect, string ToUserIdMakerCode, string ToUserIdRealName, string ToStoreIdStoreNo, string ToStoreIdStoreName, string SourceStoreIdStoreNo, string SourceStoreIdStoreName, string FromUserIdMakerCode, string FromUserIdRealName, string FromStoreIdStoreNo, string FromStoreIdStoreName)
        {
            Dictionary<string, string> Fields = new Dictionary<string, string>();
            Fields.Add("CreateDate", "3"); //时间
            Fields.Add("SnNo", "1"); //SN编号
            Fields.Add("ApplyDate", "3"); //申请时间


            string condition = " and Status>-1";
            //仓库仓库名称
            if (!string.IsNullOrEmpty(StoreIdStoreName))
            {
                condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreName where StoreName='" + StoreIdStoreName + "')";
            }
            //仓库仓库编号
            if (!string.IsNullOrEmpty(StoreIdStoreNo))
            {
                condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreNo where StoreNo='" + StoreIdStoreNo + "')";
            }
            //产品类型
            if (!string.IsNullOrEmpty(BrandIdSelect))
            {
                condition += " and BrandId=" + BrandIdSelect;
            }
            //收货人创客编号
            if (!string.IsNullOrEmpty(ToUserIdMakerCode))
            {
                condition += " and ToUserId in (select ToUserId from UsersForMakerCode where MakerCode='" + ToUserIdMakerCode + "')";
            }
            //收货人真实姓名
            if (!string.IsNullOrEmpty(ToUserIdRealName))
            {
                condition += " and ToUserId in (select ToUserId from UsersForRealName where RealName='" + ToUserIdRealName + "')";
            }
            //收货仓库仓库编号
            if (!string.IsNullOrEmpty(ToStoreIdStoreNo))
            {
                condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreNo where StoreNo='" + ToStoreIdStoreNo + "')";
            }
            //收货仓库仓库名称
            if (!string.IsNullOrEmpty(ToStoreIdStoreName))
            {
                condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreName where StoreName='" + ToStoreIdStoreName + "')";
            }
            //源仓库编号仓库编号
            if (!string.IsNullOrEmpty(SourceStoreIdStoreNo))
            {
                condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreNo where StoreNo='" + SourceStoreIdStoreNo + "')";
            }
            //源仓库编号仓库名称
            if (!string.IsNullOrEmpty(SourceStoreIdStoreName))
            {
                condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreName where StoreName='" + SourceStoreIdStoreName + "')";
            }
            //出货创客创客编号
            if (!string.IsNullOrEmpty(FromUserIdMakerCode))
            {
                condition += " and FromUserId in (select FromUserId from UsersForMakerCode where MakerCode='" + FromUserIdMakerCode + "')";
            }
            //出货创客真实姓名
            if (!string.IsNullOrEmpty(FromUserIdRealName))
            {
                condition += " and FromUserId in (select FromUserId from UsersForRealName where RealName='" + FromUserIdRealName + "')";
            }
            //出货仓库仓库编号
            if (!string.IsNullOrEmpty(FromStoreIdStoreNo))
            {
                condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreNo where StoreNo='" + FromStoreIdStoreNo + "')";
            }
            //出货仓库仓库名称
            if (!string.IsNullOrEmpty(FromStoreIdStoreName))
            {
                condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreName where StoreName='" + FromStoreIdStoreName + "')";
            }


            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreSendStockDetail", Fields, "Id desc", "0", 1, 20000, condition, "StoreId,BrandId,SnNo,SnId,ToUserId,ToStoreId,SourceStoreId,ApplyFlag,ApplyDate,FromUserId,FromStoreId,CancelFlag,CancelDate", false);
            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
            foreach (Dictionary<string, object> dic in diclist)
            {
                //仓库
                int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
                SmallStoreHouse storeid_SmallStoreHouse = db.SmallStoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new SmallStoreHouse();
                dic["StoreIdStoreName"] = storeid_SmallStoreHouse.StoreName;
                dic["StoreIdStoreNo"] = storeid_SmallStoreHouse.StoreNo;
                dic.Remove("StoreId");
                //产品类型
                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
                //SNID
                dic["SnId"] = RelationClass.GetPosMachinesTwoInfo(int.Parse(dic["SnId"].ToString()));
                //收货人
                int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
                Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
                dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
                dic["ToUserIdRealName"] = touserid_Users.RealName;
                dic.Remove("ToUserId");
                //收货仓库
                int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
                StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
                dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
                dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
                dic.Remove("ToStoreId");
                //源仓库编号
                int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
                StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
                dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
                dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
                dic.Remove("SourceStoreId");
                dic["ApplyFlagName"] = dic["ApplyFlag"].ToString() == "1" ? "是" : "否";
                //出货创客
                int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
                Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
                dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
                dic["FromUserIdRealName"] = fromuserid_Users.RealName;
                dic.Remove("FromUserId");
                //出货仓库
                int FromStoreId = int.Parse(function.CheckInt(dic["FromStoreId"].ToString()));
                StoreHouse fromstoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId) ?? new StoreHouse();
                dic["FromStoreIdStoreNo"] = fromstoreid_StoreHouse.StoreNo;
                dic["FromStoreIdStoreName"] = fromstoreid_StoreHouse.StoreName;
                dic.Remove("FromStoreId");
                dic["CancelFlagName"] = dic["CancelFlag"].ToString() == "1" ? "是" : "否";

            }

            Dictionary<string, object> result = new Dictionary<string, object>();
            result.Add("Status", "1");
            result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
            result.Add("Obj", diclist);
            Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
            ReturnFields.Add("StoreIdStoreName", "仓库仓库名称");
            ReturnFields.Add("StoreIdStoreNo", "仓库仓库编号");
            ReturnFields.Add("BrandId", "产品类型");
            ReturnFields.Add("SnNo", "SN编号");
            ReturnFields.Add("SnId", "SNID");
            ReturnFields.Add("ToUserIdMakerCode", "收货人创客编号");
            ReturnFields.Add("ToUserIdRealName", "收货人真实姓名");
            ReturnFields.Add("ToStoreIdStoreNo", "收货仓库仓库编号");
            ReturnFields.Add("ToStoreIdStoreName", "收货仓库仓库名称");
            ReturnFields.Add("SourceStoreIdStoreNo", "源仓库编号仓库编号");
            ReturnFields.Add("SourceStoreIdStoreName", "源仓库编号仓库名称");
            ReturnFields.Add("ApplyFlag", "申请标记");
            ReturnFields.Add("ApplyDate", "申请时间");
            ReturnFields.Add("FromUserIdMakerCode", "出货创客创客编号");
            ReturnFields.Add("FromUserIdRealName", "出货创客真实姓名");
            ReturnFields.Add("FromStoreIdStoreNo", "出货仓库仓库编号");
            ReturnFields.Add("FromStoreIdStoreName", "出货仓库仓库名称");
            ReturnFields.Add("CancelFlag", "撤回标记");
            ReturnFields.Add("CancelDate", "撤回时间");

            result.Add("Fields", ReturnFields);
            AddSysLog("0", "PreSendStockDetail", "ExportExcel");
            return Json(result);
        }

        #endregion

    }
}
