123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using ProductionLineMonitor.Application.Services.HomeService.Dtos;
- using ProductionLineMonitor.Application.Services.LineService.Dtos;
- using ProductionLineMonitor.Core.IRepositories;
- using ProductionLineMonitor.Web.Services;
- using ProductionLineMonitor.Web.Services.LineService;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace ProductionLineMonitor.Application.Services.LineService
- {
- public class LineService : ILineService
- {
- private readonly IUnitOfWork _unitOfWork;
- public LineService(IUnitOfWork unitOfWork)
- {
- _unitOfWork = unitOfWork;
- }
- public LineMonthData GetLineMonthData(string lineId, string date, string moduleType)
- {
- var line = _unitOfWork.ProductionLineRepository.FirstOrDefault(x => x.Id == lineId);
- return new LineMonthData(line, Convert.ToDateTime($"{date} 08:00:00"), 10, moduleType);
- }
- public IList<LineOverviewDto> GetLineOverview(string date)
- {
- IList<LineOverviewDto> lineOverviews = new List<LineOverviewDto>();
- var lines = _unitOfWork.ProductionLineRepository.GetList(
- x => x.FactoryNo == "03");
- foreach (var line in lines)
- {
- LineOverviewDto lineOverview = new LineOverviewDto
- {
- Id = line.Id,
- Floor = line.Floor,
- Line = line.Line,
- Name = line.Name,
- LineName = line.LineName
- };
- lineOverviews.Add(lineOverview);
- }
- List<Thread> threads = new List<Thread>();
- foreach (var lineOverview in lineOverviews)
- {
- Thread thread = new Thread(() =>
- {
- ProductionLineViewModel viewModel = new ProductionLineViewModel(
- lineOverview.Floor, lineOverview.Line, date, "FOG", lineOverview.LineName);
- foreach (var productionPlan in viewModel.ProductionPlans)
- {
- OverviewProductionPlanDto plan = new OverviewProductionPlanDto
- {
- ModuleType = productionPlan.ModuleType,
- Capa = productionPlan.Capa,
- PlanCapacity = productionPlan.PlanCapacity
- };
- lineOverview.OverviewProductionPlans.Add(plan);
- }
- });
- thread.Start();
- threads.Add(thread);
- }
- foreach (var item in threads)
- {
- item.Join();
- }
- return lineOverviews;
- }
- public IList<OverProductionPlanDto> GetLineOverviewV1(string date)
- {
- IList<OverProductionPlanDto> lineOverviews = new List<OverProductionPlanDto>();
- var lines = _unitOfWork.ProductionLineRepository.GetList(
- x => x.FactoryNo == "03").OrderBy(o => o.Order);
- foreach (var line in lines)
- {
- var lst = MesApiService.GetProductionPlansV1(line.Floor, line.Line, date);
- OverProductionPlanDto lineOverview = new OverProductionPlanDto(
- line.Floor, line.Line, lst, line.Id, line.HourDataTopic, line.LineName);
- lineOverviews.Add(lineOverview);
- }
- var rs = _unitOfWork.RecipeRepository.GetList().ToList();
- List<Thread> threads = new List<Thread>();
- foreach (var lineOverview in lineOverviews)
- {
- Thread thread = new Thread(() =>
- {
- ProductionLineViewModel viewModel = new ProductionLineViewModel(lineOverview.Floor,
- lineOverview.Line, date, lineOverview.HourDataTopic, lineOverview.LineName);
- int c = 0;
- if (viewModel.LoadOutPutPerHours.Count() > 0)
- {
- c = viewModel.LoadOutPutPerHours.Select(x => x.OutPut).Sum();
- }
- #region 临时处理机种获取不到问题
- if (lineOverview.ModuleType == null || lineOverview.ModuleType == "")
- {
- if (viewModel.LoadOutPutPerHours.Count() > 0)
- {
- string m = viewModel.LoadOutPutPerHours[0].ModuleType;
- lineOverview.SetModuleType(m);
- lineOverview.Capa = MesApiService.GetCapaTT(viewModel.Floor, viewModel.Line, m).Capa.ToString();
- }
- }
- #endregion
- lineOverview.SetCapacity(c);
- });
- thread.Start();
- threads.Add(thread);
- }
- foreach (var item in threads)
- {
- item.Join();
- }
- return lineOverviews;
- }
- }
- }
|