提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.point.service.impl; |
H |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
5 |
import com.iailab.module.data.point.dao.DaSequenceNumDao; |
|
6 |
import com.iailab.module.data.point.entity.DaSequenceNumEntity; |
|
7 |
import com.iailab.module.data.point.service.DaSequenceNumService; |
|
8 |
import org.springframework.stereotype.Service; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author PanZhibao |
|
12 |
* @Description |
|
13 |
* @createTime 2024年05月12日 |
|
14 |
*/ |
|
15 |
@Service |
|
16 |
public class DaSequenceNumServiceImpl extends BaseServiceImpl<DaSequenceNumDao, DaSequenceNumEntity> implements DaSequenceNumService { |
|
17 |
|
|
18 |
@Override |
|
19 |
public synchronized String getAndIncreaseByCode (String code) { |
|
20 |
QueryWrapper queryWrapper = new QueryWrapper<DaSequenceNumEntity>(); |
|
21 |
queryWrapper.eq("code", code); |
|
22 |
DaSequenceNumEntity sequenceNumEntity = baseDao.selectOne(queryWrapper); |
|
23 |
|
|
24 |
DaSequenceNumEntity sequenceNumUpdate = new DaSequenceNumEntity(); |
|
25 |
sequenceNumUpdate.setId(sequenceNumEntity.getId()); |
|
26 |
sequenceNumUpdate.setSequenceNum(sequenceNumEntity.getSequenceNum() + 1); |
|
27 |
baseDao.updateById(sequenceNumUpdate); |
|
28 |
|
|
29 |
String str = String.format("%010d", sequenceNumEntity.getSequenceNum()); |
|
30 |
return sequenceNumEntity.getPrefix() + str; |
|
31 |
} |
|
32 |
} |