12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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 DispatchListUpLoad : BaseUpLoad
- {
- //private string __sql = @"if not exists (select * from DispatchList a inner join DispatchLists b on a.DLID=b.DLID where a.DLID= '{0}')
- //insert into DispatchList(DLID,cDLCode,cCusCode,cCusName,cPersonCode,dDate,cexch_name,iTaxRate,direction,cVouchType,cSTCode,cDepCode,iExchRate,bFirst,bReturnFlag,bSettleAll,iVTid) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}')
- //insert into DispatchLists(DLID,iDLsID,cWhCode,cInvCode,iQuantity,iTaxRate,iTaxUnitPrice,cMemo,bSettleAll,bQANeedCheck,bQAUrgency,bQAChecking,bQAChecked,bcosting) values('{0}','{0}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}')";
- private string __sql = @"if not exists (select DLID from DispatchList where DLID= {0}) insert into DispatchList(DLID,cDLCode,cCusCode,cCusName,cPersonCode,direction,cDefine1,cDefine3,cDefine2,cDefine11,bReturnFlag,cDepCode,ddate,cVouchType) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','MX')";//cDefine12,'{21}'
- //避免只能插入一条子表数据
- private string sql = @" if not exists (select DLID from DispatchLists where DLID= {0}) ";
- private string newSql = @"insert into DispatchLists(DLID,iDLsID,cWhCode,cInvCode,iQuantity,iTaxRate,iTaxUnitPrice,cMemo,cCusInvCode,iQuotedPrice,cDefine28,cDefine29) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')";
- protected override Result _LoadFirstPage()
- {
- DispatchListProxy tmp = new DispatchListProxy();
- Result rtn = _load.Load<DispatchListProxy>(_args, ref tmp);
- _proxy = tmp;
- return rtn;
- }
- protected override void _SetLoader()
- {
- _load = new DispatchListLoad();
- }
- protected override void _ImportData()
- {
- //_operType = "插入采购退货单中间表数据";
- _operType = "销售出库插入发货单中间表";
- Stockin_List[] entitys = ((DispatchListProxy)_proxy).stockin_list;
- if (entitys == null || entitys.Length == 0) return;
- StringBuilder sb = new StringBuilder();
- foreach (Stockin_List item in entitys)
- {
- //单据类型编码默认05,销售类型编码默认MX,部门编码默认101
- sb.AppendLine(string.Format(__sql, new object[] { item.stockin_id, _ConvertStr(item.order_no), _ConvertStr(item.customer_no), _ConvertStr(item.customer_name), _ConvertStr("5"), 1, _ConvertStr(item.order_type), _ConvertStr(item.platform_id), _ConvertStr(item.shop_no), _ConvertStr(item.shop_name),1,"0",item.created_time }));//, "温春"
- sb.AppendLine(string.Format(sql, new object[] { item.stockin_id }));
- Details_List[] dl = item.details_list;
- sb.AppendLine("begin");
- foreach (Details_List ty in dl)
- {
- //item.warehouse_no = (item.warehouse_no.Length > 10) ? item.warehouse_no.Substring(0, 10) : item.warehouse_no;
- sb.AppendLine(string.Format(newSql, new object[] { item.stockin_id, ty.rec_id, _ConvertStr(item.warehouse_no), _ConvertStr(ty.spec_no), _ConvertStr(ty.goods_count), _ConvertStr(ty.tax), (_ConvertNotStr(ty.src_price) + (Convert.ToDouble(_ConvertNotStr(ty.src_price)) * Convert.ToDouble(_ConvertNotStr(ty.tax)))), _ConvertStr(ty.remark), _ConvertStr(item.warehouse_no),_ConvertNotStr(ty.src_price), _ConvertStr(item.src_order_no),_ConvertNotStr(ty.src_price) }));
- }
- sb.AppendLine("end");
- _InsertIntoTempDb(sb.ToString(), item.order_no);
- }
-
-
- }
- protected override void _DeleteDup()
- {
- //_operType = "删除销售出库中间表重复数据";
- ////string sql = "delete a from {0}..DispatchList a,DispatchLists b,{1}..DispatchList c,DispatchLists d where a.DLID = b.DLID and b.DLID=c.DLID and c.DLID=d.DLID";
- //string sql1 = "delete a from {0}..DispatchList a, {1}..DispatchList b where a.DLID = b.cdefine5 ";
- //string sql2 = "delete a from {0}..DispatchLists a, {1}..DispatchLists b where a.DLID = 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<DispatchListProxy>(_args);
- }
- }
- }
|