Notice.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using Abp;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace DataTransmission.Joint
  9. {
  10. public class Notice
  11. {
  12. private readonly CommonTool tool = new CommonTool();
  13. public DataTable GetOldNotice(string st_time, string end_time)
  14. {
  15. // st_time = "2024-08-26 15:42:22";
  16. var conn = tool.GetConSqlServer();
  17. var sql = $@"select WNLT_NoticeID as Id, WNLT_Title AS Title,WNCT_Content AS Content,WNLT_TypeID AS BulletinTypeId,WNT_TypeName AS BulletinTypeName,
  18. WNED_ReadCount AS ReadedNum,WNLT_CreateDate AS BulletinTime ,2 AS BulletinState,WNED_WebPubFlag AS WebPub,WNED_WeChat AS WeChat,
  19. '001' AS SourceOrgId,'热线中心' AS SourceOrgName,WNLT_CreateDate AS CommitTime,WNLT_AuditUserID AS AuditUserID,WNLT_AuditDate AS AuditDate
  20. ,WNLT_UserID as UserID,
  21. WNLT_UserName as UserName ,WNED_WinFlag as WinFlag , WNED_UpFlag as UpFlag
  22. from Web04_NoticeList nl
  23. left join Web05_NoticeExpand ne on nl.WNLT_NoticeID=ne.WNED_NoticeID
  24. left join Web06_NoticeContent nc on nc.WNCT_NoticeID=nl.WNLT_NoticeID
  25. left join Web03_NoticeType nt on nl.WNLT_TypeID=nt.WNT_TypeID
  26. where WNLT_CreateDate>='{st_time}' and WNLT_CreateDate<='{end_time}'";
  27. //HR.SHR_Date >= '{st_time}' AND HR.SHR_Date <= '{end_time}' AND
  28. return tool.GetDataTable(sql, conn);
  29. }
  30. public string GetNoticeSql(DataRow item)
  31. {
  32. var noticeSql = $@"INSERT INTO ""public"".""bulletin"" (""Id"", ""Title"", ""Content"", ""BulletinTypeId"", ""BulletinTypeName"", ""ReadedNum"", ""BulletinTime"",
  33. ""LoseEfficacyTime"", ""BulletinState"", ""PushRanges"", ""SourceOrgId"", ""SourceOrgName"", ""CreationTime"", ""CreatorId"", ""CreatorName"",
  34. ""CreatorOrgId"", ""CreatorOrgName"", ""CreatorOrgLevel"", ""AreaId"", ""CommitTime"", ""ExaminOpinion"", ""ExaminManId"", ""ExaminTime"",
  35. ""IsArrive"",""DisplayLocation"",""OldNoticeId"") VALUES";
  36. var PushRanges = "";
  37. if (item["WebPub"].ToString() == "1")
  38. {
  39. if (string.IsNullOrEmpty(PushRanges))
  40. PushRanges += $@"{{""Key"":""2"",""Value"":""门户网站""}}";
  41. else
  42. PushRanges += $@",{{""Key"":""2"",""Value"":""门户网站""}}";
  43. }
  44. if (item["WeChat"].ToString() == "1")
  45. {
  46. if (string.IsNullOrEmpty(PushRanges))
  47. PushRanges += $@"{{""Key"":""1"",""Value"":""微信小程序""}}";
  48. else
  49. PushRanges += $@",{{""Key"":""1"",""Value"":""微信小程序""}}";
  50. }
  51. PushRanges = "[" + PushRanges + "]";
  52. var noticeId = SequentialGuidGenerator.Instance.Create().ToString("D");
  53. var cretuser = GetPgUser(item["UserID"].ToString());
  54. string cretuserid = "";
  55. if (cretuser != null && cretuser.Rows.Count > 0)
  56. {
  57. cretuserid = cretuser.Rows[0]["Id"].ToString();
  58. }
  59. var aduuser = GetPgUser(item["AuditUserID"].ToString());
  60. string caduuserid = "";
  61. if (aduuser != null && aduuser.Rows.Count > 0)
  62. {
  63. caduuserid = aduuser.Rows[0]["Id"].ToString();
  64. }
  65. var displayLocation = "";
  66. if (item["WinFlag"].ToString() == "1")//飘窗 [{"Key":"1","Value":"是否置顶"},{"Key":"2","Value":"是否飘窗 "}]
  67. {
  68. if (string.IsNullOrEmpty(displayLocation))
  69. displayLocation += $@"{{""Key"":""2"",""Value"":""是否飘窗""}}";
  70. else
  71. displayLocation += $@",{{""Key"":""2"",""Value"":""是否飘窗""}}";
  72. }
  73. if (item["UpFlag"].ToString() == "1")//置顶
  74. {
  75. if (string.IsNullOrEmpty(displayLocation))
  76. displayLocation += $@"{{""Key"":""1"",""Value"":""是否置顶""}}";
  77. else
  78. displayLocation += $@",{{""Key"":""1"",""Value"":""是否置顶""}}";
  79. }
  80. displayLocation = "[" + displayLocation + "]";
  81. noticeSql += $@"('{noticeId}', '{item["Title"]}', '{item["Content"]}', '{item["BulletinTypeId"]}', '{item["BulletinTypeName"]}',
  82. {item["ReadedNum"]}, '{item["BulletinTime"]}', '2050-06-07 01:11:11', 2, '{PushRanges}', '001', '热线中心',
  83. '{item["BulletinTime"]}', '{cretuserid}', '{item["UserName"]}', '001', '热线中心', 1, '001', '{item["CommitTime"]}',
  84. '同意', '{caduuserid}', '{item["AuditDate"]}', 't','{displayLocation}','{item["Id"]}')";
  85. return noticeSql;
  86. }
  87. public DataTable GetPgUser(string userid)
  88. {
  89. var conn = tool.GetConPgSql();
  90. var sql = $@"select ""Id"",""Name"" from ""user"" where ""OldUserId""='{userid}' ";
  91. return tool.GetDataTable(sql, conn);
  92. }
  93. }
  94. }