Merge remote-tracking branch 'origin/test' into dev
This commit is contained in:
commit
ed00c8aa7f
@ -5,9 +5,9 @@ import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.draft.Lesson3DQueryVO;
|
||||
import club.joylink.rtss.vo.draft.Lesson3DVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/lesson3d")
|
||||
@ -21,4 +21,33 @@ public class Lesson3dController {
|
||||
return this.lesson3DService.pagingQuery(queryVO);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<Lesson3DVO> queryListBy(Lesson3DQueryVO queryVO) {
|
||||
return this.lesson3DService.queryBy(queryVO);
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{id}")
|
||||
public Lesson3DVO getById(@PathVariable Long id) {
|
||||
Lesson3DVO param = this.lesson3DService.getById(id);
|
||||
return param;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上线
|
||||
* @param id
|
||||
*/
|
||||
@PutMapping("/{id}/online")
|
||||
public void online(@PathVariable Long id) {
|
||||
this.lesson3DService.online(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下线
|
||||
* @param id
|
||||
*/
|
||||
@PutMapping("/{id}/offline")
|
||||
public void offline(@PathVariable Long id) {
|
||||
this.lesson3DService.offline(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,8 +4,18 @@ import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.draft.Lesson3DQueryVO;
|
||||
import club.joylink.rtss.vo.draft.Lesson3DVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Lesson3DService {
|
||||
void publish(Lesson3DVO vo);
|
||||
|
||||
PageVO<Lesson3DVO> pagingQuery(Lesson3DQueryVO queryVO);
|
||||
|
||||
List<Lesson3DVO> queryBy(Lesson3DQueryVO queryVO);
|
||||
|
||||
Lesson3DVO getById(Long id);
|
||||
|
||||
void online(Long id);
|
||||
|
||||
void offline(Long id);
|
||||
}
|
||||
|
@ -44,16 +44,65 @@ public class Lesson3DServiceImpl implements Lesson3DService {
|
||||
|
||||
@Override
|
||||
public PageVO<Lesson3DVO> pagingQuery(Lesson3DQueryVO queryVO) {
|
||||
Lesson3dExample example = this.buildExampleByQueryVo(queryVO);
|
||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
Page<Lesson3d> lesson3ds = (Page<Lesson3d>) this.lesson3dDAO.selectByExample(example);
|
||||
return PageVO.convert(lesson3ds, Lesson3DVO.convertPublish2VOList(lesson3ds.getResult()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Lesson3DVO> queryBy(Lesson3DQueryVO queryVO) {
|
||||
Lesson3dExample example = this.buildExampleByQueryVo(queryVO);
|
||||
example.getOredCriteria().get(0).andStateEqualTo(StatusEnum.Valid.getCode());
|
||||
List<Lesson3d> lesson3ds = this.lesson3dDAO.selectByExample(example);
|
||||
return Lesson3DVO.convertPublish2VOList(lesson3ds);
|
||||
}
|
||||
|
||||
private Lesson3dExample buildExampleByQueryVo(Lesson3DQueryVO queryVO) {
|
||||
Lesson3dExample example = new Lesson3dExample();
|
||||
Lesson3dExample.Criteria criteria = example.createCriteria().andStateEqualTo(StatusEnum.Valid.getCode());
|
||||
Lesson3dExample.Criteria criteria = example.createCriteria();
|
||||
if (StringUtils.hasText(queryVO.getName())) {
|
||||
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
|
||||
}
|
||||
if (StringUtils.hasText(queryVO.getType())) {
|
||||
criteria.andTypeLike(String.format("%%%s%%", queryVO.getType()));
|
||||
}
|
||||
Page<Lesson3d> lesson3ds = (Page<Lesson3d>) this.lesson3dDAO.selectByExample(example);
|
||||
return PageVO.convert(lesson3ds, Lesson3DVO.convertPublish2VOList(lesson3ds.getResult()));
|
||||
return example;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lesson3DVO getById(Long id) {
|
||||
Lesson3d lesson3d = this.lesson3dDAO.selectByPrimaryKey(id);
|
||||
return new Lesson3DVO(lesson3d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void online(Long id) {
|
||||
Lesson3dExample example = new Lesson3dExample();
|
||||
example.createCriteria()
|
||||
.andIdEqualTo(id);
|
||||
List<Lesson3d> list = this.lesson3dDAO.selectByExample(example);
|
||||
if (!list.isEmpty()) {
|
||||
Lesson3d lesson3d = list.get(0);
|
||||
if (!StatusEnum.Valid.getCode().equals(lesson3d.getState())) {
|
||||
lesson3d.setState(StatusEnum.Valid.getCode());
|
||||
this.lesson3dDAO.updateByPrimaryKey(lesson3d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offline(Long id) {
|
||||
Lesson3dExample example = new Lesson3dExample();
|
||||
example.createCriteria()
|
||||
.andIdEqualTo(id);
|
||||
List<Lesson3d> list = this.lesson3dDAO.selectByExample(example);
|
||||
if (!list.isEmpty()) {
|
||||
Lesson3d lesson3d = list.get(0);
|
||||
if (!StatusEnum.Invalid.getCode().equals(lesson3d.getState())) {
|
||||
lesson3d.setState(StatusEnum.Invalid.getCode());
|
||||
this.lesson3dDAO.updateByPrimaryKey(lesson3d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +87,10 @@ public class SimulationRealDeviceThread {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取真实设备数据
|
||||
* @param simulation
|
||||
*/
|
||||
public void queryDeviceStatus(Simulation simulation) {
|
||||
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
|
||||
if (Objects.isNull(plcGateway)) {
|
||||
@ -104,6 +108,10 @@ public class SimulationRealDeviceThread {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据获取到的真实设备状态更新仿真设备状态
|
||||
* @param simulation
|
||||
*/
|
||||
public void UpdateDeviceStatusByCollection(Simulation simulation) {
|
||||
Queue<DeviceQueryFuture> futureQueue = simulation.getDeviceQueryFutureQueue();
|
||||
DeviceQueryFuture deviceQueryFuture = futureQueue.peek();
|
||||
|
@ -35,6 +35,10 @@ public class TCPServer2 implements ApplicationRunner {
|
||||
this.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 真实设备(屏蔽门、道岔、信号机等)连接服务启动
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void start() throws InterruptedException {
|
||||
EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
|
@ -68,6 +68,7 @@ public class Lesson3DVO {
|
||||
this.id = lesson.getId();
|
||||
this.name = lesson.getName();
|
||||
this.type = lesson.getType();
|
||||
this.data = lesson.getData();
|
||||
this.state = lesson.getState();
|
||||
this.userId = lesson.getUserId();
|
||||
this.createTime = lesson.getCreateTime();
|
||||
|
Loading…
Reference in New Issue
Block a user