Compare commits
2 Commits
86754175f3
...
13ddaa3b30
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13ddaa3b30 | ||
|
|
6a3725f625 |
@ -59,7 +59,7 @@ namespace DOAN.WebApi.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产完成率
|
||||
/// 日生产完成率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("productionCompletionRate")]
|
||||
|
||||
@ -9,8 +9,7 @@
|
||||
"dbConfigs": [
|
||||
{
|
||||
// "Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=GXAssembly;Port=3308",
|
||||
//阿里云
|
||||
//"Conn": "Data Source=47.101.40.214;User ID=root;Password=Rizo123456@;Initial Catalog=gxassembly;Port=3306;AllowLoadLocalInfile=true",
|
||||
//"Conn": "Data Source=118.25.48.201;User ID=root;Password=123456;Initial Catalog=gxassembly;Port=3306;AllowLoadLocalInfile=true",
|
||||
"Conn": "Data Source=192.168.1.48;User ID=root;Password=123456;Initial Catalog=GXAssembly;Port=3306;AllowLoadLocalInfile=true",
|
||||
// "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=GXAssembly;Port=3306",
|
||||
//"Conn": "Data Source=192.168.50.163;User ID=root;Password=123456;Initial Catalog=GXAssembly;Port=3306",
|
||||
|
||||
@ -18,5 +18,7 @@ namespace DOAN.Service.MES.report.IService
|
||||
List<DeviceDowntimeRateModel> DeviceDowntimeRate(DateTime dateTime);
|
||||
|
||||
List<ProductionCompletionRate> ProductionCompletionRate(DateTime dateTime);
|
||||
|
||||
List<ProductionCompletionRate> MonthlyProductionCompletionRate(DateTime dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,35 +1,12 @@
|
||||
using AlibabaCloud.SDK.Dingtalkdoc_1_0.Models;
|
||||
using Aliyun.OSS;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.Dto;
|
||||
using DOAN.Model.MES;
|
||||
using Aliyun.OSS;
|
||||
using DOAN.Model.MES.andon;
|
||||
using DOAN.Model.MES.base_;
|
||||
using DOAN.Model.MES.group;
|
||||
using DOAN.Model.MES.product;
|
||||
using DOAN.Model.MES.product.Dto;
|
||||
using DOAN.Model.MES.report;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.MES.product.IService;
|
||||
using DOAN.Service.MES.report.IService;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using JinianNet.JNTemplate;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.Record;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace DOAN.Service.MES.report
|
||||
{
|
||||
@ -224,6 +201,75 @@ namespace DOAN.Service.MES.report
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ProductionCompletionRate> MonthlyProductionCompletionRate(DateTime dateTime)
|
||||
{
|
||||
(DateTime FirstDay, DateTime LastDay) Handlemonth = GetFirstAndLastDayOfMonth(dateTime);
|
||||
List<ProductionCompletionRate> list = new List<ProductionCompletionRate>();
|
||||
|
||||
var woList = Context.Queryable<ProWorkorder>()
|
||||
.LeftJoin<GroupSchedule>((a, b) => a.GroupCode == b.GroupCode)
|
||||
.LeftJoin<GroupShift>((a, b, c) => b.FkShift == c.Id)
|
||||
.LeftJoin<BaseGroup>((a, b, c, d) => a.GroupCode == d.GroupCode)
|
||||
.Where((a, b, c, d) => a.WorkorderDate.Value>= Handlemonth.FirstDay && a.WorkorderDate.Value<= Handlemonth.LastDay
|
||||
&& b.ScheduleDate.Value>= Handlemonth.FirstDay && b.ScheduleDate.Value<= Handlemonth.LastDay)
|
||||
.Select((a, b, c, d) =>
|
||||
new
|
||||
{
|
||||
a.Workorder,
|
||||
a.GroupCode,
|
||||
a.DeliveryNum,
|
||||
a.LineCode,
|
||||
a.Status,
|
||||
c.StartTime,
|
||||
c.EndTime,
|
||||
d.GroupName
|
||||
}).ToList();
|
||||
|
||||
string year = dateTime.Year.ToString("D4");
|
||||
string month = dateTime.Month.ToString("D2");
|
||||
string day = "01";
|
||||
|
||||
string sql = $@"SELECT FROM_UNIXTIME( FLOOR( UNIX_TIMESTAMP( d.created_time ) / 3600 ) * 3600 ) AS TimePeriod,
|
||||
r.workorder as WorkOrder, COUNT(*) AS Count
|
||||
FROM pro_workorder AS r
|
||||
RIGHT JOIN pro_reportwork_detail_{year}{month}{day} AS d ON r.workorder = d.workorder
|
||||
WHERE r.workorder_date >= @firstDay and r.workorder_date<=@lastDay
|
||||
GROUP BY FLOOR( UNIX_TIMESTAMP( d.created_time ) / 600 ),r.workorder
|
||||
ORDER BY TimePeriod";
|
||||
|
||||
var workDetailList = Context.Ado.SqlQuery<ProductionCompletionModel>(sql, new { firstDay = Handlemonth.FirstDay, lastDay= Handlemonth.LastDay });
|
||||
|
||||
list = woList.Select(t => new ProductionCompletionRate
|
||||
{
|
||||
WorkOrder = t.Workorder,
|
||||
GroupName = t.GroupName,
|
||||
WorkTimePeriod = $"{t.StartTime?.ToString("HH:mm")}-{t.EndTime?.ToString("HH:mm")}",
|
||||
DeliveryNum = t.DeliveryNum ?? 0,
|
||||
Status = GetStatusName(t.Status ?? 0),
|
||||
StartTime = t.StartTime,
|
||||
EndTime = t.EndTime
|
||||
}).ToList();
|
||||
|
||||
list.ForEach(t =>
|
||||
{
|
||||
var productionCompletionList = workDetailList.Where(wd => wd.WorkOrder == t.WorkOrder).ToList();
|
||||
var hours = (t.EndTime - t.StartTime).Value.TotalHours;
|
||||
for (int i = 0; i < hours; i++)
|
||||
{
|
||||
var productionCompletionModel = productionCompletionList.Where(t => t.TimePeriod.Hour == (8 + i)).FirstOrDefault();
|
||||
t.List.Add(new PlanModel
|
||||
{
|
||||
StartTime = $"{8 + i}:00",
|
||||
PlanNum = t.DeliveryNum / 8,
|
||||
CompletionNum = productionCompletionModel?.Count ?? 0,
|
||||
});
|
||||
}
|
||||
t.CompletionNum = productionCompletionList.Sum(t => t.Count);
|
||||
t.CompletionRate = Math.Round(t.CompletionNum * 100.0 / t.DeliveryNum, 2);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
private string GetStatusName(int status)
|
||||
{
|
||||
if (status == 1)
|
||||
@ -237,5 +283,15 @@ namespace DOAN.Service.MES.report
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
private (DateTime FirstDay, DateTime LastDay) GetFirstAndLastDayOfMonth(DateTime date)
|
||||
{
|
||||
DateTime firstDay = new DateTime(date.Year, date.Month, 1);
|
||||
int lastDay = DateTime.DaysInMonth(date.Year, date.Month);
|
||||
DateTime lastDayDate = new DateTime(date.Year, date.Month, lastDay);
|
||||
|
||||
return (firstDay, lastDayDate);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user