Browse Source

启用批次从物料批次中取,不存在取物料上面的

master
lixh 3 years ago
parent
commit
c826bbcad3
  1. 128
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs

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

@ -76,7 +76,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
ISNULL(ext.ProjectCode, '') AS ProjectCode, ISNULL(ext.ProjectCode, '') AS ProjectCode,
a.ExtensionID, a.ExtensionID,
CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,
CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,
ISNULL(ext.Version, '') AS Version, ISNULL(ext.Version, '') AS Version,
ISNULL(ext.Brand, '') AS Brand, ISNULL(ext.Brand, '') AS Brand,
ISNULL(ext.cFree1, '') AS cFree1, ISNULL(ext.cFree1, '') AS cFree1,
@ -250,7 +250,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
a.ExtensionID, a.ExtensionID,
ext.ProjectCode, ext.ProjectCode,
CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,
CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,
ext.Version, ext.Version,
ext.Brand, ext.Brand,
ext.cFree1, ext.cFree1,
@ -745,7 +745,7 @@ namespace ICSSoft.DataProject
END END
" + sql + "AND Otin.InCode = '" + JsonData.TransCode + "'" " + sql + "AND Otin.InCode = '" + JsonData.TransCode + "'"
+ @"GROUP BY a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode, + @"GROUP BY a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END,inv.AmountUnit,
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END,inv.AmountUnit,
ext.ProjectCode,ext.Version,ext.Brand,ext.cFree1,ext.cFree2,ext.cFree3,ext.cFree4,ext.cFree5,ext.cFree6,ext.cFree7,ext.cFree8,ext.cFree9,ext.cFree10,a.MUSER,a.MTIME"; ext.ProjectCode,ext.Version,ext.Brand,ext.cFree1,ext.cFree2,ext.cFree3,ext.cFree4,ext.cFree5,ext.cFree6,ext.cFree7,ext.cFree8,ext.cFree9,ext.cFree10,a.MUSER,a.MTIME";
columns = @"SUM(log.Quantity) AS Quantity, columns = @"SUM(log.Quantity) AS Quantity,
@ -754,7 +754,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
a.LocationCode, a.LocationCode,
loc.LocationName, loc.LocationName,
CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,";
CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,";
tableName = @"ICSOtherIn Otin tableName = @"ICSOtherIn Otin
INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint
@ -784,7 +784,7 @@ namespace ICSSoft.DataProject
END END
" + sql + "AND sdn.SDNCode = '" + JsonData.TransCode + "'" " + sql + "AND sdn.SDNCode = '" + JsonData.TransCode + "'"
+ @"GROUP BY a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode, + @"GROUP BY a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END,inv.AmountUnit,
wh.WarehouseName,a.LocationCode,loc.LocationName,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END,inv.AmountUnit,
ext.ProjectCode,ext.Version,ext.Brand,ext.cFree1,ext.cFree2,ext.cFree3,ext.cFree4,ext.cFree5,ext.cFree6,ext.cFree7,ext.cFree8,ext.cFree9,ext.cFree10,a.MUSER,a.MTIME"; ext.ProjectCode,ext.Version,ext.Brand,ext.cFree1,ext.cFree2,ext.cFree3,ext.cFree4,ext.cFree5,ext.cFree6,ext.cFree7,ext.cFree8,ext.cFree9,ext.cFree10,a.MUSER,a.MTIME";
columns = @"SUM(log.Quantity) AS Quantity, columns = @"SUM(log.Quantity) AS Quantity,
@ -793,7 +793,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
a.LocationCode, a.LocationCode,
loc.LocationName, loc.LocationName,
CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,";
CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,";
tableName = @"ICSSDN sdn tableName = @"ICSSDN sdn
INNER JOIN ICSWareHouseLotInfoLog log ON sdn.SDNCode=log.TransCode AND sdn.Sequence=log.TransSequence AND sdn.WorkPoint=log.WorkPoint INNER JOIN ICSWareHouseLotInfoLog log ON sdn.SDNCode=log.TransCode AND sdn.Sequence=log.TransSequence AND sdn.WorkPoint=log.WorkPoint
@ -820,7 +820,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
a.LocationCode, a.LocationCode,
loc.LocationName, loc.LocationName,
CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,
CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,
ISNULL(split.SplitLotNo, a.LotNo+'-1') AS SplitLotNo,"; ISNULL(split.SplitLotNo, a.LotNo+'-1') AS SplitLotNo,";
tableName = @"ICSWareHouseLotInfo a tableName = @"ICSWareHouseLotInfo a
@ -847,7 +847,7 @@ namespace ICSSoft.DataProject
wh.WarehouseName AS WHName, wh.WarehouseName AS WHName,
a.LocationCode, a.LocationCode,
loc.LocationName, loc.LocationName,
CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,";
CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,";
tableName = @"ICSWareHouseLotInfo a tableName = @"ICSWareHouseLotInfo a
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
@ -2012,7 +2012,7 @@ namespace ICSSoft.DataProject
} }
} }
//校验退料数量是否超出领料数量 //校验退料数量是否超出领料数量
sql = CheckOutsourcingIssueDoc(item.Type, item.id, item.WorkPoint, language);
sql = CheckOutsourcingIssueDoc(item.Type, Code, item.WorkPoint, language);
DBHelper.ExecuteNonQuery(sql, cmd); DBHelper.ExecuteNonQuery(sql, cmd);
codes += "'" + Code + item.WorkPoint + "',"; codes += "'" + Code + item.WorkPoint + "',";
} }
@ -2080,71 +2080,83 @@ namespace ICSSoft.DataProject
} }
} }
private static string CheckOutsourcingIssueDoc(string Type, string ID, string WorkPoint, Dictionary<string, string> language)
private static string CheckOutsourcingIssueDoc(string Type, string Code, string WorkPoint, Dictionary<string, string> language)
{ {
string sql = string.Empty; string sql = string.Empty;
if (Type == "1") if (Type == "1")
{ {
sql = @"DECLARE @PickID VARCHAR(10) sql = @"DECLARE @PickID VARCHAR(10)
SELECT @PickID=b.PickID
SELECT @PickID=b.PickID
FROM ICSOApplyNegDetail a
INNER JOIN ICSOOPick b ON a.SourceDetailID=b.PickID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.Type='{2}' AND a.WorkPoint='{1}'
AND a.SourceDetailID IN (SELECT a.SourceDetailID
FROM ICSOApplyNegDetail a FROM ICSOApplyNegDetail a
INNER JOIN ICSOOPick b ON a.SourceDetailID=b.PickID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ID='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}'
GROUP BY b.PickID
HAVING MAX(b.Quantity)<SUM(a.Quantity)
WHERE c.OApplyNegCode='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}')
GROUP BY b.PickID
HAVING MAX(b.Quantity)<SUM(a.Quantity)
IF (@PickID IS NOT NULL)
BEGIN
DECLARE @InvCode VARCHAR(100)
SELECT @InvCode='" + language.GetNameByCode("WMSAPIInfo064") + @"' FROM ICSOOPick WHERE PickID=@PickID AND WorkPoint='{1}'
RAISERROR(@InvCode,16,1);
RETURN
END ";
IF (@PickID IS NOT NULL)
BEGIN
DECLARE @InvCode VARCHAR(100)
SELECT @InvCode='" + language.GetNameByCode("WMSAPIInfo064") + @"' FROM ICSOOPick WHERE PickID=@PickID AND WorkPoint='{1}'
RAISERROR(@InvCode,16,1);
RETURN
END ";
} }
else if (Type == "2") else if (Type == "2")
{ {
sql = @"DECLARE @ApplyDetailID VARCHAR(10) sql = @"DECLARE @ApplyDetailID VARCHAR(10)
SELECT @ApplyDetailID=b.ApplyDetailID
SELECT @ApplyDetailID=b.ApplyDetailID
FROM ICSOApplyNegDetail a
INNER JOIN ICSOApply b ON a.SourceDetailID=b.ApplyDetailID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.Type='{2}' AND a.WorkPoint='{1}'
AND a.SourceDetailID IN (SELECT a.SourceDetailID
FROM ICSOApplyNegDetail a FROM ICSOApplyNegDetail a
INNER JOIN ICSOApply b ON a.SourceDetailID=b.ApplyDetailID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ID='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}'
GROUP BY b.ApplyDetailID
HAVING MAX(b.Quantity)<SUM(a.Quantity)
WHERE c.OApplyNegCode='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}')
GROUP BY b.ApplyDetailID
HAVING MAX(b.Quantity)<SUM(a.Quantity)
IF (@ApplyDetailID IS NOT NULL)
BEGIN
DECLARE @InvCode VARCHAR(100)
SELECT @InvCode='" + language.GetNameByCode("WMSAPIInfo064") + @"' FROM ICSOApply WHERE ApplyDetailID=@ApplyDetailID AND WorkPoint='{1}'
RAISERROR(@InvCode,16,1);
RETURN
END ";
IF (@ApplyDetailID IS NOT NULL)
BEGIN
DECLARE @InvCode VARCHAR(100)
SELECT @InvCode='" + language.GetNameByCode("WMSAPIInfo064") + @"' FROM ICSOApply WHERE ApplyDetailID=@ApplyDetailID AND WorkPoint='{1}'
RAISERROR(@InvCode,16,1);
RETURN
END ";
} }
else if (Type == "3") else if (Type == "3")
{ {
sql = @"DECLARE @IssueDetailID VARCHAR(10) sql = @"DECLARE @IssueDetailID VARCHAR(10)
SELECT @IssueDetailID=b.IssueDetailID
SELECT @IssueDetailID=b.IssueDetailID
FROM ICSOApplyNegDetail a
INNER JOIN ICSOIssue b ON a.SourceDetailID=b.IssueDetailID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.Type='{2}' AND a.WorkPoint='{1}'
AND a.SourceDetailID IN (SELECT a.SourceDetailID
FROM ICSOApplyNegDetail a FROM ICSOApplyNegDetail a
INNER JOIN ICSOIssue b ON a.SourceDetailID=b.IssueDetailID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint INNER JOIN ICSOApplyNeg c ON a.OApplyNegCode=c.OApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ID='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}'
GROUP BY b.IssueDetailID
HAVING MAX(b.Quantity)<SUM(a.Quantity)
WHERE c.OApplyNegCode='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}')
GROUP BY b.IssueDetailID
HAVING MAX(b.Quantity)<SUM(a.Quantity)
IF (@IssueDetailID IS NOT NULL)
BEGIN
DECLARE @InvCode VARCHAR(100)
SELECT @InvCode='" + language.GetNameByCode("WMSAPIInfo064") + @"' FROM ICSOIssue WHERE IssueDetailID=@IssueDetailID AND WorkPoint='{1}'
RAISERROR(@InvCode,16,1);
RETURN
END ";
IF (@IssueDetailID IS NOT NULL)
BEGIN
DECLARE @InvCode VARCHAR(100)
SELECT @InvCode='" + language.GetNameByCode("WMSAPIInfo064") + @"' FROM ICSOIssue WHERE IssueDetailID=@IssueDetailID AND WorkPoint='{1}'
RAISERROR(@InvCode,16,1);
RETURN
END ";
} }
else else
{ {
throw new Exception(language.GetNameByCode("WMSAPIInfo003"));//"类型不符!"); throw new Exception(language.GetNameByCode("WMSAPIInfo003"));//"类型不符!");
} }
sql = string.Format(sql, ID, WorkPoint, Type);
sql = string.Format(sql, Code, WorkPoint, Type);
return sql; return sql;
} }
@ -2233,7 +2245,7 @@ namespace ICSSoft.DataProject
} }
} }
//校验退料数量是否超出领料数量 //校验退料数量是否超出领料数量
sql = CheckOutsourcingIssueDoc(item.Type, item.id, item.WorkPoint, language);
sql = CheckOutsourcingIssueDoc(item.Type, Code, item.WorkPoint, language);
DBHelper.ExecuteNonQuery(sql, cmd); DBHelper.ExecuteNonQuery(sql, cmd);
ids += "'" + item.id + "',"; ids += "'" + item.id + "',";
} }
@ -2927,7 +2939,11 @@ namespace ICSSoft.DataProject
FROM ICSMOApplyNegDetail a FROM ICSMOApplyNegDetail a
INNER JOIN ICSMOPick b ON a.SourceDetailID=b.PickID AND a.WorkPoint=b.WorkPoint INNER JOIN ICSMOPick b ON a.SourceDetailID=b.PickID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ID='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}'
WHERE c.Type='{2}' AND a.WorkPoint='{1}'
AND a.SourceDetailID IN (SELECT a.SourceDetailID
FROM ICSMOApplyNegDetail a
INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ApplyNegCode='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}')
GROUP BY b.PickID GROUP BY b.PickID
HAVING MAX(b.Quantity)<SUM(a.Quantity) HAVING MAX(b.Quantity)<SUM(a.Quantity)
@ -2946,7 +2962,11 @@ namespace ICSSoft.DataProject
FROM ICSMOApplyNegDetail a FROM ICSMOApplyNegDetail a
INNER JOIN ICSMOApply b ON a.SourceDetailID=b.ApplyDetailID AND a.WorkPoint=b.WorkPoint INNER JOIN ICSMOApply b ON a.SourceDetailID=b.ApplyDetailID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ID='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}'
WHERE c.Type='{2}' AND a.WorkPoint='{1}'
AND a.SourceDetailID IN (SELECT a.SourceDetailID
FROM ICSMOApplyNegDetail a
INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ApplyNegCode='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}')
GROUP BY b.ApplyDetailID GROUP BY b.ApplyDetailID
HAVING MAX(b.Quantity)<SUM(a.Quantity) HAVING MAX(b.Quantity)<SUM(a.Quantity)
@ -2965,7 +2985,11 @@ namespace ICSSoft.DataProject
FROM ICSMOApplyNegDetail a FROM ICSMOApplyNegDetail a
INNER JOIN ICSMOIssue b ON a.SourceDetailID=b.IssueDetailID AND a.WorkPoint=b.WorkPoint INNER JOIN ICSMOIssue b ON a.SourceDetailID=b.IssueDetailID AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ID='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}'
WHERE c.Type='{2}' AND a.WorkPoint='{1}'
AND a.SourceDetailID IN (SELECT a.SourceDetailID
FROM ICSMOApplyNegDetail a
INNER JOIN ICSMOApplyNeg c ON a.ApplyNegCode=c.ApplyNegCode AND a.WorkPoint=c.WorkPoint
WHERE c.ApplyNegCode='{0}' AND c.Type='{2}' AND a.WorkPoint='{1}')
GROUP BY b.IssueDetailID GROUP BY b.IssueDetailID
HAVING MAX(b.Quantity)<SUM(a.Quantity) HAVING MAX(b.Quantity)<SUM(a.Quantity)
@ -3616,7 +3640,7 @@ namespace ICSSoft.DataProject
inv.AmountUnit, inv.AmountUnit,
{1} {1}
ext.ProjectCode, ext.ProjectCode,
CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,
CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ext.BatchCode ELSE '' END AS BatchCode,
ext.Version, ext.Version,
ext.Brand, ext.Brand,
ext.cFree1, ext.cFree1,

Loading…
Cancel
Save