zjh
2023-12-23 ddcd1e3b0a6c4a426b81cdae021e7bb3be910534
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCustomerController.java
@@ -86,44 +86,52 @@
        if (!"".equals(cusIdcard) && cusIdcard != null) {
            //判断身份证号格式是否正确
            // TODO: 2023/2/10  判断身份证号格式是否正确
            if(cusIdcard.length()==18){
                if (! MatchUtils.isIdCard(cusIdcard)) {
                    return AjaxResult.error("身份证号码错误");
                }
            }
            if(cusIdcard.length()==9){
                if (!MatchUtils.cardValidates(cusIdcard)) {
                    return AjaxResult.error("身份证号码错误");
                }
            }
//            if(cusIdcard.length()==18){
//                if (! MatchUtils.isIdCard(cusIdcard)) {
//                    return AjaxResult.error("身份证号码错误");
//                }
//            }
//            if(cusIdcard.length()==9){
//                if (!MatchUtils.cardValidates(cusIdcard)) {
//                    return AjaxResult.error("身份证号码错误");
//                }
//            }
            //根据配置调取存储过程 将临时表数据存入预约表2023.12.12
            final String getInfoFromSqlData = sysConfigService.selectConfigByKey("getInfoFromSqlData");
            if ("Y".equals(getInfoFromSqlData)){
                //根据身份证好查信息
                 LtkjTjPat tjPatByIdCard = testMapper.getTjPatByIdCard(cusIdcard);
                //根据身份证号从his查信息
                LtkjTjPat tjPatByIdCard = testMapper.getTjPatByIdCard(cusIdcard);
                if(null != tjPatByIdCard){
                    String fcardNo = tjPatByIdCard.getFcardNo();
                    if(null !=fcardNo){
                        fcardNo=fcardNo.trim();
                        tjPatByIdCard.setFcardNo(fcardNo);
                    }
                    //根据身份证号从数据库拿信息 没有的话保存
                    LtkjTjPat ltkjTjPat = tjvLtkjvtjpatService.getLtkjTjPatByCusIdCard(cusIdcard);
                    if(null==ltkjTjPat){
                        tjvLtkjvtjpatService.save(tjPatByIdCard);
                    }
                    DynamicDataSourceContextHolder.clearDataSourceType();
                    //再根据身份证号写customer表
                    TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdcard);
                    TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(tjPatByIdCard.getFcardNo());
                    if(null == tjCustomer){
                        //为空的话掉存储过程保存到客户表
                        testMapper.getTjPatByCusId(cusIdcard);
                        LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>();
                        qw.eq(TjCustomer::getCusIdcard, cusIdcard);
                        qw.eq(TjCustomer::getCusIdcard, tjPatByIdCard.getFcardNo());
                        TjCustomer customer = tjCustomerService.getOne(qw);
                        customer.setReservationId(customer.getCardId());
                        extracted(customer);
                        return success(customer);
                    }else {
                        String cardId = tjCustomer.getCardId();
                        if(null !=cardId && cardId.equals(tjPatByIdCard.getFcardId())){
                            return AjaxResult.error("不可重复签到");
                        }
                        tjCustomer.setReservationId(tjCustomer.getCardId());
                        tjCustomer.setCardId(tjPatByIdCard.getFcardId());
                        tjCustomerService.updateById(tjCustomer);
                        extracted(tjCustomer);
                        return success(tjCustomer);
                    }
@@ -169,7 +177,6 @@
                    tjCustomer1.setReservationId(tjReservation.getId());
                    tjCustomer1.setDiscount(tjReservation.getDiscount());
                    tjCustomer1.setGroupingId(tjReservation.getGroupingId());
                    return success(tjCustomer1);
                }
                TjCustomer tjCustomer = new TjCustomer();
@@ -213,6 +220,7 @@
    }
    private void extracted(TjCustomer customer) {
        //从his表抓数据
        LtkjMiddleHead pat = testMapper.getMiddleHeadByPartId(customer.getCardId());
        if (null != pat) {
            List<LtkjMiddleDetail> list = testMapper.getMiddleDetailByFeadId(pat.getFeadId());
@@ -223,7 +231,6 @@
                for (LtkjMiddleDetail ltkjMiddleDetail : list) {
                    middleDetailService.save(ltkjMiddleDetail);
                }
                testMapper.saveTjProByCusId(customer.getCardId(), customer.getCusIdcard());
            }
            testMapper.saveTjProByCusId(customer.getCardId(), customer.getCusIdcard());
        }