public ActionResult SaveThresholdValue(ThresholdValueView model) { var color = string.Empty; var message = string.Empty; if (ModelState.IsValid) { var req = new ThresholdValueSettingRequest { PointsNumber = model.PointsNumber, PointsNumberId = model.PointsNumberId }; SaveThresholdValuesFromViewToRequest(req, model); var thresholdValueSettingService = ThresholdValueSettingServiceFactory.GetThresholdValueServiceFrom(model.TestTypeId); var resp = thresholdValueSettingService.ModifyThresholdValue(req); message = resp.Message; color = resp.Succeed ? StyleConstants.GreenColor : StyleConstants.RedColor; } else { message = "阈值设置错误!"; color = StyleConstants.RedColor; } return(Json(new { color, message }, JsonRequestBehavior.AllowGet)); }
void SaveThresholdValuesFromViewToRequest(ThresholdValueSettingRequest req, ThresholdValueView model) { var tg = ThresholdValuesConvert.ConvertForm(model.ThresholdValues); req.PositiveFirstLevelThresholdValue = tg.PositiveStandardValueGroup.FirstLevelThresholdValue; req.PositiveSecondLevelThresholdValue = tg.PositiveStandardValueGroup.SecondLevelThresholdValue; req.NegativeFirstLevelThresholdValue = tg.NegativeStandardValueGroup.FirstLevelThresholdValue; req.NegativeSecondLevelThresholdValue = tg.NegativeStandardValueGroup.SecondLevelThresholdValue; }
/// <summary> /// 通过下拉菜单条件查询阈值列表 /// </summary> /// <param name="conditions"></param> /// <returns></returns> public ActionResult GetThresholdValueSettingListByPullDownSearchBar(ThresholdValueSearchBarBaseView conditions) { var req = new GetThresholdValueByPointsPositionSearchRequest { PointsPositionId = conditions.MornitoringPointsPositionId }; var thresholdValueSettingService = ThresholdValueSettingServiceFactory.GetThresholdValueServiceFrom(conditions.MornitoringTestTypeId); var resp = thresholdValueSettingService.GetThresholdValueListByPointsPosition(req); var models = new List <ThresholdValueView>(); var resultView = new ThresholdValueSettingView(); if (resp.Succeed) { if (resp.IsContainNegative) { foreach (var item in resp.ThresholdValueContainNegative) { var resultItem = new ThresholdValueView(); resultItem.TestTypeId = conditions.MornitoringTestTypeId; resultItem.PointsNumber = item.PointsNumberName; resultItem.PointsNumberId = item.PointsNumberId; resultItem.PositiveFirstLevelThresholdValue = item.PositiveFirstLevelThresholdValue; resultItem.PositiveSecondLevelThresholdValue = item.PositiveSecondLevelThresholdValue; resultItem.NegativeFirstLevelThresholdValue = item.NegativeFirstLevelThresholdValue; resultItem.NegativeSecondLevelThresholdValue = item.NegativeSecondLevelThresholdValue; resultItem.IsContainNegative = true; models.Add(resultItem); } resultView.ThresholdValues = models; } else { foreach (var item in resp.ThresholdValuesWithoutNegative) { var resultItem = new ThresholdValueView(); resultItem.TestTypeId = conditions.MornitoringTestTypeId; resultItem.PointsNumber = item.PointsNumberName; resultItem.PointsNumberId = item.PointsNumberId; resultItem.PositiveFirstLevelThresholdValue = item.PositiveFirstLevelThresholdValue; resultItem.PositiveSecondLevelThresholdValue = item.PositiveSecondLevelThresholdValue; resultItem.IsContainNegative = false; models.Add(resultItem); } resultView.ThresholdValues = models; } } else { return(Json(new { color = StyleConstants.RedColor, message = resp.Message }, JsonRequestBehavior.AllowGet)); } return(PartialView("ThresholdValueSettingListPartial", resultView)); }
/// <summary> /// 通过搜索栏查询阈值列表 /// </summary> /// <param name="conditions"></param> /// <returns></returns> public ActionResult GetThresholdValueSettingList(QueryPointsNumberConditonView conditions) { var models = new List <ThresholdValueView>(); var resultView = new ThresholdValueSettingView(); var resultCondition = GetThresholdValueSearchConditionByConditonPointsNumber(conditions); foreach (var item in resultCondition) { var req = new GetThresholdValueByPointsPositionSearchRequest { PointsPositionId = item.PointsPositionId, PointsNumber = item.PointsName }; var thresholdValueSettingService = ThresholdValueSettingServiceFactory.GetThresholdValueServiceFrom(item.TestTypeId); var resultByPointNumber = thresholdValueSettingService.GetThresholdValueListByPointsNumber(req); if (resultByPointNumber.IsContainNegative) { var resultItem = new ThresholdValueView(); resultItem.TestTypeId = item.TestTypeId; resultItem.PointsNumber = resultByPointNumber.PointsNumberName; resultItem.PointsNumberId = resultByPointNumber.PointsNumberId; resultItem.PositiveFirstLevelThresholdValue = resultByPointNumber.PositiveFirstLevelThresholdValue; resultItem.PositiveSecondLevelThresholdValue = resultByPointNumber.PositiveSecondLevelThresholdValue; resultItem.NegativeFirstLevelThresholdValue = resultByPointNumber.NegativeFirstLevelThresholdValue; resultItem.NegativeSecondLevelThresholdValue = resultByPointNumber.NegativeSecondLevelThresholdValue; resultItem.IsContainNegative = true; models.Add(resultItem); } else { var resultItem = new ThresholdValueView(); resultItem.TestTypeId = item.TestTypeId; resultItem.PointsNumber = resultByPointNumber.PointsNumberName; resultItem.PointsNumberId = resultByPointNumber.PointsNumberId; resultItem.PositiveFirstLevelThresholdValue = resultByPointNumber.PositiveFirstLevelThresholdValue; resultItem.PositiveSecondLevelThresholdValue = resultByPointNumber.PositiveSecondLevelThresholdValue; resultItem.IsContainNegative = false; models.Add(resultItem); } resultView.ThresholdValues = models; } return(PartialView("ThresholdValueSettingListPartial", resultView)); }