Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-14 09:53:42 +08:00
commit a9c39f4f02
1 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package io.renren.common.utils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
@ -12,6 +14,7 @@ import java.util.concurrent.locks.ReentrantLock;
* 编码生成工具类
*/
public class CodeGenerationUtils {
private static final Logger logger = LoggerFactory.getLogger(CodeGenerationUtils.class);
@Autowired
private JdbcTemplate jdbcTemplate;
@ -92,9 +95,10 @@ public class CodeGenerationUtils {
"AND apply_number LIKE '" + applyNumberPattern + "%' " +
"ORDER BY apply_number DESC " +
"LIMIT 1";
logger.info(sql);
try {
String s = jdbcTemplate.queryForObject(sql, String.class);
return "NLSY" + (Long.parseLong(s) + 1);
return applyNumberPattern.substring(0, 3) + (Long.parseLong(s) + 1);
} catch (Exception e) {
return applyNumberPattern + "0001";
} finally {