zjj
9 天以前 e29a9f245ff4e57a40bbab1c0acc3cbc31d3ac2b
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
package com.zy.asrs.wcs.rcs.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.R;
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.ShuttleProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.service.ShuttleService;
import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
import com.zy.asrs.wcs.system.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
 
@RestController
@RequestMapping("/api")
public class ShuttleController extends BaseController {
 
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private ShuttleService shuttleService;
 
    @GetMapping("/shuttle/status/list")
    public R getShuttleStatusList() {
        List<ShuttleProtocol> data = shuttleService.getShuttleStatusList(getHostId());
        return R.ok().add(data);
    }
 
    @GetMapping("/shuttle/status/one/{deviceNo}")
    public R getShuttleStatus(@PathVariable String deviceNo) {
        Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
                .eq(Device::getHostId, getHostId())
                .eq(Device::getStatus, 1)
                .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())
                .eq(Device::getDeviceNo, deviceNo));
 
        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
        ShuttleProtocol status = shuttleThread.getStatus();
        return R.ok().add(status);
    }
 
}