/// <summary> /// /// </summary> /// <param name="palletCode"></param> /// <param name="houseName"></param> /// <param name="putawayStationName"></param> /// <param name="isAssign"></param> /// <param name="targetStation"></param> /// <param name="taskType">任务类型</param> /// <param name="manageID"></param> /// <param name="restr"></param> /// <returns></returns> public static bool CreatePutawayManageTask(string palletCode, string houseName, string putawayStationName, bool isAssign, string targetStation, EnumManageTaskType taskType, ref string manageID, ref string restr) { ManageModel manage = new ManageModel(); manage.Mange_CreateTime = DateTime.Now; WH_WareHouseModel house = bllWareHouse.GetModelByName(houseName); if (house == null) { restr = "库房对象为空!"; return(false); } WH_Station_LogicModel stationCell = bllStationLogic.GetStationByName(house.WareHouse_ID, putawayStationName); if (stationCell == null) { restr = "上架站台不存在!"; return(false); } WH_WareHouseModel wareHouse = bllWareHouse.GetModelByName(houseName); if (wareHouse == null) { restr = "库房名称错误!"; return(false); } View_StockListModel stock = bllViewStockList.GetModelByPalletCode(palletCode, EnumCellType.货位.ToString()); if (stock != null) { restr = "库存中已经有此托盘条码!"; return(false); } View_CellModel targetCell = null; if (isAssign == true)//分配货位要做校验 { string[] targetPos = targetStation.Split('-'); if (targetPos == null || targetPos.Length != 2) { restr = "指定货位格式错误!"; return(false); } string cellName = targetPos[0]; string cellPos = targetPos[1]; targetCell = bllViewCell.GetCell(wareHouse.WareHouse_ID, cellName, cellPos); if (targetCell == null || targetCell.Cell_Child_Status != EnumCellStatus.空闲.ToString() || targetCell.Cell_Child_Run_Status != EnumGSTaskStatus.完成.ToString()) { restr = "当前货位不可用!"; return(false); } } else { targetCell = bllViewCell.ApplyCell(wareHouse.WareHouse_ID); } if (targetCell == null) { restr = "库房已满,没有货位可以申请了!"; return(false); } if (targetCell.Shelf_Type == EnumShelfType.双深.ToString() && targetCell.Cell_Chlid_Position == EnumCellPos.前.ToString())//双深工位如果选中前面的工位要判断后面是否有料 { View_CellModel backCell = bllViewCell.GetCell(wareHouse.WareHouse_ID, targetCell.Cell_Name, EnumCellPos.后.ToString()); if (backCell != null && backCell.Cell_Child_Run_Status == EnumGSTaskStatus.完成.ToString() && backCell.Cell_Child_Status == EnumCellStatus.空闲.ToString()) { restr = "此货位为双深工位 ,需要先送入后面的货位再入前面的货位!"; return(false); } if (backCell != null && backCell.Cell_Child_Run_Status == EnumGSTaskStatus.锁定.ToString()) { restr = "此货位为双深工位 ,需要先送入后面的货位再入前面的货位,后面的工位处于锁定状态!"; return(false); } } if (targetCell.Cell_Child_Run_Status != EnumGSTaskStatus.完成.ToString() && targetCell.Cell_Child_Status != EnumCellStatus.空闲.ToString()) { restr = "指定货位已经被占用!"; return(false); } manage.Mange_ID = Guid.NewGuid().ToString(); manage.Mange_Start_Cell_ID = stationCell.Cell_Child_ID; manage.Mange_End_Cell_ID = targetCell.Cell_Chlid_ID; manage.Mange_Status = EnumManageTaskStatus.待执行.ToString(); manage.Manage_BreakDown_Status = "待分解"; manage.Mange_Stock_Barcode = palletCode; if (taskType == EnumManageTaskType.空托盘上架) { manage.Mange_Type_ID = "7";// EnumManageTaskType.空托盘上架.ToString(); } else if (taskType == EnumManageTaskType.架) { manage.Mange_Type_ID = "6";//上架 } else { restr = "任务类型错误!"; return(false); } View_StockListModel vslm = bllViewStockList.GetModelByPalletCode(palletCode, EnumCellType.配盘工位.ToString());// if (vslm == null) { restr = "没有配盘,请查看!"; return(false); } EnumOrderType orderType = EnumOrderType.计划; if (vslm.Plan_List_ID == "-1")//无计划的 { manage.Plan_ID = "-1"; orderType = EnumOrderType.非计划; } else { orderType = EnumOrderType.计划; View_Plan_StockListModel plan = bllViewPalnStockList.GetModelByPalletCode(palletCode); if (plan == null) { restr = "当前库存没有对应计划!"; return(false); } manage.Plan_ID = plan.Plan_ID; } manageID = manage.Mange_ID; bllManage.Add(manage); bool status = CreatePutawayManageListTask(manage.Mange_ID, orderType, palletCode, ref restr); if (status == true) { restr += "生成托盘[" + palletCode + "]上架任务成功:终点:" + houseName + targetCell.Cell_Name + targetCell.Cell_Chlid_Position; UpdateCellStatus(targetCell.Cell_Chlid_ID, EnumCellStatus.空闲, EnumGSTaskStatus.锁定, EnumGSOperate.入库); return(true); } else { restr += "生成托盘[" + palletCode + "]上架任务失败:终点:" + houseName + targetCell.Cell_Name + targetCell.Cell_Chlid_Position; return(false); } }
/// <summary> /// wcs向wms请求任务 /// </summary> /// <param name="applyTask"></param> /// <returns></returns> public ResposeData RequireTask(RequireTaskModel requireTask) { ResposeData response = new ResposeData(); if (requireTask == null) { response.Status = false; response.Describe = "请求任务对象为空!"; return(response); } try { ManageModel existMana = bllManage.GetModelByPalletCode(requireTask.PalletCode); if (existMana != null) { response.Status = false; response.Describe = "此托盘任务已经生成!"; return(response); } ManageModel manage = new ManageModel(); manage.Mange_ID = Guid.NewGuid().ToString(); WH_Station_LogicModel stationLogic = bllStationLogic.GetModelByCellID(requireTask.RequireDevice.DeviceCode); if (stationLogic == null) { response.Status = false; response.Describe = "请求设备编号错误!"; return(response); } if (requireTask.RequireType == EnumRequireTaskType.空筐入库.ToString())//入库请求设备对应指定库房编码,库房编码和堆垛机编码一致 { //通过stationLogic得知申请的是哪个库房的入库 View_CellModel targetModel = bllViewCell.ApplyCell(stationLogic.WareHouse_ID); if (targetModel == null) { response.Status = false; response.Describe = "已经没有货位可以申请了!"; return(response); } manage.Mange_Stock_Barcode = requireTask.PalletCode; manage.Manage_BreakDown_Status = "FALSE"; manage.Mange_End_Cell_ID = targetModel.Cell_Chlid_ID; manage.Mange_Full_Flag = "0"; manage.Mange_Start_Cell_ID = requireTask.RequireDevice.DeviceCode; manage.Mange_Status = EnumManageTaskStatus.待执行.ToString(); manage.Mange_Type_ID = "7";//空托盘上架 } else if (requireTask.RequireType == EnumRequireTaskType.空筐出库.ToString()) { View_CellModel emptyPalletCell = bllViewCell.GetEmptyPalletCell(); if (emptyPalletCell == null) { response.Status = false; response.Describe = "已经没有空托盘可以申请了!"; return(response); } manage.Manage_BreakDown_Status = "FALSE"; manage.Mange_End_Cell_ID = requireTask.RequireDevice.DeviceCode; manage.Mange_Full_Flag = "0"; manage.Mange_Start_Cell_ID = emptyPalletCell.Cell_Chlid_ID; manage.Mange_Status = EnumManageTaskStatus.待执行.ToString(); manage.Mange_Stock_Barcode = requireTask.PalletCode; manage.Mange_Type_ID = "9";//空托盘下架 } else { response.Status = false; response.Describe = "请求任务类型错误!"; return(response); } bllManage.Add(manage); response.Status = true; response.Describe = "任务请求成功!"; return(response); } catch (Exception ex) { response.Status = false; response.Describe = "任务请求失败!" + ex.Message; return(response); } }