|
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
|
{
|
/// <summary>
|
/// 系统帮助类
|
/// </summary>
|
public class SystemHelper
|
{
|
/// <summary>
|
/// 字符串转换decimal类型
|
/// </summary>
|
/// <param name="value"></param>
|
/// <returns></returns>
|
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;
|
}
|
|
/// <summary>
|
/// decimal集合计算平均值
|
/// </summary>
|
/// <param name="valueList">集合</param>
|
/// <param name="digits">精度</param>
|
/// <returns></returns>
|
public static string CalcDecimalAvg(List<decimal> 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();
|
}
|
|
}
|
}
|