|
|
|
@ -6,6 +6,13 @@ import org.jeecg.modules.demo.base.service.IZyClothsTypeService; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Description: zy_cloths_type |
|
|
|
@ -16,4 +23,44 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
@Service |
|
|
|
|
public class ZyClothsTypeServiceImpl extends ServiceImpl<ZyClothsTypeMapper, ZyClothsType> implements IZyClothsTypeService { |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
ZyClothsTypeMapper zyClothsTypeMapper; |
|
|
|
|
/** |
|
|
|
|
* nums,编号,varchar,10,非空,不重复,企业缩写(4)+顺序号(6) |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public String generateNumber() { |
|
|
|
|
//先拿到类型编号
|
|
|
|
|
String nums = "QIYE"; |
|
|
|
|
//再来一个顺序号
|
|
|
|
|
String format = String.format("%06d", orderNumber()); |
|
|
|
|
//生成编码
|
|
|
|
|
String result = nums + format; |
|
|
|
|
System.err.println(result); |
|
|
|
|
return nums + format; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Long orderNumber() { |
|
|
|
|
List<String> listString = zyClothsTypeMapper.selectNumsList(); |
|
|
|
|
System.out.println(listString); |
|
|
|
|
List<Long> listLong = new ArrayList<>(); |
|
|
|
|
for (String nums : listString) { |
|
|
|
|
System.err.println(nums); |
|
|
|
|
String REGEX = "[^0-9]"; |
|
|
|
|
//只要数字
|
|
|
|
|
String newNums = Pattern.compile(REGEX).matcher(nums).replaceAll("").trim(); |
|
|
|
|
System.err.println(newNums); |
|
|
|
|
if (!StringUtils.hasText(newNums)){ |
|
|
|
|
newNums = "0"; |
|
|
|
|
} |
|
|
|
|
if (newNums.length() > 6) { |
|
|
|
|
//拿到后6位
|
|
|
|
|
String substring = newNums.substring(newNums.length() - 6); |
|
|
|
|
listLong.add(Long.valueOf(substring)); |
|
|
|
|
}else { |
|
|
|
|
listLong.add(Long.valueOf(newNums)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return Collections.max(listLong)+1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|