|
1
2
|
package com.huaheng.pc.shipment.shipmentContainerHeader.service;
|
|
3
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
4
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
5
|
import com.huaheng.common.constant.QuantityConstant;
|
|
6
|
import com.huaheng.common.exception.service.ServiceException;
|
|
7
|
import com.huaheng.common.utils.StringUtils;
|
|
8
|
import com.huaheng.common.utils.Wrappers;
|
|
9
10
|
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
|
|
11
|
import com.huaheng.framework.web.domain.RetCode;
|
|
12
13
|
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
|
|
14
15
16
17
|
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;
|
|
18
|
import com.huaheng.pc.config.shipmentPreference.service.ShipmentPreferenceService;
|
|
19
20
|
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
|
|
21
|
import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService;
|
|
22
|
import com.huaheng.pc.shipment.lockingWorkOrder.service.LockingWorkOrderService;
|
|
23
24
25
|
import com.huaheng.pc.shipment.shipmentContainerDetail.domain.ShipmentContainerDetail;
import com.huaheng.pc.shipment.shipmentContainerDetail.service.ShipmentContainerDetailService;
import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentCombinationModel;
|
|
26
27
|
import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader;
import com.huaheng.pc.shipment.shipmentContainerHeader.mapper.ShipmentContainerHeaderMapper;
|
|
28
29
30
31
|
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
|
|
32
|
import com.huaheng.pc.shipment.shippingCombination.service.ShippingCombinationService;
|
|
33
34
|
import com.huaheng.pc.shipment.wave.domain.Wave;
import com.huaheng.pc.shipment.wave.service.WaveService;
|
|
35
36
|
import com.huaheng.pc.system.role.domain.Role;
import com.huaheng.pc.system.role.service.IRoleService;
|
|
37
38
|
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
|
|
39
|
import com.huaheng.pc.task.taskHeader.domain.ShipmentTaskCreateModel;
|
|
40
|
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
|
|
41
|
import com.huaheng.pc.task.taskHeader.service.ShipmentTaskService;
|
|
42
|
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
|
|
43
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
44
|
import org.springframework.stereotype.Service;
|
|
45
46
|
import org.springframework.transaction.annotation.Transactional;
|
|
47
|
import javax.annotation.Resource;
|
|
48
|
import java.math.BigDecimal;
|
|
49
|
import java.util.ArrayList;
|
|
50
|
import java.util.Collections;
|
|
51
|
import java.util.List;
|
|
52
|
import java.util.Map;
|
|
53
|
import java.util.stream.Collectors;
|
|
54
|
|
|
55
|
@Service
|
|
56
|
public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentContainerHeaderMapper, ShipmentContainerHeader> implements ShipmentContainerHeaderService {
|
|
57
|
|
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
@Autowired
private ShipmentDetailService shipmentDetailService;
@Autowired
private InventoryDetailService inventoryDetailService;
@Autowired
private LocationService locationService;
@Autowired
private ShipmentHeaderService shipmentHeaderService;
@Resource
private ShipmentContainerHeaderMapper shipmentContainerHeaderMapper;
@Autowired
private ShipmentContainerDetailService shipmentContainerDetailService;
@Autowired
private MaterialService materialService;
|
|
72
73
|
@Autowired
private ShippingCombinationService shippingCombinationService;
|
|
74
75
|
@Autowired
private TaskHeaderService taskHeaderService;
|
|
76
77
|
@Autowired
private TaskDetailService taskDetailService;
|
|
78
79
|
@Autowired
private WaveService waveService;
|
|
80
81
|
@Autowired
private ShipmentPreferenceService shipmentPreferenceService;
|
|
82
83
|
@Autowired
private ContainerService containerService;
|
|
84
85
|
@Resource
private ShipmentTaskService shipmentTaskService;
|
|
86
87
|
@Autowired
private ReceiptContainerHeaderService receiptContainerHeaderService;
|
|
88
89
|
@Autowired
private LockingWorkOrderService lockingWorkOrderService;
|
|
90
91
|
@Autowired
private IRoleService roleService;
|
|
92
93
94
95
96
97
98
99
100
|
@Override
public Map<String, Integer> getShipmentContainerMaxAndMinStatusByShipmentID(int shipmentId) {
return shipmentContainerHeaderMapper.getShipmentContainerMaxAndMinStatusByShipmentID(shipmentId);
}
/**
|
|
101
102
103
104
105
106
107
|
* 1.检查基本属性
* 2.更改库存明细
* 3.更新单据明细的已出库数量
* 4.自动判定出库任务状态,根据库存数量减去预定库存相等就是整盘出--预计任务状态
* 5.增加出库组盘头
* 6.增加出库组盘明细
* 7.更新单据状态
|
|
108
|
* <p>
|
|
109
|
* 出库组盘单条保存
|
|
110
|
*
|
|
111
112
113
114
115
|
* @param shipmentCombinationModel
* @return
*/
@Transactional
@Override
|
|
116
|
public ShipmentContainerHeader combination(ShipmentCombinationModel shipmentCombinationModel) {
|
|
117
|
|
|
118
|
//1.检查基本属性
|
|
119
|
//校验
|
|
120
|
if (shipmentCombinationModel.getShipQty().compareTo(new BigDecimal("0")) <= 0) {
|
|
121
|
throw new ServiceException("出库数量必须大于0");
|
|
122
123
|
}
ShipmentDetail shipmentDetail = shipmentDetailService.getById(shipmentCombinationModel.getShipmentDetailId());
|
|
124
|
if (shipmentDetail == null) {
|
|
125
|
throw new ServiceException("出库明细未找到");
|
|
126
127
|
}
InventoryDetail inventoryDetail = inventoryDetailService.getById((shipmentCombinationModel.getInventoryDetailId()));
|
|
128
|
if (inventoryDetail == null) {
|
|
129
|
throw new ServiceException("库存未找到");
|
|
130
|
}
|
|
131
132
|
String containerCode = inventoryDetail.getContainerCode();
int unCompleteCombineNumber = receiptContainerHeaderService.getUnCompleteCombineNumber(containerCode);
|
|
133
|
if (unCompleteCombineNumber > 0) {
|
|
134
135
|
throw new ServiceException("托盘:" + containerCode + " 已经用于入库组盘");
}
|
|
136
|
Container container = containerService.getContainerByCode(containerCode);
|
|
137
138
|
if (container != null) {
if (container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {
|
|
139
|
//throw new ServiceException("托盘已经锁定,不能再组盘");
|
|
140
141
|
}
}
|
|
142
|
//校验数量是否超出
|
|
143
|
if ((shipmentDetail.getQty().subtract(shipmentDetail.getTaskQty())).compareTo(shipmentCombinationModel.getShipQty()) < 0) {
|
|
144
|
throw new ServiceException("录入数量超出明细待出数量");
|
|
145
146
|
}
//校验库存可用数量
|
|
147
|
if (inventoryDetail.getQty().subtract(inventoryDetail.getTaskQty()).compareTo(shipmentCombinationModel.getShipQty()) < 0) {
|
|
148
|
throw new ServiceException("录入数量超出可出数量");
|
|
149
|
}
|
|
150
|
if (!shipmentDetail.getMaterialCode().equals(inventoryDetail.getMaterialCode())) {
|
|
151
|
throw new ServiceException("配盘物料不一致");
|
|
152
153
|
}
//库位
|
|
154
155
156
|
LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(Location::getWarehouseCode, inventoryDetail.getWarehouseCode())
.eq(Location::getCode, inventoryDetail.getLocationCode());
|
|
157
|
Location location = locationService.getOne(lambdaQueryWrapper);
|
|
158
159
160
|
if (location == null) {
throw new ServiceException("库位 " + inventoryDetail.getLocationCode() + " 不存在");
}
|
|
161
162
163
164
165
166
167
168
169
|
LambdaQueryWrapper<TaskHeader> taskWrapper = Wrappers.lambdaQuery();
taskWrapper.eq(TaskHeader::getWarehouseCode, inventoryDetail.getWarehouseCode())
.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED)
.in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_VIEW, QuantityConstant.TASK_TYPE_TRANSFER)
.apply("(fromLocation='" + inventoryDetail.getLocationCode() + "' or toLocation='" + inventoryDetail.getLocationCode() + "')");
List<TaskHeader> taskHeaders = taskHeaderService.list(taskWrapper);
if (taskHeaders.size() > 0) {
throw new ServiceException("库位 " + inventoryDetail.getLocationCode() + " 已经有移库或出库查看任务,不能组盘");
}
|
|
170
|
|
|
171
|
//3.更新单据明细的已出库数量
|
|
172
173
|
shipmentDetail.setTaskQty(shipmentDetail.getTaskQty().add(shipmentCombinationModel.getShipQty()));
int i = shipmentDetail.getQty().compareTo(shipmentDetail.getTaskQty());
|
|
174
|
if (i > 0) {
|
|
175
|
shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_WAVE);
|
|
176
|
} else if (i == 0) {
|
|
177
|
shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_GROUPDISK);
|
|
178
|
} else if (i < 0) {
|
|
179
180
|
throw new ServiceException("出库数量不能大于单据数量!");
}
|
|
181
|
|
|
182
183
184
|
//2.更新库存分配数
inventoryDetail.setTaskQty(inventoryDetail.getTaskQty().add(shipmentCombinationModel.getShipQty()));
inventoryDetailService.saveOrUpdate(inventoryDetail);
|
|
185
186
|
//自动判定出库任务状态,根据库存数量减去预定库存相等就是整盘出--预计任务状态
BigDecimal inventoryQty = inventoryDetail.getQty().subtract(inventoryDetail.getTaskQty());
|
|
187
|
if (inventoryQty.compareTo(new BigDecimal(0)) <= 0) {
|
|
188
|
shipmentCombinationModel.setTaskType(QuantityConstant.TASK_TYPE_WHOLESHIPMENT);
|
|
189
|
} else {
|
|
190
|
shipmentCombinationModel.setTaskType(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT);
|
|
191
|
}
|
|
192
193
|
Container container1 = containerService.getContainerByCode(inventoryDetail.getContainerCode());
String containerType = container1.getContainerType();
|
|
194
|
if ("S".equals(containerType)) {
|
|
195
196
|
shipmentCombinationModel.setTaskType(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT);
}
|
|
197
198
199
|
//5.增加出库组盘头
ShipmentContainerHeader shipmentContainerHeader = ShipmentContainerHeaderAdd(location, shipmentDetail);
//6.增加出库组盘明细
|
|
200
|
ShipmentContainerDetail shipmentContainerDetail = ShipmentContainerDetailAdd(shipmentDetail, shipmentContainerHeader, shipmentCombinationModel);
|
|
201
202
|
shipmentDetailService.saveOrUpdate(shipmentDetail);
|
|
203
|
//7.更新单据状态
|
|
204
205
|
shipmentHeaderService.updateShipmentStatus(shipmentDetail.getShipmentId());
|
|
206
|
return shipmentContainerHeader;
|
|
207
208
209
|
}
/**
|
|
210
211
212
213
|
* 组盘头
* 1.查看是否有状态小于等于20的组盘头,有就需新建组盘头,没有就新建
* 2.没有符合条件的组盘头,新建组盘头
*
|
|
214
|
* @param location
|
|
215
|
* @param shipmentDetail
|
|
216
217
218
|
* @return
*/
private ShipmentContainerHeader ShipmentContainerHeaderAdd(Location location,
|
|
219
220
|
ShipmentDetail shipmentDetail) {
//1.查看是否有状态小于等于20的组盘头,有就需新建组盘头,没有就新建
|
|
221
222
223
224
225
|
LambdaQueryWrapper<ShipmentContainerHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ShipmentContainerHeader::getLocationCode, location.getCode())
.eq(ShipmentContainerHeader::getContainerCode, location.getContainerCode())
.eq(ShipmentContainerHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
.lt(ShipmentContainerHeader::getStatus, QuantityConstant.SHIPMENT_CONTAINER_FINISHED);
|
|
226
|
ShipmentContainerHeader shipmentContainerHeader = this.getOne(lambdaQueryWrapper);
|
|
227
228
229
|
if (shipmentContainerHeader != null) {
if (shipmentDetail.getWarehouseCode().equals("KS0001") && !ShiroUtils.getUserName().equals(shipmentContainerHeader.getCreatedBy())) {
throw new ServiceException(shipmentDetail.getMaterialName() + "物料匹配托盘" + location.getContainerCode() + "已被" + shipmentContainerHeader.getCreatedBy() + "组盘,暂时不能组盘");
|
|
230
|
}
|
|
231
|
return shipmentContainerHeader;
|
|
232
|
} else {
|
|
233
234
|
// 2.没有符合条件的组盘头,新建组盘头
//找到容器类型
|
|
235
236
237
|
LambdaQueryWrapper<Container> containerLam = Wrappers.lambdaQuery();
containerLam.eq(Container::getCode, location.getContainerCode())
.eq(Container::getWarehouseCode, ShiroUtils.getWarehouseCode());
|
|
238
|
Container container = containerService.getOne(containerLam);
|
|
239
|
if (container == null) {
|
|
240
241
|
throw new ServiceException("系统没有此容器编码");
}
|
|
242
243
|
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getContainerCode, container.getCode());
|
|
244
|
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
|
|
245
|
int taskType = QuantityConstant.TASK_TYPE_WHOLESHIPMENT;
|
|
246
247
248
|
if (inventoryDetailList != null && inventoryDetailList.size() > 0) {
for (InventoryDetail inventoryDetail : inventoryDetailList) {
if (inventoryDetail.getQty().subtract(inventoryDetail.getTaskQty()).
|
|
249
250
251
|
compareTo(BigDecimal.ZERO) > 0) {
taskType = QuantityConstant.TASK_TYPE_SORTINGSHIPMENT;
}
|
|
252
|
}
|
|
253
|
}
|
|
254
|
|
|
255
|
if ("S".equals(container.getContainerType())) {
|
|
256
257
|
taskType = QuantityConstant.TASK_TYPE_SORTINGSHIPMENT;
}
|
|
258
|
ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId());
|
|
259
260
261
|
shipmentContainerHeader = new ShipmentContainerHeader();
shipmentContainerHeader.setContainerCode(location.getContainerCode());
shipmentContainerHeader.setLocationCode(location.getCode());
|
|
262
|
shipmentContainerHeader.setZoneCode(location.getZoneCode());
|
|
263
|
shipmentContainerHeader.setWarehouseCode(ShiroUtils.getWarehouseCode());
|
|
264
|
shipmentContainerHeader.setUWarehouseCode(shipmentHeader.getUWarehouseCode());
|
|
265
266
267
268
269
270
271
272
273
274
275
276
277
|
shipmentContainerHeader.setCompanyCode(shipmentDetail.getCompanyCode());
shipmentContainerHeader.setPort(shipmentDetail.getPort());
shipmentContainerHeader.setContainerType(container.getContainerType());
shipmentContainerHeader.setStatus(QuantityConstant.SHIPMENT_CONTAINER_BUILD);
shipmentContainerHeader.setTaskType(taskType);
shipmentContainerHeader.setTaskCreated(0);
shipmentContainerHeader.setCreatedBy(ShiroUtils.getLoginName());
Boolean flag = this.save(shipmentContainerHeader);
if (flag == false) {
throw new ServiceException("新建组盘头失败,sql错误");
}
return shipmentContainerHeader;
}
|
|
278
279
280
|
}
/**
|
|
281
282
283
284
285
286
|
* 组盘明细
* 1.查看是否有同一出库明细的物料需要出库
* 2.有时修改阻盘明细的出库数量就行
* 3.没有就新建明细
* 4。查看组盘头状态,如果状态在10到20,则生成任务明细或修改任务明细的数量
*
|
|
287
288
289
290
291
292
293
294
|
* @param shipmentDetail
* @param shipmentContainerHeader
* @param shipmentCombinationModel
* @return
*/
private ShipmentContainerDetail ShipmentContainerDetailAdd(ShipmentDetail shipmentDetail,
ShipmentContainerHeader shipmentContainerHeader,
ShipmentCombinationModel shipmentCombinationModel) {
|
|
295
|
|
|
296
|
Boolean flag = true;
|
|
297
|
//1.查看是否有同一出库明细的物料需要出库
|
|
298
|
LambdaQueryWrapper<ShipmentContainerDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
299
300
301
302
303
304
|
lambdaQueryWrapper.eq(ShipmentContainerDetail::getShippingContainerId, shipmentContainerHeader.getId())
.eq(ShipmentContainerDetail::getLocationCode, shipmentContainerHeader.getLocationCode())
.eq(ShipmentContainerDetail::getContainerCode, shipmentContainerHeader.getContainerCode())
.eq(ShipmentContainerDetail::getShipmentDetailId, shipmentCombinationModel.getShipmentDetailId())
.eq(ShipmentContainerDetail::getInventoryId, shipmentCombinationModel.getInventoryDetailId())
.eq(ShipmentContainerDetail::getWarehouseCode, ShiroUtils.getWarehouseCode());
|
|
305
|
ShipmentContainerDetail shipmentContainerDetail = shipmentContainerDetailService.getOne(lambdaQueryWrapper);
|
|
306
307
|
ShipmentContainerDetail shipmentContainerDetaill = new ShipmentContainerDetail();
|
|
308
|
Container container = containerService.getContainerByCode(shipmentContainerHeader.getContainerCode());
|
|
309
|
|
|
310
|
//2.有时修改阻盘明细的出库数量就行
|
|
311
|
if (shipmentContainerDetail != null) {
|
|
312
|
shipmentContainerDetail.setQty(shipmentContainerDetail.getQty().add(shipmentCombinationModel.getShipQty()));
|
|
313
|
shipmentContainerDetaill = shipmentContainerDetail;
|
|
314
|
shipmentContainerDetaill.setZoneCode(container.getZoneCode());
|
|
315
316
|
flag = shipmentContainerDetailService.saveOrUpdate(shipmentContainerDetail);
if (flag == false) {
|
|
317
318
|
throw new ServiceException("修改组盘明细失败,sql错误");
}
|
|
319
|
} else {
|
|
320
|
|
|
321
|
//3.没有就新建明细
|
|
322
323
324
|
LambdaQueryWrapper<Material> lam = Wrappers.lambdaQuery();
lam.eq(Material::getCode, shipmentDetail.getMaterialCode())
.eq(Material::getWarehouseCode, ShiroUtils.getWarehouseCode());
|
|
325
|
Material material = materialService.getOne(lam);
|
|
326
327
328
|
if (material == null) {
throw new ServiceException("出库单(" + shipmentDetail.getShipmentCode() + ")的物料(" + shipmentDetail.getMaterialCode() + ")不存在!");
}
|
|
329
330
|
|
|
331
|
shipmentContainerDetaill.setWarehouseCode(shipmentContainerHeader.getWarehouseCode());
|
|
332
|
shipmentContainerDetaill.setUWarehouseCode(shipmentContainerHeader.getUWarehouseCode());
|
|
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
shipmentContainerDetaill.setCompanyCode(shipmentContainerHeader.getCompanyCode());
shipmentContainerDetaill.setContainerCode(shipmentContainerHeader.getContainerCode());
shipmentContainerDetaill.setLocationCode(shipmentContainerHeader.getLocationCode());
shipmentContainerDetaill.setInventoryId(shipmentCombinationModel.getInventoryDetailId());
shipmentContainerDetaill.setInventorySts(shipmentDetail.getInventorySts());
shipmentContainerDetaill.setShippingContainerId(shipmentContainerHeader.getId());
shipmentContainerDetaill.setShipmentCode(shipmentDetail.getShipmentCode());
shipmentContainerDetaill.setShipmentId(shipmentDetail.getShipmentId());
shipmentContainerDetaill.setShipmentDetailId(shipmentDetail.getId());
shipmentContainerDetaill.setMaterialCode(shipmentDetail.getMaterialCode());
shipmentContainerDetaill.setMaterialName(shipmentDetail.getMaterialName());
shipmentContainerDetaill.setMaterialSpec(shipmentDetail.getMaterialSpec());
shipmentContainerDetaill.setMaterialUnit(shipmentDetail.getMaterialUnit());
shipmentContainerDetaill.setQty(shipmentCombinationModel.getShipQty());
shipmentContainerDetaill.setWaveId(shipmentDetail.getWaveId());
shipmentContainerDetaill.setTaskCreated(0);
|
|
349
|
shipmentContainerDetaill.setStatus(QuantityConstant.SHIPMENT_CONTAINER_BUILD);
|
|
350
351
352
353
|
shipmentContainerDetaill.setBatch(shipmentDetail.getBatch());
shipmentContainerDetaill.setLot(shipmentDetail.getLot());
shipmentContainerDetaill.setProjectNo(shipmentDetail.getProjectNo());
shipmentContainerDetaill.setCreatedBy(ShiroUtils.getLoginName());
|
|
354
|
shipmentContainerDetaill.setZoneCode(container.getZoneCode());
|
|
355
|
flag = shipmentContainerDetailService.save(shipmentContainerDetaill);
|
|
356
|
if (flag == false) {
|
|
357
358
|
throw new ServiceException("新建组盘明细失败,sql错误");
}
|
|
359
|
}
|
|
360
|
|
|
361
|
//4.查看组盘头状态,如果状态在10到30,则生成任务明细或修改任务明细的数量
|
|
362
|
//查看任务头
|
|
363
|
int containerHeaderStatus = shipmentContainerHeader.getStatus().intValue();
|
|
364
365
366
367
|
if (QuantityConstant.SHIPMENT_CONTAINER_TASK <= containerHeaderStatus &&
containerHeaderStatus < QuantityConstant.SHIPMENT_CONTAINER_FINISHED) {
LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
taskHeaderLambdaQueryWrapper.eq(TaskHeader::getWarehouseCode, shipmentContainerHeader.getWarehouseCode())
|
|
368
|
.in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT, QuantityConstant.TASK_TYPE_WHOLESHIPMENT)
|
|
369
370
371
|
.eq(TaskHeader::getAllocationHeadId, shipmentContainerHeader.getId());
TaskHeader taskHeader = taskHeaderService.getOne(taskHeaderLambdaQueryWrapper);
if (taskHeader == null) {
|
|
372
|
throw new ServiceException("有相同的组盘头,但找不到相应的任务头");
|
|
373
|
}
|
|
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getContainerCode, shipmentContainerHeader.getContainerCode())
.eq(InventoryDetail::getWarehouseCode, shipmentContainerHeader.getWarehouseCode());
List<InventoryDetail> inventories = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
BigDecimal inventoryTotal = new BigDecimal("0");
for (InventoryDetail item : inventories) {
BigDecimal lastQty = item.getQty().subtract(item.getTaskQty());
inventoryTotal = inventoryTotal.add(lastQty);
}
if (inventoryTotal.compareTo(new BigDecimal(0)) <= 0 && !container.getContainerType().equals(QuantityConstant.AGV_CONTAINER_TYPE)) {
//整盘出库
taskHeader.setTaskType(QuantityConstant.TASK_TYPE_WHOLESHIPMENT);
taskHeaderService.updateById(taskHeader);
}
|
|
389
|
if (shipmentContainerDetaill == null || shipmentContainerDetaill.getId() == null) {
|
|
390
391
392
|
//shipmentContainerDetaill为空时,说明组盘明细不是新建,so修改任务明细
//查找任务明细
LambdaQueryWrapper<TaskDetail> taskDetailLam = Wrappers.lambdaQuery();
|
|
393
394
395
|
taskDetailLam.eq(TaskDetail::getWarehouseCode, shipmentContainerDetail.getWarehouseCode())
.eq(TaskDetail::getAllocationId, shipmentContainerDetail.getId())
.eq(TaskDetail::getTaskId, taskHeader.getId())
|
|
396
|
.in(TaskDetail::getTaskType, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT, QuantityConstant.TASK_TYPE_WHOLESHIPMENT);
|
|
397
|
TaskDetail taskDetail = taskDetailService.getOne(taskDetailLam);
|
|
398
|
if (taskDetail == null) {
|
|
399
400
401
|
throw new ServiceException("找不到对应的任务明细");
}
taskDetail.setQty(taskDetail.getQty().add(shipmentCombinationModel.getShipQty()));
|
|
402
403
|
flag = taskDetailService.saveOrUpdate(taskDetail);
if (flag == false) {
|
|
404
405
|
throw new ServiceException("修改任务明细失败,sql错误");
}
|
|
406
407
408
409
|
shipmentContainerDetail.setStatus(QuantityConstant.SHIPMENT_CONTAINER_TASK);
if (!shipmentContainerDetailService.updateById(shipmentContainerDetail)) {
throw new ServiceException("修改组盘明细状态失败");
}
|
|
410
|
} else {
|
|
411
|
//shipmentContainerDetaill不为空时,说明组盘明细是新建,so新建任务明细
|
|
412
|
LambdaQueryWrapper<TaskDetail> taskDetailLam = Wrappers.lambdaQuery();
|
|
413
414
|
taskDetailLam.eq(TaskDetail::getWarehouseCode, shipmentContainerDetaill.getWarehouseCode())
.eq(TaskDetail::getAllocationId, shipmentContainerDetaill.getId())
|
|
415
416
417
418
419
420
421
|
.eq(TaskDetail::getTaskId, taskHeader.getId())
.in(TaskDetail::getTaskType, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT, QuantityConstant.TASK_TYPE_WHOLESHIPMENT);
TaskDetail taskDetail = taskDetailService.getOne(taskDetailLam);
if (taskDetail != null) {
} else {
taskDetail = new TaskDetail();
}
|
|
422
423
424
425
426
427
428
429
430
431
432
433
434
|
taskDetail.setTaskId(taskHeader.getId());
taskDetail.setInternalTaskType(taskHeader.getInternalTaskType());
taskDetail.setWarehouseCode(taskHeader.getWarehouseCode());
taskDetail.setCompanyCode(taskHeader.getCompanyCode());
taskDetail.setTaskType(taskHeader.getTaskType());
taskDetail.setAllocationId(shipmentContainerDetaill.getId());
taskDetail.setBillCode(shipmentContainerDetaill.getShipmentCode());
taskDetail.setBillDetailId(shipmentContainerDetaill.getShipmentDetailId());
taskDetail.setMaterialCode(shipmentContainerDetaill.getMaterialCode());
taskDetail.setMaterialName(shipmentContainerDetaill.getMaterialName());
taskDetail.setMaterialSpec(shipmentContainerDetaill.getMaterialSpec());
taskDetail.setMaterialUnit(shipmentContainerDetaill.getMaterialUnit());
taskDetail.setFromInventoryId(shipmentContainerDetaill.getInventoryId());
|
|
435
436
|
taskDetail.setToInventoryId(shipmentContainerDetaill.getInventoryId());
taskDetail.setInventorySts(shipmentContainerDetaill.getInventorySts());
|
|
437
438
439
440
441
442
443
|
taskDetail.setQty(shipmentContainerDetaill.getQty());
taskDetail.setContainerCode(taskHeader.getContainerCode());
taskDetail.setFromLocation(taskHeader.getFromLocation());
taskDetail.setToLocation(taskHeader.getToLocation());
taskDetail.setLot(shipmentContainerDetaill.getLot());
taskDetail.setWaveId(shipmentContainerDetaill.getWaveId());
taskDetail.setBatch(shipmentContainerDetaill.getBatch());
|
|
444
|
taskDetail.setProjectNo(shipmentContainerDetaill.getProjectNo());
|
|
445
|
taskDetail.setReferenceCode(shipmentDetail.getReferCode());
|
|
446
|
taskDetail.setGoodsShelfNo(taskHeader.getGoodsShelfNo());
|
|
447
|
if (shipmentContainerHeader.getStatus().equals(QuantityConstant.SHIPMENT_CONTAINER_TASK)) {
|
|
448
449
|
// taskDetail.setStatus(QuantityConstant.TASK_STATUS_BUILD);
taskDetail.setStatus(QuantityConstant.TASK_STATUS_RELEASE);
|
|
450
|
} else {
|
|
451
|
taskDetail.setStatus(QuantityConstant.TASK_STATUS_RELEASE);
|
|
452
453
454
|
}
taskDetail.setCreatedBy(ShiroUtils.getLoginName());
taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName());
|
|
455
|
flag = taskDetailService.saveOrUpdate(taskDetail);
|
|
456
|
if (flag == false) {
|
|
457
458
|
throw new ServiceException("新建任务明细失败,sql错误");
}
|
|
459
460
|
shipmentContainerDetaill.setStatus(QuantityConstant.SHIPMENT_CONTAINER_TASK);
if (!shipmentContainerDetailService.updateById(shipmentContainerDetaill)) {
|
|
461
462
|
throw new ServiceException("修改组盘明细状态失败");
}
|
|
463
464
|
}
}
|
|
465
466
467
|
return shipmentContainerDetail;
}
|
|
468
469
470
|
/**
* 取消组盘的一组明细
|
|
471
|
*
|
|
472
473
474
475
|
* @param detailIds
* @return
*/
@Override
|
|
476
|
public AjaxResult cancelCombinationDetail(List<Integer> detailIds) {
|
|
477
|
List<ShipmentContainerDetail> shipmentContainerDetails = new ArrayList<>();
|
|
478
|
for (int detailId : detailIds) {
|
|
479
480
481
482
483
484
485
486
|
ShipmentContainerDetail shipmentContainerDetail = shipmentContainerDetailService.getById(detailId);
shipmentContainerDetails.add(shipmentContainerDetail);
}
return cancelCombinationDetailInner(shipmentContainerDetails);
}
/**
* 取消组盘的一组明细
|
|
487
|
*
|
|
488
489
490
491
492
|
* @param shipmentContainerDetails
* @return
*/
@Override
@Transactional
|
|
493
494
|
public AjaxResult cancelCombinationDetailInner(List<ShipmentContainerDetail> shipmentContainerDetails) {
for (ShipmentContainerDetail shipmentContainerDetail : shipmentContainerDetails) {
|
|
495
496
|
//获取头
ShipmentContainerHeader shipmentContainerHeader = this.getById(shipmentContainerDetail.getShippingContainerId());
|
|
497
498
|
if (shipmentContainerHeader.getStatus() >= QuantityConstant.SHIPMENT_CONTAINER_TASK) {
return AjaxResult.error("容器" + shipmentContainerHeader.getContainerCode() + "非新建状态,不允许取消明细");
|
|
499
500
501
|
}
//恢复占用库存
InventoryDetail inventoryDetail = inventoryDetailService.getById(shipmentContainerDetail.getInventoryId());
|
|
502
|
if (inventoryDetail != null) {
|
|
503
504
505
|
inventoryDetail.setTaskQty(inventoryDetail.getTaskQty().subtract(shipmentContainerDetail.getQty()));
inventoryDetailService.saveOrUpdate(inventoryDetail);
}
|
|
506
507
|
//恢复单据发货数量
ShipmentDetail shipmentDetail = shipmentDetailService.getById(shipmentContainerDetail.getShipmentDetailId());
|
|
508
|
shipmentDetail.setTaskQty(shipmentDetail.getTaskQty().subtract(shipmentContainerDetail.getQty()));
|
|
509
|
if (shipmentDetail.getTaskQty().compareTo(BigDecimal.ZERO) != 0) {
|
|
510
|
shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_WAVE);//明细状态恢复,如果删除后还有以出数量就是波次
|
|
511
512
|
} else {
shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_POOL);//明细状态
|
|
513
514
515
516
517
518
519
520
|
}
shipmentDetailService.saveOrUpdate(shipmentDetail);
//删除这个配盘明细
shipmentContainerDetailService.removeById(shipmentContainerDetail.getId());
//查询头表下还有没有明细,如果没有,则删了这个头表
ShipmentContainerDetail condition = new ShipmentContainerDetail();
condition.setShippingContainerId(shipmentContainerDetail.getShippingContainerId());
|
|
521
522
|
List<Map<String, Object>> list = shipmentContainerDetailService.selectListMapByEqual("id", condition);
if (list == null || list.size() == 0) {
|
|
523
|
this.removeById(shipmentContainerHeader.getId());
|
|
524
525
|
locationService.updateStatus(shipmentContainerHeader.getLocationCode(),
QuantityConstant.STATUS_LOCATION_EMPTY);
|
|
526
527
528
529
530
531
532
|
}
//更新单据状态
shipmentHeaderService.updateShipmentStatus(shipmentDetail.getShipmentId());
}
return AjaxResult.success("");
}
|
|
533
534
|
/**
* 取消组盘
|
|
535
|
*
|
|
536
537
538
539
|
* @param shipmentContainerIds
* @return
*/
@Override
|
|
540
|
public AjaxResult cancelCombination(List<Integer> shipmentContainerIds) {
|
|
541
542
|
AjaxResult result = checkForCancelCombination(shipmentContainerIds);
|
|
543
|
if (result.getCode() != RetCode.SUCCESS.getValue()) {
|
|
544
545
|
return result;
}
|
|
546
547
548
|
for (int id : shipmentContainerIds) {
LambdaQueryWrapper<ShipmentContainerDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ShipmentContainerDetail::getShippingContainerId, id);
|
|
549
550
|
List<ShipmentContainerDetail> shipmentContainerDetails = shipmentContainerDetailService.list(lambdaQueryWrapper);
result = cancelCombinationDetailInner(shipmentContainerDetails);
|
|
551
|
if (result.hasErr()) {
|
|
552
553
554
555
556
557
|
return result;
}
}
return AjaxResult.success("");
}
|
|
558
559
|
/**
|
|
560
561
|
* 出库自动组盘
*
|
|
562
563
564
565
566
567
|
* @param shipmentCode
* @return
*/
@Override
@Transactional
public AjaxResult autoCombination(String shipmentCode) {
|
|
568
|
LambdaQueryWrapper<ShipmentHeader> shipmentHeaderLam = Wrappers.lambdaQuery();
|
|
569
570
|
shipmentHeaderLam.eq(ShipmentHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(ShipmentHeader::getCode, shipmentCode);
|
|
571
|
ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(shipmentHeaderLam);
|
|
572
|
if (shipmentHeader == null) {
|
|
573
574
|
throw new ServiceException("系统没有此单据");
}
|
|
575
|
shipmentPreferenceService.checkShipmentProcess(shipmentHeader.getId().toString(), 100, shipmentCode);
|
|
576
|
|
|
577
578
579
|
LambdaQueryWrapper<ShipmentDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ShipmentDetail::getShipmentCode, shipmentCode)
.eq(ShipmentDetail::getWarehouseCode, ShiroUtils.getWarehouseCode());
|
|
580
|
List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(lambdaQueryWrapper);
|
|
581
|
if (shipmentDetailList.isEmpty()) {
|
|
582
583
|
return AjaxResult.error("找不到子单链");
}
|
|
584
|
for (ShipmentDetail shipmentDetail : shipmentDetailList) {
|
|
585
|
/* if(shipmentDetail.getWaveId() != 0){
|
|
586
|
return AjaxResult.error(shipmentCode+"单号已加入波次"+shipmentDetail.getWaveId()+",无法自动组盘");
|
|
587
|
}*/
|
|
588
|
}
|
|
589
590
591
592
593
|
return this.autoCombination(shipmentDetailList);
}
//出库自动组盘
|
|
594
|
@Override
|
|
595
|
public AjaxResult autoCombination(List<ShipmentDetail> shipmentDetailList) {
|
|
596
|
int num = 0;
|
|
597
|
List<Integer> list = new ArrayList<>();
|
|
598
599
|
lable1:
for (ShipmentDetail item : shipmentDetailList) {
|
|
600
|
//获取需要出库数量
|
|
601
|
BigDecimal shipmentQty = item.getQty().subtract(item.getTaskQty());
|
|
602
603
604
605
|
String userDef1 = item.getUserDef1();
if (StringUtils.isNotEmpty(userDef1)) {
shipmentQty = new BigDecimal(userDef1);
}
|
|
606
607
|
//判断是否还有需要出库的物料,如果没有就跳过该物料
if (shipmentQty.compareTo(BigDecimal.ZERO) <= 0) {
|
|
608
|
continue lable1;
|
|
609
|
}
|
|
610
|
List<InventoryDetail> inventoryList = null;
|
|
611
612
|
if (item.getWarehouseCode().equals("CS0001")) {
inventoryList = shippingCombinationService.getInventorys(item);
|
|
613
|
}
|
|
614
|
if (item.getWarehouseCode().equals("KS0001")) {
|
|
615
616
|
inventoryList = shippingCombinationService.getInventoryAutoKS(item);
}
|
|
617
|
if (inventoryList == null) {
|
|
618
|
// throw new ServiceException("没有可用库存");
|
|
619
|
continue lable1;
|
|
620
|
}
|
|
621
|
inventoryList = combCondit(inventoryList);
|
|
622
|
if (inventoryList.isEmpty()) {
|
|
623
|
continue lable1;
|
|
624
|
// throw new ServiceException("没有可用库存");
|
|
625
|
}
|
|
626
|
//去除已锁的库存
|
|
627
|
ArrayList<InventoryDetail> removeInventoryList = new ArrayList<>();
|
|
628
629
630
|
// List<TaskHeader> taskHeaderList = taskHeaderService.getUnCompleteTaskList();
// List<ReceiptContainerHeader> receiptContainerHeaderList =
// receiptContainerHeaderService.getUnCompleteCombineList();
|
|
631
632
|
boolean lock = false;
for (InventoryDetail inventoryDetail : inventoryList) {
|
|
633
634
635
636
637
638
639
640
641
642
643
644
|
// 校验锁定数量之前,先查询锁定工作令数据是否存在
// LockingWorkOrder lockingWorkOrder = lockingWorkOrderService.selectLockingWorkOrder(item.getMoCode(), item.getMaterialCode(), item.getId().toString());
// if (lockingWorkOrder == null){
// //校验库存是否有被锁定的数量
// LockingWorkOrder lockingWorkOrder1=new LockingWorkOrder();
// lockingWorkOrder1.setInventoryId(inventoryDetail.getId().toString());
// List<LockingWorkOrder> lockingWorkOrderList = lockingWorkOrderService.getListByDoamin(lockingWorkOrder1);
// BigDecimal qty = inventoryDetail.getQty().subtract(inventoryDetail.getTaskQty());
// if (lockingWorkOrderService.inventoryCheck(lockingWorkOrderList, qty, shipmentQty)){
// continue;
// }
// }
|
|
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
|
// LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
// containerLambdaQueryWrapper.eq(Container::getCode, inventoryDetail.getContainerCode());
// Container container = containerService.getOne(containerLambdaQueryWrapper);
// if (QuantityConstant.STATUS_CONTAINER_LOCK.equals(container.getStatus())) {
// removeInventoryList.add(inventoryDetail);
// lock = true;
// }
// if(taskHeaderList != null) {
// for(TaskHeader taskHeader : taskHeaderList) {
// if(taskHeader.getContainerCode().equals(container.getCode())) {
// removeInventoryList.add(inventoryDetail);
// }
// }
// }
// if(receiptContainerHeaderList != null) {
// for(ReceiptContainerHeader receiptContainerHeader : receiptContainerHeaderList) {
// if(receiptContainerHeader.getContainerCode().equals(container.getCode())) {
// removeInventoryList.add(inventoryDetail);
// }
// }
// }
|
|
666
667
668
669
|
// 判断锁定工作令数据是否需要修改
// if (lockingWorkOrder != null){
// lockingWorkOrderService.checkLockingWorkOrder(lockingWorkOrder, shipmentQty);
// }
|
|
670
|
}
|
|
671
|
inventoryList.removeAll(removeInventoryList);
|
|
672
|
if (inventoryList.size() < 1 && lock) {
|
|
673
|
// return AjaxResult.error("'"+item.getMaterialName()+"' 所在托盘全部处于锁定状态,请完成或取消任务后再进行组盘");
|
|
674
|
continue lable1;
|
|
675
676
|
}
|
|
677
|
if (inventoryList.size() < 1 && item.getWaveId() != 0) {
|
|
678
|
Wave wave = waveService.getById(item.getWaveId());
|
|
679
680
681
|
wave.setStatus(QuantityConstant.WAVE_STATUS_ERROR);
wave.setCurrentWaveStep(QuantityConstant.WAVE_STEP_ERROR);
wave.setLastWaveStep(QuantityConstant.WAVE_STEP_BUILD);
|
|
682
|
waveService.updateById(wave);
|
|
683
|
throw new ServiceException("主单为" + item.getShipmentCode() + "子单id为" + item.getId() + "的单据没有库存,波次失败");
|
|
684
|
}
|
|
685
686
687
|
if (inventoryList.size() < 1) {
num = num + 1;
} else {
|
|
688
|
//遍历扣减库存,知道扣完为止
|
|
689
690
|
lable2:
for (InventoryDetail inventory : inventoryList) {
|
|
691
692
|
//判断是否组盘完毕,完毕就退出内循环
if (shipmentQty.compareTo(BigDecimal.ZERO) <= 0) {
|
|
693
|
break lable2;
|
|
694
695
|
}
|
|
696
|
|
|
697
698
699
700
|
BigDecimal inventoryQty = inventory.getQty().subtract(inventory.getTaskQty());
ShipmentCombinationModel shipmentCombination = new ShipmentCombinationModel();
shipmentCombination.setInventoryDetailId(inventory.getId());
shipmentCombination.setShipmentDetailId(item.getId());
|
|
701
|
shipmentCombination.setType((short) QuantityConstant.TASK_TYPE_WHOLESHIPMENT);
|
|
702
|
|
|
703
704
705
|
if (inventoryQty.compareTo(BigDecimal.ZERO) <= 0) {
continue lable2;
}
|
|
706
707
708
709
|
//如果库存数 >= 待出库数,组盘数就是待出库数并且结束组盘,否则组盘数就是库存数
if (inventoryQty.compareTo(shipmentQty) > -1) {
shipmentCombination.setShipQty(shipmentQty);
} else {
|
|
710
|
shipmentCombination.setShipQty(inventoryQty);
|
|
711
|
}
|
|
712
713
|
try {
ShipmentContainerHeader shipmentContainerHeader = this.combination(shipmentCombination);
|
|
714
715
|
list.add(shipmentContainerHeader.getId());
shipmentQty = shipmentQty.subtract(shipmentCombination.getShipQty());
|
|
716
|
} catch (Exception e) {
|
|
717
718
|
break lable2;
}
|
|
719
|
|
|
720
721
722
|
}
}
}
|
|
723
|
|
|
724
|
if (num == shipmentDetailList.size()) {
|
|
725
726
|
//throw new ServiceException("单据物料的库存分配规则在此库区没有库存,无法出库");
throw new ServiceException("此库区没有库存了,无法出库");
|
|
727
|
}
|
|
728
|
return AjaxResult.success("成功", list);
|
|
729
730
|
}
|
|
731
732
|
/**
* 检查是否可以进行取消配盘
|
|
733
|
*
|
|
734
735
736
737
738
|
* @param shipmentContainerIds
* @return
*/
@Override
public AjaxResult checkForCancelCombination(List<Integer> shipmentContainerIds) {
|
|
739
|
for (int id : shipmentContainerIds) {
|
|
740
|
ShipmentContainerHeader shipmentContainerHeader = this.getById(id);
|
|
741
|
if (shipmentContainerHeader == null) {
|
|
742
743
|
return AjaxResult.error("找不到组盘信息");
}
|
|
744
|
if (shipmentContainerHeader.getStatus() >= QuantityConstant.SHIPMENT_CONTAINER_TASK) {
|
|
745
746
747
748
749
750
751
752
753
|
return AjaxResult.error("存在已生成任务的记录,请先取消任务再取消组盘");
}
}
return AjaxResult.success("");
}
/* 生成任务 */
@Override
@Transactional
|
|
754
|
public AjaxResult createTask(List<Integer> idList) {
|
|
755
|
ShipmentTaskCreateModel shipmentTask = new ShipmentTaskCreateModel();
|
|
756
|
for (Integer id : idList) {
|
|
757
|
shipmentTask.setShipmentContainerHeaderIds(id);
|
|
758
|
AjaxResult ajaxResult = shipmentTaskService.createTaskFromShipmentContainers(shipmentTask);
|
|
759
|
if (ajaxResult.hasErr()) {
|
|
760
761
|
return ajaxResult;
}
|
|
762
763
764
765
|
}
return AjaxResult.success("全部生成完毕");
}
|
|
766
767
768
769
770
771
772
773
774
775
|
/**
* 取消出库任务
*/
@Override
@Transactional(rollbackFor = ServiceException.class)
public boolean cancelShipment(Integer combineHeaderId) {
// 回滚组盘主表状态
ShipmentContainerHeader shipmentContainerHeader = new ShipmentContainerHeader();
shipmentContainerHeader.setId(combineHeaderId);
shipmentContainerHeader.setStatus(QuantityConstant.SHIPMENT_CONTAINER_BUILD);
|
|
776
|
if (!updateById(shipmentContainerHeader)) {
|
|
777
778
779
780
|
throw new ServiceException("更新出库组盘头表失败");
}
// 回滚组盘明细状态
LambdaQueryWrapper<ShipmentContainerDetail> queryWrapper = Wrappers.lambdaQuery();
|
|
781
|
queryWrapper.eq(ShipmentContainerDetail::getShippingContainerId, combineHeaderId);
|
|
782
783
784
785
|
List<ShipmentContainerDetail> shipmentContainerDetailList = shipmentContainerDetailService.list(queryWrapper);
for (ShipmentContainerDetail shipmentContainerDetail : shipmentContainerDetailList) {
shipmentContainerDetail.setStatus(QuantityConstant.SHIPMENT_CONTAINER_BUILD);
}
|
|
786
|
if (!shipmentContainerDetailService.updateBatchById(shipmentContainerDetailList)) {
|
|
787
788
789
790
791
|
throw new ServiceException("更新出库组盘明细失败");
}
return true;
}
|
|
792
793
794
795
|
@Override
public AjaxResult getShipmentInfoByCode(String code) {
LambdaQueryWrapper<ShipmentContainerDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ShipmentContainerDetail::getShipmentCode, code)
|
|
796
|
.le(ShiroUtils.getWarehouseCode().equals("KS0001"), ShipmentContainerDetail::getStatus, QuantityConstant.SHIPMENT_CONTAINER_TASK)
|
|
797
798
|
.eq(ShipmentContainerDetail::getWarehouseCode, ShiroUtils.getWarehouseCode())
.orderByAsc(ShipmentContainerDetail::getStatus);
|
|
799
800
801
802
803
|
List<ShipmentContainerDetail> shipmentContainerDetails = shipmentContainerDetailService.list(lambdaQueryWrapper);
return AjaxResult.success(shipmentContainerDetails);
}
|
|
804
805
806
807
808
809
810
|
@Override
public int getUnCompleteCombineNumber(String containerCode) {
LambdaQueryWrapper<ShipmentContainerHeader> shipmentContainerHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
shipmentContainerHeaderLambdaQueryWrapper.eq(ShipmentContainerHeader::getContainerCode, containerCode)
.lt(ShipmentContainerHeader::getStatus, QuantityConstant.SHIPMENT_CONTAINER_FINISHED);
int number = 0;
List<ShipmentContainerHeader> shipmentContainerHeaderList = list(shipmentContainerHeaderLambdaQueryWrapper);
|
|
811
|
if (shipmentContainerHeaderList != null && shipmentContainerHeaderList.size() > 0) {
|
|
812
813
814
815
816
817
818
819
820
821
822
823
|
number = shipmentContainerHeaderList.size();
}
return number;
}
@Override
public List<ShipmentContainerHeader> getUnCompleteCombineList() {
LambdaQueryWrapper<ShipmentContainerHeader> shipmentContainerHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
shipmentContainerHeaderLambdaQueryWrapper.lt(ShipmentContainerHeader::getStatus,
QuantityConstant.SHIPMENT_CONTAINER_FINISHED);
List<ShipmentContainerHeader> shipmentContainerHeaderList =
list(shipmentContainerHeaderLambdaQueryWrapper);
|
|
824
|
return shipmentContainerHeaderList;
|
|
825
826
|
}
|
|
827
|
private List<InventoryDetail> combCondit(List<InventoryDetail> inventoryDetails) {
|
|
828
829
830
831
|
List<Role> roles = roleService.selectRolesByUserId(ShiroUtils.getUserId(), ShiroUtils.getWarehouseCode());
List<Integer> roleIds = roles.stream().map(Role::getId).collect(Collectors.toList());
int role = QuantityConstant.ROLE_XC;
int roleNum = 0;
|
|
832
|
if (roleIds.contains(role)) {
|
|
833
|
roleNum = 1;
|
|
834
|
} else {
|
|
835
836
837
838
839
|
roleNum = 2;
}
String XC = QuantityConstant.ZONECODE_XC;
List<InventoryDetail> returnList = Collections.EMPTY_LIST;
for (InventoryDetail inventoryDetail : inventoryDetails) {
|
|
840
841
842
|
if (roleNum == 1 && !XC.equals(inventoryDetail.getZoneCode())) {
return returnList;
} else if (roleNum == 2 && XC.equals(inventoryDetail.getZoneCode())) {
|
|
843
844
845
846
847
848
|
return returnList;
}
}
return inventoryDetails;
}
|
|
849
|
}
|