@@ -423,4 +423,42 @@ LessonTime | |||
16:20-17:05,17:15-18:00 两节课的时间 | |||
根据身份证号更新照片接口 | |||
标准http post请求 | |||
地址: | |||
http://部署地址/EducationalAdministration/EmpRegister/updatePhotoByIdCard | |||
所需参数:(限制一次最多传值50条) | |||
参数名称 | |||
值 | |||
备注 | |||
IdCard | |||
身份证号 | |||
PhotoUrl | |||
照片地址 | |||
IdentityFlag | |||
1、2 | |||
身份标识(1老师,2学生) | |||
主要业务数据 其余字段可忽略 | |||
属性 | |||
返回值 | |||
备注 | |||
可否为空 | |||
IdCard | |||
身份证号 | |||
OperateFlag | |||
true , false | |||
操作标识(true更新成功,false更新失败) | |||
FailMsg | |||
更新失败原因 | |||
@@ -309,7 +309,16 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||
{ | |||
return Fail("请先安排课程!"); | |||
} | |||
exam_ExamPlanLessonIBLL.PlanLessonTimeByEPId(keyValue); | |||
var res = exam_ExamPlanLessonIBLL.PlanLessonTimeByEPId(keyValue); | |||
if (res.flag) | |||
{ | |||
return Success("操作成功!"); | |||
} | |||
else | |||
{ | |||
return Fail(res.msg); | |||
} | |||
return Success("操作成功!"); | |||
} | |||
@@ -6,6 +6,8 @@ using static Learun.Application.WebApi.Modules.StuInfoFreshApi; | |||
using System; | |||
using System.IO; | |||
using Learun.Application.Base.SystemModule; | |||
using System.Net; | |||
using System.Linq; | |||
namespace Learun.Application.WebApi | |||
{ | |||
@@ -22,6 +24,7 @@ namespace Learun.Application.WebApi | |||
private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL(); | |||
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); | |||
private TeachSwitchIBLL teachSwitchIBLL = new TeachSwitchBLL(); | |||
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL(); | |||
/// <summary> | |||
/// 注册接口 | |||
@@ -38,6 +41,8 @@ namespace Learun.Application.WebApi | |||
Post["/savePhoto"] = GetSavePhoto; | |||
Get["/registerbutton"] = RegisterButton; | |||
Post["/signon"] = Signon; | |||
//根据身份证号更新学生和老师的照片 | |||
Post["/updatePhotoByIdCard"] = UpdatePhotoByIdCard; | |||
} | |||
private Response Signon(dynamic _) | |||
@@ -190,6 +195,173 @@ namespace Learun.Application.WebApi | |||
empInfoIBLL.SaveEntity(this.userInfo, parameter.keyValue, entity); | |||
return Success("保存成功!"); | |||
} | |||
/// <summary> | |||
/// 根据身份证号更新学生和老师的照片 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
private Response UpdatePhotoByIdCard(dynamic _) | |||
{ | |||
//传参 | |||
var requestModels = this.GetReq<List<RequestModel>>(); | |||
//回参 | |||
var responseModels = new List<ResponseModel>(); | |||
//限制每次最多传值50条 | |||
if (requestModels.Count() > 50) | |||
{ | |||
return Fail("限制每次最多传值50条"); | |||
} | |||
//图片保存的文件夹地址 | |||
string FileEextension = ".png"; | |||
string directoryPathOfEmp = string.Format("{0}/{1}/{2}", Config.GetValue("AnnexesFile"), "ApiOfUpdatePhotoByIdCard", "Teacher"); | |||
string directoryPathOfStu = string.Format("{0}/{1}/{2}", Config.GetValue("AnnexesFile"), "ApiOfUpdatePhotoByIdCard", "Student"); | |||
if (!Directory.Exists(directoryPathOfEmp)) | |||
{ | |||
Directory.CreateDirectory(directoryPathOfEmp); | |||
}; | |||
if (!Directory.Exists(directoryPathOfStu)) | |||
{ | |||
Directory.CreateDirectory(directoryPathOfStu); | |||
}; | |||
//循环处理 | |||
foreach (var item in requestModels) | |||
{ | |||
if (item.IdentityFlag == 1)//老师 | |||
{ | |||
var entity = empInfoIBLL.GetEmpInfoEntityByIdCard(item.IdCard); | |||
if (entity == null) | |||
{ | |||
var pmodel = new ResponseModel() | |||
{ | |||
IdCard=item.IdCard, | |||
OperateFlag=false, | |||
FailMsg="该身份证号的教师信息不存在!" | |||
}; | |||
responseModels.Add(pmodel); | |||
} | |||
else | |||
{ | |||
//图片地址 | |||
var imgPath = string.Format("{0}/{1}{2}", directoryPathOfEmp, item.IdCard, FileEextension); | |||
if (!System.IO.File.Exists(imgPath)) | |||
{ | |||
//下载图片到本地 | |||
WebClient my = new WebClient(); | |||
byte[] mybyte = my.DownloadData(item.PhotoUrl); | |||
FileInfo file = new FileInfo(imgPath); | |||
FileStream fs = file.Create(); | |||
fs.Write(mybyte, 0, mybyte.Length); | |||
fs.Close(); | |||
//图片地址保存到LR_Base_AnnexesFile表中 | |||
var folderId = Guid.NewGuid().ToString(); | |||
AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); | |||
fileAnnexesEntity.F_Id = Guid.NewGuid().ToString(); | |||
fileAnnexesEntity.F_FileName =string.Format("{0}{1}",item.IdCard,FileEextension); | |||
fileAnnexesEntity.F_FilePath = imgPath; | |||
fileAnnexesEntity.F_FileSize = mybyte.Length.ToString(); | |||
fileAnnexesEntity.F_FileExtensions = FileEextension; | |||
fileAnnexesEntity.F_FileType = FileEextension.Replace(".", ""); | |||
annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); | |||
//更新EmpInfo表照片字段 | |||
entity.Photo = folderId; | |||
empInfoIBLL.SaveEntity(entity.EmpId, entity); | |||
//回参 | |||
var pmodel = new ResponseModel() | |||
{ | |||
IdCard = item.IdCard, | |||
OperateFlag = true | |||
}; | |||
responseModels.Add(pmodel); | |||
} | |||
else | |||
{ | |||
var pmodel = new ResponseModel() | |||
{ | |||
IdCard = item.IdCard, | |||
OperateFlag = false, | |||
FailMsg = "该身份证号的图片已存在!" | |||
}; | |||
responseModels.Add(pmodel); | |||
} | |||
} | |||
} | |||
else if(item.IdentityFlag == 2)//学生 | |||
{ | |||
var entity = stuInfoBasicIBLL.GetStuInfoBasicEntityByIdCard(item.IdCard); | |||
if (entity == null) | |||
{ | |||
var pmodel = new ResponseModel() | |||
{ | |||
IdCard = item.IdCard, | |||
OperateFlag = false, | |||
FailMsg = "该身份证号的学生信息不存在!" | |||
}; | |||
responseModels.Add(pmodel); | |||
} | |||
else | |||
{ | |||
//图片地址 | |||
var imgPath = string.Format("{0}/{1}{2}", directoryPathOfStu, item.IdCard, FileEextension); | |||
if (!System.IO.File.Exists(imgPath)) | |||
{ | |||
//下载图片到本地 | |||
WebClient my = new WebClient(); | |||
byte[] mybyte = my.DownloadData(item.PhotoUrl); | |||
FileInfo file = new FileInfo(imgPath); | |||
FileStream fs = file.Create(); | |||
fs.Write(mybyte, 0, mybyte.Length); | |||
fs.Close(); | |||
//图片地址保存到LR_Base_AnnexesFile表中 | |||
var folderId = Guid.NewGuid().ToString(); | |||
AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); | |||
fileAnnexesEntity.F_Id = Guid.NewGuid().ToString(); | |||
fileAnnexesEntity.F_FileName = string.Format("{0}{1}", item.IdCard, FileEextension); | |||
fileAnnexesEntity.F_FilePath = imgPath; | |||
fileAnnexesEntity.F_FileSize = mybyte.Length.ToString(); | |||
fileAnnexesEntity.F_FileExtensions = FileEextension; | |||
fileAnnexesEntity.F_FileType = FileEextension.Replace(".", ""); | |||
annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); | |||
//更新StuInfoBasic表照片字段 | |||
entity.Photo = folderId; | |||
stuInfoBasicIBLL.SaveEntity(entity.StuId, entity); | |||
//回参 | |||
var pmodel = new ResponseModel() | |||
{ | |||
IdCard = item.IdCard, | |||
OperateFlag = true | |||
}; | |||
responseModels.Add(pmodel); | |||
} | |||
else | |||
{ | |||
var pmodel = new ResponseModel() | |||
{ | |||
IdCard = item.IdCard, | |||
OperateFlag = false, | |||
FailMsg = "该身份证号的图片已存在!" | |||
}; | |||
responseModels.Add(pmodel); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
var pmodel = new ResponseModel() | |||
{ | |||
IdCard = item.IdCard, | |||
OperateFlag = false, | |||
FailMsg = "身份标识不存在!" | |||
}; | |||
responseModels.Add(pmodel); | |||
} | |||
} | |||
return Success(responseModels); | |||
} | |||
#endregion | |||
#region 私有类 | |||
@@ -202,6 +374,43 @@ namespace Learun.Application.WebApi | |||
public string keyValue { get; set; } | |||
public string strEntity { get; set; } | |||
} | |||
/// <summary> | |||
/// 更新照片传参 | |||
/// </summary> | |||
private class RequestModel | |||
{ | |||
/// <summary> | |||
/// 身份证号 | |||
/// </summary> | |||
public string IdCard { get; set; } | |||
/// <summary> | |||
/// 照片地址 | |||
/// </summary> | |||
public string PhotoUrl { get; set; } | |||
/// <summary> | |||
/// 身份标识(1老师,2学生) | |||
/// </summary> | |||
public int IdentityFlag { get; set; } | |||
} | |||
/// <summary> | |||
/// 更新照片回参 | |||
/// </summary> | |||
private class ResponseModel | |||
{ | |||
/// <summary> | |||
/// 身份证号 | |||
/// </summary> | |||
public string IdCard { get; set; } | |||
/// <summary> | |||
/// 操作标识(true更新成功,false更新失败) | |||
/// </summary> | |||
public bool OperateFlag { get; set; } | |||
/// <summary> | |||
/// 更新失败原因 | |||
/// </summary> | |||
public string FailMsg { get; set; } | |||
} | |||
#endregion | |||
} |
@@ -144,6 +144,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
} | |||
} | |||
} | |||
public EmpInfoEntity GetEmpInfoEntityByIdCard(string idcard) | |||
{ | |||
try | |||
{ | |||
return empInfoService.GetEmpInfoEntityByIdCard(idcard); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 教师年龄比例 | |||
/// </summary> | |||
@@ -39,6 +39,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
IEnumerable<EmpInfoEntity> GetList(string queryJson); | |||
IEnumerable<EmpInfoEntity> GetEmpInfoEntitiesByName(string name); | |||
EmpInfoEntity GetEmpInfoEntityByIdCard(string idcard); | |||
/// <summary> | |||
/// 教师年龄比例 | |||
/// </summary> | |||
@@ -349,6 +349,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
} | |||
} | |||
} | |||
public EmpInfoEntity GetEmpInfoEntityByIdCard(string idcard) | |||
{ | |||
try | |||
{ | |||
return this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(m => m.IdentityCardNo == idcard); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 教师年龄比例 | |||
/// </summary> | |||
@@ -112,7 +112,17 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
/// 考试时长 | |||
/// </summary> | |||
[NotMapped] | |||
public int? ExamLength { get; set; } | |||
public double? ExamLength { get; set; } | |||
/// <summary> | |||
/// 课程类型 | |||
/// </summary> | |||
[NotMapped] | |||
public string LessonTypeName { get; set; } | |||
/// <summary> | |||
/// 专业 | |||
/// </summary> | |||
[NotMapped] | |||
public string TeachMajorNo { get; set; } | |||
#endregion | |||
} | |||
@@ -419,36 +419,108 @@ and AcademicYearNo='{exam_ExamPlan.AcademicYearNo}' and Semester='{exam_ExamPlan | |||
/// <returns></returns> | |||
public (bool flag, string msg) PlanLessonTimeByEPId(string EPId) | |||
{ | |||
var db = this.BaseRepository("CollegeMIS"); | |||
try | |||
{ | |||
/* | |||
* 1.查询考试记录是否已安排时间 | |||
* 1.查询考试记录是否已批量安排公共课专业课时间 | |||
* 2.查询考试课程的考试时长是否大于0 | |||
* 3.同一时间段内只能一个专业安排一门课程 | |||
* 3.清除考试课程时间 重新安排 | |||
* 4.同一时间段内只能一个专业安排一门课程 | |||
*/ | |||
db.BeginTrans(); | |||
//考试记录 | |||
var examPlan = db.FindEntity<Exam_ExamPlanEntity>(EPId); | |||
//安排时间数据 | |||
var EPTimeList = this.BaseRepository("CollegeMIS") | |||
.FindList<Exam_ExamPlanTimeEntity>(x => x.EPId == EPId); | |||
var EPTimeList = db.FindList<Exam_ExamPlanTimeEntity>(x => x.EPId == EPId); | |||
if (EPTimeList.Count() <= 0) | |||
{ | |||
return (false, "请先安排考试记录时间!"); | |||
} | |||
//考试课程数据 | |||
var EPLessonList = this.BaseRepository("CollegeMIS") | |||
.FindList<Exam_ExamPlanLessonEntity>($@"select elesson.ExamTime as ExamLength,t.* from Exam_ExamPlanLesson t | |||
var EPLessonList = db.FindList<Exam_ExamPlanLessonEntity>($@" select distinct elesson.ExamTime as ExamLength,ltype.LessonTypeName,info.TeachMajorNo,t.* from Exam_ExamPlanLesson t | |||
join Exam_ExamLesson elesson on t.LessonNo=elesson.LessonNo | |||
where t.EPId='{EPId}'"); | |||
if (EPLessonList.ToList().Exists(x => x.ExamLength == null || x.ExamLength == 0)) | |||
left join LessonInfo info on t.LessonNo=info.LessonNo | |||
left join CdLessonType ltype on info.LessonTypeId=ltype.LTId | |||
where t.EPId='{EPId}' and info.CheckMark=1 "); | |||
if (examPlan.PlanType == "1") | |||
{ | |||
//必修 | |||
EPLessonList = db.FindList<Exam_ExamPlanLessonEntity>($@" select distinct elesson.ExamTime as ExamLength,ltype.LessonTypeName,info.TeachMajorNo,t.* from Exam_ExamPlanLesson t | |||
join Exam_ExamLesson elesson on left(t.LessonNo,charindex('(',t.LessonNo)-1)=elesson.LessonNo | |||
left join LessonInfo info on left(t.LessonNo,charindex('(',t.LessonNo)-1)=info.LessonNo | |||
left join CdLessonType ltype on info.LessonTypeId=ltype.LTId | |||
where t.EPId='{EPId}' and info.CheckMark=1 "); | |||
} | |||
if (EPLessonList.ToList().Exists(x => x.ExamLength == null || x.ExamLength <= 0)) | |||
{ | |||
return (false, "请先设置考试课程时长!"); | |||
} | |||
//清除考试时间 | |||
db.ExecuteBySql( | |||
$"update Exam_ExamPlanLesson set ExamDate=NULL,ExamTime=NULL where EPId='{EPId}'"); | |||
//循环考试课程数据,设置考试时间 | |||
foreach (var EPLesson in EPLessonList) | |||
{ | |||
if (EPLesson.LessonTypeName.Contains("公共") || EPLesson.LessonTypeName.Contains("公开")) | |||
{ | |||
var EPTimes = EPTimeList.Where(x => x.ExamType == "2" && x.ExamTimeLength == EPLesson.ExamLength).ToList(); | |||
foreach (var EPTime in EPTimes) | |||
{ | |||
var time = EPTime.ExamTimeStart + "-" + EPTime.ExamTimeEnd; | |||
//不存在同专业同时间段的考试课程,修改考试时间 | |||
if (!EPLessonList.ToList().Exists(x => | |||
x.TeachMajorNo == EPLesson.TeachMajorNo && x.ExamLength == EPTime.ExamTimeLength && x.ExamDate != null && | |||
x.ExamDate == EPTime.ExamDate && x.ExamTime == time)) | |||
{ | |||
EPLesson.ExamDate = EPTime.ExamDate; | |||
EPLesson.ExamTime = time; | |||
db.ExecuteBySql( | |||
$"update Exam_ExamPlanLesson set ExamDate='{EPTime.ExamDate}',ExamTime='{time}' where EPLId='{EPLesson.EPLId}'"); | |||
break; | |||
} | |||
else | |||
{ | |||
//存在同专业同时间段的考试课程,继续循环安排时间数据 | |||
continue; | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
//专业课 | |||
var EPTimes = EPTimeList.Where(x => x.ExamType == "1" && x.ExamTimeLength == EPLesson.ExamLength).ToList(); | |||
foreach (var EPTime in EPTimes) | |||
{ | |||
var time = EPTime.ExamTimeStart + "-" + EPTime.ExamTimeEnd; | |||
//不存在同专业同时间段的考试课程,修改考试时间 | |||
if (!EPLessonList.ToList().Exists(x => | |||
x.TeachMajorNo == EPLesson.TeachMajorNo && x.ExamLength == EPTime.ExamTimeLength && x.ExamDate != null && | |||
x.ExamDate == EPTime.ExamDate && x.ExamTime == time)) | |||
{ | |||
EPLesson.ExamDate = EPTime.ExamDate; | |||
EPLesson.ExamTime = time; | |||
db.ExecuteBySql( | |||
$"update Exam_ExamPlanLesson set ExamDate='{EPTime.ExamDate}',ExamTime='{time}' where EPLId='{EPLesson.EPLId}'"); | |||
break; | |||
} | |||
else | |||
{ | |||
//存在同专业同时间段的考试课程,继续循环安排时间数据 | |||
continue; | |||
} | |||
} | |||
} | |||
} | |||
db.Commit(); | |||
return (true, ""); | |||
} | |||
catch (Exception ex) | |||
{ | |||
db.Rollback(); | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
@@ -249,8 +249,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
} | |||
} | |||
} | |||
public StuInfoBasicEntity GetStuInfoBasicEntityByIdCard(string idcard) | |||
{ | |||
try | |||
{ | |||
return stuInfoBasicService.GetStuInfoBasicEntityByIdCard(idcard); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
@@ -41,6 +41,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
/// <summary> | |||
/// <returns></returns> | |||
List<TreeModel> GetTree(); | |||
StuInfoBasicEntity GetStuInfoBasicEntityByIdCard(string idcard); | |||
#endregion | |||
#region 提交数据 | |||
@@ -374,6 +374,25 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
} | |||
} | |||
public StuInfoBasicEntity GetStuInfoBasicEntityByIdCard(string idcard) | |||
{ | |||
try | |||
{ | |||
return this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(a => a.IdentityCardNo == idcard); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
#region 提交数据 | |||