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

139 lines
6.8 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.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8. using ICS.WCF.Base;
  9. using ICSSoft.Entity;
  10. namespace ICS.IFeaturesValue
  11. {
  12. public class FeaturesValue
  13. {
  14. public FormICSCreatedArrivalNoticeModel FindByApproveDate(ValueModel d)
  15. {
  16. StringBuilder strHead = new StringBuilder();
  17. strHead.AppendLine("***************接口传入参数记录****************:");
  18. strHead.AppendLine("开始时间:" + d.StartTime);
  19. strHead.AppendLine("结束时间:" + d.EndTime);
  20. strHead.AppendLine("***************接口传入参数记录****************:");
  21. Appconfig.WriteLogFile(strHead.ToString(), "U9采购/委外信息接口日志");
  22. StringBuilder resultlog = new StringBuilder();
  23. FormICSCreatedArrivalNoticeModel result = new FormICSCreatedArrivalNoticeModel();
  24. List<FeaturesValueModel> returnValue = new List<FeaturesValueModel>();
  25. try
  26. {
  27. //判断是否有时间戳传入
  28. DateTime time1 = Appconfig.TimestampToDateTime(d.StartTime);
  29. DateTime time2 = Appconfig.TimestampToDateTime(d.EndTime);
  30. string ERPDB = Appconfig.GetBPERPStr();
  31. DataTable _dt_ = new DataTable();
  32. string sql_new = @" select DISTINCT d.Code,a.ID,a.DocNo,a.SubType,a.ModifiedOn,c.Description from PM_PurchaseOrder a
  33. LEFT JOIN PM_POMemo b on a.ID=b.PurchaseOrder
  34. LEFT JOIN PM_POMemo_Trl c on b.ID=c.ID
  35. LEFT JOIN Base_Organization d on a.Org=d.ID
  36. WHERE 1 = 1 and d.Code='02'
  37. ";
  38. //写入传入内容数据
  39. if (!string.IsNullOrEmpty(d.StartTime.ToString()) && d.StartTime != 0)
  40. sql_new += " and a.ModifiedOn >= '" + time1 + "'";
  41. if (!string.IsNullOrEmpty(d.StartTime.ToString()) && d.EndTime != 0)
  42. sql_new += " and a.[ModifiedOn] <= '" + time2 + "'";
  43. sql_new = string.Format(sql_new,ERPDB);
  44. _dt_ = DBhlper.Query(sql_new, Appconfig.GetU9ConnStr());
  45. if (_dt_ == null || _dt_.Rows.Count <= 0)
  46. {
  47. throw new Exception("该采购/委外信息不存在");
  48. }
  49. //循环获取数据入返回集合内
  50. foreach (DataRow dr in _dt_.Rows)
  51. {
  52. FeaturesValueModel model = new FeaturesValueModel();
  53. model.OrgID = dr["Code"].ToString();
  54. model.POID = dr["ID"].ToString();
  55. model.PONo = dr["DocNo"].ToString();
  56. model.POType = Convert.ToInt32(dr["SubType"].ToString());
  57. model.CreateDate = Convert.ToDateTime(dr["ModifiedOn"].ToString());
  58. model.Remarks = dr["Description"].ToString();
  59. string sql_new1 = @"select DISTINCT a.ID,a.DocLineNo,a.ItemInfo_ItemCode,a.PurQtySU as RequireQty,a.PurQtySU as AcceptQty,g.DeliveryDate,
  60. (case a.Status WHEN '2' THEN '1' ELSE '0' end) as Status,f.Code,
  61. e.Description from PM_POLine a
  62. LEFT JOIN PM_PurchaseOrder b on a.PurchaseOrder=b.ID
  63. LEFT JOIN CBO_ItemMaster c on a.ItemInfo_ItemCode=c.Code
  64. LEFT JOIN PM_POMemo d on a.ID=d.PurchaseOrder
  65. LEFT JOIN PM_POMemo_Trl e on d.ID=e.ID
  66. LEFT JOIN Base_UOM f on c.InventoryUOM=f.ID
  67. LEFT JOIN PM_POShipLine g on a.DocLineNo=g.POLine
  68. where a.PurchaseOrder='" + dr["ID"].ToString() + @"' ";
  69. sql_new1 = string.Format(sql_new1);
  70. DataTable _dt_1 = DBhlper.Query(sql_new1, Appconfig.GetU9ConnStr());
  71. List<POs> lstpo = new List<POs>();
  72. foreach (DataRow dr1 in _dt_1.Rows)
  73. {
  74. POs pomodel = new POs();
  75. pomodel.RowNo = dr1["DocLineNo"].ToString();
  76. pomodel.POSID = dr1["ID"].ToString();
  77. pomodel.ItemNo = dr1["ItemInfo_ItemCode"].ToString();
  78. pomodel.Postdate = dr1["DeliveryDate"].ToString();
  79. pomodel.RequireQty = Convert.ToDecimal(dr1["RequireQty"].ToString());
  80. pomodel.AcceptQty = Convert.ToDecimal(dr1["AcceptQty"].ToString());
  81. pomodel.UomNo = dr1["Code"].ToString();
  82. pomodel.IsClose = Convert.ToInt32(dr1["Status"].ToString());
  83. pomodel.Remarks = dr1["Description"].ToString();
  84. lstpo.Add(pomodel);
  85. }
  86. model.POS = lstpo;
  87. returnValue.Add(model);
  88. }
  89. result.Code = 0;
  90. result.ResMsg = "获取U9采购/委外信息成功";
  91. result.ResData = returnValue;
  92. result.IsCompress = false;
  93. result.IsSuccess = true;
  94. return result;
  95. }
  96. catch (Exception ex)
  97. {
  98. result.Code = -1;
  99. result.ResMsg = ex.Message;
  100. result.ResData = null;
  101. result.IsCompress = false;
  102. result.IsSuccess = false;
  103. StringBuilder str = new StringBuilder();
  104. str.AppendLine("U9采购/委外信息获取失败");
  105. str.AppendLine("开始时间:" + d.StartTime);
  106. str.AppendLine("结束时间:" + d.EndTime);
  107. str.AppendLine("失败原因:" + ex.Message);
  108. Appconfig.WriteLogFile(str.ToString(), "U9采购/委外信息接口日志");
  109. }
  110. return result;
  111. }
  112. /// <summary>
  113. /// 返回值
  114. /// </summary>
  115. public class FormICSCreatedArrivalNoticeModel
  116. {
  117. //0 :正常数据,-1:失败。
  118. public int Code { get; set; }
  119. public string ResMsg { get; set; }
  120. public List<FeaturesValueModel> ResData { get; set; }
  121. public bool IsCompress { get; set; }
  122. public bool IsSuccess { get; set; }
  123. }
  124. }
  125. }