UploadRdrecord08.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. public class UploadRdrecord08 : BaseUpload
  19. {
  20. protected override void _PrepareData(Hashtable args)
  21. {
  22. string sql = "select sysid,id,ccode from wtu..rdrecord08 where processflag=0 and direction=0 ";
  23. _data = DbUtils.Fill(sql, ConnectionUtils.Instance.GetConnection());
  24. }
  25. public List<AddResult> _results=new List<AddResult>();
  26. protected override AddResult _Upload(DataRow dr)
  27. {
  28. Rdrecord08Upload upload = new Rdrecord08Upload();
  29. string data = string.Empty;
  30. AddResult result = upload.UploadToWang(_GetData(dr));
  31. _results.Add(result);
  32. return result;
  33. }
  34. protected override void _WriteLog(AddResult result, DataRow dr)
  35. {
  36. int id = Convert.ToInt32(dr["sysid"]);
  37. string sql;
  38. if (result.IsSucess)
  39. {
  40. //sql = "update wtu..rdrecord08 set processdate=getdate(),processflag=1 where sysid=" + id.ToString();
  41. sql = "update wtu..rdrecord08 set processdate=getdate(),processflag=1,newcode='"+ result.DocCode + "' where sysid=" + id.ToString();
  42. OperationLog.Utils.UpdateTempRecord(sql);
  43. }
  44. else
  45. {
  46. OperationLog.Utils.WriteErrorLog("上传旺店通其他入库单", "其他入库单:" + dr["ccode"].ToString() + "\t\r" + result.Message);
  47. }
  48. }
  49. protected override string _GetData(DataRow dr)
  50. {
  51. Dictionary<string, string> args = new Dictionary<string, string>();
  52. string id = dr["id"].ToString();
  53. args.Add("rdrecord08", "select * from wtu..rdrecord08 where id=" + id);
  54. args.Add("rdrecords08", "select * from wtu..rdrecords08 where id=" + id);
  55. DataSet ds = DbUtils.Fill(args, ConnectionUtils.Instance.GetConnection());
  56. //StockinProxy stockin = new StockinProxy();
  57. //Stockin_List[] list = new Stockin_List[1];
  58. Stockin_List head = __GetHead(ds);
  59. head.goods_list = __GetDetails(ds);
  60. //list[0] = head;
  61. //stockin.stockin_list = list;
  62. //return JsonUtils.GetJsonString(stockin);
  63. return JsonUtils.GetJsonString(head);//只能传单个
  64. }
  65. private Stockin_List __GetHead(DataSet ds)
  66. {
  67. Stockin_List rtn = new Stockin_List();
  68. DataTable dt = ds.Tables["rdrecord08"];
  69. //rtn.outer_no = dt.Rows[0]["ccode"].ToString();
  70. //rtn.warehouse_no = "yilv2test";
  71. rtn.warehouse_no = dt.Rows[0]["cWhCode"].ToString();
  72. rtn.outer_no = dt.Rows[0]["ccode"].ToString();
  73. rtn.remark = "来源U8";
  74. return rtn;
  75. }
  76. private Goods_List[] __GetDetails(DataSet ds)
  77. {
  78. int cnt = ds.Tables["rdrecords08"].Rows.Count;
  79. DataTable dt = ds.Tables["rdrecords08"];
  80. Goods_List[] rtn = new Goods_List[cnt];
  81. for (int i = 0; i < cnt; i++)
  82. {
  83. Goods_List item = new Goods_List();
  84. item.spec_no = dt.Rows[i]["cInvCode"].ToString();
  85. item.stockin_num = _ConvertNotStr(dt.Rows[i]["iQuantity"].ToString());
  86. item.src_price = _ConvertNotStr(dt.Rows[i]["iUnitCost"].ToString());
  87. item.stockin_price = _ConvertNotStr(dt.Rows[i]["iUnitCost"].ToString());
  88. rtn[i] = item;
  89. }
  90. return rtn;
  91. }
  92. private string _ConvertNotStr(string valueStr)
  93. {
  94. return string.IsNullOrWhiteSpace(valueStr) ? "0" : valueStr;
  95. }
  96. }
  97. }