|
@ -12,17 +12,23 @@ import com.yihu.hos.resource.viewModel.SQLResponResult;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.OutputStream;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.io.Writer;
|
|
|
|
|
|
/**
|
|
|
* Created by chenweida on 2016/1/27.
|
|
|
* EHR平台应用 REST请求
|
|
|
*/
|
|
|
@RestController
|
|
|
@Controller
|
|
|
@RequestMapping("/gateway")
|
|
|
public class GatewayControl {
|
|
|
@Autowired
|
|
@ -43,8 +49,15 @@ public class GatewayControl {
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/transfer")
|
|
|
public Object transfer(HttpServletRequest request) {
|
|
|
public void transfer(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
request.setCharacterEncoding("UTF-8");
|
|
|
response.setContentType("application/json;charset=UTF-8");
|
|
|
Writer writer = response.getWriter();
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
String returnString = "";
|
|
|
|
|
|
boolean isSyn = false;//是否异步
|
|
|
String resultData = null;
|
|
|
RestRequsetResult restRequsetResult = new RestRequsetResult();
|
|
@ -72,22 +85,27 @@ public class GatewayControl {
|
|
|
resourceRestDetailModel.getPassword(),
|
|
|
JSONObject.fromObject(resourceRestDetailModel.getParam()),
|
|
|
resourceRestDetailModel.getType())).start();
|
|
|
return new SQLResponResult();
|
|
|
returnString = JSONObject.fromObject(new SQLResponResult()).toString();
|
|
|
} else {
|
|
|
resultData = getResultData(resourceRestDetailModel, restRequsetResult.getParam());
|
|
|
returnString = resultData;
|
|
|
}
|
|
|
return resultData;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
if (e instanceof EHRException) {
|
|
|
//我们自己定义的异常,业务出错
|
|
|
EHRException eHRException = (EHRException) e;
|
|
|
return RestResponseResult.getError(eHRException.getExceptionCode(), eHRException.getExceptionMessage());
|
|
|
returnString = JSONObject.fromObject(RestResponseResult.getError(eHRException.getExceptionCode(), eHRException.getExceptionMessage())).toString();
|
|
|
} else {
|
|
|
//系统的异常
|
|
|
return RestResponseResult.getError(EHRExceptionConstant.EHREXCEPTION_SYSTEMEXCEPTION, EHRExceptionConstant.EHREXCEPTION_SYSTEMEXCEPTION_MESSAGE);
|
|
|
returnString = JSONObject.fromObject(RestResponseResult.getError(EHRExceptionConstant.EHREXCEPTION_SYSTEMEXCEPTION, EHRExceptionConstant.EHREXCEPTION_SYSTEMEXCEPTION_MESSAGE)).toString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
writer.write(returnString);
|
|
|
writer.flush();
|
|
|
writer.close();
|
|
|
}
|
|
|
|
|
|
/**
|