生产计划甘特图第一版
This commit is contained in:
parent
8163e5532f
commit
3c0a16ce5c
@ -384,5 +384,31 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
//TODO 获取甘特图
|
||||
[HttpPost("getGanttChart")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult GetGanttChart([FromBody] GanttChartQueryDto query)
|
||||
{
|
||||
var response = _ProWorkorderService.GetGanttChart(query);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 班组列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GroupList")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult GetGroupList([FromBody] ProWorkorderQueryDto parm)
|
||||
{
|
||||
parm.WorkorderDate[0] = ConvertDateTime.ConvertLocalDate(parm.WorkorderDate[0]);
|
||||
parm.WorkorderDate[1] = ConvertDateTime.ConvertLocalDate(parm.WorkorderDate[1]);
|
||||
|
||||
var response = _ProWorkorderService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using static DOAN.Model.MES.product.Dto.GanttChartChildrenDto;
|
||||
|
||||
namespace DOAN.Model.MES.product.Dto
|
||||
{
|
||||
@ -368,6 +369,42 @@ namespace DOAN.Model.MES.product.Dto
|
||||
public int? ActualNum { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 甘特图接收参数DTO
|
||||
/// </summary>
|
||||
public class GanttChartQueryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 组别
|
||||
/// </summary>
|
||||
public List<string> GroupCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
public DateTime QueryDate { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工单甘特图
|
||||
/// </summary>
|
||||
public class GanttChartDto
|
||||
{
|
||||
public string GroupCode { get; set; }
|
||||
|
||||
public double AllWorkTime { get; set; }
|
||||
public List<GanttChartChildrenDto> Workorders { get; set; }
|
||||
}
|
||||
|
||||
// 工单详情DTO
|
||||
public class GanttChartChildrenDto
|
||||
{
|
||||
public string Workorder { get; set; }
|
||||
public string ProductionName { get; set; }
|
||||
public double DeliveryNum { get; set; }
|
||||
public double Beat { get; set; }
|
||||
public DateTime? StartTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
public double CalculatedValue { get; set; }
|
||||
}
|
||||
}
|
||||
@ -62,5 +62,7 @@ namespace DOAN.Service.MES.product.IService
|
||||
List<WorkOrderBom> SearchBOMNum(string workorder_num);
|
||||
|
||||
int WorkOrderLog(string workorder, string log, string Operator);
|
||||
|
||||
public List<GanttChartDto> GetGanttChart(GanttChartQueryDto query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +1,43 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Aliyun.OSS;
|
||||
using DOAN.Model;
|
||||
|
||||
using DOAN.Model.MES.base_;
|
||||
using DOAN.Model.MES.base_.Dto;
|
||||
using DOAN.Model.MES.BI.Dto;
|
||||
using DOAN.Model.MES.exception;
|
||||
using DOAN.Model.MES.group;
|
||||
using DOAN.Model.MES.product;
|
||||
using DOAN.Model.MES.product.Dto;
|
||||
|
||||
using DOAN.Model.System;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.MES.product.IService;
|
||||
|
||||
using System.Linq;
|
||||
using SqlSugar.Extensions;
|
||||
using MimeKit.Tnef;
|
||||
using DOAN.Model.MES.base_;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using DOAN.Model.System;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System.Data.Common;
|
||||
using NPOI.XWPF.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using NPOI.Util;
|
||||
using DOAN.Model.MES.base_.Dto;
|
||||
using Aliyun.OSS;
|
||||
using DOAN.Model.MES.group;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Converter;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using System.Reflection;
|
||||
using DOAN.Model.MES.exception;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Converter;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using MimeKit.Tnef;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.Util;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using NPOI.XWPF.UserModel;
|
||||
using Org.BouncyCastle.Asn1.Pkcs;
|
||||
using SqlSugar;
|
||||
using SqlSugar.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data.Common;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DOAN.Service.MES.product
|
||||
{
|
||||
@ -1272,9 +1273,74 @@ namespace DOAN.Service.MES.product
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 甘特图
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
public List<GanttChartDto> GetGanttChart(GanttChartQueryDto query)
|
||||
{
|
||||
List<string> groupCodes = new List<string>();
|
||||
|
||||
// 确定要查询的组别(全部或指定)
|
||||
if (query == null || query.GroupCode == null || !query.GroupCode.Any())
|
||||
{
|
||||
groupCodes = Context.Queryable<ProWorkorder>()
|
||||
.Where(p => !string.IsNullOrEmpty(p.GroupCode))
|
||||
.Select(p => p.GroupCode)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
groupCodes = query.GroupCode
|
||||
.Where(item => !string.IsNullOrEmpty(item))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var result = new List<GanttChartDto>();
|
||||
|
||||
// 遍历每个组别,获取该组的所有工单
|
||||
foreach (var groupCode in groupCodes)
|
||||
{
|
||||
var workorders = Context.Queryable<ProWorkorder>()
|
||||
.Where(p => p.GroupCode == groupCode)
|
||||
.WhereIF(query != null && query.QueryDate > DateTime.MinValue,
|
||||
p => p.WorkorderDate.Value == query.QueryDate)
|
||||
.Select(p => new GanttChartChildrenDto
|
||||
{
|
||||
Workorder = p.Workorder,
|
||||
ProductionName = p.ProductionName,
|
||||
DeliveryNum = (double)p.DeliveryNum,
|
||||
Beat = (double)p.Beat,
|
||||
StartTime = p.StartTime,
|
||||
EndTime = p.EndTime,
|
||||
CalculatedValue = (double)(p.DeliveryNum * p.Beat /3600)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// 重新计算每组内的工单时间(从0点开始顺序排列)
|
||||
var lastEndTime = new DateTime(query.QueryDate.Year, query.QueryDate.Month, query.QueryDate.Day, 8, 0, 0); // 当天0点
|
||||
foreach (var workorder in workorders)
|
||||
{
|
||||
workorder.StartTime = lastEndTime;
|
||||
workorder.EndTime = lastEndTime.AddHours(workorder.CalculatedValue);
|
||||
lastEndTime = (DateTime)workorder.EndTime;
|
||||
}
|
||||
|
||||
// 将当前组的数据添加到结果中
|
||||
result.Add(new GanttChartDto
|
||||
{
|
||||
GroupCode = groupCode,
|
||||
Workorders = workorders,
|
||||
AllWorkTime = Math.Round(workorders.Sum(w => w.CalculatedValue), 1)
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user