From de3c017b024912bae55bb3f08874bfa9b306032d Mon Sep 17 00:00:00 2001 From: lilili Date: Mon, 20 Mar 2023 15:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=88=90=E5=93=81=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=8E=A5=E5=8F=A3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSSoft.DataProject/ICSSubmitService.cs | 6 +- .../ICSWareHouseLotInfoService.cs | 299 +++++++++--------- 2 files changed, 152 insertions(+), 153 deletions(-) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs index 8772b73..ceaa4ce 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs @@ -2499,7 +2499,7 @@ namespace ICSSoft.DataProject if (TransType == TransTypeEnum.PurchaseReceiveDoc.GetDescription()) { //更新源头单据数量 - ICSPurchaseService.PurchaseReceiveDoc(itemInfo.LotNo, itemInfo.Quantity, item.WorkPoint, cmd, language); + //ICSPurchaseService.PurchaseReceiveDoc(itemInfo.LotNo, itemInfo.Quantity, item.WorkPoint, cmd, language); BusinessCode = TransTypeEnum.PurchaseReceiveDoc.GetDescription(); } #endregion @@ -2575,7 +2575,7 @@ namespace ICSSoft.DataProject else if (TransType == TransTypeEnum.ManufactureReceiveDoc.GetDescription()) { //更新源头单据数量 - ICSManufactureService.ManufactureReceiveDoc(itemInfo.LotNo, itemInfo.Quantity, item.WorkPoint, cmd, language); + //ICSManufactureService.ManufactureReceiveDoc(itemInfo.LotNo, itemInfo.Quantity, item.WorkPoint, cmd, language); BusinessCode = TransTypeEnum.ManufactureReceiveDoc.GetDescription(); } #endregion @@ -2583,7 +2583,7 @@ namespace ICSSoft.DataProject else if (TransType == TransTypeEnum.ManufactureReceive.GetDescription()) { //更新源头单据数量 - ICSManufactureService.ManufactureReceive(itemInfo.LotNo, itemInfo.Quantity, item.WorkPoint, cmd, language); + //ICSManufactureService.ManufactureReceive(itemInfo.LotNo, itemInfo.Quantity, item.WorkPoint, cmd, language); BusinessCode = TransTypeEnum.ManufactureReceive.GetDescription(); } #endregion diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs index 99f6ec9..36149de 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs @@ -252,160 +252,159 @@ namespace ICSSoft.DataProject } #endregion - #region 成品(生产)入库,倒冲 - if (BusinessCode.Equals(TransTypeEnum.ManufactureReceiveDoc.GetDescription())) - { - #region sql - sql = @"-- 1.创建临时表 初始单据数据 maintemp - SELECT - c.MOCode AS TransCode, - a.MODetailID AS DetailID, - a.InvCode, - b.InvName, - b.InvStd, - a.ParentQuantity/c.Quantity*{2} AS Quantity, - a.Amount, - a.Sequence AS TransSequence, - a.IssueQuantity, - c.Sequence, - inv.InvUnit, - 0 AS LocationQty, - inv.AmountUnit, - a.ExtensionID, - a.WorkPoint, - ext.ProjectCode, - CASE WHEN ISNULL(inv.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode, - ext.Version, - ext.Brand, - ext.cFree1, - ext.cFree2, - ext.cFree3, - ext.cFree4, - ext.cFree5, - ext.cFree6, - ext.cFree7, - ext.cFree8, - ext.cFree9, - ext.cFree10 - INTO #maintemp + //if (BusinessCode.Equals(TransTypeEnum.ManufactureReceiveDoc.GetDescription())) + //{ + // #region sql + // sql = @"-- 1.创建临时表 初始单据数据 maintemp + // SELECT + // c.MOCode AS TransCode, + // a.MODetailID AS DetailID, + // a.InvCode, + // b.InvName, + // b.InvStd, + // a.ParentQuantity/c.Quantity*{2} AS Quantity, + // a.Amount, + // a.Sequence AS TransSequence, + // a.IssueQuantity, + // c.Sequence, + // inv.InvUnit, + // 0 AS LocationQty, + // inv.AmountUnit, + // a.ExtensionID, + // a.WorkPoint, + // ext.ProjectCode, + // CASE WHEN ISNULL(inv.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode, + // ext.Version, + // ext.Brand, + // ext.cFree1, + // ext.cFree2, + // ext.cFree3, + // ext.cFree4, + // ext.cFree5, + // ext.cFree6, + // ext.cFree7, + // ext.cFree8, + // ext.cFree9, + // ext.cFree10 + // INTO #maintemp - FROM - ICSMOPick a - inner join ICSMO c on a.MODetailID=c.MODetailID and a.WorkPoint=c.WorkPoint - LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint - INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint - INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint - INNER JOIN ( - SELECT a.MOCode,a.Sequence,a.WorkPoint - FROM ICSMO a - INNER JOIN ICSInventoryLotDetail b ON b.TransCode=a.MOCode AND b.TransSequence=a.Sequence AND b.WorkPoint=a.WorkPoint - INNER JOIN ICSInventoryLot c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint - WHERE c.LotNo='{0}' AND c.WorkPoint='{1}' - ) temp ON c.MOCode=temp.MOCode AND a.WorkPoint=temp.WorkPoint AND c.Sequence=temp.Sequence - WHERE a.SupplyType='1' - GROUP BY c.MOCode,a.Quantity,c.Quantity,a.InvCode,b.InvName,b.InvStd,a.WhCode,a.ExtensionID,a.WorkPoint,inv.BatchEnable,a.MODetailID,a.Amount,a.Sequence,a.IssueQuantity,inv.InvName,inv.InvCode,inv.InvUnit,inv.AmountUnit,c.Sequence, - ext.ProjectCode,ext.BatchCode,ext.Version,ext.Brand,ext.cFree1,ext.cFree2,ext.cFree3,ext.cFree4,ext.cFree5,ext.cFree6,ext.cFree7,ext.cFree8,ext.cFree9,ext.cFree10; + // FROM + // ICSMOPick a + // inner join ICSMO c on a.MODetailID=c.MODetailID and a.WorkPoint=c.WorkPoint + // LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint + // INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint + // INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint + // INNER JOIN ( + // SELECT a.MOCode,a.Sequence,a.WorkPoint + // FROM ICSMO a + // INNER JOIN ICSInventoryLotDetail b ON b.TransCode=a.MOCode AND b.TransSequence=a.Sequence AND b.WorkPoint=a.WorkPoint + // INNER JOIN ICSInventoryLot c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint + // WHERE c.LotNo='{0}' AND c.WorkPoint='{1}' + // ) temp ON c.MOCode=temp.MOCode AND a.WorkPoint=temp.WorkPoint AND c.Sequence=temp.Sequence + // WHERE a.SupplyType='1' + // GROUP BY c.MOCode,a.Quantity,c.Quantity,a.InvCode,b.InvName,b.InvStd,a.WhCode,a.ExtensionID,a.WorkPoint,inv.BatchEnable,a.MODetailID,a.Amount,a.Sequence,a.IssueQuantity,inv.InvName,inv.InvCode,inv.InvUnit,inv.AmountUnit,c.Sequence, + // ext.ProjectCode,ext.BatchCode,ext.Version,ext.Brand,ext.cFree1,ext.cFree2,ext.cFree3,ext.cFree4,ext.cFree5,ext.cFree6,ext.cFree7,ext.cFree8,ext.cFree9,ext.cFree10; - select * into #resulttemp from #maintemp - ALTER TABLE #resulttemp ADD LotNo VARCHAR(50) - delete from #resulttemp - - -- 2.根据maintemp 中的物料信息 查出库存中对应的条码信息 barcodetemp - select a.lotno,a.invcode,(a.quantity-a.lockQuantity) as quantity ,a.mtime into #barcodetemp from ICSWareHouseLotInfo a LEFT JOIN - (select #maintemp.invcode from #maintemp group by #maintemp.InvCode) b on a.invcode = b.invcode where a.Quantity-a.lockQuantity>0 ORDER BY a.MTIME ASC - - -- 3.循环maintemp,根据 行号和子表ID 向最终结果集中写入数据 ;barcodetemp 中的已匹配数据删除或更新 - BEGIN - DECLARE @transSequence int;--当前循环的行号 - DECLARE @qty int;--条码表数量 - DECLARE @needqty int;--本行所需数量 - DECLARE @lotno VARCHAR(50);--条码 - DECLARE @DetailID VARCHAR(50);--本行所在工单行ID - DECLARE tempCursor CURSOR FOR (select transSequence,DetailID from #maintemp); --创建游标tempCursor,并定义游标所指向的集合 - OPEN tempCursor; --打开游标 - FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; --游标读取下一个数据 - WHILE @@fetch_status=0 - BEGIN - select @needqty=Quantity from #maintemp where transSequence = @transSequence AND DetailID = @DetailID - PRINT @transSequence - WHILE @needqty>0 - BEGIN - - 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 + // select * into #resulttemp from #maintemp + // ALTER TABLE #resulttemp ADD LotNo VARCHAR(50) + // delete from #resulttemp + + // -- 2.根据maintemp 中的物料信息 查出库存中对应的条码信息 barcodetemp + // select a.lotno,a.invcode,(a.quantity-a.lockQuantity) as quantity ,a.mtime into #barcodetemp from ICSWareHouseLotInfo a LEFT JOIN + // (select #maintemp.invcode from #maintemp group by #maintemp.InvCode) b on a.invcode = b.invcode where a.Quantity-a.lockQuantity>0 ORDER BY a.MTIME ASC + + // -- 3.循环maintemp,根据 行号和子表ID 向最终结果集中写入数据 ;barcodetemp 中的已匹配数据删除或更新 + // BEGIN + // DECLARE @transSequence int;--当前循环的行号 + // DECLARE @qty int;--条码表数量 + // DECLARE @needqty int;--本行所需数量 + // DECLARE @lotno VARCHAR(50);--条码 + // DECLARE @DetailID VARCHAR(50);--本行所在工单行ID + // DECLARE tempCursor CURSOR FOR (select transSequence,DetailID from #maintemp); --创建游标tempCursor,并定义游标所指向的集合 + // OPEN tempCursor; --打开游标 + // FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; --游标读取下一个数据 + // WHILE @@fetch_status=0 + // BEGIN + // select @needqty=Quantity from #maintemp where transSequence = @transSequence AND DetailID = @DetailID + // PRINT @transSequence + // WHILE @needqty>0 + // BEGIN + + // 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 - CLOSE tempCursor - DEALLOCATE tempCursor - END - - select TransCode,LotNo,LocationQty AS Quantity,InvCode,DetailID,Sequence,TransSequence from #resulttemp - --select * from #resulttemp - - DROP table #maintemp - DROP table #resulttemp - DROP table #barcodetemp"; - #endregion - sql = String.Format(sql, LotNo, WorkPoint, Quantity); - DataTable table = DBHelper.SQlReturnData(sql, cmd); - string json = JsonConvert.SerializeObject(table); - List downItemModels = JsonConvert.DeserializeObject>(json); - foreach (DownItemModel model in downItemModels) - { - if (model != null && model.LotNo == null || "" == model.LotNo) - { - throw new Exception(language.GetNameByCode("WMSAPIInfo201")); - } - WareHouseLotInfoDown(Identification, model.TransCode, model.Sequence + "~" + model.TransSequence, model.LotNo, model.Quantity, User, WorkPoint, "12", BusinessCode, cmd, language); - //回写已领数量 - sql = @"UPDATE ICSMOPick SET IssueQuantity=(ISNULL(IssueQuantity,0)+" + model.Quantity + ") WHERE MODetailID='{0}' AND Sequence='{1}' AND WorkPoint='{2}'"; - sql = String.Format(sql, model.DetailID, model.TransSequence, WorkPoint); - if (!DBHelper.ExecuteNonQuery(sql, cmd)) - { - throw new Exception(language.GetNameByCode("WMSAPIInfo199")); - } - } - } + // SET @needqty=0 + // END + //END + // END + // FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; + // END + // CLOSE tempCursor + // DEALLOCATE tempCursor + // END + + // select TransCode,LotNo,LocationQty AS Quantity,InvCode,DetailID,Sequence,TransSequence from #resulttemp + // --select * from #resulttemp + + // DROP table #maintemp + // DROP table #resulttemp + // DROP table #barcodetemp"; + // #endregion + // sql = String.Format(sql, LotNo, WorkPoint, Quantity); + // DataTable table = DBHelper.SQlReturnData(sql, cmd); + // string json = JsonConvert.SerializeObject(table); + // List downItemModels = JsonConvert.DeserializeObject>(json); + // foreach (DownItemModel model in downItemModels) + // { + // if (model != null && model.LotNo == null || "" == model.LotNo) + // { + // throw new Exception(language.GetNameByCode("WMSAPIInfo201")); + // } + // WareHouseLotInfoDown(Identification, model.TransCode, model.Sequence + "~" + model.TransSequence, model.LotNo, model.Quantity, User, WorkPoint, "12", BusinessCode, cmd, language); + // //回写已领数量 + // sql = @"UPDATE ICSMOPick SET IssueQuantity=(ISNULL(IssueQuantity,0)+" + model.Quantity + ") WHERE MODetailID='{0}' AND Sequence='{1}' AND WorkPoint='{2}'"; + // sql = String.Format(sql, model.DetailID, model.TransSequence, WorkPoint); + // if (!DBHelper.ExecuteNonQuery(sql, cmd)) + // { + // throw new Exception(language.GetNameByCode("WMSAPIInfo199")); + // } + // } + //} #endregion #region 委外入库,倒冲