Commit 277586cc authored by caotao's avatar caotao

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

parent 6e6b6493
......@@ -18,17 +18,16 @@ import java.util.HashMap;
@Component
public class HouseholdPvUtils {
private static HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl;
private static HouseholdPvApiServiceImpl householdPvApiServiceImpl;
@Autowired
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, String> hashMaphead = new HashMap<>();
HouseholdPvProducerInfo householdPvProducerInfo = householdPvProducerInfoServiceImpl.queryForHouseholdPvProducerInfoByCode(code);
HouseholdPvProducerInfo householdPvProducerInfo =this.householdPvProducerInfoServiceImpl.queryForHouseholdPvProducerInfoByCode(code);
String url = householdPvProducerInfo.getProdcerUrl() + householdPvProducerInfo.getTokenUrl();
hashMap.put("apiurl", householdPvProducerInfo.getProdcerUrl());
if (PVProducerInfoEnum.GDW.getCode().equals(code)) {
......@@ -58,9 +57,9 @@ public class HouseholdPvUtils {
}
return hashMap;
}
public static String gerResponseByAPiID(Long seq){
HouseholdPvApiDto householdPvApiDto = householdPvApiServiceImpl.queryBySeq(seq);
HashMap<String,Object> producerInfo = HouseholdPvUtils.getHeaderByProducerCode(householdPvApiDto.getProducerId());
public String gerResponseByAPiID(Long seq){
HouseholdPvApiDto householdPvApiDto = this.householdPvApiServiceImpl.queryBySeq(seq);
HashMap<String,Object> producerInfo = this.getHeaderByProducerCode(householdPvApiDto.getProducerId());
HashMap<String,String> headMap = (HashMap<String, String>) producerInfo.get("header");
String respone="";
if(householdPvApiDto.getRequestMethod().equals("POST")){
......
......@@ -33,9 +33,8 @@ import java.util.Map;
@RequestMapping(value = "/household-pv-api-test1")
public class HouseholdTestController {
@Autowired
private HouseholdPvApiServiceImpl householdPvApiServiceImpl;
@Autowired
private HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl;
private HouseholdPvUtils householdPvUtils;
/**
* 新增户用光伏-厂商API haders
......@@ -46,18 +45,6 @@ public class HouseholdTestController {
@PostMapping(value = "/gdwdemo")
@ApiOperation(httpMethod = "get", value = "固德威示例", notes = "固德威示例")
public String save(Long seq) throws IOException {
HouseholdPvApiDto householdPvApiDto = householdPvApiServiceImpl.queryBySeq(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;
return householdPvUtils.gerResponseByAPiID(seq);
}
}
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