Kaynağa Gözat

fix 修改异常类

DYH2020 1 yıl önce
ebeveyn
işleme
dd2f5cbe04

+ 0 - 12
ywt-platform-outpatient-taihe-rpc/src/main/java/com/ywt/outpatient/taihe/rpc/core/AppMessageException.java

@@ -1,12 +0,0 @@
-package com.ywt.outpatient.taihe.rpc.core;
-
-/**
- * @author Walker
- * Created on 2019/12/30
- */
-public class AppMessageException extends Exception {
-    public AppMessageException(){}
-    public AppMessageException(String msg){
-        super(msg);
-    }
-}

+ 19 - 18
ywt-platform-outpatient-taihe-rpc/src/main/java/com/ywt/outpatient/taihe/rpc/core/utils/CheckUtil.java

@@ -1,6 +1,7 @@
 package com.ywt.outpatient.taihe.rpc.core.utils;
 package com.ywt.outpatient.taihe.rpc.core.utils;
 
 
-import com.ywt.outpatient.taihe.rpc.core.AppMessageException;
+import com.ywt.biz.common.constant.YwtCommonRespCode;
+import com.ywt.biz.common.exception.YwtCommonException;
 
 
 
 
 /**
 /**
@@ -12,43 +13,43 @@ public final class CheckUtil {
     public static final int INPUT_TEXT_LENGTH_10 = 10;
     public static final int INPUT_TEXT_LENGTH_10 = 10;
     public static final int INPUT_TEXT_LENGTH_20 = 20;
     public static final int INPUT_TEXT_LENGTH_20 = 20;
 
 
-    public static void ensureNotEmpty(String val, String msg) throws AppMessageException {
-        if (StringHelper.isNullOrEmpty(val)) throw new AppMessageException(msg);
+    public static void ensureNotEmpty(String val, String msg) throws YwtCommonException {
+        if (StringHelper.isNullOrEmpty(val)) throw new YwtCommonException(YwtCommonRespCode.P_ERR, msg);
     }
     }
 
 
-    public static void ensureStringLength(String val, int length, String msg) throws AppMessageException {
-        if (Checker.getStringValue(val).trim().length() > length) throw new AppMessageException(msg);
+    public static void ensureStringLength(String val, int length, String msg) throws YwtCommonException {
+        if (Checker.getStringValue(val).trim().length() > length) throw new YwtCommonException(YwtCommonRespCode.P_ERR, msg);
     }
     }
 
 
-    public static void ensureLargerThanZero(Integer val, String msg) throws AppMessageException {
-        if (Checker.getIntegerValue(val) <= 0) throw new AppMessageException(msg);
+    public static void ensureLargerThanZero(Integer val, String msg) throws YwtCommonException {
+        if (Checker.getIntegerValue(val) <= 0) throw new YwtCommonException(YwtCommonRespCode.P_ERR, msg);
     }
     }
 
 
-    public static void ensurePositive(Integer val, String msg) throws AppMessageException {
-        if (Checker.getIntegerValue(val) < 0) throw new AppMessageException(msg);
+    public static void ensurePositive(Integer val, String msg) throws YwtCommonException {
+        if (Checker.getIntegerValue(val) < 0) throw new YwtCommonException(YwtCommonRespCode.P_ERR, msg);
     }
     }
 
 
-    public static void ensureLargerThanZero(Double val, String msg) throws AppMessageException {
-        if (Checker.getDoubleValue(val) <= 0) throw new AppMessageException(msg);
+    public static void ensureLargerThanZero(Double val, String msg) throws YwtCommonException {
+        if (Checker.getDoubleValue(val) <= 0) throw new YwtCommonException(YwtCommonRespCode.P_ERR, msg);
     }
     }
 
 
-    public static void ensureLargerThanZero(Long val, String msg) throws AppMessageException {
-        if (Checker.getLongValue(val) <= 0) throw new AppMessageException(msg);
+    public static void ensureLargerThanZero(Long val, String msg) throws YwtCommonException {
+        if (Checker.getLongValue(val) <= 0) throw new YwtCommonException(YwtCommonRespCode.P_ERR, msg);
     }
     }
 
 
-    public static void ensureNotNull(Object obj, String msg) throws AppMessageException {
-        if (obj == null) throw new AppMessageException(msg);
+    public static void ensureNotNull(Object obj, String msg) throws YwtCommonException {
+        if (obj == null) throw new YwtCommonException(YwtCommonRespCode.P_ERR, msg);
     }
     }
 
 
-    public static void limitString100(String val, String msg) throws AppMessageException {
+    public static void limitString100(String val, String msg) throws YwtCommonException {
         ensureStringLength(val, INPUT_TEXT_LENGTH_100, msg);
         ensureStringLength(val, INPUT_TEXT_LENGTH_100, msg);
     }
     }
 
 
-    public static void limitString10(String val, String msg) throws AppMessageException {
+    public static void limitString10(String val, String msg) throws YwtCommonException {
         ensureStringLength(val, INPUT_TEXT_LENGTH_10, msg);
         ensureStringLength(val, INPUT_TEXT_LENGTH_10, msg);
     }
     }
 
 
-    public static void limitStringForName(String val, String msg) throws AppMessageException {
+    public static void limitStringForName(String val, String msg) throws YwtCommonException {
         ensureStringLength(val, INPUT_TEXT_LENGTH_20, msg);
         ensureStringLength(val, INPUT_TEXT_LENGTH_20, msg);
     }
     }
 }
 }

+ 5 - 4
ywt-platform-outpatient-taihe-rpc/src/main/java/com/ywt/outpatient/taihe/rpc/core/utils/IdCardUtil.java

@@ -1,6 +1,7 @@
 package com.ywt.outpatient.taihe.rpc.core.utils;
 package com.ywt.outpatient.taihe.rpc.core.utils;
 
 
-import com.ywt.outpatient.taihe.rpc.core.AppMessageException;
+import com.ywt.biz.common.constant.YwtCommonRespCode;
+import com.ywt.biz.common.exception.YwtCommonException;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -337,15 +338,15 @@ public final class IdCardUtil {
      * @param idNo 身份证号码
      * @param idNo 身份证号码
      * @param birthday 出生日期
      * @param birthday 出生日期
      * @return 年龄
      * @return 年龄
-     * @throws AppMessageException 非合法大陆身份证,或港澳台身份证但无出生日期,则抛出异常
+     * @throws YwtCommonException 非合法大陆身份证,或港澳台身份证但无出生日期,则抛出异常
      */
      */
