7bab891c84dd4aa071e9fbaa6d42f1f2c494e18f.svn-base 707 B

1234567891011121314151617181920212223242526272829303132
  1. package org.jeecg.modules.system.util;
  2. import java.math.BigDecimal;
  3. public class OnlineUtil {
  4. public static Object calculation(Object o1, Object o2, String op){
  5. Object result = null;
  6. if(op == null){
  7. op = "";
  8. }
  9. switch (op) {
  10. case "count":
  11. result = new BigDecimal(o1.toString()).add(BigDecimal.ONE);
  12. break;
  13. case "sum":
  14. BigDecimal b1 = new BigDecimal(o1.toString());
  15. BigDecimal b2 = new BigDecimal(o2.toString());
  16. result = b1.add(b2);
  17. break;
  18. case "avg":
  19. BigDecimal ba1 = new BigDecimal(o1.toString());
  20. BigDecimal ba2 = new BigDecimal(o2.toString());
  21. result = ba1.add(ba2);
  22. break;
  23. default:
  24. result = o2;
  25. break;
  26. }
  27. return result;
  28. }
  29. }