Commit 61ca0fca LN

记录接口req

1 个父辈 93112ff2
......@@ -42,25 +42,11 @@ public class HikApi {
*/
public static final int CODE_ERROR = 99;
private static Integer currReqCodeNum=10000000;
/**
* 获取请求号
* @return
*/
private static String getReqCode()
{
String id="";
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String temp = sf.format(new Date());
id=temp+codeAdd();
return id;
}
private static synchronized String codeAdd(){
currReqCodeNum++;
return currReqCodeNum.toString();
}
private static String getReqCode(){
return config.getReqCode();
}
public static String getUrl(String apiAddr,String apiName){
if(ObjectUtil.isNotEmpty(apiAddr)){
return apiAddr;
......
package com.neotel.smfcore.hikvision;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.core.device.util.DataCache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -7,6 +8,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.Date;
@Service
@Slf4j
......@@ -169,8 +172,42 @@ public class HikConfig {
addr_10_reservedOrderApi = dataCache.GetConfigCache("hik.addr_10_reservedOrderApi", "hik.addr_10_reservedOrderApi", addr_10_reservedOrderApi);
addr_11_orderEndApi = dataCache.GetConfigCache("hik.addr_11_orderEndApi", "hik.addr_11_orderEndApi", addr_11_orderEndApi);
log.info("HIK服务器地址:" + mesServer + ",baseCode=" + baseCode + ",lgort=" + lgort);
try {
String cacheCode = dataCache.getCache("hikapi_req");
if (ObjectUtil.isEmpty(cacheCode)) {
currReqCodeNum = 10000000;
} else {
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
String temp = sf.format(new Date());
if (cacheCode.startsWith(temp)) {
String str=cacheCode.substring(14, cacheCode.length());
currReqCodeNum = Integer.parseInt(str);
}
}
} catch (Exception ex) {
log.info("加载req出错:" + ex);
}
log.info("HIK服务器地址:" + mesServer + ",baseCode=" + baseCode + ",lgort=" + lgort + ",currReqCodeNum=" + currReqCodeNum);
}
private Integer currReqCodeNum=10000000;
/**
* 获取请求号
* @return
*/
public String getReqCode()
{
String id="";
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String temp = sf.format(new Date());
id=temp+codeAdd();
dataCache.updateCache("hikapi_req" ,id);
return id;
}
private synchronized String codeAdd(){
currReqCodeNum++;
return currReqCodeNum.toString();
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!