Merge branch 'dev' of http://git.znkjfw.com/ak/zn-cloud into frx

This commit is contained in:
furongxin 2024-11-09 09:57:05 +08:00
commit 80f91de677
2 changed files with 7 additions and 3 deletions

View File

@ -58,6 +58,10 @@ public class Constants {
* yyyy-MM-dd格式 * yyyy-MM-dd格式
*/ */
public static final DateTimeFormatter REPO_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); public static final DateTimeFormatter REPO_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
/**
* 年月格式
*/
public static final DateTimeFormatter YEAR_MONTH_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM");
/** /**
* yyyy-MM-dd HH:mm:ss格式 * yyyy-MM-dd HH:mm:ss格式
*/ */

View File

@ -1018,7 +1018,7 @@ public class AttendanceServiceImpl implements AttendanceService {
public Integer getReplacementCardNum() { public Integer getReplacementCardNum() {
Long userId = getLoginUserId(); Long userId = getLoginUserId();
Integer num = 0; Integer num = 0;
String key = "ReplacementCardNum" + "_" + userId + "_" + LocalDateTime.now().format(Constants.REPO_DATE_FORMAT); String key = "ReplacementCardNum" + "_" + userId + "_" + LocalDateTime.now().format(Constants.YEAR_MONTH_FORMAT);
String value = stringRedisTemplate.opsForValue().get(key); String value = stringRedisTemplate.opsForValue().get(key);
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
// -- 获取当前用户 // -- 获取当前用户
@ -1064,7 +1064,7 @@ public class AttendanceServiceImpl implements AttendanceService {
} }
} catch (Exception e) { } catch (Exception e) {
// -- 如果有报错的话 - 那么进行回滚操作 - 并且redis 中的补卡次数也要+1 (redis并不会回滚) // -- 如果有报错的话 - 那么进行回滚操作 - 并且redis 中的补卡次数也要+1 (redis并不会回滚)
String key = "ReplacementCardNum" + "_" + userId + "_" + LocalDateTime.now().format(Constants.REPO_DATE_FORMAT); String key = "ReplacementCardNum" + "_" + userId + "_" + LocalDateTime.now().format(Constants.YEAR_MONTH_FORMAT);
stringRedisTemplate.opsForValue().increment(key, 1); stringRedisTemplate.opsForValue().increment(key, 1);
throw exception(ABNORMAL_CARD_REPLENISHMENT); throw exception(ABNORMAL_CARD_REPLENISHMENT);
} }
@ -1121,7 +1121,7 @@ public class AttendanceServiceImpl implements AttendanceService {
@Override @Override
public void useReplacementCardNum(Long userId) { public void useReplacementCardNum(Long userId) {
userId = userId == null ? getLoginUserId() : userId; userId = userId == null ? getLoginUserId() : userId;
String key = "ReplacementCardNum" + "_" + userId + "_" + LocalDateTime.now().format(Constants.REPO_DATE_FORMAT); String key = "ReplacementCardNum" + "_" + userId + "_" + LocalDateTime.now().format(Constants.YEAR_MONTH_FORMAT);
String value = stringRedisTemplate.opsForValue().get(key); String value = stringRedisTemplate.opsForValue().get(key);
if (StringUtils.isNotEmpty(value)) { if (StringUtils.isNotEmpty(value)) {
if (Integer.parseInt(value) > 0) { if (Integer.parseInt(value) > 0) {