|
|
@ -413,7 +413,120 @@ namespace ICSSoft.DataProject |
|
|
|
throw; |
|
|
|
} |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 添加库存
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="LocationCode"></param>
|
|
|
|
/// <param name="LotNo"></param>
|
|
|
|
/// <param name="Quantity"></param>
|
|
|
|
/// <param name="User"></param>
|
|
|
|
/// <param name="WorkPoint"></param>
|
|
|
|
/// <param name="TransType"></param>
|
|
|
|
/// <param name="BusinessCode"></param>
|
|
|
|
/// <param name="cmd"></param>
|
|
|
|
/// <param name="jointLotNo"></param>
|
|
|
|
public static void WareHouseLotInfoUpForkLift(string Identification, string LocationCode, string ContainerCode, string User, |
|
|
|
string TransType, string BusinessCode, SqlCommand cmd, Dictionary<string, string> language) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
|
|
|
|
#region 正常入库
|
|
|
|
///添加库存(原条码退回,更新库存;新条码直接入库)
|
|
|
|
//stirng locationcode = "";
|
|
|
|
string sql = string.Empty; |
|
|
|
string locationcode = ""; |
|
|
|
string lotsql = @" select A.LotNo,C.Quantity,B.WorkPoint from ICSContainerLot A
|
|
|
|
LEFT JOIN ICSContainer B ON B.ID=A.ContainerID AND B.WorkPoint=A.WorkPoint |
|
|
|
LEFT JOIN ICSInventoryLot C ON C.LotNo=A.LotNo AND C.WorkPoint=A.WorkPoint |
|
|
|
where B.ContainerCode='{0}'";
|
|
|
|
lotsql = string.Format(lotsql, ContainerCode); |
|
|
|
DataTable lotdt = DBHelper.SQlReturnData(lotsql, cmd); |
|
|
|
foreach (DataRow dr in lotdt.Rows) |
|
|
|
{ |
|
|
|
sql = @"
|
|
|
|
IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}') |
|
|
|
BEGIN |
|
|
|
IF EXISTS(SELECT a.LotNO FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.Quantity=0) |
|
|
|
BEGIN |
|
|
|
UPDATE a SET a.Quantity=ISNULL(a.Quantity,0)+'{3}',WarehouseCode=e.WarehouseCode,LocationCode=d.LocationCode |
|
|
|
From ICSWareHouseLotInfo a |
|
|
|
INNER JOIN ICSLocation d ON d.LocationCode='{4}' AND a.WorkPoint=d.WorkPoint |
|
|
|
INNER JOIN ICSWarehouse e ON d.WHID=e.ID AND d.WorkPoint=e.WorkPoint |
|
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' |
|
|
|
END |
|
|
|
ELSE IF EXISTS(SELECT a.LotNO FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.LocationCode='{4}') |
|
|
|
BEGIN |
|
|
|
UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)+'{3}' |
|
|
|
WHERE LotNo='{0}' AND WorkPoint='{1}' |
|
|
|
END |
|
|
|
ELSE IF('" + locationcode + @"' != '{4}') |
|
|
|
BEGIN |
|
|
|
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo395"), "{4}", locationcode) + @"', 16, 1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
IF EXISTS(SELECT il.InvCode FROM ICSInventoryLocation il |
|
|
|
INNER JOIN ICSInventoryLot a ON a.InvCode=il.InvCode AND a.WorkPoint=il.WorkPoint |
|
|
|
WHERE il.Enable='1' AND a.LotNo='{0}' AND a.WorkPoint='{1}') |
|
|
|
BEGIN |
|
|
|
IF NOT EXISTS(SELECT il.InvCode FROM ICSInventoryLocation il |
|
|
|
INNER JOIN ICSInventoryLot a ON a.InvCode=il.InvCode AND a.WorkPoint=il.WorkPoint |
|
|
|
WHERE il.Enable='1' AND a.LotNo='{0}' AND a.WorkPoint='{1}' AND il.LocationCode='{4}') |
|
|
|
BEGIN |
|
|
|
RAISERROR('" + language.GetNameByCode("WMSAPIInfo180") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
END |
|
|
|
INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) |
|
|
|
SELECT NEWID(),a.LotNo ,e.WarehouseCode,d.LocationCode,a.InvCode ,'{3}',SYSDATETIME(),'0','{2}','{2}',SYSDATETIME() ,a.WorkPoint ,'' |
|
|
|
FROM ICSInventoryLot a |
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
--INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSLocation d ON d.LocationCode='{4}' AND a.WorkPoint=d.WorkPoint |
|
|
|
INNER JOIN ICSWarehouse e ON d.WHID=e.ID AND d.WorkPoint=e.WorkPoint |
|
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' |
|
|
|
END";
|
|
|
|
sql = string.Format(sql, dr["LotNo"].ToString(), dr["WorkPoint"].ToString(), User, dr["Quantity"].ToString(), LocationCode); |
|
|
|
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo165")); |
|
|
|
} |
|
|
|
|
|
|
|
///添加日志
|
|
|
|
sql = @"INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
|
|
|
|
FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity, |
|
|
|
Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID, |
|
|
|
ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName, |
|
|
|
MTIME,WorkPoint,EATTRIBUTE1) |
|
|
|
SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode , |
|
|
|
'','',c.WarehouseCode,c.LocationCode,'{6}', |
|
|
|
'','0','{4}','{5}','0','', |
|
|
|
'','','','{2}','{2}', |
|
|
|
SYSDATETIME() ,a.WorkPoint ,'' |
|
|
|
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 |
|
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' |
|
|
|
";
|
|
|
|
sql = string.Format(sql, dr["LotNo"].ToString(), dr["WorkPoint"].ToString(), User, Identification, TransType, BusinessCode, dr["Quantity"].ToString()); |
|
|
|
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo166")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
throw; |
|
|
|
} |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 添加库存(货柜)
|
|
|
|
/// </summary>
|
|
|
@ -2369,38 +2482,104 @@ namespace ICSSoft.DataProject |
|
|
|
/// <param name="WorkPoint"></param>
|
|
|
|
/// <param name="cmd"></param>
|
|
|
|
/// <param name="language"></param>
|
|
|
|
public static void ContainerBind(string LotNo, string ContainerCode, string ContainerType, string LocationCode, string User, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language) |
|
|
|
public static void ContainerBind(string LotNo, string ContainerCode, string ContainerType, string LocationCode,string RecomendBinCode, string User, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
///添加日志
|
|
|
|
string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}')
|
|
|
|
BEGIN |
|
|
|
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{3}") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
IF NOT EXISTS (SELECT * FROM ICSContainerLot WHERE ContainerID= |
|
|
|
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}')) |
|
|
|
BEGIN |
|
|
|
update ICSContainer set LocationCode='{4}',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 |
|
|
|
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, ContainerType, LocationCode); |
|
|
|
if (ContainerType != "窄巷道叉车(木托盘)") |
|
|
|
{ |
|
|
|
string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}')
|
|
|
|
BEGIN |
|
|
|
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{3}") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
IF NOT EXISTS (SELECT * FROM ICSContainerLot WHERE ContainerID= |
|
|
|
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}')) |
|
|
|
BEGIN |
|
|
|
update ICSContainer set LocationCode='{4}',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 |
|
|
|
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, ContainerType, LocationCode); |
|
|
|
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
{ |
|
|
|
throw new Exception("容器:" + ContainerCode + "与条码:" + LotNo + "绑定失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new Exception("料架:" + ContainerCode + "与条码:" + LotNo + "绑定失败!"); |
|
|
|
string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}')
|
|
|
|
BEGIN |
|
|
|
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{3}") + @"',16,1); |
|
|
|
RETURN |
|
|
|
END |
|
|
|
IF NOT EXISTS (SELECT * FROM ICSContainerLot WHERE ContainerID= |
|
|
|
(SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}')) |
|
|
|
BEGIN |
|
|
|
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 |
|
|
|
WHERE ContainerCode='{1}' AND WorkPoint='{2}' |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
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, ContainerType, LocationCode); |
|
|
|
|
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
{ |
|
|
|
throw new Exception("容器:" + ContainerCode + "与条码:" + LotNo + "绑定失败!"); |
|
|
|
} |
|
|
|
if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadForkLift"])) |
|
|
|
{ |
|
|
|
string ForkLiftUrl = System.Configuration.ConfigurationManager.AppSettings["ForkLiftUrl"]; |
|
|
|
string Year = DateTime.Now.Year.ToString(); |
|
|
|
string Month = DateTime.Now.Month.ToString().PadLeft(2, '0'); |
|
|
|
string Day = DateTime.Now.Day.ToString().PadLeft(2, '0'); |
|
|
|
string Hour = DateTime.Now.Hour.ToString().PadLeft(2, '0'); |
|
|
|
string Minute = DateTime.Now.Minute.ToString().PadLeft(2, '0'); |
|
|
|
string Second = DateTime.Now.Second.ToString().PadLeft(2, '0'); |
|
|
|
string InspectJosn = "{"; |
|
|
|
InspectJosn += "\"ID\":\"" + Year + Month + Day + Hour + Minute + Second + "\","; |
|
|
|
InspectJosn += "\"ForkliftCode\": \"" + ContainerCode + "\","; |
|
|
|
InspectJosn += "\"TaskType\": \"PTWY\","; |
|
|
|
InspectJosn += "\"DestBin\": \"" + RecomendBinCode + "\""; |
|
|
|
InspectJosn += "}"; |
|
|
|
RestHelper rest = new RestHelper(ForkLiftUrl, HttpVerb.POST); |
|
|
|
rest.PostData = InspectJosn; |
|
|
|
string strResult = rest.MakeRequest(); |
|
|
|
//string resultstr = HTTPHelper.Post(ERPUrl.AGVBineURL, InspectJosn);
|
|
|
|
ForkLiftStartTaskResultModel result = JsonConvert.DeserializeObject<ForkLiftStartTaskResultModel>(strResult); |
|
|
|
if (result.Ret == 1) |
|
|
|
{ |
|
|
|
sql = @"update ICSContainer set LocationCode='{2}',EATTRIBUTE1='已搬运' where ContainerCode='{0}' AND WorkPoint='{1}'"; |
|
|
|
sql = string.Format(sql, ContainerCode, WorkPoint, LocationCode); |
|
|
|
if (!DBHelper.ExecuteNonQuery(sql, cmd)) |
|
|
|
{ |
|
|
|
throw new Exception(language.GetNameByCode("WMSAPIInfo207"));//料架状态更新失败
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new Exception(result.RetMsg); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//else
|
|
|
|
//{
|
|
|
@ -2529,7 +2708,7 @@ namespace ICSSoft.DataProject |
|
|
|
/// <param name="WorkPoint"></param>
|
|
|
|
/// <param name="cmd"></param>
|
|
|
|
/// <param name="language"></param>
|
|
|
|
public static void CallAGVStartTask(string ContainerCode,string TransType, string LocationCode, string User, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language) |
|
|
|
public static void CallAGVStartTask(string ContainerCode, string TransType, string LocationCode, string User, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
xxxxxxxxxx