* https://www.renren.io
- *
+ *
* 版权所有,侵权必究!
*/
package com.elink.esua.epdc.service.impl;
+import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.entity.ScheduleJobEntity;
@@ -18,10 +19,8 @@ import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.dao.ScheduleJobDao;
import com.elink.esua.epdc.dto.ScheduleJobDTO;
-import com.elink.esua.epdc.entity.ScheduleJobEntity;
import com.elink.esua.epdc.enums.ScheduleStatusEnum;
import com.elink.esua.epdc.service.ScheduleJobService;
-import com.elink.esua.epdc.utils.ScheduleUtils;
import org.apache.commons.lang3.StringUtils;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,110 +29,123 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
@Service
public class ScheduleJobServiceImpl extends BaseServiceImpl implements ScheduleJobService {
- @Autowired
- private Scheduler scheduler;
-
- @Override
- public PageData page(Map params) {
- IPage page = baseDao.selectPage(
- getPage(params, Constant.CREATE_DATE, false),
- getWrapper(params)
- );
- return getPageData(page, ScheduleJobDTO.class);
- }
+ @Autowired
+ private Scheduler scheduler;
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, Constant.CREATE_DATE, false),
+ getWrapper(params)
+ );
+ return getPageData(page, ScheduleJobDTO.class);
+ }
- @Override
- public ScheduleJobDTO get(Long id) {
- ScheduleJobEntity entity = baseDao.selectById(id);
+ @Override
+ public ScheduleJobDTO get(Long id) {
+ ScheduleJobEntity entity = baseDao.selectById(id);
- return ConvertUtils.sourceToTarget(entity, ScheduleJobDTO.class);
- }
+ return ConvertUtils.sourceToTarget(entity, ScheduleJobDTO.class);
+ }
- private QueryWrapper getWrapper(Map params){
- String beanName = (String)params.get("beanName");
+ private QueryWrapper getWrapper(Map params) {
+ String beanName = (String) params.get("beanName");
- QueryWrapper wrapper = new QueryWrapper<>();
- wrapper.like(StringUtils.isNotBlank(beanName), "bean_name", beanName);
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.like(StringUtils.isNotBlank(beanName), "bean_name", beanName);
- return wrapper;
- }
+ return wrapper;
+ }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void save(ScheduleJobDTO dto) {
- ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class);
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(ScheduleJobDTO dto) {
+ ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class);
- entity.setStatus(ScheduleStatusEnum.NORMAL.value());
+ entity.setStatus(ScheduleStatusEnum.NORMAL.value());
this.insert(entity);
ScheduleUtils.createScheduleJob(scheduler, entity);
}
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void update(ScheduleJobDTO dto) {
- ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class);
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(ScheduleJobDTO dto) {
+ ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class);
ScheduleUtils.updateScheduleJob(scheduler, entity);
this.updateById(entity);
}
- @Override
- @Transactional(rollbackFor = Exception.class)
+ @Override
+ @Transactional(rollbackFor = Exception.class)
public void deleteBatch(Long[] ids) {
- for(Long id : ids){
- ScheduleUtils.deleteScheduleJob(scheduler, id);
- }
-
- //删除数据
- this.deleteBatchIds(Arrays.asList(ids));
- }
-
- @Override
- public int updateBatch(Long[] ids, int status){
- Map map = new HashMap<>(2);
- map.put("ids", ids);
- map.put("status", status);
- return baseDao.updateBatch(map);
+ for (Long id : ids) {
+ ScheduleUtils.deleteScheduleJob(scheduler, id);
+ }
+
+ //删除数据
+ this.deleteBatchIds(Arrays.asList(ids));
}
- @Override
- @Transactional(rollbackFor = Exception.class)
+ @Override
+ public int updateBatch(Long[] ids, int status) {
+ Map map = new HashMap<>(2);
+ map.put("ids", ids);
+ map.put("status", status);
+ return baseDao.updateBatch(map);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
public void run(Long[] ids) {
- for(Long id : ids){
- ScheduleUtils.run(scheduler, this.selectById(id));
- }
+ for (Long id : ids) {
+ ScheduleUtils.run(scheduler, this.selectById(id));
+ }
}
- @Override
- @Transactional(rollbackFor = Exception.class)
+ @Override
+ @Transactional(rollbackFor = Exception.class)
public void pause(Long[] ids) {
- for(Long id : ids){
- ScheduleUtils.pauseJob(scheduler, id);
- }
+ for (Long id : ids) {
+ ScheduleUtils.pauseJob(scheduler, id);
+ }
- updateBatch(ids, ScheduleStatusEnum.PAUSE.value());
+ updateBatch(ids, ScheduleStatusEnum.PAUSE.value());
}
- @Override
- @Transactional(rollbackFor = Exception.class)
+ @Override
+ @Transactional(rollbackFor = Exception.class)
public void resume(Long[] ids) {
- for(Long id : ids){
- ScheduleUtils.resumeJob(scheduler, id);
- }
+ for (Long id : ids) {
+ ScheduleUtils.resumeJob(scheduler, id);
+ }
- updateBatch(ids, ScheduleStatusEnum.NORMAL.value());
+ updateBatch(ids, ScheduleStatusEnum.NORMAL.value());
}
- @Override
- public void deleteJobByParams(String params) {
- //删除数据
- baseDao.deleteJobByParams(params);
- }
+ @Override
+ public void deleteJobByParams(String params) {
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq("params", params);
+ List scheduleJobEntities = baseDao.selectList(wrapper);
+
+ if (CollUtil.isNotEmpty(scheduleJobEntities)) {
+ Long[] jobIds = scheduleJobEntities.stream()
+ .map(ScheduleJobEntity::getId)
+ .distinct()
+ .toArray(Long[]::new);
+
+ this.deleteBatch(jobIds);
+ }
+
+ }
}
diff --git a/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/activity/AutoAuditActUserTask.java b/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/activity/AutoAuditActUserTask.java
index 44aca3e46..78cf190eb 100644
--- a/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/activity/AutoAuditActUserTask.java
+++ b/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/activity/AutoAuditActUserTask.java
@@ -17,15 +17,40 @@
package com.elink.esua.epdc.task.activity;
+import com.elink.esua.epdc.commons.tools.utils.Result;
+import com.elink.esua.epdc.constant.JobModuleConstant;
+import com.elink.esua.epdc.service.ActivityService;
+import com.elink.esua.epdc.service.ScheduleJobService;
+import com.elink.esua.epdc.task.ITask;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
/**
- * 志愿者排名
+ * 自动审核通过未审核的报名人员
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-19
*/
-public interface AutoAuditActUserTask {
+@Component(JobModuleConstant.TASK_NAME_AUDIT_ACT)
+public class AutoAuditActUserTask implements ITask {
+
+ @Autowired
+ private ActivityService activityService;
+
+ @Autowired
+ private ScheduleJobService scheduleJobService;
+
+ @Override
+ public void run(String actId) {
+ // 活动时间到自动审核通过未审核的报名人员
+ Result result = activityService.AutoAuditActUser(actId);
+
+ // 删除对应job
+ if (result.success()) {
+ scheduleJobService.deleteJobByParams(actId);
+ }
- void run(String actId);
+ }
}
\ No newline at end of file
diff --git a/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/activity/AutoAuditActUserTaskImpl.java b/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/activity/AutoAuditActUserTaskImpl.java
deleted file mode 100644
index d75336440..000000000
--- a/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/activity/AutoAuditActUserTaskImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright 2018 人人开源 https://www.renren.io
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.elink.esua.epdc.task.activity;
-
-import com.elink.esua.epdc.commons.tools.utils.Result;
-import com.elink.esua.epdc.service.ActivityService;
-import com.elink.esua.epdc.service.ScheduleJobService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * 自动审核通过未审核的报名人员
- *
- * @author qu qu@elink-cn.com
- * @since v1.0.0 2019-12-19
- */
-@Component("AutoAuditActUserTask")
-public class AutoAuditActUserTaskImpl implements AutoAuditActUserTask {
-
- @Autowired
- private ActivityService activityService;
-
- @Autowired
- private ScheduleJobService scheduleJobService;
-
- @Override
- public void run(String actId){
- //活动时间到自动审核通过未审核的报名人员
- Result result = activityService.AutoAuditActUser(actId);
-
- //删除对应job
- if(result.getCode() == 0){
- scheduleJobService.deleteJobByParams(actId);
- }
-
-
- }
-
-
-}
\ No newline at end of file
diff --git a/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/volunteer/UpdateVolunteerRankTask.java b/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/volunteer/UpdateVolunteerRankTask.java
index fcba26c11..6a1c0c330 100644
--- a/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/volunteer/UpdateVolunteerRankTask.java
+++ b/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/volunteer/UpdateVolunteerRankTask.java
@@ -17,15 +17,28 @@
package com.elink.esua.epdc.task.volunteer;
+import com.elink.esua.epdc.service.VolunteerService;
+import com.elink.esua.epdc.task.ITask;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
/**
- * 志愿者排名
+ * 定时更新志愿者排名
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-19
*/
-public interface UpdateVolunteerRankTask {
+@Component("updateVolunteerRankTask")
+public class UpdateVolunteerRankTask implements ITask {
+
+ @Autowired
+ private VolunteerService volunteerService;
- void run(String param);
+ @Override
+ public void run(String param) {
+ //每日定时更新排行榜
+ volunteerService.generateRankingList();
+ }
}
\ No newline at end of file
diff --git a/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/volunteer/UpdateVolunteerRankTaskImpl.java b/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/volunteer/UpdateVolunteerRankTaskImpl.java
deleted file mode 100644
index 667b19a78..000000000
--- a/esua-epdc/epdc-module/epdc-job/epdc-job-server/src/main/java/com/elink/esua/epdc/task/volunteer/UpdateVolunteerRankTaskImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright 2018 人人开源 https://www.renren.io
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.elink.esua.epdc.task.volunteer;
-
-import com.elink.esua.epdc.service.VolunteerService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * 定时更新志愿者排名
- *
- * @author qu qu@elink-cn.com
- * @since v1.0.0 2019-12-19
- */
-@Component("UpdateVolunteerRankTask")
-public class UpdateVolunteerRankTaskImpl implements UpdateVolunteerRankTask {
-
- @Autowired
- private VolunteerService volunteerService;
-
- @Override
- public void run(String param){
- //每日定时更新排行榜
- volunteerService.generateRankingList();
- }
-
-
-}
\ No newline at end of file