油漆
This commit is contained in:
21
server/ZR.Service/mes/op/IService/IOperationService.cs
Normal file
21
server/ZR.Service/mes/op/IService/IOperationService.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.MES.op.DTO;
|
||||
using ZR.Model.MES.op.ZR.Model.mes.md;
|
||||
using ZR.Model.MES.qc;
|
||||
|
||||
namespace ZR.Service.MES.op.IService
|
||||
{
|
||||
public interface IOperationService
|
||||
{
|
||||
|
||||
public List<OpStatisticsDTO> GetAllData(string workshopID);
|
||||
|
||||
public (List<QcFqcDTO>,int) GueryQualityStatistics(string workorderid, int pageNum, int pageSize, int year = -1, int week = -1, int date = -1);
|
||||
|
||||
public List<DetailsOfDetectionDTO> QueryDetailsOfDetection(string fkWorkorderId, int order);
|
||||
}
|
||||
}
|
||||
232
server/ZR.Service/mes/op/OperationService.cs
Normal file
232
server/ZR.Service/mes/op/OperationService.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.mes.md;
|
||||
using ZR.Model.MES.op.ZR.Model.mes.md;
|
||||
using ZR.Service.MES.md.IService;
|
||||
using ZR.Service;
|
||||
using ZR.Service.MES.op.IService;
|
||||
using ZR.Model.MES.op.DTO;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Org.BouncyCastle.Asn1.Esf;
|
||||
using ZR.Model.MES.qc;
|
||||
using SqlSugar;
|
||||
using ZR.Model.mes.pro;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
using ZR.Model.MES.qu;
|
||||
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
|
||||
using ZR.Model.MES.pro;
|
||||
|
||||
namespace ZR.Service.MES.op
|
||||
{
|
||||
[AppService(ServiceType = typeof(IOperationService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class OperationService : BaseService<OpStatistics>, IOperationService
|
||||
{
|
||||
public List<OpStatisticsDTO> GetAllData(string workshopID)
|
||||
{
|
||||
decimal myDecimal = 123.456789m;
|
||||
string formattedDecimal = myDecimal.ToString("0.00"); // 保留两位小数
|
||||
|
||||
List<OpStatisticsDTO> OpStatisticsDTOList= new List<OpStatisticsDTO>();
|
||||
List<OpStatistics> OpStatisticsList =Queryable().Where(it => it.WorkshopId == workshopID ).ToList();
|
||||
foreach (var OpStatistics in OpStatisticsList)
|
||||
{
|
||||
OpStatisticsDTO opStatisticsDTO=new OpStatisticsDTO();
|
||||
opStatisticsDTO.WorkshopId = OpStatistics.WorkshopId;
|
||||
opStatisticsDTO.WorkshopName = OpStatistics.WorkshopName;
|
||||
opStatisticsDTO.ProductDate = OpStatistics.ProductDate;
|
||||
opStatisticsDTO.PlanNum = OpStatistics.PlanNum;
|
||||
opStatisticsDTO.ProductedNum = OpStatistics.ProductedNum;
|
||||
decimal num1 = (decimal) OpStatistics.ProductedNum / (decimal)OpStatistics.PlanNum*100;
|
||||
opStatisticsDTO.ProductProgressRate = (int)num1 ;
|
||||
opStatisticsDTO.GoodproductsNum = OpStatistics.GoodproductsNum;
|
||||
opStatisticsDTO.DefectiveProductsNum = OpStatistics.DefectiveProductsNum;
|
||||
decimal num2 = (decimal)OpStatistics.DefectiveProductsNum / (decimal)(OpStatistics.GoodproductsNum + OpStatistics.DefectiveProductsNum);
|
||||
opStatisticsDTO.QualityRate = num2.ToString("f2");
|
||||
opStatisticsDTO.ProductStarttime = OpStatistics.ProductStarttime;
|
||||
opStatisticsDTO.ProductEndtime = OpStatistics.ProductEndtime;
|
||||
if(DateTime.Now> opStatisticsDTO.ProductStarttime&& DateTime.Now < opStatisticsDTO.ProductEndtime)
|
||||
{
|
||||
opStatisticsDTO.isProducting = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
opStatisticsDTO.isProducting = false;
|
||||
}
|
||||
|
||||
opStatisticsDTO.numSort = OpStatisticsList.IndexOf(OpStatistics);
|
||||
|
||||
opStatisticsDTO.LineId = OpStatistics.LineId;
|
||||
opStatisticsDTO.LineName = OpStatistics.LineName;
|
||||
opStatisticsDTO.ProductEndtime = OpStatistics.ProductEndtime;
|
||||
|
||||
OpStatisticsDTOList.Add(opStatisticsDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return OpStatisticsDTOList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 质量统计分析表和工单关联一下
|
||||
/// </summary>
|
||||
/// <param name="workorderid"></param>
|
||||
/// <param name="pageNum"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="week"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
public (List<QcFqcDTO>,int) GueryQualityStatistics(string workorderid ,int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||||
{
|
||||
var predicate = Expressionable.Create<QcFqcDTO>()
|
||||
.AndIF(year > 0, p => p.Year == year)
|
||||
.AndIF(week > 0, p => p.Week == week)
|
||||
.AndIF(date > 0, p => p.Date == date)
|
||||
.ToExpression();
|
||||
|
||||
|
||||
var predicate2 = Expressionable.Create<QcFqc>()
|
||||
.AndIF(!string.IsNullOrEmpty(workorderid),q=>q.FkWorkorderId== workorderid)
|
||||
.ToExpression();
|
||||
|
||||
int totalCount = 0;
|
||||
|
||||
var query5 = Context.Queryable<QcFqc>()
|
||||
.LeftJoin<ProWorkorder_v2>((q, p) => q.FkWorkorderId == p.Id)
|
||||
.Where(predicate2)
|
||||
.Select((q, p) => new QcFqcDTO {
|
||||
Year = p.Year,
|
||||
Week = p.Week,
|
||||
Date = p.Date,
|
||||
Id = q.Id,
|
||||
FkWorkorderId = q.FkWorkorderId,
|
||||
ProductName = q.ProductName,
|
||||
Color = q.Color,
|
||||
Require = q.Require,
|
||||
LeftRight = q.LeftRight,
|
||||
Team = q.Team,
|
||||
QualifiedNum01 = q.QualifiedNum01,
|
||||
DefectNum01 = q.DefectNum01,
|
||||
PolishNum01 = q.PolishNum01,
|
||||
ScrapNum01 = q.ScrapNum01,
|
||||
QualifiedNum02 = q.QualifiedNum02,
|
||||
PolishNum02 = q.PolishNum02,
|
||||
ScrapNum02 = q.ScrapNum02,
|
||||
QualifiedNum03 = q.QualifiedNum03,
|
||||
PolishNum03 = q.PolishNum03,
|
||||
ScrapNum03 = q.ScrapNum03,
|
||||
FirstgoodNum=q.FirstgoodNum,
|
||||
FirstgoodRate=q.FirstgoodRate,
|
||||
FinalgoodRate=q.FinalgoodRate,
|
||||
FinalgoodNum=q.FinalgoodNum,
|
||||
|
||||
}).MergeTable();
|
||||
|
||||
List<QcFqcDTO> QcFqcDTOList = query5.Where(predicate).ToPageList(pageNum, pageSize,ref totalCount);
|
||||
return (QcFqcDTOList, totalCount);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取工单 缺陷详细信息
|
||||
/// </summary>
|
||||
/// <param name="fkWorkorderId"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
public List<DetailsOfDetectionDTO> QueryDetailsOfDetection(string fkWorkorderId, int order)
|
||||
{
|
||||
List<DetailsOfDetectionDTO> detailsList = null;
|
||||
switch(order)
|
||||
{
|
||||
case 1:
|
||||
// 首检抛光数量
|
||||
detailsList = Context.Queryable<QcFirstinspectionRecord>().LeftJoin<QcInspectionitem>((f, i) => SqlFunc.ToInt32(f.FKInpectionId) == i.Id).Where(f => SqlFunc.Like(f.FKInpectionId, "_1_")).Where(f=>f.FKWorkorderId== fkWorkorderId)
|
||||
.Select((f, i) => new DetailsOfDetectionDTO
|
||||
{
|
||||
InspectionName = i.InspectionName,
|
||||
Counter = (int)f.Counter,
|
||||
|
||||
}).ToList(); break;
|
||||
case 2:
|
||||
// 首检打磨数量
|
||||
detailsList = Context.Queryable<QcFirstinspectionRecord>().LeftJoin<QcInspectionitem>((f, i) => SqlFunc.ToInt32(f.FKInpectionId) == i.Id).Where(f => SqlFunc.Like(f.FKInpectionId, "_2_"))
|
||||
.Select((f, i) => new DetailsOfDetectionDTO
|
||||
{
|
||||
InspectionName = i.InspectionName,
|
||||
Counter = (int)f.Counter,
|
||||
|
||||
}).ToList();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// 首检报废数量
|
||||
detailsList = Context.Queryable<QcFirstinspectionRecord>().LeftJoin<QcInspectionitem>((f, i) => SqlFunc.ToInt32(f.FKInpectionId) == i.Id).Where(f => SqlFunc.Like(f.FKInpectionId, "_3_"))
|
||||
|
||||
.Select((f, i) => new DetailsOfDetectionDTO
|
||||
{
|
||||
InspectionName = i.InspectionName,
|
||||
Counter = (int)f.Counter,
|
||||
|
||||
}).ToList();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// 二检打磨数量
|
||||
detailsList = Context.Queryable<QcAgaininspectionRecord>().LeftJoin<QcInspectionitem>((f, i) => SqlFunc.ToInt32(f.FkInpectionId) == i.Id).Where(f => SqlFunc.Like(f.FkInpectionId, "_2_"))
|
||||
.Select((f, i) => new DetailsOfDetectionDTO
|
||||
{
|
||||
InspectionName = i.InspectionName,
|
||||
Counter = (int)f.Counter,
|
||||
|
||||
}).ToList();
|
||||
break;
|
||||
case 5:
|
||||
// 二检报废数量
|
||||
detailsList = Context.Queryable<QcAgaininspectionRecord>().LeftJoin<QcInspectionitem>((f, i) => SqlFunc.ToInt32(f.FkInpectionId) == i.Id).Where(f => SqlFunc.Like(f.FkInpectionId, "_3_"))
|
||||
.Select((f, i) => new DetailsOfDetectionDTO
|
||||
{
|
||||
InspectionName = i.InspectionName,
|
||||
Counter = (int)f.Counter,
|
||||
|
||||
}).ToList();
|
||||
break;
|
||||
case 6:
|
||||
// 三检打磨数量
|
||||
detailsList = Context.Queryable<QcFinalinspectionRecord>().LeftJoin<QcInspectionitem>((f, i) => SqlFunc.ToInt32(f.FkInpectionId) == i.Id).Where(f => SqlFunc.Like(f.FkInpectionId, "_2_"))
|
||||
.Select((f, i) => new DetailsOfDetectionDTO
|
||||
{
|
||||
InspectionName = i.InspectionName,
|
||||
Counter = (int)f.Counter,
|
||||
|
||||
}).ToList();
|
||||
|
||||
break;
|
||||
case 7:
|
||||
// 三检报废数量
|
||||
detailsList = Context.Queryable<QcFinalinspectionRecord>().LeftJoin<QcInspectionitem>((f, i) => SqlFunc.ToInt32(f.FkInpectionId) == i.Id).Where(f => SqlFunc.Like(f.FkInpectionId, "_3_"))
|
||||
.Select((f, i) => new DetailsOfDetectionDTO
|
||||
{
|
||||
InspectionName = i.InspectionName,
|
||||
Counter = (int)f.Counter,
|
||||
|
||||
}).ToList();
|
||||
break;
|
||||
|
||||
default:break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return detailsList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user