|
@ -1042,25 +1042,25 @@ b.IssueCode+a.MUSER+ISNULL(b.SourceCode,'')+ISNULL(c.DepCode,'') AS Costre,a.Fro |
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo114") + @"',16,1); |
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo114") + @"',16,1); |
|
|
END |
|
|
END |
|
|
|
|
|
|
|
|
UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)-'{2}' |
|
|
|
|
|
FROM ICSInventoryLot a |
|
|
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
|
|
INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
|
|
INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint |
|
|
|
|
|
{3} |
|
|
|
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='{4}' |
|
|
|
|
|
|
|
|
-- UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)-'{2}' |
|
|
|
|
|
-- FROM ICSInventoryLot a |
|
|
|
|
|
-- INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
|
|
-- INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
|
|
-- INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint |
|
|
|
|
|
-- {3} |
|
|
|
|
|
-- WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='{4}' |
|
|
|
|
|
|
|
|
{5} |
|
|
{5} |
|
|
|
|
|
|
|
|
IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a |
|
|
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
|
|
INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
|
|
INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint |
|
|
|
|
|
{3} |
|
|
|
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='{4}' AND e.IssueQuantity<0) |
|
|
|
|
|
BEGIN |
|
|
|
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo192") + @"',16,1); |
|
|
|
|
|
END";
|
|
|
|
|
|
|
|
|
-- IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a |
|
|
|
|
|
-- INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
|
|
-- INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
|
|
-- INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint |
|
|
|
|
|
-- {3} |
|
|
|
|
|
-- WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='{4}' AND e.IssueQuantity<0) |
|
|
|
|
|
-- BEGIN |
|
|
|
|
|
-- RAISERROR('" + language.GetNameByCode("WMSAPIInfo192") + @"',16,1); |
|
|
|
|
|
-- END";
|
|
|
|
|
|
|
|
|
sql = string.Format(sql, LotNo, WorkPoint, Quantity, table, type, sqlMOIssueDocNegativeIssueDH, quantitySql); |
|
|
sql = string.Format(sql, LotNo, WorkPoint, Quantity, table, type, sqlMOIssueDocNegativeIssueDH, quantitySql); |
|
|
#endregion
|
|
|
#endregion
|
|
@ -1314,46 +1314,6 @@ SELECT y.DepCode+a.ToWarehouseCode+y.MOCode+a.MUSER AS Costre,y.DepCode,a.ToWare |
|
|
DROP TABLE #NewDouTempERP";
|
|
|
DROP TABLE #NewDouTempERP";
|
|
|
} |
|
|
} |
|
|
else if (TransType == TransTypeEnum.MOIssueDocNegativeApply.GetDescription()) |
|
|
else if (TransType == TransTypeEnum.MOIssueDocNegativeApply.GetDescription()) |
|
|
{ |
|
|
|
|
|
if (DBHelper.IsPNU9()) |
|
|
|
|
|
{ |
|
|
|
|
|
sql = @"select LotNo,WorkPoint,InvCode,ToWarehouseCode,MUSER,Quantity
|
|
|
|
|
|
INTO #NewTempERP |
|
|
|
|
|
from ICSWareHouseLotInfoLog |
|
|
|
|
|
WHERE Identification='{0}' AND ERPUpload='0' AND ISNULL(LogID, '')='' |
|
|
|
|
|
|
|
|
|
|
|
select LotNo,WorkPoint,InvCode,ToWarehouseCode,MUSER,Quantity,LogID |
|
|
|
|
|
INTO #NewDouTempERP |
|
|
|
|
|
from ICSWareHouseLotInfoLog |
|
|
|
|
|
WHERE Identification='{0}' AND ERPUpload='0' AND ISNULL(LogID, '')<>'' |
|
|
|
|
|
|
|
|
|
|
|
SELECT a.ToWarehouseCode+z.ApplyNegCode+a.MUSER AS Costre,'' AS DepCode,a.ToWarehouseCode AS WarehouseCode,z.ApplyNegCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY a.ToWarehouseCode,z.ApplyNegCode,c.id,a.InvCode) AS Sequence, |
|
|
|
|
|
a.InvCode,SUM(a.Quantity) AS Quantity,0 AS Amount,c.id AS SourceDetailID,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock |
|
|
|
|
|
,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand, |
|
|
|
|
|
ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 |
|
|
|
|
|
INTO #TempERP |
|
|
|
|
|
FROM #NewTempERP 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 |
|
|
|
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint |
|
|
|
|
|
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint |
|
|
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
|
|
INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
|
|
INNER JOIN ICSMOApplyNeg z ON c.ApplyNegCode=z.ApplyNegCode AND c.WorkPoint=z.WorkPoint |
|
|
|
|
|
INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint |
|
|
|
|
|
INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock002' AND a.WorkPoint=conStock.WorkPoint |
|
|
|
|
|
GROUP BY a.ToWarehouseCode,z.ApplyNegCode,a.MUSER,a.InvCode,c.id,con.Enable,conStock.Enable |
|
|
|
|
|
,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''), |
|
|
|
|
|
ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '') |
|
|
|
|
|
|
|
|
|
|
|
SELECT DISTINCT Costre,WorkPoint,DepCode,WarehouseCode AS WHCode,'领料申请单' AS SourceType,ApplyNegCode AS SourceCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,UpdateStock FROM #TempERP |
|
|
|
|
|
SELECT Costre,Sequence,InvCode,Quantity,Amount,SourceDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 ,WarehouseCode AS WHCode FROM #TempERP |
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE #TempERP |
|
|
|
|
|
DROP TABLE #NewTempERP |
|
|
|
|
|
DROP TABLE #NewDouTempERP";
|
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
{ |
|
|
sql = @"select LotNo,WorkPoint,InvCode,ToWarehouseCode,MUSER,Quantity
|
|
|
sql = @"select LotNo,WorkPoint,InvCode,ToWarehouseCode,MUSER,Quantity
|
|
|
INTO #NewTempERP |
|
|
INTO #NewTempERP |
|
@ -1409,7 +1369,6 @@ INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock002' AND a.Wor |
|
|
DROP TABLE #NewTempERP |
|
|
DROP TABLE #NewTempERP |
|
|
DROP TABLE #NewDouTempERP";
|
|
|
DROP TABLE #NewDouTempERP";
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据材料出库单查询上游单据,根据上游单据生成红字材料出库
|
|
|
//根据材料出库单查询上游单据,根据上游单据生成红字材料出库
|
|
|
else if (TransType == TransTypeEnum.MOIssueDocNegativeIssue.GetDescription()) |
|
|
else if (TransType == TransTypeEnum.MOIssueDocNegativeIssue.GetDescription()) |
|
|