#
Junjie
2025-11-27 9e715c16b49a066e627d150fb2d973a8562db8dc
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.zy.asrs.controller;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.service.BasDevpService;
import com.zy.core.model.StationObjModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.domain.param.StationCommandMoveParam;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.Task;
import com.zy.core.model.command.StationCommand;
import com.zy.core.thread.StationThread;
 
import java.util.List;
 
@RestController
@RequestMapping("/station")
public class StationController {
 
    @Autowired
    private BasDevpService basDevpService;
 
    @PostMapping("/command/move")
    public R commandMove(@RequestBody StationCommandMoveParam param) {
        if (Cools.isEmpty(param)) {
            return R.error("缺少参数");
        }
 
        Integer stationId = param.getStationId();
        Integer taskNo = param.getTaskNo();
        Integer targetStationId = param.getTargetStationId();
 
        StationObjModel finalStation = null;
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>());
        for (BasDevp basDevp : basDevps) {
            List<StationObjModel> list = basDevp.getStationList$();
            for (StationObjModel entity : list) {
                if(entity.getStationId().equals(stationId)){
                    finalStation = entity;
                    break;
                }
            }
 
            if(finalStation != null){
                break;
            }
        }
 
        if(finalStation == null){
            return R.error("站点不存在");
        }
 
        Integer devpNo = finalStation.getDeviceNo();
 
        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, devpNo);
        if (stationThread == null) {
            return R.error("线程不存在");
        }
 
        StationCommand command = stationThread.getMoveCommand(taskNo, stationId, targetStationId, 0);
        MessageQueue.offer(SlaveType.Devp, devpNo, new Task(2, command));
        return R.ok();
    }
 
}