xiugaiBUG

This commit is contained in:
zhangzhuo 2025-03-18 05:24:15 +08:00
parent a82b05bd60
commit 957917bc4d
9 changed files with 83 additions and 48 deletions

View File

@ -132,15 +132,23 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
{
while (!token.IsCancellationRequested)
{
await QueryScanProductRequest();
await QueryScanFixtureRequest();
if (!isLeaving)
await QueryLeavingProductionLine();
await QueryNeedTrayCode();
await QueryPutOnceCompleted();
await QueryPackLineOption();
await QueryPrintLabel();
await Task.Delay(100, token);
try
{
await QueryScanProductRequest();
await QueryScanFixtureRequest();
if (!isLeaving)
await QueryLeavingProductionLine();
await QueryNeedTrayCode();
await QueryPutOnceCompleted();
await QueryPackLineOption();
await QueryPrintLabel();
await Task.Delay(100, token);
}
catch(Exception e)
{
}
}
}
@ -234,8 +242,9 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
private async Task QueryPutOnceCompleted()
{
var status = await _reader.ReadShortsAsync(4691, 2);
if (status[0] == 1)
if (status[0] >0 )
{
await _writer.WriteShortsAsync(4690, 0, 0, 0);
var trayCode = await _reader.ReadStringAsync(4620);
var yarn1 = await _reader.ReadStringAsync(4630);
var yarn2 = await _reader.ReadStringAsync(4640);
@ -258,7 +267,7 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
return;
}
await _writer.WriteShortsAsync(4690, 0, 0, 0);
await _writer.WriteShortsAsync(4620, new short[40]);
OnPlcPutCompleted?.Invoke(info);
}

View File

@ -14,7 +14,7 @@ public class TrayEntity
[SugarColumn(ColumnDescription = "所属的品类信息")]
public int VarietyId { get; set; }
[SugarColumn(ColumnDescription = "垛高")]
[SugarColumn(ColumnDescription = "垛高",IsNullable =true)]
public int? StackHeight { get; set; }
[SugarColumn(ColumnDescription = "是否为双号")]

View File

@ -57,7 +57,7 @@ public class VarietyEntity
[SugarColumn(ColumnDescription = "垛头数量")]
public int? StackHeadCount { get; set; }
[SugarColumn(ColumnDescription = "纸托Id")]
[SugarColumn(ColumnDescription = "纸托Id",IsNullable =true)]
public int? PaperTrayId { get; set; }
[SugarColumn(ColumnDescription = "是否需要纸箱")]

View File

@ -4,10 +4,10 @@ namespace Seyounth.Hyosung.Data.Models;
public enum NeedType
{
[Description("需要")] Need,
[Description("不需要")] NotNeed,
[Description("单号需要")] OddNeed,
[Description("双号需要")] EvenNeed
[Description("需要")] Need=1,
[Description("不需要")] NotNeed=2,
[Description("单号需要")] OddNeed=3,
[Description("双号需要")] EvenNeed=4
}
public class NeedTypeEnumItem

View File

@ -164,13 +164,13 @@ public class Variety
ls.Add((short)PaperTray.Height);
}
ls.Add((short)TopAndBottomPallet.HoleCount);
ls.Add((short)(TopAndBottomPallet.IsBigHole.Value ? 1 : 2));
ls.Add((short)(TopAndBottomPallet.HoleCount is null?0: TopAndBottomPallet.HoleCount));
ls.Add((short)(TopAndBottomPallet.IsBigHole is null?2:(TopAndBottomPallet.IsBigHole.Value?1:2)));
ls.Add((short)TopAndBottomPallet.Length);
ls.Add((short)TopAndBottomPallet.Width);
ls.Add((short)TopAndBottomPallet.Height);
ls.Add((short)MiddlePallet.HoleCount);
ls.Add((short)(MiddlePallet.IsBigHole.Value ? 1 : 2));
ls.Add((short)(MiddlePallet.HoleCount is null ? 0 : MiddlePallet.HoleCount));
ls.Add((short)(MiddlePallet.IsBigHole is null ? 2 : (MiddlePallet.IsBigHole.Value ? 1 : 2)));
ls.Add((short)MiddlePallet.Length);
ls.Add((short)MiddlePallet.Width);
ls.Add((short)MiddlePallet.Height);

