change-替换原有条码表及实体实现类

dev
liuwf 3 months ago
parent c7d71551d6
commit 4549a649d1

@ -0,0 +1,89 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Model.domain
* 6741452a-5ee5-4405-9465-8aaa5c331cbc
*
* WenJY
* wenjy@mesnac.com
* 2024-04-10 16:40:11
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Model.domain
{
[SugarTable("mes_prd_barcode_info"), TenantAttribute("mes")]
public class MesPrdBarcodeInfo
{
/// <summary>
/// 主键标识
/// </summary>
[SugarColumn(ColumnName = "prd_barcode_id", IsPrimaryKey = true, IsIdentity = true)]
public int PrdBarcodeId { get; set; }
/// <summary>
/// 小包条码
/// </summary>
[SugarColumn(ColumnName = "prd_barcode_info")]
public string PrdBarcodeInfo { get; set; }
/// <summary>
/// 喷码标识,1-已喷印0-未喷印
/// </summary>
[SugarColumn(ColumnName = "print_flag")]
public string ?PrintFlag { get; set; }
/// <summary>
/// 关联mes_base_barcode_info里的大条码
/// </summary>
[SugarColumn(ColumnName = "mes_barcode_info")]
public string? MesBarcodeInfo { get; set; }
/// <summary>
/// 绑定托盘号
/// </summary>
[SugarColumn(ColumnName = "pallet_info_code")]
public string? PalletInfoCode { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "creat_time")]
public DateTime?CreatTime { get; set; }
/// <summary>
/// 喷印时间
/// </summary>
[SugarColumn(ColumnName = "print_time")]
public DateTime? PrintTime { get; set; }
/// <summary>
/// 绑定时间
/// </summary>
[SugarColumn(ColumnName = "bind_time")]
public DateTime? BindTime { get; set; }
}
}

@ -1,63 +0,0 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Model.domain
* 6741452a-5ee5-4405-9465-8aaa5c331cbc
*
* WenJY
* wenjy@mesnac.com
* 2024-04-10 16:40:11
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Model.domain
{
[SugarTable("real_barcode_task"), TenantAttribute("mes")]
public class RealBarCodeTask
{
/// <summary>
/// 主键标识
/// </summary>
[SugarColumn(ColumnName = "obj_id", IsPrimaryKey = true, IsIdentity = true)]
public int ObjId { get; set; }
/// <summary>
/// 小包条码
/// </summary>
[SugarColumn(ColumnName = "bar_code")]
public string BarCode { get; set; }
/// <summary>
/// 计划编号
/// </summary>
[SugarColumn(ColumnName = "plan_code")]
public string PlanCode { get;set; }
/// <summary>
/// 物料编码
/// </summary>
[SugarColumn(ColumnName = "material_code")]
public string MaterialCode { get;set; }
/// <summary>
/// 记录时间
/// </summary>
[SugarColumn(ColumnName = "record_time")]
public DateTime RecordTime { get; set; }
}
}

@ -6,7 +6,7 @@ using System.Text;
namespace SlnMesnac.Repository.service
{
public interface IRealBarCodeTaskService:IBaseService<RealBarCodeTask>
public interface IMesPrdBarCodeService:IBaseService<MesPrdBarcodeInfo>
{
/// <summary>
/// 保存条码队列信息
@ -14,13 +14,13 @@ namespace SlnMesnac.Repository.service
/// <param name="task"></param>
/// <param name="barCodeTasks"></param>
/// <exception cref="InvalidOperationException"></exception>
void InsertBarCodeTask(RealBarCodeTask task);
void InsertBarCodeTask(MesPrdBarcodeInfo barcodeInfo);
/// <summary>
/// 移除条码队列
/// </summary>
/// <param name="barCode"></param>
/// <exception cref="InvalidOperationException"></exception>
void RemoveBarCodeTask(string barCode);
// void RemoveBarCodeTask(string barCode);
}
}

@ -30,10 +30,10 @@ using System.Text;
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository.service.Impl
{
public class RealBarCodeTaskServiceImpl : BaseServiceImpl<RealBarCodeTask>, IRealBarCodeTaskService
public class MesPrdBarCodeServiceImpl : BaseServiceImpl<MesPrdBarcodeInfo>, IMesPrdBarCodeService
{
private IServiceProvider _serviceProvider;
public RealBarCodeTaskServiceImpl(Repository<RealBarCodeTask> rep, IServiceProvider serviceProvider) : base(rep)
public MesPrdBarCodeServiceImpl(Repository<MesPrdBarcodeInfo> rep, IServiceProvider serviceProvider) : base(rep)
{
_serviceProvider = serviceProvider;
}
@ -44,24 +44,21 @@ namespace SlnMesnac.Repository.service.Impl
/// <param name="task"></param>
/// <param name="barCodeTasks"></param>
/// <exception cref="InvalidOperationException"></exception>
public void InsertBarCodeTask(RealBarCodeTask task)
public void InsertBarCodeTask(MesPrdBarcodeInfo mesPrdBarcodeInfo)
{
try
{
if (task == null)
if (mesPrdBarcodeInfo == null)
{
throw new ArgumentNullException($"保存条码队列信息异常:参数为空");
}
var taskInfos = Query(x => x.BarCode == task.BarCode).ToList();
var taskInfos = Query(x => x.PrdBarcodeInfo == mesPrdBarcodeInfo.PrdBarcodeInfo).ToList();
if (taskInfos.Count > 0)
{
Deletes(taskInfos);
}
Insert(task);
RefreshLocalTask();
Insert(mesPrdBarcodeInfo);
}
catch (Exception e)
@ -75,53 +72,53 @@ namespace SlnMesnac.Repository.service.Impl
/// </summary>
/// <param name="barCode"></param>
/// <exception cref="InvalidOperationException"></exception>
public void RemoveBarCodeTask(string barCode)
{
try
{
if (string.IsNullOrEmpty(barCode))
{
throw new ArgumentNullException($"移除条码队列信息异常:参数为空");
}
var taskInfos = Query(x => x.BarCode == barCode).ToList();
Deletes(taskInfos);
RefreshLocalTask();
}
catch (Exception e)
{
throw new InvalidOperationException($"移除条码队列信息异常:{e.Message}");
}
}
/// <summary>
//public void RemoveBarCodeTask(string barCode)
//{
// try
// {
// if (string.IsNullOrEmpty(barCode))
// {
// throw new ArgumentNullException($"移除条码队列信息异常:参数为空");
// }
// var taskInfos = Query(x => x.BarCode == barCode).ToList();
// Deletes(taskInfos);
// RefreshLocalTask();
// }
// catch (Exception e)
// {
// throw new InvalidOperationException($"移除条码队列信息异常:{e.Message}");
// }
//}
///// <summary>
/// 刷新条码队列缓存信息
/// </summary>
/// <param name="palletTasks"></param>
/// <exception cref="InvalidOperationException"></exception>
private void RefreshLocalTask()
{
try
{
//private void RefreshLocalTask()
//{
// try
// {
using (var scope = _serviceProvider.CreateScope())
{
var info = scope.ServiceProvider.GetRequiredService<List<RealBarCodeTask>>();
// using (var scope = _serviceProvider.CreateScope())
// {
// var info = scope.ServiceProvider.GetRequiredService<List<RealBarCodeTask>>();
var infos = base.Query(x => 1 == 1, y => y.RecordTime, true).ToList();
// var infos = base.Query(x => 1 == 1, y => y.RecordTime, true).ToList();
info.Clear();
// info.Clear();
info.AddRange(infos);
// info.AddRange(infos);
}
}
catch (Exception e)
{
throw new InvalidOperationException($"刷新条码队列缓存信息异常:{e.Message}");
}
}
// }
// }
// catch (Exception e)
// {
// throw new InvalidOperationException($"刷新条码队列缓存信息异常:{e.Message}");
// }
//}
}
}
Loading…
Cancel
Save