Browse Source

调整调拨的接口

master
lilili 2 years ago
parent
commit
c91c2a442d
  1. 22
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
  2. 129
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

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

@ -5374,6 +5374,26 @@ namespace ICSSoft.DataProject
foreach (var itemInfo in item.Detail)
{
var tranferWorkpoint=string.Empty;
var checksql= $@"SELECT
top 1 a.EATTRIBUTE1
FROM
ICSTransfer a
WHERE
TransferNO = '{item.TransCode}'
AND Sequence = '{item.TransSequence}'
AND WorkPoint = '{item.WorkPoint}'
AND Type = '{item.TransType}'";
var workPoint=DBHelper.ExecuteScalar(checksql, cmd);
if (workPoint == null)
{
tranferWorkpoint = item.WorkPoint;
}
else
{
tranferWorkpoint = workPoint.ToString();
}
//验证仓库库位信息
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouse a WHERE a.WarehouseCode='{0}' AND a.WorkPoint='{1}')
BEGIN
@ -5393,7 +5413,7 @@ namespace ICSSoft.DataProject
RAISERROR('" + language.GetNameByCode("WMSAPIInfo071") + @"',16,1);
RETURN
END";
sql = string.Format(sql, itemInfo.WarehouseCode, item.WorkPoint, itemInfo.LocationCode);
sql = string.Format(sql, itemInfo.WarehouseCode, tranferWorkpoint, itemInfo.LocationCode);
DBHelper.ExecuteNonQuery(sql, cmd);
BusinessCode = TransTypeEnum.OneStepTransferDocIn.GetDescription<DBValue>();

129
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

@ -968,7 +968,7 @@ namespace ICSSoft.DataProject
public static DataTable WareHouseLotInfoTransfer(string Identification, string TransCode, string TransSequence, string WarehouseCode, string LocationCode,
string LotNo, string Quantity, string User, string WorkPoint, string TransType, string BusinessCode, SqlCommand cmd, Dictionary<string, string> language, string MergeID)
{
String LotEnable = "";
bool? LotEnable = null;
String PrintEnable = "";
string lotstr = "";
int result = 0;
@ -977,6 +977,25 @@ namespace ICSSoft.DataProject
List<string> NewBarCodeList = new List<string>();
try
{
var tranferWorkpoint = string.Empty;
var checksql = $@"SELECT
top 1 a.EATTRIBUTE1
FROM
ICSTransfer a
WHERE
TransferNO = '{TransCode}'
AND Sequence = '{TransSequence}'
AND WorkPoint = '{WorkPoint}'
AND Type = '{TransType}'";
var workPoint = DBHelper.ExecuteScalar(checksql, cmd);
if (workPoint == null)
{
tranferWorkpoint = WorkPoint;
}
else
{
tranferWorkpoint = workPoint.ToString();
}
//检验是否分批
string sql = @"SELECT b.LotEnable,b.PrintEnable FROM ICSInventoryLot a
LEFT JOIN ICSInventory b ON a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
@ -990,26 +1009,12 @@ namespace ICSSoft.DataProject
}
else
{
LotEnable = dt.Rows[0]["LotEnable"].ToString();
LotEnable = dt.Rows[0]["LotEnable"] as bool?;
PrintEnable = dt.Rows[0]["PrintEnable"].ToString();
}
if (!LotEnable.Equals("False"))
if (LotEnable == true )
{
///更新库存
sql = @"UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity<0)
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
RETURN
END";
sql = string.Format(sql, LotNo, WorkPoint, Quantity);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存更新失败!");
}
///分批前添加日志
sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
@ -1027,23 +1032,41 @@ namespace ICSSoft.DataProject
c.WarehouseCode,c.LocationCode,'','',c.Quantity+{6},
'','0','{4}','31','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,''
SYSDATETIME() ,'{9}' ,''
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
";
sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransType, BusinessCode, Quantity, TransCode, TransSequence);
sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransType, BusinessCode, Quantity, TransCode, TransSequence, tranferWorkpoint);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo166"));
}
///更新库存
sql = @"UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}',LocationCode = '{3}',
WorkPoint ='{4}' WHERE LotNo='{0}' AND WorkPoint='{1}';
UPDATE ICSInventoryLot SET WorkPoint='{4}' WHERE LotNo='{0}' AND WorkPoint='{1}';
IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity<0)
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
RETURN
END";
sql = string.Format(sql, LotNo, WorkPoint, Quantity,LocationCode, tranferWorkpoint);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存更新失败!");
}
#region 获取分批后的条码(lotstr)
sql = @"SELECT TOP 1 LotNO FROM ICSInventoryLot WHERE EATTRIBUTE1='{0}' AND WorkPoint='{1}'
ORDER BY CAST(SUBSTRING(LotNO, (LEN(LotNO)-CHARINDEX('-',REVERSE(LotNO))+1)+1,CHARINDEX('-',REVERSE(LotNO))-1) AS INT) DESC";
sql = string.Format(sql, LotNo, WorkPoint);
sql = string.Format(sql, LotNo, tranferWorkpoint);
dt = DBHelper.SQlReturnData(sql, cmd);
if (dt.Rows.Count == 0)
{
@ -1064,10 +1087,10 @@ namespace ICSSoft.DataProject
SELECT TOP 1 NEWID(),'{0}',a.InvCode,a.ProductDate,a.ExpirationDate,
'{2}',a.Amount,a.ExtensionID,a.Type,a.PrintTimes,
a.LastPrintUser,a.LastPrintTime,a.MUSER ,a.MUSERName ,GETDATE(),
a.WorkPoint ,'{1}'
'{3}' ,'{1}'
From ICSInventoryLot a
where a.LotNo='{1}' and a.WorkPoint='{3}'";
sql = string.Format(sql, lotstr, LotNo, Quantity, WorkPoint);
sql = string.Format(sql, lotstr, LotNo, Quantity, tranferWorkpoint);
cmd.CommandText = sql;
result = cmd.ExecuteNonQuery();
if (result <= 0)
@ -1076,11 +1099,11 @@ namespace ICSSoft.DataProject
}
#endregion
sql = @"INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
select NEWID(),'{0}','{4}','{5}',InvCode,'{2}',InDate,LockQuantity
select NEWID(),'{0}','{4}','{3}',InvCode,'{2}',InDate,LockQuantity
,MUSER,MUSERName,GETDATE(),'{3}',''
from ICSWareHouseLotInfo
where LotNO='{1}' AND WorkPoint='{3}'";
sql = string.Format(sql, lotstr, LotNo, Quantity, WorkPoint,WarehouseCode,LocationCode);
sql = string.Format(sql, lotstr, LotNo, Quantity, tranferWorkpoint, WarehouseCode,LocationCode);
cmd.CommandText = sql;
result = cmd.ExecuteNonQuery();
if (result <= 0)
@ -1089,12 +1112,12 @@ namespace ICSSoft.DataProject
}
//插入条码单据表
sql = @"INSERT INTO ICSInventoryLotDetail(LotNo,TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
SELECT '{3}',b.TransCode,b.TransSequence,f.F_Account ,f.F_RealName ,SYSDATETIME() ,a.WorkPoint
SELECT '{0}',b.TransCode,b.TransSequence,f.F_Account ,f.F_RealName ,SYSDATETIME() ,'{1}'
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'";
sql = string.Format(sql, LotNo, WorkPoint, User, lotstr);
sql = string.Format(sql, lotstr, tranferWorkpoint, User);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
@ -1109,13 +1132,13 @@ namespace ICSSoft.DataProject
c.WarehouseCode,c.LocationCode,'{11}','{12}','{6}',
'','0','{7}','{8}','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,'','{9}'
SYSDATETIME() ,'{1}' ,'','{9}'
FROM ICSInventoryLot a
INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
";
sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, MergeID, lotstr, WarehouseCode, LocationCode);
sql = string.Format(sql, LotNo, tranferWorkpoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, MergeID, lotstr, WarehouseCode, LocationCode);
cmd.CommandText = sql;
result = cmd.ExecuteNonQuery();
if (result <= 0)
@ -1138,13 +1161,13 @@ namespace ICSSoft.DataProject
c.WarehouseCode,c.LocationCode,'','',c.Quantity,
'','0','{7}','32','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,'','{9}'
SYSDATETIME() ,'{10}' ,'','{9}'
FROM ICSInventoryLot a
INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
";
sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, MergeID);
sql = string.Format(sql, LotNo, tranferWorkpoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, MergeID, tranferWorkpoint);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
@ -1160,7 +1183,7 @@ namespace ICSSoft.DataProject
where a.BusinessCode ='105'
and A.lotno like'{0}%' and a.workpoint='{1}'
";
sql = string.Format(sql, LotNo, WorkPoint);
sql = string.Format(sql, LotNo, tranferWorkpoint);
dtLotno = DBHelper.SQlReturnData(sql, cmd);
lstDt = dtLotno;
}
@ -1189,13 +1212,13 @@ namespace ICSSoft.DataProject
c.WarehouseCode,c.LocationCode,'{9}','{10}',{6},
'','0','{7}','{8}','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,'','{11}'
SYSDATETIME() ,'{12}' ,'','{11}'
FROM ICSInventoryLot a
INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
";
sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, WarehouseCode, LocationCode, MergeID);
sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, WarehouseCode, LocationCode, MergeID, tranferWorkpoint);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
@ -1210,48 +1233,18 @@ namespace ICSSoft.DataProject
// RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
// RETURN
// END";
sql = $@"DECLARE @EATTRIBUTE INT;
SELECT
@EATTRIBUTE = a.EATTRIBUTE1
FROM
ICSTransfer a
WHERE
TransferNO = '{TransCode}'
AND Sequence = '{TransSequence}'
AND WorkPoint = '{WorkPoint}'
AND Type = '{TransType}';
IF
@EATTRIBUTE IS NULL BEGIN
UPDATE ICSWareHouseLotInfo
SET WareHouseCode = '{WarehouseCode}',
LocationCode = '{LocationCode}'
WHERE
LotNo = '{LotNo}'
AND WorkPoint = '{WorkPoint}';
END
ELSE IF @EATTRIBUTE=''
BEGIN
UPDATE ICSWareHouseLotInfo
SET WareHouseCode = '{WarehouseCode}',
LocationCode = '{LocationCode}'
WHERE
LotNo = '{LotNo}'
AND WorkPoint = '{WorkPoint}';
END
ELSE BEGIN
UPDATE ICSWareHouseLotInfo
sql = $@"UPDATE ICSWareHouseLotInfo
SET WareHouseCode = '{WarehouseCode}',
LocationCode = '{LocationCode}',
WorkPoint =@EATTRIBUTE
WorkPoint ='{tranferWorkpoint}'
WHERE
LotNo = '{LotNo}'
AND WorkPoint = '{WorkPoint}';
END
UPDATE ICSInventoryLot SET WorkPoint='{tranferWorkpoint}' WHERE LotNo='{LotNo}' AND WorkPoint='{WorkPoint}';
IF EXISTS ( SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo= '{LotNo}' AND a.WorkPoint= '{WorkPoint}' AND Quantity < 0 ) BEGIN
RAISERROR ( '{language.GetNameByCode("WMSAPIInfo167")}', 16, 1 );
RETURN END;";
sql = string.Format(sql, LotNo, WorkPoint, WarehouseCode, LocationCode, TransCode, TransSequence, TransType);
//sql = string.Format(sql, LotNo, WorkPoint, WarehouseCode, LocationCode, TransCode, TransSequence, TransType);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{

Loading…
Cancel
Save