UploadRdrecord09.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Collections;
  7. using System.Data;
  8. using cuidian.Sql;
  9. using WdtUtils.Proxy;
  10. using WdtUtils.UpLoad;
  11. using WdtUtils;
  12. using cuidian.Common;
  13. namespace TempDbToWang
  14. {
  15. /// <summary>
  16. /// 其他出库单从中间库上传到旺店通
  17. /// </summary>
  18. ///
  19. public delegate void DelSql();
  20. public class UploadRdrecord09 : BaseUpload
  21. {
  22. protected override void _PrepareData(Hashtable args)
  23. {
  24. string sql = "select sysid,id,ccode from wtu..rdrecord09 where processflag=0 and direction=0 ";
  25. _data = DbUtils.Fill(sql, ConnectionUtils.Instance.GetConnection());
  26. }
  27. public List<AddResult> _results = new List<AddResult>();
  28. private string _strSql="";
  29. public string StrSql
  30. {
  31. get
  32. {
  33. return _strSql;
  34. }
  35. set
  36. {
  37. this._strSql = value;
  38. }
  39. }
  40. protected override AddResult _Upload(DataRow dr)
  41. {
  42. Rdrecord09Upload upload = new Rdrecord09Upload();
  43. string data = string.Empty;
  44. AddResult result = upload.UploadToWang(_GetData(dr));
  45. _results.Add(result);
  46. return result;
  47. }
  48. protected override void _WriteLog(AddResult result, DataRow dr)
  49. {
  50. int id = Convert.ToInt32(dr["sysid"]);
  51. string sql;
  52. if (result.IsSucess)
  53. {
  54. //sql = "update wtu..rdrecord09 set processdate=getdate(),processflag=1 where sysid=" + id.ToString();
  55. sql = "update wtu..rdrecord09 set processdate=getdate(),processflag=1,newcode='" + result.DocCode + "' where sysid=" + id.ToString();
  56. OperationLog.Utils.UpdateTempRecord(sql);
  57. }
  58. else
  59. {
  60. OperationLog.Utils.WriteErrorLog("上传旺店通其他出库单", "其他出库单:" + dr["ccode"].ToString() + "\t\r" + result.Message);
  61. }
  62. }
  63. protected override string _GetData(DataRow dr)
  64. {
  65. Dictionary<string, string> args = new Dictionary<string, string>();
  66. string id = dr["id"].ToString();
  67. args.Add("rdrecord09", "select * from wtu..rdrecord09 where id=" + id);
  68. args.Add("rdrecords09", "select * from wtu..rdrecords09 where id=" + id);
  69. DataSet ds = DbUtils.Fill(args, ConnectionUtils.Instance.GetConnection());
  70. Stockin_List head = __GetHead(ds);
  71. head.detail_list = __GetDetails(ds);
  72. return JsonUtils.GetJsonString(head);
  73. }
  74. private Stockin_List __GetHead(DataSet ds)
  75. {
  76. Stockin_List rtn = new Stockin_List();
  77. DataTable dt = ds.Tables["rdrecord09"];
  78. rtn.outer_no = dt.Rows[0]["ccode"].ToString();
  79. //rtn.warehouse_no = "yilv2test";
  80. rtn.warehouse_no = dt.Rows[0]["cWhCode"].ToString();
  81. rtn.remark = "来源U8";
  82. return rtn;
  83. }
  84. private Detail_List[] __GetDetails(DataSet ds)
  85. {
  86. int cnt = ds.Tables["rdrecords09"].Rows.Count;
  87. DataTable dt = ds.Tables["rdrecords09"];
  88. Detail_List[] rtn = new Detail_List[cnt];
  89. for (int i = 0; i < cnt; i++)
  90. {
  91. Detail_List item = new Detail_List();
  92. item.spec_no = dt.Rows[i]["cInvCode"].ToString();
  93. item.num = _ConvertNotStr(dt.Rows[i]["iQuantity"].ToString());
  94. item.price = _ConvertNotStr(dt.Rows[i]["iUnitCost"].ToString());
  95. //item.stockin_price = _ConvertNotStr(dt.Rows[i]["iUnitCost"].ToString());
  96. rtn[i] = item;
  97. }
  98. return rtn;
  99. }
  100. private string _ConvertNotStr(string valueStr)
  101. {
  102. return string.IsNullOrWhiteSpace(valueStr) ? "0" : valueStr;
  103. }
  104. }
  105. }