/// <summary> /// 修改后的获取审批单据列表的接口 /// </summary> /// <param name="payment">参数结合</param> /// <returns></returns> public IList <PaymentMstModel> GetPaymentList(PaymentMstModel payment) { IList <PaymentMstModel> paymentList = new List <PaymentMstModel>(); Dictionary <string, object> dic = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(payment.FName)) { Dictionary <string, object> dicCode = new Dictionary <string, object>(); Dictionary <string, object> dicName = new Dictionary <string, object>(); new CreateCriteria(dicCode). Add(ORMRestrictions <string> .Like("FCode", payment.FName)); new CreateCriteria(dicName). Add(ORMRestrictions <string> .Like("FName", payment.FName)); new CreateCriteria(dic). Add(ORMRestrictions.Or(dicCode, dicName)); } if (payment.ApprovalBzs != null && payment.ApprovalBzs.Count > 0) { new CreateCriteria(dic). Add(ORMRestrictions <List <byte> > .In("FApproval", payment.ApprovalBzs)); } if (payment.PayBzs != null && payment.PayBzs.Count > 0) { new CreateCriteria(dic). Add(ORMRestrictions <List <byte> > .In("IsPay", payment.PayBzs)); } if (!string.IsNullOrEmpty(payment.StartDate.ToString()) && !string.IsNullOrEmpty(payment.EndDate.ToString())) { new CreateCriteria(dic). Add(ORMRestrictions <DateTime> .Ge("FDate", DateTime.Parse(payment.StartDate.ToString()))). Add(ORMRestrictions <DateTime> .Le("FDate", DateTime.Parse(payment.EndDate.Value.AddDays(1).ToString()))); } if (!string.IsNullOrEmpty(payment.MaxAmount) && !string.IsNullOrEmpty(payment.MinAmount)) { decimal max = decimal.Parse(payment.MaxAmount); decimal min = decimal.Parse(payment.MinAmount); if (max < min) { throw new Exception("申请金额传递错误!"); } new CreateCriteria(dic). Add(ORMRestrictions <decimal> .Ge("FAmountTotal", min)). Add(ORMRestrictions <decimal> .Le("FAmountTotal", max)); } new CreateCriteria(dic). Add(ORMRestrictions <long> .Eq("FOrgphid", payment.FOrgphid)). Add(ORMRestrictions <long> .Eq("FDepphid", payment.FDepphid)). Add(ORMRestrictions <string> .Eq("FYear", payment.FYear)); //获取符合条件的审批单据 paymentList = this.PaymentMstRule.Find(dic, new string[] { "IsPay asc", "FCode desc" }); if (paymentList != null && paymentList.Count > 0) { //获取单据类型与单据类型主键 IList <QTSysSetModel> models = QTSysSetRule.RuleHelper.Find(t => t.DicType == "splx" && t.TypeCode == "1"); List <AppvalRecordVo> appvalRecords = new List <AppvalRecordVo>(); SqlDao sqlDao = new SqlDao(); if (models.Count > 0) { OrganizeModel Org = this.OrganizationRule.Find(payment.FOrgphid); payment.FOrgcode = Org.OCode; appvalRecords = sqlDao.GetRecords(payment.FYear, long.Parse(payment.UserId), models[0].Value, payment.FOrgcode, "1", models[0].PhId); if (appvalRecords != null && appvalRecords.Count > 0) { appvalRecords = appvalRecords.FindAll(t => t.DepId == payment.FDepphid); } } //该部门下存在自己未审核的数据要放最前面 if (appvalRecords != null && appvalRecords.Count > 0) { var refbillPhids = appvalRecords.Select(t => t.RefbillPhid); var pays1 = paymentList.ToList().FindAll(t => refbillPhids.Contains(t.PhId)); if (pays1.Count > 0) { foreach (var pay in pays1) { pay.IsApprovalNow = 1; var appvalRecord = appvalRecords.Find(t => t.RefbillPhid == pay.PhId); if (appvalRecord == null) { throw new Exception("单据审批流查询失败!"); } pay.RefbillPhid = appvalRecord.RefbillPhid; pay.FBilltype = appvalRecord.FBilltype; pay.PostPhid = appvalRecord.PostPhid; pay.ProcPhid = appvalRecord.ProcPhid; pay.OperaPhid = appvalRecord.OperaPhid; pay.AppvalPhid = appvalRecord.PhId; } } var pays2 = paymentList.ToList().FindAll(t => (!refbillPhids.Contains(t.PhId))); if (pays2.Count > 0) { foreach (var pay in pays2) { pay.IsApprovalNow = 0; } } pays1.AddRange(pays2); paymentList = pays1; } var payPhids = paymentList.Select(t => t.PhId).ToList(); if (payPhids.Count > 0) { dic.Clear(); new CreateCriteria(dic). Add(ORMRestrictions <List <long> > .In("RefbillPhid", payPhids)); var GkPayments = this.GKPaymentMstRule.Find(dic); if (GkPayments.Count > 0) { foreach (var per in paymentList) { var Gks = GkPayments.ToList().FindAll(t => t.RefbillPhid == per.PhId); if (Gks.Count > 0) { per.GkPaymentCode = Gks.OrderByDescending(t => t.FCode).ToList()[0].FCode; } } } } } return(paymentList); }