圣珀
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.

109 lines
4.6 KiB

2 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using ICS.WCF.Base;
  8. using ICSSoft.Entity;
  9. namespace ICS.Supplier
  10. {
  11. public class GetSupplier
  12. {
  13. public FormICSCreatedArrivalNoticeModel FindByApproveDate(ISupplier d)
  14. {
  15. StringBuilder strHead = new StringBuilder();
  16. strHead.AppendLine("***************接口传入参数记录****************:");
  17. strHead.AppendLine("开始时间:" + d.StartTime);
  18. strHead.AppendLine("结束时间:" + d.EndTime);
  19. strHead.AppendLine("***************接口传入参数记录****************:");
  20. Appconfig.WriteLogFile(strHead.ToString(), "U9料品信息接口日志");
  21. StringBuilder resultlog = new StringBuilder();
  22. FormICSCreatedArrivalNoticeModel result = new FormICSCreatedArrivalNoticeModel();
  23. List<KPRApprovedEntity> returnValue = new List<KPRApprovedEntity>();
  24. try
  25. {
  26. DateTime time1 = Appconfig.TimestampToDateTime(d.StartTime);
  27. DateTime time2 = Appconfig.TimestampToDateTime(d.EndTime);
  28. string sql = @"select DISTINCT A.[Code] as 供应商编码, A1.[Name] as 供应商名称,A1.ID as 供应商id,A2.Code as 组织代码
  29. from CBO_Supplier as A
  30. left join [CBO_Supplier_Trl] as A1 on (A1.SysMlFlag = 'zh-CN') and (A.[ID] = A1.[ID])
  31. LEFT JOIN Base_Organization as A2 on A.Org=A2.ID
  32. where 1=1 and A.[Effective_IsEffective]=1 AND A2.Code='02' ";
  33. if (!string.IsNullOrEmpty(d.StartTime.ToString()) && d.StartTime != 0)
  34. {
  35. sql += " and A.ModifiedOn >= '" + time1 + "'";
  36. }
  37. if (!string.IsNullOrEmpty(d.EndTime.ToString()) && d.EndTime != 0)
  38. {
  39. sql += " and A.ModifiedOn <= '" + time2 + "'";
  40. }
  41. DataTable dt = DBhlper.Query(sql, Appconfig.GetU9ConnStr());
  42. if (dt == null)
  43. {
  44. result.Code = -1;
  45. result.ResMsg = "获取U9供应商信息失败";
  46. result.ResData = null;
  47. result.IsCompress = false;
  48. result.IsSuccess = false;
  49. resultlog.AppendLine("获取U9供应商信息失败");
  50. resultlog.AppendLine("查询sql:" + sql);
  51. Appconfig.WriteLogFile(resultlog.ToString(), "U9供应商信息接口日志");
  52. return result;
  53. }
  54. int count = dt.Rows.Count; ;
  55. foreach (DataRow dr in dt.Rows)
  56. {
  57. KPRApprovedEntity PRLine = new KPRApprovedEntity();
  58. PRLine.OrgID = dr["组织代码"].ToString();
  59. PRLine.ERPID = dr["供应商id"].ToString();
  60. PRLine.bstSupNo = dr["供应商编码"].ToString();
  61. PRLine.bstName = dr["供应商名称"].ToString();
  62. returnValue.Add(PRLine);
  63. }
  64. result.Code = 0;
  65. result.ResMsg = "获取U9供应商信息成功";
  66. result.ResData = returnValue;
  67. result.IsCompress = false;
  68. result.IsSuccess = true;
  69. return result;
  70. }
  71. catch (Exception ex)
  72. {
  73. result.Code = -1;
  74. result.ResMsg = "U9供应商信息获取失败,请查看日志";
  75. result.ResData = null;
  76. result.IsCompress = false;
  77. result.IsSuccess = false;
  78. StringBuilder str = new StringBuilder();
  79. str.AppendLine("U9供应商信息获取失败");
  80. str.AppendLine("开始时间:" + d.StartTime);
  81. str.AppendLine("结束时间:" + d.EndTime);
  82. str.AppendLine("失败原因:" + ex.Message);
  83. Appconfig.WriteLogFile(str.ToString(), "U9供应商信息接口日志");
  84. }
  85. return result;
  86. }
  87. /// <summary>
  88. /// 返回值
  89. /// </summary>
  90. public class FormICSCreatedArrivalNoticeModel
  91. {
  92. //0 :正常数据,-1:失败。
  93. public int Code { get; set; }
  94. public string ResMsg { get; set; }
  95. public List<KPRApprovedEntity> ResData { get; set; }
  96. public bool IsCompress { get; set; }
  97. public bool IsSuccess { get; set; }
  98. }
  99. }
  100. }