-    public static int calcAgeByIdNoAndBirthday(String idNo, String birthday) throws AppMessageException {
+    public static int calcAgeByIdNoAndBirthday(String idNo, String birthday) throws YwtCommonException {
         if (!Checker.isNone(idNo) && IdCardUtil.verifyMainlandIdCard(idNo)) {
         if (!Checker.isNone(idNo) && IdCardUtil.verifyMainlandIdCard(idNo)) {
             return IdCardUtil.getCurrentAge(idNo);
             return IdCardUtil.getCurrentAge(idNo);
         } else {
         } else {
             // 如果身份证号为空或者非大陆身份证,则根据his系统录入的出生年月日
             // 如果身份证号为空或者非大陆身份证,则根据his系统录入的出生年月日
             int curAge = IdCardUtil.getCurrentAgeByBirthday(birthday);
             int curAge = IdCardUtil.getCurrentAgeByBirthday(birthday);
-            if (curAge < 0) throw new AppMessageException("当前诊疗卡未绑定出生日期信息,请完善");
+            if (curAge < 0) throw new YwtCommonException(YwtCommonRespCode.P_ERR, "当前诊疗卡未绑定出生日期信息,请完善");
             return curAge;
             return curAge;
         }
         }
     }
     }

+ 14 - 13
ywt-platform-outpatient-taihe-rpc/src/main/java/com/ywt/outpatient/taihe/rpc/provider/MriProvider.java

@@ -1,10 +1,11 @@
 package com.ywt.outpatient.taihe.rpc.provider;
 package com.ywt.outpatient.taihe.rpc.provider;
 
 
 
 
+import com.ywt.biz.common.constant.YwtCommonRespCode;
+import com.ywt.biz.common.exception.YwtCommonException;
 import com.ywt.biz.common.util.serializers.JsonSerializer;
 import com.ywt.biz.common.util.serializers.JsonSerializer;
 import com.ywt.gapi.ResultCode;
 import com.ywt.gapi.ResultCode;
 import com.ywt.gapi.taihe.biz.*;
 import com.ywt.gapi.taihe.biz.*;
-import com.ywt.outpatient.taihe.rpc.core.AppMessageException;
 import com.ywt.outpatient.taihe.rpc.core.utils.Checker;
 import com.ywt.outpatient.taihe.rpc.core.utils.Checker;
 import com.ywt.outpatient.taihe.rpc.core.utils.DateUtil;
 import com.ywt.outpatient.taihe.rpc.core.utils.DateUtil;
 import com.ywt.outpatient.taihe.rpc.domain.entity.center.*;
 import com.ywt.outpatient.taihe.rpc.domain.entity.center.*;
