using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using ICS.WCF.Base;
using ICSSoft.APIApproveShipment;
using ICSSoft.APIDeleteShipment;
using ICSSoft.Entity;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UFSoft.UBF.Service;
using UFSoft.UBF.Util.Context;
using www.ufida.org.EntityData;

namespace ICS.CreateShipPlanToShipment
{
    public class CreateShipmentByShipPlan
    {

        //private static string ORGCode = ConfigurationManager.AppSettings["orgCode"].ToString();
        private static string ERPConStr = Appconfig.GetU9ConnStr();
        private static string UserCode = ConfigurationManager.AppSettings["userCode"].ToString();
        public ShipPlanToShipReturnValue CustCreateShipmentByShipPlan(List<ICSSalesShipmentDoc> Data)
        {
            #region 服务调用框架结构
            //实例化代理类 UFIDAU9ISVItemIBatchCreateItemByDTOSRVClient 
            UFIDAU9ISVSMISMPullSrcDocSVClient client = new UFIDAU9ISVSMISMPullSrcDocSVClient();
            //服务返回结果

            //UFIDAU9ISVPRSVPRBizKeyDTOData[] returnItems;
            UFSoft.UBF.Exceptions1.MessageBase[] returnItems;
            //返回异常信息，目前还没有使用此属性
            //UFSoft.UBF.Exceptions1.MessageBase[] returnMsg;
            //上下文信息
            object context;
            //传入 参数

            string[] splitBy = new string[] { };
            List<string> docno = new List<string>();
            string ORGCode = "";
            try
            {
                if (Data == null || Data.Count == 0)
                {
                    throw new Exception("传入数据为空");
                }

                string ORGID = "";
                ORGCode = Data[0].WorkPoint;

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

                if (string.IsNullOrEmpty(ORGID))
                {
                    throw new Exception("组织编码：" + ORGCode + "在U9中不存在。");
                }
                //给上下文信息赋值
                context = CreateContextObj();

                //给传入参数赋值
                UFIDAU9ISVSMSrcDocInfoDTOData[] itemDatas = setDataForItem(Data, ORGID, ORGCode);

                StringBuilder beginstrlog = new StringBuilder();
                beginstrlog.AppendLine("参数获取完毕");
                Appconfig.WriteLogFile(beginstrlog.ToString(), "出货计划转出货单");

                //服务调用
                (client.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
                (client.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;
                long[] IDList = client.Do(out returnItems, context, 0, DateTime.Now, itemDatas);

                StringBuilder str = new StringBuilder();

                ShipPlanToShipReturnValue value = new ShipPlanToShipReturnValue();

                List<Data> values = new List<Data>();
                int msgnumber = 0;
                string docnolist = "";
                string sqlIDList = "";
                foreach (long docid in IDList)
                {
                    sqlIDList += "'" + docid + "',";
                    string docsql = @"select DocNo from SM_Ship
                                      where ID='" + docid + "'";
                    DataTable docdt = DBhlper.Query(docsql, Appconfig.GetU9ConnStr());
                    if (docdt.Rows.Count != 0)
                    {
                        docnolist += docdt.Rows[0]["DocNo"].ToString() + ",";
                    }
                    docno.Add(docdt.Rows[0]["DocNo"].ToString());
                }
                if (string.IsNullOrEmpty(docnolist))
                {
                    value.IsSuccess = false;
                    value.Message = "出货单创建失败";
                }
                else
                {
                    value.DocNo = docnolist.TrimEnd(',');
                    value.IsSuccess = true;
                    value.Message = "出货单创建成功";
                }

                foreach (string item in docno)
                {
                    bool approveResult = ApproveShipment.Approve(docno, ORGCode);
                    if (!approveResult)
                    {
                        DeleteShipment.Delete(docno, ORGCode);
                        throw new Exception("单据：" + item + "审核失败！");
                    }
                }
                Data _data = new Data();
                List<DataLine> list = new List<DataLine>();
                string Selsql = @"SELECT a.ID,d.Code AS CusCode,dd.Name AS CusName,a.DocNo AS SSDCode,c.Code AS WHCode,cc.Name WHName,b.SrcDocNo AS cordercode,a.Org
                               ,a.CreatedBy AS CreateUser,a.CreatedOn AS CreateDateTime,a.ApproveMan AS Checker,
							   a.ApproveDate AS CheckDateTime,b.ID AS DetailID,b.DocLineNo AS Sequence,b.ItemInfo_ItemCode AS InvCode
                               ,b.ShipQtyTUAmount AS Quantity,0 AS Amount,b.SrcDocLineKey AS SDNDetailID,
                               b.LotInfo_LotCode AS cBatch,
                                                 '' cFree1,'' cFree2,'' cFree3,
                                                 '' cFree4,'' cFree5,'' cFree6,
                                                 '' cFree7,'' cFree8,'' cFree9,
                                                 '' cFree10
                                                   FROM SM_Ship a
                                                 LEFT JOIN SM_ShipLine b ON b.Ship=a.ID
                                                 LEFT JOIN CBO_Wh c ON b.Wh=c.ID
                                                 LEFT JOIN CBO_Wh_Trl cc ON c.ID=cc.ID
												 LEFT JOIN CBO_Customer d on d.ID=a.OrderBy_Customer
												 LEFT JOIN CBO_Customer_Trl dd on dd.ID=d.ID
                                                 WHERE a.ID in (" + sqlIDList.TrimEnd(',') + ") AND a.Org='" + ORGID + "'";
                DataTable Seldt = DBhlper.Query(Selsql, Appconfig.GetU9ConnStr());
                if (Seldt != null && Seldt.Rows.Count > 0)
                {
                    foreach (DataRow item in Seldt.Rows)
                    {
                        DataLine _DataLine = new DataLine();
                        _data.ID = item["ID"].ToString();
                        _data.SSDCode = item["SSDCode"].ToString();
                        _data.CusCode = item["CusCode"].ToString();
                        _data.CusName = item["CusName"].ToString();
                        _data.WHCode = item["WHCode"].ToString();
                        _data.WHName = item["WHName"].ToString();
                        _data.cordercode = item["cordercode"].ToString();
                        _data.CreateUser = item["CreateUser"].ToString();
                        _data.CreateDateTime = Convert.ToDateTime(item["CreateDateTime"].ToString());
                        _data.Checker = item["Checker"].ToString();
                        _data.CheckDateTime = Convert.ToDateTime(item["CheckDateTime"].ToString());
                        _DataLine.DetailID = item["DetailID"].ToString();
                        _DataLine.Sequence = Int32.Parse(item["Sequence"].ToString());
                        _DataLine.Quantity = Decimal.Parse(item["Quantity"].ToString());
                        _DataLine.InvCode = item["InvCode"].ToString();
                        _DataLine.SDNDetailID = item["SDNDetailID"].ToString();
                        _DataLine.cBatch = item["cBatch"].ToString();
                        _DataLine.cFree1 = item["cFree1"].ToString();
                        _DataLine.cFree2 = item["cFree2"].ToString();
                        _DataLine.cFree3 = item["cFree3"].ToString();
                        _DataLine.cFree4 = item["cFree4"].ToString();
                        _DataLine.cFree5 = item["cFree5"].ToString();
                        _DataLine.cFree6 = item["cFree6"].ToString();
                        _DataLine.cFree7 = item["cFree7"].ToString();
                        _DataLine.cFree8 = item["cFree8"].ToString();
                        _DataLine.cFree9 = item["cFree9"].ToString();
                        _DataLine.cFree10 = item["cFree10"].ToString();
                        list.Add(_DataLine);
                    }
                    _data.details = list;
                    value.Data = _data;
                }
                Appconfig.WriteLogFile("成功", "出货计划转出货单");
                return value;
            }
            catch (Exception ex)
            {
                if (docno.Count != 0)
                {
                    DeleteShipment.Delete(docno, ORGCode);
                }
                //异常信息捕获
                string HeadList = string.Empty;

                //string message=    GetExceptionMessage(ex);
                StringBuilder str = new StringBuilder();
                foreach (ICSSalesShipmentDoc data in Data)
                {
                    str.AppendLine("出货计划转出货单");
                    str.AppendLine(ex.ToString());
                    HeadList += "\r\n 出货计划单号：" + data.SDNCode;
                }
                str.AppendLine(HeadList);
                str.AppendLine("结果:" + "False");


                Appconfig.WriteLogFile(str.ToString(), "出货计划转出货单");

                ShipPlanToShipReturnValue value = new ShipPlanToShipReturnValue();
                value.IsSuccess = false;
                value.Message = GetExceptionMessage(ex);
                return value;
            }
            #endregion
        }

        public Result CreateShipmentByShipPlanAPI(List<ICSSalesShipmentDoc> Infos)
        {
            var res = new Result();
            var datalist = new List<ICSSalesShipmentDoc>();

            if (Infos == null || Infos.Count == 0)
            {
                res.Success = false;
                res.Message = "入参为空";
                res.Data = datalist;
                return res;
            }

            foreach (ICSSalesShipmentDoc info in Infos)
            {
                try
                {
                    string OrgID = "";
                    string orgsql = @"select ID from Base_Organization
                                          where Code='{0}'";
                    orgsql = string.Format(orgsql, info.WorkPoint);
                    DataTable orgdt = DBhlper.Query(orgsql, Appconfig.GetU9ConnStr());
                    if (orgdt.Rows.Count != 0)
                    {
                        OrgID = orgdt.Rows[0]["ID"].ToString();
                    }
                    else
                    {
                        throw new Exception("组织编码不存在");
                    }


                    var UserCode = "";

                    string sqluser = "Select ID from base_user where code ='" + info.User + "'";
                    DataTable dtuser = DBhlper.Query(sqluser, Appconfig.GetU9ConnStr());
                    if (dtuser.Rows.Count == 0)
                    {
                        sqluser = "Select ID from base_user where code ='" + Appconfig.GetDefaultUser() + "'";
                        dtuser = DBhlper.Query(sqluser, Appconfig.GetU9ConnStr());
                        if (dtuser.Rows.Count == 0)
                        {
                            throw new Exception("用户不存在!");
                        }
                        UserCode = Appconfig.GetDefaultUser();
                    }
                    else
                    {
                        UserCode = info.User;
                    }


                    List<Data> values = new List<Data>();
                    CreateSMShipOperationResult _result = new CreateSMShipOperationResult();
                    List<SMShip> _SOFileList = new List<SMShip>();

                    foreach (ICSSalesShipmentDocs Body in info.details)
                    {
                        string SrcID = Appconfig.GetShipPlanID(Body.SDNDetailID);
                        if (string.IsNullOrEmpty(SrcID))
                        {
                            throw new Exception("传入出货计划行ID：" + Body.SDNDetailID + "在U9中不存在。");
                        }
                        SMShip model = new SMShip();
                        model.ShipDocTypeCode = "";
                        model.ShipDocTypeID = "0";
                        model.CurShipQty1 = Body.Quantity;
                        model.DocStatus = 2;// d.DocStatus;
                        model.Locations = new List<Location>();
                        model.OptionalSplitTerm = new OptionalSplitTerm[] { };
                        model.SrcDocNo = info.SDNCode;
                        model.SrcDocLineID = long.Parse(SrcID);
                        //model.SrcDocLineNo = int.Parse(Body.Sequence);
                        model.SrcDocType = 2;
                        string WHID = Appconfig.GetWhIDByCode(Body.WHCode, OrgID);
                        model.WH = WHID;
                        bool IsLot = Appconfig.GetWhLotControl(Body.WHCode, OrgID);
                        if (IsLot == true)
                        {
                            model.LotCode = Body.BatchCode;
                        }
                        else
                        {
                            model.LotCode = "";
                        }

                        SHLinePurDS linedesc = new SHLinePurDS();
                        linedesc.PrivateDescSeg30 = Body.LogIds;

                        model.LineDescFlexField = linedesc;

                        _SOFileList.Add(model);
                    }


                    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);

                    if (objuu["Success"].ToString().ToUpper() == "TRUE" && !string.IsNullOrEmpty(objuu["Data"].ToString()))
                    {
                        string keyCode = objuu["Data"].ToString();
                        //获取Token
                        string ToeknUrl = "http://{4}/u9c/webapi/OAuth2/Login?userCode={0}&entcode={1}&orgcode={2}&code={3}";
                        ToeknUrl = string.Format(ToeknUrl, UserCode, ConfigurationManager.AppSettings["enterpriseID"].ToString(), info.WorkPoint, keyCode, ConfigurationManager.AppSettings["U9IP"].ToString());
                        string resultToken = PostData.GetInfo("", ToeknUrl);

                        objuu = JObject.Parse(resultToken);

                        if (objuu["Success"].ToString().ToUpper() == "TRUE" && !string.IsNullOrEmpty(objuu["Data"].ToString()))
                        {
                            string TokenCode = objuu["Data"].ToString();
                            //创建单据
                            string Url = "http://{0}/u9c/webapi/Ship/CreateBySrcDoc";
                            Url = string.Format(Url, ConfigurationManager.AppSettings["U9IP"].ToString());


                            string postData = JsonConvert.SerializeObject(_SOFileList);

                            Appconfig.WriteLogFile("调用API传入参数：" + postData, "销售发货-销售发货单");

                            string resultCreateFile = PostData.APT(Url, postData, TokenCode);

                            Appconfig.WriteLogFile("调用API返回参数：" + resultCreateFile, "销售发货-销售发货单");

                            objuu = JObject.Parse(resultCreateFile);

                            if (objuu["Success"].ToString().ToUpper() != "TRUE" || string.IsNullOrEmpty(objuu["Data"].ToString()))
                            {
                                throw new Exception("调用OpenAPI操作单据失败：" + objuu["ResMsg"].ToString());
                            }
                            else
                            {
                                foreach (JObject item in objuu["Data"])
                                {
                                    if (item["m_isSucess"].ToString().ToUpper() == "TRUE")
                                    {
                                        string sql = @"select a.ID,a.DocNo,b.ID LineID,b.DocLineNo,c.Code,b.QtyPriceAmount,
                                                b.DescFlexField_PrivateDescSeg30,b.SrcDocLineKey from SM_Ship a
                                                left join SM_ShipLine b on a.ID = b.Ship
                                                left join CBO_ItemMaster c on b.ItemInfo_ItemID = c.ID
                                                where a.ID ='" + item["m_iD"].ToString() + "'";
                                        DataTable dt = DBhlper.Query(sql, Appconfig.GetU9ConnStr());
                                        if (dt.Rows.Count == 0)
                                        {
                                            throw new Exception("U9标准接口返回的单据ID未查询到相关单据信息");
                                        }

                                        var linelist = new List<ICSSalesShipmentDocs>();
                                        foreach (DataRow dr in dt.Rows)
                                        {
                                            linelist.Add(new ICSSalesShipmentDocs
                                            {
                                                DetailID = dr["LineID"].ToString(),
                                                Sequence = dr["DocLineNo"].ToString(),
                                                InvCode = dr["Code"].ToString(),
                                                Quantity =decimal.Parse(dr["QtyPriceAmount"].ToString()),
                                                SDNDetailID = dr["SrcDocLineKey"].ToString(),
                                                LogIds = dr["DescFlexField_PrivateDescSeg30"].ToString()
                                            });
                                        }
                                        datalist.Add(new ICSSalesShipmentDoc
                                        {
                                            ID = dt.Rows[0]["ID"].ToString(),
                                            SSDCode = dt.Rows[0]["DocNo"].ToString(),
                                            IsSuccess = true,
                                            Message = "成功",
                                            details = linelist
                                        });
                                    }
                                    else
                                    {
                                        throw new Exception("操作推送数据到U9API失败：" + item["m_errorMsg"].ToString());
                                    }
                                }
                            }
                        }
                        else
                        {
                            throw new Exception("获取Token失败：" + objuu["ResMsg"].ToString());
                        }
                    }
                    else
                    {
                        throw new Exception("获取授权失败：" + objuu["ResMsg"].ToString());
                    }
                }
                catch (Exception ex)
                {
                    var linelist = new List<ICSSalesShipmentDocs>();
                    foreach (var item in info.details)
                    {
                        linelist.Add(new ICSSalesShipmentDocs
                        {
                            SDNDetailID = item.SDNDetailID,
                            LogIds = item.LogIds
                        });
                    }

                    datalist.Add(new ICSSalesShipmentDoc
                    {
                        IsSuccess = false,
                        Message = "创建失败：" + ex.Message,
                        details = linelist
                    });
                }
            }
            res.Success = true;
            res.Message = "成功";
            res.Data = datalist;
            return res;
        }

        private string GetExceptionMessage(Exception ex)
        {
            string faultMessage = "未知错误，请查看ERP日志！";

            System.TimeoutException timeoutEx = ex as System.TimeoutException;
            if (timeoutEx != null)
            {
                faultMessage = "访问服务超时，请修改配置信息！";
            }
            else
            {
                FaultException<ServiceException> faultEx = ex as FaultException<ServiceException>;
                if (faultEx == null)
                {
                    faultMessage = ex.Message;
                }
                else
                {
                    ServiceException serviceEx = faultEx.Detail;
                    if (serviceEx != null && !string.IsNullOrEmpty(serviceEx.Message)
                        && !serviceEx.Message.Equals("fault", StringComparison.OrdinalIgnoreCase))
                    {
                        // 错误信息在faultEx.Message中，请提取，
                        // 格式为"Fault:料品不能为空，请录入\n 在....."
                        int startIndex = serviceEx.Message.IndexOf(":");
                        int endIndex = serviceEx.Message.IndexOf("\n");
                        if (endIndex == -1)
                            endIndex = serviceEx.Message.Length;
                        if (endIndex > 0 && endIndex > startIndex + 1)
                        {
                            faultMessage = serviceEx.Message.Substring(startIndex + 1, endIndex - startIndex - 1);
                        }
                        else
                        {
                            faultMessage = serviceEx.Message;
                        }
                    }
                }
            }
            return faultMessage;
        }

        #region 给上下文信息赋值1
        /// <summary>
        /// 给上下文信息赋值
        /// </summary>
        /// <returns></returns>
        private ThreadContext CreateContextObj()
        {
            // 实例化应用上下文对象
            ThreadContext thContext = new ThreadContext();

            System.Collections.Generic.Dictionary<object, object> ns = new Dictionary<object, object>();
            ns.Add("OrgID", ConfigurationManager.AppSettings["orgID"].ToString());
            ns.Add("UserID", ConfigurationManager.AppSettings["userID"].ToString());
            ns.Add("UserCode", ConfigurationManager.AppSettings["userCode"].ToString());
            ns.Add("Datetime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            ns.Add("CultureName", ConfigurationManager.AppSettings["cultureName"].ToString());
            ns.Add("EnterpriseID", ConfigurationManager.AppSettings["enterpriseID"].ToString());
            ns.Add("DefaultCultureName", ConfigurationManager.AppSettings["cultureName"].ToString());
            thContext.nameValueHas = ns;

            return thContext;
        }
        #endregion

        private static UFIDAU9ISVSMSrcDocInfoDTOData[] setDataForItem(List<ICSSalesShipmentDoc> datas, string ORGID, string OrgCode)
        {
            List<UFIDAU9ISVSMSrcDocInfoDTOData> prs = new List<UFIDAU9ISVSMSrcDocInfoDTOData>();
            List<ItemCURR> lstitem = new List<ItemCURR>();

            StringBuilder beginstrlog = new StringBuilder();
            beginstrlog.AppendLine("出货计划转出货单(传入数据开始)");
            foreach (ICSSalesShipmentDoc data in datas)
            {
                foreach (ICSSalesShipmentDocs linedr in data.details)
                {
                    string WHID = Appconfig.GetWhIDByCode(linedr.WHCode, ORGID);
                    UFIDAU9ISVSMSrcDocInfoDTOData pr = new UFIDAU9ISVSMSrcDocInfoDTOData();
                    pr.m_lotCode = linedr.BatchCode;
                    pr.m_srcDocType = 2;
                    pr.m_srcDocLineID = long.Parse(linedr.SDNDetailID);
                    pr.m_wH = long.Parse(WHID);
                    pr.m_curShipQty1 = linedr.Quantity;

                    pr.ExtensionData = null;
                    beginstrlog.AppendLine("出货计划单号:" + data.SDNCode);
                    beginstrlog.AppendLine("出货计划行ID:" + linedr.SDNDetailID);
                    beginstrlog.AppendLine("出货存储地点:" + linedr.WHCode);
                    beginstrlog.AppendLine("出货数量:" + linedr.Quantity.ToString());
                    beginstrlog.AppendLine("出货批号:" + linedr.BatchCode);

                    prs.Add(pr);
                }
            }
            Appconfig.WriteLogFile(beginstrlog.ToString(), "出货计划转出货单");
            return prs.ToArray();
        }

        #region 时间戳方法
        private DateTime TimestampToDateTime(long timestamp)
        {
            DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            long lTime = timestamp * 10000000;
            TimeSpan nowTimeSpan = new TimeSpan(lTime);
            DateTime resultDateTime = dateTimeStart.Add(nowTimeSpan);
            return resultDateTime;
        }
        #endregion



    }
    public class ItemCURR
    {
        public string LOTNO { get; set; }//批号
        public string ORG { get; set; }//组织编码
        public string WH { get; set; }//仓库
        public string BIN { get; set; }//库位
        public string ITEM { get; set; }//物料
        public decimal QTY { get; set; }//数量
    }
    public class ItemRatio
    {
        public long ID { get; set; }//单位编码
        public string Code { get; set; }//单位编码
        public decimal Ratio { get; set; }//位数
        public int Precision { get; set; }//精度
    }

    public class ShipPlanToShipReturnValue
    {
        public string DocNo { get; set; }
        public bool IsSuccess { get; set; }
        public string Message { get; set; }
        public rtnRcvLine[] rtnLines { get; set; }
        public Data Data { get; set; }
    }

    public class rtnRcvLine
    {
        public int LineNo { get; set; }
    }

    public class Data
    {
        public string ID { get; set; }
        public string SSDCode { get; set; }
        public string CusCode { get; set; }
        public string CusName { get; set; }
        public string WHCode { get; set; }
        public string WHName { get; set; }
        public string cordercode { get; set; }
        public string CreateUser { get; set; }
        public DateTime CreateDateTime { get; set; }
        public string Checker { get; set; }
        public DateTime CheckDateTime { get; set; }
        public List<DataLine> details { get; set; }
    }
    public class DataLine
    {
        public string DetailID { get; set; }
        public int Sequence { get; set; }
        public string InvCode { get; set; }
        public Decimal Quantity { get; set; }
        public string SDNDetailID { get; set; }
        public Decimal Amount { get; set; }
        public string cBatch { get; set; }
        public string brand { get; set; }
        public string cFree1 { get; set; }
        public string cFree2 { get; set; }
        public string cFree3 { get; set; }
        public string cFree4 { get; set; }
        public string cFree5 { get; set; }
        public string cFree6 { get; set; }
        public string cFree7 { get; set; }
        public string cFree8 { get; set; }
        public string cFree9 { get; set; }
        public string cFree10 { get; set; }

        public string LogId { get; set; }
    }

    public class RtnToRcvITEMREQDATA
    {
        public string DocDate { get; set; }
        public string SrcID { get; set; }//	外系统ID 
        public string POLineID { get; set; }//	采购行ID 
        public string Uom { get; set; }//	单位  
        public decimal RcvQty { get; set; }//	收货数量 
        public string BusinessDate { get; set; }//	日期 
        public string CreatedBy { get; set; }//	操作人 
        public string LotNo { get; set; }//	批号 
        public string WHCode { get; set; }//	存储地点 
        public string Bin { get; set; }//	库位 
        public string Memo { get; set; }//	备注 
        public string Mfc { get; set; }//	厂牌 
        public string Project { get; set; }//	项目 
        public string Item { get; set; }//	料品 
        public string Supplier { get; set; }//	供应商 
        public string DocTypeCode { get; set; }//	单据类型 
        public string GroupFlag { get; set; }//	分单标识       
        public string SourceCode { get; set; }//	单号 
        public string Sequence { get; set; }//	行号     
        public decimal RtnFillQty { get; set; }//	补货数量 
        public decimal Quantity { get; set; }//	退扣数量 
        public string ReceivementType { get; set; }//	收货单类型 
        public string OtherDesc { get; set; }//	弹性域 
        public decimal PriceTC { get; set; }//	价格 

        public string WorkPoint { get; set; }//	组织 


    }
}
