12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using ServiceCenter.Logs;
- using ServiceCenter.SqlSugars;
- using System.ComponentModel;
- using WCS.Core;
- using WCS.Entity;
- using WCS.WorkEngineering.Extensions;
- using WCS.WorkEngineering.Protocol.BCR;
- using WCS.WorkEngineering.Protocol.Station;
- using WCS.WorkEngineering.WebApi.Controllers;
- using WCS.WorkEngineering.WebApi.Models.WMS.Request;
- using WCS.WorkEngineering.Worlds;
- namespace WCS.WorkEngineering.Systems
- {
- /// <summary>
- /// 一楼叠盘机入库
- /// </summary>
- [BelongTo(typeof(MainWorld))]
- [Description("一楼叠盘机入库")]
- public class 一楼叠盘机入库 : DeviceSystem<Device<IStation520, IStation521, IStation523, IStation91, IBCR81>>
- {
- protected override bool ParallelDo => true;
- protected override bool SaveLogsToFile => true;
- public override void Do(Device<IStation520, IStation521, IStation523, IStation91, IBCR81> obj)
- {
- obj.入库站点是否被禁止();
- obj.入库站点是否满足执行条件();
- WCS_TaskInfo task = null;//处理完成的任务
- try
- {
- SqlSugarHelper.Do(_db =>
- {
- var db = _db.Default;
- //获取托盘条码
- var barcode = obj.Data5.GetBCRCode();
- //验证是否有对应的任务
- if (!db.Queryable<WCS_TaskInfo>().Any(v => v.BarCode == barcode))
- {
- PalletType palletType = PalletType.Pallet09;
- if (obj.Entity.Code is "2727" or "2527") palletType = PalletType.Pallet09;
- else palletType = PalletType.PalletNo09;
- WmsApi.OneFloorWorkerBuildEmptyPalletsStock(new OneFloorWorkerBuildEmptyPalletsStockRequest()
- {
- PalletCode = barcode,
- StartLoc = obj.Entity.Code,
- PalletType = palletType
- });
- }
- //找到对应的任务
- task = db.Queryable<WCS_TaskInfo>().First(v => v.BarCode == barcode);
- if (task.Status == Entity.TaskStatus.NewBuild)
- {
- //开始对任务进行处理
- task.Status = Entity.TaskStatus.ConveyorExecution;
- task.StartTime = DateTime.Now;
- task.SrmStation = task.AddrFrom;
- task.AddWCS_TASK_DTL(_db, obj.Entity.Code, "开始执行入库任务");
- db.Updateable(task).ExecuteCommand();
- task.updateRedisHash();
- }
- else return;
- });
- }
- catch (Exception ex)
- {
- throw new KnownException(ex.Message, LogLevelEnum.High);
- }
- obj.Data.TaskNumber = task.ID;
- obj.Data.VoucherNo++;
- }
- public override bool Select(Device dev)
- {
- return dev.HasFlag(Extensions.DeviceFlags.一楼叠盘机);
- }
- }
- }
|