Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn
# Conflicts:
# 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs
# 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs
# 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs
# 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/MES/MesController.cs
已添加10个文件
已修改34个文件
已删除3个文件
| | |
| | | task.DeviceCode = stationManger.StackerCraneCode; |
| | | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | } |
| | | else if (item.TaskType == TaskTypeEnum.MesOutbound.ObjToInt() && item.RoadWay.Contains("ZH")) |
| | | { |
| | | task.NextAddress = stationManger.StackerCraneStationCode; |
| | | task.DeviceCode = stationManger.StackerCraneCode; |
| | | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | task.NextAddress = taskTypeGroup == TaskTypeGroup.InboundGroup ? task.TargetAddress : router.NextPosi; |
| | |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è·¯ç±é
置信æ¯"); |
| | | } |
| | | router = routers.FirstOrDefault(); |
| | | |
| | | task.NextAddress = router?.StartPosi ?? ""; |
| | | task.DeviceCode = item.RoadWay; |
| | | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | |
| | | |
| | | //} |
| | | #endregion |
| | | //2016åºåºç«å°ä»»å¡å®æ |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | if (conveyorLineSignalRead.STB) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | |
| | | Thread.Sleep(500); |
| | | device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode); |
| | | _taskService.TaskCompleted(conveyorLineInfoRead.TaskNum); |
| | | } |
| | | } |
| | | else if (item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt()) |
| | | { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Quartz; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_Tasks.HoisterJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | /// <summary> |
| | | /// é»çä»å°é¢ç« |
| | | /// </summary> |
| | | [DisallowConcurrentExecution] |
| | | public class GroundStationJob_ZH : JobBase, IJob |
| | | { |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | |
| | | public GroundStationJob_ZH(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _taskRepository = taskRepository; |
| | | _stationMangerRepository = stationMangerRepository; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | OtherDevice device = (OtherDevice)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | try |
| | | { |
| | | if (device == null) |
| | | { |
| | | WriteError(nameof(GroundStationJob_CSJ), "è°åº¦é误,设å¤å¯¹è±¡ä¼ å¼ä¸ºnull"); |
| | | return Task.CompletedTask; |
| | | } |
| | | List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList(); |
| | | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode); |
| | | foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) |
| | | { |
| | | try |
| | | { |
| | | short isTraytype = device.GetValue<GroundStationDBName, short>(GroundStationDBName.R_TakePalletType, item.StationCode); |
| | | bool isCanPut = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, item.StationCode); |
| | | bool isCanTake = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, item.StationCode); |
| | | short takePalletType = device.GetValue<GroundStationDBName, short>(GroundStationDBName.W_PutPalletType, item.StationCode); |
| | | bool putRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutRequest, item.StationCode); |
| | | bool putFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutFinish, item.StationCode); |
| | | bool takeRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeRequest, item.StationCode); |
| | | bool takeFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeFinish, item.StationCode); |
| | | |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | |
| | | //device.SetValue(GroundStationDBName.W_TakeRequest, true, item.StationCode); |
| | | //device.SetValue(GroundStationDBName.W_PutPalletType, 1, item.StationCode);//task.PalletType |
| | | |
| | | |
| | | //device.SetValue(GroundStationDBName.W_TakeFinish, true, item.StationCode); |
| | | ////夿AGVä»»å¡å®æï¼ååç»å°é¢ç«åè´§å®æ |
| | | //device.SetValue(GroundStationDBName.W_TakeRequest, false, item.StationCode); |
| | | //device.SetValue(GroundStationDBName.W_TakeFinish, false, item.StationCode); |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.SC_Execute.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); |
| | | if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, nextAddress: item.StationCode); |
| | | } |
| | | } |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => (x.TargetAddress == item.StackerCraneCode || string.IsNullOrEmpty(x.TargetAddress) || x.NextAddress == item.StackerCraneCode || string.IsNullOrEmpty(x.NextAddress)) && (x.TaskState == TaskStatusEnum.New.ObjToInt() || x.TaskState == TaskStatusEnum.AGV_Finish.ObjToInt()) && (x.SourceAddress == item.StationCode || x.CurrentAddress == item.AGVStationCode || x.CurrentAddress == item.StationCode)); |
| | | if (task != null) |
| | | { |
| | | if (isCanPut) |
| | | { |
| | | device.SetValue(GroundStationDBName.W_PutRequest, true, item.StationCode); |
| | | device.SetValue(GroundStationDBName.W_PutPalletType, 1, item.StationCode);//task.PalletType |
| | | } |
| | | //夿AGVä»»å¡å®æï¼ååç»å°é¢ç«æ¾è´§å®æ |
| | | device.SetValue(GroundStationDBName.W_PutFinish, true, item.StationCode); |
| | | |
| | | string oldAddress = task.NextAddress; |
| | | int oldStatus = task.TaskState; |
| | | Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode); |
| | | if (stationManger == null) |
| | | { |
| | | WriteError(item.StationName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | continue; |
| | | } |
| | | string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode); |
| | | if (string.IsNullOrEmpty(locationCode)) |
| | | { |
| | | WriteError(item.StationName, $"请æ±åé
è´§ä½è¿åä¿¡æ¯é误,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | continue; |
| | | } |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: stationManger.StackerCraneStationCode, targetAddress: locationCode, nextAddress: locationCode, deviceCode: stationManger.StackerCraneCode); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(device.DeviceCode, $"{item}交äºé误", ex); |
| | | } |
| | | } |
| | | |
| | | foreach (var item in stationMangers.Where(x => !deviceStations.Contains(x.StationCode))) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && x.SourceAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType)); |
| | | if (task != null) |
| | | { |
| | | Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode); |
| | | if (stationManger == null) |
| | | { |
| | | WriteError(item.StationName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | continue; |
| | | } |
| | | string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode); |
| | | if (string.IsNullOrEmpty(locationCode)) |
| | | { |
| | | WriteError(item.StationName, $"请æ±åé
è´§ä½è¿åä¿¡æ¯é误,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | continue; |
| | | } |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: stationManger.StackerCraneStationCode, targetAddress: locationCode, nextAddress: locationCode, deviceCode: stationManger.StackerCraneCode); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(device.DeviceName, "", ex); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | } |
| | | } |
| | |
| | | using WIDESEAWCS_Tasks.HoisterJob; |
| | | using WIDESEAWCS_Tasks.StackerCraneJob; |
| | | using WIDESEAWCS_Tasks; |
| | | using WIDESEAWCS_Core; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | |
| | | if (sendFlag) |
| | | { |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | // _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | task.Dispatchertime = DateTime.Now; |
| | | task.ExceptionMessage = ""; |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) |
| | | { |
| | | Console.Out.WriteLine("TaskCompleted" + e.TaskNum); |
| | | // _taskService.StackCraneTaskCompleted(e.TaskNum); |
| | | StackerCraneTaskCompleted(e.TaskNum, commonStackerCrane.DeviceCode); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent StackerCraneTaskCompleted(int taskNum, string deviceCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task != null) |
| | | { |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StackerCraneStationCode == task.NextAddress); |
| | | if (stationManger == null) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"AGVç«ç¹æªé
ç½®,{task.NextAddress}"); |
| | | _taskService.UpdateTaskExceptionMessage(taskNum, $"AGVç«ç¹æªé
ç½®,{task.NextAddress}"); |
| | | return WebResponseContent.Instance.Error($"AGVç«ç¹æªé
ç½®,{task.NextAddress}"); |
| | | } |
| | | |
| | | _taskService.UpdateTask(task, TaskStatusEnum.AGV_Execute, deviceCode: "AGV_ZH", currentAddress: stationManger.AGVStationCode ?? throw new Exception($"agvç«ç¹é误"), nextAddress: task.TargetAddress); |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup || task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | { |
| | | _taskService.TaskCompleted(taskNum); |
| | | } |
| | | else |
| | | { |
| | | WriteError(deviceCode, $"æªæ¾å°è¯¥ä»»å¡ç±»ååè°WMSä»»å¡å®ææ¥å£,{task.TaskType}"); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"æªæ¾å°è¯¥ä»»å¡ç±»ååè°WMSä»»å¡å®ææ¥å£,{task.TaskType}"); |
| | | _taskService.UpdateTaskExceptionMessage(taskNum, $"æªæ¾å°è¯¥ä»»å¡ç±»ååè°WMSä»»å¡å®ææ¥å£,{task.TaskType}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteError(deviceCode, $"æªæ¾å°ä»»å¡ä¿¡æ¯,ä»»å¡å·:{taskNum}"); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ä»»å¡ä¿¡æ¯,ä»»å¡å·:{taskNum}"); |
| | | } |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(deviceCode, $"ä»»å¡å®æé误", ex); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | /// <returns>妿æªè¢«å ç¨ï¼è¿åä¼ å
¥çä»»å¡ä¿¡æ¯ï¼å¦åï¼è¿ånull</returns> |
| | | private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task) |
| | | { |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.TargetAddress && x.StackerCraneCode == task.DeviceCode); |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => (x.StationCode == task.NextAddress || x.StackerCraneStationCode == task.NextAddress) && x.StackerCraneCode == task.DeviceCode); |
| | | if (stationManger != null) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); |
| | |
| | | OtherDevice client = (OtherDevice)device; |
| | | if (client.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode))//åºåºç«å°æªè¢«å ç¨ |
| | | { |
| | | task.TargetAddress = stationManger.StackerCraneStationCode; |
| | | task.NextAddress = stationManger.StackerCraneStationCode; |
| | | _taskRepository.UpdateData(task); |
| | | client.SetValue(GroundStationDBName.R_IsCanPut, true, stationManger.StationCode); |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteError(task.DeviceCode, $"æªæ¾å°åºåºç«å°ã{stationManger.StationDeviceCode}ã对åºçéè®¯å¯¹è±¡ï¼æ æ³å¤æåºåºç«å°æ¯å¦è¢«å ç¨"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"æªæ¾å°åºåºç«å°ã{stationManger.StationDeviceCode}ã对åºçéè®¯å¯¹è±¡ï¼æ æ³å¤æåºåºç«å°æ¯å¦è¢«å ç¨"); |
| | | WriteInfo(nameof(StackerCraneJob_ZH), $"æªæ¾å°åºåºç«å°ã{stationManger.StationDeviceCode}ã对åºçéè®¯å¯¹è±¡ï¼æ æ³å¤æåºåºç«å°æ¯å¦è¢«å ç¨"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteError(task.DeviceCode, $"æªæ¾å°ç«å°ã{task.NextAddress}ãä¿¡æ¯ï¼æ æ³æ ¡éªç«å°"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"æªæ¾å°ç«å°ã{task.NextAddress}ãä¿¡æ¯ï¼æ æ³æ ¡éªç«å°"); |
| | | WriteInfo(nameof(StackerCraneJob_ZH), $"æªæ¾å°ç«å°ã{task.NextAddress}ãä¿¡æ¯ï¼æ æ³æ ¡éªç«å°"); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | stackerCraneTaskCommand.TrayType = 1; |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//夿æ¯å¦æ¯å
¥åºä»»å¡ |
| | | { |
| | | //List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway); |
| | | //if (routers.Count > 0) |
| | | //{ |
| | | string[] startCodes = task.CurrentAddress.Split("-"); |
| | | |
| | | string[] startCodes = task.CurrentAddress.Split("-"); |
| | | if (startCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(startCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = Convert.ToInt16(startCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = Convert.ToInt16(startCodes[2]); |
| | | |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"å
¥åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | if (targetCodes.Length == 5) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"å
¥åºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"å
¥åºä»»å¡ç»ç¹é误ï¼èµ·ç¹ï¼ã{task.NextAddress}ã"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"åºåºä»»å¡ä¸ä¸å°åç¹é误ï¼èµ·ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | //} |
| | | //else |
| | | //{ |
| | | // _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"æªæ¾å°ç«å°ã{task.NextAddress}ãä¿¡æ¯ï¼æ æ³è·å对åºçå åæºåè´§ç«å°ä¿¡æ¯"); |
| | | // return null; |
| | | //} |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | //List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress); |
| | | //if (routers.Count > 0) |
| | | { |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); |
| | | |
| | | string[] sourceCodes = task.CurrentAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | if (sourceCodes.Length == 5) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"åºåºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | WriteInfo(nameof(StackerCraneJob_ZH), $"åºåºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | } |
| | | //else |
| | | //{ |
| | | // _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"æªæ¾å°ç«å°ã{task.NextAddress}ãä¿¡æ¯ï¼æ æ³è·å对åºçå åæºæ¾è´§ç«å°ä¿¡æ¯"); |
| | | // return null; |
| | | //} |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | { |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | if (targetCodes.Length == 5) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ç§»åºä»»å¡ç»ç¹é误ï¼èµ·ç¹ï¼ã{task.NextAddress}ã"); |
| | | WriteInfo(nameof(StackerCraneJob_ZH), $"ç§»åºä»»å¡ç»ç¹é误ï¼èµ·ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | string[] sourceCodes = task.CurrentAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | if (sourceCodes.Length == 5) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ç§»åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | |
| | | WriteInfo(nameof(StackerCraneJob_ZH), $"ç§»åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <vol-box |
| | | v-model="showDetialBox" |
| | | :lazy="true" |
| | | width="60%" |
| | | :padding="15" |
| | | title="æå®åºå" |
| | | > |
| | | <div class="box-head"> |
| | | <el-alert :closable="false" style="width: 100%"> |
| | | <el-row> |
| | | <el-col :span="16"> |
| | | <span class="less-style">ç©æåç§°ï¼ {{ row.materielName }} </span> |
| | | <el-divider direction="vertical"></el-divider> |
| | | <span class="less-style">ç©æç¼å·ï¼ {{ row.materielCode }} </span> |
| | | <el-divider direction="vertical"></el-divider> |
| | | <span class="less-style" |
| | | >éæ±æ°éï¼ {{ row.orderQuantity }} |
| | | </span> |
| | | <el-divider direction="vertical"></el-divider> |
| | | <span :class="selectionClass" |
| | | >已鿰éï¼ {{ selectionSum }} |
| | | </span> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-link |
| | | type="primary" |
| | | size="small" |
| | | style="float: right; height: 20px" |
| | | @click="getData(false)" |
| | | >{{ kcname }}</el-link |
| | | > |
| | | <el-link |
| | | type="primary" |
| | | size="small" |
| | | style="float: right; height: 20px; margin-right: 10px" |
| | | @click="getData" |
| | | >å·æ°</el-link |
| | | > |
| | | <el-link |
| | | type="primary" |
| | | size="small" |
| | | style="float: right; height: 20px; margin-right: 10px" |
| | | @click="revokeAssign" |
| | | >æ¤éåé
</el-link |
| | | > |
| | | </el-col> |
| | | </el-row> |
| | | </el-alert> |
| | | </div> |
| | | <div class="box-table" style="margin-top: 1%"> |
| | | <el-table |
| | | ref="singleTable" |
| | | :data="tableData" |
| | | style="width: 100%; height: 100%" |
| | | highlight-current-row |
| | | @row-click="handleRowClick" |
| | | height="500px" |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | > |
| | | <el-table-column type="selection" width="55"> </el-table-column> |
| | | <el-table-column |
| | | label="åºå·" |
| | | type="index" |
| | | fixed="left" |
| | | width="55" |
| | | align="center" |
| | | ></el-table-column> |
| | | <el-table-column |
| | | v-for="(item, index) in tableColumns.filter((x) => !x.hidden)" |
| | | :key="index" |
| | | :prop="item.prop" |
| | | :label="item.title" |
| | | :width="item.width" |
| | | align="center" |
| | | > |
| | | <template #default="scoped" v-if="item.type == 'icon'"> |
| | | <el-tooltip |
| | | class="item" |
| | | effect="dark" |
| | | :content="item.title" |
| | | placement="bottom" |
| | | ><el-button |
| | | type="text" |
| | | @click="tableButtonClick(scoped.row, item)" |
| | | ><i :class="item.icon" style="font-size: 22px"></i></el-button |
| | | ></el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | <template #footer> |
| | | <el-button type="primary" size="small" @click="outbound" |
| | | >ç´æ¥åºåº</el-button |
| | | > |
| | | <el-button type="primary" size="small" @click="lockStock" |
| | | >éå®åºå</el-button |
| | | > |
| | | <el-button type="danger" size="small" @click="showDetialBox = false" |
| | | >å
³é</el-button |
| | | > |
| | | </template> |
| | | </vol-box> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import VolBox from "@/components/basic/VolBox.vue"; |
| | | import { fa } from "element-plus/es/locales.mjs"; |
| | | export default { |
| | | components: { VolBox }, |
| | | data() { |
| | | return { |
| | | row: null, |
| | | kcname: "", |
| | | pkcx: false, |
| | | showDetialBox: false, |
| | | tableData: [], |
| | | tableColumns: [ |
| | | { |
| | | prop: "materielCode", |
| | | title: "ç©æç¼å·", |
| | | type: "string", |
| | | width: 150, |
| | | }, |
| | | { |
| | | prop: "materielName", |
| | | title: "ç©æåç§°", |
| | | type: "string", |
| | | width: 150, |
| | | }, |
| | | { |
| | | prop: "palletCode", |
| | | title: "æçç¼å·", |
| | | type: "string", |
| | | width: 150, |
| | | }, |
| | | { |
| | | prop: "locationCode", |
| | | title: "è´§ä½ç¼å·", |
| | | type: "string", |
| | | width: 180, |
| | | }, |
| | | { |
| | | prop: "unit", |
| | | title: "åä½", |
| | | type: "string", |
| | | width: 90, |
| | | }, |
| | | { |
| | | prop: "cutedWidth", |
| | | title: "è£å宽", |
| | | type: "string", |
| | | width: 100, |
| | | align: "left", |
| | | }, |
| | | { |
| | | prop: "useableQuantity", |
| | | title: "å¯ç¨æ°é", |
| | | type: "string", |
| | | }, |
| | | ], |
| | | selection: [], |
| | | selectionSum: 0, |
| | | selectionClass: "less-style", |
| | | originalQuantity: 0, |
| | | }; |
| | | }, |
| | | methods: { |
| | | open(row) { |
| | | console.log(row); |
| | | this.row = row; |
| | | this.showDetialBox = true; |
| | | this.originalQuantity = this.row.lockQuantity; |
| | | this.selectionSum = this.row.lockQuantity; |
| | | this.getData(); |
| | | if (this.selectionSum == this.row.orderQuantity) { |
| | | this.selectionClass = "equle-style"; |
| | | } else if (this.selectionSum < this.row.orderQuantity) { |
| | | this.selectionClass = "less-style"; |
| | | } else { |
| | | this.selectionClass = "more-style"; |
| | | } |
| | | }, |
| | | lockStock() { |
| | | this.http |
| | | .post( |
| | | "api/OutboundOrderDetail/LockOutboundStock?id=" + this.row.id, |
| | | this.selection, |
| | | "æ°æ®å¤çä¸" |
| | | ) |
| | | .then((x) => { |
| | | if (!x.status) return this.$message.error(x.message); |
| | | this.$message.success("æä½æå"); |
| | | this.showDetialBox = false; |
| | | this.$emit("parentCall", ($vue) => { |
| | | $vue.getData(); |
| | | }); |
| | | }); |
| | | }, |
| | | outbound() { |
| | | if (this.selection.length <= 0) { |
| | | return this.$message.error("请å¾é"); |
| | | } |
| | | let url = this.pkcx |
| | | ? "api/Mes/PPGeneratePKOutboundTask?orderDetailId=" |
| | | : "api/Mes/PPCutOutGenerateOutboundTasks?orderDetailId="; |
| | | this.http |
| | | .post(url + this.row.id, this.selection, "æ°æ®å¤çä¸") |
| | | .then((x) => { |
| | | if (!x.status) return this.$message.error(x.message); |
| | | this.$message.success("æä½æå"); |
| | | this.showDetialBox = false; |
| | | this.$emit("parentCall", ($vue) => { |
| | | $vue.getData(); |
| | | }); |
| | | }); |
| | | }, |
| | | getData(a) { |
| | | if (!a) this.pkcx = !this.pkcx; |
| | | let url = this.pkcx |
| | | ? "api/StockInfo/PPGetPKStockSelectViews?materielCode=" |
| | | : "api/StockInfo/PPGetStockSelectViews?materielCode="; |
| | | this.kcname = this.pkcx ? "ç«åºåºå" : "å¹³åºåºå"; |
| | | console.log(this.row.materielCode), |
| | | this.http |
| | | .post( |
| | | url + this.row.materielCode + "&orderId=" + this.row.orderId, |
| | | null, |
| | | "æ¥è¯¢ä¸" |
| | | ) |
| | | .then((x) => { |
| | | this.tableData = x; |
| | | }); |
| | | }, |
| | | revokeAssign() { |
| | | console.log(this.row); |
| | | this.http |
| | | .post( |
| | | "api/OutboundOrderDetail/RevokeLockOutboundStock?id=" + this.row.id, |
| | | null, |
| | | "æ°æ®å¤çä¸" |
| | | ) |
| | | .then((x) => { |
| | | if (!x.status) return this.$message.error(x.message); |
| | | this.$message.success("æä½æå"); |
| | | this.showDetialBox = false; |
| | | this.$emit("parentCall", ($vue) => { |
| | | $vue.getData(); |
| | | }); |
| | | }); |
| | | }, |
| | | handleSelectionChange(val) { |
| | | this.selection = val; |
| | | this.selectionSum = |
| | | val.reduce( |
| | | (accumulator, currentValue) => |
| | | accumulator + currentValue["useableQuantity"], |
| | | 0 |
| | | ) + this.originalQuantity; |
| | | if (this.selectionSum == this.row.orderQuantity) { |
| | | this.selectionClass = "equle-style"; |
| | | } else if (this.selectionSum < this.row.orderQuantity) { |
| | | this.selectionClass = "less-style"; |
| | | } else { |
| | | this.selectionClass = "more-style"; |
| | | } |
| | | }, |
| | | toggleSelection(rows) { |
| | | if (rows) { |
| | | rows.forEach((row) => { |
| | | this.$refs.singleTable.toggleRowSelection(row); |
| | | }); |
| | | } else { |
| | | this.$refs.singleTable.clearSelection(); |
| | | } |
| | | }, |
| | | clearSelection() { |
| | | this.$refs.singleTable.clearSelection(); |
| | | }, |
| | | handleRowClick(row) { |
| | | this.$refs.singleTable.toggleRowSelection(row); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | <style scoped> |
| | | .less-style { |
| | | color: black; |
| | | } |
| | | |
| | | .equle-style { |
| | | color: green; |
| | | } |
| | | |
| | | .more-style { |
| | | color: red; |
| | | } |
| | | </style> |
| | | |
| | | <style> |
| | | .text-button:hover { |
| | | background-color: #f0f9eb !important; |
| | | } |
| | | |
| | | .el-table .warning-row { |
| | | background: oldlace; |
| | | } |
| | | |
| | | .box-table .el-table tbody tr:hover > td { |
| | | background-color: #d8e0d4 !important; |
| | | /* color: #ffffff; */ |
| | | } |
| | | |
| | | .box-table .el-table tbody tr.current-row > td { |
| | | background-color: #f0f9eb !important; |
| | | /* color: #ffffff; */ |
| | | } |
| | | |
| | | .el-table .success-row { |
| | | background: #f0f9eb; |
| | | } |
| | | |
| | | .box-table .el-table { |
| | | border: 1px solid #ebeef5; |
| | | } |
| | | |
| | | .box-head .el-alert__content { |
| | | width: 100%; |
| | | } |
| | | </style> |
| | |
| | | </el-table> |
| | | </div> |
| | | </vol-box> |
| | | <stock-select ref="child" @parentCall="parentCall"></stock-select> |
| | | <pp-stock-select ref="childs" ></pp-stock-select> |
| | | <selected-stock |
| | | ref="selectedStock" |
| | | ref="SelectedStock" |
| | | @parentCall="parentCall" |
| | | ></selected-stock> |
| | | </div> |
| | |
| | | <script> |
| | | import VolBox from "@/components/basic/VolBox.vue"; |
| | | import VolForm from "@/components/basic/VolForm.vue"; |
| | | import StockSelect from "./StockSelect.vue"; |
| | | import PPStockSelect from "./PPStockSelect.vue"; |
| | | import SelectedStock from "./SelectedStock.vue"; |
| | | export default { |
| | | components: { VolBox, VolForm, StockSelect, SelectedStock }, |
| | | components: { VolBox, VolForm,"pp-stock-select":PPStockSelect, SelectedStock }, |
| | | data() { |
| | | return { |
| | | row: null, |
| | |
| | | }, |
| | | tableButtonClick(row, column) { |
| | | if (column.prop == "assignStock") { |
| | | this.$refs.child.open(row); |
| | | console.log(row); |
| | | console.log(this.$refs.childs); |
| | | this.$refs.childs.open(row); |
| | | } else { |
| | | //ç¹å»æå¼åºåºè¯¦æ
|
| | | this.$refs.selectedStock.open(row); |
| | | this.$refs.SelectedStock.open(row); |
| | | } |
| | | }, |
| | | lockstocks() { |
| | |
| | | var keys = this.selection.map((item) => item.id); // è·åéä¸è¡çid |
| | | |
| | | this.http |
| | | .post("api/Task/GenerateOutboundTasks", keys, "æ°æ®å¤çä¸") |
| | | .post("api/Mes/PPCutOutGenerateOutboundTasks", keys, "æ°æ®å¤çä¸") |
| | | .then((x) => { |
| | | if (!x.status) return this.$message.error(x.message); |
| | | this.$message.success("æä½æå"); |
| | |
| | | this.http |
| | | .post("api/MesPPOutboundOrderDetail/GetPageData", param, "æ¥è¯¢ä¸") |
| | | .then((x) => { |
| | | // console.log(x.rows); |
| | | console.log(x.rows); |
| | | this.tableData = x.rows; |
| | | }); |
| | | }, |
| | |
| | | var keys = this.selection.map((item) => item.id); // è·åéä¸è¡çid |
| | | |
| | | this.http |
| | | .post("api/Task/GenerateOutboundTasks", keys, "æ°æ®å¤çä¸") |
| | | .post("api/Mes/MESPPGenerateOutboundTasks", keys, "æ°æ®å¤çä¸") |
| | | .then((x) => { |
| | | if (!x.status) return this.$message.error(x.message); |
| | | this.$message.success("æä½æå"); |
| | |
| | | methods: { |
| | | //ä¸é¢è¿äºæ¹æ³å¯ä»¥ä¿çä¹å¯ä»¥å é¤ |
| | | onInit() { |
| | | //æ©å±é¡µé¢åå§åæä½ |
| | | this.columns.push({ |
| | | field: 'æä½', |
| | | title: 'æä½', |
| | | width: 90, |
| | | fixed: 'right', |
| | | align: 'center', |
| | | formatter: (row) => { |
| | | return ( |
| | | '<i style="cursor: pointer;color: #2d8cf0;"class="el-icon-view">æ¥çæç»</i>' |
| | | ); |
| | | }, |
| | | click: (row) => { |
| | | this.$refs.gridBody.open(row); |
| | | } |
| | | }); |
| | | }, |
| | | onInited() { |
| | | //æ¡æ¶åå§åé
ç½®å |
| | |
| | | } |
| | | }; |
| | | export default extension; |
| | | |
| | |
| | | ]); |
| | | const detail = ref({ |
| | | cnName: "åºåºæç»å", |
| | | table: "OnboundOrderDetail", |
| | | table: "mesPPCutOutOrderDetail", |
| | | columns: [ |
| | | { |
| | | field: "id", |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åå¯åºåºè´§ä½ç¼å· |
| | | /// </summary> |
| | | /// <param name="warehouseId"></param> |
| | | /// <returns></returns> |
| | | public List<string> PPGetCanOutLocationCodes(int warehouseId) |
| | | { |
| | | return QueryData(x => x.LocationCode, x => x.WarehouseId == warehouseId && x.LocationType == LocationTypeEnum.Undefined.ObjToInt() && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())).Distinct().ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åMESæå®å¯åºåºè´§ä½ç¼å· |
| | | /// </summary> |
| | | /// <param name="warehouseId"></param> |
| | |
| | | "HA58" => AssignLocation_PP(roadwayNo, palletType, palletTypeInfo, beRelocationCode), |
| | | "HA152" => AssignLocation_GM(roadwayNo, palletType, palletTypeInfo, beRelocationCode), |
| | | "HA64" => AssignLocation_CSJ(roadwayNo, palletType, palletTypeInfo, beRelocationCode), |
| | | "é»çä»" => AssignLocation_ZH(roadwayNo, palletType, palletTypeInfo, beRelocationCode), |
| | | "HA154" => AssignLocation_ZH(roadwayNo, palletType, palletTypeInfo, beRelocationCode), |
| | | "HA153" => AssignLocation(roadwayNo), |
| | | "HA71" => AssignLocation(roadwayNo), |
| | | "HA60" => AssignLocation(roadwayNo), |
| | |
| | | /// |
| | | /// </summary> |
| | | public string DataTime { get; set; } |
| | | |
| | | public static MesResponseContent Instance |
| | | { |
| | | get { return new MesResponseContent(); } |
| | | } |
| | | |
| | | public MesResponseContent OK(string message = null) |
| | | { |
| | | BSucc = true; |
| | | StrCode = "0000"; |
| | | StrMsg = message == null ? "æ§è¡æå" : message; |
| | | DataTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | return this; |
| | | } |
| | | |
| | | public MesResponseContent Error(string message = null) |
| | | { |
| | | BSucc = false; |
| | | StrCode = "404"; |
| | | StrMsg = message == null ? "æ§è¡å¤±è´¥" : message; |
| | | DataTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | return this; |
| | | } |
| | | public object Content { get; set; } |
| | | } |
| | | |
| | | public class Contents |
| | | { |
| | | public string Contacts { get; set; } |
| | | /// <summary> |
| | | /// ç©æç¼ç |
| | | /// </summary> |
| | |
| | | /// ç©ææ¹æ¬¡ |
| | | /// </summary> |
| | | public string MaterialLot { get; set; } |
| | | |
| | | public static MesResponseContent Instance |
| | | { |
| | | get { return new MesResponseContent(); } |
| | | } |
| | | |
| | | public MesResponseContent OK(string message = null) |
| | | { |
| | | BSucc = true; |
| | | StrCode = "0000"; |
| | | StrMsg = message == null ? "æ§è¡æå" : message; |
| | | DataTime= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | return this; |
| | | } |
| | | |
| | | public MesResponseContent Error(string message = null) |
| | | { |
| | | BSucc = false; |
| | | StrCode = "404"; |
| | | StrMsg = message == null ? "æ§è¡å¤±è´¥" : message; |
| | | DataTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | return this; |
| | | } |
| | | public ContentMes Content { get; set; } |
| | | } |
| | | public class ContentMes: Content |
| | | { |
| | | public string Contacts { get; set; } |
| | | } |
| | | /// <summary> |
| | | /// PPåºåæ¥è¯¢ï¼åå¤MES |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_DTO.Stock |
| | | { |
| | | public class PPStockSelectViewDTO |
| | | { |
| | | public string MaterielCode { get; set; } |
| | | |
| | | public string MaterielName { get; set; } |
| | | |
| | | public float UseableQuantity { get; set; } |
| | | |
| | | public string PalletCode { get; set; } |
| | | |
| | | public string LocationCode { get; set; } |
| | | |
| | | public string Unit { get; set; } |
| | | public float CutedWidth { get; set; } |
| | | } |
| | | } |
| | |
| | | /// <returns></returns> |
| | | List<string> GetCanOutLocationCodes(int warehouseId); |
| | | |
| | | List<string> PPGetCanOutLocationCodes(int warehouseId); |
| | | |
| | | /// <summary> |
| | | /// è·åMESæå®å¯åºåºè´§ä½ç¼å· |
| | | /// </summary> |
| | |
| | | IOutboundOrderRepository OutboundOrderRepository { get; } |
| | | |
| | | IOutStockLockInfoRepository OutboundStockLockInfoRepository { get; } |
| | | |
| | | IMesPPCutOutboundOrderRepository MesPPCutOutboundOrderRepository { get; } |
| | | } |
| | | } |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_IOutboundService |
| | | { |
| | | public interface IMesPPCutOutboundOrderDetailService : IService<Dt_MesPPCutOutboundOrderDetail> |
| | | { |
| | | IMesPPCutOutboundOrderDetailRepository Repository { get; } |
| | | |
| | | (List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPCutOutboundOrderDetail mesOutboundOrder,List<PPStockSelectViewDTO> stockSelectViewDTOs); |
| | | |
| | | /// <summary> |
| | | /// éå®åºåºåºå(ä¿®æ¹æ°æ®) |
| | | /// </summary> |
| | | /// <param name="stockInfos">åºåæç»éå</param> |
| | | /// <param name="outboundOrderDetails">åºåºåæç»éå</param> |
| | | /// <param name="outStockLockInfos">åºåºé宿ç»éå</param> |
| | | /// <param name="locationInfos">è´§ä½ç»å</param> |
| | | /// <param name="locationStatus">è´§ä½ç¶æä¿®æ¹çå¼</param> |
| | | /// <param name="tasks">ä»»å¡ä¿¡æ¯</param> |
| | | /// <returns></returns> |
| | | WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_MesPPCutOutboundOrderDetail> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null); |
| | | |
| | | } |
| | | } |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Microsoft.AspNetCore.Hosting.Server; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_IOutboundService |
| | | { |
| | | public interface IMesPPOutboundOrderDetailService : IService<Dt_MesPPOutboundOrderDetail> |
| | | { |
| | | IMesPPOutboundOrderDetailRepository Repository { get; } |
| | | |
| | | (List<Dt_StockInfo>, List<Dt_MesPPOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>, Dt_MesPPOutboundOrder mesPPOutboundOrder) AssignStockOutbound(List<Dt_MesPPOutboundOrderDetail> mesOutboundOrder); |
| | | |
| | | /// <summary> |
| | | /// éå®åºåºåºå(ä¿®æ¹æ°æ®) |
| | | /// </summary> |
| | | /// <param name="stockInfos">åºåæç»éå</param> |
| | | /// <param name="outboundOrderDetails">åºåºåæç»éå</param> |
| | | /// <param name="outStockLockInfos">åºåºé宿ç»éå</param> |
| | | /// <param name="locationInfos">è´§ä½ç»å</param> |
| | | /// <param name="locationStatus">è´§ä½ç¶æä¿®æ¹çå¼</param> |
| | | /// <param name="tasks">ä»»å¡ä¿¡æ¯</param> |
| | | /// <returns></returns> |
| | | WebResponseContent LockOutboundStockDataUpdate(Dt_MesPPOutboundOrder mesPPOutboundOrder,List<Dt_StockInfo> stockInfos, List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null); |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | IMesPPOutboundOrderRepository Repository { get; } |
| | | |
| | | (List<Dt_StockInfo>, Dt_MesPPOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPOutboundOrder mesOutboundOrder); |
| | | //(List<Dt_StockInfo>, Dt_MesPPOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPOutboundOrder mesOutboundOrder); |
| | | |
| | | (List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPCutOutboundOrder mesPPOutboundOrder, Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail); |
| | | //(List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPCutOutboundOrder mesPPOutboundOrder, Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail); |
| | | |
| | | } |
| | | } |
| | |
| | | /// <param name="assignQuantity"></param> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | Dt_OutStockLockInfo GetOutStockLockInfo(Dt_MesPPCutOutboundOrder mesPPCutOutboundOrder,Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail, Dt_StockInfo outStock, float assignQuantity, int? taskNum = null); |
| | | List<Dt_OutStockLockInfo> GetOutStockLockInfos(Dt_MesPPCutOutboundOrder mesPPCutOutboundOrder,Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail, List<Dt_StockInfo> outStock, int? taskNum = null); |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | /// <returns></returns> |
| | | (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails); |
| | | |
| | | |
| | | /// <summary> |
| | | /// éå®åºåºåºå |
| | | /// </summary> |
| | |
| | | |
| | | List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo, int warehoseId); |
| | | |
| | | //List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo,,string , int warehoseId); |
| | | |
| | | List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo, string palletcode,int warehoseId); |
| | | WebResponseContent StockQueryData(SaveModel saveModel); |
| | | |
| | | List<PPStockSelectViewDTO> PPGetStockSelectViews(int orderId, string materielCode); |
| | | List<PPStockSelectViewDTO> PPGetPKStockSelectViews(int orderId, string materielCode); |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// PPä»å¤§å·MESåºåºåæç» |
| | | /// </summary> |
| | | [SugarTable(nameof(Dt_MesPPOutboundOrderDetail))] |
| | | [SugarTable(nameof(Dt_MesPPOutboundOrderDetail), "PPä»å¤§å·MESåºåºåæç»")] |
| | | public class Dt_MesPPOutboundOrderDetail : BaseEntity |
| | | { |
| | | /// <summary> |
| | |
| | | |
| | | public IOutStockLockInfoRepository OutboundStockLockInfoRepository { get; } |
| | | |
| | | public OutboundRepository(IOutboundOrderDetailRepository outboundOrderDetailRepository, IOutboundOrderRepository outboundOrderRepository, IOutStockLockInfoRepository outboundStockLockInfoRepository) |
| | | public IMesPPCutOutboundOrderRepository MesPPCutOutboundOrderRepository { get; } |
| | | |
| | | public OutboundRepository(IOutboundOrderDetailRepository outboundOrderDetailRepository, IOutboundOrderRepository outboundOrderRepository, IOutStockLockInfoRepository outboundStockLockInfoRepository,IMesPPCutOutboundOrderRepository mesPPCutOutboundOrderRepository) |
| | | { |
| | | OutboundOrderDetailRepository = outboundOrderDetailRepository; |
| | | OutboundOrderRepository = outboundOrderRepository; |
| | | OutboundStockLockInfoRepository = outboundStockLockInfoRepository; |
| | | MesPPCutOutboundOrderRepository = mesPPCutOutboundOrderRepository; |
| | | } |
| | | } |
| | | } |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using SqlSugar.Extensions; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IOutboundRepository; |
| | |
| | | _basicService = basicService; |
| | | _recordService = recordService; |
| | | } |
| | | |
| | | public (List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPCutOutboundOrderDetail mesPPOutboundOrderDetails, List<PPStockSelectViewDTO> stockSelectViews) |
| | | { |
| | | #region |
| | | //Dt_MesPPCutOutboundOrder OutboundOrder = BaseDal.Db.Queryable<Dt_MesPPCutOutboundOrder>().Where(x => x.Id == mesPPOutboundOrderDetails.OrderId).First(); |
| | | //List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | //List<Dt_MesPPCutOutboundOrderDetail> groupDetails = mesPPOutboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo }).Select(x => new Dt_MesPPCutOutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo, }).ToList(); |
| | | |
| | | //List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | //List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | //foreach (var item in groupDetails) |
| | | //{ |
| | | // float originalNeedQuantity = item.OrderQuantity; |
| | | |
| | | // float needQuantity = originalNeedQuantity; |
| | | |
| | | // List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, OutboundOrder.WarehouseId); |
| | | // if (!stockInfos.Any()) |
| | | // { |
| | | // throw new Exception($"æªæ¾å°å¯åé
åºå"); |
| | | // } |
| | | // List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out float residueQuantity); |
| | | // item.LockQuantity += needQuantity - residueQuantity; |
| | | // outStocks.AddRange(autoAssignStocks); |
| | | // float assignQuantity = needQuantity - residueQuantity; |
| | | |
| | | // List<Dt_MesPPCutOutboundOrderDetail> details = mesPPOutboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList(); |
| | | |
| | | // for (int i = 0; i < details.Count; i++) |
| | | // { |
| | | // float orderQuantity = details[i].OrderQuantity; |
| | | // for (int j = 0; j < autoAssignStocks.Count; j++) |
| | | // { |
| | | // float detailAssignQuantity = outStockLockInfos.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity);//åºåºè®¢åæç»å·²åé
æ°é |
| | | |
| | | // float palletAssignQuantity = outStockLockInfos.Where(x => x.BatchNo == item.BatchNo && x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é |
| | | // if (string.IsNullOrEmpty(item.BatchNo)) |
| | | // { |
| | | // palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é |
| | | // } |
| | | // float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); |
| | | // if (palletAssignQuantity < palletOutboundQuantity)//妿åºåºè¯¦æ
å·²åé
æ°éå°äºæçå·²åé
æ°éï¼åå¯ä»¥ç»§ç»æ·»å 该æçåºåºä¿¡æ¯ |
| | | // { |
| | | // float orderDetailNeedQuantity = details[i].OrderQuantity - detailAssignQuantity; |
| | | // if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) |
| | | // { |
| | | // details[i].LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; |
| | | // Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, details[i], autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); |
| | | // outStockLockInfos.Add(outStockLockInfo); |
| | | // } |
| | | // else |
| | | // { |
| | | // Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, details[i], autoAssignStocks[j], details[i].OrderQuantity - details[i].LockQuantity); |
| | | // outStockLockInfos.Add(outStockLockInfo); |
| | | // details[i].LockQuantity = details[i].OrderQuantity; |
| | | // break; |
| | | // } |
| | | |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | |
| | | // locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); |
| | | |
| | | //} |
| | | #endregion |
| | | (bool, string) checkResult = CheckSelectStockDeital(mesPPOutboundOrderDetails, stockSelectViews); |
| | | if (!checkResult.Item1) throw new Exception(checkResult.Item2); |
| | | Dt_MesPPCutOutboundOrder OutboundOrder = BaseDal.Db.Queryable<Dt_MesPPCutOutboundOrder>().Where(x => x.Id == mesPPOutboundOrderDetails.OrderId).First(); |
| | | float originalNeedQuantity = mesPPOutboundOrderDetails.OrderQuantity - mesPPOutboundOrderDetails.LockQuantity; |
| | | |
| | | float needQuantity = originalNeedQuantity; |
| | | |
| | | List<Dt_StockInfo> outStocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList()); |
| | | float assignQuantity = 0; |
| | | outStocks.ForEach(x => |
| | | { |
| | | x.Details.ForEach(v => |
| | | { |
| | | assignQuantity += v.StockQuantity - v.OutboundQuantity; |
| | | }); |
| | | }); |
| | | |
| | | mesPPOutboundOrderDetails.LockQuantity += assignQuantity; |
| | | outStocks.ForEach(x => |
| | | { |
| | | x.Details.ForEach(v => |
| | | { |
| | | v.OutboundQuantity = v.StockQuantity; |
| | | }); |
| | | }); |
| | | needQuantity -= assignQuantity; |
| | | if (mesPPOutboundOrderDetails.OrderQuantity > mesPPOutboundOrderDetails.LockQuantity) |
| | | { |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesPPOutboundOrderDetails.MaterielCode, mesPPOutboundOrderDetails.BatchNo, OutboundOrder.WarehouseId); |
| | | stockInfos = stockInfos.Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode)).ToList(); |
| | | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesPPOutboundOrderDetails.MaterielCode, needQuantity, out float residueQuantity); |
| | | mesPPOutboundOrderDetails.LockQuantity += needQuantity - residueQuantity; |
| | | outStocks.AddRange(autoAssignStocks); |
| | | mesPPOutboundOrderDetails.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt(); |
| | | if (residueQuantity > 0) |
| | | { |
| | | mesPPOutboundOrderDetails.OrderDetailStatus = OrderDetailStatusEnum.AssignOverPartial.ObjToInt(); |
| | | } |
| | | } |
| | | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outStockLockInfoService.GetOutStockLockInfos(OutboundOrder, mesPPOutboundOrderDetails, outStocks); |
| | | |
| | | |
| | | List<Dt_LocationInfo> locationInfos = _basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()); |
| | | return (outStocks, mesPPOutboundOrderDetails, outStockLockInfos, locationInfos); |
| | | } |
| | | private (bool, string) CheckSelectStockDeital(Dt_MesPPCutOutboundOrderDetail outboundOrderDetail, List<PPStockSelectViewDTO> stockSelectViews) |
| | | { |
| | | if (outboundOrderDetail == null) |
| | | { |
| | | return (false, "æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt() && outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) |
| | | { |
| | | return (false, "该æç»ä¸å¯æä½"); |
| | | } |
| | | if (stockSelectViews.Sum(x => x.UseableQuantity) > outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity) |
| | | { |
| | | return (false, "éæ©æ°éè¶
åºåæ®æ°é"); |
| | | } |
| | | return (true, "æå"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// åºåºåºååé
åï¼æ´æ°æ°æ®åºæ°æ® |
| | | /// </summary> |
| | | /// <param name="stockInfos"></param> |
| | | /// <param name="outboundOrderDetails"></param> |
| | | /// <param name="outStockLockInfos"></param> |
| | | /// <param name="locationInfos"></param> |
| | | /// <param name="locationStatus"></param> |
| | | /// <param name="tasks"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_MesPPCutOutboundOrderDetail> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null) |
| | | { |
| | | try |
| | | { |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfos); |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | foreach (var item in stockInfos) |
| | | { |
| | | stockInfoDetails.AddRange(item.Details); |
| | | } |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetails); |
| | | BaseDal.UpdateData(outboundOrderDetails); |
| | | |
| | | List<Dt_OutStockLockInfo> addOutStockLockInfos = outStockLockInfos.Where(x => x.Id == 0).ToList(); |
| | | if (addOutStockLockInfos != null && addOutStockLockInfos.Any()) |
| | | { |
| | | if (tasks != null) |
| | | { |
| | | addOutStockLockInfos.ForEach(x => |
| | | { |
| | | x.TaskNum = tasks.FirstOrDefault(v => v.PalletCode == x.PalletCode)?.TaskNum; |
| | | }); |
| | | } |
| | | |
| | | _outStockLockInfoService.Repository.AddData(addOutStockLockInfos); |
| | | } |
| | | List<Dt_OutStockLockInfo> updateOutStockLockInfos = outStockLockInfos.Where(x => x.Id > 0).ToList(); |
| | | if (updateOutStockLockInfos != null && updateOutStockLockInfos.Any()) |
| | | { |
| | | _outStockLockInfoService.Repository.UpdateData(updateOutStockLockInfos); |
| | | } |
| | | |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, locationStatus, LocationChangeType.OutboundAssignLocation, "", tasks?.Select(x => x.TaskNum).ToList()); |
| | | _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | |
| | | private readonly IOutStockLockInfoService _outStockLockInfoService; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IRecordService _recordService; |
| | | |
| | | private readonly IMesPPOutboundOrderService _mesPPOutboundOrderService; |
| | | public IMesPPOutboundOrderDetailRepository Repository => BaseDal; |
| | | |
| | | public MesPPOutboundOrderDetailService(IMesPPOutboundOrderDetailRepository BaseDal, IBasicRepository basicRepository, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IBasicService basicService, IRecordService recordService) : base(BaseDal) |
| | | public MesPPOutboundOrderDetailService(IMesPPOutboundOrderDetailRepository BaseDal,IMesPPOutboundOrderService mesPPOutboundOrderService ,IBasicRepository basicRepository, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IBasicService basicService, IRecordService recordService) : base(BaseDal) |
| | | { |
| | | _basicRepository = basicRepository; |
| | | _stockService = stockService; |
| | | _outStockLockInfoService = outStockLockInfoService; |
| | | _basicService = basicService; |
| | | _recordService = recordService; |
| | | _mesPPOutboundOrderService=mesPPOutboundOrderService; |
| | | } |
| | | |
| | | public (List<Dt_StockInfo>, List<Dt_MesPPOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>, Dt_MesPPOutboundOrder mesPPOutboundOrder) AssignStockOutbound(List<Dt_MesPPOutboundOrderDetail> mesPPOutboundOrderDetails) |
| | | { |
| | | List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | Dt_MesPPOutboundOrder OutboundOrder = BaseDal.Db.Queryable<Dt_MesPPOutboundOrder>().Where(x => x.Id == mesPPOutboundOrderDetails.FirstOrDefault().OrderId).First(); |
| | | float originalNeedQuantity = OutboundOrder.OrderQuantity; |
| | | |
| | | float needQuantity = originalNeedQuantity; |
| | | //Dt_MesPPOutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(OutboundOrder.MaterialCode, "", mesPPOutboundOrderDetails.FirstOrDefault()?.CarrierCode ?? "", OutboundOrder.WarehouseId); |
| | | if (!stockInfos.Any()) |
| | | { |
| | | throw new Exception($"æªæ¾å°å¯åé
åºå"); |
| | | } |
| | | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, OutboundOrder.MaterialCode, needQuantity, out float residueQuantity); |
| | | OutboundOrder.LockQuantity += needQuantity - residueQuantity; |
| | | autoAssignStocks.OrderBy(x => x.Details.FirstOrDefault()?.StockQuantity).ToList(); |
| | | outStocks.AddRange(autoAssignStocks); |
| | | float assignQuantity = needQuantity - residueQuantity; |
| | | |
| | | float orderQuantity = OutboundOrder.OrderQuantity; |
| | | |
| | | for (int j = 0; j < autoAssignStocks.Count; j++) |
| | | { |
| | | float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == OutboundOrder.MaterialCode).Sum(x => x.AssignQuantity);//åºåºè®¢åæç»å·²åé
æ°é |
| | | |
| | | float palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == OutboundOrder.MaterialCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é |
| | | |
| | | float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); |
| | | if (palletAssignQuantity < palletOutboundQuantity)//妿åºåºè¯¦æ
å·²åé
æ°éå°äºæçå·²åé
æ°éï¼åå¯ä»¥ç»§ç»æ·»å 该æçåºåºä¿¡æ¯ |
| | | { |
| | | float orderDetailNeedQuantity = OutboundOrder.OrderQuantity - detailAssignQuantity; |
| | | if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) |
| | | { |
| | | OutboundOrder.LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; |
| | | //Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); |
| | | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, autoAssignStocks[j], assignQuantity); |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | } |
| | | else |
| | | { |
| | | //Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, autoAssignStocks[j], OutboundOrder.OrderQuantity - OutboundOrder.LockQuantity); |
| | | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, autoAssignStocks[j], assignQuantity); |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | OutboundOrder.LockQuantity = OutboundOrder.OrderQuantity; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); |
| | | |
| | | return (outStocks, mesPPOutboundOrderDetails, outStockLockInfos, locationInfos, OutboundOrder); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºåºåºååé
åï¼æ´æ°æ°æ®åºæ°æ® |
| | | /// </summary> |
| | | /// <param name="stockInfos"></param> |
| | | /// <param name="outboundOrderDetails"></param> |
| | | /// <param name="outStockLockInfos"></param> |
| | | /// <param name="locationInfos"></param> |
| | | /// <param name="locationStatus"></param> |
| | | /// <param name="tasks"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent LockOutboundStockDataUpdate(Dt_MesPPOutboundOrder mesPPOutboundOrder, List<Dt_StockInfo> stockInfos, List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null) |
| | | { |
| | | try |
| | | { |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfos); |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | foreach (var item in stockInfos) |
| | | { |
| | | stockInfoDetails.AddRange(item.Details); |
| | | } |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetails); |
| | | BaseDal.UpdateData(outboundOrderDetails); |
| | | |
| | | List<Dt_OutStockLockInfo> addOutStockLockInfos = outStockLockInfos.Where(x => x.Id == 0).ToList(); |
| | | if (addOutStockLockInfos != null && addOutStockLockInfos.Any()) |
| | | { |
| | | if (tasks != null) |
| | | { |
| | | addOutStockLockInfos.ForEach(x => |
| | | { |
| | | x.TaskNum = tasks.FirstOrDefault(v => v.PalletCode == x.PalletCode)?.TaskNum; |
| | | }); |
| | | } |
| | | |
| | | _outStockLockInfoService.Repository.AddData(addOutStockLockInfos); |
| | | } |
| | | List<Dt_OutStockLockInfo> updateOutStockLockInfos = outStockLockInfos.Where(x => x.Id > 0).ToList(); |
| | | if (updateOutStockLockInfos != null && updateOutStockLockInfos.Any()) |
| | | { |
| | | _outStockLockInfoService.Repository.UpdateData(updateOutStockLockInfos); |
| | | } |
| | | if (mesPPOutboundOrder != null) |
| | | { |
| | | _mesPPOutboundOrderService.UpdateData(mesPPOutboundOrder); |
| | | } |
| | | |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, locationStatus, LocationChangeType.OutboundAssignLocation, "", tasks?.Select(x => x.TaskNum).ToList()); |
| | | _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | _recordService = recordService; |
| | | } |
| | | |
| | | public (List<Dt_StockInfo>, Dt_MesPPOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPOutboundOrder mesPPOutboundOrder) |
| | | { |
| | | List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | //public (List<Dt_StockInfo>, Dt_MesPPOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPOutboundOrder mesPPOutboundOrder) |
| | | //{ |
| | | // List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | // List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | // List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | |
| | | float originalNeedQuantity = mesPPOutboundOrder.OrderQuantity; |
| | | // float originalNeedQuantity = mesPPOutboundOrder.OrderQuantity; |
| | | |
| | | float needQuantity = originalNeedQuantity; |
| | | // float needQuantity = originalNeedQuantity; |
| | | |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesPPOutboundOrder.MaterialCode, "", mesPPOutboundOrder.Details.FirstOrDefault()?.CarrierCode ?? "",mesPPOutboundOrder.WarehouseId); |
| | | if (!stockInfos.Any()) |
| | | { |
| | | throw new Exception($"æªæ¾å°å¯åé
åºå"); |
| | | } |
| | | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesPPOutboundOrder.MaterialCode, needQuantity, out float residueQuantity); |
| | | mesPPOutboundOrder.LockQuantity += needQuantity - residueQuantity; |
| | | outStocks.AddRange(autoAssignStocks); |
| | | float assignQuantity = needQuantity - residueQuantity; |
| | | // List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesPPOutboundOrder.MaterialCode, "", mesPPOutboundOrder.Details.FirstOrDefault()?.CarrierCode ?? "",mesPPOutboundOrder.WarehouseId); |
| | | // if (!stockInfos.Any()) |
| | | // { |
| | | // throw new Exception($"æªæ¾å°å¯åé
åºå"); |
| | | // } |
| | | // List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesPPOutboundOrder.MaterialCode, needQuantity, out float residueQuantity); |
| | | // mesPPOutboundOrder.LockQuantity += needQuantity - residueQuantity; |
| | | // outStocks.AddRange(autoAssignStocks); |
| | | // float assignQuantity = needQuantity - residueQuantity; |
| | | |
| | | float orderQuantity = mesPPOutboundOrder.OrderQuantity; |
| | | for (int j = 0; j < autoAssignStocks.Count; j++) |
| | | { |
| | | float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPOutboundOrder.MaterialCode).Sum(x => x.AssignQuantity);//åºåºè®¢åæç»å·²åé
æ°é |
| | | // float orderQuantity = mesPPOutboundOrder.OrderQuantity; |
| | | // for (int j = 0; j < autoAssignStocks.Count; j++) |
| | | // { |
| | | // float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPOutboundOrder.MaterialCode).Sum(x => x.AssignQuantity);//åºåºè®¢åæç»å·²åé
æ°é |
| | | |
| | | float palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPOutboundOrder.MaterialCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é |
| | | // float palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPOutboundOrder.MaterialCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é |
| | | |
| | | float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); |
| | | if (palletAssignQuantity < palletOutboundQuantity)//妿åºåºè¯¦æ
å·²åé
æ°éå°äºæçå·²åé
æ°éï¼åå¯ä»¥ç»§ç»æ·»å 该æçåºåºä¿¡æ¯ |
| | | { |
| | | float orderDetailNeedQuantity = mesPPOutboundOrder.OrderQuantity - detailAssignQuantity; |
| | | if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) |
| | | { |
| | | mesPPOutboundOrder.LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; |
| | | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | } |
| | | else |
| | | { |
| | | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, autoAssignStocks[j], mesPPOutboundOrder.OrderQuantity - mesPPOutboundOrder.LockQuantity); |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | mesPPOutboundOrder.LockQuantity = mesPPOutboundOrder.OrderQuantity; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); |
| | | // float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); |
| | | // if (palletAssignQuantity < palletOutboundQuantity)//妿åºåºè¯¦æ
å·²åé
æ°éå°äºæçå·²åé
æ°éï¼åå¯ä»¥ç»§ç»æ·»å 该æçåºåºä¿¡æ¯ |
| | | // { |
| | | // float orderDetailNeedQuantity = mesPPOutboundOrder.OrderQuantity - detailAssignQuantity; |
| | | // if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) |
| | | // { |
| | | // mesPPOutboundOrder.LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; |
| | | // Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); |
| | | // outStockLockInfos.Add(outStockLockInfo); |
| | | // } |
| | | // else |
| | | // { |
| | | // Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, autoAssignStocks[j], mesPPOutboundOrder.OrderQuantity - mesPPOutboundOrder.LockQuantity); |
| | | // outStockLockInfos.Add(outStockLockInfo); |
| | | // mesPPOutboundOrder.LockQuantity = mesPPOutboundOrder.OrderQuantity; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); |
| | | |
| | | return (outStocks, mesPPOutboundOrder, outStockLockInfos, locationInfos); |
| | | } |
| | | // return (outStocks, mesPPOutboundOrder, outStockLockInfos, locationInfos); |
| | | //} |
| | | |
| | | |
| | | public (List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPCutOutboundOrder mesPPOutboundOrder, Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail) |
| | | { |
| | | List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | //public (List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPCutOutboundOrder mesPPOutboundOrder, Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail) |
| | | //{ |
| | | // List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | //Dt_MesPPCutOutboundOrder outboundOrder = BaseDal.Db.Queryable<Dt_MesPPCutOutboundOrder>().Where(x=>x.Id==mesPPOutboundOrder.OrderId).First(); |
| | | float originalNeedQuantity = mesPPCutOutboundOrderDetail.OrderQuantity; |
| | | // List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | // List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | // //Dt_MesPPCutOutboundOrder outboundOrder = BaseDal.Db.Queryable<Dt_MesPPCutOutboundOrder>().Where(x=>x.Id==mesPPOutboundOrder.OrderId).First(); |
| | | // float originalNeedQuantity = mesPPCutOutboundOrderDetail.OrderQuantity; |
| | | |
| | | float needQuantity = originalNeedQuantity; |
| | | // float needQuantity = originalNeedQuantity; |
| | | |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesPPCutOutboundOrderDetail.MaterielCode, "", mesPPOutboundOrder.WarehouseId); |
| | | if (!stockInfos.Any()) |
| | | { |
| | | throw new Exception($"æªæ¾å°å¯åé
åºå"); |
| | | } |
| | | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesPPCutOutboundOrderDetail.MaterielCode, needQuantity, out float residueQuantity); |
| | | mesPPCutOutboundOrderDetail.LockQuantity += needQuantity - residueQuantity; |
| | | outStocks.AddRange(autoAssignStocks); |
| | | float assignQuantity = needQuantity - residueQuantity; |
| | | // List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesPPCutOutboundOrderDetail.MaterielCode, "", mesPPOutboundOrder.WarehouseId); |
| | | // if (!stockInfos.Any()) |
| | | // { |
| | | // throw new Exception($"æªæ¾å°å¯åé
åºå"); |
| | | // } |
| | | // List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesPPCutOutboundOrderDetail.MaterielCode, needQuantity, out float residueQuantity); |
| | | // mesPPCutOutboundOrderDetail.LockQuantity += needQuantity - residueQuantity; |
| | | // outStocks.AddRange(autoAssignStocks); |
| | | // float assignQuantity = needQuantity - residueQuantity; |
| | | |
| | | float orderQuantity = mesPPCutOutboundOrderDetail.OrderQuantity; |
| | | for (int j = 0; j < autoAssignStocks.Count; j++) |
| | | { |
| | | float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPCutOutboundOrderDetail.MaterielCode).Sum(x => x.AssignQuantity);//åºåºè®¢åæç»å·²åé
æ°é |
| | | // float orderQuantity = mesPPCutOutboundOrderDetail.OrderQuantity; |
| | | // for (int j = 0; j < autoAssignStocks.Count; j++) |
| | | // { |
| | | // float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPCutOutboundOrderDetail.MaterielCode).Sum(x => x.AssignQuantity);//åºåºè®¢åæç»å·²åé
æ°é |
| | | |
| | | float palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPCutOutboundOrderDetail.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é |
| | | // float palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPCutOutboundOrderDetail.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é |
| | | |
| | | float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); |
| | | if (palletAssignQuantity < palletOutboundQuantity)//妿åºåºè¯¦æ
å·²åé
æ°éå°äºæçå·²åé
æ°éï¼åå¯ä»¥ç»§ç»æ·»å 该æçåºåºä¿¡æ¯ |
| | | { |
| | | float orderDetailNeedQuantity = mesPPCutOutboundOrderDetail.OrderQuantity - detailAssignQuantity; |
| | | if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) |
| | | { |
| | | mesPPCutOutboundOrderDetail.LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; |
| | | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, mesPPCutOutboundOrderDetail, autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | } |
| | | else |
| | | { |
| | | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, mesPPCutOutboundOrderDetail, autoAssignStocks[j], mesPPCutOutboundOrderDetail.OrderQuantity - mesPPCutOutboundOrderDetail.LockQuantity); |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | mesPPCutOutboundOrderDetail.LockQuantity = mesPPCutOutboundOrderDetail.OrderQuantity; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); |
| | | // float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); |
| | | // if (palletAssignQuantity < palletOutboundQuantity)//妿åºåºè¯¦æ
å·²åé
æ°éå°äºæçå·²åé
æ°éï¼åå¯ä»¥ç»§ç»æ·»å 该æçåºåºä¿¡æ¯ |
| | | // { |
| | | // float orderDetailNeedQuantity = mesPPCutOutboundOrderDetail.OrderQuantity - detailAssignQuantity; |
| | | // if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) |
| | | // { |
| | | // mesPPCutOutboundOrderDetail.LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; |
| | | // Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, mesPPCutOutboundOrderDetail, autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); |
| | | // outStockLockInfos.Add(outStockLockInfo); |
| | | // } |
| | | // else |
| | | // { |
| | | // Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, mesPPCutOutboundOrderDetail, autoAssignStocks[j], mesPPCutOutboundOrderDetail.OrderQuantity - mesPPCutOutboundOrderDetail.LockQuantity); |
| | | // outStockLockInfos.Add(outStockLockInfo); |
| | | // mesPPCutOutboundOrderDetail.LockQuantity = mesPPCutOutboundOrderDetail.OrderQuantity; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); |
| | | |
| | | return (outStocks, mesPPCutOutboundOrderDetail, outStockLockInfos, locationInfos); |
| | | } |
| | | // return (outStocks, mesPPCutOutboundOrderDetail, outStockLockInfos, locationInfos); |
| | | //} |
| | | |
| | | } |
| | | } |
| | |
| | | /// <param name="assignQuantity"></param> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | public Dt_OutStockLockInfo GetOutStockLockInfo(Dt_MesPPCutOutboundOrder mesPPCutOutboundOrder,Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail, Dt_StockInfo outStock, float assignQuantity, int? taskNum = null) |
| | | public List<Dt_OutStockLockInfo> GetOutStockLockInfos(Dt_MesPPCutOutboundOrder mesPPCutOutboundOrder, Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail, List<Dt_StockInfo> outStock, int? taskNum = null) |
| | | { |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | |
| | | foreach (var item in outStock) |
| | | { |
| | | Dt_OutStockLockInfo outStockLockInfo = new Dt_OutStockLockInfo() |
| | | { |
| | | PalletCode = outStock.PalletCode, |
| | | AssignQuantity = assignQuantity, |
| | | PalletCode = item.PalletCode, |
| | | AssignQuantity = item.Details.Where(x => x.MaterielCode == mesPPCutOutboundOrderDetail.MaterielCode).Sum(x => x.OutboundQuantity), |
| | | MaterielCode = mesPPCutOutboundOrderDetail.MaterielCode, |
| | | BatchNo = outStock.Details.FirstOrDefault()?.BatchNo ?? "", |
| | | LocationCode = outStock.LocationCode, |
| | | BatchNo = item.Details.FirstOrDefault().BatchNo, |
| | | LocationCode = item.LocationCode, |
| | | MaterielName = mesPPCutOutboundOrderDetail.MaterielName, |
| | | OrderDetailId = mesPPCutOutboundOrderDetail.Id, |
| | | OrderNo = mesPPCutOutboundOrder.OrderNo, |
| | | OrderType = mesPPCutOutboundOrder.OrderType, |
| | | OriginalQuantity = outStock.Details.Where(x => x.MaterielCode == mesPPCutOutboundOrderDetail.MaterielCode).Sum(x => x.StockQuantity), |
| | | OriginalQuantity = item.Details.Where(x => x.MaterielCode == mesPPCutOutboundOrderDetail.MaterielCode).Sum(x => x.StockQuantity), |
| | | Status = taskNum == null ? OutLockStockStatusEnum.å·²åé
.ObjToInt() : OutLockStockStatusEnum.åºåºä¸.ObjToInt(), |
| | | StockId = outStock.Id, |
| | | StockId = item.Id, |
| | | TaskNum = taskNum, |
| | | OrderQuantity = mesPPCutOutboundOrderDetail.OrderQuantity, |
| | | Unit = mesPPCutOutboundOrderDetail.Unit |
| | | }; |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | } |
| | | |
| | | return outStockLockInfo; |
| | | return outStockLockInfos; |
| | | } |
| | | |
| | | public Dt_OutStockLockInfo GetOutStockLockInfo(Dt_MesPPOutboundOrder mesPPOutboundOrder, Dt_StockInfo outStock, float assignQuantity, int? taskNum = null) |
| | |
| | | public IMesPPCutOutboundOrderService MesPPCutOutboundOrderService { get; } |
| | | |
| | | public IMesPPCutOutboundOrderDetailService MesPPCutOutboundOrderDetailService { get; } |
| | | public IProOutOrderService ProOutOrderService { get; } |
| | | public IProOutOrderDetailService ProOutOrderDetailService { get; } |
| | | |
| | | public OutboundService(IOutboundOrderDetailService outboundOrderDetailService,IMesPPOutboundOrderService mesPPOutboundOrderService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IMesOutboundOrderService mesOutboundOrderService, IProOutOrderService proOutOrderService, IProOutOrderDetailService proOutOrderDetailService) |
| | | public OutboundService(IOutboundOrderDetailService outboundOrderDetailService, IMesPPOutboundOrderDetailService mesPPOutboundOrderDetailService, IMesPPCutOutboundOrderDetailService mesPPCutOutboundOrderDetailService, IMesPPCutOutboundOrderService mesPPCutOutboundOrderService, IMesPPOutboundOrderService mesPPOutboundOrderService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IMesOutboundOrderService mesOutboundOrderService) |
| | | { |
| | | OutboundOrderDetailService = outboundOrderDetailService; |
| | | OutboundOrderService = outboundOrderService; |
| | | OutboundStockLockInfoService = outboundStockLockInfoService; |
| | | MesOutboundOrderService = mesOutboundOrderService; |
| | | MesPPOutboundOrderService = mesPPOutboundOrderService; |
| | | ProOutOrderService = proOutOrderService; |
| | | ProOutOrderDetailService = proOutOrderDetailService; |
| | | MesPPCutOutboundOrderService = mesPPCutOutboundOrderService; |
| | | MesPPCutOutboundOrderDetailService = mesPPCutOutboundOrderDetailService; |
| | | MesPPOutboundOrderDetailService = mesPPOutboundOrderDetailService; |
| | | } |
| | | } |
| | | } |
| | |
| | | throw new Exception($"æªæ¾å°åºåºåä¿¡æ¯"); |
| | | } |
| | | |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(outboundOrder.WarehouseId); |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.PPGetCanOutLocationCodes(outboundOrder.WarehouseId); |
| | | |
| | | return BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, StockSelectViewDTO>((a, b) => a.Id == b.StockId, (a, b) => new StockSelectViewDTO |
| | | { |
| | |
| | | return null; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æ¥è¯¢è®¢åPPç«åºåºåè§å¾ |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <param name="materielCode"></param> |
| | | /// <returns></returns> |
| | | public List<PPStockSelectViewDTO> PPGetStockSelectViews(int orderId, string materielCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_MesPPCutOutboundOrder mesPPCutOutboundOrder = _outboundRepository.MesPPCutOutboundOrderRepository.QueryFirst(x => x.Id == orderId); |
| | | if (mesPPCutOutboundOrder == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°åºåºåä¿¡æ¯"); |
| | | } |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.PPGetCanOutLocationCodes(mesPPCutOutboundOrder.WarehouseId); |
| | | |
| | | return BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, PPStockSelectViewDTO>((a, b) => a.Id == b.StockId, (a, b) => new PPStockSelectViewDTO |
| | | { |
| | | LocationCode = a.LocationCode, |
| | | MaterielCode = b.MaterielCode, |
| | | MaterielName = b.MaterielName, |
| | | PalletCode = a.PalletCode, |
| | | Unit = b.Unit, |
| | | CutedWidth = b.CutedWidth, |
| | | UseableQuantity = b.StockQuantity - b.OutboundQuantity |
| | | }, a => locationCodes.Contains(a.LocationCode), b => b.StockQuantity > b.OutboundQuantity && b.MaterielCode == materielCode, x => true).GroupBy(x => x.PalletCode).Select(x => new PPStockSelectViewDTO |
| | | { |
| | | LocationCode = x.FirstOrDefault()?.LocationCode ?? "", |
| | | MaterielCode = x.FirstOrDefault()?.MaterielCode ?? "", |
| | | MaterielName = x.FirstOrDefault()?.MaterielName ?? "", |
| | | Unit = x.FirstOrDefault()?.Unit ?? "", |
| | | CutedWidth = x.Sum(x => x.CutedWidth), |
| | | PalletCode = x.Key, |
| | | UseableQuantity = x.Sum(x => x.UseableQuantity) |
| | | }).ToList(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢è®¢åPPå¹³åºåºåè§å¾ |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <param name="materielCode"></param> |
| | | /// <returns></returns> |
| | | public List<PPStockSelectViewDTO> PPGetPKStockSelectViews(int orderId, string materielCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_MesPPCutOutboundOrder outboundOrder = _outboundRepository.MesPPCutOutboundOrderRepository.QueryFirst(x => x.Id == orderId); |
| | | if (outboundOrder == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°åºåºåä¿¡æ¯"); |
| | | } |
| | | return BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, PPStockSelectViewDTO>((a, b) => a.Id == b.StockId && a.WarehouseId == outboundOrder.WarehouseId, (a, b) => new PPStockSelectViewDTO |
| | | { |
| | | LocationCode = a.LocationCode, |
| | | MaterielCode = b.MaterielCode, |
| | | MaterielName = b.MaterielName, |
| | | PalletCode = a.PalletCode, |
| | | Unit = b.Unit, |
| | | CutedWidth = b.CutedWidth, |
| | | UseableQuantity = b.StockQuantity - b.OutboundQuantity |
| | | }, a => a.LocationCode.Contains("AGV_PP"), b => b.StockQuantity > b.OutboundQuantity && b.MaterielCode == materielCode, x => true).GroupBy(x => x.PalletCode).Select(x => new PPStockSelectViewDTO |
| | | { |
| | | LocationCode = x.FirstOrDefault()?.LocationCode ?? "", |
| | | MaterielCode = x.FirstOrDefault()?.MaterielCode ?? "", |
| | | MaterielName = x.FirstOrDefault()?.MaterielName ?? "", |
| | | Unit = x.FirstOrDefault()?.Unit ?? "", |
| | | CutedWidth = x.Sum(x => x.CutedWidth), |
| | | PalletCode = x.Key, |
| | | UseableQuantity = x.Sum(x => x.UseableQuantity) |
| | | }).ToList(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public WebResponseContent StockQueryData(SaveModel saveModel) |
| | | { |
| | |
| | | |
| | | return BaseDal.GetStockInfos(materielCode, batchNo, locationCodes); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | using System.Diagnostics.Metrics; |
| | | using System.Reflection.Metadata; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_DTO.Stock; |
| | | using SqlSugar; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// WMS忥æååºåºè³MES |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ShipmentOrderSync(MesShipmentOrderSync model) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMS_MES_ShipmentOrderSync.ToString()); |
| | | MESRoot<MesShipmentOrderSync> root = new MESRoot<MesShipmentOrderSync>() |
| | | { |
| | | From = "WMS", |
| | | DateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | Content = model |
| | | }; |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | | ContractResolver = new CamelCasePropertyNamesContractResolver() |
| | | }; |
| | | string request = JsonConvert.SerializeObject(root, settings); |
| | | string response = HttpMesHelper.Post(apiInfo.ApiAddress, request); |
| | | MesResponseContent mesResponseContent = response.DeserializeObject<MesResponseContent>(); |
| | | //è°ç¨æ¥å£ |
| | | if (mesResponseContent.BSucc == true) |
| | | { |
| | | content.OK(mesResponseContent.StrMsg); |
| | | } |
| | | else |
| | | { |
| | | content.Error(mesResponseContent.StrMsg); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | |
| | | MesResponseContent modelCount = new MesResponseContent(); |
| | | try |
| | | { |
| | | foreach (var item in model.Carriers) |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == item.Warehouse); |
| | | |
| | | Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA58.ToString()); |
| | | if (warehouse == null) |
| | | { |
| | | return MesResponseContent.Instance.Error("ä»åºä¿¡æ¯æªé
ç½®"); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == item.CarrierCode || x.WarehouseId == warehouse.WarehouseId); |
| | | if (stockInfo == null) |
| | | { |
| | | return MesResponseContent.Instance.Error("æªæ¾å°æ¤è½½å
·ç¼å·åºå"); |
| | | } |
| | | Dt_MesPPOutboundOrder mesPPOutboundOrder = BaseDal.Db.Queryable<Dt_MesPPOutboundOrder>().Where(x => x.TaskNo == model.TaskNo).Includes(x => x.Details).First(); |
| | | if (mesPPOutboundOrder != null) |
| | | { |
| | | return MesResponseContent.Instance.Error("å·²å卿¤ä»»å¡åå·"); |
| | | } |
| | | Dt_MesPPOutboundOrderDetail mesPPOutboundOrderDetail = new Dt_MesPPOutboundOrderDetail() |
| | | List<Dt_MesPPOutboundOrderDetail> mesPPOutboundOrderDetail = new List<Dt_MesPPOutboundOrderDetail>(); |
| | | foreach (var item in model.Carriers) |
| | | { |
| | | Warehouse = item.Warehouse, |
| | | //mesPPOutboundOrderDetail.Add(_mapper.Map<Dt_MesPPOutboundOrderDetail>(item)); |
| | | Dt_MesPPOutboundOrderDetail dt_MesPPOutboundOrderDetail = new Dt_MesPPOutboundOrderDetail |
| | | { |
| | | CarrierCode = item.CarrierCode, |
| | | Warehouse = item.Warehouse, |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt() |
| | | }; |
| | | |
| | | mesPPOutboundOrderDetail.Add(dt_MesPPOutboundOrderDetail); |
| | | } |
| | | Dt_MesPPOutboundOrder mesOutboundOrder = new Dt_MesPPOutboundOrder() |
| | | { |
| | | CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(), |
| | |
| | | Unit = model.Unit,//PPéè¦è½¬æ¢æç±³(鿱平æ¹(PNLæ°*é¢ç§¯)/宽度) |
| | | Width = model.Width, |
| | | TargetAddressCode = model.TargetAddressCode, |
| | | OrderType = TaskTypeEnum.MesHandPickOutbound.ObjToInt(), |
| | | OrderStatus = OutOrderStatusEnum.æªå¼å§.ObjToInt(), |
| | | OrderType = OutOrderTypeEnum.Issue.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | Details = new List<Dt_MesPPOutboundOrderDetail> { mesPPOutboundOrderDetail } |
| | | Details = mesPPOutboundOrderDetail |
| | | }; |
| | | #region |
| | | //Db.InsertNav(mesOutboundOrder).Include(x=>x.Details).ExecuteCommand(); |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | // List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | (List<Dt_StockInfo>, Dt_MesPPOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesPPOutboundOrderService.AssignStockOutbound(mesOutboundOrder); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | // List<Dt_StockInfo>? stockInfos = null; |
| | | // List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | // List<Dt_LocationInfo>? locationInfos = null; |
| | | // { |
| | | //(List<Dt_StockInfo>, Dt_MesPPOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesPPOutboundOrderService.AssignStockOutbound(mesOutboundOrder); |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | // result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // result.Item3.ForEach(x => |
| | | // { |
| | | // x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | // }); |
| | | |
| | | stockInfos = result.Item1; |
| | | mesOutboundOrder = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | mesPPOutboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // stockInfos = result.Item1; |
| | | // mesOutboundOrder = result.Item2; |
| | | // outStockLockInfos = result.Item3; |
| | | // locationInfos = result.Item4; |
| | | // mesPPOutboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | tasks.ForEach(x => |
| | | { |
| | | x.TargetAddress = model.TargetAddressCode; |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | // } |
| | | // else |
| | | // { |
| | | // throw new Exception("æ åºå"); |
| | | // } |
| | | // } |
| | | // tasks.ForEach(x => |
| | | // { |
| | | // x.TargetAddress = model.TargetAddressCode; |
| | | // }); |
| | | // _unitOfWorkManage.BeginTran(); |
| | | |
| | | int id = BaseDal.AddData(tasks); |
| | | outStockLockInfos.ForEach(x => |
| | | { |
| | | x.OrderNo = mesOutboundOrder.TaskNo; |
| | | x.OrderDetailId = id; |
| | | }); |
| | | //_outboundService.MesPPOutboundOrderService.Repository.AddData(mesOutboundOrder); |
| | | // int id = BaseDal.AddData(tasks); |
| | | // outStockLockInfos.ForEach(x => |
| | | // { |
| | | // x.OrderNo = mesOutboundOrder.TaskNo; |
| | | // x.OrderDetailId = id; |
| | | // }); |
| | | // //_outboundService.MesPPOutboundOrderService.Repository.AddData(mesOutboundOrder); |
| | | // Db.InsertNav(mesOutboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | // if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | // { |
| | | // WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | // if (!content.Status) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return MesResponseContent.Instance.Error(content.Message); |
| | | // } |
| | | // } |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // PushTasksToWCS(tasks); |
| | | |
| | | //} |
| | | #endregion |
| | | Db.InsertNav(mesOutboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return MesResponseContent.Instance.Error(content.Message); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | |
| | | } |
| | | return MesResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | try |
| | | { |
| | | foreach (var item in model.MaterialDetails) |
| | | { |
| | | |
| | | Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA58.ToString()); |
| | | if (warehouse == null) |
| | | { |
| | | return MesResponseContent.Instance.Error("ä»åºåºç¡ä¿¡æ¯æªé
ç½®"); |
| | | } |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == item.MaterialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return MesResponseContent.Instance.Error($"æªæ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | Dt_MesPPCutOutboundOrder mesPPCutOutboundOrder = BaseDal.Db.Queryable<Dt_MesPPCutOutboundOrder>().Where(x => x.TaskNo == model.TaskNo).Includes(x => x.Details).First(); |
| | | if (mesPPCutOutboundOrder != null) |
| | | { |
| | | return MesResponseContent.Instance.Error("å·²å卿¤ä»»å¡åå·"); |
| | | } |
| | | Dt_MesPPCutOutboundOrderDetail mesPPCutOutboundOrderDetail = new Dt_MesPPCutOutboundOrderDetail() |
| | | List<Dt_MesPPCutOutboundOrderDetail> mesPPCutOutboundOrderDetail = new List<Dt_MesPPCutOutboundOrderDetail>(); |
| | | foreach (var item in model.MaterialDetails) |
| | | { |
| | | MaterielCode = item.MaterialCode, |
| | | MaterielName = item.MaterialName, |
| | | OrderQuantity = item.RequiredQuantity, |
| | | Unit = item.Unit, |
| | | LayerCode = item.LayerCode, |
| | | Sequence = item.Sequence, |
| | | TargetAddressCode = item.TargetAddressCode, |
| | | Width = item.Width, |
| | | }; |
| | | mesPPCutOutboundOrderDetail.Add(_mapper.Map<Dt_MesPPCutOutboundOrderDetail>(item)); |
| | | } |
| | | Dt_MesPPCutOutboundOrder mesPPOutboundOrder = new Dt_MesPPCutOutboundOrder() |
| | | { |
| | | CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(), |
| | | TaskNo = model.TaskNo, |
| | | OrderType = TaskTypeEnum.MesOutbound.ObjToInt(), |
| | | OrderType = OutOrderTypeEnum.Issue.ObjToInt(), |
| | | OrderStatus = OutOrderStatusEnum.æªå¼å§.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | Details = new List<Dt_MesPPCutOutboundOrderDetail> { mesPPCutOutboundOrderDetail } |
| | | Details = mesPPCutOutboundOrderDetail, |
| | | }; |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | (List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesPPOutboundOrderService.AssignStockOutbound(mesPPOutboundOrder, mesPPCutOutboundOrderDetail); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | mesPPCutOutboundOrderDetail = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | tasks.ForEach(x => |
| | | { |
| | | x.TargetAddress = mesPPCutOutboundOrderDetail.TargetAddressCode; |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | int id = BaseDal.AddData(tasks); |
| | | outStockLockInfos.ForEach(x => |
| | | { |
| | | x.OrderNo = mesPPOutboundOrder.TaskNo; |
| | | x.OrderDetailId = id; |
| | | }); |
| | | //_outboundService.MesPPOutboundOrderService.Repository.AddData(mesOutboundOrder); |
| | | Db.InsertNav(mesPPOutboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return MesResponseContent.Instance.Error(content.Message); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks, "AGV_PP"); |
| | | } |
| | | #region |
| | | //List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | |
| | | //List<Dt_StockInfo>? stockInfos = null; |
| | | //List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | //List<Dt_LocationInfo>? locationInfos = null; |
| | | //{ |
| | | //(List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesPPOutboundOrderService.AssignStockOutbound(mesPPOutboundOrder, mesPPCutOutboundOrderDetail); |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | // result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // result.Item3.ForEach(x => |
| | | // { |
| | | // x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | // }); |
| | | |
| | | // stockInfos = result.Item1; |
| | | // mesPPCutOutboundOrderDetail = result.Item2; |
| | | // outStockLockInfos = result.Item3; |
| | | // locationInfos = result.Item4; |
| | | |
| | | // } |
| | | // else |
| | | // { |
| | | // throw new Exception("æ åºå"); |
| | | // } |
| | | //} |
| | | //tasks.ForEach(x => |
| | | //{ |
| | | // x.TargetAddress = mesPPCutOutboundOrderDetail.TargetAddressCode; |
| | | //}); |
| | | //_unitOfWorkManage.BeginTran(); |
| | | |
| | | //int id = BaseDal.AddData(tasks); |
| | | //outStockLockInfos.ForEach(x => |
| | | //{ |
| | | // x.OrderNo = mesPPOutboundOrder.TaskNo; |
| | | // x.OrderDetailId = id; |
| | | //}); |
| | | ////_outboundService.MesPPOutboundOrderService.Repository.AddData(mesOutboundOrder); |
| | | //Db.InsertNav(mesPPOutboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | //if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | //{ |
| | | // WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | // if (!content.Status) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return MesResponseContent.Instance.Error(content.Message); |
| | | // } |
| | | //} |
| | | //_unitOfWorkManage.CommitTran(); |
| | | //PushTasksToWCS(tasks, "AGV_PP"); |
| | | #endregion |
| | | return MesResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return MesResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | |
| | | MesResponseContent content = new MesResponseContent(); |
| | | try |
| | | { |
| | | |
| | | //é夿æ¥è¯¢ç«åº,å¹³åº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA58.ToString()); |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => |
| | | x.WarehouseId == warehouse.WarehouseId && |
| | |
| | | var stock = stockInfo.Details.FirstOrDefault(); |
| | | if (stock != null) |
| | | { |
| | | content.BSucc = true; |
| | | content.StrCode = "0000"; |
| | | content.StrMsg = "æ§è¡æå"; |
| | | content.MaterialCode = stock.MaterielCode; |
| | | content.Quantity = stock.StockQuantity; |
| | | content.Unit = stock.Unit; |
| | | content.Warehouse = warehouse.WarehouseCode; |
| | | content.WarehouseName = warehouse.WarehouseName; |
| | | content.CutedWidth = stock.CutedWidth; |
| | | content.CarrierCode = stockInfo.PalletCode; |
| | | content.MaterialLot = stock.BatchNo; |
| | | content.Content = new |
| | | { |
| | | MaterialCode = stock.MaterielCode, |
| | | Quantity = stock.StockQuantity, |
| | | Unit = stock.Unit, |
| | | Warehouse = warehouse.WarehouseCode, |
| | | WarehouseName = warehouse.WarehouseName, |
| | | CutedWidth = stock.CutedWidth, |
| | | CarrierCode = stockInfo.PalletCode, |
| | | MaterialLot = stock.BatchNo, |
| | | }; |
| | | } |
| | | return content; |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | { |
| | | return content.Error("æªæ¾å°ä»åºä¿¡æ¯"); |
| | | } |
| | | //夿æ¯å¦MESå
å
ä¿¡æ¯æ¯å¦éå¤ |
| | | List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>(); |
| | | foreach (var item in bagInfoModel.BagDetails) |
| | | { |
| | | foreach (var child in item.BagItems) |
| | | { |
| | | Dt_MesProInOrderDetail mesProInOrderDetail=new Dt_MesProInOrderDetail() |
| | | { |
| | | BagNo=item.BagNo, |
| | | ProductCode=item.ProductCode, |
| | | ProductVersion=item.ProductVersion, |
| | | SETQty=child.SETQty, |
| | | OKPCSQTY=child.OKPCSQTY, |
| | | DateCode=item.DateCode, |
| | | XQty=child.XQty, |
| | | XSite=child.XSite, |
| | | Weight=item.Weight, |
| | | PackingDate=item.PackingDate, |
| | | LotNumber=child.LotNumber, |
| | | ERPOrder=child.ERPOrder, |
| | | SaleOrder=child.SaleOrder, |
| | | MoNumber=child.MoNumber, |
| | | }; |
| | | mesProInOrderDetails.Add(mesProInOrderDetail); |
| | | } |
| | | } |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>(); |
| | | foreach (var item in mesProInOrderDetails) |
| | | { |
| | | proStockInfoDetails.Add(_mapper.Map<Dt_ProStockInfoDetail>(item)); |
| | | mesProInOrderDetails.Add(_mapper.Map<Dt_MesProInOrderDetail>(item)); |
| | | } |
| | | Dt_MesProInOrder mesProInOrder = new Dt_MesProInOrder() |
| | | { |
| | | WarehouseId = warehouse.WarehouseId, |
| | | BatchNo = bagInfoModel.BatchNo, |
| | | WorkCenter=bagInfoModel.WorkCenter, |
| | | MesProStatus = InOrderStatusEnum.æªå¼å§.ObjToInt(), |
| | | UnPackStock=bagInfoModel.UnPackStock, |
| | | Details= mesProInOrderDetails |
| | | }; |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | PalletCode = bagInfoModel.BatchNo, |
| | | PalletType = 1, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | proStockInfoDetails= proStockInfoDetails |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | Db.InsertNav(mesProInOrder).Include(x=>x.Details).ExecuteCommand(); |
| | | Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content.OK("æ¥æ¶æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public MesResponseContent BoxStockin(MesBoxInfoModel boxInfoModel) |
| | | { |
| | | MesResponseContent content = new MesResponseContent(); |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode==WarehouseEnum.HA101.ToString()); |
| | | //è·åMESå
å
ä¿¡æ¯ |
| | | List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>(); |
| | | foreach (var item in boxInfoModel.Bags) |
| | | { |
| | | foreach (var child in item.BagItems) |
| | | { |
| | | Dt_MesProInOrderDetail mesProInOrderDetail = new Dt_MesProInOrderDetail() |
| | | { |
| | | BagNo = item.BagNo, |
| | | ProductCode = item.ProductCode, |
| | | ProductVersion = item.ProductVersion, |
| | | SETQty = child.SETQty, |
| | | OKPCSQTY = child.OKPCSQTY, |
| | | DateCode = item.DateCode, |
| | | XQty = child.XQty, |
| | | XSite = child.XSite, |
| | | Weight = item.Weight, |
| | | PackingDate = item.PackingDate, |
| | | LotNumber = child.LotNumber, |
| | | ERPOrder = child.ERPOrder, |
| | | SaleOrder = child.SaleOrder, |
| | | MoNumber = child.MoNumber, |
| | | }; |
| | | mesProInOrderDetails.Add(mesProInOrderDetail); |
| | | } |
| | | } |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>(); |
| | | foreach (var item in mesProInOrderDetails) |
| | | { |
| | | proStockInfoDetails.Add(_mapper.Map<Dt_ProStockInfoDetail>(item)); |
| | | } |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | PalletCode = boxInfoModel.BoxNo, |
| | | PalletType = 0, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | ShipmentOrder= boxInfoModel.ShipmentOrder, |
| | | StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(), |
| | | proStockInfoDetails = proStockInfoDetails |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content.OK("å¤å
æ¥æ¶æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æåè¿å·¥æåº |
| | | /// </summary> |
| | |
| | | } |
| | | Dt_Task exsit2 = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode); |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | return MesResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// çæPP大å·åºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="keys">åºåºåæç»ä¸»é®</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent MESPPGenerateOutboundTasks(int[] keys) |
| | | { |
| | | try |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | | List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails = new List<Dt_MesPPOutboundOrderDetail>(); |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?, Dt_MesPPOutboundOrder mesPPOutboundOrder) result = MESPPOutboundTaskDataHandle(keys); |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | | stockInfos.AddRange(result.Item2); |
| | | } |
| | | if (result.Item3 != null && result.Item3.Count > 0) |
| | | { |
| | | outboundOrderDetails.AddRange(result.Item3); |
| | | } |
| | | if (result.Item4 != null && result.Item4.Count > 0) |
| | | { |
| | | outStockLockInfos.AddRange(result.Item4); |
| | | } |
| | | if (result.Item5 != null && result.Item5.Count > 0) |
| | | { |
| | | locationInfos.AddRange(result.Item5); |
| | | } |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks.AddRange(result.Item1); |
| | | } |
| | | if (result.mesPPOutboundOrder != null) |
| | | { |
| | | |
| | | } |
| | | |
| | | WebResponseContent content = MESPPGenerateOutboundTaskDataUpdate(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, result.mesPPOutboundOrder); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// PP大å·åºåºä»»å¡æ°æ®å¤ç |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?, Dt_MesPPOutboundOrder mesPPOutboundOrder) MESPPOutboundTaskDataHandle(int[] keys) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails = BaseDal.Db.Queryable<Dt_MesPPOutboundOrderDetail>().Where(x => keys.Contains(x.Id)).ToList(); |
| | | if (outboundOrderDetails == null || outboundOrderDetails.Count == 0) |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | { |
| | | throw new Exception("æéåºåºåæç»åå¨åºåºä¸æå·²å®æ"); |
| | | } |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_MesPPOutboundOrderDetail>? orderDetails = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | Dt_MesPPOutboundOrder? mesPPOutboundOrders = null; |
| | | if (outboundOrderDetails.FirstOrDefault().OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | (List<Dt_StockInfo>, List<Dt_MesPPOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>, Dt_MesPPOutboundOrder mesPPOutboundOrder) result = _outboundService.MesPPOutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | Dt_MesPPOutboundOrder outboundOrder = _outboundService.MesPPOutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | { |
| | | (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound, |
| | | (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate, |
| | | (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality, |
| | | _ => new TaskTypeEnum() |
| | | }; |
| | | tasks = GetTasks(result.Item1, typeEnum); |
| | | result.Item2.ForEach(x => |
| | | { |
| | | x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | orderDetails = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | mesPPOutboundOrders = result.mesPPOutboundOrder; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | //else |
| | | //{ |
| | | // List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetails.oi, OutLockStockStatusEnum.å·²åé
); |
| | | // if (stockLockInfos != null && stockLockInfos.Count > 0) |
| | | // { |
| | | // List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); |
| | | // tasks = GetTasks(stocks); |
| | | // } |
| | | //} |
| | | |
| | | return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos, mesPPOutboundOrders); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// PPå¹³åºç´æ¥åºåº |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PPGeneratePKOutboundTask(int orderDetailId, List<PPStockSelectViewDTO> stockSelectViews) |
| | | { |
| | | try |
| | | { |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPCutOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = PPOutboundTaskDataHandle(orderDetailId, stockSelectViews); |
| | | |
| | | WebResponseContent content = PPGenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5); |
| | | |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// PPç«åºå°å·ç´æ¥åºåº |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PPCutOutGenerateOutboundTasks(int orderDetailId, List<PPStockSelectViewDTO> stockSelectViews) |
| | | { |
| | | try |
| | | { |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPCutOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = PPOutboundTaskDataHandle(orderDetailId, stockSelectViews); |
| | | |
| | | WebResponseContent content = PPGenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5); |
| | | |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºåºä»»å¡æ°æ®å¤ç |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPCutOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) PPOutboundTaskDataHandle(int orderDetailId, List<PPStockSelectViewDTO> stockSelectViews) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | Dt_MesPPCutOutboundOrderDetail outboundOrderDetail = _outboundService.MesPPCutOutboundOrderDetailService.Repository.QueryFirst(x => x.Id == orderDetailId); |
| | | |
| | | if (outboundOrderDetail == null) |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | if (stockSelectViews.Sum(x => x.UseableQuantity) > outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity) |
| | | { |
| | | throw new Exception("éæ©æ°éè¶
åºåæ®æ°é"); |
| | | } |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | Dt_MesPPCutOutboundOrderDetail? orderDetail = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | (List<Dt_StockInfo>, Dt_MesPPCutOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesPPCutOutboundOrderDetailService.AssignStockOutbound(outboundOrderDetail, stockSelectViews); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | Dt_MesPPCutOutboundOrder outboundOrder = _outboundService.MesPPCutOutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId); |
| | | TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | { |
| | | (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound, |
| | | (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate, |
| | | (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality, |
| | | _ => new TaskTypeEnum() |
| | | }; |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.Outbound); |
| | | result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | orderDetail = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.å·²åé
); |
| | | if (stockLockInfos != null && stockLockInfos.Count > 0) |
| | | { |
| | | List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); |
| | | tasks = GetTasks(stocks, TaskTypeEnum.Outbound); |
| | | } |
| | | } |
| | | |
| | | return (tasks, stockInfos, orderDetail == null ? null : new List<Dt_MesPPCutOutboundOrderDetail> { orderDetail }, outStockLockInfos, locationInfos); |
| | | } |
| | | |
| | | public WebResponseContent PPGenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_MesPPCutOutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | BaseDal.AddData(tasks); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | WebResponseContent content = _outboundService.MesPPCutOutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | } |
| | | } |
| | | else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0) |
| | | { |
| | | outboundOrderDetails.ForEach(x => |
| | | { |
| | | x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | |
| | | _outboundService.MesPPCutOutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | #region |
| | | /// <summary> |
| | | /// çæPPå°å·åºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="keys">åºåºåæç»ä¸»é®</param> |
| | | /// <returns></returns> |
| | | //public WebResponseContent PPCutOutGenerateOutboundTasks(int[] keys) |
| | | //{ |
| | | // try |
| | | // { |
| | | // List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | // List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | | // List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | // List<Dt_MesPPCutOutboundOrderDetail> outboundOrderDetails = new List<Dt_MesPPCutOutboundOrderDetail>(); |
| | | // List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | // List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | |
| | | // (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPCutOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = PPCutOutboundTaskDataHandle(keys); |
| | | // if (result.Item2 != null && result.Item2.Count > 0) |
| | | // { |
| | | // stockInfos.AddRange(result.Item2); |
| | | // } |
| | | // if (result.Item3 != null && result.Item3.Count > 0) |
| | | // { |
| | | // outboundOrderDetails.AddRange(result.Item3); |
| | | // } |
| | | // if (result.Item4 != null && result.Item4.Count > 0) |
| | | // { |
| | | // outStockLockInfos.AddRange(result.Item4); |
| | | // } |
| | | // if (result.Item5 != null && result.Item5.Count > 0) |
| | | // { |
| | | // locationInfos.AddRange(result.Item5); |
| | | // } |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // tasks.AddRange(result.Item1); |
| | | // } |
| | | |
| | | // WebResponseContent content = PPCutOutGenerateOutboundTaskDataUpdate(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos); |
| | | // return content; |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// PPå°å·åºåºä»»å¡æ°æ®å¤ç |
| | | ///// </summary> |
| | | ///// <param name="orderDetailId"></param> |
| | | ///// <param name="stockSelectViews"></param> |
| | | ///// <returns></returns> |
| | | ///// <exception cref="Exception"></exception> |
| | | //public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPCutOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) PPCutOutboundTaskDataHandle(int[] keys) |
| | | //{ |
| | | // List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | // List<Dt_MesPPCutOutboundOrderDetail> outboundOrderDetails = BaseDal.Db.Queryable<Dt_MesPPCutOutboundOrderDetail>().Where(x => keys.Contains(x.Id)).ToList(); |
| | | // if (outboundOrderDetails == null || outboundOrderDetails.Count == 0) |
| | | // { |
| | | // throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | // } |
| | | // if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | // { |
| | | // throw new Exception("æéåºåºåæç»åå¨åºåºä¸æå·²å®æ"); |
| | | // } |
| | | // List<Dt_StockInfo>? stockInfos = null; |
| | | // List<Dt_MesPPCutOutboundOrderDetail>? orderDetails = null; |
| | | // List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | // List<Dt_LocationInfo>? locationInfos = null; |
| | | // if (outboundOrderDetails.FirstOrDefault().OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | // { |
| | | // (List<Dt_StockInfo>, List<Dt_MesPPCutOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesPPCutOutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails); |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // Dt_MesPPCutOutboundOrder outboundOrder = _outboundService.MesPPCutOutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | // //TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | // //{ |
| | | // // (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound, |
| | | // // (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate, |
| | | // // (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality, |
| | | // // _ => new TaskTypeEnum() |
| | | // //}; |
| | | // tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | // result.Item2.ForEach(x => |
| | | // { |
| | | // x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // }); |
| | | // result.Item3.ForEach(x => |
| | | // { |
| | | // x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | // }); |
| | | |
| | | // stockInfos = result.Item1; |
| | | // orderDetails = result.Item2; |
| | | // outStockLockInfos = result.Item3; |
| | | // locationInfos = result.Item4; |
| | | // } |
| | | // else |
| | | // { |
| | | // throw new Exception("æ åºå"); |
| | | // } |
| | | // } |
| | | // //else |
| | | // //{ |
| | | // // List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetails.OrderId, OutLockStockStatusEnum.å·²åé
); |
| | | // // if (stockLockInfos != null && stockLockInfos.Count > 0) |
| | | // // { |
| | | // // List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); |
| | | // // tasks = GetTasks(stocks); |
| | | // // } |
| | | // //} |
| | | |
| | | // return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// çæPPå°å·åºåºä»»å¡åæ°æ®æ´æ°å°æ°æ®åº |
| | | ///// </summary> |
| | | ///// <param name="tasks"></param> |
| | | ///// <param name="stockInfos"></param> |
| | | ///// <param name="outboundOrderDetails"></param> |
| | | ///// <param name="outStockLockInfos"></param> |
| | | ///// <param name="locationInfos"></param> |
| | | ///// <returns></returns> |
| | | //public WebResponseContent PPCutOutGenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_MesPPCutOutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | //{ |
| | | // try |
| | | // { |
| | | // _unitOfWorkManage.BeginTran(); |
| | | |
| | | // BaseDal.AddData(tasks); |
| | | // if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | // { |
| | | // stockInfos.ForEach(x => |
| | | // { |
| | | // x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | // }); |
| | | // WebResponseContent content = _outboundService.MesPPCutOutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | // if (!content.Status) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return content; |
| | | // } |
| | | // } |
| | | // else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0) |
| | | // { |
| | | // outboundOrderDetails.ForEach(x => |
| | | // { |
| | | // x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // }); |
| | | |
| | | // _outboundService.MesPPCutOutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | // } |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // PushTasksToWCS(tasks,"AGV_PP"); |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | #endregion |
| | | /// <summary> |
| | | /// çæPP大å·åºåºä»»å¡åæ°æ®æ´æ°å°æ°æ®åº |
| | | /// </summary> |
| | | /// <param name="tasks"></param> |
| | | /// <param name="stockInfos"></param> |
| | | /// <param name="outboundOrderDetails"></param> |
| | | /// <param name="outStockLockInfos"></param> |
| | | /// <param name="locationInfos"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent MESPPGenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_MesPPOutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null, Dt_MesPPOutboundOrder? mesPPOutboundOrder = null) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | BaseDal.AddData(tasks); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | WebResponseContent content = _outboundService.MesPPOutboundOrderDetailService.LockOutboundStockDataUpdate(mesPPOutboundOrder, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | } |
| | | } |
| | | else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0) |
| | | { |
| | | outboundOrderDetails.ForEach(x => |
| | | { |
| | | x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | |
| | | _outboundService.MesPPOutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.TaskNum == taskNum); |
| | | List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | List<Dt_MesOutboundOrder> mesOutboundOrders = new List<Dt_MesOutboundOrder>(); |
| | | |
| | | List<Dt_MesPPOutboundOrder> mesPPOutboundOrders = new List<Dt_MesPPOutboundOrder>(); |
| | | if ((outStockLockInfos == null || outStockLockInfos.Count == 0) && warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && (task.TaskType != TaskTypeEnum.OutEmpty.ObjToInt())) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåºè¯¦æ
ä¿¡æ¯"); |
| | |
| | | mesOutboundOrder.OrderStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | mesOutboundOrders.Add(mesOutboundOrder); |
| | | } |
| | | } |
| | | //PPåºåºä»»å¡å®æå¤æããããããããããããããããã |
| | | else if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() && warehouse.WarehouseCode == WarehouseEnum.HA58.ToString()) |
| | | { |
| | | Dt_MesPPOutboundOrder mesPPOutboundOrder = _outboundService.MesPPOutboundOrderService.Repository.QueryFirst(x => x.OrderNo == item.OrderNo); |
| | | if (mesPPOutboundOrder != null) |
| | | { |
| | | mesPPOutboundOrder.OverOutQuantity = item.AssignQuantity; |
| | | if (mesPPOutboundOrder.OverOutQuantity == mesPPOutboundOrder.OrderQuantity) |
| | | { |
| | | mesPPOutboundOrder.OrderStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | mesPPOutboundOrders.Add(mesPPOutboundOrder); |
| | | } |
| | | } |
| | | else |
| | |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, (LocationStatusEnum)beforeStatus, LocationStatusEnum.Free, LocationChangeType.OutboundCompleted, stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | //PPåºåºä»»å¡å®æå¤æããããããããããããããããã |
| | | if (warehouse.WarehouseCode == WarehouseEnum.HA58.ToString() && task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | { |
| | | _outboundService.MesPPOutboundOrderService.Repository.UpdateData(mesPPOutboundOrders); |
| | | MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesPPOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, stockInfo.Details.Where(x => x.MaterielCode == mesPPOutboundOrders.FirstOrDefault().MaterialCode).Sum(x => x.StockQuantity)); |
| | | UploadMesMaterialLotaAcept(model); |
| | | _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | } |
| | | if (warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | { |
| | | _outboundService.OutboundOrderService.TestOutUpload(outboundOrderDetails.FirstOrDefault().OrderId, outStockLockInfos); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | #region |
| | | ///// <summary> |
| | | ///// çæåºåºä»»å¡ |
| | | ///// </summary> |
| | | ///// <param name="keys">åºåºåæç»ä¸»é®</param> |
| | | ///// <returns></returns> |
| | | //public WebResponseContent MESPPGenerateOutboundTasks(int[] keys) |
| | | //{ |
| | | // try |
| | | // { |
| | | // List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | // List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | | // List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | // List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails = new List<Dt_MesPPOutboundOrderDetail>(); |
| | | // List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | // List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | |
| | | // (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = MESPPOutboundTaskDataHandle(keys); |
| | | // if (result.Item2 != null && result.Item2.Count > 0) |
| | | // { |
| | | // stockInfos.AddRange(result.Item2); |
| | | // } |
| | | // if (result.Item3 != null && result.Item3.Count > 0) |
| | | // { |
| | | // outboundOrderDetails.AddRange(result.Item3); |
| | | // } |
| | | // if (result.Item4 != null && result.Item4.Count > 0) |
| | | // { |
| | | // outStockLockInfos.AddRange(result.Item4); |
| | | // } |
| | | // if (result.Item5 != null && result.Item5.Count > 0) |
| | | // { |
| | | // locationInfos.AddRange(result.Item5); |
| | | // } |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // tasks.AddRange(result.Item1); |
| | | // } |
| | | |
| | | // WebResponseContent content = MESPPGenerateOutboundTaskDataUpdate(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos); |
| | | // return content; |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// åºåºä»»å¡æ°æ®å¤ç |
| | | ///// </summary> |
| | | ///// <param name="orderDetailId"></param> |
| | | ///// <param name="stockSelectViews"></param> |
| | | ///// <returns></returns> |
| | | ///// <exception cref="Exception"></exception> |
| | | //public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) MESPPOutboundTaskDataHandle(int[] keys) |
| | | //{ |
| | | // List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | // List<Dt_MesPPOutboundOrderDetail> outboundOrderDetailss = _outboundService.MesPPOutboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id)); |
| | | // List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails = BaseDal.Db.Queryable<Dt_MesPPOutboundOrderDetail>().Where(x => keys.Contains(x.Id)).ToList(); |
| | | // if (outboundOrderDetails == null || outboundOrderDetails.Count == 0) |
| | | // { |
| | | // throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | // } |
| | | // if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | // { |
| | | // throw new Exception("æéåºåºåæç»åå¨åºåºä¸æå·²å®æ"); |
| | | // } |
| | | // List<Dt_StockInfo>? stockInfos = null; |
| | | // List<Dt_MesPPOutboundOrderDetail>? orderDetails = null; |
| | | // List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | // List<Dt_LocationInfo>? locationInfos = null; |
| | | // //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | // { |
| | | // (List<Dt_StockInfo>, List<Dt_MesPPOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesPPOutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails); |
| | | |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // Dt_MesPPOutboundOrder outboundOrder = _outboundService.MesPPOutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | // TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | // { |
| | | // (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound, |
| | | // (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate, |
| | | // (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality, |
| | | // _ => new TaskTypeEnum() |
| | | // }; |
| | | // tasks = GetTasks(result.Item1, typeEnum); |
| | | // result.Item2.ForEach(x => |
| | | // { |
| | | // x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // }); |
| | | // result.Item3.ForEach(x => |
| | | // { |
| | | // x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | // }); |
| | | |
| | | // stockInfos = result.Item1; |
| | | // orderDetails = result.Item2; |
| | | // outStockLockInfos = result.Item3; |
| | | // locationInfos = result.Item4; |
| | | // } |
| | | // else |
| | | // { |
| | | // throw new Exception("æ åºå"); |
| | | // } |
| | | // } |
| | | // //else |
| | | // //{ |
| | | // // List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.å·²åé
); |
| | | // // if (stockLockInfos != null && stockLockInfos.Count > 0) |
| | | // // { |
| | | // // List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); |
| | | // // tasks = GetTasks(stocks); |
| | | // // } |
| | | // //} |
| | | |
| | | // return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// çæåºåºä»»å¡åæ°æ®æ´æ°å°æ°æ®åº |
| | | ///// </summary> |
| | | ///// <param name="tasks"></param> |
| | | ///// <param name="stockInfos"></param> |
| | | ///// <param name="outboundOrderDetails"></param> |
| | | ///// <param name="outStockLockInfos"></param> |
| | | ///// <param name="locationInfos"></param> |
| | | ///// <returns></returns> |
| | | //public WebResponseContent MESPPGenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_MesPPOutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | //{ |
| | | // try |
| | | // { |
| | | // _unitOfWorkManage.BeginTran(); |
| | | |
| | | // BaseDal.AddData(tasks); |
| | | // if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | // { |
| | | // stockInfos.ForEach(x => |
| | | // { |
| | | // x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | // }); |
| | | // WebResponseContent content = _outboundService.MesPPOutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | // if (!content.Status) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return content; |
| | | // } |
| | | // } |
| | | // else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0) |
| | | // { |
| | | // outboundOrderDetails.ForEach(x => |
| | | // { |
| | | // x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // }); |
| | | |
| | | // _outboundService.MesPPOutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | // } |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // PushTasksToWCS(tasks); |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | |
| | | //} |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | using WIDESEA_DTO.ERP; |
| | | using WIDESEA_DTO.MES; |
| | | using WIDESEA_Core.Helper; |
| | | using Autofac.Core; |
| | | using WIDESEA_DTO.Stock; |
| | | |
| | | namespace WIDESEA_WMSServer.Controllers.MES |
| | | { |
| | |
| | | return _taskService.RworkTask(model); |
| | | } |
| | | /// <summary> |
| | | /// MESæåå
å
ä¿¡æ¯æ¥æ¶ |
| | | /// MESæåå
¥åºåæ¥æ¶ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | |
| | | return _taskService.BagInfoSync(model.Content); |
| | | } |
| | | /// <summary> |
| | | /// MESæåå¤å
ä¿¡æ¯æ¥æ¶ |
| | | /// çæMESPPä»å¤§å·åºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <param name="keys"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("BoxStockin"), AllowAnonymous] |
| | | public MesResponseContent BoxStockin([FromBody] Root<MesBoxInfoModel> model) |
| | | [HttpPost, HttpGet, Route("MESPPGenerateOutboundTasks"), AllowAnonymous] |
| | | public WebResponseContent MESPPGenerateOutboundTasks([FromBody] int[] keys) |
| | | { |
| | | return _taskService.BoxStockin(model.Content); |
| | | return _taskService.MESPPGenerateOutboundTasks(keys); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// MESæååºåºæ¥å£è°ç¨ |
| | | /// çæMESPPä»å°å·åºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="keys"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ShipmentOrderSync"), AllowAnonymous] |
| | | public WebResponseContent ShipmentOrderSync([FromBody] MesShipmentOrderSync model) |
| | | //[HttpPost, HttpGet, Route("PPCutOutGenerateOutboundTasks"), AllowAnonymous] |
| | | //public WebResponseContent PPCutOutGenerateOutboundTasks([FromBody] int[] keys) |
| | | //{ |
| | | // return _taskService.PPCutOutGenerateOutboundTasks(keys); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("PPCutOutGenerateOutboundTasks"), AllowAnonymous] |
| | | public WebResponseContent PPCutOutGenerateOutboundTasks(int orderDetailId, [FromBody] List<PPStockSelectViewDTO> stockSelectViews) |
| | | { |
| | | return _taskService.ShipmentOrderSync(model); |
| | | return _taskService.PPCutOutGenerateOutboundTasks(orderDetailId, stockSelectViews); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// PPå¹³åºç´æ¥åºåº |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("PPGeneratePKOutboundTask"), AllowAnonymous] |
| | | public WebResponseContent PPGeneratePKOutboundTask(int orderDetailId, [FromBody] List<PPStockSelectViewDTO> stockSelectViews) |
| | | { |
| | | return _taskService.PPGeneratePKOutboundTask(orderDetailId, stockSelectViews); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Autofac.Core; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseController; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.MES; |
| | | using WIDESEA_DTO.Outbound; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_WMSServer.Controllers.Outbound |
| | | { |
| | | /// <summary> |
| | | /// MESåºåºå |
| | | /// PPä»å¤§å·MESåºåºå |
| | | /// </summary> |
| | | [Route("api/mesPPOutboundOrderDetail")] |
| | | [ApiController] |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢PPç«åºåºåè§å¾ |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <param name="materlCode"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("PPGetStockSelectViews")] |
| | | public List<PPStockSelectViewDTO> PPGetStockSelectViews(int orderId, string materielCode) |
| | | { |
| | | return Service.PPGetStockSelectViews(orderId, materielCode); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢è®¢åPPå¹³åºåºåè§å¾ |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <param name="materielCode"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("PPGetPKStockSelectViews")] |
| | | public List<PPStockSelectViewDTO> PPGetPKStockSelectViews(int orderId, string materielCode) |
| | | { |
| | | return Service.PPGetPKStockSelectViews(orderId, materielCode); |
| | | } |
| | | /// <summary> |
| | | /// æ ¹æ®æçååºåºæ¥è¯¢åºåä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | |
| | | { |
| | | return Service.GenerateOutboundTasks(keys); |
| | | } |
| | | |
| | | ///// <summary> |
| | | ///// çæMESPPä»å¤§å·åºåºä»»å¡ |
| | | ///// </summary> |
| | | ///// <param name="keys"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost, HttpGet, Route("MESPPGenerateOutboundTasks"), AllowAnonymous] |
| | | //public WebResponseContent MESPPGenerateOutboundTasks([FromBody] int[] keys) |
| | | //{ |
| | | // return Service.MESPPGenerateOutboundTasks(keys); |
| | | //} |
| | | /// <summary> |
| | | /// åºåºä»»å¡å®æ |
| | | /// </summary> |