终极优化
This commit is contained in:
parent
d352c4ff02
commit
755beed64d
@ -454,7 +454,7 @@ namespace ZR.Service.MES.dev
|
||||
/// <returns></returns>
|
||||
public DeviceStatusAnalysisDto GetDeviceStatus(int devicetype_id)
|
||||
{
|
||||
|
||||
|
||||
DeviceStatusAnalysisDto analysis = new DeviceStatusAnalysisDto();
|
||||
|
||||
// 设备总数
|
||||
@ -484,13 +484,29 @@ namespace ZR.Service.MES.dev
|
||||
stopwatch.Stop();
|
||||
|
||||
// 输出执行时间
|
||||
Console.WriteLine("代码段执行时间: {0} 秒", stopwatch.ElapsedMilliseconds/1000);
|
||||
Console.WriteLine("代码段执行时间: {0} 秒", stopwatch.ElapsedMilliseconds / 1000);
|
||||
// 2 获取每个线下的所有设备
|
||||
if (All_device_type.Count > 0)
|
||||
{
|
||||
List<DeviceType> all_deviceTyepe_s= Context.Queryable<DeviceType>().ToList();
|
||||
List<DeviceAccount> all_account_s=Context.Queryable<DeviceAccount>().ToList();
|
||||
List<DeviceRepair> all_deviceRepair_s= Context.Queryable<DeviceRepair>().ToList();
|
||||
List<DeviceType> all_deviceTyepe_s = Context.Queryable<DeviceType>().ToList();
|
||||
List<DeviceAccount> all_account_s = Context.Queryable<DeviceAccount>().ToList();
|
||||
List<DeviceRepair> all_deviceRepair_s = Context.Queryable<DeviceRepair>().ToList();
|
||||
var query_point = Context.Queryable<DeviceTaskExecute>()
|
||||
.LeftJoin<DevicePointInspectionPlan>((e, p) => e.TaskId == p.Id)
|
||||
.LeftJoin<DeviceRelPpAt>((e, p, r) => p.Id == r.FkPointInspectionPlanId)
|
||||
.Select((e, p, r) => new
|
||||
{
|
||||
FkDeviceAccountId = r.FkDeviceAccountId,
|
||||
Status = e.Status
|
||||
}).ToList();
|
||||
var query_route = Context.Queryable<DeviceTaskExecute>()
|
||||
.LeftJoin<DeviceRouteInspectionPlan>((e, p) => e.TaskId == p.Id)
|
||||
.LeftJoin<DeviceRelPpAt>((e, p, r) => p.Id == r.FkPointInspectionPlanId)
|
||||
.Select((e, p, r) => new
|
||||
{
|
||||
FkDeviceAccountId = r.FkDeviceAccountId,
|
||||
Status = e.Status
|
||||
}).ToList();
|
||||
|
||||
foreach (DeviceType type in All_device_type)
|
||||
{
|
||||
@ -541,12 +557,24 @@ namespace ZR.Service.MES.dev
|
||||
}
|
||||
//0.2 判断是否维护中
|
||||
|
||||
//var query = from person in people
|
||||
// join address in addresses on person.Id equals address.PersonId into addressGroup
|
||||
// from addressItem in addressGroup.DefaultIfEmpty()
|
||||
// join phoneNumber in phoneNumbers on person.Id equals phoneNumber.PersonId into phoneGroup
|
||||
// from phoneNumberItem in phoneGroup.DefaultIfEmpty()
|
||||
// select new
|
||||
// {
|
||||
// PersonName = person.Name,
|
||||
// Address = addressItem?.AddressLine ?? "No address available",
|
||||
// PhoneNumber = phoneNumberItem?.Number ?? "No phone number available"
|
||||
// };
|
||||
|
||||
|
||||
|
||||
//处理点检
|
||||
int isExist_point = Context.Queryable<DeviceTaskExecute>()
|
||||
.LeftJoin<DevicePointInspectionPlan>((e, p) => e.TaskId == p.Id)
|
||||
.LeftJoin<DeviceRelPpAt>((e, p, r) => p.Id == r.FkPointInspectionPlanId)
|
||||
.Where((e, p, r) => r.FkDeviceAccountId == item.Id)
|
||||
.Where((e, p, r) => e.Status == 0 || e.Status == 1 || e.Status == 3)
|
||||
int isExist_point = query_point
|
||||
.Where(it => it.FkDeviceAccountId == item.Id)
|
||||
.Where(it => it.Status == 0 || it.Status == 1 || it.Status == 3)
|
||||
.Count();
|
||||
// UnmaintainedTotal = UnmaintainedTotal + isExist_point;
|
||||
if (isExist_point > 0)
|
||||
@ -561,11 +589,9 @@ namespace ZR.Service.MES.dev
|
||||
|
||||
|
||||
//处理巡检
|
||||
int isExist_route = Context.Queryable<DeviceTaskExecute>()
|
||||
.LeftJoin<DeviceRouteInspectionPlan>((e, p) => e.TaskId == p.Id)
|
||||
.LeftJoin<DeviceRelPpAt>((e, p, r) => p.Id == r.FkPointInspectionPlanId)
|
||||
.Where((e, p, r) => r.FkDeviceAccountId == item.Id)
|
||||
.Where((e, p, r) => e.Status == 0 || e.Status == 1 || e.Status == 3)
|
||||
int isExist_route = query_route
|
||||
.Where(it => it.FkDeviceAccountId == item.Id)
|
||||
.Where(it => it.Status == 0 || it.Status == 1 || it.Status == 3)
|
||||
.Count();
|
||||
|
||||
|
||||
@ -597,7 +623,7 @@ namespace ZR.Service.MES.dev
|
||||
analysis.DamageTotal = DamageTotal;
|
||||
analysis.NormalTotal = NormalTotal;
|
||||
analysis.NoUseTotal = NoUseTotal;
|
||||
|
||||
|
||||
return analysis;
|
||||
|
||||
}
|
||||
@ -609,7 +635,7 @@ namespace ZR.Service.MES.dev
|
||||
|
||||
public List<DeviceType> FindAllLeafNodes(int targetId)
|
||||
{
|
||||
List<DeviceType> list_device_types= Context.Queryable<DeviceType>().ToList();
|
||||
List<DeviceType> list_device_types = Context.Queryable<DeviceType>().ToList();
|
||||
List<int> childIds = new List<int> { targetId };
|
||||
List<DeviceType> result = new List<DeviceType>();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user