Commit da3bebbf by 李小龙

语音短信

parent 3bbedd54
...@@ -103,8 +103,9 @@ CREATE TABLE `plat_menu` ( ...@@ -103,8 +103,9 @@ CREATE TABLE `plat_menu` (
`del_flag` char(1) DEFAULT NULL COMMENT '删除标识', `del_flag` char(1) DEFAULT NULL COMMENT '删除标识',
`create_by` varchar(64) NOT NULL COMMENT '创建人', `create_by` varchar(64) NOT NULL COMMENT '创建人',
`update_by` varchar(64) NOT NULL COMMENT '更新人', `update_by` varchar(64) NOT NULL COMMENT '更新人',
`page_type` varchar(4) DEFAULT NULL COMMENT '页面类别', `page_type` varchar(20) DEFAULT NULL COMMENT '页面类别',
`page_query` varchar(512) DEFAULT NULL COMMENT '跳转参数', `page_query` varchar(512) DEFAULT NULL COMMENT '跳转参数',
`code` varchar(255) DEFAULT NULL COMMENT '页面标识',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户端资源管理'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户端资源管理';
......
...@@ -6,7 +6,7 @@ public class IdConst { ...@@ -6,7 +6,7 @@ public class IdConst {
public static final String DEFAULT_ID_ZERO = "0"; public static final String DEFAULT_ID_ZERO = "0";
public static final String DEFAULT_ID_ONE = "1"; public static final String DEFAULT_ID_ONE = "1";
//todo 这个id待确认
public static final String DEFAULT_FACTORY_ID = "1544975976697262082"; public static final String DEFAULT_FACTORY_ID = "1544975976697262082";
public static final String ROLE_COMMON_USER_NAME="普通用户"; public static final String ROLE_COMMON_USER_NAME="普通用户";
......
...@@ -24,6 +24,11 @@ public class PlatMenuDTOVO extends BaseIdDTO { ...@@ -24,6 +24,11 @@ public class PlatMenuDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
private String name; private String name;
/**
* 资源标识
*/
private String code;
@ApiModelProperty(value = "图标") @ApiModelProperty(value = "图标")
private String icon; private String icon;
......
...@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component; ...@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
import java.util.Collection; import java.util.Collection;
@Component @Component
public class MsgUtil { public class MsgSendUtil {
/** /**
* 发送消息并保存记录 * 发送消息并保存记录
......
package com.makeit.utils.msg.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@ConfigurationProperties("voice-sms.send")
@Configuration
public class SmsVoiceConfig {
private String url;
private String uid;
private String pwd;
}
\ No newline at end of file
package com.makeit.utils.msg.dto; package com.makeit.utils.msg.dto;
import com.makeit.utils.msg.SendTypeEnum;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -17,14 +16,15 @@ import java.util.regex.Pattern; ...@@ -17,14 +16,15 @@ import java.util.regex.Pattern;
@NoArgsConstructor @NoArgsConstructor
public class MsgDTO { public class MsgDTO {
private SendTypeEnum sendTypeEnum;
private String subject; private String subject;
private List<String> receiverList; private List<String> receiverList;
private String oriContent; private String oriContent;
/**
* 语音短信:老人姓名 最多支持两个
*/
private String[] param; private String[] param;
private String sendContent; private String sendContent;
......
...@@ -8,5 +8,5 @@ public interface IMsgSender { ...@@ -8,5 +8,5 @@ public interface IMsgSender {
* 发送消息 * 发送消息
* @param msgData 消息数据 * @param msgData 消息数据
*/ */
void send(MsgDTO MsgDTO) throws Exception; void send(MsgDTO msgDTO);
} }
...@@ -30,14 +30,14 @@ public class SmsMsgSender implements IMsgSender{ ...@@ -30,14 +30,14 @@ public class SmsMsgSender implements IMsgSender{
* @param msgDTO * @param msgDTO
*/ */
@Override @Override
public void send(MsgDTO msgDTO) throws Exception { public void send(MsgDTO msgDTO) {
try { try {
Date now = new Date(); Date now = new Date();
String time = String.valueOf(now.getTime()); String time = String.valueOf(now.getTime());
List<String> receiverList = msgDTO.getReceiverList(); List<String> receiverList = msgDTO.getReceiverList();
String receiverJoin = receiverList.stream().collect(Collectors.joining(",")); String receiverJoin = receiverList.stream().collect(Collectors.joining(","));
HashMap<String, String> paramMap = new HashMap<>(); HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsConfig.getUid() + 1000); paramMap.put("uid", smsConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time ) //md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsConfig.getPwd()); String md16 = CryptoUtil.md5_16(smsConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time); String md32 = CryptoUtil.md5(md16 + time);
...@@ -47,7 +47,7 @@ public class SmsMsgSender implements IMsgSender{ ...@@ -47,7 +47,7 @@ public class SmsMsgSender implements IMsgSender{
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8")); paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class); String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr); JSONObject jsonObject = JSON.parseObject(resStr);
String status = (String) jsonObject.get("status"); String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) { if (!StringUtils.equals(status, "0")) {
throw new BusinessException((String) jsonObject.get("status_code")); throw new BusinessException((String) jsonObject.get("status_code"));
} }
......
package com.makeit.utils.msg.sender;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.makeit.exception.BusinessException;
import com.makeit.utils.msg.config.SmsVoiceConfig;
import com.makeit.utils.msg.dto.MsgDTO;
import com.makeit.utils.old.encode.CryptoUtil;
import com.makeit.utils.third.HttpClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
@Component
public class SmsVoiceSender implements IMsgSender{
@Autowired
private SmsVoiceConfig smsVoiceConfig;
/**
* 发送消息
*
* @param msgDTO
*/
@Override
public void send(MsgDTO msgDTO) {
try {
Date now = new Date();
String time = String.valueOf(now.getTime());
List<String> receiverList = msgDTO.getReceiverList();
String receiverJoin = receiverList.stream().collect(Collectors.joining(","));
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsVoiceConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsVoiceConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", receiverJoin);
String[] param = msgDTO.getParam();
List<BiConsumer<HashMap<String,String>,String>> consumerList = Arrays.asList(
(t,v)->t.put("one",v),
(t,v)->t.put("two",v)
);
for (int i = 0; i < param.length; i++) {
BiConsumer<HashMap<String, String>, String> biConsumer = consumerList.get(i);
biConsumer.accept(paramMap,param[i]);
}
String resStr = HttpClient.sendJSONPostRequest(smsVoiceConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
throw new BusinessException((String) jsonObject.get("status_code"));
}
}catch (Exception e){
throw new BusinessException(e.getMessage().toString());
}
}
}
...@@ -57,6 +57,10 @@ public class RedisUtil { ...@@ -57,6 +57,10 @@ public class RedisUtil {
client = redissonClient; client = redissonClient;
} }
public static RedissonClient getClient() {
return client;
}
/** /**
* 创建锁带默认过期时间 * 创建锁带默认过期时间
*/ */
......
...@@ -7,10 +7,12 @@ import com.makeit.common.page.PageVO; ...@@ -7,10 +7,12 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO; import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.msg.dto.MsgDTO; import com.makeit.utils.msg.dto.MsgDTO;
import com.makeit.utils.msg.sender.MailMsgSender; import com.makeit.utils.msg.sender.MailMsgSender;
import com.makeit.utils.msg.sender.SmsMsgSender; import com.makeit.utils.msg.sender.SmsMsgSender;
import com.makeit.utils.msg.sender.SmsVoiceSender;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO; import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -57,6 +59,8 @@ public class PlatAlarmRecordController { ...@@ -57,6 +59,8 @@ public class PlatAlarmRecordController {
private MailMsgSender mailMsgSender; private MailMsgSender mailMsgSender;
@Autowired @Autowired
private SmsMsgSender smsMsgSender; private SmsMsgSender smsMsgSender;
@Autowired
private SmsVoiceSender smsVoiceSender;
@ApiOperation("测试邮箱") @ApiOperation("测试邮箱")
@PostMapping("testMail") @PostMapping("testMail")
...@@ -78,5 +82,16 @@ public class PlatAlarmRecordController { ...@@ -78,5 +82,16 @@ public class PlatAlarmRecordController {
smsMsgSender.send(msgDTO); smsMsgSender.send(msgDTO);
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("测试语音短信")
@PostMapping("testVoice")
@AuthIgnore
public ApiResponseEntity<Void> testVoice(@RequestBody BaseIdDTO dto) throws Exception {
MsgDTO msgDTO = new MsgDTO();
msgDTO.setReceiverList(Collections.singletonList("18850503603"));
msgDTO.setOriContent("测试短信test");
smsVoiceSender.send(msgDTO);
return ApiResponseUtils.success();
}
} }
...@@ -23,6 +23,11 @@ public class PlatMenu extends BaseEntity { ...@@ -23,6 +23,11 @@ public class PlatMenu extends BaseEntity {
private String name; private String name;
/** /**
* 资源标识
*/
private String code;
/**
* 账号链接 * 账号链接
*/ */
private String requestPath; private String requestPath;
......
...@@ -23,7 +23,7 @@ import com.makeit.service.platform.elder.PlatElderSocialRelationService; ...@@ -23,7 +23,7 @@ import com.makeit.service.platform.elder.PlatElderSocialRelationService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService; import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.msg.MsgUtil; import com.makeit.utils.msg.MsgSendUtil;
import com.makeit.utils.msg.SendTypeEnum; import com.makeit.utils.msg.SendTypeEnum;
import com.makeit.utils.sql.join.JoinUtil; import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.utils.user.common.CommonUserUtil; import com.makeit.utils.user.common.CommonUserUtil;
...@@ -61,7 +61,7 @@ implements PlatAlarmRecordService{ ...@@ -61,7 +61,7 @@ implements PlatAlarmRecordService{
private PlatElderSocialRelationService platElderSocialRelationService; private PlatElderSocialRelationService platElderSocialRelationService;
@Autowired @Autowired
private MsgUtil msgUtil; private MsgSendUtil msgUtil;
@Override @Override
public PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto) { public PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
......
...@@ -117,7 +117,7 @@ implements PlatMenuService { ...@@ -117,7 +117,7 @@ implements PlatMenuService {
*/ */
private void checkCode(PlatMenuDTOVO dto) { private void checkCode(PlatMenuDTOVO dto) {
PlatMenu old = getOne(new QueryWrapper<PlatMenu>().lambda() PlatMenu old = getOne(new QueryWrapper<PlatMenu>().lambda()
.eq(PlatMenu::getName, dto.getName())); .eq(PlatMenu::getCode, dto.getCode()));
if (old != null && !old.getId().equals(dto.getId())) { if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE); throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
} }
...@@ -174,33 +174,33 @@ implements PlatMenuService { ...@@ -174,33 +174,33 @@ implements PlatMenuService {
public void sync() { public void sync() {
List<PlatMenu> exitList = list(new QueryWrapper<PlatMenu>().lambda() List<PlatMenu> exitList = list(new QueryWrapper<PlatMenu>().lambda()
.isNotNull(PlatMenu::getName) .isNotNull(PlatMenu::getCode)
.in(PlatMenu::getResourceType, SysEnum.MenuTypeEnum.MENU.getValue(), SysEnum.MenuTypeEnum.BUTTON.getValue()) .in(PlatMenu::getResourceType, SysEnum.MenuTypeEnum.MENU.getValue(), SysEnum.MenuTypeEnum.BUTTON.getValue())
); );
Map<String, PlatMenu> exitCodeMap = StreamUtil.toMapDep(exitList, PlatMenu::getName); Map<String, PlatMenu> exitCodeMap = StreamUtil.toMapDep(exitList, PlatMenu::getCode);
//查询数据库中已存在的权限 //查询数据库中已存在的权限
List<PlatMenu> exitButtonList = StreamUtil.filter(exitList, e -> SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getResourceType())); List<PlatMenu> exitButtonList = StreamUtil.filter(exitList, e -> SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getResourceType()));
Map<String, PlatMenu> exitButtonCodeMap = StreamUtil.toMap(exitButtonList, PlatMenu::getName); Map<String, PlatMenu> exitButtonCodeMap = StreamUtil.toMap(exitButtonList, PlatMenu::getCode);
//加载项目中的权限 //加载项目中的权限
List<PlatMenu> loadActionList = StreamUtil.filter(this.load(), e -> !TreeConst.TOP_LEVEL.equals(e.getParentId())); List<PlatMenu> loadActionList = StreamUtil.filter(this.load(), e -> !TreeConst.TOP_LEVEL.equals(e.getParentId()));
Set<String> loadActionCodeList = loadActionList.stream().map(PlatMenu::getName).collect(Collectors.toSet()); Set<String> loadActionCodeList = loadActionList.stream().map(PlatMenu::getCode).collect(Collectors.toSet());
//新增加的权限 //新增加的权限
List<PlatMenu> addActionList = loadActionList.stream().filter(item -> List<PlatMenu> addActionList = loadActionList.stream().filter(item ->
!exitButtonCodeMap.containsKey(item.getName())).collect(Collectors.toList()); !exitButtonCodeMap.containsKey(item.getCode())).collect(Collectors.toList());
//删除的权限 //删除的权限
List<PlatMenu> deleteActionList = exitButtonList.stream().filter(item -> List<PlatMenu> deleteActionList = exitButtonList.stream().filter(item ->
!loadActionCodeList.contains(item.getName())).collect(Collectors.toList()); !loadActionCodeList.contains(item.getCode())).collect(Collectors.toList());
saveBatch(StreamUtil.filter(addActionList, e -> TreeConst.TOP_LEVEL.equals(e.getParentId()))); saveBatch(StreamUtil.filter(addActionList, e -> TreeConst.TOP_LEVEL.equals(e.getParentId())));
addActionList.forEach(e -> { addActionList.forEach(e -> {
if (TreeConst.TOP_LEVEL.equals(e.getParentId())) { if (TreeConst.TOP_LEVEL.equals(e.getParentId())) {
exitCodeMap.put(e.getName(), e); exitCodeMap.put(e.getCode(), e);
} }
}); });
...@@ -210,7 +210,7 @@ implements PlatMenuService { ...@@ -210,7 +210,7 @@ implements PlatMenuService {
if (!TreeConst.TOP_LEVEL.equals(e.getParentId())) { if (!TreeConst.TOP_LEVEL.equals(e.getParentId())) {
String groupCode = getGroupCode(e.getName()); String groupCode = getGroupCode(e.getCode());
PlatMenu buttonGroup = exitCodeMap.get(groupCode); PlatMenu buttonGroup = exitCodeMap.get(groupCode);
if (buttonGroup != null) { if (buttonGroup != null) {
e.setParentId(buttonGroup.getId()); e.setParentId(buttonGroup.getId());
...@@ -287,7 +287,7 @@ implements PlatMenuService { ...@@ -287,7 +287,7 @@ implements PlatMenuService {
PlatMenu button = new PlatMenu(); PlatMenu button = new PlatMenu();
button.setName(action.name()); button.setName(action.name());
//button.setCode(e); button.setCode(e);
button.setSort(0); button.setSort(0);
button.setStatus(CommonEnum.YES.getValue()); button.setStatus(CommonEnum.YES.getValue());
button.setResourceType(SysEnum.MenuTypeEnum.BUTTON.getValue()); button.setResourceType(SysEnum.MenuTypeEnum.BUTTON.getValue());
...@@ -323,7 +323,7 @@ implements PlatMenuService { ...@@ -323,7 +323,7 @@ implements PlatMenuService {
private PlatMenu generateButtonGroup(String name, String code) { private PlatMenu generateButtonGroup(String name, String code) {
PlatMenu button = new PlatMenu(); PlatMenu button = new PlatMenu();
button.setName(name); button.setName(name);
// button.setCode(code); button.setCode(code);
button.setParentId(TreeConst.TOP_LEVEL); button.setParentId(TreeConst.TOP_LEVEL);
button.setSort(0); button.setSort(0);
button.setStatus(CommonEnum.YES.getValue()); button.setStatus(CommonEnum.YES.getValue());
......
...@@ -134,16 +134,11 @@ sms: ...@@ -134,16 +134,11 @@ sms:
url: http://www.aozoneyun.com/message/message/send url: http://www.aozoneyun.com/message/message/send
uid: 357 uid: 357
pwd: xmks123456 pwd: xmks123456
rec: voice-sms:
url: send:
query: url: http://www.aozoneyun.com/Message/Message/video_send
url: http://www.aozoneyun.com/message/message/balance uid: 362
pwd: xmksyy123456
voiceSms:
url: http://www.aozoneyun.com/Message/Message/video_send
uid: 362
pwd: xmksyy123456
......
...@@ -131,13 +131,8 @@ sms: ...@@ -131,13 +131,8 @@ sms:
url: http://www.aozoneyun.com/message/message/send url: http://www.aozoneyun.com/message/message/send
uid: 357 uid: 357
pwd: xmks123456 pwd: xmks123456
rec: voice-sms:
url: send:
query: url: http://www.aozoneyun.com/Message/Message/video_send
url: http://www.aozoneyun.com/message/message/balance uid: 362
pwd: xmksyy123456
\ No newline at end of file
voiceSms:
url: http://www.aozoneyun.com/Message/Message/video_send
uid: 362
pwd: xmksyy123456
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment