RedisToUse.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.idea.oa.apply.util.constant;
  2. import org.springframework.util.StringUtils;
  3. public class RedisToUse {
  4. //拍卖场次
  5. public static String pmnumber = null;//"付款领用单20240401-002";
  6. /**
  7. * 获取各种订单编号递增的值
  8. *
  9. * @param topName
  10. * @param maxnum
  11. * @return
  12. */
  13. public static String addNumber(String topName, String maxnum) {
  14. if (StringUtils.isEmpty(maxnum)) {
  15. return null;
  16. } else {
  17. String substring = maxnum.substring(maxnum.length() - 1);
  18. if ("9".equals(substring)) {
  19. Integer num = Integer.parseInt(maxnum.substring(topName.length()));
  20. num++;
  21. int i = maxnum.length() - topName.length() - num.toString().length();
  22. StringBuilder sb = new StringBuilder();
  23. sb.append(topName);
  24. for (int i1 = 0; i1 < i; i1++) {
  25. sb.append('0');
  26. }
  27. sb.append(num.toString());
  28. maxnum = sb.toString();
  29. } else {
  30. int i = Integer.parseInt(substring) + 1;
  31. maxnum = maxnum.substring(0, maxnum.length() - 1) + i;
  32. }
  33. }
  34. return maxnum;
  35. }
  36. }