修正代码
This commit is contained in:
parent
999fb457a4
commit
ab2ae0969a
@ -2,8 +2,8 @@ namespace Seyounth.Core.Extensions;
|
|||||||
|
|
||||||
public static class DateTimeExtensions
|
public static class DateTimeExtensions
|
||||||
{
|
{
|
||||||
public static long ToTimestamp(this DateTime dateTime)
|
public static int ToTimestamp(this DateTime dateTime)
|
||||||
{
|
{
|
||||||
return new DateTimeOffset(dateTime).ToUnixTimeMilliseconds();
|
return (int)new DateTimeOffset(dateTime).ToUnixTimeSeconds();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ public class HyosungAgvService(
|
|||||||
private readonly HikAgv _agv = new(loggerFactory.CreateLogger<HikAgv>());
|
private readonly HikAgv _agv = new(loggerFactory.CreateLogger<HikAgv>());
|
||||||
|
|
||||||
|
|
||||||
public async Task StorageAsync(long trayCode)
|
public async Task StorageAsync(string trayCode)
|
||||||
{
|
{
|
||||||
AgvStatusInfo? status;
|
AgvStatusInfo? status;
|
||||||
do
|
do
|
||||||
|
@ -7,5 +7,5 @@ public interface IHyosungAgvService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trayCode"></param>
|
/// <param name="trayCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task StorageAsync(long trayCode);
|
Task StorageAsync(string trayCode);
|
||||||
}
|
}
|
@ -46,12 +46,12 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
logger.LogInformation($"write [{variety.Id}] to plc address[4230]");
|
logger.LogInformation($"write [{variety.Id}] to plc address[4230]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteScanYarnResultAsync(bool result, short? varietyId = null, long yarnCode = 0)
|
public async Task WriteScanYarnResultAsync(bool result, short? varietyId = null, string? yarnCode= null )
|
||||||
{
|
{
|
||||||
if (result && yarnCode != null && varietyId != null)
|
if (result && yarnCode != null && varietyId != null)
|
||||||
{
|
{
|
||||||
await _writer.WriteShortsAsync(4009, varietyId.Value);
|
await _writer.WriteShortsAsync(4009, varietyId.Value);
|
||||||
await _writer.WriteLongAsync(4010, yarnCode);
|
await _writer.WriteStringAsync(4010, yarnCode);
|
||||||
logger.LogInformation($"write [{yarnCode}] to plc address[4010]");
|
logger.LogInformation($"write [{yarnCode}] to plc address[4010]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,10 +81,10 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
isLeaving = false;
|
isLeaving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteTrayCodeAsync(int index, long trayCode)
|
public async Task WriteTrayCodeAsync(int index, string trayCode)
|
||||||
{
|
{
|
||||||
var address = index == 1 ? 4100 : 4110;
|
var address = index == 1 ? 4100 : 4110;
|
||||||
await _writer.WriteLongAsync(address, trayCode);
|
await _writer.WriteStringAsync(address, trayCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteReceivedYarnCountAsync(int count)
|
public async Task WriteReceivedYarnCountAsync(int count)
|
||||||
@ -105,14 +105,25 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
await _writer.WriteShortsAsync(12120, ls.ToArray());
|
await _writer.WriteShortsAsync(12120, ls.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WritePrintLabelResultAsync(int index, bool result)
|
public async Task WritePrintLabelResultAsync(int index, int side, bool result)
|
||||||
{
|
{
|
||||||
var address = index == 1 ? 13060 : 13061;
|
var address = index == 1 ? 13060 : 13061;
|
||||||
if (index == 2)
|
if (index == 2)
|
||||||
await _writer.WriteShortsAsync(13053, 4);
|
{
|
||||||
|
var data = SetBit(0, side);
|
||||||
|
await _writer.WriteShortsAsync(13053, data);
|
||||||
|
}
|
||||||
|
|
||||||
await _writer.WriteShortsAsync(address, (short)(result ? 1 : 2));
|
await _writer.WriteShortsAsync(address, (short)(result ? 1 : 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static byte SetBit(byte value, int bitPosition)
|
||||||
|
{
|
||||||
|
// 创建一个掩码,该掩码只有第 bitPosition 位为 1
|
||||||
|
byte mask = (byte)(1 << bitPosition);
|
||||||
|
// 使用按位或操作将 value 的第 bitPosition 位置为 1
|
||||||
|
return (byte)(value | mask);
|
||||||
|
}
|
||||||
|
|
||||||
public event Func<int, Task>? OnPlcRequestScanProduct;
|
public event Func<int, Task>? OnPlcRequestScanProduct;
|
||||||
|
|
||||||
@ -124,9 +135,9 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
|
|
||||||
public event Func<PlcStackingInfo, Task>? OnPlcPutCompleted;
|
public event Func<PlcStackingInfo, Task>? OnPlcPutCompleted;
|
||||||
|
|
||||||
public event Func<long, Task>? OnPlcRequestPackLineOption;
|
public event Func<string, Task>? OnPlcRequestPackLineOption;
|
||||||
|
|
||||||
public event Func<int, long, int, Task>? OnRequestPrintLabel;
|
public event Func<int, string, int, Task>? OnRequestPrintLabel;
|
||||||
|
|
||||||
|
|
||||||
private async Task ReadLoop(CancellationToken token)
|
private async Task ReadLoop(CancellationToken token)
|
||||||
@ -205,8 +216,8 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
if (leavingProductionLine[0] == 1)
|
if (leavingProductionLine[0] == 1)
|
||||||
{
|
{
|
||||||
await _writer.WriteShortsAsync(4020, 0);
|
await _writer.WriteShortsAsync(4020, 0);
|
||||||
var trayCode = await _reader.ReadLongAsync(12600);
|
var trayCode = await _reader.ReadStringAsync(12600);
|
||||||
if (trayCode != 0)
|
if (!string.IsNullOrEmpty(trayCode))
|
||||||
{
|
{
|
||||||
PlcStackInfo info = new PlcStackInfo()
|
PlcStackInfo info = new PlcStackInfo()
|
||||||
{
|
{
|
||||||
@ -244,21 +255,21 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
if (status[0] > 0)
|
if (status[0] > 0)
|
||||||
{
|
{
|
||||||
await _writer.WriteShortsAsync(4690, 0, 0, 0);
|
await _writer.WriteShortsAsync(4690, 0, 0, 0);
|
||||||
var trayCode = await _reader.ReadLongAsync(4620);
|
var trayCode = await _reader.ReadStringAsync(4620);
|
||||||
var yarn1 = await _reader.ReadLongAsync(4630);
|
var yarn1 = await _reader.ReadStringAsync(4630);
|
||||||
var yarn2 = await _reader.ReadLongAsync(4640);
|
var yarn2 = await _reader.ReadStringAsync(4640);
|
||||||
var yarn3 = await _reader.ReadLongAsync(4650);
|
var yarn3 = await _reader.ReadStringAsync(4650);
|
||||||
var info = new PlcStackingInfo()
|
var info = new PlcStackingInfo()
|
||||||
{
|
{
|
||||||
TrayCode = trayCode,
|
TrayCode = trayCode,
|
||||||
YarnCount = status[0],
|
YarnCount = status[0],
|
||||||
TotalYarnCount = status[1]
|
TotalYarnCount = status[1]
|
||||||
};
|
};
|
||||||
if (yarn1!=0)
|
if (!string.IsNullOrEmpty(yarn1))
|
||||||
info.YarnCode.Add(yarn1);
|
info.YarnCode.Add(yarn1);
|
||||||
if (yarn2!=0)
|
if (!string.IsNullOrEmpty(yarn2))
|
||||||
info.YarnCode.Add(yarn2);
|
info.YarnCode.Add(yarn2);
|
||||||
if (yarn3!=0)
|
if (!string.IsNullOrEmpty(yarn3))
|
||||||
info.YarnCode.Add(yarn3);
|
info.YarnCode.Add(yarn3);
|
||||||
if (info.YarnCode.Count != info.YarnCount)
|
if (info.YarnCode.Count != info.YarnCount)
|
||||||
{
|
{
|
||||||
@ -280,7 +291,7 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
var requestPackLineOption = await _reader.ReadShortsAsync(4022, 1);
|
var requestPackLineOption = await _reader.ReadShortsAsync(4022, 1);
|
||||||
if (requestPackLineOption[0] == 1)
|
if (requestPackLineOption[0] == 1)
|
||||||
{
|
{
|
||||||
var trayCode = await _reader.ReadLongAsync(12100);
|
var trayCode = await _reader.ReadStringAsync(12100);
|
||||||
await _writer.WriteShortsAsync(4022, 0);
|
await _writer.WriteShortsAsync(4022, 0);
|
||||||
OnPlcRequestPackLineOption?.Invoke(trayCode);
|
OnPlcRequestPackLineOption?.Invoke(trayCode);
|
||||||
}
|
}
|
||||||
@ -291,7 +302,7 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
var requestPrintLabel = await _reader.ReadShortsAsync(13010, 3);
|
var requestPrintLabel = await _reader.ReadShortsAsync(13010, 3);
|
||||||
if (requestPrintLabel[0] == 1)
|
if (requestPrintLabel[0] == 1)
|
||||||
{
|
{
|
||||||
var trayCode = await _reader.ReadLongAsync(13000);
|
var trayCode = await _reader.ReadStringAsync(13000);
|
||||||
await _writer.WriteShortsAsync(13010, 0);
|
await _writer.WriteShortsAsync(13010, 0);
|
||||||
await _writer.WriteShortsAsync(13012, 0);
|
await _writer.WriteShortsAsync(13012, 0);
|
||||||
OnRequestPrintLabel?.Invoke(1, trayCode, requestPrintLabel[2]);
|
OnRequestPrintLabel?.Invoke(1, trayCode, requestPrintLabel[2]);
|
||||||
@ -299,7 +310,7 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
|
|
||||||
if (requestPrintLabel[1] == 1)
|
if (requestPrintLabel[1] == 1)
|
||||||
{
|
{
|
||||||
var trayCode = await _reader.ReadLongAsync(13000);
|
var trayCode = await _reader.ReadStringAsync(13000);
|
||||||
await _writer.WriteShortsAsync(13011, 0);
|
await _writer.WriteShortsAsync(13011, 0);
|
||||||
await _writer.WriteShortsAsync(13012, 0);
|
await _writer.WriteShortsAsync(13012, 0);
|
||||||
OnRequestPrintLabel?.Invoke(2, trayCode, requestPrintLabel[2]);
|
OnRequestPrintLabel?.Invoke(2, trayCode, requestPrintLabel[2]);
|
||||||
|
@ -24,7 +24,7 @@ public interface IHyosungPlcService
|
|||||||
/// <param name="varietyId">品类ID</param>
|
/// <param name="varietyId">品类ID</param>
|
||||||
/// <param name="yarnCode">纱码</param>
|
/// <param name="yarnCode">纱码</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task WriteScanYarnResultAsync(bool result, short? varietyId = null, long yarnCode = 0);
|
Task WriteScanYarnResultAsync(bool result, short? varietyId = null, string? yarnCode = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入治具扫码结果
|
/// 写入治具扫码结果
|
||||||
@ -47,7 +47,7 @@ public interface IHyosungPlcService
|
|||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <param name="trayCode"></param>
|
/// <param name="trayCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task WriteTrayCodeAsync(int index, long trayCode);
|
Task WriteTrayCodeAsync(int index, string trayCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入收到的纱数量
|
/// 写入收到的纱数量
|
||||||
@ -58,7 +58,7 @@ public interface IHyosungPlcService
|
|||||||
|
|
||||||
Task WritePackLineOptionAsync(PackLineOption option);
|
Task WritePackLineOptionAsync(PackLineOption option);
|
||||||
|
|
||||||
Task WritePrintLabelResultAsync(int index, bool result);
|
Task WritePrintLabelResultAsync(int index, int side, bool result);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plc请求扫描产品
|
/// Plc请求扫描产品
|
||||||
@ -88,10 +88,10 @@ public interface IHyosungPlcService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plc请求打包线选项
|
/// Plc请求打包线选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Func<long, Task> OnPlcRequestPackLineOption;
|
event Func<string, Task> OnPlcRequestPackLineOption;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 贴标站请求贴标
|
/// 贴标站请求贴标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Func<int, long, int, Task> OnRequestPrintLabel;
|
event Func<int, string, int, Task> OnRequestPrintLabel;
|
||||||
}
|
}
|
@ -51,27 +51,6 @@ public class McPlc(string host, int port, Mitsubishi.McFrame type)
|
|||||||
return shorts;
|
return shorts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<long> ReadLongAsync(int address)
|
|
||||||
{
|
|
||||||
// 一个 long 类型是 8 字节,所以需要读取 8 个字节的数据
|
|
||||||
var bytes = await ReadBytesAsync(address, 8);
|
|
||||||
// 确保读取到了足够的字节
|
|
||||||
if (bytes.Length < 8)
|
|
||||||
{
|
|
||||||
throw new Exception("读取 long 类型数据时字节数不足");
|
|
||||||
}
|
|
||||||
// 将字节数组转换为 long 类型
|
|
||||||
return BitConverter.ToInt64(bytes, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task WriteLongAsync(int address, long value)
|
|
||||||
{
|
|
||||||
byte[] bytes = BitConverter.GetBytes(value);
|
|
||||||
|
|
||||||
// Write the byte array to the PLC
|
|
||||||
await WriteBytesAsync(address, bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task WriteShortsAsync(int address, params short[] values)
|
public async Task WriteShortsAsync(int address, params short[] values)
|
||||||
{
|
{
|
||||||
var code = await _mc.WriteDeviceBlock(Mitsubishi.PlcDeviceType.D, address, values.Length,
|
var code = await _mc.WriteDeviceBlock(Mitsubishi.PlcDeviceType.D, address, values.Length,
|
||||||
|
@ -34,7 +34,7 @@ public class HyosungPrinter(
|
|||||||
logger.LogInformation("printer disconnected");
|
logger.LogInformation("printer disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PrintAsync(int index, long trayCode)
|
public async Task PrintAsync(int index, string trayCode)
|
||||||
{
|
{
|
||||||
var tray = await trayService.GetByCode(trayCode);
|
var tray = await trayService.GetByCode(trayCode);
|
||||||
if (index == 1)
|
if (index == 1)
|
||||||
|
@ -11,5 +11,5 @@ public interface IHyosungPrinter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trayCode"></param>
|
/// <param name="trayCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task PrintAsync(int index,long trayCode);
|
Task PrintAsync(int index,string trayCode);
|
||||||
}
|
}
|
@ -31,4 +31,6 @@ public class AgvBinEntity
|
|||||||
|
|
||||||
[SugarColumn(ColumnDescription = "排序")]
|
[SugarColumn(ColumnDescription = "排序")]
|
||||||
public int Sort { get; set; }
|
public int Sort { get; set; }
|
||||||
|
|
||||||
|
public bool IsDeleted { get; set; }
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ public class ScannedYarnEntity
|
|||||||
public string QrCode { get; set; }
|
public string QrCode { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "纱线代码", Length = 20)]
|
[SugarColumn(ColumnDescription = "纱线代码", Length = 20)]
|
||||||
public long ScanCode { get; set; }
|
public string ScanCode { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "Lot")]
|
[SugarColumn(ColumnDescription = "Lot")]
|
||||||
public int Lot { get; set; }
|
public int Lot { get; set; }
|
||||||
|
@ -9,12 +9,12 @@ public class TrayEntity
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "托盘唯一号")]
|
[SugarColumn(ColumnDescription = "托盘唯一号")]
|
||||||
public long TrayCode { get; set; }
|
public string TrayCode { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "所属的品类信息")]
|
[SugarColumn(ColumnDescription = "所属的品类信息")]
|
||||||
public int VarietyId { get; set; }
|
public int VarietyId { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "垛高", IsNullable = true)]
|
[SugarColumn(ColumnDescription = "垛高",IsNullable =true)]
|
||||||
public int? StackHeight { get; set; }
|
public int? StackHeight { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "是否为双号")]
|
[SugarColumn(ColumnDescription = "是否为双号")]
|
||||||
|
@ -16,5 +16,5 @@ public partial class PackLineOption : ObservableObject
|
|||||||
|
|
||||||
[ObservableProperty] private bool isLam;
|
[ObservableProperty] private bool isLam;
|
||||||
|
|
||||||
[ObservableProperty] private long trayCode;
|
[ObservableProperty] private string trayCode;
|
||||||
}
|
}
|
@ -5,6 +5,6 @@ namespace Seyounth.Hyosung.Data.Models.Plc;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlcStackInfo
|
public class PlcStackInfo
|
||||||
{
|
{
|
||||||
public long TrayCode { get; set; }
|
public string TrayCode { get; set; }
|
||||||
|
|
||||||
}
|
}
|
@ -2,9 +2,9 @@ namespace Seyounth.Hyosung.Data.Models.Plc;
|
|||||||
|
|
||||||
public class PlcStackingInfo
|
public class PlcStackingInfo
|
||||||
{
|
{
|
||||||
public long TrayCode { get; set; }
|
public string TrayCode { get; set; }
|
||||||
|
|
||||||
public List<long> YarnCode { get; set; } = new ();
|
public List<string> YarnCode { get; set; } = new List<string>();
|
||||||
|
|
||||||
public int YarnCount { get; set; }
|
public int YarnCount { get; set; }
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ public class Tray
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public long TrayCode { get; set; }
|
public string TrayCode { get; set; }
|
||||||
|
|
||||||
public int VarietyId { get; set; }
|
public int VarietyId { get; set; }
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ public class Yarn
|
|||||||
|
|
||||||
public string QrCode { get; set; }
|
public string QrCode { get; set; }
|
||||||
|
|
||||||
public long ScanCode { get; set; }
|
public string ScanCode { get; set; }
|
||||||
|
|
||||||
public int Lot { get; set; }
|
public int Lot { get; set; }
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public class Yarn
|
|||||||
ProduceTime = parts[3],
|
ProduceTime = parts[3],
|
||||||
ScanTime = DateTime.Now,
|
ScanTime = DateTime.Now,
|
||||||
VarietyId = varietyId,
|
VarietyId = varietyId,
|
||||||
ScanCode = DateTime.Now.ToTimestamp(),
|
ScanCode = DateTime.Now.ToTimestamp().ToString(),
|
||||||
TrayId = null
|
TrayId = null
|
||||||
};
|
};
|
||||||
yarn.WorkShift = parts[1] switch
|
yarn.WorkShift = parts[1] switch
|
||||||
@ -79,7 +79,7 @@ public class Yarn
|
|||||||
ScanTime = DateTime.Now,
|
ScanTime = DateTime.Now,
|
||||||
VarietyId = varietyId,
|
VarietyId = varietyId,
|
||||||
TrayId = null,
|
TrayId = null,
|
||||||
ScanCode = DateTime.Now.ToTimestamp(),
|
ScanCode = DateTime.Now.ToTimestamp().ToString().PadLeft(10, '0'),
|
||||||
};
|
};
|
||||||
yarn.WorkShift = parts[5] switch
|
yarn.WorkShift = parts[5] switch
|
||||||
{
|
{
|
||||||
|
@ -18,22 +18,24 @@ public class AgvBinService : IAgvBinService
|
|||||||
|
|
||||||
public async Task<AgvBinEntity> GetAvailableBin(int height)
|
public async Task<AgvBinEntity> GetAvailableBin(int height)
|
||||||
{
|
{
|
||||||
if (height < 180)
|
var bin = await _repository.AsQueryable()
|
||||||
|
.Where(x => x.IsFree && !x.IsDeleted).OrderBy(x => x.Sort).FirstAsync();
|
||||||
|
if (bin.BinCode == "B10")
|
||||||
{
|
{
|
||||||
return _cache
|
await _repository.AsUpdateable()
|
||||||
.Where(x =>
|
.Where(x => x.RackType == 2 && !x.IsDeleted)
|
||||||
x is { CtnrType: 1, IsFree: true } ||
|
.SetColumns(x => x.IsFree, true)
|
||||||
x is { CtnrType: 2, IsFree: true } &&
|
.ExecuteCommandAsync();
|
||||||
_cache.Any(y =>
|
}
|
||||||
y is { CtnrType: 1, IsFree: false } && y.BinCode == x.BinCode &&
|
else if (bin.BinCode == "B33")
|
||||||
y is { Height: < 180 })
|
{
|
||||||
)
|
await _repository.AsUpdateable()
|
||||||
.OrderByDescending(x => x.CtnrType)
|
.Where(x => x.RackType == 1 && !x.IsDeleted)
|
||||||
.ThenBy(x => x.Sort)
|
.SetColumns(x => x.IsFree, true)
|
||||||
.First();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _cache.Where(a => a is { IsFree: true }).OrderBy(a => a.CtnrType).First();
|
return bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task BindAsync(AgvBinEntity entity)
|
public Task BindAsync(AgvBinEntity entity)
|
||||||
|
@ -17,21 +17,21 @@ public interface ITrayService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code"></param>
|
/// <param name="code"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> GetIdByCode(long code);
|
Task<int> GetIdByCode(string code);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code"></param>
|
/// <param name="code"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Tray> GetByCode(long code);
|
Task<Tray> GetByCode(string code);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成控制号
|
/// 生成控制号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trayCode"></param>
|
/// <param name="trayCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task StorageAsync(long trayCode);
|
Task StorageAsync(string trayCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打印托盘
|
/// 打印托盘
|
||||||
@ -41,5 +41,5 @@ public interface ITrayService
|
|||||||
/// <param name="controlNo"></param>
|
/// <param name="controlNo"></param>
|
||||||
/// <param name="itemInfo"></param>
|
/// <param name="itemInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task PrintTrayAsync(long trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo);
|
Task PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo);
|
||||||
}
|
}
|
@ -5,21 +5,21 @@ namespace Seyounth.Hyosung.Data.Services;
|
|||||||
|
|
||||||
public interface IYarnService
|
public interface IYarnService
|
||||||
{
|
{
|
||||||
ConcurrentDictionary<long, Yarn> NoFinished { get; }
|
ConcurrentDictionary<string, Yarn> NoFinished { get; }
|
||||||
|
|
||||||
Task<Yarn?> AddYarnAsync(Yarn yarn);
|
Task<Yarn?> AddYarnAsync(Yarn yarn);
|
||||||
|
|
||||||
|
|
||||||
Task<List<Yarn>> GetYarnsByTrayIdAsync(int trayId);
|
Task<List<Yarn>> GetYarnsByTrayIdAsync(int trayId);
|
||||||
|
|
||||||
Task<Yarn> GetYarnByCodeAsync(long code);
|
Task<Yarn> GetYarnByCodeAsync(string code);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 完成指定纱
|
/// 完成指定纱
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="yarnCode"></param>
|
/// <param name="yarnCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task FinishYarnAsync(long yarnCode);
|
Task FinishYarnAsync(string yarnCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 绑定托盘号
|
/// 绑定托盘号
|
||||||
@ -27,5 +27,5 @@ public interface IYarnService
|
|||||||
/// <param name="yarnCode"></param>
|
/// <param name="yarnCode"></param>
|
||||||
/// <param name="trayId"></param>
|
/// <param name="trayId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task BindTrayAsync(long yarnCode, int trayId);
|
Task BindTrayAsync(string yarnCode, int trayId);
|
||||||
}
|
}
|
@ -11,7 +11,7 @@ namespace Seyounth.Hyosung.Data.Services;
|
|||||||
|
|
||||||
public class TrayService : ITrayService
|
public class TrayService : ITrayService
|
||||||
{
|
{
|
||||||
private readonly ConcurrentDictionary<long, Tray> _cache = new();
|
private readonly ConcurrentDictionary<string, Tray> _cache = new();
|
||||||
private readonly IRepository<TrayEntity> _repository;
|
private readonly IRepository<TrayEntity> _repository;
|
||||||
private readonly IHyosungWmsService _hyosungWmsService;
|
private readonly IHyosungWmsService _hyosungWmsService;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class TrayService : ITrayService
|
|||||||
{
|
{
|
||||||
var tray = new Tray()
|
var tray = new Tray()
|
||||||
{
|
{
|
||||||
TrayCode = DateTime.Now.ToTimestamp(),
|
TrayCode =DateTime.Now.ToTimestamp().ToString(),
|
||||||
VarietyId = varietyId,
|
VarietyId = varietyId,
|
||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now
|
||||||
};
|
};
|
||||||
@ -42,19 +42,21 @@ public class TrayService : ITrayService
|
|||||||
return tray;
|
return tray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetIdByCode(long code)
|
public async Task<int> GetIdByCode(string code)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _cache[code].Id;
|
return _cache[code].Id;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return (await _repository.GetFirstAsync(d => d.TrayCode == code)).Id;
|
return (await _repository.GetFirstAsync(d => d.TrayCode == code)).Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Tray> GetByCode(long code)
|
public async Task<Tray> GetByCode(string code)
|
||||||
{
|
{
|
||||||
return Tray.FromEntity(await _repository.GetSingleAsync(t => t.TrayCode == code));
|
return Tray.FromEntity(await _repository.GetSingleAsync(t => t.TrayCode == code));
|
||||||
}
|
}
|
||||||
@ -64,7 +66,7 @@ public class TrayService : ITrayService
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PrintTrayAsync(long trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo)
|
public async Task PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo)
|
||||||
{
|
{
|
||||||
Tray tray;
|
Tray tray;
|
||||||
try
|
try
|
||||||
@ -75,7 +77,7 @@ public class TrayService : ITrayService
|
|||||||
{
|
{
|
||||||
tray = await GetByCode(trayCode);
|
tray = await GetByCode(trayCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
tray.ControlNo = controlNo;
|
tray.ControlNo = controlNo;
|
||||||
tray.StackHeight = stackHeight;
|
tray.StackHeight = stackHeight;
|
||||||
tray.Grade = itemInfo.GRADE;
|
tray.Grade = itemInfo.GRADE;
|
||||||
@ -89,11 +91,8 @@ public class TrayService : ITrayService
|
|||||||
_cache.Remove(tray.TrayCode, out _);
|
_cache.Remove(tray.TrayCode, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StorageAsync(long trayCode)
|
public async Task StorageAsync(string trayCode)
|
||||||
{
|
{
|
||||||
var tray = await GetByCode(trayCode);
|
|
||||||
tray.FinishTime = DateTime.Now;
|
|
||||||
await _repository.UpdateAsync(tray.ToEntity());
|
|
||||||
_cache.Remove(tray.TrayCode, out _);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ public class YarnService : IYarnService
|
|||||||
public YarnService(IServiceProvider provider)
|
public YarnService(IServiceProvider provider)
|
||||||
{
|
{
|
||||||
_yarnRepository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<ScannedYarnEntity>>();
|
_yarnRepository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<ScannedYarnEntity>>();
|
||||||
NoFinished = new ConcurrentDictionary<long, Yarn>();
|
NoFinished = new ConcurrentDictionary<string, Yarn>();
|
||||||
var yarns = _yarnRepository.GetList(y => !y.IsFinished);
|
var yarns = _yarnRepository.GetList(y => !y.IsFinished);
|
||||||
foreach (var yarn in yarns)
|
foreach (var yarn in yarns)
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ public class YarnService : IYarnService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentDictionary<long, Yarn> NoFinished { get; }
|
public ConcurrentDictionary<string, Yarn> NoFinished { get; }
|
||||||
|
|
||||||
public async Task<Yarn?> AddYarnAsync(Yarn yarn)
|
public async Task<Yarn?> AddYarnAsync(Yarn yarn)
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ public class YarnService : IYarnService
|
|||||||
.Select(Yarn.FromEntity).ToList();
|
.Select(Yarn.FromEntity).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Yarn> GetYarnByCodeAsync(long code)
|
public async Task<Yarn> GetYarnByCodeAsync(string code)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ public class YarnService : IYarnService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FinishYarnAsync(long yarnCode)
|
public async Task FinishYarnAsync(string yarnCode)
|
||||||
{
|
{
|
||||||
var yarn = NoFinished[yarnCode];
|
var yarn = NoFinished[yarnCode];
|
||||||
yarn.IsFinished = true;
|
yarn.IsFinished = true;
|
||||||
@ -58,7 +58,7 @@ public class YarnService : IYarnService
|
|||||||
NoFinished.TryRemove(yarnCode, out _);
|
NoFinished.TryRemove(yarnCode, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task BindTrayAsync(long yarnCode, int trayId)
|
public async Task BindTrayAsync(string yarnCode, int trayId)
|
||||||
{
|
{
|
||||||
var yarn = NoFinished[yarnCode];
|
var yarn = NoFinished[yarnCode];
|
||||||
yarn.TrayId = trayId;
|
yarn.TrayId = trayId;
|
||||||
|
@ -245,7 +245,7 @@ public class HyosungRuntime(
|
|||||||
/// <param name="arg"></param>
|
/// <param name="arg"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcRequestPackLineOption(long arg)
|
private async Task OnPlcRequestPackLineOption(string arg)
|
||||||
{
|
{
|
||||||
logger.LogInformation($"plc request pack line option");
|
logger.LogInformation($"plc request pack line option");
|
||||||
try
|
try
|
||||||
@ -286,34 +286,36 @@ public class HyosungRuntime(
|
|||||||
/// <param name="arg2"></param>
|
/// <param name="arg2"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcRequestPrintLabel(int arg1, long trayCode, int height)
|
private async Task OnPlcRequestPrintLabel(int arg1, string trayCode, int height)
|
||||||
{
|
{
|
||||||
logger.LogInformation($"plc request print label:{arg1} {trayCode} {height}");
|
logger.LogInformation($"plc request print label:{arg1} {trayCode} {height}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var tray = await trayService.GetByCode(trayCode);
|
||||||
var tray = await trayService.GetByCode(trayCode);
|
var variety = await varietyService.GetById(tray.VarietyId);
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
var mod = await hyosungWmsService.GetItemInfoByItemCode(variety.Code);
|
||||||
var mod = await hyosungWmsService.GetItemInfoByItemCode(variety.Code);
|
var grade = "1";
|
||||||
var grade = "1";
|
if (mod.GRADE != "AA") grade = mod.GRADE;
|
||||||
if (mod.GRADE != "AA") grade = mod.GRADE;
|
var controlNo = await hyosungWmsService.GetControlNo(variety, grade);
|
||||||
var controlNo = await hyosungWmsService.GetControlNo(variety, grade);
|
|
||||||
await trayService.PrintTrayAsync(trayCode, height, controlNo, mod);
|
await trayService.PrintTrayAsync(trayCode, height, controlNo, mod);
|
||||||
if (arg1 == 1)
|
if (arg1 == 1)
|
||||||
{
|
{
|
||||||
|
await printer.PrintAsync(1, trayCode);
|
||||||
await printer.PrintAsync(1, trayCode);
|
await hyosungPlcService.WritePrintLabelResultAsync(arg1, variety.SubLabelCount, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
await printer.PrintAsync(2, trayCode);
|
await printer.PrintAsync(2, trayCode);
|
||||||
|
await hyosungPlcService.WritePrintLabelResultAsync(arg1, variety.MasterLabelCount, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
await hyosungPlcService.WritePrintLabelResultAsync(arg1, true);
|
|
||||||
await hyosungWmsService.UpdateControlNo(variety, controlNo);
|
await hyosungWmsService.UpdateControlNo(variety, controlNo);
|
||||||
logger.LogInformation($"plc request print label success");
|
logger.LogInformation($"plc request print label success");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
await hyosungPlcService.WritePrintLabelResultAsync(arg1, false);
|
await hyosungPlcService.WritePrintLabelResultAsync(arg1, 1,false);
|
||||||
logger.LogError(e, "print label fail");
|
logger.LogError(e, "print label fail");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace Seyounth.Hyosung.Runtime.Models;
|
|||||||
public partial class StackStationModel
|
public partial class StackStationModel
|
||||||
{
|
{
|
||||||
[ObservableProperty] [DefaultValue("NoData")]
|
[ObservableProperty] [DefaultValue("NoData")]
|
||||||
private long trayCode;
|
private string trayCode;
|
||||||
|
|
||||||
[ObservableProperty] [DefaultValue("NoData")]
|
[ObservableProperty] [DefaultValue("NoData")]
|
||||||
private string varietyCode;
|
private string varietyCode;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user