| | |
| | | } |
| | | #endregion |
| | | |
| | | // CN_S_EXT1:业务类型 |
| | | // CN_S_EXT2:子任务标识 |
| | | // CN_S_EXT3:任务执行阶段 |
| | | public void SelfManageTask() |
| | | { |
| | | try |
| | |
| | | CN_S_STATE = new List<string>() { Constants.TaskState_NoExecuted, Constants.TaskState_CompleteHalf, Constants.TaskState_CompletePart } |
| | | }); |
| | | |
| | | // 接驳位配置 |
| | | var connectBitStr = JsonHelper.GetValue("connectBit"); |
| | | if (string.IsNullOrEmpty(connectBitStr)) |
| | | throw new Exception("未找到配置:connectBit"); |
| | | |
| | | List<OperateResult> ors = new List<OperateResult>(); |
| | | foreach (var task in tasks) |
| | | { |
| | | try |
| | | { |
| | | var connectBitStr = JsonHelper.GetValue("connectBit"); |
| | | if (string.IsNullOrEmpty(connectBitStr)) |
| | | throw new Exception("未找到配置:connectBit"); |
| | | var connectBits = JsonConvert.DeserializeObject<List<ConnectBitDto>>(connectBitStr); |
| | | |
| | | OperateResult or = OperateResult.Error("未知错误"); |
| | | if (task.CN_S_EXT1 == BusinessTypeConstants.BCP_MTRK)// 半成品满托入库流程 |
| | | |
| | | #region 半成品 |
| | | |
| | | #region 空托出库 |
| | | |
| | | if (task.CN_S_EXT3 == TaskSectionConstants.BCP_KTCK) |
| | | { |
| | | // -空托出库阶段 |
| | | if (task.CN_S_EXT3 == TaskSectionConstants.KTCK) |
| | | // 空托出库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.KTCK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.KTCK); |
| | | // 创建两条并行子任务 |
| | | if (string.IsNullOrEmpty(task.CN_S_EXT2)) |
| | | { |
| | | or = ExecKTCK(task, connectBit); |
| | | } |
| | | // sub_1 -用于向WCS发送空托->接驳位的出库任务 |
| | | else if (task.CN_S_EXT2 == "ktck_sub_1") |
| | | { |
| | | or = ExecKTCK_Sub1(task, connectBit); |
| | | } |
| | | // sub_2 - 用于向AMS发送准备点->终点的空托搬运任务 |
| | | else if (task.CN_S_EXT2 == "ktck_sub_2") |
| | | { |
| | | or = ExecKTCK_Sub2(task, connectBit); |
| | | } |
| | | or = ExecBCP_KTCK_Add(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.BCP_MTRK) |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.BCP_KTCK_SUB_1) |
| | | { |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.MTRK); |
| | | // 创建第一条子任务 |
| | | if (string.IsNullOrEmpty(task.CN_S_EXT2)) |
| | | { |
| | | or = ExecBCP_MTRK_AddSub1(task, connectBit); |
| | | } |
| | | // 执行第一条子任务 |
| | | else if (task.CN_S_EXT2 == "bcp_mtrk_sub_1") |
| | | { |
| | | or = ExecBCP_MTRK_Sub1(task, connectBit); |
| | | } |
| | | // 创建第二条子任务 |
| | | else if (task.CN_S_EXT2 == "bcp_mtrk_sub_1_completed") |
| | | { |
| | | or = ExecBCP_MTRK_AddSub2(task, connectBit); |
| | | } |
| | | // 执行第二条子任务 |
| | | else if (task.CN_S_EXT2 == "bcp_mtrk_sub_2") |
| | | { |
| | | or = ExecBCP_MTRK_Sub2(task, connectBit); |
| | | } |
| | | or = ExecBCP_KTCK_Sub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.BCP_KTCK_SUB_2) |
| | | { |
| | | // 执行第二条任务 |
| | | or = ExecBCP_KTCK_Sub2(task, connectBit); |
| | | } |
| | | } |
| | | else |
| | | |
| | | #endregion |
| | | |
| | | #region 满托入库 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.BCP_MTRK) |
| | | { |
| | | or = OperateResult.Error("未知的业务类型:task.CN_S_EXT1=" + task.CN_S_EXT1); |
| | | // 满托入库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.MTRK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | // 创建第一条子任务 |
| | | or = ExecBCP_MTRK_AddSub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.BCP_MTRK_SUB_1) |
| | | { |
| | | // 执行第一条子任务 |
| | | or = ExecBCP_MTRK_Sub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.BCP_MTRK_SUB_2) |
| | | { |
| | | // 执行第二条子任务 |
| | | or = ExecBCP_MTRK_Sub2(task, connectBit); |
| | | } |
| | | } |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.BCP_MTRK_SECOND) |
| | | { |
| | | // 满托入库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.MTRK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | // 创建第二条子任务 |
| | | or = ExecBCP_MTRK_AddSub2(task, connectBit); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 成型机 |
| | | |
| | | #region 半成品回库 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_BCPHK) |
| | | { |
| | | // 满托入库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.MTRK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | // 创建第一条子任务 |
| | | ExecCXJ_BCPHK_AddSub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.CXJ_BCPHK_SUB_1) |
| | | { |
| | | // 执行第一条子任务 |
| | | ExecCXJ_BCPHK_Sub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.CXJ_BCPHK_SUB_2) |
| | | { |
| | | // 执行第二条子任务 |
| | | ExecCXJ_BCPHK_Sub2(task, connectBit); |
| | | } |
| | | } |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_BCPHK_SECOND) |
| | | { |
| | | // 满托入库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.MTRK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | // 创建第二条子任务 |
| | | ExecCXJ_BCPHK_AddSub2(task, connectBit); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 空托回库 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_KTHK_RECORD) |
| | | { |
| | | // 只用于记录 |
| | | // 在同一线边货位的满托出库任务完成后执行 |
| | | } |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_KTHK_KTRK) |
| | | { |
| | | // 空托入库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.KTRK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | // 创建第一条子任务 |
| | | ExecCXJ_KTHK_KTRK_AddSub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.CXJ_BCPHK_SUB_1) |
| | | { |
| | | // 执行第一条子任务 |
| | | ExecCXJ_KTHK_KTRK_Sub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.CXJ_BCPHK_SUB_2) |
| | | { |
| | | // 执行第二条子任务 |
| | | ExecCXJ_KTHK_KTRK_Sub2(task, connectBit); |
| | | } |
| | | } |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_KTHK_KTRK_SECOND) |
| | | { |
| | | // 空托入库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.KTRK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | // 创建第二条子任务 |
| | | ExecCXJ_KTHK_KTRK_AddSub2(task, connectBit); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 满托出库 |
| | | |
| | | else if (task.CN_S_EXT3 == TaskSectionConstants.CXJ_MTCK) |
| | | { |
| | | // 满托出库的接驳位 |
| | | var connectBit = connectBits.Find(f => f.tasktype == ConnectBitConstants.MTCK); |
| | | if (task.CN_S_EXT2 == TaskFlagConstants.ROOT) |
| | | { |
| | | // 创建两条并行子任务 |
| | | or = ExecCXJ_MTCK_Add(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.CXJ_MTCK_SUB_1) |
| | | { |
| | | // 执行第一条子任务 |
| | | or = ExecCXJ_MTCK_Sub1(task, connectBit); |
| | | } |
| | | else if (task.CN_S_EXT2 == TaskFlagConstants.CXJ_MTCK_SUB_2) |
| | | { |
| | | // 执行第二条任务 |
| | | or = ExecCXJ_MTCK_Sub2(task, connectBit); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | continue; |
| | | |
| | |
| | | switch (task.BUSI_TYPE) |
| | | { |
| | | case "1": |
| | | section = TaskSectionConstants.KTCK; |
| | | section = TaskSectionConstants.BCP_KTCK; |
| | | break; |
| | | case "2": |
| | | section = TaskSectionConstants.CXJ_BCPHK; |
| | | break; |
| | | case "3": |
| | | section = TaskSectionConstants.CXJ_KTHK_RECORD; |
| | | break; |
| | | case "4": |
| | | section = TaskSectionConstants.CXJ_MTCK; |
| | | break; |
| | | case "5": |
| | | break; |
| | |
| | | CN_T_MODIFY = DateTime.Now, |
| | | CN_S_REMARK = "", |
| | | CN_S_TASK_FLAG = Constants.TaskFlag_ZG, |
| | | CN_S_EXT1 = task.BUSI_TYPE, |
| | | CN_S_EXT2 = "", |
| | | CN_S_EXT1 = "", |
| | | CN_S_EXT2 = TaskFlagConstants.ROOT, |
| | | CN_S_EXT3 = section |
| | | }; |
| | | UseTransaction(trans => |
| | |
| | | } |
| | | } |
| | | |
| | | #region 半成品-满托入库 |
| | | #region 货位状态 |
| | | |
| | | // 接驳位锁定状态:预入库锁定、预出库锁定 |
| | | // 接驳位空闲状态:正常 |
| | | // 准备点状态同接驳位 |
| | | // 立库锁定状态: 预入库锁定、预出库锁定 |
| | | // 立库空闲状态: 空(入库前)、满(出库前) |
| | | |
| | | // 创建任务前、执行任务前 检查货位状态 |
| | | // 完成任务后 清除货位状态 |
| | | // 执行失败后 如何处理? |
| | | |
| | | #endregion |
| | | |
| | | #region 半成品 |
| | | |
| | | #region 空托出库 |
| | | |
| | | /// <summary> |
| | | /// 创建空托出库并行子任务 |
| | | /// </summary> |
| | | public OperateResult ExecKTCK(TN_WM_TASKEntity task, ConnectBitDto bit) |
| | | public OperateResult ExecBCP_KTCK_Add(TN_WM_TASKEntity task, ConnectBitDto bit) |
| | | { |
| | | // 空托出库和满托入库是反向的 |
| | | 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_END_AREA, |
| | | CN_S_START_BIT = task.CN_S_END_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_EXT1, |
| | | CN_S_EXT2 = "ktck_sub_1" |
| | | }; |
| | | // 准备点->工位 |
| | | 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_START_AREA, |
| | | CN_S_END_BIT = task.CN_S_START_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_EXT1, |
| | | CN_S_EXT2 = "ktck_sub_2" |
| | | }; |
| | | |
| | | 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_END_AREA, |
| | | CN_S_START_BIT = task.CN_S_END_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.BCP_KTCK_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_START_AREA, |
| | | CN_S_END_BIT = task.CN_S_START_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.BCP_KTCK_SUB_2, |
| | | CN_S_EXT3 = "" |
| | | }; |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 创建空托出库子任务1 |
| | | // 创建半成品-空托出库子任务一 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity1); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | | // 创建空托出库子任务2 |
| | | |
| | | // 创建半成品-空托出库子任务二 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity2); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("创建空托出库子任务失败,主任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | OperateResult.Error("创建半成品-空托出库子任务失败,主任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | |
| | | return re; |
| | |
| | | /// <param name="task"></param> |
| | | /// <param name=""></param> |
| | | /// <returns></returns> |
| | | public OperateResult ExecKTCK_Sub1(TN_WM_TASKEntity task1, ConnectBitDto connectBit) |
| | | public OperateResult ExecBCP_KTCK_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 = connectBit.bit }, trans); |
| | | }, 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任务 |
| | | or = BLLCreator.Create<OtherSysApi>().SendWcsCreateTask(task1, connectBit); |
| | | 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("执行空托出库子任务1失败,任务编号=" + task1.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | OperateResult.Error("执行半成品-空托出库子任务一失败,任务编号=" + task1.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | return or; |
| | | } |
| | |
| | | /// <param name="task"></param> |
| | | /// <param name="connectBit"></param> |
| | | /// <returns></returns> |
| | | public OperateResult ExecKTCK_Sub2(TN_WM_TASKEntity task2, ConnectBitDto connectBit) |
| | | public OperateResult ExecBCP_KTCK_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 = connectBit.readybit }, trans); |
| | | }, 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("执行空托出库子任务2失败,任务编号=" + task2.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | OperateResult.Error("执行半成品-空托出库子任务二失败,任务编号=" + task2.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | return or; |
| | | } |
| | |
| | | |
| | | #region 满托入库 |
| | | |
| | | #region 主任务 |
| | | |
| | | /// <summary> |
| | | /// 创建 半成品-满托入库 子任务1 |
| | | /// 创建 半成品-满托入库 子任务一 |
| | | /// </summary> |
| | | public OperateResult ExecBCP_MTRK_AddSub1(TN_WM_TASKEntity task, ConnectBitDto bit) |
| | | { |
| | | 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 + "_3", |
| | | 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_EXT1, |
| | | CN_S_EXT2 = "bcp_mtrk_sub_1" |
| | | }; |
| | | 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 + "_3", |
| | | 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.BCP_MTRK_SUB_1, |
| | | CN_S_EXT3 = "" |
| | | }; |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 创建满托入库子任务1 |
| | | // 创建半成品-满托入库子任务一 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity1); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("创建满托入库子任务1失败,任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | OperateResult.Error("创建半成品-满托入库子任务一失败,任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | |
| | | return re; |
| | | } |
| | | /// <summary> |
| | | /// 创建 半成品-满托入库 子任务2 |
| | | /// 创建 半成品-满托入库 子任务二 |
| | | /// </summary> |
| | | public OperateResult ExecBCP_MTRK_AddSub2(TN_WM_TASKEntity task, ConnectBitDto bit) |
| | | { |
| | | 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 + "_4", |
| | | 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_EXT1, |
| | | CN_S_EXT2 = "bcp_mtrk_sub_2" |
| | | }; |
| | | 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 + "_4", |
| | | 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.BCP_MTRK_SUB_2, |
| | | CN_S_EXT3 = "" |
| | | }; |
| | | |
| | | UseTransaction(trans => |
| | | { |
| | | // 创建满托入库子任务2 |
| | | // 创建满托入库子任务二 |
| | | re = CreateDapperDAL<TN_WM_TASKEntity>().Add(taskEntity2); |
| | | if (!re.Success) |
| | | throw new Exception(re.Msg); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | OperateResult.Error("创建满托入库子任务2失败,任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | OperateResult.Error("创建半成品-满托入库子任务二失败,任务编号=" + task.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | |
| | | return re; |
| | |
| | | /// <param name="task"></param> |
| | | /// <param name=""></param> |
| | | /// <returns></returns> |
| | | public OperateResult ExecBCP_MTRK_Sub1(TN_WM_TASKEntity task1, ConnectBitDto connectBit) |
| | | public OperateResult ExecBCP_MTRK_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 = connectBit.bit }, trans); |
| | | // 子任务1状态置为执行中 |
| | | }, 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("执行满托入库子任务1失败,任务编号=" + task1.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | OperateResult.Error("执行半成品-满托入库子任务一失败,任务编号=" + task1.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | return or; |
| | | } |
| | |
| | | /// <param name="task"></param> |
| | | /// <param name="connectBit"></param> |
| | | /// <returns></returns> |
| | | public OperateResult ExecBCP_MTRK_Sub2(TN_WM_TASKEntity task2, ConnectBitDto connectBit) |
| | | public OperateResult ExecBCP_MTRK_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 = connectBit.bit }, trans); |
| | | // 子任务2状态置为执行中 |
| | | }, 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任务 |
| | | or = BLLCreator.Create<OtherSysApi>().SendWcsCreateTask(task2, connectBit); |
| | | 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("执行满托入库子任务2失败,任务编号=" + task2.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | OperateResult.Error("执行半成品-满托入库子任务二失败,任务编号=" + task2.CN_S_TASK_NO + ",错误信息:" + ex.Message); |
| | | } |
| | | return or; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 成型机 |
| | | |
| | | #region 半成品回库 |
| | | |
| | | /// <summary> |
| | | /// 创建 成型机-半成品回库 子任务一 |
| | | /// </summary> |
| | | public OperateResult ExecCXJ_BCPHK_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.CXJ_BCPHK_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 ExecCXJ_BCPHK_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.CXJ_BCPHK_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 ExecCXJ_BCPHK_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 ExecCXJ_BCPHK_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 ExecCXJ_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.CXJ_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.CXJ_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 ExecCXJ_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 ExecCXJ_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 |
| | | |
| | | #region 回托回库-空托入库 |
| | | |
| | | /// <summary> |
| | | /// 创建 成型机-空托回库-空托入库 子任务一 |
| | | /// </summary> |
| | | public OperateResult ExecCXJ_KTHK_KTRK_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.CXJ_KTHK_KTRK_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 ExecCXJ_KTHK_KTRK_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.CXJ_KTHK_KTRK_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 ExecCXJ_KTHK_KTRK_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 ExecCXJ_KTHK_KTRK_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 |
| | | |
| | | #endregion |
| | | |
| | | #region 带束 |
| | | |
| | | #region 半成品及空托回库 |
| | | |
| | | #endregion |
| | | |
| | | #region 满托出库 |
| | | |
| | | #endregion |
| | | |
| | |
| | | public static string CXJ_DSMTCK = "6"; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任务阶段常量 |
| | | /// </summary> |
| | | public class TaskSectionConstants |
| | | { |
| | | /// <summary> |
| | | /// 空托出库 |
| | | /// 任务完成 |
| | | /// </summary> |
| | | public static string KTCK = "空托出库"; |
| | | public static string COMPLETE = "任务完成"; |
| | | |
| | | #region 半成品 |
| | | |
| | | /// <summary> |
| | | /// 半成品-空托出库 |
| | | /// </summary> |
| | | public static string BCP_KTCK = "空托出库"; |
| | | /// <summary> |
| | | /// 半成品-满托入库 |
| | | /// </summary> |
| | | public static string BCP_MTRK = "半成品-满托入库"; |
| | | /// <summary> |
| | | /// 半成品-满托入库-第二阶段 |
| | | /// </summary> |
| | | public static string BCP_MTRK_SECOND = "半成品-满托入库-第二阶段"; |
| | | |
| | | #endregion |
| | | |
| | | #region 成型机 |
| | | |
| | | /// <summary> |
| | | /// 成型机-半成品回库 |
| | | /// </summary> |
| | | public static string CXJ_BCPHK = "成型机-半成品回库"; |
| | | |
| | | /// <summary> |
| | | /// 成型机-半成品回库-第二阶段 |
| | | /// </summary> |
| | | public static string CXJ_BCPHK_SECOND = "成型机-半成品回库-第二阶段"; |
| | | /// <summary> |
| | | /// 成型机-空托回库-记录阶段 |
| | | /// </summary> |
| | | public static string CXJ_KTHK_RECORD = "成型机-空托回库-记录阶段"; |
| | | /// <summary> |
| | | /// 成型机-空托回库-入库阶段 |
| | | /// </summary> |
| | | public static string CXJ_KTHK_KTRK = "成型机-空托回库-入库阶段"; |
| | | /// <summary> |
| | | /// 成型机-空托回库-入库阶段-第二阶段 |
| | | /// </summary> |
| | | public static string CXJ_KTHK_KTRK_SECOND = "成型机-空托回库-入库阶段-第二阶段"; |
| | | /// <summary> |
| | | /// 成型机-满托出库 |
| | | /// </summary> |
| | | public static string CXJ_MTCK = "成型机-满托出库"; |
| | | /// <summary> |
| | | /// 成型机-空托入库 |
| | | /// </summary> |
| | | public static string CXJ_KTRK = "成型机-空托入库"; |
| | | |
| | | #endregion |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任务标识常量 |
| | | /// </summary> |
| | | public class TaskFlagConstants |
| | | { |
| | | /// <summary> |
| | | /// 主任务 |
| | | /// </summary> |
| | | public static string ROOT = "主任务"; |
| | | |
| | | #region 半成品 |
| | | |
| | | /// <summary> |
| | | /// 半成品-空托出库子任务一 |
| | | /// </summary> |
| | | public static string BCP_KTCK_SUB_1 = "半成品-空托出库-子任务一"; |
| | | /// <summary> |
| | | /// 半成品-空托出库子任务二 |
| | | /// </summary> |
| | | public static string BCP_KTCK_SUB_2 = "半成品-空托出库-子任务二"; |
| | | /// <summary> |
| | | /// 半成品-满托入库子任务一 |
| | | /// </summary> |
| | | public static string BCP_MTRK_SUB_1 = "半成品-满托入库-子任务一"; |
| | | /// <summary> |
| | | /// 半成品-满托入库子任务二 |
| | | /// </summary> |
| | | public static string BCP_MTRK_SUB_2 = "半成品-满托入库-子任务二"; |
| | | |
| | | #endregion |
| | | |
| | | #region 成型机 |
| | | |
| | | /// <summary> |
| | | /// 成型机-半成品回库-子任务一 |
| | | /// </summary> |
| | | public static string CXJ_BCPHK_SUB_1 = "成型机-半成品回库-子任务一"; |
| | | /// <summary> |
| | | /// 成型机-半成品回库-子任务二 |
| | | /// </summary> |
| | | public static string CXJ_BCPHK_SUB_2 = "成型机-半成品回库-子任务一"; |
| | | /// <summary> |
| | | /// 成型机-空托回库-记录任务 |
| | | /// </summary> |
| | | public static string CXJ_KTHK_RECORD = "成型机-空托回库-记录任务"; |
| | | /// <summary> |
| | | /// 成型机-空托回库-入库阶段-子任务一 |
| | | /// </summary> |
| | | public static string CXJ_KTHK_KTRK_SUB_1 = "成型机-空托回库-入库阶段-子任务一"; |
| | | /// <summary> |
| | | /// 成型机-空托回库-入库阶段-子任务二 |
| | | /// </summary> |
| | | public static string CXJ_KTHK_KTRK_SUB_2 = "成型机-空托回库-入库阶段-子任务二"; |
| | | /// <summary> |
| | | /// 成型机-满托出库-子任务一 |
| | | /// </summary> |
| | | public static string CXJ_MTCK_SUB_1 = "成型机-满托出库-子任务一"; |
| | | /// <summary> |
| | | /// 成型机-满托出库-子任务二 |
| | | /// </summary> |
| | | public static string CXJ_MTCK_SUB_2 = "成型机-满托出库-子任务二"; |
| | | |
| | | #endregion |
| | | } |
| | | } |