update:
1 核销规则对缓存的删除操作,采用更严谨的判定,确定缓存删除成功. 2 对偶尔核销异常的情况,增加对三宝二维码接口增加日志跟踪.以判定到底是哪里核销失败.是缓存删除失败,还是二维码释放失败.
正在显示
5 个修改的文件
包含
38 行增加
和
7 行删除
| @@ -3,6 +3,7 @@ package com.sy.crossDomain; | @@ -3,6 +3,7 @@ package com.sy.crossDomain; | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | +import lombok.extern.slf4j.Slf4j; | ||
| 6 | import org.springframework.stereotype.Component; | 7 | import org.springframework.stereotype.Component; |
| 7 | 8 | ||
| 8 | import java.io.BufferedReader; | 9 | import java.io.BufferedReader; |
| @@ -16,6 +17,7 @@ import java.util.Map; | @@ -16,6 +17,7 @@ import java.util.Map; | ||
| 16 | 17 | ||
| 17 | 18 | ||
| 18 | @Component | 19 | @Component |
| 20 | +@Slf4j | ||
| 19 | public class BuildBarCode { | 21 | public class BuildBarCode { |
| 20 | 22 | ||
| 21 | private static String CREATEBARCODE = "http://10.50.7.11:8088/publiclogistics/createVehicleBarCode"; | 23 | private static String CREATEBARCODE = "http://10.50.7.11:8088/publiclogistics/createVehicleBarCode"; |
| @@ -86,7 +88,8 @@ public class BuildBarCode { | @@ -86,7 +88,8 @@ public class BuildBarCode { | ||
| 86 | // 取消二维码 | 88 | // 取消二维码 |
| 87 | public static void cancleBarCode(String frameNo) { | 89 | public static void cancleBarCode(String frameNo) { |
| 88 | String json = "{\"token\":\"samples\",\"data\":{\"vehicle_no\":\""+frameNo+"\",\"vehicle_no_color\":\"黄\"}}"; | 90 | String json = "{\"token\":\"samples\",\"data\":{\"vehicle_no\":\""+frameNo+"\",\"vehicle_no_color\":\"黄\"}}"; |
| 89 | - BuildBarCode.sendData(CANCLEBARCODE, json); | 91 | + String cancelContent = BuildBarCode.sendData(CANCLEBARCODE, json); |
| 92 | + log.info("车牌:{},取消二维码返回结果:{}",frameNo,cancelContent); | ||
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | } | 95 | } |
| @@ -136,14 +136,20 @@ class X21FormReleaseCheck extends Script { | @@ -136,14 +136,20 @@ class X21FormReleaseCheck extends Script { | ||
| 136 | RedisService redisService = context.getBean(RedisService.class); | 136 | RedisService redisService = context.getBean(RedisService.class); |
| 137 | 137 | ||
| 138 | //车辆流转申请缓存删除 | 138 | //车辆流转申请缓存删除 |
| 139 | - redisService.del(info.getVename()); | 139 | + Long count_vename =redisService.delWithCount(info.getVename()); |
| 140 | //流转申请时生成的临时核碰场站代码列表 | 140 | //流转申请时生成的临时核碰场站代码列表 |
| 141 | - redisService.del(info.getVename()+"_endstationList"); | 141 | + Long count_station =redisService.delWithCount(info.getVename()+"_endstationList"); |
| 142 | //车辆过卡信息缓存删除-X22金二判定时候生成的这个缓存 | 142 | //车辆过卡信息缓存删除-X22金二判定时候生成的这个缓存 |
| 143 | - redisService.del(info.getSeqno()); | ||
| 144 | - logger.info("[流转缓存]-{}缓存已核销",info.getVename()); | ||
| 145 | - //核销记录 | ||
| 146 | - releaseRecord(info,executeParams); | 143 | + Long count_seqn = redisService.delWithCount(info.getSeqno()); |
| 144 | + if (count_vename>0){ | ||
| 145 | + //核销记录 | ||
| 146 | + releaseRecord(info,executeParams); | ||
| 147 | + logger.info("[流转缓存]-{}缓存已核销",info.getVename()); | ||
| 148 | + logger.info("[流转缓存]-{}缓存删除确认结果:{}",info.getVename(),redisService.hasKey(info.getVename())); | ||
| 149 | + }else{ | ||
| 150 | + logger.info("[流转缓存]-{}缓存核销失败,需人工核销",info.getVename()); | ||
| 151 | + } | ||
| 152 | + | ||
| 147 | } | 153 | } |
| 148 | 154 | ||
| 149 | /** | 155 | /** |
| @@ -13,6 +13,8 @@ public interface RedisService { | @@ -13,6 +13,8 @@ public interface RedisService { | ||
| 13 | 13 | ||
| 14 | void del(String ... key); | 14 | void del(String ... key); |
| 15 | 15 | ||
| 16 | + Long delWithCount(String ... key); | ||
| 17 | + | ||
| 16 | Set<String> deleteBatchByKeys(String key); | 18 | Set<String> deleteBatchByKeys(String key); |
| 17 | 19 | ||
| 18 | String get(String key); | 20 | String get(String key); |
| @@ -76,6 +76,25 @@ public class RedisServiceImpl implements RedisService { | @@ -76,6 +76,25 @@ public class RedisServiceImpl implements RedisService { | ||
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | /** | 78 | /** |
| 79 | + * 删除缓存 - 增强版,返回实际删除的key数量 | ||
| 80 | + * @param key 可以传一个值 或多个 | ||
| 81 | + */ | ||
| 82 | + @Override | ||
| 83 | + @SuppressWarnings("unchecked") | ||
| 84 | + public Long delWithCount(String ... key){ | ||
| 85 | + if(key!=null&&key.length>0){ | ||
| 86 | + if(key.length==1){ | ||
| 87 | + Boolean result = redisTemplate.delete(key[0]); | ||
| 88 | + return result != null && result ? 1L : 0L; | ||
| 89 | + }else{ | ||
| 90 | + Collection<String> keyList = CollectionUtils.arrayToList(key); | ||
| 91 | + return redisTemplate.delete(keyList); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + return 0L; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + /** | ||
| 79 | * 【 递归删除redis key-value 】 | 98 | * 【 递归删除redis key-value 】 |
| 80 | * 效率会低点 但是删除方法安全 | 99 | * 效率会低点 但是删除方法安全 |
| 81 | * @author yangjunxiong | 100 | * @author yangjunxiong |
-
请 注册 或 登录 后发表评论