Commit 330c060ad3b776a28487826b46c72ef50fb206fa
1 parent
13669fb0
新增去向分配
Showing
1 changed file
with
82 additions
and
3 deletions
src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
... | ... | @@ -115,6 +115,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
115 | 115 | taskDetailLambda.eq(TaskDetail::getTaskId, wcsTask.getTaskNo()); |
116 | 116 | List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailLambda); |
117 | 117 | |
118 | + /* 循环查询入库组盘明细*/ | |
118 | 119 | List<ReceiptContainerDetail> receiptContainerDetailList = new ArrayList<>(); |
119 | 120 | for (TaskDetail taskDetail : taskDetailList) { |
120 | 121 | receiptContainerDetailList.add(receiptContainerDetailService.getById(taskDetail.getAllocationId())); |
... | ... | @@ -122,6 +123,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
122 | 123 | //去重 |
123 | 124 | receiptContainerDetailList = receiptContainerDetailList.stream().distinct().collect(Collectors.toList()); |
124 | 125 | |
126 | + /* 循环入库组盘明细,重新分配库位*/ | |
125 | 127 | for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetailList) { |
126 | 128 | ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(receiptContainerDetail.getReceiptContainerId()); |
127 | 129 | |
... | ... | @@ -164,7 +166,6 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
164 | 166 | receiptContainerDetail2.setLocationCode(locationCode); |
165 | 167 | if (!receiptContainerDetailService.updateById(receiptContainerDetail2)){throw new ServiceException("更新库位编码到入库组盘明细");} |
166 | 168 | } |
167 | - | |
168 | 169 | } |
169 | 170 | |
170 | 171 | if (StringUtils.isNotEmpty(locationCode)){ |
... | ... | @@ -251,10 +252,88 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
251 | 252 | } |
252 | 253 | |
253 | 254 | |
254 | - ////去向分配 | |
255 | + /** | |
256 | + * 去向分配 | |
257 | + */ | |
255 | 258 | @Override |
256 | 259 | public AjaxResult destinationAllocation(WcsTask wcsTask) { |
257 | 260 | |
258 | - return null; | |
261 | + //1、判断非空字段 | |
262 | + if(StringUtils.isEmpty(wcsTask.getTaskNo())){ | |
263 | + return AjaxResult.error("任务号为空"); | |
264 | + } | |
265 | + if(StringUtils.isNull(wcsTask.getLength())){ | |
266 | + return AjaxResult.error("长为空"); | |
267 | + } | |
268 | + if(StringUtils.isNull(wcsTask.getWidth())){ | |
269 | + return AjaxResult.error("宽为空"); | |
270 | + } | |
271 | + if(StringUtils.isNull(wcsTask.getHeight())){ | |
272 | + return AjaxResult.error("高为空"); | |
273 | + } | |
274 | + if(StringUtils.isNull(wcsTask.getWeight())){ | |
275 | + return AjaxResult.error("重为空"); | |
276 | + } | |
277 | + | |
278 | + //查询满足条件的库位类型 | |
279 | + LambdaQueryWrapper<LocationType> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
280 | + lambdaQueryWrapper.gt(LocationType::getLength,wcsTask.getLength()) | |
281 | + .gt(LocationType::getWidth, wcsTask.getWidth()) | |
282 | + .gt(LocationType::getHeight, wcsTask.getHeight()) | |
283 | + .gt(LocationType::getMaxWeight, wcsTask.getWidth()); | |
284 | + List<LocationType> locationTypeList = locationTypeService.list(lambdaQueryWrapper); | |
285 | + | |
286 | + if (locationTypeList.isEmpty()){ | |
287 | + return AjaxResult.error("没有区域可分配"); | |
288 | + } | |
289 | + List<String> codeList = new ArrayList<>(); | |
290 | + for (LocationType locationType: locationTypeList) { | |
291 | + codeList.add(locationType.getCode()); | |
292 | + } | |
293 | + | |
294 | + //定位库位List | |
295 | + List<String> positioningLocationCodeList = null; | |
296 | + //查询任务明细 | |
297 | + LambdaQueryWrapper<TaskDetail> taskDetailLambda = Wrappers.lambdaQuery(); | |
298 | + taskDetailLambda.eq(TaskDetail::getTaskId, wcsTask.getTaskNo()); | |
299 | + List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailLambda); | |
300 | + | |
301 | + /* 循环查询入库组盘明细*/ | |
302 | + List<ReceiptContainerDetail> receiptContainerDetailList = new ArrayList<>(); | |
303 | + for (TaskDetail taskDetail : taskDetailList) { | |
304 | + receiptContainerDetailList.add(receiptContainerDetailService.getById(taskDetail.getAllocationId())); | |
305 | + } | |
306 | + //去重 | |
307 | + receiptContainerDetailList = receiptContainerDetailList.stream().distinct().collect(Collectors.toList()); | |
308 | + | |
309 | + for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetailList) { | |
310 | + String locatingRule = this.taskPositioning(receiptContainerDetail); | |
311 | + | |
312 | + LambdaQueryWrapper<FilterConfigDetail> filterConfigDetailLambda = Wrappers.lambdaQuery(); | |
313 | + filterConfigDetailLambda.eq(FilterConfigDetail::getCode, locatingRule) | |
314 | + .eq(FilterConfigDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
315 | + FilterConfigDetail filterConfigDetail = filterConfigDetailService.getOne(filterConfigDetailLambda); | |
316 | + String[] locatingRules = filterConfigDetail.getStatement().split("limit"); | |
317 | + | |
318 | + //根据定位规则查询库位编码 | |
319 | + LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery(); | |
320 | + locationLambda.last(locatingRules[0]); | |
321 | + List<Location> locationList = locationService.list(locationLambda); | |
322 | + List<String> locationCodeList = locationTypeList.stream().map(t-> t.getCode()).collect(Collectors.toList()); | |
323 | + List<Location> newLocation = locationList.stream().filter(t-> locationCodeList.contains(t.getLocationType())).collect(Collectors.toList()); | |
324 | + if (!newLocation.isEmpty()){ | |
325 | + positioningLocationCodeList.add(newLocation.get(0).getCode()); | |
326 | + } | |
327 | + | |
328 | + if (StringUtils.isEmpty(positioningLocationCodeList)){ | |
329 | + throw new ServiceException("没有区域可分配"); | |
330 | + } | |
331 | + } | |
332 | + | |
333 | + LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
334 | + locationLambdaQueryWrapper.eq(Location::getCode, positioningLocationCodeList.get(0)); | |
335 | + Location location = locationService.getOne(locationLambdaQueryWrapper); | |
336 | + String destinationArea = location.getRoadway(); | |
337 | + return AjaxResult.success(destinationArea); | |
259 | 338 | } |
260 | 339 | } |
261 | 340 | \ No newline at end of file |
... | ... |