parent
8a615ef604
commit
1e729f1465
@ -0,0 +1,39 @@ |
|||||||
|
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) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
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) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue