DownLoadOtherout.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 DownLoadOtherout : BaseDataDownLoad
  19. {
  20. protected override void _Init()
  21. {
  22. _loadSql = "select * from RdRecord09 where processflag=0 and direction=1";
  23. base._Init();
  24. }
  25. protected override BusinessObject _ImportData(DataRow row)
  26. {
  27. OtheroutApi api = new OtheroutApi();
  28. Dictionary<string, string> args = new Dictionary<string, string>();
  29. string id = row["ID"].ToString();
  30. args.Add("RdRecord09", "select * from wtu..RdRecord09 where ID=" + id);
  31. args.Add("RdRecords09", "select * from wtu..RdRecords09 where ID=" + id);
  32. DataSet ds = DbUtils.Fill(args, ConnectionUtils.Instance.GetConnection());
  33. Otherout v = __GetHead(ds);
  34. v.entry = __GetDetails(ds);
  35. OtheroutRoot vr = new OtheroutRoot();
  36. vr.otherout = v;
  37. BusinessObject result = api.Add(JsonUtils.GetJsonString(vr));
  38. return result;
  39. }
  40. protected override void _Audit(string id)
  41. {
  42. OtheroutApi api = new OtheroutApi();
  43. api.Audit(id);
  44. }
  45. private Otherout __GetHead(DataSet ds)
  46. {
  47. Otherout v = new Otherout();
  48. DataTable dt = ds.Tables["RdRecord09"];
  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. //define5 用友 U8 API中 其他出库单 的 单据头自定义项5
  56. v.define5 = dt.Rows[0]["ID"].ToString();//其他出库单 标识ID
  57. v.define1 = "来源旺店通";
  58. string cDefine15 = dt.Rows[0]["cDefine15"].ToString();
  59. if (cDefine15.Equals("2"))
  60. {
  61. v.receivecode = AppSeting.Instance.GetValue("receivecodeOut2");//收发类型默认F
  62. }
  63. else if (cDefine15.Equals("4"))
  64. {
  65. v.receivecode = AppSeting.Instance.GetValue("receivecodeOut4");//收发类型默认F
  66. }
  67. else if (cDefine15.Equals("7"))
  68. {
  69. v.receivecode = AppSeting.Instance.GetValue("receivecodeOut7");//收发类型默认F
  70. }
  71. return v;
  72. }
  73. private Entry[] __GetDetails(DataSet ds)
  74. {
  75. int cnt = ds.Tables["RdRecords09"].Rows.Count;
  76. DataTable dt = ds.Tables["RdRecords09"];
  77. Entry[] rtn = new Entry[cnt];
  78. for (int i = 0; i < cnt; i++)
  79. {
  80. Entry e = new Entry();
  81. e.inventorycode = dt.Rows[i]["cInvCode"].ToString().Replace(" ", "");
  82. e.quantity = dt.Rows[i]["iQuantity"].ToString();
  83. e.price = dt.Rows[i]["iUnitCost"].ToString();//
  84. e.cost = (Double.Parse(string.IsNullOrEmpty(e.quantity) ? "0" : e.quantity) * Double.Parse(string.IsNullOrEmpty(e.price)?"0":e.price)).ToString();
  85. //define27 用友U8 API中 其他出库单 的
  86. e.define27 = dt.Rows[i]["ID"].ToString();// 其他出库单 标识ID
  87. e.rowno = (i + 1).ToString();
  88. rtn[i] = e;
  89. }
  90. return rtn;
  91. }
  92. protected override void _LogError(int id, string msg)
  93. {
  94. OperationLog.Utils.WriteErrorLog("向U8导入其他出库资料", "sysid = " + id.ToString() + " " + msg);
  95. }
  96. protected override void _LogSucess(int id,string newCode)
  97. {
  98. string sql = "update RdRecord09 set processflag = 1,processdate = getdate(),newcode='" + newCode + "'" + " where sysid = " + id.ToString();
  99. //string sql = "update RdRecord09 set processflag = 1,processdate = getdate(),newcode=(select cCode from wtu..RdRecord09 where sysid = " + id.ToString() + ") where sysid = " + id.ToString();
  100. OperationLog.Utils.UpdateTempRecord(sql);
  101. }
  102. protected override string _GetReturnCode(BusinessObject result)
  103. {
  104. //string ID = DbUtils.ExecuteScalar(string.Format("select ID from RdRecord09 where cCode='{0}' ", result.Id), ConnectionUtils.Instance.GetConnection("003")).ToString();
  105. return result.Id;
  106. }
  107. }
  108. }