Przeglądaj źródła

修复身份校验问题

Guos 2 tygodni temu
rodzic
commit
527019576b

+ 17 - 166
fs-user-app/src/main/java/com/fs/app/controller/PatientController.java

@@ -21,6 +21,7 @@ import com.fs.his.utils.IdCardUtil;
 import com.fs.system.service.ISysConfigService;
 import com.fs.system.service.ISysConfigService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.ObjectUtils;
 import org.checkerframework.checker.units.qual.A;
 import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
@@ -82,116 +83,36 @@ public class PatientController extends  AppBaseController {
         }
         }
         return R.ok().put("data",data);
         return R.ok().put("data",data);
     }
     }
+
+    /**
+     * 添加病人
+     * @param param
+     * @return 添加结果
+     */
     @Login
     @Login
     @RepeatSubmit
     @RepeatSubmit
     @ApiOperation("添加病人")
     @ApiOperation("添加病人")
     @PostMapping("/addPatient")
     @PostMapping("/addPatient")
     public R addPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
     public R addPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
-        String json = configService.selectConfigByKey("his.store");
-        StoreConfig storeConfig = JSONUtil.toBean(json, StoreConfig.class);
-        Integer isIdVerification = storeConfig.getIsIdVerification();
-
-        String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
-        String mobile = param.getMobile();
-        if (idCardNumber == null || idCardNumber.trim().isEmpty()) {
-            return R.error("身份证号码不合法");
-        }
-        if (idCardNumber.length() != 18) {
-//            //大陆身份证是18位
-//            if (isIdVerification != 1) {
-//                return R.error("身份证号码不合法");
-//            } else {
-//                //非大陆身份校验需要手机号 手机号只支持大陆的办理的手机号
-//                if (StringUtils.isBlank(mobile)){
-//                    R.error("手机号不能为空");
-//                }
-//            }
-            //暂时仅支持大陆身份证
-            return  R.error("身份证号码不合法");
-        } else {
-            String regex = "\\d{17}[0-9Xx]";
-            if (!Pattern.matches(regex, idCardNumber)) {
-                return   R.error("身份证号码不合法");
+        if (ObjectUtils.isNotEmpty(param.getIdCard())) {
+            String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
+            IdCardVerificationResponse idCardVerificationResponse = TxOcrClient.IdCardVerification(param.getPatientName(), idCardNumber);
+            if(0 != idCardVerificationResponse.getResult()){
+                throw new CustomException(idCardVerificationResponse.getDescription());
             }
             }
         }
         }
-
-
-        if (param.getPatientName().length()<2||param.getPatientName().length()>30||!param.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
-            return   R.error("就诊人名称不合法");
-        }
-
-        IdCardVerificationResponse idCardVerificationResponse = TxOcrClient.IdCardVerification(param.getPatientName(), idCardNumber);
-        if(0 != idCardVerificationResponse.getResult()){
-            throw new CustomException(idCardVerificationResponse.getDescription());
-        }
-
-        try {
-            if (idCardNumber != null) {
-                String birthDateString = idCardNumber.substring(6, 14);
-                LocalDate birthDate = LocalDate.parse(birthDateString, DateTimeFormatter.ofPattern("yyyyMMdd"));
-                LocalDate currentDate = LocalDate.now();
-                int age = currentDate.getYear() - birthDate.getYear();
-                if (currentDate.getMonthValue() < birthDate.getMonthValue()
-                        || (currentDate.getMonthValue() == birthDate.getMonthValue()
-                        && currentDate.getDayOfMonth() < birthDate.getDayOfMonth())) {
-                    age--;
-                }
-                if (age < 18) {
-                    return R.error("年龄必须大于18岁");
-                }
-                if (age > 200) {
-                    return   R.error("年龄超过200岁");
-
-                }
-                Date birthday = param.getBirthday();
-                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-                String formattedBirthday = sdf.format(birthday);
-                LocalDate da = LocalDate.parse(formattedBirthday, DateTimeFormatter.ofPattern("yyyyMMdd"));
-                LocalDate currentDate2 = LocalDate.now();
-                int age2 = currentDate2.getYear() - da.getYear();
-                if (currentDate2.getMonthValue() < da.getMonthValue()
-                        || (currentDate2.getMonthValue() == da.getMonthValue()
-                        && currentDate2.getDayOfMonth() < da.getDayOfMonth())) {
-                    age2--;
-                }
-                if (age2 < 18) {
-                    return   R.error("年龄必须大于18岁");
-                }
-                if (age2 > 200) {
-                    return   R.error("年龄超过200岁");
-                }
-            }
-        }catch (Exception e){
-            return   R.error("身份证校验错误");
-        }
-
-        //三方校验
-        if (isIdVerification!=null&&isIdVerification == 1){
-            boolean match = true;
-            if (idCardNumber.length() != 18) {
-                match = IdCardUtil.isMatchByMobile(storeConfig,param.getPatientName(), mobile);
-            } else {
-                match = IdCardUtil.isMatchById(storeConfig,param.getPatientName(), param.getIdCard());
-            }
-            if (!match){
-                return R.error("身份证校验错误");
-            }
-        }
-
         FsPatient patient=new FsPatient();
         FsPatient patient=new FsPatient();
         BeanUtil.copyProperties(param, patient);
         BeanUtil.copyProperties(param, patient);
         patient.setUserId(Long.parseLong(getUserId()));
         patient.setUserId(Long.parseLong(getUserId()));
         patient.setIsDel(0);
         patient.setIsDel(0);
         patient.setStatus(1);
         patient.setStatus(1);
         patientService.insertFsPatient(patient);
         patientService.insertFsPatient(patient);
