using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.CommonLogic.SystemServices;
using EMIS.ViewModel;
namespace EMIS.ExtensionLogic.ServiceLogic.GraduationManage
{
public class GraduationListServices : EMIS.CommonLogic.GraduationManage.GraduationManage.GraduationListServices
{
///
/// 流水号生成Services
///
public Lazy SerialNumberServices { get; set; }
///
/// 流程结束跳转函数(工作流平台中配置)
/// 注:毕业审核通过需对毕业证书编号进行生成(东莞理工学院)
/// 生成规则:学校代码+办学类型Value(1位)+毕业年份+培养层次类型Code(2位)+6位流水号
/// 例如:学校代码+成人高等继续教育+毕业年份+专科或本科+6位流水号,11819+2+2016+05或06+000001
///
///
///
public override void OnApproveEnd(List graduationApplyIDList, Guid? userID)
{
////更新对应的学生信息(如:在校状态、学籍状态、毕业日期)
//base.OnApproveEnd(graduationApplyIDList, userID);
//查询对应的毕业申请信息List
var graduationApplyList = GraduationApplyDAL.GraduationApplyRepository
.GetList(x => graduationApplyIDList.Contains(x.GraduationApplyID), (x => x.CF_Student)).ToList();
//查询对应的毕业申请信息ViewList
var graduationApplyViewList = GraduationApplyDAL
.GetGraduationApplyViewQueryable(x => graduationApplyIDList.Contains(x.GraduationApplyID)).ToList();
//查询毕业学期对应的毕业学期信息List
var graduatingSemesterIDList = graduationApplyList.Select(x => x.GraduatingSemesterID).ToList();
var graduateSchoolyearList = GraduationApplyDAL.GraduateSchoolyearRepository
.GetList(x => graduatingSemesterIDList.Contains(x.SchoolyearID)).ToList();
//更新对应的学生信息(如:在校状态、学籍状态、毕业日期、毕业证书编号)
foreach (var graduationApply in graduationApplyList)
{
graduationApply.CF_Student.InSchoolStatusID = (int)CF_InschoolStatus.Graduation;
graduationApply.CF_Student.StudentStatus = (int)CF_StudentStatus.Graduation;
//查询对应的毕业申请信息View
var graduationApplyView = graduationApplyViewList
.Where(x => x.GraduationApplyID == graduationApply.GraduationApplyID).SingleOrDefault();
//毕业证书编号生成(学校代码+办学类型Value(1位)+毕业年份+培养层次类型Code(2位)+6位流水号)
var graduateCardNoPrefix = string.Format("{0}{1}{2}{3}", graduationApplyView.UniversityCode,
graduationApplyView.SchoolTypeID ?? null,
graduationApplyView.GraduationYear ?? null,
graduationApplyView.EducationCode ?? null);
graduationApply.CF_Student.GraduateCardNo = SerialNumberServices.Value.SetSN(graduateCardNoPrefix, 6);
//毕业日期
foreach (var graduateSchoolyear in graduateSchoolyearList)
{
if (graduationApply.GraduatingSemesterID == graduateSchoolyear.SchoolyearID)
{
graduationApply.CF_Student.GraduateDate = graduateSchoolyear.GraduateDate;
}
}
this.SetModifyStatus(graduationApply.CF_Student);
}
var updateStudentList = graduationApplyList.Select(x => x.CF_Student).ToList();
this.UnitOfWork.BatchUpdate(updateStudentList);
}
}
}