pjb
2025-03-13 19e6e3559842d23fc5bd4f28a688dd8c2c747d4b
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package com.zy.asrs.wms.apis.wcs.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wms.apis.wcs.entity.request.ContainerArrivedParam;
import com.zy.asrs.wms.apis.wcs.entity.request.RfidSingalRequest;
import com.zy.asrs.wms.apis.wcs.entity.request.TasksStatusCallbackParam;
import com.zy.asrs.wms.apis.wcs.services.WcsApiService;
import com.zy.asrs.wms.asrs.entity.CacheSite;
import com.zy.asrs.wms.asrs.entity.Task;
import com.zy.asrs.wms.asrs.entity.param.BindPlatformParam;
import com.zy.asrs.wms.asrs.service.CacheSiteService;
import com.zy.asrs.wms.asrs.service.PlatformService;
import com.zy.asrs.wms.asrs.service.TaskService;
import com.zy.asrs.wms.system.controller.BaseController;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;
 
@Slf4j
@RestController
@RequestMapping("/out/stock/")
public class OutStockController extends BaseController {
 
    @Autowired
    private WcsApiService wcsApiService;
 
    @Autowired
    private PlatformService platformService;
 
    @Resource
    private CacheSiteService cacheSiteService;
 
    @Resource
    private TaskService taskService;
 
 
    /**
     * 出库任务-接收回调状态接口
     * @param callbackParam
     * @return
     */
    @PostMapping("/receive/tasks/status")
    public R receiveTaskStatus(@RequestBody TasksStatusCallbackParam callbackParam) {
        if (!StringUtil.isNullOrEmpty(callbackParam.getEventType())) {
            if (StringUtil.isNullOrEmpty(callbackParam.getContainerCode())) {
                return R.error("容器编码不能为空!!");
            }
            if (StringUtil.isNullOrEmpty(callbackParam.getTaskCode())) {
                return R.error("任务编码不能为空!!");
            }
            wcsApiService.receiveTaskStatus(callbackParam, "outStock", getHostId());
        } else {
            return R.error("上报事件类型不能为空!!");
        }
 
        return R.success();
    }
 
    /***
     * 容器到达接收
     * @param arrivedParam
     * @return
     */
    @PostMapping("/container/arrived")
    public R containerArrivedNotify(@RequestBody ContainerArrivedParam arrivedParam) {
 
        if (StringUtil.isNullOrEmpty(arrivedParam.getContainerCode())) {
            return R.error("容器编码不能为空!!");
        }
        if (StringUtil.isNullOrEmpty(arrivedParam.getSlotCode())) {
            return R.error("输送线节点编码不能为空!!");
        }
 
        return wcsApiService.containerArrivedNotify(arrivedParam, "outStock", getHostId());
 
    }
 
    /**
     * 播种墙拍灯,ESS调用
     */
    @PostMapping("/light/off")
    public R lightOff(@RequestBody Map<String, Object> request) {
        if (Objects.isNull(request)) {
            throw new CoolException("参数不能为空!!");
        }
        if (Objects.isNull(request.get("tagCode"))) {
            throw new CoolException("电子标签编号不能为空!!");
        }
        if (Objects.isNull(request.get("eventCode"))){
            throw new CoolException("事件名称不能为空!!");
        }
 
        // 根据站点编码查播种站点信息
        CacheSite cacheSite = cacheSiteService.getOne(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getSiteNo, request.get("tagCode")));
        // 根据播种站点信息条码,查任务
        Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, cacheSite.getBarcode()));
 
        request.clear();
        request.put("taskNo", task.getTaskNo());
        request.put("orderNo",cacheSite.getOrderNo());
 
        wcsApiService.slapLightLogic(request);
 
        return R.ok();
    }
 
    /**
     * 容器流动通知(当前物料播种完成)
     * //fixme 此接口将不再单独调用
     * 1. 更新当前任务物料信息
     * 2.
     * @param code 容器编码
     * @return
     */
    @GetMapping("/container/converyor/{code}")
    public R containerConveyor(@PathVariable String code) {
        if (StringUtil.isNullOrEmpty(code)) {
            return R.error("容器编码不能为空!!!");
        }
        return wcsApiService.containerConveryor(code);
    }
 
 
    /**
     * 发送命令给电子标签,可以控制电子标签亮灯颜色及灭灯等。
     *
     * 1. 判断当前容器是否还有物料未拣,未拣完闪灯,拣完通知容器流动,并灭灯
     * 2. 容器流动判断,如果料箱没有物料 code传200, 有物料传100 执行回库任务, IOTYP = 4
     *
     * @param request
     * @return
     */
    @PostMapping("/slap/light")
    public R slapLightLogic(@RequestBody Map<String, Object> request) {
        if (Objects.isNull(request)) {
            throw new CoolException("参数不能为空!!");
        }
        if (Objects.isNull(request.get("taskNo"))) {
            throw new CoolException("任务号不能为空!!");
        }
        if (Objects.isNull(request.get("orderNo"))){
            throw new CoolException("当前任务订单号不能为空!!");
        }
 
         wcsApiService.slapLightLogic(request);
 
        return R.ok();
    }
 
 
 
    /**
     * 信号回传接口,回传电子标签状态变化内容给上游系统。
     * 当人为操作(比如拍灯,更改数字,放箱等)导致电子标签的状态和信号等发生变化、或设备本身发生异常时,ESS接收到信号后,通过该接口将信号回传给上游系统。
     * RFID回调接口
     * @param request
     * @return
     */
    @PostMapping("/")
    public R rfidCallback(@RequestBody RfidSingalRequest request) {
        if (Objects.isNull(request)) {
            throw new CoolException("参数不能为空!!");
        }
        return wcsApiService.rfidCallback(request);
    }
 
 
    /**
     * 获取所有集货区
     * @return
     */
    @GetMapping("/all/platforms")
    public R getPlatforms() {
        return  wcsApiService.getPlatforms();
    }
 
//    /**
//     * 绑定订单与集货区关系
//     * @param platform
//     * @return
//     */
//    @PostMapping("/bind/shipping/platform")
//    public R bindShippingAndPlatform(@RequestBody BindPlatformParam platform) {
//        return platformService.bindShippingPlatform(platform);
//    }
//
 
 
}