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

综窗对接事项查询增加参数

parent ab73da49
......@@ -12,4 +12,6 @@ public class Material {
private String uploadFileName;
/**材料内容base64 */
private String materialContent;
/**材料文件地址 */
private String materialFilePath;
}
package com.mortals.xhx.module.sst.pdu;
import lombok.Data;
/**
* 综窗可受理事项查询参数
*/
@Data
public class SyntheticalMatterQuery {
/**当前页*/
private Integer currentPage;
/**每页条数*/
private Integer pageSize;
/**事项面向对象O/P,O是法人P是个人 */
private String eventObjectType;
/** 事项是否纳入通办。N/Y */
private String crossFlag;
/**事项名称,模糊查找 */
private String implementName;
}
package com.mortals.xhx.module.sst.web;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.Method;
......@@ -8,17 +9,26 @@ 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.exception.AppException;
import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.util.StringUtils;
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 com.mortals.xhx.module.matter.service.UserMatterApplyService;
import com.mortals.xhx.module.sst.pdu.*;
import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -31,6 +41,13 @@ import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_CWS_HTTP_URL;
@RestController
public class SyntheticalController extends BaseJsonBodyController {
@Value("${upload.path}")
@Getter
private String filePath;
@Autowired
private UserMatterApplyService userMatterApplyService;
/**
* 查询可受理事项
* @param query
......@@ -38,7 +55,7 @@ public class SyntheticalController extends BaseJsonBodyController {
*/
@PostMapping({"api/event-implementation/list"})
@UnAuth
public String eventList(@RequestBody SyntheticalPdu query) {
public String eventList(@RequestBody SyntheticalMatterQuery 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();
......@@ -228,8 +245,14 @@ public class SyntheticalController extends BaseJsonBodyController {
Map<String, Object> model = new HashMap();
String busiDesc = "自助设备接件" ;
try {
doFileToBase64(query);
resp = doPost(url, JSONObject.toJSONString(query));
this.recordSysLog(this.request, busiDesc + " 【成功】");
JSONObject jsonObject = JSONObject.parseObject(resp);
if(jsonObject.getIntValue("code")==1){
}
} catch (Exception e) {
this.doException(this.request, busiDesc + " 【异常】", model, e);
Rest<Object> ret = new Rest();
......@@ -240,6 +263,30 @@ public class SyntheticalController extends BaseJsonBodyController {
return resp;
}
/**
* 将上传文件地址转换为Base64
* @param pdu
*/
private void doFileToBase64(AcceptHandlingPdu pdu){
if(ObjectUtil.isNotEmpty(pdu)){
List<Material> materials = pdu.getMaterials();
if(CollectionUtils.isNotEmpty(materials)){
String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/";
for(Material item:materials){
String filePath = rootPath + item.getMaterialFilePath();
try {
Path path = Paths.get(filePath); // 替换为实际文件路径
byte[] fileBytes = Files.readAllBytes(path);
String base64EncodedString = Base64.getEncoder().encodeToString(fileBytes);
item.setMaterialContent(base64EncodedString);
} catch (Exception e) {
throw new AppException(e.getMessage());
}
}
}
}
}
private String doPost(String url,String body) throws Exception{
HttpRequest httpRequest = HttpRequest.post(url);
httpRequest.body(body);
......@@ -254,29 +301,40 @@ public class SyntheticalController extends BaseJsonBodyController {
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","2e4575157ed27dbc7330b1595207b49c");
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);
// 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","2e4575157ed27dbc7330b1595207b49c");
// 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();
// }
// }
} catch (Exception e) {
e.printStackTrace();
}
}
// public static void main(String[] args) {
// try {
// Path filePath = Paths.get("D:\\home\\mortals\\app\\aaa.jpg"); // 替换为实际文件路径
// byte[] fileBytes = Files.readAllBytes(filePath);
// String base64EncodedString = Base64.getEncoder().encodeToString(fileBytes);
// System.out.println(base64EncodedString);
// } 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