TaskConfirm.java
5.15 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.huaheng.api.acs.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.acs.domain.AgvTask;
import com.huaheng.api.acs.service.AcsService;
import com.huaheng.api.wcs.domain.ManyEmptyDomain;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.ShipmentTaskService;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/ACS/v1")
@Api(tags = {"ACS任务回传接口"}, value = "ACS任务回传接口")
public class TaskConfirm extends BaseController {
@Resource
private AcsService acsService;
@Resource
private ContainerService containerService;
@Resource
private InventoryDetailService inventoryDetailService;
@Resource
private ShipmentTaskService shipmentTaskService;
@Resource
private TaskHeaderService taskHeaderService;
/**
* AGV 任务回传
*/
// @RequiresPermissions("api:acs:TaskConfirm")
@Log(title = "AGV 任务回传", action = BusinessType.UPDATE)
@PostMapping("/TaskConfirm")
@ApiOperation("AGV 任务回传接口")
@ResponseBody
@ApiLogger(apiName = "AGV任务回传", from="ACS")
public AjaxResult TaskConfirm(@RequestBody AgvTask model)
{
return acsService.TaskConfirm(model);
}
@Log(title = "AGV 呼叫空托盘出库", action = BusinessType.UPDATE)
@PostMapping("/callEmptyContainerShipment")
@ApiOperation("AGV 呼叫空托盘出库")
@ResponseBody
@ApiLogger(apiName = "呼叫空托盘出库", from="ACS")
public AjaxResult callEmptyContainerShipment(@RequestBody ManyEmptyDomain domain)
{
return AjaxResult.success();
}
/**
* agv出库
*/
@PostMapping("/agvShipment")
@ApiOperation("agv出库")
@ResponseBody
@ApiLogger(apiName = "agv出库", from="ROBOT")
public AjaxResult agvShipment (@RequestBody Map<String,Object> map) {
String area = String.valueOf( (Integer) map.get("area"));
List<String> containerCodeList = (List<String>) map.get("containerCodeList");
// String taskIndex = (String) map.get("taskIndex");
if(containerCodeList == null) {
return AjaxResult.error("没有containerCodeList");
}
if(area == null) {
return AjaxResult.error("没有area");
}
// if(taskIndex == null) {
// return AjaxResult.error("没有taskIndex");
// }
AjaxResult ajaxResult = null;
int areaInt = Integer.parseInt(area);
if(areaInt != 4) {
return AjaxResult.error("AGV只有4号区");
}
String stationCode = "P1001";
for(String containerCode : containerCodeList) {
String warehouseCode = QuantityConstant.DEFAULT_WAREHOUSE;
Container container = containerService.getContainerByCode(containerCode, warehouseCode);
String locationCode = container.getLocationCode();
String materialCode = null;
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getContainerCode, containerCode)
.eq(InventoryDetail::getTaskQty, 0);
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
if (inventoryDetailList != null && inventoryDetailList.size() > 0) {
InventoryDetail inventoryDetail = inventoryDetailList.get(0);
materialCode = inventoryDetail.getMaterialCode();
} else {
return AjaxResult.error("没有找到库存");
}
ajaxResult = shipmentTaskService.createWholeShipmentTask(containerCode, locationCode, materialCode,
warehouseCode, stationCode);
if (!ajaxResult.hasErr()) {
Integer taskId = (Integer) ajaxResult.getData();
TaskHeader taskHeader = taskHeaderService.getById(taskId);
if (taskHeader != null) {
// taskHeader.setTaskIndex(taskIndex);
}
taskHeaderService.updateById(taskHeader);
ajaxResult.setData("P1001");
}
}
return ajaxResult;
}
}