Commit 277586cc authored by caotao's avatar caotao

户用光伏数据调用工具调整

parent 6e6b6493
...@@ -18,17 +18,16 @@ import java.util.HashMap; ...@@ -18,17 +18,16 @@ import java.util.HashMap;
@Component @Component
public class HouseholdPvUtils { public class HouseholdPvUtils {
private static HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl; @Autowired
private static HouseholdPvApiServiceImpl householdPvApiServiceImpl; private HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl;
@Autowired
private HouseholdPvApiServiceImpl householdPvApiServiceImpl;
public HouseholdPvUtils(HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl) {
this.householdPvProducerInfoServiceImpl = householdPvProducerInfoServiceImpl;
}
public static HashMap<String, Object> getHeaderByProducerCode(String code) { public HashMap<String, Object> getHeaderByProducerCode(String code) {
HashMap<String, Object> hashMap = new HashMap<>(); HashMap<String, Object> hashMap = new HashMap<>();
HashMap<String, String> hashMaphead = new HashMap<>(); HashMap<String, String> hashMaphead = new HashMap<>();
HouseholdPvProducerInfo householdPvProducerInfo = householdPvProducerInfoServiceImpl.queryForHouseholdPvProducerInfoByCode(code); HouseholdPvProducerInfo householdPvProducerInfo =this.householdPvProducerInfoServiceImpl.queryForHouseholdPvProducerInfoByCode(code);
String url = householdPvProducerInfo.getProdcerUrl() + householdPvProducerInfo.getTokenUrl(); String url = householdPvProducerInfo.getProdcerUrl() + householdPvProducerInfo.getTokenUrl();
hashMap.put("apiurl", householdPvProducerInfo.getProdcerUrl()); hashMap.put("apiurl", householdPvProducerInfo.getProdcerUrl());
if (PVProducerInfoEnum.GDW.getCode().equals(code)) { if (PVProducerInfoEnum.GDW.getCode().equals(code)) {
...@@ -58,9 +57,9 @@ public class HouseholdPvUtils { ...@@ -58,9 +57,9 @@ public class HouseholdPvUtils {
} }
return hashMap; return hashMap;
} }
public static String gerResponseByAPiID(Long seq){ public String gerResponseByAPiID(Long seq){
HouseholdPvApiDto householdPvApiDto = householdPvApiServiceImpl.queryBySeq(seq); HouseholdPvApiDto householdPvApiDto = this.householdPvApiServiceImpl.queryBySeq(seq);
HashMap<String,Object> producerInfo = HouseholdPvUtils.getHeaderByProducerCode(householdPvApiDto.getProducerId()); HashMap<String,Object> producerInfo = this.getHeaderByProducerCode(householdPvApiDto.getProducerId());
HashMap<String,String> headMap = (HashMap<String, String>) producerInfo.get("header"); HashMap<String,String> headMap = (HashMap<String, String>) producerInfo.get("header");
String respone=""; String respone="";
if(householdPvApiDto.getRequestMethod().equals("POST")){ if(householdPvApiDto.getRequestMethod().equals("POST")){
......
...@@ -33,9 +33,8 @@ import java.util.Map; ...@@ -33,9 +33,8 @@ import java.util.Map;
@RequestMapping(value = "/household-pv-api-test1") @RequestMapping(value = "/household-pv-api-test1")
public class HouseholdTestController { public class HouseholdTestController {
@Autowired @Autowired
private HouseholdPvApiServiceImpl householdPvApiServiceImpl; private HouseholdPvUtils householdPvUtils;
@Autowired
private HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl;
/** /**
* 新增户用光伏-厂商API haders * 新增户用光伏-厂商API haders
...@@ -46,18 +45,6 @@ public class HouseholdTestController { ...@@ -46,18 +45,6 @@ public class HouseholdTestController {
@PostMapping(value = "/gdwdemo") @PostMapping(value = "/gdwdemo")
@ApiOperation(httpMethod = "get", value = "固德威示例", notes = "固德威示例") @ApiOperation(httpMethod = "get", value = "固德威示例", notes = "固德威示例")
public String save(Long seq) throws IOException { public String save(Long seq) throws IOException {
HouseholdPvApiDto householdPvApiDto = householdPvApiServiceImpl.queryBySeq(seq); return householdPvUtils.gerResponseByAPiID(seq);
HashMap<String,Object> producerInfo = HouseholdPvUtils.getHeaderByProducerCode(householdPvApiDto.getProducerId());
HashMap<String,String> headMap = (HashMap<String, String>) producerInfo.get("header");
String respone="";
if(householdPvApiDto.getRequestMethod().equals("POST")){
respone = HttpUtil.createPost(producerInfo.get("apiurl")+householdPvApiDto.getApiUrl()).headerMap(headMap,true).
body(householdPvApiDto.getParamInfo()).execute().body();
}
if(householdPvApiDto.getRequestMethod().equals("GET")){
respone = HttpUtil.createGet(producerInfo.get("apiurl")+householdPvApiDto.getApiUrl()).headerMap(headMap,true).
body(householdPvApiDto.getParamInfo()).execute().body();
}
return respone;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment