xiugaiBUG
This commit is contained in:
parent
a82b05bd60
commit
957917bc4d
@ -131,6 +131,8 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
||||
private async Task ReadLoop(CancellationToken token)
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
await QueryScanProductRequest();
|
||||
await QueryScanFixtureRequest();
|
||||
@ -142,6 +144,12 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
||||
await QueryPrintLabel();
|
||||
await Task.Delay(100, token);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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 = "是否为双号")]
|
||||
|
@ -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 = "是否需要纸箱")]
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -17,22 +17,22 @@ public static class ServiceExtensions
|
||||
services.AddSingleton<ISqlSugarClient>(s =>
|
||||
{
|
||||
//#if RELEASE
|
||||
// SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
|
||||
// {
|
||||
// DbType = DbType.SqlServer,
|
||||
// ConnectionString = connectionString,
|
||||
// IsAutoCloseConnection = true,
|
||||
// }
|
||||
// );
|
||||
//#elif DEBUG
|
||||
SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.Sqlite,
|
||||
ConnectionString = "Data Source=hyosung.db",
|
||||
DbType = DbType.SqlServer,
|
||||
ConnectionString = connectionString,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = InitKeyType.Attribute
|
||||
}
|
||||
);
|
||||
//#elif DEBUG
|
||||
//SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
|
||||
// {
|
||||
// DbType = DbType.Sqlite,
|
||||
// ConnectionString = "Data Source=hyosung.db",
|
||||
// IsAutoCloseConnection = true,
|
||||
// InitKeyType = InitKeyType.Attribute
|
||||
// }
|
||||
//);
|
||||
//#endif
|
||||
return sqlSugar;
|
||||
});
|
||||
@ -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));
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
@ -42,8 +43,17 @@ public class TrayService : ITrayService
|
||||
}
|
||||
|
||||
public async Task<int> GetIdByCode(string code)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _cache[code].Id;
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (await _repository.GetFirstAsync(d => d.TrayCode == code)).Id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<Tray> GetByCode(string code)
|
||||
|
@ -38,9 +38,17 @@ public class YarnService : IYarnService
|
||||
}
|
||||
|
||||
public async Task<Yarn> GetYarnByCodeAsync(string code)
|
||||
{
|
||||
try
|
||||
{
|
||||
return NoFinished[code];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Yarn.FromEntity(await _yarnRepository.GetFirstAsync(d => d.ScanCode == code)) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task FinishYarnAsync(string yarnCode)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user