MesController.java
10.4 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
package com.huaheng.api.mes.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.api.mes.domain.InventoryDetailQuery;
import com.huaheng.api.mes.domain.MaterialQuery;
import com.huaheng.api.mes.domain.MesTask;
import com.huaheng.api.mes.domain.TaskHeaderQuery;
import com.huaheng.api.mes.service.MesService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.aspectj.bridge.ISourceLocation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* mes下发任务接口
* @author xcq
*/
@RestController
@RequestMapping("/api/mes")
@Api(tags = {"MES下发任务接口"}, value = "MES下发任务接口")
public class MesController extends BaseController {
@Resource
private MesService mesService;
@Resource
private MaterialService materialService;
@Resource
private LocationService locationService;
@Resource
private ContainerService containerService;
@ApiOperation(value = "mes任务创建", httpMethod = "POST")
@PostMapping("/createTask")
@ResponseBody
@ApiLogger(apiName = "mes任务创建", from="MES")
public AjaxResult createTask(@RequestBody MesTask mesTask){
return mesService.createTaskService(mesTask);
}
@ApiOperation(value = "空料框处理", httpMethod = "POST")
@PostMapping("/emptyContainerHandle")
@ResponseBody
public AjaxResult emptyContainerHandle(@RequestBody MesTask mesTask){
return mesService.emptyContainerHandleService(mesTask);
}
@ApiOperation(value = "初始化货架点位", httpMethod = "POST")
@PostMapping("/initialLocation")
@ResponseBody
public AjaxResult initialLocation(@RequestBody MesTask mesTask){
return mesService.initialLocationService(mesTask);
}
@ApiOperation(value = "机加库获取物料信息", httpMethod = "POST")
@PostMapping("/getMaterialByMES")
@ResponseBody
public AjaxResult getMaterialByMES(@RequestBody MesTask mesTask) {
return mesService.getMaterialByMES(mesTask);
}
@ApiOperation(value = "常规点位初始化", httpMethod = "POST")
@PostMapping("/routineInitialLocation")
@ResponseBody
public AjaxResult routineInitialLocation(@RequestBody MesTask mesTask){
return mesService.routineInitialLocationService(mesTask);
}
@ApiOperation(value = "解绑库位", httpMethod = "POST")
@PostMapping("/locationUntie")
@ResponseBody
public AjaxResult locationUntie(@RequestBody MesTask mesTask){
return mesService.untieLocationService(mesTask);
}
@ApiOperation(value = "取消任务", httpMethod = "POST")
@PostMapping("/cancelACSTask")
@ResponseBody
public AjaxResult cancelACSTask(@RequestBody Integer id){
return mesService.cancelACSTaskService(id);
}
@ApiOperation(value = "任务查看", httpMethod = "POST")
@PostMapping("/getTaskList")
@ResponseBody
public TableDataInfo getTaskList(@RequestBody TaskHeaderQuery taskHeaderQuery){
return mesService.getTaskListService(taskHeaderQuery);
}
@ApiOperation(value = "库存查看", httpMethod = "POST")
@PostMapping("/getInventoryList")
@ResponseBody
@ApiLogger(apiName = "库存查看", from="MES")
public TableDataInfo getInventoryList(@RequestBody InventoryDetailQuery inventoryDetailQuery){
return mesService.getInventoryListService(inventoryDetailQuery);
}
@ApiOperation(value = "区域同步", httpMethod = "POST")
@PostMapping("/zoneSync")
@ResponseBody
@ApiLogger(apiName = "区域同步", from="MES")
public AjaxResult zoneSync(@RequestBody List<Zone> zones){
return mesService.zoneSyncService(zones);
}
@ApiOperation(value = "点位到点位任务创建", httpMethod = "POST")
@PostMapping("/pointToPoint")
@ResponseBody
@ApiLogger(apiName = "点位到点位任务创建", from="MES")
public AjaxResult pointToPoint(@RequestBody MesTask mesTask){
return mesService.pointToPointService(mesTask);
}
/**
* 获取光腾物料
* @return
*/
@PostMapping("/getGTMaterial")
@ResponseBody
public TableDataInfo getGTMaterial(@RequestBody MaterialQuery materialQuery){
LambdaQueryWrapper<Material> queryWrapper = Wrappers.lambdaQueryNoWarehouse();
queryWrapper.eq(Material::getWarehouseCode, QuantityConstant.WAREHOUSE_KS)
.eq(Material::getCompanyCode, QuantityConstant.COMPANY_GT)
.like(StringUtils.isNotEmpty(materialQuery.getCode()),Material::getCode, materialQuery.getCode())
.like(StringUtils.isNotEmpty(materialQuery.getName()),Material::getName, materialQuery.getName())
.select(Material::getCode, Material::getName,Material::getSpec, Material::getUnit);
if (StringUtils.isNotNull(materialQuery.getPageNum()) && StringUtils.isNotNull(materialQuery.getPageSize())){
// 分页查询
Page<Material> page = new Page<>(materialQuery.getPageNum(), materialQuery.getPageSize());
IPage<Material> iPage = materialService.page(page, queryWrapper);
return getMpDataTable(iPage.getRecords(), iPage.getTotal());
}else {
List<Material> list = materialService.list(queryWrapper);
return getDataTable(list);
}
}
/**
* 区域移动
* @return
*/
@PostMapping("/regionalMove")
@ResponseBody
@ApiLogger(apiName = "区域移动", from="MES")
public AjaxResult regionalMove(@RequestBody MesTask mesTask){
return mesService.regionalMoveService(mesTask);
}
/**
* PDA修改光腾点位状态
* @param location
* @return
*/
@PostMapping("/updateLocationStatus")
@ResponseBody
@ApiLogger(apiName = "修改光腾点位状态", from="PDA")
public AjaxResult updateLocationStatus(@RequestBody Location location){
return mesService.updateLocationStatusService(location);
}
/**
* PDA点位转换成空料框
* @param location
* @return
*/
@PostMapping("/locationConvert")
@ResponseBody
@ApiLogger(apiName = "PDA点位转换", from="PDA")
public AjaxResult locationConvert(@RequestBody Location location){
return mesService.locationConvertService(location);
}
/**
* PDA获取点位信息
* @param location
* @return
*/
@PostMapping("/getLocation")
@ResponseBody
@ApiLogger(apiName = "PDA获取点位信息", from="PDA")
public AjaxResult getLocation(@RequestBody Location location){
LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper
.eq(Location::getZoneCode, QuantityConstant.GT_RECEIPT_TYPE)
.eq(StringUtils.isNotEmpty(location.getCode()), Location::getCode, location.getCode())
.eq(StringUtils.isNotEmpty(location.getName()), Location::getName, location.getName())
.eq(StringUtils.isNotEmpty(location.getContainerCode()), Location::getContainerCode, location.getContainerCode())
.eq(StringUtils.isNotNull(location.getSystemCreated()), Location::getStatus, location.getStatus())
.eq(StringUtils.isNotNull(location.getIRow()), Location::getIRow, location.getIRow())
.eq(StringUtils.isNotNull(location.getIColumn()), Location::getIColumn, location.getIColumn())
.eq(StringUtils.isNotNull(location.getIGrid()), Location::getIGrid, location.getIGrid())
.eq(StringUtils.isNotNull(location.getILayer()), Location::getILayer, location.getILayer())
.eq(StringUtils.isNotEmpty(location.getStatus()), Location::getStatus, location.getStatus())
.eq(StringUtils.isNotEmpty(location.getLocationType()), Location::getLocationType, location.getLocationType())
.eq(Location::getDeleted, false)
.orderByDesc(Location::getId);
List<Location> locations = locationService.list(lambdaQueryWrapper);
if (locations == null ||locations.size() == 0){
return AjaxResult.success("点位信息为空!");
}
// 根据容器编码查询容器数据
List<String> containerCodes = locations.stream().map(Location::getContainerCode).collect(Collectors.toList());
LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
containerLambdaQueryWrapper.in(Container::getCode, containerCodes);
List<Container> containers = containerService.list(containerLambdaQueryWrapper);
// 将containers转换成map
Map<String, Container> containerMap = containers.stream().collect(Collectors.toMap(Container::getCode, container -> container));
locations.forEach(location1 -> {
if (containerMap.containsKey(location1.getContainerCode()) && containerMap.get(location1.getContainerCode()).getStatus() == QuantityConstant.STATUS_CONTAINER_SOME){
location1.setStatus(QuantityConstant.STATUS_CONTAINER_SOME);
}
});
AjaxResult result = AjaxResult.success("点位信息获取成功!");
result.setData(locations);
return result;
}
}