using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询抵质押品信息(文件)
    /// 通过合同号查询抵质押品信息
    /// </summary>
    public class QueryCollateralInformationOfFile : TFOutput
    {
        #region Output
        /// <summary>
        /// 抵质押列表
        /// 担保合同号|抵质押品编号|抵质押类型|抵质押品认定价值|抵押品评估价值|状态|入库日期|抵质押物名称|质押账号|
        /// </summary>
        public string DZYLB { get; internal set; }

        /// <summary>
        /// 抵质押列表
        /// 担保合同号|抵质押品编号|抵质押类型|抵质押品认定价值|抵押品评估价值|状态|入库日期|抵质押物名称|质押账号|
        /// </summary>
        public List<E_DZYLB> DZYLBData { get; internal set; }

        /// <summary>
        /// 抵质押列表
        /// 担保合同号|抵质押品编号|抵质押类型|抵质押品认定价值|抵押品评估价值|状态|入库日期|抵质押物名称|质押账号|
        /// </summary>
        public class E_DZYLB
        {
            /// <summary>
            /// 担保合同号
            /// </summary>
            public string DBHTH { get; set; }

            /// <summary>
            /// 抵质押品编号
            /// </summary>
            public string DZYPBH { get; set; }

            /// <summary>
            /// 抵质押类型
            /// </summary>
            public string DZYLX { get; set; }

            /// <summary>
            /// 抵质押品认定价值
            /// </summary>
            public string DZYPRDJZ { get; set; }

            /// <summary>
            /// 抵押品评估价值
            /// </summary>
            public string DYPPGJZ { get; set; }

            /// <summary>
            /// 状态
            /// </summary>
            public string ZT { get; set; }

            /// <summary>
            /// 入库日期
            /// </summary>
            public string RKRQ { get; set; }

            /// <summary>
            /// 抵质押物名称
            /// </summary>
            public string DZYWMC { get; set; }

            /// <summary>
            /// 质押账号
            /// </summary>
            public string ZYZH { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 合同号 0380
            ///  
            /// </summary>
            public string HTH { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryCollateralInformationOfFile();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd38 = HTH;
                MessageData.Fd128 = "0027";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.DZYLBData = AnilyzeFileData<E_DZYLB>(MessageData.FileData,
                                            "担保合同号|抵质押品编号|抵质押类型|抵质押品认定价值|抵押品评估价值|状态|入库日期|抵质押物名称|质押账号|",
                                            x =>
                                            {
                                                return new E_DZYLB
                                                {
                                                    DBHTH = x["担保合同号"],
                                                    DZYPBH = x["抵质押品编号"],
                                                    DZYLX = x["抵质押类型"],
                                                    DZYPRDJZ = x["抵质押品认定价值"],
                                                    DYPPGJZ = x["抵押品评估价值"],
                                                    ZT = x["状态"],
                                                    RKRQ = x["入库日期"],
                                                    DZYWMC = x["抵质押物名称"],
                                                    ZYZH = x["质押账号"]
                                                };
                                            });
                output.DZYLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
