فهرست منبع

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/care/bms/controller/VoiceCallbackController.java
suntianwu 3 سال پیش
والد
کامیت
e9542bcb98

+ 2 - 2
src/main/java/com/care/bms/controller/VoiceCallbackController.java

@@ -54,7 +54,7 @@ public class VoiceCallbackController {
                     status = ContactorStatusEnum.WEI_JIE_TONG.getValue();
                 }
 
-                bmsEventOrderService.updateOrderContactStatus4Callback(callId,Long.parseLong(orderId), mobile, status,"无");
+                bmsEventOrderService.updateOrderContactStatus4Callback(Long.parseLong(orderId), mobile, status,"无");
 
                 Map<String, Object> rtn = new HashMap<>();
                 rtn.put("result", 0);
@@ -74,7 +74,7 @@ public class VoiceCallbackController {
 
                     Integer status =  ContactorStatusEnum.WEI_JIE_TONG.getValue();
 
-                    bmsEventOrderService.updateOrderContactStatus4Callback(callId,Long.parseLong(orderId), mobile, status,failureReason);
+                    bmsEventOrderService.updateOrderContactStatus4Callback(Long.parseLong(orderId), mobile, status,failureReason);
 
                     Map<String, Object> rtn = new HashMap<>();
                     rtn.put("result", 0);

+ 28 - 24
src/main/java/com/care/bms/service/BmsEventOrderService.java

@@ -522,7 +522,7 @@ public class BmsEventOrderService {
         List<OrderHandleHisVO> result = Lists.newArrayList();
         QueryWrapper<CareEventOrderHandleHis> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("distinct org_id,station_id,house_id,order_id,log_type,order_type,log_object_id,log_object_name,log_result," +
-                "op_user_role,op_user_id,op_user_name,create_time,relation_type_desc,call_result_id").lambda().eq(CareEventOrderHandleHis::getOrderId, orderId)
+                "op_user_role,op_user_id,op_user_name,create_time,relation_type_desc,call_result_id,voice_call_status,voice_failure_reason").lambda().eq(CareEventOrderHandleHis::getOrderId, orderId)
                 .orderByDesc(CareEventOrderHandleHis::getCreateTime);
         List<CareEventOrderHandleHis> datas = this.careEventOrderHandleHisService.list(queryWrapper);
         if (CollUtil.isNotEmpty(datas)) {
@@ -605,30 +605,34 @@ public class BmsEventOrderService {
         List<Dict> pushRecords = Lists.newArrayList();
         for (Object orderId : orderIds) {
             CareEventOrder order = this.careEventOrderService.getById(NumberUtils.toLong(Objects.toString(orderId)));
-            UpdateWrapper<CareEventOrder> updateWrapper = new UpdateWrapper<>();
-            updateWrapper.lambda().eq(CareEventOrder::getId, orderId)
-                    .set(CareEventOrder::getStatus, OrderStatusEnum.COMPLETE.getValue())
-                    .set(CareEventOrder::getModifyTime, DateUtil.date());
-            this.careEventOrderService.update(updateWrapper);
-            CareEventOrderHandleHis log = new CareEventOrderHandleHis();
-            log.setOrgId(order.getOrgId());
-            log.setStationId(order.getStationId());
-            log.setOrderId(order.getId());
-            log.setLogType(LogTypeEnum.CLOSE.getValue());
-            log.setLogObjectId(loginUser.getId());
-            log.setLogObjectName(loginUser.getName());
-            log.setLogResult("完成工单");
-            log.setOpUserRole(UserRoleEnum.SEAT.getValue());
-            log.setCreateTime(DateUtil.date());
-            log.setRelationTypeDesc(UserRoleEnum.getCodeToName(loginUser.getRole()));
-            boolean saved = this.careEventOrderHandleHisService.save(log);
-            if (!saved) {
-                throw new BDException("事件归档出现错误, 请稍后重试");
+            if (OrderStatusEnum.TODO.getValue().equals(order.getStatus()) || OrderStatusEnum.DOING.getValue().equals(order.getStatus())){
+                UpdateWrapper<CareEventOrder> updateWrapper = new UpdateWrapper<>();
+                updateWrapper.lambda().eq(CareEventOrder::getId, orderId)
+                        .set(CareEventOrder::getStatus, OrderStatusEnum.COMPLETE.getValue())
+                        .set(CareEventOrder::getSeatId,loginUser.getId())
+                        .set(CareEventOrder::getSeatName,loginUser.getName())
+                        .set(CareEventOrder::getModifyTime, DateUtil.date());
+                this.careEventOrderService.update(updateWrapper);
+                CareEventOrderHandleHis log = new CareEventOrderHandleHis();
+                log.setOrgId(order.getOrgId());
+                log.setStationId(order.getStationId());
+                log.setOrderId(order.getId());
+                log.setLogType(LogTypeEnum.CLOSE.getValue());
+                log.setLogObjectId(loginUser.getId());
+                log.setLogObjectName(loginUser.getName());
+                log.setLogResult("完成工单");
+                log.setOpUserRole(UserRoleEnum.SEAT.getValue());
+                log.setCreateTime(DateUtil.date());
+                log.setRelationTypeDesc(UserRoleEnum.getCodeToName(loginUser.getRole()));
+                boolean saved = this.careEventOrderHandleHisService.save(log);
+                if (!saved) {
+                    throw new BDException("事件归档出现错误, 请稍后重试");
+                }
+                pushRecords.add(Dict.create()
+                        .set("orgId", order.getOrgId())
+                        .set("stationId", order.getStationId())
+                        .set("orderId", orderId));
             }
-            pushRecords.add(Dict.create()
-                    .set("orgId", order.getOrgId())
-                    .set("stationId", order.getStationId())
-                    .set("orderId", orderId));
         }
         for (Dict dict : pushRecords) {
             this.bigScreenService.pushRtEventFlag(dict.getLong("orgId"), dict.getLong("stationId"), dict.getStr("orderId"), "bigscreenRefresh");

+ 19 - 9
src/main/java/com/care/common/service/impl/CareEventOrderServiceImpl.java

@@ -176,7 +176,7 @@ public class CareEventOrderServiceImpl extends ServiceImpl<CareEventOrderMapper,
                 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                 data.put("first", new TemplateDataDTO("新安全事件", "#ff5200"));
                 data.put("keyword1", new TemplateDataDTO(OrderTypeEnum.getCodeToName(order.getOrderType())+"报警", "#000000"));
-                data.put("keyword2", new TemplateDataDTO(simpleDateFormat.format(new Date()), "#000000"));
+                data.put("keyword2", new TemplateDataDTO(simpleDateFormat.format(order.getCreateTime()), "#000000"));
                 data.put("keyword3", new TemplateDataDTO(house.getAddr(), "#000000"));
                 data.put("remark", new TemplateDataDTO("请尽快联系您的被监护人, 确认现场情况", "#ff5200"));
                 boolean smsResult = this.wxNoticSendService.sendWhenHappen(careMemberInfo.getOpenId(),data);
@@ -294,6 +294,7 @@ public class CareEventOrderServiceImpl extends ServiceImpl<CareEventOrderMapper,
                 CareHouse house = this.careHouseService.getById(order.getHouseId());
                 if (CollUtil.isNotEmpty(contacts)){
                     contacts.forEach(item ->{
+                        log.warn("语音联系人:{}",item);
                         MySendStatus sendStatus = null;
                         String[] params = null;
                         log.info(" 准备发送语音消息 : 工单ID:{}, 联系人:{}",order.getId(),item.getContactPhone());
@@ -308,7 +309,7 @@ public class CareEventOrderServiceImpl extends ServiceImpl<CareEventOrderMapper,
                             sendStatus = voiceSendService.sendVoiceHappen(order.getId()+"",item.getContactPhone(),params);
                         }
 
-                        if (sendStatus != null && sendStatus.isSuccess()) {
+                        if (sendStatus != null ) {
                             CareEventOrderHandleHis his2 = new CareEventOrderHandleHis();
                             his2.setOrgId(item.getOrgId());
                             his2.setStationId(item.getStationId());
@@ -321,16 +322,21 @@ public class CareEventOrderServiceImpl extends ServiceImpl<CareEventOrderMapper,
                             his2.setOpUserRole(UserRoleEnum.SEAT.getValue());
                             his2.setCreateTime(DateUtil.date());
                             his2.setRelationTypeDesc(item.getRelationTypeDesc());
+                            if ( sendStatus.isSuccess()){
+                                log.info(" 事件语音通知成功 : 工单ID:{}, 联系人:{}",order.getId(),item);
+                            }else{
+                                his2.setVoiceCallStatus(ContactorStatusEnum.WEI_LIAN_XI.getValue().toString());
+                                his2.setVoiceFailureReason(sendStatus.getReason());
+                                log.error(" 事件语音通知失败 : 工单ID:{}, 联系人:{}",order.getId(),item);
+                            }
                             this.careEventOrderHandleHisService.save(his2);
-                            log.info(" 事件语音通知成功 : 工单ID:{}, 联系人:{}",order.getId(),item);
-                        }else{
-                            log.error(" 事件语音通知失败 : 工单ID:{}, 联系人:{}",order.getId(),item);
                         }
                     });
                 }
                 //给管家发语音通知
                 if (CollUtil.isNotEmpty(chambList)){
                     chambList.forEach(item ->{
+                        log.warn("语音管家:{}",item);
                         MySendStatus sendStatus = null;
                         String[] params = null;
                         log.info(" 准备发送语音消息 : 工单ID:{}, 联系人:{}",order.getId(),item.getPhone());
@@ -341,7 +347,7 @@ public class CareEventOrderServiceImpl extends ServiceImpl<CareEventOrderMapper,
                             params = new String[]{DateUtil.format(order.getCreateTime(),"MM月dd日HH时mm分"),"跌倒",house.getName()};
                             sendStatus = voiceSendService.sendVoiceHappen(order.getId()+"",item.getPhone(),params);
                         }
-                        if (sendStatus != null && sendStatus.isSuccess()){
+                        if (sendStatus!=null){
                             CareEventOrderHandleHis his2 = new CareEventOrderHandleHis();
                             his2.setOrgId(item.getOrgId());
                             his2.setStationId(item.getStationId());
@@ -354,10 +360,14 @@ public class CareEventOrderServiceImpl extends ServiceImpl<CareEventOrderMapper,
                             his2.setOpUserRole(UserRoleEnum.SEAT.getValue());
                             his2.setCreateTime(DateUtil.date());
                             his2.setRelationTypeDesc("管家");
+                            if ( sendStatus.isSuccess()){
+                                log.info(" 事件语音通知成功 : 工单ID:{}, 管家:{}",order.getId(),item);
+                            }else{
+                                his2.setVoiceCallStatus(ContactorStatusEnum.WEI_LIAN_XI.getValue().toString());
+                                his2.setVoiceFailureReason(sendStatus.getReason());
+                                log.error(" 事件语音短信通知失败 : 工单ID:{}, 管家:{},失败原因:{}",order.getId(),item,sendStatus.getReason());
+                            }
                             this.careEventOrderHandleHisService.save(his2);
-                            log.info(" 事件语音通知成功 : 工单ID:{}, 管家:{}",order.getId(),item);
-                        }else{
-                            log.error(" 事件语音短信通知失败 : 工单ID:{}, 管家:{}",order.getId(),item);
                         }
                     });
                 }

+ 5 - 15
src/main/java/com/care/common/service/impl/VoiceSendServiceImpl.java

@@ -42,45 +42,35 @@ public class VoiceSendServiceImpl implements VoiceSendService {
     @Override
     public MySendStatus sendVoiceHappen(String sessionContext,String phone, String[] params) {
         String[] _p = params;
-        MySendStatus mySendStatus = new MySendStatus();
+        MySendStatus sendStatus = null;
         String _noticeTemplateId =  templateidHappen;
         if (StrUtil.isNotEmpty(_noticeTemplateId)){
-            SendStatus sendStatus =  VoiceUtil.sendTtsVoice(sessionContext,noticeEndpoint,
+            sendStatus =  VoiceUtil.sendTtsVoice(sessionContext,noticeEndpoint,
                     noticeRegion,
                     noticeSecretId,
                     noticeecretKey,
                     noticeVoiceSdkAppId,
                     _noticeTemplateId,
                     phone,_p);
-            if (sendStatus != null && sendStatus.getCallId() != null){
-                mySendStatus.setCallId(sendStatus.getCallId());
-                mySendStatus.setSessionContext(sendStatus.getSessionContext());
                 //存入redis
                 System.out.println("sendVoiceHappen:callId==" + sendStatus.getCallId());
                 redisUtil.hset(RedisKeyConstant.VOICE_CALLBACK_INFO, sendStatus.getCallId(), sendStatus.getSessionContext(), RedisKeyConstant.VOICE_CALLBACK_INFO_TIME);
-                mySendStatus.setSuccess(true);
-            }
         }
-        return  mySendStatus;
+        return  sendStatus;
     }
     @Override
     public MySendStatus sendVoiceCancel(String sessionContext, String phone, String[] params) {
         String[] _p = params;
-        MySendStatus mySendStatus = new MySendStatus();
+        MySendStatus mySendStatus = null;
         String _noticeTemplateId =  templateidCancel;
         if (StrUtil.isNotEmpty(_noticeTemplateId)){
-            SendStatus sendStatus =  VoiceUtil.sendTtsVoice(sessionContext,noticeEndpoint,
+             mySendStatus =  VoiceUtil.sendTtsVoice(sessionContext,noticeEndpoint,
                     noticeRegion,
                     noticeSecretId,
                     noticeecretKey,
                     noticeVoiceSdkAppId,
                     _noticeTemplateId,
                     phone,_p);
-            if (sendStatus != null && sendStatus.getCallId() != null){
-                mySendStatus.setCallId(sendStatus.getCallId());
-                mySendStatus.setSessionContext(sendStatus.getSessionContext());
-                mySendStatus.setSuccess(true);
-            }
         }
         return  mySendStatus;
     }

+ 22 - 18
src/main/java/com/care/common/util/VoiceUtil.java

@@ -1,21 +1,20 @@
 package com.care.common.util;
+
 import cn.hutool.json.JSONUtil;
+import com.care.common.vo.MySendStatus;
 import com.tencentcloudapi.common.Credential;
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
-
-// 导入可选配置类
 import com.tencentcloudapi.common.profile.ClientProfile;
 import com.tencentcloudapi.common.profile.HttpProfile;
-
-// 导入对应VMS模块的client
 import com.tencentcloudapi.vms.v20200902.VmsClient;
-
-// 导入要请求接口对应的request response类
-import com.tencentcloudapi.vms.v20200902.models.SendStatus;
 import com.tencentcloudapi.vms.v20200902.models.SendTtsVoiceRequest;
 import com.tencentcloudapi.vms.v20200902.models.SendTtsVoiceResponse;
 import lombok.extern.slf4j.Slf4j;
 
+// 导入可选配置类
+// 导入对应VMS模块的client
+// 导入要请求接口对应的request response类
+
 /**
  * Tencent Cloud Vms SendTtsVoice
  * https://cloud.tencent.com/document/product/1128/51558
@@ -23,14 +22,15 @@ import lombok.extern.slf4j.Slf4j;
  */
 @Slf4j
 public class VoiceUtil {
-    public static SendStatus sendTtsVoice(String sessionContext,String endpoint,
-                                          String region,
-                                          String secretId,
-                                          String secretKey,
-                                          String voiceSdkAppId,
-                                          String templateId,
-                                          String phoneNumber,
-                                          String[] templateParam) {
+    public static MySendStatus sendTtsVoice(String sessionContext, String endpoint,
+                                            String region,
+                                            String secretId,
+                                            String secretKey,
+                                            String voiceSdkAppId,
+                                            String templateId,
+                                            String phoneNumber,
+                                            String[] templateParam) {
+        MySendStatus mySendStatus = new MySendStatus();
         try {
             /* 必要步骤:
              * 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
@@ -112,11 +112,15 @@ public class VoiceUtil {
 
             // 也可以取出单个值,您可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
             System.out.println(res.getRequestId());
-            return res.getSendStatus();
+            mySendStatus.setCallId(res.getSendStatus().getCallId());
+            mySendStatus.setSuccess(true);
+            mySendStatus.setSessionContext(res.getSendStatus().getSessionContext());
+
         } catch (TencentCloudSDKException e) {
             log.error("语音发送失败:号码:"+phoneNumber+" ,session:"+sessionContext,e);
-            return null;
+            mySendStatus.setReason(e.getMessage());
         }
+        return mySendStatus;
     }
     public static void main(String[] args) {
         String endpoint ="vms.tencentcloudapi.com";
@@ -127,7 +131,7 @@ public class VoiceUtil {
         String templateId="1182623";
         String phoneNumber="18010375763";
         String[] templateParam = {"yyyy年MM月dd日HH时mm分ss秒","久滞","双华时代"};
-        SendStatus sendStatus = VoiceUtil.sendTtsVoice("", endpoint,
+        MySendStatus sendStatus = VoiceUtil.sendTtsVoice("", endpoint,
                  region,
                  secretId,
                  secretKey,

+ 2 - 0
src/main/java/com/care/common/vo/MySendStatus.java

@@ -10,6 +10,8 @@ public class MySendStatus {
     private String SessionContext;
     // 是否成功
     boolean isSuccess = false;
+
+    private String reason;
     public MySendStatus(){
         this.isSuccess = false;
     }

+ 7 - 0
src/main/java/com/care/common/vo/order/OrderHandleHisVO.java

@@ -1,6 +1,7 @@
 package com.care.common.vo.order;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
@@ -44,6 +45,12 @@ public class OrderHandleHisVO implements Serializable {
     private String logResult;
 
 
+    @ApiModelProperty("语音通知状态:1未联系,2未接通,3已联系")
+    private String voiceCallStatus;
+
+    @ApiModelProperty("操作结果")
+    private String voiceFailureReason;
+
     @ApiModelProperty("chanmb管家 contact紧联系人")
     private String opUserRole;