20260831功能同步:
1. 不同车间区分料框查询、料框解绑接口 2. 注释电池型号逻辑 3. 打开电池状况界面
This commit is contained in:
@@ -116,10 +116,18 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Enums\Enums.cs" />
|
||||
<Compile Include="ISugarHelper.cs" />
|
||||
<Compile Include="Models\MaterialFrameRule.cs" />
|
||||
<Compile Include="Models\ModelExtension.cs" />
|
||||
<Compile Include="Models\OrderSortEntity.cs" />
|
||||
<Compile Include="Models\QueryCondition.cs" />
|
||||
<Compile Include="Models\QueryDescriptor.cs" />
|
||||
<Compile Include="Models\WorkshopInterfaceConfig.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Service\IBaseService.cs" />
|
||||
<Compile Include="Service\MaterialFrameRuleService.cs" />
|
||||
<Compile Include="Service\MesUrlService.cs" />
|
||||
<Compile Include="Service\BaseService.cs" />
|
||||
<Compile Include="Service\WorkshopInterCfgService.cs" />
|
||||
<Compile Include="SQLSugarHelper.cs" />
|
||||
<Compile Include="SQLSugarService.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 料框码规则表
|
||||
/// </summary>
|
||||
[SugarTable("material_frame_rule")]
|
||||
public class MaterialFrameRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 料框码规则起始匹配编码(第4-7位)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "start_code", Length = 20, IsNullable = false)]
|
||||
public string Start_Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间编码 (如 601)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workshop_code", Length = 10, IsNullable = false)]
|
||||
public string Workshop_Code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除标识 (0:正常, 1:已删除)
|
||||
/// 注意:建议在Service层统一过滤此字段,不直接参与常规业务查询映射
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_deleted")]
|
||||
public bool Is_Deleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "update_time", IsOnlyIgnoreUpdate = true)] // 插入时由数据库默认值处理,更新时自动更新
|
||||
public DateTime Update_Time { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
public static class ModelExtension
|
||||
{
|
||||
public static T ToModel<T>(this System.Data.DataRow row) where T : class, new()
|
||||
{
|
||||
if (row == null) return null;
|
||||
T model = new T();
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
foreach (var prop in properties)
|
||||
{
|
||||
if (row.Table.Columns.Contains(prop.Name))
|
||||
{
|
||||
var value = row[prop.Name];
|
||||
if (value != DBNull.Value)
|
||||
{
|
||||
prop.SetValue(model, Convert.ChangeType(value, prop.PropertyType));
|
||||
}
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 车间接口配置表
|
||||
/// </summary>
|
||||
[SugarTable("workshop_interface_config")]
|
||||
public class WorkshopInterfaceConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workshop_code", Length = 10, IsNullable = false)]
|
||||
public string Workshop_Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接口标识 (如 QueryTrayUrl)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "interface_flag", Length = 50, IsNullable = false)]
|
||||
public string Interface_Flag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接口名称 (如 料框查询)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "interface_name", Length = 100, IsNullable = true)]
|
||||
public string Interface_Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接口URL地址
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "interface_url", Length = 500, IsNullable = true)]
|
||||
public string Interface_Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除标识 (0:正常, 1:已删除)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_deleted", IsIgnore = true)]
|
||||
public bool Is_Deleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "update_time", IsOnlyIgnoreUpdate = true)]
|
||||
public DateTime Update_Time { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Service
|
||||
{
|
||||
public class BaseService<T> : IBaseService<T> where T : class, new()
|
||||
{
|
||||
protected readonly ISqlSugarClient _db;
|
||||
public BaseService(ISqlSugarClient db) { _db = db; }
|
||||
|
||||
public virtual bool Add(T model)
|
||||
{
|
||||
return _db.Insertable(model).ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
public virtual DataTable GetDataTable()
|
||||
{
|
||||
return _db.Queryable<T>().ToDataTable();
|
||||
}
|
||||
|
||||
public virtual List<T> GetList()
|
||||
{
|
||||
return _db.Queryable<T>().ToList();
|
||||
}
|
||||
|
||||
public virtual bool SoftDelete(int id)
|
||||
{
|
||||
return _db.Deleteable<T>().In(id).ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
public virtual bool Update(T model)
|
||||
{
|
||||
return _db.Updateable(model).ExecuteCommand() > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Service
|
||||
{
|
||||
public interface IBaseService<T> where T : class, new()
|
||||
{
|
||||
List<T> GetList();
|
||||
|
||||
DataTable GetDataTable();
|
||||
|
||||
bool Add(T model);
|
||||
bool Update(T model);
|
||||
bool SoftDelete(int id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using JinYuan.DAL.Models;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Service
|
||||
{
|
||||
public interface IMaterialFrameRuleService : IBaseService<MaterialFrameRule>
|
||||
{
|
||||
MaterialFrameRule GetRuleByCode(string code);
|
||||
}
|
||||
public class MaterialFrameRuleService : BaseService<MaterialFrameRule>, IMaterialFrameRuleService
|
||||
{
|
||||
public MaterialFrameRuleService(ISqlSugarClient db) : base(db)
|
||||
{ }
|
||||
|
||||
public override List<MaterialFrameRule> GetList()
|
||||
{
|
||||
return _db.Queryable<MaterialFrameRule>()
|
||||
.Where(x => !x.Is_Deleted)
|
||||
.OrderBy(x => x.Start_Code)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public override DataTable GetDataTable()
|
||||
{
|
||||
return _db.Queryable<MaterialFrameRule>()
|
||||
.Where(x => !x.Is_Deleted)
|
||||
.OrderBy(x => x.Start_Code)
|
||||
.ToDataTable();
|
||||
}
|
||||
|
||||
public override bool Add(MaterialFrameRule model)
|
||||
{
|
||||
// 车间 + 匹配编码 + isdelete = 0 的唯一性校验
|
||||
bool isExist = _db.Queryable<MaterialFrameRule>()
|
||||
.Where(x => x.Workshop_Code == model.Workshop_Code
|
||||
&& x.Start_Code == model.Start_Code
|
||||
&& !x.Is_Deleted)
|
||||
.Any();
|
||||
if (isExist)
|
||||
{
|
||||
throw new ArgumentException($"该车间{model.Workshop_Code}已存在该匹配编码{model.Start_Code}");
|
||||
}
|
||||
|
||||
return base.Add(model);
|
||||
}
|
||||
|
||||
public override bool Update(MaterialFrameRule model)
|
||||
{
|
||||
// 车间 + 匹配编码 + isdelete = 0 的唯一性校验
|
||||
bool isExist = _db.Queryable<MaterialFrameRule>()
|
||||
.Where(x => x.Workshop_Code == model.Workshop_Code
|
||||
&& x.Start_Code == model.Start_Code
|
||||
&& !x.Is_Deleted)
|
||||
.Any();
|
||||
if (isExist)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.Update(model);
|
||||
}
|
||||
|
||||
public MaterialFrameRule GetRuleByCode(string code)
|
||||
{
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string matchStr = code.Substring(3, 4);
|
||||
return _db.Queryable<MaterialFrameRule>()
|
||||
.Where(x => matchStr.StartsWith(x.Start_Code) && !x.Is_Deleted)
|
||||
.First();
|
||||
}
|
||||
|
||||
public override bool SoftDelete(int id)
|
||||
{
|
||||
return _db.Updateable<MaterialFrameRule>()
|
||||
.SetColumns(x => x.Is_Deleted == true)
|
||||
.SetColumns(x => x.Update_Time == DateTime.Now)
|
||||
.Where(x => x.Id == id)
|
||||
.ExecuteCommand() > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using JinYuan.DAL.Models;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Service
|
||||
{
|
||||
public interface IMesUrlService
|
||||
{
|
||||
string GetMesUrl(string trayCode, string interfaceKey);
|
||||
}
|
||||
|
||||
public class MesUrlService : IMesUrlService
|
||||
{
|
||||
protected readonly ISqlSugarClient _db;
|
||||
private MaterialFrameRuleService _ruleService;
|
||||
private WorkshopInterCfgService _cfgService;
|
||||
|
||||
public MesUrlService(ISqlSugarClient db)
|
||||
{
|
||||
_db = db;
|
||||
_ruleService = new MaterialFrameRuleService(_db);
|
||||
_cfgService = new WorkshopInterCfgService(_db);
|
||||
}
|
||||
|
||||
public string GetMesUrl(string trayCode, string interfaceKey)
|
||||
{
|
||||
if (string.IsNullOrEmpty(trayCode) || string.IsNullOrEmpty(interfaceKey))
|
||||
return string.Empty;
|
||||
|
||||
var rule = _ruleService.GetRuleByCode(trayCode);
|
||||
if (rule == null)
|
||||
return string.Empty;
|
||||
|
||||
var url = _cfgService.GetUrl(rule.Workshop_Code, interfaceKey);
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using JinYuan.DAL.Models;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Service
|
||||
{
|
||||
public interface IWorkshopInterCfgService : IBaseService<WorkshopInterfaceConfig>
|
||||
{
|
||||
string GetUrl(string workshopCode, string interfaceKey);
|
||||
}
|
||||
|
||||
public class WorkshopInterCfgService : BaseService<WorkshopInterfaceConfig>, IWorkshopInterCfgService
|
||||
{
|
||||
public WorkshopInterCfgService(ISqlSugarClient db) : base(db)
|
||||
{
|
||||
}
|
||||
|
||||
public override List<WorkshopInterfaceConfig> GetList()
|
||||
{
|
||||
return _db.Queryable<WorkshopInterfaceConfig>()
|
||||
.Where(x => !x.Is_Deleted)
|
||||
.OrderBy(x => x.Workshop_Code)
|
||||
.OrderBy(x => x.Interface_Flag)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public override DataTable GetDataTable()
|
||||
{
|
||||
return _db.Queryable<WorkshopInterfaceConfig>()
|
||||
.Where(x => !x.Is_Deleted)
|
||||
.OrderBy(x => x.Workshop_Code)
|
||||
.OrderBy(x => x.Interface_Flag)
|
||||
.ToDataTable();
|
||||
}
|
||||
|
||||
public override bool Add(WorkshopInterfaceConfig model)
|
||||
{
|
||||
// 车间 + 接口标识 + isDeleted = 0 的唯一性校验
|
||||
bool isExist = _db.Queryable<WorkshopInterfaceConfig>()
|
||||
.Where(x => x.Workshop_Code == model.Workshop_Code && x.Interface_Flag == model.Interface_Flag && !x.Is_Deleted)
|
||||
.Any();
|
||||
if (isExist)
|
||||
{
|
||||
throw new ArgumentException($"该车间{model.Workshop_Code}已存在该接口{model.Interface_Flag}");
|
||||
}
|
||||
|
||||
return base.Add(model);
|
||||
}
|
||||
|
||||
public override bool Update(WorkshopInterfaceConfig model)
|
||||
{
|
||||
// 车间 + 接口标识 + isDeleted = 0 的唯一性校验
|
||||
bool isExist = _db.Queryable<WorkshopInterfaceConfig>()
|
||||
.Where(x => x.Workshop_Code == model.Workshop_Code && x.Interface_Flag == model.Interface_Flag && !x.Is_Deleted)
|
||||
.Any();
|
||||
if (isExist)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.Update(model);
|
||||
}
|
||||
|
||||
public override bool SoftDelete(int id)
|
||||
{
|
||||
return _db.Updateable<WorkshopInterfaceConfig>()
|
||||
.SetColumns(x => x.Is_Deleted == true)
|
||||
.SetColumns(x => x.Update_Time == DateTime.Now)
|
||||
.Where(x => x.Id == id)
|
||||
.ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
|
||||
public string GetUrl(string workshopCode, string interfaceKey)
|
||||
{
|
||||
return _db.Queryable<WorkshopInterfaceConfig>()
|
||||
.Where(x => x.Workshop_Code == workshopCode && x.Interface_Flag == interfaceKey && !x.Is_Deleted)
|
||||
.Select(x => x.Interface_Url)
|
||||
.First();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user