代码接口调试提交
This commit is contained in:
parent
dbb14db432
commit
2c78ee9ff7
|
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>bonus-business</artifactId>
|
||||
<artifactId>yn-message-gadget</artifactId>
|
||||
<description>
|
||||
web服务入口
|
||||
</description>
|
||||
|
|
|
|||
|
|
@ -159,12 +159,16 @@ public class PmTaskController extends BaseController
|
|||
/**
|
||||
* 短信平台回执
|
||||
*/
|
||||
@Log(title = "短信平台回执", businessType = BusinessType.DELETE)
|
||||
// @Log(title = "短信平台回执", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("msgSendStatus")
|
||||
public AjaxResult msgSendStatus(String msg)
|
||||
public AjaxResult msgSendStatus(String param)
|
||||
{
|
||||
try {
|
||||
return service.msgSendStatus(msg);
|
||||
log.error("短信平台回执:{}", param);
|
||||
if(StringUtils.isEmpty(param)){
|
||||
return AjaxResult.error("数据格式异常");
|
||||
}
|
||||
return service.msgSendStatus(param);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return AjaxResult.error("数据格式异常");
|
||||
|
|
@ -191,7 +195,7 @@ public class PmTaskController extends BaseController
|
|||
|
||||
|
||||
/**
|
||||
* 查询短信循环次数
|
||||
* 查询单次短信循环详细数据
|
||||
*/
|
||||
@Log(title = "查询单次短信循环详细数据", businessType = BusinessType.OTHER)
|
||||
@GetMapping("getOneLoopMsgData")
|
||||
|
|
@ -240,7 +244,7 @@ public class PmTaskController extends BaseController
|
|||
* 立即执行一次任务,不管其他状态
|
||||
*/
|
||||
@Log(title = "立即执行一次任务", businessType = BusinessType.OTHER)
|
||||
@GetMapping("executeOnceJob")
|
||||
@PostMapping("executeOnceJob")
|
||||
public AjaxResult executeOnceJob(@RequestBody PmTask o)
|
||||
{
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -35,4 +35,7 @@ public interface WorkerJobMapper {
|
|||
* @return
|
||||
*/
|
||||
List<WorkerVo> getHappyBirthDayWorkerByJobId(String jobId);
|
||||
|
||||
SysJob getJobByJobId(String jobId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.job.service;
|
|||
import com.bonus.common.constant.Constants;
|
||||
import com.bonus.common.core.domain.AjaxResult;
|
||||
import com.bonus.common.exception.job.TaskException;
|
||||
import com.bonus.common.utils.DateUtils;
|
||||
import com.bonus.common.utils.SecurityUtils;
|
||||
import com.bonus.common.utils.StringUtils;
|
||||
import com.bonus.job.domain.SysJob;
|
||||
|
|
@ -10,6 +11,7 @@ import com.bonus.job.util.CronUtils;
|
|||
import com.bonus.job.util.MessageSendUtil;
|
||||
import com.bonus.job.util.ScheduleUtils;
|
||||
import com.bonus.message.dao.WorkerVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -22,6 +24,7 @@ import java.time.LocalDate;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PmTaskServiceImpl implements PmTaskService{
|
||||
|
||||
|
|
@ -104,7 +107,7 @@ public class PmTaskServiceImpl implements PmTaskService{
|
|||
byId.setWorkerList(list);
|
||||
//分组
|
||||
List<WorkerVo> groupList = mapper.getGroupByTaskId(task.getId());
|
||||
byId.setGroupList(list);
|
||||
byId.setGroupList(groupList);
|
||||
//按性别群发
|
||||
Integer sex = mapper.getWorkerSexByTaskId(task.getId());
|
||||
byId.setSex(sex);
|
||||
|
|
@ -128,12 +131,20 @@ public class PmTaskServiceImpl implements PmTaskService{
|
|||
job.setRelationType("短信");
|
||||
job.setUpdateBy(SecurityUtils.getUsername());
|
||||
//验证job数据
|
||||
AjaxResult ajaxResult = verifyJob(job);
|
||||
AjaxResult ajaxResult;
|
||||
try{
|
||||
ajaxResult = verifyJob(job);
|
||||
}catch (Exception e){
|
||||
log.error("修改失败",e);
|
||||
return AjaxResult.error("校验job数据失败");
|
||||
}
|
||||
if(!ajaxResult.isSuccess()){
|
||||
return ajaxResult;
|
||||
}
|
||||
int update = mapper.update(task);
|
||||
if(update > 0){
|
||||
//修改时不该任务,默认原任务,不然会影响生日等特殊任务
|
||||
job.setInvokeTarget(null);
|
||||
int i = jobService.updateJob(job);
|
||||
List<WorkerVo> allList = new ArrayList<>();
|
||||
List<WorkerVo> workerList = task.getWorkerList();
|
||||
|
|
@ -179,9 +190,6 @@ public class PmTaskServiceImpl implements PmTaskService{
|
|||
|
||||
@Override
|
||||
public AjaxResult msgSendStatus(String msg) {
|
||||
if (msg == null) {
|
||||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
String[] split = msg.split(";");
|
||||
List<WorkerVo> list = new ArrayList<>();
|
||||
for (String s : split) {
|
||||
|
|
@ -193,11 +201,14 @@ public class PmTaskServiceImpl implements PmTaskService{
|
|||
if("1".equals(splitStatus[2])){
|
||||
bean.setSendStatus("发送成功");
|
||||
}else{
|
||||
bean.setReason("发送失败");
|
||||
bean.setSendStatus("发送失败");
|
||||
}
|
||||
list.add(bean);
|
||||
}
|
||||
}
|
||||
if (list.isEmpty()){
|
||||
return AjaxResult.error("数据为空");
|
||||
}
|
||||
int i = mapper.msgSendStatus(list);
|
||||
return i > 0 ? AjaxResult.success("更新成功") : AjaxResult.error("更新失败");
|
||||
}
|
||||
|
|
@ -237,7 +248,7 @@ public class PmTaskServiceImpl implements PmTaskService{
|
|||
}
|
||||
// 在设置发送时间时使用时分秒格式
|
||||
// 只要年月日 → 用 LocalDate
|
||||
o.setSendTime(LocalDate.now().toString()); // 简洁且安全
|
||||
o.setSendTime(DateUtils.getTime()); // 简洁且安全
|
||||
int i = mapper.updateOneWorkerData(o);
|
||||
return i > 0 ? AjaxResult.success("更新成功") : AjaxResult.error("更新失败");
|
||||
}
|
||||
|
|
@ -310,8 +321,7 @@ public class PmTaskServiceImpl implements PmTaskService{
|
|||
{
|
||||
return AjaxResult.error("处理任务'" + job.getJobName() + "'失败,目标字符串存在违规");
|
||||
}
|
||||
else if (!ScheduleUtils.whiteList(job.getInvokeTarget()))
|
||||
{
|
||||
else if (!ScheduleUtils.whiteList(job.getInvokeTarget())){
|
||||
return AjaxResult.error("处理任务'" + job.getJobName() + "'失败,目标字符串不在白名单内");
|
||||
}
|
||||
return AjaxResult.success();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.bonus.job.domain.SysJob;
|
|||
import com.bonus.job.mapper.SysJobMapper;
|
||||
import com.bonus.job.util.CronUtils;
|
||||
import com.bonus.job.util.ScheduleUtils;
|
||||
import org.hibernate.validator.internal.util.StringHelper;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.Scheduler;
|
||||
|
|
@ -201,7 +202,9 @@ public class SysJobServiceImpl implements ISysJobService
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertJob(SysJob job) throws SchedulerException, TaskException
|
||||
{
|
||||
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
|
||||
if(StringHelper.isNullOrEmptyString(job.getStatus())){
|
||||
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
|
||||
}
|
||||
int rows = jobMapper.insertJob(job);
|
||||
if (rows > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
package com.bonus.job.task;
|
||||
|
||||
import com.bonus.common.utils.DateUtils;
|
||||
import com.bonus.job.domain.SysJob;
|
||||
import com.bonus.job.mapper.WorkerJobMapper;
|
||||
import com.bonus.job.service.ISysJobService;
|
||||
import com.bonus.job.util.HttpRequestHelper;
|
||||
import com.bonus.job.util.MessageSendUtil;
|
||||
import com.bonus.job.util.SnowflakeIdGenerator;
|
||||
import com.bonus.message.dao.WorkerVo;
|
||||
import org.quartz.Job;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -31,6 +36,9 @@ public class WorkerSendMsgTask{
|
|||
@Resource
|
||||
private WorkerJobMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private ISysJobService jobService;
|
||||
|
||||
SnowflakeIdGenerator idGen = new SnowflakeIdGenerator(1, 1);
|
||||
|
||||
/**
|
||||
|
|
@ -42,6 +50,12 @@ public class WorkerSendMsgTask{
|
|||
//查询任务发送人人员信息
|
||||
List<WorkerVo> list = mapper.getWorkerByJobId(jobId);
|
||||
sendInBatches(list);
|
||||
//如果任务是指执行一次,就将任务status停掉
|
||||
SysJob job = mapper.getJobByJobId(jobId);
|
||||
if ("2".equals(job.getMisfirePolicy())){
|
||||
job.setStatus("1");
|
||||
int i = jobService.changeStatus(job);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("人员短信调度,{}",e.getMessage());
|
||||
}
|
||||
|
|
@ -97,7 +111,7 @@ public class WorkerSendMsgTask{
|
|||
user.setSubmitStatus(split[0]);
|
||||
user.setBatchNumber(split[1]);
|
||||
// 在设置发送时间时使用时分秒格式
|
||||
user.setSendTime(LocalDate.now().toString()); // 简洁且安全
|
||||
user.setSendTime(DateUtils.getTime()); // 简洁且安全
|
||||
});
|
||||
|
||||
} else {
|
||||
|
|
@ -108,7 +122,7 @@ public class WorkerSendMsgTask{
|
|||
user.setSubmitStatus(split[0]);
|
||||
user.setReason(split[1]);
|
||||
// 在设置发送时间时使用时分秒格式
|
||||
user.setSendTime(LocalDate.now().toString()); // 简洁且安全
|
||||
user.setSendTime(DateUtils.getTime()); // 简洁且安全
|
||||
});
|
||||
}
|
||||
mapper.insertTaskRecord(userList);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.message.controller;
|
|||
import com.bonus.common.core.controller.BaseController;
|
||||
import com.bonus.common.core.domain.AjaxResult;
|
||||
import com.bonus.common.core.page.TableDataInfo;
|
||||
import com.bonus.common.utils.AesUtil;
|
||||
import com.bonus.common.utils.poi.ExcelUtil;
|
||||
import com.bonus.message.dao.WorkerVo;
|
||||
import com.bonus.message.service.WorkerService;
|
||||
|
|
@ -42,6 +43,9 @@ public class WorkerController extends BaseController {
|
|||
try {
|
||||
startPage();
|
||||
List<WorkerVo> list = workerService.getWorkerList(workerVo);
|
||||
for (WorkerVo worker : list) {
|
||||
workerVo.setPhone(AesUtil.encrypt(worker.getPhone()));
|
||||
}
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
|
|
@ -150,6 +154,9 @@ public class WorkerController extends BaseController {
|
|||
try {
|
||||
ExcelUtil<WorkerVo> util = new ExcelUtil<WorkerVo>(WorkerVo.class);
|
||||
List<WorkerVo> workerList = util.importExcel(file.getInputStream());
|
||||
if (workerList.isEmpty()){
|
||||
return AjaxResult.error("文件为空或者模版有问题,请按照模版导入数据");
|
||||
}
|
||||
String message = workerService.importWorker(workerList);
|
||||
if ("导入成功".equals(message)) {
|
||||
return success(message);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@ public class WorkerVo {
|
|||
@Excel(name = "性别")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@Excel(name = "生日")
|
||||
private String birthday;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -31,11 +31,7 @@ public class WorkerServiceImpl implements WorkerService {
|
|||
*/
|
||||
@Override
|
||||
public List<WorkerVo> getWorkerList(WorkerVo workerVo) {
|
||||
List<WorkerVo> workerList = workerMapper.getWorkerList(workerVo);
|
||||
for (WorkerVo worker : workerList) {
|
||||
workerVo.setPhone(AesUtil.encrypt(worker.getPhone()));
|
||||
}
|
||||
return workerList;
|
||||
return workerMapper.getWorkerList(workerVo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,6 +92,7 @@ public class WorkerServiceImpl implements WorkerService {
|
|||
|| StringUtils.isEmpty(workerVo.getOrgName())
|
||||
|| StringUtils.isEmpty(workerVo.getWorkerName())
|
||||
|| StringUtils.isEmpty(workerVo.getSex())
|
||||
|| StringUtils.isEmpty(workerVo.getBirthday())
|
||||
){
|
||||
return "缺少必填项";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ spring:
|
|||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://192.168.0.14:4418/yn_message_gadget?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://192.168.0.14:4418/yn_message_gadget?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: Bonus@admin123!
|
||||
# 从库数据源
|
||||
|
|
|
|||
|
|
@ -68,14 +68,14 @@ spring:
|
|||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
# host: 192.168.0.14
|
||||
# port: 2004
|
||||
# database: 6
|
||||
# password: Plzbns@Redis123!
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
host: 192.168.0.14
|
||||
port: 2004
|
||||
database: 6
|
||||
password:
|
||||
password: Plzbns@Redis123!
|
||||
# host: 127.0.0.1
|
||||
# port: 6379
|
||||
# database: 6
|
||||
# password:
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -96,7 +96,7 @@
|
|||
</delete>
|
||||
|
||||
<update id="msgSendStatus">
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
update bm_task_record set send_status = #{item.sendStatus} where batch_number = #{item.batchNumber} and phone = #{item.phone}
|
||||
</foreach>
|
||||
</update>
|
||||
|
|
@ -122,6 +122,8 @@
|
|||
</if>
|
||||
GROUP BY
|
||||
btw.loop_id
|
||||
order by
|
||||
btw.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="getOneLoopMsgData" resultMap="BaseResultMap">
|
||||
|
|
|
|||
|
|
@ -87,4 +87,13 @@
|
|||
pt.id = #{jobId}
|
||||
AND w.birthday = CURRENT_DATE;
|
||||
</select>
|
||||
|
||||
<select id="getJobByJobId" resultType="com.bonus.job.domain.SysJob">
|
||||
select
|
||||
job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status
|
||||
from
|
||||
sys_job
|
||||
where
|
||||
relation_id = #{jobId} and relation_type = '短信'
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class SecurityConfig
|
|||
.authorizeHttpRequests((requests) -> {
|
||||
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
requests.antMatchers("/login", "/register", "/captchaImage", "/msgJob/msgSendStatus").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
|
|
|
|||
Loading…
Reference in New Issue