puzhibing
2023-06-30 f58cca364b731eac2d60a440ffaa804be3cd43fd
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
55
56
57
58
package com.stylefeng.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.modular.system.dao.TDriverMapper;
import com.stylefeng.guns.modular.system.enums.UserTypeEnum;
import com.stylefeng.guns.modular.system.model.TDriver;
import com.stylefeng.guns.modular.system.model.TSystemBulletin;
import com.stylefeng.guns.modular.system.dao.TSystemBulletinMapper;
import com.stylefeng.guns.modular.system.model.TSystemBulletinUser;
import com.stylefeng.guns.modular.system.service.ITSystemBulletinService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.service.ITSystemBulletinUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * <p>
 * 系统公告 服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2023-03-16
 */
@Service
public class TSystemBulletinServiceImpl extends ServiceImpl<TSystemBulletinMapper, TSystemBulletin> implements ITSystemBulletinService {
 
    @Autowired
    private ITSystemBulletinUserService tSystemBulletinUserService;
    @Autowired
    private TDriverMapper tDriverMapper;
 
    @Override
    public void sendBulletin(TSystemBulletin tSystemBulletin) {
        // 判断发送状态
        if(2 == tSystemBulletin.getState()){
            // 查找所有司机
            List<TDriver> list = tDriverMapper.selectList(new EntityWrapper<TDriver>()
                    .eq("approvalStatus",2)
                    .eq("status",1));
            List<TSystemBulletinUser> tSystemBulletinUsers = new ArrayList<>(list.size());
            for (TDriver tDriver : list) {
                TSystemBulletinUser tSystemBulletinUser = new TSystemBulletinUser();
                tSystemBulletinUser.setCreateTime(new Date());
                tSystemBulletinUser.setStatus(1);
                tSystemBulletinUser.setSystemBulletinId(tSystemBulletin.getId());
                tSystemBulletinUser.setUserId(tDriver.getId());
                tSystemBulletinUser.setUserType(UserTypeEnum.DRIVER.getCode());
                tSystemBulletinUser.setIsRead(0);
                tSystemBulletinUsers.add(tSystemBulletinUser);
            }
            tSystemBulletinUserService.insertBatch(tSystemBulletinUsers);
        }
    }
}