コード例 #1
0
        /// <summary>
        /// 获取资金拨付支付单列表
        /// </summary>
        /// <param name="mstList"></param>
        /// <param name="TotalItems"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PagedResult <GKPayment4ZjbfModel> GetPaymentList4Zjbf2(List <GKPaymentMstModel> mstList, int TotalItems, int pageIndex, int pageSize = 20)
        {
            if (mstList == null || mstList.Count == 0)
            {
                PagedResult <GKPayment4ZjbfModel> gk = new PagedResult <GKPayment4ZjbfModel>();
                return(gk);
            }
            else
            {
                //加入业务单名称
                List <long> phids = mstList.Select(t => t.RefbillPhid).ToList();
                Dictionary <string, object> dic = new Dictionary <string, object>();
                new CreateCriteria(dic).Add(ORMRestrictions <List <long> > .In("PhId", phids));
                var payments = this.PaymentMstRule.Find(dic);
                if (payments.Count > 0)
                {
                    foreach (var mstGk in mstList)
                    {
                        var mstBk = payments.ToList().Find(t => t.PhId == mstGk.RefbillPhid);
                        if (mstBk != null)
                        {
                            mstGk.RefbillName = mstBk.FName;
                        }
                    }
                }
            }

            //获得列表对应的明细数据
            Dictionary <long, long> mstIds   = new Dictionary <long, long>();
            Dictionary <long, long> mstBfIds = new Dictionary <long, long>();

            mstIds.Clear();
            foreach (GKPaymentMstModel mst in mstList)
            {
                //获取phid
                if (!mstIds.ContainsKey(mst.PhId))
                {
                    mstIds.Add(mst.PhId, mst.PhId);
                }


                if (!mstBfIds.ContainsKey(mst.RefbillPhid))
                {
                    mstBfIds.Add(mst.RefbillPhid, mst.RefbillPhid);
                }
            }

            string[] sorts2 = new string[] { "MstPhid Asc", "PhId Asc" };
            Dictionary <string, object> where = new Dictionary <string, object>();
            new CreateCriteria(where).Add(ORMRestrictions <List <Int64> > .In("MstPhid", mstIds.Keys.ToList()));

            IList <GKPaymentDtlModel> Dtls = this.GKPaymentDtlRule.Find(where, sorts2);

            Dictionary <string, object> where2 = new Dictionary <string, object>();

            new CreateCriteria(where2).Add(ORMRestrictions <List <Int64> > .In("MstPhid", mstBfIds.Keys.ToList()));
            IList <PaymentDtlModel> bfDtls = this.PaymentDtlRule.Find(where2, sorts2);


            //组装数据
            PagedResult <GKPayment4ZjbfModel> mstPageResult = new PagedResult <GKPayment4ZjbfModel>();

            IList <GKPayment4ZjbfModel>   zjbflist   = new List <GKPayment4ZjbfModel>();
            GKPayment4ZjbfModel           zjbfMo     = null;
            GKPaymentDtl4ZjbfModel        zjbfDtlMo  = null;
            List <GKPaymentDtlModel>      payDtls    = null;
            PaymentDtlModel               bfDtl      = null;
            IEnumerable <PaymentDtlModel> enuZjbfDtl = null;

            foreach (GKPaymentMstModel mst in mstList)
            {
                zjbfMo      = new GKPayment4ZjbfModel();
                zjbfMo.Mst  = mst;
                zjbfMo.Dtls = new List <GKPaymentDtl4ZjbfModel>();
                //加入必要的判断
                if (Dtls != null && Dtls.Count > 0)
                {
                    payDtls = Dtls.Where(x => x.MstPhid == mst.PhId).ToList();
                    if (payDtls != null && payDtls.Count > 0)
                    {
                        foreach (GKPaymentDtlModel payDtl in payDtls)
                        {
                            zjbfDtlMo = CommonUtils.TransReflection <GKPaymentDtlModel, GKPaymentDtl4ZjbfModel>(payDtl);

                            //资金拨付支付明细赋值
                            if (bfDtls != null && bfDtls.Count > 0)
                            {
                                enuZjbfDtl = bfDtls.Where(x => x.PhId == zjbfDtlMo.RefbillDtlPhid && x.BudgetdtlPhid == zjbfDtlMo.RefbillDtlPhid2);
                                if (enuZjbfDtl != null && enuZjbfDtl.Count() > 0)
                                {
                                    bfDtl = enuZjbfDtl.First();
                                    if (string.IsNullOrEmpty(zjbfDtlMo.QtKmdm))
                                    {
                                        zjbfDtlMo.QtKmdm = bfDtl.QtKmdm; //预算科目
                                        zjbfDtlMo.QtKmmc = bfDtl.QtKmmc; //预算科目名称
                                    }

                                    zjbfDtlMo.FDepartmentcode = bfDtl.FDepartmentcode;   //补助单位/部门代码
                                    zjbfDtlMo.FDepartmentname = bfDtl.FDepartmentname;   //补助单位/部门名称
                                    zjbfDtlMo.BudgetdtlName   = bfDtl.BudgetdtlName;     //预算明细项目名称
                                }
                            }
                            zjbfMo.Dtls.Add(zjbfDtlMo);
                        }
                    }
                }
                #region
                //payDtls = Dtls.Where(x => x.MstPhid == mst.PhId).ToList();
                //foreach (GKPaymentDtlModel payDtl in payDtls)
                //{
                //    zjbfDtlMo = CommonUtils.TransReflection<GKPaymentDtlModel, GKPaymentDtl4ZjbfModel>(payDtl);

                //    //资金拨付支付明细赋值
                //    enuZjbfDtl = bfDtls.Where(x => x.PhId == zjbfDtlMo.RefbillDtlPhid && x.BudgetdtlPhid == zjbfDtlMo.RefbillDtlPhid2);
                //    if (enuZjbfDtl.Count() > 0)
                //    {
                //        bfDtl = enuZjbfDtl.First();
                //        if (string.IsNullOrEmpty(zjbfDtlMo.QtKmdm))
                //        {
                //            zjbfDtlMo.QtKmdm = bfDtl.QtKmdm; //预算科目
                //            zjbfDtlMo.QtKmmc = bfDtl.QtKmmc; //预算科目名称
                //        }

                //        zjbfDtlMo.FDepartmentcode = bfDtl.FDepartmentcode;   //补助单位/部门代码
                //        zjbfDtlMo.FDepartmentname = bfDtl.FDepartmentname;   //补助单位/部门名称
                //        zjbfDtlMo.BudgetdtlName = bfDtl.BudgetdtlName;       //预算明细项目名称
                //    }

                //    zjbfMo.Dtls.Add(zjbfDtlMo);
                //}
                #endregion
                zjbflist.Add(zjbfMo);
            }

            mstPageResult.Results    = zjbflist;
            mstPageResult.PageIndex  = pageIndex;
            mstPageResult.PageSize   = pageSize;
            mstPageResult.TotalItems = TotalItems;

            return(mstPageResult);
        }
