增加插入到Hyosung数据库的方法

This commit is contained in:
anerx 2025-03-20 20:45:38 +08:00
parent ab90afda5b
commit 4251b781f9
11 changed files with 141 additions and 59 deletions

View File

@ -103,23 +103,23 @@ public class HyosungPrinter(
private async Task<string> GetPrint2Content(Tray tray)
{
var variety = await varietyService.GetById(tray.VarietyId);
var labelResult =
await hyosungWmsService.GetLabelResult(variety.Code, variety.Lot.ToString(), tray.ControlNo!.Value);
var dic = new Dictionary<string, string>
{
{ "$1153", $"\"{variety.Lot}\"" },
{ "1670dtex -144F", $"\"{tray.DtexFila}\"" },
{ "1500D - 144F", $"\"{tray.DenFila}\"" },
{ "$SA", $"\"{tray.Grade}\"" },
{ "$900", $"\"{labelResult.NET_WEIGHT.ToString("0.0")}\"" },
{ "$900", $"\"{tray.NetWeight:0.0}\"" },
{ "25-01-01", $"\"{DateTime.Now:yy-MM-dd}\"" },
{ "$90", $"\"{variety.TotalCount}\"" },
{ "$965", $"\"{labelResult.GROSS_WEIGHT}\"" },
{ "$965", $"\"{tray.GrossWeight}\"" },
{
"250101J068",
$"\"{DateTime.Now.ToString("yyMMdd" + "J") + tray.ControlNo.ToString()?.PadLeft(3, '0')}\""
},
{ "DTYY-JPA11530SFG250101000900115305480", $"\"{labelResult.BAR_CODE}\"" }
{ "DTYY-JPA11530SFG250101000900115305480", $"\"{tray.Barcode}\"" }
};
string content = options.Value.DefaultTemp;
foreach (var (key, value) in dic)

View File

@ -40,4 +40,6 @@ public class TrayEntity
[SugarColumn(IsNullable = true)] public double GrossWeight { get; set; }
[SugarColumn(IsNullable = true)] public int? AgvBinId { get; set; }
[SugarColumn(IsNullable = true)] public string? Barcode { get; set; }
}

View File

@ -36,6 +36,8 @@ public class Tray
public int? AgvBinId { get; set; }
public string? Barcode { get; set; }
public TrayEntity ToEntity()
{
return new TrayEntity()
@ -55,7 +57,8 @@ public class Tray
Grade = Grade,
Type = Type,
Unit = Unit,
AgvBinId = AgvBinId
AgvBinId = AgvBinId,
Barcode = Barcode
};
}
@ -78,7 +81,8 @@ public class Tray
Grade = entity.Grade,
Type = entity.Type,
Unit = entity.Unit,
AgvBinId = entity.AgvBinId
AgvBinId = entity.AgvBinId,
Barcode = entity.Barcode
};
}
}

View File

