diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs index b3443d4e..383c0651 100644 --- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs @@ -44,6 +44,24 @@ namespace ZR.Admin.WebApi.Controllers.MES.pro return ToResponse(new ApiResult(200, "success", data)); } + + /// + /// 甘特图 + /// + /// + /// + /// + /// + [HttpGet("GetGanttList")] + public IActionResult GetGanttList(int year = -1, int week = -1, int date = -1) + { + GanttTaskDTO data = proWorkorderService.GetGanttList(year, week, date); + + return ToResponse(new ApiResult(200, "success", data)); + } + + + /// /// 获取所有排产工单 /// diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/QcRoughController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/QcRoughController.cs index efc11583..6518383c 100644 --- a/ZR.Admin.WebApi/Controllers/mes/qc/QcRoughController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/qc/QcRoughController.cs @@ -7,13 +7,14 @@ using Newtonsoft.Json.Linq; using System.Text.Json; using ZR.Admin.WebApi.Extensions; using ZR.Model.mes.pro; +using ZR.Model.MES.qc.DTO; using ZR.Service.mes.pro; using ZR.Service.mes.pro.IService; using ZR.Service.mes.qu.IService; namespace ZR.Admin.WebApi.Controllers.mes.qu { - [Route("mes/qu/rough")] + [Route("mes/qc/IQC")] public class QcRoughController : BaseController { private readonly IQcRoughService quRoughService; @@ -32,10 +33,10 @@ namespace ZR.Admin.WebApi.Controllers.mes.qu /// /// /// - [HttpGet("getworkorderList")] - public IActionResult GetWorkorderList(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1) + [HttpGet("getStatisticslist")] + public IActionResult GetStatisticslist(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1) { - (List, int) data = quRoughService.GetWorkorderList(pageNum, pageSize, year, week, date, 1); + (List, int) data = quRoughService.GetStatisticslist(pageNum, pageSize, year, week, date, 1); return ToResponse(new ApiResult(200, "success", data)); } diff --git a/ZR.Model/MES/pro/DTO/GanttTaskDTO.cs b/ZR.Model/MES/pro/DTO/GanttTaskDTO.cs new file mode 100644 index 00000000..d51762be --- /dev/null +++ b/ZR.Model/MES/pro/DTO/GanttTaskDTO.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.pro.DTO +{ + public class GanttTaskDTO + { + public List Data { get; set; } + public List Links { get; set; } + + } + + public class GanttTask_data + { + // id + public string id { set; get; } + /// + /// 文字 + /// + public string text { set; get; } + /// + /// 开始时间 + /// + public string start_date { set; get; } + /// + /// 任务时长 + /// + public decimal? duration { set; get; } + /// + /// 完成进度 + /// + public decimal? progress { set; get; } + /// + /// 父任务id + /// + public int? parent { set; get; } + /// + /// 使用者 + /// + public string user { set; get; } + /// + /// 计划结束时间 + /// + public string planned_end { set; get; } + + /// + /// 计划开始时间 + /// + public string planned_start { set; get; } + + + + + + + public bool? show { set; get; } + + public bool? open { set; get; } + + public string type { set; get; } + + } + public class GanttTask_link + { + public int? id { set; get; } + public int? source { set; get; } + public int? target { set; get; } + public int? type { set; get; } + } + +} diff --git a/ZR.Model/MES/qc/DTO/Mr_QuRoughDTO.cs b/ZR.Model/MES/qc/DTO/Mr_QuRoughDTO.cs new file mode 100644 index 00000000..ceb0edc6 --- /dev/null +++ b/ZR.Model/MES/qc/DTO/Mr_QuRoughDTO.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.qc.DTO +{ + public class Mr_QuRoughDTO + { + + /// + /// 流水号 + /// + public string Id { get; set; } + + /// + /// 领料单id + /// + public string FkMaterialrequisitionId { get; set; } + + + /// + /// 毛坯零件号 + /// + + public string Workblankpartnumber { get; set; } + + + /// + /// 需要数量 + /// + + public int? Requirenum { get; set; } + + + /// + /// 状态 (0:未领料 1已经领料) + /// + + public string Status { get; set; } + + /// + /// 年 + /// + + public int? Year { get; set; } + /// + /// 周 + /// + + public int? Week { get; set; } + /// + /// 日 + /// + + public int? Date { get; set; } + + + + + /// + /// 应到数量 + /// + public int? RequireNum { get; set; } + /// + /// 实际到达数量 + /// + public int? ActualNumber { get; set; } + /// + /// 抽检比例% + /// + public int? RandomRate { get; set; } + /// + /// 合格数 + /// + public int? Oks { get; set; } + /// + /// 不合格数 + /// + public int? Ngs { get; set; } + /// + /// 合格率 + /// + public decimal? OksRatio { get; set; } + /// + /// 是否可以上料 + /// + public string IsFeeding { get; set; } + + + } +} diff --git a/ZR.Model/MES/qc/QuRough.cs b/ZR.Model/MES/qc/QuRough.cs index e52c910d..c87cbcff 100644 --- a/ZR.Model/MES/qc/QuRough.cs +++ b/ZR.Model/MES/qc/QuRough.cs @@ -23,6 +23,8 @@ namespace ZR.Model.MES.qu /// [SugarColumn(ColumnName = "fk_materialRequisition_id")] public string FkMaterialrequisitionId { get; set; } + + /// /// 应到数量 /// diff --git a/ZR.Model/ZR.Model.csproj b/ZR.Model/ZR.Model.csproj index d1315fb2..d8ec2149 100644 --- a/ZR.Model/ZR.Model.csproj +++ b/ZR.Model/ZR.Model.csproj @@ -24,8 +24,4 @@ - - - - diff --git a/ZR.Service/mes/pro/IService/IProWorkorderService.cs b/ZR.Service/mes/pro/IService/IProWorkorderService.cs index f5b1b8e4..86702bca 100644 --- a/ZR.Service/mes/pro/IService/IProWorkorderService.cs +++ b/ZR.Service/mes/pro/IService/IProWorkorderService.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Http; +using Microsoft.VisualBasic; using System; using System.Collections.Generic; using System.Drawing; @@ -7,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using ZR.Model.mes.pro; using ZR.Model.MES.op.DTO; +using ZR.Model.MES.pro.DTO; namespace ZR.Service.mes.pro.IService { @@ -21,6 +23,9 @@ namespace ZR.Service.mes.pro.IService public int SortWorkorderSchedule(string id, int sort); public int ReleaseProduction(string id, HttpContext httpContext); - + + + public GanttTaskDTO GetGanttList(int year,int week,int date); + } } diff --git a/ZR.Service/mes/pro/ProWorkorderService.cs b/ZR.Service/mes/pro/ProWorkorderService.cs index f40736c0..08284b8b 100644 --- a/ZR.Service/mes/pro/ProWorkorderService.cs +++ b/ZR.Service/mes/pro/ProWorkorderService.cs @@ -19,6 +19,7 @@ using static System.Net.WebRequestMethods; using JinianNet.JNTemplate; using static Aliyun.OSS.Model.LiveChannelStat; +using ZR.Model.MES.pro.DTO; namespace ZR.Service.mes.pro { @@ -150,5 +151,64 @@ namespace ZR.Service.mes.pro return result; } + /// + /// 获取甘特图 + /// + /// + /// + /// + /// + public GanttTaskDTO GetGanttList(int year, int week, int date) + { + + + var predicate = Expressionable.Create() + .AndIF(year > 0, it => it.Year == year) + .AndIF(week > 0, it => it.Week == week) + .AndIF(date > 0, it => it.Date == date) + .And(it=>it.Wrokerorder_status==1) + .ToExpression(); + + + List proWorkorderList = Context.Queryable().Where(predicate).ToList(); + + + GanttTaskDTO ganttTask = new GanttTaskDTO(); + + List ganttTask_data = new List(); + List ganttTask_Links = new List(); + + foreach (var item in proWorkorderList) + { + GanttTask_data data = new GanttTask_data(); + data.id = item.Id; + data.text = item.ProductionName; + data.start_date = ((DateTime)item.ArrangeStarttime).ToString("yyyy-MM-dd"); + data.duration = item.ProductionTime; + data.planned_start = ((DateTime)item.ArrangeStarttime).ToString("yyyy-MM-dd"); + data.planned_end = ((DateTime)item.ArrangeEndtime).ToString("yyyy-MM-dd"); + data.progress = 1; + data.show = false; + data.open = true; + data.type = "project"; + + + GanttTask_link link = new GanttTask_link(); + link.id = item.Order; + link.source = item.Order; + int index = proWorkorderList.IndexOf(item); + if (index < proWorkorderList.Count-1) + link.target = (int)proWorkorderList[index + 1]?.Order; + link.type = 0; + + ganttTask_data.Add(data); + ganttTask_Links.Add(link); + + + } + ganttTask.Data = ganttTask_data; + ganttTask.Links = ganttTask_Links; + return ganttTask; + } } } diff --git a/ZR.Service/mes/qc/IService/IQcRoughService.cs b/ZR.Service/mes/qc/IService/IQcRoughService.cs index 2a2f11a4..016ce262 100644 --- a/ZR.Service/mes/qc/IService/IQcRoughService.cs +++ b/ZR.Service/mes/qc/IService/IQcRoughService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using ZR.Model.mes.pro; +using ZR.Model.MES.qc.DTO; using ZR.Model.MES.qu; @@ -11,6 +12,6 @@ namespace ZR.Service.mes.qu.IService { public interface IQcRoughService { - public (List, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule); + public (List, int) GetStatisticslist(int pageNum, int pageSize, int year, int week, int date, int isSchedule); } } diff --git a/ZR.Service/mes/qc/QcRoughService.cs b/ZR.Service/mes/qc/QcRoughService.cs index fc6f9297..b38eb0c2 100644 --- a/ZR.Service/mes/qc/QcRoughService.cs +++ b/ZR.Service/mes/qc/QcRoughService.cs @@ -1,4 +1,5 @@ using Infrastructure.Attribute; +using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.Extensions.DependencyInjection; using SqlSugar; using System; @@ -8,9 +9,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using ZR.Model.mes.pro; +using ZR.Model.MES.qc.DTO; using ZR.Model.MES.qu; +using ZR.Model.MES.wm; using ZR.Service.mes.pro.IService; using ZR.Service.mes.qu.IService; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace ZR.Service.mes.qu { @@ -18,19 +22,40 @@ namespace ZR.Service.mes.qu public class QcRoughService : BaseService, IQcRoughService { - public (List, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule) + public (List, int) GetStatisticslist(int pageNum, int pageSize, int year, int week, int date, int isSchedule) { - var predicate = Expressionable.Create() - .AndIF(year > 0, it => it.Year == year) - .AndIF(week > 0, it => it.Week == week) - .AndIF(date > 0, it => it.Date == date) - .AndIF(date > 0, it => it.Wrokerorder_status==isSchedule) + var predicate = Expressionable.Create() + .AndIF(year > 0, wm => wm.Year == year) + .AndIF(week > 0, wm => wm.Week == week) + .AndIF(date > 0, wm => wm.Date == date) .ToExpression(); int totalCount = 0; - List proWorkorderList = Context.Queryable().Where(predicate).ToPageList(pageNum, pageSize, ref totalCount); - return (proWorkorderList, totalCount); + //联表查询 + List mr_QusList = Context.Queryable() + .LeftJoin((wm, qc) =>wm.Id==qc.FkMaterialrequisitionId) + .Where(predicate) + .Select((wm,qc) => new Mr_QuRoughDTO { + Id = qc.Id, + FkMaterialrequisitionId=qc.FkMaterialrequisitionId, + Workblankpartnumber=wm.Workblankpartnumber, + Requirenum=wm.Requirenum, + Status = wm.Status, + Year = wm.Year, + Week = wm.Week, + Date = wm.Date, + RequireNum= qc.RequireNum, + ActualNumber=qc.ActualNumber, + RandomRate = qc.RandomRate, + Oks = qc.Oks, + Ngs = qc.Ngs, + OksRatio = qc.OksRatio, + IsFeeding = qc.IsFeeding + }) + .ToPageList(pageNum, pageSize, ref totalCount); + + return (mr_QusList, totalCount); } } }