Commit da3bebbf by 李小龙

语音短信

parent 3bbedd54
......@@ -103,8 +103,9 @@ CREATE TABLE `plat_menu` (
`del_flag` char(1) DEFAULT NULL COMMENT '删除标识',
`create_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 '跳转参数',
`code` varchar(255) DEFAULT NULL COMMENT '页面标识',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户端资源管理';
......
......@@ -6,7 +6,7 @@ public class IdConst {
public static final String DEFAULT_ID_ZERO = "0";
public static final String DEFAULT_ID_ONE = "1";
//todo 这个id待确认
public static final String DEFAULT_FACTORY_ID = "1544975976697262082";
public static final String ROLE_COMMON_USER_NAME="普通用户";
......
......@@ -24,6 +24,11 @@ public class PlatMenuDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "名称")
private String name;
/**
* 资源标识
*/
private String code;
@ApiModelProperty(value = "图标")
private String icon;
......
......@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
import java.util.Collection;
@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;
import com.makeit.utils.msg.SendTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -17,14 +16,15 @@ import java.util.regex.Pattern;
@NoArgsConstructor
public class MsgDTO {
private SendTypeEnum sendTypeEnum;
private String subject;
private List<String> receiverList;
private String oriContent;
/**
* 语音短信:老人姓名 最多支持两个
*/
private String[] param;
private String sendContent;
......
......@@ -8,5 +8,5 @@ public interface IMsgSender {
* 发送消息
* @param msgData 消息数据
*/
void send(MsgDTO MsgDTO) throws Exception;
void send(MsgDTO msgDTO);
}
......@@ -30,14 +30,14 @@ public class SmsMsgSender implements IMsgSender{
* @param msgDTO
*/
@Override
public void send(MsgDTO msgDTO) throws Exception {
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", smsConfig.getUid() + 1000);
paramMap.put("uid", smsConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
......@@ -47,7 +47,7 @@ public class SmsMsgSender implements IMsgSender{
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = (String) jsonObject.get("status");
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
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 {
client = redissonClient;
}
public static RedissonClient getClient() {
return client;
}
/**
* 创建锁带默认过期时间
*/
......
......@@ -7,10 +7,12 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.msg.dto.MsgDTO;
import com.makeit.utils.msg.sender.MailMsgSender;
import com.makeit.utils.msg.sender.SmsMsgSender;
import com.makeit.utils.msg.sender.SmsVoiceSender;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -57,6 +59,8 @@ public class PlatAlarmRecordController {
private MailMsgSender mailMsgSender;
@Autowired
private SmsMsgSender smsMsgSender;
@Autowired
private SmsVoiceSender smsVoiceSender;
@ApiOperation("测试邮箱")
@PostMapping("testMail")
......@@ -78,5 +82,16 @@ public class PlatAlarmRecordController {
smsMsgSender.send(msgDTO);
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 {
private String name;
/**
* 资源标识
*/
private String code;
/**
* 账号链接
*/
private String requestPath;
......
......@@ -23,7 +23,7 @@ import com.makeit.service.platform.elder.PlatElderSocialRelationService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
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.sql.join.JoinUtil;
import com.makeit.utils.user.common.CommonUserUtil;
......@@ -61,7 +61,7 @@ implements PlatAlarmRecordService{
private PlatElderSocialRelationService platElderSocialRelationService;
@Autowired
private MsgUtil msgUtil;
private MsgSendUtil msgUtil;
@Override
public PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
......
......@@ -117,7 +117,7 @@ implements PlatMenuService {
*/
private void checkCode(PlatMenuDTOVO dto) {
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())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
}
......@@ -174,33 +174,33 @@ implements PlatMenuService {
public void sync() {
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())
);
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()));
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()));
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 ->
!exitButtonCodeMap.containsKey(item.getName())).collect(Collectors.toList());
!exitButtonCodeMap.containsKey(item.getCode())).collect(Collectors.toList());
//删除的权限
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())));
addActionList.forEach(e -> {
if (TreeConst.TOP_LEVEL.equals(e.getParentId())) {
exitCodeMap.put(e.getName(), e);
exitCodeMap.put(e.getCode(), e);
}
});
......@@ -210,7 +210,7 @@ implements PlatMenuService {
if (!TreeConst.TOP_LEVEL.equals(e.getParentId())) {
String groupCode = getGroupCode(e.getName());
String groupCode = getGroupCode(e.getCode());
PlatMenu buttonGroup = exitCodeMap.get(groupCode);
if (buttonGroup != null) {
e.setParentId(buttonGroup.getId());
......@@ -287,7 +287,7 @@ implements PlatMenuService {
PlatMenu button = new PlatMenu();
button.setName(action.name());
//button.setCode(e);
button.setCode(e);
button.setSort(0);
button.setStatus(CommonEnum.YES.getValue());
button.setResourceType(SysEnum.MenuTypeEnum.BUTTON.getValue());
......@@ -323,7 +323,7 @@ implements PlatMenuService {
private PlatMenu generateButtonGroup(String name, String code) {
PlatMenu button = new PlatMenu();
button.setName(name);
// button.setCode(code);
button.setCode(code);
button.setParentId(TreeConst.TOP_LEVEL);
button.setSort(0);
button.setStatus(CommonEnum.YES.getValue());
......
......@@ -134,13 +134,8 @@ sms:
url: http://www.aozoneyun.com/message/message/send
uid: 357
pwd: xmks123456
rec:
url:
query:
url: http://www.aozoneyun.com/message/message/balance
voiceSms:
voice-sms:
send:
url: http://www.aozoneyun.com/Message/Message/video_send
uid: 362
pwd: xmksyy123456
......
......@@ -131,13 +131,8 @@ sms:
url: http://www.aozoneyun.com/message/message/send
uid: 357
pwd: xmks123456
rec:
url:
query:
url: http://www.aozoneyun.com/message/message/balance
voiceSms:
voice-sms:
send:
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