|
@@ -2,48 +2,76 @@ package com.fdkankan.scene.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.fdkankan.common.constant.SceneInfoReqType;
|
|
import com.fdkankan.common.constant.SceneInfoReqType;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.common.util.ThreeDESUtil;
|
|
import com.fdkankan.feign.TietaEntityClient;
|
|
import com.fdkankan.feign.TietaEntityClient;
|
|
import com.fdkankan.scene.annotation.InitEditInfo;
|
|
import com.fdkankan.scene.annotation.InitEditInfo;
|
|
import com.fdkankan.scene.bean.ResultData;
|
|
import com.fdkankan.scene.bean.ResultData;
|
|
|
|
+import com.fdkankan.scene.entity.SystemSecret;
|
|
|
|
+import com.fdkankan.scene.httpclient.CustomHttpClient;
|
|
import com.fdkankan.scene.service.*;
|
|
import com.fdkankan.scene.service.*;
|
|
import com.fdkankan.scene.vo.*;
|
|
import com.fdkankan.scene.vo.*;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.LinkedHashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.net.InetAddress;
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 场景编辑管理
|
|
* 场景编辑管理
|
|
*/
|
|
*/
|
|
-@Log4j2
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/service/scene/edit")
|
|
@RequestMapping("/service/scene/edit")
|
|
public class TIetaEditController extends BaseController{
|
|
public class TIetaEditController extends BaseController{
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private TietaEntityClient tietaEntityClient;
|
|
private TietaEntityClient tietaEntityClient;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SystemSecretService systemSecretService;
|
|
|
|
+ @Value("${gateway.key:6#dPz>3F}")
|
|
|
|
+ private String gatewayKey;
|
|
|
|
+ @Value("${tieta.checkToken.syscode}")
|
|
|
|
+ private String syscode;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CustomHttpClient customHttpClient;
|
|
|
|
+ @Value("${gateway.url}")
|
|
|
|
+ private String gatewayUrl;
|
|
|
|
|
|
@GetMapping("getStationResource")
|
|
@GetMapping("getStationResource")
|
|
public ResultData getStationResource(String stationCode){
|
|
public ResultData getStationResource(String stationCode){
|
|
- JSONObject stationResource = tietaEntityClient.getStationResource(stationCode);
|
|
|
|
|
|
+
|
|
|
|
+ List<SystemSecret> list = systemSecretService.list(new LambdaQueryWrapper<SystemSecret>().orderByDesc(SystemSecret::getUpdatedat));
|
|
|
|
+
|
|
|
|
+ String APPID = syscode;
|
|
|
|
+ String APPUUID = UUID.randomUUID().toString();
|
|
|
|
+ String secret = ThreeDESUtil.decode(list.get(0).getAppsecret(), gatewayKey);
|
|
|
|
+ String APPUUIDCRPT = ThreeDESUtil.encode(APPUUID, secret);
|
|
|
|
+ String ACCESSIPADDR = InetAddress.getLoopbackAddress().getHostAddress();
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("APPID",APPID);
|
|
|
|
+ headers.put("APPUUID",APPUUID);
|
|
|
|
+ headers.put("APPUUIDCRPT",APPUUIDCRPT);
|
|
|
|
+ headers.put("ACCESSIPADDR",ACCESSIPADDR);
|
|
|
|
+
|
|
|
|
+ String url = gatewayUrl + "/CHINATOWER-RES-ENTITY-SERVICE/station/page/lower/resource/" + stationCode;
|
|
|
|
+ JSONObject stationResource = customHttpClient.post(headers, url);
|
|
|
|
+// JSONObject stationResource = tietaEntityClient.getStationResource(headers, stationCode);
|
|
Integer resultCode = stationResource.getInteger("resultCode");
|
|
Integer resultCode = stationResource.getInteger("resultCode");
|
|
if(resultCode == null || resultCode != 0){
|
|
if(resultCode == null || resultCode != 0){
|
|
throw new BusinessException(-1, String.format("资源平台返回失败,resultCode:%d, resultMsg:%s", resultCode, stationResource.getString("resultMsg")));
|
|
throw new BusinessException(-1, String.format("资源平台返回失败,resultCode:%d, resultMsg:%s", resultCode, stationResource.getString("resultMsg")));
|
|
}
|
|
}
|
|
JSONArray jsonArray = stationResource.getJSONArray("data");
|
|
JSONArray jsonArray = stationResource.getJSONArray("data");
|
|
List<Map<String, Object>> collect = jsonArray.stream().map(v -> {
|
|
List<Map<String, Object>> collect = jsonArray.stream().map(v -> {
|
|
- LinkedHashMap<String, Object> resource = (LinkedHashMap) v;
|
|
|
|
|
|
+ JSONObject resource = (JSONObject) v;
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
map.put("ENTITY_ID", resource.get("ENTITY_ID"));
|
|
map.put("ENTITY_ID", resource.get("ENTITY_ID"));
|
|
map.put("ENTITY_NAME", resource.get("ENTITY_NAME"));
|
|
map.put("ENTITY_NAME", resource.get("ENTITY_NAME"));
|