From d86dd7c9ff8dca3575c7a76a8fec8a55246337fc Mon Sep 17 00:00:00 2001 From: FoxV Date: Thu, 22 Sep 2022 17:44:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=92=E5=86=B2=E8=A7=A3=E5=86=B3=E7=89=A9?= =?UTF-8?q?=E6=96=99=E6=97=A0=E5=BA=93=E5=AD=98=E7=9A=84=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSWareHouseLotInfoService.cs | 130 +++++++++++------- 1 file changed, 80 insertions(+), 50 deletions(-) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs index 77a8eab..e593499 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs @@ -249,31 +249,46 @@ namespace ICSSoft.DataProject WHILE @needqty>0 BEGIN - select top 1 @qty = quantity,@lotno = lotno from #barcodetemp where invcode = (select invcode from #maintemp where transSequence = @transSequence AND DetailID = @DetailID) ORDER BY mtime - IF(@needqty-@qty>=0) - BEGIN - insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, - Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, - ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) - SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, - ISNULL(Amount, 0), InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@qty,ISNULL(AmountUnit, ''), - ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp - where #maintemp.transSequence = @transSequence AND DetailID = @DetailID - delete from #barcodetemp where lotno = @lotno - SET @needqty=@needqty-@qty - END - ELSE - BEGIN - insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, - Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, - ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) - SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, - ISNULL(Amount, 0),InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@needqty,ISNULL(AmountUnit, ''), - ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp - where #maintemp.transSequence = @transSequence AND DetailID = @DetailID - update #barcodetemp set quantity = @qty-@needqty where lotno = @lotno - SET @needqty=@needqty-@qty - END + select top 1 @qty = isnull(quantity,0),@lotno = isnull(lotno,'') from #barcodetemp a + RIGHT JOIN (select invcode from #maintemp where transSequence = @transSequence AND DetailID = @DetailID) b on a.invcode=b.invcode ORDER BY mtime + BEGIN + IF(@needqty-@qty>=0 and ISNULL(@lotno, '')<>'') + BEGIN + insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, + Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) + SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, + ISNULL(Amount, 0), InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@qty,ISNULL(AmountUnit, ''), + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp + where #maintemp.transSequence = @transSequence AND DetailID = @DetailID + delete from #barcodetemp where lotno = @lotno + SET @needqty=@needqty-@qty + END + ELSE IF(@needqty-@qty<0 and ISNULL(@lotno, '')<>'') + BEGIN + insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, + Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) + SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, + ISNULL(Amount, 0),InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@needqty,ISNULL(AmountUnit, ''), + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp + where #maintemp.transSequence = @transSequence AND DetailID = @DetailID + update #barcodetemp set quantity = @qty-@needqty where lotno = @lotno + SET @needqty=@needqty-@qty + END + ELSE + BEGIN + insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, + Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) + SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, + ISNULL(Amount, 0),InvCode,InvName,ISNULL(InvStd, ''),InvUnit,0,ISNULL(AmountUnit, ''), + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp + where #maintemp.transSequence = @transSequence AND DetailID = @DetailID + + SET @needqty=0 + END + END END FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; END @@ -385,31 +400,46 @@ namespace ICSSoft.DataProject WHILE @needqty>0 BEGIN - select top 1 @qty = quantity,@lotno = lotno from #barcodetemp where invcode = (select invcode from #maintemp where transSequence = @transSequence AND DetailID = @DetailID) ORDER BY mtime - IF(@needqty-@qty>=0) - BEGIN - insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, - Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, - ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) - SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, - ISNULL(Amount, 0), InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@qty,ISNULL(AmountUnit, ''), - ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp - where #maintemp.transSequence = @transSequence AND DetailID = @DetailID - delete from #barcodetemp where lotno = @lotno - SET @needqty=@needqty-@qty - END - ELSE - BEGIN - insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, - Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, - ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) - SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, - ISNULL(Amount, 0),InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@needqty,ISNULL(AmountUnit, ''), - ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp - where #maintemp.transSequence = @transSequence AND DetailID = @DetailID - update #barcodetemp set quantity = @qty-@needqty where lotno = @lotno - SET @needqty=@needqty-@qty - END + select top 1 @qty = isnull(quantity,0),@lotno = isnull(lotno,'') from #barcodetemp a + RIGHT JOIN (select invcode from #maintemp where transSequence = @transSequence AND DetailID = @DetailID) b on a.invcode=b.invcode ORDER BY mtime + BEGIN + IF(@needqty-@qty>=0 and ISNULL(@lotno, '')<>'') + BEGIN + insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, + Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) + SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, + ISNULL(Amount, 0), InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@qty,ISNULL(AmountUnit, ''), + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp + where #maintemp.transSequence = @transSequence AND DetailID = @DetailID + delete from #barcodetemp where lotno = @lotno + SET @needqty=@needqty-@qty + END + ELSE IF(@needqty-@qty<0 and ISNULL(@lotno, '')<>'') + BEGIN + insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, + Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) + SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, + ISNULL(Amount, 0),InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@needqty,ISNULL(AmountUnit, ''), + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp + where #maintemp.transSequence = @transSequence AND DetailID = @DetailID + update #barcodetemp set quantity = @qty-@needqty where lotno = @lotno + SET @needqty=@needqty-@qty + END + ELSE + BEGIN + insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, + Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) + SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, + ISNULL(Amount, 0),InvCode,InvName,ISNULL(InvStd, ''),InvUnit,0,ISNULL(AmountUnit, ''), + ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp + where #maintemp.transSequence = @transSequence AND DetailID = @DetailID + + SET @needqty=0 + END + END END FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; END