|
|
@@ -8,17 +8,21 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.hdkj.lt.core.rest.service.IRemoteCallService;
|
|
|
import com.hdkj.lt.modle.dto.recon.*;
|
|
|
import com.hdkj.lt.modle.po.*;
|
|
|
+import com.hdkj.lt.modle.vo.recon.ReconSaveResultVO;
|
|
|
import com.hdkj.lt.si.dao.*;
|
|
|
import com.hdkj.lt.si.service.recon.ReconResultService;
|
|
|
import com.hdkj.lt.si.service.remote.impl.ReconRemoteCallServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.StreamUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.OffsetDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
@@ -49,14 +53,15 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
private static final DateTimeFormatter ISO_OFFSET = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
|
|
|
|
private static final String REQUEST_URI = "http://25.91.249.219:18080/api/reconfiguration";
|
|
|
+
|
|
|
@Resource(type = ReconRemoteCallServiceImpl.class)
|
|
|
private IRemoteCallService remoteCallService;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void saveReconResult(String eventId, List<String> feederIds) {
|
|
|
+ public ReconSaveResultVO saveReconResult(String eventId, Map<String, Object> params) {
|
|
|
// 1. 构造请求参数
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
// params.put("county_sid", "honghu");
|
|
|
// params.put("county_name", "honghu");
|
|
|
// params.put("problem_feeder_ids", Collections.singletonList("15DKX-20690"));
|
|
|
@@ -66,12 +71,8 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
Object data = remoteCallService.call(REQUEST_URI, HttpMethod.POST, params, Object.class);
|
|
|
str = JSON.toJSONString(data);
|
|
|
|
|
|
- // 3. 解析返回的JSON数据
|
|
|
-// try {
|
|
|
+ // 2. 解析返回的JSON数据
|
|
|
// str = StreamUtils.copyToString(new ClassPathResource("1.txt").getInputStream(), StandardCharsets.UTF_8);
|
|
|
-// } catch (IOException e) {
|
|
|
-// throw new RuntimeException("读取算法响应样本 1.txt 失败", e);
|
|
|
-// }
|
|
|
|
|
|
JsonNode root = OM.readTree(str);
|
|
|
log.info("重构方案接口返回参数{}",str);
|
|
|
@@ -134,6 +135,12 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
counts.put("metrics", 1);
|
|
|
}
|
|
|
log.info("重构方案counts:{}", JSON.toJSONString(counts));
|
|
|
+ ReconSaveResultVO vo = new ReconSaveResultVO();
|
|
|
+ vo.setSuccess(true);
|
|
|
+ vo.setMainId(resultId);
|
|
|
+ vo.setEventId(main.getEventId());
|
|
|
+ vo.setCounts(counts);
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
// ==================== 构建主表 ====================
|