diff --git a/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java b/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java index 231944e..5dfc3ec 100644 --- a/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java +++ b/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java @@ -1,14 +1,12 @@ package aiyh.utils.httpUtil.cushttpclasses; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletInputStream; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; +import javax.servlet.*; +import javax.servlet.http.*; import java.io.BufferedReader; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.Principal; +import java.util.Collection; import java.util.Enumeration; import java.util.Locale; import java.util.Map; @@ -95,6 +93,11 @@ public class CusHttpServletRequest implements HttpServletRequest { return null; } + @Override + public String changeSessionId() { + return null; + } + @Override public String getRequestedSessionId() { return null; @@ -143,6 +146,36 @@ public class CusHttpServletRequest implements HttpServletRequest { return false; } + @Override + public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException { + return false; + } + + @Override + public void login(String s, String s1) throws ServletException { + + } + + @Override + public void logout() throws ServletException { + + } + + @Override + public Collection getParts() throws IOException, ServletException { + return null; + } + + @Override + public Part getPart(String s) throws IOException, ServletException { + return null; + } + + @Override + public T upgrade(Class aClass) throws IOException, ServletException { + return null; + } + @Override public String getProtocol() { return null; @@ -218,6 +251,11 @@ public class CusHttpServletRequest implements HttpServletRequest { return 0; } + @Override + public long getContentLengthLong() { + return 0; + } + @Override public String getContentType() { return null; @@ -271,4 +309,59 @@ public class CusHttpServletRequest implements HttpServletRequest { public String getRealPath(String s) { return null; } + + @Override + public int getRemotePort() { + return 0; + } + + @Override + public String getLocalName() { + return null; + } + + @Override + public String getLocalAddr() { + return null; + } + + @Override + public int getLocalPort() { + return 0; + } + + @Override + public ServletContext getServletContext() { + return null; + } + + @Override + public AsyncContext startAsync() throws IllegalStateException { + return null; + } + + @Override + public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException { + return null; + } + + @Override + public boolean isAsyncStarted() { + return false; + } + + @Override + public boolean isAsyncSupported() { + return false; + } + + @Override + public AsyncContext getAsyncContext() { + return null; + } + + @Override + public DispatcherType getDispatcherType() { + return null; + } } diff --git a/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java b/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java index 6a7f2c3..3b8beb4 100644 --- a/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java +++ b/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java @@ -5,8 +5,10 @@ import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSONObject; import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil; @@ -16,8 +18,10 @@ import javax.servlet.http.HttpServletResponse; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,9 +44,9 @@ public class GetExchangeRate { @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public String exchangeRate(@Context HttpServletRequest request, - @Context HttpServletResponse response, - @RequestBody Map params){ + @Context HttpServletResponse response){ try { + Map params = parseBody(request); if(eySeconddevUtil == null){ eySeconddevUtil = new EYSeconddevUtil(); } @@ -101,4 +105,25 @@ public class GetExchangeRate { } } + private Map parseBody(HttpServletRequest request) { + try { + InputStream inputStream = request.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder requestBody = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + requestBody.append(line); + } + ObjectMapper objectMapper = new ObjectMapper(); + Map body = objectMapper.readValue(requestBody.toString(), Map.class); + if(MapUtils.isEmpty(body)){ + throw new CustomerException("parse body map is empty!"); + } + return body; + }catch (Exception e){ + throw new CustomerException("解析请求体json error : " + e.getMessage()); + } + } + + } diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java index 4e23cda..024f20d 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java @@ -2,6 +2,8 @@ package com.api.xuanran.wang.xk_hospital.data_async.controller; import aiyh.utils.ApiResult; import aiyh.utils.Util; +import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService; +import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl; import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.log4j.Logger; @@ -23,19 +25,23 @@ public class CommonDataAsyncController { private final Logger logger = Util.getLogger(); + private final XkHospitalCommonDataAsyncService service = new XkHospitalCommonDataAsyncServiceImpl(); + @POST - @Path("/{configId}}") + @Path("/{type}/{configId}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public String async(@Context HttpServletRequest request, - @Context HttpServletResponse response, - @PathParam("configId") String configId, - @RequestBody Map params){ + @Context HttpServletResponse response, + @PathParam("configId") String configId, + @PathParam("type") String type, + @RequestBody Map params){ try { - return ""; + service.async(configId, type, params); + return ApiResult.successNoData(); }catch (Exception e){ logger.error("CommonDataAsyncController error : " + e.getMessage()); - Util.logErrorStr(e, logger); + Util.logErrorStr(e); return ApiResult.error("数据同步失败! [ " + e.getMessage() + " ]"); } }