|
@@ -17,14 +17,11 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
- * 区域管理Service业务层处理
|
|
|
+ * 乐橙单兵Service业务层处理
|
|
|
*
|
|
|
* @author ruoyi
|
|
|
* @date 2022-02-21
|
|
@@ -45,6 +42,7 @@ public class TlSinglePawnServiceImpl implements ITlSinglePawnService{
|
|
|
private ISysDictDataService dictDataService;
|
|
|
@Override
|
|
|
public List<Map<String, String>> getSinglePawnList() {
|
|
|
+ List resdata = new ArrayList();
|
|
|
//获取accseetoken
|
|
|
String accesstoken = "";
|
|
|
//从redie获取token
|
|
@@ -72,30 +70,43 @@ public class TlSinglePawnServiceImpl implements ITlSinglePawnService{
|
|
|
|
|
|
// 获取设备列表
|
|
|
|
|
|
-// dictDataService.selectDictDataList();
|
|
|
-
|
|
|
- //获取kkticket
|
|
|
- try{
|
|
|
- String time = (new Date().getTime()/1000) +"";
|
|
|
- String appid = "lc61bad51959214a1b";
|
|
|
- String appsc = "0338ad90e7504fc0818b498d84d844";
|
|
|
- String nonce = UUID.randomUUID().toString().replace("-", "");
|
|
|
-
|
|
|
- String data = HttpUtil.post("https://openapi.lechange.cn:443/openapi/accessToken","{\r\n \"system\": {\r\n \"ver\": \"1.0\", \r\n \"sign\": \""+calcSign(time,nonce,appsc)+"\",\r\n \"appId\": \""+appid+"\",\r\n \"time\": "+time
|
|
|
- +", \r\n \"nonce\": \""+ nonce+"\"\r\n },\r\n \"params\": {\r\n \"token\":\"At_0000040c93ce212e44a69bac7ef1faf2\", \"deviceId\":\"8E057FBPAJ00090\", \"channelId\":\"0\",\"type\": \"0\" },\r\n \"id\": \"+time+\"\r\n}");
|
|
|
- String token = JSON.parseObject(data).getJSONObject("result").getJSONObject("data").getString("accessToken");
|
|
|
- Integer exp = JSON.parseObject(data).getJSONObject("result").getJSONObject("data").getInteger("expireTime");
|
|
|
- redisCache.setCacheObject("lechengtoken",token,exp.intValue(), TimeUnit.SECONDS);
|
|
|
- accesstoken = token;
|
|
|
-
|
|
|
- }catch (Exception ee){
|
|
|
- log.error("获取乐橙accesstoken错误");
|
|
|
+ SysDictData dictData = new SysDictData();
|
|
|
+ dictData.setDictType("SinglePawn");
|
|
|
+ List<SysDictData> datalist = dictDataService.selectDictDataList(dictData);
|
|
|
+ if(datalist!=null){
|
|
|
+ for (SysDictData data:datalist
|
|
|
+ ) {
|
|
|
+ String kktoken = "";
|
|
|
+ Object kkticket = redisCache.getCacheObject("lechengkkticket_"+data.getDictValue());
|
|
|
+ if(kkticket==null){
|
|
|
+ try{
|
|
|
+ String time = (new Date().getTime()/1000) +"";
|
|
|
+ String appid = "lc61bad51959214a1b";
|
|
|
+ String appsc = "0338ad90e7504fc0818b498d84d844";
|
|
|
+ String nonce = UUID.randomUUID().toString().replace("-", "");
|
|
|
+
|
|
|
+ String datap = HttpUtil.post("https://openapi.lechange.cn:443/openapi/getKitToken","{\r\n \"system\": {\r\n \"ver\": \"1.0\", \r\n \"sign\": \""+calcSign(time,nonce,appsc)+"\",\r\n \"appId\": \""+appid+"\",\r\n \"time\": "+time
|
|
|
+ +", \r\n \"nonce\": \""+ nonce+"\"\r\n },\r\n \"params\": {\r\n \"token\":\""+accesstoken+"\", \"deviceId\":\""+data.getDictValue()+"\", \"channelId\":\"0\",\"type\": \"0\" },\r\n \"id\": \"+time+\"\r\n}");
|
|
|
+ String token = JSON.parseObject(datap).getJSONObject("result").getJSONObject("data").getString("kitToken");
|
|
|
+ Integer exp = JSON.parseObject(datap).getJSONObject("result").getJSONObject("data").getInteger("expireTime");
|
|
|
+ redisCache.setCacheObject("lechengkkticket_"+data.getDictValue(),token,exp.intValue(), TimeUnit.SECONDS);
|
|
|
+ kktoken = token;
|
|
|
+ }catch (Exception ee){
|
|
|
+ log.error("获取乐橙"+data.getDictValue()+"设备kkticket错误");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ kktoken = (String)kkticket;
|
|
|
+ }
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("code",data.getDictValue());
|
|
|
+ map.put("name",data.getDictLabel());
|
|
|
+ map.put("remark",data.getRemark());
|
|
|
+ map.put("playaddr","imou://open.lechange.com/"+data.getDictValue()+"/0/1?streamId=1|kitToken="+kktoken);
|
|
|
+ resdata.add(map);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return null;
|
|
|
+ return resdata;
|
|
|
}
|
|
|
|
|
|
private String calcSign(String timestamp,String nonce,String appSecret){
|