You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.4 KiB
38 lines
1.4 KiB
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) {
|
|
|
|
}
|
|
}
|
|
}
|
|
|