Browse Source

倒冲解决物料无库存的冲突问题

master
FoxV 2 years ago
parent
commit
d86dd7c9ff
  1. 130
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

130
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

@ -249,31 +249,46 @@ namespace ICSSoft.DataProject
WHILE @needqty>0 WHILE @needqty>0
BEGIN 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 END
FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID;
END END
@ -385,31 +400,46 @@ namespace ICSSoft.DataProject
WHILE @needqty>0 WHILE @needqty>0
BEGIN 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 END
FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID;
END END

Loading…
Cancel
Save