|
|
@ -314,7 +314,29 @@ public class RedisCache |
|
|
|
String serialNum = String.format("%03d",no); |
|
|
|
return codeKey+serialNum; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成流水号(年为单位) |
|
|
|
* @param prefix |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String generateBillNoByYear(String prefix) { |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
|
|
|
SimpleDateFormat year_format = new SimpleDateFormat("yyyy"); |
|
|
|
String yearMonthDay = sdf.format(new Date()); |
|
|
|
String yearPart = year_format.format(new Date()); |
|
|
|
String codeKey = prefix+yearPart; |
|
|
|
Long no = 0L; |
|
|
|
//获取每日流水
|
|
|
|
if (hasKey(codeKey)) { |
|
|
|
no = Long.valueOf(get(codeKey).toString()); |
|
|
|
} |
|
|
|
no = incr(codeKey, 1); |
|
|
|
if (no == null) { |
|
|
|
throw new RuntimeException("Redis单据编号流水递增失败"); |
|
|
|
} |
|
|
|
String serialNum = String.format("%03d",no); |
|
|
|
return prefix + yearMonthDay +serialNum; |
|
|
|
} |
|
|
|
public String generateNo(String prefix) { |
|
|
|
String codeKey = prefix; |
|
|
|
Long no = 0L; |
|
|
|