@@ -63,15 +64,15 @@ public class MriProvider extends DubboTaiheBizServiceTriple.TaiheBizServiceImplB
         MriBaseResponse.Builder builder = MriBaseResponse.newBuilder();
         MriBaseResponse.Builder builder = MriBaseResponse.newBuilder();
         try {
         try {
             Date bookDate = validateBookDate(date);
             Date bookDate = validateBookDate(date);
-            if (userId <= 0) throw new AppMessageException("用户 id 不正确");
+            if (userId <= 0) throw new YwtCommonException(YwtCommonRespCode.P_ERR, "用户 id 不正确");
             // 一名患者,一个日期,只能预约一个号,以“手机号”来判断是一个患者。当患者重复预约时,点击提交,提示“患者已预约,请勿重复预约”
             // 一名患者,一个日期,只能预约一个号,以“手机号”来判断是一个患者。当患者重复预约时,点击提交,提示“患者已预约,请勿重复预约”
-            if (checkHasBooked(mobile, bookDate)) throw new AppMessageException("患者已预约,请勿重复预约");
+            if (checkHasBooked(mobile, bookDate)) throw new YwtCommonException(YwtCommonRespCode.P_ERR, "患者已预约,请勿重复预约");
             // 当患者被后台标志 N 次以上(包含 N 次)预约不就诊的,拉入黑名单,患者点击提交时,提示“用户过去 N 次预约未就诊,已被拉入黑名单”。
             // 当患者被后台标志 N 次以上(包含 N 次)预约不就诊的,拉入黑名单,患者点击提交时,提示“用户过去 N 次预约未就诊,已被拉入黑名单”。
-            if (checkIfInBlackList(mobile)) throw new AppMessageException(String.format("用户过去 %d 次预约未就诊,已被拉入黑名单",
+            if (checkIfInBlackList(mobile)) throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("用户过去 %d 次预约未就诊,已被拉入黑名单",
                     configProvider.getMriBlackListLimitation()));
                     configProvider.getMriBlackListLimitation()));
             // 每天最多只有 N 个号源
             // 每天最多只有 N 个号源
             // TODO: 并发控制
             // TODO: 并发控制
-            if (checkIfFullyBooked(bookDate)) throw new AppMessageException("当前选择的时间已约满,请更换时间重试");
+            if (checkIfFullyBooked(bookDate)) throw new YwtCommonException(YwtCommonRespCode.P_ERR, "当前选择的时间已约满,请更换时间重试");
             // 可以预约,插入数据
             // 可以预约,插入数据
             MriSubscribe subscribe = new MriSubscribe();
             MriSubscribe subscribe = new MriSubscribe();
             subscribe.setCreateTime(new Date());
             subscribe.setCreateTime(new Date());
@@ -88,7 +89,7 @@ public class MriProvider extends DubboTaiheBizServiceTriple.TaiheBizServiceImplB
             taiheWeChatMsgService.sendMsgForMriBooking(userId, name, mobile, date);
             taiheWeChatMsgService.sendMsgForMriBooking(userId, name, mobile, date);
             builder.setCode(ResultCode.SUCCEED_VALUE).setInfo("操作成功");
             builder.setCode(ResultCode.SUCCEED_VALUE).setInfo("操作成功");
             return builder.build();
             return builder.build();
-        } catch (AppMessageException e) {
+        } catch (YwtCommonException e) {
             builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setInfo(e.getMessage());
             builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setInfo(e.getMessage());
             return builder.build();
             return builder.build();
         } catch (Exception e) {
         } catch (Exception e) {
@@ -97,15 +98,15 @@ public class MriProvider extends DubboTaiheBizServiceTriple.TaiheBizServiceImplB
         }
         }
     }
     }
 
 
-    private Date validateBookDate(String date) throws AppMessageException {
+    private Date validateBookDate(String date) throws YwtCommonException {
         Date bookDate = DateUtil.stringToDate(date, BIRTHDAY_FORMAT);
         Date bookDate = DateUtil.stringToDate(date, BIRTHDAY_FORMAT);
-        if (bookDate == null) throw new AppMessageException("日期格式不正确");
+        if (bookDate == null) throw new YwtCommonException(YwtCommonRespCode.P_ERR, "日期格式不正确");
         // 只能预约未来 N 天的号(当天不能预约)
         // 只能预约未来 N 天的号(当天不能预约)
         LocalDate bookLocalDate = DateUtil.convertToLocalDate(bookDate);
         LocalDate bookLocalDate = DateUtil.convertToLocalDate(bookDate);
         LocalDate today = LocalDate.now();
         LocalDate today = LocalDate.now();
         LocalDate maxDate = today.plusDays(configProvider.getMriMaxBookDay());
         LocalDate maxDate = today.plusDays(configProvider.getMriMaxBookDay());
         if (!bookLocalDate.isAfter(today) || bookLocalDate.isAfter(maxDate))
         if (!bookLocalDate.isAfter(today) || bookLocalDate.isAfter(maxDate))
-            throw new AppMessageException(String.format("只能预约未来 %d 天的号", configProvider.getMriMaxBookDay()));
+            throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("只能预约未来 %d 天的号", configProvider.getMriMaxBookDay()));
         return bookDate;
         return bookDate;
     }
     }
 
 
