Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "automatic"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

import com.cl.service.YishengyuyueService;
import com.cl.service.TokenService;
import com.cl.service.SmsService;
import com.cl.service.YishengService;
import com.cl.service.YonghuService;
import com.cl.utils.PageUtils;
import com.cl.utils.R;
import com.cl.utils.MPUtil;
Expand All @@ -47,6 +50,15 @@
public class YishengyuyueController {
@Autowired
private YishengyuyueService yishengyuyueService;

@Autowired
private SmsService smsService;

@Autowired
private YishengService yishengService;

@Autowired
private YonghuService yonghuService;



Expand Down Expand Up @@ -149,6 +161,8 @@ public R detail(@PathVariable("id") Long id){
public R save(@RequestBody YishengyuyueEntity yishengyuyue, HttpServletRequest request){
//ValidatorUtils.validateEntity(yishengyuyue);
yishengyuyueService.insert(yishengyuyue);
// 发送短信通知医生
sendSmsToDoctor(yishengyuyue);
return R.ok();
}

Expand All @@ -160,8 +174,29 @@ public R save(@RequestBody YishengyuyueEntity yishengyuyue, HttpServletRequest r
public R add(@RequestBody YishengyuyueEntity yishengyuyue, HttpServletRequest request){
//ValidatorUtils.validateEntity(yishengyuyue);
yishengyuyueService.insert(yishengyuyue);
// 发送短信通知医生
sendSmsToDoctor(yishengyuyue);
return R.ok();
}

/**
* 发送短信通知医生
*/
private void sendSmsToDoctor(YishengyuyueEntity yishengyuyue) {
try {
// 根据医生账号获取医生信息
com.cl.entity.YishengEntity doctor = yishengService.selectOne(new com.baomidou.mybatisplus.mapper.EntityWrapper<com.cl.entity.YishengEntity>()
.eq("yishengzhanghao", yishengyuyue.getYishengzhanghao()));

if (doctor != null && doctor.getDianhua() != null) {
String phone = doctor.getDianhua();
String content = "尊敬的" + doctor.getYishengxingming() + "医生,您有一个新的预约,请及时查看。";
smsService.sendSms(phone, content);
}
} catch (Exception e) {
e.printStackTrace();
}
}



Expand All @@ -187,13 +222,38 @@ public R update(@RequestBody Long[] ids, @RequestParam String sfsh, @RequestPara
List<YishengyuyueEntity> list = new ArrayList<YishengyuyueEntity>();
for(Long id : ids) {
YishengyuyueEntity yishengyuyue = yishengyuyueService.selectById(id);
String oldSfsh = yishengyuyue.getSfsh();
yishengyuyue.setSfsh(sfsh);
yishengyuyue.setShhf(shhf);
list.add(yishengyuyue);

// 如果审核通过,发送短信通知用户
if ("审核通过".equals(sfsh) && !"审核通过".equals(oldSfsh)) {
sendSmsToUser(yishengyuyue);
}
}
yishengyuyueService.updateBatchById(list);
return R.ok();
}

/**
* 发送短信通知用户
*/
private void sendSmsToUser(YishengyuyueEntity yishengyuyue) {
try {
// 根据用户账号获取用户信息
com.cl.entity.YonghuEntity user = yonghuService.selectOne(new com.baomidou.mybatisplus.mapper.EntityWrapper<com.cl.entity.YonghuEntity>()
.eq("zhanghao", yishengyuyue.getZhanghao()));

if (user != null && user.getShouji() != null) {
String phone = user.getShouji();
String content = "尊敬的" + user.getXingming() + ",您的预约已审核通过,请按时就诊。";
smsService.sendSms(phone, content);
}
} catch (Exception e) {
e.printStackTrace();
}
}



Expand Down
22 changes: 22 additions & 0 deletions server_code/src/main/java/com/cl/service/SmsService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.cl.service;

/**
* 短信服务接口
*/
public interface SmsService {

/**
* 发送短信
* @param phone 手机号
* @param content 短信内容
* @return 是否发送成功
*/
boolean sendSms(String phone, String content);

/**
* 验证手机号格式是否正确
* @param phone 手机号
* @return 是否正确
*/
boolean validatePhone(String phone);
}
98 changes: 98 additions & 0 deletions server_code/src/main/java/com/cl/service/impl/SmsServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.cl.service.impl;

import com.cl.entity.SyslogEntity;
import com.cl.service.SmsService;
import com.cl.service.SyslogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.regex.Pattern;

/**
* 短信服务实现类
*/
@Service("smsService")
public class SmsServiceImpl implements SmsService {

@Autowired
private SyslogService syslogService;

// 手机号正则表达式
private static final String PHONE_REGEX = "^1[3-9]\\d{9}$";

// 最大重试次数
private static final int MAX_RETRY = 2;

@Override
public boolean sendSms(String phone, String content) {
// 验证手机号
if (!validatePhone(phone)) {
logSmsSend(phone, content, "失败", "手机号格式不正确");
return false;
}

int retryCount = 0;
boolean success = false;

// 重试机制
while (retryCount <= MAX_RETRY && !success) {
try {
// 模拟短信发送
success = simulateSmsSend(phone, content);
if (success) {
logSmsSend(phone, content, "成功", "");
} else {
logSmsSend(phone, content, "失败", "发送失败,正在重试...");
retryCount++;
// 重试间隔
Thread.sleep(1000);
}
} catch (Exception e) {
logSmsSend(phone, content, "失败", e.getMessage());
retryCount++;
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
}
}

if (!success) {
logSmsSend(phone, content, "失败", "达到最大重试次数");
}

return success;
}

@Override
public boolean validatePhone(String phone) {
return Pattern.matches(PHONE_REGEX, phone);
}

/**
* 模拟短信发送
*/
private boolean simulateSmsSend(String phone, String content) {
// 模拟短信发送,这里只是打印日志
System.out.println("模拟发送短信到 " + phone + ",内容:" + content);
// 模拟90%的成功率
return Math.random() < 0.9;
}

/**
* 记录短信发送日志
*/
private void logSmsSend(String phone, String content, String status, String remark) {
SyslogEntity log = new SyslogEntity();
log.setUsername("system");
log.setOperation("短信发送");
log.setMethod("SmsServiceImpl.sendSms");
log.setParams("phone=" + phone + ", content=" + content + ", status=" + status + ", remark=" + remark);
log.setTime(1L);
log.setIp("127.0.0.1");
log.setAddtime(new Date());
syslogService.insert(log);
}
}
2 changes: 1 addition & 1 deletion server_code/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false
username: root
password: 202911
password: 123456

# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=cl515882190
Expand Down
2 changes: 1 addition & 1 deletion server_code/target/classes/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false
username: root
password: 202911
password: 123456

# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=cl515882190
Expand Down
Binary file modified server_code/target/classes/com/cl/AutoRunWeb.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/annotation/IgnoreAuth.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/annotation/SysLog.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/aspect/SysLogAspect.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/config/AlipayConfig.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/config/InterceptorConfig.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/config/MybatisPlusConfig.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/controller/CommonController.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/controller/FileController.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/ChatFriendDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/ChatMessageDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/ChufangxinxiDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/ChukujiluDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/CommonDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/ConfigDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/FriendshipLinkDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/JiuzhenqiandaoDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/JiuzhentongzhiDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/MenuDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/MessagesDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/NewsDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/PaibanxinxiDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/RukujiluDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/SyslogDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/TokenDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/UsersDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/YaopinxinxiDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/YishengDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/YishengyuyueDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/YonghuDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/dao/ZhenduanbingliDao.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/ChatFriendEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/ChatMessageEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/ChufangxinxiEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/ChukujiluEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/ConfigEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/EIException.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/MenuEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/MessagesEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/NewsEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/PaibanxinxiEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/RukujiluEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/SyslogEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/TokenEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/UsersEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/YaopinxinxiEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/YishengEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/YishengyuyueEntity.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/YonghuEntity.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/ConfigView.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/MenuView.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/MessagesView.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/NewsView.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/RukujiluView.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/SyslogView.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/UsersView.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/YishengView.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/entity/view/YonghuView.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/ChukujiluService.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/CommonService.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/ConfigService.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/MenuService.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/MessagesService.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/NewsService.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/RukujiluService.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/SyslogService.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/TokenService.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/UsersService.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/YishengService.class
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/service/YonghuService.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/BaiduUtil.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/CommonUtil.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/EncryptUtil.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/FileUtil.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/HttpClientUtils.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/HttpContextUtils.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/IPUtils.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/JQPageInfo.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/MD5Util.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/MPUtil.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/MapUtils.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/PageUtils.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/Query.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/R.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/SQLFilter.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/SpringContextUtils.class
Binary file not shown.
Binary file modified server_code/target/classes/com/cl/utils/ValidatorUtils.class
Binary file not shown.