短信配置

This commit is contained in:
guoshengxiong 2025-07-29 18:17:51 +08:00
parent b178980110
commit ccf93552c0
17 changed files with 925 additions and 5 deletions

View File

@ -58,6 +58,13 @@
</repositories>
<dependencies>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<!-- 如 CVM 产品包tencentcloud-sdk-java-cvm -->
<!-- 请到 maven 官网查询 sdk 的所有版本,例如 cvm 的产品包链接为 https://central.sonatype.com/artifact/com.tencentcloudapi/tencentcloud-sdk-java-cvm/versions -->
<version>3.1.1000</version>
</dependency>
<dependency>
<groupId>javax.json.bind</groupId>
<artifactId>javax.json.bind-api</artifactId>

View File

@ -1,7 +1,15 @@
package com.zhgd.xmgl.async;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhgd.mqtt.bean.PushPayload;
import com.zhgd.mqtt.server.IMqttSender;
import com.zhgd.xmgl.call.TencentCloudMessageCall;
import com.zhgd.xmgl.call.YunPianMessageCall;
import com.zhgd.xmgl.call.api.MessageManufacturer;
import com.zhgd.xmgl.call.factory.MessageManufacturerFactory;
import com.zhgd.xmgl.constant.Cts;
import com.zhgd.xmgl.modules.basicdata.constant.DictionaryConstant;
import com.zhgd.xmgl.modules.basicdata.entity.CompanyConfig;
@ -13,19 +21,27 @@ import com.zhgd.xmgl.modules.basicdata.service.ICompanyConfigService;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import com.zhgd.xmgl.modules.basicdata.service.impl.DictionaryItemServiceImpl;
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
import com.zhgd.xmgl.modules.project.service.IMessageConfigV2Service;
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
import com.zhgd.xmgl.push.service.UniPushService;
import com.zhgd.xmgl.util.MapBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
* @program: wisdomSite
@ -36,6 +52,9 @@ import java.util.Objects;
@Slf4j
@Component
public class AsyncAiAnalyse {
@Lazy
@Autowired
WorkerInfoServiceImpl workerInfoService;
@Autowired
private IMqttSender mqttPushClient;
@Autowired
@ -54,6 +73,12 @@ public class AsyncAiAnalyse {
@Value("${mqtt-scope}")
private String scope;
@Autowired
@Qualifier("doubleCarbonExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Lazy
@Autowired
private MessageManufacturerFactory messageManufacturerFactory;
/**
* @param record
@ -63,6 +88,7 @@ public class AsyncAiAnalyse {
try {
String title = getTitleByAlarmType(record.getAlarmType(), record.getProjectSn());
title = title == null ? "其他类型" : title;
String typeName = title;
String msg = title + ",位置" + record.getLocation();
List<SystemUser> systemUserList;
if (type.equals(Cts.PROJECT_LEVEL)) {
@ -78,11 +104,36 @@ public class AsyncAiAnalyse {
}
// sendAppNotice(record.getProjectSn(), title, msg, systemUserList, "/pages/potentialRisk/potentialRisk?id=" + record.getId());
}
sendMsg(systemUserList, typeName, record.getLocation(), record.getProjectSn());
} catch (Exception e) {
log.error("error", e);
}
}
/**
* 发送短信
*
* @param systemUserList
* @param typeName
* @param location
* @param projectSn
*/
private void sendMsg(List<SystemUser> systemUserList, String typeName, String location, String projectSn) {
CompletableFuture.runAsync(() -> {
MessageManufacturer messageManufacturer = messageManufacturerFactory.getMessageManufacturer(projectSn);
if (messageManufacturer != null) {
List<String> phoneNums = systemUserList.stream().map(SystemUser::getUserTel).collect(Collectors.toList());
List<String> templateParams = new ArrayList<>();
//报警类型报警名称设备名称报警值阈值超标时间超标量
templateParams.add(typeName);
templateParams.add(location);
String text = StrUtil.format("【{}】AI警报{},位置{}",
messageManufacturer.getConfig().getSignature(), typeName, location);
messageManufacturer.sendMsgByConfig(phoneNums, 2, templateParams, text);
}
}, threadPoolTaskExecutor);
}
public String getTitleByAlarmType(Integer alarmType, String projectSn) {
DictionaryItem dict = dictionaryItemService.getDict(DictionaryConstant.AI_ANALYSE_HARD_WARE_ALARM_RECORD_TYPE, alarmType + "", projectSn);
return dict != null ? dict.getName() : null;

View File

@ -0,0 +1,75 @@
package com.zhgd.xmgl.call;
import com.gexin.fastjson.JSON;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import com.zhgd.xmgl.call.api.MessageManufacturer;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.stream.Collectors;
/**
* 腾讯云短信
*/
@Slf4j
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class TencentCloudMessageCall implements MessageManufacturer {
private MessageConfigV2 config;
@Override
public MessageConfigV2 getConfig() {
return config;
}
@Override
public void setConfig(MessageConfigV2 config) {
this.config = config;
}
@Override
public void sendMsgByConfig(List<String> phoneNums, int pushFunctionType, List<String> templateParams, String text) {
try {
if (pushFunctionType == 1 && config.getEnableDustSend() == 1) {
//报警类型报警名称设备名称报警值阈值超标时间超标量
doSendMsg(phoneNums, config.getDustTemplateId(), templateParams.toArray(new String[]{}));
} else if (pushFunctionType == 2 && config.getEnableAiSend() == 1) {
doSendMsg(phoneNums, config.getAiTemplateId(), templateParams.toArray(new String[]{}));
} else if (pushFunctionType == 3 && config.getEnableLoginSend() == 1) {
doSendMsg(phoneNums, config.getLoginTemplateId(), templateParams.toArray(new String[]{}));
}
} catch (Exception e) {
log.error("按短信配置发送短信异常", e);
}
}
/**
* 发送短信
*
* @param phoneNums 手机号码
* @param templateId 短信模板id
* @param templateParamSet 短信模板参数
* @throws TencentCloudSDKException
*/
private void doSendMsg(List<String> phoneNums, String templateId, String[] templateParamSet) throws TencentCloudSDKException {
Credential credential = new Credential(config.getSecretId(), config.getSecretKey());
SmsClient smsClient = new SmsClient(credential, "ap-singapore");
SendSmsRequest req = new SendSmsRequest();
req.setPhoneNumberSet(phoneNums.stream().map(s -> "+86" + s).collect(Collectors.toList()).toArray(new String[]{}));
req.setSmsSdkAppId(config.getSmsSdkAppId());
req.setTemplateId(templateId);
req.setTemplateParamSet(templateParamSet);
SendSmsResponse response = smsClient.SendSms(req);
log.info("腾讯云发送短信结果:{}", JSON.toJSONString(response));
}
}

View File

@ -0,0 +1,53 @@
package com.zhgd.xmgl.call;
import cn.hutool.http.HttpRequest;
import com.gexin.fastjson.JSON;
import com.zhgd.xmgl.call.api.MessageManufacturer;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
/**
* 云片短信
*/
@Slf4j
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class YunPianMessageCall implements MessageManufacturer {
private MessageConfigV2 config;
@Override
public MessageConfigV2 getConfig() {
return config;
}
@Override
public void setConfig(MessageConfigV2 config) {
this.config = config;
}
@Override
public void sendMsgByConfig(List<String> phoneNums, int pushFunctionType, List<String> templateParams, String text) {
try {
for (String phoneNum : phoneNums) {
HashMap<String, Object> formMap = new HashMap<>();
formMap.put("apikey", config.getApiKey());
formMap.put("mobile", phoneNum);
formMap.put("text", text);
String url = "https://sms.yunpian.com/v2/sms/single_send.json";
log.info("云片短信按短信配置发送短信url{}body{}", url, JSON.toJSONString(formMap));
String body = HttpRequest.post(url).form(formMap).execute().body();
log.info("云片短信按短信配置发送短信,结果:{}", body);
}
} catch (Exception e) {
log.error("云片短信按短信配置发送短信异常", e);
}
}
}

View File

@ -0,0 +1,26 @@
package com.zhgd.xmgl.call.api;
import com.zhgd.xmgl.modules.car.entity.CarInfo;
import com.zhgd.xmgl.modules.car.entity.ProjectCarCameraConfig;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import java.util.Date;
import java.util.List;
/**
* 短信接口
*/
public interface MessageManufacturer {
MessageConfigV2 getConfig();
void setConfig(MessageConfigV2 config);
/**
* 按配置发送短信
* @param phoneNums
* @param pushFunctionType 1:扬尘;2:AI报警;3:登录;
* @param templateParams
* @param text 消息云片选择
*/
void sendMsgByConfig(List<String> phoneNums, int pushFunctionType, List<String> templateParams, String text);
}

View File

@ -0,0 +1,47 @@
package com.zhgd.xmgl.call.factory;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhgd.jeecg.common.util.SpringContextUtils;
import com.zhgd.xmgl.call.TencentCloudMessageCall;
import com.zhgd.xmgl.call.YunPianMessageCall;
import com.zhgd.xmgl.call.api.MessageManufacturer;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import com.zhgd.xmgl.modules.project.service.IMessageConfigV2Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.Objects;
@Slf4j
@Component
public class MessageManufacturerFactory {
@Lazy
@Autowired
private IMessageConfigV2Service messageConfigV2Service;
/**
* 获取CarManufacturer
*
* @param projectSn
* @return
*/
public MessageManufacturer getMessageManufacturer(String projectSn) {
MessageConfigV2 config = messageConfigV2Service.getOne(new LambdaQueryWrapper<MessageConfigV2>()
.eq(MessageConfigV2::getProjectSn, projectSn)
);
if (config == null) {
return null;
}
MessageManufacturer manufacturer = null;
if (Objects.equals(config.getMessageManufacturerType(), 1)) {
manufacturer = SpringContextUtils.getBean(TencentCloudMessageCall.class);
manufacturer.setConfig(config);
} else if (Objects.equals(config.getMessageManufacturerType(), 2)) {
manufacturer = SpringContextUtils.getBean(YunPianMessageCall.class);
manufacturer.setConfig(config);
}
return manufacturer;
}
}

View File

@ -112,4 +112,8 @@ public interface Cts {
String STR1112 = ".";
String S32434 = ".";
String LIMIT_1 = "limit 1";
/**
* 手机号登录的验证码前缀
*/
String LOGIN_VERIFICATION_CODE = "LOGIN_VERIFICATION_CODE_";
}

View File

@ -1,14 +1,23 @@
package com.zhgd.xmgl.modules.basicdata.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.redis.lock.RedisRepository;
import com.zhgd.xmgl.call.api.MessageManufacturer;
import com.zhgd.xmgl.call.factory.MessageManufacturerFactory;
import com.zhgd.xmgl.constant.Cts;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
import com.zhgd.xmgl.modules.basicdata.entity.dto.LoginInfoByTokenDto;
import com.zhgd.xmgl.modules.basicdata.service.ILoginService;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.util.MapBuilder;
import com.zhgd.xmgl.util.NumberUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -16,12 +25,13 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import java.util.*;
/**
* @program: devManage
@ -38,6 +48,12 @@ public class LoginController {
private ISystemUserService systemUserService;
@Autowired
private ILoginService iLoginService;
@Lazy
@Autowired
private MessageManufacturerFactory messageManufacturerFactory;
@Lazy
@Autowired
private RedisRepository redisRepository;
@OperLog(operModul = "用户登录", operType = "账号密码登录", operDesc = "账号密码登录")
@ApiOperation(value = "账号密码登录", notes = "账号密码登录", httpMethod = "POST")
@ -170,7 +186,6 @@ public class LoginController {
return Result.ok();
}
@ApiOperation(value = "获取注册短信验证码", notes = "获取注册短信验证码", httpMethod = "POST")
@ApiImplicitParam(name = "phone", required = true, value = "手机号", paramType = "body")
@PostMapping(value = "/getRegisterVerificationCode")
@ -179,7 +194,6 @@ public class LoginController {
return Result.success(resultMap);
}
@ApiOperation(value = "通过第三方标识获取用户登录信息", notes = "通过第三方标识获取用户登录信息", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "uid", required = true, value = "第三方标识", paramType = "body"),
@ -212,4 +226,76 @@ public class LoginController {
}
return Result.success(true);
}
@ApiOperation(value = "获取登录短信验证码", notes = "获取登录短信验证码", httpMethod = "POST")
@ApiImplicitParam(name = "phone", required = true, value = "手机号", paramType = "body")
@PostMapping(value = "/getLoginVerificationCode")
public Result getLoginVerificationCode(@RequestBody Map<String, Object> map) {
try {
SystemUser user = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>()
.eq(SystemUser::getUserTel, MapUtils.getString(map, "phone")));
if (user == null) {
throw new OpenAlertException("手机号不存在");
}
MessageManufacturer messageManufacturer = messageManufacturerFactory.getMessageManufacturer(user.getSn());
if (messageManufacturer != null && messageManufacturer.getConfig().getEnableLoginSend() == 1) {
List<String> templateParams = new ArrayList<>();
String key = Cts.LOGIN_VERIFICATION_CODE + user.getUserTel();
Map<String, Object> hashValue = redisRepository.getHashValue(key);
if (hashValue == null) {
hashValue = new HashMap<>();
} else {
if (DateUtil.compare(DateUtil.parseDateTime(hashValue.get("t").toString()), DateUtil.offsetMinute(new Date(), -1)) > 0) {
throw new OpenAlertException("获取登录短信验证码太频繁,请稍后重试");
}
}
//报警类型报警名称设备名称报警值阈值超标时间超标量
String randomNum = NumberUtils.randomNum(6);
hashValue.put("num", randomNum);
hashValue.put("t", DateUtil.now());
redisRepository.set(key, hashValue, 60L);
templateParams.add(randomNum);
String text = StrUtil.format("【{}】您的登录验证码是:{}有效期5分钟。请勿泄露给他人。",
messageManufacturer.getConfig().getSignature(), randomNum);
List<String> phoneNums = new ArrayList<>();
phoneNums.add(user.getUserTel());
messageManufacturer.sendMsgByConfig(phoneNums, 3, templateParams, text);
return Result.ok();
} else {
throw new OpenAlertException("短信没配置或没启动短信登录");
}
} catch (OpenAlertException e) {
throw e;
} catch (Exception e) {
throw new OpenAlertException("获取登录短信验证码异常");
}
}
@ApiOperation(value = "短信验证码手机号登录", notes = "短信验证码手机号登录", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "phone", required = true, value = "手机号", paramType = "body"),
@ApiImplicitParam(name = "verificationCode", required = true, value = "短信验证码", paramType = "body"),
})
@PostMapping(value = "/loginPhoneByVerificationCode")
public Result<Map<String, Object>> loginPhoneByVerificationCode(@RequestBody Map<String, Object> map) {
SystemUser user = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>()
.eq(SystemUser::getUserTel, MapUtils.getString(map, "phone")));
if (user == null) {
throw new OpenAlertException("手机号不存在");
}
String key = Cts.LOGIN_VERIFICATION_CODE + user.getUserTel();
Map<String, Object> hashValue = redisRepository.getHashValue(key);
if (hashValue == null) {
throw new OpenAlertException("短信验证码已过期");
} else {
if (!hashValue.get("num").toString().equals(MapUtils.getString(map,"verificationCode"))) {
throw new OpenAlertException("短信验证码不正确");
}
}
Map<String, Object> resultMap = systemUserService.login(new MapBuilder<String, Object>()
.put("account", user.getAccount())
.put("password", user.getShowPassword())
.build());
return Result.success(resultMap);
}
}

View File

@ -1,5 +1,8 @@
package com.zhgd.xmgl.modules.environment.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.xuyanwu.spring.file.storage.FileInfo;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -7,13 +10,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.redis.lock.RedisRepository;
import com.zhgd.xmgl.async.AsyncEnvironment;
import com.zhgd.xmgl.call.api.MessageManufacturer;
import com.zhgd.xmgl.call.factory.MessageManufacturerFactory;
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import com.zhgd.xmgl.modules.basicdata.service.UploadFileService;
import com.zhgd.xmgl.modules.bigdevice.mapper.BigDeviceVideoMapper;
import com.zhgd.xmgl.modules.environment.entity.*;
@ -23,12 +28,17 @@ import com.zhgd.xmgl.modules.environment.mapper.EnvironmentAlarmMapper;
import com.zhgd.xmgl.modules.environment.mapper.EnvironmentWarningMapper;
import com.zhgd.xmgl.modules.environment.service.IEnvironmentAlarmService;
import com.zhgd.xmgl.modules.project.entity.qo.QueryProjectTodayAlarmInfoQO;
import com.zhgd.xmgl.modules.project.service.IMessageConfigV2Service;
import com.zhgd.xmgl.modules.sprayrt.service.ISprayRtDevService;
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
import com.zhgd.xmgl.util.DateUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -36,6 +46,7 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
@ -47,6 +58,12 @@ import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMapper, EnvironmentAlarm> implements IEnvironmentAlarmService {
@Lazy
@Autowired
WorkerInfoServiceImpl workerInfoService;
@Lazy
@Autowired
ISystemUserService systemUserService;
@Autowired
private SystemUserMapper systemUserMapper;
@Autowired
@ -69,6 +86,15 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
private String serverUrl;
@Autowired
private ISprayRtDevService sprayRtDevService;
@Lazy
@Autowired
private IMessageConfigV2Service messageConfigV2Service;
@Lazy
@Autowired
private MessageManufacturerFactory messageManufacturerFactory;
@Autowired
@Qualifier("doubleCarbonExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
public IPage<EntityMap> queryEnvironmentAlarmPageList(Map<String, Object> map) {
@ -127,6 +153,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "噪音", pushPerson);
}
}
@ -161,6 +188,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "噪音", pushPerson);
}
}
@ -200,6 +228,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "PM2.5", pushPerson);
}
}
isThreeAlarm = true;
@ -235,6 +264,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "PM2.5", pushPerson);
}
}
@ -272,6 +302,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "PM10", pushPerson);
}
}
isThreeAlarm = true;
@ -307,6 +338,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "PM10", pushPerson);
}
}
}
@ -344,6 +376,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "Tsp", pushPerson);
}
}
@ -380,6 +413,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "Tsp", pushPerson);
}
}
}
@ -415,6 +449,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "风速", pushPerson);
}
}
} else {
@ -447,6 +482,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "风速", pushPerson);
}
}
@ -484,6 +520,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "温度", pushPerson);
}
}
} else {
@ -517,6 +554,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "温度", pushPerson);
}
}
@ -553,6 +591,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "温度", pushPerson);
}
}
@ -587,6 +626,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "温度", pushPerson);
}
}
@ -625,6 +665,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "湿度", pushPerson);
}
}
@ -659,6 +700,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
notice.setSendTime(format1.format(new Date()));
notice.setType("7");
noticeService.addNotice(notice, true);
sendMsg(devname, environmentAlarm, "湿度", pushPerson);
}
}
@ -689,6 +731,39 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
}
}
/**
* 发送短信
*
* @param devname
* @param environmentAlarm
* @param alarmName
* @param pushPerson
*/
private void sendMsg(String devname, EnvironmentAlarm environmentAlarm, String alarmName, String pushPerson) {
CompletableFuture.runAsync(() -> {
MessageManufacturer messageManufacturer = messageManufacturerFactory.getMessageManufacturer(environmentAlarm.getProjectSn());
if (messageManufacturer != null) {
String alarmType = environmentAlarm.getType() == 1 ? "预警" : "报警";
String threshold = NumberUtil.sub(environmentAlarm.getAlarmValue(), environmentAlarm.getExceed()) + "";
String time = DateUtil.formatDateTime(environmentAlarm.getAlarmTime());
List<String> phoneNums = systemUserService.list(new LambdaQueryWrapper<SystemUser>()
.in(SystemUser::getId, StrUtil.split(pushPerson, ","))).stream().map(SystemUser::getUserTel).collect(Collectors.toList());
List<String> templateParams = new ArrayList<>();
//报警类型报警名称设备名称报警值阈值超标时间超标量
templateParams.add(alarmType);
templateParams.add(alarmName);
templateParams.add(devname);
templateParams.add(environmentAlarm.getAlarmValue() + "");
templateParams.add(threshold);
templateParams.add(time);
templateParams.add(environmentAlarm.getExceed() + "");
String text = StrUtil.format("【{}】扬尘超标警报!报警类型:{},报警名称:{},设备名称:{},报警值:{},阈值:{},超标时间:{},超标量:{}",
messageManufacturer.getConfig().getSignature(), alarmType, alarmName, devname, environmentAlarm.getAlarmValue() + "", threshold, time, environmentAlarm.getExceed() + "");
messageManufacturer.sendMsgByConfig(phoneNums, 1, templateParams, text);
}
}, threadPoolTaskExecutor);
}
@Override
public List<NewEnvironmentAlarmVo> selectNewEnvironmentAlarmList(Map<String, Object> map) {
return environmentAlarmMapper.selectNewEnvironmentAlarmList(map);

View File

@ -0,0 +1,141 @@
package com.zhgd.xmgl.modules.project.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import com.zhgd.xmgl.modules.project.entity.dto.MessageConfigV2Dto;
import com.zhgd.xmgl.modules.project.entity.vo.MessageConfigV2Vo;
import com.zhgd.xmgl.modules.project.service.IMessageConfigV2Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.simpleframework.xml.core.Validate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.HashMap;
import java.util.List;
/**
* @Title: Controller
* @Description: 短信配置v2
* @author pds
* @date 2025-07-29
* @version V1.0
*/
@RestController
@RequestMapping("/xmgl/messageConfigV2")
@Slf4j
@Api(tags = "短信配置v2相关Api")
public class MessageConfigV2Controller {
@Lazy
@Autowired
private IMessageConfigV2Service messageConfigV2Service;
/**
* 分页列表查询
*
* @return
*/
@OperLog(operModul = "短信配置v2管理", operType = "分页查询", operDesc = "分页列表查询短信配置v2信息")
@ApiOperation(value = "分页列表查询短信配置v2信息", notes = "分页列表查询短信配置v2信息", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
})
@GetMapping(value = "/page")
public Result<IPage<MessageConfigV2Vo>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
return Result.success(messageConfigV2Service.queryPageList(param));
}
/**
* 列表查询
*
* @return
*/
@OperLog(operModul = "短信配置v2管理", operType = "列表查询", operDesc = "列表查询短信配置v2信息")
@ApiOperation(value = "列表查询短信配置v2信息", notes = "列表查询短信配置v2信息", httpMethod = "GET")
@GetMapping(value = "/list")
public Result<List<MessageConfigV2Vo>> queryList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
return Result.success(messageConfigV2Service.queryList(param));
}
/**
* 添加
*
* @param messageConfigV2Dto
* @return
*/
@OperLog(operModul = "短信配置v2管理", operType = "添加", operDesc = "添加短信配置v2信息")
@ApiOperation(value = "添加短信配置v2信息", notes = "添加短信配置v2信息", httpMethod = "POST")
@PostMapping(value = "/add")
public Result<MessageConfigV2Vo> add(@RequestBody @Validate MessageConfigV2Dto messageConfigV2Dto) {
messageConfigV2Service.add(messageConfigV2Dto);
return Result.ok();
}
/**
* 编辑
*
* @param messageConfigV2Dto
* @return
*/
@OperLog(operModul = "短信配置v2管理", operType = "编辑", operDesc = "编辑短信配置v2信息")
@ApiOperation(value = "编辑短信配置v2信息", notes = "编辑短信配置v2信息", httpMethod = "POST")
@PostMapping(value = "/edit")
public Result<MessageConfigV2> edit(@RequestBody MessageConfigV2Dto messageConfigV2Dto) {
messageConfigV2Service.edit(messageConfigV2Dto);
return Result.ok();
}
/**
* 通过id删除
*
* @return
*/
@OperLog(operModul = "短信配置v2管理", operType = "删除", operDesc = "删除短信配置v2信息")
@ApiOperation(value = "删除短信配置v2信息", notes = "删除短信配置v2信息", httpMethod = "POST")
@ApiImplicitParam(name = "id", value = "短信配置v2ID", paramType = "body", required = true, dataType = "String", example = "{\"id\":\"1\"}")
@PostMapping(value = "/delete")
public Result<MessageConfigV2> delete(@ApiIgnore @RequestBody HashMap<String, Object> map) {
messageConfigV2Service.delete(MapUtils.getString(map, "id"));
return Result.ok();
}
/**
* 通过id查询
*
* @param id
* @return
*/
@OperLog(operModul = "短信配置v2管理", operType = "通过id查询", operDesc = "通过id查询短信配置v2信息")
@ApiOperation(value = "通过id查询短信配置v2信息", notes = "通过id查询短信配置v2信息", httpMethod = "GET")
@ApiImplicitParam(name = "id", value = "短信配置v2ID", paramType = "query", required = true, dataType = "Integer")
@GetMapping(value = "/queryById")
public Result<MessageConfigV2Vo> queryById(@RequestParam(name = "id", required = true) String id) {
return Result.success(messageConfigV2Service.queryById(id));
}
@OperLog(operModul = "短信配置v2管理", operType = "", operDesc = "保存短信配置v2信息")
@ApiOperation(value = "保存短信配置v2信息", notes = "保存短信配置v2信息", httpMethod = "POST")
@PostMapping(value = "/saveConfig")
public Result<MessageConfigV2> saveConfig(@RequestBody MessageConfigV2Dto messageConfigV2Dto) {
MessageConfigV2 configV2 = messageConfigV2Service.getOne(new LambdaQueryWrapper<MessageConfigV2>()
.eq(MessageConfigV2::getProjectSn, messageConfigV2Dto.getProjectSn()));
if (configV2 == null) {
messageConfigV2Service.add(messageConfigV2Dto);
} else {
messageConfigV2Dto.setId(configV2.getId());
messageConfigV2Service.edit(messageConfigV2Dto);
}
return Result.success(messageConfigV2Dto);
}
}

View File

@ -0,0 +1,117 @@
package com.zhgd.xmgl.modules.project.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/**
* @Description: 短信配置v2
* @author pds
* @date 2025-07-29
* @version V1.0
*/
@Data
@TableName("message_config_v2")
@ApiModel(value = "MessageConfigV2实体类", description = "MessageConfigV2")
public class MessageConfigV2 implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键id")
private java.lang.Long id;
/**
* 所属项目SN
*/
@ApiModelProperty(value = "所属项目SN")
private java.lang.String projectSn;
/**
* 短信厂商:1:腾讯云;2:云片;
*/
@ApiModelProperty(value = "短信厂商:1:腾讯云;2:云片;")
private java.lang.Integer messageManufacturerType;
/**
* 签名
*/
@ApiModelProperty(value = "签名")
private java.lang.String signature;
/**
* 腾讯云的secret_id
*/
@ApiModelProperty(value = "腾讯云的secret_id")
private java.lang.String secretId;
/**
* 腾讯云的secret_key
*/
@ApiModelProperty(value = "腾讯云的secret_key")
private java.lang.String secretKey;
/**
* 腾讯云在短信控制台中添加应用后生成的短信 SdkAppId例如 2400006666
*/
@ApiModelProperty(value = "腾讯云在短信控制台中添加应用后生成的短信 SdkAppId例如 2400006666")
private java.lang.String smsSdkAppId;
/**
* 云片apikey
*/
@ApiModelProperty(value = "云片apikey")
private java.lang.String apiKey;
/**
* 验证码短信模板
*/
@ApiModelProperty(value = "验证码短信模板")
private java.lang.String validCodeMessage;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
/**
* 更新时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private java.util.Date updateTime;
/**
* 1扬尘推送配置发送短信0不发送
*/
@ApiModelProperty(value = "1扬尘推送配置发送短信0不发送")
private java.lang.Integer enableDustSend;
/**
* 1AI报警人员推送配置发送短信0不发送
*/
@ApiModelProperty(value = "1AI报警人员推送配置发送短信0不发送")
private java.lang.Integer enableAiSend;
/**
* 1短信登录推送配置发送短信0不发送
*/
@ApiModelProperty(value = "1短信登录推送配置发送短信0不发送")
private java.lang.Integer enableLoginSend;
/**
* 腾讯云扬尘短信模板id
*/
@ApiModelProperty(value = "腾讯云扬尘短信模板id")
private java.lang.String dustTemplateId;
/**
* 腾讯云AI报警短信模板id
*/
@ApiModelProperty(value = "腾讯云AI报警短信模板id")
private java.lang.String aiTemplateId;
/**
* 腾讯云登录短信模板id
*/
@ApiModelProperty(value = "腾讯云登录短信模板id")
private java.lang.String loginTemplateId;
}

View File

@ -0,0 +1,11 @@
package com.zhgd.xmgl.modules.project.entity.dto;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(value="MessageConfigV2Dto实体类",description="MessageConfigV2Dto实体类")
public class MessageConfigV2Dto extends MessageConfigV2 {
}

View File

@ -0,0 +1,11 @@
package com.zhgd.xmgl.modules.project.entity.vo;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(value="MessageConfigV2Vo实体类",description="MessageConfigV2Vo实体类")
public class MessageConfigV2Vo extends MessageConfigV2 {
}

View File

@ -0,0 +1,52 @@
package com.zhgd.xmgl.modules.project.mapper;
import java.util.List;
import java.util.HashMap;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import com.zhgd.xmgl.modules.project.entity.vo.MessageConfigV2Vo;
import com.zhgd.xmgl.modules.project.entity.dto.MessageConfigV2Dto;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 短信配置v2
* @author pds
* @date 2025-07-29
* @version V1.0
*/
@Mapper
public interface MessageConfigV2Mapper extends BaseMapper<MessageConfigV2> {
/**
* 分页列表查询短信配置v2信息
*
* @param page
* @param queryWrapper
* @param param
* @return
*/
IPage<MessageConfigV2Vo> queryList(Page<MessageConfigV2Vo> page, @Param(Constants.WRAPPER) QueryWrapper<MessageConfigV2Vo> queryWrapper, @Param("param") HashMap<String, Object> param);
/**
* 列表查询短信配置v2信息
*
* @param queryWrapper
* @param param
* @return
*/
List<MessageConfigV2Vo> queryList(@Param(Constants.WRAPPER) QueryWrapper<MessageConfigV2Vo> queryWrapper, @Param("param") HashMap<String, Object> param);
/**
* 通过id查询短信配置v2信息
*
* @param id
* @return
*/
MessageConfigV2Vo queryById(String id);
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhgd.xmgl.modules.project.mapper.MessageConfigV2Mapper">
<select id="queryList" resultType="com.zhgd.xmgl.modules.project.entity.vo.MessageConfigV2Vo">
select * from (
select t.*
from message_config_v2 t
)t
${ew.customSqlSegment}
</select>
<select id="queryById" resultType="com.zhgd.xmgl.modules.project.entity.vo.MessageConfigV2Vo">
select * from (
select t.*
from message_config_v2 t
)t
where t.id = #{id}
</select>
</mapper>

View File

@ -0,0 +1,56 @@
package com.zhgd.xmgl.modules.project.service;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import com.zhgd.xmgl.modules.project.entity.vo.MessageConfigV2Vo;
import com.zhgd.xmgl.modules.project.entity.dto.MessageConfigV2Dto;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.HashMap;
import java.util.List;
/**
* @Description: 短信配置v2
* @author pds
* @date 2025-07-29
* @version V1.0
*/
public interface IMessageConfigV2Service extends IService<MessageConfigV2> {
/**
* 分页列表查询短信配置v2信息
* @param param 参数map
* @return
*/
IPage<MessageConfigV2Vo> queryPageList(HashMap<String, Object> param);
/**
* 列表查询短信配置v2信息
* @param param 参数map
* @return
*/
List<MessageConfigV2Vo> queryList(HashMap<String, Object> param);
/**
* 添加短信配置v2信息
* @param messageConfigV2Dto 短信配置v2
* @return
*/
void add(MessageConfigV2Dto messageConfigV2Dto);
/**
* 编辑短信配置v2信息
* @param messageConfigV2Dto 短信配置v2
* @return
*/
void edit(MessageConfigV2Dto messageConfigV2Dto);
/**
* 根据id删除短信配置v2信息
* @param id 短信配置v2的id
* @return
*/
void delete(String id);
/**
* 根据id查询短信配置v2信息
* @param id 短信配置v2的id
* @return
*/
MessageConfigV2Vo queryById(String id);
}

View File

@ -0,0 +1,90 @@
package com.zhgd.xmgl.modules.project.service.impl;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.xmgl.modules.project.entity.MessageConfigV2;
import com.zhgd.xmgl.modules.project.entity.vo.MessageConfigV2Vo;
import com.zhgd.xmgl.modules.project.entity.dto.MessageConfigV2Dto;
import com.zhgd.xmgl.modules.project.mapper.MessageConfigV2Mapper;
import com.zhgd.xmgl.modules.project.service.IMessageConfigV2Service;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.xmgl.util.PageUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.HashMap;
import java.util.List;
import com.zhgd.xmgl.util.RefUtil;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Description: 短信配置v2
* @author pds
* @date 2025-07-29
* @version V1.0
*/
@Service
public class MessageConfigV2ServiceImpl extends ServiceImpl<MessageConfigV2Mapper, MessageConfigV2> implements IMessageConfigV2Service {
@Autowired
private MessageConfigV2Mapper messageConfigV2Mapper;
@Override
public IPage<MessageConfigV2Vo> queryPageList(HashMap<String, Object> param) {
QueryWrapper<MessageConfigV2Vo> queryWrapper = this.getQueryWrapper(param);
Page<MessageConfigV2Vo> page = PageUtil.getPage(param);
IPage<MessageConfigV2Vo> pageList = baseMapper.queryList(page, queryWrapper,param);
pageList.setRecords(this.dealList(pageList.getRecords()));
return pageList;
}
@Override
public List<MessageConfigV2Vo> queryList(HashMap<String, Object> param) {
QueryWrapper<MessageConfigV2Vo> queryWrapper = getQueryWrapper(param);
return dealList(baseMapper.queryList(queryWrapper,param));
}
private QueryWrapper<MessageConfigV2Vo> getQueryWrapper(HashMap<String, Object> param) {
QueryWrapper<MessageConfigV2Vo> queryWrapper = QueryGenerator.initPageQueryWrapper(MessageConfigV2Vo.class, param, true);
queryWrapper.orderByDesc(RefUtil.fieldNameUlc(MessageConfigV2Vo::getId));
return queryWrapper;
}
private List<MessageConfigV2Vo> dealList(List<MessageConfigV2Vo> list) {
return list;
}
@Override
public void add(MessageConfigV2Dto messageConfigV2Dto) {
messageConfigV2Dto.setId(null);
baseMapper.insert(messageConfigV2Dto);
}
@Override
public void edit(MessageConfigV2Dto messageConfigV2Dto) {
MessageConfigV2 oldMessageConfigV2 = baseMapper.selectById(messageConfigV2Dto.getId());
if(oldMessageConfigV2==null) {
throw new OpenAlertException("未找到对应实体");
}
baseMapper.updateById(messageConfigV2Dto);
}
@Override
public void delete(String id) {
MessageConfigV2 messageConfigV2 = baseMapper.selectById(id);
if(messageConfigV2==null) {
throw new OpenAlertException("未找到对应实体");
}
baseMapper.deleteById(id);
}
@Override
public MessageConfigV2Vo queryById(String id) {
MessageConfigV2Vo entity = baseMapper.queryById(id);
if (entity == null) {
throw new OpenAlertException("未找到对应实体");
}
return entity;
}
}