public DataResult GetSmartDeviceModel([FromQuery] int qId, int cId, int wId, bool menu) { var result = new DataResult(); result.datas.AddRange(menu ? SmartDeviceModelHelper.GetMenu(qId, cId, wId) : SmartDeviceModelHelper.GetDetail(qId, cId, wId)); if (qId != 0 && !result.datas.Any()) { result.errno = Error.SmartDeviceModelNotExist; return(result); } return(result); }
public object GetSmartCapacityListInfo([FromQuery] int qId, int processId) { var result = new DataResult(); var deviceCategoryId = 0; SmartCapacityListDetail capacityList = null; if (qId != 0) { capacityList = SmartCapacityListHelper.GetDetail(qId); if (capacityList == null) { return(Result.GenError <Result>(Error.SmartCapacityListNotExist)); } var capacity = SmartCapacityHelper.Instance.Get <SmartCapacity>(capacityList.CapacityId); if (capacity == null) { return(Result.GenError <Result>(Error.SmartCapacityNotExist)); } deviceCategoryId = capacityList.CategoryId; } else if (processId != 0) { var process = SmartProcessCodeCategoryProcessHelper.GetDetailByProcessId(processId); if (process == null) { return(Result.GenError <Result>(Error.SmartProcessCodeCategoryProcessNotExist)); } capacityList = new SmartCapacityListDetail { ProcessId = process.Id }; deviceCategoryId = process.CategoryId; } else { return(Result.GenError <Result>(Error.ParamError)); } capacityList.PId = SmartProcessCodeCategoryProcessHelper.Instance.Get <SmartProcessCodeCategoryProcess>(capacityList.ProcessId)?.ProcessId ?? 0; var actDevices = new List <SmartDeviceCapacity>(); if (deviceCategoryId != 0) { var models = SmartDeviceModelHelper.GetDetail(0, deviceCategoryId); var devices = capacityList.DeviceList; if (models.Any()) { var modelCount = SmartDeviceHelper.GetNormalDeviceModelCount(models.Select(x => x.Id)); foreach (var model in models) { var device = devices.FirstOrDefault(x => x.ModelId == model.Id) ?? new SmartDeviceCapacity(); device.Category = model.Category; device.CategoryId = model.CategoryId; device.ModelId = model.Id; device.Model = model.Model; device.Count = modelCount.FirstOrDefault(x => x.ModelId == model.Id) != null ? modelCount.FirstOrDefault(x => x.ModelId == model.Id).Count : 0; actDevices.Add(device); } } } var actOperators = new List <SmartOperatorCapacity>(); var levels = SmartOperatorLevelHelper.Instance.GetAll <SmartOperatorLevel>().OrderBy(x => x.Order); if (levels.Any()) { var operatorCount = SmartOperatorHelper.GetNormalOperatorCount(capacityList.ProcessId); var operators = capacityList.OperatorList; if (levels.Any()) { foreach (var level in levels) { var op = operators.FirstOrDefault(x => x.LevelId == level.Id) ?? new SmartOperatorCapacity(); op.Level = level.Level; op.LevelId = level.Id; op.Count = operatorCount.FirstOrDefault(x => x.ProcessId == capacityList.PId && x.LevelId == op.LevelId) != null ? operatorCount.FirstOrDefault(x => x.ProcessId == capacityList.PId && x.LevelId == level.Id).Count : 0; actOperators.Add(op); } } } result.datas.Add(capacityList); return(new { errno = 0, errmsg = "成功", Devices = actDevices, Operators = actOperators }); }