|
|
@ -67,6 +67,7 @@ namespace ICSSoft.DataProject |
|
|
|
{0} |
|
|
|
convert(varchar(100),'') AS LocationCode, |
|
|
|
convert(varchar(100),'') AS LotNo, |
|
|
|
convert(varchar(10),'') AS ToWarehouseCode, |
|
|
|
0 AS LocationQty, |
|
|
|
0 AS isMatched, |
|
|
|
a.InvCode, |
|
|
@ -266,6 +267,10 @@ namespace ICSSoft.DataProject |
|
|
|
#region SLQ
|
|
|
|
sql = @"SELECT a.ID,
|
|
|
|
{0} |
|
|
|
convert(varchar(100),'') AS LocationCode, |
|
|
|
convert(varchar(100),'') AS LotNo, |
|
|
|
0 AS LocationQty, |
|
|
|
0 AS isMatched, |
|
|
|
a.InvCode, |
|
|
|
inv.InvName, |
|
|
|
inv.InvStd, |
|
|
@ -683,7 +688,7 @@ namespace ICSSoft.DataProject |
|
|
|
string sqlCheckSign = @"select F_EnabledMark from Sys_SRM_Items where F_EnCode = 'OutWithLocationCode'and F_EnabledMark = '1'"; |
|
|
|
DataTable flag = DBHelper.SQlReturnData(sqlCheckSign, cmd); |
|
|
|
if (flag != null && flag.Rows.Count > 0) |
|
|
|
// if (true)
|
|
|
|
//if (true)
|
|
|
|
{ |
|
|
|
sql = @"select * into #maintemp from (" + sql + @")a
|
|
|
|
select * into #resulttemp from #maintemp |
|
|
@ -723,24 +728,26 @@ namespace ICSSoft.DataProject |
|
|
|
|
|
|
|
BEGIN |
|
|
|
DECLARE @transSequence VARCHAR(50);--当前循环的行号 |
|
|
|
DECLARE @qty int;--条码表数量 |
|
|
|
DECLARE @needqty int;--本行所需数量 |
|
|
|
DECLARE @qty decimal(18, 4);--条码表数量 |
|
|
|
DECLARE @needqty decimal(18, 4);--本行所需数量 |
|
|
|
DECLARE @lotno VARCHAR(50);--本行所需数量 |
|
|
|
DECLARE @locationcode VARCHAR(50);--本行所在库位 |
|
|
|
DECLARE @WHCode VARCHAR(50);--本行所在仓库 |
|
|
|
DECLARE @invcode VARCHAR(50);--本行条码 |
|
|
|
DECLARE @issueQuantity decimal(18, 4); |
|
|
|
DECLARE tempCursor CURSOR FOR (select transSequence from #maintemp); --创建游标tempCursor,并定义游标所指向的集合 |
|
|
|
OPEN tempCursor; --打开游标 |
|
|
|
FETCH NEXT FROM tempCursor INTO @transSequence; --游标读取下一个数据 |
|
|
|
WHILE @@fetch_status=0 |
|
|
|
BEGIN |
|
|
|
select @needqty=Quantity from #maintemp where transSequence = @transSequence |
|
|
|
select @needqty=Quantity,@issueQuantity=issueQuantity from #maintemp where transSequence = @transSequence |
|
|
|
PRINT @transSequence |
|
|
|
WHILE @needqty>0 |
|
|
|
BEGIN |
|
|
|
|
|
|
|
select top 1 @qty = a.quantity, @locationcode = a.locationcode,@lotno = a.lotno,@WHCode = a.warehousecode from #barcodetemp a |
|
|
|
inner JOIN(select invcode,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WHCODE from #maintemp where transSequence=@transSequence)b on a.invcode = b.invcode |
|
|
|
where ((isnull(b.ProjectCode,'')<>'' and b.ProjectCode = a.ProjectCode) or isnull(b.ProjectCode,'') ='') and |
|
|
|
select top 1 @qty = isnull(a.quantity,0), @locationcode = isnull(a.locationcode,''),@lotno = isnull(a.lotno,''),@WHCode = isnull(a.warehousecode,''),@invcode = b.invcode from #barcodetemp a |
|
|
|
right JOIN(select invcode,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WHCODE from #maintemp where transSequence=@transSequence)b on a.invcode = b.invcode |
|
|
|
and ((isnull(b.ProjectCode,'')<>'' and b.ProjectCode = a.ProjectCode) or isnull(b.ProjectCode,'') ='') and |
|
|
|
((isnull(b.Version,'')<>'' and b.Version = a.Version) or isnull(b.Version,'') ='') and |
|
|
|
((isnull(b.Brand,'')<>'' and b.Brand = a.Brand )or isnull(b.Brand,'') ='') and |
|
|
|
((isnull(b.cFree1,'')<>'' and b.cFree1 =a.cFree1) or isnull(b.cFree1,'') ='') and |
|
|
@ -754,30 +761,41 @@ namespace ICSSoft.DataProject |
|
|
|
((isnull(b.cFree9,'')<>'' and b.cFree9 =a.cFree9) or isnull(b.cFree9,'') ='') and |
|
|
|
((isnull(b.cFree10,'')<>'' and b.cFree10 =a.cFree10) or isnull(b.cFree10,'') ='') and |
|
|
|
((isnull(b.BatchCode,'')<>'' and b.BatchCode =a.BatchCode) or isnull(b.BatchCode,'') ='')ORDER BY mtime,locationcode |
|
|
|
IF(@needqty-@qty>=0) |
|
|
|
IF(@needqty-@issueQuantity-@qty>=0 and ISNULL(@lotno, '')<>'') |
|
|
|
BEGIN |
|
|
|
|
|
|
|
insert INTO #resulttemp (id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,LocationCode,LocationQty,isMatched,AmountUnit,lotNo, |
|
|
|
Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,ToWarehouseCode,LocationCode,LocationQty,isMatched,AmountUnit,lotNo, |
|
|
|
WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10) |
|
|
|
SELECT id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, |
|
|
|
ISNULL(Amount, 0),[User],[MTime],InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@WHCode,isnull(@LocationCode,''),@qty,1,ISNULL(AmountUnit, ''),ISNULL(@lotno, ''), |
|
|
|
ISNULL(Amount, 0),[User],[MTime],InvCode,InvName,ISNULL(InvStd, ''),InvUnit,isnull(@WHCode,''),isnull(ToWarehouseCode,''),isnull(@LocationCode,''),@qty,1,ISNULL(AmountUnit, ''),ISNULL(@lotno, ''), |
|
|
|
WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 from #maintemp where #maintemp.transSequence = @transSequence |
|
|
|
delete from #barcodetemp where lotno = @lotno |
|
|
|
SET @needqty=@needqty-@qty |
|
|
|
END |
|
|
|
ELSE if(@needqty-@issueQuantity-@qty<0 and ISNULL(@lotno, '')<>''and @needqty-@issueQuantity>0) |
|
|
|
BEGIN |
|
|
|
|
|
|
|
insert INTO #resulttemp (id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,ToWarehouseCode,LocationCode,LocationQty,isMatched,AmountUnit,lotno, |
|
|
|
WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10) |
|
|
|
SELECT id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, |
|
|
|
ISNULL(Amount, 0),[User],[MTime],InvCode,InvName,ISNULL(InvStd, ''),InvUnit,isnull(@WHCode,''),isnull(ToWarehouseCode,''),isnull(@LocationCode,''),case WHEN ISNULL(@qty, 0)=0 THEN 0 else @needqty-@issueQuantity end ,1,ISNULL(AmountUnit, ''),ISNULL(@lotno, ''), |
|
|
|
WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 from #maintemp where #maintemp.transSequence = @transSequence |
|
|
|
update #barcodetemp set quantity = @qty-@needqty+-@issueQuantity where lotno = @lotno |
|
|
|
SET @needqty=@needqty-@issueQuantity-@qty |
|
|
|
|
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
|
|
|
|
insert INTO #resulttemp (id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,LocationCode,LocationQty,isMatched,AmountUnit,lotno, |
|
|
|
Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,ToWarehouseCode,LocationCode,LocationQty,isMatched,AmountUnit,lotno, |
|
|
|
WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10) |
|
|
|
SELECT id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, |
|
|
|
ISNULL(Amount, 0),[User],[MTime],InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@WHCode,isnull(@LocationCode,''),case WHEN ISNULL(@qty, 0)=0 THEN 0 else @needqty end ,1,ISNULL(AmountUnit, ''),ISNULL(@lotno, ''), |
|
|
|
ISNULL(Amount, 0),[User],[MTime],InvCode,InvName,ISNULL(InvStd, ''),InvUnit,isnull(@WHCode,''),isnull(ToWarehouseCode,''),isnull(@LocationCode,''),0 ,1,ISNULL(AmountUnit, ''),ISNULL(@lotno, ''), |
|
|
|
WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 from #maintemp where #maintemp.transSequence = @transSequence |
|
|
|
|
|
|
|
update #barcodetemp set quantity = @qty-@needqty where lotno = @lotno |
|
|
|
SET @needqty=@needqty-@qty |
|
|
|
SET @needqty=0 |
|
|
|
|
|
|
|
END |
|
|
|
END |
|
|
@ -789,9 +807,9 @@ namespace ICSSoft.DataProject |
|
|
|
|
|
|
|
|
|
|
|
select id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, |
|
|
|
[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,LocationCode,sum(LocationQty)as LocationQty,isMatched,AmountUnit,lotno, |
|
|
|
[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,ToWarehouseCode,LocationCode,sum(LocationQty)as LocationQty,isMatched,AmountUnit,--lotno, |
|
|
|
WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 from #resulttemp GROUP BY id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, |
|
|
|
[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,LocationCode,isMatched,AmountUnit,lotno, |
|
|
|
[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,ToWarehouseCode,LocationCode,isMatched,AmountUnit,--lotno, |
|
|
|
WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 ORDER BY locationcode ASC ,InvCode ASC |
|
|
|
|
|
|
|
|
|
|
|