成品检验
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.MES.quality.FQC;
|
||||
using DOAN.Model.MES.quality.IQC;
|
||||
using DOAN.Model.MES.quality.IQC.Dto;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.MES.quality.FQC.IService;
|
||||
using Infrastructure.Attribute;
|
||||
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
|
||||
|
||||
namespace DOAN.Service.MES.quality.FQC
|
||||
{
|
||||
/// <summary>
|
||||
/// 成品缺陷收集 Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IQcFinishedproductDefectService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class QcFinishedproductDefectService : BaseService<QcFinishedproductDefectCollection>, IQcFinishedproductDefectService
|
||||
{
|
||||
public bool AddDefectNum(string WorkOrder, string DefectCode)
|
||||
{
|
||||
int flag = 0;
|
||||
|
||||
// 检查 Workorder 是否存在
|
||||
var existingRecord = Context.Queryable<QcFinishedproductDefectCollection>()
|
||||
.Where(it => it.Workorder == WorkOrder)
|
||||
.Where(it => it.DefectCode == DefectCode)
|
||||
.First();
|
||||
|
||||
if (existingRecord != null)
|
||||
{
|
||||
// 更新 Number 字段
|
||||
flag = Context.Updateable<QcFinishedproductDefectCollection>()
|
||||
.SetColumns(it => new QcFinishedproductDefectCollection
|
||||
{
|
||||
Number = it.Number + 1,
|
||||
UpdatedTime = DateTime.Now
|
||||
})
|
||||
.Where(it => it.Workorder == WorkOrder)
|
||||
.Where(it => it.DefectCode == DefectCode)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 插入新记录
|
||||
QcFinishedproductDefectCollection qcFinishedproductDefect = new QcFinishedproductDefectCollection();
|
||||
qcFinishedproductDefect.Id = XueHua;
|
||||
qcFinishedproductDefect.Workorder = WorkOrder;
|
||||
qcFinishedproductDefect.DefectCode = DefectCode;
|
||||
qcFinishedproductDefect.CreatedTime = DateTime.Now;
|
||||
qcFinishedproductDefect.UpdatedTime = DateTime.Now;
|
||||
qcFinishedproductDefect.Number = 1;
|
||||
flag = Context.Insertable(qcFinishedproductDefect).ExecuteCommand();
|
||||
}
|
||||
|
||||
return flag > 0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
public bool UpdateDefectNum(string WorkOrder, string DefectCode, int num)
|
||||
{
|
||||
int flag = 0;
|
||||
|
||||
flag = Context.Updateable<QcFinishedproductDefectCollection>()
|
||||
.SetColumns(it => new QcFinishedproductDefectCollection
|
||||
{
|
||||
Number = num,
|
||||
UpdatedTime = DateTime.Now
|
||||
})
|
||||
.Where(it => it.Workorder == WorkOrder)
|
||||
.Where(it => it.DefectCode == DefectCode)
|
||||
.ExecuteCommand();
|
||||
return flag > 0 ? true : false;
|
||||
}
|
||||
|
||||
public List<QcFinishedproductDefectCollection> SearchDefectList(string WorkOrder)
|
||||
{
|
||||
return Context.Queryable<QcFinishedproductDefectCollection>().Where(it => it.Workorder == WorkOrder).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user