123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using PlcSiemens.Core.Extension;
- using ServiceCenter.Extensions;
- using ServiceCenter.Logs;
- using ServiceCenter.SqlSugars;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using WCS.Core;
- using WCS.Entity;
- using WCS.Entity.Protocol.BCR;
- using WCS.Entity.Protocol.Station;
- using WCS.WorkEngineering.Extensions;
- using WCS.WorkEngineering.Worlds;
- namespace WCS.WorkEngineering.Systems.重绕区
- {
- /// <summary>
- /// 扫码入库
- /// </summary>
- [BelongTo(typeof(RewindWorld))]
- [Description("扫码入库")]
- public class 扫码入库 : DeviceSystem<Device<IStation520, IStation521, IStation523, IBCR81>>
- {
- protected override bool ParallelDo => true;
- public override void Do(Device<IStation520, IStation521, IStation523, IBCR81> obj)
- {
- if (obj.Data.VoucherNo != obj.Data2.VoucherNo)
- {
- World.Log($"凭证号不一致,DB520:{obj.Data.VoucherNo}-DB521:{obj.Data2.VoucherNo}");
- return;
- }
- if (obj.Data3.Status.HasFlag(StationStatus.Run))
- {
- World.Log("设备运行中");
- return;
- }
- if (!obj.Data3.Status.HasFlag(StationStatus.OT_Status))
- {
- World.Log("站台货物信息与实际占用不一致");
- return;
- }
- if (!obj.Data3.Status.HasFlag(StationStatus.PH_Status))
- {
- World.Log("无光电");
- return;
- }
- if (obj.Data2.Request != 1)
- {
- World.Log("无请求");
- return;
- }
- SqlSugarHelper.Do(db =>
- {
- WCS_TaskInfo task = null;
- try
- {
- //获取托盘条码
- var barcode = obj.Data4.GetBCRCode();
- if (barcode.IsNullOrWhiteSpace())
- {
- World.Log("扫码失败,内容为空", LogLevelEnum.Mid);
- return;
- }
- else if (!barcode.Contains("TPB"))
- {
- World.Log($"扫码异常{barcode},请检查扫码器", LogLevelEnum.Mid);
- return;
- }
- SqlSugarHelper.Do(_db =>
- {
- var db = _db.Default;
- //找到对应的任务
- var taskInfo = db.Queryable<WCS_TaskInfo>().First(v => v.BarCode == barcode && v.Type == TaskType.EnterDepot && v.Status < Entity.TaskStatus.Finish);
- if (taskInfo == null) return;
- if (taskInfo.Status != Entity.TaskStatus.WaitingToExecute) return;
- {
- taskInfo.Status = Entity.TaskStatus.ConveyorExecution;
- taskInfo.EditTime = DateTime.Now;
- db.UpdateableRowLock(taskInfo).UpdateColumns(x => new { x.Status, x.EditTime }).ExecuteCommand();
- taskInfo.AddWCS_TASK_DTL(db, obj.Entity.Code, $"任务{taskInfo.ID}扫码成功,条码{taskInfo.BarCode}");
- task = taskInfo;
- }
- });
- }
- catch (Exception ex)
- {
- throw new KnownException(ex.Message, LogLevelEnum.High);
- }
- if (task == null) return;
- obj.Data.TaskNumber = task.ID;
- obj.Data.GoodsStart = obj.Entity.Code.ToShort();
- obj.Data.GoodsEnd = obj.Entity.Code switch
- {
- "9125" => 9126.ToShort(),
- "9136" => 9137.ToShort(),
- "9147" => 9148.ToShort(),
- _ => 9999
- };
- obj.Data.VoucherNo++;
- });
- }
- public override bool Select(Device dev)
- {
- return dev.Code is "9125";
- }
- }
- }
|