12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package thyyxxk.webserver.service.jianyanjiekou;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.dtflys.forest.Forest;
- import lombok.Data;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Service;
- import thyyxxk.webserver.config.exception.BizException;
- import thyyxxk.webserver.config.exception.ExceptionEnum;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.examinations.inspections.consts.ResponseMode;
- import thyyxxk.webserver.entity.jianyanjiekou.QueryNormal;
- import thyyxxk.webserver.utils.ResultVoUtil;
- import thyyxxk.webserver.utils.StringUtil;
- @Service
- @Slf4j
- public class JianYanJieKouService {
- @Data
- public static class Res {
- private Boolean code;
- private String message;
- private Integer returnNumber;
- private String data;
- }
- @Data
- public static class ResItems {
- private String paperSize;
- private String imgData;
- }
- private Res postHttp(String url, JSONObject data) {
- try {
- String API_IP = "http://172.16.32.178/apis";
- Res res = Forest.post(API_IP + url)
- .addHeader("Content-Type", "application/json")
- .addBody(data)
- .setRetryEnabled(false)
- .setConnectTimeout(2000)
- .setReadTimeout(2000)
- .execute(Res.class);
- if (res == null) {
- throw new BizException(ExceptionEnum.NETWORK_ERROR, "接口调用失败。");
- }
- return res;
- } catch (Exception e) {
- throw new BizException(ExceptionEnum.NETWORK_ERROR, e.getMessage());
- }
- }
- public ResultVo<JSONArray> getNormal(QueryNormal param) {
- JSONObject js = new JSONObject();
- js.put("departId", "");
- js.put("patientNum", param.getPatientNum());
- js.put("patientNumType", "InPatient");
- if (StringUtil.isBlank(param.getStartDate())) {
- return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "请先选择时间。");
- }
- js.put("startDate", param.getStartDate());
- js.put("endDate", param.getEndDate());
- Res res = postHttp("/third/report/query/normal", js);
- if (res.getCode()) {
- JSONObject data = JSONObject.parseObject(res.getData());
- return ResultVoUtil.success(data.getJSONArray("items"));
- }
- return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, res.getMessage());
- }
- public ResultVo<JSONObject> getDetail(String reportId) {
- JSONObject js = new JSONObject();
- js.put("reportId", reportId);
- js.put("responseMode", ResponseMode.Json);
- Res res = postHttp("/third/report/query/detail", js);
- if (res.getCode()) {
- return ResultVoUtil.success(JSONObject.parseObject(res.getData()));
- }
- return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, res.getMessage());
- }
- public JSONObject getImage(String reportId) {
- JSONObject js = new JSONObject();
- js.put("reportId", reportId);
- js.put("responseMode", ResponseMode.Json);
- Res res = postHttp("/third/report/query/pic", js);
- if (res.getCode()) {
- return JSONObject.parseObject(res.getData());
- }
- return null;
- }
- }
|