|
@@ -1,6 +1,7 @@
|
|
|
package org.jeecg.modules.baseCode.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import io.micrometer.core.instrument.util.StringUtils;
|
|
|
import org.jeecg.modules.baseCode.entity.SerialPattern;
|
|
|
import org.jeecg.modules.baseCode.mapper.SerialPatternMapper;
|
|
|
import org.jeecg.modules.baseCode.service.ISerialPatternService;
|
|
@@ -55,13 +56,6 @@ public class SerialPatternServiceImpl extends ServiceImpl<SerialPatternMapper, S
|
|
|
if (oConvertUtils.isEmpty(pattern)){
|
|
|
return Result.error("表格:"+tableName+",字段:"+fieldName+"的编号定义为空");
|
|
|
}
|
|
|
- // 查找最大值
|
|
|
- QueryWrapper<Map<String,String>> queryWrapper = new QueryWrapper<>();
|
|
|
- Map<String,Object> row = sysSerialPatternMapper.selectMax(tableName, fieldName, queryWrapper);
|
|
|
- String maxValue = "";
|
|
|
- if (row != null && row.containsKey(fieldName)){
|
|
|
- maxValue = oConvertUtils.getString(row.get(fieldName));
|
|
|
- }
|
|
|
|
|
|
String[] splitPattern = pattern.split("\\+");
|
|
|
String prefix = ""; // 前缀
|
|
@@ -71,7 +65,7 @@ public class SerialPatternServiceImpl extends ServiceImpl<SerialPatternMapper, S
|
|
|
for (String subPattern : splitPattern){
|
|
|
if (Pattern.matches("\\{[^{}]+\\}", subPattern)){ // 字符串前缀
|
|
|
prefix = subPattern.substring(1, subPattern.length()-1);
|
|
|
- }else if(!Pattern.matches("[^yMdHms]", subPattern)){ // yyyyMMddHHmmss
|
|
|
+ }else if(!Pattern.matches("[^yMdHms]", subPattern)){ // yyyyMMddHHmmss
|
|
|
DateFormat dateFormat = new java.text.SimpleDateFormat(subPattern);
|
|
|
dateStr = dateFormat.format(new Date());
|
|
|
} else if (Pattern.matches("^[1-9]+[0-9]*$", subPattern)){
|
|
@@ -79,6 +73,18 @@ public class SerialPatternServiceImpl extends ServiceImpl<SerialPatternMapper, S
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 查找最大值
|
|
|
+ QueryWrapper<Map<String,String>> queryWrapper = new QueryWrapper<>();
|
|
|
+ if(StringUtils.isNotBlank(prefix)){
|
|
|
+ queryWrapper.likeLeft(fieldName,prefix);
|
|
|
+ }
|
|
|
+ Map<String,Object> row = sysSerialPatternMapper.selectMax(tableName, fieldName, queryWrapper);
|
|
|
+ String maxValue = "";
|
|
|
+ if (row != null && row.containsKey(fieldName)){
|
|
|
+ maxValue = oConvertUtils.getString(row.get(fieldName));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
int maxSerial = 0;
|
|
|
if (oConvertUtils.isNotEmpty(maxValue)){
|
|
|
if (oConvertUtils.isNotEmpty(prefix)){
|