liusheng
2024-11-27 e44f3f7b666394907a016488e79f788e7ed97a70
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -749,6 +749,9 @@
                req.put("caller", phoneCallReqYQVO.getPhone());
                HttpUtil.postJsonRequest(hangup, new Gson().toJson(req));
                redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- hangup", "1", 2, TimeUnit.MINUTES);
                //先把默认的recordAccept-hungup删除,再更新
                redisCache.deleteObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup");
                redisCache.setCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES);
                //这个时候就需要走补偿机制了,先暂定走短信
                getSmsCompensate(Long.valueOf(phoneCallReqYQVO.getTaskid()));
                return new PhoneCallBackYQVO();
@@ -781,7 +784,6 @@
                    HttpUtil.postJsonRequest(hangup, new Gson().toJson(req));
                    //删除结束语的患存
                    redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "- jsy");
                    redisCache.setCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup", "2", 10, TimeUnit.MINUTES);
                } else {
                    redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop", true, 120, TimeUnit.MINUTES);
                    log.error("-------PlayEventCallbackPlaystop的值为:{}", true);
@@ -870,7 +872,9 @@
            }
            return phoneCallBackYQVO;
        } else if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) {
            //做一个标识,用来在通话详情接口里,判断是否有人接电话(value=2,表示有人接)
            redisCache.deleteObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup");
            redisCache.setCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup", "2", 10, TimeUnit.MINUTES);
            // 先对通话进行通用库匹配一次
            String extemplateID = ivrTaskTemplate.getSubmoduleID();
            if (StringUtils.isNotEmpty(extemplateID)) {
@@ -1700,8 +1704,12 @@
    @Override
    public Integer recordAccept(PhoneCallRecordVO phoneCallRecordVO) {
        Object cacheObject = redisCache.getCacheObject("recordAccept-hungup");
        if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("2")) {
        Object cacheObject = redisCache.getCacheObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup");
        if (phoneCallRecordVO.getHangup_cause().equals("NO_USER_RESPONSE") || ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("1")) {
            //无人接听
            getSmsCompensate(Long.valueOf(phoneCallRecordVO.getTaskid()));
            redisCache.deleteObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup");
        } else if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("2")) {
//        if (phoneCallRecordVO.getAnswered() != null && phoneCallRecordVO.getAnswered() == true) {
            log.error("有人接电话了,并且完了");
            //说明有人接了
@@ -1710,11 +1718,21 @@
            String result = phoneCallRecordVO.getRecord_path().substring(startIndex, endIndex);
            //下载文件
            ftpService.downloadFolder("/" + LocalDate.now().toString(), profile + "/upload/vadio/voice/" + LocalDate.now().toString());
        } else if (phoneCallRecordVO.getHangup_cause().equals("NO_USER_RESPONSE") || ObjectUtils.isNotEmpty(cacheObject) && !String.valueOf(cacheObject).equals("2")) {
            //无人接听
            getSmsCompensate(Long.valueOf(phoneCallRecordVO.getTaskid()));
            redisCache.deleteObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup");
        } else {
            //患者拒绝随访
            ServiceSubtask serviceSubtask = new ServiceSubtask();
            serviceSubtask.setRemark("电话接通成功,患者拒绝随访");
            serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid()));
            serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
            int startIndex = phoneCallRecordVO.getRecord_path().indexOf("voice") + "voice".length() + 1;  // 加1是跳过/符号
            int endIndex = phoneCallRecordVO.getRecord_path().lastIndexOf("/");
            String result = phoneCallRecordVO.getRecord_path().substring(startIndex, endIndex);
            //下载文件
            ftpService.downloadFolder("/" + LocalDate.now().toString(), profile + "/upload/vadio/voice/" + LocalDate.now().toString());
            redisCache.deleteObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup");
        }
        redisCache.deleteObject("recordAccept-hungup");
        return 1;
    }
@@ -1829,8 +1847,7 @@
        map.put("content", sendMagParam.getContent());
        String result = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map));
        redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES);
        if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
            serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功");
        if (StringUtils.isNotEmpty(serviceSubtask.getRemark())) serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功");
        else serviceSubtask.setRemark("短信补偿发送成功");
        serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
    }