all
This commit is contained in:
@@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
@@ -13,6 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
@MapperScan({"com.zscat.mallplus.mapper", "com.zscat.mallplus.ums.mapper", "com.zscat.mallplus.sms.mapper", "com.zscat.mallplus.cms.mapper", "com.zscat.mallplus.sys.mapper", "com.zscat.mallplus.oms.mapper", "com.zscat.mallplus.pms.mapper"})
|
||||
@EnableTransactionManagement
|
||||
@EnableScheduling
|
||||
public class MallAdminApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MallAdminApplication.class, args);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.zscat.mallplus.task;
|
||||
|
||||
import com.zscat.mallplus.ums.service.SysMessageTaskService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Project: mallplus <br/>
|
||||
* File: SchedulingService.java <br/>
|
||||
* Class: com.zscat.mallplus.task.SchedulingService <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2023/3/18 22:10 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Component
|
||||
public class SchedulingTaskComponent {
|
||||
|
||||
@Autowired
|
||||
private SysMessageTaskService sysMessageTaskService;
|
||||
|
||||
@Scheduled(cron = "0 */5 * * * ?")
|
||||
public void remindVehicle() {
|
||||
sysMessageTaskService.checkTask();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,39 @@
|
||||
package com.zscat.mallplus.ums.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zscat.mallplus.ums.entity.SysMessage;
|
||||
import com.zscat.mallplus.ums.entity.SysMessageTask;
|
||||
import com.zscat.mallplus.ums.mapper.SysMessageTaskMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysMessageTaskService extends ServiceImpl<SysMessageTaskMapper, SysMessageTask> {
|
||||
|
||||
@Autowired
|
||||
private ISysMessageService messageService;
|
||||
|
||||
public void checkTask() {
|
||||
QueryWrapper<SysMessageTask> qw = new QueryWrapper<>();
|
||||
qw.eq("status", 0);
|
||||
qw.lt("sendtime", new Date());
|
||||
List<SysMessageTask> list = baseMapper.selectList(qw);
|
||||
for (SysMessageTask task : list) {
|
||||
SysMessage sm = new SysMessage();
|
||||
sm.setCode("系统消息");
|
||||
sm.setUserId(1);
|
||||
sm.setId(null);
|
||||
sm.setContent(task.getContent());
|
||||
sm.setParams(task.getParams());
|
||||
sm.setCtime(System.currentTimeMillis());
|
||||
messageService.sendToAll(sm);
|
||||
task.setStatus(1);
|
||||
baseMapper.updateById(task);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user