Commit c4dfa4b6 authored by 张欣's avatar 张欣

救助信息接口xml转json

parent a9966def
package com.mth.requestsecret.controller; package com.mth.requestsecret.controller;
import com.alibaba.fastjson.JSONObject;
import com.mth.requestsecret.vo.shuguanjuvo.*; import com.mth.requestsecret.vo.shuguanjuvo.*;
import com.mth.requestsecret.service.RestTemplateService; import com.mth.requestsecret.service.RestTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.DocumentException;
import org.json.XML;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
* 纪委智慧监督平台接口 * 纪委智慧监督平台接口
* *
...@@ -16,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -16,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
* @date 2020/7/13 * @date 2020/7/13
*/ */
@RestController @RestController
@Slf4j
public class RequestController { public class RequestController {
@Autowired @Autowired
...@@ -1026,16 +1035,36 @@ public class RequestController { ...@@ -1026,16 +1035,36 @@ public class RequestController {
* @return * @return
*/ */
@PostMapping("/dUzfwd0e86Z00oc4") @PostMapping("/dUzfwd0e86Z00oc4")
public ResponseEntity<String> dUzfwd0e86Z00oc4(BaseParamVO param) { public ResponseEntity<String> dUzfwd0e86Z00oc4(BaseParamVO param) throws DocumentException {
// api签名 // api签名
String apiMethod = "dUzfwd0e86Z00oc4.action"; String apiMethod = "dUzfwd0e86Z00oc4.action";
// api参数 // api参数
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
paramMap.add("dsfz", param.getIdCard()); paramMap.add("dsfz", param.getIdCard());
paramMap.add("additional", param.getAdditional()); paramMap.add("additional", param.getAdditional());
return restTemplateService.commonSendRequest(paramMap, apiMethod); ResponseEntity<String> responseEntity = restTemplateService.commonSendRequest(paramMap, apiMethod);
String body = responseEntity.getBody();
log.info("救助信息接口responseEntity的body为:"+body);
JSONObject jObject1 = JSONObject.parseObject(body);
if(jObject1 != null){
String datas1 = jObject1.get("datas").toString();
log.info("救助信息接口外层datas为:"+datas1);
JSONObject jSONObject2 = JSONObject.parseObject(datas1);
if(jSONObject2 != null){
String tempDatas2 = jSONObject2.get("datas").toString();
log.info("救助信息接口里层datas为:"+tempDatas2);
org.json.JSONObject xmlJSONObj = XML.toJSONObject(tempDatas2);
return ResponseEntity
.status(HttpStatus.OK)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.body(xmlJSONObj.toString());
}
}
return responseEntity;
} }
/** /**
* 六十一.浙江杭州国土局不动产权属证书信息查询 * 六十一.浙江杭州国土局不动产权属证书信息查询
* *
......
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