|
@@ -0,0 +1,107 @@
|
|
|
+package com.ruoyi.qdtl.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
+import com.ruoyi.common.core.redis.RedisCache;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.sign.Md5Utils;
|
|
|
+import com.ruoyi.qdtl.domain.TlArea;
|
|
|
+import com.ruoyi.qdtl.mapper.TlAreaMapper;
|
|
|
+import com.ruoyi.qdtl.service.ITlAreaService;
|
|
|
+import com.ruoyi.qdtl.service.ITlSinglePawnService;
|
|
|
+import com.ruoyi.system.service.ISysDictDataService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+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.concurrent.TimeUnit;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 区域管理Service业务层处理
|
|
|
+ *
|
|
|
+ * @author ruoyi
|
|
|
+ * @date 2022-02-21
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class TlSinglePawnServiceImpl implements ITlSinglePawnService{
|
|
|
+
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(TlSinglePawnServiceImpl.class);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysDictDataService dictDataService;
|
|
|
+ @Override
|
|
|
+ public List<Map<String, String>> getSinglePawnList() {
|
|
|
+ //获取accseetoken
|
|
|
+ String accesstoken = "";
|
|
|
+ //从redie获取token
|
|
|
+ Object tokenc = redisCache.getCacheObject("lechengtoken");
|
|
|
+ if(tokenc!=null){
|
|
|
+ accesstoken = (String)tokenc;
|
|
|
+ }else{
|
|
|
+ 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 },\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错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// 获取设备列表
|
|
|
+
|
|
|
+// 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错误");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String calcSign(String timestamp,String nonce,String appSecret){
|
|
|
+ String str = "time:" + timestamp+",nonce:" + nonce +",appSecret:" + appSecret;
|
|
|
+ String sign = Md5Utils.hash(str);
|
|
|
+ return sign;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|