修正重量信息
This commit is contained in:
parent
6a1382993b
commit
22576d17cc
@ -87,4 +87,10 @@ public class VarietyEntity
|
||||
[SugarColumn(IsNullable =true)]
|
||||
public int? LastNo { get; set; }
|
||||
|
||||
[SugarColumn(IsNullable =true)]
|
||||
public double? NetWeight { get; set; }
|
||||
|
||||
[SugarColumn(IsNullable =true)]
|
||||
public double? GrossWeight { get; set; }
|
||||
|
||||
}
|
||||
@ -66,6 +66,10 @@ public class Variety
|
||||
|
||||
public int? LastNo { get; set; }
|
||||
|
||||
public double? NetWeight { get; set; }
|
||||
|
||||
public double? GrossWeight { get; set; }
|
||||
|
||||
public static Variety Create(VarietyEntity entity, List<PalletEntity> pallets)
|
||||
{
|
||||
var variety = new Variety()
|
||||
@ -95,7 +99,9 @@ public class Variety
|
||||
TopAndBottomPallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.TopAndBottomPalletId)),
|
||||
Tray = Pallet.FromEntity(pallets.First(x => x.Id == entity.TrayId)),
|
||||
HasBox = entity.HasBox,
|
||||
LastNo = entity.LastNo
|
||||
LastNo = entity.LastNo,
|
||||
NetWeight = entity.NetWeight,
|
||||
GrossWeight = entity.GrossWeight
|
||||
};
|
||||
if (entity.PaperTrayId != null && entity.PaperTrayId != 0)
|
||||
variety.PaperTray = Pallet.FromEntity(pallets.First(x => x.Id == entity.PaperTrayId));
|
||||
@ -133,7 +139,9 @@ public class Variety
|
||||
TopAndBottomPalletId = TopAndBottomPallet.Id,
|
||||
TrayId = Tray.Id,
|
||||
HasBox = HasBox,
|
||||
LastNo=LastNo
|
||||
LastNo = LastNo,
|
||||
NetWeight = NetWeight,
|
||||
GrossWeight = GrossWeight
|
||||
};
|
||||
return entity;
|
||||
}
|
||||
@ -168,13 +176,13 @@ public class Variety
|
||||
ls.Add((short)PaperTray.Height);
|
||||
}
|
||||
|
||||
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.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 is null ? 0 : MiddlePallet.HoleCount));
|
||||
ls.Add((short)(MiddlePallet.IsBigHole is null ? 2 : (MiddlePallet.IsBigHole.Value ?1 : 2)));
|
||||
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);
|
||||
|
||||
@ -6,4 +6,6 @@ public interface IReportExportService
|
||||
|
||||
|
||||
Task ExportNoExportAsync();
|
||||
|
||||
Task ExportTodayTotalReportAsync();
|
||||
}
|
||||
@ -44,7 +44,7 @@ public interface ITrayService
|
||||
/// <param name="controlNo"></param>
|
||||
/// <param name="itemInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<Tray> PrintTrayAsync(string trayCode, MST_ITEM_2240_V itemInfo);
|
||||
Task<Tray> PrintTrayAsync(string trayCode, MST_ITEM_2240_V itemInfo,Variety variety);
|
||||
|
||||
Task UpdateHeightAsync(string trayCode, int height);
|
||||
|
||||
@ -54,4 +54,6 @@ public interface ITrayService
|
||||
Task<List<string>> GetNoExportCodesAsync();
|
||||
|
||||
Task SetControlNoAsync(string trayCode, int controlNo);
|
||||
|
||||
Task<List<Tray>> GetTodayTrayAsync();
|
||||
}
|
||||
@ -62,10 +62,15 @@ public class ReportExportService(
|
||||
row++;
|
||||
}
|
||||
|
||||
for (int i = 8; i < row; i++)
|
||||
{
|
||||
worksheet.Row(i).Height = 31.5;
|
||||
}
|
||||
|
||||
// 自动调整列宽
|
||||
// worksheet.Columns().AdjustToContents();
|
||||
// 获取数据区域
|
||||
var dataRange = worksheet.Range(8, 2, row, 18);
|
||||
var dataRange = worksheet.Range(8, 2, row - 1, 18);
|
||||
// 设置外边框样式
|
||||
dataRange.Style.Border.OutsideBorder = XLBorderStyleValues.Thick;
|
||||
dataRange.Style.Border.InsideBorder = XLBorderStyleValues.Medium;
|
||||
@ -94,6 +99,73 @@ public class ReportExportService(
|
||||
});
|
||||
}
|
||||
|
||||
public async Task ExportTodayTotalReportAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
dt.Columns.Add("序号");
|
||||
dt.Columns.Add("LOT");
|
||||
dt.Columns.Add("品类");
|
||||
dt.Columns.Add("条码");
|
||||
dt.Columns.Add("数量");
|
||||
dt.Columns.Add("毛重");
|
||||
dt.Columns.Add("净重");
|
||||
dt.Columns.Add("控制号");
|
||||
dt.Columns.Add("完成时间");
|
||||
var trays = await trayService.GetTodayTrayAsync();
|
||||
for (int i = 0; i < trays.Count; i++)
|
||||
{
|
||||
var variety = await varietyService.GetById(trays[i].VarietyId);
|
||||
var yarns = await yarnService.GetYarnsByTrayIdAsync(trays[i].Id);
|
||||
dt.Rows.Add(i + 1, variety.Lot, variety.Code, trays[i].Barcode, yarns.Count,
|
||||
trays[i].GrossWeight, trays[i].NetWeight, trays[i].ControlNo,
|
||||
trays[i].FinishTime?.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
||||
var path = await GetTotalDirectoryAsync();
|
||||
var fileName = $"每日报表-{DateTime.Now:yyyyMMdd}.xlsx";
|
||||
var filePath = Path.Combine(path, fileName);
|
||||
using var workbook = new XLWorkbook();
|
||||
var worksheet = workbook.Worksheets.Add(dt);
|
||||
var headerRow = worksheet.FirstRowUsed();
|
||||
headerRow.Style.Font.FontSize = 16;
|
||||
|
||||
// 设置数据行字体大小
|
||||
var dataRows = worksheet.RowsUsed().Skip(1);
|
||||
foreach (var row in dataRows)
|
||||
{
|
||||
row.Style.Font.FontSize = 14;
|
||||
}
|
||||
|
||||
// 自动调整列宽
|
||||
worksheet.Columns().AdjustToContents();
|
||||
workbook.SaveAs(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, "export today report error");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<string> GetTotalDirectoryAsync(DateTime? date = null)
|
||||
{
|
||||
var root = "D:\\每日报表";
|
||||
if (date is null)
|
||||
date = DateTime.Now;
|
||||
// 构建文件夹路径,格式为 年/月/日
|
||||
string directoryPath = Path.Combine(root, date.Value.Year.ToString(), date.Value.Month.ToString());
|
||||
|
||||
// 检查文件夹是否存在
|
||||
if (!Directory.Exists(directoryPath))
|
||||
{
|
||||
// 如果不存在,则创建文件夹
|
||||
await Task.Run(() => Directory.CreateDirectory(directoryPath));
|
||||
}
|
||||
|
||||
return directoryPath;
|
||||
}
|
||||
|
||||
public async Task<string> GetDirectoryAsync(DateTime? date = null)
|
||||
{
|
||||
var root = "D:\\码垛信息";
|
||||
|
||||
@ -69,7 +69,7 @@ public class TrayService : ITrayService
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<Tray> PrintTrayAsync(string trayCode, MST_ITEM_2240_V itemInfo)
|
||||
public async Task<Tray> PrintTrayAsync(string trayCode, MST_ITEM_2240_V itemInfo, Variety variety)
|
||||
{
|
||||
Tray tray;
|
||||
//try
|
||||
@ -86,8 +86,8 @@ public class TrayService : ITrayService
|
||||
tray.DenFila = itemInfo.DEN_FILA;
|
||||
tray.DtexFila = itemInfo.DTEX_FILA;
|
||||
tray.Unit = itemInfo.UNIT;
|
||||
tray.NetWeight = itemInfo.NET_WEIGHT;
|
||||
tray.GrossWeight = itemInfo.GROSS_WEIGHT;
|
||||
tray.NetWeight = variety.NetWeight ?? itemInfo.NET_WEIGHT;
|
||||
tray.GrossWeight = variety.GrossWeight ?? itemInfo.GROSS_WEIGHT;
|
||||
tray.Barcode =
|
||||
$"{itemInfo.ITEM_CODE} {DateTime.Now:yyMMdd}00{itemInfo.LOTNO.PadLeft(4, '0')}{tray.ControlNo?.ToString().PadLeft(4, '0')}0";
|
||||
await _db.Updateable<TrayEntity>(tray.ToEntity()).ExecuteCommandAsync();
|
||||
@ -137,6 +137,14 @@ public class TrayService : ITrayService
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
public Task<List<Tray>> GetTodayTrayAsync()
|
||||
{
|
||||
return _db.CopyNew()
|
||||
.Queryable<TrayEntity>()
|
||||
.Where(x => x.FinishTime >= DateTime.Today && x.FinishTime < DateTime.Today.AddDays(1))
|
||||
.ToListAsync(x => Tray.FromEntity(x));
|
||||
}
|
||||
|
||||
public async Task<Tray> GetIsPacking()
|
||||
{
|
||||
var tray = await _db.CopyNew().Queryable<TrayEntity>().Where(x => x.IsPacking != null && x.IsPacking.Value)
|
||||
|
||||
@ -116,6 +116,15 @@ public class HyosungRuntime(
|
||||
logger.LogInformation($"send variety to plc success: {variety.Id}");
|
||||
}
|
||||
|
||||
public async Task GenerateReportAsync()
|
||||
{
|
||||
var trays = await trayService.GetTodayTrayAsync();
|
||||
foreach (var tray in trays)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理PLC请求扫描治具事件
|
||||
/// </summary>
|
||||
@ -372,7 +381,7 @@ public class HyosungRuntime(
|
||||
// controlNo += 1;
|
||||
//
|
||||
// }
|
||||
tray = await trayService.PrintTrayAsync(arg, mod);
|
||||
tray = await trayService.PrintTrayAsync(arg, mod,variety);
|
||||
await dictService.SetValue("System", "CurrentPackingTrayCode", arg);
|
||||
await hyosungPlcService.WritePrintLableOptionsAsync(variety.MasterLabelCount);
|
||||
}
|
||||
|
||||
@ -32,4 +32,10 @@ public interface IHyosungRuntime
|
||||
/// <param name="variety"></param>
|
||||
/// <returns></returns>
|
||||
Task SendVarietyToPlcAsync(Variety variety);
|
||||
|
||||
/// <summary>
|
||||
/// 生成当日报表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task GenerateReportAsync();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user