DownLoadOtherin.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 cuidian.Common;
  8. using cuidian.OpenApi.Api;
  9. using cuidian.OpenApi.Model;
  10. using cuidian.OpenApi.Utils;
  11. using OperationLog;
  12. using cuidian.Sql;
  13. namespace TempDbToUfida.OpenApi
  14. {
  15. /// <summary>
  16. /// 从中间库将其他入库资料下载到U8数据库
  17. /// </summary>
  18. public class DownLoadOtherin : BaseDataDownLoad
  19. {
  20. protected override void _Init()
  21. {
  22. _loadSql = "select * from RdRecord08 where processflag=0 and direction=1";
  23. base._Init();
  24. }
  25. protected override BusinessObject _ImportData(DataRow row)
  26. {
  27. OtherinApi api = new OtherinApi();
  28. Dictionary<string, string> args = new Dictionary<string, string>();
  29. string id = row["ID"].ToString();
  30. args.Add("RdRecord08", "select * from wtu..RdRecord08 where ID=" + id);
  31. args.Add("RdRecords08", "select * from wtu..RdRecords08 where ID=" + id);
  32. DataSet ds = DbUtils.Fill(args, ConnectionUtils.Instance.GetConnection());
  33. Otherin v = __GetHead(ds);
  34. v.entry = __GetDetails(ds);
  35. OtherinRoot vr = new OtherinRoot();
  36. vr.otherin = v;
  37. BusinessObject result = api.Add(JsonUtils.GetJsonString(vr));
  38. return result;
  39. }
  40. protected override void _Audit(string id)
  41. {
  42. OtherinApi api = new OtherinApi();
  43. api.Audit(id);
  44. }
  45. private Otherin __GetHead(DataSet ds)
  46. {
  47. Otherin v = new Otherin();
  48. DataTable dt = ds.Tables["RdRecord08"];
  49. v.code = dt.Rows[0]["cCode"].ToString();
  50. DateTime date = DateTime.Parse(dt.Rows[0]["dDate"].ToString());
  51. v.date = date.ToString("yyyy-MM-dd");
  52. v.maker = dt.Rows[0]["cMaker"].ToString();
  53. v.warehousecode = dt.Rows[0]["cWhCode"].ToString();
  54. v.memory = dt.Rows[0]["cMemo"].ToString();
  55. v.define5 = dt.Rows[0]["ID"].ToString();
  56. v.define1 = "来源旺店通";
  57. string cDefine15 = dt.Rows[0]["cDefine15"].ToString();
  58. if (cDefine15.Equals("2"))
  59. {
  60. v.receivecode = AppSeting.Instance.GetValue("receivecodeIn2");//收发类型默认S
  61. }
  62. else if (cDefine15.Equals("4"))
  63. {
  64. v.receivecode = AppSeting.Instance.GetValue("receivecodeIn4");//收发类型默认S
  65. }
  66. else if (cDefine15.Equals("6"))
  67. {
  68. v.receivecode = AppSeting.Instance.GetValue("receivecodeIn6");//收发类型默认S
  69. }
  70. else if (cDefine15.Equals("7"))
  71. {
  72. v.receivecode = AppSeting.Instance.GetValue("receivecodeIn7");//收发类型默认S
  73. }
  74. else if (cDefine15.Equals("3"))
  75. {
  76. v.receivecode = "S8";
  77. }
  78. return v;
  79. }
  80. private Entry[] __GetDetails(DataSet ds)
  81. {
  82. int cnt = ds.Tables["RdRecords08"].Rows.Count;
  83. DataTable dt = ds.Tables["RdRecords08"];
  84. Entry[] rtn = new Entry[cnt];
  85. for (int i = 0; i < cnt; i++)
  86. {
  87. Entry e = new Entry();
  88. e.inventorycode = dt.Rows[i]["cInvCode"].ToString().Replace(" ", "");
  89. e.quantity = dt.Rows[i]["iQuantity"].ToString();
  90. e.quantity = string.IsNullOrEmpty(e.quantity) ? "0" : e.quantity;
  91. e.price = dt.Rows[i]["iUnitCost"].ToString();
  92. e.price = string.IsNullOrEmpty(e.price) ? "0" : e.price;
  93. e.cost = dt.Rows[i]["iPUnitCost"].ToString();
  94. e.define27 = dt.Rows[i]["ID"].ToString();
  95. e.rowno = (i + 1).ToString();
  96. rtn[i] = e;
  97. }
  98. return rtn;
  99. }
  100. protected override void _LogError(int id, string msg)
  101. {
  102. OperationLog.Utils.WriteErrorLog("向U8导入其他入库资料", "sysid = " + id.ToString() + " " + msg);
  103. }
  104. protected override void _LogSucess(int id, string newCode)
  105. {
  106. string sql = "update RdRecord08 set processflag = 1,processdate = getdate(),newcode='" + newCode + "'" + " where sysid = " + id.ToString();
  107. //string sql = "update RdRecord08 set processflag = 1,processdate = getdate(),newcode=(select cCode from wtu..RdRecord08 where sysid = " + id.ToString() + ") where sysid = " + id.ToString();
  108. OperationLog.Utils.UpdateTempRecord(sql);
  109. }
  110. protected override string _GetReturnCode(BusinessObject result)
  111. {
  112. //string ID = DbUtils.ExecuteScalar(string.Format("select ID from RdRecord08 where cCode='{0}' ", result.Id), ConnectionUtils.Instance.GetConnection("003")).ToString();
  113. //return ID;
  114. return result.Id;
  115. }
  116. }
  117. }