| | |
| | | |
| | | #region 空托回库 |
| | | |
| | | #region 记录 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_KTHK_RECORD) |
| | | { |
| | | // 只用于记录 |
| | | // 在同一线边货位的满托出库任务完成后执行 |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 空托入库 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_KTHK_KTRK) |
| | | { |
| | | // 空托入库的接驳位 |
| | |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 满托出库 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_MTCK) |
| | |
| | | |
| | | #endregion |
| | | |
| | | continue; |
| | | #region 带束 |
| | | |
| | | //未执行表示第一个任务 |
| | | if (task.CN_S_STATE == Constants.TaskState_NoExecuted) |
| | | #region 半成品/空托回库 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.DS_BCPKTHK) |
| | | { |
| | | //立库货位 |
| | | string lkBit = string.Empty; |
| | | //根据任务类型判断立库货位 |
| | | if (task.CN_S_TASK_TYPE == Constants.Out) |
| | | // 带束入库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.DSRK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | lkBit = task.CN_S_START_BIT; |
| | | // 创建第一条子任务 |
| | | ExecDS_BCPKTHK_AddSub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_TASK_TYPE == Constants.In) |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.CXJ_BCPHK_SUB_1) |
| | | { |
| | | lkBit = task.CN_S_END_BIT; |
| | | // 执行第一条子任务 |
| | | ExecDS_BCPKTHK_Sub1(task, connectBit); |
| | | } |
| | | else |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.CXJ_BCPHK_SUB_2) |
| | | { |
| | | throw new Exception("自管任务任务类型不正确"); |
| | | // 执行第二条子任务 |
| | | ExecDS_BCPKTHK_Sub2(task, connectBit); |
| | | } |
| | | |
| | | var locationBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = lkBit |
| | | }); |
| | | if (locationBit == null) |
| | | throw new Exception("未找到立库货位:" + lkBit); |
| | | var _bit = connectBits.Find(f => f.tunnel == Util.ToString(locationBit.CN_S_ROADWAY).Trim()); |
| | | if (_bit == null) |
| | | throw new Exception("未找到配置巷道:" + locationBit.CN_S_ROADWAY + "的接驳位"); |
| | | |
| | | var connectBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = _bit.bit |
| | | }); |
| | | if (connectBit == null) |
| | | throw new Exception("未找到接驳位货位:" + _bit.bit); |
| | | if (connectBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("接驳位:" + _bit.bit + "存在未执行完的任务"); |
| | | |
| | | //赋值接驳位 |
| | | task.CN_S_CONNECT_BIT = _bit.bit; |
| | | |
| | | //string postData = "{\"appCode\":\"" + Constants.appCode + "\",\"ruleName\":\"" + Constants.Rule_TransTaskNo + "\",\"orgId\":\"\",\"orgFlag\":\"0\"}"; |
| | | //string taskNo = WebApiManager.HttpAutoBom_Post("api/BillRule/GenBillNo", postData); |
| | | //if (string.IsNullOrEmpty(taskNo)) |
| | | // throw new Exception("任务号生成失败,请检查在AUTOBOM中是否配置转运任务号生成规则!"); |
| | | string taskNo = task.CN_S_TASK_NO + "_1"; |
| | | //创建第一个任务 |
| | | TN_WM_TASKEntity taskEntity = new TN_WM_TASKEntity() |
| | | { |
| | | CN_S_TASK_NO = taskNo, |
| | | CN_S_TRAY_CODE = task.CN_S_TRAY_CODE, |
| | | CN_S_START_BIT = task.CN_S_START_BIT, |
| | | CN_S_END_BIT = task.CN_S_CONNECT_BIT, |
| | | CN_S_STATE = Constants.TaskState_NoExecuted, |
| | | CN_S_BF_TASK_NO = "", |
| | | CN_S_AF_TASK_NO = "", |
| | | CN_S_STOCK_CODE = task.CN_S_STOCK_CODE, |
| | | CN_S_START_AREA = task.CN_S_START_AREA, |
| | | CN_S_END_AREA = connectBit.CN_S_AREA_CODE, |
| | | CN_N_PRIORITY = 1, |
| | | CN_S_CREATOR = "sys", |
| | | CN_S_CREATOR_BY = "sys", |
| | | CN_T_CREATE = DateTime.Now, |
| | | CN_T_MODIFY = DateTime.Now, |
| | | CN_S_REMARK = "", |
| | | //CN_C_IS_AUTO = transport.CN_C_IS_AUTO, |
| | | CN_S_TASK_FLAG = task.CN_S_TASK_TYPE == Constants.Out ? Constants.TaskFlag_LG : Constants.TaskFlag_AGV, |
| | | //CN_C_START_IS_CONTROL_QTY = transport.CN_C_START_IS_CONTROL_QTY, |
| | | //CN_C_END_IS_CONTROL_QTY = transport.CN_C_END_IS_CONTROL_QTY, |
| | | //CN_S_START_CONTROL_INV = transport.CN_S_START_CONTROL_INV, |
| | | //CN_S_END_CONTROL_INV = transport.CN_S_END_CONTROL_INV, |
| | | //CN_S_START_AREA_TYPE = transport.CN_S_START_AREA_TYPE, |
| | | //CN_S_END_AREA_TYPE = transport.CN_S_END_AREA_TYPE, |
| | | }; |
| | | var or = UseTransaction(trans => |
| | | { |
| | | //增加子任务 |
| | | CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity, trans); |
| | | //更新接驳位状态 |
| | | CreateDapperDAL<TN_WM_LOCATION_EXTEntity>().Update(new |
| | | { |
| | | CN_S_LOCATION_STATE = Constants.Location_State_OutLock |
| | | }, new |
| | | { |
| | | CN_S_LOCATION_CODE = taskEntity.CN_S_END_BIT |
| | | }, trans); |
| | | // 更新主任务接驳位 状态置为执行中 |
| | | CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_CONNECT_BIT = task.CN_S_CONNECT_BIT, |
| | | CN_S_STATE = Constants.TaskState_Executing |
| | | }, new |
| | | { |
| | | CN_S_TASK_NO = task.CN_S_TASK_NO |
| | | }, trans); |
| | | //立库任务 需要调用wcs接口 |
| | | if (taskEntity.CN_S_TASK_FLAG == Constants.TaskFlag_LG) |
| | | { |
| | | //to do... |
| | | #region 待测试 |
| | | //OperateResult re = new OtherSysApi().SendWcsCreateTask(taskEntity, _bit); |
| | | //if (!re.Success) |
| | | //{ |
| | | // throw new Exception(re.Msg); |
| | | //} |
| | | #endregion |
| | | } |
| | | else//agv任务 |
| | | { |
| | | //OperateResult re = new OtherSysApi().SendAmsCreateTask(taskEntity); |
| | | //if (!re.Success) |
| | | //{ |
| | | // throw new Exception(re.Msg); |
| | | //} |
| | | } |
| | | }); |
| | | if (!or.Success) throw new Exception(or.Msg); |
| | | } |
| | | else//执行一半的任务,开始创建第二个任务 |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.DS_BCPKTHK_SECOND) |
| | | { |
| | | //string postData = "{\"appCode\":\"" + Constants.appCode + "\",\"ruleName\":\"" + Constants.Rule_TransTaskNo + "\",\"orgId\":\"\",\"orgFlag\":\"0\"}"; |
| | | //string taskNo = WebApiManager.HttpAutoBom_Post("api/BillRule/GenBillNo", postData); |
| | | //if (string.IsNullOrEmpty(taskNo)) |
| | | // throw new Exception("任务号生成失败,请检查在AUTOBOM中是否配置转运任务号生成规则!"); |
| | | string taskNo = task.CN_S_TASK_NO + "_2"; |
| | | var connectBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | // 带束入库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.DSRK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | CN_S_LOCATION_CODE = task.CN_S_CONNECT_BIT |
| | | }); |
| | | var _bit = connectBits.Find(f => f.tunnel == Util.ToString(connectBit.CN_S_ROADWAY).Trim()); |
| | | if (_bit == null) |
| | | throw new Exception("未找到配置巷道:" + connectBit.CN_S_ROADWAY + "的接驳位"); |
| | | //创建第二个任务 |
| | | TN_WM_TASKEntity taskEntity = new TN_WM_TASKEntity() |
| | | { |
| | | CN_S_TASK_NO = taskNo, |
| | | CN_S_TRAY_CODE = task.CN_S_TRAY_CODE, |
| | | CN_S_START_BIT = task.CN_S_CONNECT_BIT, |
| | | CN_S_END_BIT = task.CN_S_END_BIT, |
| | | CN_S_STATE = Constants.TaskState_NoExecuted, |
| | | CN_S_BF_TASK_NO = "", |
| | | CN_S_AF_TASK_NO = "", |
| | | CN_S_STOCK_CODE = task.CN_S_STOCK_CODE, |
| | | CN_S_START_AREA = connectBit.CN_S_AREA_CODE, |
| | | CN_S_END_AREA = task.CN_S_END_AREA, |
| | | CN_N_PRIORITY = 1, |
| | | CN_S_CREATOR = "sys", |
| | | CN_S_CREATOR_BY = "sys", |
| | | CN_T_CREATE = DateTime.Now, |
| | | CN_T_MODIFY = DateTime.Now, |
| | | CN_S_REMARK = "", |
| | | //CN_C_IS_AUTO = transport.CN_C_IS_AUTO, |
| | | CN_S_TASK_FLAG = task.CN_S_TASK_TYPE == Constants.Out ? Constants.TaskFlag_AGV : Constants.TaskFlag_LG, |
| | | //CN_C_START_IS_CONTROL_QTY = transport.CN_C_START_IS_CONTROL_QTY, |
| | | //CN_C_END_IS_CONTROL_QTY = transport.CN_C_END_IS_CONTROL_QTY, |
| | | //CN_S_START_CONTROL_INV = transport.CN_S_START_CONTROL_INV, |
| | | //CN_S_END_CONTROL_INV = transport.CN_S_END_CONTROL_INV, |
| | | //CN_S_START_AREA_TYPE = transport.CN_S_START_AREA_TYPE, |
| | | //CN_S_END_AREA_TYPE = transport.CN_S_END_AREA_TYPE, |
| | | }; |
| | | |
| | | var or = UseTransaction(trans => |
| | | { |
| | | //增加子任务 |
| | | CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity, trans); |
| | | //更新接驳位状态 |
| | | CreateDapperDAL<TN_WM_LOCATION_EXTEntity>().Update(new |
| | | { |
| | | CN_S_LOCATION_STATE = Constants.Location_State_InLock |
| | | }, new |
| | | { |
| | | CN_S_LOCATION_CODE = taskEntity.CN_S_START_BIT |
| | | }, trans); |
| | | // 更新主任务接驳位 状态置为执行中 |
| | | CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_STATE = Constants.TaskState_Executing |
| | | }, new |
| | | { |
| | | CN_S_TASK_NO = task.CN_S_TASK_NO |
| | | }, trans); |
| | | |
| | | //立库任务 需要调用wcs接口 |
| | | if (taskEntity.CN_S_TASK_FLAG == Constants.TaskFlag_LG) |
| | | { |
| | | //to do... |
| | | #region 待测试 |
| | | //OperateResult re = new OtherSysApi().SendWcsCreateTask(taskEntity, _bit); |
| | | //if (!re.Success) |
| | | //{ |
| | | // throw new Exception(re.Msg); |
| | | //} |
| | | #endregion |
| | | } |
| | | else//agv任务 |
| | | { |
| | | //OperateResult re = new OtherSysApi().SendAmsCreateTask(taskEntity); |
| | | //if (!re.Success) |
| | | //{ |
| | | // throw new Exception(re.Msg); |
| | | //} |
| | | } |
| | | }); |
| | | if (!or.Success) throw new Exception(or.Msg); |
| | | // 创建第二条子任务 |
| | | ExecDS_BCPKTHK_AddSub2(task, connectBit); |
| | | } |
| | | } |
| | | ors.Add(OperateResult.Succeed("生成成功")); |
| | | |
| | | #endregion |
| | | |
| | | #region 满托出库 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.DS_MTCK) |
| | | { |
| | | // 带束出库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.DSCK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | // 创建两条并行子任务 |
| | | or = ExecCXJ_MTCK_Add(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.DS_MTCK_SUB_1) |
| | | { |
| | | // 执行第一条子任务 |
| | | or = ExecCXJ_MTCK_Sub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.DS_MTCK_SUB_2) |
| | | { |
| | | // 执行第二条任务 |
| | | or = ExecCXJ_MTCK_Sub2(task, connectBit); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | section = TaskSectionConstants.CXJ_MTCK; |
| | | break; |
| | | case "5": |
| | | section = TaskSectionConstants.DS_BCPKTHK; |
| | | break; |
| | | case "6": |
| | | section = TaskSectionConstants.DS_MTCK; |
| | | break; |
| | | } |
| | | // 创建WMS主任务 |
| | |
| | | return or; |
| | | } |
| | | /// <summary> |
| | | /// 执行成型机-半成品回库的第一条子任务 |
| | | /// 执行成型机-半成品回库的第二条子任务 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <param name="connectBit"></param> |
| | |
| | | |
| | | #region 半成品及空托回库 |
| | | |
| | | /// <summary> |
| | | /// 创建 成型机带束-半成品/空托回库 子任务一 |
| | | /// </summary> |
| | | public OperateResult ExecDS_BCPKTHK_AddSub1(TN_WM_TASKEntity task, ConnectBitDto bit) |
| | | { |
| | | OperateResult re = OperateResult.Error("未知错误"); |
| | | |
| | | try |
| | | { |
| | | var connectBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = bit.bit |
| | | }); |
| | | |
| | | if (connectBit == null) |
| | | throw new Exception("未找到接驳位货位:" + bit.bit); |
| | | if (connectBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("接驳位:" + bit.bit + "存在未执行完的任务"); |
| | | |
| | | // 线边->接驳位 |
| | | TN_WM_TASKEntity taskEntity1 = new TN_WM_TASKEntity() |
| | | { |
| | | CN_S_TASK_NO = task.CN_S_TASK_NO + "_1", |
| | | CN_S_TRAY_CODE = task.CN_S_TRAY_CODE, |
| | | CN_S_STATE = Constants.TaskState_NoExecuted, |
| | | CN_S_BF_TASK_NO = "", |
| | | CN_S_AF_TASK_NO = "", |
| | | CN_S_STOCK_CODE = task.CN_S_STOCK_CODE, |
| | | CN_S_START_AREA = task.CN_S_START_AREA, |
| | | CN_S_START_BIT = task.CN_S_START_BIT, |
| | | CN_S_END_AREA = connectBit.CN_S_AREA_CODE, |
| | | CN_S_END_BIT = connectBit.CN_S_LOCATION_CODE, |
| | | CN_N_PRIORITY = 1, |
| | | CN_S_CREATOR = "sys", |
| | | CN_S_CREATOR_BY = "sys", |
| | | CN_T_CREATE = DateTime.Now, |
| | | CN_T_MODIFY = DateTime.Now, |
| | | CN_S_REMARK = "", |
| | | CN_S_TASK_FLAG = Constants.TaskFlag_ZG, |
| | | CN_S_EXT1 = task.CN_S_TASK_NO, |
| | | CN_S_EXT2 = TaskFlagConstants.DS_BCPKTHK_SUB_1, |
| | | CN_S_EXT3 = "" |
| | | }; |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 创建成型机带束-半成品/空托回库-子任务一 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity1); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | | |
| | | // 主任务状态置为执行中 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_STATE = Constants.TaskState_Executing |
| | | }, new { CN_S_TASK_NO = task.CN_S_TASK_NO }, trans); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("创建成型机带束-半成品/空托回库子任务一失败,任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | |
| | | return re; |
| | | } |
| | | /// <summary> |
| | | /// 创建 成型机带束-半成品/空托回库 子任务二 |
| | | /// </summary> |
| | | public OperateResult ExecDS_BCPKTHK_AddSub2(TN_WM_TASKEntity task, ConnectBitDto bit) |
| | | { |
| | | OperateResult re = OperateResult.Error("未知错误"); |
| | | |
| | | try |
| | | { |
| | | var connectBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = bit.bit |
| | | }); |
| | | |
| | | if (connectBit == null) |
| | | throw new Exception("未找到接驳位货位:" + bit.bit); |
| | | if (connectBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("接驳位:" + bit.bit + "存在未执行完的任务"); |
| | | |
| | | // 接驳位->立库 |
| | | TN_WM_TASKEntity taskEntity2 = new TN_WM_TASKEntity() |
| | | { |
| | | CN_S_TASK_NO = task.CN_S_TASK_NO + "_2", |
| | | CN_S_TRAY_CODE = task.CN_S_TRAY_CODE, |
| | | CN_S_STATE = Constants.TaskState_NoExecuted, |
| | | CN_S_BF_TASK_NO = "", |
| | | CN_S_AF_TASK_NO = "", |
| | | CN_S_STOCK_CODE = task.CN_S_STOCK_CODE, |
| | | CN_S_START_AREA = connectBit.CN_S_AREA_CODE, |
| | | CN_S_START_BIT = connectBit.CN_S_LOCATION_CODE, |
| | | CN_S_END_AREA = task.CN_S_END_AREA, |
| | | CN_S_END_BIT = task.CN_S_END_BIT, |
| | | CN_N_PRIORITY = 1, |
| | | CN_S_CREATOR = "sys", |
| | | CN_S_CREATOR_BY = "sys", |
| | | CN_T_CREATE = DateTime.Now, |
| | | CN_T_MODIFY = DateTime.Now, |
| | | CN_S_REMARK = "", |
| | | CN_S_TASK_FLAG = Constants.TaskFlag_ZG, |
| | | CN_S_EXT1 = task.CN_S_TASK_NO, |
| | | CN_S_EXT2 = TaskFlagConstants.DS_BCPKTHK_SUB_2, |
| | | CN_S_EXT3 = "" |
| | | }; |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 创建成型机带束-半成品/空托回库子任务二 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity2); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | | |
| | | // 主任务状态置为执行中 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_STATE = Constants.TaskState_Executing |
| | | }, new { CN_S_TASK_NO = task.CN_S_TASK_NO }, trans); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("创建成型机带束-半成品/空托回库子任务二失败,任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | |
| | | return re; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 执行成型机带束-半成品/空托回库的第一条子任务 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <param name=""></param> |
| | | /// <returns></returns> |
| | | public OperateResult ExecDS_BCPKTHK_Sub1(TN_WM_TASKEntity task1, ConnectBitDto bit) |
| | | { |
| | | OperateResult or = OperateResult.Error("未知错误"); |
| | | |
| | | try |
| | | { |
| | | // 执行前检查货位状态 |
| | | // 接驳位 |
| | | var connectBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = bit.bit |
| | | }); |
| | | |
| | | if (connectBit == null) |
| | | throw new Exception("未找到接驳位货位:" + bit.bit); |
| | | if (connectBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("接驳位:" + bit.bit + "存在未执行完的任务"); |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 线边货位不管控 |
| | | |
| | | // 接驳位 预入库锁定 |
| | | CreateDapperDAL<TN_WM_LOCATION_EXTEntity>().Update(new |
| | | { |
| | | CN_S_LOCATION_STATE = Constants.Location_State_InLock |
| | | }, new { CN_S_LOCATION_CODE = bit.bit }, trans); |
| | | // 子任务一状态置为执行中 |
| | | or = CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_STATE = Constants.TaskState_Executing |
| | | }, new { CN_S_TASK_NO = task1.CN_S_TASK_NO }, trans); |
| | | // 发送Ams任务 |
| | | Log.Detail(LogType.LogPara("调用AMS接口执行任务"), "任务信息:" + JsonConvert.SerializeObject(task1)); |
| | | or = BLLCreator.Create<OtherSysApi>().SendAmsTask(task1); |
| | | Log.Detail(LogType.LogPara("调用AMS接口执行任务"), "执行结果:" + JsonConvert.SerializeObject(or)); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("执行成型机带束-半成品/空托回库子任务一失败,任务编号=" + task1.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | return or; |
| | | } |
| | | /// <summary> |
| | | /// 执行成型机带束-半成品/空托回库的第二条子任务 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <param name="connectBit"></param> |
| | | /// <returns></returns> |
| | | public OperateResult ExecDS_BCPKTHK_Sub2(TN_WM_TASKEntity task2, ConnectBitDto bit) |
| | | { |
| | | OperateResult or = OperateResult.Error("未知错误"); |
| | | |
| | | try |
| | | { |
| | | // 执行前检查货位状态 |
| | | // 接驳位 |
| | | var connectBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = bit.bit |
| | | }); |
| | | |
| | | if (connectBit == null) |
| | | throw new Exception("未找到接驳位货位:" + bit.bit); |
| | | if (connectBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("接驳位:" + bit.bit + "存在未执行完的任务"); |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 接驳位 预出库锁定 |
| | | CreateDapperDAL<TN_WM_LOCATION_EXTEntity>().Update(new |
| | | { |
| | | CN_S_LOCATION_STATE = Constants.Location_State_OutLock |
| | | }, new { CN_S_LOCATION_CODE = bit.bit }, trans); |
| | | // 立库预入库锁定 |
| | | CreateDapperDAL<TN_WM_LOCATION_EXTEntity>().Update(new |
| | | { |
| | | CN_S_LOCATION_STATE = Constants.Location_State_InLock |
| | | }, new { CN_S_LOCATION_CODE = task2.CN_S_END_BIT }, trans); |
| | | |
| | | // 子任务二状态置为执行中 |
| | | or = CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_STATE = Constants.TaskState_Executing |
| | | }, new { CN_S_TASK_NO = task2.CN_S_TASK_NO }, trans); |
| | | // 发送Wcs任务 |
| | | Log.Detail(LogType.LogPara("调用WCS接口执行任务"), "任务信息:" + JsonConvert.SerializeObject(task2)); |
| | | or = BLLCreator.Create<OtherSysApi>().SendWcsCreateTask(task2); |
| | | Log.Detail(LogType.LogPara("调用WCS接口执行任务"), "执行结果:" + JsonConvert.SerializeObject(or)); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("执行成型机带束-半成品/空托回库子任务二失败,任务编号=" + task2.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | return or; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 满托出库 |
| | | |
| | | /// <summary> |
| | | /// 创建满托出库并行子任务 |
| | | /// </summary> |
| | | public OperateResult ExecDS_MTCK_Add(TN_WM_TASKEntity task, ConnectBitDto bit) |
| | | { |
| | | OperateResult re = OperateResult.Error("未知错误"); |
| | | |
| | | try |
| | | { |
| | | // 接驳位 |
| | | var connectBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = bit.bit |
| | | }); |
| | | // 准备点 |
| | | var readyBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = bit.readybit |
| | | }); |
| | | if (connectBit == null) |
| | | throw new Exception("未找到接驳位货位:" + bit.bit); |
| | | if (connectBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("接驳位:" + bit.bit + "存在未执行完的任务"); |
| | | |
| | | if (readyBit == null) |
| | | throw new Exception("未找到准备点货位:" + bit.readybit); |
| | | if (readyBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("准备点货位:" + bit.readybit + "存在未执行完的任务"); |
| | | |
| | | // 立库->接驳位 |
| | | TN_WM_TASKEntity taskEntity1 = new TN_WM_TASKEntity() |
| | | { |
| | | CN_S_TASK_NO = task.CN_S_TASK_NO + "_1", |
| | | CN_S_TRAY_CODE = task.CN_S_TRAY_CODE, |
| | | CN_S_STATE = Constants.TaskState_NoExecuted, |
| | | CN_S_BF_TASK_NO = "", |
| | | CN_S_AF_TASK_NO = "", |
| | | CN_S_STOCK_CODE = task.CN_S_STOCK_CODE, |
| | | CN_S_START_AREA = task.CN_S_START_AREA, |
| | | CN_S_START_BIT = task.CN_S_START_BIT, |
| | | CN_S_END_AREA = connectBit.CN_S_AREA_CODE, |
| | | CN_S_END_BIT = connectBit.CN_S_LOCATION_CODE, |
| | | CN_N_PRIORITY = 1, |
| | | CN_S_CREATOR = "sys", |
| | | CN_S_CREATOR_BY = "sys", |
| | | CN_T_CREATE = DateTime.Now, |
| | | CN_T_MODIFY = DateTime.Now, |
| | | CN_S_REMARK = "", |
| | | CN_S_TASK_FLAG = Constants.TaskFlag_ZG, |
| | | CN_S_EXT1 = task.CN_S_TASK_NO, |
| | | CN_S_EXT2 = TaskFlagConstants.DS_MTCK_SUB_1, |
| | | CN_S_EXT3 = "" |
| | | }; |
| | | // 准备点->线边 |
| | | TN_WM_TASKEntity taskEntity2 = new TN_WM_TASKEntity() |
| | | { |
| | | CN_S_TASK_NO = task.CN_S_TASK_NO + "_2", |
| | | CN_S_TRAY_CODE = task.CN_S_TRAY_CODE, |
| | | CN_S_STATE = Constants.TaskState_NoExecuted, |
| | | CN_S_BF_TASK_NO = "", |
| | | CN_S_AF_TASK_NO = "", |
| | | CN_S_STOCK_CODE = task.CN_S_STOCK_CODE, |
| | | CN_S_START_AREA = readyBit.CN_S_AREA_CODE, |
| | | CN_S_START_BIT = readyBit.CN_S_LOCATION_CODE, |
| | | CN_S_END_AREA = task.CN_S_END_AREA, |
| | | CN_S_END_BIT = task.CN_S_END_BIT, |
| | | CN_N_PRIORITY = 1, |
| | | CN_S_CREATOR = "sys", |
| | | CN_S_CREATOR_BY = "sys", |
| | | CN_T_CREATE = DateTime.Now, |
| | | CN_T_MODIFY = DateTime.Now, |
| | | CN_S_REMARK = "", |
| | | CN_S_TASK_FLAG = Constants.TaskFlag_ZG, |
| | | CN_S_EXT1 = task.CN_S_TASK_NO, |
| | | CN_S_EXT2 = TaskFlagConstants.DS_MTCK_SUB_2, |
| | | CN_S_EXT3 = "" |
| | | }; |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 创建成型机带束-满托出库子任务一 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity1); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | | |
| | | // 创建成型机带束-满托出库子任务二 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity2); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | | |
| | | // 主任务状态置为执行中 记录接驳位 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_STATE = Constants.TaskState_Executing, |
| | | CN_S_CONNECT_BIT = bit.bit |
| | | }, new { CN_S_TASK_NO = task.CN_S_TASK_NO }, trans); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("创建成型机带束-满托出库子任务失败,主任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | |
| | | return re; |
| | | } |
| | | /// <summary> |
| | | /// 执行满托出库的第一条子任务 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <param name=""></param> |
| | | /// <returns></returns> |
| | | public OperateResult ExecDS_MTCK_Sub1(TN_WM_TASKEntity task1, ConnectBitDto bit) |
| | | { |
| | | OperateResult or = OperateResult.Error("未知错误"); |
| | | |
| | | try |
| | | { |
| | | // 执行前检查货位状态 |
| | | // 接驳位 |
| | | var connectBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = bit.bit |
| | | }); |
| | | if (connectBit == null) |
| | | throw new Exception("未找到接驳位货位:" + bit.bit); |
| | | if (connectBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("接驳位:" + bit.bit + "存在未执行完的任务"); |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 立库 预出库锁定 |
| | | CreateDapperDAL<TN_WM_LOCATION_EXTEntity>().Update(new |
| | | { |
| | | CN_S_LOCATION_STATE = Constants.Location_State_OutLock |
| | | }, new { CN_S_LOCATION_CODE = task1.CN_S_START_BIT }, trans); |
| | | // 接驳位 预入库锁定 |
| | | CreateDapperDAL<TN_WM_LOCATION_EXTEntity>().Update(new |
| | | { |
| | | CN_S_LOCATION_STATE = Constants.Location_State_InLock |
| | | }, new { CN_S_LOCATION_CODE = bit.bit }, trans); |
| | | // 子任务1状态置为执行中 |
| | | or = CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_STATE = Constants.TaskState_Executing |
| | | }, new { CN_S_TASK_NO = task1.CN_S_TASK_NO }, trans); |
| | | // 发送Wcs任务 |
| | | Log.Detail(LogType.LogPara("调用WCS接口执行任务"), "任务信息:" + JsonConvert.SerializeObject(task1)); |
| | | or = BLLCreator.Create<OtherSysApi>().SendWcsCreateTask(task1); |
| | | Log.Detail(LogType.LogPara("调用WCS接口执行任务"), "执行结果:" + JsonConvert.SerializeObject(or)); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("执行成型机带束-满托出库子任务一失败,任务编号=" + task1.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | return or; |
| | | } |
| | | /// <summary> |
| | | /// 执行满托出库的第二条子任务 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <param name="connectBit"></param> |
| | | /// <returns></returns> |
| | | public OperateResult ExecDS_MTCK_Sub2(TN_WM_TASKEntity task2, ConnectBitDto bit) |
| | | { |
| | | OperateResult or = OperateResult.Error("未知错误"); |
| | | |
| | | try |
| | | { |
| | | // 执行前检查货位状态 |
| | | // 接驳位的准备点货位 |
| | | var readyBit = BLLCreator.CreateDapper<TN_WM_LOCATION_EXTEntity>().GetSingleEntity(new |
| | | { |
| | | CN_S_LOCATION_CODE = bit.readybit |
| | | }); |
| | | if (readyBit == null) |
| | | throw new Exception("未找到准备点货位:" + bit.readybit); |
| | | if (readyBit.CN_S_LOCATION_STATE != Constants.Location_State_Normal) |
| | | throw new Exception("准备点货位:" + bit.readybit + "存在未执行完的任务"); |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 准备点 预出库锁定 |
| | | CreateDapperDAL<TN_WM_LOCATION_EXTEntity>().Update(new |
| | | { |
| | | CN_S_LOCATION_STATE = Constants.Location_State_OutLock |
| | | }, new { CN_S_LOCATION_CODE = bit.readybit }, trans); |
| | | // 线边货位不管控 |
| | | |
| | | // 子任务2状态置为执行中 |
| | | or = CreateDapperDAL<TN_WM_TASKEntity>().Update(new |
| | | { |
| | | CN_S_STATE = Constants.TaskState_Executing |
| | | }, new { CN_S_TASK_NO = task2.CN_S_TASK_NO }, trans); |
| | | // 发送Ams任务 |
| | | Log.Detail(LogType.LogPara("调用AMS接口执行任务"), "任务信息:" + JsonConvert.SerializeObject(task2)); |
| | | or = BLLCreator.Create<OtherSysApi>().SendAmsTask(task2); |
| | | Log.Detail(LogType.LogPara("调用AMS接口执行任务"), "执行结果:" + JsonConvert.SerializeObject(or)); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("执行成型机带束-满托出库子任务二失败,任务编号=" + task2.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | return or; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | |
| | | public static string CXJ_KTRK = "成型机-空托入库"; |
| | | |
| | | #endregion |
| | | |
| | | #region 带束 |
| | | |
| | | /// <summary> |
| | | /// 带束-半成品/空托回库 |
| | | /// </summary> |
| | | public static string DS_BCPKTHK = "成型机带束-半成品/空托回库"; |
| | | /// <summary> |
| | | /// 带束-半成品/空托回库-第二阶段 |
| | | /// </summary> |
| | | public static string DS_BCPKTHK_SECOND = "成型机带束-半成品/空托回库-第二阶段"; |
| | | /// <summary> |
| | | /// 带束-满托出库 |
| | | /// </summary> |
| | | public static string DS_MTCK = "成型机带束-满托出库"; |
| | | |
| | | #endregion |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public static string CXJ_MTCK_SUB_2 = "成型机-满托出库-子任务二"; |
| | | |
| | | #endregion |
| | | |
| | | #region 带束 |
| | | |
| | | /// <summary> |
| | | /// 成型机带束-半成品/空托回库-子任务一 |
| | | /// </summary> |
| | | public static string DS_BCPKTHK_SUB_1 = "成型机带束-半成品/空托回库-子任务一"; |
| | | /// <summary> |
| | | /// 成型机带束-半成品/空托回库-子任务二 |
| | | /// </summary> |
| | | public static string DS_BCPKTHK_SUB_2 = "成型机带束-半成品/空托回库-子任务二"; |
| | | /// <summary> |
| | | /// 成型机带束-满托出库-子任务一 |
| | | /// </summary> |
| | | public static string DS_MTCK_SUB_1 = "成型机带束-满托出库-子任务一"; |
| | | /// <summary> |
| | | /// 成型机带束-满托出库-子任务二 |
| | | /// </summary> |
| | | public static string DS_MTCK_SUB_2 = "成型机带束-满托出库-子任务二"; |
| | | |
| | | #endregion |
| | | } |
| | | } |