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.ArrearsSituation;
using EMIS.DataLogic.ChargeManage.ArrearsSituation;
using System.Text.RegularExpressions;
using EMIS.CommonLogic.ChargeManage.ChargeSituation;
using EMIS.CommonLogic.StudentManage.StudentStatistics;
namespace EMIS.CommonLogic.ChargeManage.ArrearsSituation
{
public class ArrearsListServices : BaseServices, IArrearsListServices
{
public ArrearsListDAL ArrearsListDAL { get; set; }
public IInSchoolSettingServices InSchoolSettingServices { get; set; }
public IChargeDelayServices IChargeDelayServices { get; set; }
///
/// 查询欠费名单信息View(左连对应的缴费控制信息表)
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public IGridResultSet GetArrearListViewGrid(ConfiguretView configuretView, Guid? collegeID, int? yearID,
int? standardID, int? educationID, int? learningformID, string learnSystem, int? isArrear,
int? isControl, int? inSchoolStatus, int pageIndex, int pageSize)
{
//查询对应的全部流程环节信息(WorkflowStatusView)
var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
{
throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
}
//查询缓交申请工作流程结束环节状态ID(通过)
var chargeDelayEndStatus = IChargeDelayServices.GetCorrectEndStatus();
if (chargeDelayEndStatus == null)
{
throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
}
//应收名单
Expression> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
//缓交信息
Expression> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
//缓交申请(审核通过)
expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndStatus);
//学生信息
Expression> 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 = ArrearsListDAL.GetArrearListView(expStudentCharge, expChargeDelayPass, expStudent);
//欠费状态
if (isArrear.HasValue)
{
if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
{
query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
}
if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
{
query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
}
}
//登录控制
if (isControl.HasValue)
{
if (isControl.Value == (int)CF_GeneralPurpose.IsYes)
{
query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsYes);
}
if (isControl.Value == (int)CF_GeneralPurpose.IsNo)
{
query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsNo);
}
}
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);
}
//查询条件
if (!string.IsNullOrEmpty(configuretView.ConditionValue))
{
query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
}
return this.GetQueryByDataRangeByCollege(query)
.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
.ThenBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
.ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
.ToGridResultSet(pageIndex, pageSize);
}
///
/// 查询欠费名单信息View(左连对应的缴费控制信息表)
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public IGridResultSet GetArrearListViewGridForAdult(ConfiguretView configuretView, Guid? collegeID, int? yearID,
int? standardID, int? educationID, int? learningformID, string learnSystem, int? isArrear,
int? isControl, int? inSchoolStatus, int pageIndex, int pageSize)
{
//查询对应的全部流程环节信息(WorkflowStatusView)
var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
{
throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
}
//查询缓交申请工作流程结束环节状态ID(通过)
var chargeDelayEndStatus = IChargeDelayServices.GetCorrectEndStatus();
if (chargeDelayEndStatus == null)
{
throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
}
//应收名单
Expression> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
//缓交信息
Expression> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
//缓交申请(审核通过)
expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndStatus);
//学生信息
Expression> 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 = ArrearsListDAL.GetArrearListView(expStudentCharge, expChargeDelayPass, expStudent);
//欠费状态
if (isArrear.HasValue)
{
if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
{
query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
}
if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
{
query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
}
}
//登录控制
if (isControl.HasValue)
{
if (isControl.Value == (int)CF_GeneralPurpose.IsYes)
{
query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsYes);
}
if (isControl.Value == (int)CF_GeneralPurpose.IsNo)
{
query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsNo);
}
}
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);
}
//查询条件
if (!string.IsNullOrEmpty(configuretView.ConditionValue))
{
query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
}
query = query.Where(x => x.AmountSum > 0);
return this.GetQueryByDataRangeByCollege(query)
.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
.ThenBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
.ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
.ToGridResultSet(pageIndex, pageSize);
}
///
/// 查询欠费名单信息List(左连对应的缴费控制信息表)
///
///
///
///
///
///
///
///
///
///
///
///
public List GetArrearsListViewList(ConfiguretView configuretView, Guid? collegeID, int? yearID,
int? standardID, int? educationID, int? learningformID, string learnSystem, int? isArrear,
int? isControl, int? inSchoolStatus)
{
//查询对应的全部流程环节信息(WorkflowStatusView)
var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
{
throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
}
//查询缓交申请工作流程结束环节状态ID(通过)
var chargeDelayEndStatus = IChargeDelayServices.GetCorrectEndStatus();
if (chargeDelayEndStatus == null)
{
throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
}
//应收名单
Expression> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
//缓交信息
Expression> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
//缓交申请(审核通过)
expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndStatus);
//学生信息
Expression> 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 = ArrearsListDAL.GetArrearListView(expStudentCharge, expChargeDelayPass, expStudent);
//欠费状态
if (isArrear.HasValue)
{
if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
{
query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
}
if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
{
query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
}
}
//登录控制
if (isControl.HasValue)
{
if (isControl.Value == (int)CF_GeneralPurpose.IsYes)
{
query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsYes);
}
if (isControl.Value == (int)CF_GeneralPurpose.IsNo)
{
query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsNo);
}
}
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);
}
//查询条件
if (!string.IsNullOrEmpty(configuretView.ConditionValue))
{
query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
}
return this.GetQueryByDataRangeByCollege(query)
.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
.ThenBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
.ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
.ToList();
}
///
/// 查询对应的欠费信息ArrearsListView(根据用户信息ID)
///
///
///
public ArrearsListView GetArrearListView(Guid? userID)
{
try
{
//查询缓交申请工作流程结束环节状态ID(通过)
var chargeDelayEndStatus = IChargeDelayServices.GetCorrectEndStatus();
if (chargeDelayEndStatus == null)
{
throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
}
//应收名单
Expression> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
//userID
expStudentCharge = expStudentCharge.And(x => x.UserID == userID);
//缓交信息
Expression> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
//缓交申请(审核通过)
expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndStatus);
var arrearsListView = ArrearsListDAL.GetArrearListViewAble(expStudentCharge, expChargeDelayPass)
.SingleOrDefault();
return arrearsListView;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
///
/// 放行(个性化控制登录)
///
///
public void Pass(List userIDList)
{
try
{
//控制放行信息
Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
exp = exp.And(x => userIDList.Contains(x.UserID));
//查询控制放行信息
var passStudentViewList = ArrearsListDAL.GetPassStudentView(exp);
List passStudentInList = new List();
foreach (var userID in userIDList)
{
//查询对应的控制放行信息
var passStudentView = passStudentViewList.Where(x=>x.UserID == userID).SingleOrDefault();
if (passStudentView == null)
{
EC_PassStudent passStudent = new EC_PassStudent();
passStudent.PassStudentID = Guid.NewGuid();
passStudent.UserID = userID;
passStudent.Remark = "放行(个性化允许登录,不受欠费控制)";
SetNewStatus(passStudent, (int)SYS_STATUS.USABLE);
passStudentInList.Add(passStudent);
}
else
{
throw new Exception("数据有误,请核查");
}
}
//批量插入
UnitOfWork.BulkInsert(passStudentInList);
UnitOfWork.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
///
/// 控制(个性化控制登录)
///
///
public void Control(List userIDList)
{
try
{
UnitOfWork.Delete(x => userIDList.Contains(x.UserID));
UnitOfWork.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}