/** 生成DD00001格式的编码 */ public String getNextAppleCode() { //指定编码数字位数 DecimalFormat decimalFormat=new DecimalFormat("0000"); LambdaQueryWrapper<Apple> queryWrap=new LambdaQueryWrapper<Apple>(); queryWrap.orderByDesc(Apple::getCreateTime); Optional<Apple> first=baseMapper.selectList(queryWrap).stream().findFirst(); String oldCode=first.isPresent()?first.get().getAppleCode():"DD0000"; String codenew=oldCode.substring(2); int i=Integer.parseInt(codenew)+1; //拼接编码 String newCode="DD"+decimalFormat.format(i); return newCode; }
生成指定字符及长度的编码
最新推荐文章于 2023-04-13 09:16:59 发布