|
|
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hxhq.common.core.utils.DateUtils; |
|
|
|
import com.hxhq.common.core.utils.SpringUtils; |
|
|
|
import com.hxhq.common.core.utils.StringUtils; |
|
|
|
import com.hxhq.common.redis.service.RedisService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -31,11 +32,11 @@ public class SnGenServiceImpl extends ServiceImpl implements |
|
|
|
private final Lock lock = new ReentrantLock(true); |
|
|
|
|
|
|
|
@Override |
|
|
|
public String getNewSn(Integer type) { |
|
|
|
public String getNewSn(Integer type, String my) { |
|
|
|
lock.lock(); |
|
|
|
try { |
|
|
|
Integer sort = 1; |
|
|
|
String date = DateUtils.dateTimeNow("yyMMdd"); |
|
|
|
String date = StringUtils.isBlank(my)? DateUtils.dateTimeNow("yyMMdd"):my; |
|
|
|
QueryWrapper<SnGen> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("date",date); |
|
|
|
queryWrapper.eq("type",type); |
|
|
|
@ -49,7 +50,7 @@ public class SnGenServiceImpl extends ServiceImpl implements |
|
|
|
baseMapper.addSn(date,type); |
|
|
|
sort = getOne(queryWrapper,false).getSn(); |
|
|
|
} |
|
|
|
return date+"-"+String.format("%03d", sort); |
|
|
|
return (StringUtils.isBlank(my)?(date+"-"):"")+String.format("%03d", sort); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("getNewSn执行被中断", e); |
|
|
|
} finally { |
|
|
|
@ -57,4 +58,9 @@ public class SnGenServiceImpl extends ServiceImpl implements |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String getNewSn(Integer type) { |
|
|
|
return getNewSn(type,null); |
|
|
|
} |
|
|
|
} |