springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -11312,6 +11312,15 @@ R volunteerDeleteById(@RequestParam("id") String id); /** * 定时刷新活动状态 * @return */ @GetMapping("/Volunteer/timedTaskVolunteerActivitiesJobHandler") public R timedTaskVolunteerActivitiesJobHandler(); /******************************************************************************************************************* * * @@ -11402,4 +11411,9 @@ @DeleteMapping("/VolunteerActivitiesPeople/vapDelete") public R vapDelete(@RequestParam("id") String id); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/VolunteerActivitiesPeopleApi.java
@@ -88,4 +88,7 @@ } return R.fail(); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/VolunteerActivityApi.java
@@ -85,4 +85,19 @@ } return R.fail(); } @GetMapping("/timedTaskVolunteerActivitiesJobHandler") R timedTaskVolunteerActivitiesJobHandler() { int num = volunteerActivityService.timedTaskVolunteerActivitiesJobHandler(); if(num>0) { return R.ok(); } return R.fail(); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/VolunteerActivitiesPeopleDao.java
@@ -49,6 +49,14 @@ int vapDelete(@Param("id") String id); /*********************************************************************************** * * * 定时任务内容 * */ } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/VolunteerActivityDao.java
@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Param; import java.util.Date; import java.util.List; @Mapper public interface VolunteerActivityDao extends BaseMapper<VolunteerActivity> @@ -46,5 +47,6 @@ int deleteById(@Param("id") String id); List<VolunteerActivity> timedTaskList(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/VolunteerActivityService.java
@@ -43,4 +43,8 @@ int deleteById(String id); int timedTaskVolunteerActivitiesJobHandler(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/VolunteerActivitiesPeopleServiceImpl.java
@@ -41,4 +41,6 @@ public int vapDelete(String id) { return baseMapper.vapDelete(id); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/VolunteerActivityServiceImpl.java
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.model.vos.community.MostBeautifulVolunteerVO; import com.panzhihua.common.model.vos.community.VolunteerActivityVO; import com.panzhihua.common.utlis.StringUtils; import com.panzhihua.service_community.dao.MostBeautifulVolunteerDao; import com.panzhihua.service_community.dao.VolunteerActivityDao; import com.panzhihua.service_community.entity.MostBeautifulVolunteer; @@ -15,6 +16,7 @@ import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; @Slf4j @Service @@ -53,4 +55,65 @@ public int deleteById(String Id) { return baseMapper.deleteById(Id); } /** * 定时任务 * @return */ @Override public int timedTaskVolunteerActivitiesJobHandler() { List<VolunteerActivity> list = baseMapper.timedTaskList(); Long newTiem=System.currentTimeMillis(); if(list.size()>0) { for (VolunteerActivity itemDate:list) { String state = itemDate.getAcState(); //2未开始 3报名中", 4进行中" //活动报名开始时间 Long applyBegintime = itemDate.getApplyBeginTime().getTime(); //活动报名结束时间 Long applyEndtime = itemDate.getApplyEndTime().getTime(); //活动开始时间 Long actityBegintime = itemDate.getActityBeginTime().getTime(); //活动结束时间 Long actityEndtime = itemDate.getActityEndTime().getTime(); //判断是否在报名中 if (newTiem >= applyBegintime && newTiem < applyEndtime) { state = "3"; } else if (newTiem>applyEndtime) { //报名如果截止 报名人数为0 结束活动 Integer num=Integer.valueOf(itemDate.getVolunteerNum()); if(num<=0) { state = "6"; } } else if (newTiem >= actityBegintime && newTiem <= actityEndtime) { //判断是否活动进行中 state = "4"; } else if(newTiem>actityEndtime) { //活动结束 state = "5"; } if(!StringUtils.equals(state,itemDate.getAcState())) { itemDate.setAcState(state); baseMapper.updateById(itemDate); } } } return 1; } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/VolunteerActivityMapper.xml
@@ -37,7 +37,7 @@ name, ac_type, address, volunteer_num, (select count(id) from volunteer_activities_people_involved where activity_id=id) volunteerNum, ac_state, award_state, issue_time, @@ -334,4 +334,22 @@ delete from volunteer_activity where id=#{id} </delete> <!-- 分页查询 --> <select id="timedTaskList" resultMap="VolunteerActivityMap"> select ac_state, (select count(id) from volunteer_activities_people_involved where activity_id=id) volunteerNum, apply_begin_time, apply_end_time, actity_begin_time, actity_end_time from volunteer_activity where ac_state in (2,3,4) </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/timejob/src/main/java/com/panzhihua/timejob/jobhandler/LBJobHandler.java
New file @@ -0,0 +1,35 @@ package com.panzhihua.timejob.jobhandler; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.VolunteerActivityVO; import com.panzhihua.common.service.community.ComBatteryCommodityOrderFeign; import com.panzhihua.common.service.community.CommunityService; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.annotation.Resource; /** * 路北社区任务定时器 * @author lyq */ @Slf4j @Component public class LBJobHandler { @Resource private CommunityService communityService; //定时任务 路北社区 @XxlJob("timedTaskVolunteerActivitiesJobHandler") public ReturnT<String> timedTaskVolunteerActivitiesJobHandler(String param) throws Exception { log.info("定时任务 每半小时检测一次路北社区 活动任务状态"); // R r = communityService.timedTaskVolunteerActivitiesJobHandler(); // log.info("执行结果【{}】", r.toString()); log.info("测试执行结果【{}】"); return ReturnT.SUCCESS; } }