generate_defectCollection
This commit is contained in:
parent
b2950823bf
commit
967dc811ce
@ -4,6 +4,8 @@ using DOAN.Model.MES.quality;
|
||||
using DOAN.Model.MES.quality.Dto;
|
||||
using DOAN.Service.MES.quality;
|
||||
using DOAN.Admin.WebApi.Filters;
|
||||
using DOAN.Infrastructure;
|
||||
using Aliyun.OSS;
|
||||
|
||||
//创建时间:2024-09-30
|
||||
namespace DOAN.Admin.WebApi.Controllers
|
||||
@ -25,6 +27,20 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
_QcDefectCollectionService = QcDefectCollectionService;
|
||||
}
|
||||
|
||||
//TODO 生成指定产线和日期的 缺陷收集计划
|
||||
[HttpGet("generate_defectCollection")]
|
||||
public IActionResult GenerateDefectConllectionPlan(string line_code,DateTime dateTime)
|
||||
{
|
||||
dateTime= ConvertDateTime.ConvertLocalDate(dateTime);
|
||||
if(string.IsNullOrEmpty(line_code)||dateTime== DateTime.MinValue)
|
||||
{
|
||||
throw new CustomException("请求数据为空");
|
||||
}
|
||||
|
||||
var response = _QcDefectCollectionService.GenerateDefectConllectionPlan( line_code, dateTime,HttpContext.GetName());
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询缺陷收集列表
|
||||
/// </summary>
|
||||
@ -108,7 +124,7 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
{
|
||||
var response = _QcDefectCollectionService.GetAllLines();
|
||||
|
||||
return ToResponse(response);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ namespace DOAN.Model.MES.quality.Dto
|
||||
/// <summary>
|
||||
/// 缺陷收集查询对象
|
||||
/// </summary>
|
||||
public class QcDefectCollectionQueryDto : PagerInfo
|
||||
public class QcDefectCollectionQueryDto : PagerInfo
|
||||
{
|
||||
public string MaterialCode { get; set; }
|
||||
|
||||
@ -13,7 +13,7 @@ namespace DOAN.Model.MES.quality.Dto
|
||||
|
||||
public DateTime? DateTime { get; set; }
|
||||
|
||||
public string GroupCode { get; set; }
|
||||
|
||||
|
||||
public string LineCode { get; set; }
|
||||
|
||||
@ -25,9 +25,13 @@ namespace DOAN.Model.MES.quality.Dto
|
||||
/// </summary>
|
||||
public class QcDefectCollectionDto
|
||||
{
|
||||
|
||||
[Required(ErrorMessage = "id不能为空")]
|
||||
public string Id { get; set; }
|
||||
|
||||
public string LineCode { get; set; }
|
||||
|
||||
public DateTime? DateTime { get; set; }
|
||||
|
||||
public string MaterialCode { get; set; }
|
||||
|
||||
public string MaterialName { get; set; }
|
||||
@ -36,14 +40,12 @@ namespace DOAN.Model.MES.quality.Dto
|
||||
|
||||
public string Unit { get; set; }
|
||||
|
||||
public decimal PlanNum { get; set; }
|
||||
|
||||
public decimal ActualNum { get; set; }
|
||||
|
||||
public decimal Quantity { get; set; }
|
||||
|
||||
public DateTime? DateTime { get; set; }
|
||||
|
||||
public string GroupCode { get; set; }
|
||||
|
||||
public string LineCode { get; set; }
|
||||
|
||||
public string ProcessName { get; set; }
|
||||
|
||||
public string Superintendent { get; set; }
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
namespace DOAN.Model.MES.quality
|
||||
{
|
||||
/// <summary>
|
||||
@ -13,6 +12,18 @@ namespace DOAN.Model.MES.quality
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 线别
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "line_code")]
|
||||
public string LineCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "date_time")]
|
||||
public DateTime? DateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
@ -36,29 +47,26 @@ namespace DOAN.Model.MES.quality
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
|
||||
public string Specification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// 计划数量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "plan_num")]
|
||||
public decimal PlanNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际数量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "actual_num")]
|
||||
public decimal ActualNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 缺陷数量
|
||||
/// </summary>
|
||||
public decimal Quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "date_time")]
|
||||
public DateTime? DateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组别
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_code")]
|
||||
public string GroupCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 线别
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "line_code")]
|
||||
public string LineCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
|
||||
@ -14,6 +14,8 @@ namespace DOAN.Service.MES.quality
|
||||
/// </summary>
|
||||
public interface IQcDefectCollectionService : IBaseService<QcDefectCollection>
|
||||
{
|
||||
|
||||
bool GenerateDefectConllectionPlan(string line_code, DateTime dateTime, string CreatedBy);
|
||||
PagedInfo<QcDefectCollectionDto> GetList(QcDefectCollectionQueryDto parm);
|
||||
|
||||
QcDefectCollection GetInfo(string Id);
|
||||
@ -22,7 +24,7 @@ namespace DOAN.Service.MES.quality
|
||||
|
||||
int UpdateQcDefectCollection(QcDefectCollection parm);
|
||||
|
||||
List<BaseWorkRoute> GetAllLines();
|
||||
List<BaseWorkRoute> GetAllLines();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,10 @@ using System.Linq;
|
||||
using DOAN.Model.Mobile.Dto;
|
||||
using DOAN.Infrastructure;
|
||||
using DOAN.Model.MES.base_;
|
||||
using DOAN.Model.MES.mm;
|
||||
using NPOI.SS.UserModel;
|
||||
using MathNet.Numerics.Distributions;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
|
||||
namespace DOAN.Service.MES.quality
|
||||
{
|
||||
@ -21,6 +25,62 @@ namespace DOAN.Service.MES.quality
|
||||
[AppService(ServiceType = typeof(IQcDefectCollectionService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class QcDefectCollectionService : BaseService<QcDefectCollection>, IQcDefectCollectionService
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成指定产线和日期的 缺陷收集计划
|
||||
/// </summary>
|
||||
/// <param name="line_code"></param>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
public bool GenerateDefectConllectionPlan(string line_code, DateTime dateTime, string CreatedBy)
|
||||
{
|
||||
List<QcDefectCollection> qcDefectCollections = new List<QcDefectCollection>();
|
||||
//1 查询 产线物料需求计划
|
||||
List<MmRequirePlanByline> MmPreparationTaskLineList = Context.Queryable<MmRequirePlanByline>().Where(it => it.LineCode == line_code)
|
||||
.Where(it => it.RequireDate == dateTime).ToList();
|
||||
//2 算出每个物料实际派发数量
|
||||
var ActualDistributionQuantityOfMaterials = Context.Queryable<MmPreparationTaskLine>()
|
||||
.LeftJoin<MmTaskMaterialInfoByLine>((t, i) => t.TaskCode == i.FkTaskCode)
|
||||
.Where((t, i) => t.LineCode == line_code && t.TaskDate == dateTime)
|
||||
.GroupBy((t, i) => i.MaterialCode)
|
||||
.Select((t, i) => new
|
||||
{
|
||||
MaterialCode = i.MaterialCode,
|
||||
ActualNum = SqlFunc.AggregateSum(i.Quantity)
|
||||
}).ToList();
|
||||
|
||||
foreach (var item in MmPreparationTaskLineList)
|
||||
{
|
||||
QcDefectCollection qcDefect = new QcDefectCollection();
|
||||
qcDefect.Id = XueHua;
|
||||
qcDefect.LineCode = line_code;
|
||||
qcDefect.DateTime = dateTime;
|
||||
qcDefect.MaterialCode = item.MaterialCode;
|
||||
qcDefect.MaterialName = item.MaterialName;
|
||||
var itemm = ActualDistributionQuantityOfMaterials.Where(it => it.MaterialCode == item.MaterialCode).First();
|
||||
qcDefect.Specification = item.Specification;
|
||||
qcDefect.Unit = item.Unit;
|
||||
qcDefect.PlanNum = item.RequireNum;
|
||||
qcDefect.ActualNum = itemm.ActualNum;
|
||||
qcDefect.CreatedTime = item.CreatedTime;
|
||||
qcDefect.CreatedBy = CreatedBy;
|
||||
qcDefectCollections.Add(qcDefect);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int result = Context.Insertable(qcDefectCollections).ExecuteCommand();
|
||||
if (result > 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询缺陷收集列表
|
||||
/// </summary>
|
||||
@ -32,7 +92,6 @@ namespace DOAN.Service.MES.quality
|
||||
var predicate = Expressionable.Create<QcDefectCollection>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.MaterialCode), it => it.MaterialCode.Contains(parm.MaterialCode))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.MaterialName), it => it.MaterialName.Contains(parm.MaterialName))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.GroupCode), it => it.GroupCode.Contains(parm.GroupCode))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.LineCode), it => it.LineCode.Contains(parm.LineCode))
|
||||
.AndIF(parm.DateTime != null && parm.DateTime > DateTime.MinValue.AddYears(1), it => it.DateTime == parm.DateTime)
|
||||
.AndIF(parm.Tqm != null, it => it.Tqm == parm.Tqm)
|
||||
|
||||
@ -91,8 +91,6 @@ namespace Infrastructure.Extensions
|
||||
{
|
||||
var uid = context.User?.Identity?.Name;
|
||||
|
||||
|
||||
|
||||
return uid;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user