|
@@ -1,9 +1,12 @@
|
|
|
package com.sckw.slope.detection.service.api;
|
|
package com.sckw.slope.detection.service.api;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
+import com.sckw.core.model.constant.NumberConstant;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.OkHttpUtils;
|
|
import com.sckw.core.utils.OkHttpUtils;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
|
|
+import com.sckw.core.web.response.PhpResult;
|
|
|
|
|
+import com.sckw.slope.detection.model.dto.SystemDict;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -24,6 +27,7 @@ import java.util.Objects;
|
|
|
public class DetectionApiService {
|
|
public class DetectionApiService {
|
|
|
|
|
|
|
|
private String okHttpClientUrl = "http://10.10.10.220";
|
|
private String okHttpClientUrl = "http://10.10.10.220";
|
|
|
|
|
+ private String okHttpClientUrlTest = "http://10.10.10.185:9501";
|
|
|
|
|
|
|
|
public HttpResult toSaasPostDemo() {
|
|
public HttpResult toSaasPostDemo() {
|
|
|
OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(okHttpClientUrl + "/api/menu/getMenu");
|
|
OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(okHttpClientUrl + "/api/menu/getMenu");
|
|
@@ -84,4 +88,55 @@ public class DetectionApiService {
|
|
|
log.info("返回值->{}", sync);
|
|
log.info("返回值->{}", sync);
|
|
|
return HttpResult.ok(parse);
|
|
return HttpResult.ok(parse);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public PhpResult toSaasGetDict(String okHttpClientUrl, String address, Map<String, Object> paraBody, Map<String, String> paraPara) {
|
|
|
|
|
+ OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(okHttpClientUrl + address);
|
|
|
|
|
+// Map<String, Object> para = new HashMap<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(paraBody)) {
|
|
|
|
|
+ for (Map.Entry<String, Object> p : paraBody.entrySet()) {
|
|
|
|
|
+ //跳过非空参数
|
|
|
|
|
+ Object v = p.getValue();
|
|
|
|
|
+ String k = p.getKey();
|
|
|
|
|
+ if (Objects.isNull(v)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+// okHttpUtils.addBodyPara(k, JSONObject.toJSONString(v));
|
|
|
|
|
+ okHttpUtils.addBodyPara(k, v.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(paraPara)) {
|
|
|
|
|
+ paraPara.forEach(okHttpUtils::addPara);
|
|
|
|
|
+// for (Map.Entry<String, Object> p : paraPara.entrySet()) {
|
|
|
|
|
+// //跳过非空参数
|
|
|
|
|
+// Object v = p.getValue();
|
|
|
|
|
+// String k = p.getKey();
|
|
|
|
|
+// if (Objects.isNull(v)) {
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+// okHttpUtils.addPara(k, v.toString());
|
|
|
|
|
+// }
|
|
|
|
|
+ }
|
|
|
|
|
+ String sync;
|
|
|
|
|
+ try {
|
|
|
|
|
+ sync = okHttpUtils.addHeader("adminid", "4f98414ac8411d85b45146659780c4aa6e104347").get().sync();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("http get error ", e.getCause());
|
|
|
|
|
+ throw new RuntimeException("http get error 异常!");
|
|
|
|
|
+ }
|
|
|
|
|
+ PhpResult result = new PhpResult();
|
|
|
|
|
+ Map<String, SystemDict> map = new HashMap(NumberConstant.SIXTEEN);
|
|
|
|
|
+ if (StringUtils.isNotBlank(sync)) {
|
|
|
|
|
+ result = JSONObject.parseObject(sync, PhpResult.class);
|
|
|
|
|
+ if (result.isStatus()) {
|
|
|
|
|
+ HashMap hashMap = JSONObject.parseObject(JSONObject.toJSONString(result.getData()), HashMap.class);
|
|
|
|
|
+ for (Object value : hashMap.values()) {
|
|
|
|
|
+ SystemDict systemDict = JSONObject.parseObject(value.toString(), SystemDict.class);
|
|
|
|
|
+ map.put(systemDict.getValue(), systemDict);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("返回值->{}", sync);
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|