Notice.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_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"") VALUES";
  36. var PushRanges = "[";
  37. if (item["WebPub"].ToString() == "1")
  38. {
  39. PushRanges += $@"{{""Key"":""2"",""Value"":""门户网站""}}";
  40. }
  41. if (item["WeChat"].ToString() == "1")
  42. {
  43. PushRanges += $@",{{""Key"":""1"",""Value"":""微信小程序""}}";
  44. }
  45. PushRanges += "]";
  46. var noticeId = SequentialGuidGenerator.Instance.Create().ToString("D");
  47. var cretuser = GetPgUser(item["UserID"].ToString());
  48. string cretuserid = "";
  49. if (cretuser != null && cretuser.Rows.Count > 0)
  50. {
  51. cretuserid = cretuser.Rows[0]["Id"].ToString();
  52. }
  53. var aduuser = GetPgUser(item["AuditUserID"].ToString());
  54. string caduuserid = "";
  55. if (aduuser != null && aduuser.Rows.Count > 0)
  56. {
  57. caduuserid = aduuser.Rows[0]["Id"].ToString();
  58. }
  59. var displayLocation = "[";
  60. if (item["WinFlag"].ToString() == "1")//飘窗 [{"Key":"1","Value":"是否置顶"},{"Key":"2","Value":"是否飘窗 "}]
  61. {
  62. displayLocation += $@"{{""Key"":""2"",""Value"":""是否飘窗""}}";
  63. }
  64. if (item["UpFlag"].ToString() == "1")//置顶
  65. {
  66. displayLocation += $@",{{""Key"":""1"",""Value"":""是否置顶""}}";
  67. }
  68. displayLocation += "]";
  69. noticeSql += $@"('{noticeId}', '{item["Title"]}', '{item["Content"]}', '{item["BulletinTypeId"]}', '{item["BulletinTypeName"]}',
  70. {item["ReadedNum"]}, '{item["BulletinTime"]}', '2050-06-07 00:00:00', 2, '{PushRanges}', '001', '市民热线服务中心',
  71. '{item["BulletinTime"]}', '{cretuserid}', '{item["UserName"]}', '001', '市民热线服务中心', 1, '001', '{item["CommitTime"]}',
  72. '同意', '{caduuserid}', '{item["AuditDate"]}', 't','{displayLocation}')";
  73. return noticeSql;
  74. }
  75. public DataTable GetPgUser(string userid)
  76. {
  77. var conn = tool.GetConPgSql();
  78. var sql = $@"select ""Id"",""Name"" from ""user"" where ""OldUserId""='{userid}' ";
  79. return tool.GetDataTable(sql, conn);
  80. }
  81. }
  82. }