赵士淞
2023-05-09 b8441a1ac74d2c3325dd36d69ced511f19cd760b
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
package me.zhengjie.modules.attendance.rabbit;
 
import com.alibaba.fastjson.JSON;
import me.zhengjie.modules.attendance.domain.AttendanceLeave;
import me.zhengjie.modules.attendance.service.AttendanceLeaveService;
import me.zhengjie.modules.constant.Constant;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.Map;
 
@Component
@RabbitListener(queues = "attendance.attendanceLeaveApply")
public class AttendanceLeaveRabbit {
 
    @Autowired
    private AttendanceLeaveService attendanceLeaveService;
 
    @RabbitHandler
    public void process(Map<String, Object> message) throws Exception {
        // Map 转 实体类
        AttendanceLeave attendanceLeave = JSON.parseObject(JSON.toJSONString(message), AttendanceLeave.class);
        attendanceLeave.setApprovalStatus(Constant.APPROVAL_STATUS_PASSED);
        // 新增考勤请假
        attendanceLeaveService.flowableCreate(attendanceLeave);
    }
}