请他上线电话通知

This commit is contained in:
曹磊 2024-09-11 10:31:59 +08:00
parent 16f1f62981
commit 62b7640f5b
4 changed files with 51 additions and 9 deletions

View File

@ -128,14 +128,10 @@ public class AppMessageController {
messageInfo.setTitle("通知上线");
messageInfo.setByUserName(userEntity.getUserName());
messageInfo.setUserName(artificer.getArtificerName());
messageService.saveBody(messageInfo);
messageService.insertUpMessage(messageInfo);
if (StringUtils.isNotEmpty(artificerUser.getPhone())) {
userService.sendMsg(artificerUser.getPhone(), "qtsx");
}
return Result.success();
}

View File

@ -22,6 +22,8 @@ public interface MessageService extends IService<MessageInfo> {
int saveBody(MessageInfo messageInfo);
int insertUpMessage(MessageInfo messageInfo);
Result insertArtificerLocation(MessageInfo messageInfo);
int update(MessageInfo messageInfo);

View File

@ -30,10 +30,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 消息
@ -165,6 +162,30 @@ public class MessageServiceImpl extends
return messageInfoDao.insert(messageInfo);
}
@Override
public int insertUpMessage(MessageInfo messageInfo){
messageInfo.setCreateAt(DateUtils.format(new Date()));
int returncount = messageInfoDao.insert(messageInfo);
if(returncount == 1) {
//技师电话通知业务
//accountId
String accountId = commonInfoService.findOne(428).getValue();
//token
String token = commonInfoService.findOne(429).getValue();
//templateId 模板id
String templateId = commonInfoService.findOne(466).getValue();
//呼救手机号
Artificer artificer = artificerService.getById(Long.valueOf(messageInfo.getUserId()));
UserEntity byId = userService.getById(artificer.getUserId());
//参数
LinkedHashMap<String,String> params = new LinkedHashMap<String,String>();
params.put("var1",messageInfo.getByUserName());
//呼叫
AppNotifyUtil.AppNotify(byId.getPhone(), accountId, token, templateId, params);
}
return returncount;
}
@Override
public Result insertArtificerLocation(MessageInfo messageInfo){
messageInfo.setState("12");

View File

@ -31,4 +31,27 @@ public class AppNotifyUtil {
}
return Result.error("系统错误,请联系管理员。");
}
public static Result AppNotify(String calleeNumber, String accountId, String token, String templateId, LinkedHashMap<String,String> params) {
VoiceNotifyBody message = new VoiceNotifyBody();
/*用户接收回执的服务器地址*/
message.setCallbackUrl("");
message.setCalleeNumber(calleeNumber);
message.setReplayTimes(1);
/*设置平台分配的模板ID*/
message.setTemplateId(templateId);
if(params == null){
params = new LinkedHashMap<String,String>();
}
message.setTemplateArgs(params);
try {
VoiceResponseResult result1 = VoiceSender.httpsSendVoiceNotify(message, accountId, token);
System.out.println("result = " + result1);
return Result.success().put("data",result1);
}catch (Exception e) {
//Log.e(this.getClass(), " e = " + e);
e.printStackTrace();
}
return Result.error("系统错误,请联系管理员。");
}
}