@ -1,3 +1,4 @@
using Seyounth.Hyosung.Data.Models;
using SqlSugar;
namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
@ -5,34 +6,54 @@ namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
[SugarTable("LABEL_RESULT")]
public class LabelResult
{
public string BE_ID { get; set; }
public string BAR_CODE { get; set; }
public string ITEM_CODE { get; set; }
public string LABEL_ID { get; set; }
public string WMS_UOM { get; set; }
public string ERP_UOM { get; set; }
public string MFG_DATE { get; set; }
public decimal NET_WEIGHT { get; set; }
public double GROSS_WEIGHT { get; set; }
public string MFG_LINE { get; set; }
public string GRADE { get; set; }
public string LOT { get; set; }
public string BOX_NO { get; set; }
public string DENIER { get; set; }
public string FILA { get; set; }
public string CUSTOMER_NAME { get; set; }
public string REMARKS { get; set; }
public string TRI_INTERFACE_YN { get; set; }
public string TRI_TYPE { get; set; }
public string COMMON_S1 { get; set; }
public string COMMON_S2 { get; set; }
public string COMMON_S3 { get; set; }
public string COMMON_S4 { get; set; }
public string COMMON_S5 { get; set; }
public string COMMON_N1 { get; set; }
public string TRI_YN { get; set; }
public string CREATED_BY { get; set; }
public string CREATED_ON { get; set; }
public string MODIFIED_BY { get; set; }
public string MODIFIED_ON { get; set; }
public string BE_ID { get; set; } = "2240";
public string BAR_CODE { get; set; } = "";
public string ITEM_CODE { get; set; } = "";
public string LABEL_ID { get; set; } = "";
public string WMS_UOM { get; set; } = "";
public string ERP_UOM { get; set; } = "";
public string MFG_DATE { get; set; } = "";
public decimal NET_WEIGHT { get; set; } = 0;
public double GROSS_WEIGHT { get; set; } = 0;
public string MFG_LINE { get; set; } = "";
public string GRADE { get; set; } = "";
public string LOT { get; set; } = "";
public string BOX_NO { get; set; } = "";
public string DENIER { get; set; } = "";
public string FILA { get; set; } = "";
public string CUSTOMER_NAME { get; set; } = "";
public string REMARKS { get; set; } = "";
public string TRI_INTERFACE_YN { get; set; } = "";
public string TRI_TYPE { get; set; } = "zp10";
public string COMMON_S1 { get; set; } = "";
public string COMMON_S2 { get; set; } = "";
public string COMMON_S3 { get; set; } = "";
public string COMMON_S4 { get; set; } = "";
public string COMMON_S5 { get; set; } = "";
public string COMMON_N1 { get; set; } = "";
public string TRI_YN { get; set; } = "";
public string CREATED_BY { get; set; } = "seyounth";
public string CREATED_ON { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
public string MODIFIED_BY { get; set; } = "seyounth";
public string MODIFIED_ON { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
public LabelResult(Tray tray, Variety variety)
{
LABEL_ID = tray.TrayCode;
BE_ID = "2240";
BAR_CODE = tray.Barcode ?? "";
ITEM_CODE = variety.Code;
MFG_DATE = DateTime.Now.ToString("yyyy-MM-dd");
NET_WEIGHT = (decimal)tray.NetWeight;
GROSS_WEIGHT = tray.GrossWeight;
GRADE = tray.Grade ?? "";
LOT = variety.Lot.ToString();
BOX_NO = tray.ControlNo?.ToString() ?? "";
CREATED_BY = "seyounth";
CREATED_ON = DateTime.Now.ToString("yyyy-MM-dd");
}
public LabelResult()
{
}
}

View File

@ -0,0 +1,26 @@
namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
public class MST_ITEM
{
public string BE_ID { get; set; } = "2240";
public string ITEM_CODE { get; set; }
public string ITEM_CODE_TYPE { get; set; } = "FERT";
public string COMMON_S1 { get; set; }
public string COMMON_S2 { get; set; }
public string COMMON_S3 { get; set; }
public string COMMON_S4 { get; set; }
public string COMMON_S5 { get; set; }
public string ERP_UOM_ID { get; set; }
public string WMS_UOM_ID { get; set; }
}

View File

@ -0,0 +1,9 @@
namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
public class MST_ITEM_VERSION
{
public string ITEM_CODE { get; set; }
public string WORK_CENTER { get; set; }
}

View File

@ -80,10 +80,26 @@ public class HyosungWmsService : IHyosungWmsService
x.BE_ID == "2240"
)
.FirstAsync();
} catch (Exception e)
}
catch (Exception e)
{
throw e;
}
}
public async Task AddLabelResult(LabelResult result)
{
var mst_item = await _db.Queryable<MST_ITEM>()
.FirstAsync(t => t.BE_ID == "2240"
&& t.ITEM_CODE == result.ITEM_CODE
&& t.ITEM_CODE_TYPE == "FERT");
result.COMMON_S1 = mst_item.COMMON_S1;
result.COMMON_S3 = mst_item.COMMON_S3;
result.COMMON_S5 = mst_item.COMMON_S5;
result.WMS_UOM = mst_item.WMS_UOM_ID;
result.ERP_UOM = mst_item.ERP_UOM_ID;
var workCenter = await _db.Queryable<MST_ITEM_VERSION>()
.FirstAsync(v => v.ITEM_CODE == result.ITEM_CODE);
await _db.Insertable(result).ExecuteCommandAsync();
}
}

View File

@ -12,4 +12,6 @@ public interface IHyosungWmsService
Task UpdateControlNo(Variety variety, int controlNo);
Task<LabelResult> GetLabelResult(string itemCode, string lot, int controlNo);
Task AddLabelResult(LabelResult result);
}

View File

@ -41,5 +41,5 @@ public interface ITrayService
/// <param name="controlNo"></param>
/// <param name="itemInfo"></param>
/// <returns></returns>
Task PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo);
Task<Tray> PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo);
}

View File

@ -47,13 +47,11 @@ public class TrayService : ITrayService
try
{
return _cache[code].Id;
}
catch
{
return (await _repository.GetFirstAsync(d => d.TrayCode == code)).Id;
}
}
public async Task<Tray> GetByCode(string code)
@ -66,7 +64,7 @@ public class TrayService : ITrayService
throw new NotImplementedException();
}
public async Task PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo)
public async Task<Tray> PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo)
{
Tray tray;
try
@ -87,12 +85,14 @@ public class TrayService : ITrayService
tray.Unit = itemInfo.UNIT;
tray.NetWeight = itemInfo.NET_WEIGHT;
tray.GrossWeight = itemInfo.GROSS_WEIGHT;
tray.Barcode =
$"{itemInfo.ITEM_CODE} {DateTime.Now:yyMMdd}00{controlNo.ToString().PadLeft(4, '0')}{itemInfo.LOTNO.PadLeft(4, '0')}0";
await _repository.UpdateAsync(tray.ToEntity());
_cache.Remove(tray.TrayCode, out _);
return tray;
}
public async Task StorageAsync(string trayCode)
{
}
}

View File

@ -10,6 +10,7 @@ using Seyounth.Hyosung.Data.Models;
using Seyounth.Hyosung.Data.Models.Plc;
using Seyounth.Hyosung.Data.Services;
using Seyounth.Hyosung.Data.Services.Hyosung;
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
using Seyounth.Hyosung.Runtime.Models;
namespace Seyounth.Hyosung.Runtime;
@ -297,7 +298,7 @@ public class HyosungRuntime(
var grade = "1";
if (mod.GRADE != "AA") grade = mod.GRADE;
var controlNo = await hyosungWmsService.GetControlNo(variety, grade);
await trayService.PrintTrayAsync(trayCode, height, controlNo, mod);
tray = await trayService.PrintTrayAsync(trayCode, height, controlNo, mod);
if (arg1 == 1)
{
await printer.PrintAsync(1, trayCode);
@ -311,6 +312,7 @@ public class HyosungRuntime(
await hyosungWmsService.UpdateControlNo(variety, controlNo);
await hyosungWmsService.AddLabelResult(new LabelResult(tray, variety));
logger.LogInformation($"plc request print label success");
}
catch (Exception e)