成品检验 缺陷收集
This commit is contained in:
parent
6de82f52c3
commit
6097d50da1
@ -0,0 +1,55 @@
|
||||
using DOAN.Admin.WebApi.Filters;
|
||||
using DOAN.Model.MES.quality.IQC;
|
||||
using DOAN.Model.MES.quality.IQC.Dto;
|
||||
using DOAN.Service.MES.quality.FQC.IService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
//创建时间:2024-10-10
|
||||
namespace DOAN.WebApi.Controllers.MES.quality.FQC
|
||||
{
|
||||
/// <summary>
|
||||
/// 成品检验 缺陷收集
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[Route("mes/qualityManagement/FQC/QcFinishedproductDefect")]
|
||||
public class QcFinishedproductDefectController : BaseController
|
||||
{
|
||||
private readonly IQcFinishedproductDefectService qcFinishedproductDefectService;
|
||||
public QcFinishedproductDefectController(IQcFinishedproductDefectService qcFinishedproductDefectService)
|
||||
{
|
||||
this.qcFinishedproductDefectService = qcFinishedproductDefectService;
|
||||
}
|
||||
|
||||
|
||||
//TODO 增加 缺陷数
|
||||
[HttpGet("add_defect_num")]
|
||||
public IActionResult AddDefectNum(string WorkOrder, string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(WorkOrder) || string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new CustomException("WorkOrder为空||name为空");
|
||||
}
|
||||
var response = qcFinishedproductDefectService.AddDefectNum(WorkOrder, name);
|
||||
return SUCCESS(response);
|
||||
|
||||
}
|
||||
|
||||
//TODO 修改缺陷数
|
||||
[HttpGet("update_defect_num")]
|
||||
public IActionResult UpdateDefectNum(string WorkOrder, string name, int num)
|
||||
{
|
||||
if (string.IsNullOrEmpty(WorkOrder) || string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new CustomException("WorkOrder为空||name为空");
|
||||
}
|
||||
var response = qcFinishedproductDefectService.UpdateDefectNum(WorkOrder, name, num);
|
||||
return SUCCESS(response);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Service.MES.quality.FQC.IService
|
||||
{
|
||||
public interface IQcFinishedproductDefectService
|
||||
{
|
||||
bool AddDefectNum(string WorkOrder,string name);
|
||||
bool UpdateDefectNum(string WorkOrder,string name,int num);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
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 name)
|
||||
{
|
||||
int flag = 0;
|
||||
|
||||
// 检查 Workorder 是否存在
|
||||
var existingRecord = Context.Queryable<QcFinishedproductDefectCollection>()
|
||||
.Where(it => it.Workorder == WorkOrder)
|
||||
.Where(it => it.DefectDescribe == name)
|
||||
.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.DefectDescribe == name)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 插入新记录
|
||||
QcFinishedproductDefectCollection qcFinishedproductDefect = new QcFinishedproductDefectCollection();
|
||||
qcFinishedproductDefect.Id = XueHua;
|
||||
qcFinishedproductDefect.Workorder = WorkOrder;
|
||||
qcFinishedproductDefect.DefectDescribe = name;
|
||||
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 name, 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.DefectDescribe == name)
|
||||
.ExecuteCommand();
|
||||
return flag > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -76,28 +76,28 @@ namespace DOAN.ServiceCore.SqlSugar
|
||||
////SQL执行前
|
||||
db.GetConnectionScope(configId).Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
//if (showDbLog)
|
||||
//{
|
||||
// string log = $"【db{configId} SQL】{UtilMethods.GetSqlString(config.DbType, sql, pars)}\n";
|
||||
// if (sql.TrimStart().StartsWith("SELECT", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// logger.Info(log);
|
||||
// }
|
||||
// else if (sql.StartsWith("UPDATE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("INSERT", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// logger.Warn(log);
|
||||
// }
|
||||
// else if (sql.StartsWith("DELETE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("TRUNCATE", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// logger.Error(log);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// log = $"【db{configId} SQL语句】dbo.{sql} {string.Join(", ", pars.Select(x => x.ParameterName + " = " + GetParsValue(x)))};\n";
|
||||
// logger.Info(log);
|
||||
// }
|
||||
// // 计算所需时间
|
||||
//}
|
||||
if (showDbLog)
|
||||
{
|
||||
string log = $"【db{configId} SQL】{UtilMethods.GetSqlString(config.DbType, sql, pars)}\n";
|
||||
if (sql.TrimStart().StartsWith("SELECT", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
logger.Info(log);
|
||||
}
|
||||
else if (sql.StartsWith("UPDATE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("INSERT", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
logger.Warn(log);
|
||||
}
|
||||
else if (sql.StartsWith("DELETE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("TRUNCATE", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
logger.Error(log);
|
||||
}
|
||||
else
|
||||
{
|
||||
log = $"【db{configId} SQL语句】dbo.{sql} {string.Join(", ", pars.Select(x => x.ParameterName + " = " + GetParsValue(x)))};\n";
|
||||
logger.Info(log);
|
||||
}
|
||||
// 计算所需时间
|
||||
}
|
||||
};
|
||||
//SQL执行完
|
||||
db.GetConnectionScope(configId).Aop.OnLogExecuted = (sql, pars) =>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user