Commit 716e4810 by wqc

残疾人接口

parent 84274b77
package com.zq.open.config;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfigurer {
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
}
package com.zq.open.controller.api;
import com.zq.common.utils.StringUtils;
import com.zq.open.service.DisabledService;
import com.zq.open.vo.BizContent;
import com.zq.open.vo.DisableRequestVo;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;
@Api(tags = "残疾人相关接口")
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/open/api/disabled")
public class DisabledApi {
private final DisabledService disabledService;
@Autowired
private RestTemplate restTemplate;
@PostMapping("/up")
public Object upload(@RequestBody BizContent bizContent) {
RestTemplate client = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
// 请勿轻易改变此提交方式,大部分的情况下,提交方式都是表单提交
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
// 封装参数,千万不要替换为Map与HashMap,否则参数无法传递
MultiValueMap<String, Object> params= new LinkedMultiValueMap<String, Object>();
// 也支持中文
params.add("access_key", "");
params.add("version", "1.0");
params.add("format", "json");
params.add("sign", "");
params.add("timestamp", String.valueOf(new Date().getTime()));
params.add("access_key", "mzb_gx_450000");
params.add("biz_content", bizContent);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(params, headers);
// 执行HTTP请求
ResponseEntity<String> response = client.exchange("https://zwxt.mca.gov.cn/fwjc_engine_int/rest/cjrfl_report_btdxlxxx", HttpMethod.POST, requestEntity, String.class);
// 输出结果
System.out.println(response.getBody());
return response.getBody();
// BizContent bizContent = requestVo.getBizContent();
// map.put("msg","成功");
// map.put("code","1");
// map.put("sub_msg","");
// map.put("sub_code","");
// ConcurrentHashMap<String,Object> bizMap = new ConcurrentHashMap<>();
// map.put("biz_data",bizMap);
// ConcurrentHashMap<String,Object> errorInfoMap = new ConcurrentHashMap<>();
// bizMap.put("WorkStatus",1);
// if (StringUtils.isBlank(bizContent.getAFDX0801())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0801","补贴对象类型名称不能为空!");
// } else if (StringUtils.isBlank(bizContent.getAXCP0004())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AXCP0004","补贴类型不能为空!");
//
// }else if (StringUtils.isBlank(bizContent.getAFDX0803())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0803","标准金额不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0804())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0804","备注不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0805())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0805","标准状态不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0806())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0806","省不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0807())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0807","市不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0808())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0808","县不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0810())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0810","启用月份不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0814())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0814","提标扩面不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0815())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0815","发放类型不能为空!");
// }else if (StringUtils.isBlank(bizContent.getAFDX0816())) {
// bizMap.put("WorkStatus",2);
// bizMap.put("ErrorInfo",errorInfoMap);
// errorInfoMap.put("AFDX0816","区县民政录入人姓名不能为空!");
// }
// if (Integer.parseInt((String)bizMap.get("WorkStatus"))!=1) {
// return map;
// }
// String url = "https://59.255.186.1/yhbcp-engine_gov/rest/cjrfl_report_btdxlxxx";
// Map vo = restTemplate.postForObject(url, requestVo, Map.class);
// System.out.println(vo);
}
}
package com.zq.open.service;
import org.springframework.stereotype.Service;
@Service
public class DisabledService {
}
package com.zq.open.vo;
import lombok.Data;
@Data
public class BizContent {
private String AFDX0801;
private String AXCP0004;
private String AFDX0803;
private String AFDX0804;
private String AFDX0805;
private String AFDX0806;
private String AFDX0807;
private String AFDX0808;
private String AFDX0809;
private String AFDX0810;
private String AFDX0811;
private String AFDX0812;
private String AFDX0814;
private String AFDX0815;
private String AFDX0816;
private String AFDX0817;
private String AFDX0818;
}
package com.zq.open.vo;
import lombok.Data;
@Data
public class DisableRequestVo {
private String accessKey;
private String format;
private String requestId;
private String sign;
private String timestamp;
private String version;
private BizContent bizContent;
}
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