提交BUG
This commit is contained in:
parent
61407f6436
commit
a84cfd5e71
@ -155,8 +155,8 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
|
|
||||||
public event Func<string, Task>? OnPlcRequestPackLineOption;
|
public event Func<string, Task>? OnPlcRequestPackLineOption;
|
||||||
|
|
||||||
public event Func<int, string, int, Task>? OnRequestPrintLabel;
|
public event Func<int, int, Task>? OnRequestPrintLabel;
|
||||||
|
public event Func<string, Task> OnRequestGetPrintLableOption;
|
||||||
|
|
||||||
private async Task ReadLoop(CancellationToken token)
|
private async Task ReadLoop(CancellationToken token)
|
||||||
{
|
{
|
||||||
@ -173,6 +173,7 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
await QueryPackLineOption();
|
await QueryPackLineOption();
|
||||||
await QueryPrintLabel();
|
await QueryPrintLabel();
|
||||||
await Task.Delay(100, token);
|
await Task.Delay(100, token);
|
||||||
|
await QueryGetPrintLabel();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -315,23 +316,32 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task QueryGetPrintLabel()
|
||||||
|
{
|
||||||
|
var trayCode = await _reader.ReadStringAsync(13000);
|
||||||
|
if (!string.IsNullOrEmpty(trayCode)||!trayCode.StartsWith("0000"))
|
||||||
|
{
|
||||||
|
await _reader.WriteStringAsync(13000, "00000000000000000000");
|
||||||
|
OnRequestGetPrintLableOption?.Invoke(trayCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
private async Task QueryPrintLabel()
|
private async Task QueryPrintLabel()
|
||||||
{
|
{
|
||||||
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.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, requestPrintLabel[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestPrintLabel[1] == 1)
|
if (requestPrintLabel[1] == 1)
|
||||||
{
|
{
|
||||||
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, requestPrintLabel[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -93,5 +93,7 @@ public interface IHyosungPlcService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 贴标站请求贴标
|
/// 贴标站请求贴标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Func<int, string, int, Task> OnRequestPrintLabel;
|
event Func<int, int, Task> OnRequestPrintLabel;
|
||||||
|
|
||||||
|
event Func<string, Task> OnRequestGetPrintLableOption;
|
||||||
}
|
}
|
@ -13,6 +13,9 @@ public class HyosungScannerService : IHyosungScannerService
|
|||||||
private readonly ConcurrentDictionary<int, HikScanner> _fixtureScanners = new();
|
private readonly ConcurrentDictionary<int, HikScanner> _fixtureScanners = new();
|
||||||
|
|
||||||
|
|
||||||
|
private List<string> lastCodes = new List<string>();
|
||||||
|
|
||||||
|
|
||||||
public HyosungScannerService(ILogger<HyosungScannerService> logger)
|
public HyosungScannerService(ILogger<HyosungScannerService> logger)
|
||||||
{
|
{
|
||||||
_yarnScanners.Add(new HikScanner("192.168.3.35", 2001));
|
_yarnScanners.Add(new HikScanner("192.168.3.35", 2001));
|
||||||
@ -25,6 +28,10 @@ public class HyosungScannerService : IHyosungScannerService
|
|||||||
_fixtureScanners.TryAdd(3, new HikScanner("192.168.3.33", 2001));
|
_fixtureScanners.TryAdd(3, new HikScanner("192.168.3.33", 2001));
|
||||||
_fixtureScanners.TryAdd(4, new HikScanner("192.168.3.30", 2001));
|
_fixtureScanners.TryAdd(4, new HikScanner("192.168.3.30", 2001));
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
lastCodes.Add("");
|
||||||
|
lastCodes.Add("");
|
||||||
|
lastCodes.Add("");
|
||||||
|
lastCodes.Add("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken token)
|
public async Task StartAsync(CancellationToken token)
|
||||||
@ -131,5 +138,13 @@ public class HyosungScannerService : IHyosungScannerService
|
|||||||
public async Task<string> ScanFixtureAsync(int fixtureId)
|
public async Task<string> ScanFixtureAsync(int fixtureId)
|
||||||
{
|
{
|
||||||
return await _fixtureScanners[fixtureId].ScanAsync();
|
return await _fixtureScanners[fixtureId].ScanAsync();
|
||||||
|
//string code = "";
|
||||||
|
//do
|
||||||
|
//{
|
||||||
|
// code= await _fixtureScanners[fixtureId].ScanAsync();
|
||||||
|
// await Task.Delay(100);
|
||||||
|
//} while (code != lastCodes[fixtureId - 1]);
|
||||||
|
//lastCodes[fixtureId - 1] = code;
|
||||||
|
//return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,7 +36,7 @@ public static class ServiceExtensions
|
|||||||
//#endif
|
//#endif
|
||||||
return sqlSugar;
|
return sqlSugar;
|
||||||
});
|
});
|
||||||
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
services.AddSingleton(typeof(IRepository<>), typeof(Repository<>));
|
||||||
services.AddSingleton<IVarietyService, VarietyService>();
|
services.AddSingleton<IVarietyService, VarietyService>();
|
||||||
services.AddSingleton<IYarnService, YarnService>();
|
services.AddSingleton<IYarnService, YarnService>();
|
||||||
services.AddSingleton<ITrayService, TrayService>();
|
services.AddSingleton<ITrayService, TrayService>();
|
||||||
|
@ -13,6 +13,7 @@ public class AgvBinService : IAgvBinService
|
|||||||
public AgvBinService(IServiceProvider provider)
|
public AgvBinService(IServiceProvider provider)
|
||||||
{
|
{
|
||||||
_repository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<AgvBinEntity>>();
|
_repository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<AgvBinEntity>>();
|
||||||
|
//_repository = provider.GetService<IRepository<AgvBinEntity>>();
|
||||||
_cache = _repository.GetList();
|
_cache = _repository.GetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ public class DictService : IDictService
|
|||||||
{
|
{
|
||||||
_repository = provider.CreateScope()
|
_repository = provider.CreateScope()
|
||||||
.ServiceProvider.GetRequiredService<IRepository<DictEntity>>();
|
.ServiceProvider.GetRequiredService<IRepository<DictEntity>>();
|
||||||
|
//_repository = provider.GetService<IRepository<DictEntity>>();
|
||||||
_cache = _repository.GetList();
|
_cache = _repository.GetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Globalization;
|
||||||
using Seyounth.Hyosung.Data.Models;
|
using Seyounth.Hyosung.Data.Models;
|
||||||
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
||||||
|
|
||||||
@ -41,5 +42,7 @@ public interface ITrayService
|
|||||||
/// <param name="controlNo"></param>
|
/// <param name="controlNo"></param>
|
||||||
/// <param name="itemInfo"></param>
|
/// <param name="itemInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Tray> PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo);
|
Task<Tray> PrintTrayAsync(string trayCode, int controlNo, MST_ITEM_2240_V itemInfo);
|
||||||
|
|
||||||
|
Task UpdateHeightAsync(string trayCode, int height);
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ public class PalletService : IPalletService
|
|||||||
{
|
{
|
||||||
_palletRepository = serviceProvider.CreateScope().ServiceProvider
|
_palletRepository = serviceProvider.CreateScope().ServiceProvider
|
||||||
.GetRequiredService<IRepository<PalletEntity>>();
|
.GetRequiredService<IRepository<PalletEntity>>();
|
||||||
|
// _palletRepository = serviceProvider.GetService<IRepository<PalletEntity>>();
|
||||||
_pallets = _palletRepository.GetList().Select(Pallet.FromEntity).ToList();
|
_pallets = _palletRepository.GetList().Select(Pallet.FromEntity).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ public class TrayService : ITrayService
|
|||||||
public TrayService(IServiceProvider provider, IHyosungWmsService hyosungWmsService)
|
public TrayService(IServiceProvider provider, IHyosungWmsService hyosungWmsService)
|
||||||
{
|
{
|
||||||
_repository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<TrayEntity>>();
|
_repository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<TrayEntity>>();
|
||||||
|
//_repository = provider.GetService<IRepository<TrayEntity>>();
|
||||||
var trays = _repository.GetList(t => t.ControlNo == null);
|
var trays = _repository.GetList(t => t.ControlNo == null);
|
||||||
_hyosungWmsService = hyosungWmsService;
|
_hyosungWmsService = hyosungWmsService;
|
||||||
foreach (var tray in trays)
|
foreach (var tray in trays)
|
||||||
@ -64,7 +65,7 @@ public class TrayService : ITrayService
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Tray> PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo)
|
public async Task<Tray> PrintTrayAsync(string trayCode, int controlNo, MST_ITEM_2240_V itemInfo)
|
||||||
{
|
{
|
||||||
Tray tray;
|
Tray tray;
|
||||||
try
|
try
|
||||||
@ -77,7 +78,6 @@ public class TrayService : ITrayService
|
|||||||
}
|
}
|
||||||
|
|
||||||
tray.ControlNo = controlNo;
|
tray.ControlNo = controlNo;
|
||||||
tray.StackHeight = stackHeight;
|
|
||||||
tray.Grade = itemInfo.GRADE;
|
tray.Grade = itemInfo.GRADE;
|
||||||
tray.Type = itemInfo.TYPE;
|
tray.Type = itemInfo.TYPE;
|
||||||
tray.DenFila = itemInfo.DEN_FILA;
|
tray.DenFila = itemInfo.DEN_FILA;
|
||||||
@ -99,4 +99,11 @@ public class TrayService : ITrayService
|
|||||||
await _repository.UpdateAsync(tray);
|
await _repository.UpdateAsync(tray);
|
||||||
_cache.TryRemove(tray.TrayCode, out _);
|
_cache.TryRemove(tray.TrayCode, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateHeightAsync(string trayCode, int height)
|
||||||
|
{
|
||||||
|
await _repository.AsUpdateable()
|
||||||
|
.Where(x => x.TrayCode == trayCode)
|
||||||
|
.SetColumns(x => x.StackHeight, height).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,6 +20,8 @@ public class VarietyService : IVarietyService
|
|||||||
_varietyRepository =
|
_varietyRepository =
|
||||||
provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<VarietyEntity>>();
|
provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<VarietyEntity>>();
|
||||||
_palletRepository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<PalletEntity>>();
|
_palletRepository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<PalletEntity>>();
|
||||||
|
//_varietyRepository = provider.GetService<IRepository<VarietyEntity>>();
|
||||||
|
// _palletRepository = provider.GetService<IRepository<PalletEntity>>();
|
||||||
_varietiesCache = new List<VarietyEntity>(_varietyRepository.GetList());
|
_varietiesCache = new List<VarietyEntity>(_varietyRepository.GetList());
|
||||||
_palletsCache = new List<PalletEntity>(_palletRepository.GetList());
|
_palletsCache = new List<PalletEntity>(_palletRepository.GetList());
|
||||||
}
|
}
|
||||||
|
@ -13,6 +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>>();
|
||||||
|
// _yarnRepository = provider.GetService<IRepository<ScannedYarnEntity>>();
|
||||||
NoFinished = new ConcurrentDictionary<string, 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)
|
||||||
|
@ -12,6 +12,7 @@ using Seyounth.Hyosung.Data.Services;
|
|||||||
using Seyounth.Hyosung.Data.Services.Hyosung;
|
using Seyounth.Hyosung.Data.Services.Hyosung;
|
||||||
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
||||||
using Seyounth.Hyosung.Runtime.Models;
|
using Seyounth.Hyosung.Runtime.Models;
|
||||||
|
using static System.Runtime.CompilerServices.RuntimeHelpers;
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Runtime;
|
namespace Seyounth.Hyosung.Runtime;
|
||||||
|
|
||||||
@ -30,6 +31,8 @@ public class HyosungRuntime(
|
|||||||
public StackStationModel Stack1 { get; private set; } = new();
|
public StackStationModel Stack1 { get; private set; } = new();
|
||||||
public StackStationModel Stack2 { get; private set; } = new();
|
public StackStationModel Stack2 { get; private set; } = new();
|
||||||
|
|
||||||
|
private string currentPrintTrayCode = "";
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken token)
|
public async Task StartAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
//启动扫码服务
|
//启动扫码服务
|
||||||
@ -43,9 +46,12 @@ public class HyosungRuntime(
|
|||||||
hyosungPlcService.OnPlcPutCompleted += OnPlcPutCompleted;
|
hyosungPlcService.OnPlcPutCompleted += OnPlcPutCompleted;
|
||||||
hyosungPlcService.OnPlcRequestPackLineOption += OnPlcRequestPackLineOption;
|
hyosungPlcService.OnPlcRequestPackLineOption += OnPlcRequestPackLineOption;
|
||||||
hyosungPlcService.OnRequestPrintLabel += OnPlcRequestPrintLabel;
|
hyosungPlcService.OnRequestPrintLabel += OnPlcRequestPrintLabel;
|
||||||
|
hyosungPlcService.OnRequestGetPrintLableOption += OnRequestGetPrintLabel;
|
||||||
await hyosungPlcService.StartAsync(token);
|
await hyosungPlcService.StartAsync(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task StopAsync(CancellationToken token)
|
public async Task StopAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
//先停止扫码服务
|
//先停止扫码服务
|
||||||
@ -280,19 +286,10 @@ public class HyosungRuntime(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private async Task OnRequestGetPrintLabel(string arg)
|
||||||
/// 处理贴标站请求贴标事件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="arg1"></param>
|
|
||||||
/// <param name="arg2"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
|
||||||
private async Task OnPlcRequestPrintLabel(int arg1, string trayCode, int height)
|
|
||||||
{
|
{
|
||||||
logger.LogInformation($"plc request print label:{arg1} {trayCode} {height}");
|
currentPrintTrayCode = arg;
|
||||||
try
|
var tray = await trayService.GetByCode(arg);
|
||||||
{
|
|
||||||
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";
|
||||||
@ -301,18 +298,36 @@ public class HyosungRuntime(
|
|||||||
if (tray.ControlNo is null || tray.ControlNo == 0)
|
if (tray.ControlNo is null || tray.ControlNo == 0)
|
||||||
{
|
{
|
||||||
controlNo = await hyosungWmsService.GetControlNo(variety, grade);
|
controlNo = await hyosungWmsService.GetControlNo(variety, grade);
|
||||||
tray = await trayService.PrintTrayAsync(trayCode, height, controlNo, mod);
|
tray = await trayService.PrintTrayAsync(arg, controlNo, mod);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理贴标站请求贴标事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg1"></param>
|
||||||
|
/// <param name="arg2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
|
private async Task OnPlcRequestPrintLabel(int arg1, int height)
|
||||||
|
{
|
||||||
|
logger.LogInformation($"plc request print label:{arg1} {currentPrintTrayCode} {height}");
|
||||||
|
var tray = await trayService.GetByCode(currentPrintTrayCode);
|
||||||
|
var variety = await varietyService.GetById(tray.VarietyId);
|
||||||
|
await trayService.UpdateHeightAsync(currentPrintTrayCode, height);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
if (arg1 == 1)
|
if (arg1 == 1)
|
||||||
{
|
{
|
||||||
await printer.PrintAsync(1, trayCode);
|
await printer.PrintAsync(1, currentPrintTrayCode);
|
||||||
await hyosungPlcService.WritePrintLabelResultAsync(arg1, variety.SubLabelCount, true);
|
await hyosungPlcService.WritePrintLabelResultAsync(arg1, variety.SubLabelCount, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await printer.PrintAsync(2, trayCode);
|
await printer.PrintAsync(2, currentPrintTrayCode);
|
||||||
await hyosungPlcService.WritePrintLabelResultAsync(arg1, variety.MasterLabelCount, true);
|
await hyosungPlcService.WritePrintLabelResultAsync(arg1, variety.MasterLabelCount, true);
|
||||||
await hyosungWmsService.UpdateControlNo(variety, controlNo);
|
await hyosungWmsService.UpdateControlNo(variety, tray.ControlNo.Value);
|
||||||
await hyosungWmsService.AddLabelResult(new LabelResult(tray, variety));
|
await hyosungWmsService.AddLabelResult(new LabelResult(tray, variety));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user