Commit 60fc6633fb1668b1cfc7673ed069d94d2dcccd17
1 parent
cabf7776
修改入库任务完成、出库自动组盘
Showing
4 changed files
with
94 additions
and
494 deletions
src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderServiceImpl.java
... | ... | @@ -243,11 +243,12 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont |
243 | 243 | Boolean flag =true; |
244 | 244 | //1.查看是否有同一出库明细的物料需要出库 |
245 | 245 | LambdaQueryWrapper<ShipmentContainerDetail> lambdaQueryWrapper=Wrappers.lambdaQuery(); |
246 | - lambdaQueryWrapper.eq(ShipmentContainerDetail::getShippingContainerId,shipmentContainerHeader.getId()) | |
247 | - .eq(ShipmentContainerDetail::getLocationCode,shipmentContainerHeader.getLocationCode()) | |
248 | - .eq(ShipmentContainerDetail::getContainerCode,shipmentContainerHeader.getContainerCode()) | |
249 | - .eq(ShipmentContainerDetail::getShipmentDetailId,shipmentCombinationModel.getShipmentDetailId()) | |
250 | - .eq(ShipmentContainerDetail::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
246 | + lambdaQueryWrapper.eq(ShipmentContainerDetail::getShippingContainerId, shipmentContainerHeader.getId()) | |
247 | + .eq(ShipmentContainerDetail::getLocationCode, shipmentContainerHeader.getLocationCode()) | |
248 | + .eq(ShipmentContainerDetail::getContainerCode, shipmentContainerHeader.getContainerCode()) | |
249 | + .eq(ShipmentContainerDetail::getShipmentDetailId, shipmentCombinationModel.getShipmentDetailId()) | |
250 | + .eq(ShipmentContainerDetail::getInventoryId, shipmentCombinationModel.getInventoryDetailId()) | |
251 | + .eq(ShipmentContainerDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
251 | 252 | ShipmentContainerDetail shipmentContainerDetail = shipmentContainerDetailService.getOne(lambdaQueryWrapper); |
252 | 253 | ShipmentContainerDetail shipmentContainerDetaill = new ShipmentContainerDetail(); |
253 | 254 | |
... | ... | @@ -472,7 +473,7 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont |
472 | 473 | lambdaQueryWrapper.eq(ShipmentDetail::getShipmentCode, shipmentCode) |
473 | 474 | .eq(ShipmentDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); |
474 | 475 | List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(lambdaQueryWrapper); |
475 | - if (shipmentDetailList.size() < 1 || shipmentDetailList == null) { | |
476 | + if (shipmentDetailList.isEmpty()) { | |
476 | 477 | return AjaxResult.error("找不到子单链"); |
477 | 478 | } |
478 | 479 | for(ShipmentDetail shipmentDetail: shipmentDetailList){ |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/ReceiptTaskService.java
... | ... | @@ -91,7 +91,7 @@ public class ReceiptTaskService { |
91 | 91 | * 创建入库任务(整盘入库、补充入库) |
92 | 92 | * |
93 | 93 | * @param ids 入库组盘头表id |
94 | - * @return | |
94 | + * @return AjaxResult 创建结果 | |
95 | 95 | */ |
96 | 96 | @Transactional(rollbackFor = Exception.class) |
97 | 97 | public AjaxResult createReceiptTask(List<Integer> ids) { |
... | ... | @@ -170,9 +170,7 @@ public class ReceiptTaskService { |
170 | 170 | throw new ServiceException("更新入库组盘明细状态出错"); |
171 | 171 | } |
172 | 172 | |
173 | - /** | |
174 | - * 修改明细状态为上架 | |
175 | - */ | |
173 | + /* 修改明细状态为上架*/ | |
176 | 174 | ReceiptDetail receiptDetail = receiptDetailService.getById(item.getReceiptDetailId()); |
177 | 175 | receiptDetail.setProcessStamp(String.valueOf(QuantityConstant.RECEIPT_HEADER_SHELF)); |
178 | 176 | if (!receiptDetailService.updateById(receiptDetail)) { |
... | ... | @@ -192,137 +190,84 @@ public class ReceiptTaskService { |
192 | 190 | |
193 | 191 | /** |
194 | 192 | * 完成入库任务 |
193 | + * @param task 任务 | |
194 | + * @return AjaxResult 完成入库任务结果 | |
195 | 195 | */ |
196 | 196 | @Transactional(rollbackFor = Exception.class) |
197 | 197 | public AjaxResult completeReceiptTask(TaskHeader task) { |
198 | - List<Map<String, Object>> taskReceiptContainerDetail = taskHeaderMapper.getReceiptTask(task.getId()); | |
199 | - if (taskReceiptContainerDetail.size() < 1) { | |
200 | - return AjaxResult.success("未找到对应任务的入库单号!!!"); | |
198 | + /* 判断任务状态*/ | |
199 | + if (task.getStatus().equals(QuantityConstant.TASK_STATUS_COMPLETED)) { | |
200 | + return AjaxResult.error("任务已完成"); | |
201 | 201 | } |
202 | - LambdaQueryWrapper<InventoryHeader> inventoryHeaderErapper = Wrappers.lambdaQuery(); | |
203 | - inventoryHeaderErapper.eq(InventoryHeader::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
202 | + BigDecimal totalQty = BigDecimal.ZERO; | |
203 | + List<TaskDetail> taskDetailList = taskDetailService.findByTaskId(task.getId()); | |
204 | + if (taskDetailList.isEmpty()) { | |
205 | + throw new ServiceException("任务明细为空"); | |
206 | + } | |
207 | + | |
208 | + LambdaQueryWrapper<InventoryHeader> inventoryHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
209 | + inventoryHeaderLambdaQueryWrapper.eq(InventoryHeader::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
204 | 210 | .eq(InventoryHeader::getLocationCode, task.getToLocation()) |
205 | 211 | .eq(InventoryHeader::getContainerCode, task.getContainerCode()); |
206 | - InventoryHeader header = inventoryHeaderService.getOne(inventoryHeaderErapper); | |
207 | - | |
208 | - if(header == null) { | |
209 | - //添加库存单 | |
210 | - header = new InventoryHeader(); | |
211 | - header.setWarehouseCode(task.getWarehouseCode()); | |
212 | - header.setCompanyCode(task.getCompanyCode());//货主 | |
213 | - header.setContainerCode(task.getContainerCode()); | |
214 | - header.setContainerStatus("some"); | |
215 | - header.setLocationCode(task.getToLocation()); | |
216 | - header.setLocking(1); | |
217 | - header.setEnable(1); | |
218 | - header.setTotalQty(new BigDecimal(0)); | |
219 | - header.setTotalWeight(task.getWeight()); | |
220 | - header.setCreatedBy(ShiroUtils.getLoginName()); | |
221 | - header.setCreated(new Date()); | |
222 | - header.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
223 | - header.setLastUpdated(new Date()); | |
224 | - if (!inventoryHeaderService.save(header)) { | |
212 | + InventoryHeader inventoryHeader = inventoryHeaderService.getOne(inventoryHeaderLambdaQueryWrapper); | |
213 | + /* 如果库存 头明细不存在则新增库存头表记录*/ | |
214 | + if (StringUtils.isNull(inventoryHeader)) { | |
215 | + inventoryHeader = new InventoryHeader(); | |
216 | + inventoryHeader.setWarehouseCode(task.getWarehouseCode()); | |
217 | + inventoryHeader.setLocationCode(task.getToLocation()); | |
218 | + inventoryHeader.setContainerCode(task.getContainerCode()); | |
219 | + inventoryHeader.setContainerStatus("some"); | |
220 | + inventoryHeader.setTotalWeight(task.getWeight()); | |
221 | + inventoryHeader.setTotalQty(new BigDecimal(0)); | |
222 | + inventoryHeader.setTotalLines(0); | |
223 | + inventoryHeader.setLocking(1); | |
224 | + inventoryHeader.setEnable(1); | |
225 | + if (!inventoryHeaderService.save(inventoryHeader)) { | |
225 | 226 | throw new ServiceException("添加库存单失败"); |
226 | 227 | } |
228 | + inventoryHeader = inventoryHeaderService.getOne(inventoryHeaderLambdaQueryWrapper); | |
227 | 229 | } |
228 | - for (Map<String, Object> map : taskReceiptContainerDetail) { | |
229 | - //将未完成的任务数量更新到库存表 | |
230 | - if (DataUtils.getInteger(map.get("status")) < QuantityConstant.TASK_STATUS_COMPLETED) { | |
231 | 230 | |
232 | - LambdaQueryWrapper<InventoryDetail> inventory = Wrappers.lambdaQuery(); | |
233 | - inventory.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
234 | - .eq(InventoryDetail::getLocationCode, task.getToLocation()) | |
235 | - .eq(InventoryDetail::getMaterialCode, DataUtils.getString(map.get("materialCode"))) | |
236 | - .eq(InventoryDetail::getContainerCode, DataUtils.getString(map.get("containerCode"))) | |
237 | - .eq(InventoryDetail::getBatch, DataUtils.getString(map.get("batch"))) | |
238 | - .eq(InventoryDetail::getLot, DataUtils.getString(map.get("lot"))) | |
239 | - .eq(InventoryDetail::getProjectNo, DataUtils.getString(map.get("projectNo"))) | |
240 | - .eq(InventoryDetail::getCompanyCode, DataUtils.getString(map.get("companyCode"))); | |
241 | - InventoryDetail detail = inventoryDetailService.getOne(inventory); | |
242 | - if (detail == null) { | |
243 | - //库存明细添加 | |
244 | - detail = new InventoryDetail(); | |
245 | - detail.setInventoryHeaderId(header.getId());//库存头ID | |
246 | - detail.setWarehouseCode(DataUtils.getString(map.get("warehouseCode")));//仓库 | |
247 | - detail.setCompanyCode(task.getCompanyCode());//货主 | |
248 | - detail.setLocationCode(task.getToLocation());//库位号 | |
249 | - detail.setContainerCode(DataUtils.getString(map.get("containerCode")));//容器号 | |
250 | - detail.setMaterialCode(DataUtils.getString(map.get("materialCode")));//物料号 | |
251 | - detail.setMaterialName(DataUtils.getString(map.get("materialName")));//物料名称 | |
252 | - detail.setMaterialSpec(DataUtils.getString(map.get("materialSpec")));//物料规格 | |
253 | - detail.setMaterialUnit(DataUtils.getString(map.get("materialUnit")));//物料单位 | |
254 | - detail.setReceiptCode(DataUtils.getString(map.get("receiptCode")));//入库单编码 | |
255 | - detail.setReceiptDetailId(DataUtils.getInteger(map.get("receiptDetailId")));//入库单明细ID | |
256 | - detail.setBatch(DataUtils.getString(map.get("batch")));//批次 | |
257 | - detail.setLot(DataUtils.getString(map.get("lot")));//批号 | |
258 | - detail.setProjectNo(DataUtils.getString(map.get("projectNo")));//项目号 | |
259 | - detail.setInventorySts(DataUtils.getString(map.get("inventorySts")));//库存状态 | |
260 | -// detail.setManufactureDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("manufactureDate").toString()));//生产日期 | |
261 | -// detail.setExpirationDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("expirationDate").toString()));//失效日期 | |
262 | - detail.setQty(DataUtils.getBigDecimal(map.get("qty")));//数量 | |
263 | - detail.setLockedQty(DataUtils.getBigDecimal(0)); | |
264 | - detail.setTaskQty(DataUtils.getBigDecimal(0)); | |
265 | - detail.setCreatedBy(ShiroUtils.getLoginName());//创建人 | |
266 | - detail.setLastUpdatedBy(ShiroUtils.getLoginName());//创建时间 | |
267 | - if (!inventoryDetailService.save(detail)) { | |
268 | - throw new ServiceException("添加库存明细失败"); | |
269 | - } | |
270 | - } else { | |
271 | - detail.setQty(detail.getQty().add(DataUtils.getBigDecimal(map.get("qty")))); | |
272 | - detail.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
273 | - LambdaUpdateWrapper<InventoryDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate(); | |
274 | - lambdaUpdateWrapper.eq(InventoryDetail::getId, detail.getId()); | |
275 | - if (!inventoryDetailService.update(detail, lambdaUpdateWrapper)){ | |
276 | - throw new ServiceException("更新库存明细失败"); | |
231 | + /* 遍历任务明细,修改关联的入库组盘、入库单状态、添加库存*/ | |
232 | + for (TaskDetail taskDetail : taskDetailList) { | |
233 | + if (taskDetail.getStatus() < QuantityConstant.TASK_STATUS_COMPLETED) { | |
234 | + totalQty = totalQty.add(taskDetail.getQty()); | |
235 | + /*查询入库单明细*/ | |
236 | + ReceiptDetail receiptDetail = receiptDetailService.getById(taskDetail.getBillDetailId()); | |
237 | + if (StringUtils.isNotNull(receiptDetail)) { | |
238 | + | |
239 | + totalQty = this.addInventoryDetail(taskDetail, receiptDetail, inventoryHeader); | |
240 | + //修改组盘表状态为完成 | |
241 | + ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail(); | |
242 | + receiptContainerDetail.setStatus(QuantityConstant.RECEIPT_CONTAINER_FINISHED); | |
243 | + LambdaUpdateWrapper<ReceiptContainerDetail> receiptContainerDetailLambdaUpdateWrapper = Wrappers.lambdaUpdate(); | |
244 | + receiptContainerDetailLambdaUpdateWrapper.eq(ReceiptContainerDetail::getId, taskDetail.getAllocationId()); | |
245 | + if (!receiptContainerDetailService.update(receiptContainerDetail, receiptContainerDetailLambdaUpdateWrapper)){ | |
246 | + throw new ServiceException("更新组盘状态失败"); | |
277 | 247 | } |
278 | - } | |
279 | - //记录库存交易记录 | |
280 | - InventoryTransaction inventoryTransaction = new InventoryTransaction(); | |
281 | - inventoryTransaction.setTransactionType(QuantityConstant.INVENTORY_TRANSACTION_RECEIPT); | |
282 | - inventoryTransaction.setWarehouseCode(DataUtils.getString(map.get("warehouseCode"))); | |
283 | - inventoryTransaction.setCompanyCode(task.getCompanyCode()); | |
284 | - inventoryTransaction.setLocationCode(task.getToLocation()); | |
285 | - inventoryTransaction.setContainerCode(DataUtils.getString(map.get("containerCode"))); | |
286 | - inventoryTransaction.setMaterialCode(DataUtils.getString(map.get("materialCode"))); | |
287 | - inventoryTransaction.setMaterialName(DataUtils.getString(map.get("materialName"))); | |
288 | - inventoryTransaction.setMaterialSpec(DataUtils.getString(map.get("materialSpec")));//物料规格 | |
289 | - inventoryTransaction.setMaterialUnit(DataUtils.getString(map.get("materialUnit")));//物料单位 | |
290 | - inventoryTransaction.setBillCode(DataUtils.getString(map.get("receiptCode"))); | |
291 | - inventoryTransaction.setBillDetailId(DataUtils.getInteger(map.get("receiptDetailId"))); | |
292 | - inventoryTransaction.setBatch(DataUtils.getString(map.get("batch"))); | |
293 | - inventoryTransaction.setLot(DataUtils.getString(map.get("lot"))); | |
294 | - inventoryTransaction.setInventorySts(DataUtils.getString((map.get("inventorySts")))); | |
295 | - inventoryTransaction.setTaskQty(DataUtils.getBigDecimal(map.get("qty"))); | |
296 | - inventoryTransaction.setCreated(new Date()); | |
297 | - inventoryTransaction.setCreatedBy(ShiroUtils.getLoginName()); | |
298 | - if (!inventoryTransactionService.save(inventoryTransaction)) { | |
299 | - throw new ServiceException("新增库存记录失败"); | |
300 | - } | |
301 | 248 | |
302 | - //修改任务明细的状态为完成 | |
303 | - TaskDetail taskDetail = new TaskDetail(); | |
304 | - taskDetail.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); | |
305 | - taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
306 | - taskDetail.setAgingDate(new Date()); //入库时间 | |
307 | - LambdaUpdateWrapper<TaskDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate(); | |
308 | - lambdaUpdateWrapper.eq(TaskDetail::getTaskId, task.getId()); | |
309 | - taskDetailService.update(taskDetail, lambdaUpdateWrapper); | |
310 | - if (!taskDetailService.update(taskDetail, lambdaUpdateWrapper)) { | |
311 | - throw new ServiceException("修改入库单明细失败"); | |
249 | + } else { | |
250 | + throw new ServiceException("未找到id:" + taskDetail.getBillDetailId() + "入库单明细"); | |
312 | 251 | } |
313 | - | |
252 | + receiptDetail.setProcessStamp(String.valueOf(QuantityConstant.RECEIPT_HEADER_POSTING)); | |
253 | + receiptDetailService.updateById(receiptDetail); | |
254 | + receiptDetailService.updateReceiptHeaderLastStatus(receiptDetail.getReceiptId()); | |
255 | + materialWarningService.materialWarning(taskDetail.getMaterialCode(), taskDetail.getCompanyCode()); | |
314 | 256 | } |
257 | + } | |
258 | + if (StringUtils.isNull(inventoryHeader)) { | |
259 | + throw new ServiceException("库存添加失败"); | |
260 | + } else { | |
315 | 261 | |
316 | 262 | } |
317 | 263 | //修改任务主表状态,因为立库任务表单头只对应一个货箱,表单详情的任务会同时完成 |
318 | 264 | task.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); |
319 | - task.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
320 | - task.setLastUpdated(new Date()); | |
321 | 265 | LambdaUpdateWrapper<TaskHeader> taskHeaderLambdaUpdateWrapper = Wrappers.lambdaUpdate(); |
322 | 266 | taskHeaderLambdaUpdateWrapper.eq(TaskHeader::getId, task.getId()); |
323 | 267 | if (!taskHeaderService.update(task, taskHeaderLambdaUpdateWrapper)){ |
324 | 268 | throw new ServiceException("更新任务主表失败"); |
325 | 269 | } |
270 | + | |
326 | 271 | //修改库位状态和对应的容器 |
327 | 272 | Location location = new Location(); |
328 | 273 | location.setContainerCode(task.getContainerCode()); |
... | ... | @@ -341,41 +286,15 @@ public class ReceiptTaskService { |
341 | 286 | if (!containerService.update(container, containerLambdaUpdateWrapper)) { |
342 | 287 | throw new ServiceException("更新容器失败"); |
343 | 288 | } |
344 | - //修改组盘表状态为20 | |
345 | - ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail(); | |
346 | - receiptContainerDetail.setStatus(QuantityConstant.RECEIPT_CONTAINER_REVIEWSUCCESS); | |
347 | - receiptContainerDetail.setProcessStamp("0"); | |
348 | - receiptContainerDetail.setLastUpdated(new Date()); | |
349 | - receiptContainerDetail.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
350 | - LambdaUpdateWrapper<ReceiptContainerDetail> receiptContainerDetailLambdaUpdateWrapper = Wrappers.lambdaUpdate(); | |
351 | - receiptContainerDetailLambdaUpdateWrapper.eq(ReceiptContainerDetail::getReceiptId, DataUtils.getInteger(taskReceiptContainerDetail.get(0).get("receiptId"))); | |
352 | - if (!receiptContainerDetailService.update(receiptContainerDetail, receiptContainerDetailLambdaUpdateWrapper)){ | |
353 | - throw new ServiceException("更新组盘状态失败"); | |
354 | - } | |
355 | 289 | |
356 | 290 | //修改入库组盘头表状态 |
357 | - | |
358 | 291 | ReceiptContainerHeader receiptContainerHeader = new ReceiptContainerHeader(); |
359 | 292 | receiptContainerHeader.setId(task.getAllocationHeadId()); |
360 | - receiptContainerHeader.setLastUpdated(new Date()); | |
361 | - receiptContainerHeader.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
362 | - receiptContainerHeader.setStatus(QuantityConstant.RECEIPT_CONTAINER_FINISHED.intValue()); | |
293 | + receiptContainerHeader.setStatus(QuantityConstant.RECEIPT_CONTAINER_FINISHED); | |
363 | 294 | if (!receiptContainerHeaderService.updateById(receiptContainerHeader)) { |
364 | 295 | throw new ServiceException("更新入库组盘头表状态失败"); |
365 | 296 | } |
366 | - | |
367 | - //修改入库单状态 | |
368 | - ReceiptHeader receiptHeader = new ReceiptHeader(); | |
369 | - receiptHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_POSTING); | |
370 | - receiptHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_POSTING); | |
371 | - receiptHeader.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
372 | - receiptHeader.setLastUpdated(new Date()); | |
373 | - LambdaUpdateWrapper<ReceiptHeader> receiptHeaderLambdaUpdateWrapper = Wrappers.lambdaUpdate(); | |
374 | - receiptHeaderLambdaUpdateWrapper.eq(ReceiptHeader::getId, DataUtils.getInteger(taskReceiptContainerDetail.get(0).get("receiptId"))); | |
375 | - if (!receiptHeaderService.update(receiptHeader, receiptHeaderLambdaUpdateWrapper)) { | |
376 | - throw new ServiceException("更新入库头表状态失败"); | |
377 | - } | |
378 | - return AjaxResult.success("完成入库任务"); | |
297 | + return AjaxResult.success(); | |
379 | 298 | } |
380 | 299 | |
381 | 300 | /** |
... | ... | @@ -445,10 +364,13 @@ public class ReceiptTaskService { |
445 | 364 | inventoryDetail.setAttribute3(receiptDetail.getAttribute3()); |
446 | 365 | inventoryDetail.setReceiptCode(receiptHeader.getCode()); |
447 | 366 | inventoryDetail.setReceiptDetailId(receiptDetail.getId()); |
448 | - if (!inventoryDetailService.save(inventoryDetail)) { | |
449 | - throw new ServiceException("保存库存明细失败"); | |
450 | - } | |
367 | + inventoryHeader.setTotalLines(inventoryHeader.getTotalLines()+1); | |
368 | + } | |
369 | + if (!inventoryDetailService.saveOrUpdate(inventoryDetail)) { | |
370 | + throw new ServiceException("保存库存明细失败"); | |
451 | 371 | } |
372 | + inventoryHeader.setTotalQty(inventoryHeader.getTotalQty().add(taskDetail.getQty())); | |
373 | + inventoryHeaderService.updateById(inventoryHeader); | |
452 | 374 | //记录库存交易记录 |
453 | 375 | InventoryTransaction inventoryTransaction = new InventoryTransaction(); |
454 | 376 | inventoryTransaction.setTransactionType(QuantityConstant.INVENTORY_TRANSACTION_RECEIPT); |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderService.java
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
... | ... | @@ -6,23 +6,17 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
6 | 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
7 | 7 | import com.huaheng.api.wcs.service.taskAssignService.TaskAssignService; |
8 | 8 | import com.huaheng.common.constant.QuantityConstant; |
9 | -import com.huaheng.common.exception.BusinessException; | |
10 | 9 | import com.huaheng.common.exception.service.ServiceException; |
11 | 10 | import com.huaheng.common.support.Convert; |
12 | -import com.huaheng.common.utils.DataUtils; | |
13 | 11 | import com.huaheng.common.utils.StringUtils; |
14 | 12 | import com.huaheng.common.utils.security.ShiroUtils; |
15 | 13 | import com.huaheng.framework.web.domain.AjaxResult; |
16 | -import com.huaheng.mobile.download.Constant; | |
17 | 14 | import com.huaheng.pc.config.configWarning.service.ConfigWarningService; |
18 | 15 | import com.huaheng.pc.config.container.domain.Container; |
19 | 16 | import com.huaheng.pc.config.container.service.ContainerService; |
20 | -import com.huaheng.pc.config.containerCapacity.domain.ContainerCapacity; | |
21 | 17 | import com.huaheng.pc.config.containerCapacity.service.ContainerCapacityService; |
22 | 18 | import com.huaheng.pc.config.location.domain.Location; |
23 | 19 | import com.huaheng.pc.config.location.service.LocationService; |
24 | -import com.huaheng.pc.config.sendMail.service.MailService; | |
25 | -import com.huaheng.pc.config.sendMail.service.SendMailService; | |
26 | 20 | import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail; |
27 | 21 | import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService; |
28 | 22 | import com.huaheng.pc.inventory.cycleCountHeader.service.CycleCountHeaderService; |
... | ... | @@ -30,33 +24,24 @@ import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail; |
30 | 24 | import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService; |
31 | 25 | import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader; |
32 | 26 | import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService; |
33 | -import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction; | |
34 | 27 | import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService; |
35 | -import com.huaheng.pc.monitor.message.service.BrokerMessageLogService; | |
36 | 28 | import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail; |
37 | 29 | import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService; |
38 | 30 | import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader; |
39 | 31 | import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService; |
40 | -import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail; | |
41 | 32 | import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService; |
42 | -import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader; | |
43 | 33 | import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService; |
44 | 34 | import com.huaheng.pc.receipt.receiving.service.ReceivingService; |
45 | -import com.huaheng.pc.shipment.shipmentContainerDetail.domain.ShipmentContainerDetail; | |
46 | 35 | import com.huaheng.pc.shipment.shipmentContainerDetail.service.ShipmentContainerDetailService; |
47 | 36 | import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader; |
48 | 37 | import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService; |
49 | -import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail; | |
50 | 38 | import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService; |
51 | -import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader; | |
52 | 39 | import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService; |
53 | 40 | import com.huaheng.pc.task.taskDetail.domain.TaskDetail; |
54 | 41 | import com.huaheng.pc.task.taskDetail.service.TaskDetailService; |
55 | 42 | import com.huaheng.pc.task.taskHeader.domain.MobileTask; |
56 | -import com.huaheng.pc.task.taskHeader.domain.ShipmentTaskCreateModel; | |
57 | 43 | import com.huaheng.pc.task.taskHeader.domain.TaskHeader; |
58 | 44 | import com.huaheng.pc.task.taskHeader.mapper.TaskHeaderMapper; |
59 | -import io.swagger.models.auth.In; | |
60 | 45 | import org.springframework.beans.factory.annotation.Autowired; |
61 | 46 | import org.springframework.stereotype.Service; |
62 | 47 | import org.springframework.transaction.annotation.Transactional; |
... | ... | @@ -162,15 +147,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
162 | 147 | LambdaQueryWrapper<TaskHeader> taskQueryWrapper = Wrappers.lambdaQuery(); |
163 | 148 | taskQueryWrapper.eq(TaskHeader::getToLocation, locationCode); |
164 | 149 | List<TaskHeader> list = this.list(taskQueryWrapper); |
165 | - if (list.size() < 1) { | |
150 | + if (list.isEmpty()) { | |
166 | 151 | throw new ServiceException("库位(" + locationCode + ")没有任务!"); |
167 | - } else if(list.get(0).getStatus() == 100) { | |
152 | + } else if(list.get(0).getStatus().equals(QuantityConstant.TASK_STATUS_COMPLETED)) { | |
168 | 153 | //如果已完成则不管 |
169 | 154 | throw new ServiceException("库位(" + locationCode + ")任务已经完成!"); |
170 | 155 | } |
171 | - if(list.get(0).getTaskType()==100 || list.get(0).getTaskType()==200){ | |
156 | + if(list.get(0).getInternalTaskType().equals(QuantityConstant.TASK_INTENERTYPE_SHELF)){ | |
172 | 157 | //入库任务 |
173 | - return receiptTaskService.completeReceiptTask((list.get(0))); | |
158 | + return receiptTaskService.completeReceiptTask((list.get(0))); | |
174 | 159 | } else { |
175 | 160 | throw new ServiceException("库位(" + locationCode + ")的任务不是上架,不能完成!"); |
176 | 161 | } |
... | ... | @@ -208,7 +193,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
208 | 193 | } |
209 | 194 | List<Integer> ids = new ArrayList<>(); |
210 | 195 | ids.add(containerHeader.getId()); |
211 | - this.createReceiptTask(ids); | |
196 | + receiptTaskService.createReceiptTask(ids); | |
212 | 197 | return AjaxResult.success("成功!"); |
213 | 198 | } |
214 | 199 | |
... | ... | @@ -330,7 +315,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
330 | 315 | Container container = new Container(); |
331 | 316 | container.setStatus("empty"); |
332 | 317 | if(inventoryHeader != null) { |
333 | - if(inventoryHeader.getContainerStatus().equals("some")) { | |
318 | + if("some".equals(inventoryHeader.getContainerStatus())) { | |
334 | 319 | container.setStatus("some"); |
335 | 320 | } |
336 | 321 | } |
... | ... | @@ -382,13 +367,14 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
382 | 367 | if (StringUtils.isEmpty(ids)){ |
383 | 368 | return AjaxResult.error("id不能为空"); |
384 | 369 | } |
370 | + | |
385 | 371 | Integer maxId = idList.stream().max(Comparator.comparing(Integer::intValue)).orElse(null); |
386 | 372 | |
387 | 373 | LambdaQueryWrapper<ReceiptContainerHeader> lambda = Wrappers.lambdaQuery(); |
388 | 374 | lambda.select(ReceiptContainerHeader::getId) |
389 | 375 | .lt(ReceiptContainerHeader::getStatus, 10) |
390 | 376 | .le(ReceiptContainerHeader::getId, maxId); |
391 | - return createReceiptTask(idList); | |
377 | + return receiptTaskService.createReceiptTask(idList); | |
392 | 378 | } |
393 | 379 | return AjaxResult.error("生成入库任务失败"); |
394 | 380 | } |
... | ... | @@ -407,6 +393,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
407 | 393 | if (task.getStatus() >= QuantityConstant.TASK_STATUS_RELEASE) { |
408 | 394 | return AjaxResult.error("任务" + taskId + "已经下发,请不要重复下发,操作中止"); |
409 | 395 | } |
396 | + | |
410 | 397 | // 给wcs传递任务 |
411 | 398 | try { |
412 | 399 | createTaskMessage.createTask(task); |
... | ... | @@ -487,6 +474,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
487 | 474 | } |
488 | 475 | |
489 | 476 | @Override |
477 | + @Transactional(rollbackFor = Exception.class) | |
490 | 478 | public AjaxResult completeTaskByWMS(Integer[] taskIds, String[] weightConvert) { |
491 | 479 | for (int i = 0;i<taskIds.length;i++) { |
492 | 480 | TaskHeader task = taskHeaderService.getById(taskIds[i]); |
... | ... | @@ -510,8 +498,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
510 | 498 | if(task.getTaskType().equals(QuantityConstant.TASK_TYPE_WHOLERECEIPT) || task.getTaskType().equals(QuantityConstant.TASK_TYPE_EMPTYRECEIPT)){ |
511 | 499 | if(StringUtils.isEmpty(task.getToLocation())){ |
512 | 500 | //自动分配库位 |
513 | -// AjaxResult ajaxResult = this.setLocationCode(task.getId(),0 ); | |
514 | -// task.setToLocation((String)ajaxResult.getData()); | |
501 | + // AjaxResult ajaxResult = this.setLocationCode(task.getId(),0 ); | |
502 | + // task.setToLocation((String)ajaxResult.getData()); | |
515 | 503 | } |
516 | 504 | } |
517 | 505 | //如果没有库位不能完成 |
... | ... | @@ -534,7 +522,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
534 | 522 | if (task.getInternalTaskType().equals(QuantityConstant.TASK_INTENERTYPE_SHELF) ) { |
535 | 523 | //入库任务 |
536 | 524 | receiptTaskService.completeReceiptTask(task); |
537 | - combineInventory(task); | |
538 | 525 | } |
539 | 526 | if (task.getInternalTaskType().equals(QuantityConstant.TASK_INTENERTYPE_PICKING) && |
540 | 527 | (task.getTaskType().equals(QuantityConstant.TASK_TYPE_WHOLESHIPMENT) || task.getTaskType().equals(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT))) { |
... | ... | @@ -543,7 +530,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
543 | 530 | } |
544 | 531 | // 900 出库查看,空托出库查看 |
545 | 532 | if (task.getTaskType().equals( QuantityConstant.TASK_TYPE_VIEW)) { |
546 | - workTaskService.completeCheckOutTask(task); | |
533 | + workTaskService.completeCheckOutTask(task); | |
547 | 534 | } |
548 | 535 | // 700 盘点 |
549 | 536 | if (task.getTaskType().equals(QuantityConstant.TASK_TYPE_CYCLECOUNT)) { |
... | ... | @@ -634,138 +621,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
634 | 621 | } |
635 | 622 | List<Integer> idList = new ArrayList<>(); |
636 | 623 | idList.add(receiptContainerHeader.getId()); |
637 | - createReceiptTask(idList); | |
624 | + receiptTaskService.createReceiptTask(idList); | |
638 | 625 | |
639 | 626 | return AjaxResult.success(receiptContainerHeader); |
640 | 627 | } |
641 | 628 | |
642 | - | |
643 | - /** | |
644 | - * 完成移库任务 | |
645 | - * | |
646 | - * @param task | |
647 | - */ | |
648 | - @Transactional(rollbackFor = Exception.class) | |
649 | - public void completeTransferTask(TaskHeader task) { | |
650 | - //找到任务明细 | |
651 | - TaskDetail taskDetail = new TaskDetail(); | |
652 | - taskDetail.setTaskId(task.getId()); | |
653 | - taskDetail.setWarehouseCode(task.getWarehouseCode()); | |
654 | - taskDetail.setCompanyCode(task.getCompanyCode()); | |
655 | - taskDetail.setContainerCode(task.getContainerCode()); | |
656 | - LambdaQueryWrapper<TaskDetail> taskDetailLW = Wrappers.lambdaQuery(taskDetail); | |
657 | - taskDetail = taskDetailService.getOne(taskDetailLW); | |
658 | - //更新库存主表和明细的库位,更改更新用户和时间 | |
659 | - InventoryHeader inventoryHeader = new InventoryHeader(); | |
660 | - //主表 | |
661 | - inventoryHeader.setWarehouseCode(taskDetail.getWarehouseCode()); | |
662 | - inventoryHeader.setCompanyCode(taskDetail.getCompanyCode()); | |
663 | - inventoryHeader.setContainerCode(taskDetail.getContainerCode()); | |
664 | - inventoryHeader.setLocationCode(taskDetail.getFromLocation());//通过源库位查找库存 | |
665 | - LambdaQueryWrapper<InventoryHeader> inventoryHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(inventoryHeader); | |
666 | - inventoryHeader = inventoryHeaderService.getOne(inventoryHeaderLambdaQueryWrapper); | |
667 | - if (StringUtils.isNotNull(inventoryHeader)){ | |
668 | - inventoryHeader.setLocationCode(taskDetail.getToLocation());//把目的库位写入库存 | |
669 | - inventoryHeader.setLastUpdated(new Date()); | |
670 | - inventoryHeader.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
671 | - inventoryHeaderService.saveOrUpdate(inventoryHeader);//修改主表库位 | |
672 | - | |
673 | - //明细表 | |
674 | - List<InventoryDetail> inventoryDetails = new ArrayList<>(); | |
675 | - InventoryDetail inventoryDetail = new InventoryDetail(); | |
676 | - inventoryDetail.setWarehouseCode(inventoryHeader.getWarehouseCode()); | |
677 | - inventoryDetail.setCompanyCode(inventoryHeader.getCompanyCode()); | |
678 | - inventoryDetail.setInventoryHeaderId(inventoryHeader.getId()); | |
679 | - LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery(inventoryDetail); | |
680 | - List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper); | |
681 | - /*同时写入库存交易表*/ | |
682 | - List<InventoryTransaction> inventoryTransactionList = new ArrayList<>(); | |
683 | - for (InventoryDetail item : inventoryDetailList) { | |
684 | - item.setLocationCode(inventoryHeader.getLocationCode());//修改明细表库位 | |
685 | - item.setLastUpdated(new Date()); | |
686 | - item.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
687 | - inventoryDetails.add(item); | |
688 | - /*----------*/ | |
689 | - InventoryTransaction inventoryTransaction = new InventoryTransaction(); | |
690 | - inventoryTransaction.setWarehouseCode(task.getWarehouseCode()); | |
691 | - inventoryTransaction.setLocationCode(taskDetail.getToLocation()); | |
692 | - inventoryTransaction.setContainerCode(taskDetail.getContainerCode()); | |
693 | - inventoryTransaction.setTransactionType(QuantityConstant.INVENTORY_TRANSACTION_ADJUSTPROPERTIES); | |
694 | - inventoryTransaction.setMaterialCode(item.getMaterialCode()); | |
695 | - inventoryTransaction.setManufactureDate(item.getManufactureDate()); | |
696 | - inventoryTransaction.setMaterialName(item.getMaterialName()); | |
697 | - inventoryTransaction.setMaterialSpec(item.getMaterialSpec()); | |
698 | - inventoryTransaction.setMaterialUnit(item.getMaterialUnit()); | |
699 | - inventoryTransaction.setTaskQty(BigDecimal.ZERO); | |
700 | - inventoryTransaction.setInventorySts(item.getInventorySts()); | |
701 | - inventoryTransaction.setCompanyCode(item.getCompanyCode()); | |
702 | - inventoryTransaction.setReferDetailId(item.getId().toString()); | |
703 | - inventoryTransaction.setBatch(item.getBatch()); | |
704 | - inventoryTransaction.setLot(item.getLot()); | |
705 | - inventoryTransaction.setProjectNo(item.getProjectNo()); | |
706 | - inventoryTransaction.setWeight(item.getWeight()); | |
707 | - inventoryTransaction.setManufactureDate(item.getManufactureDate()); | |
708 | - inventoryTransaction.setExpirationDate(item.getExpirationDate()); | |
709 | - inventoryTransaction.setAgingDate(item.getCreated()); | |
710 | - inventoryTransaction.setAttributeId(item.getAttributeId()); | |
711 | - inventoryTransaction.setAttribute1(item.getAttribute1()); | |
712 | - inventoryTransaction.setAttribute2(item.getAttribute2()); | |
713 | - inventoryTransaction.setAttribute3(item.getAttribute3()); | |
714 | - inventoryTransaction.setCreated(new Date()); | |
715 | - inventoryTransaction.setCreatedBy(ShiroUtils.getLoginName()); | |
716 | - //inventoryTransaction.setLockCode(); | |
717 | - inventoryTransaction.setBillCode(item.getInventoryHeaderId().toString()); | |
718 | - inventoryTransaction.setBillDetailId(item.getId()); | |
719 | - inventoryTransaction.setSupplierCode(item.getSupplierCode()); | |
720 | - inventoryTransactionList.add(inventoryTransaction); | |
721 | - } | |
722 | - if(inventoryDetails != null && inventoryDetails.size() > 0) { | |
723 | - if (inventoryDetailService.saveOrUpdateBatch(inventoryDetails)) { | |
724 | - //更新库存明细成功后,写入库存交易 | |
725 | - inventoryTransactionService.saveBatch(inventoryTransactionList); | |
726 | - } else { | |
727 | - throw new ServiceException("库存明细更新错误!"); | |
728 | - } | |
729 | - } | |
730 | - | |
731 | - } | |
732 | - //更新托盘、库位状态 | |
733 | - Location temp1 = new Location(); //源库位 | |
734 | - temp1.setCode(taskDetail.getFromLocation()); | |
735 | - temp1.setWarehouseCode(ShiroUtils.getWarehouseCode()); | |
736 | - LambdaQueryWrapper<Location> lambdaQueryWrapper1 = Wrappers.lambdaQuery(temp1); | |
737 | - Location loc1 = locationService.getOne(lambdaQueryWrapper1); | |
738 | - | |
739 | - Location temp2 = new Location();//目的库位 | |
740 | - temp2.setCode(taskDetail.getToLocation()); | |
741 | - temp2.setWarehouseCode(ShiroUtils.getWarehouseCode()); | |
742 | - LambdaQueryWrapper<Location> lambdaQueryWrapper2 = Wrappers.lambdaQuery(temp2); | |
743 | - Location loc2 = locationService.getOne(lambdaQueryWrapper2); | |
744 | - loc2.setContainerCode(loc1.getContainerCode()); | |
745 | - loc2.setStatus("empty"); | |
746 | - loc1.setContainerCode(""); | |
747 | - loc1.setStatus("empty"); | |
748 | - locationService.saveOrUpdate(loc1); | |
749 | - locationService.saveOrUpdate(loc2); | |
750 | - | |
751 | - Container container = containerService.findAllByCode(task.getContainerCode()); | |
752 | - container.setLocationCode(task.getToLocation()); | |
753 | - if (!containerService.updateById(container)){ | |
754 | - throw new ServiceException("更新容器失败"); | |
755 | - } | |
756 | - | |
757 | - //更新taskHeader状态 | |
758 | - task.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); | |
759 | - task.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
760 | - task.setLastUpdated(new Date()); | |
761 | - taskHeaderService.saveOrUpdate(task); | |
762 | - //更新taskDetail状态 | |
763 | - taskDetail.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); | |
764 | - taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
765 | - taskDetail.setLastUpdated(new Date()); | |
766 | - taskDetailService.saveOrUpdate(taskDetail); | |
767 | - } | |
768 | - | |
769 | 629 | /** |
770 | 630 | * 盘点完成 |
771 | 631 | * |
... | ... | @@ -821,191 +681,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
821 | 681 | } |
822 | 682 | |
823 | 683 | /** |
824 | - * 完成空托盘入库任务 | |
825 | - * | |
826 | - * @param taskHeader | |
827 | - */ | |
828 | - @Transactional(rollbackFor = Exception.class) | |
829 | - public void completeEmptyIn(TaskHeader taskHeader) { | |
830 | - | |
831 | - //完成任务,修改主单和明细状态 | |
832 | - taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); | |
833 | - taskHeader.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
834 | - taskHeader.setLastUpdated(new Date()); | |
835 | - //taskHeaderService.saveOrUpdate(taskHeader); | |
836 | - //taskDetail更新明细单总的状态 | |
837 | - TaskDetail taskDetail = new TaskDetail(); | |
838 | - taskDetail.setWarehouseCode(taskHeader.getWarehouseCode()); | |
839 | - taskDetail.setTaskType(taskHeader.getTaskType()); | |
840 | - taskDetail.setTaskId(taskHeader.getId()); | |
841 | - LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(taskDetail); | |
842 | - List<TaskDetail> taskDetailList = taskDetailService.list(lambdaQueryWrapper);//查询子单 | |
843 | - for (TaskDetail item : taskDetailList) { | |
844 | - item.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); | |
845 | - item.setLastUpdatedBy(ShiroUtils.getLoginName()); //更新用户 | |
846 | - item.setLastUpdated(new Date()); //更新时间 | |
847 | - } | |
848 | - if (taskDetailService.saveOrUpdateBatch(taskDetailList) == false || | |
849 | - taskHeaderService.saveOrUpdate(taskHeader) == false) { | |
850 | - throw new ServiceException("任务单据状态更新失败!"); | |
851 | - } | |
852 | - //解锁容器,更新库位 | |
853 | - containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(), taskHeader.getToLocation(), "empty"); | |
854 | - //解锁库位,更新容器 | |
855 | - locationService.updateContainerCodeAndStatus(taskHeader.getToLocation(), taskHeader.getContainerCode(), "empty"); | |
856 | - | |
857 | - //写入库存头表 | |
858 | - InventoryHeader inventoryHeader = new InventoryHeader(); | |
859 | - inventoryHeader.setWarehouseCode(taskHeader.getWarehouseCode()); | |
860 | - inventoryHeader.setLocationCode(taskHeader.getToLocation()); | |
861 | - inventoryHeader.setContainerCode(taskHeader.getContainerCode()); | |
862 | - inventoryHeader.setContainerStatus("empty"); | |
863 | - inventoryHeader.setCompanyCode(taskHeader.getCompanyCode()); | |
864 | - inventoryHeader.setMaterialSkuQty("0"); | |
865 | - inventoryHeader.setTotalWeight("0"); | |
866 | - inventoryHeader.setTotalQty(new BigDecimal(0)); | |
867 | - inventoryHeader.setTotalLines(0); | |
868 | - inventoryHeader.setProjectNos(""); | |
869 | - inventoryHeader.setBatchs(""); | |
870 | - inventoryHeader.setLots(""); | |
871 | - inventoryHeader.setLockRemark(""); | |
872 | - inventoryHeader.setCreated(new Date()); | |
873 | - inventoryHeader.setCreatedBy(ShiroUtils.getLoginName()); | |
874 | - inventoryHeader.setLastUpdated(new Date()); | |
875 | - inventoryHeader.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
876 | - Boolean j = inventoryHeaderService.save(inventoryHeader); | |
877 | - if(!j){ | |
878 | - throw new ServiceException("新增空托库存头失败!"); | |
879 | - | |
880 | - } | |
881 | - } | |
882 | - | |
883 | - /** | |
884 | - * 创建上架任务 | |
885 | - * | |
886 | - * @param ids | |
887 | - * @return | |
888 | - */ | |
889 | - @Override | |
890 | - @Transactional(rollbackFor = Exception.class) | |
891 | - public AjaxResult createReceiptTask(List<Integer> ids) { | |
892 | - for (Integer id : ids) { | |
893 | - ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(id); | |
894 | - if (receiptContainerHeader == null) { | |
895 | - throw new ServiceException("任务不存在!"); | |
896 | - } | |
897 | - | |
898 | - if (!receiptContainerHeader.getWarehouseCode().equals(ShiroUtils.getWarehouseCode())) { | |
899 | - throw new ServiceException("任务不在当前仓库!"); | |
900 | - } | |
901 | - | |
902 | - //锁定容器 | |
903 | - Container container = new Container(); | |
904 | - container.setStatus("lock"); | |
905 | - LambdaUpdateWrapper<Container> containerUpdateWrapper = Wrappers.lambdaUpdate(); | |
906 | - containerUpdateWrapper.eq(Container::getCode, receiptContainerHeader.getContainerCode()); | |
907 | - containerService.update(container, containerUpdateWrapper); | |
908 | - | |
909 | - //查询入库组盘明细 | |
910 | - LambdaQueryWrapper<ReceiptContainerDetail> containerDetailLambda = Wrappers.lambdaQuery(); | |
911 | - containerDetailLambda.eq(ReceiptContainerDetail::getReceiptContainerId, id); | |
912 | - List<ReceiptContainerDetail> list = receiptContainerDetailService.list(containerDetailLambda); | |
913 | - | |
914 | - if (list.size() < 1) { | |
915 | - throw new ServiceException("没有组盘明细,请先组盘!"); | |
916 | - } | |
917 | - if (receiptContainerHeader.getStatus() == QuantityConstant.RECEIPT_CONTAINER_BUILD.intValue()) { | |
918 | - if (receiptContainerHeader.getStatus().intValue() < QuantityConstant.RECEIPT_CONTAINER_TASK) { | |
919 | - receiptContainerHeader.setStatus(QuantityConstant.RECEIPT_CONTAINER_TASK.intValue()); | |
920 | - receiptContainerHeaderService.updateById(receiptContainerHeader); | |
921 | - } | |
922 | - //添加任务主表 | |
923 | - TaskHeader task = new TaskHeader(); | |
924 | - task.setAllocationHeadId(receiptContainerHeader.getId()); | |
925 | - task.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_SHELF); | |
926 | - task.setWarehouseCode(receiptContainerHeader.getWarehouseCode()); | |
927 | - task.setCompanyCode(receiptContainerHeader.getCompanyCode()); | |
928 | - task.setTaskType(Integer.valueOf(receiptContainerHeader.getTaskType())); | |
929 | - task.setFromLocation(receiptContainerHeader.getFromLocation()); | |
930 | - task.setToLocation(receiptContainerHeader.getToLocation()); | |
931 | - task.setContainerCode(receiptContainerHeader.getContainerCode()); | |
932 | - task.setRecvDock(receiptContainerHeader.getRecvDock()); | |
933 | - task.setCreated(new Date()); | |
934 | - task.setCreatedBy(ShiroUtils.getLoginName()); | |
935 | - if (this.save(task)) { | |
936 | - //添加任务明细表 | |
937 | - int conatinQty = 0; | |
938 | - for (ReceiptContainerDetail item : list) { | |
939 | - LambdaQueryWrapper<ContainerCapacity> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
940 | - String[] containCodeSplit = task.getContainerCode().split("\\D"); | |
941 | - String containType = containCodeSplit[0]; | |
942 | - lambdaQueryWrapper.eq(ContainerCapacity::getContainerType, task.getContainerCode()) | |
943 | - .eq(ContainerCapacity::getMaterialCode, item.getMaterialCode()) | |
944 | - .eq(ContainerCapacity::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
945 | - .eq(ContainerCapacity::getEnable, 0); | |
946 | - ContainerCapacity containerCapacity = containerCapacityService.getOne(lambdaQueryWrapper); | |
947 | - | |
948 | - TaskDetail taskDetail = new TaskDetail(); | |
949 | - taskDetail.setTaskId(task.getId()); | |
950 | - taskDetail.setTaskType(Integer.valueOf(receiptContainerHeaderService.getById(item.getReceiptContainerId()).getTaskType())); | |
951 | - taskDetail.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_SHELF); | |
952 | - taskDetail.setWarehouseCode(task.getWarehouseCode()); | |
953 | - taskDetail.setAllocationId(item.getId()); | |
954 | - taskDetail.setCompanyCode(task.getCompanyCode()); | |
955 | - taskDetail.setCompanyCode(task.getCompanyCode()); | |
956 | - taskDetail.setMaterialCode(item.getMaterialCode()); | |
957 | - taskDetail.setMaterialName(item.getMaterialName()); | |
958 | - taskDetail.setMaterialSpec(item.getMaterialSpec()); | |
959 | - taskDetail.setMaterialUnit(item.getMaterialUnit()); | |
960 | - taskDetail.setBillCode(item.getReceiptCode()); | |
961 | - taskDetail.setBillDetailId(item.getReceiptDetailId()); | |
962 | - taskDetail.setBillCode(item.getReceiptCode()); | |
963 | - taskDetail.setQty(item.getQty()); | |
964 | - taskDetail.setContainerCode(task.getContainerCode()); | |
965 | - taskDetail.setFromLocation(task.getFromLocation()); | |
966 | - taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
967 | - taskDetail.setBatch(item.getBatch()); | |
968 | - taskDetail.setProjectNo(item.getProjectNo()); | |
969 | - if (containerCapacity != null) { | |
970 | - conatinQty += (int) Math.floor(item.getQty().intValue() / containerCapacity.getQty().intValue()); | |
971 | - taskDetail.setContainQty((int) Math.floor(item.getQty().intValue() / containerCapacity.getQty().intValue())); | |
972 | - } | |
973 | - if (!taskDetailService.save(taskDetail)) { | |
974 | - throw new ServiceException("生成任务明细失败"); | |
975 | - } | |
976 | - | |
977 | - //更新入库组盘明细状态 | |
978 | - item.setStatus(QuantityConstant.RECEIPT_CONTAINER_TASK); | |
979 | - if (!receiptContainerDetailService.updateById(item)) { | |
980 | - throw new ServiceException("更新入库组盘明细状态出错"); | |
981 | - } | |
982 | - | |
983 | - /** | |
984 | - * 修改明细状态为上架 | |
985 | - */ | |
986 | - ReceiptDetail receiptDetail = receiptDetailService.getById(item.getReceiptDetailId()); | |
987 | - receiptDetail.setProcessStamp(String.valueOf(QuantityConstant.RECEIPT_HEADER_SHELF)); | |
988 | - if (!receiptDetailService.updateById(receiptDetail)) { | |
989 | - throw new ServiceException("更新入库单详情失败"); | |
990 | - } | |
991 | - //更新头表状态 | |
992 | - receiptDetailService.updateReceiptHeaderLastStatus(receiptDetail.getReceiptId()); | |
993 | - | |
994 | - } | |
995 | - | |
996 | - task.setContainQty(conatinQty); | |
997 | - if (!taskHeaderService.updateById(task)) { | |
998 | - throw new ServiceException("更新任务头表容器数量失败"); | |
999 | - } | |
1000 | - } else { | |
1001 | - throw new ServiceException("生成任务头表失败"); | |
1002 | - } | |
1003 | - } | |
1004 | - } | |
1005 | - return AjaxResult.success("生成上架任务成功"); | |
1006 | - } | |
1007 | - | |
1008 | - /** | |
1009 | 684 | * 自动分配库位 |
1010 | 685 | * @param taskId 任务号 |
1011 | 686 | * @param high 1是高库位,否则低库位 |
... | ... | @@ -1054,10 +729,14 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1054 | 729 | condition.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
1055 | 730 | condition.setTaskId(taskHeader.getId()); |
1056 | 731 | LambdaQueryWrapper<TaskDetail> taskDetailLambdaQueryWrapper = Wrappers.lambdaQuery(condition); |
1057 | - TaskDetail taskDetail = taskDetailService.getOne(taskDetailLambdaQueryWrapper); | |
1058 | - if (taskDetail != null) { | |
1059 | - taskDetail.setToLocation(location.getCode()); | |
1060 | - taskDetailService.update(taskDetail, taskDetailLambdaQueryWrapper); | |
732 | + List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailLambdaQueryWrapper); | |
733 | + if(taskDetailList != null && taskDetailList.size() > 0) { | |
734 | + for(TaskDetail taskDetail : taskDetailList) { | |
735 | + if (taskDetail != null) { | |
736 | + taskDetail.setToLocation(location.getCode()); | |
737 | + taskDetailService.update(taskDetail, taskDetailLambdaQueryWrapper); | |
738 | + } | |
739 | + } | |
1061 | 740 | } |
1062 | 741 | } |
1063 | 742 | //给任务分配库位 |
... | ... |