From 5262d64d3821ad383066993f149e33f708cc7934 Mon Sep 17 00:00:00 2001 From: dyy <807692433@qq.com> Date: Tue, 10 Dec 2024 09:45:49 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91PC=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=A2=9E=E5=8A=A0=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=EF=BC=9B=E6=88=90=E7=BB=A9=E6=9F=A5=E7=9C=8B=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=9A=E6=80=BB=E5=88=86=E3=80=81=E6=8E=92=E5=90=8D=E5=8F=AA?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=80=83=E8=AF=95=E7=B1=BB=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StuScoreController.cs | 22 +- .../Views/StuScore/AllStuScoreQueryIndex.js | 1 + .../Controllers/LoginController.cs | 234 ++++++++++++++++-- .../Learun.Application.Web.csproj | 4 + .../Views/Login/Default.cshtml | 79 +++--- .../Views/Login/Default/Index.js | 90 ++++++- .../Modules/UserApi.cs | 18 +- .../OpenLessonPlan/OpenLessonPlanEntity.cs | 2 +- .../StuScore/StuScoreEntity.cs | 5 + .../StuScore/StuScoreService.cs | 45 ++-- .../LearunApp-2.2.0/pages/login.vue | 1 + 11 files changed, 419 insertions(+), 82 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs index 91ab3ea65..185d00c5a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs @@ -595,10 +595,10 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { var semesterAndYear = Common.GetSemesterAndYear(); var queryParam = queryJson.ToJObject(); - string year = queryParam["AcademicYearNo"].IsEmpty()? semesterAndYear.AcademicYearShort: queryParam["AcademicYearNo"].ToString(); + string year = queryParam["AcademicYearNo"].IsEmpty() ? semesterAndYear.AcademicYearShort : queryParam["AcademicYearNo"].ToString(); string semester = queryParam["Semester"].IsEmpty() ? semesterAndYear.AcademicYearShort : queryParam["Semester"].ToString(); var loginInfo = LoginUserInfo.Get(); - var data = stuScoreIBLL.GetLessonNoDataOfAll(loginInfo.account, loginInfo.Description,year, semester); + var data = stuScoreIBLL.GetLessonNoDataOfAll(loginInfo.account, loginInfo.Description, year, semester); foreach (var item in data) { item.text = string.Format("{0}({1})", item.text, item.value); @@ -733,30 +733,28 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers var data = stuScoreIBLL.GetScoreListByClassNo(queryJson); //var stuData = stuInfoBasicIBLL.GetAllList(); - var aa = data.GroupBy(x => new { x.StuNo, x.StuName, x.StuId }).Select(x => new + var aa = data.GroupBy(x => new { x.StuNo, x.StuName }).Select(x => new { - StuId = x.Key.StuId, StuNo = x.Key.StuNo, StuName = x.Key.StuName, //FinishSchoolMark = stuData.FirstOrDefault(a => a.StuNo == x.Key.StuNo)?.FinishSchoolMark, - TotalScore = x.Select(y => y.Score).Sum(), + TotalScore = x.Where(s => s.ExamType == "1").Select(y => y.Score).Sum(), LessonInfo = x.Select(y => new { y.LessonNo, y.LessonName, y.Score, y.ScoreFormat }).OrderBy(y => y.LessonNo) }).OrderByDescending(x => x.TotalScore); - - var bb=aa.Select(x=>x.StuNo).ToList(); - var cc=stuScoreIBLL.GetScoreListByMajor(queryJson).ToList(); + + var bb = aa.Select(x => x.StuNo).ToList(); + var cc = stuScoreIBLL.GetScoreListByMajor(queryJson).ToList(); var result = new List>(); foreach (var item in aa) { var aaa = new Dictionary(); - aaa.Add("StuId", item.StuId); aaa.Add("StuNo", item.StuNo); aaa.Add("StuName", item.StuName); //aaa.Add("FinishSchoolMark", item.FinishSchoolMark); aaa.Add("TotalScore", item.TotalScore.ToString()); aaa.Add("OrderClass", (bb.IndexOf(item.StuNo) + 1).ToString()); - aaa.Add("OrderMajor",(cc.IndexOf(item.StuNo)+1).ToString()); + aaa.Add("OrderMajor", (cc.IndexOf(item.StuNo) + 1).ToString()); foreach (var lessonInfoItem in item.LessonInfo) { aaa.Add(lessonInfoItem.LessonNo, lessonInfoItem.ScoreFormat); @@ -817,9 +815,9 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers var data = stuScoreIBLL.GetScoreListByStuInfo(queryJson); if (data.Any()) { - data = data.OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x=>x.LessonSortNo).ThenBy(x => x.LessonNo); + data = data.OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonSortNo).ThenBy(x => x.LessonNo); } - + return Success(data); } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/AllStuScoreQueryIndex.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/AllStuScoreQueryIndex.js index a8553a604..4df54862a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/AllStuScoreQueryIndex.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/AllStuScoreQueryIndex.js @@ -87,6 +87,7 @@ var bootstrap = function ($, learun) { { label: '第二次补考成绩', name: 'ScoreOfNotPassTwo', width: 100, align: "left" }, { label: '专业排名', name: 'RankInMajor', width: 100, align: "left" }, { label: '班级排名', name: 'RankInClass', width: 100, align: "left" }, + { label: '备注', name: 'Remark', width: 100, align: "left" }, ], mainId: 'StuNo', isPage: false, diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs index 259158ef9..ac0d73fb5 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs @@ -17,6 +17,10 @@ using System.Web; using Quanjiang.DigitalScholl.WebLicense; using Learun.Application.TwoDevelopment.EducationalAdministration; using Newtonsoft.Json; +using Learun.Cache.Base; +using Learun.Cache.Factory; +using Quanjiang.DigitalScholl.SendSms; +using System.Collections.Generic; namespace Learun.Application.Web.Controllers { @@ -38,6 +42,10 @@ namespace Learun.Application.Web.Controllers private LoginModelIBLL loginModelIbll = new LoginModelBLL(); private AnnexesFileIBLL annexesFileIbll = new AnnexesFileBLL(); WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL(); + private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL(); + private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL(); + private readonly ISms yixintongSms = new YixintongSms(); + private ICache redisCache = CacheFactory.CaChe(); #endregion #region 视图功能 @@ -510,11 +518,11 @@ namespace Learun.Application.Web.Controllers if (error >= 3) { #region 验证码验证 - verifycode = Md5Helper.Encrypt(verifycode.ToLower(), 16); - if (Session["session_verifycode"].IsEmpty() || verifycode != Session["session_verifycode"].ToString()) - { - return Fail("验证码错误"); - } + //verifycode = Md5Helper.Encrypt(verifycode.ToLower(), 16); + //if (Session["session_verifycode"].IsEmpty() || verifycode != Session["session_verifycode"].ToString()) + //{ + // return Fail("验证码错误"); + //} #endregion } int ForbidLoginNum = 5; @@ -522,14 +530,15 @@ namespace Learun.Application.Web.Controllers { ForbidLoginNum = Convert.ToInt32(ConfigurationManager.AppSettings["ForbidLoginNum"]); } - if (error>= ForbidLoginNum) + if (error >= ForbidLoginNum) { var needlockaccount = userBll.GetEntityByMobile(username); - userBll.UpdateState(needlockaccount.F_UserId,0); + userBll.UpdateState(needlockaccount.F_UserId, 0); OperatorHelper.Instance.ClearCurrentErrorNum(); return Fail("密码错误次数过多,账户已被锁定!"); } + var isSend = GetAccountIsSendMsg(username); #region 内部账户验证 UserEntity userEntity = userBll.CheckLogin(username, password); @@ -556,6 +565,17 @@ namespace Learun.Application.Web.Controllers } else { + if (!isSend.HasValue) + return Fail("请检查登录账号信息"); + if (isSend.Value) + { + if (string.IsNullOrEmpty(verifycode)) + return Success(new { sendresult = true, msg = "请输入验证码" }); + var redisKey = $"studentuserlogin_pc_{userEntity.F_Mobile}"; + if (redisCache.Read(redisKey) != verifycode) + return Fail("验证码错误或已失效。"); + redisCache.Remove(redisKey); + } //记录ip userBll.UpdateIp(GetIP(), userEntity.F_UserId); OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null);//写入缓存信息 @@ -564,13 +584,29 @@ namespace Learun.Application.Web.Controllers logEntity.F_ExecuteResultJson = "登录成功"; logEntity.WriteLog(); OperatorHelper.Instance.ClearCurrentErrorNum(); + if (isSend.Value) + { + logEntity = new LogEntity + { + F_CategoryId = 3, + F_OperateTypeId = "sms", + F_OperateType = "sms", + F_OperateAccount = "system", + F_ExecuteResult = 200, + F_ExecuteResultJson = "短信发送成功:发送短信成功", + F_Description = "短信发送:" + userEntity.F_Mobile + }; + logEntity.WriteLog(); + } + //配置短信发送日志,为登录时效验是否需要发送短信 + //是否强密码验证 if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["verifypwd"]) && ConfigurationManager.AppSettings["verifypwd"] == "true" && up == "false") { return Success(new { pwd = true }); } //每月1号强制用户修改密码 - if (DateTime.Now.Day == 1 && up == "false"&&teachSwitchIBLL.FindFirst("modifypwdfirstday")) + if (DateTime.Now.Day == 1 && up == "false" && teachSwitchIBLL.FindFirst("modifypwdfirstday")) { return Success(new { pwd = true }); } @@ -580,16 +616,16 @@ namespace Learun.Application.Web.Controllers { if (userEntity.F_ModifyPwdDate.HasValue) { - if ((DateTime.Now-userEntity.F_ModifyPwdDate.Value).Days>30) + if ((DateTime.Now - userEntity.F_ModifyPwdDate.Value).Days > 30) { return Success(new { pwdtip = true }); } } else { - if (userEntity.F_CreateDate.HasValue && (DateTime.Now-userEntity.F_CreateDate.Value).Days>30) + if (userEntity.F_CreateDate.HasValue && (DateTime.Now - userEntity.F_CreateDate.Value).Days > 30) { - return Success(new { pwdtip=true }); + return Success(new { pwdtip = true }); } } } @@ -783,13 +819,13 @@ namespace Learun.Application.Web.Controllers /// /// [HttpGet] - public ActionResult CheckLoginForSSOBC(string u,string p) + public ActionResult CheckLoginForSSOBC(string u, string p) { try { string uid = Request.QueryString["u"]; string pwd = Request.QueryString["p"]; - if (!string.IsNullOrEmpty(uid)&&!string.IsNullOrEmpty(pwd)) + if (!string.IsNullOrEmpty(uid) && !string.IsNullOrEmpty(pwd)) { string username = uid; string password = pwd; @@ -818,7 +854,7 @@ namespace Learun.Application.Web.Controllers logEntity.F_ExecuteResult = 1; logEntity.F_ExecuteResultJson = "无ui接口登录成功"; logEntity.WriteLog(); - return Success("login success",new{userType=userEntity?.F_Description}); + return Success("login success", new { userType = userEntity?.F_Description }); } } else @@ -843,7 +879,7 @@ namespace Learun.Application.Web.Controllers logEntity.F_CategoryId = 1; logEntity.F_OperateTypeId = ((int)OperationType.Exit).ToString(); logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Exit); - logEntity.F_OperateAccount ="第三方无ui"; + logEntity.F_OperateAccount = "第三方无ui"; logEntity.F_OperateUserId = "noui"; logEntity.F_ExecuteResult = 1; logEntity.F_ExecuteResultJson = "无ui退出系统"; @@ -1015,13 +1051,177 @@ namespace Learun.Application.Web.Controllers { string appid = "76d40062-349f-486d-b871-35bed08d2f59"; string secret = "cgpi"; - string appkey =Request.QueryString["appkey"]; - string response = Util.HttpMethods.HttpGet("http://localhost:20472/SSOSystem/authorize?appid=" + appid + "&secret=" + secret + "&appkey="+ appkey); + string appkey = Request.QueryString["appkey"]; + string response = Util.HttpMethods.HttpGet("http://localhost:20472/SSOSystem/authorize?appid=" + appid + "&secret=" + secret + "&appkey=" + appkey); return Content(response); } #endregion + #region 登录验证码的验证 + + /// + /// 验证是否需要输入验证码 + /// + /// + [HttpPost] + public ActionResult LoginVerify(string account) + { + var isSend = GetAccountIsSendMsg(account); + if (!isSend.HasValue) + { + return Fail("请检查登录账号信息"); + } + return Success(new { sendresult = isSend }); + } + + /// + /// 发送短信验证码 + /// + /// + [HttpPost] + public ActionResult LoginSendMessage(string account) + { + var isSend = GetAccountIsSendMsg(account); + if (!isSend.HasValue) + return Fail("请检查登录账号信息"); + + if (!isSend.Value) + return Fail("该用户不需要短信登录"); + var userEntity = userBll.GetEntityByMobile(account); + if (userEntity == null) + { + userEntity = userBll.GetEntityByAccount(account); + if (userEntity == null) + { + return Fail("请检查登录账号信息"); + } + } + LogEntity logEntity; + var redisKey = $"studentuserlogin_pc_{userEntity.F_Mobile}"; + var msg = redisCache.Read(redisKey); + if (!string.IsNullOrEmpty(msg)) return Fail("原验证码未过期请使用原验证码。"); + try + { + //短信发送验证 + string raRndNum = CommonHelper.RndNum(6); + var listStr = new List { $"欢迎使用智慧校园,您本次登录的验证码是 {raRndNum}。" }; + var result = yixintongSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); + if (result.Result.code == "0") + { + redisCache.Write(redisKey, raRndNum, new TimeSpan(0, 5, 0)); + return Success(new { sendstate = true, msg = $"短信发送成功:{raRndNum}" }); + } + logEntity = new LogEntity + { + F_CategoryId = 4, + F_OperateTypeId = "sms", + F_OperateType = "sms", + F_OperateAccount = "system", + F_ExecuteResult = 400, + F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType, + F_Description = "短信发送:" + userEntity.F_Mobile + }; + logEntity.WriteLog(); + return Fail("短信发送失败" + result.Result.message); + } + catch (Exception e) + { + logEntity = new LogEntity + { + F_CategoryId = 4, + F_OperateTypeId = "sms", + F_OperateType = "sms", + F_OperateAccount = "system", + F_ExecuteResult = 400, + F_ExecuteResultJson = "短信发送失败:" + e.Message, + F_Description = "短信发送:" + userEntity.F_Mobile + }; + logEntity.WriteLog(); + return Fail("短信发送失败" + e.Message); + } + } + + /// + /// 判断是否需要发送验证码 + /// + /// + /// + [HttpPost] + public bool? GetAccountIsSendMsg(string account) + { + var userEntity = userBll.GetEntityByMobile(account); + if (userEntity == null) + { + userEntity = userBll.GetEntityByAccount(account); + if (userEntity == null) + { + return null; + } + } + //是否强密码验证 + bool pwd = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["verifypwd"]) && ConfigurationManager.AppSettings["verifypwd"] == "true"; + //是否发送短信 + bool whethersendsms = false; + if (!pwd) + { + #region 学生 + + var studententity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(userEntity.F_Account); + if (studententity != null) + { + string queryjson = "{\"keywords\":\"" + userEntity.F_Mobile + "\"}"; + LogEntity lastsendlog = LogBLL.GetlikeList(queryjson); + if (lastsendlog != null) + { + var aa = ((DateTime)lastsendlog.F_OperateTime - DateTime.Now).TotalMinutes; + //大于1天就要发短信了 + if (Math.Abs(aa) > 1 * 24 * 60) + { + whethersendsms = true; + } + } + else + { + whethersendsms = true; + } + } + + #endregion + + #region 老师 + + var teacherentity = empInfoIBLL.GetEmpInfoEntityByEmpNo(userEntity.F_Account); + if (teacherentity != null) + { + + string queryjson = "{\"keywords\":\"" + userEntity.F_Mobile + "\"}"; + LogEntity lastsendlog = LogBLL.GetlikeList(queryjson); + if (lastsendlog != null) + { + var aa = ((DateTime)lastsendlog.F_OperateTime - DateTime.Now).TotalMinutes; + //大于1天就要发短信了 + if (Math.Abs(aa) > 1 * 24 * 60) + { + whethersendsms = true; + } + } + else + { + whethersendsms = true; + } + } + #endregion + if (studententity == null && teacherentity == null && userEntity.F_SecurityLevel != 1) + { + return null; + } + } + return whethersendsms; + } + + #endregion + /// /// 获取IP /// diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index e85603232..c0ddd4dd7 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -7104,6 +7104,10 @@ {1d192591-b85a-41db-ae3a-4bf9765786c1} Learun.Workflow.Engine + + {55F0F08D-2A9F-489A-BE1B-2EEAE80687E6} + Quanjiang.DigitalScholl.SendSms + {4D841EAD-3FD8-4FAC-BC67-C4CE6C0D1181} Quanjiang.DigitalScholl.WebLicense diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/Default.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/Default.cshtml index 470405679..fd53db2e4 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/Default.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/Default.cshtml @@ -26,21 +26,40 @@ width: 880px; margin: auto; } - .tips{ - position: absolute; - left: 50%; - bottom: 35px; - color: #fff; - font-size: 13px; - margin-left: -91px; - } - .tips > *{ - display: inline-block; - vertical-align: middle; - } - .tips img{ - margin-right: 8px - } + + .tips { + position: absolute; + left: 50%; + bottom: 35px; + color: #fff; + font-size: 13px; + margin-left: -91px; + } + + .tips > * { + display: inline-block; + vertical-align: middle; + } + + .tips img { + margin-right: 8px + } + + .codeBtn { + border: 1px solid #DCDFE6; + padding: 6px 10px; + color: #606266; + font-size: 12px; + cursor: pointer; + border-radius: 2px; + position: absolute; + left: 260px; + top: 10px; + } + + .codeBtn:hover { + border-color: #CBCFD5; + } @@ -59,7 +78,7 @@ - -