123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using WdtUtils;
- using WdtUtils.Proxy;
- using WdtUtils.Load;
- using cuidian.Sql;
- using Logs;
- namespace WangToTempDb
- {
- /// <summary>
- /// 将旺店通存货信息导入中间库
- /// </summary>
- public class InventoryUpLoad : BaseUpLoad
- { //d.spec_no,item.brand_name,d.lowest_price,item.spec_count,item.barcode,d.retail_price,d.length,d.width,d.height,d.weight //
- private string __sql = "if not exists (select 1 from inventory where cinvcode = '{0}') insert into inventory(cinvcode,cinvname,cinvstd,itaxrate,bPurchase,cInvDefine4,cInvDefine7,cInvDefine13,cInvDefine10,cInvDefine9,fRetailPrice,cInvDefine1,cInvDefine2,cInvDefine3,cInvDefine14,cInvDefine5,cInvDefine6,cInvDefine8) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}')";
- protected override Result _LoadFirstPage()
- {
- InventoryProxy tmp = new InventoryProxy();
- Result rtn = _load.Load<InventoryProxy>(_args, ref tmp);
- _proxy = tmp;
- return rtn;
- }
- protected override void _SetLoader()
- {
- _load = new InventoryLoad();
- }
- protected override void _ImportData()
- {
- _operType = "插入存货中间表数据";
- Goods_List[] entitys = ((InventoryProxy)_proxy).goods_list;
- if (entitys == null || entitys.Length == 0) return ;
- //LogHelper.Debug("inventory entitys length = " + entitys.Length.ToString());
- StringBuilder sb = new StringBuilder();
- int i = 0;
- foreach (Goods_List item in entitys)
- {
- foreach (Spec_List d in item.spec_list)
- {
- try
- {
- item.prop4 = Convert.ToDecimal(item.prop4).ToString();
- }
- catch
- {
- item.prop4 = "0";
- }
-
- i++;
- sb.AppendLine(string.Format(__sql, new object[] { _ConvertStr(d.spec_no), _ConvertStr(item.goods_name), _ConvertStr(d.spec_name), _ConvertNotStr(d.tax_rate), 1, _ConvertStr(d.spec_no), _ConvertStr(item.brand_name), item.prop4, _ConvertNotStr(item.prop5), _ConvertNotStr(d.barcode).Replace("'", "''"), _ConvertNotStr(d.retail_price) , _ConvertStr(d.length), _ConvertStr(d.width), _ConvertStr(d.height), _ConvertNotStr(d.weight) , _ConvertStr(item.prop1), _ConvertStr(item.prop2), _ConvertStr(item.prop3).Length<60? _ConvertStr(item.prop3):_ConvertStr(item.prop3).Substring(0,60) }));
- _InsertIntoTempDb(sb.ToString(), item.spec_no);
- }
-
- }
- //LogHelper.Debug("inventory Goods_List length = " + i.ToString());
-
- }
- protected override void _DeleteDup()
- {
- _operType = "删除存货中间表重复数据";
- //string sql = "delete a from {0}..inventory a,{1}..inventory b where a.cinvcode = b.cinvcode and processflag = '0'";
- string sql = @"delete a from {0}..inventory a,{1}..inventory b where a.cinvcode = b.cinvcode and processflag = '0'";
- //where not exists(select cInvCode from {1}..inventory where cinvcode = a.cinvcode)";
- DbUtils.ExecuteNonQuery(string.Format(sql, _tempDb.Database, _targetDb.Database), _tempDb);
- }
- protected override void _LoadNextPage()
- {
- _proxy = _load.Load<InventoryProxy>(_args);
- }
- }
- }
|