jiangping
2023-08-18 6c2d51a68d4dc59415d92fb8f60a16726d62951f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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());
        }
    }
}