| | |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Security.Cryptography; |
| | | using static HH.WCS.Mobox3.YNJT_BZP.util.Settings; |
| | | |
| | | namespace HH.WCS.Mobox3.YNJT_BZP.process { |
| | | internal class TaskProcess { |
| | |
| | | /// <param name="forkliftNo"></param> |
| | | /// <param name="extData"></param> |
| | | internal static void OperateReq(string no, int state, string forkliftNo, string extData) { |
| | | LogHelper.Info($"开始安全请求,任务号:{no},请求码:{state},小车号:{forkliftNo}", "AGV"); |
| | | var cst = WCSHelper.GetTask(no); |
| | | var mst = WMSHelper.GetWmsTask(cst.S_OP_CODE); |
| | | var endLoc = LocationHelper.GetLoc(cst.S_END_LOC); |
| | | if (state == 1101) { |
| | | //请求取货, |
| | | |
| | | } |
| | | if (state == 1102) { |
| | | //请求卸货, |
| | | bool isCan = false; |
| | | |
| | | |
| | | if (endLoc != null) |
| | | var taskAction = WCSHelper.getActionRecord(no, state); |
| | | if (taskAction != null) |
| | | { |
| | | LogHelper.Info($"再次安全请求,查询设备是否反馈", "AGV"); |
| | | if (taskAction.N_S_STATUS == 1) |
| | | { |
| | | // 1.查看终点货位放货条件是否满足 |
| | | var waitLoc = Settings.getAgvWaitLoc(endLoc.S_CODE); |
| | | if (waitLoc != null) |
| | | LogHelper.Info($"再次安全请求,设备已反馈", "AGV"); |
| | | NDCApi.ChangeOrderParam(no, 8, "1"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"首次进行安全请求,任务号:{no},请求码:{state},小车号:{forkliftNo}", "AGV"); |
| | | bool result = false; |
| | | if (state == 1101) |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "1"); //请求取货, |
| | | } |
| | | if (state == 1102) |
| | | { |
| | | //请求卸货, |
| | | var container = ContainerHelper.GetCntr(cst.S_CNTR_CODE); |
| | | // 胎圈入库,下发母拖出库任务 \ 帘布、内衬入库,下发托盘回库任务 |
| | | if (cst.S_TYPE.Contains("入库") && endLoc.N_LOCK_STATE == 0) |
| | | { |
| | | if (container.N_TYPE != 6 ) |
| | | { |
| | | if (endLoc.N_CURRENT_NUM == 1) |
| | | { |
| | | var locCntrRels = LocationHelper.GetLocCntr(endLoc.S_CODE); |
| | | if (locCntrRels != null && locCntrRels.Count > 0) |
| | | { |
| | | var container1 = ContainerHelper.GetCntr(locCntrRels[0].S_CNTR_CODE); |
| | | if (container1.N_TYPE == 0) |
| | | { |
| | | LogHelper.Info("非胎圈入库,接驳位存在母拖,下发母拖入库任务", "AGV"); |
| | | ApiHelper.baseTrayInStockAgv(endLoc.S_CODE, mst.S_CODE); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result = true; |
| | | } |
| | | } |
| | | |
| | | // 胎圈入库 |
| | | if (container.N_TYPE == 6 ) |
| | | { |
| | | if (endLoc.N_CURRENT_NUM == 0) |
| | | { |
| | | LogHelper.Info("胎圈入库,接驳位缺少母拖,下发母拖出库任务", "AGV"); |
| | | ApiHelper.baseTrayOutStockAgv(endLoc.S_CODE, mst.S_CODE); |
| | | } |
| | | else if (endLoc.N_CURRENT_NUM == 1) |
| | | { |
| | | var locCntrRels = LocationHelper.GetLocCntr(endLoc.S_CODE); |
| | | if (locCntrRels != null && locCntrRels.Count > 0) |
| | | { |
| | | var container1 = ContainerHelper.GetCntr(locCntrRels[0].S_CNTR_CODE); |
| | | if (container1.N_TYPE == 0) |
| | | { |
| | | result = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 请求WCS是否允许放货 |
| | | if (result) |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "2"); // 请求放货 |
| | | } |
| | | |
| | | if (result) |
| | | { |
| | | //根据终点判断,是cb02的入口,判断内存中状态(要状态时间),允许卸货,通知agv改参数 |
| | | var dic = new Dictionary<string, string>(); |
| | |
| | | dic.Add("ParamNo", "8"); |
| | | dic.Add("Param1", "1"); |
| | | NDC.ChangeOrder(dic); |
| | | //改完参数车子就会自己卸货 |
| | | } |
| | | else |
| | | { |
| | | var container = ContainerHelper.GetCntr(cst.S_CNTR_CODE); |
| | | if (container != null && container.N_TYPE == 6) |
| | | { |
| | | isCan = false; |
| | | var locCntrs = LocationHelper.GetLocCntr(endLoc.S_CODE); |
| | | if (endLoc.N_CURRENT_NUM == 1 && locCntrs.Count > 0) |
| | | { |
| | | var container1 = ContainerHelper.GetCntr(locCntrs[0].S_CNTR_CODE); |
| | | if (container1.N_TYPE == 0) |
| | | { |
| | | isCan = true; |
| | | } |
| | | } |
| | | if (!isCan) |
| | | { |
| | | LogHelper.Info("胎圈请求放货失败,母拖没有到位", "AGV"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 2.查询输送线 是否允许放货 |
| | | |
| | | } |
| | | |
| | | if (isCan) |
| | | if (state == 1103) |
| | | { |
| | | //根据终点判断,是cb02的入口,判断内存中状态(要状态时间),允许卸货,通知agv改参数 |
| | | var dic = new Dictionary<string, string>(); |
| | | //< Req >< Order No = 'TN2302020002' ParamNo = '18' Param1 = '12' /></ Req > |
| | | dic.Add("No", no); |
| | | dic.Add("ParamNo", "8"); |
| | | dic.Add("Param1", "1"); |
| | | NDC.ChangeOrder(dic); |
| | | //改完参数车子就会自己卸货 |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "3"); //取货完成允许离开 |
| | | } |
| | | } |
| | | if (state == 1103) |
| | | { |
| | | // 取货完成请求离开 |
| | | // 安全退出 |
| | | // 胎圈出库,下发母拖回库任务 |
| | | var locCntrRels = LocationHelper.GetLocCntrRel(cst.S_START_LOC); |
| | | if (locCntrRels.Count > 0) |
| | | if (state == 1104) |
| | | { |
| | | var container = ContainerHelper.GetCntr(locCntrRels[0].S_CNTR_CODE); |
| | | if (container != null && container.N_TYPE == 0) |
| | | { |
| | | ApiHelper.baseTrayInStockAgv(cst.S_START_LOC, cst.S_OP_CODE); |
| | | } |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "4"); //放货完成允许离开 |
| | | } |
| | | } |
| | | if (state == 1104) |
| | | { |
| | | // 放货完成请求离开 |
| | | |
| | | // 安全请求发送成功,添加任务动作记录 |
| | | if (result) |
| | | { |
| | | WCSHelper.AddActionRecord(no, state, forkliftNo, extData); |
| | | LogHelper.Info($"首次进行安全请求成功", "AGV"); |
| | | } |
| | | } |
| | | } |
| | | |