1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using cuidian.Common;
- using cuidian.Sql;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using WdtUtils;
- using WdtUtils.Load;
- using WdtUtils.Proxy;
- namespace WangToTempDb
- {
- /// <summary>
- /// 库存现存量上传中间库
- /// </summary>
- public class StockUpLoad : BaseUpLoad
- {
- private string __sql = "if not exists(select 1 from stock where cinvcode = '{0}' and cwhcode = '{1}') insert into stock(cinvcode, cwhcode, qty, price) values('{0}','{1}','{2}','{3}')";
- protected override Result _LoadFirstPage()
- {
- StockProxy tmp = new StockProxy();
- Result rtn = _load.Load<StockProxy>(_args, ref tmp);
- _proxy = tmp;
- return rtn;
- }
- protected override void _SetLoader()
- {
- _load = new StockLoad();
- }
- protected override void _ImportData()
- {
- _operType = "插入库存现存量中间表数据";
- Stock[] entitys = ((StockProxy)_proxy).stocks;
- StringBuilder sb = new StringBuilder();
- foreach (Stock item in entitys)
- {
- if (Convert.ToDecimal(item.stock_num) > 0)
- {
- sb.Append(string.Format(__sql, new object[] { item.spec_no, item.warehouse_no, item.stock_num, item.cost_price }));
- _InsertIntoTempDb(sb.ToString(), item.spec_no + "~~~" + item.warehouse_no);
- }
- }
- }
- protected override void _LoadNextPage()
- {
- _proxy = _load.Load<StockProxy>(_args);
- }
- protected override void _DeleteDup()
- {
- _operType = "删除库存现存量中间表重复数据";
-
- string sql = @"delete a from stock a,stock b where a.cinvcode = b.cinvcode and a.cwhcode = b.cwhcode and a.processflag=0 and b.processflag=1";
-
- DbUtils.ExecuteNonQuery(sql, _tempDb);
- }
- }
- }
|