20260831功能同步:
1. 不同车间区分料框查询、料框解绑接口 2. 注释电池型号逻辑 3. 打开电池状况界面
This commit is contained in:
@@ -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