You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package com.glxp.api.util;
|
|
|
|
|
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.dao.inv.DeptDeviceDetailDao;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ID工具类
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
public class IdUtil {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
@Resource
|
|
|
|
|
private DeptDeviceDetailDao deptDeviceDetailDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取最新的科室设备明细的资产编码
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String getDeptDeviceCode() {
|
|
|
|
|
Long code = redisUtil.incr(Constant.DEPT_CACHE_CODE, 1);
|
|
|
|
|
if (code == 1) {
|
|
|
|
|
//redis中的key不存在,重新缓存当前最大的key进去
|
|
|
|
|
redisUtil.set(Constant.DEPT_CACHE_CODE, Long.valueOf(deptDeviceDetailDao.selectMaxCode()));
|
|
|
|
|
//重新获取最新的编码
|
|
|
|
|
code = redisUtil.incr(Constant.DEPT_CACHE_CODE, 1);
|
|
|
|
|
}
|
|
|
|
|
return String.valueOf(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|