55 lines
2.3 KiB
C#
55 lines
2.3 KiB
C#
using Infrastructure.Attribute;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ZR.Model.MES.dev;
|
|
using ZR.Model.MES.dev.Dto;
|
|
using ZR.Service.MES.dev.IService;
|
|
|
|
namespace ZR.Service.MES.dev
|
|
{
|
|
/// <summary>
|
|
/// 设备数据分析
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IDeviceDataAnalysisServcie), ServiceLifetime = LifeTime.Transient)]
|
|
public class DeviceDataAnalysisService : BaseService<DeviceAccount>, IDeviceDataAnalysisServcie
|
|
{
|
|
/// <summary>
|
|
/// 故障类型 pie
|
|
/// </summary>
|
|
/// <param name="devicedefault"></param>
|
|
/// <returns></returns>
|
|
public List<DeviceStatusAnalysisResultDto> DefaultTypePie(DeviceDefaultDto devicedefault)
|
|
{
|
|
List<DeviceStatusAnalysisResultDto> resultList = new List<DeviceStatusAnalysisResultDto>();
|
|
var predicate = Expressionable.Create<DeviceRepair, DeviceAccount>()
|
|
.AndIF(devicedefault.DevicetTypeId > 0, (r, a) => a.FkDeviceType == devicedefault.DevicetTypeId)
|
|
.AndIF(!string.IsNullOrEmpty(devicedefault.DeviceName), (r, a) => a.DeviceName.Contains(devicedefault.DeviceName))
|
|
.AndIF(!string.IsNullOrEmpty(devicedefault.DeviceCode), (r, a) => a.DeviceCode.Contains(devicedefault.DeviceCode))
|
|
.AndIF(devicedefault.searchTime[0] > new DateTime(1991, 0, 0, 0, 0, 0, 0), (r, a) => a.CreatedTime >= devicedefault.searchTime[0])
|
|
.AndIF(devicedefault.searchTime[1] > new DateTime(1991, 0, 0, 0, 0, 0, 0), (r, a) => a.CreatedTime <= devicedefault.searchTime[1]);
|
|
|
|
List<DeviceRepair> deviceRepair_list= Context.Queryable<DeviceRepair>()
|
|
.LeftJoin<DeviceAccount>((r, a) => r.FkDeviceId == a.Id)
|
|
.Where(predicate.ToExpression())
|
|
.Select((r,a)=>r).ToList();
|
|
|
|
|
|
var TypeGroups= deviceRepair_list.GroupBy(it => it.Type);
|
|
|
|
foreach(var group in TypeGroups)
|
|
{
|
|
DeviceStatusAnalysisResultDto result=new DeviceStatusAnalysisResultDto();
|
|
result.name = group.Key;
|
|
result.value = group.Count();
|
|
resultList.Add(result);
|
|
}
|
|
|
|
|
|
return resultList;
|
|
}
|
|
}
|
|
}
|