123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.ViewModel;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.ChargeManage.ChargeTotal;
- using EMIS.DataLogic.ChargeManage.ChargeTotal;
- using System.Text.RegularExpressions;
- using EMIS.CommonLogic.ChargeManage.ChargeSituation;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.ChargeManage.ChargeTotal
- {
- public class ChargeTotalServices : BaseServices, IChargeTotalServices
- {
- public ChargeTotalDAL ChargeTotalDAL { get; set; }
- public IInSchoolSettingServices InSchoolSettingServices { get; set; }
- public IChargeDelayServices IChargeDelayServices { get; set; }
- /// <summary>
- /// 查询费用统计信息View(以班级信息分组统计)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ChargeTotalView> GetChargeTotadViewGrid(ConfiguretView configuretView, Guid? collegeID,
- int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- int? chargeYearID, Guid? chargeProjectID, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- //查询对应的全部流程环节信息(WorkflowStatusView)
- var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
- if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
- {
- throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
- }
- //查询缓交申请工作流程结束环节状态ID(通过)
- var chargeDelayEndtStatus = IChargeDelayServices.GetCorrectEndStatus();
- if (chargeDelayEndtStatus == null)
- {
- throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
- }
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (chargeYearID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- //缓交信息
- Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //缓交申请(审核通过)
- expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => true);
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = ChargeTotalDAL.GetChargeTotalView(expStudentCharge, expChargeDelayPass, expStudent);
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.Grade == yearID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
- .ThenByDescending(x => x.Grade).ThenBy(x => x.ChargeProjectStr)
- .ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
- .ToGridResultSet<ChargeTotalView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询费用统计信息List(以班级信息、缴费学年、收费项目分组统计)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <returns></returns>
- public List<ChargeTotalView> GetChargeTotalViewList(ConfiguretView configuretView, Guid? collegeID,
- int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- int? chargeYearID, Guid? chargeProjectID, int? inSchoolStatus)
- {
- //查询对应的全部流程环节信息(WorkflowStatusView)
- var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
- if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
- {
- throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
- }
- //查询缓交申请工作流程结束环节状态ID(通过)
- var chargeDelayEndtStatus = IChargeDelayServices.GetCorrectEndStatus();
- if (chargeDelayEndtStatus == null)
- {
- throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
- }
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (chargeYearID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- //缓交信息
- Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //缓交申请(审核通过)
- expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => true);
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = ChargeTotalDAL.GetChargeTotalView(expStudentCharge, expChargeDelayPass, expStudent);
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.Grade == yearID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
- .ThenByDescending(x => x.Grade).ThenBy(x => x.ChargeProjectStr)
- .ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
- .ToList();
- }
- /// <summary>
- /// 统计相应的费用信息(应收总额、实收总额等)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public ChargeTotalSumView GetTotalView(ConfiguretView configuretView, Guid? collegeID,
- int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- int? chargeYearID, Guid? chargeProjectID, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- //查询对应的全部流程环节信息(WorkflowStatusView)
- var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
- if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
- {
- throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
- }
- //查询缓交申请工作流程结束环节状态ID(通过)
- var chargeDelayEndtStatus = IChargeDelayServices.GetCorrectEndStatus();
- if (chargeDelayEndtStatus == null)
- {
- throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
- }
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (chargeYearID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- //缓交信息
- Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //缓交申请(审核通过)
- expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => true);
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = ChargeTotalDAL.GetChargeTotalView(expStudentCharge, expChargeDelayPass, expStudent);
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.Grade == yearID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var chargeTotalViewList = this.GetQueryByDataRangeByCollege(query).ToList<ChargeTotalView>();
- int? chargeCountSum = 0;
- decimal? amountSum = 0;
- decimal? chargeAmountSum = 0;
- decimal? actualAmountSum = 0;
- int? delayCountSum = 0;
- decimal? delayAmountSum = 0;
- int? paymenCountSum = 0;
- decimal? paymenAmountSum = 0;
- foreach (var chargeTotalView in chargeTotalViewList)
- {
- chargeCountSum += chargeTotalView.ChargeCount;
- amountSum += chargeTotalView.Amount;
- chargeAmountSum += chargeTotalView.ChargeAmount;
- actualAmountSum += chargeTotalView.ActualAmount;
- delayCountSum += chargeTotalView.DelayCount;
- delayAmountSum += chargeTotalView.DelayAmount;
- paymenCountSum += chargeTotalView.PaymenCount;
- paymenAmountSum += chargeTotalView.PaymenAmount;
- }
- var chargeTotalSumView = new ChargeTotalSumView();
- chargeTotalSumView.ChargeCountSum = chargeCountSum;
- chargeTotalSumView.AmountSum = amountSum;
- chargeTotalSumView.ChargeAmountSum = chargeAmountSum;
- chargeTotalSumView.ActualAmountSum = actualAmountSum;
- chargeTotalSumView.DelayCountSum = delayCountSum;
- chargeTotalSumView.DelayAmountSum = delayAmountSum;
- chargeTotalSumView.PaymenCountSum = paymenCountSum;
- chargeTotalSumView.PaymenAmountSum = paymenAmountSum;
- return chargeTotalSumView;
- }
- }
- }
|