Delay.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 Delay
  11. {
  12. private readonly CommonTool tool = new CommonTool();
  13. public DataTable GetDelay(string flowId)
  14. {
  15. var conn = tool.GetConSqlServer();
  16. var sql = $@" SELECT * FROM dbo.Flow11_Postpone WHERE FPE_FlowID = {flowId} AND FPE_AuditFlag IN (1) ";
  17. return tool.GetDataTable(sql, conn);
  18. }
  19. public string GetDelaySql(DataTable data, DataRow row, string orderId, DataTable org, DataTable user) {
  20. var delayNum = 0;
  21. var pgDelaySql = string.Empty;
  22. foreach (DataRow delay in data.Rows)
  23. {
  24. var delayId = SequentialGuidGenerator.Instance.Create().ToString("D");
  25. var EmployeeId = delay["FPE_UserID"].ToString();
  26. var VisitOrgCode = delay["FPE_BMID"].ToString();
  27. try
  28. {
  29. DataRow userRow = user.AsEnumerable().First(x => x.Field<int>("OldUserId").ToString() == delay["FPE_UserID"].ToString());
  30. EmployeeId = string.IsNullOrEmpty(userRow?["Id"].ToString()) ? "NULL" : userRow?["Id"].ToString();
  31. DataRow ogrRow = org.AsEnumerable().First(x => x.Field<int>("oldBmid").ToString() == delay["FPE_BMID"].ToString());
  32. VisitOrgCode = string.IsNullOrEmpty(ogrRow?["Id"].ToString()) ? delay["FPE_BMID"].ToString() : ogrRow?["Id"].ToString();
  33. }
  34. catch (Exception e)
  35. {
  36. tool.SaveLog(" DelayMessage :" + e.Message + ";FPE_BMID:" + delay["FPE_BMID"].ToString() + "FPE_UserID:"+ delay["FPE_UserID"].ToString() + " ;", 1);
  37. }
  38. if (delayNum == 0)
  39. {
  40. pgDelaySql = $@"INSERT INTO ""public"".""order_delay"" (""Id"", ""No"", ""OrderId"", ""ApplyDelayTime"", ""ApplyOrgCode"", ""ApplyOrgName"", ""EmployeeId"", ""DelayNum"", ""DelayUnit"", ""DelayReason"",
  41. ""BeforeDelay"", ""AfterDelay"", ""DelayState"", ""IsProDelay"", ""CreationTime"", ""CreatorOrgId"", ""CreatorId"", ""AreaId"", ""CreatorOrgName"", ""CreatorName"", ""CreatorOrgLevel"",
  42. ""WorkflowId"", ""FileJson"", ""EmployeeName"", ""ExpiredTimeConfigId"", ""FlowedOrgIds"", ""FlowedUserIds"", ""LastModificationTime"", ""IsDeleted"", ""DeletionTime"") VALUES
  43. ('{delayId}', '{row["FSH_Code"].ToString().Trim()}', '{orderId}', '{delay["FPE_FPDate"]}', '{VisitOrgCode}', '{delay["FPE_BMName"]}', '{EmployeeId}', '{delay["FPE_SLimits"]}', 2, '{delay["FPE_Reson"]}', NULL, '{delay["FPE_STTime"]}',
  44. 1, 'f', '{delay["FPE_FPDate"]}', '{VisitOrgCode}', '08dc10ec-2dd8-4383-8426-b194c4f5e917', '', '{delay["FPE_BMName"]}', '张晓梅1', 1, '', NULL, '{delay["FPE_UserName"]}', NULL, NULL,NULL, NULL, 'f', NULL)";
  45. }
  46. else
  47. {
  48. pgDelaySql += $@",('{delayId}', '{row["FSH_Code"].ToString().Trim()}', '{orderId}', '{delay["FPE_FPDate"]}', '{VisitOrgCode}', '{delay["FPE_BMName"]}', '{EmployeeId}', '{delay["FPE_SLimits"]}', 2, '{delay["FPE_Reson"]}', NULL, '{delay["FPE_STTime"]}',
  49. 1, 'f', '{delay["FPE_FPDate"]}', '{VisitOrgCode}', '08dc10ec-2dd8-4383-8426-b194c4f5e917', '', '{delay["FPE_BMName"]}', '张晓梅1', 1, '', NULL, '{delay["FPE_UserName"]}', NULL, NULL, NULL, NULL, 'f', NULL)";
  50. }
  51. delayNum++;
  52. }
  53. return pgDelaySql += ";";
  54. }
  55. }
  56. }