|
|
@@ -13,7 +13,9 @@ import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.redis.utils.SequenceUtils;
|
|
|
import org.dromara.customer.domain.SupplierAddress;
|
|
|
+import org.dromara.customer.domain.SupplierInfo;
|
|
|
import org.dromara.customer.domain.bo.SupplierAddressBo;
|
|
|
import org.dromara.customer.domain.vo.SupplierAddressVo;
|
|
|
import org.dromara.customer.domain.vo.SupplierInfoVo;
|
|
|
@@ -23,6 +25,7 @@ import org.dromara.customer.service.ISupplierAddressService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.Duration;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -137,6 +140,7 @@ public class SupplierAddressServiceImpl extends ServiceImpl<SupplierAddressMappe
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean insertByBo(SupplierAddressBo bo) {
|
|
|
+ SupplierInfo supplierInfo = supplierInfoMapper.selectById(bo.getSupplierId());
|
|
|
SupplierAddress add = MapstructUtils.convert(bo, SupplierAddress.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
// 如果设置为自身地址
|
|
|
@@ -149,7 +153,7 @@ public class SupplierAddressServiceImpl extends ServiceImpl<SupplierAddressMappe
|
|
|
|
|
|
baseMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
- LambdaQueryWrapper<SupplierAddress> lqw = Wrappers.lambdaQuery();
|
|
|
+ /* LambdaQueryWrapper<SupplierAddress> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.select(SupplierAddress::getAddressNo)
|
|
|
.orderByDesc(SupplierAddress::getAddressNo)
|
|
|
.last("LIMIT 1");
|
|
|
@@ -157,7 +161,16 @@ public class SupplierAddressServiceImpl extends ServiceImpl<SupplierAddressMappe
|
|
|
String addressNo = supplierAddress.getAddressNo();
|
|
|
Long maxNo = Long.parseLong(addressNo);
|
|
|
String newAddressNo = String.valueOf(maxNo + 1);
|
|
|
- add.setAddressNo(newAddressNo);
|
|
|
+ add.setAddressNo(newAddressNo);*/
|
|
|
+ // 1. 构造带供应商编号的 Key,实现“每个供应商独立计数”
|
|
|
+ String seqKey = "supplier_address:supplier_address_no:" + supplierInfo.getSupplierNo();
|
|
|
+
|
|
|
+ // 2. 调用工具类
|
|
|
+ String seqId = SequenceUtils.nextPaddedIdStr(seqKey, Duration.ofDays(3650), 4);
|
|
|
+
|
|
|
+ // 3. 拼接最终结果
|
|
|
+ String addressNo = "2" + supplierInfo.getSupplierNo() + seqId;
|
|
|
+ add.setAddressNo(addressNo);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setId(add.getId());
|