DownLoadInventory.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 DownLoadInventory : BaseDataDownLoad
  19. {
  20. protected override void _Init()
  21. {
  22. _loadSql = "select * from Inventory where processflag=0";
  23. base._Init();
  24. }
  25. protected override BusinessObject _ImportData(DataRow row)
  26. {
  27. InventoryApi api = new InventoryApi();
  28. Inventory v = new Inventory();
  29. v.code = row["cInvCode"].ToString();
  30. v.name = row["cInvName"].ToString();
  31. v.specs = row["cInvStd"].ToString();
  32. v.bsuitretail = "0";
  33. v.purchase_flag = "1";
  34. v.sale_flag = "1";
  35. v.bexpsale = "0";
  36. v.selfmake_flag = "1";
  37. v.bbommain = "1";
  38. v.bbomsub = "1";
  39. v.bProxyForeign = "1";
  40. v.prod_consu_flag = "1";
  41. v.iimptaxrate = "13";//进项税率
  42. v.tax_rate = "13";//销项税率
  43. v.pricetype = "移动平均";
  44. //v.tax_rate = row["iTaxRate"].ToString();
  45. //存货分类编码默认01
  46. v.sort_code = AppSeting.Instance.GetValue("sort_code");
  47. //计量单位组默认00
  48. v.unitgroup_code = AppSeting.Instance.GetValue("unitgroup_code");
  49. v.unitgroup_type = "0";
  50. //计量单位编码默认J
  51. v.main_measure = AppSeting.Instance.GetValue("measureUnit");
  52. v.self_define7= row["cInvDefine7"].ToString();
  53. v.self_define5 = row["cInvDefine5"].ToString();
  54. v.self_define6 = row["cInvDefine6"].ToString();
  55. v.self_define8 = row["cInvDefine8"].ToString().Length<=60?row["cInvDefine8"].ToString(): row["cInvDefine8"].ToString().Substring(0,60);
  56. v.ref_sale_price = row["cInvDefine13"].ToString();
  57. v.self_define10= row["cInvDefine10"].ToString();
  58. v.barcode= row["cInvDefine9"].ToString().Replace("'", "''");
  59. v.fRetailPrice = row["fRetailPrice"].ToString();
  60. v.self_define1= row["cInvDefine1"].ToString();
  61. v.self_define2 = row["cInvDefine2"].ToString();
  62. v.self_define3 = row["cInvDefine3"].ToString();
  63. v.self_define4 = row["cInvDefine14"].ToString();
  64. v.self_define9 = v.ref_sale_price;
  65. v.pricetype = "移动平均法";
  66. Entry e = new Entry();
  67. e.invcode = row["cInvCode"].ToString();
  68. Entry[] ey = new Entry[1];
  69. ey[0] = e;
  70. InventoryRoot vr = new InventoryRoot();
  71. vr.inventory = v;
  72. vr.inventory.entry = ey;
  73. BusinessObject result = api.Add(JsonUtils.GetJsonString(vr));
  74. return result;
  75. }
  76. protected override void _LogError(int id, string msg)
  77. {
  78. OperationLog.Utils.WriteErrorLog("向U8导入存货资料", "sysid = " + id.ToString() + " " + msg);
  79. }
  80. protected override void _LogSucess(int id, string newCode)
  81. {
  82. string sql = "update Inventory set processflag = 1,processdate = getdate() where sysid = " + id.ToString();
  83. OperationLog.Utils.UpdateTempRecord(sql);
  84. }
  85. }
  86. }