StationService.java
6.58 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
package com.huaheng.pc.config.station.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
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.containerType.domain.ContainerType;
import com.huaheng.pc.config.containerType.service.ContainerTypeService;
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.service.ZoneService;
import org.springframework.stereotype.Service;
import java.util.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.station.domain.Station;
import com.huaheng.pc.config.station.mapper.StationMapper;
import javax.annotation.Resource;
/**
* Created by Enzo Cotter on 2019/10/11.
*/
@Service("stationService")
public class StationService extends ServiceImpl<StationMapper, Station> {
@Resource
private ContainerService containerService;
@Resource
private ContainerTypeService containerTypeService;
@Resource
private ZoneService zoneService;
public List<Station> selectlist(){
LambdaQueryWrapper<Station> lambdaQueryWrapper = Wrappers.lambdaQuery();
List<Station> list = this.list(lambdaQueryWrapper);
return list;
}
public Station getStaionByCode(String code,String warehouseCode){
Station station = this.getOne(
new LambdaQueryWrapper<Station>()
.eq(Station::getWarehouseCode, warehouseCode)
.eq(Station::getCode, code)
.last("limit 1"));
return station;
}
public List<Station> getStationByAreaType(String containerCode, String stationtype, String warehouseCode) {
String area = null;
if (StringUtils.isNotEmpty(containerCode)) {
Container container = containerService.getContainerByCode(containerCode, ShiroUtils.getWarehouseCode());
ContainerType containerType = containerTypeService.getContainerTypeByCode(container.getContainerType(), container.getWarehouseCode());
Map<String, Object> map = new HashMap<>();
if (container == null) {
return null;
}
area = containerType.getArea();
}
LambdaQueryWrapper<Station> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(StringUtils.isNotEmpty(area),Station::getArea, area);
queryWrapper.eq(StringUtils.isNotEmpty(stationtype),Station::getStationType, stationtype);
queryWrapper.eq(StringUtils.isNotEmpty(warehouseCode),Station::getWarehouseCode, warehouseCode);
List<Station> stationList = this.list(queryWrapper);
return stationList;
}
public List<Station> getStationByContainers(String containerCode,String type,String stationType){
Container container = containerService.getContainerByCode(containerCode, ShiroUtils.getWarehouseCode());
ContainerType containerType = containerTypeService.getContainerTypeByCode(container.getContainerType(), container.getWarehouseCode());
Map<String, Object> map = new HashMap<>();
if (container == null) {
return null;
}
String area=containerType.getArea();
List<Integer> types = new ArrayList<>();
if (StringUtils.isNotEmpty(type)){
types = Arrays.asList(Convert.toIntArray(type));
}
String[] stationTypes = stationType.split(",");
LambdaQueryWrapper<Station> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(StringUtils.isNotEmpty(area),Station::getArea, area);
queryWrapper.in(StringUtils.isNotEmpty(type),Station::getType, types);
queryWrapper.in(StringUtils.isNotEmpty(stationType),Station::getStationType, Convert.toIntArray(stationType));
List<Station> stationList = this.list(queryWrapper);
return stationList;
}
public List<Station> getStationByArea(String area, String type, String stationType, String containerCode) {
Container container = containerService.getContainerByCode(containerCode, ShiroUtils.getWarehouseCode());
ContainerType containerType = containerTypeService.getContainerTypeByCode(container.getContainerType(), container.getWarehouseCode());
Map<String, Object> map = new HashMap<>();
if (container == null) {
return null;
}
area = containerType.getArea();
List<Integer> types = new ArrayList<>();
if (StringUtils.isNotEmpty(type)){
types = Arrays.asList(Convert.toIntArray(type));
}
LambdaQueryWrapper<Station> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(StringUtils.isNotEmpty(area),Station::getArea, area);
queryWrapper.in(StringUtils.isNotEmpty(type),Station::getType, types);
queryWrapper.eq(StringUtils.isNotEmpty(stationType),Station::getStationType, stationType);
List<Station> stationList = this.list(queryWrapper);
return stationList;
}
public List<Station> getListByType(int type, String roadWay, String zoneCode, String warehouseCode) {
LambdaQueryWrapper<Zone> lambda = new LambdaQueryWrapper<>();
lambda.eq(Zone::getCode,zoneCode);
lambda.eq(Zone::getWarehouseCode, warehouseCode);
lambda.last("limit 1");
Zone zone=zoneService.getOne(lambda);
String area=null;
if(zone!=null){
area=zone.getArea();
}
LambdaQueryWrapper<Station> portLambdaQueryWrapper = new LambdaQueryWrapper<>();
portLambdaQueryWrapper.eq(Station::getType, type).eq(Station::getArea, area).eq(Station::getWarehouseCode, warehouseCode).in(roadWay != null,
Station::getRoadway, roadWay);
List<Station> portList = list(portLambdaQueryWrapper);
if (CollectionUtils.isEmpty(portList)) {
portList = getPortListByType(type, area, warehouseCode);
}
return portList;
}
public List<Station> getPortListByType(int type, String area, String warehouseCode) {
LambdaQueryWrapper<Station> portLambdaQueryWrapper = new LambdaQueryWrapper<>();
portLambdaQueryWrapper.eq(Station::getType, type).eq(Station::getArea, area).eq(Station::getWarehouseCode, warehouseCode);
List<Station> portList = list(portLambdaQueryWrapper);
return portList;
}
}