已删除4个文件
已修改22个文件
已添加5个文件
已重命名1个文件
| | |
| | | /// </summary> |
| | | public string GroupId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ç©æé¿åº¦ |
| | | /// </summary> |
| | | public int TaskLength { get; set; } |
| | | |
| | | public string AGVArea { get; set; } |
| | | |
| | | public int PalletType { get; set; } |
| | |
| | | /// <param name="palletCode">æçå·</param> |
| | | /// <param name="sourceAddress">èµ·å§å°å</param> |
| | | /// <returns></returns> |
| | | WebResponseContent RequestWMSTask(string palletCode, string sourceAddress); |
| | | WebResponseContent RequestWMSTask(string palletCode, string sourceAddress, string materielBoxCode = ""); |
| | | |
| | | /// <summary> |
| | | /// åWMSç³è¯·ä»»å¡ |
| | |
| | | /// <param name="sourceAddress">èµ·å§å°å</param> |
| | | /// <param name="roadway">å··éå·</param> |
| | | /// <returns></returns> |
| | | WebResponseContent RequestWMSTask(string palletCode, string sourceAddress, string roadway); |
| | | //WebResponseContent RequestWMSTask(string palletCode, string sourceAddress, string roadway); |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | [ExporterHeader(DisplayName = "ä»»å¡ç»")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "ä»»å¡ç»")] |
| | | public string GroupId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ç©æé¿åº¦ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "ä»»å¡ç©æé¿åº¦")] |
| | | [ExporterHeader(DisplayName = "ä»»å¡ç©æé¿åº¦")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "ä»»å¡ç©æé¿åº¦")] |
| | | public int TaskLength { get; set; } |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | |
| | | //è°ç¨AGVé¢è°åº¦æ¥å£ |
| | | AgvScheduleTaskDTO agvScheduleTask = new AgvScheduleTaskDTO() |
| | | { |
| | | PositionCode = task.CurrentAddress, |
| | | NextTask = "60", |
| | | PositionCode = "8001", |
| | | NextTask = "90", |
| | | UseableLayers = "1", |
| | | CacheCount = "1", |
| | | Update = "0", |
| | | AgvTyp = "11", |
| | | AgvTyp = "10", |
| | | PreTaskQty = "1", |
| | | ReqCode = Guid.NewGuid().ToString().Replace("-", ""), |
| | | ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | |
| | | /// <param name="palletCode">æçå·</param> |
| | | /// <param name="sourceAddress">èµ·å§å°å</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress) |
| | | public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress, string materielBoxCode = "") |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°WMSApiå°å"); |
| | | } |
| | | string responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}"); |
| | | string responseStr = ""; |
| | | if (!string.IsNullOrEmpty(materielBoxCode)) |
| | | { |
| | | responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}&materielBoxCode={materielBoxCode}"); |
| | | } |
| | | else |
| | | { |
| | | responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}"); |
| | | } |
| | | WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr); |
| | | if (responseContent != null && responseContent.Status && responseContent.Data != null) |
| | | { |
| | |
| | | /// <param name="sourceAddress"></param> |
| | | /// <param name="roadway"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress, string roadway) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string address = AppSettings.Get("WMSApiAddress"); |
| | | if (string.IsNullOrEmpty(address)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°WMSApiå°å"); |
| | | } |
| | | string responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={roadway}&palletCode={palletCode}"); |
| | | WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr); |
| | | if (responseContent != null && responseContent.Status && responseContent.Data != null) |
| | | { |
| | | WMSTaskDTO? taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(responseContent.Data.ToString()); |
| | | if (taskDTO != null) |
| | | { |
| | | content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | } |
| | | } |
| | | //public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress, string roadway) |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // string address = AppSettings.Get("WMSApiAddress"); |
| | | // if (string.IsNullOrEmpty(address)) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"æªæ¾å°WMSApiå°å"); |
| | | // } |
| | | // string responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={roadway}&palletCode={palletCode}"); |
| | | // WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr); |
| | | // if (responseContent != null && responseContent.Status && responseContent.Data != null) |
| | | // { |
| | | // WMSTaskDTO? taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(responseContent.Data.ToString()); |
| | | // if (taskDTO != null) |
| | | // { |
| | | // content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // content = WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | /// </summary> |
| | | public short CheckPos { get; set; } |
| | | } |
| | | public class R_ConveyorLineGMInfo : DeviceCommand |
| | | { |
| | | /// <summary> |
| | | /// ç®±å· |
| | | /// </summary> |
| | | /// <summary> |
| | | [DataLength(120)] |
| | | public string Boxcode { get; set; } |
| | | } |
| | | public class R_ConveyorLineFLInfo : DeviceCommand |
| | | { |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// ååºä¿¡å· |
| | | /// </summary> |
| | | ACK |
| | | ACK, |
| | | /// <summary> |
| | | /// æ¡ç |
| | | /// </summary> |
| | | Boxcode |
| | | } |
| | | |
| | | public enum R_ConveyorLineWorkType |
| | |
| | | { |
| | | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK) |
| | | { |
| | | if (!string.IsNullOrEmpty(conveyorLineInfoRead.Barcode)) |
| | | string boxcode = device.GetValue<R_ConveyorLineDB, string>(R_ConveyorLineDB.Boxcode, item.StationCode); |
| | | |
| | | if (!string.IsNullOrEmpty(boxcode)) |
| | | { |
| | | WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode); |
| | | string sc = device.Communicator.Read<string>("DB900.598.0"); |
| | | WriteError(device.DeviceName, $"读åå¼ï¼{boxcode},对æ¯{sc}"); |
| | | string boxEndCode = ""; |
| | | if (boxcode.LastIndexOf(",SC:") >= 0) |
| | | { |
| | | boxEndCode = "M" + boxcode.Substring(0, boxcode.LastIndexOf(",SC:")) + sc.Substring(sc.IndexOf(",SC:")).Replace("\0", ""); |
| | | } |
| | | else if (boxcode.LastIndexOf(",SC") > 0) |
| | | { |
| | | boxEndCode = "M" + boxcode.Substring(0, boxcode.LastIndexOf(",SC")) + sc.Substring(sc.IndexOf("SC:")).Replace("\0", ""); |
| | | } |
| | | else if (boxcode.LastIndexOf(",S") > 0) |
| | | { |
| | | boxEndCode = "M" + boxcode.Substring(0, boxcode.LastIndexOf(",S")) + sc.Substring(sc.IndexOf("SC:")).Replace("\0", ""); |
| | | } |
| | | |
| | | //å
¥åºç³è¯·ä»»å¡ |
| | | WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode, boxEndCode); |
| | | if (content.Status) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | } |
| | | //if (!string.IsNullOrEmpty(conveyorLineInfoRead.Barcode)) |
| | | //{ |
| | | // WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode); |
| | | // if (content.Status) |
| | | // { |
| | | // device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | // } |
| | | //} |
| | | } |
| | | else if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && conveyorLineSignalWrite.ACK) |
| | | { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | #region << ç æ¬ 注 é >> |
| | | /*---------------------------------------------------------------- |
| | | * å½å空é´ï¼WIDESEAWCS_Tasks.StackerCraneJob |
| | | * å建è
ï¼è¡ç«¥åº |
| | | * å建æ¶é´ï¼2024/8/2 16:13:36 |
| | | * çæ¬ï¼V1.0.0 |
| | | * æè¿°ï¼ |
| | | * |
| | | * ---------------------------------------------------------------- |
| | | * ä¿®æ¹äººï¼ |
| | | * ä¿®æ¹æ¶é´ï¼ |
| | | * çæ¬ï¼V1.0.1 |
| | | * ä¿®æ¹è¯´æï¼ |
| | | * |
| | | *----------------------------------------------------------------*/ |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | |
| | | namespace WIDESEAWCS_Tasks.StackerCraneJob |
| | | { |
| | | public class StackerCraneTaskCommandGMPP : DeviceCommand |
| | | { |
| | | #region <Public Menber> |
| | | /// <summary> |
| | | /// ä»»å¡å· |
| | | /// </summary> |
| | | public int TaskNum { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä½ä¸ç±»å |
| | | /// </summary> |
| | | public short WorkType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æçç±»å |
| | | /// </summary> |
| | | public short TrayType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// èµ·å§è¡ |
| | | /// </summary> |
| | | public short StartRow { get; set; } |
| | | |
| | | /// <summary> |
| | | /// èµ·å§å |
| | | /// </summary> |
| | | public short StartColumn { get; set; } |
| | | |
| | | /// <summary> |
| | | /// èµ·å§å± |
| | | /// </summary> |
| | | public short StartLayer { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç®æ è¡ |
| | | /// </summary> |
| | | public short EndRow { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç®æ å |
| | | /// </summary> |
| | | public short EndColumn { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç®æ å± |
| | | /// </summary> |
| | | public short EndLayer { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æçå· |
| | | /// </summary> |
| | | [DataLength(30)] |
| | | public string Barcode { get; set; } |
| | | /// <summary> |
| | | /// ç©æé¿åº¦ |
| | | /// </summary> |
| | | public short TaskLength { get; set; } |
| | | #endregion <Public Menber> |
| | | } |
| | | } |
| | |
| | | using Newtonsoft.Json; |
| | | using Microsoft.IdentityModel.Tokens; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | { |
| | | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK) |
| | | { |
| | | if (!string.IsNullOrEmpty(conveyorLineInfoRead.Barcode)) |
| | | string boxcode = device.GetValue<R_ConveyorLineDB, string>(R_ConveyorLineDB.Boxcode, item.StationCode); |
| | | |
| | | if (!string.IsNullOrEmpty(boxcode)) |
| | | { |
| | | string sc = device.Communicator.Read<string>("DB900.508.0"); |
| | | WriteError(device.DeviceName, $"读åå¼ï¼{boxcode},对æ¯{sc}"); |
| | | string boxEndCode = ""; |
| | | if (boxcode.LastIndexOf(",SC:") >=0) |
| | | { |
| | | boxEndCode = "M"+ boxcode.Substring(0,boxcode.LastIndexOf(",SC:")) + sc.Substring(sc.IndexOf(",SC:")).Replace("\0", ""); |
| | | } |
| | | else if (boxcode.LastIndexOf(",SC") > 0) |
| | | { |
| | | boxEndCode = "M" + boxcode.Substring(0, boxcode.LastIndexOf(",SC")) + sc.Substring(sc.IndexOf("SC:")).Replace("\0", ""); |
| | | } |
| | | else if (boxcode.LastIndexOf(",S") > 0) |
| | | { |
| | | boxEndCode = "M" + boxcode.Substring(0, boxcode.LastIndexOf(",S")) + sc.Substring(sc.IndexOf("SC:")).Replace("\0", ""); |
| | | } |
| | | |
| | | //å
¥åºç³è¯·ä»»å¡ |
| | | WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode); |
| | | WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode, boxEndCode); |
| | | if (content.Status) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | |
| | | } |
| | | else if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && conveyorLineSignalWrite.ACK) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.PalletCode == conveyorLineInfoRead.Barcode && x.DeviceCode == item.StationDeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt()); |
| | | string boxcode = device.GetValue<R_ConveyorLineDB, string>(R_ConveyorLineDB.Boxcode, item.StationCode); |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && boxcode.Contains(x.PalletCode) && x.TaskState == TaskStatusEnum.New.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: item.StackerCraneStationCode, deviceCode: task.Roadway, nextAddress: task.TargetAddress); |
| | |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | task.Dispatchertime = DateTime.Now; |
| | | task.ExceptionMessage = ""; |
| | | if (task.TaskLength<=0) |
| | | { |
| | | WriteInfo(commonStackerCrane.DeviceCode, $"ç©æé¿åº¦é误{task.TaskLength}"); |
| | | return Task.CompletedTask; |
| | | } |
| | | commonStackerCrane.Communicator.Write("DB105.58", (short)task.TaskLength); |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing); |
| | | commonStackerCrane.Communicator.Write("DB105.54", (short)1); |
| | | //å»¶æ¶1s |
| | |
| | | stackerCraneTaskCommand.Barcode = task.PalletCode; |
| | | stackerCraneTaskCommand.TaskNum = task.TaskNum; |
| | | stackerCraneTaskCommand.WorkType = 1; |
| | | stackerCraneTaskCommand.TrayType = (Int16)task.PalletType; |
| | | stackerCraneTaskCommand.TrayType = 0; |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//夿æ¯å¦æ¯å
¥åºä»»å¡ |
| | | { |
| | | string[] startCodes = task.CurrentAddress.Split("-"); |
| | |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value); |
| | | if (flag && value != null) |
| | | try |
| | | { |
| | | OtherDevice device = (OtherDevice)value; |
| | | 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))) |
| | | bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value); |
| | | if (flag && value != null) |
| | | { |
| | | DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineFLDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && deviceProRead != null) |
| | | OtherDevice device = (OtherDevice)value; |
| | | 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))) |
| | | { |
| | | R_ConveyorLineFLInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineFLInfo>(deviceProRead.DeviceProAddress); |
| | | bool conveyArrivaled = device.GetValue<R_ConveyorLineFLDB, bool>(R_ConveyorLineFLDB.ConveyArrivaled, item.StationCode); |
| | | if (conveyArrivaled) |
| | | DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineFLDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && deviceProRead != null) |
| | | { |
| | | Dt_Task newTask = _taskRepository.QueryFirst(x => x.TaskNum== conveyorLineInfoRead.TaskNum.ObjToInt() && x.PalletCode == conveyorLineInfoRead.Barcode && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode== item.StackerCraneCode && !string.IsNullOrEmpty(x.DeviceCode)); |
| | | if (newTask != null) |
| | | R_ConveyorLineFLInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineFLInfo>(deviceProRead.DeviceProAddress); |
| | | bool conveyArrivaled = device.GetValue<R_ConveyorLineFLDB, bool>(R_ConveyorLineFLDB.ConveyArrivaled, item.StationCode); |
| | | if (conveyArrivaled) |
| | | { |
| | | _taskService.UpdateTask(newTask, TaskStatusEnum.AGV_Execute); |
| | | Dt_Task newTask = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNum.ObjToInt() && x.PalletCode == conveyorLineInfoRead.Barcode && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode == item.StackerCraneCode && !string.IsNullOrEmpty(x.DeviceCode)); |
| | | if (newTask != null) |
| | | { |
| | | _taskService.UpdateTask(newTask, TaskStatusEnum.AGV_Execute); |
| | | } |
| | | WriteError(item.StationName, $"å
¥åºå°ä½ä¿¡å·ï¼æçå·{conveyorLineInfoRead.Barcode},ä»»å¡å·:{conveyorLineInfoRead.TaskNum}"); |
| | | } |
| | | WriteError(item.StationName, $"å
¥åºå°ä½ä¿¡å·ï¼æçå·{conveyorLineInfoRead.Barcode},ä»»å¡å·:{conveyorLineInfoRead.TaskNum}"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(nameof(ConveyorLineJob_FL), ex.Message, ex); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | |
| | | public string GroupId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ç©æé¿åº¦ |
| | | /// </summary> |
| | | public int TaskLength { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string AGVArea { get; set; } |
| | |
| | | //WebResponseContent FeedbackInboundOrder(int id); |
| | | |
| | | WebResponseContent MaterielGroup(SaveModel saveModel); |
| | | |
| | | WebResponseContent MaterielPPorGM(string materielBoxCode=""); |
| | | /// <summary> |
| | | /// å
¥åºå®æä¸æ¥ |
| | | /// </summary> |
| | |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode); |
| | | WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode,string materielBoxCode = ""); |
| | | |
| | | /// <summary> |
| | | /// ä»
ç³è¯·ä»»å¡ï¼è®©WCSæ ¹æ®è·¯ç±ç¡®å®ä¸ä¸å°å |
| | |
| | | using Microsoft.AspNetCore.Mvc.RazorPages; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections; |
| | |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent MaterielPPorGM(string materielBoxCode = "") |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string SerNum = materielBoxCode.Substring(0, materielBoxCode.LastIndexOf("SC:")-1); |
| | | MatSerNumAnalysisModel model = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, SerNum); |
| | | //éªè¯å¤ææ¶é´æ ¼å¼ |
| | | WebResponseContent IsValidContent = IsValidMCDates(new List<MatSerNumAnalysisModel>() { model }); |
| | | if (!IsValidContent.Status) |
| | | { |
| | | return content.Error(IsValidContent.Message); |
| | | } |
| | | string result = materielBoxCode.Substring(materielBoxCode.LastIndexOf("SC:") + 3); |
| | | //è·åå
¥åºåæç» |
| | | Dt_InboundOrderDetail inboundOrderDetail = _inboundRepository.InboundOrderDetailRepository.QueryFirst(x=>x.BatchNo== model.LotNo && x.MaterielCode== model.MaterielCode); |
| | | if (inboundOrderDetail == null) |
| | | { |
| | | return InOtherGMOrPP(model, result); |
| | | } |
| | | Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().First(x => x.Id == inboundOrderDetail.OrderId); |
| | | |
| | | if (inboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåä¿¡æ¯"); |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == inboundOrder.WarehouseId); |
| | | //é¤éè´å
¥åºå以å¤å
¶ä»å
¥åºåç»çæ°æ®å¤ç |
| | | if (inboundOrder.OrderType != InOrderTypeEnum.Purchase.ObjToInt()) |
| | | { |
| | | return OtherInGroup(inboundOrder, model.LotNo, 0, warehouse, new List<MatSerNumAnalysisModel>() { model }); |
| | | } |
| | | Dt_ReceiveOrder receiveOrder = _inboundRepository.ReceiveOrderRepository.Db.Queryable<Dt_ReceiveOrder>().Where(x => x.ReceiveOrderNo == inboundOrder.UpperOrderNo).Includes(x => x.Details).First(); |
| | | if (receiveOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºçæ¶è´§å"); |
| | | } |
| | | if (receiveOrder.Details == null || receiveOrder.Details.Count <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºçæ¶è´§åæç»"); |
| | | } |
| | | |
| | | List<string> purchaseOrderNos = receiveOrder.Details.Select(x => x.PurchaseOrderNo).ToList(); |
| | | |
| | | string materielCode = model?.MaterielCode ?? ""; |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ç©æçä¿¡æ¯"); |
| | | } |
| | | |
| | | float beforeQuantity = 0; |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == model.LotNo).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = model.LotNo, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | WarehouseId = inboundOrder.WarehouseId, |
| | | PalletType = GetPalletTypeGMOrPP(warehouse, result.Split("*")[0]), |
| | | StockLength = result.Split("*")[0].ObjToInt(), |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçå·éå¤"); |
| | | } |
| | | } |
| | | if (stockInfo.PalletType==-1) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçç±»åä¸åå¨"); |
| | | } |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | if (purchaseOrderNos.FirstOrDefault(x => x == model.PurchaseOrderNo) == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨æ¶è´§æç»ä¸æ¾å°è¯¥éè´å"); |
| | | } |
| | | |
| | | if (inboundOrderDetail.OrderDetailStatus > OrderDetailStatusEnum.Inbounding.ObjToInt() || inboundOrderDetail.OrderQuantity == inboundOrderDetail.ReceiptQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è¯¥ç©æå¨è¯¥å
¥åºåä¸å·²å
¨é¨ç»ç宿"); |
| | | } |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | BatchNo = model.LotNo, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | OrderNo = inboundOrder.InboundOrderNo, |
| | | SerialNumber = model.SerialNumber, |
| | | StockQuantity = model.Quantity, |
| | | OutboundQuantity = 0, |
| | | Unit = materielInfo.MaterielUnit, |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | ProductionDate = model.ProductionDate, |
| | | EffectiveDate = model.EffectiveDate, |
| | | InboundOrderRowNo = inboundOrderDetail.RowNo, |
| | | }; |
| | | |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | |
| | | stockInfoDetails.Add(stockInfoDetail); |
| | | |
| | | inboundOrderDetail.ReceiptQuantity += model.Quantity; |
| | | if (inboundOrderDetail.ReceiptQuantity > inboundOrderDetail.OrderQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç»çæ°é溢åº{inboundOrderDetail.ReceiptQuantity - inboundOrderDetail.OrderQuantity}"); |
| | | } |
| | | if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | } |
| | | float totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity); |
| | | if (inboundOrder.OrderStatus == InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | } |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail); |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfoDetails, beforeQuantity, totalQuantity, StockChangeTypeEnum.MaterielGroup); |
| | | content.OK(data: stockInfo); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent InOtherGMOrPP(MatSerNumAnalysisModel model,string request = "") |
| | | { |
| | | string materielCode = model?.MaterielCode ?? ""; |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ç©æçä¿¡æ¯"); |
| | | } |
| | | float beforeQuantity = 0; |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == materielInfo.WarehouseId); |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == model.LotNo).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = model.LotNo, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | PalletType = GetPalletTypeGMOrPP(warehouse, request.Split("*")[0]), |
| | | StockLength = request.Split("*")[0].ObjToInt(), |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçå·éå¤"); |
| | | } |
| | | } |
| | | if (stockInfo.PalletType == -1) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçç±»åä¸åå¨"); |
| | | } |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | BatchNo = model.LotNo, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | OrderNo = "", |
| | | SerialNumber = model.SerialNumber, |
| | | StockQuantity = model.Quantity, |
| | | OutboundQuantity = 0, |
| | | Unit = materielInfo.MaterielUnit, |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | ProductionDate = model.ProductionDate, |
| | | EffectiveDate = model.EffectiveDate, |
| | | InboundOrderRowNo = 0, |
| | | }; |
| | | |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | |
| | | stockInfoDetails.Add(stockInfoDetail); |
| | | float totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity); |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfoDetails, beforeQuantity, totalQuantity, StockChangeTypeEnum.MaterielGroup); |
| | | return WebResponseContent.Instance.OK(data: stockInfo); |
| | | } |
| | | public int GetPalletTypeGMOrPP(Dt_Warehouse warehouse, string boxWidth) |
| | | { |
| | | if (warehouse.WarehouseCode == WarehouseEnum.HA152.ToString()) |
| | | { |
| | | |
| | | if (boxWidth.ObjToInt() <= 690 && boxWidth.ObjToInt()>=515) |
| | | { |
| | | return 15; |
| | | } |
| | | else if (boxWidth.ObjToInt() > 690 && boxWidth.ObjToInt() <= 1400) |
| | | { |
| | | return 16; |
| | | } |
| | | |
| | | } |
| | | else if (warehouse.WarehouseCode == WarehouseEnum.HA58.ToString()) |
| | | { |
| | | Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.WarehouseId == warehouse.WarehouseId); |
| | | return palletTypeInfo.PalletType; |
| | | } |
| | | return -1; |
| | | } |
| | | public WebResponseContent OtherInGroup(Dt_InboundOrder inboundOrder,string? palletCode,int Initiallife,Dt_Warehouse warehouse,List<MatSerNumAnalysisModel> models) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "夿³¨")] |
| | | public string Remark { get; set; } |
| | | /// <summary> |
| | | /// åºåç©æé¿åº¦GM/PP |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "åºåç©æé¿åº¦")] |
| | | public int StockLength { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åºåæç» |
| | |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "ä»»å¡ç»")] |
| | | public string GroupId { get; set; } |
| | | /// <summary> |
| | | /// ä»»å¡ç©æé¿åº¦ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "ä»»å¡ç©æé¿åº¦")] |
| | | [ExporterHeader(DisplayName = "ä»»å¡ç©æé¿åº¦")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "ä»»å¡ç©æé¿åº¦")] |
| | | public int TaskLength { get; set; } |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "夿³¨")] |
| | |
| | | { |
| | | x.Status = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | }); |
| | | if (stockInfo.StockLength>0) |
| | | { |
| | | stockInfo.StockLength = 0; |
| | | } |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | } |
| | |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode) |
| | | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode,string materielBoxCode = "") |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | } |
| | | if (!string.IsNullOrEmpty(materielBoxCode)) |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | WebResponseContent responseGroup = _inboundOrderService.MaterielPPorGM(materielBoxCode); |
| | | if (!responseGroup.Status) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{responseGroup.Message}"); |
| | | } |
| | | Dt_StockInfo stockInfoPPorGM = responseGroup.Data as Dt_StockInfo ?? null; |
| | | if (stockInfoPPorGM==null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç»çæ°æ®è½¬æ¢å¤±è´¥"); |
| | | } |
| | | Dt_LocationInfo? locationInfoPPorGM = _basicService.LocationInfoService.AssignLocation(roadwayNo, stockInfoPPorGM.PalletType, stockInfoPPorGM.WarehouseId); |
| | | if (locationInfoPPorGM == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | Dt_Task newTaskPPorGM = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = locationInfoPPorGM.LocationCode, |
| | | PalletCode = stockInfoPPorGM.PalletCode, |
| | | Roadway = roadwayNo, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = locationInfoPPorGM.LocationCode, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfoPPorGM.WarehouseId, |
| | | PalletType = stockInfoPPorGM.PalletType, |
| | | TaskLength= stockInfoPPorGM.StockLength |
| | | }; |
| | | |
| | | //è·åæ¯å¦åå¨å
¥åºå |
| | | Dt_InboundOrder? inboundOrderPPorGM = null; |
| | | if (stockInfoPPorGM != null && stockInfoPPorGM.Details.Count > 0) |
| | | { |
| | | string? orderNo = stockInfoPPorGM.Details.FirstOrDefault()?.OrderNo ?? ""; |
| | | inboundOrderPPorGM = _inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()); |
| | | } |
| | | |
| | | if (inboundOrderPPorGM != null) |
| | | { |
| | | if (inboundOrderPPorGM.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) |
| | | { |
| | | newTaskPPorGM.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); |
| | | } |
| | | else if (inboundOrderPPorGM.OrderType == InOrderTypeEnum.Return.ObjToInt()) |
| | | { |
| | | newTaskPPorGM.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); |
| | | } |
| | | } |
| | | stockInfoPPorGM.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | LocationStatusEnum lastStatusPPorGM = (LocationStatusEnum)locationInfoPPorGM.LocationStatus; |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfoPPorGM, lastStatusPPorGM, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoPPorGM, newTaskPPorGM.PalletType, LocationStatusEnum.Lock, newTaskPPorGM.WarehouseId); |
| | | int taskIdPPorGM = BaseDal.AddData(newTaskPPorGM); |
| | | newTaskPPorGM.TaskId = taskIdPPorGM; |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfoPPorGM).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WMSTaskDTO wMSTaskDTOPPorGM = _mapper.Map<WMSTaskDTO>(newTaskPPorGM); |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTaskPPorGM }); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTOPPorGM); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | }; |
| | | if (stockInfo.StockLength>0) |
| | | { |
| | | task.TaskLength = stockInfo.StockLength; |
| | | } |
| | | tasks.Add(task); |
| | | } |
| | | } |
| | |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("DeviceRequestInboundTask"), AllowAnonymous] |
| | | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode) |
| | | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode,string materielBoxCode = "") |
| | | { |
| | | return Service.DeviceRequestInboundTask(stationCode, roadwayNo, palletCode); |
| | | return Service.DeviceRequestInboundTask(stationCode, roadwayNo, palletCode, materielBoxCode); |
| | | } |
| | | |
| | | /// <summary> |