#
Junjie
2024-04-19 e222fba1a5aab1c9877667560629ae643133cb7d
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
package com.zy.asrs.wcs.rcs.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.service.LiftService;
import com.zy.asrs.wcs.rcs.thread.LiftThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Service("LiftService")
public class LiftServiceImpl implements LiftService {
 
    @Autowired
    private DeviceService deviceService;
 
    @Override
    public List<LiftProtocol> getLiftStatusList(Long hostId) {
        ArrayList<LiftProtocol> data = new ArrayList<>();
        List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>()
                .eq(Device::getHostId, hostId)
                .eq(Device::getStatus, 1)
                .eq(Device::getDeviceType, DeviceCtgType.LIFT.val()));
        for (Device device : list) {
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
            if (liftThread == null) {
                continue;
            }
            LiftProtocol status = liftThread.getStatus();
            data.add(status);
        }
        return data;
    }
}