parent
1d06667710
commit
14504a2884
@ -1,39 +0,0 @@ |
|||||||
package com.hfkj.consumer; |
|
||||||
|
|
||||||
import com.hfkj.entity.BsGasOilPriceTask; |
|
||||||
import com.hfkj.entity.CmsContent; |
|
||||||
import com.hfkj.service.cms.CmsContentService; |
|
||||||
import com.hfkj.service.gas.BsGasOilPriceTaskService; |
|
||||||
import com.hfkj.sysenum.cms.CmsStatusEnum; |
|
||||||
import com.hfkj.sysenum.gas.GasTaskStatusEnum; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
|
||||||
import org.apache.rocketmq.spring.core.RocketMQListener; |
|
||||||
import org.springframework.stereotype.Component; |
|
||||||
|
|
||||||
import javax.annotation.Resource; |
|
||||||
import java.util.Date; |
|
||||||
|
|
||||||
@Component |
|
||||||
@Slf4j |
|
||||||
@RocketMQMessageListener(consumerGroup = "cms-offline", topic = "task-topic",selectorExpression = "cms-offline") |
|
||||||
public class CmsOfflineConsumer implements RocketMQListener<String> { |
|
||||||
@Resource |
|
||||||
private CmsContentService cmsContentService; |
|
||||||
|
|
||||||
@Override |
|
||||||
public void onMessage(String id) { |
|
||||||
System.out.println("CMS内容下线id:" + id); |
|
||||||
try { |
|
||||||
CmsContent content = cmsContentService.getDetail(Long.parseLong(id)); |
|
||||||
if (content != null && content.getEndTime() != null && content.getStatus().equals(CmsStatusEnum.status2.getStatus())) { |
|
||||||
if (content.getEndTime().compareTo(new Date()) <= 0) { |
|
||||||
cmsContentService.offline(Long.parseLong(id)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} catch (Exception e) { |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,38 +0,0 @@ |
|||||||
package com.hfkj.consumer; |
|
||||||
|
|
||||||
import com.hfkj.entity.BsGasOilPriceTask; |
|
||||||
import com.hfkj.entity.CmsContent; |
|
||||||
import com.hfkj.service.cms.CmsContentService; |
|
||||||
import com.hfkj.service.gas.BsGasOilPriceTaskService; |
|
||||||
import com.hfkj.sysenum.cms.CmsStatusEnum; |
|
||||||
import com.hfkj.sysenum.gas.GasTaskStatusEnum; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
|
||||||
import org.apache.rocketmq.spring.core.RocketMQListener; |
|
||||||
import org.springframework.stereotype.Component; |
|
||||||
|
|
||||||
import javax.annotation.Resource; |
|
||||||
import java.util.Date; |
|
||||||
|
|
||||||
@Component |
|
||||||
@Slf4j |
|
||||||
@RocketMQMessageListener(consumerGroup = "cms-online", topic = "task-topic",selectorExpression = "cms-online") |
|
||||||
public class CmsOnlineConsumer implements RocketMQListener<String> { |
|
||||||
@Resource |
|
||||||
private CmsContentService cmsContentService; |
|
||||||
|
|
||||||
@Override |
|
||||||
public void onMessage(String id) { |
|
||||||
System.out.println("CMS内容上线id:" + id); |
|
||||||
try { |
|
||||||
CmsContent content = cmsContentService.getDetail(Long.parseLong(id)); |
|
||||||
if (content != null && content.getStartTime() != null && content.getStatus().equals(CmsStatusEnum.status1.getStatus())) { |
|
||||||
if (content.getStartTime().compareTo(new Date()) <= 0) { |
|
||||||
cmsContentService.online(Long.parseLong(id)); |
|
||||||
} |
|
||||||
} |
|
||||||
} catch (Exception e) { |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,66 @@ |
|||||||
|
package com.hfkj.schedule; |
||||||
|
|
||||||
|
import com.hfkj.entity.BsDiscount; |
||||||
|
import com.hfkj.entity.CmsContent; |
||||||
|
import com.hfkj.service.cms.CmsContentService; |
||||||
|
import com.hfkj.service.discount.BsDiscountService; |
||||||
|
import com.hfkj.service.discount.BsDiscountUserService; |
||||||
|
import com.hfkj.sysenum.cms.CmsStatusEnum; |
||||||
|
import com.hfkj.sysenum.discount.DiscountStatusEnum; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: DiscountSchedule |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/9/4 |
||||||
|
**/ |
||||||
|
@Component |
||||||
|
public class CmsSchedule { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private CmsContentService cmsContentService; |
||||||
|
|
||||||
|
/** |
||||||
|
* CMS上线 |
||||||
|
*/ |
||||||
|
@Scheduled(cron="0 0/1 * * * ?") //每分钟执行一次
|
||||||
|
public void online() { |
||||||
|
try { |
||||||
|
Map<String,Object> param = new HashMap<>(); |
||||||
|
param.put("status", CmsStatusEnum.status1.getStatus()); |
||||||
|
param.put("createTimeS", new Date().getTime()); |
||||||
|
List<CmsContent> list = cmsContentService.getList(param); |
||||||
|
for (CmsContent data : list) { |
||||||
|
cmsContentService.online(data.getId()); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
System.out.println("更新失败!!!"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* CMS上线 |
||||||
|
*/ |
||||||
|
@Scheduled(cron="0 0/1 * * * ?") //每30分钟执行一次
|
||||||
|
public void offline() { |
||||||
|
try { |
||||||
|
Map<String,Object> param = new HashMap<>(); |
||||||
|
param.put("status", CmsStatusEnum.status2.getStatus()); |
||||||
|
param.put("createTimeE", new Date().getTime()); |
||||||
|
List<CmsContent> list = cmsContentService.getList(param); |
||||||
|
for (CmsContent data : list) { |
||||||
|
cmsContentService.offline(data.getId()); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
System.out.println("更新失败!!!"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue