diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs index 0779a2c..7465538 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs @@ -7428,9 +7428,9 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; + Result res = new Result(); try { - Result res = new Result(); string PostionCode = ""; foreach (ICSContainerBind item in JsonData) { @@ -7457,6 +7457,20 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer { //呼叫AGV开始搬运任务 PostionCode = ICSWareHouseLotInfoService.GetAGVTaskPosition(item.ContainerCode, item.IsOverLoad, item.User, item.WorkPoint, cmd, language); + if (item.IsOverLoad == true) + { + #region 获取字典维护的超托目标点位 + string sql = @" select F_Define2 from Sys_SRM_ItemsDetail + where F_ItemName='AGV超托点位' + AND F_Define1='{0}' AND F_Define4='{1}'"; + sql = string.Format(sql, PostionCode, item.WorkPoint); + DataTable chkdt = DBHelper.SQlReturnData(sql, cmd); + if (chkdt.Rows.Count == 0) + { + throw new Exception("超托入库区域:" + PostionCode + "未维护默认点位,无法入库!"); + } + #endregion + } } } res.Success = true; @@ -7468,7 +7482,9 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer if (cmd.Transaction != null) cmd.Transaction.Rollback(); log.Error(ex.Message); - throw new Exception(ex.Message); + res.Success = false; + res.Message = ex.Message; + return res; } finally { @@ -7625,7 +7641,7 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer } else { - if (chkdt.Rows[0]["EATTRIBUTE1"].ToString()=="出库") + if (chkdt.Rows[0]["EATTRIBUTE1"].ToString() == "出库") { logsql = @"update ICSAGVTaskLog set MTIME=GETDATE(),EATTRIBUTE2='已完成',EATTRIBUTE3='{1}' WHERE ID='{0}'"; @@ -8867,7 +8883,7 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer #endregion #region 调用AGV搬运任务失败后调用,用于删除入库时的库位占用 - public static AGVResult AGVTaskEnd(AGVCallBackModel JsonData, string Jsonstr) + public static Result LocationOccupyCancel(ICSContainerInfo JsonData) { var language = LanguageHelper.GetName("WMSAPIInfo"); DataTable table = new DataTable(); @@ -8881,94 +8897,37 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer cmd.Transaction = sqlTran; try { - #region 记录AGV回调日志 - string logsql = @"INSERT INTO ICSAGVCallBackLog - (ID,ReqCode,InputJSON,Result,Message,EATTRIBUTE1) - SELECT NEWID(),'{0}','{1}','','',GETDATE()"; - logsql = string.Format(logsql, JsonData.taskCode, Jsonstr); - DBHelper.ExecuteNonQuery(connString, CommandType.Text, logsql); - #endregion - AGVResult res = new AGVResult(); - if (string.IsNullOrEmpty(JsonData.taskCode)) - { - msg = "传入AGV任务ID不能为空!"; - } - if (string.IsNullOrEmpty(JsonData.podCode)) + Result res = new Result(); + if (string.IsNullOrEmpty(JsonData.ContainerCode)) { - msg = "传入料架不能为空!"; - } - if (string.IsNullOrEmpty(JsonData.currentPositionCode)) - { - msg = "传入入库具体点位不能为空!"; + msg = "传入料架编码不能为空!"; } if (msg != "") { - #region 更新AGV回调日志 - logsql = @"update ICSAGVCallBackLog set Result='失败',Message='{1}' - where ReqCode='{0}'"; - logsql = string.Format(logsql, JsonData.taskCode, msg); - DBHelper.ExecuteNonQuery(connString, CommandType.Text, logsql); - #endregion - res.code = "1"; - res.message = msg;// "接口调用失败!"; - res.reqCode = JsonData.reqCode; + res.Success = false; + res.Message = msg;// "接口调用失败!"; return res; } else { - string chksql = @"select EATTRIBUTE1 from ICSAGVTaskLog - where ID='{0}'"; - chksql = string.Format(chksql, JsonData.taskCode); - DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd); - if (chkdt.Rows.Count == 0) - { - #region 更新AGV回调日志 - logsql = @"update ICSAGVCallBackLog set Result='失败',Message='{1}' - where ReqCode='{0}'"; - logsql = string.Format(logsql, JsonData.taskCode, "传入TaskCode不存在!"); - DBHelper.ExecuteNonQuery(connString, CommandType.Text, logsql); - #endregion - res.code = "1"; - res.message = "传入TaskCode不存在!";// "接口调用失败!"; - res.reqCode = JsonData.reqCode; - return res; - } - else - { - if (chkdt.Rows[0]["EATTRIBUTE1"].ToString() == "出库") - { - logsql = @"update ICSAGVTaskLog set MTIME=GETDATE(),EATTRIBUTE2='已完成',EATTRIBUTE3='{1}' - WHERE ID='{0}'"; - logsql = string.Format(logsql, JsonData.taskCode, JsonData.currentPositionCode); - DBHelper.ExecuteNonQuery(connString, CommandType.Text, logsql); - } - else - { - ICSWareHouseLotInfoService.ActionAGVTaskEnd(JsonData.taskCode, JsonData.currentPositionCode, JsonData.taskCode, JsonData.action, JsonData.podCode, cmd, language); - } - } + string sql = @"update ICSLocation set Isoccupy='' + where Isoccupy='{0}' and WorkPoint='{1}'"; + sql = string.Format(sql, JsonData.ContainerCode, JsonData.WorkPoint); + DBHelper.ExecuteNonQuery(connString, CommandType.Text, sql); } cmd.Transaction.Commit(); - res.code = "0"; - res.message = "成功";// "接口调用成功!"; - res.reqCode = JsonData.reqCode; + res.Success = true; + res.Message = "成功";// "接口调用成功!"; return res; } catch (Exception ex) { - #region 更新AGV回调日志 - string logsql = @"update ICSAGVCallBackLog set Result='失败',Message='{1}' - where ReqCode='{0}'"; - logsql = string.Format(logsql, JsonData.reqCode, ex.Message); - DBHelper.ExecuteNonQuery(connString, CommandType.Text, logsql); - #endregion if (cmd.Transaction != null) cmd.Transaction.Rollback(); log.Error(ex.Message); - AGVResult res = new AGVResult(); - res.code = "1"; - res.message = ex.Message;// "接口调用失败!"; - res.reqCode = JsonData.reqCode; + Result res = new Result(); + res.Success = false; + res.Message = ex.Message;// "接口调用失败!"; return res; } finally diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs b/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs index d33fbc9..408e454 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs @@ -2730,7 +2730,7 @@ namespace ICSSoft.WebAPI.Controllers #region 获取AGV搬运的目标位置 /// - /// 呼叫AGV开始搬运任务 + /// 获取AGV搬运的目标位置 /// /// /// @@ -3124,6 +3124,42 @@ namespace ICSSoft.WebAPI.Controllers } #endregion + #region 调用AGV搬运任务失败后调用,用于删除入库时的库位占用 + /// + /// 调用AGV搬运任务失败后调用,用于删除入库时的库位占用 + /// + /// + /// + [HttpPost] + [Route("api/LocationOccupyCancel/Post")] + public HttpResponseMessage LocationOccupyCancel([FromBody] object JsonData) + { + + log.Info("合并传入值" + JsonData); + try + { + if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]") + { + ICSContainerInfo model = new ICSContainerInfo(); + model = JsonConvert.DeserializeObject(JsonData.ToString()); + res = ICSSubmitService.LocationOccupyCancel(model); + } + } + catch (Exception ex) + { + log.Error("转换失败:" + ex.ToString()); + res.Success = false; + res.Message = ex.Message; + } + finally + { + str = JsonConvert.SerializeObject(res); + result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json"); + } + return result; + } + #endregion + #region 临时接口(用于单独过账SAP接口 不经过WMS) /// /// 临时接口(用于单独过账SAP接口 不经过WMS)