From 758d66624f9cd4533e5c0ef2e84a6b5b6423d49b Mon Sep 17 00:00:00 2001 From: dyy <18335927079@163.com> Date: Mon, 23 Nov 2020 17:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E6=95=99?= =?UTF-8?q?=E5=AD=A6=E5=B7=A5=E4=BD=9C=E5=AE=89=E6=8E=92=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=8E=A8=E9=80=81=E3=80=81=E9=A3=9E=E6=98=9F?= =?UTF-8?q?=E6=8E=A8=E9=80=81=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EADateArrange/EADateArrangeService.cs | 91 ++++++++++++++++++- 1 file changed, 88 insertions(+), 3 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/EADateArrange/EADateArrangeService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/EADateArrange/EADateArrangeService.cs index bf3548573..b1eae04ab 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/EADateArrange/EADateArrangeService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/EADateArrange/EADateArrangeService.cs @@ -1,10 +1,18 @@ using Dapper; +using Learun.Application.Organization; +using Learun.Application.TwoDevelopment.LR_Desktop; using Learun.DataBase.Repository; using Learun.Util; +using Microsoft.AspNet.SignalR.Client; +using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Configuration; using System.Data; +using System.Linq; using System.Text; +using System.Threading.Tasks; +using System.Web; namespace Learun.Application.TwoDevelopment.EducationalAdministration { @@ -174,6 +182,38 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration try { this.BaseRepository("CollegeMIS").ExecuteBySql("update EADateArrange set CheckMark=" + checkMark + " where dm='" + keyValue + "'"); + if (checkMark == 1)//审核 + { + var entity = this.BaseRepository("CollegeMIS").FindEntity(keyValue); + if (entity != null) + { + var needpostuserlist = this.BaseRepository().FindList(m => m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师").ToList(); + //读取信息推送管理-教学工作安排推送(08)的配置 + var informationPushEntity = this.BaseRepository().FindEntity(x => x.PushItem == "08"); + if (informationPushEntity != null && informationPushEntity.Status == true) + { + //微信推送 + try + { + PushWeixin(needpostuserlist, entity.WorkName); + } + catch (Exception e) + { + } + //飞星推送 + Task.Run(async () => + { + using (var hubConnection = new HubConnection(ConfigurationManager.AppSettings["CommunicationServeraddress"])) + { + var hubProxy = hubConnection.CreateHubProxy("SignalRHub"); + await hubConnection.Start(); + await hubProxy.Invoke("PushAnnouncement", LoginUserInfo.Get().userId, entity.WorkName, Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.WorkName)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.WorkName)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.WorkName)).Substring(0, 20), "eadatearrange", string.Join(",", needpostuserlist.Select(m => m.F_UserId)), ""); + } + }); + } + + } + } } catch (Exception ex) { @@ -269,7 +309,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration { //成绩录入前初始化数据 //必修课 - if (string.IsNullOrEmpty(entity.LessonSortNo) ||entity.LessonSortNo=="1") + if (string.IsNullOrEmpty(entity.LessonSortNo) || entity.LessonSortNo == "1") { //dyy:20190429 string sql = @"insert into stuscore(NoticeBookNo,StuNo,DeptNo,MajorNo,ClassNo,StuName,GenderNo,AcademicYearNo,Semester,OpenLessonDeptNo,OpenLessonMajorNo,LessonNo,LessonName,LessonNameEn,TeachClassNo,LessonSortNo,StuSortNo,Grade,StudyScore,TotalStudyHour,OrdinaryScore,TermInScore,TermEndScore,OtherScore,IsInEffect,Remark,ConflictLessonNo,IsPitchOn,CheckMark,TechPlanNo,EmpNo,PartCode,ScoreRecordStyleNo,TestModeNo,zysx,TestKindNo,IsEditable,F_SchoolId) @@ -283,7 +323,7 @@ where s.CheckMark='1' ) as sl where StuNo not in(Select StuNo from stuscore s where s.Academicyearno=sl.Academicyearno and s.Semester=sl.Semester and s.lessonno=sl.lessonno and s.teachclassno=sl.teachclassno and s.LessonSortNo='1' -and s.Academicyearno='"+entity.AcademicYearNo+ "' and s.Semester='"+entity.Semester+ "') and sl.AcademicYearNo='"+entity.AcademicYearNo+ "' and sl.Semester='"+entity.Semester+"'"; +and s.Academicyearno='" + entity.AcademicYearNo + "' and s.Semester='" + entity.Semester + "') and sl.AcademicYearNo='" + entity.AcademicYearNo + "' and sl.Semester='" + entity.Semester + "'"; BaseRepository("CollegeMIS").ExecuteBySql(sql); //dyy:20190722 //初始化教师成绩单提交表 @@ -299,7 +339,7 @@ where s.lessonsortno='1' ) as bb where bb.EmpNo not in (select a.EmpNo from EmpReportCard a where a.AcademicYearNo=bb.AcademicYearNo and a.Semester=bb.Semester and a.LessonNo=bb.LessonNo and a.ClassNo=bb.ClassNo and a.LessonSortNo=bb.LessonSortNo and a.LessonSortNo='1' -and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity.Semester+ "') and bb.AcademicYearNo='" + entity.AcademicYearNo + "' and bb.Semester='" + entity.Semester + "' order by bb.EmpNo"; +and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity.Semester + "') and bb.AcademicYearNo='" + entity.AcademicYearNo + "' and bb.Semester='" + entity.Semester + "' order by bb.EmpNo"; BaseRepository("CollegeMIS").ExecuteBySql(sql3); } //选修课 @@ -350,5 +390,50 @@ and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity. } } } + + + public void PushWeixin(List needpostuserlist, string title) + { + var WeChatConfigentity = BaseRepository().FindEntity(m => m.IsEnable == true); + string appid = WeChatConfigentity.APPId; + string secret = WeChatConfigentity.secret; + var wechatemplete = BaseRepository() + .FindEntity(m => m.WeID == WeChatConfigentity.ID && m.TCode == "task"); + string weixintaskurl = wechatemplete.TUrl; + string weixintasktempid = wechatemplete.TempId; + var responsejson = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret); + foreach (UserEntity userinfo in needpostuserlist) + { + if (userinfo != null && !string.IsNullOrEmpty(userinfo.OpenIdForWeixin)) + { + //执行推送任务 + if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid)) + { + if (!string.IsNullOrEmpty(responsejson)) + { + var weixintokenobj = JsonConvert.DeserializeObject(responsejson); + if (string.IsNullOrEmpty(weixintokenobj.errcode)) + { + string access_token = weixintokenobj.access_token; + string jsondata = "{\"touser\":\"" + userinfo.OpenIdForWeixin + "\"," + + "\"template_id\":\"" + weixintasktempid + "\"," + + "\"url\":\"" + weixintaskurl + "\"," + + "\"data\":{" + + "\"first\": {\"value\":\"您有新的教学工作安排\",\"color\":\"#173177\"}," + + "\"keyword1\":{\"value\":\"教学工作安排\",\"color\":\"#173177\"}," + + "\"keyword2\": {\"value\":\"" + title + "\",\"color\":\"#173177\"}," + + "\"keyword3\": {\"value\":\"待查看\",\"color\":\"#173177\"}," + + "\"keyword4\": {\"value\":\"您有新的教学工作安排需要查看【" + title + "】\",\"color\":\"#173177\"}" + + "}" + + "}"; + string pushresult = Util.HttpMethods.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, jsondata); + } + } + } + } + } + } + + } }