You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

632 lines
27 KiB

  1. using Dapper;
  2. using Learun.Application.Base.AuthorizeModule;
  3. using Learun.Application.Organization;
  4. using Learun.Application.TwoDevelopment.LR_Desktop;
  5. using Learun.DataBase.Repository;
  6. using Learun.Util;
  7. using Newtonsoft.Json;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Linq;
  12. using System.Text;
  13. using Learun.Application.Base.SystemModule;
  14. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  15. {
  16. /// <summary>
  17. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  18. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  19. /// 创 建:超级管理员
  20. /// 日 期:2020-04-16 15:52
  21. /// 描 述:班级自诊打卡
  22. /// </summary>
  23. public class ThermographyService : RepositoryFactory
  24. {
  25. #region 获取数据
  26. /// <summary>
  27. /// 获取页面显示列表分页数据
  28. /// <summary>
  29. /// <param name="pagination">分页参数</param>
  30. /// <param name="queryJson">查询参数</param>
  31. /// <returns></returns>
  32. public IEnumerable<ThermographyEntity> GetPageList(Pagination pagination, string queryJson)
  33. {
  34. try
  35. {
  36. var strSql = new StringBuilder();
  37. strSql.Append("SELECT t.* ");
  38. strSql.Append(" FROM Thermography t ");
  39. strSql.Append(" WHERE 1=1 ");
  40. var queryParam = queryJson.ToJObject();
  41. // 虚拟参数
  42. var dp = new DynamicParameters(new { });
  43. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  44. {
  45. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  46. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  47. strSql.Append(" AND ( t.MeasureDate >= @startTime AND t.MeasureDate <= @endTime ) ");
  48. }
  49. if (!queryParam["DeptNo"].IsEmpty())
  50. {
  51. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  52. strSql.Append(" AND t.DeptNo = @DeptNo ");
  53. }
  54. if (!queryParam["MajorNo"].IsEmpty())
  55. {
  56. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  57. strSql.Append(" AND t.MajorNo = @MajorNo ");
  58. }
  59. if (!queryParam["ClassNo"].IsEmpty())
  60. {
  61. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  62. strSql.Append(" AND t.ClassNo = @ClassNo ");
  63. }
  64. if (!queryParam["MeasureTime"].IsEmpty())
  65. {
  66. dp.Add("MeasureTime", queryParam["MeasureTime"].ToString(), DbType.String);
  67. strSql.Append(" AND t.MeasureTime = @MeasureTime ");
  68. }
  69. if (!queryParam["PersonBeingMeasured"].IsEmpty())
  70. {
  71. dp.Add("PersonBeingMeasured", queryParam["PersonBeingMeasured"].ToString(), DbType.String);
  72. strSql.Append(" AND t.PersonBeingMeasured = @PersonBeingMeasured ");
  73. }
  74. if (!queryParam["Status"].IsEmpty())
  75. {
  76. dp.Add("Status", queryParam["Status"].ToString(), DbType.String);
  77. strSql.Append(" AND t.Status = @Status ");
  78. }
  79. if (!queryParam["MeasurerID"].IsEmpty())
  80. {
  81. dp.Add("MeasurerID", queryParam["MeasurerID"].ToString(), DbType.String);
  82. strSql.Append(" AND t.MeasurerID = @MeasurerID ");
  83. }
  84. return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp, pagination);
  85. }
  86. catch (Exception ex)
  87. {
  88. if (ex is ExceptionEx)
  89. {
  90. throw;
  91. }
  92. else
  93. {
  94. throw ExceptionEx.ThrowServiceException(ex);
  95. }
  96. }
  97. }
  98. /// <summary>
  99. /// 获取页面显示列表数据
  100. /// <summary>
  101. /// <param name="queryJson">查询参数</param>
  102. /// <returns></returns>
  103. public IEnumerable<ThermographyEntity> GetList(string queryJson)
  104. {
  105. try
  106. {
  107. var strSql = new StringBuilder();
  108. strSql.Append("SELECT ");
  109. strSql.Append(@"
  110. t.ID,
  111. t.ClassNo,
  112. t.MeasurerID,
  113. t.PersonBeingMeasured,
  114. t.Status,
  115. t.Temperature,
  116. t.ProcessingResult,
  117. t.Remark,
  118. t.MeasureTime,
  119. t.DeptNo,
  120. t.MajorNo,
  121. t.MeasureDate
  122. ");
  123. strSql.Append(" FROM Thermography t ");
  124. strSql.Append(" WHERE 1=1 ");
  125. var queryParam = queryJson.ToJObject();
  126. // 虚拟参数
  127. var dp = new DynamicParameters(new { });
  128. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  129. {
  130. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  131. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  132. strSql.Append(" AND ( t.MeasureDate >= @startTime AND t.MeasureDate <= @endTime ) ");
  133. }
  134. if (!queryParam["ClassNo"].IsEmpty())
  135. {
  136. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  137. strSql.Append(" AND t.ClassNo = @ClassNo ");
  138. }
  139. if (!queryParam["PersonBeingMeasured"].IsEmpty())
  140. {
  141. dp.Add("PersonBeingMeasured", queryParam["PersonBeingMeasured"].ToString(), DbType.String);
  142. strSql.Append(" AND t.PersonBeingMeasured = @PersonBeingMeasured ");
  143. }
  144. if (!queryParam["Status"].IsEmpty())
  145. {
  146. dp.Add("Status", queryParam["Status"].ToString(), DbType.String);
  147. strSql.Append(" AND t.Status = @Status ");
  148. }
  149. return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp);
  150. }
  151. catch (Exception ex)
  152. {
  153. if (ex is ExceptionEx)
  154. {
  155. throw;
  156. }
  157. else
  158. {
  159. throw ExceptionEx.ThrowServiceException(ex);
  160. }
  161. }
  162. }
  163. /// <summary>
  164. /// 获取Thermography表实体数据
  165. /// <param name="keyValue">主键</param>
  166. /// <summary>
  167. /// <returns></returns>
  168. public ThermographyEntity GetThermographyEntity(string keyValue)
  169. {
  170. try
  171. {
  172. return this.BaseRepository("CollegeMIS").FindEntity<ThermographyEntity>(keyValue);
  173. }
  174. catch (Exception ex)
  175. {
  176. if (ex is ExceptionEx)
  177. {
  178. throw;
  179. }
  180. else
  181. {
  182. throw ExceptionEx.ThrowServiceException(ex);
  183. }
  184. }
  185. }
  186. /// <summary>
  187. /// 获取Thermography表实体数据
  188. /// <param name="keyValue">主键</param>
  189. /// <summary>
  190. /// <returns></returns>
  191. public ThermographyEntity GetThermographyEntitiesByClass(string classNo, DateTime measureDate, string measureTime)
  192. {
  193. try
  194. {
  195. var nextday = measureDate.AddDays(1).Date;
  196. return this.BaseRepository("CollegeMIS").FindEntity<ThermographyEntity>(x => x.ClassNo == classNo && x.MeasureDate >= measureDate && x.MeasureDate < nextday && x.MeasureTime == measureTime);
  197. }
  198. catch (Exception ex)
  199. {
  200. if (ex is ExceptionEx)
  201. {
  202. throw;
  203. }
  204. else
  205. {
  206. throw ExceptionEx.ThrowServiceException(ex);
  207. }
  208. }
  209. }
  210. /// <summary>
  211. /// 开始测温的学生列表
  212. /// <summary>
  213. /// <param name="pagination">分页参数</param>
  214. /// <param name="queryJson">查询参数</param>
  215. /// <returns></returns>
  216. public IEnumerable<ThermographyEntity> GetPageListOfStudent(string queryJson)
  217. {
  218. try
  219. {
  220. var userInfo = LoginUserInfo.Get();
  221. var strSql = new StringBuilder();
  222. strSql.Append("SELECT t.ClassNo,t.DeptNo,t.MajorNo,t.StuNo as PersonBeingMeasured,t.StuName as PersonBeingMeasuredName,'" + userInfo.account + "' as MeasurerID,'0' as Status,c.ClassName ");
  223. strSql.Append(" FROM StuInfoBasic t left join StuInfoBasic tt on t.ClassNo=tt.ClassNo left join ClassInfo c on t.ClassNo=c.ClassNo ");
  224. strSql.Append(" WHERE 1=1 ");
  225. var queryParam = queryJson.ToJObject();
  226. // 虚拟参数
  227. var dp = new DynamicParameters(new { });
  228. if (!queryParam["MeasurerID"].IsEmpty())
  229. {
  230. dp.Add("MeasurerID", queryParam["MeasurerID"].ToString(), DbType.String);
  231. strSql.Append(" AND tt.StuNo = @MeasurerID ");
  232. }
  233. return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp);
  234. }
  235. catch (Exception ex)
  236. {
  237. if (ex is ExceptionEx)
  238. {
  239. throw;
  240. }
  241. else
  242. {
  243. throw ExceptionEx.ThrowServiceException(ex);
  244. }
  245. }
  246. }
  247. /// <summary>
  248. /// APP中开始测温的学生列表
  249. /// <summary>
  250. /// <param name="pagination">分页参数</param>
  251. /// <param name="queryJson">查询参数</param>
  252. /// <returns></returns>
  253. public IEnumerable<ThermographyEntity> GetPageListOfStudentInApp(string queryJson)
  254. {
  255. try
  256. {
  257. var userInfo = LoginUserInfo.Get();
  258. var strSql = new StringBuilder();
  259. var queryParam = queryJson.ToJObject();
  260. // 虚拟参数
  261. var dp = new DynamicParameters(new { });
  262. var nowDate = DateTime.Now.Date;
  263. var nextDate = DateTime.Now.AddDays(1).Date;
  264. strSql.Append("SELECT t.ClassNo,t.DeptNo,t.MajorNo,t.StuNo as PersonBeingMeasured,t.StuName as PersonBeingMeasuredName,'" + userInfo.account + "' as MeasurerID,c.ClassName ");
  265. strSql.Append(" ,g.ID,case when g.Status is null then '0' else g.Status end as Status,g.Temperature,g.ProcessingResult,g.Remark,g.MeasureTime ");
  266. strSql.Append(" FROM StuInfoBasic t left join StuInfoBasic tt on t.ClassNo=tt.ClassNo left join ClassInfo c on t.ClassNo=c.ClassNo ");
  267. 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 ");
  268. strSql.Append(" and g.MeasureDate >='" + nowDate + "' and g.MeasureDate<'" + nextDate + "' ");
  269. if (!queryParam["MeasureTime"].IsEmpty())
  270. {
  271. dp.Add("MeasureTime", queryParam["MeasureTime"].ToString(), DbType.String);
  272. strSql.Append(" and g.MeasureTime=@MeasureTime ");
  273. }
  274. strSql.Append(" WHERE 1=1 ");
  275. if (!queryParam["MeasurerID"].IsEmpty())
  276. {
  277. dp.Add("MeasurerID", queryParam["MeasurerID"].ToString(), DbType.String);
  278. strSql.Append(" AND tt.StuNo = @MeasurerID ");
  279. }
  280. return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp);
  281. }
  282. catch (Exception ex)
  283. {
  284. if (ex is ExceptionEx)
  285. {
  286. throw;
  287. }
  288. else
  289. {
  290. throw ExceptionEx.ThrowServiceException(ex);
  291. }
  292. }
  293. }
  294. /// <summary>
  295. /// 班级自诊打卡统计
  296. /// <summary>
  297. /// <param name="queryJson">查询参数</param>
  298. /// <returns></returns>
  299. public IEnumerable<ThermographyEntity> GetListOfStatistic(string queryJson)
  300. {
  301. try
  302. {
  303. var queryParam = queryJson.ToJObject();
  304. // 虚拟参数
  305. var dp = new DynamicParameters(new { });
  306. var strSql = new StringBuilder();
  307. 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 ");
  308. strSql.Append(" FROM Thermography t ");
  309. strSql.Append(" WHERE 1=1 ");
  310. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  311. {
  312. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  313. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  314. strSql.Append(" AND ( t.MeasureDate >= @startTime AND t.MeasureDate <= @endTime ) ");
  315. }
  316. if (!queryParam["DeptNo"].IsEmpty())
  317. {
  318. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  319. strSql.Append(" AND t.DeptNo = @DeptNo ");
  320. }
  321. if (!queryParam["MajorNo"].IsEmpty())
  322. {
  323. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  324. strSql.Append(" AND t.MajorNo = @MajorNo ");
  325. }
  326. if (!queryParam["ClassNo"].IsEmpty())
  327. {
  328. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  329. strSql.Append(" AND t.ClassNo = @ClassNo ");
  330. }
  331. strSql.Append(" group by t.DeptNo,CONVERT(varchar(100), t.MeasureDate, 23),t.MeasureTime ");
  332. return this.BaseRepository("CollegeMIS").FindList<ThermographyEntity>(strSql.ToString(), dp);
  333. }
  334. catch (Exception ex)
  335. {
  336. if (ex is ExceptionEx)
  337. {
  338. throw;
  339. }
  340. else
  341. {
  342. throw ExceptionEx.ThrowServiceException(ex);
  343. }
  344. }
  345. }
  346. #endregion
  347. #region 提交数据
  348. /// <summary>
  349. /// 删除实体数据
  350. /// <param name="keyValue">主键</param>
  351. /// <summary>
  352. /// <returns></returns>
  353. public void DeleteEntity(string keyValue)
  354. {
  355. try
  356. {
  357. this.BaseRepository("CollegeMIS").Delete<ThermographyEntity>(t => t.ID == keyValue);
  358. }
  359. catch (Exception ex)
  360. {
  361. if (ex is ExceptionEx)
  362. {
  363. throw;
  364. }
  365. else
  366. {
  367. throw ExceptionEx.ThrowServiceException(ex);
  368. }
  369. }
  370. }
  371. /// <summary>
  372. /// 保存实体数据(新增、修改)
  373. /// <param name="keyValue">主键</param>
  374. /// <summary>
  375. /// <returns></returns>
  376. public void SaveEntity(UserInfo userInfo, string keyValue, ThermographyEntity entity)
  377. {
  378. try
  379. {
  380. if (!string.IsNullOrEmpty(keyValue))
  381. {
  382. entity.Modify(keyValue, userInfo);
  383. this.BaseRepository("CollegeMIS").Update(entity);
  384. }
  385. else
  386. {
  387. entity.Create(userInfo);
  388. this.BaseRepository("CollegeMIS").Insert(entity);
  389. }
  390. LogEntity logEntity = new LogEntity();
  391. logEntity.F_LogId = Guid.NewGuid().ToString();
  392. logEntity.F_Module = "Thermography";
  393. logEntity.F_ExecuteResultJson = "Thermography Status="+entity.Status;
  394. logEntity.WriteLog();
  395. //体温异常
  396. if (entity.Status == "2")
  397. {
  398. //微信推送
  399. try
  400. {
  401. var stuModel = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(x => x.StuNo == entity.PersonBeingMeasured);
  402. if (stuModel != null)
  403. {
  404. logEntity = new LogEntity();
  405. logEntity.F_LogId = Guid.NewGuid().ToString();
  406. logEntity.F_Module = "Thermography";
  407. logEntity.F_ExecuteResultJson = "Thermography stuModelStuNo=" + stuModel.StuNo;
  408. logEntity.WriteLog();
  409. var title = string.Format("{0}({1})", stuModel.StuName, stuModel.StuNo);
  410. PushWeixin(title);
  411. }
  412. }
  413. catch (Exception e)
  414. {
  415. }
  416. }
  417. }
  418. catch (Exception ex)
  419. {
  420. if (ex is ExceptionEx)
  421. {
  422. throw;
  423. }
  424. else
  425. {
  426. throw ExceptionEx.ThrowServiceException(ex);
  427. }
  428. }
  429. }
  430. /// <summary>
  431. /// 生成对应时间段的测量体温的学生数据
  432. /// <param name="timeType">时间段类型</param>
  433. /// <summary>
  434. /// <returns></returns>
  435. public void CreateMorningStudents(string timeType)
  436. {
  437. try
  438. {
  439. //获取当前登录人
  440. var loginUser = LoginUserInfo.Get();
  441. //根据当前登录人获取所属班级
  442. //var classNo = this.BaseRepository("CollegeMIS")
  443. // .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account)?.ClassNo;
  444. var classNo = "201801301";
  445. if (classNo != null)
  446. {
  447. var latestTheEntity = this.BaseRepository("CollegeMIS")
  448. .FindList<ThermographyEntity>(a => a.CreateTime > DateTime.Today && a.MeasureTime == timeType).ToList();
  449. if (latestTheEntity.Count == 0)
  450. {
  451. //根据班号获取所有学生
  452. var students = this.BaseRepository("CollegeMIS")
  453. .FindList<StuInfoBasicEntity>(a => a.ClassNo == classNo);
  454. foreach (var student in students)
  455. {
  456. var thermographyEntity = new ThermographyEntity()
  457. {
  458. ClassNo = student.ClassNo,
  459. MeasureTime = timeType,
  460. PersonBeingMeasured = student.StuNo,
  461. CreateTime = DateTime.Now,
  462. MeasurerID = loginUser.account,
  463. MeasureDate = DateTime.Now,
  464. DeptNo = student.DeptNo,
  465. MajorNo = student.MajorNo,
  466. Status = "0"
  467. };
  468. thermographyEntity.Create(loginUser);
  469. this.BaseRepository("CollegeMIS").Insert(thermographyEntity);
  470. }
  471. }
  472. }
  473. }
  474. catch (Exception ex)
  475. {
  476. if (ex is ExceptionEx)
  477. {
  478. throw;
  479. }
  480. else
  481. {
  482. throw ExceptionEx.ThrowServiceException(ex);
  483. }
  484. }
  485. }
  486. /// <summary>
  487. /// 保存实体数据(新增、修改)
  488. /// <param name="keyValue">主键</param>
  489. /// <summary>
  490. /// <returns></returns>
  491. public void SaveEntityList(string measureTime, List<ThermographyEntity> entities)
  492. {
  493. var db = this.BaseRepository("CollegeMIS");
  494. db.BeginTrans();
  495. try
  496. {
  497. var userInfo = LoginUserInfo.Get();
  498. var now = DateTime.Now;
  499. var nowDate = DateTime.Now.Date;
  500. var nextDate = DateTime.Now.AddDays(1).Date;
  501. foreach (var entity in entities)
  502. {
  503. entity.MeasurerID = userInfo.account;
  504. entity.MeasureDate = now;
  505. entity.MeasureTime = measureTime;
  506. entity.CreateTime = now;
  507. //判断学生是否已测温
  508. var model = db.FindEntity<ThermographyEntity>(x => x.PersonBeingMeasured == entity.PersonBeingMeasured && x.MeasureTime == measureTime && x.MeasureDate >= nowDate && x.MeasureDate < nextDate);
  509. if (model != null)
  510. {
  511. db.Delete(model);
  512. }
  513. entity.Create(userInfo);
  514. db.Insert(entity);
  515. //体温异常
  516. if (entity.Status == "2")
  517. {
  518. //微信推送
  519. try
  520. {
  521. var stuModel = db.FindEntity<StuInfoBasicEntity>(x => x.StuNo == entity.PersonBeingMeasured);
  522. if (stuModel != null)
  523. {
  524. var title = string.Format("{0}({1})", stuModel.StuName, stuModel.StuNo);
  525. PushWeixin(title);
  526. }
  527. }
  528. catch (Exception e)
  529. {
  530. }
  531. }
  532. }
  533. db.Commit();
  534. }
  535. catch (Exception ex)
  536. {
  537. db.Rollback();
  538. if (ex is ExceptionEx)
  539. {
  540. throw;
  541. }
  542. else
  543. {
  544. throw ExceptionEx.ThrowServiceException(ex);
  545. }
  546. }
  547. }
  548. /// <summary>
  549. /// 微信推送
  550. /// </summary>
  551. /// <param name="title"></param>
  552. public void PushWeixin(string title)
  553. {
  554. var EpidemicControlTeamRoleId = Config.GetValue("EpidemicControlTeamRoleId");
  555. if (!string.IsNullOrEmpty(EpidemicControlTeamRoleId))
  556. {
  557. //疫情防控组成员
  558. var userRelationList = this.BaseRepository().FindList<UserRelationEntity>(x => x.F_ObjectId == EpidemicControlTeamRoleId);
  559. //微信配置
  560. var WeChatConfigentity = BaseRepository().FindEntity<WeChatConfigEntity>(m => m.IsEnable == true);
  561. string appid = WeChatConfigentity.APPId;
  562. string secret = WeChatConfigentity.secret;
  563. var wechatemplete = BaseRepository().FindEntity<WeChatTemplateEntity>(m => m.WeID == WeChatConfigentity.ID && m.TCode == "task");
  564. string weixintaskurl = wechatemplete.TUrl;
  565. string weixintasktempid = wechatemplete.TempId;
  566. var responsejson = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret);
  567. LogEntity logEntity = new LogEntity();
  568. logEntity.F_LogId = Guid.NewGuid().ToString();
  569. logEntity.F_Module = "Thermography";
  570. logEntity.F_ExecuteResultJson = "Thermography responsejson=" + responsejson;
  571. logEntity.WriteLog();
  572. foreach (var userRelationItem in userRelationList)
  573. {
  574. var userEntity = this.BaseRepository().FindEntity<UserEntity>(userRelationItem.F_UserId);
  575. if (userEntity != null && !string.IsNullOrEmpty(userEntity.OpenIdForWeixin))
  576. {
  577. //执行推送任务
  578. if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid))
  579. {
  580. if (!string.IsNullOrEmpty(responsejson))
  581. {
  582. var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson);
  583. if (string.IsNullOrEmpty(weixintokenobj.errcode))
  584. {
  585. string access_token = weixintokenobj.access_token;
  586. string jsondata = "{\"touser\":\"" + userEntity.OpenIdForWeixin + "\"," +
  587. "\"template_id\":\"" + weixintasktempid + "\"," +
  588. "\"url\":\"" + weixintaskurl + "\"," +
  589. "\"data\":{" +
  590. "\"first\": {\"value\":\"发现体温异常学生\",\"color\":\"#173177\"}," +
  591. "\"keyword1\":{\"value\":\"体温异常学生\",\"color\":\"#173177\"}," +
  592. "\"keyword2\": {\"value\":\"" + title + "\",\"color\":\"#173177\"}," +
  593. "\"keyword3\": {\"value\":\"待查看\",\"color\":\"#173177\"}," +
  594. "\"keyword4\": {\"value\":\"发现体温异常学生【" + title + "】\",\"color\":\"#173177\"}" +
  595. "}" +
  596. "}";
  597. string pushresult = Util.HttpMethods.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, jsondata);
  598. logEntity = new LogEntity();
  599. logEntity.F_LogId = Guid.NewGuid().ToString();
  600. logEntity.F_Module = "Thermography";
  601. logEntity.F_ExecuteResultJson = "Thermography pushresult=" + pushresult;
  602. logEntity.WriteLog();
  603. }
  604. }
  605. }
  606. }
  607. }
  608. }
  609. }
  610. #endregion
  611. }
  612. }