diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/dmpMonitor/request/HttpRequestRds.java b/eladmin-system/src/main/java/me/zhengjie/modules/dmpMonitor/request/HttpRequestRds.java index 0275691..b1ab498 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/dmpMonitor/request/HttpRequestRds.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/dmpMonitor/request/HttpRequestRds.java @@ -2,12 +2,15 @@ package me.zhengjie.modules.dmpMonitor.request; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import lombok.extern.slf4j.Slf4j; import me.zhengjie.modules.dmpMonitor.domian.DmpMonitorNumDto; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import java.util.HashMap; import java.util.Map; /** @@ -18,6 +21,31 @@ import java.util.Map; @Component public class HttpRequestRds { + @Value("${callback.url}") + private String URL; + + public Map generateDmp(String tag, Integer type) { + String reqUrl = URL + "/generate/dmp?" + "tag=" + tag + "&type=" + type; + String getResult = HttpUtil + .createGet(reqUrl) + .execute() + .charset("utf-8") + .body(); + JSONObject jsonObject = JSONUtil.parseObj(getResult); + String status= jsonObject.get("status").toString(); + + Map map = new HashMap<>(); + map.put("status",status); + if (status.equals("1")){ + String msg = jsonObject.get("msg").toString(); + map.put("data",msg); + }else{ + String data = jsonObject.get("data").toString(); + map.put("data",data); + } + return map; + } + /** * 请求大数据平台 * diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/dmpMonitor/rest/StatisticsDmpController.java b/eladmin-system/src/main/java/me/zhengjie/modules/dmpMonitor/rest/StatisticsDmpController.java index 5e2b075..5e3fc0c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/dmpMonitor/rest/StatisticsDmpController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/dmpMonitor/rest/StatisticsDmpController.java @@ -4,14 +4,18 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import me.zhengjie.annotation.Log; +import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.dmpMonitor.domian.DmpMonitorNumDto; +import me.zhengjie.modules.dmpMonitor.request.HttpRequestRds; import me.zhengjie.modules.dmpMonitor.service.StatisticsDmpService; +import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; +import java.util.prefs.BackingStoreException; /** @@ -23,7 +27,9 @@ import org.springframework.web.bind.annotation.RestController; @Api(tags = "dmp监测") @RequestMapping("/api/dmp") public class StatisticsDmpController { + private final StatisticsDmpService statisticsDmpService; + private final HttpRequestRds httpRequestRds; @Log("获取数目") @ApiOperation("导出数据") @@ -40,4 +46,20 @@ public class StatisticsDmpController { statisticsDmpService.sendEmail(conditionDto); return new ResponseEntity<>(HttpStatus.OK); } + + /** + * 生成DMP链接 + * @param tag + * @return + */ + @GetMapping("/generateDmp") + public ResponseEntity generateDmp(@RequestParam("tag") String tag, @RequestParam("type") Integer type){ + Map map = httpRequestRds.generateDmp(tag, type); + String status = map.get("status"); + String data = map.get("data"); + if (status.equals("1")){ + throw new BadRequestException(data); + } + return new ResponseEntity<>(data,HttpStatus.OK); + } } diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index 3fc0457..ac18ecf 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -64,3 +64,6 @@ upload: bucketName: hjrecording endpoint: oss-cn-shanghai.aliyuncs.com url: https://app.hjdata.com/api/dymaticform/channel/save? + +callback: + url: http://47.110.11.213:9191