|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
package com.glxp.api.service.basic;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.glxp.api.req.basic.BasicCollectBusTypeRequest;
|
|
|
|
|
import com.glxp.api.res.basic.BasicCollectBusTypeResponse;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.glxp.api.dao.basic.BasicCollectBustypeMapper;
|
|
|
|
@ -13,6 +15,7 @@ import com.glxp.api.entity.basic.BasicCollectBustypeEntity;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class BasicCollectBustypeService extends ServiceImpl<BasicCollectBustypeMapper, BasicCollectBustypeEntity> {
|
|
|
|
@ -34,4 +37,15 @@ public class BasicCollectBustypeService extends ServiceImpl<BasicCollectBustypeM
|
|
|
|
|
return basicCollectBustypeMapper.selectOne(new LambdaQueryWrapper<BasicCollectBustypeEntity>().eq(BasicCollectBustypeEntity::getCode, code).last("limit 1 "));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String genCode() {
|
|
|
|
|
long workerId = IdUtil.getSnowflakeNextId();
|
|
|
|
|
String s = String.valueOf(workerId);
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
int startRange = Math.max(0, s.length() - 6);
|
|
|
|
|
int randomStart = random.nextInt(startRange + 1);
|
|
|
|
|
String randomNumber = "SP" + s.substring(randomStart, randomStart + 6);
|
|
|
|
|
return randomNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|