FoxV 2 years ago
parent
commit
776583c4f1
  1. 186
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs

186
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs

@ -65,6 +65,10 @@ namespace ICSSoft.DataProject
";
string 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,
@ -675,70 +679,13 @@ namespace ICSSoft.DataProject
#endregion
if (string.IsNullOrWhiteSpace(columns) || string.IsNullOrWhiteSpace(tableName) || string.IsNullOrWhiteSpace(where))
throw new Exception(language.GetNameByCode("WMSAPIInfo003"));
if (isDeliveryNotice)//送货、到货、含委外
{
#region SLQ
sql = sqlCheck + @"SELECT a.ID,
{0}
a.InvCode,
inv.InvName,
inv.InvStd,
inv.InvUnit,
a.WHCode,
inv.AmountUnit,
'' AS WHName,
a.ExtensionID,
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
FROM {1}
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
WHERE {2} ";
#endregion
}
else if(isMerge)//合并发料
{
#region SLQ
string sqlMerge = @"IF EXISTS(SELECT ID FROM ICSMOPickMerge WHERE MergeID='{3}' AND WorkPoint='{4}' )
BEGIN
"+ sql;
string whereMerge = string.Format("mer.MergeID='{0}' AND mer.WorkPoint='{1}'", JsonData.TransCode, JsonData.WorkPoint);
sqlMerge = string.Format(sqlMerge, columnsMerge, tableNameMerge, whereMerge, JsonData.TransCode, JsonData.WorkPoint);
sql = sqlMerge + @"
END
ELSE
BEGIN
IF EXISTS(SELECT a.ID FROM {1} INNER JOIN ICSMOPickMerge c ON a.ID=c.SourceID AND a.WorkPoint=c.WorkPoint WHERE {2})
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo194") + @"',16,1);
RETURN
END
" + sqlCheck + sql + @"
END";
#endregion
}
else
{
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)
// if (true)
{
sql = sqlCheck + @"select * from (" + sql + @")a into #maintemp
sql = @"select * into #maintemp from (" + sql + @")a
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,
@ -758,7 +705,9 @@ namespace ICSSoft.DataProject
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
where (a.warehousecode = b.whcode or ISNULL(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
@ -769,7 +718,8 @@ namespace ICSSoft.DataProject
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, '')))
isnull(ext.cFree10,'')=b.cFree10 and
((isnull(b.BatchCode,'')<>'' and b.BatchCode =ext.BatchCode) or isnull(b.BatchCode,'') ='')
BEGIN
DECLARE @transSequence VARCHAR(50);--
@ -789,28 +739,30 @@ namespace ICSSoft.DataProject
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
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
((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
((isnull(b.cFree2,'')<>'' and b.cFree2 =a.cFree2 )or isnull(b.cFree2,'') ='') and
((isnull(b.cFree3,'')<>'' and b.cFree3 =a.cFree3 )or isnull(b.cFree3,'') ='') and
((isnull(b.cFree4,'')<>'' and b.cFree4 =a.cFree4 )or isnull(b.cFree4,'') ='') and
((isnull(b.cFree5,'')<>'' and b.cFree5 =a.cFree5) or isnull(b.cFree5,'') ='') and
((isnull(b.cFree6,'')<>'' and b.cFree6 =a.cFree6 )or isnull(b.cFree6,'') ='') and
((isnull(b.cFree7,'')<>'' and b.cFree7 =a.cFree7) or isnull(b.cFree7,'') ='') and
((isnull(b.cFree8,'')<>'' and b.cFree8 =a.cFree8) or isnull(b.cFree8,'') ='') and
((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)
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)
Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,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,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
ISNULL(Amount, 0),[User],[MTime],InvCode,InvName,ISNULL(InvStd, ''),InvUnit,@WHCode,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
@ -818,11 +770,11 @@ namespace ICSSoft.DataProject
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)
Amount,[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,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 ,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
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, ''),
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
@ -837,10 +789,10 @@ namespace ICSSoft.DataProject
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
[User],[MTime],InvCode,InvName,InvStd,InvUnit,WHCode,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,
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
@ -848,6 +800,68 @@ namespace ICSSoft.DataProject
DROP table #barcodetemp";
}
#endregion
if (isDeliveryNotice)//送货、到货、含委外
{
#region SLQ
sql = sqlCheck + @"SELECT a.ID,
{0}
a.InvCode,
inv.InvName,
inv.InvStd,
inv.InvUnit,
'' AS WHCode,
inv.AmountUnit,
'' AS WHName,
a.ExtensionID,
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
FROM {1}
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
WHERE {2} ";
#endregion
}
else if(isMerge)//合并发料
{
#region SLQ
string sqlMerge = "SELECT ID FROM ICSMOPickMerge WHERE MergeID='"+ JsonData.TransCode + "' AND WorkPoint='"+ JsonData.WorkPoint + "'";
DataTable sign = DBHelper.SQlReturnData(sqlMerge, cmd);
if (sign != null && flag.Rows.Count > 0)
{
string whereMerge = string.Format("mer.MergeID='{0}' AND mer.WorkPoint='{1}'", JsonData.TransCode, JsonData.WorkPoint);
sql = string.Format(sql, columnsMerge, tableNameMerge, whereMerge, JsonData.TransCode, JsonData.WorkPoint);
}
else
{
sql = @" BEGIN
IF EXISTS(SELECT a.ID FROM {1} INNER JOIN ICSMOPickMerge c ON a.ID=c.SourceID AND a.WorkPoint=c.WorkPoint WHERE {2})
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo194") + @"',16,1);
RETURN
END
" + sqlCheck + sql + @"
END";
}
#endregion
}
else
{
sql = sqlCheck + sql;
}
where = string.Format(where, JsonData.TransCode, JsonData.WorkPoint);
sql = string.Format(sql, columns, tableName, where, JsonData.TransCode);

Loading…
Cancel
Save