@@ -190,7 +191,7 @@ public class MriProvider extends DubboTaiheBizServiceTriple.TaiheBizServiceImplB
             if (tableId > 0) {
             if (tableId > 0) {
                 // 更新筛查表
                 // 更新筛查表
                 mriScreening = mriScreeningRepository.findById(tableId).orElse(null);
                 mriScreening = mriScreeningRepository.findById(tableId).orElse(null);
-                if (mriScreening == null) throw new AppMessageException(String.format("记录 id 不存在:%d", tableId));
+                if (mriScreening == null) throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("记录 id 不存在:%d", tableId));
             } else {
             } else {
                 // 插入新的记录
                 // 插入新的记录
                 mriScreening = new MriScreening();
                 mriScreening = new MriScreening();
@@ -201,7 +202,7 @@ public class MriProvider extends DubboTaiheBizServiceTriple.TaiheBizServiceImplB
                 mriScreening.setPatientName(patientInfo.getPatientName());
                 mriScreening.setPatientName(patientInfo.getPatientName());
                 mriScreening.setSex(patientInfo.getSex());
                 mriScreening.setSex(patientInfo.getSex());
                 Date d = DateUtil.stringToDate(patientInfo.getBirthday(), BIRTHDAY_FORMAT);
                 Date d = DateUtil.stringToDate(patientInfo.getBirthday(), BIRTHDAY_FORMAT);
-                if (d == null) throw new AppMessageException("出生年月格式不正确!");
+                if (d == null) throw new YwtCommonException(YwtCommonRespCode.P_ERR, "出生年月格式不正确!");
                 mriScreening.setBirthday(d);
                 mriScreening.setBirthday(d);
                 mriScreening.setPatientMobile(patientInfo.getPatientMobile());
                 mriScreening.setPatientMobile(patientInfo.getPatientMobile());
                 mriScreening.setAddress(patientInfo.getAddress());
                 mriScreening.setAddress(patientInfo.getAddress());
@@ -225,7 +226,7 @@ public class MriProvider extends DubboTaiheBizServiceTriple.TaiheBizServiceImplB
             MriScreening result = mriScreeningRepository.save(mriScreening);
             MriScreening result = mriScreeningRepository.save(mriScreening);
             builder.setCode(ResultCode.SUCCEED_VALUE).setMsg("操作成功").setTableId(result.getId());
             builder.setCode(ResultCode.SUCCEED_VALUE).setMsg("操作成功").setTableId(result.getId());
             return builder.build();
             return builder.build();
-        } catch (AppMessageException e) {
+        } catch (YwtCommonException e) {
             builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setMsg(e.getMessage());
             builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setMsg(e.getMessage());
             return builder.build();
             return builder.build();
         } catch (Exception e) {
         } catch (Exception e) {
@@ -376,7 +377,7 @@ public class MriProvider extends DubboTaiheBizServiceTriple.TaiheBizServiceImplB
             if (leftBookNum < 0) leftBookNum = 0;
             if (leftBookNum < 0) leftBookNum = 0;
             builder.setCode(ResultCode.SUCCEED_VALUE).setMsg("OK").setCount(leftBookNum);
             builder.setCode(ResultCode.SUCCEED_VALUE).setMsg("OK").setCount(leftBookNum);
             return builder.build();
             return builder.build();
-        } catch (AppMessageException e) {
+        } catch (YwtCommonException e) {
             builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setMsg(e.getMessage());
             builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setMsg(e.getMessage());
             return builder.build();
             return builder.build();
         } catch (Exception e) {
         } catch (Exception e) {

+ 32 - 32
ywt-platform-outpatient-taihe-rpc/src/main/java/com/ywt/outpatient/taihe/rpc/provider/TaiheRegisterProvider.java

@@ -2,8 +2,9 @@ package com.ywt.outpatient.taihe.rpc.provider;
 
 
 import com.google.protobuf.TextFormat;
 import com.google.protobuf.TextFormat;
 import com.ywt.biz.common.constant.GlobalConstants;
 import com.ywt.biz.common.constant.GlobalConstants;
+import com.ywt.biz.common.constant.YwtCommonRespCode;
 import com.ywt.biz.common.enums.PaymentChannelEnum;
 import com.ywt.biz.common.enums.PaymentChannelEnum;
-import com.ywt.biz.common.util.serializers.JsonSerializer;
+import com.ywt.biz.common.exception.YwtCommonException;
 import com.ywt.gapi.Result;
 import com.ywt.gapi.Result;
 import com.ywt.gapi.ResultCode;
 import com.ywt.gapi.ResultCode;
 import com.ywt.gapi.base.idCard.IdCardService;
 import com.ywt.gapi.base.idCard.IdCardService;
@@ -19,7 +20,6 @@ import com.ywt.gapi.taihe.register.RegisterResponse;
 import com.ywt.gapi.third.taihe.*;
 import com.ywt.gapi.third.taihe.*;
 import com.ywt.gapi.user.*;
 import com.ywt.gapi.user.*;
 import com.ywt.outpatient.taihe.rpc.domain.entity.center.RegisteredOrder;
 import com.ywt.outpatient.taihe.rpc.domain.entity.center.RegisteredOrder;
-import com.ywt.outpatient.taihe.rpc.core.AppMessageException;
 import com.ywt.outpatient.taihe.rpc.core.PagedList;
 import com.ywt.outpatient.taihe.rpc.core.PagedList;
 import com.ywt.outpatient.taihe.rpc.core.ServiceResult;
 import com.ywt.outpatient.taihe.rpc.core.ServiceResult;
 import com.ywt.outpatient.taihe.rpc.core.SqlHelper;
 import com.ywt.outpatient.taihe.rpc.core.SqlHelper;
@@ -155,7 +155,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
         try {
         try {
             VerifyCreateRegisteredResult verifyCreateRegisteredResult = verifyCreateRegisteredRequest(request);
             VerifyCreateRegisteredResult verifyCreateRegisteredResult = verifyCreateRegisteredRequest(request);
             if (!verifyCreateRegisteredResult.isSuccess()) {
             if (!verifyCreateRegisteredResult.isSuccess()) {
-                throw new AppMessageException(String.format("校验未通过:%s", verifyCreateRegisteredResult.getMsg()));
+                throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("校验未通过:%s", verifyCreateRegisteredResult.getMsg()));
             }
             }
             MedicalCard medicalCard = verifyCreateRegisteredResult.getMedicalCard();
             MedicalCard medicalCard = verifyCreateRegisteredResult.getMedicalCard();
             String doctorTitle = verifyCreateRegisteredResult.getDoctorTitle();
             String doctorTitle = verifyCreateRegisteredResult.getDoctorTitle();
@@ -255,7 +255,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
             LockOrderResponse lockOrderResponse = taiheServiceBlockingStub.lockOrder(lockOrderRequest);
             LockOrderResponse lockOrderResponse = taiheServiceBlockingStub.lockOrder(lockOrderRequest);
             if (lockOrderResponse.getCode() != ResultCode.SUCCEED_VALUE) {
             if (lockOrderResponse.getCode() != ResultCode.SUCCEED_VALUE) {
                 String errMsg = StringHelper.isNullOrEmpty(lockOrderResponse.getMsg()) ? "号源不足,请选择其他医生!" : lockOrderResponse.getMsg();
                 String errMsg = StringHelper.isNullOrEmpty(lockOrderResponse.getMsg()) ? "号源不足,请选择其他医生!" : lockOrderResponse.getMsg();
-                throw new AppMessageException(errMsg);
+                throw new YwtCommonException(YwtCommonRespCode.P_ERR, errMsg);
             }
             }
             // 存入 orderCode
             // 存入 orderCode
             registeredOrder.setHisOrderCode(Checker.getStringValue(lockOrderResponse.getOrderCode()));
             registeredOrder.setHisOrderCode(Checker.getStringValue(lockOrderResponse.getOrderCode()));
@@ -265,7 +265,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
             //创建订单中心订单
             //创建订单中心订单
             ServiceResult serviceResult = createOrder(registeredOrder);
             ServiceResult serviceResult = createOrder(registeredOrder);
             if (!serviceResult.isSuccessful()) {
             if (!serviceResult.isSuccessful()) {
-                throw new AppMessageException(String.format("创建订单出错:%s", serviceResult.getMsg()));
+                throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("创建订单出错:%s", serviceResult.getMsg()));
             }
             }
 
 
             // 非名医挂号,如果挂号费是 0 元的订单或公医订单,不用支付,直接去 HIS 挂号然后修改订单状态
             // 非名医挂号,如果挂号费是 0 元的订单或公医订单,不用支付,直接去 HIS 挂号然后修改订单状态
@@ -289,8 +289,8 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                     TextFormat.printToUnicodeString(builder.build()));
                     TextFormat.printToUnicodeString(builder.build()));
             return builder.build();
             return builder.build();
 
 
