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