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