From 5d61da2d1b9228167c584e605747834cbce37fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AD=A3=E4=BC=9F?= <1063165173@qq.com> Date: Fri, 9 Sep 2022 15:49:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=91=E6=96=99=E5=BA=93?= =?UTF-8?q?=E4=BD=8D=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSSoft.DataProject/ICSSubmitService.cs | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs index 044767b..2d6a022 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs @@ -733,6 +733,121 @@ namespace ICSSoft.DataProject { sql = sqlCheck + sql; } + #region 判断是否启用匹配库位 + 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) + { + sql = sqlCheck + @"select * from (" + sql + @")a into #maintemp + select * into #resulttemp from #maintemp + truncate table #resulttemp + select a.lotno,a.locationcode,a.invcode,(a.quantity-a.lockQuantity) as quantity ,a.mtime,a.warehousecode,isnull(ext.ProjectCode,'')as ProjectCode, isnull(ext.Version,'')as Version, + isnull(ext.Brand,'')as Brand, + isnull(ext.cFree1,'')as cFree1, + isnull(ext.cFree2,'') cFree2, + isnull(ext.cFree3,'') cFree3, + isnull(ext.cFree4,'') cFree4, + isnull(ext.cFree5,'') cFree5, + isnull(ext.cFree6,'') cFree6, + isnull(ext.cFree7,'') cFree7, + isnull(ext.cFree8,'') cFree8, + isnull(ext.cFree9,'') cFree9, + isnull(ext.cFree10,'') cFree10,ISNULL(ext.BatchCode, '') BatchCode into #barcodetemp + from ICSWareHouseLotInfo a INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint + INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint + LEFT JOIN + (select invcode,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WHCODE from #maintemp + group by invcode,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WHCODE) b on a.invcode = b.invcode + where a.warehousecode = b.whcode and a.Quantity-a.lockQuantity>0 and isnull(ext.ProjectCode,'') = b.ProjectCode and isnull(ext.Version,'')=b.Version and + isnull(ext.Brand,'') =b.Brand and + isnull(ext.cFree1,'')=b.cFree1 and + isnull(ext.cFree2,'')=b.cFree2 and + isnull(ext.cFree3,'')=b.cFree3 and + isnull(ext.cFree4,'')=b.cFree4 and + isnull(ext.cFree5,'')=b.cFree5 and + isnull(ext.cFree6,'')=b.cFree6 and + isnull(ext.cFree7,'')=b.cFree7 and + isnull(ext.cFree8,'')=b.cFree8 and + isnull(ext.cFree9,'')=b.cFree9 and + isnull(ext.cFree10,'')=b.cFree10 and (b.BatchCode=''OR (b.batchcode<>'' and b.BatchCode = ISNULL(ext.BatchCode, ''))) + + BEGIN + DECLARE @transSequence VARCHAR(50);--当前循环的行号 + DECLARE @qty int;--条码表数量 + DECLARE @needqty int;--本行所需数量 + DECLARE @lotno VARCHAR(50);--本行所需数量 + DECLARE @locationcode VARCHAR(50);--本行所在库位 + DECLARE @WHCode VARCHAR(50);--本行所在仓库 + 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 + PRINT @transSequence + WHILE @needqty>0 + BEGIN + + select top 1 @qty = a.quantity, @locationcode = a.locationcode,@lotno = a.lotno,@WHCode = a.warehousecode from #barcodetemp a + LEFT 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(a.ProjectCode,'') = b.ProjectCode and isnull(a.Version,'')=b.Version and + isnull(a.Brand,'') =b.Brand and + isnull(a.cFree1,'')=b.cFree1 and + isnull(a.cFree2,'')=b.cFree2 and + isnull(a.cFree3,'')=b.cFree3 and + isnull(a.cFree4,'')=b.cFree4 and + isnull(a.cFree5,'')=b.cFree5 and + isnull(a.cFree6,'')=b.cFree6 and + isnull(a.cFree7,'')=b.cFree7 and + isnull(a.cFree8,'')=b.cFree8 and + isnull(a.cFree9,'')=b.cFree9 and a.warehousecode = b.WHCODE and + isnull(a.cFree10,'')=b.cFree10 and (b.BatchCode=''OR (b.batchcode<>a.BatchCode and b.BatchCode = ISNULL(a.BatchCode, '')))ORDER BY mtime,locationcode + IF(@needqty-@qty>=0) + BEGIN + + insert INTO #resulttemp (id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, + Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,LocationCode,LocationQty,AmountUnit, + LocationName,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,ISNULL(AmountUnit, ''), + LocationName,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 + BEGIN + + insert INTO #resulttemp (id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, + Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,LocationCode,LocationQty,AmountUnit, + LocationName,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 ,ISNULL(AmountUnit, ''), + LocationName,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 + + END + END + FETCH NEXT FROM tempCursor INTO @transSequence; + END + CLOSE tempCursor + DEALLOCATE tempCursor + END + + + select id,TransCode,DetailID,Type,TransSequence,IssueQuantity,Quantity, + [User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,LocationCode,sum(LocationQty)as LocationQty,AmountUnit, + LocationName,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,AmountUnit, + LocationName,WHName,ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 ORDER BY locationcode ASC ,InvCode ASC + + + DROP table #maintemp + DROP table #resulttemp + DROP table #barcodetemp"; + } + #endregion where = string.Format(where, JsonData.TransCode, JsonData.WorkPoint); sql = string.Format(sql, columns, tableName, where, JsonData.TransCode); @@ -1515,6 +1630,8 @@ namespace ICSSoft.DataProject #region 出库检验是否符合源头单据 string msg = string.Empty; bool isLimit = false; + string sqlCheckSign = @"select F_EnabledMark from Sys_SRM_Items where F_EnCode = 'OutWithLocationCode'"; + DataTable flag = DBHelper.SQlReturnData(sqlCheckSign, cmd); if (isOut) // && TransType != TransTypeEnum.LOTSplit.GetDescription() {//&& TransType != TransTypeEnum.TransferLibrary.GetDescription() string Lot = ""; @@ -1590,6 +1707,11 @@ namespace ICSSoft.DataProject CheckTrans(dataView, rowFilter, string.Format(language.GetNameByCode("WMSAPIInfo055"), Lot, drLot["cFree9"])); rowFilter += "AND (LEN(ISNULL(cFree10,''))<=0 OR (LEN(ISNULL(cFree10,''))>0 AND cFree10='" + drLot["cFree10"] + "'))"; CheckTrans(dataView, rowFilter, string.Format(language.GetNameByCode("WMSAPIInfo056"), Lot, drLot["cFree10"])); + if (flag != null && flag.Rows.Count > 0) + { + rowFilter += " AND LocationCode='" + drLot["LocationCode"] + "'"; + CheckTrans(dataView, rowFilter, string.Format(language.GetNameByCode("WMSAPIInfo042"), Lot, drLot["LocationCode"])); + } //保质期管理 var resultEffective = Effective(Lot, JsonData.WorkPoint, cmd, language); //0 - 已经是最早的批次