{
+ private static final long serialVersionUID = -1185015143654744140L;
+
+ /**
+ * SecureRandom 的单例
+ *
+ */
+ private static class Holder {
+ static final SecureRandom numberGenerator = getSecureRandom();
+ }
+
+ /** 此UUID的最高64有效位 */
+ private final long mostSigBits;
+
+ /** 此UUID的最低64有效位 */
+ private final long leastSigBits;
+
+ /**
+ * 私有构造
+ *
+ * @param data 数据
+ */
+ private UUID(byte[] data) {
+ long msb = 0;
+ long lsb = 0;
+ assert data.length == 16 : "data must be 16 bytes in length";
+ for (int i = 0; i < 8; i++) {
+ msb = (msb << 8) | (data[i] & 0xff);
+ }
+ for (int i = 8; i < 16; i++) {
+ lsb = (lsb << 8) | (data[i] & 0xff);
+ }
+ this.mostSigBits = msb;
+ this.leastSigBits = lsb;
+ }
+
+ /**
+ * 使用指定的数据构造新的 UUID。
+ *
+ * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位
+ * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位
+ */
+ public UUID(long mostSigBits, long leastSigBits) {
+ this.mostSigBits = mostSigBits;
+ this.leastSigBits = leastSigBits;
+ }
+
+ /**
+ * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。
+ *
+ * @return 随机生成的 {@code UUID}
+ */
+ public static UUID fastUUID() {
+ return randomUUID(false);
+ }
+
+ /**
+ * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
+ *
+ * @return 随机生成的 {@code UUID}
+ */
+ public static UUID randomUUID() {
+ return randomUUID(true);
+ }
+
+ /**
+ * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
+ *
+ * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能
+ * @return 随机生成的 {@code UUID}
+ */
+ public static UUID randomUUID(boolean isSecure) {
+ final Random ng = isSecure ? Holder.numberGenerator : getRandom();
+
+ byte[] randomBytes = new byte[16];
+ ng.nextBytes(randomBytes);
+ randomBytes[6] &= 0x0f; /* clear version */
+ randomBytes[6] |= 0x40; /* set to version 4 */
+ randomBytes[8] &= 0x3f; /* clear variant */
+ randomBytes[8] |= 0x80; /* set to IETF variant */
+ return new UUID(randomBytes);
+ }
+
+ /**
+ * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。
+ *
+ * @param name 用于构造 UUID 的字节数组。
+ *
+ * @return 根据指定数组生成的 {@code UUID}
+ */
+ public static UUID nameUUIDFromBytes(byte[] name) {
+ MessageDigest md;
+ try {
+ md = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new InternalError("MD5 not supported");
+ }
+ byte[] md5Bytes = md.digest(name);
+ md5Bytes[6] &= 0x0f; /* clear version */
+ md5Bytes[6] |= 0x30; /* set to version 3 */
+ md5Bytes[8] &= 0x3f; /* clear variant */
+ md5Bytes[8] |= 0x80; /* set to IETF variant */
+ return new UUID(md5Bytes);
+ }
+
+ /**
+ * 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。
+ *
+ * @param name 指定 {@code UUID} 字符串
+ * @return 具有指定值的 {@code UUID}
+ * @throws IllegalArgumentException 如果 name 与 {@link #toString}
+ * 中描述的字符串表示形式不符抛出此异常
+ *
+ */
+ public static UUID fromString(String name) {
+ String[] components = name.split("-");
+ if (components.length != 5) {
+ throw new IllegalArgumentException("Invalid UUID string: " + name);
+ }
+ for (int i = 0; i < 5; i++) {
+ components[i] = "0x" + components[i];
+ }
+
+ long mostSigBits = Long.decode(components[0]).longValue();
+ mostSigBits <<= 16;
+ mostSigBits |= Long.decode(components[1]).longValue();
+ mostSigBits <<= 16;
+ mostSigBits |= Long.decode(components[2]).longValue();
+
+ long leastSigBits = Long.decode(components[3]).longValue();
+ leastSigBits <<= 48;
+ leastSigBits |= Long.decode(components[4]).longValue();
+
+ return new UUID(mostSigBits, leastSigBits);
+ }
+
+ /**
+ * 返回此 UUID 的 128 位值中的最低有效 64 位。
+ *
+ * @return 此 UUID 的 128 位值中的最低有效 64 位。
+ */
+ public long getLeastSignificantBits() {
+ return leastSigBits;
+ }
+
+ /**
+ * 返回此 UUID 的 128 位值中的最高有效 64 位。
+ *
+ * @return 此 UUID 的 128 位值中最高有效 64 位。
+ */
+ public long getMostSignificantBits() {
+ return mostSigBits;
+ }
+
+ /**
+ * 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。
+ *
+ * 版本号具有以下含意:
+ *
+ * - 1 基于时间的 UUID
+ *
- 2 DCE 安全 UUID
+ *
- 3 基于名称的 UUID
+ *
- 4 随机生成的 UUID
+ *
+ *
+ * @return 此 {@code UUID} 的版本号
+ */
+ public int version() {
+ // Version is bits masked by 0x000000000000F000 in MS long
+ return (int) ((mostSigBits >> 12) & 0x0f);
+ }
+
+ /**
+ * 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。
+ *
+ * 变体号具有以下含意:
+ *
+ * - 0 为 NCS 向后兼容保留
+ *
- 2 IETF RFC 4122(Leach-Salz),
+ * 用于此类
+ *
- 6 保留,微软向后兼容
+ *
- 7 保留供以后定义使用
+ *
+ *
+ * @return 此 {@code UUID} 相关联的变体号
+ */
+ public int variant() {
+ // This field is composed of a varying number of bits.
+ // 0 - - Reserved for NCS backward compatibility
+ // 1 0 - The IETF aka Leach-Salz variant (used by this class)
+ // 1 1 0 Reserved, Microsoft backward compatibility
+ // 1 1 1 Reserved for future definition.
+ return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63));
+ }
+
+ /**
+ * 与此 UUID 相关联的时间戳值。
+ *
+ *
+ * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。
+ * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。
+ *
+ *
+ * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
+ *
+ * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。
+ */
+ public long timestamp() throws UnsupportedOperationException {
+ checkTimeBase();
+ return (mostSigBits & 0x0FFFL) << 48//
+ | ((mostSigBits >> 16) & 0x0FFFFL) << 32//
+ | mostSigBits >>> 32;
+ }
+
+ /**
+ * 与此 UUID 相关联的时钟序列值。
+ *
+ *
+ * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。
+ *
+ * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的
+ * UUID,则此方法抛出 UnsupportedOperationException。
+ *
+ * @return 此 {@code UUID} 的时钟序列
+ *
+ * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
+ */
+ public int clockSequence() throws UnsupportedOperationException {
+ checkTimeBase();
+ return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
+ }
+
+ /**
+ * 与此 UUID 相关的节点值。
+ *
+ *
+ * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。
+ *
+ * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
+ *
+ * @return 此 {@code UUID} 的节点值
+ *
+ * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
+ */
+ public long node() throws UnsupportedOperationException {
+ checkTimeBase();
+ return leastSigBits & 0x0000FFFFFFFFFFFFL;
+ }
+
+ /**
+ * 返回此{@code UUID} 的字符串表现形式。
+ *
+ *
+ * UUID 的字符串表示形式由此 BNF 描述:
+ *
+ *
+ * {@code
+ * UUID = ----
+ * time_low = 4*
+ * time_mid = 2*
+ * time_high_and_version = 2*
+ * variant_and_sequence = 2*
+ * node = 6*
+ * hexOctet =
+ * hexDigit = [0-9a-fA-F]
+ * }
+ *
+ *
+ *
+ *
+ * @return 此{@code UUID} 的字符串表现形式
+ * @see #toString(boolean)
+ */
+ @Override
+ public String toString() {
+ return toString(false);
+ }
+
+ /**
+ * 返回此{@code UUID} 的字符串表现形式。
+ *
+ *
+ * UUID 的字符串表示形式由此 BNF 描述:
+ *
+ *
+ * {@code
+ * UUID = ----
+ * time_low = 4*
+ * time_mid = 2*
+ * time_high_and_version = 2*
+ * variant_and_sequence = 2*
+ * node = 6*
+ * hexOctet =
+ * hexDigit = [0-9a-fA-F]
+ * }
+ *
+ *
+ *
+ *
+ * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串
+ * @return 此{@code UUID} 的字符串表现形式
+ */
+ public String toString(boolean isSimple) {
+ final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
+ // time_low
+ builder.append(digits(mostSigBits >> 32, 8));
+ if (false == isSimple) {
+ builder.append('-');
+ }
+ // time_mid
+ builder.append(digits(mostSigBits >> 16, 4));
+ if (false == isSimple) {
+ builder.append('-');
+ }
+ // time_high_and_version
+ builder.append(digits(mostSigBits, 4));
+ if (false == isSimple) {
+ builder.append('-');
+ }
+ // variant_and_sequence
+ builder.append(digits(leastSigBits >> 48, 4));
+ if (false == isSimple) {
+ builder.append('-');
+ }
+ // node
+ builder.append(digits(leastSigBits, 12));
+
+ return builder.toString();
+ }
+
+ /**
+ * 返回此 UUID 的哈希码。
+ *
+ * @return UUID 的哈希码值。
+ */
+ @Override
+ public int hashCode() {
+ long hilo = mostSigBits ^ leastSigBits;
+ return ((int) (hilo >> 32)) ^ (int) hilo;
+ }
+
+ /**
+ * 将此对象与指定对象比较。
+ *
+ * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的
+ * varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。
+ *
+ * @param obj 要与之比较的对象
+ *
+ * @return 如果对象相同,则返回 {@code true};否则返回 {@code false}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if ((null == obj) || (obj.getClass() != UUID.class)) {
+ return false;
+ }
+ UUID id = (UUID) obj;
+ return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
+ }
+
+ // Comparison Operations
+
+ /**
+ * 将此 UUID 与指定的 UUID 比较。
+ *
+ *
+ * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。
+ *
+ * @param val 与此 UUID 比较的 UUID
+ *
+ * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。
+ *
+ */
+ @Override
+ public int compareTo(UUID val) {
+ // The ordering is intentionally set up so that the UUIDs
+ // can simply be numerically compared as two numbers
+ return (this.mostSigBits < val.mostSigBits ? -1 : //
+ (this.mostSigBits > val.mostSigBits ? 1 : //
+ (this.leastSigBits < val.leastSigBits ? -1 : //
+ (this.leastSigBits > val.leastSigBits ? 1 : //
+ 0))));
+ }
+
+ // -------------------------------------------------------------------------------------------------------------------
+ // Private method start
+ /**
+ * 返回指定数字对应的hex值
+ *
+ * @param val 值
+ * @param digits 位
+ * @return 值
+ */
+ private static String digits(long val, int digits) {
+ long hi = 1L << (digits * 4);
+ return Long.toHexString(hi | (val & (hi - 1))).substring(1);
+ }
+
+ /**
+ * 检查是否为time-based版本UUID
+ */
+ private void checkTimeBase() {
+ if (version() != 1) {
+ throw new UnsupportedOperationException("Not a time-based UUID");
+ }
+ }
+
+ /**
+ * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG)
+ *
+ * @return {@link SecureRandom}
+ */
+ public static SecureRandom getSecureRandom() {
+ try {
+ return SecureRandom.getInstance("SHA1PRNG");
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 获取随机数生成器对象
+ * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。
+ *
+ * @return {@link ThreadLocalRandom}
+ */
+ public static ThreadLocalRandom getRandom() {
+ return ThreadLocalRandom.current();
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/base/controller/BaseController.java b/health_framework/src/main/java/cn/card/health/base/controller/BaseController.java
new file mode 100644
index 0000000..870a29d
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/base/controller/BaseController.java
@@ -0,0 +1,180 @@
+package cn.card.health.base.controller;
+
+import java.beans.PropertyEditorSupport;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.InitBinder;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+
+import cn.card.health.common.core.ServletUtils;
+import cn.card.health.common.core.SqlUtil;
+import cn.card.health.common.page.PageDomain;
+import cn.card.health.common.page.TableDataInfo;
+import cn.card.health.common.page.TableSupport;
+import cn.card.health.common.utils.DateUtils;
+import cn.card.health.common.utils.HttpStatus;
+import cn.card.health.common.utils.StringUtils;
+
+/**
+ * web层通用数据处理
+ *
+ * @author yc
+ */
+public class BaseController {
+ protected final Logger logger = LoggerFactory
+ .getLogger(BaseController.class);
+
+ /**
+ * 将前台传递过来的日期格式的字符串,自动转化为Date类型
+ */
+ @InitBinder
+ public void initBinder(WebDataBinder binder) {
+ // Date 类型转换
+ binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
+ @Override
+ public void setAsText(String text) {
+ setValue(DateUtils.parseDate(text));
+ }
+ });
+ }
+
+ /**
+ * 设置请求分页数据
+ */
+ protected void startPage() {
+ PageDomain pageDomain = TableSupport.buildPageRequest();
+ Integer pageNum = pageDomain.getPageNum();
+ Integer pageSize = pageDomain.getPageSize();
+ if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
+ String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
+ PageHelper.startPage(pageNum, pageSize, orderBy);
+ }
+ }
+
+ /**
+ * 响应请求分页数据
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ protected TableDataInfo getDataTable(List> list) {
+ TableDataInfo rspData = new TableDataInfo();
+ rspData.setCode(HttpStatus.SUCCESS);
+ rspData.setMsg("查询成功");
+ rspData.setRows(list);
+ rspData.setTotal(new PageInfo(list).getTotal());
+ return rspData;
+ }
+
+// /**
+// * 响应返回结果
+// *
+// * @param rows
+// * 影响行数
+// * @return 操作结果
+// */
+// protected AjaxResult toAjax(int rows) {
+// return rows > 0 ? AjaxResult.success() : AjaxResult.error();
+// }
+
+ /**
+ * 页面跳转
+ */
+ public String redirect(String url) {
+ return StringUtils.format("redirect:{}", url);
+ }
+
+ /**
+ * 取前端在JSON中的数据
+ *
+ * @return JSONObject
+ * @author xinggm
+ */
+ public JSONObject getJSONParams() {
+ HttpServletRequest request = ServletUtils.getRequest();
+ try {
+ BufferedReader br = request.getReader();
+ String str = "";
+ String lsStr = "";
+ while ((str = br.readLine()) != null) {
+ lsStr += str;
+ }
+ JSONObject paramsJSON = JSONObject.parseObject(lsStr);
+ return paramsJSON;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return new JSONObject();
+ }
+ }
+
+ /**
+ * 用于方便的获取request中的参数
+ *
+ * @return
+ * @author cheng.li 2017年1月5日
+ */
+ public Map getRequestParams() {
+ Map map = new HashMap();
+ HttpServletRequest request = ServletUtils.getRequest();
+ try {
+ BufferedReader br = request.getReader();
+ String str = "";
+ String lsStr = "";
+ while ((str = br.readLine()) != null) {
+ lsStr += str;
+ }
+ logger.info("====字节流参数:===={}", lsStr);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Set> set = request.getParameterMap().entrySet();
+ Iterator> it = set.iterator();
+ while (it.hasNext()) {
+ Entry entry = it.next();
+ StringBuffer value = new StringBuffer();
+ for (String i : entry.getValue()) {
+ value.append(i + ",");
+ }
+ value.deleteCharAt(value.length() - 1);
+ map.put(entry.getKey(), value.toString());
+ }
+ return map;
+ }
+
+ public Map getParams(){
+ //获取支付宝POST过来反馈信息
+ Map params = new HashMap();
+ HttpServletRequest request = ServletUtils.getRequest();
+ Map requestParams = request.getParameterMap();
+ for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
+ String name = (String) iter.next();
+ String[] values = (String[]) requestParams.get(name);
+ String valueStr = "";
+ for (int i = 0; i < values.length; i++) {
+ valueStr = (i == values.length - 1) ? valueStr + values[i]
+ : valueStr + values[i] + ",";
+ }
+ //乱码解决,这段代码在出现乱码时使用。
+ //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
+ params.put(name, valueStr);
+ }
+
+ return params;
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/bean/insurance/MkAppletRequest.java b/health_framework/src/main/java/cn/card/health/bean/insurance/MkAppletRequest.java
new file mode 100644
index 0000000..d6f6d2d
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/bean/insurance/MkAppletRequest.java
@@ -0,0 +1,178 @@
+package cn.card.health.bean.insurance;
+
+import cn.card.health.common.utils.Md5Utils;
+import cn.card.health.insurance.HealthInsuranceConfig;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.Date;
+
+/**
+ * 支付宝小程序请求对象 mk_applet_request
+ *
+ * @author ruoyi
+ * @date 2022-10-15
+ */
+public class MkAppletRequest
+{
+ private static final long serialVersionUID = 1L;
+
+ /** 主键 */
+ private Long mkId;
+
+ /** 请求号 */
+ private String mkRequestid;
+
+ /** 请求方法 */
+ private String mkRequestMethod;
+
+ /** 小程序请求数据 */
+ private String mkAppletRequestData;
+
+ /** 小程序返回数据 */
+ private String mkAppletResponseData;
+
+ /** 医保请求数据 */
+ private String mkInsuranceRequestData;
+
+ /** 医保返回数据 */
+ private String mkInsuranceResponseData;
+ /** 签名 */
+ private String mkSign;
+
+ /** 验签结果 */
+ private Boolean mkValidate;
+
+ /**
+ * 创建时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+ /**
+ * 更新时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date updateTime;
+
+ public MkAppletRequest() {
+ }
+ public MkAppletRequest(JSONObject params) {
+ this.mkAppletRequestData = params.toJSONString();
+// this.mkRequestid = params.getString("requestid");
+// this.mkSign = params.getString("sign");
+// String md5Sign = Md5Utils.hash(mkRequestid + HealthInsuranceConfig.REQUEST_KEY);
+// this.mkValidate = md5Sign.equals(mkSign);
+ }
+
+ public void setMkId(Long mkId)
+ {
+ this.mkId = mkId;
+ }
+
+ public Long getMkId()
+ {
+ return mkId;
+ }
+ public void setMkRequestid(String mkRequestid)
+ {
+ this.mkRequestid = mkRequestid;
+ }
+
+ public String getMkRequestid()
+ {
+ return mkRequestid;
+ }
+ public void setMkAppletRequestData(String mkAppletRequestData)
+ {
+ this.mkAppletRequestData = mkAppletRequestData;
+ }
+
+ public String getMkAppletRequestData()
+ {
+ return mkAppletRequestData;
+ }
+ public void setMkAppletResponseData(String mkAppletResponseData)
+ {
+ this.mkAppletResponseData = mkAppletResponseData;
+ }
+
+ public String getMkAppletResponseData()
+ {
+ return mkAppletResponseData;
+ }
+ public void setMkInsuranceRequestData(String mkInsuranceRequestData)
+ {
+ this.mkInsuranceRequestData = mkInsuranceRequestData;
+ }
+
+ public String getMkInsuranceRequestData()
+ {
+ return mkInsuranceRequestData;
+ }
+ public void setMkInsuranceResponseData(String mkInsuranceResponseData)
+ {
+ this.mkInsuranceResponseData = mkInsuranceResponseData;
+ }
+
+ public String getMkInsuranceResponseData()
+ {
+ return mkInsuranceResponseData;
+ }
+
+ public String getMkRequestMethod() {
+ return mkRequestMethod;
+ }
+
+ public void setMkRequestMethod(String mkRequestMethod) {
+ this.mkRequestMethod = mkRequestMethod;
+ }
+
+ public String getMkSign() {
+ return mkSign;
+ }
+
+ public void setMkSign(String mkSign) {
+ this.mkSign = mkSign;
+ }
+
+ public Boolean getMkValidate() {
+ return mkValidate;
+ }
+
+ public void setMkValidate(Boolean mkValidate) {
+ this.mkValidate = mkValidate;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ public Date getUpdateTime() {
+ return updateTime;
+ }
+
+ public void setUpdateTime(Date updateTime) {
+ this.updateTime = updateTime;
+ }
+
+ @Override
+ public String toString() {
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ return objectMapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/bean/insurance/MkInsurancePay.java b/health_framework/src/main/java/cn/card/health/bean/insurance/MkInsurancePay.java
new file mode 100644
index 0000000..d603d8a
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/bean/insurance/MkInsurancePay.java
@@ -0,0 +1,463 @@
+package cn.card.health.bean.insurance;
+
+import cn.card.health.common.utils.DateUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.Date;
+
+/**
+ * 医保支付对象 mk_insurance_pay
+ *
+ * @author ruoyi
+ * @date 2022-10-24
+ */
+public class MkInsurancePay {
+ private static final long serialVersionUID = 1L;
+
+ public MkInsurancePay() {
+ }
+
+ public MkInsurancePay(JSONObject params) {
+ this.idno = params.getString("idNo");
+ this.idtype = params.getString("idType");
+ this.username = params.getString("userName");
+ this.psnno = params.getString("psnNo");
+ this.medorgord = params.getString("medOrgOrd");
+ this.medtype = params.getString("medType");
+ this.feetype = params.getString("feeType");
+ this.psnsetlway = params.getString("psnSetlway");
+ this.mdtrtcerttype = params.getString("mdtrtCertType");
+ this.paytoken = params.getString("payAuthNo");
+ this.chrgbchno = params.getString("chrgBchno");
+ this.mdtrtid = params.getString("mdtrtId");
+ this.ordstas = "0";
+ this.applytime = DateUtils.getNowDate();
+// this.approvedtime = params.getString("");
+ this.userid = params.getString("userid");
+ this.feesumamt = params.getFloat("medfeeSumamt");
+ }
+
+
+ /**
+ * 主键
+ */
+ private Long mkId;
+
+ /**
+ * 订单ID
+ */
+ private Long orderid;
+
+ /**
+ * 证件号码
+ */
+ private String idno;
+
+ /**
+ * 用户姓名
+ */
+ private String username;
+
+ /**
+ * 证件类别
+ */
+ private String idtype;
+
+ /**
+ * 人员编号
+ */
+ private String psnno;
+
+ /**
+ * 医疗机构订单号
+ */
+ private String medorgord;
+
+ /**
+ * 医疗类别
+ */
+ private String medtype;
+
+ /**
+ * 个人结算方式
+ */
+ private String feetype;
+
+ /**
+ * 个人结算方式
+ */
+ private String psnsetlway;
+
+ /**
+ * 就诊凭证类型
+ */
+ private String mdtrtcerttype;
+
+ /**
+ * 支付订单号
+ */
+ private String payordid;
+
+ /**
+ * 支付token
+ */
+ private String paytoken;
+
+ /**
+ * payAuthNo
+ */
+ private String payAuthNo;
+
+ /**
+ * 收费批次号
+ */
+ private String chrgbchno;
+
+ /**
+ * 就诊ID
+ */
+ private String mdtrtid;
+
+ /**
+ * 订单状态
+ */
+ private String ordstas;
+
+ /**
+ * 费用总金额
+ */
+ private Float feesumamt;
+
+ /**
+ * 现金支付
+ */
+ private Float ownpayamt;
+
+ /**
+ * 个人账户支出
+ */
+ private Float psnacctpay;
+
+ /**
+ * 医保基金支付
+ */
+ private Float fundpay;
+
+ /**
+ * 其他金额支付
+ */
+ private Float othFeeAmt;
+
+ /**
+ * 上传时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ private Date applytime;
+
+ /**
+ * 结算时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ private Date approvedtime;
+
+ /**
+ * 用户标志
+ */
+ private String userid;
+
+ /**
+ * 商户订单号
+ */
+ private String outTradeNo;
+
+ /**
+ * 交易流水号
+ */
+ private String tradeno;
+ /**
+ *
+ */
+ private String medinsSetlId;
+
+ /**
+ * 原因
+ */
+ private String reason;
+
+ /**
+ * 创建时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+ /**
+ * 更新时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date updateTime;
+
+ public void setMkId(Long mkId) {
+ this.mkId = mkId;
+ }
+
+ public Long getMkId() {
+ return mkId;
+ }
+
+ public Long getOrderid() {
+ return orderid;
+ }
+
+ public void setOrderid(Long orderid) {
+ this.orderid = orderid;
+ }
+
+ public void setIdno(String idno) {
+ this.idno = idno;
+ }
+
+ public String getIdno() {
+ return idno;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setIdtype(String idtype) {
+ this.idtype = idtype;
+ }
+
+ public String getIdtype() {
+ return idtype;
+ }
+
+ public void setPsnno(String psnno) {
+ this.psnno = psnno;
+ }
+
+ public String getPsnno() {
+ return psnno;
+ }
+
+ public void setMedorgord(String medorgord) {
+ this.medorgord = medorgord;
+ }
+
+ public String getMedorgord() {
+ return medorgord;
+ }
+
+ public void setMedtype(String medtype) {
+ this.medtype = medtype;
+ }
+
+ public String getMedtype() {
+ return medtype;
+ }
+
+ public void setFeetype(String feetype) {
+ this.feetype = feetype;
+ }
+
+ public String getFeetype() {
+ return feetype;
+ }
+
+ public void setPsnsetlway(String psnsetlway) {
+ this.psnsetlway = psnsetlway;
+ }
+
+ public String getPsnsetlway() {
+ return psnsetlway;
+ }
+
+ public void setMdtrtcerttype(String mdtrtcerttype) {
+ this.mdtrtcerttype = mdtrtcerttype;
+ }
+
+ public String getMdtrtcerttype() {
+ return mdtrtcerttype;
+ }
+
+ public void setPayordid(String payordid) {
+ this.payordid = payordid;
+ }
+
+ public String getPayordid() {
+ return payordid;
+ }
+
+ public void setPaytoken(String paytoken) {
+ this.paytoken = paytoken;
+ }
+
+ public String getPaytoken() {
+ return paytoken;
+ }
+
+ public void setChrgbchno(String chrgbchno) {
+ this.chrgbchno = chrgbchno;
+ }
+
+ public String getChrgbchno() {
+ return chrgbchno;
+ }
+
+ public void setMdtrtid(String mdtrtid) {
+ this.mdtrtid = mdtrtid;
+ }
+
+ public String getMdtrtid() {
+ return mdtrtid;
+ }
+
+ public void setOrdstas(String ordstas) {
+ this.ordstas = ordstas;
+ }
+
+ public String getOrdstas() {
+ return ordstas;
+ }
+
+ public void setFeesumamt(Float feesumamt) {
+ this.feesumamt = feesumamt;
+ }
+
+ public Float getFeesumamt() {
+ return feesumamt;
+ }
+
+ public void setOwnpayamt(Float ownpayamt) {
+ this.ownpayamt = ownpayamt;
+ }
+
+ public Float getOwnpayamt() {
+ return ownpayamt;
+ }
+
+ public void setPsnacctpay(Float psnacctpay) {
+ this.psnacctpay = psnacctpay;
+ }
+
+ public Float getPsnacctpay() {
+ return psnacctpay;
+ }
+
+ public void setFundpay(Float fundpay) {
+ this.fundpay = fundpay;
+ }
+
+ public Float getFundpay() {
+ return fundpay;
+ }
+
+ public void setApplytime(Date applytime) {
+ this.applytime = applytime;
+ }
+
+ public Date getApplytime() {
+ return applytime;
+ }
+
+ public void setApprovedtime(Date approvedtime) {
+ this.approvedtime = approvedtime;
+ }
+
+ public Date getApprovedtime() {
+ return approvedtime;
+ }
+
+ public void setUserid(String userid) {
+ this.userid = userid;
+ }
+
+ public Float getOthFeeAmt() {
+ return othFeeAmt;
+ }
+
+ public void setOthFeeAmt(Float othFeeAmt) {
+ this.othFeeAmt = othFeeAmt;
+ }
+
+ public String getUserid() {
+ return userid;
+ }
+
+ public String getOutTradeNo() {
+ return outTradeNo;
+ }
+
+ public void setOutTradeNo(String outTradeNo) {
+ this.outTradeNo = outTradeNo;
+ }
+
+ public String getTradeno() {
+ return tradeno;
+ }
+
+ public void setTradeno(String tradeno) {
+ this.tradeno = tradeno;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ public Date getUpdateTime() {
+ return updateTime;
+ }
+
+ public void setUpdateTime(Date updateTime) {
+ this.updateTime = updateTime;
+ }
+
+ public String getPayAuthNo() {
+ return payAuthNo;
+ }
+
+ public void setPayAuthNo(String payAuthNo) {
+ this.payAuthNo = payAuthNo;
+ }
+
+ public String getMedinsSetlId() {
+ return medinsSetlId;
+ }
+
+ public void setMedinsSetlId(String medinsSetlId) {
+ this.medinsSetlId = medinsSetlId;
+ }
+
+ @Override
+ public String toString() {
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ return objectMapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/bean/order/YcMsg.java b/health_framework/src/main/java/cn/card/health/bean/order/YcMsg.java
new file mode 100644
index 0000000..1fad31a
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/bean/order/YcMsg.java
@@ -0,0 +1,107 @@
+package cn.card.health.bean.order;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 消息发送
+ *
+ * @author xinggm
+ * @email
+ * @date 2021-07-22 10:30:48
+ */
+public class YcMsg implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /** 消息主键 */
+ private Long msgid;
+ /** openid */
+ private String touser;
+ /** 微信模板标志 */
+ private String temlateid;
+ /** 跳转连接 */
+ private String msgurl;
+ /** 消息内容 */
+ private String content;
+ /** 消息状态 */
+ private Integer msgStatus;
+ /** 创建时间 */
+ private Date createDate;
+ /** 更新时间 */
+ private Date updateTime;
+ /** 第三方消息标志 */
+ private String tmsgid;
+
+ public Long getMsgid() {
+ return msgid;
+ }
+
+ public void setMsgid(Long msgid) {
+ this.msgid = msgid;
+ }
+
+ public String getTouser() {
+ return touser;
+ }
+
+ public void setTouser(String touser) {
+ this.touser = touser;
+ }
+
+ public String getTemlateid() {
+ return temlateid;
+ }
+
+ public void setTemlateid(String temlateid) {
+ this.temlateid = temlateid;
+ }
+
+ public String getMsgurl() {
+ return msgurl;
+ }
+
+ public void setMsgurl(String msgurl) {
+ this.msgurl = msgurl;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public Integer getMsgStatus() {
+ return msgStatus;
+ }
+
+ public void setMsgStatus(Integer msgStatus) {
+ this.msgStatus = msgStatus;
+ }
+
+ public Date getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate) {
+ this.createDate = createDate;
+ }
+
+ public Date getUpdateTime() {
+ return updateTime;
+ }
+
+ public void setUpdateTime(Date updateTime) {
+ this.updateTime = updateTime;
+ }
+
+ public String getTmsgid() {
+ return tmsgid;
+ }
+
+ public void setTmsgid(String tmsgid) {
+ this.tmsgid = tmsgid;
+ }
+
+}
diff --git a/health_framework/src/main/java/cn/card/health/bean/order/YcPayCallback.java b/health_framework/src/main/java/cn/card/health/bean/order/YcPayCallback.java
new file mode 100644
index 0000000..38330a3
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/bean/order/YcPayCallback.java
@@ -0,0 +1,101 @@
+package cn.card.health.bean.order;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 微信调用
+ *
+ * @author tt
+ * @date 2021-07-06 12:15:47
+ */
+public class YcPayCallback implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ @ApiModelProperty(value = "")
+ private Integer id;
+
+ /**
+ *
+ */
+ @ApiModelProperty(value = "支付内容")
+ private String content;
+
+
+ @ApiModelProperty(value = "解密结果")
+ private String descContent;
+
+
+ /**
+ * 支付方式
+ */
+ @ApiModelProperty(value = "支付方式")
+ private String paytype;
+
+ /**
+ * 支付名称
+ */
+ @ApiModelProperty(value = "支付名称")
+ private String payname;
+
+ /**
+ *
+ */
+ @ApiModelProperty(value = "")
+ private Date createtime;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getPaytype() {
+ return paytype;
+ }
+
+ public void setPaytype(String paytype) {
+ this.paytype = paytype;
+ }
+
+ public String getPayname() {
+ return payname;
+ }
+
+ public void setPayname(String payname) {
+ this.payname = payname;
+ }
+
+ public String getDescContent() {
+ return descContent;
+ }
+
+ public void setDescContent(String descContent) {
+ this.descContent = descContent;
+ }
+
+ public Date getCreatetime() {
+ return createtime;
+ }
+
+ public void setCreatetime(Date createtime) {
+ this.createtime = createtime;
+ }
+
+ }
\ No newline at end of file
diff --git a/health_framework/src/main/java/cn/card/health/config/DataSourceConfig.java b/health_framework/src/main/java/cn/card/health/config/DataSourceConfig.java
new file mode 100644
index 0000000..77b64b6
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/config/DataSourceConfig.java
@@ -0,0 +1,19 @@
+package cn.card.health.config;
+
+
+import javax.sql.DataSource;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class DataSourceConfig {
+ @Bean(name = "dataSource")
+ @ConfigurationProperties(prefix = "spring.datasource") // application.properteis中对应属性的前缀
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().build();
+ }
+
+}
diff --git a/health_framework/src/main/java/cn/card/health/config/HealthCardConfig.java b/health_framework/src/main/java/cn/card/health/config/HealthCardConfig.java
new file mode 100644
index 0000000..d702ffc
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/config/HealthCardConfig.java
@@ -0,0 +1,11 @@
+package cn.card.health.config;
+
+/**
+ * 项目配置
+ * @author xinggm
+ * @date 2021年5月26日
+ */
+public class HealthCardConfig {
+ /** 服务器地址 */
+ public static final String serverUrl = "http://www.hbyctr.com/healht_service";
+}
diff --git a/health_framework/src/main/java/cn/card/health/config/MybatisPubConfig.java b/health_framework/src/main/java/cn/card/health/config/MybatisPubConfig.java
new file mode 100644
index 0000000..12db3f7
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/config/MybatisPubConfig.java
@@ -0,0 +1,58 @@
+package cn.card.health.config;
+
+import javax.sql.DataSource;
+
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+
+@Configuration
+@MapperScan(basePackages = { "cn.card.health.mapper" }, sqlSessionFactoryRef = "sqlSessionFactory")
+public class MybatisPubConfig {
+ @Autowired
+ @Qualifier("dataSource")
+ private DataSource dataSource;
+
+ @Bean
+ public SqlSessionFactory sqlSessionFactory() throws Exception {
+ SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
+ factoryBean.setDataSource(dataSource);
+
+ // 获取PathMatchingResourcePatternResolver对象为扫描mapper文件做准备
+ PathMatchingResourcePatternResolver path = new PathMatchingResourcePatternResolver();
+ // 设置mapper文件位置
+ factoryBean.setMapperLocations(path.getResources("classpath*:mapper/**/*Mapper.xml"));
+ // 为javaBean对象设置别名
+ factoryBean.setTypeAliasesPackage("cn.card.health.bean");
+ return factoryBean.getObject();
+ }
+
+ @Bean
+ public SqlSessionTemplate sqlSessionTemplate() throws Exception {
+ SqlSessionTemplate template = new SqlSessionTemplate(sqlSessionFactory());
+ return template;
+ }
+
+// // 配置sqlSessionFactory
+// @Bean
+// public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
+// // 在spring和Mybatis整合中采用mybatis提供的SQLSessionFactoryBean对象
+// SqlSessionFactoryBean sqlSessionFactoryBean = sqlSessionFactory();
+// // 为sqlSessionFatoryBean设置连接池属性
+// sqlSessionFactoryBean.setDataSource(dataSource);
+// // 获取PathMatchingResourcePatternResolver对象为扫描mapper文件做准备
+// PathMatchingResourcePatternResolver path = new PathMatchingResourcePatternResolver();
+// // 设置mapper文件位置
+// sqlSessionFactoryBean.setMapperLocations(path.getResources("classpath*:mapper/**/*Mapper.xml"));
+// // 为javaBean对象设置别名
+// sqlSessionFactoryBean.setTypeAliasesPackage("cn.card.health");
+// // 返回SqlSessionFactory对象
+// return sqlSessionFactoryBean.getObject();
+// }
+}
diff --git a/health_framework/src/main/java/cn/card/health/config/Swagger2Config.java b/health_framework/src/main/java/cn/card/health/config/Swagger2Config.java
new file mode 100644
index 0000000..65d2b17
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/config/Swagger2Config.java
@@ -0,0 +1,74 @@
+package cn.card.health.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.swagger.annotations.ApiOperation;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.ApiKey;
+import springfox.documentation.service.AuthorizationScope;
+import springfox.documentation.service.SecurityReference;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+/**
+ * Swagger2配置
+ */
+@Configuration
+@EnableSwagger2
+public class Swagger2Config {
+ private boolean enabled = true;
+ @Bean
+ public Docket createRestApi() {
+ return new Docket(DocumentationType.SWAGGER_2).enable(enabled).apiInfo(apiInfo()).select() // 返回一个ApiSelectorBuilder实例用来控制哪些接口暴露给Swagger来展现
+ .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) // 采用指定扫描的包路径来定义,Swagger会扫描该包下所有Controller定义的API,并产生文档内容(除了被@ApiIgnore指定的请求)
+ .apis(RequestHandlerSelectors.basePackage("cn.card.health")).apis(RequestHandlerSelectors.any())
+ .paths(PathSelectors.any()).build().securitySchemes(securitySchemes())
+ .securityContexts(securityContexts());
+ }
+// public Docket createRestApi() {
+// return new Docket(DocumentationType.SWAGGER_2).enable(enabled).apiInfo(apiInfo()).select() // 返回一个ApiSelectorBuilder实例用来控制哪些接口暴露给Swagger来展现
+// .apis(RequestHandlerSelectors.basePackage("cn.card.health.**.web")) // 采用指定扫描的包路径来定义,Swagger会扫描该包下所有Controller定义的API,并产生文档内容(除了被@ApiIgnore指定的请求)
+// .paths(PathSelectors.any()).build().securitySchemes(securitySchemes())
+// .securityContexts(securityContexts());
+// }
+
+ /**
+ * 来创建该Api的基本信息(这些基本信息会展现在文档页面中)
+ */
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder().title("健康卡模块api").description("健康卡模块api").termsOfServiceUrl("localhost:2023")
+ .version("0.1").build();
+ }
+
+ private List securitySchemes() {
+ List apiKeys = new ArrayList<>();
+ apiKeys.add(new ApiKey("Authorization", "Authorization", "header"));
+ return apiKeys;
+ }
+
+ private List securityContexts() {
+ List securityContexts = new ArrayList<>();
+ securityContexts.add(SecurityContext.builder().securityReferences(defaultAuth())
+ .forPaths(PathSelectors.regex("^(?!auth).*$")).build());
+ return securityContexts;
+ }
+
+ private List defaultAuth() {
+ AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
+ AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
+ authorizationScopes[0] = authorizationScope;
+ List securityReferences = new ArrayList<>();
+ securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
+ return securityReferences;
+ }
+
+}
diff --git a/health_framework/src/main/java/cn/card/health/config/XBasicDataSource.java b/health_framework/src/main/java/cn/card/health/config/XBasicDataSource.java
new file mode 100644
index 0000000..ab28111
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/config/XBasicDataSource.java
@@ -0,0 +1,21 @@
+//package cn.card.health.config;
+//
+//import java.sql.DriverManager;
+//import java.sql.SQLException;
+//
+//import org.apache.commons.dbcp2.BasicDataSource;
+//
+//import com.mysql.cj.jdbc.AbandonedConnectionCleanupThread;
+//
+////import com.mysql.jdbc.AbandonedConnectionCleanupThread;
+//
+////import com.mysql.cj.jdbc.AbandonedConnectionCleanupThread;
+//
+//public class XBasicDataSource extends BasicDataSource {
+// @Override
+// public synchronized void close() throws SQLException {
+// DriverManager.deregisterDriver(DriverManager.getDriver(getUrl()));
+// AbandonedConnectionCleanupThread.checkedShutdown();
+// super.close();
+// }
+//}
diff --git a/health_framework/src/main/java/cn/card/health/entity/HealthCardInfoEntity.java b/health_framework/src/main/java/cn/card/health/entity/HealthCardInfoEntity.java
new file mode 100644
index 0000000..ebb7eaa
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/entity/HealthCardInfoEntity.java
@@ -0,0 +1,184 @@
+package cn.card.health.entity;
+
+/**
+ * 健康卡实体类
+ *
+ * @author 郭彬
+ * @date 2021年5月26日
+ */
+public class HealthCardInfoEntity {
+
+ /** 姓名 */
+ private String name;
+ /** 性别 男;女 */
+ private String gender;
+ /** 民族 */
+ private String nation;
+ /** 生日 */
+ private String birthday;
+ /** 卡号 */
+ private String idNumber;
+ /** 地址 */
+ private String address;
+ /** 手机号1 */
+ private String phone1;
+ /** 手机号2 */
+ private String phone2;
+ /** 二维码内容 */
+ private String qrCodeText;
+ /** 微信用户标志openid */
+ private String openId;
+ /**
+ * 卡类型 01 居民身份证, 02 居民户口簿, 03 护照 ,04 军官证, 05 驾驶证, 06 港澳居民来往内地通行证,07 台湾居民来往内地通行证,
+ * 08 出生医学证明, 09 医保, 10 就诊卡, 11 健康卡 ,99 其他法定有效证件
+ */
+ private String idType;
+ /** 健康卡 主索引 */
+ private String phid;
+ /** 院内 ID,院内用户唯一标识 */
+ private String patid;
+ /** 健康卡ID */
+ private String healthCardId;
+ /** 微信身份码 */
+ private String wechatCode;
+ /** 健康卡授权码 */
+ private String healthCode;
+ /** 主键 */
+ private Long id;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getGender() {
+ return gender;
+ }
+
+ public void setGender(String gender) {
+ this.gender = gender;
+ }
+
+ public String getNation() {
+ return nation;
+ }
+
+ public void setNation(String nation) {
+ this.nation = nation;
+ }
+
+ public String getBirthday() {
+ return birthday;
+ }
+
+ public void setBirthday(String birthday) {
+ this.birthday = birthday;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getIdNumber() {
+ return idNumber;
+ }
+
+ public void setIdNumber(String idNumber) {
+ this.idNumber = idNumber;
+ }
+
+ public String getPhone1() {
+ return phone1;
+ }
+
+ public void setPhone1(String phone1) {
+ this.phone1 = phone1;
+ }
+
+ public String getPhone2() {
+ return phone2;
+ }
+
+ public void setPhone2(String phone2) {
+ this.phone2 = phone2;
+ }
+
+ public String getQrCodeText() {
+ return qrCodeText;
+ }
+
+ public void setQrCodeText(String qrCodeText) {
+ this.qrCodeText = qrCodeText;
+ }
+
+ public String getOpenId() {
+ return openId;
+ }
+
+ public void setOpenId(String openId) {
+ this.openId = openId;
+ }
+
+ public String getIdType() {
+ return idType;
+ }
+
+ public void setIdType(String idType) {
+ this.idType = idType;
+ }
+
+ public String getPhid() {
+ return phid;
+ }
+
+ public void setPhid(String phid) {
+ this.phid = phid;
+ }
+
+ public String getPatid() {
+ return patid;
+ }
+
+ public void setPatid(String patid) {
+ this.patid = patid;
+ }
+
+ public String getHealthCardId() {
+ return healthCardId;
+ }
+
+ public void setHealthCardId(String healthCardId) {
+ this.healthCardId = healthCardId;
+ }
+
+ public String getWechatCode() {
+ return wechatCode;
+ }
+
+ public void setWechatCode(String wechatCode) {
+ this.wechatCode = wechatCode;
+ }
+
+ public String getHealthCode() {
+ return healthCode;
+ }
+
+ public void setHealthCode(String healthCode) {
+ this.healthCode = healthCode;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/entity/Image.java b/health_framework/src/main/java/cn/card/health/entity/Image.java
new file mode 100644
index 0000000..d057df3
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/entity/Image.java
@@ -0,0 +1,14 @@
+package cn.card.health.entity;
+
+public class Image {
+ /** */
+ private String imageContent;
+
+ public String getImageContent() {
+ return imageContent;
+ }
+
+ public void setImageContent(String imageContent) {
+ this.imageContent = imageContent;
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/entity/Phone.java b/health_framework/src/main/java/cn/card/health/entity/Phone.java
new file mode 100644
index 0000000..cddeff6
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/entity/Phone.java
@@ -0,0 +1,48 @@
+package cn.card.health.entity;
+
+public class Phone {
+ /**
+ *
+ */
+ private String phone;
+ /**
+ *
+ */
+ private String openId;
+
+ private String idNumber;
+
+ private String client;
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getOpenId() {
+ return openId;
+ }
+
+ public void setOpenId(String openId) {
+ this.openId = openId;
+ }
+
+ public void setIdNumber(String idNumber) {
+ this.idNumber = idNumber;
+ }
+
+ public String getIdNumber() {
+ return this.idNumber;
+ }
+
+ public void setClient(String client) {
+ this.client = client;
+ }
+
+ public String getClient() {
+ return this.client;
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/entity/Unbing.java b/health_framework/src/main/java/cn/card/health/entity/Unbing.java
new file mode 100644
index 0000000..f34b416
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/entity/Unbing.java
@@ -0,0 +1,14 @@
+package cn.card.health.entity;
+
+public class Unbing {
+ /** */
+ private String qrText;
+
+ public String getCode() {
+ return qrText;
+ }
+
+ public void setCode(String qrText) {
+ this.qrText = qrText;
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/framework/ScheduleRegistResource.java b/health_framework/src/main/java/cn/card/health/framework/ScheduleRegistResource.java
new file mode 100644
index 0000000..e4b5d5b
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/ScheduleRegistResource.java
@@ -0,0 +1,31 @@
+package cn.card.health.framework;
+
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.stereotype.Component;
+import cn.card.health.common.core.ApplicationContextUtil;
+
+/**
+ * 号源同步定时任务
+ * @author xinggm
+ * @date 2021年8月14日
+ */
+@Component
+@EnableScheduling
+public class ScheduleRegistResource {
+
+ private int count = 0;
+
+// @Scheduled(cron="*/5 * * * * ?")
+// @Scheduled(initialDelay = 10000, fixedRate = 3000)
+// public void test() {
+//
+// System.out.println(count++);
+// }
+//
+
+ public void print() {
+
+ ApplicationContextUtil.getBean("");
+
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/framework/UserLoginService.java b/health_framework/src/main/java/cn/card/health/framework/UserLoginService.java
new file mode 100644
index 0000000..21bf6a8
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/UserLoginService.java
@@ -0,0 +1,54 @@
+package cn.card.health.framework;
+
+import javax.annotation.Resource;
+
+import cn.card.health.common.exception.base.BaseException;
+import cn.card.health.common.redis.RedisCache;
+import cn.card.health.framework.service.alipay.TokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.stereotype.Service;
+
+import cn.card.health.bean.user.LoginUser;
+import cn.card.health.service.user.IYcUserService;
+
+@Service
+public class UserLoginService {
+
+ @Autowired
+ private TokenService tokenService;
+ @Resource
+ private AuthenticationManager authenticationManager;
+
+ @Autowired
+ private IYcUserService userService;
+
+ /**
+ * 登录验证
+ *
+ * @param username 用户名
+ * @return 结果
+ */
+ public String login(String username ) {
+
+ // 用户验证
+ Authentication authentication = null;
+ try {
+ // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
+ authentication = authenticationManager
+ .authenticate(new UsernamePasswordAuthenticationToken(username, ""));
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new BaseException(e.getMessage());
+ }
+ LoginUser loginUser = (LoginUser) authentication.getPrincipal();
+ // 生成token
+ return tokenService.createToken(loginUser);
+ }
+
+
+
+
+}
diff --git a/health_framework/src/main/java/cn/card/health/framework/config/ApplicationConfig.java b/health_framework/src/main/java/cn/card/health/framework/config/ApplicationConfig.java
new file mode 100644
index 0000000..20a9836
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/config/ApplicationConfig.java
@@ -0,0 +1,39 @@
+//package cn.card.health.framework.config;
+//
+//import org.apache.ibatis.session.SqlSessionFactory;
+//import org.mybatis.spring.annotation.MapperScan;
+//import org.springframework.boot.autoconfigure.SpringBootApplication;
+//import org.springframework.context.annotation.ComponentScan;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.context.annotation.EnableAspectJAutoProxy;
+//
+///**
+// *
+// * @author xinggm
+// * @date 2021年5月27日
+// */
+//@SpringBootApplication
+//@Configuration
+////表示通过aop框架暴露该代理对象,AopContext能够访问
+//@EnableAspectJAutoProxy(exposeProxy = true)
+////指定要扫描的Mapper类的包的路径
+//@MapperScan("cn.card.health.mapper")
+//@ComponentScan(basePackages="cn.card.health")
+//public class ApplicationConfig {
+// //配置sqlSessionFactory
+// @Bean
+// public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
+// //在spring和Mybatis整合中采用mybatis提供的SQLSessionFactoryBean对象
+// SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
+// //为sqlSessionFatoryBean设置连接池属性
+// sqlSessionFactoryBean.setDataSource(dataSource());
+// //获取PathMatchingResourcePatternResolver对象为扫描mapper文件做准备
+// PathMatchingResourcePatternResolver path = new PathMatchingResourcePatternResolver();
+// //设置mapper文件位置
+// sqlSessionFactoryBean.setMapperLocations(path.getResources("classpath*:com/hello/mapper/**/*.xml"));
+// //为javaBean对象设置别名
+// sqlSessionFactoryBean.setTypeAliasesPackage("com.hello.bean");
+// //返回SqlSessionFactory对象
+// return sqlSessionFactoryBean.getObject();
+// }
+//}
diff --git a/health_framework/src/main/java/cn/card/health/framework/config/JwtAuthenticationTokenFilter.java b/health_framework/src/main/java/cn/card/health/framework/config/JwtAuthenticationTokenFilter.java
new file mode 100644
index 0000000..fabe663
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/config/JwtAuthenticationTokenFilter.java
@@ -0,0 +1,45 @@
+package cn.card.health.framework.config;
+
+import java.io.IOException;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.card.health.bean.user.LoginUser;
+import cn.card.health.common.utils.StringUtils;
+import cn.card.health.common.utils.spring.SecurityUtils;
+import cn.card.health.framework.service.alipay.TokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
+import org.springframework.stereotype.Component;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+/**
+ * token过滤器 验证token有效性
+ *
+ * @author ruoyi
+ */
+@Component
+public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
+{
+ @Autowired
+ private TokenService tokenService;
+
+ @Override
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
+ throws ServletException, IOException
+ {
+ LoginUser loginUser = tokenService.getLoginUser(request);
+ if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication()))
+ {
+ tokenService.verifyToken(loginUser);
+ UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities());
+ authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
+ SecurityContextHolder.getContext().setAuthentication(authenticationToken);
+ }
+ chain.doFilter(request, response);
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/framework/config/ResourcesConfig.java b/health_framework/src/main/java/cn/card/health/framework/config/ResourcesConfig.java
new file mode 100644
index 0000000..ab7729e
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/config/ResourcesConfig.java
@@ -0,0 +1,62 @@
+package cn.card.health.framework.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * 通用配置
+ *
+ * @author yc
+ */
+@Configuration
+public class ResourcesConfig implements WebMvcConfigurer {
+// @Autowired
+// private RepeatSubmitInterceptor repeatSubmitInterceptor;
+
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ /** 本地文件上传路径 */
+ registry.addResourceHandler("/healthService" + "/**")
+ .addResourceLocations("file:" + "/healthService" + "/");
+
+ /** swagger配置 */
+ registry.addResourceHandler("swagger-ui.html").addResourceLocations(
+ "classpath:/META-INF/resources/");
+ registry.addResourceHandler("/webjars/**").addResourceLocations(
+ "classpath:/META-INF/resources/webjars/");
+ }
+
+// /**
+// * 自定义拦截规则
+// */
+// @Override
+// public void addInterceptors(InterceptorRegistry registry) {
+// registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
+//// registry.addInterceptor(gzipInterceptor).addPathPatterns("/**");
+// }
+
+ /**
+ * 跨域配置
+ */
+ @Bean
+ public CorsFilter corsFilter() {
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration config = new CorsConfiguration();
+ config.setAllowCredentials(true);
+ // 设置访问源地址
+ config.addAllowedOrigin("*");
+ // 设置访问源请求头
+ config.addAllowedHeader("*");
+ // 设置访问源请求方法
+ config.addAllowedMethod("*");
+ // 对接口配置跨域设置
+ source.registerCorsConfiguration("/**", config);
+ return new CorsFilter(source);
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/framework/config/SecurityConfig.java b/health_framework/src/main/java/cn/card/health/framework/config/SecurityConfig.java
new file mode 100644
index 0000000..32181c7
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/config/SecurityConfig.java
@@ -0,0 +1,141 @@
+package cn.card.health.framework.config;
+
+import cn.card.health.framework.security.handle.AuthenticationEntryPointImpl;
+import cn.card.health.framework.security.handle.LogoutSuccessHandlerImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+import org.springframework.security.web.authentication.logout.LogoutFilter;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * spring security配置
+ *
+ * @author ruoyi
+ */
+@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
+public class SecurityConfig extends WebSecurityConfigurerAdapter {
+ /**
+ * 自定义用户认证逻辑
+ */
+ @Autowired
+ private UserDetailsService userDetailsService;
+
+ /**
+ * 认证失败处理类
+ */
+ @Autowired
+ private AuthenticationEntryPointImpl unauthorizedHandler;
+
+ /**
+ * 退出处理类
+ */
+ @Autowired
+ private LogoutSuccessHandlerImpl logoutSuccessHandler;
+
+ /**
+ * token认证过滤器
+ */
+ @Autowired
+ private JwtAuthenticationTokenFilter authenticationTokenFilter;
+
+ /**
+ * 跨域过滤器
+ */
+ @Autowired
+ private CorsFilter corsFilter;
+
+ /**
+ * 解决 无法直接注入 AuthenticationManager
+ *
+ * @return
+ * @throws Exception
+ */
+ @Bean
+ @Override
+ public AuthenticationManager authenticationManagerBean() throws Exception {
+ return super.authenticationManagerBean();
+ }
+
+ /**
+ * anyRequest | 匹配所有请求路径
+ * access | SpringEl表达式结果为true时可以访问
+ * anonymous | 匿名可以访问
+ * denyAll | 用户不能访问
+ * fullyAuthenticated | 用户完全认证可以访问(非remember-me下自动登录)
+ * hasAnyAuthority | 如果有参数,参数表示权限,则其中任何一个权限可以访问
+ * hasAnyRole | 如果有参数,参数表示角色,则其中任何一个角色可以访问
+ * hasAuthority | 如果有参数,参数表示权限,则其权限可以访问
+ * hasIpAddress | 如果有参数,参数表示IP地址,如果用户IP和参数匹配,则可以访问
+ * hasRole | 如果有参数,参数表示角色,则其角色可以访问
+ * permitAll | 用户可以任意访问
+ * rememberMe | 允许通过remember-me登录的用户访问
+ * authenticated | 用户登录后可访问
+ */
+ @Override
+ protected void configure(HttpSecurity httpSecurity) throws Exception {
+ httpSecurity
+ // CSRF禁用,因为不使用session
+ .csrf().disable()
+ // 认证失败处理类
+ .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
+ // 基于token,所以不需要session
+ .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
+ // 过滤请求
+ .authorizeRequests()
+ // 对于登录login 注册register 验证码captchaImage 允许匿名访问
+ .antMatchers("/login", "/register", "/oauth/openidLogin", "/oauth/alipayLogin", "/hisQuery/*").permitAll()
+ .antMatchers("/captcha/get", "/captcha/check").permitAll()
+ .antMatchers("/thirdpay/*", "/insurance/**", "/alipay/**").permitAll()
+ .antMatchers(
+ HttpMethod.GET,
+ "/",
+ "/*.html",
+ "/**/*.html",
+ "/**/*.css",
+ "/**/*.js",
+ "/profile/**"
+ ).permitAll()
+ .antMatchers("/swagger-ui.html").anonymous()
+ .antMatchers("/swagger-resources/**").anonymous()
+ .antMatchers("/webjars/**").anonymous()
+ .antMatchers("/*/api-docs").anonymous()
+ .antMatchers("/druid/**").anonymous()
+ // 除上面外的所有请求全部需要鉴权认证
+ .anyRequest().authenticated()
+ .and()
+ .headers().frameOptions().disable();
+// httpSecurity.antMatcher("/hisQuery/*").anonymous();
+ httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
+ // 添加JWT filter
+ httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
+ // 添加CORS filter
+ httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
+ httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
+ }
+
+ /**
+ * 强散列哈希加密实现
+ */
+ @Bean
+ public BCryptPasswordEncoder bCryptPasswordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ /**
+ * 身份认证接口
+ */
+ @Override
+ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+ auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
+ }
+}
diff --git a/health_framework/src/main/java/cn/card/health/framework/security/handle/AuthenticationEntryPointImpl.java b/health_framework/src/main/java/cn/card/health/framework/security/handle/AuthenticationEntryPointImpl.java
new file mode 100644
index 0000000..1466c33
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/security/handle/AuthenticationEntryPointImpl.java
@@ -0,0 +1,35 @@
+package cn.card.health.framework.security.handle;
+
+import java.io.IOException;
+import java.io.Serializable;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.card.health.common.core.ServletUtils;
+import cn.card.health.common.utils.BaseResultJSON;
+import cn.card.health.common.utils.HttpStatus;
+import cn.card.health.common.utils.StringUtils;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.stereotype.Component;
+import com.alibaba.fastjson.JSON;
+
+/**
+ * 认证失败处理类 返回未授权
+ *
+ * @author ruoyi
+ */
+@Component
+public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable
+{
+ private static final long serialVersionUID = -8970718410437077606L;
+
+ @Override
+ public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
+ throws IOException
+ {
+ int code = HttpStatus.UNAUTHORIZED;
+ String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI());
+ ServletUtils.renderString(response, JSON.toJSONString(BaseResultJSON.error(code, msg)));
+ }
+}
\ No newline at end of file
diff --git a/health_framework/src/main/java/cn/card/health/framework/security/handle/LogoutSuccessHandlerImpl.java b/health_framework/src/main/java/cn/card/health/framework/security/handle/LogoutSuccessHandlerImpl.java
new file mode 100644
index 0000000..677fd2e
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/security/handle/LogoutSuccessHandlerImpl.java
@@ -0,0 +1,49 @@
+package cn.card.health.framework.security.handle;
+
+import cn.card.health.bean.user.LoginUser;
+import cn.card.health.common.core.ServletUtils;
+import cn.card.health.common.utils.BaseResultJSON;
+import cn.card.health.common.utils.HttpStatus;
+import cn.card.health.common.utils.StringUtils;
+import cn.card.health.framework.service.alipay.TokenService;
+import com.alibaba.fastjson.JSON;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * 自定义退出处理类 返回成功
+ *
+ * @author ruoyi
+ */
+@Configuration
+public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler
+{
+ @Autowired
+ private TokenService tokenService;
+
+ /**
+ * 退出处理
+ *
+ * @return
+ */
+ @Override
+ public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
+ throws IOException, ServletException
+ {
+ LoginUser loginUser = tokenService.getLoginUser(request);
+ if (StringUtils.isNotNull(loginUser))
+ {
+ String userName = loginUser.getUsername();
+ // 删除用户缓存记录
+ tokenService.delLoginUser(loginUser.getToken());
+ }
+ ServletUtils.renderString(response, JSON.toJSONString(BaseResultJSON.error(HttpStatus.SUCCESS, "退出成功")));
+ }
+}
\ No newline at end of file
diff --git a/health_framework/src/main/java/cn/card/health/framework/service/GetHeatlhCardService.java b/health_framework/src/main/java/cn/card/health/framework/service/GetHeatlhCardService.java
new file mode 100644
index 0000000..243e32e
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/service/GetHeatlhCardService.java
@@ -0,0 +1,433 @@
+//package cn.card.health.framework.service;
+//
+//import cn.card.health.common.utils.BaseResultJSON;
+//import cn.card.health.common.utils.wechat.ResponseWechatJSON;
+//import cn.card.health.helper.InitCommonIn;
+//import cn.card.health.service.HealthCardApptokenService;
+//import cn.card.health.service.HealthCardInfoService;
+//import cn.card.health.service.user.IYcPatientService;
+//import com.alibaba.fastjson.JSON;
+//import com.alibaba.fastjson.JSONArray;
+//import com.alibaba.fastjson.JSONObject;
+//import com.alipay.api.domain.HealthCardInfo;
+//import com.tencent.healthcard.HealthCardServer;
+//import com.tencent.healthcard.impl.HealthCardServerImpl;
+//import com.tencent.healthcard.model.CommonIn;
+//import com.tencent.healthcard.model.HealthCardInfo;
+//import com.tencent.healthcard.model.ReportHISData;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//import org.springframework.transaction.annotation.Transactional;
+//
+//import java.util.ArrayList;
+//import java.util.List;
+//
+//@Service
+//public class GetHeatlhCardService {
+// private Logger log = LoggerFactory.getLogger(GetHeatlhCardService.class);
+//
+// @Autowired
+// private HealthCardInfoService healthCardInfoService;
+// @Autowired
+// private HealthCardApptokenService healthCardApptokenService;
+// @Autowired
+// private IYcPatientService ycPatientService;
+//
+// /**
+// * 注册电子健康卡
+// *
+// * @param healthCardInfoReq
+// * @return
+// */
+// @Transactional
+// public JSONObject getHeathCard(HealthCardInfo healthCardInfoReq) {
+// /**
+// * 接口:注册健康卡接口
+// */
+// HealthCardInfo cardInfo = healthCardInfoService.findHealthCardInfoByIdNumber(healthCardInfoReq.getIdNumber(),
+// healthCardInfoReq.getOpenId());
+// JSONObject result = new JSONObject();
+// if (cardInfo == null) {
+// CommonIn commonIn = InitCommonIn.getCommonIn(getApptoken());
+// String idCard = healthCardInfoReq.getIdNumber();
+// int i = Integer.valueOf(idCard.substring(16, 17));
+// if (i % 2 == 1) {
+// healthCardInfoReq.setGender("男");
+// } else {
+// healthCardInfoReq.setGender("女");
+// }
+// String year = idCard.substring(6, 10);
+// String month = idCard.substring(10, 12);
+// String day = idCard.substring(12, 14);
+// healthCardInfoReq.setBirthday(year + "-" + month + "-" + day);
+// JSONObject healthCardInfoRsp = InitCommonIn.getHealthCard().registerHealthCard(commonIn, healthCardInfoReq);
+//
+// result = ResponseWechatJSON.getInstance(healthCardInfoRsp).getBaseResultJSON();
+//
+// if (result.getIntValue("retcode") != 0) {
+// result.put("retcode", 0);
+// result.put("retmsg", result.getString("retmsg"));
+// } else {
+// System.out.println(JSON.toJSONString(healthCardInfoRsp));
+// JSONObject rsp = healthCardInfoRsp.getJSONObject("rsp");
+// String qrCodeText = rsp.getString("qrCodeText");
+// String healthCardId = rsp.getString("healthCardId");
+// String adminExt = rsp.getString("adminExt");
+// healthCardInfoReq.setQrCodeText(qrCodeText);
+// healthCardInfoReq.setOpenId(healthCardInfoReq.getOpenId());
+// healthCardInfoReq.setHealthCardId(healthCardId);
+// int r = healthCardInfoService.insertHealthCardInfo(healthCardInfoReq);
+//// YcPatient patient = new YcPatient(healthCardInfoReq);
+//// int r = ycPatientService.addPatient(patient);
+// if (r != 1) {
+// result = BaseResultJSON.error(-1, "HIS建卡失败");
+// }
+// }
+// } else if (cardInfo.getPatid() == null || "".equals(cardInfo.getPatid())) {
+// //没有拿到HIS返回的patId
+// int r = healthCardInfoService.insertHealthCardInfo(cardInfo);
+// if (r != 1) {
+// result = BaseResultJSON.error(-1, "HIS建卡失败");
+// }
+// } else {
+//// result.put("retcode", -1);
+//// result.put("retmsg", "此号码您已注册,不可重复注册");
+// result = BaseResultJSON.error(-1, "此号码您已注册,不可重复注册");
+// }
+//
+// /*
+// if (result.getIntValue("retcode") != -1) {
+// //绑定健康卡和院内ID关系接口
+// ThreadUtil.execute(() -> {
+// HealthCardInfo info = healthCardInfoService.findHealthCardInfoByIdNumber(healthCardInfoReq.getIdNumber(),
+// healthCardInfoReq.getOpenId());
+// String patId = info.getPatid();
+// String qrCodeText = info.getQrCodeText();
+// if (!StrUtil.isBlank(patId) && !StrUtil.isBlank(qrCodeText)) {
+// JSONObject bindResult = bindCardRelation(patId, qrCodeText);
+// log.info("微信健康卡与院内ID关系绑定结果,健康卡{},院内卡{},绑定结果:{}", qrCodeText, patId, bindResult.toJSONString());
+// }
+// });
+// }
+// */
+//
+// return result;
+// }
+//
+// /**
+// * 注册电子健康卡
+// *
+// * @param healthCardInfoReq
+// * @return
+// */
+// @Transactional
+// public JSONObject getHospitalCard(HealthCardInfo healthCardInfoReq) {
+// HealthCardInfo cardInfo = healthCardInfoService.findHealthCardInfoByIdNumber(healthCardInfoReq.getIdNumber(),
+// healthCardInfoReq.getOpenId());
+// if (cardInfo == null) {
+// int r = healthCardInfoService.insertHealthCardInfo(healthCardInfoReq);
+// if (r != 1) {
+// log.info("患者:{},HIS建卡失败!", healthCardInfoReq.getOpenId());
+// return BaseResultJSON.error(-1, "HIS建卡失败");
+// }
+// } else if (cardInfo.getPatid() == null || "".equals(cardInfo.getPatid())) {
+// //没有拿到HIS返回的patId
+// int r = healthCardInfoService.insertHealthCardInfo(cardInfo);
+// if (r != 1) {
+// log.info("患者:{},HIS建卡失败!", healthCardInfoReq.getOpenId());
+// return BaseResultJSON.error(-1, "HIS建卡失败");
+// }
+// } else {
+// log.info("患者:{},此号码您已注册,不可重复注册!", healthCardInfoReq.getOpenId());
+// return BaseResultJSON.error(-1, "此号码您已注册,不可重复注册");
+// }
+// log.info("患者:{},建卡成功!", healthCardInfoReq.getOpenId());
+//
+// return BaseResultJSON.success("成功");
+// }
+//
+// /**
+// * 注册电子健康卡
+// *
+// * @param openid
+// * @param healthCode
+// * @return
+// */
+// public JSONObject relatedHeathCardByHealthCode(String openid, String healthCode) {
+// CommonIn commonIn = InitCommonIn.getCommonIn(getApptoken());
+// //根据用户和HealthCode查询健康卡
+// JSONObject response = InitCommonIn.getHealthCard().getHealthCardByHealthCode(commonIn, healthCode);
+// log.info("根据healthCode:{}获取用户的健康卡信息:{}", healthCode, response.toJSONString());
+//
+// if (response.getJSONObject("commonOut").getIntValue("resultCode") != 0) {
+// return BaseResultJSON.error("获取健康卡失败!错误信息:" + response.getJSONObject("commonOut").getString("errMsg"));
+// } else {
+// JSONObject cardInfoObj = response.getJSONObject("rsp").getJSONObject("card");
+// HealthCardInfo cardInfo = new HealthCardInfo();
+// cardInfo.setQrCodeText(cardInfoObj.getString("qrCodeText"));
+// cardInfo.setName(cardInfoObj.getString("name"));
+// cardInfo.setGender(cardInfoObj.getString("gender"));
+// cardInfo.setNation(cardInfoObj.getString("nation"));
+// cardInfo.setBirthday(cardInfoObj.getString("birthday"));
+// cardInfo.setIdNumber(cardInfoObj.getString("idNumber"));
+// cardInfo.setIdType(cardInfoObj.getString("idType"));
+// cardInfo.setAddress(cardInfoObj.getString("address"));
+// cardInfo.setPhone1(cardInfoObj.getString("phone1"));
+// cardInfo.setPhone2(cardInfoObj.getString("phone2"));
+// cardInfo.setHealthCardId(cardInfoObj.getString("healthCardId"));
+//
+// cardInfo.setOpenId(openid);
+//
+// HealthCardInfo cardInfo1 = healthCardInfoService.findHealthCardInfoByIdNumber(cardInfo.getIdNumber(), openid);
+// if (cardInfo1 != null) {
+// log.info("{}卡已存在,无须重复绑卡!", cardInfo.getName());
+// return BaseResultJSON.error("卡已存在,无须重复绑卡!");
+// } else {
+// //使用数据库进行加锁,防止并发产生数据库死锁
+// int lock = ycPatientService.registerLock(cardInfo.getIdNumber());
+// if (lock < 1) {
+// return BaseResultJSON.error("操作正在执行!");
+// }
+//
+// int r = healthCardInfoService.insertHealthCardInfo(cardInfo);
+//
+// //解锁
+// ycPatientService.registerUnlock(cardInfo.getIdNumber());
+//
+// JSONObject result;
+// if (r == 1) {
+// result = BaseResultJSON.success("绑卡成功!");
+// } else {
+// result = BaseResultJSON.error(-1, "HIS建卡失败");
+// }
+// return result;
+// }
+// }
+// }
+//
+// /**
+// * 批量升级健康卡
+// *
+// * @param healthCardInfoReqs
+// * @return
+// */
+// public JSONObject upgradeHeathCards(HealthCardInfo[] healthCardInfoReqs) {
+// /**
+// * 接口:批量健康卡接口
+// */
+// String wechatCode = "73EFA6796D3869FF82FAE7E81E9814B7";
+// String wechatUrl = "https://www.hbyctr.com/health_service/api/templateActiveHealthCard?openId=";
+//
+// BaseResultJSON result;
+// List healthCardItems = new ArrayList<>();
+//
+// // 遍历请求,获取注册信息
+// for (HealthCardInfo healthCardInfoReq : healthCardInfoReqs) {
+// HealthCardInfo cardInfo = healthCardInfoService.findHealthCardInfoByIdNumber(healthCardInfoReq.getIdNumber(),
+// healthCardInfoReq.getOpenId());
+// if (cardInfo == null) {
+// String idCard = healthCardInfoReq.getIdNumber();
+// int i = Integer.valueOf(idCard.substring(16, 17));
+// if (i % 2 == 1) {
+// healthCardInfoReq.setGender("男");
+// } else {
+// healthCardInfoReq.setGender("女");
+// }
+// String year = idCard.substring(6, 10);
+// String month = idCard.substring(10, 12);
+// String day = idCard.substring(12, 14);
+// healthCardInfoReq.setBirthday(year + "-" + month + "-" + day);
+// healthCardInfoReq.setIdType("01");
+//
+// // 离线WeChatcode
+// healthCardInfoReq.setWechatCode(wechatCode);
+// // 模版消息跳转url
+// healthCardInfoReq.setWechatUrl(wechatUrl + healthCardInfoReq.getOpenId());
+//
+// healthCardItems.add(healthCardInfoReq);
+// } else {
+// // 已注册健康卡,忽略??
+// }
+// }
+//
+// // 升级健康卡
+// CommonIn commonIn = InitCommonIn.getCommonIn(getApptoken());
+// JSONObject healthCardInfoRsp = InitCommonIn.getHealthCard().registerBatchHealthCard(commonIn, healthCardItems);
+//
+//// result.put("retcode", healthCardInfoRsp.getJSONObject("commonOut").getIntValue("resultCode"));
+//// result.put("retmsg", healthCardInfoRsp.getJSONObject("commonOut").getString("errMsg"));
+// ResponseWechatJSON responseWechatJson = ResponseWechatJSON.getInstance(healthCardInfoRsp);
+// result = responseWechatJson.getBaseResultJSON();
+//
+// if (responseWechatJson.getResultCode() == 0) {
+//// result.put("retcode", -1);
+//// result.put("retmsg", result.getString("retmsg"));
+// return result;
+// }
+// System.out.println(JSON.toJSONString(healthCardInfoRsp));
+// JSONObject rsp = responseWechatJson.getJsonResp();
+// JSONArray items = rsp.getJSONArray("rspItems");
+// JSONObject item = null;
+//
+// List failItems = new ArrayList<>();
+// for (int i = 0; i < items.size(); i++) {
+// item = items.getJSONObject(i);
+//
+// String qrCodeText = item.getString("qrCodeText");
+// String healthCardId = item.getString("healthCardId");
+// String idNumber = item.getString("idNumber");
+//
+// // 判断是否升级成功,成功则加入数据库
+// for (HealthCardInfo healthCardInfoReq : healthCardInfoReqs) {
+// String idCard = healthCardInfoReq.getIdNumber();
+//
+// if (idCard == idNumber) {
+// if (qrCodeText.length() > 0) {
+// healthCardInfoReq.setQrCodeText(qrCodeText);
+// healthCardInfoReq.setOpenId(healthCardInfoReq.getOpenId());
+// healthCardInfoReq.setHealthCardId(healthCardId);
+// healthCardInfoService.insertHealthCardInfo(healthCardInfoReq);
+// } else {
+// // qrCodeText 为空,升级失败
+// failItems.add(idNumber);
+// }
+// }
+// }
+// }
+//// result.put("failItems", failItems);
+// result = BaseResultJSON.success(failItems);
+//
+// // 打印返回结果
+// System.out.println(result);
+// return result;
+// }
+//
+// /**
+// * 通过二维码获取健康卡信息
+// *
+// * @param qrCodeText
+// * @return
+// */
+// public JSONObject getHealthCardByCode(String qrCodeText) {
+// HealthCardServer healthCardService = InitCommonIn.getHealthCard();
+// String token = getApptoken();
+// CommonIn commonIn = InitCommonIn.getCommonIn(token);
+// // 调用接口
+// JSONObject healthCardInfoRsp = healthCardService.getHealthCardByQRCode(commonIn, qrCodeText);
+//
+// // 解析json生成
+// ResponseWechatJSON responseWechatJSON = ResponseWechatJSON.getInstance(healthCardInfoRsp, "card");
+// // 响应请求
+// return responseWechatJSON.getBaseResultJSON();
+// }
+//
+// /**
+// * 通过健康卡授权码获取健康卡信息
+// *
+// * @param healthCode
+// * @return
+// */
+// public JSONObject getHealthCardByHealthCode(String healthCode) {
+// HealthCardServerImpl healthCard = InitCommonIn.getHealthCard();
+// // 调用接口
+// JSONObject healthCardInfoRsp = healthCard.getHealthCardByHealthCode(InitCommonIn.getCommonIn(getApptoken()),
+// healthCode);
+// // 解析json生成
+// ResponseWechatJSON responseWechatJSON = ResponseWechatJSON.getInstance(healthCardInfoRsp, "card");
+// return responseWechatJSON.getBaseResultJSON();
+// }
+//
+// public String getApptoken() {
+// String apptoken1;
+// Long expiresIn = healthCardApptokenService.findHealthCardExpiresIn();
+// Long dateTime = System.currentTimeMillis();
+// if (expiresIn == null || dateTime - expiresIn > 3600000 || dateTime - expiresIn < 0) {
+// apptoken1 = InitCommonIn.getApptoken();
+// Long expiresIn2 = System.currentTimeMillis();
+// healthCardApptokenService.updateHealthCardApptoken(apptoken1, expiresIn2);
+//
+// } else {
+// apptoken1 = healthCardApptokenService.findHealthCardApptoken();
+// }
+//
+// return apptoken1;
+// }
+//
+// /**
+// * 接口:用卡数据监测接口
+// */
+// public JSONObject bindCardRelation(String patId, String qrCodeText) {
+// // 调用接口
+// CommonIn commonIn = InitCommonIn.getCommonIn(getApptoken());
+// JSONObject reportHISDataRsp = InitCommonIn.getHealthCard().bindCardRelation(commonIn, patId, qrCodeText);
+// return ResponseWechatJSON.getInstance(reportHISDataRsp).getBaseResultJSON();
+// }
+//
+// /**
+// * 接口:用卡数据监测接口
+// */
+// public JSONObject reportHISData(ReportHISData reportHISData) {
+// // 调用接口
+// CommonIn commonIn = InitCommonIn.getCommonIn(getApptoken());
+// try {
+// JSONObject reportHISDataRsp = InitCommonIn.getHealthCard().reportHISData(commonIn, reportHISData);
+// // 打印响应
+// log.info("微信用卡数据监测上报结果:{}", JSON.toJSONString(reportHISDataRsp));
+// return ResponseWechatJSON.getInstance(reportHISDataRsp).getBaseResultJSON();
+// } catch (Exception e) {
+// log.info("微信用卡数据监测上报异常:{}", e.getMessage());
+// return BaseResultJSON.error("微信用卡数据上报异常!");
+// }
+//
+// }
+//
+// /**
+// * 接口:获取卡包订单ID接口
+// */
+// public String getOrderId(String qrCodeText) {
+// // 调用接口
+// CommonIn commonIn = InitCommonIn.getCommonIn(getApptoken());
+// JSONObject orderIdObj = InitCommonIn.getHealthCard().getOrderIdByOutAppId(commonIn, InitCommonIn.appId,
+// qrCodeText);
+// // 打印响应
+// String orderId = orderIdObj.getJSONObject("rsp").getString("orderId");
+// log.info("放入卡包orderId:{}", orderId);
+// return orderId;
+//
+// }
+//
+// /**
+// * 接口:身份证照片OCR接口
+// */
+// public JSONObject registerByOcr(String imageContent) {
+// // 调用接口
+// CommonIn commonIn = InitCommonIn.getCommonIn(getApptoken());
+// HealthCardServerImpl healthCard = InitCommonIn.getHealthCard();
+// JSONObject idCardInfo = healthCard.ocrInfo(commonIn, imageContent);
+// // 打印响应
+// System.out.println(JSON.toJSONString(idCardInfo));
+// return idCardInfo;
+//
+// }
+//
+// /**
+// * 获取动态二维码
+// *
+// * @param healthCardId
+// * @param idType
+// * @param idNumber
+// * @return
+// */
+// public JSONObject getDynamicQRCode(String healthCardId, String idType, String idNumber) {
+// HealthCardServerImpl healthCard = InitCommonIn.getHealthCard();
+// // 调用接口
+// JSONObject healthCardInfoRsp = healthCard.getDynamicQRCode(InitCommonIn.getCommonIn(getApptoken()),
+// healthCardId, idType, idNumber, "0");
+// // 解析json生成
+// ResponseWechatJSON responseWechatJSON = ResponseWechatJSON.getInstance(healthCardInfoRsp, null);
+// return responseWechatJSON.getBaseResultJSON();
+// }
+//
+//}
diff --git a/health_framework/src/main/java/cn/card/health/framework/service/HisCallService.java b/health_framework/src/main/java/cn/card/health/framework/service/HisCallService.java
new file mode 100644
index 0000000..c030091
--- /dev/null
+++ b/health_framework/src/main/java/cn/card/health/framework/service/HisCallService.java
@@ -0,0 +1,78 @@
+//package cn.card.health.framework.service;
+//
+//import java.util.ArrayList;
+//import java.util.Collections;
+//import java.util.Comparator;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//import org.springframework.stereotype.Service;
+//
+//import cn.card.health.bean.order.YcOrderRegist;
+//import cn.card.health.common.utils.DateUtils;
+//import cn.card.health.common.utils.MapUtils;
+//import cn.card.health.common.utils.Md5Utils;
+//import cn.card.health.common.utils.XMLUtils;
+//import cn.card.healthconfig.WechatConfig;
+//import cn.his.service.HisWebClient;
+//
+///**
+// * 调用his 服务
+// * @author xinggm
+// * @date 2021年7月13日
+// */
+//public interface HisCallService {
+//
+// // 4.2 患者信息匹配002
+// @SuppressWarnings({ "unchecked" })
+// public Map getPatientInfo(Map params);
+//
+// // 4.7 患者信息绑定003
+// @SuppressWarnings({ "unchecked" })
+// public Map bindPatientInfo(Map params) ;
+//
+// // 4.7 患者信息绑定003
+// public Map registCard(Map params) ;
+//
+// // 5.1.1 科室挂号信息查询接口001
+// public List