Utility.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using DynamicExpresso;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using wispro.sp.entity;
  7. namespace wispro.sp.api.Utility
  8. {
  9. public class Utility
  10. {
  11. public static void CalBasePoint(PerformanceItem item, List<BasePointRule> rules)
  12. {
  13. #region 计算基本点数值及绩效类型
  14. rules.Sort((a, b) =>
  15. {
  16. var o = b.Priority - a.Priority;
  17. return o;
  18. });
  19. foreach (BasePointRule rule in rules)
  20. {
  21. var interpreter = new Interpreter();
  22. //item.ApplicationType
  23. Func<PerformanceItem, bool> func = interpreter.ParseAsDelegate<Func<PerformanceItem, bool>>(rule.Rule, "p");
  24. bool result = func.Invoke(item);
  25. if (result)
  26. {
  27. //interpreter.SetVariable("p", item);
  28. item.BasePoint = (double?)interpreter.Eval(rule.PointExpress);
  29. item.Type = rule.Type;
  30. break;
  31. }
  32. }
  33. #endregion
  34. }
  35. }
  36. }