|
|
|
@ -5,7 +5,9 @@ import com.ynxbd.common.action.base.BaseAction; |
|
|
|
import com.ynxbd.common.bean.Patient; |
|
|
|
import com.ynxbd.common.bean.Patient; |
|
|
|
import com.ynxbd.common.bean.User; |
|
|
|
import com.ynxbd.common.bean.User; |
|
|
|
import com.ynxbd.common.bean.enums.HCardTypeEnum; |
|
|
|
import com.ynxbd.common.bean.enums.HCardTypeEnum; |
|
|
|
|
|
|
|
import com.ynxbd.common.bean.enums.HealthCardEnum; |
|
|
|
import com.ynxbd.common.bean.enums.HealthCardRespCodeEnum; |
|
|
|
import com.ynxbd.common.bean.enums.HealthCardRespCodeEnum; |
|
|
|
|
|
|
|
import com.ynxbd.common.bean.enums.HealthCardSceneEnum; |
|
|
|
import com.ynxbd.common.config.interceptor.AesDecode; |
|
|
|
import com.ynxbd.common.config.interceptor.AesDecode; |
|
|
|
import com.ynxbd.common.dao.PatientDao; |
|
|
|
import com.ynxbd.common.dao.PatientDao; |
|
|
|
import com.ynxbd.common.helper.HealthCardHelper; |
|
|
|
import com.ynxbd.common.helper.HealthCardHelper; |
|
|
|
@ -15,8 +17,10 @@ import com.ynxbd.common.helper.common.ValidHelper; |
|
|
|
import com.ynxbd.common.result.Result; |
|
|
|
import com.ynxbd.common.result.Result; |
|
|
|
import com.ynxbd.common.result.ResultEnum; |
|
|
|
import com.ynxbd.common.result.ResultEnum; |
|
|
|
import com.ynxbd.common.service.PatientService; |
|
|
|
import com.ynxbd.common.service.PatientService; |
|
|
|
|
|
|
|
import com.ynxbd.wx.wxfactory.AesWxHelper; |
|
|
|
import com.ynxbd.wx.wxfactory.WxCacheHelper; |
|
|
|
import com.ynxbd.wx.wxfactory.WxCacheHelper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.apache.struts2.convention.annotation.Action; |
|
|
|
import org.apache.struts2.convention.annotation.Action; |
|
|
|
import org.apache.struts2.convention.annotation.Namespace; |
|
|
|
import org.apache.struts2.convention.annotation.Namespace; |
|
|
|
import org.ehcache.Cache; |
|
|
|
import org.ehcache.Cache; |
|
|
|
@ -29,13 +33,23 @@ public class HealthCardAction extends BaseAction { |
|
|
|
* [电子健康卡]绑卡验证授权 |
|
|
|
* [电子健康卡]绑卡验证授权 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Action("registerHealthCardPreAuth") |
|
|
|
@Action("registerHealthCardPreAuth") |
|
|
|
public Result registerHealthCardPreAuth(Boolean isMiniApp, @AesDecode String openid, String wechatCode) { |
|
|
|
public Result registerHealthCardPreAuth(Boolean isMiniApp, Integer patientType, String wechatCode, String enHisPatientId) { |
|
|
|
log.info("[电子健康卡]绑卡验证授权 isMiniApp={}, wechatCode={}, openid={}", isMiniApp, wechatCode, openid); |
|
|
|
try { |
|
|
|
JSONObject result = new HealthCardHelper().registerHealthCardPreAuth(isMiniApp, false, wechatCode); |
|
|
|
log.info("[电子健康卡]绑卡验证授权 isMiniApp={}, patientType={}, wechatCode={}, enHisPatientId={}", isMiniApp, patientType, wechatCode, enHisPatientId); |
|
|
|
if (result == null) { |
|
|
|
if (wechatCode == null) { |
|
|
|
return Result.error(); |
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!ObjectUtils.isEmpty(enHisPatientId)) { |
|
|
|
|
|
|
|
String hisPatientId = AesWxHelper.decode(enHisPatientId); |
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(hisPatientId)) { |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_INVALID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JSONObject result = HealthCardHelper.registerHealthCardPreAuth(isMiniApp, false, patientType, wechatCode, enHisPatientId); |
|
|
|
return Result.success(result); |
|
|
|
return Result.success(result); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return Result.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -45,7 +59,7 @@ public class HealthCardAction extends BaseAction { |
|
|
|
@Action("registerHealthCardPreFill") |
|
|
|
@Action("registerHealthCardPreFill") |
|
|
|
public Result registerHealthCardPreFill(Boolean isMiniApp, @AesDecode String openid, String authCode, String name, String gender, String nation, String birthday, String idNumber, String phone) { |
|
|
|
public Result registerHealthCardPreFill(Boolean isMiniApp, @AesDecode String openid, String authCode, String name, String gender, String nation, String birthday, String idNumber, String phone) { |
|
|
|
log.info("[电子健康卡]验证注册/绑卡接口 isMiniApp={}, authCode={}, name={}, openid={}", isMiniApp, authCode, name, openid); |
|
|
|
log.info("[电子健康卡]验证注册/绑卡接口 isMiniApp={}, authCode={}, name={}, openid={}", isMiniApp, authCode, name, openid); |
|
|
|
JSONObject result = new HealthCardHelper().registerHealthCardPreFill(isMiniApp, authCode, name, gender, nation, birthday, |
|
|
|
JSONObject result = HealthCardHelper.registerHealthCardPreFill(isMiniApp, authCode, name, gender, nation, birthday, |
|
|
|
idNumber, HCardTypeEnum._01, phone); |
|
|
|
idNumber, HCardTypeEnum._01, phone); |
|
|
|
if (result == null) { |
|
|
|
if (result == null) { |
|
|
|
return Result.error(); |
|
|
|
return Result.error(); |
|
|
|
@ -181,101 +195,77 @@ public class HealthCardAction extends BaseAction { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* [升级绑定]-->已在HIS绑定-->注册健康卡 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param wechatCode wechatCode |
|
|
|
|
|
|
|
* @param id id |
|
|
|
|
|
|
|
* @param idCardNo idCardNo |
|
|
|
|
|
|
|
* @param cardType cardType |
|
|
|
|
|
|
|
* @param openid openid |
|
|
|
|
|
|
|
* @param tel tel |
|
|
|
|
|
|
|
* @param name name |
|
|
|
|
|
|
|
* @param nation nation |
|
|
|
|
|
|
|
* @param patientId patientId |
|
|
|
|
|
|
|
* @param address address |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Action("upBindCard") |
|
|
|
|
|
|
|
public Result upBindCard(String wechatCode, Integer id, @AesDecode String idCardNo, @AesDecode String patientId, String cardType, String openid, String tel, String name, String nation, String address) { |
|
|
|
|
|
|
|
log.info("[电子健康卡]升级绑定 id={}, name={}, address={}, nation={}, patientId={}, tel={}, idType={}, wechatCode={}", id, name, address, nation, patientId, tel, cardType, wechatCode); |
|
|
|
|
|
|
|
if (wechatCode == null || openid == null || patientId == null || name == null || idCardNo == null || tel == null || address == null || nation == null) { |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cardType == null) cardType = HCardTypeEnum._01.WX_CODE; |
|
|
|
@Action("getCardOrderId") |
|
|
|
HCardTypeEnum cardTypeEnum = HCardTypeEnum.toTypeByWxCode(cardType); |
|
|
|
public Result getCardOrderId(Boolean isMiniApp, @AesDecode String idCardNo, String healthCardId) { |
|
|
|
if (cardTypeEnum == null) { |
|
|
|
log.info("[电子健康卡]获取卡包订单ID healthCardId={}, idCardNo={}", healthCardId, idCardNo); |
|
|
|
return Result.error(ResultEnum.CARD_TYPE_NOT_FOUNT); |
|
|
|
if (healthCardId == null || idCardNo == null) { |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); // 参数缺失
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!ValidHelper.isValidNation(nation)) { |
|
|
|
String qrCodeText = HealthCardHelper.getQRCodeText(isMiniApp, healthCardId, idCardNo); |
|
|
|
return Result.error(ResultEnum.NATION_ERROR); |
|
|
|
if (qrCodeText == null) { |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); // qrCodeText参数缺失
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
JSONObject result = HealthCardHelper.getOrderIdByOutAppId(isMiniApp, qrCodeText); |
|
|
|
String sex = IDNumberHelper.getSex(idCardNo); |
|
|
|
if (result == null) { |
|
|
|
String birthday = IDNumberHelper.getBirthday(idCardNo); |
|
|
|
return Result.error(); |
|
|
|
if (sex == null || birthday == null) { // 身份证解析数据错误
|
|
|
|
|
|
|
|
log.info("[电子健康卡]升级绑失败,身份证解析数据错误 sex={} birthday={}", sex, birthday); |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_TYPE_ERROR); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return Result.success(result); |
|
|
|
// 先注册,后修改-->先获取健康卡ID
|
|
|
|
|
|
|
|
JSONObject rspObj = HealthCardHelper.registerHealthCard(false, patientId, wechatCode, birthday, cardTypeEnum, address, null, sex, nation, name, idCardNo, tel); |
|
|
|
|
|
|
|
if (rspObj == null) { |
|
|
|
|
|
|
|
log.info("[电子健康卡]升级绑定失败, 响应内容为空"); |
|
|
|
|
|
|
|
return Result.error("[电子健康卡]升级绑定失败, 响应内容为空"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String healthCardId = rspObj.getString("healthCardId"); |
|
|
|
|
|
|
|
if (healthCardId == null) { |
|
|
|
|
|
|
|
// 响应处理
|
|
|
|
|
|
|
|
String errMsg = rspObj.getString("errMsg"); |
|
|
|
|
|
|
|
String resultCode = rspObj.getString("resultCode"); |
|
|
|
|
|
|
|
HealthCardRespCodeEnum healthCardRespCodeEnum = HealthCardRespCodeEnum.findEnumByResultCode(resultCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("[电子健康卡]升级绑定失败原因 resultCode={}, errMsg={}, statusMsg={}", resultCode, errMsg, healthCardRespCodeEnum.MESSAGE); |
|
|
|
@Action("registerUniformVerifyOrder") |
|
|
|
return Result.error(healthCardRespCodeEnum.MESSAGE); |
|
|
|
public Result registerUniformVerifyOrder(Boolean isMiniApp, String wechatCode, String sceneCode, String name, String idCardNo) { |
|
|
|
|
|
|
|
log.info("[电子健康卡]实人认证生成orderId isMiniApp={}, wechatCode={}, sceneCode={}, name={}, idCardNo={}", isMiniApp, wechatCode, sceneCode, name, idCardNo); |
|
|
|
|
|
|
|
if (idCardNo == null || name == null || wechatCode == null) { |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); // 参数为空
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
HealthCardSceneEnum sceneEnum = HealthCardSceneEnum.findEnum(sceneCode); |
|
|
|
Patient bindInfo = new Patient(); |
|
|
|
if (sceneEnum == null) { |
|
|
|
bindInfo.setOpenid(openid); |
|
|
|
return Result.error(ResultEnum.PARAM_IS_INVALID); |
|
|
|
bindInfo.setPatientId(patientId); |
|
|
|
|
|
|
|
bindInfo.setIdCardNo(idCardNo); |
|
|
|
|
|
|
|
bindInfo.setHealthCardId(healthCardId); |
|
|
|
|
|
|
|
bindInfo.setName(name); |
|
|
|
|
|
|
|
bindInfo.setNation(nation); |
|
|
|
|
|
|
|
bindInfo.setTel(tel); |
|
|
|
|
|
|
|
bindInfo.setAddress(address); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean isUpdate = new PatientDao().updateInfo(bindInfo, id); |
|
|
|
|
|
|
|
if (isUpdate) { |
|
|
|
|
|
|
|
Cache<String, User> cache = WxCacheHelper.getUserCacheManager(); |
|
|
|
|
|
|
|
cache.remove(openid); |
|
|
|
|
|
|
|
return Result.success(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject dataJson = HealthCardHelper.registerUniformVerifyOrder(isMiniApp, wechatCode, sceneEnum, name, idCardNo); |
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(dataJson)) { |
|
|
|
return Result.error(); |
|
|
|
return Result.error(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return Result.success(dataJson); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Action("checkUniformVerifyResult") |
|
|
|
|
|
|
|
public Result checkUniformVerifyResult(Boolean isMiniApp, String orderId, String registerOrderId) { |
|
|
|
|
|
|
|
log.info("[电子健康卡]实人认证结果查询 isMiniApp={}, orderId={}, registerOrderId={}", isMiniApp, orderId, registerOrderId); |
|
|
|
|
|
|
|
if (orderId == null || registerOrderId == null) { |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); // 参数为空
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Result.isOK(HealthCardHelper.checkUniformVerifyResult(isMiniApp, orderId, registerOrderId)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* [电子健康卡]获取卡包订单ID |
|
|
|
* 健康卡[上报数据] |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param scene 上报类型编码 |
|
|
|
|
|
|
|
* @param openid openid |
|
|
|
|
|
|
|
* @param idCardNo 身份证 |
|
|
|
|
|
|
|
* @param healthCardId 健康卡id |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Action("getCardOrderId") |
|
|
|
@Action("reportHISData") |
|
|
|
public Result getCardOrderId(Boolean isMiniApp, @AesDecode String idCardNo, String healthCardId) { |
|
|
|
public Result reportHISData(String scene, @AesDecode String openid, @AesDecode String idCardNo, String healthCardId) { |
|
|
|
log.info("[电子健康卡]获取卡包订单ID healthCardId={}, idCardNo={}", healthCardId, idCardNo); |
|
|
|
if (scene == null || openid == null || healthCardId == null || idCardNo == null) { |
|
|
|
if (healthCardId == null || idCardNo == null) { |
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); // 参数缺失
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String qrCodeText = HealthCardHelper.getQRCodeText(isMiniApp, healthCardId, idCardNo); |
|
|
|
String qrCodeText = HealthCardHelper.getQRCodeText(false, healthCardId, idCardNo); |
|
|
|
if (qrCodeText == null) { |
|
|
|
if (qrCodeText == null) { |
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); // qrCodeText参数缺失
|
|
|
|
return Result.error(ResultEnum.INTERFACE_OUTER_INVOKE_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
JSONObject result = HealthCardHelper.getOrderIdByOutAppId(isMiniApp, qrCodeText); |
|
|
|
|
|
|
|
if (result == null) { |
|
|
|
JSONObject dataJson = HealthCardHelper.reportHISData(qrCodeText, null, scene, HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null); |
|
|
|
|
|
|
|
if (dataJson == null) { |
|
|
|
return Result.error(); |
|
|
|
return Result.error(); |
|
|
|
} |
|
|
|
} |
|
|
|
return Result.success(result); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|