123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 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 StockoutUpLoad : BaseUpLoad
- {
- //private string __sql = @"if not exists (select * from RdRecord09 as a inner join RdRecords09 as b on a.ID=b.ID where a.ID= '{0}')
- //insert into RdRecord09(ID,cCode,cSource,cWhCode,dDate,cBusType,cMemo,cMaker,bRdFlag,cVouchType,bTransFlag,bIsSTQc) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')
- //insert into RdRecords09(AutoID,ID,cInvCode,iFlag,iQuantity,iUnitCost) values('{12}','{0}','{13}','{14}','{15}','{16}')";
- private string __sql = @"if not exists (select ID from RdRecord09 where ID= {0}) insert into RdRecord09(ID,cCode,cSource,cWhCode,dDate,cBusType,cMemo,cMaker,bRdFlag,cVouchType,bTransFlag,bIsSTQc,direction,cDefine15) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',1,'{12}') ";
- //避免只能插入一条子表数据
- private string sql = @"if not exists (select * from RdRecords09 where ID= {0}) ";
- private string newSql = @"insert into RdRecords09(ID,AutoID,cInvCode,iFlag,iQuantity,iUnitCost) values('{0}','{1}','{2}','{3}','{4}','{5}')";
- protected override Result _LoadFirstPage()
- {
- StockoutProxy tmp = new StockoutProxy();
- Result rtn = _load.Load<StockoutProxy>(_args, ref tmp);
- _proxy = tmp;
- return rtn;
- }
- protected override void _SetLoader()
- {
- _load = new StockoutLoad();
- }
- protected override void _ImportData()
- {
- _operType = "插入其他出库单中间表数据";
- Stockout_List[] entitys = ((StockoutProxy)_proxy).stockout_list;
- if (entitys == null || entitys.Length == 0) return;
- StringBuilder sb = new StringBuilder();
- foreach (Stockout_List item in entitys)
- {
- if (item.remark.Contains("来源U8") || (!item.order_type.Equals("2") && !item.order_type.Equals("4") && !item.order_type.Equals("7")) || item.remark.Contains("库存管理"))//|| item.remark.Contains("库存管理")
- {
- continue;
- }
- //sb.AppendLine(string.Format(__sql, new object[] { item.stockout_id, item.order_no, item.src_order_no, item.warehouse_no,item.consign_time,item.order_type_name,item.remark,item.operator_name,0,"09",0,0,1, item.details_list[0].rec_id, item.details_list[0].goods_no, 0, item.details_list[0].goods_count, item.details_list[0].sell_price }));
- //item.warehouse_no = (item.warehouse_no.Length > 10) ? item.warehouse_no.Substring(0, 10) : item.warehouse_no;
- sb.AppendLine(string.Format(__sql, new object[] { item.stockout_id, _ConvertStr(item.order_no), _ConvertStr(item.src_order_no), _ConvertStr(item.warehouse_no), item.consign_time, _ConvertStr(item.order_type_name), _ConvertStr(item.remark), _ConvertStr(item.operator_name),_ConvertNotStr( item.status), _ConvertStr("09"), 0, 0,_ConvertNotStr(item.order_type) }));//cVouchType单据类型编码,bTransFlag是否传递 ,bIsSTQc库存期初标志
- sb.AppendLine(string.Format(sql, new object[] { item.stockout_id }));
- Details_List[] dl = item.details_list;
- sb.AppendLine("begin");
- foreach (Details_List ty in dl)
- {
- sb.AppendLine(string.Format(newSql, new object[] { item.stockout_id, ty.rec_id, _ConvertStr(ty.spec_no), 0,_ConvertNotStr( ty.goods_count),_ConvertNotStr(ty.cost_price) }));
- }
- sb.AppendLine("end");
- _InsertIntoTempDb(sb.ToString(), item.order_no);
- }
- }
- protected override void _DeleteDup()
- {
- //_operType = "删除其他出库单中间表重复数据";
- ////string sql = "delete a from {0}..RdRecord09 a,RdRecords09 b,{1}..RdRecord09 c,RdRecords09 d where a.ID = b.ID and b.ID=c.ID and c.ID=d.ID";
- //string sql1 = "delete a from {0}..RdRecord09 a, {1}..RdRecord09 b where a.ID = b.cdefine5 ";
- //string sql2 = "delete a from {0}..RdRecords09 a, {1}..RdRecords09 b where a.ID = b.cdefine27 ";
- //DbUtils.ExecuteNonQuery(string.Format(sql1, _tempDb.Database, _targetDb.Database), _tempDb);
- //DbUtils.ExecuteNonQuery(string.Format(sql2, _tempDb.Database, _targetDb.Database), _tempDb);
- }
- protected override void _LoadNextPage()
- {
- _proxy = _load.Load<StockoutProxy>(_args);
- }
- }
- }
|