コード例 #2
0
        /// <summary>
        /// 获取资金拨付支付单信息
        /// </summary>
        /// <param name="phid">支付单主键</param>
        /// <returns></returns>
        public GKPayment4ZjbfModel GetPayment4Zjbf(Int64 phid)
        {
            GKPayment4ZjbfModel ret = null;

            GKPaymentMstModel mst = this.EntRule.Find(phid);

            if (mst != null)
            {
                ret = new GKPayment4ZjbfModel();
                //去业务单查部门名称
                PaymentMstModel paymentMst = PaymentMstRule.Find(mst.RefbillPhid);
                mst.fdepname = paymentMst.FDepname;
                mst.FOrgname = paymentMst.FOrgname;

                Dictionary <string, object> where = new Dictionary <string, object>();
                new CreateCriteria(where).Add(ORMRestrictions <Int64> .Eq("MstPhid", mst.PhId));
                //查询相关明细数据
                var dtlList = this.GKPaymentDtlRule.Find(where, new string[] { "QtKmdm Asc" }); //PVoucherDelService.Find(where, new string[] { "SortCode Asc" }).Data.ToList();QtKmdm

                if (dtlList.Count > 0)
                {
                    long mstPhid = mst.RefbillPhid;
                    Dictionary <string, object> where2 = new Dictionary <string, object>();
                    new CreateCriteria(where2).Add(ORMRestrictions <Int64> .Eq("MstPhid", mstPhid));

                    //资金拨付单对应项目信息
                    var bfXmList = this.PaymentXmRule.Find(where2);

                    //资金拨付单明细表
                    var bfDtlList = this.PaymentDtlRule.Find(where2);


                    var       newCodeDt = this.GetPaymentNewCodeDataTable(mst.RefbillPhid);
                    DataRow[] drs       = null;
                    Dictionary <string, string> dicNewCode = null;
                    Dictionary <string, string> dicNewCodeMstPhid = null;
                    string fNewCode = string.Empty, fNewCodeMstPhid = string.Empty;
                    string old_phid = string.Empty;

                    //给明细表赋值,写入扩展字段信息

                    ret.Mst  = mst;
                    ret.Dtls = new List <GKPaymentDtl4ZjbfModel>();

                    GKPaymentDtl4ZjbfModel        dtl4Zjbf = null;
                    PaymentDtlModel               bfDtl    = null;
                    PaymentXmModel                bfXm     = null;
                    IEnumerable <PaymentDtlModel> enuDtl   = null;
                    IEnumerable <PaymentXmModel>  enuXm    = null;


                    Dictionary <string, object> dicOrg = new Dictionary <string, object>();
                    new CreateCriteria(dicOrg)
                    .Add(ORMRestrictions <long> .NotEq("PhId", 0));
                    IList <OrganizeModel> OrgList = OrganizationRule.Find2(dicOrg);
                    //补充完善明细信息
                    foreach (GKPaymentDtlModel dtl in dtlList)
                    {
                        dtl4Zjbf = CommonUtils.TransReflection <GKPaymentDtlModel, GKPaymentDtl4ZjbfModel>(dtl);

                        if (bfDtlList.Count > 0)
                        {
                            enuDtl = bfDtlList.Where(x => x.PhId == dtl.RefbillDtlPhid && x.BudgetdtlPhid == dtl.RefbillDtlPhid2);
                            if (enuDtl.Count() > 0)
                            {
                                bfDtl = enuDtl.First();
                                if (string.IsNullOrEmpty(dtl.QtKmdm))
                                {
                                    dtl4Zjbf.QtKmdm = bfDtl.QtKmdm; //预算科目
                                    dtl4Zjbf.QtKmmc = bfDtl.QtKmmc; //预算科目名称
                                }

                                dtl4Zjbf.FDepartmentcode = bfDtl.FDepartmentcode;   //补助单位/部门代码
                                OrganizeModel Org = OrgList.ToList().Find(x => x.OCode == bfDtl.FDepartmentcode);
                                dtl4Zjbf.FDepartmentphid = Org.PhId;
                                dtl4Zjbf.FDepartmentname = bfDtl.FDepartmentname;   //补助单位/部门名称
                                if (Org.IfCorp == "N")
                                {
                                    OrganizeModel Org2 = OrgList.ToList().Find(x => x.PhId == Org.ParentOrgId);
                                    dtl4Zjbf.FDepartmentParentcode = Org2.OCode;
                                    dtl4Zjbf.FDepartmentParentphid = Org2.PhId;
                                    dtl4Zjbf.FDepartmentParentname = Org2.OName;
                                }

                                dtl4Zjbf.BudgetdtlName = bfDtl.BudgetdtlName;       //预算明细项目名称

                                //预算项目
                                enuXm = bfXmList.Where(x => x.PhId == bfDtl.PayXmPhid);
                                if (enuXm.Count() > 0)
                                {
                                    bfXm = enuXm.First();
                                    dtl4Zjbf.XmProjcode = bfXm.XmProjcode;
                                    dtl4Zjbf.XmProjname = bfXm.XmProjname;
                                    dtl4Zjbf.FSeq       = bfXm.FSeq;
                                }
                            }
                        }

                        //写重新支付单的单号
                        if (newCodeDt != null && newCodeDt.Rows.Count > 0)
                        {
                            dicNewCode         = new Dictionary <string, string>();
                            dicNewCodeMstPhid  = new Dictionary <string, string>();
                            dtl4Zjbf.FNewCodes = "";

                            //drs = newCodeDt.Select("ng_insert_dt>=#" + dtl.NgInsertDt.ToString("yyyy-MM-dd HH:mm:ss") + "#");
                            drs = newCodeDt.Select(string.Format("phid ={0}", dtl.PhId));
                            while (drs.Length > 0)
                            {
                                foreach (var row in drs)
                                {
                                    fNewCode = row["f_new_code"].ToString();
                                    if (!string.IsNullOrEmpty(fNewCode))
                                    {
                                        if (!dicNewCode.ContainsKey(fNewCode))
                                        {
                                            dicNewCode.Add(fNewCode, fNewCode);
                                        }
                                    }
                                }
                                old_phid = drs[0]["phid"].ToString();
                                if (!string.IsNullOrEmpty(old_phid))
                                {
                                    drs = newCodeDt.Select(string.Format("old_dtl_phid={0}", old_phid));
                                    if (drs.Length > 0)
                                    {
                                        fNewCodeMstPhid = drs[0]["mst_phid"].ToString();
                                        if (!dicNewCodeMstPhid.ContainsKey(fNewCodeMstPhid))
                                        {
                                            dicNewCodeMstPhid.Add(fNewCodeMstPhid, fNewCodeMstPhid);
                                        }
                                    }
                                }
                                else
                                {
                                    drs = newCodeDt.Select("1=2");
                                }
                            }

                            dtl4Zjbf.FNewCodes        = string.Join(",", dicNewCode.Values.ToArray());
                            dtl4Zjbf.FNewCodesMstPhid = string.Join(",", dicNewCodeMstPhid.Values.ToArray());
                        }

                        ret.Dtls.Add(dtl4Zjbf);
                    }
                }
                ret.Dtls = ret.Dtls.OrderBy(t => t.FSeq).ToList();
            }


            return(ret);
        }