MesController.java
4.12 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
package com.huaheng.api.mes.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.general.domain.ReceiptDomain;
import com.huaheng.api.general.domain.ShipmentDomain;
import com.huaheng.api.general.service.ReceiptApiService;
import com.huaheng.api.general.service.ShipmentApiService;
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.AgvPort;
import com.huaheng.pc.agv.service.IAgvPortService;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/MES")
public class MesController {
@Resource
private ReceiptApiService receiptApiService;
@Resource
private ShipmentApiService shipmentApiService;
@Resource
private IAgvPortService agvPortService;
@PostMapping("/receipt")
@ResponseBody
@ApiLogger(apiName = "mes生成入库单", from = "mes", to = "wms")
public AjaxResult receipt(@RequestBody ReceiptDomain receiptDomain) {
if (receiptDomain == null) {
return AjaxResult.error("没有传参");
}
if (receiptDomain.getReceiptHeader() == null) {
return AjaxResult.error("缺少主单据");
}
if (receiptDomain.getReceiptDetails() == null) {
return AjaxResult.error("缺少子单据");
}
receiptDomain.getReceiptHeader().setSourcePlatform("MES");
receiptDomain.getReceiptDetails().forEach(receiptDetail -> {
if (StringUtils.isEmpty(receiptDetail.getFromPort())) {
throw new RuntimeException("参数中没有起点位置");
}
if(StringUtils.isEmpty(receiptDetail.getContainerCode())){
throw new RuntimeException("参数中没有托盘号");
}
});
AjaxResult ajaxResult = receiptApiService.receipt(receiptDomain);
//生成AGV搬运任务 。。。。。。
return ajaxResult;
}
@PostMapping("/shipment")
@ResponseBody
@ApiLogger(apiName = "mes生成出库单", from = "mes", to = "wms")
public AjaxResult shipment(@RequestBody ShipmentDomain shipmentDomain) {
if (shipmentDomain == null) {
return AjaxResult.error("没有传参");
}
if (shipmentDomain.getShipmentHeader() == null) {
return AjaxResult.error("缺少主单据");
}
if (shipmentDomain.getShipmentDetails() == null) {
return AjaxResult.error("缺少子单据");
}
shipmentDomain.getShipmentHeader().setSourcePlatform("MES");
shipmentDomain.getShipmentDetails().forEach(shipmentDetail -> {
shipmentDetail.setSourcePlatform("MES");
shipmentDetail.setWarehouseCode(QuantityConstant.WAREHOUSECODE);
shipmentDetail.setCompanyCode(QuantityConstant.COMPANYCODE);
if (StringUtils.isEmpty(shipmentDetail.getToPort())) {
throw new RuntimeException("参数中没有终点位置");
}
});
AjaxResult ajaxResult = shipmentApiService.shipment(shipmentDomain);
//生成AGV搬运任务 。。。。。。
return ajaxResult;
}
@PostMapping("/searchStation")
@ResponseBody
@ApiLogger(apiName = "mes查询点位", from = "mes", to = "wms")
public List<Map<String, Object>> searchStation(){
LambdaQueryWrapper<AgvPort> agvPortLambdaQueryWrapper = Wrappers.lambdaQuery();
agvPortLambdaQueryWrapper.select(AgvPort::getCode,AgvPort::getName,AgvPort::getArea).eq(AgvPort::getType,1);
List<Map<String, Object>> maps = agvPortService.listMaps(agvPortLambdaQueryWrapper);
return maps;
}
}