| package doumeemes.config.rabbitmq; | 
|   | 
| import com.alibaba.fastjson.JSONObject; | 
| import doumeemes.core.utils.Constants; | 
| import doumeemes.dao.business.model.Workorder; | 
| import doumeemes.dao.system.model.SystemUser; | 
| import doumeemes.service.ext.WorkorderExtService; | 
| import doumeemes.service.system.impl.SystemUserServiceImpl; | 
| import org.slf4j.Logger; | 
| import org.slf4j.LoggerFactory; | 
| import org.springframework.amqp.rabbit.annotation.RabbitListener; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Component; | 
|   | 
| //@Component | 
| public class TopicReceiveListener { | 
|     private static final Logger logger = LoggerFactory.getLogger(TopicReceiveListener.class); | 
|     @Autowired | 
|     private SystemUserServiceImpl systemUserService; | 
|     @Autowired | 
|     private WorkorderExtService workorderExtService; | 
|     /** | 
|      * 测试 | 
|      * @param msg | 
|      */ | 
|     @RabbitListener(queues = Constants.RabbitMqQueue.TEST) | 
|     public void receiveMsg1(String msg) { | 
|         System.out.println("测试:" + msg); | 
|         try { | 
|             SystemUser model = JSONObject.toJavaObject(JSONObject.parseObject(msg),SystemUser.class); | 
|             if(model != null){ | 
|                 systemUserService.updateById(model); | 
|             } | 
|         }catch (Exception e){ | 
|             logger.error("------------浏览失败---------------"+e.getMessage()); | 
|         } | 
|     } | 
|     /** | 
|      * 工单及相应计划的数量统计 | 
|      * @param msg | 
|      */ | 
|     @RabbitListener(queues = Constants.RabbitMqQueue.QUEUE_STATISTIC) | 
|     public void receiveMsg2(String msg) { | 
|         System.out.println("工单及相应计划的数量统计:" + msg); | 
|         try { | 
|             Workorder model = JSONObject.toJavaObject(JSONObject.parseObject(msg),Workorder.class); | 
|             if(model != null && model.getId()!=null){ | 
|                 workorderExtService.statisticNum(model); | 
|             } | 
|         }catch (Exception e){ | 
|             logger.error("------------工单及相应计划的数量统计失败---------------"+e.getMessage()); | 
|         } | 
|     } | 
| } |