| | |
| | | /// 嫿æºå° |
| | | /// </summary> |
| | | public string Tags { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç©ææ¡ç |
| | | /// </summary> |
| | | public string MaterialBarcode { get; set; } |
| | | } |
| | | |
| | | public class CZTaskBarCodeDto |
| | | { |
| | | /// <summary> |
| | | /// 1å·æ¡ç |
| | | /// </summary> |
| | | public string BarCode1 { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 2å·æ¡ç |
| | | /// </summary> |
| | | public string BarCode2 { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 3å·æ¡ç |
| | | /// </summary> |
| | | public string BarCode3 { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 4å·æ¡ç |
| | | /// </summary> |
| | | public string BarCode4 { get; set; } |
| | | |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | [SugarColumn( IsNullable = true)] |
| | | public int TaskFJFinishNumber { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡è¯¦æ
(jsonæ ¼å¼,åå¨ä»»å¡ç详ç»ä¿¡æ¯Barcode) |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true)] |
| | | public string DtCZTaskDetails { get; set; } |
| | | } |
| | | } |
| | |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical; |
| | | using System.Text.Json; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | |
| | | public class TaskCZService : ServiceBase<DtCZTask, ITaskCZRepository>, ITaskCZService |
| | | { |
| | | private readonly ITaskRepository _taskRepository; |
| | | |
| | | public TaskCZService(ITaskCZRepository BaseDal, ITaskRepository taskRepository) : base(BaseDal) |
| | | { |
| | | _taskRepository = taskRepository; |
| | |
| | | { |
| | | czTask.TaskStatus = TaskInStatusEnum.Line_InExecuting.ToString(); |
| | | } |
| | | |
| | | |
| | | if (dto.FinishNum is < 1 or > 4) |
| | | throw new ArgumentException("åæ°é误ï¼FinishNum å¿
须为 1-4"); |
| | | |
| | | var detail = dto.FinishNum == 1 |
| | | ? new CZTaskBarCodeDto() |
| | | : JsonSerializer.Deserialize<CZTaskBarCodeDto>(czTask.DtCZTaskDetails) ?? new CZTaskBarCodeDto(); |
| | | |
| | | var property = dto.FinishNum switch |
| | | { |
| | | 1 => nameof(CZTaskBarCodeDto.BarCode1), |
| | | 2 => nameof(CZTaskBarCodeDto.BarCode2), |
| | | 3 => nameof(CZTaskBarCodeDto.BarCode3), |
| | | 4 => nameof(CZTaskBarCodeDto.BarCode4), |
| | | _ => throw new ArgumentOutOfRangeException("åæ°é误ï¼è¯·æ£æ¥ãFinishNumãï¼") |
| | | }; |
| | | |
| | | typeof(CZTaskBarCodeDto).GetProperty(property)?.SetValue(detail, dto.MaterialBarcode); |
| | | |
| | | czTask.DtCZTaskDetails = JsonSerializer.Serialize(detail); |
| | | |
| | | var isTrue = BaseDal.UpdateData(czTask); |
| | | if (isTrue) |
| | | { |
| | |
| | | } |
| | | return Task.FromResult(response); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾éçº¿åæµ |
| | | /// </summary> |
| | |
| | | public class CommonAGVJob : JobBase, IJob, IDisposable |
| | | { |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly ITaskCZRepository _taskCZRepository; |
| | | |
| | | public CommonAGVJob(ITaskRepository taskRepository) |
| | | public CommonAGVJob(ITaskRepository taskRepository, ITaskCZRepository taskCZRepository) |
| | | { |
| | | _taskRepository = taskRepository; |
| | | _taskCZRepository = taskCZRepository; |
| | | } |
| | | |
| | | public void Dispose() |
| | |
| | | { |
| | | AGV agv = (AGV)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | SendTaskAGV.SendAGVTask(agv, _taskRepository); |
| | | UpdateTaskAGV.UpdateTask(agv, _taskRepository); |
| | | UpdateTaskAGV.UpdateTask(agv, _taskRepository, _taskCZRepository); |
| | | |
| | | return Task.CompletedTask; |
| | | } |
| | |
| | | using Newtonsoft.Json; |
| | | using WIDESEAWCS_Common.AGVEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | |
| | | } |
| | | } |
| | | |
| | | public static void UpdateTask(AGV plcClient, ITaskRepository taskRepository) |
| | | public static void UpdateTask(AGV plcClient, ITaskRepository taskRepository, ITaskCZRepository _taskCZRepository) |
| | | { |
| | | // 使ç¨Interlocked.Exchangeä¿è¯å䏿¶é´åªæä¸ä¸ªçº¿ç¨å¯ä»¥æ§è¡ä»»å¡æ´æ° |
| | | if (Interlocked.Exchange(ref _readUpdateAGVTaskSignalso, 1) == 0) |
| | |
| | | throw new Exception($"ä»»å¡ç¶ææ´æ¹ä¸º4ç»ç¹å·²å®æå¤±è´¥,ä»»å¡ID:{taskId},å½åç¶æ:{agvTask.TaskState}"); |
| | | } |
| | | |
| | | if (agvTask.TargetAddress.Contains("HXWLX")) |
| | | { |
| | | if (agvTask.SourceAddress.Contains("KPHLX")) |
| | | { |
| | | // 空ç线è¿çç®± |
| | | // TODO: 任塿ªå宿´æ¡ç |
| | | var materials = new List<BakingClass>(); |
| | | |
| | | MESback WMSbackresult = MESAPIInvoke.BakingFeedingBinding(agvTask.TargetAddress, materials); |
| | | if (WMSbackresult.Code > 0) { new Exception(WMSbackresult.Message); return; } |
| | | } |
| | | else |
| | | { |
| | | // æåæºè¿çç®± |
| | | // TODO: è°ç¨åæºæ¥å£è·å宿´æ¡ç |
| | | var czTask = _taskCZRepository.QueryFirst(x => x.Id == agvTask.WMSId); |
| | | CZTaskBarCodeDto barCodeDto = JsonConvert.DeserializeObject<CZTaskBarCodeDto>(czTask.DtCZTaskDetails); |
| | | var materials = Enumerable.Range(0, 2) |
| | | .Select(i => new BakingClass |
| | | { |
| | | MaterialType = czTask.TaskProductCode, |
| | | BarCode = GetBarCodeByIndex(barCodeDto, i, hasDesc: !string.IsNullOrEmpty(czTask.TaskDesc)) |
| | | }) |
| | | .ToList(); |
| | | |
| | | MESback WMSbackresult = MESAPIInvoke.BakingFeedingBinding(agvTask.TargetAddress, materials); |
| | | if (WMSbackresult.Code > 0) { new Exception(WMSbackresult.Message); return; } |
| | | else |
| | | { |
| | | if (!string.IsNullOrEmpty(czTask.TaskDesc)) |
| | | { |
| | | czTask.TaskDesc = "ä»»å¡å®æä¸¤æ¬¡æ¬¡"; |
| | | _taskCZRepository.DeleteData(czTask); |
| | | } |
| | | else |
| | | { |
| | | czTask.TaskDesc = "ä»»å¡å®æä¸æ¬¡"; |
| | | _taskCZRepository.UpdateData(czTask); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // å é¤å·²å®æçä»»å¡ |
| | | taskRepository.DeleteData(agvTask); |
| | | plcClient.Communicator.Write(taskFbInteractive2, 1); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // è¾
婿¹æ³ |
| | | private static string GetBarCodeByIndex(CZTaskBarCodeDto dto, int index, bool hasDesc) |
| | | { |
| | | return (index, hasDesc) switch |
| | | { |
| | | (0, false) => dto.BarCode1, |
| | | (1, false) => dto.BarCode2, |
| | | (0, true) => dto.BarCode3, |
| | | (1, true) => dto.BarCode4, |
| | | _ => throw new IndexOutOfRangeException() |
| | | }; |
| | | } |
| | | } |
| | | |
| | | public class BakingFeedingClass |
| | |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | |
| | | |
| | | |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | // åå»ºå¹¶æ·»å æ°ä»»å¡å°ä»»å¡ä»åº |
| | | task = CreateTask(fromAdd, czTask.TaskEndAddress, czTask.TaskOrderNo, czTask.TaskProductCode, taskType); |
| | | task = CreateTask(fromAdd, czTask.TaskEndAddress, czTask.TaskOrderNo, czTask.TaskProductCode, taskType, czTask.Id); |
| | | _taskRepository.AddData(task); |
| | | ConsoleHelper.WriteInfoLine($"{nameof(CommonConveyorLineJob)}: {taskType}{requestType},ä»»å¡å·²çæï¼çå¾
æ§è¡......"); |
| | | } |
| | |
| | | } |
| | | |
| | | // è¾
婿¹æ³ï¼å建任å¡å¯¹è±¡ |
| | | private Dt_Task CreateTask(string currentAddress, string targetAddress, string remark, string palletCode, string taskType) |
| | | private Dt_Task CreateTask(string currentAddress, string targetAddress, string remark, string palletCode, string taskType, int czTaskID = 0) |
| | | { |
| | | Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.SourceAddress == currentAddress); |
| | | if (dt_Task != null) |
| | |
| | | NextAddress = targetAddress, |
| | | Barcode = "", |
| | | Roadway = $"{taskType}AGV", |
| | | WMSId = 0, |
| | | WMSId = czTaskID > 0 ? czTaskID : 0, |
| | | Remark = remark |
| | | }; |
| | | } |