WarehouseServiceImpl.java
9.01 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package com.huaheng.pc.config.warehouse.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.pc.config.FilterConfigHeader.service.FilterConfigHeaderService;
import com.huaheng.pc.config.address.domain.Address;
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.config.configValue.service.ConfigValueService;
import com.huaheng.pc.config.containerType.service.ContainerTypeService;
import com.huaheng.pc.config.cycleCountPreference.service.CycleCountPreferenceService;
import com.huaheng.pc.config.locationType.service.LocationTypeService;
import com.huaheng.pc.config.receiptPreference.service.ReceiptPreferenceService;
import com.huaheng.pc.config.receiptType.service.ReceiptTypeService;
import com.huaheng.pc.config.shipmentPreference.service.ShipmentPreferenceService;
import com.huaheng.pc.config.shipmentType.service.ShipmentTypeService;
import com.huaheng.pc.config.statusFlow.service.StatusFlowHeaderService;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
import com.huaheng.pc.config.warehouse.mapper.WarehouseMapper;
import com.huaheng.pc.config.warehouseCompany.domain.WarehouseCompany;
import com.huaheng.pc.config.warehouseCompany.service.WarehouseCompanyService;
import com.huaheng.pc.config.waveMaster.service.WaveMasterService;
import com.huaheng.pc.config.zone.service.ZoneService;
import com.huaheng.pc.system.dict.service.IDictTypeService;
import com.huaheng.pc.system.menu.service.IMenuService;
import com.huaheng.pc.system.role.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("WarehouseService")
public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse> implements WarehouseService {
@Resource
private AddressService addressService;
@Resource
private ConfigValueService configValueService;
@Resource
private ContainerTypeService containerTypeService;
@Resource
private CycleCountPreferenceService cycleCountPreferenceService;
@Resource
private LocationTypeService locationTypeService;
@Resource
private ReceiptPreferenceService receiptPreferenceService;
@Resource
private ReceiptTypeService receiptTypeService;
@Resource
private ShipmentPreferenceService shipmentPreferenceService;
@Resource
private ShipmentTypeService shipmentTypeService;
@Resource
private WarehouseMapper warehouseMapper;
@Resource
private WarehouseCompanyService warehouseCompanyService;
@Autowired
private IRoleService roleService;
@Autowired
private IDictTypeService dictTypeService;
@Autowired
private IMenuService menuService;
@Autowired
private FilterConfigHeaderService filterConfigHeaderService;
@Autowired
private StatusFlowHeaderService statusFlowHeaderService;
@Autowired
private WaveMasterService waveMasterService;
@Autowired
private ZoneService zoneService;
@Override
public List<Map<String, Object>> getWarehouseList(Integer id) {
/**
* 查询仓库的code、name、enable
*/
LambdaQueryWrapper<Warehouse> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.select(Warehouse::getCode, Warehouse::getName, Warehouse::getEnable);
List<Map<String, Object>> warehouseList = warehouseMapper.selectMaps(lambdaQueryWrapper);
LambdaQueryWrapper<WarehouseCompany> lambdaQueryWrapper1 = Wrappers.lambdaQuery();
lambdaQueryWrapper1.select(WarehouseCompany::getCompanyCode,WarehouseCompany::getWarehouseCode)
.eq(WarehouseCompany::getCompanyId,id);
List<Map<String, Object>> warehouseCompanies = warehouseCompanyService.listMaps(lambdaQueryWrapper1);
for(Map<String, Object> item : warehouseList){
item.put("flag",false);
item.put("value", item.get("code").toString());
for (Map<String, Object> warehouseI:warehouseCompanies) {
if (item.get("code").toString().equals(warehouseI.get("warehouseCode").toString())) {
item.put("flag",true);
break;
}
}
}
return warehouseList;
}
@Override
public List<Warehouse> selectWarehouseByUserId(Integer userId)
{
List<Warehouse> userWarhouses = warehouseMapper.selectWarehouseByUserId(userId);
List<Warehouse> warehouses = warehouseMapper.selectWarehouseAll();
for (Warehouse warehouse : warehouses)
{
for (Warehouse userWarehouse: userWarhouses)
{
if (warehouse.getCode().equals(userWarehouse.getCode()))
{
warehouse.setFlag(true);
break;
}
}
}
return warehouses;
}
/**
* 复制仓库
* @param warehouseCode 仓库编码
* @param newWarehouseCode 新仓库编码
*/
@Override
@Transactional
public Boolean warehouseCopy(String warehouseCode, String newWarehouseCode) {
/* 复制地址表*/
if (!addressService.addressCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制地址表失败");
}
/* 复制系统参数配置表*/
if (!configValueService.configValueCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制系统参数配置表失败");
}
/* 复制容器类型表*/
if (!containerTypeService.containerTypeCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制容器类型表失败");
}
/* 复制库位类型表*/
if (!locationTypeService.locationTypeCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制库位类型表失败");
}
/* 复制库区表*/
if (!zoneService.zoneCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制库区类型表失败");
}
/* 复制盘点首选项表*/
if (!cycleCountPreferenceService.cycleCountPreferenceCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制盘点首选项表失败");
}
/* 复制入库首选项*/
if (!receiptPreferenceService.receiptPreferenceCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制入库首选项表失败");
}
/* 复制出库首选项*/
if (!shipmentPreferenceService.shipmentPreferenceCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制出库首选项表失败");
}
/* 复制入库类型*/
if (!receiptTypeService.receiptTypeCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制入库类型表失败");
}
/* 复制出库类型*/
if (!shipmentTypeService.ShipmentTypeCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制出库类型表失败");
}
/* 复制仓库货主关系*/
if (warehouseMapper.companyCopy(warehouseCode, newWarehouseCode) < 1){
throw new ServiceException("复制仓库货主关系表失败");
}
/* 复制仓库用户关系*/
if (warehouseMapper.userCopy(warehouseCode, newWarehouseCode) < 1){
throw new ServiceException("复制仓库货主关系表失败");
}
/* 复制角色*/
if (!roleService.roleCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制角色表失败");
}
/* 复制字典数据*/
if (!dictTypeService.dictTypeCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制字典数据表失败");
}
/* 复制菜单*/
if (!menuService.menuCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制菜单表失败");
}
/* 复制流程*/
if (!statusFlowHeaderService.statusFlowCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制流程表失败");
}
/* 复制规则配置*/
if (!filterConfigHeaderService.filterConfigCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制规则配置表失败");
}
/* 复制波次配置*/
if (!waveMasterService.waveMasterCopy(warehouseCode, newWarehouseCode)){
throw new ServiceException("复制波次配置表失败");
}
return true;
}
@Override
public List<Warehouse> selectListEntityByEqual(Warehouse condition) {
return warehouseMapper.selectListEntityByEqual(condition);
}
}