| | |
| | | primary key (job_id, job_name, job_group) |
| | | ) engine=innodb auto_increment=4 comment = '定时任务调度表'; |
| | | |
| | | insert into sys_job values(1, '软件检测定时任务', 'DEFAULT', 'ryTask.runSoftTest', '0/10 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_job values(2, '分系统检测定时任务', 'DEFAULT', 'ryTask.runSubSysTest', '0/10 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_job values(1, '软件状态检测定时任务', 'DEFAULT', 'ryTask.runSoftTest', '0/10 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_job values(2, '系统状态检测定时任务', 'DEFAULT', 'ryTask.runSubSysTest', '0/10 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, ''); |
| | | -- insert into sys_job values(3, '系统默认(多参)', 'DEFAULT', 'ryTask.ryMultipleParams(\'ry\', true, 2000L, 316.50D, 100)', '0/20 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, ''); |
| | | -- select * from sys_job order by job_id; |
| | | |
| | |
| | | update sys_menu set mark = 'sys' where menu_id >= @parentId; |
| | | |
| | | insert into sys_status_ctrl (sys_name,ip,url,method,order_num) values ('用户及权限管理','127.0.0.1','http://localhost:8080/system/health','GET',1); |
| | | insert into sys_status_ctrl (sys_name,ip,url,method,order_num) values ('数据管理分系统','127.0.0.1','http://localhost:8080/gateway/health','GET',2); |
| | | -- ---------------------------- |
| | | |
| | |
| | | package com.se.system; |
| | | |
| | | import com.se.system.utils.CaffeineUtils; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import com.se.common.security.annotation.EnableCustomConfig; |
| | |
| | | @EnableCustomSwagger2 |
| | | @EnableRyFeignClients |
| | | @SpringBootApplication |
| | | public class SeSystemApplication |
| | | { |
| | | public static void main(String[] args) |
| | | { |
| | | public class SeSystemApplication { |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(SeSystemApplication.class, args); |
| | | CaffeineUtils.init(); |
| | | System.out.println(" 系统模块启动成功 "); |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | import com.se.common.core.utils.DateUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.se.system.utils.CaffeineUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import com.se.system.mapper.SysSoftMapper; |
| | | import com.se.system.domain.SysSoft; |
| | | import com.se.system.service.inte.ISysSoftService; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 软件Service业务层处理 |
| | |
| | | * @date 2024-11-22 |
| | | */ |
| | | @Service |
| | | public class SysSoftServiceImpl implements ISysSoftService |
| | | { |
| | | @Autowired |
| | | @SuppressWarnings("ALL") |
| | | public class SysSoftServiceImpl implements ISysSoftService { |
| | | @Resource |
| | | private SysSoftMapper sysSoftMapper; |
| | | |
| | | private final static String CACHE_KEY = "list:syssoft"; |
| | | |
| | | /** |
| | | * 查询软件 |
| | |
| | | * @return 软件 |
| | | */ |
| | | @Override |
| | | public SysSoft selectSysSoftBySoftId(Long softId) |
| | | { |
| | | public SysSoft selectSysSoftBySoftId(Long softId) { |
| | | return sysSoftMapper.selectSysSoftBySoftId(softId); |
| | | } |
| | | |
| | |
| | | * @return 软件 |
| | | */ |
| | | @Override |
| | | public List<SysSoft> selectSysSoftList(SysSoft sysSoft) |
| | | { |
| | | public List<SysSoft> selectSysSoftList(SysSoft sysSoft) { |
| | | return sysSoftMapper.selectSysSoftList(sysSoft); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertSysSoft(SysSoft sysSoft) |
| | | { |
| | | public int insertSysSoft(SysSoft sysSoft) { |
| | | CaffeineUtils.remove(CACHE_KEY); |
| | | sysSoft.setCreateTime(DateUtils.getNowDate()); |
| | | return sysSoftMapper.insertSysSoft(sysSoft); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateSysSoft(SysSoft sysSoft) |
| | | { |
| | | public int updateSysSoft(SysSoft sysSoft) { |
| | | CaffeineUtils.remove(CACHE_KEY); |
| | | sysSoft.setUpdateTime(DateUtils.getNowDate()); |
| | | return sysSoftMapper.updateSysSoft(sysSoft); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteSysSoftBySoftIds(Long[] softIds) |
| | | { |
| | | public int deleteSysSoftBySoftIds(Long[] softIds) { |
| | | CaffeineUtils.remove(CACHE_KEY); |
| | | return sysSoftMapper.deleteSysSoftBySoftIds(softIds); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteSysSoftBySoftId(Long softId) |
| | | { |
| | | public int deleteSysSoftBySoftId(Long softId) { |
| | | CaffeineUtils.remove(CACHE_KEY); |
| | | return sysSoftMapper.deleteSysSoftBySoftId(softId); |
| | | } |
| | | |
| | | private List<SysSoft> getList() { |
| | | List<SysSoft> list = CaffeineUtils.getListByKey(CACHE_KEY); |
| | | if (null == list) { |
| | | list = selectSysSoftList(new SysSoft()); |
| | | CaffeineUtils.putListByKey(CACHE_KEY, list); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | public void runSoftTest() throws Exception { |
| | | List<SysSoft> list = getList(); |
| | | if (CollectionUtils.isEmpty(list)) return; |
| | | |
| | | // |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | import com.se.common.core.utils.DateUtils; |
| | | import com.se.system.domain.SysSoft; |
| | | import com.se.system.utils.CaffeineUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import com.se.system.mapper.SysStatusCtrlMapper; |
| | | import com.se.system.domain.SysStatusCtrl; |
| | | import com.se.system.service.inte.ISysStatusCtrlService; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | * @date 2024-12-07 |
| | | */ |
| | | @Service |
| | | public class SysStatusCtrlServiceImpl implements ISysStatusCtrlService |
| | | { |
| | | @SuppressWarnings("ALL") |
| | | public class SysStatusCtrlServiceImpl implements ISysStatusCtrlService { |
| | | @Resource |
| | | private SysStatusCtrlMapper sysStatusCtrlMapper; |
| | | |
| | | private final static String CACHE_KEY = "list:statusctrl"; |
| | | |
| | | /** |
| | | * 查询系统状态监控 |
| | |
| | | * @return 系统状态监控 |
| | | */ |
| | | @Override |
| | | public SysStatusCtrl selectSysStatusCtrlByStatusId(Long statusId) |
| | | { |
| | | public SysStatusCtrl selectSysStatusCtrlByStatusId(Long statusId) { |
| | | return sysStatusCtrlMapper.selectSysStatusCtrlByStatusId(statusId); |
| | | } |
| | | |
| | |
| | | * @return 系统状态监控 |
| | | */ |
| | | @Override |
| | | public List<SysStatusCtrl> selectSysStatusCtrlList(SysStatusCtrl sysStatusCtrl) |
| | | { |
| | | public List<SysStatusCtrl> selectSysStatusCtrlList(SysStatusCtrl sysStatusCtrl) { |
| | | return sysStatusCtrlMapper.selectSysStatusCtrlList(sysStatusCtrl); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertSysStatusCtrl(SysStatusCtrl sysStatusCtrl) |
| | | { |
| | | public int insertSysStatusCtrl(SysStatusCtrl sysStatusCtrl) { |
| | | CaffeineUtils.remove(CACHE_KEY); |
| | | sysStatusCtrl.setCreateTime(DateUtils.getNowDate()); |
| | | return sysStatusCtrlMapper.insertSysStatusCtrl(sysStatusCtrl); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateSysStatusCtrl(SysStatusCtrl sysStatusCtrl) |
| | | { |
| | | public int updateSysStatusCtrl(SysStatusCtrl sysStatusCtrl) { |
| | | CaffeineUtils.remove(CACHE_KEY); |
| | | sysStatusCtrl.setUpdateTime(DateUtils.getNowDate()); |
| | | return sysStatusCtrlMapper.updateSysStatusCtrl(sysStatusCtrl); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteSysStatusCtrlByStatusIds(Long[] statusIds) |
| | | { |
| | | public int deleteSysStatusCtrlByStatusIds(Long[] statusIds) { |
| | | CaffeineUtils.remove(CACHE_KEY); |
| | | return sysStatusCtrlMapper.deleteSysStatusCtrlByStatusIds(statusIds); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteSysStatusCtrlByStatusId(Long statusId) |
| | | { |
| | | public int deleteSysStatusCtrlByStatusId(Long statusId) { |
| | | CaffeineUtils.remove(CACHE_KEY); |
| | | return sysStatusCtrlMapper.deleteSysStatusCtrlByStatusId(statusId); |
| | | } |
| | | |
| | | private List<SysStatusCtrl> getList() { |
| | | List<SysStatusCtrl> list = CaffeineUtils.getListByKey(CACHE_KEY); |
| | | if (null == list) { |
| | | list = selectSysStatusCtrlList(new SysStatusCtrl()); |
| | | CaffeineUtils.putListByKey(CACHE_KEY, list); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | public void runSubSysTest() throws Exception { |
| | | List<SysStatusCtrl> list = getList(); |
| | | if (CollectionUtils.isEmpty(list)) return; |
| | | |
| | | // |
| | | } |
| | | } |
| | |
| | | |
| | | import com.github.benmanes.caffeine.cache.Cache; |
| | | import com.github.benmanes.caffeine.cache.Caffeine; |
| | | import com.se.system.SeSystemApplication; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | |
| | | import java.math.BigInteger; |
| | | import java.security.MessageDigest; |
| | |
| | | |
| | | @SuppressWarnings("ALL") |
| | | public class CaffeineUtils { |
| | | static Integer cacheTime; |
| | | |
| | | @Value("${sys.cacheTime}") |
| | | public void setCacheTime(Integer cacheTime) { |
| | | CaffeineUtils.cacheTime = cacheTime; |
| | | } |
| | | |
| | | private static Cache<String, Object> cache; |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(CaffeineUtils.class); |
| | | |
| | | public static void init(Integer cacheTime) { |
| | | public static void init() { |
| | | cache = Caffeine.newBuilder() |
| | | .initialCapacity(16) |
| | | .maximumSize(4096) |
| | | .expireAfterWrite(cacheTime, TimeUnit.MINUTES) |
| | | .expireAfterWrite(60 * 60 * 8, TimeUnit.SECONDS) |
| | | .build(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | public static <T> void putListByKey(String key, List<T> list) { |
| | | if (null != list && list.size() > 0) { |
| | | if (null != list) { |
| | | put(key, list); |
| | | } |
| | | } |
| | |
| | | package com.se.system.utils; |
| | | |
| | | import com.se.common.core.utils.StringUtils; |
| | | import com.se.system.service.impl.SysSoftServiceImpl; |
| | | import com.se.system.service.impl.SysStatusCtrlServiceImpl; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 定时任务调度 |
| | |
| | | */ |
| | | @Component("ryTask") |
| | | public class RyTask { |
| | | @Resource |
| | | SysSoftServiceImpl sysSoftService; |
| | | |
| | | @Resource |
| | | SysStatusCtrlServiceImpl sysStatusCtrlService; |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(RyTask.class); |
| | | |
| | | public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { |
| | | System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); |
| | | } |
| | |
| | | System.out.println("执行无参方法"); |
| | | } |
| | | |
| | | public void runSoftTest() { |
| | | public void runSoftTest() throws Exception { |
| | | System.out.println("ryTask.runSoftTest()"); |
| | | sysSoftService.runSoftTest(); |
| | | } |
| | | |
| | | public void runSubSysTest() { |
| | | public void runSubSysTest() throws Exception { |
| | | System.out.println("ryTask.runSubSysTest()"); |
| | | sysStatusCtrlService.runSubSysTest(); |
| | | } |
| | | } |