using iWare_SCADA_Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace iWare_SCADA_BusinessLogical.Utils { /// /// 系统帮助类 /// public class SystemHelper { public static string GetStrForQualityOP70(string str) { if (string.IsNullOrEmpty(str) || str == "0") { return ""; } return str; } /// /// 字符串转换decimal类型 /// /// /// public static decimal GetDecimal(string value) { if (string.IsNullOrEmpty(value)) { return 0; } decimal decimalValue = 0; var isRight = decimal.TryParse(value, out decimalValue); if (isRight) { return decimalValue; } return 0; } /// /// decimal集合计算平均值 /// /// 集合 /// 精度 /// public static string CalcDecimalAvg(List valueList, int digits) { var sum = valueList.Sum(); var count = valueList.Count; var bb = Convert.ToDecimal((sum / (decimal)count).ToString("f" + digits.ToString())); return bb.ToString(); } } }