zhangback
5 天以前 3974fad5d836431e417e99220cc07bb5b0aba331
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
package com.ruoyi.tms.consumer;
 
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.tms.domain.TmsCarKeyDispatch;
import com.ruoyi.tms.mapper.TmsCarKeyDispatchMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
@Slf4j
@Component
public class CarKeyExpireConsumer {
 
    @Resource
    private TmsCarKeyDispatchMapper tmsCarKeyDispatchMapper;
 
    @RabbitListener(queues = "car_key_dead_queue")
    public void handle(Integer carKeyId) {
 
        TmsCarKeyDispatch tmsCarKeyDispatch = tmsCarKeyDispatchMapper.selectTmsCarKeyDispatchById(carKeyId);
        if (tmsCarKeyDispatch != null && tmsCarKeyDispatch.getStatus() == 0){
            log.info("超时领取钥匙:{}", carKeyId);
            tmsCarKeyDispatchMapper.update(new LambdaUpdateWrapper<TmsCarKeyDispatch>()
                    .eq(TmsCarKeyDispatch::getId, carKeyId)
                    .set(TmsCarKeyDispatch::getStatus, 2)
            );
        }
    }
}