View File

@ -16,24 +16,24 @@ public static class ServiceExtensions
var connectionString = configuration.GetConnectionString("DefaultConnection");
services.AddSingleton<ISqlSugarClient>(s =>
{
//#if RELEASE
// SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
// {
// DbType = DbType.SqlServer,
// ConnectionString = connectionString,
// IsAutoCloseConnection = true,
// }
// );
//#elif DEBUG
//#if RELEASE
SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
{
DbType = DbType.Sqlite,
ConnectionString = "Data Source=hyosung.db",
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
}
{
DbType = DbType.SqlServer,
ConnectionString = connectionString,
IsAutoCloseConnection = true,
}
);
//#endif
//#elif DEBUG
//SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
// {
// DbType = DbType.Sqlite,
// ConnectionString = "Data Source=hyosung.db",
// IsAutoCloseConnection = true,
// InitKeyType = InitKeyType.Attribute
// }
//);
//#endif
return sqlSugar;
});
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
@ -49,13 +49,13 @@ public static class ServiceExtensions
public static void UseHyosungData(this IServiceProvider provider)
{
var db = provider.GetRequiredService<ISqlSugarClient>();
db.DbMaintenance.CreateDatabase();
db.CodeFirst.InitTables(typeof(VarietyEntity),
typeof(PalletEntity),
typeof(ScannedYarnEntity),
typeof(TrayEntity),
typeof(AgvBinEntity),
typeof(DictEntity));
//var db = provider.GetRequiredService<ISqlSugarClient>();
//db.DbMaintenance.CreateDatabase();
//db.CodeFirst.InitTables(typeof(VarietyEntity),
// typeof(PalletEntity),
// typeof(ScannedYarnEntity),
// typeof(TrayEntity),
// typeof(AgvBinEntity),
// typeof(DictEntity));
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Concurrent;
using Microsoft.Extensions.DependencyInjection;
using Seyounth.Core.Extensions;
using Seyounth.Hyosung.Data.Entities;
using Seyounth.Hyosung.Data.Models;
using Seyounth.Hyosung.Data.Repositories;
@ -29,7 +30,7 @@ public class TrayService : ITrayService
{
var tray = new Tray()
{
TrayCode = DateTime.Now.ToString("yyMMddHHmmss"),
TrayCode =DateTime.Now.ToTimestamp().ToString(),
VarietyId = varietyId,
CreateTime = DateTime.Now
};
@ -43,7 +44,16 @@ public class TrayService : ITrayService
public async Task<int> GetIdByCode(string code)
{
return _cache[code].Id;
try
{
return _cache[code].Id;
}
catch
{
return (await _repository.GetFirstAsync(d => d.TrayCode == code)).Id;
}
}
public async Task<Tray> GetByCode(string code)

View File

@ -39,7 +39,15 @@ public class YarnService : IYarnService
public async Task<Yarn> GetYarnByCodeAsync(string code)
{
return NoFinished[code];
try
{
return NoFinished[code];
}
catch
{
return Yarn.FromEntity(await _yarnRepository.GetFirstAsync(d => d.ScanCode == code)) ;
}
}
public async Task FinishYarnAsync(string yarnCode)

View File

@ -102,6 +102,13 @@ public class HyosungRuntime(
return;
}
var variety = await varietyService.GetById(varietyId);
if (yarn.Lot != variety.Lot)
{
await hyosungPlcService.WriteScanYarnResultAsync(false);
logger.LogInformation($"scan yarn fail,lot not equal");
return;
}
await yarnService.AddYarnAsync(yarn);
await hyosungPlcService.WriteScanYarnResultAsync(true, (short)varietyId, yarn.ScanCode);
logger.LogInformation($"scan yarn {yarn.ScanCode} success: qrcode[{yarn.QrCode}]");
@ -180,6 +187,7 @@ public class HyosungRuntime(
foreach (var yarnCode in arg.YarnCode)
{
await yarnService.BindTrayAsync(yarnCode, await trayService.GetIdByCode(arg.TrayCode));
logger.LogInformation($" stack yarn{yarnCode} succeed");
}
await hyosungPlcService.WriteReceivedYarnCountAsync(arg.YarnCode.Count);