|
|
@@ -1,5 +1,6 @@
|
|
|
package com.zd.bottle.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -7,7 +8,6 @@ import com.zd.bottle.domain.RfidTag;
|
|
|
import com.zd.bottle.mapper.RfidTagMapper;
|
|
|
import com.zd.bottle.service.RfidTagService;
|
|
|
import com.zd.common.core.exception.ServiceException;
|
|
|
-import com.zd.common.core.utils.IdGen;
|
|
|
import com.zd.common.security.service.TokenService;
|
|
|
import com.zd.system.api.domain.SysUser;
|
|
|
import com.zd.system.api.model.LoginUser;
|
|
|
@@ -30,32 +30,10 @@ public class RfidTagServiceImpl extends ServiceImpl<RfidTagMapper, RfidTag> impl
|
|
|
|
|
|
@Resource
|
|
|
private TokenService tokenService;
|
|
|
- private static final Integer DATA_LENGTH=8;
|
|
|
|
|
|
@Resource
|
|
|
private RfidTagMapper rfidTagMapper;
|
|
|
|
|
|
- protected static final String[] CHARS = new String[] { "a", "b", "c", "d", "e", "f",
|
|
|
- "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
|
|
|
- "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
|
|
|
- "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
|
|
|
- "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
|
|
|
- "W", "X", "Y", "Z" };
|
|
|
-
|
|
|
-
|
|
|
- public static String generateShortUuid() {
|
|
|
- StringBuilder shortBuffer = new StringBuilder();
|
|
|
- String uuid = IdGen.uuid();
|
|
|
- for (int i = 0; i < DATA_LENGTH; i++) {
|
|
|
- String str = uuid.substring(i * 4, i * 4 + 4);
|
|
|
- int x = Integer.parseInt(str, 16);
|
|
|
- shortBuffer.append(CHARS[x % 0x3E]);
|
|
|
- }
|
|
|
- return shortBuffer.toString();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public RfidTag add(RfidTag rfidTag) {
|
|
|
String username=null;
|
|
|
@@ -68,13 +46,12 @@ public class RfidTagServiceImpl extends ServiceImpl<RfidTagMapper, RfidTag> impl
|
|
|
userId=sysUser.getUserId();
|
|
|
deptId=sysUser.getDeptId();
|
|
|
}
|
|
|
- rfidTag.setAuthCode(generateShortUuid());
|
|
|
QueryWrapper<RfidTag> wrapper = Wrappers.query();
|
|
|
wrapper.select(" IFNULL( max(auth_code),0) as authCode");
|
|
|
Map<String, Object> map = getMap(wrapper);
|
|
|
int authCode = Integer.parseInt((String) map.get("authCode"));
|
|
|
authCode+=1;
|
|
|
- DecimalFormat gf=new DecimalFormat("00000");
|
|
|
+ DecimalFormat gf=new DecimalFormat("0000000");
|
|
|
rfidTag.setAuthCode(gf.format(authCode));
|
|
|
rfidTag.setCommonValue(username,userId,deptId);
|
|
|
boolean save = save(rfidTag);
|
|
|
@@ -91,7 +68,9 @@ public class RfidTagServiceImpl extends ServiceImpl<RfidTagMapper, RfidTag> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public RfidTag getRfidByTagCode(String authCode) {
|
|
|
- return rfidTagMapper.getRfidByTagCode(authCode);
|
|
|
+ LambdaQueryWrapper<RfidTag> wrapper = Wrappers.lambdaQuery(RfidTag.class);
|
|
|
+ wrapper.eq(RfidTag::getAuthCode,authCode);
|
|
|
+ return getOne(wrapper);
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
@@ -101,7 +80,7 @@ public class RfidTagServiceImpl extends ServiceImpl<RfidTagMapper, RfidTag> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateQpRfidTag(RfidTag rfidTag) {
|
|
|
- return rfidTagMapper.updateQpRfidTag(rfidTag);
|
|
|
+ return updateById(rfidTag) ?1:0;
|
|
|
}
|
|
|
|
|
|
|