|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671 |
- using Dapper;
- using Learun.Application.Base.AuthorizeModule;
- using Learun.Application.Organization;
- using Learun.Application.TwoDevelopment.LR_Desktop;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using Learun.Application.Base.SystemModule;
-
- namespace Learun.Application.TwoDevelopment.EducationalAdministration
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2020-04-16 15:52
- /// 描 述:班级自诊打卡
- /// </summary>
- public class ThermographyService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<ThermographyEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.* ");
- strSql.Append(" FROM Thermography t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
- {
- dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
- dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
- strSql.Append(" AND ( t.MeasureDate >= @startTime AND t.MeasureDate <= @endTime ) ");
- }
- if (!queryParam["DeptNo"].IsEmpty())
- {
- dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
- strSql.Append(" AND t.DeptNo = @DeptNo ");
- }
- if (!queryParam["MajorNo"].IsEmpty())
- {
- dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
- strSql.Append(" AND t.MajorNo = @MajorNo ");
- }
- if (!queryParam["ClassNo"].IsEmpty())
- {
- dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
- strSql.Append(" AND t.ClassNo = @ClassNo ");
- }
- if (!queryParam["MeasureTime"].IsEmpty())
- {
- dp.Add("MeasureTime", queryParam["MeasureTime"].ToString(), DbType.String);
- strSql.Append(" AND t.MeasureTime = @MeasureTime ");
- }
- if (!queryParam["PersonBeingMeasured"].IsEmpty())
- {
- dp.Add("PersonBeingMeasured", queryParam["PersonBeingMeasured"].ToString(), DbType.String);
- strSql.Append(" AND t.PersonBeingMeasured = @PersonBeingMeasured ");
- }
- if (!queryParam["Status"].IsEmpty())
- {
- dp.Add("Status", queryParam["Status"].ToString(), DbType.String);
- strSql.Append(" AND t.Status = @Status ");
- }
- if (!queryParam["MeasurerID"].IsEmpty())
- {
- dp.Add("MeasurerID", queryParam["MeasurerID"].ToString(), DbType.String);
- strSql.Append(" AND t.MeasurerID = @MeasurerID ");
- }
- return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<ThermographyEntity> GetList(string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT ");
- strSql.Append(@"
- t.ID,
- t.ClassNo,
- t.MeasurerID,
- t.PersonBeingMeasured,
- t.Status,
- t.Temperature,
- t.ProcessingResult,
- t.Remark,
- t.MeasureTime,
- t.DeptNo,
- t.MajorNo,
- t.MeasureDate
- ");
- strSql.Append(" FROM Thermography t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
- {
- dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
- dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
- strSql.Append(" AND ( t.MeasureDate >= @startTime AND t.MeasureDate <= @endTime ) ");
- }
- if (!queryParam["ClassNo"].IsEmpty())
- {
- dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
- strSql.Append(" AND t.ClassNo = @ClassNo ");
- }
- if (!queryParam["PersonBeingMeasured"].IsEmpty())
- {
- dp.Add("PersonBeingMeasured", queryParam["PersonBeingMeasured"].ToString(), DbType.String);
- strSql.Append(" AND t.PersonBeingMeasured = @PersonBeingMeasured ");
- }
- if (!queryParam["Status"].IsEmpty())
- {
- dp.Add("Status", queryParam["Status"].ToString(), DbType.String);
- strSql.Append(" AND t.Status = @Status ");
- }
- return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取Thermography表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public ThermographyEntity GetThermographyEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<ThermographyEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取Thermography表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public ThermographyEntity GetThermographyEntitiesByClass(string classNo, DateTime measureDate, string measureTime)
- {
- try
- {
- var nextday = measureDate.AddDays(1).Date;
- return this.BaseRepository("CollegeMIS").FindEntity<ThermographyEntity>(x => x.ClassNo == classNo && x.MeasureDate >= measureDate && x.MeasureDate < nextday && x.MeasureTime == measureTime);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 开始测温的学生列表
- /// <summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<ThermographyEntity> GetPageListOfStudent(string queryJson)
- {
- try
- {
- var userInfo = LoginUserInfo.Get();
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.ClassNo,t.DeptNo,t.MajorNo,t.StuNo as PersonBeingMeasured,t.StuName as PersonBeingMeasuredName,'" + userInfo.account + "' as MeasurerID,'1' as Status,c.ClassName ");
- strSql.Append(" FROM StuInfoBasic t left join StuInfoBasic tt on t.ClassNo=tt.ClassNo left join ClassInfo c on t.ClassNo=c.ClassNo ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
-
- if (!queryParam["MeasurerID"].IsEmpty())
- {
- dp.Add("MeasurerID", queryParam["MeasurerID"].ToString(), DbType.String);
- strSql.Append(" AND tt.StuNo = @MeasurerID ");
- }
- return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// APP中开始测温的学生列表
- /// <summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<ThermographyEntity> GetPageListOfStudentInApp(string queryJson)
- {
- try
- {
- var userInfo = LoginUserInfo.Get();
- var strSql = new StringBuilder();
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- var nowDate = DateTime.Now.Date;
- var nextDate = DateTime.Now.AddDays(1).Date;
- strSql.Append("SELECT t.ClassNo,t.DeptNo,t.MajorNo,t.StuNo as PersonBeingMeasured,t.StuName as PersonBeingMeasuredName,'" + userInfo.account + "' as MeasurerID,'1' as Status,c.ClassName ");
- if (!queryParam["MeasureTime"].IsEmpty() && queryParam["MeasureTime"].ToString() != "-1")
- {
- strSql.Append(" ,g.ID,case when g.Status is null then '1' else g.Status end as Status,g.Temperature,g.ProcessingResult,g.Remark,g.MeasureTime ");
- }
- strSql.Append(" FROM StuInfoBasic t left join StuInfoBasic tt on t.ClassNo=tt.ClassNo left join ClassInfo c on t.ClassNo=c.ClassNo ");
- if (!queryParam["MeasureTime"].IsEmpty() && queryParam["MeasureTime"].ToString() != "-1")
- {
- strSql.Append(" left join Thermography g on t.StuNo=g.PersonBeingMeasured and t.ClassNo=g.ClassNo and t.DeptNo=g.DeptNo and t.MajorNo=g.DeptNo ");
- strSql.Append(" and g.MeasureDate >='" + nowDate + "' and g.MeasureDate<'" + nextDate + "' ");
-
- dp.Add("MeasureTime", queryParam["MeasureTime"].ToString(), DbType.String);
- strSql.Append(" and g.MeasureTime=@MeasureTime ");
- }
-
- strSql.Append(" WHERE 1=1 ");
- if (!queryParam["MeasurerID"].IsEmpty())
- {
- dp.Add("MeasurerID", queryParam["MeasurerID"].ToString(), DbType.String);
- strSql.Append(" AND tt.StuNo = @MeasurerID ");
- }
- return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 班级自诊打卡统计
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<ThermographyEntity> GetListOfStatistic(string queryJson)
- {
- try
- {
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- var strSql = new StringBuilder();
- strSql.Append("select t.DeptNo,CONVERT(varchar(100), t.MeasureDate, 23) as MeasureDate,t.MeasureTime,sum(case when t.Status='0' then 1 else 0 end) as statusNum0,sum(case when t.Status='1' then 1 else 0 end) as statusNum1,sum(case when t.Status='2' then 1 else 0 end) as statusNum2,sum(case when t.Status!='0' then 1 else 0 end) as statusNum12,(select count(s.StuId) from StuInfoBasic s where s.DeptNo=t.DeptNo and s.CheckMark='1') as totalNum ");
- strSql.Append(" FROM Thermography t ");
- strSql.Append(" WHERE 1=1 ");
- if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
- {
- dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
- dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
- strSql.Append(" AND ( t.MeasureDate >= @startTime AND t.MeasureDate <= @endTime ) ");
- }
- if (!queryParam["DeptNo"].IsEmpty())
- {
- dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
- strSql.Append(" AND t.DeptNo = @DeptNo ");
- }
- if (!queryParam["MajorNo"].IsEmpty())
- {
- dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
- strSql.Append(" AND t.MajorNo = @MajorNo ");
- }
- if (!queryParam["ClassNo"].IsEmpty())
- {
- dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
- strSql.Append(" AND t.ClassNo = @ClassNo ");
- }
- strSql.Append(" group by t.DeptNo,CONVERT(varchar(100), t.MeasureDate, 23),t.MeasureTime ");
- return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DeleteEntity(string keyValue)
- {
- try
- {
- this.BaseRepository("CollegeMIS").Delete<ThermographyEntity>(t => t.ID == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void SaveEntity(UserInfo userInfo, string keyValue, ThermographyEntity entity)
- {
- try
- {
- //限制测温时间(上午、中午、晚上)时:判断学生是否已测温,是则更新,否则新增;不限制测温时间时:新增;
- if (entity.MeasureTime == "-1")
- {
- entity.Create(userInfo);
- this.BaseRepository("CollegeMIS").Insert(entity);
- }
- else
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- entity.Modify(keyValue, userInfo);
- this.BaseRepository("CollegeMIS").Update(entity);
- }
- else
- {
- entity.Create(userInfo);
- this.BaseRepository("CollegeMIS").Insert(entity);
- }
- }
-
- LogEntity logEntity = new LogEntity();
- logEntity.F_LogId = Guid.NewGuid().ToString();
- logEntity.F_Module = "Thermography";
- logEntity.F_ExecuteResultJson = "Thermography Status=" + entity.Status;
- logEntity.WriteLog();
- //体温异常
- if (entity.Status == "2")
- {
- try
- {
- var stuModel = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(x => x.StuNo == entity.PersonBeingMeasured);
- if (stuModel != null)
- {
- logEntity = new LogEntity();
- logEntity.F_LogId = Guid.NewGuid().ToString();
- logEntity.F_Module = "Thermography";
- logEntity.F_ExecuteResultJson = "Thermography stuModelStuNo=" + stuModel.StuNo;
- logEntity.WriteLog();
- var title = string.Format("{0}({1})", stuModel.StuName, stuModel.StuNo);
- //读取信息推送管理-班级自诊打卡体温异常学生推送(05)的配置
- var informationPushEntity = this.BaseRepository().FindEntity<Sys_InformationPushEntity>(x => x.PushItem == "05");
- if (informationPushEntity != null && informationPushEntity.Status == true)
- {
- //微信推送
- PushWeixin(title);
- }
-
- }
- }
- catch (Exception e)
- {
- }
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 生成对应时间段的测量体温的学生数据
- /// <param name="timeType">时间段类型</param>
- /// <summary>
- /// <returns></returns>
- public void CreateMorningStudents(string timeType)
- {
- try
- {
- //获取当前登录人
- var loginUser = LoginUserInfo.Get();
- //根据当前登录人获取所属班级
- //var classNo = this.BaseRepository("CollegeMIS")
- // .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account)?.ClassNo;
- var classNo = "201801301";
- if (classNo != null)
- {
- var latestTheEntity = this.BaseRepository("CollegeMIS")
- .FindList<ThermographyEntity>(a => a.CreateTime > DateTime.Today && a.MeasureTime == timeType).ToList();
- if (latestTheEntity.Count == 0)
- {
- //根据班号获取所有学生
- var students = this.BaseRepository("CollegeMIS")
- .FindList<StuInfoBasicEntity>(a => a.ClassNo == classNo);
- foreach (var student in students)
- {
- var thermographyEntity = new ThermographyEntity()
- {
- ClassNo = student.ClassNo,
- MeasureTime = timeType,
- PersonBeingMeasured = student.StuNo,
- CreateTime = DateTime.Now,
- MeasurerID = loginUser.account,
- MeasureDate = DateTime.Now,
- DeptNo = student.DeptNo,
- MajorNo = student.MajorNo,
- Status = "0"
- };
- thermographyEntity.Create(loginUser);
- this.BaseRepository("CollegeMIS").Insert(thermographyEntity);
-
- }
- }
-
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void SaveEntityList(string measureTime, List<ThermographyEntity> entities)
- {
- var db = this.BaseRepository("CollegeMIS");
- db.BeginTrans();
- try
- {
- var userInfo = LoginUserInfo.Get();
- var now = DateTime.Now;
- var nowDate = DateTime.Now.Date;
- var nextDate = DateTime.Now.AddDays(1).Date;
- var pushTitle = string.Empty;//微信推送标题
- foreach (var entity in entities)
- {
- entity.MeasurerID = userInfo.account;
- entity.MeasureDate = now;
- entity.MeasureTime = measureTime;
- entity.CreateTime = now;
- //限制测温时间(上午、中午、晚上)时:判断学生是否已测温,是则更新,否则新增;不限制测温时间时:新增;
- if (measureTime != "-1")
- {
- var model = db.FindEntity<ThermographyEntity>(x => x.PersonBeingMeasured == entity.PersonBeingMeasured && x.MeasureTime == measureTime && x.MeasureDate >= nowDate && x.MeasureDate < nextDate);
- if (model != null)
- {
- db.Delete(model);
- }
- }
- entity.Create(userInfo);
- db.Insert(entity);
- //体温异常
- if (entity.Status == "2")
- {
- if (string.IsNullOrEmpty(pushTitle))
- {
- var classModel = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.ClassNo);
- pushTitle = string.Format("{0}班级({1})发现异常学生:{2}({3})", classModel?.ClassName, entity.ClassNo, entity.PersonBeingMeasuredName, entity.PersonBeingMeasured);
- }
- else
- {
- pushTitle += string.Format(",{0}({1})", entity.PersonBeingMeasuredName, entity.PersonBeingMeasured);
- }
- }
- }
- db.Commit();
-
- if (entities.Any(x => x.Status == "2"))
- {
- //读取信息推送管理-班级自诊打卡体温异常学生推送(05)的配置
- var informationPushEntity = this.BaseRepository().FindEntity<Sys_InformationPushEntity>(x => x.PushItem == "05");
- if (informationPushEntity != null && informationPushEntity.Status == true)
- {
- try
- {
- //微信推送
- PushWeixin(pushTitle);
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
-
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- /// <summary>
- /// 微信推送
- /// </summary>
- /// <param name="title"></param>
- public void PushWeixin(string title)
- {
- var EpidemicControlTeamRoleId = Config.GetValue("EpidemicControlTeamRoleId");
- if (!string.IsNullOrEmpty(EpidemicControlTeamRoleId))
- {
- //疫情防控组成员
- var userRelationList = this.BaseRepository().FindList<UserRelationEntity>(x => x.F_ObjectId == EpidemicControlTeamRoleId);
- //微信配置
- var WeChatConfigentity = BaseRepository().FindEntity<WeChatConfigEntity>(m => m.IsEnable == true);
- string appid = WeChatConfigentity.APPId;
- string secret = WeChatConfigentity.secret;
- var wechatemplete = BaseRepository().FindEntity<WeChatTemplateEntity>(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);
- LogEntity logEntity = new LogEntity();
- logEntity.F_LogId = Guid.NewGuid().ToString();
- logEntity.F_Module = "Thermography";
- logEntity.F_ExecuteResultJson = "Thermography responsejson=" + responsejson;
- logEntity.WriteLog();
- foreach (var userRelationItem in userRelationList)
- {
- var userEntity = this.BaseRepository().FindEntity<UserEntity>(userRelationItem.F_UserId);
- if (userEntity != null && !string.IsNullOrEmpty(userEntity.OpenIdForWeixin))
- {
- //执行推送任务
- if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid))
- {
- if (!string.IsNullOrEmpty(responsejson))
- {
- var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson);
- if (string.IsNullOrEmpty(weixintokenobj.errcode))
- {
- string access_token = weixintokenobj.access_token;
- string jsondata = "{\"touser\":\"" + userEntity.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);
- logEntity = new LogEntity();
- logEntity.F_LogId = Guid.NewGuid().ToString();
- logEntity.F_Module = "Thermography";
- logEntity.F_ExecuteResultJson = "Thermography pushresult=" + pushresult;
- logEntity.WriteLog();
- }
- }
- }
- }
- }
- }
-
- }
- #endregion
-
- }
- }
|