package com.iailab.module.data.point.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.framework.common.service.impl.BaseServiceImpl;
|
import com.iailab.module.data.point.dao.DaSequenceNumDao;
|
import com.iailab.module.data.point.entity.DaSequenceNumEntity;
|
import com.iailab.module.data.point.service.DaSequenceNumService;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年05月12日
|
*/
|
@Service
|
public class DaSequenceNumServiceImpl extends BaseServiceImpl<DaSequenceNumDao, DaSequenceNumEntity> implements DaSequenceNumService {
|
|
@Override
|
public synchronized String getAndIncreaseByCode (String code) {
|
QueryWrapper queryWrapper = new QueryWrapper<DaSequenceNumEntity>();
|
queryWrapper.eq("code", code);
|
DaSequenceNumEntity sequenceNumEntity = baseDao.selectOne(queryWrapper);
|
|
DaSequenceNumEntity sequenceNumUpdate = new DaSequenceNumEntity();
|
sequenceNumUpdate.setId(sequenceNumEntity.getId());
|
sequenceNumUpdate.setSequenceNum(sequenceNumEntity.getSequenceNum() + 1);
|
baseDao.updateById(sequenceNumUpdate);
|
|
String str = String.format("%010d", sequenceNumEntity.getSequenceNum());
|
return sequenceNumEntity.getPrefix() + str;
|
}
|
}
|