```
docs(release-notes): 添加住院护士站划价功能说明和发版记录 - 新增住院护士站划价服务流程说明文档,详细描述了从参数预处理到结果响应的五大阶段流程 - 包含耗材类医嘱和诊疗活动类医嘱的差异化处理逻辑 - 添加完整的发版内容记录,涵盖新增菜单功能和各模块优化点 - 记录了住院相关功能的新增和门诊业务流程的修复 ```
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.openhis.web.tencentJH.appservice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.openhis.web.doctorstation.dto.PatientInfoDto;
|
||||
import com.openhis.web.tencentJH.dto.CurrentDayEncounterTencentDto;
|
||||
import com.openhis.web.tencentJH.dto.PatientInfoTencentDto;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 腾讯医疗支付 Qmi支付 应用Service
|
||||
*/
|
||||
public interface ITencentAppService {
|
||||
|
||||
|
||||
IPage<CurrentDayEncounterTencentDto> getCurrentDayEncounter(String searchKey, Integer pageNo, Integer pageSize, HttpServletRequest request);
|
||||
/**
|
||||
* 查询就诊患者信息
|
||||
*
|
||||
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
|
||||
* @param searchKey 模糊查询关键字
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页多少条
|
||||
* @param pricingFlag 划价标记
|
||||
* @return 就诊患者信息
|
||||
*/
|
||||
IPage<PatientInfoTencentDto> getPatientInfo(PatientInfoTencentDto patientInfoDto, String searchKey, Integer pageNo,
|
||||
Integer pageSize, HttpServletRequest request, Integer pricingFlag);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.openhis.web.tencentJH.appservice.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.utils.AgeCalculatorUtil;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.common.enums.*;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.web.doctorstation.dto.PatientInfoDto;
|
||||
import com.openhis.web.tencentJH.dto.CurrentDayEncounterTencentDto;
|
||||
import com.openhis.web.tencentJH.dto.PatientInfoTencentDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.openhis.common.utils.EnumUtils;
|
||||
import com.openhis.web.tencentJH.appservice.ITencentAppService;
|
||||
import com.openhis.web.tencentJH.mapper.TencentAppMapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 交易QMI支付 应用实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TencentAppServiceImpl implements ITencentAppService {
|
||||
|
||||
@Resource
|
||||
private TencentAppMapper tencentAppMapper;
|
||||
|
||||
@Override
|
||||
public IPage<CurrentDayEncounterTencentDto> getCurrentDayEncounter(String searchKey, Integer pageNo, Integer pageSize, HttpServletRequest request) {
|
||||
// 构建查询条件
|
||||
QueryWrapper<CurrentDayEncounterTencentDto> queryWrapper = HisQueryUtils.buildQueryWrapper(null, searchKey,
|
||||
new HashSet<>(Arrays.asList("patient_name", "organization_name", "practitioner_name", "healthcare_name")),
|
||||
request);
|
||||
|
||||
IPage<CurrentDayEncounterTencentDto> currentDayEncounter = tencentAppMapper.getCurrentDayEncounter(
|
||||
new Page<>(pageNo, pageSize), EncounterClass.AMB.getValue(), EncounterStatus.IN_PROGRESS.getValue(),
|
||||
ParticipantType.ADMITTER.getCode(), ParticipantType.REGISTRATION_DOCTOR.getCode(), queryWrapper,
|
||||
ChargeItemContext.REGISTER.getValue(), PaymentStatus.SUCCESS.getValue());
|
||||
currentDayEncounter.getRecords().forEach(e -> {
|
||||
// 性别
|
||||
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
|
||||
// 就诊状态
|
||||
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(EncounterStatus.class, e.getStatusEnum()));
|
||||
// 计算年龄
|
||||
e.setAge(e.getBirthDate() != null ? AgeCalculatorUtil.getAge(e.getBirthDate()) : "");
|
||||
});
|
||||
return currentDayEncounter;
|
||||
}
|
||||
/**
|
||||
* 查询就诊患者信息
|
||||
*
|
||||
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
|
||||
* @param searchKey 模糊查询关键字
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页多少条
|
||||
* @param pricingFlag 划价标记
|
||||
* @return 就诊患者信息
|
||||
*/
|
||||
@Override
|
||||
public IPage<PatientInfoTencentDto> getPatientInfo(PatientInfoTencentDto patientInfoDto, String searchKey, Integer pageNo,
|
||||
Integer pageSize, HttpServletRequest request, Integer pricingFlag) {
|
||||
// 当前登录账号ID
|
||||
Long userId = SecurityUtils.getLoginUser().getUserId();
|
||||
Long currentUserOrganizationId = SecurityUtils.getLoginUser().getOrgId();
|
||||
// 在诊的情况,需要参与者账户id(接诊医生)的条件
|
||||
if (EncounterStatus.IN_PROGRESS.getValue().equals(patientInfoDto.getStatusEnum())) {
|
||||
patientInfoDto.setJzPractitionerUserId(userId);
|
||||
}
|
||||
// 划价时
|
||||
if (Whether.YES.getValue().equals(pricingFlag)) {
|
||||
userId = null;
|
||||
currentUserOrganizationId = null;
|
||||
}
|
||||
// 构建查询条件
|
||||
QueryWrapper<PatientInfoTencentDto> queryWrapper = HisQueryUtils.buildQueryWrapper(patientInfoDto, searchKey,
|
||||
new HashSet<>(Arrays.asList("patient_name", "id_card", "phone")), request);
|
||||
// 现诊列表按接诊时间倒序
|
||||
if (EncounterStatus.IN_PROGRESS.getValue().equals(patientInfoDto.getStatusEnum())) {
|
||||
queryWrapper.orderByDesc("reception_time");
|
||||
} else {
|
||||
queryWrapper.orderByDesc("register_time");
|
||||
}
|
||||
IPage<PatientInfoTencentDto> patientInfo = tencentAppMapper.getPatientInfo(new Page<>(pageNo, pageSize),
|
||||
ParticipantType.REGISTRATION_DOCTOR.getCode(), ParticipantType.ADMITTER.getCode(), userId,
|
||||
currentUserOrganizationId, pricingFlag, EncounterStatus.PLANNED.getValue(),
|
||||
EncounterActivityStatus.ACTIVE.getValue(), queryWrapper);
|
||||
patientInfo.getRecords().forEach(e -> {
|
||||
// 性别
|
||||
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
|
||||
// 计算年龄
|
||||
e.setAge(e.getBirthDate() != null ? AgeCalculatorUtil.getAge(e.getBirthDate()) : "");
|
||||
// 就诊状态
|
||||
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(EncounterStatus.class, e.getStatusEnum()));
|
||||
});
|
||||
return patientInfo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.openhis.web.tencentJH.controller;
|
||||
|
||||
import com.openhis.common.enums.Whether;
|
||||
import com.openhis.web.doctorstation.dto.PatientInfoDto;
|
||||
import com.openhis.web.tencentJH.dto.PatientInfoTencentDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.web.tencentJH.appservice.ITencentAppService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/*
|
||||
腾讯相关接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/tencentJH")
|
||||
@Slf4j
|
||||
public class TencentController {
|
||||
@Autowired
|
||||
private ITencentAppService iTencentAppService;
|
||||
|
||||
/**
|
||||
* 查询当日就诊数据
|
||||
*
|
||||
* @param searchKey 模糊查询关键字
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页多少条
|
||||
* @return 当日就诊数据
|
||||
*/
|
||||
@GetMapping(value = "/current-day-encounter")
|
||||
public R<?> getCurrentDayEncounter(@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
|
||||
return R.ok(iTencentAppService.getCurrentDayEncounter(searchKey, pageNo, pageSize, request));
|
||||
}
|
||||
/**
|
||||
* 查询就诊患者信息
|
||||
*
|
||||
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
|
||||
* @param searchKey 模糊查询关键字
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页多少条
|
||||
* @return 就诊患者信息
|
||||
*/
|
||||
@GetMapping(value = "/patient-info")
|
||||
public R<?> getPatientInfo(PatientInfoTencentDto patientInfoDto,
|
||||
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
|
||||
return R.ok(iTencentAppService.getPatientInfo(patientInfoDto, searchKey, pageNo, pageSize, request,
|
||||
Whether.NO.getValue()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.openhis.web.tencentJH.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 当天就诊信息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CurrentDayEncounterTencentDto {
|
||||
|
||||
/** 租户ID */
|
||||
private Integer tenantId;
|
||||
|
||||
/**
|
||||
* 就诊ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long encounterId;
|
||||
|
||||
/**
|
||||
* 科室ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long organizationId;
|
||||
|
||||
/**
|
||||
* 科室名称
|
||||
*/
|
||||
private String organizationName;
|
||||
|
||||
/**
|
||||
* 挂号类型
|
||||
*/
|
||||
private String healthcareName;
|
||||
|
||||
/**
|
||||
* 专家账号id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long practitionerUserId;
|
||||
|
||||
/**
|
||||
* 专家
|
||||
*/
|
||||
private String practitionerName;
|
||||
|
||||
/**
|
||||
* 费用性质
|
||||
*/
|
||||
private String contractName;
|
||||
|
||||
/**
|
||||
* 患者id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long patientId;
|
||||
|
||||
/**
|
||||
* 患者姓名
|
||||
*/
|
||||
private String patientName;
|
||||
|
||||
/**
|
||||
* 患者性别
|
||||
*/
|
||||
private Integer genderEnum;
|
||||
private String genderEnum_enumText;
|
||||
|
||||
/**
|
||||
* 证件号
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 就诊状态
|
||||
*/
|
||||
private Integer statusEnum;
|
||||
private String statusEnum_enumText;
|
||||
|
||||
/**
|
||||
* 挂号日期/时间
|
||||
*/
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
/**
|
||||
* 账户名称
|
||||
*/
|
||||
private String accountName;
|
||||
|
||||
/**
|
||||
* 挂号人
|
||||
*/
|
||||
private String entererName;
|
||||
|
||||
/**
|
||||
* 收费项目ids
|
||||
*/
|
||||
private String chargeItemIds;
|
||||
|
||||
/**
|
||||
* 付款id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long paymentId;
|
||||
|
||||
/**
|
||||
* 发票url地址
|
||||
*/
|
||||
private String pictureUrl;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private String age;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
private Date birthDate;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
/*
|
||||
英文名
|
||||
*/
|
||||
private String englishName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.openhis.web.tencentJH.dto;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.openhis.common.annotation.Dict;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 就诊患者信息 dto
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PatientInfoTencentDto {
|
||||
|
||||
/**
|
||||
* 就诊ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long encounterId;
|
||||
|
||||
/**
|
||||
* 患者id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long patientId;
|
||||
|
||||
/**
|
||||
* 账户id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long accountId;
|
||||
|
||||
/**
|
||||
* 患者挂号对应的科室id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 患者姓名
|
||||
*/
|
||||
private String patientName;
|
||||
|
||||
/**
|
||||
* 患者性别
|
||||
*/
|
||||
private Integer genderEnum;
|
||||
private String genderEnum_enumText;
|
||||
|
||||
/**
|
||||
* 证件号
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
|
||||
private Date birthDate;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private String age;
|
||||
|
||||
/**
|
||||
* 就诊状态
|
||||
*/
|
||||
private Integer statusEnum;
|
||||
private String statusEnum_enumText;
|
||||
|
||||
/**
|
||||
* 过敏史标记
|
||||
*/
|
||||
private Integer allergyHistoryFlag;
|
||||
|
||||
/**
|
||||
* 挂号时间
|
||||
*/
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 接诊时间
|
||||
*/
|
||||
private Date receptionTime;
|
||||
|
||||
/** 账户类型编码 */
|
||||
@Dict(dictCode = "account_code")
|
||||
private String typeCode;
|
||||
private String typeCode_dictText;
|
||||
|
||||
/**
|
||||
* 费用性质
|
||||
*/
|
||||
private String contractName;
|
||||
|
||||
/**
|
||||
* 参与者对应的userId - 挂号医生
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long practitionerUserId;
|
||||
|
||||
/**
|
||||
* 参与者对应的userId - 接诊医生
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long jzPractitionerUserId;
|
||||
|
||||
/**
|
||||
* 病历号
|
||||
*/
|
||||
private String busNo;
|
||||
/*
|
||||
英文名
|
||||
*/
|
||||
private String englishName;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.tencentJH.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.openhis.web.chargemanage.dto.CurrentDayEncounterDto;
|
||||
import com.openhis.web.doctorstation.dto.PatientInfoDto;
|
||||
import com.openhis.web.tencentJH.dto.CurrentDayEncounterTencentDto;
|
||||
import com.openhis.web.tencentJH.dto.PatientInfoTencentDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 费用明细报表查询用 mapper
|
||||
*
|
||||
* @author yuxj
|
||||
* @date 2025-05-20
|
||||
*/
|
||||
@Repository
|
||||
public interface TencentAppMapper {
|
||||
|
||||
|
||||
/**
|
||||
* 查询当日就诊数据
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param classEnum 就诊类型
|
||||
* @param statusEnum 门诊就诊状态 | 在诊
|
||||
* @param participantType1 参与者类型 | 接诊医生
|
||||
* @param participantType2 参与者类型 | 挂号医生
|
||||
* @param queryWrapper 查询条件
|
||||
* @param register 收费项目类型:挂号
|
||||
* @param paymentStatus 支付状态:成功
|
||||
* @return 当日就诊数据
|
||||
*/
|
||||
IPage<CurrentDayEncounterTencentDto> getCurrentDayEncounter(@Param("page") Page<CurrentDayEncounterTencentDto> page,
|
||||
@Param("classEnum") Integer classEnum, @Param("statusEnum") Integer statusEnum,
|
||||
@Param("participantType1") String participantType1, @Param("participantType2") String participantType2,
|
||||
@Param(Constants.WRAPPER) QueryWrapper<CurrentDayEncounterTencentDto> queryWrapper,
|
||||
@Param("register") Integer register, @Param("paymentStatus") Integer paymentStatus);;
|
||||
|
||||
/**
|
||||
* 查询就诊患者信息
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param participantType 参与者类型 - 挂号医生
|
||||
* @param participantType2 参与者类型 - 接诊医生
|
||||
* @param userId 当前登录账号ID
|
||||
* @param currentUserOrganizationId 当前登录账号所属的科室ID
|
||||
* @param pricingFlag 划价标记
|
||||
* @param encounterStatus 就诊状态
|
||||
* @param activityStatus 活跃状态
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 就诊患者信息
|
||||
*/
|
||||
IPage<PatientInfoTencentDto> getPatientInfo(@Param("page") Page<PatientInfoTencentDto> page,
|
||||
@Param("participantType") String participantType, @Param("participantType2") String participantType2,
|
||||
@Param("userId") Long userId, @Param("currentUserOrganizationId") Long currentUserOrganizationId,
|
||||
@Param("pricingFlag") Integer pricingFlag, @Param("encounterStatus") Integer encounterStatus,
|
||||
@Param("activityStatus") Integer activityStatus,
|
||||
@Param(Constants.WRAPPER) QueryWrapper<PatientInfoTencentDto> queryWrapper);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.openhis.web.tencentJH.utils.httpUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class HttpClient {
|
||||
|
||||
// 发送post请求
|
||||
public static Map<String, String> post(String url, Map<String, Object> map) {
|
||||
HttpRequesPost httpRequesPost = new HttpRequesPost(url, map, null);
|
||||
return httpRequesPost.executeResponse();
|
||||
}
|
||||
|
||||
// 发送post请求
|
||||
public static Map<String, String> post(String url) {
|
||||
HttpRequesPost httpRequesPost = new HttpRequesPost(url, null, null);
|
||||
return httpRequesPost.executeResponse();
|
||||
}
|
||||
|
||||
// 发送json格式的post请求
|
||||
public static Map<String, String> postJson(String url, Map<String, Object> map) {
|
||||
HttpRequesPost httpRequesPost = new HttpRequesPost(url, map, null, "json");
|
||||
return httpRequesPost.executeResponse();
|
||||
}
|
||||
|
||||
// 发送json格式的post请求带有header
|
||||
public static Map<String, String> postJson(String url, Map<String, Object> headerMap,Map<String, Object> map) {
|
||||
HttpRequesPost httpRequesPost = new HttpRequesPost(url, map, headerMap, "json");
|
||||
return httpRequesPost.executeResponse();
|
||||
}
|
||||
|
||||
// 发送xml格式的请求
|
||||
public static Map<String, String> postXML(String url, Map<String, Object> map) {
|
||||
HttpRequesPost httpRequesPost = new HttpRequesPost(url, map, null, "xml");
|
||||
return httpRequesPost.executeResponse();
|
||||
}
|
||||
|
||||
// 发送get请求
|
||||
public static Map<String, String> get(String url) {
|
||||
HttpRequesGet httpRequesGet = new HttpRequesGet(url);
|
||||
return httpRequesGet.executeResponse();
|
||||
}
|
||||
|
||||
// 发送get请求
|
||||
public static Map<String, String> get(String url, Map<String, Object> map) {
|
||||
HttpRequesGet httpRequesGet = new HttpRequesGet(url, map, null);
|
||||
return httpRequesGet.executeResponse();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.openhis.web.tencentJH.utils.httpUtil;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class HttpReques {
|
||||
|
||||
// 创建HttpClientBuilder
|
||||
private HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
// HttpClient
|
||||
private CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
|
||||
|
||||
protected HttpUriRequest httpReques;
|
||||
// HttpUriRequest httpReques;
|
||||
@SuppressWarnings("finally")
|
||||
public Map<String, String> executeResponse() {
|
||||
Map<String, String> context = new HashMap<>();
|
||||
try {
|
||||
// closeableHttpClient= WebClientDevWrapper.wrapClient(closeableHttpClient);
|
||||
// 设置请求头
|
||||
// 设置请求
|
||||
HttpResponse httpResponse = closeableHttpClient.execute(httpReques);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
// 响应状态
|
||||
int status = httpResponse.getStatusLine().getStatusCode();
|
||||
context.put("msg", EntityUtils.toString(entity,"utf-8"));
|
||||
context.put("status", status+"");
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (closeableHttpClient != null) {
|
||||
try {
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.openhis.web.tencentJH.utils.httpUtil;
|
||||
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class HttpRequesGet extends HttpReques {
|
||||
|
||||
public HttpRequesGet(String url) {
|
||||
HttpGet httpGet = new HttpGet(url);
|
||||
this.httpReques = httpGet;
|
||||
}
|
||||
|
||||
public HttpRequesGet(String path, Map<String, Object> param, Map<String, String> headers) {
|
||||
|
||||
StringBuffer sb = new StringBuffer(path);
|
||||
if (param != null) {
|
||||
sb.append("?");
|
||||
// 设置参数
|
||||
for (String key : param.keySet()) {
|
||||
sb.append(key);
|
||||
sb.append("=");
|
||||
sb.append(param.get(key));
|
||||
sb.append("&");
|
||||
}
|
||||
}
|
||||
HttpGet httpGet = new HttpGet(sb.toString());
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(20000).setConnectionRequestTimeout(15000)
|
||||
.setSocketTimeout(20000).build();
|
||||
|
||||
httpGet.setConfig(requestConfig);
|
||||
if (headers != null) {
|
||||
for (String key : headers.keySet()) {
|
||||
httpGet.addHeader(key, headers.get(key));
|
||||
}
|
||||
}
|
||||
this.httpReques = httpGet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.openhis.web.tencentJH.utils.httpUtil;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
public class HttpRequesPost extends HttpReques {
|
||||
|
||||
public HttpRequesPost(String path, Map<String, Object> param, Map<String, String> headers) {
|
||||
HttpPost httpPost = new HttpPost(path);
|
||||
try {
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(20000)
|
||||
.setConnectionRequestTimeout(20000).setSocketTimeout(20000).build();
|
||||
httpPost.setConfig(requestConfig);
|
||||
// 创建参数队列
|
||||
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
|
||||
if (param != null) {
|
||||
for (String key : param.keySet()) {
|
||||
if (param.get(key) != null) {
|
||||
formparams.add(new BasicNameValuePair(key, param.get(key).toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
|
||||
httpPost.setEntity(entity);
|
||||
if (headers != null) {
|
||||
for (String key : headers.keySet()) {
|
||||
httpPost.addHeader(key, headers.get(key));
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.httpReques = httpPost;
|
||||
}
|
||||
|
||||
public HttpRequesPost(String path, Map<String, Object> param, Map<String, Object> headers, String requestType) {
|
||||
HttpPost httpPost = new HttpPost(path);
|
||||
try {
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(5000)
|
||||
.setConnectionRequestTimeout(5000).setSocketTimeout(5000).build();
|
||||
httpPost.setConfig(requestConfig);
|
||||
// 创建参数队列
|
||||
if ("json".equals(requestType.toLowerCase())) {
|
||||
// 解决中文乱码问题
|
||||
StringEntity entity = new StringEntity(JSON.toJSONString(param), "utf-8");
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpPost.setEntity(entity);
|
||||
} else if("xml".equals(requestType.toLowerCase())){
|
||||
StringBuffer xml=new StringBuffer();
|
||||
xml.append("<xml>");
|
||||
for (String key : param.keySet()) {
|
||||
xml.append("<"+key+">");
|
||||
xml.append(param.get(key));
|
||||
xml.append("</"+key+">");
|
||||
}
|
||||
xml.append("</xml>");
|
||||
// 解决中文乱码问题
|
||||
StringEntity entity = new StringEntity(xml.toString(), "utf-8");
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("text/xml");
|
||||
System.out.println("----------xml:"+xml.toString());
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
} else if ("".equals(requestType) || requestType == null) {
|
||||
List<NameValuePair> formParams = new ArrayList<NameValuePair>();
|
||||
if (param != null) {
|
||||
for (String key : param.keySet()) {
|
||||
if (param.get(key) != null) {
|
||||
formParams.add(new BasicNameValuePair(key, param.get(key).toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, "UTF-8");
|
||||
httpPost.setEntity(entity);
|
||||
}
|
||||
if (headers != null) {
|
||||
for (String key : headers.keySet()) {
|
||||
httpPost.addHeader(key, headers.get(key).toString());
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.httpReques = httpPost;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.openhis.web.tencentJH.utils.httpUtil;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @ClassName HttpRequestGetJson
|
||||
* @Description 返回给产权的get json格式
|
||||
* @Author raymond
|
||||
* @Date 2023/12/5 10:52
|
||||
* @Version 1.0
|
||||
**/
|
||||
public class HttpRequestGetJson extends HttpReques {
|
||||
|
||||
static Logger logger = LoggerFactory.getLogger(HttpRequestGetJson.class);
|
||||
/**
|
||||
* Desc: 返回给产权的工具方法
|
||||
* @param url 地址
|
||||
* @param json json数据
|
||||
* @Author raymond
|
||||
* @Date 11:02 2023/12/5
|
||||
* @return void
|
||||
**/
|
||||
public static void sendData(String url,String json){
|
||||
try {
|
||||
String data = url + json;
|
||||
URL apiURL = new URL(data);
|
||||
HttpURLConnection connection = (HttpURLConnection) apiURL.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Content-Type","application/json");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((line = reader.readLine()) != null){
|
||||
response.append(line);
|
||||
}
|
||||
reader.close();
|
||||
} catch (MalformedURLException e) {
|
||||
logger.error("CQ_DATA_LOG:{}",e.getMessage());
|
||||
} catch (IOException e) {
|
||||
logger.error("CQ_DATA_LOG:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.openhis.web.tencentJH.utils.httpUtil;
|
||||
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
/**
|
||||
* @ClassName HttpsClientUtil
|
||||
* @Description
|
||||
* @Author raymond
|
||||
* @Date 2024/1/9 08:42
|
||||
* @Version 1.0
|
||||
**/
|
||||
public class HttpsClientUtil {
|
||||
|
||||
public static String doPost(String url,String jsonData){
|
||||
HttpClient httpClient = null;
|
||||
HttpPost httpPost = null;
|
||||
String result = null;
|
||||
try{
|
||||
httpClient = new SSLClient();
|
||||
httpPost = new HttpPost(url);
|
||||
httpPost.addHeader("Content-Type", "application/json");
|
||||
StringEntity se = new StringEntity(jsonData);
|
||||
se.setContentType("text/json");
|
||||
se.setContentEncoding(new BasicHeader("Content-Type", "application/json"));
|
||||
httpPost.setEntity(se);
|
||||
HttpResponse response = httpClient.execute(httpPost);
|
||||
if(response != null){
|
||||
HttpEntity resEntity = response.getEntity();
|
||||
if(resEntity != null){
|
||||
result = EntityUtils.toString(resEntity,"utf-8");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.openhis.web.tencentJH.utils.httpUtil;
|
||||
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* @ClassName SSLClient
|
||||
* @Description TODO
|
||||
* @Author raymond
|
||||
* @Date 2024/1/9 08:28
|
||||
* @Version 1.0
|
||||
**/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SSLClient extends DefaultHttpClient {
|
||||
|
||||
public SSLClient() throws Exception {
|
||||
super();
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
X509TrustManager tm = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
ctx.init(null,new TrustManager[]{tm},null);
|
||||
SSLSocketFactory ssf = new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
ClientConnectionManager ccm = this.getConnectionManager();
|
||||
SchemeRegistry registry = ccm.getSchemeRegistry();
|
||||
registry.register(new Scheme("https",443,ssf));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @Title: WebClientDevWrapper.java
|
||||
* @Package com.hmc.core.util.http_client
|
||||
* @Description: TODO(用一句话描述该文件做什么)
|
||||
* @author daniel
|
||||
* @date 2016年9月26日 下午5:28:13
|
||||
* @version V1.0
|
||||
*/
|
||||
package com.openhis.web.tencentJH.utils.httpUtil;
|
||||
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
|
||||
public class WebClientDevWrapper {
|
||||
public static DefaultHttpClient wrapClient(org.apache.http.client.HttpClient base) {
|
||||
try {
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
X509TrustManager tm = new X509TrustManager() {
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {}
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {}
|
||||
};
|
||||
ctx.init(null, new TrustManager[] { tm }, null);
|
||||
SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
SchemeRegistry registry = new SchemeRegistry();
|
||||
registry.register(new Scheme("https", 443, ssf));
|
||||
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(registry);
|
||||
return new DefaultHttpClient(mgr, base.getParams());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user