| 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.entity.DeviceType; | 
| 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.thread.LiftThread; | 
| import com.zy.asrs.wcs.system.controller.BaseController; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.web.bind.annotation.GetMapping; | 
| import org.springframework.web.bind.annotation.PathVariable; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.RestController; | 
|   | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| @RestController | 
| @RequestMapping("/api") | 
| public class LiftController extends BaseController { | 
|   | 
|     @Autowired | 
|     private DeviceService deviceService; | 
|   | 
|     @GetMapping("/lift/status/list") | 
|     public R getLiftStatusList() { | 
|         ArrayList<LiftProtocol> data = new ArrayList<>(); | 
|         List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() | 
|                 .eq(Device::getHostId, getHostId()) | 
|                 .eq(Device::getStatus, 1) | 
|                 .eq(Device::getDeviceType, DeviceCtgType.LIFT.val())); | 
|         for (Device device : list) { | 
|             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); | 
|             LiftProtocol status = liftThread.getStatus(); | 
|             data.add(status); | 
|         } | 
|         return R.ok().add(data); | 
|     } | 
|   | 
|     @GetMapping("/lift/status/one/{deviceNo}") | 
|     public R getLiftStatus(@PathVariable String deviceNo) { | 
|         Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() | 
|                 .eq(Device::getHostId, getHostId()) | 
|                 .eq(Device::getStatus, 1) | 
|                 .eq(Device::getDeviceType, DeviceCtgType.LIFT.val()) | 
|                 .eq(Device::getDeviceNo, deviceNo)); | 
|   | 
|         LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); | 
|         LiftProtocol status = liftThread.getStatus(); | 
|         return R.ok().add(status); | 
|     } | 
|   | 
| } |