zjh
2025-03-05 6b73ef6f82fa10747c29bdec04cb43d0f7e91598
ltkj-admin/src/main/java/com/ltkj/web/controller/app/CustomerController.java
@@ -43,8 +43,8 @@
 * @Date: 2023/1/12 11:08
 */
@RestController
@RequestMapping("/cus/hospital")
@Api(tags = "小程序-客户信息")
@RequestMapping ("/cus/hospital")
@Api (tags = "小程序-客户信息")
public class CustomerController extends BaseController {
    @Resource
@@ -69,8 +69,8 @@
    /**
     * 小程序就诊人列表
     */
    @GetMapping("/getListByOpenId")
    @ApiOperation(value = "小程序-就诊人列表")
    @GetMapping ("/getListByOpenId")
    @ApiOperation (value = "小程序-就诊人列表")
    public AjaxResult getListByOpenId(@RequestParam String openId) {
        LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
        wq.eq(TjCustomer::getConnect, openId);
@@ -81,9 +81,9 @@
    /**
     * 解绑就诊人
     */
    @PostMapping("/delCustomer")
    @ApiOperation(value = "小程序-解绑就诊人")
    public AjaxResult delCustomer(@RequestBody @ApiParam(value = "客户对象信息") TjCustomer tjCustomer) {
    @PostMapping ("/delCustomer")
    @ApiOperation (value = "小程序-解绑就诊人")
    public AjaxResult delCustomer(@RequestBody @ApiParam (value = "客户对象信息") TjCustomer tjCustomer) {
        if (tjCustomer == null) {
            return AjaxResult.error();
        }
@@ -105,11 +105,11 @@
    /**
     * 新增并绑定就诊人
     */
    @PostMapping("/addNew")
    @ApiOperation(value = "小程序-新增并绑定就诊人")
    @PostMapping ("/addNew")
    @ApiOperation (value = "小程序-新增并绑定就诊人")
    @Transactional
    @RepeatSubmit
    public AjaxResult addNew(@RequestBody @ApiParam(value = "客户对象信息") TjCustomer tjCustomer) {
    public AjaxResult addNew(@RequestBody @ApiParam (value = "客户对象信息") TjCustomer tjCustomer) {
        if (tjCustomer == null) {
            return AjaxResult.error("添加失败");
        }
@@ -121,12 +121,12 @@
        if (!MatchUtils.isMobileNO(tjCustomer.getCusPhone()))
            return AjaxResult.error("手机号错误");
        if(cusIdcard.length()==18){
        if (cusIdcard.length() == 18) {
            if (!MatchUtils.isIdCard(cusIdcard)) {
                return AjaxResult.error("身份证号码错误");
            }
        }
        if(cusIdcard.length()==9){
        if (cusIdcard.length() == 9) {
            if (!MatchUtils.cardValidates(cusIdcard)) {
                return AjaxResult.error("身份证号码错误");
            }
@@ -140,15 +140,7 @@
        if (customer != null) {
            customer.setConnect(tjCustomer.getConnect());
            if (customerService.updateById(customer)) {
                if(null !=key && key.equals("Y")){
                    AjaxResult xinXi = suijieHisXinXi(tjCustomer);
                    if(!xinXi.get("code").toString().equals("200")){
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return AjaxResult.error("添加就诊人信息失败!" + xinXi.get("msg").toString());
                    }
                }
            }
            customerService.updateById(customer);
            return AjaxResult.success(customer);
        }
        String substring = cusIdcard.substring(cusIdcard.length() - 6);
@@ -156,7 +148,6 @@
        tjCustomer.setCusPassword(substring);
        tjCustomer.setCusBrithday(DateUtil.parse(MatchUtils.getBirthDayByIdCard(cusIdcard), "yyyy-MM-dd"));
        tjCustomer.setCusSex(Long.valueOf(MatchUtils.getSexByIdCard(cusIdcard)));
        //tjCustomer.setAddr(MatchUtils.getNativePlace(Integer.parseInt((cusIdcard))));
        tjCustomer.setAge(String.valueOf(MatchUtils.getAgeByIdCard(cusIdcard)));
        tjCustomer.setIdType("1");
        tjCustomer.setAgeUnit("0");
@@ -164,34 +155,35 @@
        tjCustomer.setCusIntroduce("无");
        tjCustomer.setCusNumber(0L);
        tjCustomer.setCusIsvip("N");
        if (customerService.save(tjCustomer)) {
            if(null !=key && key.equals("Y")){
                AjaxResult xinXi = suijieHisXinXi(tjCustomer);
                if(!xinXi.get("code").toString().equals("200")){
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("添加就诊人信息失败!" + xinXi.get("msg").toString());
                }
        if (null != key && key.equals("Y")) {
            AjaxResult xinXi = suijieHisXinXi(tjCustomer);
            if (!xinXi.get("code").toString().equals("200")) {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error("注册失败,请到前台登记!" + xinXi.get("msg").toString());
            }
        } else {
            customerService.save(tjCustomer);
            return AjaxResult.success(tjCustomer);
        }
        return AjaxResult.error("添加失败");
        return AjaxResult.success(tjCustomer);
    }
    /**
     * 小程序体检报告列表
     */
    @GetMapping("/getReportList")
    @ApiOperation(value = "小程序-体检报告列表")
    public AjaxResult getReportList(@RequestParam @ApiParam(value = "手机号") String cusPhone) {
    @GetMapping ("/getReportList")
    @ApiOperation (value = "小程序-体检报告列表")
    public AjaxResult getReportList(@RequestParam @ApiParam (value = "手机号") String cusPhone) {
        return AjaxResult.success();
    }
    /**
     * 回显就诊人
     */
    @PostMapping("/showCustomer")
    @ApiOperation(value = "小程序-回显就诊人")
    public AjaxResult showCustomer(@RequestBody @ApiParam(value = "客户对象信息") TjCustomer tjCustomer) {
    @PostMapping ("/showCustomer")
    @ApiOperation (value = "小程序-回显就诊人")
    public AjaxResult showCustomer(@RequestBody @ApiParam (value = "客户对象信息") TjCustomer tjCustomer) {
        if (tjCustomer == null) {
            return AjaxResult.error();
        }
@@ -206,8 +198,8 @@
    /**
     * 小程序判断是否能编辑
     */
    @PostMapping("/canUpdate")
    @ApiOperation(value = "小程序判断是否能编辑")
    @PostMapping ("/canUpdate")
    @ApiOperation (value = "小程序判断是否能编辑")
    public AjaxResult canUpdate(@RequestBody TjCustomer tjCustomer) {
        if (tjCustomer == null) {
            return AjaxResult.error("出错了,请联系工作人员!");
@@ -224,8 +216,8 @@
    /**
     * 小程序编辑就诊人信息
     */
    @PostMapping("/updateCustomerBy")
    @ApiOperation(value = "小程序-修改就诊人信息")
    @PostMapping ("/updateCustomerBy")
    @ApiOperation (value = "小程序-修改就诊人信息")
    @Transactional
    @RepeatSubmit
    public AjaxResult updateCustomerBy(@RequestBody TjCustomer tjCustomer) {
@@ -239,30 +231,33 @@
        one.setCusPhone(tjCustomer.getCusPhone());
        one.setCusNational(tjCustomer.getCusNational());
        one.setCusMarryStatus(tjCustomer.getCusMarryStatus());
        if (customerService.updateById(one)) {
            if(null !=key && key.equals("Y")){
                AjaxResult xinXi = suijieHisXinXi(one);
                if(!xinXi.get("code").toString().equals("200")){
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("添加就诊人信息失败!" + xinXi.get("msg").toString());
                }
        if (null != key && key.equals("Y")) {
            AjaxResult xinXi = suijieHisXinXi(one);
            if (!xinXi.get("code").toString().equals("200")) {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error("修改就诊人信息失败!" + xinXi.get("msg").toString());
            }
            return AjaxResult.success(one);
        } else {
            if (!customerService.updateById(one)) {
                return AjaxResult.error("修改失败");
            }
        }
        return AjaxResult.error("修改失败");
        return AjaxResult.success(one);
    }
    /**
     * 小程序根据手机号码获取用户身份证号码
     */
    @GetMapping(value = "/getIdCardByPhone")
    @ApiOperation(value = "小程序根据手机号码获取用户身份证号码")
    public AjaxResult getIdCardByPhone(@RequestParam @ApiParam(value = "手机号") String phone) {
    @GetMapping (value = "/getIdCardByPhone")
    @ApiOperation (value = "小程序根据手机号码获取用户身份证号码")
    public AjaxResult getIdCardByPhone(@RequestParam @ApiParam (value = "手机号") String phone) {
        if (!"".equals(phone) && phone != null && MatchUtils.isMobileNO(phone)) {
            LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>();
            qw.eq(TjCustomer::getCusPhone, phone);
            List<TjCustomer> tjCustomer1 = customerService.list(qw);
            if (tjCustomer1 != null && tjCustomer1.size()>0) {
            if (tjCustomer1 != null && tjCustomer1.size() > 0) {
                List<String> num = new ArrayList<>();
                for (TjCustomer tjCustomer : tjCustomer1) {
                    num.add(tjCustomer.getCusIdcard());
@@ -277,7 +272,7 @@
    /**
     * 根据字典类型查询字典数据信息
     */
    @GetMapping(value = "/type/{dictType}")
    @GetMapping (value = "/type/{dictType}")
    public AjaxResult dictType(@PathVariable String dictType) {
        List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
        if (StringUtils.isNull(data)) {
@@ -285,7 +280,6 @@
        }
        return success(data);
    }
    //将方法返回值解析成json格式
@@ -311,10 +305,17 @@
            if (null != resultData && resultData.size() > 0) {
                String pationid = resultData.get("PationId").toString();
                if (null != pationid) {
                    tjCustomer.setPationId(pationid);
                    customerService.updateById(tjCustomer);
                    try {
                        if (tjCustomer.getCusId() == null) {
                            tjCustomer.setPationId(pationid);
                        }
                        customerService.saveOrUpdate(tjCustomer);
                    } catch (Exception e) {
                        e.printStackTrace();
                        return AjaxResult.error("操作失败!");
                    }
                    //保存注册入参出参
                    resultData.put("cardId",pationid);
                    resultData.put("cardId", pationid);
                    JSONObject object4 = JSONUtil.parseObj(resultData);
                    LambdaQueryWrapper<HisApiConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
                    lambdaQueryWrapper.eq(HisApiConfig::getApiMethod, "Outpincreateapply");
@@ -323,7 +324,7 @@
                }
            }
           return AjaxResult.success();
            return AjaxResult.success(tjCustomer);
        }
        return AjaxResult.error(object.getStr("ResultContent"));
    }