|
|
|
@ -1,11 +1,14 @@
|
|
|
|
|
package com.glxp.api.service.basic;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.text.split.SplitIter;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.glxp.api.dao.sync.SyncDataPurtypeDao;
|
|
|
|
|
import com.glxp.api.req.basic.BasicCollectBusTypeRequest;
|
|
|
|
|
import com.glxp.api.res.basic.BasicCollectBusTypeResponse;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.apache.bcel.generic.PUSH;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
@ -38,14 +41,25 @@ public class BasicCollectBustypeService extends ServiceImpl<BasicCollectBustypeM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String genCode() {
|
|
|
|
|
String code = this.getCode();
|
|
|
|
|
return code;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getCode(){
|
|
|
|
|
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;
|
|
|
|
|
BasicCollectBustypeEntity basicCollectBustypeEntity = basicCollectBustypeMapper.selectOne(new LambdaQueryWrapper<BasicCollectBustypeEntity>().eq(BasicCollectBustypeEntity::getCode, randomNumber));
|
|
|
|
|
if (basicCollectBustypeEntity != null){
|
|
|
|
|
String code1 = this.getCode();
|
|
|
|
|
return code1;
|
|
|
|
|
}
|
|
|
|
|
return randomNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|