diff --git a/Service/Station/BatteryOpModelDetailService.cs b/Service/Station/BatteryOpModelDetailService.cs index d30c853..5613e64 100644 --- a/Service/Station/BatteryOpModelDetailService.cs +++ b/Service/Station/BatteryOpModelDetailService.cs @@ -60,9 +60,11 @@ public class BatteryOpModelDetailService : BaseServices // 删除模型 var isExistModel = await _batteryOpModelRepository.QueryByClauseAsync(u => u.ModelId == user.ModelId); bool batteay = true; + var batteryOpModel = _batteryOpModelRepository.QueryListByClause(i => i.ModelId == user.ModelId); if (isExistModel != null) { - batteay = await _batteryOpModelRepository.DeleteAsync(isExistModel); + if (batteryOpModel.Count > 1) //如果模型里面还有数据,此模型就不删除 + batteay = await _batteryOpModelRepository.DeleteAsync(isExistModel); } // 删除模型详情 @@ -116,7 +118,7 @@ public class BatteryOpModelDetailService : BaseServices ModelId = input.ModelId }; await _batteryOpModelDetailRepository.InsertAsync(input); - + var isExistModel = await _batteryOpModelRepository.QueryByClauseAsync(u => u.ModelId == input.ModelId); if (isExistModel == null) { @@ -147,7 +149,6 @@ public class BatteryOpModelDetailService : BaseServices List batteryOpModelDetails = await _batteryOpModelDetailRepository.QueryAsync(); foreach (var detail in batteryOpModelDetails) { - if (detail.StartTime == batteryOpReq.StartTime && detail.Id != batteryOpReq.Id || detail.EndTime == batteryOpReq.EndTime && detail.Id != batteryOpReq.Id) { @@ -155,7 +156,6 @@ public class BatteryOpModelDetailService : BaseServices } } - // 通过id查找修改之前的模型id var batteryOpModelDetail =