StationService.java
4.5 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
package com.huaheng.pc.config.station.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
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.station.domain.StationType;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.station.domain.Station;
import com.huaheng.pc.config.station.mapper.StationMapper;
/**
* Created by Enzo Cotter on 2019/10/11.
*/
@Service
public class StationService extends ServiceImpl<StationMapper, Station> {
@Resource
private InventoryDetailService inventoryDetailService;
@Resource
private MaterialService materialService;
@Resource
private ContainerService containerService;
@Resource
private LocationService locationService;
@Resource
private StationService stationService;
public Map<String, Object> StationFromType(StationType stationType) {
String containerCode = stationType.getContainerCode();
int type = Integer.parseInt(stationType.getType());
Container container = containerService.getContainerByCode(containerCode);
Map<String, Object> map = new HashMap<>();
if(container == null) {
return map;
}
String locationCode = container.getLocationCode();
if(StringUtils.isEmpty(locationCode)) {
return map;
}
LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
locationLambdaQueryWrapper.eq(Location::getCode, locationCode)
.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode());
Location location1 = locationService.getOne(locationLambdaQueryWrapper);
if(location1 == null) {
return map;
}
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper=Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getContainerCode,containerCode).eq(InventoryDetail::getLocationCode,locationCode);
List<InventoryDetail> list1 = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
Material one1=new Material();
if (list1.size()>0){
LambdaQueryWrapper<Material> materialLambdaQueryWrapper=Wrappers.lambdaQuery();
materialLambdaQueryWrapper.eq(Material::getCode,list1.get(0).getMaterialCode());
one1 = materialService.getOne(materialLambdaQueryWrapper);
}
LambdaQueryWrapper<Station> queryWrapper = Wrappers.lambdaQuery();
if(type == QuantityConstant.STATION_PICK_AND_OUT) {
queryWrapper.in(Station::getType,
QuantityConstant.STATION_OUT, QuantityConstant.STATION_PICK);
} else {
queryWrapper.eq(Station::getType, type);
}
queryWrapper.eq(Station::getArea, location1.getArea()).eq(StringUtils.isNotEmpty(one1.getSpec()),
Station::getDestination, one1.getSpec());
List<Station> stationList = stationService.list(queryWrapper);
if (stationList==null || stationList.size()<=0||list1.size()>1)
{
queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Station::getArea, location1.getArea()).eq(Station::getType, type);
stationList = stationService.list(queryWrapper);
}
List<Map<String, Object>> list = new ArrayList<>();
for (Station station : stationList) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("id", station.getCode());
resultMap.put("text", station.getName());
list.add(resultMap);
map.put("hhh",station.getCode());
}
map.put("results", list);
return map;
}
}