Commit b12d2a46 authored by 廖旭伟's avatar 廖旭伟

综窗对接

parent 069a08dd
......@@ -32,5 +32,9 @@ public final class Constant {
* 服务器http
*/
public final static String PARAM_SERVER_PHP_HTTP_URL = "server_php_http_url";
/**
* 综窗服务器http
*/
public final static String PARAM_SERVER_CWS_HTTP_URL = "server_cws_http_url";
}
package com.mortals.xhx.module.sst.pdu;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* 自助设备接件
*/
@Data
public class AcceptHandlingPdu {
/** 申请人信息 */
private ApplicantLegal applicantLegal;
/** 事项信息 */
private List<Map<String,String>> handlings;
/** 法人信息 */
private LegalProxy legalProxy;
/**表单信息,办件要素这个接口获取的需要填写的表单信息*/
private Map<String,String> infoMap;
/** 情形项id集合 */
private List<String> itemsIds;
/** 材料 */
private List<Material> materials;
}
package com.mortals.xhx.module.sst.pdu;
import lombok.Data;
@Data
public class ApplicantLegal {
/** 申请人证件号 */
private String applicantIdNumber;
/** 申请人姓名 */
private String applicantName;
/** 证件类型:身份证办理默认111 */
private String documentId;
/** 申请人电话 */
private String phone;
}
package com.mortals.xhx.module.sst.pdu;
import lombok.Data;
@Data
public class LegalProxy {
/** 法人证件号 */
private String legalIdNumber;
/** 法人姓名 */
private String legalName;
/** 证件类型:身份证办理默认111 */
private String documentId;
}
package com.mortals.xhx.module.sst.pdu;
import lombok.Data;
@Data
public class Material {
/**材料id */
private String materialId;
/**材料提交方式 */
private String materialForm;
/**材料原名 */
private String uploadFileName;
/**材料内容base64 */
private String materialContent;
}
package com.mortals.xhx.module.sst.pdu;
import lombok.Data;
import java.util.List;
/**
* 综窗对接
*/
@Data
public class SyntheticalPdu {
/** 事项id */
private String eventId;
/** 事项对应的情形id */
private List<String> itemsIds;
/** 事项id */
private List<String> eventIdList;
/** 字典 */
private String dict;
}
package com.mortals.xhx.module.sst.web;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.Method;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.module.sst.pdu.AcceptHandlingPdu;
import com.mortals.xhx.module.sst.pdu.SyntheticalPdu;
import com.mortals.xhx.module.sst.pdu.TerminalPdu;
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 java.net.HttpCookie;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_CWS_HTTP_URL;
/**
* 综窗对接
*/
@RestController
@RequestMapping("complex")
public class SyntheticalController extends BaseJsonBodyController {
/**
* 查询可受理事项
* @param query
* @return
*/
@PostMapping({"api/event-implementation/list"})
@UnAuth
public String eventList(@RequestBody SyntheticalPdu query) {
String url = GlobalSysInfo.getParamValue(PARAM_SERVER_CWS_HTTP_URL, "http://8.136.255.30:1086");
url += "/complex/api/event-implementation/list";
JSONObject jsonObject = new JSONObject();
String resp = null;
Map<String, Object> model = new HashMap();
String busiDesc = "查询可受理事项" ;
try {
resp = doPost(url, jsonObject.toJSONString());
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
ret.setCode(-1);
ret.setMsg(busiDesc + " 【异常】");
resp = JSON.toJSONString(ret);
}
return resp;
}
/**
* 查询事项详情
* @param query
* @return
*/
@PostMapping({"api/event-implementation/get-by-id"})
@UnAuth
public String eventInfo(@RequestBody SyntheticalPdu query) {
String url = GlobalSysInfo.getParamValue(PARAM_SERVER_CWS_HTTP_URL, "http://8.136.255.30:1086");
url += "/complex/api/event-implementation/get-by-id";
String resp = null;
Map<String, Object> model = new HashMap();
String busiDesc = "查询事项详情" ;
try {
resp = HttpUtil.doPost(url, JSONObject.toJSONString(query));
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
ret.setCode(-1);
ret.setMsg(busiDesc + " 【异常】");
resp = JSON.toJSONString(ret);
}
return resp;
}
/**
* 查询事项情形
* @param query
* @return
*/
@PostMapping({"api/bus-situation-material/getSituationMaterialTreeByEventIds"})
@UnAuth
public String getSituationMaterialTreeByEventIds(@RequestBody SyntheticalPdu query) {
String url = GlobalSysInfo.getParamValue(PARAM_SERVER_CWS_HTTP_URL, "http://8.136.255.30:1086");
url += "/complex/api/bus-situation-material/getSituationMaterialTreeByEventIds";
String resp = null;
Map<String, Object> model = new HashMap();
String busiDesc = "查询事项情形" ;
try {
resp = HttpUtil.doPost(url, JSONObject.toJSONString(query));
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
ret.setCode(-1);
ret.setMsg(busiDesc + " 【异常】");
resp = JSON.toJSONString(ret);
}
return resp;
}
/**
* 根据事项EventId查询办理事项材料
* @param query
* @return
*/
@PostMapping({"api/material/findList"})
@UnAuth
public String findMaterialList(@RequestBody SyntheticalPdu query) {
String url = GlobalSysInfo.getParamValue(PARAM_SERVER_CWS_HTTP_URL, "http://8.136.255.30:1086");
url += "/complex/api/material/findList";
String resp = null;
Map<String, Object> model = new HashMap();
String busiDesc = "根据事项EventId查询办理事项材料" ;
try {
resp = HttpUtil.doPost(url, JSONObject.toJSONString(query));
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
ret.setCode(-1);
ret.setMsg(busiDesc + " 【异常】");
resp = JSON.toJSONString(ret);
}
return resp;
}
/**
* 根据事项情形查询办理事项材料
* @param query
* @return
*/
@PostMapping({"api/consulting-service/getMaterialByEventAndSituation"})
@UnAuth
public String getMaterialByEventAndSituation(@RequestBody SyntheticalPdu query) {
String url = GlobalSysInfo.getParamValue(PARAM_SERVER_CWS_HTTP_URL, "http://8.136.255.30:1086");
url += "/complex/api/consulting-service/getMaterialByEventAndSituation";
String resp = null;
Map<String, Object> model = new HashMap();
String busiDesc = "根据事项情形查询办理事项材料" ;
try {
resp = HttpUtil.doPost(url, JSONObject.toJSONString(query));
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
ret.setCode(-1);
ret.setMsg(busiDesc + " 【异常】");
resp = JSON.toJSONString(ret);
}
return resp;
}
/**
* 获取办件要素
* @param query
* @return
*/
@PostMapping({"api/event-implementation/getDynamicFormByEventIds"})
@UnAuth
public String getDynamicFormByEventIds(@RequestBody SyntheticalPdu query) {
String url = GlobalSysInfo.getParamValue(PARAM_SERVER_CWS_HTTP_URL, "http://8.136.255.30:1086");
url += "/complex/api/event-implementation/getDynamicFormByEventIds";
String resp = null;
Map<String, Object> model = new HashMap();
String busiDesc = "获取办件要素" ;
try {
resp = HttpUtil.doPost(url, JSONObject.toJSONString(query));
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
ret.setCode(-1);
ret.setMsg(busiDesc + " 【异常】");
resp = JSON.toJSONString(ret);
}
return resp;
}
/**
* 查询字典
* @param query
* @return
*/
@PostMapping({"api/common/queryDict"})
@UnAuth
public String queryDict(@RequestBody SyntheticalPdu query) {
String url = GlobalSysInfo.getParamValue(PARAM_SERVER_CWS_HTTP_URL, "http://8.136.255.30:1086");
url += "/complex/api/common/queryDict";
String resp = null;
Map<String, Object> model = new HashMap();
String busiDesc = "查询字典" ;
try {
resp = HttpUtil.doPost(url, JSONObject.toJSONString(query));
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
ret.setCode(-1);
ret.setMsg(busiDesc + " 【异常】");
resp = JSON.toJSONString(ret);
}
return resp;
}
/**
* 自助设备接件
* @param query
* @return
*/
@PostMapping({"api/self-device-info/acceptHandling"})
@UnAuth
public String acceptHandling(@RequestBody AcceptHandlingPdu query) {
String url = GlobalSysInfo.getParamValue(PARAM_SERVER_CWS_HTTP_URL, "http://8.136.255.30:1086");
url += "/complex/api/self-device-info/acceptHandling";
String resp = null;
Map<String, Object> model = new HashMap();
String busiDesc = "自助设备接件" ;
try {
resp = HttpUtil.doPost(url, JSONObject.toJSONString(query));
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
ret.setCode(-1);
ret.setMsg(busiDesc + " 【异常】");
resp = JSON.toJSONString(ret);
}
return resp;
}
private String doPost(String url,String body) throws Exception{
HttpRequest httpRequest = HttpRequest.post(url);
httpRequest.body(body);
HttpResponse execute = httpRequest.execute();
// 6. 解析这个http响应类,可以获取到响应主体、cookie、是否请求成功等信息
// boolean ok = execute.isOk(); // 是否请求成功 判断依据为:状态码范围在200~299内
// System.out.println(ok);
// List<HttpCookie> cookies = execute.getCookies();// 获取所有cookie
// cookies.forEach(System.out::println); // 如果为空不会遍历的
String resp = execute.body(); // 获取响应主体
return resp;
}
public static void main(String[] args){
String url = "http://8.136.255.30:1086/complex/api/event-implementation/get-by-id";
JSONObject jsonObject=new JSONObject();
System.out.println(jsonObject.toJSONString());
jsonObject.put("eventId","852dcb2bb1aa70255871f75cf4868fa7");
String resp = null;
Map<String, Object> model = new HashMap();
HashMap<String, String> paramsMap = new HashMap<>();
try {
HttpRequest httpRequest = HttpRequest.post(url);
httpRequest.body(jsonObject.toJSONString());
HttpResponse execute = httpRequest.execute();
// 6. 解析这个http响应类,可以获取到响应主体、cookie、是否请求成功等信息
boolean ok = execute.isOk(); // 是否请求成功 判断依据为:状态码范围在200~299内
System.out.println(ok);
List<HttpCookie> cookies = execute.getCookies();// 获取所有cookie
cookies.forEach(System.out::println); // 如果为空不会遍历的
String body = execute.body(); // 获取响应主体
System.out.println(body);
} catch (Exception e) {
e.printStackTrace();
}
}
}
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