Commit 74e87234 authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register' into develop_tzs_test

parents b2e4009d 80592fb2
......@@ -223,8 +223,8 @@
WHERE LENGTH(t.use_registration_code) = 14
AND SUBSTR(t.use_registration_code, 1, 1) IN ('容', '锅', '管', '瓶', '梯', '起', '索', '游', '车')
AND TRIM(t.use_registration_code) LIKE concat('%(',#{year},')')
and tjur.reg_type is null
and tjur.is_delete = 0
AND (tjur.reg_type IS NULL OR tjur.reg_type = 2)
AND tjur.is_delete = 0
GROUP BY SUBSTR(t.use_registration_code, 1, 5)
HAVING code <![CDATA[ <> ]]> '00000'
ORDER BY prefix
......
......@@ -751,7 +751,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
String record = (String) equipmentInfoForm.get(RECORD);
String dataSource = (String) equipmentInfoForm.get(DATA_SOURCE);
if (dataSource.startsWith("jg_his")) {
if (dataSource.contains("his")) {
String useRegistrationCode = String.valueOf(equipmentInfoForm.get("useRegistrationCode")).trim();
String equipId = String.valueOf(equipmentInfoForm.get("RECORD"));
// 校验使用登记证编号的唯一性
......
......@@ -44,6 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
......@@ -61,6 +62,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.parseArray;
......@@ -765,8 +767,30 @@ public class JgUseRegistrationManageServiceImpl extends BaseService<JgUseRegistr
}
public void initUseRegistrationCodeIntoRedis() {
jgUseRegistrationManageMapper.initUseRegistrationCodeIntoRedis(String.valueOf(LocalDate.now().getYear() % 100))
.forEach(resultMap -> redisTemplate.opsForValue().set(resultMap.get("prefix"), resultMap.get("code")));
// 获取当前年份的两位数
String currentYearSuffix = String.valueOf(LocalDate.now().getYear() % 100);
Date endOfYear = com.yeejoin.amos.boot.module.ymt.api.common.DateUtils.calculateEndOfYear(new Date());
// 从数据库中加载数据并批量设置到 Redis
jgUseRegistrationManageMapper.initUseRegistrationCodeIntoRedis(currentYearSuffix)
.forEach(resultMap ->
Optional.ofNullable(resultMap)
.ifPresent(map -> setValueWithExpiration(map.get("prefix"), map.get("code"), endOfYear))
);
}
/**
* redis设置key
*
* @param key key
* @param value value
* @param expirationDate 过期时间
*/
public void setValueWithExpiration(String key, String value, Date expirationDate) {
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
valueOps.set(key, value);
long expirationTimeInSeconds = expirationDate.getTime() - System.currentTimeMillis();
redisTemplate.expire(key, expirationTimeInSeconds, TimeUnit.MILLISECONDS);
}
public Object handleErrorDeviceCode(String applyNo) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment