获取任务,增加百分比
This commit is contained in:
parent
edee48cd1c
commit
d82dfbdc4e
@ -67,4 +67,15 @@ namespace DOAN.Model.MES.mm.Dto
|
||||
public List<MmTaskMaterialInfoDto> mmTaskMaterialInfoDtos { get; set; } = new List<MmTaskMaterialInfoDto>();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 带任务配料数量占工单数量的百分比
|
||||
/// </summary>
|
||||
public class MmPreparationTaskDto3:MmPreparationTaskDto
|
||||
{
|
||||
//任务配料数量占工单数量的百分比
|
||||
public float Percentage { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,7 +17,7 @@ namespace DOAN.Service.MES.mm.IService
|
||||
|
||||
List<ProWorkorder> GetWorkOrder(DateTime searchDate, string route_code);
|
||||
|
||||
List<MmPreparationTaskDto> GetTaskList(string workorder);
|
||||
List<MmPreparationTaskDto3> GetTaskList(string workorder);
|
||||
|
||||
|
||||
List<MmTaskMaterialInfoDto> GetTaskMaterialInfo(string task_code);
|
||||
|
||||
@ -8,6 +8,7 @@ using DOAN.Service.MES.mm.IService;
|
||||
using Infrastructure.Attribute;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@ -39,9 +40,38 @@ namespace DOAN.Service.MES.mm
|
||||
/// </summary>
|
||||
/// <param name="workorder"></param>
|
||||
/// <returns></returns>
|
||||
public List<MmPreparationTaskDto> GetTaskList(string workorder)
|
||||
public List<MmPreparationTaskDto3> GetTaskList(string workorder)
|
||||
{
|
||||
return Context.Queryable<MmPreparationTask>().Where(it => it.FkWorkorder == workorder).ToList().Adapt<List<MmPreparationTaskDto>>();
|
||||
List<MmPreparationTaskDto3> MmPreparationTaskList = Context.Queryable<MmPreparationTask>().Where(it => it.FkWorkorder == workorder).ToList().Adapt<List<MmPreparationTaskDto3>>();
|
||||
if (MmPreparationTaskList != null && MmPreparationTaskList.Count() > 0)
|
||||
{
|
||||
// 算工单 子物料需求总数
|
||||
ProWorkorder workorder1 = Context.Queryable<ProWorkorder>().Where(it => it.Workorder == workorder).First();
|
||||
List<BaseMaterialBom> subMaterialReq = Context.Queryable<BaseMaterialBom>()
|
||||
.Where(it => it.InvCode == workorder1.ProductionCode).ToList();
|
||||
|
||||
float MaterialRequire_totals = workorder1.DeliveryNum.Value*subMaterialReq.Sum(it => float.Parse(it.Iusequantity));
|
||||
|
||||
foreach (var item in MmPreparationTaskList)
|
||||
{
|
||||
//计算每个任务 配料数量总数
|
||||
decimal task_Quantity = Context.Queryable<MmTaskMaterialInfo>().Where(it => it.FkTaskCode == item.TaskCode).Sum(it => it.Quantity);
|
||||
// 计算百分比
|
||||
float percentage = ((float)task_Quantity / MaterialRequire_totals) * 100;
|
||||
|
||||
// 保留两位小数
|
||||
float roundedPercentage = (float)Math.Round(percentage, 1);
|
||||
|
||||
item.Percentage = roundedPercentage;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return MmPreparationTaskList;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -65,13 +95,13 @@ namespace DOAN.Service.MES.mm
|
||||
|
||||
|
||||
var query2 = Context.Queryable<BaseMaterialBom>().Where(it => it.InvCode == proworkorder.ProductionCode);
|
||||
TotalMaterialRequirements= Context.Queryable(query2).LeftJoin<BaseMaterialList>((bom, list) => bom.SubInvCode == list.Code)
|
||||
TotalMaterialRequirements = Context.Queryable(query2).LeftJoin<BaseMaterialList>((bom, list) => bom.SubInvCode == list.Code)
|
||||
.Select((bom, list) => new BaseMaterialBomDto2()
|
||||
{
|
||||
Specification=list.Specification,
|
||||
Unit=list.Unit,
|
||||
Specification = list.Specification,
|
||||
Unit = list.Unit,
|
||||
|
||||
},true).ToList();
|
||||
}, true).ToList();
|
||||
|
||||
if (TotalMaterialRequirements != null && TotalMaterialRequirements
|
||||
.Count() > 0)
|
||||
@ -108,7 +138,7 @@ namespace DOAN.Service.MES.mm
|
||||
{
|
||||
MaterialCode = i.MaterialCode,
|
||||
configured_all_Quantity = SqlFunc.AggregateSum(i.Quantity),
|
||||
|
||||
|
||||
}).ToList();
|
||||
// 其中本次任务满足的物料需求
|
||||
var configuredList2 = Context.Queryable<MmPreparationTask>()
|
||||
@ -129,7 +159,7 @@ namespace DOAN.Service.MES.mm
|
||||
if (item.MaterialCode == configured.MaterialCode)
|
||||
{
|
||||
item.configured_all_Quantity = configured.configured_all_Quantity;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
foreach (var configured in configuredList2)
|
||||
@ -191,12 +221,12 @@ namespace DOAN.Service.MES.mm
|
||||
int result = 0;
|
||||
UseTran2(() =>
|
||||
{
|
||||
result+= Context.Deleteable<MmTaskMaterialInfo>().Where(it => it.FkTaskCode == task_code).ExecuteCommand();
|
||||
result+= Context.Deleteable<MmPreparationTask>().Where(it => it.TaskCode == task_code).ExecuteCommand();
|
||||
result += Context.Deleteable<MmTaskMaterialInfo>().Where(it => it.FkTaskCode == task_code).ExecuteCommand();
|
||||
result += Context.Deleteable<MmPreparationTask>().Where(it => it.TaskCode == task_code).ExecuteCommand();
|
||||
});
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -228,7 +258,7 @@ namespace DOAN.Service.MES.mm
|
||||
|
||||
|
||||
result += x.AsInsertable.ExecuteCommand();
|
||||
result += x.AsUpdateable.IgnoreColumns(z => new {z.Id, z.CreatedBy, z.CreatedTime, z.MaterialName, z.Specification, z.Unit }).ExecuteCommand();
|
||||
result += x.AsUpdateable.IgnoreColumns(z => new { z.Id, z.CreatedBy, z.CreatedTime, z.MaterialName, z.Specification, z.Unit }).ExecuteCommand();
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user