作者 朱兆平

update:

1 核销规则对缓存的删除操作,采用更严谨的判定,确定缓存删除成功.
2 对偶尔核销异常的情况,增加对三宝二维码接口增加日志跟踪.以判定到底是哪里核销失败.是缓存删除失败,还是二维码释放失败.
... ... @@ -26,3 +26,4 @@
/logs/
/bw/
/log/
/bugLog/*
... ...
... ... @@ -3,6 +3,7 @@ package com.sy.crossDomain;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
... ... @@ -16,6 +17,7 @@ import java.util.Map;
@Component
@Slf4j
public class BuildBarCode {
private static String CREATEBARCODE = "http://10.50.7.11:8088/publiclogistics/createVehicleBarCode";
... ... @@ -86,7 +88,8 @@ public class BuildBarCode {
// 取消二维码
public static void cancleBarCode(String frameNo) {
String json = "{\"token\":\"samples\",\"data\":{\"vehicle_no\":\""+frameNo+"\",\"vehicle_no_color\":\"黄\"}}";
BuildBarCode.sendData(CANCLEBARCODE, json);
String cancelContent = BuildBarCode.sendData(CANCLEBARCODE, json);
log.info("车牌:{},取消二维码返回结果:{}",frameNo,cancelContent);
}
}
... ...
... ... @@ -136,14 +136,20 @@ class X21FormReleaseCheck extends Script {
RedisService redisService = context.getBean(RedisService.class);
//车辆流转申请缓存删除
redisService.del(info.getVename());
Long count_vename =redisService.delWithCount(info.getVename());
//流转申请时生成的临时核碰场站代码列表
redisService.del(info.getVename()+"_endstationList");
Long count_station =redisService.delWithCount(info.getVename()+"_endstationList");
//车辆过卡信息缓存删除-X22金二判定时候生成的这个缓存
redisService.del(info.getSeqno());
logger.info("[流转缓存]-{}缓存已核销",info.getVename());
//核销记录
releaseRecord(info,executeParams);
Long count_seqn = redisService.delWithCount(info.getSeqno());
if (count_vename>0){
//核销记录
releaseRecord(info,executeParams);
logger.info("[流转缓存]-{}缓存已核销",info.getVename());
logger.info("[流转缓存]-{}缓存删除确认结果:{}",info.getVename(),redisService.hasKey(info.getVename()));
}else{
logger.info("[流转缓存]-{}缓存核销失败,需人工核销",info.getVename());
}
}
/**
... ...
... ... @@ -13,6 +13,8 @@ public interface RedisService {
void del(String ... key);
Long delWithCount(String ... key);
Set<String> deleteBatchByKeys(String key);
String get(String key);
... ...
... ... @@ -76,6 +76,25 @@ public class RedisServiceImpl implements RedisService {
}
/**
* 删除缓存 - 增强版,返回实际删除的key数量
* @param key 可以传一个值 或多个
*/
@Override
@SuppressWarnings("unchecked")
public Long delWithCount(String ... key){
if(key!=null&&key.length>0){
if(key.length==1){
Boolean result = redisTemplate.delete(key[0]);
return result != null && result ? 1L : 0L;
}else{
Collection<String> keyList = CollectionUtils.arrayToList(key);
return redisTemplate.delete(keyList);
}
}
return 0L;
}
/**
* 【 递归删除redis key-value 】
* 效率会低点 但是删除方法安全
* @author yangjunxiong
... ...