Browse Source

调整料架条码绑定接口

master
lilili 1 year ago
parent
commit
0ff950f8be
  1. 41
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
  2. 56
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

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

@ -7098,8 +7098,11 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer
using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
SqlTransaction sqlTran = conn.BeginTransaction();
cmd.Transaction = sqlTran;
try
{
Result res = new Result();
@ -7107,6 +7110,17 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo007"));//"传入数据为空!"
}
//获取第一个数据的料架编码
string fistContainerCode = JsonData.FirstOrDefault().ContainerCode;
//获取第一个条码数据
string fistLotNO= JsonData.FirstOrDefault().LotNo;
//查询第一个条码的仓库和库位信息
var tableData=ICSWareHouseLotInfoService.GetWHCodeArea(fistLotNO, cmd);
if (tableData.Rows.Count==0)
{
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo038"), fistLotNO));
}
foreach (ICSContainerBind item in JsonData)
{
string TransType = item.TransType;
@ -7134,6 +7148,10 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo206"));//"位置编码不能为空!"
}
if (item.ContainerCode!=fistContainerCode)
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo474"));//"所传的料架编码不一致,调用失败!"
}
if (msg != "")
{
res.Success = false;
@ -7144,8 +7162,26 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer
{
if (TransType == TransTypeEnum.ContainerBind.GetDescription())
{
//料架条码绑定
ICSWareHouseLotInfoService.ContainerBind(item.LotNo, item.ContainerCode, item.ContainerType, item.LocationCode, item.RecomendBinCode, item.User, item.WorkPoint, cmd, language);
var tableModel = ICSWareHouseLotInfoService.GetWHCodeArea(item.LotNo, cmd);
if (tableModel.Rows.Count == 0)
{
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo038"), item.LotNo));
}
else if (tableModel.Rows[0]["WHCode"].ToString()!= tableData.Rows[0]["WHCode"].ToString())
{
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo475"), item.LotNo));
}
else if (tableModel.Rows[0]["LocationCode"].ToString() != tableData.Rows[0]["LocationCode"].ToString())
{
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo476"), item.LotNo));
}
else
{
//料架条码绑定
ICSWareHouseLotInfoService.ContainerBind(item.LotNo, item.ContainerCode, item.ContainerType, item.LocationCode, item.RecomendBinCode, item.User, item.WorkPoint, cmd, language);
}
}
else
{
@ -7156,6 +7192,7 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer
}
res.Success = true;
res.Message = msg;// "接口调用成功!";
cmd.Transaction.Commit();
return res;
}
catch (Exception ex)

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

@ -2878,23 +2878,33 @@ namespace ICSSoft.DataProject
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{3}") + @"',16,1);
RETURN
END
IF NOT EXISTS(SELECT ID FROM ICSInventoryLot WHERE LotNO='{0}')
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo038"), "{0}") + @"',16,1);
RETURN
END
IF NOT EXISTS(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}')
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo473"), "{2}", "{1}") + @"',16,1);
RETURN
END
IF NOT EXISTS (SELECT * FROM ICSContainerLot WHERE ContainerID=
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}'))
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}') AND LotNo='{0}')
BEGIN
update ICSContainer set LocationCode='{4}',EATTRIBUTE1='' where ContainerCode='{1}' AND WorkPoint='{2}'
-- update ICSContainer set EATTRIBUTE1='' where ContainerCode='{1}' AND WorkPoint='{2}'
INSERT INTO ICSContainerLot
(ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME,EATTRIBUTE1)
SELECT NEWID(),ID,'{0}','{3}'
,(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}'),'{2}',GETDATE(),'{4}' FROM ICSContainer
,(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}'),'{2}',GETDATE(),'' FROM ICSContainer
WHERE ContainerCode='{1}' AND WorkPoint='{2}'
END
ELSE
BEGIN
update ICSContainer set LocationCode='{4}',EATTRIBUTE1='' where ContainerCode='{1}' AND WorkPoint='{2}'
UPDATE ICSContainerLot SET LotNo='{0}' WHERE ContainerID=
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}')
END
-- ELSE
-- BEGIN
-- update ICSContainer set LocationCode='{4}',EATTRIBUTE1='' where ContainerCode='{1}' AND WorkPoint='{2}'
-- UPDATE ICSContainerLot SET LotNo='{0}' WHERE ContainerID=
-- (SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}')
-- END
";
sql = string.Format(sql, LotNo, ContainerCode, WorkPoint, User, LocationCode);
@ -3244,5 +3254,33 @@ namespace ICSSoft.DataProject
throw new Exception(ex.Message);
}
}
/// <summary>
/// 根据条码获取仓库和区域信息
/// </summary>
/// <param name="LotNo"></param>
/// <param name="cmd"></param>
public static DataTable GetWHCodeArea(string LotNo,SqlCommand cmd)
{
try
{
string check = $@"SELECT C.WHCode,C.LocationCode FROM ICSInventoryLotDetail A
INNER JOIN ICSDeliveryNotice B ON B.DNCode=A.TransCode AND B.Sequence=A.TransSequence AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSInventoryDetail C ON C.INVCode=B.InvCode AND C.WHCode=B.WHCode AND C.WorkPoint=B.WorkPoint
WHERE A.LotNo='{LotNo}'
UNION ALL
SELECT C.WHCode,C.LocationCode FROM ICSInventoryLotDetail A
INNER JOIN ICSMOApplyNegDetail B ON B.ApplyNegCode=A.TransCode AND B.Sequence=A.TransSequence AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSInventoryDetail C ON C.INVCode=B.InvCode AND C.WHCode=B.WHCode AND C.WorkPoint=B.WorkPoint
WHERE A.LotNo='{LotNo}'";
var table = DBHelper.SQlReturnData(check, cmd);
return table;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
Loading…
Cancel
Save