|
|
@ -7,6 +7,9 @@ import javax.annotation.Resource;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
@ -37,6 +40,7 @@ public class SupplierCompanyServiceImpl implements SupplierCompanyService {
|
|
|
|
String companyNumber = numberCreate();
|
|
|
|
String companyNumber = numberCreate();
|
|
|
|
supplierCompany.setCompanyNumber(companyNumber);
|
|
|
|
supplierCompany.setCompanyNumber(companyNumber);
|
|
|
|
supplierCompanyMapper.insert(supplierCompany);
|
|
|
|
supplierCompanyMapper.insert(supplierCompany);
|
|
|
|
|
|
|
|
|
|
|
|
// 返回
|
|
|
|
// 返回
|
|
|
|
return supplierCompany.getId();
|
|
|
|
return supplierCompany.getId();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -91,44 +95,22 @@ public class SupplierCompanyServiceImpl implements SupplierCompanyService {
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
Date date = new Date(currentTime);
|
|
|
|
Date date = new Date(currentTime);
|
|
|
|
String companyNumber="gys"+ DateUtils.dateToStr(DateUtils.FORMAT_HOUR_MINUT,date);
|
|
|
|
String companyNumber="gys"+ DateUtils.dateToStr(DateUtils.FORMAT_HOUR_MINUT,date);
|
|
|
|
Long companyNumberSize = supplierCompanyMapper.selectCount(new QueryWrapper<SupplierCompanyDO>().likeLeft("company_number", companyNumber));
|
|
|
|
SupplierCompanyDO supplierCompanyDO = supplierCompanyMapper.selectOne(new QueryWrapper<SupplierCompanyDO>().like("company_number", companyNumber).orderByDesc("create_time").last("limit 1"));
|
|
|
|
Long l = companyNumberSize + 1L;
|
|
|
|
if (null!=supplierCompanyDO){
|
|
|
|
int length = String.valueOf(companyNumberSize + 1L).length();
|
|
|
|
Long aLong = numKun(supplierCompanyDO.getCompanyNumber());
|
|
|
|
if ((4-length) !=0){
|
|
|
|
companyNumber ="gys"+(aLong+1);
|
|
|
|
String gys = fillStr("", (4-length), true, "0");
|
|
|
|
|
|
|
|
companyNumber=companyNumber+gys+l.intValue();
|
|
|
|
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
companyNumber=companyNumber+l;
|
|
|
|
companyNumber=companyNumber+"0000";
|
|
|
|
|
|
|
|
long l = numKun(companyNumber) + 1;
|
|
|
|
|
|
|
|
companyNumber ="gys"+(numKun(companyNumber) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return companyNumber;
|
|
|
|
return companyNumber;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Long numKun(String a){
|
|
|
|
private String fillStr(String value, int count, boolean frontORback, String fillChar) {
|
|
|
|
String regEx = "[^0-9]";
|
|
|
|
String rtvalue = value;
|
|
|
|
Pattern p = Pattern.compile(regEx);
|
|
|
|
if (rtvalue == null) {
|
|
|
|
Matcher m = p.matcher(a);
|
|
|
|
rtvalue = "";
|
|
|
|
String result = m.replaceAll("").trim();
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
return Long.valueOf(result);
|
|
|
|
if (frontORback)
|
|
|
|
|
|
|
|
rtvalue = String.valueOf(rtvalue)
|
|
|
|
|
|
|
|
+ String.valueOf(fillChar);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
rtvalue = String.valueOf(fillChar)
|
|
|
|
|
|
|
|
+ String.valueOf(rtvalue);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
int len = rtvalue.length();
|
|
|
|
|
|
|
|
if (len > count) {
|
|
|
|
|
|
|
|
rtvalue = rtvalue.substring(0, count);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
int a = count - len;
|
|
|
|
|
|
|
|
for (int i = 0; i < a; i++)
|
|
|
|
|
|
|
|
if (frontORback)
|
|
|
|
|
|
|
|
rtvalue = String.valueOf(rtvalue)
|
|
|
|
|
|
|
|
+ String.valueOf(fillChar);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
rtvalue = String.valueOf(fillChar)
|
|
|
|
|
|
|
|
+ String.valueOf(rtvalue);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return rtvalue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|