-
         // 填写就诊人信息
         // 填写就诊人信息
         FsUserAddIntegralTemplateParam integralTemplateParam = new FsUserAddIntegralTemplateParam();
         FsUserAddIntegralTemplateParam integralTemplateParam = new FsUserAddIntegralTemplateParam();
         integralTemplateParam.setUserId(Long.parseLong(getUserId()));
         integralTemplateParam.setUserId(Long.parseLong(getUserId()));
         integralTemplateParam.setLogType(FsUserIntegralLogTypeEnum.TYPE_11.getValue());
         integralTemplateParam.setLogType(FsUserIntegralLogTypeEnum.TYPE_11.getValue());
         integralTemplateParam.setBusinessId(patient.getPatientId().toString());
         integralTemplateParam.setBusinessId(patient.getPatientId().toString());
         userIntegralLogsService.addIntegralTemplate(integralTemplateParam);
         userIntegralLogsService.addIntegralTemplate(integralTemplateParam);
-
         return R.ok("操作成功");
         return R.ok("操作成功");
     }
     }
 
 
@@ -199,83 +120,13 @@ public class PatientController extends  AppBaseController {
     @ApiOperation("编辑病人")
     @ApiOperation("编辑病人")
     @PostMapping("/editPatient")
     @PostMapping("/editPatient")
     public R editPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
     public R editPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
-        String json = configService.selectConfigByKey("his.store");
-        StoreConfig storeConfig = JSONUtil.toBean(json, StoreConfig.class);
-        Integer isIdVerification = storeConfig.getIsIdVerification();
-        String mobile = param.getMobile();
-
-        String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
-        if (idCardNumber == null || idCardNumber.trim().isEmpty()) {
-            return R.error("身份证号码不合法");
-        }
-        if (idCardNumber.length() != 18) {
-//            //大陆身份证是18位
-//            if (isIdVerification != 1) {
-//                return R.error("身份证号码不合法");
-//            } else {
-//                //非大陆身份校验需要手机号 手机号只支持大陆的办理的手机号
-//                if (StringUtils.isBlank(mobile)){
-//                    R.error("手机号不能为空");
-//                }
-//            }
-            //暂时仅支持大陆身份证
-            return  R.error("身份证号码不合法");
-        } else {
-            String regex = "\\d{17}[0-9Xx]";
-            if (!Pattern.matches(regex, idCardNumber)) {
-                return   R.error("身份证号码不合法");
-            }
-        }
-
-        if (param.getPatientName().length()<2||param.getPatientName().length()>30||!param.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
-            return   R.error("就诊人名称不合法");
-        }
-//        String birthDateString = idCardNumber.substring(6, 14);
-//        LocalDate birthDate = LocalDate.parse(birthDateString, DateTimeFormatter.ofPattern("yyyyMMdd"));
-//        LocalDate currentDate = LocalDate.now();
-//        int age = currentDate.getYear() - birthDate.getYear();
-//        if (currentDate.getMonthValue() < birthDate.getMonthValue()
-//                || (currentDate.getMonthValue() == birthDate.getMonthValue()
-//                && currentDate.getDayOfMonth() < birthDate.getDayOfMonth())) {
-//            age--;
-//        }
-//        if (age < 18) {
-//            throw new CustomException("年龄必须大于18岁");
-//        }
-//        if (age > 200) {
-//            throw new CustomException("年龄超过200岁");
-//        }
-//        Date birthday = param.getBirthday();
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-//        String formattedBirthday = sdf.format(birthday);
-//        LocalDate da = LocalDate.parse(formattedBirthday, DateTimeFormatter.ofPattern("yyyyMMdd"));
-//        LocalDate currentDate2 = LocalDate.now();
-//        int age2 = currentDate2.getYear() - da.getYear();
-//        if (currentDate2.getMonthValue() < da.getMonthValue()
-//                || (currentDate2.getMonthValue() == da.getMonthValue()
-//                && currentDate2.getDayOfMonth() < da.getDayOfMonth())) {
-//            age2--;
-//        }
-//        if (age2 < 18) {
-//            throw new CustomException("年龄必须大于18岁");
-//        }
-//        if (age2 > 200) {
-//            throw new CustomException("年龄超过200岁");
-//        }
-
-        //三方校验
-        if (isIdVerification!=null&&isIdVerification == 1){
-            boolean match = true;
-            if (idCardNumber.length() != 18) {
-                match = IdCardUtil.isMatchByMobile(storeConfig,param.getPatientName(), mobile);
-            } else {
-                match = IdCardUtil.isMatchById(storeConfig,param.getPatientName(), param.getIdCard());
-            }
-            if (!match){
-                return R.error("身份证校验错误");
+        if (ObjectUtils.isNotEmpty(param.getIdCard())) {
+            String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
+            IdCardVerificationResponse idCardVerificationResponse = TxOcrClient.IdCardVerification(param.getPatientName(), idCardNumber);
+            if(0 != idCardVerificationResponse.getResult()){
+                throw new CustomException(idCardVerificationResponse.getDescription());
             }
             }
         }
         }
-
         FsPatient patient=new FsPatient();
         FsPatient patient=new FsPatient();
         BeanUtil.copyProperties(param, patient);
         BeanUtil.copyProperties(param, patient);
         patientService.updateFsPatient(patient);
         patientService.updateFsPatient(patient);

+ 0 - 3
fs-user-app/src/main/java/com/fs/app/controller/UserController.java

@@ -272,7 +272,6 @@ public class UserController extends  AppBaseController {
             }
             }
             param.setStoreName(fsStoreScrm.getStoreName());
             param.setStoreName(fsStoreScrm.getStoreName());
         }
         }
