using System; using System.Collections.Generic; using System.Text; using WIDESEA.Common; using WIDESEA.Core.ManageUser; using WIDESEA.Entity.DomainModels; using WIDESEA.Services.Repositories; namespace WIDESEA.Services.Services { public partial class CommonFunction { /// /// 创建空托盘入库功能 /// /// 目的货位 /// 托盘码 /// dbcontext /// public static Dt_taskinfo AddWMSTask_EmptyPalletIn(Dt_locationinfo locationinfo, string barcode) { Dt_general_info general_Info = Dt_general_infoRepository.Instance.FindFirst(x => true); string currentModel = general_Info.general_box_empty_flag; if (!"empty".Equals(currentModel)) throw new Exception("当前非空托盘入库模式,请切换模式后进行入库."); string targetAddress = GetInboundAddress(general_Info, locationinfo.location_layer); Dt_taskinfo taskinfo = new Dt_taskinfo(); taskinfo.task_id = Guid.NewGuid(); taskinfo.task_type = TaskType.TaskType_Empty_Pallet_Inbound.ToString(); taskinfo.task_state = TaskState.TaskState_Create.ToString(); taskinfo.task_barcode = barcode; //taskinfo.task_sn = currentModel; //该条任务时处于正常模式下的任务还是应急模式下的任务 taskinfo.task_materielid = "100"; //起始货位,就是目的站台 taskinfo.task_fromlocationid = targetAddress; //目的货位 taskinfo.task_tolocationid = locationinfo.location_id; //起始站台 taskinfo.task_beginstation = "20101"; //目的站台 taskinfo.task_endstation = targetAddress; taskinfo.task_grade = 0; taskinfo.task_isunpacked = false; taskinfo.task_creator = UserContext.Current.UserTrueName; taskinfo.task_createtime = DateTime.Now; Dt_taskinfoRepository.Instance.Add(taskinfo, true); return taskinfo; } /// /// 创建【组盘实托】入库功能 /// /// 目的货位 /// 托盘码 /// dbcontext /// public static Dt_taskinfo AddWMSTask_BoxPalletIn(Dt_locationinfo locationinfo, string barcode, string materielid, string goodsQrCode, string task_materielType) { Dt_general_info general_Info = Dt_general_infoRepository.Instance.FindFirst(x => true); string currentModel = general_Info.general_box_empty_flag; if (!"box".Equals(currentModel)) throw new Exception("当前非轴承入库模式,请切换模式后进行入库."); string targetAddress = GetInboundAddress(general_Info, locationinfo.location_layer); Dt_taskinfo taskinfo = new Dt_taskinfo(); taskinfo.task_id = Guid.NewGuid(); taskinfo.task_type = TaskType.TaskType_Box_Pallet_Inbound.ToString(); taskinfo.task_state = TaskState.TaskState_Create.ToString(); taskinfo.task_barcode = barcode; taskinfo.task_sn = goodsQrCode; taskinfo.task_materielid = materielid; //起始货位,就是目的站台 taskinfo.task_fromlocationid = LayerToStation.OutLayerToStation(locationinfo.location_layer); //目的货位 taskinfo.task_tolocationid = locationinfo.location_id; //起始站台 taskinfo.task_beginstation = "20101"; //目的站台 taskinfo.task_endstation = LayerToStation.OutLayerToStation(locationinfo.location_layer); taskinfo.task_grade = 0; taskinfo.task_isunpacked = false; taskinfo.task_createtime = DateTime.Now; taskinfo.task_creator = UserContext.Current.UserTrueName; taskinfo.task_materielType = task_materielType; Dt_taskinfoRepository.Instance.Add(taskinfo, true); return taskinfo; } /// /// 创建空托盘出库功能 /// /// 目的货位 /// 托盘码 /// dbcontext /// public static Dt_taskinfo AddWMSTask_EmptyPalletOut(Dt_locationinfo locationinfo, string barcode, string weight, Dt_general_info general_Info) { string targetAddress = GetOutboundAddress(general_Info, locationinfo.location_layer); Dt_taskinfo taskinfo = new Dt_taskinfo(); taskinfo.task_id = Guid.NewGuid(); taskinfo.task_type = TaskType.TaskType_Empty_Pallet_Outbound.ToString(); taskinfo.task_state = TaskState.TaskState_Create.ToString(); taskinfo.task_barcode = barcode; taskinfo.task_materielid = "100"; //起始货位 taskinfo.task_fromlocationid = locationinfo.location_id; //目的货位 taskinfo.task_tolocationid = targetAddress; //起始站台 taskinfo.task_beginstation = targetAddress; //目的站台 taskinfo.task_endstation = "20101"; taskinfo.task_grade = 0; taskinfo.task_isunpacked = false; taskinfo.task_creator = UserContext.Current.UserTrueName; taskinfo.task_createtime = DateTime.Now; taskinfo.task_weight = weight; Dt_taskinfoRepository.Instance.Add(taskinfo, true); return taskinfo; } /// /// 获取层 /// /// /// /// public static string GetInboundAddress(Dt_general_info general_Info, int layer) { string targetAddress = string.Empty; if ("应急模式".Equals(general_Info.general_inline_current_model)) { if ("left".Equals(general_Info.general_bak_2)) targetAddress = LayerToStation.EmptyPalletOutLayerToStation(layer); else if ("right".Equals(general_Info.general_bak_2)) targetAddress = LayerToStation.OutLayerToStation(layer); else throw new Exception("应急模式找不到可用提升机."); } else targetAddress = LayerToStation.OutLayerToStation(layer); return targetAddress; } public static string GetOutboundAddress(Dt_general_info general_Info, int layer) { string targetAddress = string.Empty; if ("应急模式".Equals(general_Info.general_inline_current_model)) { if ("left".Equals(general_Info.general_bak_2)) targetAddress = LayerToStation.EmptyPalletOutLayerToStation(layer); else if ("right".Equals(general_Info.general_bak_2)) targetAddress = LayerToStation.OutLayerToStation(layer); else throw new Exception("应急模式找不到可用提升机."); } else targetAddress = LayerToStation.EmptyPalletOutLayerToStation(layer); return targetAddress; } } }