|
1
2
3
|
package com.huaheng.pc.config.location.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
5
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
6
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
7
|
import com.huaheng.common.utils.Wrappers;
|
|
8
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
9
|
import com.huaheng.common.constant.QuantityConstant;
|
|
10
11
12
13
|
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
|
|
14
|
import com.huaheng.pc.config.location.domain.Location;
|
|
15
|
import com.huaheng.pc.config.location.domain.LocationInfo;
|
|
16
|
import com.huaheng.pc.config.location.mapper.LocationMapper;
|
|
17
18
|
import com.huaheng.pc.config.locationType.domain.LocationType;
import com.huaheng.pc.config.locationType.service.LocationTypeService;
|
|
19
|
import com.huaheng.pc.config.points.domain.Points;
|
|
20
21
|
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.service.ZoneService;
|
|
22
|
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
|
|
23
|
import org.springframework.stereotype.Service;
|
|
24
|
|
|
25
26
|
import javax.annotation.Resource;
import java.text.MessageFormat;
|
|
27
|
import java.util.*;
|
|
28
|
import java.util.stream.Collectors;
|
|
29
30
|
@Service("LocationService")
|
|
31
|
public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> implements LocationService {
|
|
32
33
34
35
36
37
38
39
40
|
@Resource
private LocationService locationService;
@Resource
private LocationTypeService locationTypeService;
@Resource
private ZoneService zoneService;
@Resource
private LocationMapper locationMapper;
|
|
41
42
|
@Resource
private TaskHeaderService taskHeaderService;
|
|
43
|
|
huhai
authored
|
44
45
46
47
|
/**
* //新增库位,需要建立code,并判断是否重复
* 1. 库区和库位没有绝对关系。 先建立库区,然后在库区的位置进行建立库位类型。
* TODO:胡海--在判断库位类型和库区是否匹配,应该用库位类型表进行判断。库位类型在库区存在即可
|
|
48
|
*
|
huhai
authored
|
49
50
51
|
* @param location
* @return
*/
|
|
52
|
@Override
|
|
53
|
public AjaxResult addsave(Location location) {
|
|
54
55
|
//库区与库位类型的匹配判断
|
|
56
57
|
if (!location.getZoneCode().equals(location.getLocationType())) {
throw new ServiceException(location.getLocationType() + "的库位类型与" + location.getZoneCode() + "库区不匹配");
|
|
58
|
}
|
|
59
|
//TODO:胡海-- 库位编码长度应该是弹性的,即我们的库位是由4个维度组成的,正常情况下 平库(行列) 立体仓库(行列层) AGV料架库(行列层格)
|
huhai
authored
|
60
|
// 这里可以判断下 然后决定库位编码长度。
|
|
61
|
//创建库位编码code
|
|
62
63
|
String prefix = location.getLocationType();
String code = MessageFormat.format("{0}{1}_{2}_{3}",
|
|
64
65
66
|
prefix,
String.format("%02d", location.getIRow()),
String.format("%02d", location.getIColumn()),
|
|
67
|
String.format("%02d", location.getILayer()));
|
|
68
69
70
|
//判断code是否重复
LambdaQueryWrapper<Location> lam = Wrappers.lambdaQuery();
|
|
71
72
73
|
lam.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(Location::getCode, code);
if (this.getOne(lam) != null) {
|
|
74
75
76
77
78
79
80
|
return AjaxResult.error("该位置已有库位生成,请重新输入位置");
}
//插入数据库
location.setCode(code);
location.setWarehouseCode(ShiroUtils.getWarehouseCode());
location.setCreatedBy(ShiroUtils.getLoginName());
|
|
81
82
|
Boolean flag = this.save(location);
if (flag == false) {
|
|
83
84
85
86
87
88
89
|
return AjaxResult.error("新增库位失败,插入数据库时失败");
}
return AjaxResult.success("新增库位成功");
}
/**
* 批量新增库位
|
|
90
|
*
|
|
91
92
93
94
95
96
97
|
* @param location
* @return boolean
*/
@Override
public boolean insertLocation(Location location) {
/* 判断库位类型编码是否存在*/
LambdaQueryWrapper<LocationType> typeLambda = Wrappers.lambdaQuery();
|
|
98
99
|
typeLambda.eq(LocationType::getCode, location.getLocationType())
.select(LocationType::getCode);
|
|
100
|
List<Map<String, Object>> list = locationTypeService.listMaps(typeLambda);
|
|
101
|
if (list.size() < 1) {
|
|
102
103
104
105
|
throw new ServiceException("库位类型编码不存在");
}
/* 判断库区编码是否存在*/
|
|
106
|
LambdaQueryWrapper<Zone> zoneLambda = Wrappers.lambdaQuery();
|
|
107
108
109
110
|
zoneLambda.eq(Zone::getCode, location.getZoneCode())
.select(Zone::getCode);
list = zoneService.listMaps(zoneLambda);
|
|
111
|
if (list.size() < 1) {
|
|
112
113
|
throw new ServiceException("库区编码不存在");
}
|
huhai
authored
|
114
|
//TODO:胡海--在判断库位类型和库区是否匹配,应该用库位类型表进行判断。库位类型在库区存在即可
|
|
115
116
|
if (!location.getZoneCode().equals(location.getLocationType())) {
throw new ServiceException(location.getLocationType() + "的库位类型与" + location.getZoneCode() + "库区不匹配");
|
|
117
118
119
|
}
List<Location> locations = new ArrayList<>();
|
|
120
121
122
123
|
for (int i = 1; i <= location.getIRow().intValue(); i++) {
for (int j = 1; j <= location.getIColumn().intValue(); j++) {
for (int k = 1; k <= location.getILayer().intValue(); k++) {
for (int m = 1; m <= location.getIGrid().intValue(); m++) {
|
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
//Integer roadway = (j / 2) + 1;
Location param = new Location();
param.setIRow(i);
param.setIColumn(j);
param.setILayer(k);
param.setIGrid(m);
param.setRoadway(location.getRoadway());
param.setZoneCode(location.getZoneCode());
param.setLocationType(location.getLocationType());
param.setStatus(location.getStatus());
param.setWarehouseCode(ShiroUtils.getWarehouseCode());
param.setCreatedBy(ShiroUtils.getLoginName());
param.setLastUpdatedBy(ShiroUtils.getLoginName());
String code = MessageFormat.format("{0}{1}_{2}_{3}",
location.getLocationType(),
String.format("%02d", i),
String.format("%02d", j),
String.format("%02d", k));
//查询该库位编码是否存在
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
|
|
144
145
|
queryWrapper.eq(Location::getCode, code)
.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode());
|
|
146
147
148
149
150
151
152
153
154
|
List<Location> locationList = locationService.list(queryWrapper);
if (locationList.size() == 0) {
param.setCode(code);
locations.add(param);
}
}
}
}
}
|
|
155
|
int num = 0;
|
|
156
|
List<Location> locations1 = new ArrayList<>();
|
|
157
158
|
if (locations.size() > 1000) {
for (Location item : locations) {
|
|
159
160
|
num++;
locations1.add(item);
|
|
161
|
if (num % 1000 == 0 || num == locations.size()) {
|
|
162
|
locationMapper.addList(locations1);
|
|
163
|
locations1 = new ArrayList<>();
|
|
164
165
|
}
}
|
|
166
|
} else {
|
|
167
168
|
locationMapper.addList(locations);
}
|
|
169
170
|
List<Integer> integerList = new ArrayList<>();
|
|
171
172
|
for (Location location2 : locations) {
if (integerList.size() == 0) {
|
|
173
174
|
integerList.add(location2.getIRow());
} else {
|
|
175
176
|
for (int i = 0; i < integerList.size(); i++) {
if (integerList.get(i).intValue() == location2.getIRow().intValue()) {
|
|
177
178
|
break;
} else {
|
|
179
|
if (i == (integerList.size() - 1)) {
|
|
180
181
182
183
184
185
|
integerList.add(location2.getIRow());
}
}
}
}
}
|
|
186
|
if (integerList.size() == 4) {
|
|
187
188
189
190
191
192
193
194
195
196
197
198
199
|
for (Location location3 : locations) {
for (int i = 0; i < integerList.size(); i++) {
if (location3.getIRow().intValue() == integerList.get(i).intValue()) {
if (i == 0 || i == (integerList.size() - 1)) {
location3.setRowFlag(1);
} else {
location3.setRowFlag(0);
}
}
}
}
locationMapper.updateList(locations);
}
|
|
200
201
202
|
return true;
}
|
|
203
|
@Override
|
|
204
|
public boolean addBatchSave(String prefix, Integer firstRow, Integer lastRow, Integer firstColumn, Integer lastColumn, Integer firstLayer, Integer lastLayer,
|
|
205
|
Integer firstGrid, Integer lastGrid, String roadWay, String status, String zoneCode, String locationType, String high) {
|
|
206
207
208
209
|
LambdaQueryWrapper<LocationType> typeLambda = Wrappers.lambdaQuery();
typeLambda.eq(LocationType::getCode, locationType)
.select(LocationType::getCode);
List<Map<String, Object>> list = locationTypeService.listMaps(typeLambda);
|
|
210
|
if (list.size() < 1) {
|
|
211
212
213
214
|
throw new ServiceException("库位类型编码不存在");
}
/* 判断库区编码是否存在*/
|
|
215
|
LambdaQueryWrapper<Zone> zoneLambda = Wrappers.lambdaQuery();
|
|
216
217
218
219
|
zoneLambda.eq(Zone::getCode, zoneCode)
.select(Zone::getCode);
list = zoneService.listMaps(zoneLambda);
|
|
220
|
if (list.size() < 1) {
|
|
221
222
223
|
throw new ServiceException("库区编码不存在");
}
//TODO:胡海--在判断库位类型和库区是否匹配,应该用库位类型表进行判断。库位类型在库区存在即可
|
|
224
|
/* if(!zoneCode.equals(locationType)){
|
|
225
|
throw new ServiceException(locationType+"的库位类型与"+ zoneCode +"库区不匹配");
|
|
226
|
}*/
|
|
227
|
LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
228
|
zoneLambdaQueryWrapper.eq(Zone::getWarehouseCode, ShiroUtils.getWarehouseCode());
|
|
229
230
231
232
233
234
235
236
|
zoneLambdaQueryWrapper.eq(Zone::getCode, zoneCode);
Zone zone = zoneService.getOne(zoneLambdaQueryWrapper);
String area = zone.getArea();
List<Location> locations = new ArrayList<>(); // 为零?
for (int i = firstRow.intValue(); i <= lastRow.intValue(); i++) {
for (int j = firstColumn.intValue(); j <= lastColumn.intValue(); j++) {
for (int k = firstLayer.intValue(); k <= lastLayer.intValue(); k++) {
for (int m = firstGrid.intValue(); m <= lastGrid.intValue(); m++) {
|
|
237
238
239
240
241
242
243
|
//Integer roadway = (j / 2) + 1;
Location param = new Location();
param.setIRow(i);
param.setIColumn(j);
param.setILayer(k);
param.setIGrid(m);
param.setRoadway(roadWay);
|
|
244
|
param.setArea(area);
|
|
245
246
247
|
param.setZoneCode(zoneCode);
param.setLocationType(locationType);
param.setStatus(status);
|
|
248
|
param.setHigh(Integer.parseInt(high));
|
|
249
250
251
|
param.setWarehouseCode(ShiroUtils.getWarehouseCode());
param.setCreatedBy(ShiroUtils.getLoginName());
param.setLastUpdatedBy(ShiroUtils.getLoginName());
|
|
252
|
String code = MessageFormat.format("{0}{1}{2}{3}",
|
|
253
|
prefix,
|
|
254
255
256
257
258
|
String.format("%02d", i),
String.format("%02d", j),
String.format("%02d", k));
//查询该库位编码是否存在
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
|
|
259
260
|
queryWrapper.eq(Location::getCode, code)
.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode());
|
|
261
262
263
264
265
266
267
268
269
270
|
List<Location> locationList = locationService.list(queryWrapper);
if (locationList.size() == 0) {
param.setCode(code);
locations.add(param);
}
}
}
}
}
|
|
271
|
int num = 0;
|
|
272
|
List<Location> locations1 = new ArrayList<>();
|
|
273
274
|
if (locations.size() > 1000) {
for (Location item : locations) {
|
|
275
276
|
num++;
locations1.add(item);
|
|
277
|
if (num % 1000 == 0 || num == locations.size()) {
|
|
278
|
locationMapper.addList(locations1);
|
|
279
|
locations1 = new ArrayList<>();
|
|
280
281
|
}
}
|
|
282
|
} else {
|
|
283
284
285
286
|
locationMapper.addList(locations);
}
List<Integer> integerList = new ArrayList<>();
|
|
287
288
|
for (Location location2 : locations) {
if (integerList.size() == 0) {
|
|
289
290
|
integerList.add(location2.getIRow());
} else {
|
|
291
292
|
for (int i = 0; i < integerList.size(); i++) {
if (integerList.get(i).intValue() == location2.getIRow().intValue()) {
|
|
293
294
|
break;
} else {
|
|
295
|
if (i == (integerList.size() - 1)) {
|
|
296
297
298
299
300
301
|
integerList.add(location2.getIRow());
}
}
}
}
}
|
|
302
|
if (integerList.size() == 4) {
|
|
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
for (Location location3 : locations) {
for (int i = 0; i < integerList.size(); i++) {
if (location3.getIRow().intValue() == integerList.get(i).intValue()) {
if (i == 0 || i == (integerList.size() - 1)) {
location3.setRowFlag(1);
} else {
location3.setRowFlag(0);
}
}
}
}
locationMapper.updateList(locations);
}
return true;
}
|
huhai
authored
|
320
321
|
/**
* 根据库位编码对库位表格的状态进行更新
|
|
322
|
*
|
huhai
authored
|
323
324
325
|
* @param locationCode
* @param status
*/
|
|
326
327
328
329
330
331
332
|
@Override
public void updateStatus(String locationCode, String status) {
if (StringUtils.isNotEmpty(locationCode)) {
locationMapper.updateStatus(ShiroUtils.getWarehouseCode(), locationCode, status);
}
}
|
|
333
334
335
336
337
338
339
|
@Override
public void updateStatus(String locationCode, String status, String warehouseCode) {
if (StringUtils.isNotEmpty(locationCode)) {
locationMapper.updateStatus(warehouseCode, locationCode, status);
}
}
|
|
340
341
|
/**
* 通过定位规则查找库位
|
|
342
|
*
|
|
343
344
345
346
|
* @param locatingRule
* @return
*/
@Override
|
|
347
|
public String position(String locatingRule) {
|
|
348
349
350
351
352
|
return locationMapper.position(locatingRule).getCode();
}
/**
* 修改容器和库位状态
|
|
353
|
*/
|
|
354
355
356
|
@Override
public void updateContainerCodeAndStatus(String locationCode, String containerCode, String status) {
if (StringUtils.isNotEmpty(locationCode) || StringUtils.isNotEmpty(containerCode)) {
|
|
357
358
359
|
LambdaUpdateWrapper<Location> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.set(Location::getContainerCode, containerCode)
.set(Location::getStatus, status)
|
|
360
|
.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode())
|
|
361
362
|
.eq(Location::getCode, locationCode);
this.update(updateWrapper);
|
|
363
364
365
366
|
}
}
@Override
|
|
367
|
public void updateContainerCodeAndStatus(String locationCode, String containerCode,
|
|
368
|
String status, String warehouseCode) {
|
|
369
370
371
372
373
374
375
376
|
if (StringUtils.isNotEmpty(locationCode) || StringUtils.isNotEmpty(containerCode)) {
LambdaUpdateWrapper<Location> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.set(Location::getContainerCode, containerCode)
.set(Location::getStatus, status)
.eq(Location::getWarehouseCode, warehouseCode)
.eq(Location::getCode, locationCode);
this.update(updateWrapper);
}
|
|
377
378
379
380
381
382
383
384
385
|
}
/**
* 获取库区最大行列
* @param type
* @return
*/
@Override
public LocationInfo getAllLocation(String type) {
|
|
386
|
if (StringUtils.isNotEmpty(type)) {
|
|
387
|
Location location = locationMapper.getAllLocation(ShiroUtils.getWarehouseCode(), type);
|
|
388
389
390
391
392
|
LocationInfo locationInfo = new LocationInfo();
locationInfo.setMaxRow(location.getIRow());
locationInfo.setMaxLine(location.getIColumn());
locationInfo.setMaxLayer(location.getILayer());
locationInfo.setMaxGrid(location.getIGrid());
|
|
393
394
|
int minRow = locationMapper.getFirstRowOfZone(ShiroUtils.getWarehouseCode(), type);
locationInfo.setMinRow(minRow);
|
|
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
return locationInfo;
}
return null;
}
/**
* 验证库位合法性
*
* @param code
* @return
*/
@Override
public boolean checkLocation(String code) {
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
|
|
409
|
queryWrapper.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode())
|
|
410
|
.eq(Location::getDeleted, false)
|
|
411
412
|
.eq(Location::getCode, code);
List<Location> locations = list(queryWrapper);
|
|
413
|
if (locations.size() >= 1) {
|
|
414
|
Location location = locations.get(0);
|
|
415
|
String containerCode = location.getContainerCode();
|
|
416
417
418
419
|
if (containerCode != null && containerCode.length() > 0) {
throw new ServiceException("货架上已有容器");
}
String status = location.getStatus();
|
|
420
|
if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(status)) {
|
|
421
422
423
424
425
426
427
428
429
430
431
|
throw new ServiceException("库位状态不为空");
}
return true;
} else {
return false;
}
}
@Override
public boolean getFreeLocation(String materialCode, String batch) {
LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
432
|
lambdaQueryWrapper.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode())
|
|
433
434
|
.eq(Location::getContainerCode, "")
.eq(Location::getDeleted, false)
|
|
435
|
.eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY);
|
|
436
|
List<Location> locations = locationService.list(lambdaQueryWrapper);
|
|
437
|
if (locations != null && locations.size() > 0) {
|
|
438
439
440
441
442
443
444
|
return true;
}
return false;
}
/**
* 查询库位利用率
|
|
445
|
*
|
|
446
447
448
449
450
451
452
453
454
|
* @return
*/
@Override
public List<LinkedHashMap<String, Object>> getLocationProp() {
return locationMapper.getLocationProp();
}
/**
* 根据库位编码查询库位信息
|
|
455
|
*
|
|
456
|
* @param
|
|
457
458
459
|
* @return
*/
@Override
|
|
460
|
public Location getLocationByCode(String locationCode) {
|
|
461
|
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
|
|
462
|
queryWrapper.eq(Location::getCode, locationCode);
|
|
463
|
queryWrapper.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode());
|
|
464
465
466
|
return getOne(queryWrapper);
}
|
|
467
|
@Override
|
|
468
469
470
471
472
473
474
475
|
public Location getLocationByCode(String locationCode, String warehouseCode) {
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Location::getCode, locationCode);
queryWrapper.eq(Location::getWarehouseCode, warehouseCode);
return getOne(queryWrapper);
}
@Override
|
|
476
477
478
479
|
public List<Location> pickLocation() {
return locationMapper.pickLocation();
}
|
|
480
|
@Override
|
|
481
482
483
484
485
|
public List<Location> selectLocationByContainerEmpty(String warehouseCode, String zoneCode, String roadWay) {
return locationMapper.selectLocationByContainerEmpty(warehouseCode,zoneCode,roadWay);
}
@Override
|
|
486
487
488
489
|
public List<Location> selectContainerEmpty(String warehouseCode) {
return locationMapper.selectContainerEmpty(warehouseCode);
}
|
|
490
491
492
493
|
@Override
public Location getInsideNear(Location location) {
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Location::getWarehouseCode, location.getWarehouseCode());
|
|
494
|
queryWrapper.eq(Location::getZoneCode, location.getZoneCode());
|
|
495
496
497
|
queryWrapper.eq(Location::getRoadway, location.getRoadway());
queryWrapper.eq(Location::getIColumn, location.getIColumn());
queryWrapper.eq(Location::getILayer, location.getILayer());
|
|
498
|
queryWrapper.eq(!location.getWarehouseCode().equalsIgnoreCase("KS0001"),Location::getLocationType, location.getLocationType());
|
|
499
|
queryWrapper.eq(Location::getRowFlag, QuantityConstant.ROW_IN);
|
|
500
|
List<Location> locationList = list(queryWrapper);
|
|
501
502
503
504
505
|
for (Location location1 : locationList) {
int diff = Math.abs(location1.getIRow().intValue() - location.getIRow().intValue());
if (diff == 1) {
return location1;
}
|
|
506
507
508
509
510
|
}
return null;
}
@Override
|
|
511
512
513
|
public Location getOutSideNear(Location location) {
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Location::getWarehouseCode, location.getWarehouseCode());
|
|
514
|
queryWrapper.eq(Location::getZoneCode, location.getZoneCode());
|
|
515
516
517
|
queryWrapper.eq(Location::getRoadway, location.getRoadway());
queryWrapper.eq(Location::getIColumn, location.getIColumn());
queryWrapper.eq(Location::getILayer, location.getILayer());
|
|
518
|
queryWrapper.eq(!location.getWarehouseCode().equalsIgnoreCase("KS0001"),Location::getLocationType, location.getLocationType());
|
|
519
|
queryWrapper.eq(Location::getRowFlag, QuantityConstant.ROW_OUT);
|
|
520
|
List<Location> locationList = list(queryWrapper);
|
|
521
|
for (Location location1 : locationList) {
|
|
522
|
int diff = Math.abs(location1.getIRow().intValue() - location.getIRow().intValue());
|
|
523
|
if (diff == 1) {
|
|
524
525
526
527
528
529
530
531
|
return location1;
}
}
return null;
}
@Override
public Location getNear(Location location) {
|
|
532
533
|
int rowFlag = location.getRowFlag().intValue();
Location locaiton2 = null;
|
|
534
|
if (rowFlag == 1) {
|
|
535
536
|
locaiton2 = getInsideNear(location);
} else {
|
|
537
538
539
540
541
|
locaiton2 = getOutSideNear(location);
}
return locaiton2;
}
|
|
542
543
|
private boolean getOutSideCanMove(Location location) {
Location locaiton2 = getInsideNear(location);
|
|
544
545
|
if (!locaiton2.getStatus().equals(QuantityConstant.STATUS_LOCATION_EMPTY)) {
return false;
|
|
546
|
}
|
|
547
|
if (!locaiton2.getContainerCode().equals("")) {
|
|
548
549
|
return false;
}
|
|
550
|
return true;
|
|
551
552
553
554
555
556
557
|
}
@Override
public Location getEmptyOutSideLocation(Location location) {
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Location::getWarehouseCode, location.getWarehouseCode());
queryWrapper.eq(Location::getRoadway, location.getRoadway());
|
|
558
|
queryWrapper.ge(Location::getHigh, location.getHigh());
|
|
559
|
queryWrapper.eq(Location::getRowFlag, QuantityConstant.ROW_OUT);
|
|
560
|
queryWrapper.eq(Location::getContainerCode, "");
|
|
561
|
queryWrapper.eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY);
|
|
562
|
queryWrapper.eq(!location.getWarehouseCode().equalsIgnoreCase("KS0001"),Location::getLocationType, location.getLocationType());
|
|
563
|
List<Location> locationList = list(queryWrapper);
|
|
564
565
|
List<Location> removeLocationList = new ArrayList<>();
int column = location.getIColumn();
|
|
566
|
Collections.sort(locationList, new Comparator<Location>() {
|
|
567
568
569
570
571
572
|
@Override
public int compare(Location o1, Location o2) {
int dvalue1 = Math.abs(o1.getIColumn() - column);
int dvalue2 = Math.abs(o2.getIColumn() - column);
return dvalue1 - dvalue2;
}
|
|
573
|
});
|
|
574
|
int removeSize = 0;
|
|
575
|
for (int i = 0; i < locationList.size(); i++) {
|
|
576
|
Location location1 = locationList.get(i);
|
|
577
|
if (taskHeaderService.getUncompleteTaskInNear(location1) > 0) {
|
|
578
579
580
581
582
583
584
585
|
removeLocationList.add(location1);
removeSize++;
} else if (!getOutSideCanMove(location1)) {
removeLocationList.add(location1);
removeSize++;
}
if (i - removeSize >= 3) {
break;
|
|
586
587
|
}
}
|
|
588
|
locationList.removeAll(removeLocationList);
|
|
589
|
if (locationList == null || locationList.size() <= 0) {
|
|
590
591
592
593
594
595
596
|
return null;
}
Location location1 = locationList.get(0);
return location1;
}
|
|
597
|
@Override
|
|
598
599
600
601
|
public Location getEmptyInsideLocation(Location location) {
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Location::getWarehouseCode, location.getWarehouseCode());
queryWrapper.eq(Location::getRoadway, location.getRoadway());
|
|
602
|
queryWrapper.eq(Location::getRowFlag, QuantityConstant.ROW_IN);
|
|
603
|
queryWrapper.ge(Location::getHigh, location.getHigh());
|
|
604
|
queryWrapper.eq(Location::getContainerCode, "");
|
|
605
|
queryWrapper.eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY);
|
|
606
|
queryWrapper.eq(!location.getWarehouseCode().equalsIgnoreCase("KS0001"),Location::getLocationType, location.getLocationType());
|
|
607
|
List<Location> locationList = list(queryWrapper);
|
|
608
|
List<Location> removeLocaationList = new ArrayList<>();
|
|
609
|
int column = location.getIColumn();
|
|
610
|
Collections.sort(locationList, new Comparator<Location>() {
|
|
611
612
613
614
615
616
|
@Override
public int compare(Location o1, Location o2) {
int dvalue1 = Math.abs(o1.getIColumn() - column);
int dvalue2 = Math.abs(o2.getIColumn() - column);
return dvalue1 - dvalue2;
}
|
|
617
618
|
});
int removeSize = 0;
|
|
619
|
for (int i = 0; i < locationList.size(); i++) {
|
|
620
621
622
623
624
625
626
627
628
629
|
Location location1 = locationList.get(i);
if (taskHeaderService.getUncompleteTaskInNear(location1) > 0) {
removeLocaationList.add(location1);
removeSize++;
}
if (i - removeSize >= 3) {
break;
}
}
locationList.removeAll(removeLocaationList);
|
|
630
|
if (locationList == null || locationList.size() <= 0) {
|
|
631
632
|
return null;
}
|
|
633
|
Location location1 = locationList.get(0);
|
|
634
635
636
|
return location1;
}
|
|
637
638
639
640
641
642
643
644
|
@Override
public Location getEmptyLocation(Location location) {
Location location1 = getEmptyOutSideLocation(location);
if (location1 == null) {
location1 = getEmptyInsideLocation(location);
}
return location1;
}
|
|
645
646
647
648
649
650
651
652
653
654
|
@Override
public int getFirstRowOfZone(String warehouseCode, String locationType) {
return locationMapper.getFirstRowOfZone(warehouseCode, locationType);
}
@Override
public int getLastRowOfZone(String warehouseCode, String locationType) {
return locationMapper.getLastRowOfZone(warehouseCode, locationType);
}
|
|
655
656
657
658
659
660
|
@Override
public List<Location> remoteList(String type) {
LambdaQueryWrapper<Location> wrapper = Wrappers.lambdaQuery();
if ("status".equals(type)) {
wrapper.eq(Location::getStatus, "lock");
|
|
661
|
} else if ("container".equals(type)) {
|
|
662
|
wrapper.isNotNull(Location::getContainerCode)
|
|
663
|
.ne(Location::getContainerCode, "");
|
|
664
665
666
|
}
return list(wrapper);
}
|
|
667
668
669
670
671
672
673
674
675
|
@Override
public void upstatus(String code) {
Location user = new Location();
user.setStatus("empty");
//修改条件s
UpdateWrapper<Location> userUpdateWrapper = new UpdateWrapper<>();
userUpdateWrapper.eq("containerCode", code);
int update = locationMapper.update(user, userUpdateWrapper);
|
|
676
|
// System.out.println(update);
|
|
677
|
}
|
|
678
|
@Override
|
|
679
680
681
682
683
684
685
686
687
|
public int locationSIsnull(){
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode());
queryWrapper.eq(Location::getRoadway, 2);
queryWrapper.eq(Location::getZoneCode,"LK");
queryWrapper.eq(Location::getContainerCode,"").or().isNull(Location::getContainerCode);
int count=this.count();
return count;
}
|
|
688
|
@Override
|
|
689
690
691
692
693
694
695
696
697
698
699
700
|
public Location getLocationOfRule(int roadWay){
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode());
queryWrapper.eq(Location::getStatus,QuantityConstant.STATUS_LOCATION_EMPTY);
queryWrapper.eq(Location::getRoadway, roadWay);
queryWrapper.eq(Location::getZoneCode,"LK");
queryWrapper.eq(Location::getContainerCode,"").or().isNull(Location::getContainerCode);
queryWrapper.orderByAsc(Location::getIColumn,Location::getIRow);
queryWrapper.last("limit 1");
Location location=this.getOne(queryWrapper);
return location;
}
|
|
701
702
703
704
705
|
@Override
public Location selectFirstEntity(Location temp1){
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(StringUtils.isNotEmpty(temp1.getWarehouseCode()),Location::getWarehouseCode, temp1.getWarehouseCode());
|
|
706
|
queryWrapper.eq(StringUtils.isNotEmpty(temp1.getCode()),Location::getCode,temp1.getCode());
|
|
707
|
queryWrapper.eq(StringUtils.isNotNull(temp1.getIRow()),Location::getIRow,temp1.getIRow());
|
|
708
709
710
|
queryWrapper.eq(StringUtils.isNotNull(temp1.getIColumn()),Location::getIColumn,temp1.getIColumn());
queryWrapper.eq(StringUtils.isNotNull(temp1.getRoadway()),Location::getRoadway,temp1.getRoadway());
queryWrapper.eq(StringUtils.isNotNull(temp1.getILayer()),Location::getILayer,temp1.getILayer());
|
|
711
|
queryWrapper.eq(StringUtils.isNotNull(temp1.getIGrid()),Location::getIGrid,temp1.getIGrid());
|
|
712
713
714
715
|
queryWrapper.last("limit 1");
return this.getOne(queryWrapper);
}
|
|
716
717
718
719
720
721
722
723
724
725
726
727
|
@Override
public Location selectAddress(Location location) {
return locationMapper.selectAddress(location);
}
@Override
public List<Location> selectEmptyAddress() {
Points points=new Points();
points.setWarehouseCode(ShiroUtils.getWarehouseCode());
points.setIsLocked(2);
return locationMapper.selectEmptyAddress(points);
}
|
|
728
729
730
731
732
733
734
735
736
|
@Override
public List<Location> getRoadwayByLocationType(String locationType) {
QueryWrapper<Location> qw = new QueryWrapper<>();
qw.select("DISTINCT locationType,roadway").lambda().eq(Location::getLocationType,locationType);
List<Location> list = this.list(qw);
return list;
}
|
|
737
|
@Override
|
|
738
739
|
public List<String> selectlistEmpty(String warehouseCode) {
return locationMapper.selectlistEmpty(warehouseCode);
|
|
740
741
|
}
@Override
|
|
742
743
|
public List<Location> selectCode(String warehouseCode) {
return locationMapper.selectCode(warehouseCode);
|
|
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
}
@Override
public Location selectByPrefix(Location location) {
return locationMapper.selectByPrefix(location);
}
@Override
public Location selectModelByOld(Location location) {
return locationMapper.selectModelByOld(location);
}
@Override
public Location selectModelByOld(Location location,List<String> codes) {
return locationMapper.selectModelByOlds(location,codes);
}
@Override
|
|
759
|
public void pickAndplace(List<Location> locationAajacentIsNull,Boolean flag,Location s1,Location s2){
|
|
760
761
762
763
764
765
766
767
768
|
Boolean f=true;
int m=0;
while (f){
int layer = (int) (Math.random() * 8) + 1;
int line = (int) (Math.random() * 23) + 1;
locationAajacentIsNull.addAll(locationMapper.getLocationAajacentIsNull(layer, line,flag));
if(locationAajacentIsNull.size()!=2){
m++;
if(m==23){
|
|
769
|
return;
|
|
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
|
}
continue;
}
List<Integer> c = locationAajacentIsNull.stream().map(j -> j.getIColumn()).collect(Collectors.toList());
if(c.get(0) - c.get(1)==1||c.get(0) - c.get(1)==-1){
f=false;
}else {
locationAajacentIsNull.clear();
}
}
s1.setCode(locationAajacentIsNull.get(0).getCode());
s2.setCode(locationAajacentIsNull.get(1).getCode());
}
@Override
public Location getLocationFarAway(Integer roadway, int flag,int layer) {
return locationMapper.getLocationFarAway(roadway,flag,layer);
}
|
|
787
788
789
790
|
@Override
public Location getLocationOfRule() {
return locationMapper.getLocationOfRule();
}
|
|
791
792
793
794
|
@Override
public List<Location> selectListInventory(String zoneCode) {
return locationMapper.selectListInventory(zoneCode);
}
|
|
795
|
}
|