-
         //一个用户可以提交多个申请
         //一个用户可以提交多个申请
 //        FsDoctor doctor= doctorService.selectFsDoctorByUserId(Long.parseLong(getUserId()));
 //        FsDoctor doctor= doctorService.selectFsDoctorByUserId(Long.parseLong(getUserId()));
 //        if(doctor!=null){
 //        if(doctor!=null){
@@ -283,8 +282,6 @@ public class UserController extends  AppBaseController {
 //                return R.error(String.format("您已提交过申请 提交信息: %s",doctor.getDoctorName()));
 //                return R.error(String.format("您已提交过申请 提交信息: %s",doctor.getDoctorName()));
 //            }
 //            }
 //        }
 //        }
-
-
         FsDoctor doctor=new FsDoctor();
         FsDoctor doctor=new FsDoctor();
         BeanUtils.copyProperties(param,doctor);
         BeanUtils.copyProperties(param,doctor);
         doctor.setUserId(Long.parseLong(getUserId()));
         doctor.setUserId(Long.parseLong(getUserId()));

+ 4 - 4
fs-user-app/src/main/java/com/fs/app/param/FsPatientAddEditParam.java

@@ -4,10 +4,9 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import com.fs.common.annotation.Excel;
 import lombok.Getter;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.Setter;
+import lombok.Singular;
 
 
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
+import javax.validation.constraints.*;
 import java.io.Serializable;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Date;
 
 
@@ -19,7 +18,8 @@ public class FsPatientAddEditParam implements Serializable {
     private Long patientId;
     private Long patientId;
 
 
     /** 患者姓名 */
     /** 患者姓名 */
-    @NotBlank(message = "患者姓名不能为空")
+    @NotBlank(message = "患者姓名不能为空" )
+    @Size(max = 30, min = 2, message = "患者姓名长度不能低于2个字符,超过30个字符" )
     private String patientName;
     private String patientName;
 
 
     /** 身份证号 */
     /** 身份证号 */