12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.ChargeManage.ChargeSituation;
- using EMIS.ViewModel;
- using EMIS.ViewModel.ChargeManage.ChargeSituation;
- using System.Text.RegularExpressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using System.Linq.Expressions;
- using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
- using EMIS.ViewModel.Students;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.ChargeManage.ChargeSituation
- {
- public class ChargeStandardServices : BaseServices, IChargeStandardServices
- {
- public ChargeStandardDAL ChargeStandardDAL { get; set; }
- public ChargeProjectDAL ChargeProjectDAL { get; set; }
- public StudentChargeDAL StudentChargeDAL { get; set; }
- public IInSchoolSettingServices InSchoolSettingServices { get; set; }
- /// <summary>
- /// 查询收费标准信息列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ViewModel.ChargeManage.ChargeSituation.ChargeStandardView> GetChargeStandardViewGrid(ConfiguretView configuretView,
- Guid? collegeID, int? yearID, int? chargeYearID, int? standardID, int? educationID, int? learningformID,
- Guid? chargeProjectID, string LearnSystem, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- Expression<Func<EC_ChargeStandard, bool>> expChargeStandard = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (chargeYearID.HasValue)
- {
- //缴费学年
- expChargeStandard = expChargeStandard.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- //收费项目
- expChargeStandard = expChargeStandard.And(x => x.ChargeProjectID == chargeProjectID);
- }
- 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 = ChargeStandardDAL.GetChargeStandarViewQueryAble(expChargeStandard, expStudent);
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.GradeStr == 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);
- }
- ////去掉学生人数为0的数据
- //if (inSchoolStatus != null && inSchoolStatus > -1)
- //{
- // query = query.Where(x => x.StudentCount > 0);
- //}
- //查询条件()
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.GrademajorStr)
- .ThenByDescending(x => x.ChargeYear).ThenBy(x => x.ChargeProjectStr)
- .ToGridResultSet<ChargeStandardView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询收费标准信息列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <returns></returns>
- public List<ChargeStandardView> GetChargeStandardList(ConfiguretView configuretView, Guid? collegeID, int? yearID, int? standardID,
- int? learningformID, int? chargeYearID, Guid? chargeProjectID, string LearnSystem, int? educationID, int? inSchoolStatus)
- {
- Expression<Func<EC_ChargeStandard, bool>> expChargeStandard = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (chargeYearID.HasValue)
- {
- //缴费学年
- expChargeStandard = expChargeStandard.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- //收费项目
- expChargeStandard = expChargeStandard.And(x => x.ChargeProjectID == chargeProjectID);
- }
- 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 = ChargeStandardDAL.GetChargeStandarViewQueryAble(expChargeStandard, expStudent);
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.GradeStr == 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);
- }
- ////去掉学生人数为0的数据
- //if (inSchoolStatus != null && inSchoolStatus > -1)
- //{
- // query = query.Where(x => x.StudentCount > 0);
- //}
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- string conditionValue = string.Empty;
- Regex rg = new Regex(@"^[0-9]*$");
- if (rg.IsMatch(configuretView.ConditionValue))
- conditionValue = Convert.ToInt32(configuretView.ConditionValue).ToString();
- else
- conditionValue = configuretView.ConditionValue;
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, conditionValue);
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.GrademajorStr).ThenByDescending(x => x.ChargeYear)
- .ThenBy(x => x.ChargeProjectStr).ToList();
- }
- /// <summary>
- /// 查询收费标准新增年级专业列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradeMajorID"></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="inschoolstatus"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<GrademajorView> GetGradeMajorViewGrid(ConfiguretView configuretView, Guid? gradeMajorID,
- Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID,
- string learnSystem, int? inSchoolStatus, int? chargeYearID, Guid? chargeProjectID, int pageIndex, int pageSize)
- {
- Expression<Func<EC_ChargeStandard, bool>> expChargeStandard = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (chargeYearID!=null && chargeYearID.HasValue)
- {
- //缴费学年
- expChargeStandard = expChargeStandard.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID != null && chargeProjectID.HasValue)
- {
- //收费项目
- expChargeStandard = expChargeStandard.And(x => x.ChargeProjectID == chargeProjectID);
- }
- 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 = ChargeStandardDAL.GetGradeMajorViewQueryAble(expChargeStandard, expStudent);
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.GradeID == 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);
- }
- //去掉学生人数为0的数据(去除人数为0的年级专业,但选全部时可不去除)
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- query = query.Where(x => x.StudentCount > 0);
- }
- //查询条件()
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.GradeID)
- .OrderBy(x=>x.StandardID).OrderBy(x=>x.EducationID).OrderBy(x=>x.LearningformID)
- .OrderBy(x=>x.LearnSystem).OrderBy(x=>x.Name)
- .ToGridResultSet<GrademajorView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 刷新名单(生成对应的收费标准应收名单,注:目前只对不在应收名单中的学生进行插入操作)
- /// </summary>
- /// <param name="chargeStandardIDs"></param>
- /// <param name="inschoolstatus"></param>
- /// <returns></returns>
- public string CreatStudentChargeList(List<Guid?> chargeStandardIDs, int? inschoolStatus)
- {
- try
- {
- //查询收费标准信息
- var chargeStandardList = ChargeStandardDAL.ChargeStandardRepository
- .GetList(x => chargeStandardIDs.Contains(x.ChargeStandardID)).ToList();
- //获取年级专业列表
- var gradeMajorIDList = chargeStandardList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString()))
- .Select(x => x.GrademajorID).ToList();
- //获取缴费学年列表
- var chargeYearIDList = chargeStandardList.Where(x => !string.IsNullOrEmpty(x.ChargeYear.ToString()))
- .Select(x => x.ChargeYear).ToList();
- //获取收费项目列表
- var chargeProjectIDList = chargeStandardList.Where(x => !string.IsNullOrEmpty(x.ChargeProjectID.ToString()))
- .Select(x => x.ChargeProjectID).ToList();
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => true);
- if (chargeYearIDList != null && chargeYearIDList.Count() > 0)
- {
- expStudentCharge = expStudentCharge.And(x => chargeYearIDList.Contains(x.ChargeYear));
- }
- if (chargeProjectIDList != null && chargeProjectIDList.Count() > 0)
- {
- expStudentCharge = expStudentCharge.And(x => chargeProjectIDList.Contains(x.ChargeProjectID));
- }
- //查询当前应收名单信息(根据应收名单、年级专业查询)
- var studentChargeViewList = ChargeStandardDAL.GetGradeMajorStudentChargeViewQueryAble(expStudentCharge,
- x => gradeMajorIDList.Contains(x.GrademajorID)).ToList();
- //在校状态
- 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));
- }
- }
- //查询各年级专业对应的学生信息List(含在校状态)
- var gradeMajorStudentList = ChargeStandardDAL.GetGradeMajorStudentViewQueryAble(x => gradeMajorIDList.Contains(x.GrademajorID),
- expStudent).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- //注:只对不在应收名单中的学生进行插入操作
- List<EC_StudentCharge> studentChargeInList = new List<EC_StudentCharge>();
- foreach (var chargeStandard in chargeStandardList)
- {
- //收费标准信息验证
- var chargeStandardVerify = chargeStandardList.Where(x => x.ChargeStandardID == chargeStandard.ChargeStandardID)
- .SingleOrDefault();
- if (chargeStandardVerify != null)
- {
- //查询对应的应收名单List
- var studentChargeList = studentChargeViewList.Where(x => x.ChargeYear == chargeStandardVerify.ChargeYear
- && x.ChargeProjectID == chargeStandardVerify.ChargeProjectID
- && x.GradeMajorID == chargeStandardVerify.GrademajorID).ToList();
- //查询年级专业对应的学生信息List(含在校状态)
- var studentIDList = gradeMajorStudentList.Where(x => x.GradeMajorID == chargeStandardVerify.GrademajorID)
- .Select(x => x.UserID).ToList();
- if (studentIDList != null && studentIDList.Count() > 0)
- {
- foreach (var studentID in studentIDList)
- {
- //对应的应收名单信息
- var studentChargeVerify = studentChargeList.Where(x => x.UserID == studentID)
- .SingleOrDefault();
- if (studentChargeVerify == null)
- {
- //表示不存在对应的应收名单
- EC_StudentCharge studentCharge = new EC_StudentCharge();
- studentCharge.StudentChargeID = Guid.NewGuid();
- studentCharge.UserID = studentID;
- studentCharge.ChargeProjectID = chargeStandardVerify.ChargeProjectID;
- studentCharge.ChargeYear = chargeStandardVerify.ChargeYear;
- studentCharge.Amount = chargeStandardVerify.Amount;
- studentCharge.ActualAmount = studentCharge.Amount; //减免后金额
- studentCharge.ChargeTag = (int)EC_ChargeTag.Normal; //默认为正常收费
- SetNewStatus(studentCharge, (int)SYS_STATUS.USABLE);
- studentChargeInList.Add(studentCharge);
- }
- else
- {
- //表示已存在对应的应收名单(可做更新)
- }
- }
- }
- else
- {
- //表示学生信息为空
- }
- success++;
- }
- else
- {
- //数据有误,刷新失败
- fail++;
- }
- }
- if (studentChargeInList != null && studentChargeInList.Count() > 0)
- {
- //批量插入
- UnitOfWork.BulkInsert<EC_StudentCharge>(studentChargeInList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:选择刷新的数据有误,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 收费标准新增(批量新增,同时生成应收名单)
- /// </summary>
- /// <param name="gradeMajorIDs"></param>
- /// <param name="chargeStandardView"></param>
- /// <returns></returns>
- public string ChargeStandardAdd(List<Guid?> gradeMajorIDs, ChargeStandardView chargeStandardView)
- {
- try
- {
- //收费标准信息List
- var chargeStandardList = ChargeStandardDAL.ChargeStandardRepository
- .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- //在校状态
- Expression<Func<CF_Student, bool>> expStudent = (x => true);
- if (chargeStandardView.InSchoolStatus != null && chargeStandardView.InSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (chargeStandardView.InSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (chargeStandardView.InSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- //各年级专业对应的学生信息List(含在校状态)
- var gradeMajorStudentList = ChargeStandardDAL.GetGradeMajorStudentViewQueryAble(x => gradeMajorIDs.Contains(x.GrademajorID),
- expStudent).ToList();
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => true);
- if (chargeStandardView.ChargeYear != null && chargeStandardView.ChargeYear.HasValue)
- {
- //缴费学年
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeStandardView.ChargeYear);
- }
- if (chargeStandardView.ChargeProjectID != null && chargeStandardView.ChargeProjectID.HasValue)
- {
- //收费项目
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeStandardView.ChargeProjectID);
- }
- //查询应收名单信息
- var studentChargeViewList = ChargeStandardDAL.GetGradeMajorStudentChargeViewQueryAble(expStudentCharge,
- x => gradeMajorIDs.Contains(x.GrademajorID)).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<EC_ChargeStandard> chargeStandardInList = new List<EC_ChargeStandard>();
- List<EC_StudentCharge> studentChargeInList = new List<EC_StudentCharge>();
- //注:收费标准业务主键(年级专业ID、学年、收费项目ID)
- foreach (var gradeMajorID in gradeMajorIDs)
- {
- var chargeStandardVerify = chargeStandardList.Where(x => x.GrademajorID == gradeMajorID
- && x.ChargeYear == chargeStandardView.ChargeYear
- && x.ChargeProjectID == chargeStandardView.ChargeProjectID)
- .SingleOrDefault();
- if (chargeStandardVerify == null)
- {
- //表示收费标准不存在
- EC_ChargeStandard chargeStandard = new EC_ChargeStandard();
- chargeStandard.ChargeStandardID = Guid.NewGuid();
- chargeStandard.GrademajorID = gradeMajorID;
- chargeStandard.ChargeProjectID = chargeStandardView.ChargeProjectID;
- chargeStandard.ChargeYear = chargeStandardView.ChargeYear;
- chargeStandard.Amount = chargeStandardView.Amount;
- SetNewStatus(chargeStandard, (int)SYS_STATUS.USABLE);
- chargeStandardInList.Add(chargeStandard);
- //查询年级专业对应的学生信息ID(含在校状态)
- var studentIDList = gradeMajorStudentList.Where(x => x.GradeMajorID == gradeMajorID)
- .Select(x => x.UserID).ToList();
- if (studentIDList != null && studentIDList.Count() > 0)
- {
- foreach (var studentID in studentIDList)
- {
- //对应的应收名单信息
- var studentChargeVerify = studentChargeViewList.Where(x => x.UserID == studentID)
- .SingleOrDefault();
- if (studentChargeVerify == null)
- {
- //表示不存在对应的应收名单
- EC_StudentCharge studentCharge = new EC_StudentCharge();
- studentCharge.StudentChargeID = Guid.NewGuid();
- studentCharge.UserID = studentID;
- studentCharge.ChargeProjectID = chargeStandardView.ChargeProjectID;
- studentCharge.ChargeYear = chargeStandardView.ChargeYear;
- studentCharge.Amount = chargeStandardView.Amount;
- studentCharge.ActualAmount = studentCharge.Amount; //减免后金额
- studentCharge.ChargeTag = (int)EC_ChargeTag.Normal; //默认为正常收费
- SetNewStatus(studentCharge, (int)SYS_STATUS.USABLE);
- studentChargeInList.Add(studentCharge);
- }
- else
- {
- //表示已存在对应的应收名单(可做更新)
- }
- }
- }
- else
- {
- //表示学生信息为空
- }
- success++;
- }
- else
- {
- //表示已存在相同的收费标准
- fail++;
- }
- }
- //批量插入
- UnitOfWork.BulkInsert<EC_ChargeStandard>(chargeStandardInList);
- UnitOfWork.BulkInsert<EC_StudentCharge>(studentChargeInList);
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的收费标准,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 获取年级专业各在校状态学生
- /// </summary>
- /// <param name="grademajorID"></param>
- /// <param name="inschoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentsView> GetGradeMajorStudentViewGrid(Guid? grademajorID, int? inschoolStatus, int pageIndex, int pageSize)
- {
- //在校状态
- 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 = ChargeStandardDAL.GetGradeMajorStudentViewQueryAble(x => x.GrademajorID == grademajorID, expStudent);
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.ClassMajorCode.Length)
- .OrderBy(x => x.ClassMajorCode).OrderBy(x => x.LoginID)
- .ToGridResultSet<StudentsView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 获取年级专业各在校状态学生
- /// </summary>
- /// <param name="grademajorID"></param>
- /// <param name="inschoolStatus"></param>
- /// <returns></returns>
- public List<StudentsView> GetGradeMajorStudentViewGrid(Guid? grademajorID, int? inschoolStatus)
- {
- //在校状态
- 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 = ChargeStandardDAL.GetGradeMajorStudentViewQueryAble(x => x.GrademajorID == grademajorID, expStudent);
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.ClassMajorCode.Length)
- .OrderBy(x => x.ClassMajorCode).OrderBy(x => x.LoginID)
- .ToList();
- }
- /// <summary>
- /// 获取收费标准对应的年级专业应收名单
- /// </summary>
- /// <param name="grademajorID"></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<StudentChargeView> GetGradeMajorStudentChargeViewGrid(Guid? grademajorID, int? chargeYearID, Guid? chargeProjectID, int? inschoolStatus, int pageIndex, int pageSize)
- {
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => true);
- if (chargeYearID != null && chargeYearID.HasValue)
- {
- //缴费学年
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID != null && chargeProjectID.HasValue)
- {
- //收费项目
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- //在校状态
- 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));
- }
- }
- //年级专业
- Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => true);
- if (grademajorID != null && grademajorID.HasValue)
- {
- expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
- }
- var query = ChargeStandardDAL.GetGradeMajorStudentChargeViewQueryAble(expStudentCharge, expGrademajor);
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.ClassNo.Length)
- .OrderBy(x => x.ClassNo).OrderBy(x => x.StudentNo)
- .ToGridResultSet<StudentChargeView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 获取收费标准对应的年级专业应收名单
- /// </summary>
- /// <param name="grademajorID"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <param name="inschoolStatus"></param>
- /// <returns></returns>
- public List<StudentChargeView> GetGradeMajorStudentChargeViewGrid(Guid? grademajorID, int? chargeYearID, Guid? chargeProjectID, int? inschoolStatus)
- {
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => true);
- if (chargeYearID != null && chargeYearID.HasValue)
- {
- //缴费学年
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID != null && chargeProjectID.HasValue)
- {
- //收费项目
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- //在校状态
- 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));
- }
- }
- //年级专业
- Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => true);
- if (grademajorID != null && grademajorID.HasValue)
- {
- expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
- }
- var query = ChargeStandardDAL.GetGradeMajorStudentChargeViewQueryAble(expStudentCharge, expGrademajor);
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.ClassNo.Length)
- .OrderBy(x => x.ClassNo).OrderBy(x => x.StudentNo)
- .ToList();
- }
- /// <summary>
- /// 查询收费标准信息View(ChargeStandardView)
- /// </summary>
- /// <param name="chargeStandardID"></param>
- /// <returns></returns>
- public ChargeStandardView GetChargeStandardView(Guid? chargeStandardID)
- {
- var query = ChargeStandardDAL.GetChargeStandarViewQueryAble(x => x.ChargeStandardID == chargeStandardID, x => true);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 查询收费标准信息实体
- /// </summary>
- /// <param name="chargeStandardID"></param>
- /// <returns></returns>
- public Entities.EC_ChargeStandard GetChargeStandard(Guid? chargeStandardID)
- {
- System.Linq.Expressions.Expression<Func<EC_ChargeStandard, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.ChargeStandardID == chargeStandardID);
- return ChargeStandardDAL.ChargeStandardRepository.GetSingle(expression);
- }
-
- /// <summary>
- /// 查询应收名单实体
- /// </summary>
- /// <param name="studentChargeID"></param>
- /// <returns></returns>
- public EC_StudentCharge GetStudentCharge(Guid? studentChargeID)
- {
- System.Linq.Expressions.Expression<Func<EC_StudentCharge, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.StudentChargeID == studentChargeID);
- return ChargeStandardDAL.StudentChargeRepository.GetSingle(expression);
- }
- /// <summary>
- /// 新增、修改(处理方式:当存在对应的应收名单时,无法修改)
- /// </summary>
- /// <param name="chargeStandardView"></param>
- /// <returns></returns>
- public void ChargeStandardEdit(ChargeStandardView chargeStandardView)
- {
- try
- {
- //查询数据库进行验证(需排除自己)
- var chargeStandardVerification = ChargeStandardDAL.ChargeStandardRepository.GetList(x => x.ChargeStandardID != chargeStandardView.ChargeStandardID
- && x.GrademajorID == chargeStandardView.GrademajorID
- && x.ChargeYear == chargeStandardView.ChargeYear
- && x.ChargeProjectID == chargeStandardView.ChargeProjectID)
- .SingleOrDefault();
- if (chargeStandardVerification == null)
- {
- //数据有误验证
- if (chargeStandardView.ChargeStandardID != Guid.Empty)
- {
- //表示修改
- var chargeStandard = ChargeStandardDAL.ChargeStandardRepository
- .GetList(x => x.ChargeStandardID == chargeStandardView.ChargeStandardID)
- .SingleOrDefault();
- if (chargeStandard == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => true);
- if (chargeStandard.ChargeYear != null && chargeStandard.ChargeYear.HasValue)
- {
- //缴费学年
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeStandard.ChargeYear);
- }
- if (chargeStandard.ChargeProjectID != null && chargeStandard.ChargeProjectID.HasValue)
- {
- //收费项目
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeStandard.ChargeProjectID);
- }
- //年级专业
- Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => true);
- if (chargeStandard.GrademajorID != null && chargeStandard.GrademajorID.HasValue)
- {
- expGrademajor = expGrademajor.And(x => x.GrademajorID == chargeStandard.GrademajorID);
- }
- //查询应收名单信息(业务主键:年级专业ID、缴费学年、收费项目ID)
- var studentChargeList = ChargeStandardDAL.GetGradeMajorStudentChargeViewQueryAble(expStudentCharge, expGrademajor).ToList();
-
- if (studentChargeList != null && studentChargeList.Count() > 0)
- {
- //表示已存在应收名单
- throw new Exception("已生成应收名单,如需修改请删除相关的应收名单信息");
- }
- else
- {
- //chargeStandard.GrademajorID = chargeStandardView.GrademajorID;
- //chargeStandard.ChargeProjectID = chargeStandardView.ChargeProjectID;
- //chargeStandard.ChargeYear = chargeStandardView.ChargeYear;
- chargeStandard.Amount = chargeStandardView.Amount;
- SetModifyStatus(chargeStandard);
- }
- }
- }
- else
- {
- //表示新增
- EC_ChargeStandard chargeStandard = new EC_ChargeStandard();
- chargeStandard.ChargeStandardID = Guid.NewGuid();
- chargeStandard.GrademajorID = chargeStandardView.GrademajorID;
- chargeStandard.ChargeProjectID = chargeStandardView.ChargeProjectID;
- chargeStandard.ChargeYear = chargeStandardView.ChargeYear;
- chargeStandard.Amount = chargeStandardView.Amount;
- SetNewStatus(chargeStandard, (int)SYS_STATUS.USABLE);
- UnitOfWork.Add(chargeStandard);
- }
- }
- else
- {
- throw new Exception("已存在相同的收费标准,请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
- /// <summary>
- /// 删除(当选择删除的信息中存在的应收名单时,无法删除)
- /// </summary>
- /// <param name="chargeStandardIDs"></param>
- /// <returns></returns>
- public bool ChargeStandardDelete(List<Guid> chargeStandardIDs)
- {
- try
- {
- //查询收费标准信息List
- var chargeStandardList = ChargeStandardDAL.ChargeStandardRepository
- .GetList(x => chargeStandardIDs.Contains(x.ChargeStandardID)).ToList();
- //年级专业IDList
- var gradeMajorIDList = chargeStandardList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString()))
- .Select(x => x.GrademajorID).ToList();
- //缴费学年IDList
- var chargeYearIDList = chargeStandardList.Where(x => !string.IsNullOrEmpty(x.ChargeYear.ToString()))
- .Select(x => x.ChargeYear).ToList();
- //收费项目IDList
- var chargeProjectIDList = chargeStandardList.Where(x => !string.IsNullOrEmpty(x.ChargeProjectID.ToString()))
- .Select(x => x.ChargeProjectID).ToList();
- //年级专业
- Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => true);
- if (gradeMajorIDList != null && gradeMajorIDList.Count() > 0)
- {
- expGrademajor = expGrademajor.And(x => gradeMajorIDList.Contains(x.GrademajorID));
- }
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => true);
- if (chargeYearIDList != null && chargeYearIDList.Count() > 0)
- {
- //缴费学年
- expStudentCharge = expStudentCharge.And(x => chargeYearIDList.Contains(x.ChargeYear));
- }
- if (chargeProjectIDList != null && chargeProjectIDList.Count() > 0)
- {
- //收费项目
- expStudentCharge = expStudentCharge.And(x => chargeProjectIDList.Contains(x.ChargeProjectID));
- }
- //查询应收名单信息(业务主键:年级专业ID、缴费学年、收费项目ID)
- var studentChargeList = ChargeStandardDAL.GetGradeMajorStudentChargeViewQueryAble(expStudentCharge, expGrademajor).ToList();
- //注:由于用户会选择多条信息进行删除
- //目前的删除逻辑暂时不处理更进一步的删除操作(如:同时存在可删除、不可删除的信息)
- if (studentChargeList != null && studentChargeList.Count() > 0)
- {
- //表示已存在应收名单
- throw new Exception("选择删除的信息中存在相应的应收名单,如需删除,请删除相关的应收名单信息。");
- }
- else
- {
- UnitOfWork.Delete<EC_ChargeStandard>(x => chargeStandardIDs.Contains(x.ChargeStandardID));
- }
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 收费标准验证(业务主键:年级专业ID、缴费学年、收费项目ID)
- /// </summary>
- /// <param name="chargeStandardID"></param>
- /// <param name="grademajorID"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- public string GetVerification(Guid? chargeStandardID, Guid? grademajorID, int? chargeYearID, Guid? chargeProjectID)
- {
- //查询数据库进行验证(需排除自己)
- var chargeStandard = ChargeStandardDAL.ChargeStandardRepository.GetList(x => x.ChargeStandardID != chargeStandardID
- && x.GrademajorID == grademajorID
- && x.ChargeYear == chargeYearID
- && x.ChargeProjectID == chargeProjectID)
- .SingleOrDefault();
- if (chargeStandard == null)
- {
- //数据有误验证
- if (chargeStandardID.HasValue && chargeStandardID != Guid.Empty)
- {
- chargeStandard = ChargeStandardDAL.ChargeStandardRepository.GetList(x => x.ChargeStandardID == chargeStandardID)
- .SingleOrDefault();
- if (chargeStandard == null)
- {
- return "数据有误,请核查";
- }
- else
- {
- return "成功";
- }
- }
- else
- {
- return "成功";
- }
- }
- else
- {
- return "已存在相同的收费标准";
- }
- }
- }
- }
|