-        } catch (AppMessageException ame) {
-            builder.setCode(ResultCode.APP_ERROR_VALUE).setMsg(ame.getMessage());
+        } catch (YwtCommonException ame) {
+            builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setMsg(ame.getMessage());
             return builder.build();
             return builder.build();
         } catch (Exception e) {
         } catch (Exception e) {
             logger.error("createRegistered({}): {}", TextFormat.printToUnicodeString(request), e.getMessage(), e);
             logger.error("createRegistered({}): {}", TextFormat.printToUnicodeString(request), e.getMessage(), e);
@@ -302,10 +302,10 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
     /**
     /**
      * 免费挂号,0 元挂号费的订单(如公医)调用 HIS 挂号并修改订单状态
      * 免费挂号,0 元挂号费的订单(如公医)调用 HIS 挂号并修改订单状态
      */
      */
-    private void payFreeReg(int regId, int paymentChannel) throws AppMessageException {
+    private void payFreeReg(int regId, int paymentChannel) throws YwtCommonException {
         RegisteredOrder registeredOrder = registeredOrderRepository.getById(regId);
         RegisteredOrder registeredOrder = registeredOrderRepository.getById(regId);
         if (registeredOrder == null) {
         if (registeredOrder == null) {
-            throw new AppMessageException("0 元挂号:挂号订单不存在");
+            throw new YwtCommonException(YwtCommonRespCode.P_ERR, "0 元挂号:挂号订单不存在");
         }
         }
         int orderId = Checker.getIntegerValue(registeredOrder.getOrderId());
         int orderId = Checker.getIntegerValue(registeredOrder.getOrderId());
         String payMode = Constants.PAY_MODE_WECHAT;
         String payMode = Constants.PAY_MODE_WECHAT;
@@ -332,7 +332,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
             // 挂号失败,修改挂号订单状态为初始状态
             // 挂号失败,修改挂号订单状态为初始状态
             registeredOrder.setRegisteredStatus(0);
             registeredOrder.setRegisteredStatus(0);
             registeredOrderRepository.save(registeredOrder);
             registeredOrderRepository.save(registeredOrder);
-            throw new AppMessageException(String.format("call HIS pay:%s", payRes.getMsg()));
+            throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("call HIS pay:%s", payRes.getMsg()));
         } else {
         } else {
             //挂号成功,更新挂号订单信息
             //挂号成功,更新挂号订单信息
             registeredOrderRepository.updateRegisterInfoById(payRes.getSeqCode(), String.valueOf(payRes.getRegFee())
             registeredOrderRepository.updateRegisterInfoById(payRes.getSeqCode(), String.valueOf(payRes.getRegFee())
@@ -364,7 +364,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
      *
      *
      * @param request {@link CreateRegisteredRequest}
      * @param request {@link CreateRegisteredRequest}
      */
      */
-    private VerifyCreateRegisteredResult verifyCreateRegisteredRequest(CreateRegisteredRequest request) throws AppMessageException {
+    private VerifyCreateRegisteredResult verifyCreateRegisteredRequest(CreateRegisteredRequest request) throws YwtCommonException {
         VerifyCreateRegisteredResult result = new VerifyCreateRegisteredResult();
         VerifyCreateRegisteredResult result = new VerifyCreateRegisteredResult();
         long minTimestamp = DateUtil.convertToTimestamp(LocalDate.now());
         long minTimestamp = DateUtil.convertToTimestamp(LocalDate.now());
         long maxTimestamp = DateUtil.convertToTimestamp(LocalDate.now().plusDays(8));
         long maxTimestamp = DateUtil.convertToTimestamp(LocalDate.now().plusDays(8));
@@ -2125,14 +2125,14 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
             List<DoctorHisCode> doctorHisCodeList = doctorHisCodeRepository.getListByDoctorIdAndHospitalId(doctorId,
             List<DoctorHisCode> doctorHisCodeList = doctorHisCodeRepository.getListByDoctorIdAndHospitalId(doctorId,
                     hospitalId);
                     hospitalId);
             if (Checker.isNone(doctorHisCodeList)) {
             if (Checker.isNone(doctorHisCodeList)) {
-                throw new AppMessageException("医生 id 有误");
+                throw new YwtCommonException(YwtCommonRespCode.P_ERR, "医生 id 有误");
             }
             }
             DoctorHisCode netRelated = doctorHisCodeList.stream()
             DoctorHisCode netRelated = doctorHisCodeList.stream()
                     .filter(d -> checkIsNetDept(d.getDeptCode(), hospitalId))
                     .filter(d -> checkIsNetDept(d.getDeptCode(), hospitalId))
                     .findFirst()
                     .findFirst()
                     .orElse(null);
                     .orElse(null);
             if (netRelated == null) {
             if (netRelated == null) {
-                throw new AppMessageException("找不到医生对应的科室排班信息");
+                throw new YwtCommonException(YwtCommonRespCode.P_ERR, "找不到医生对应的科室排班信息");
             }
             }
             String deptCode = netRelated.getDeptCode();
             String deptCode = netRelated.getDeptCode();
             String doctorName = netRelated.getDoctorName();
             String doctorName = netRelated.getDoctorName();
@@ -2140,7 +2140,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
             // 获取 deptId & deptName
             // 获取 deptId & deptName
             HospitalDept hospitalDept = getDepartmentByDeptCodeAndHospitalId(deptCode, hospitalId);
             HospitalDept hospitalDept = getDepartmentByDeptCodeAndHospitalId(deptCode, hospitalId);
             if (hospitalDept == null) {
             if (hospitalDept == null) {
-                throw new AppMessageException("找不到科室信息");
+                throw new YwtCommonException(YwtCommonRespCode.P_ERR, "找不到科室信息");
             }
             }
             int deptId = hospitalDept.getDeptId();
             int deptId = hospitalDept.getDeptId();
             String deptName = hospitalDept.getDeptName();
             String deptName = hospitalDept.getDeptName();
@@ -2150,7 +2150,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                     .build();
                     .build();
             DoctorInfoResponse response = doctorServiceBlockingStub.getDoctorInfo(doctorRequest);
             DoctorInfoResponse response = doctorServiceBlockingStub.getDoctorInfo(doctorRequest);
             if (response.getResult().getCode() != ResultCode.SUCCEED) {
             if (response.getResult().getCode() != ResultCode.SUCCEED) {
-                throw new AppMessageException(String.format("获取不到医生信息: %s", response.getResult().getInfo()));
+                throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("获取不到医生信息: %s", response.getResult().getInfo()));
             }
             }
             // v3.2.0 线下就诊费用跟问诊费分开,线下就诊费用读取 offline_fee 字段
             // v3.2.0 线下就诊费用跟问诊费分开,线下就诊费用读取 offline_fee 字段
             int consultFee = Checker.getIntegerValue(response.getInfo().getOfflineFee());
             int consultFee = Checker.getIntegerValue(response.getInfo().getOfflineFee());
@@ -2164,8 +2164,8 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                     .setConsultFee(consultFee);
                     .setConsultFee(consultFee);
 
 
             return builder.build();
             return builder.build();
-        } catch (AppMessageException e) {
-            builder.setCode(ResultCode.APP_ERROR_VALUE).setInfo(e.getMessage());
+        } catch (YwtCommonException e) {
+            builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setInfo(e.getMessage());
             return builder.build();
             return builder.build();
         } catch (Exception e) {
         } catch (Exception e) {
             logger.error("TaiheRegisterService#getOfflineConsultInfoByDoctorId(request={}):\n {}", request, e.getMessage(), e);
             logger.error("TaiheRegisterService#getOfflineConsultInfoByDoctorId(request={}):\n {}", request, e.getMessage(), e);
@@ -2277,7 +2277,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                 logger.info("userId={}, idCardNo={}, mobile={}查询不到结果", userId, idCardNo, mobile);
                 logger.info("userId={}, idCardNo={}, mobile={}查询不到结果", userId, idCardNo, mobile);
                 User user = userRepository.getByIdAndIsDeletedFalse(userId);
                 User user = userRepository.getByIdAndIsDeletedFalse(userId);
                 if (user == null) {
                 if (user == null) {
-                    throw new AppMessageException(String.format("用户不存在,id: %d", userId));
+                    throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("用户不存在,id: %d", userId));
                 }
                 }
                 // 不能直接用 userName, 要使用 patientName, 因为用户可以添加其他患者
                 // 不能直接用 userName, 要使用 patientName, 因为用户可以添加其他患者
                 String patientName = request.getName();
                 String patientName = request.getName();
@@ -2301,14 +2301,14 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                                 idCardNo, patientInfo.getPatientType(), request.getAddress(), hospitalId, 0, cardType);
                                 idCardNo, patientInfo.getPatientType(), request.getAddress(), hospitalId, 0, cardType);
                     } else {
                     } else {
                         if (!"1".equals(cardType)) {
                         if (!"1".equals(cardType)) {
-                            throw new AppMessageException("港澳台患者需先到院线下建档。");
+                            throw new YwtCommonException(YwtCommonRespCode.P_ERR, "港澳台患者需先到院线下建档。");
                         }
                         }
                         // 建档
                         // 建档
                         mc = createNewMedicalCard(request.getAddress(), request.getCardNo(), userId, user, userName, hospitalId, cardType);
                         mc = createNewMedicalCard(request.getAddress(), request.getCardNo(), userId, user, userName, hospitalId, cardType);
                     }
                     }
                 } else {
                 } else {
                     if (!"1".equals(cardType)) {
                     if (!"1".equals(cardType)) {
-                        throw new AppMessageException("港澳台患者需先到院线下建档。");
+                        throw new YwtCommonException(YwtCommonRespCode.P_ERR, "港澳台患者需先到院线下建档。");
                     }
                     }
                     logger.error("获取就诊卡信息失败,patientName: {}, idCardNo: {}: {}", userName, idCardNo, getPatientInfoResponse.getMsg());
                     logger.error("获取就诊卡信息失败,patientName: {}, idCardNo: {}: {}", userName, idCardNo, getPatientInfoResponse.getMsg());
                     // 建档
                     // 建档
@@ -2339,8 +2339,8 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
             builder.setCode(ResultCode.SUCCEED_VALUE)
             builder.setCode(ResultCode.SUCCEED_VALUE)
                     .setHisPatientId(hisPatientId);
                     .setHisPatientId(hisPatientId);
             return builder.build();
             return builder.build();
-        } catch (AppMessageException ame) {
-            builder.setCode(ResultCode.APP_ERROR_VALUE)
+        } catch (YwtCommonException ame) {
+            builder.setCode(ResultCode.PARAMETER_ERROR_VALUE)
                     .setInfo(Checker.getStringValue(ame.getMessage()));
                     .setInfo(Checker.getStringValue(ame.getMessage()));
             return builder.build();
             return builder.build();
         } catch (Exception e) {
         } catch (Exception e) {
@@ -2355,7 +2355,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
      * 调用 HIS 接口建档,建档成功后新建就诊卡
      * 调用 HIS 接口建档,建档成功后新建就诊卡
      */
      */
     private MedicalCard createNewMedicalCard4HIS(String address, String cardNo, String city, String userName, String mobile,
     private MedicalCard createNewMedicalCard4HIS(String address, String cardNo, String city, String userName, String mobile,
-                                                 String isInsu, int hospitalId, int userId, int sex, int relationship, String cardType) throws AppMessageException {
+                                                 String isInsu, int hospitalId, int userId, int sex, int relationship, String cardType) throws YwtCommonException {
         MedicalCard mc;
         MedicalCard mc;
         CreatePatInfoRequest createPatInfoRequest = CreatePatInfoRequest.newBuilder()
         CreatePatInfoRequest createPatInfoRequest = CreatePatInfoRequest.newBuilder()
                 .setAddress(Checker.getStringValue(address))
                 .setAddress(Checker.getStringValue(address))
@@ -2369,7 +2369,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
         CreatePatInfoResponse createPatInfoResponse = taiheServiceBlockingStub.createPatInfo(createPatInfoRequest);
         CreatePatInfoResponse createPatInfoResponse = taiheServiceBlockingStub.createPatInfo(createPatInfoRequest);
         if (createPatInfoResponse.getCode() != ResultCode.SUCCEED_VALUE) {
         if (createPatInfoResponse.getCode() != ResultCode.SUCCEED_VALUE) {
 //            throw new AppMessageException(String.format("HIS 建档:%s", createPatInfoResponse.getInfo()));
 //            throw new AppMessageException(String.format("HIS 建档:%s", createPatInfoResponse.getInfo()));
-            throw new AppMessageException(createPatInfoResponse.getInfo());
+            throw new YwtCommonException(YwtCommonRespCode.P_ERR, createPatInfoResponse.getInfo());
         }
         }
         // 建档成功,新增诊疗卡记录
         // 建档成功,新增诊疗卡记录
         mc = addNewMedicalCard(userId, userName, mobile, sex, createPatInfoResponse.getPatientCard(),
         mc = addNewMedicalCard(userId, userName, mobile, sex, createPatInfoResponse.getPatientCard(),
@@ -2382,7 +2382,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
      */
      */
     private MedicalCard createNewMedicalCard(String address, String cardNo, int userId,
     private MedicalCard createNewMedicalCard(String address, String cardNo, int userId,
                                              User user, String userName,
                                              User user, String userName,
-                                             int hospitalId, String cardType) throws AppMessageException {
+                                             int hospitalId, String cardType) throws YwtCommonException {
         return createNewMedicalCard4HIS(Checker.getStringValue(address), Checker.getStringValue(cardNo),
         return createNewMedicalCard4HIS(Checker.getStringValue(address), Checker.getStringValue(cardNo),
                 Checker.getStringValue(user.getCity()), userName, Checker.getStringValue(user.getMobile()), "",
                 Checker.getStringValue(user.getCity()), userName, Checker.getStringValue(user.getMobile()), "",
                 hospitalId, userId, Checker.getIntegerValue(user.getSex()), 0, cardType);
                 hospitalId, userId, Checker.getIntegerValue(user.getSex()), 0, cardType);
@@ -2454,7 +2454,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                 // 港澳台身份证
                 // 港澳台身份证
                 // 如果前端传入的是大陆身份证,但提交的类型是港澳台类型,这里需要返回错误提示
                 // 如果前端传入的是大陆身份证,但提交的类型是港澳台类型,这里需要返回错误提示
                 if (IdCardUtil.verifyMainlandIdCard(idNo)) {
                 if (IdCardUtil.verifyMainlandIdCard(idNo)) {
-                    throw new AppMessageException("“身份证号”或“证件类型”有误,建档不成功,请修改!");
+                    throw new YwtCommonException(YwtCommonRespCode.P_ERR, "“身份证号”或“证件类型”有误,建档不成功,请修改!");
                 }
                 }
                 int sex = IdCardUtil.getSexIntWithGAT(idNo);
                 int sex = IdCardUtil.getSexIntWithGAT(idNo);
                 // 查询 HIS 是否已有 姓名+身份证 绑定的卡
                 // 查询 HIS 是否已有 姓名+身份证 绑定的卡
@@ -2510,7 +2510,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
             } else {
             } else {
                 // 大陆身份证
                 // 大陆身份证
                 if (!IdCardUtil.verifyMainlandIdCard(idNo)) {
                 if (!IdCardUtil.verifyMainlandIdCard(idNo)) {
-                    throw new AppMessageException("“身份证号”或“证件类型”有误,建档不成功,请修改!");
+                    throw new YwtCommonException(YwtCommonRespCode.P_ERR, "“身份证号”或“证件类型”有误,建档不成功,请修改!");
                 }
                 }
                 // 根据配置做实名校验
                 // 根据配置做实名校验
                 HisMedCardConfig config = configProvider.getHisMedCardConfig(hospitalId);
                 HisMedCardConfig config = configProvider.getHisMedCardConfig(hospitalId);
@@ -2520,9 +2520,9 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                             .setRealName(patientName)
                             .setRealName(patientName)
                             .build());
                             .build());
                     if (validateIdCardResponse.getCode() != ResultCode.SUCCEED_VALUE)
                     if (validateIdCardResponse.getCode() != ResultCode.SUCCEED_VALUE)
-                        throw new AppMessageException(String.format("实名校验:%s", validateIdCardResponse.getInfo()));
+                        throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("实名校验:%s", validateIdCardResponse.getInfo()));
                     if (!validateIdCardResponse.getValid())
                     if (!validateIdCardResponse.getValid())
-                        throw new AppMessageException(String.format("实名校验:%s(^%s^%s^)", validateIdCardResponse.getInfo(),
+                        throw new YwtCommonException(YwtCommonRespCode.P_ERR, String.format("实名校验:%s(^%s^%s^)", validateIdCardResponse.getInfo(),
                                 idNo, patientName));
                                 idNo, patientName));
                 }
                 }
                 CheckUtil.ensureNotEmpty(phoneNo, "手机号不能为空");
                 CheckUtil.ensureNotEmpty(phoneNo, "手机号不能为空");
@@ -2543,7 +2543,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                             .setMedicalCardId(medicalCard.getId())
                             .setMedicalCardId(medicalCard.getId())
                             .setMedicalCardNo(medicalCard.getCardNo());
                             .setMedicalCardNo(medicalCard.getCardNo());
                     sendMsgForCreateCard(userId, hospitalId, medicalCard, terminal);
                     sendMsgForCreateCard(userId, hospitalId, medicalCard, terminal);
-                } catch (AppMessageException e) {
+                } catch (YwtCommonException e) {
                     // 建卡 HIS 返回失败,查询 HIS 是否已有 姓名+身份证 绑定的卡
                     // 建卡 HIS 返回失败,查询 HIS 是否已有 姓名+身份证 绑定的卡
                     // 先查一次数据库有没有存在建卡记录
                     // 先查一次数据库有没有存在建卡记录
                     MedicalCard card = medicalCardRepository.getByUserIdAndPatientNameAndIdNoAndCardTypeAndHospitalIdAndStatus(userId,
                     MedicalCard card = medicalCardRepository.getByUserIdAndPatientNameAndIdNoAndCardTypeAndHospitalIdAndStatus(userId,
@@ -2595,7 +2595,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
                 }
                 }
             }
             }
             return builder.build();
             return builder.build();
-        } catch (AppMessageException e) {
+        } catch (YwtCommonException e) {
             builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setInfo(e.getMessage());
             builder.setCode(ResultCode.PARAMETER_ERROR_VALUE).setInfo(e.getMessage());
             return builder.build();
             return builder.build();
         } catch (Exception e) {
         } catch (Exception e) {
@@ -2614,7 +2614,7 @@ public class TaiheRegisterProvider extends DubboTaiheRegisterServiceTriple.Taihe
         try {
         try {
             age = IdCardUtil.calcAgeByIdNoAndBirthday(idNo, birthday);
             age = IdCardUtil.calcAgeByIdNoAndBirthday(idNo, birthday);
             realAge = String.valueOf(age);
             realAge = String.valueOf(age);
-        } catch (AppMessageException e) {
+        } catch (YwtCommonException e) {
             e.printStackTrace();
             e.printStackTrace();
             logger.error("TaiheRegisterService#calAdditionalFee(idNo={} , birthday={} ): 无法获取身份证与生日", idNo, birthday);
             logger.error("TaiheRegisterService#calAdditionalFee(idNo={} , birthday={} ): 无法获取身份证与生日", idNo, birthday);
         }
         }