TransmissionLineInteractionController.java
4.3 KB
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
package com.huaheng.api.wcs.controller;
import com.huaheng.api.acs.service.AcsService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.agv.domain.AgvInventory;
import com.huaheng.pc.agv.domain.AgvPort;
import com.huaheng.pc.agv.domain.AgvTaskDetail;
import com.huaheng.pc.agv.domain.WorkStation;
import com.huaheng.pc.agv.service.*;
import com.huaheng.pc.config.container.service.ContainerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
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 java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/transmissionLine")
public class TransmissionLineInteractionController {
@Autowired
private AcsService acsService;
@Autowired
private IAgvPortService agvPortService;
@Autowired
private IAgvInventoryService agvInventoryService;
@Autowired
private IAgvTaskDetailService agvTaskDetailService;
@Autowired
private IWorkStationService workStationService;
@Autowired
private ContainerService containerService;
@PostMapping("/getContainerCode")
@ApiLogger(apiName = "wcs输送线交互点位请求托盘", from = "wcs", to = "wms")
public AjaxResult wcsGetContainerCode(@RequestBody Map map) {
String wcsLinePort = (String)map.get("port");
if (StringUtils.isEmpty(wcsLinePort)) {
return AjaxResult.error("port不能为空");
}
AgvPort agvPort = agvPortService.getByWcsLinePort(wcsLinePort);
if (agvPort == null) {
return AjaxResult.error("没有找到:" + wcsLinePort + " 对应的agv点位");
}
String code = agvPort.getCode();
String containerCode = agvPort.getContainerCode();
if (StringUtils.isEmpty(containerCode)) {
return AjaxResult.error("位置{},无容器号!", code);
}
agvPortService.clearContainerCodeByCode(code);
agvInventoryService.removeByPortCode(code);
containerService.updateSetLocationNullByCode(containerCode, QuantityConstant.STATUS_POSITION_EMPTY);
return AjaxResult.success("成功").setData(containerCode);
}
@PostMapping("/setContainerCode")
@ApiLogger(apiName = "wcs输送线交互点位托盘到达", from = "wcs", to = "wms")
@Transactional(rollbackFor = Exception.class)
public AjaxResult wcsSetContainerCode(@RequestBody Map map) {
String wcsLinePort = (String)map.get("port");
if (StringUtils.isEmpty(wcsLinePort)) {
return AjaxResult.error("port不能为空");
}
AgvPort agvPort = agvPortService.getByWcsLinePort(wcsLinePort);
if (agvPort == null) {
return AjaxResult.error("没有找到:" + wcsLinePort + " 对应的agv点位");
}
String containerCode = (String)map.get("containerCode");
if (StringUtils.isEmpty(containerCode)) {
return AjaxResult.error("containerCode不能为空");
}
List<AgvTaskDetail> list = agvTaskDetailService.getListByContainer(containerCode);
agvPort.setContainerCode(containerCode);
agvPortService.updateById(agvPort);
if (list != null) {
List<AgvInventory> agvInvs = new ArrayList<>();
list.forEach(it -> {
AgvInventory inv = new AgvInventory();
inv.setQty(it.getQty().longValue());
inv.setStatus("empty");
inv.setContainerCode(containerCode);
inv.setMaterialCode(it.getMaterialCode());
inv.setMaterialName(it.getMaterialName());
inv.setAgvPortCode(agvPort.getCode());
inv.setAgvPortId(agvPort.getId());
inv.setWorkStationId(agvPort.getWorkStationId());
agvInvs.add(inv);
});
agvInventoryService.saveBatch(agvInvs);
}
return AjaxResult.success("接收到了");
}
}