Commit 8d1410fd1bcd48eea6e69e3c8e7d5facec787732
1 parent
501e5c6e
增加车架库特殊处理
Showing
1 changed file
with
51 additions
and
8 deletions
src/main/java/com/huaheng/pc/task/taskHeader/service/ReceiptTaskService.java
@@ -45,10 +45,8 @@ import org.springframework.transaction.annotation.Transactional; | @@ -45,10 +45,8 @@ import org.springframework.transaction.annotation.Transactional; | ||
45 | 45 | ||
46 | import javax.annotation.Resource; | 46 | import javax.annotation.Resource; |
47 | import java.math.BigDecimal; | 47 | import java.math.BigDecimal; |
48 | -import java.util.ArrayList; | ||
49 | -import java.util.Date; | ||
50 | -import java.util.List; | ||
51 | -import java.util.Map; | 48 | +import java.text.MessageFormat; |
49 | +import java.util.*; | ||
52 | 50 | ||
53 | /** | 51 | /** |
54 | * 入库任务创建和完成 | 52 | * 入库任务创建和完成 |
@@ -219,6 +217,32 @@ public class ReceiptTaskService { | @@ -219,6 +217,32 @@ public class ReceiptTaskService { | ||
219 | return AjaxResult.success("生成上架任务成功").setData(taskIds); | 217 | return AjaxResult.success("生成上架任务成功").setData(taskIds); |
220 | } | 218 | } |
221 | 219 | ||
220 | + | ||
221 | + /** | ||
222 | + * 自动生成容器编码 | ||
223 | + * @return 容器编码 | ||
224 | + */ | ||
225 | + @Transactional | ||
226 | + public String createContainer(){ | ||
227 | + String code = MessageFormat.format("{0}{1}", | ||
228 | + "LS", | ||
229 | + String.format("%d", Calendar.getInstance().getTimeInMillis())); | ||
230 | + Container container = new Container(); | ||
231 | + container.setCode(code); | ||
232 | + container.setWarehouseCode(ShiroUtils.getWarehouseCode()); | ||
233 | + container.setCompanyCode(ShiroUtils.getCompanyCodeList().get(0)); | ||
234 | + container.setContainerType("LS"); | ||
235 | + container.setCreatedBy(ShiroUtils.getLoginName()); | ||
236 | + container.setLastUpdated(new Date()); | ||
237 | + container.setLastUpdatedBy(ShiroUtils.getLoginName()); | ||
238 | + container.setEnable(true); | ||
239 | + container.setStatus(QuantityConstant.STATUS_CONTAINER_EMPTY); | ||
240 | + if (!containerService.save(container)){ | ||
241 | + throw new ServiceException("新增容器失败"); | ||
242 | + } | ||
243 | + return code; | ||
244 | + } | ||
245 | + | ||
222 | /** | 246 | /** |
223 | * 完成入库任务 | 247 | * 完成入库任务 |
224 | * @param task 任务 | 248 | * @param task 任务 |
@@ -234,11 +258,16 @@ public class ReceiptTaskService { | @@ -234,11 +258,16 @@ public class ReceiptTaskService { | ||
234 | if (StringUtils.isEmpty(task.getToLocation())) { | 258 | if (StringUtils.isEmpty(task.getToLocation())) { |
235 | throw new ServiceException("任务" + task.getId() + "没有目的库位,执行中止"); | 259 | throw new ServiceException("任务" + task.getId() + "没有目的库位,执行中止"); |
236 | } | 260 | } |
261 | + | ||
237 | BigDecimal totalQty = BigDecimal.ZERO; | 262 | BigDecimal totalQty = BigDecimal.ZERO; |
238 | List<TaskDetail> taskDetailList = taskDetailService.findByTaskId(task.getId()); | 263 | List<TaskDetail> taskDetailList = taskDetailService.findByTaskId(task.getId()); |
239 | if (taskDetailList.isEmpty()) { | 264 | if (taskDetailList.isEmpty()) { |
240 | throw new ServiceException("任务明细为空"); | 265 | throw new ServiceException("任务明细为空"); |
241 | } | 266 | } |
267 | + String containerCode = null; | ||
268 | + if(task.getZoneCode().equals("C")) { | ||
269 | + containerCode = createContainer(); | ||
270 | + } | ||
242 | InventoryHeader inventoryHeader = null; | 271 | InventoryHeader inventoryHeader = null; |
243 | if(task.getTaskType().equals(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT)) { | 272 | if(task.getTaskType().equals(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT)) { |
244 | LambdaQueryWrapper<InventoryHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(); | 273 | LambdaQueryWrapper<InventoryHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
@@ -282,7 +311,12 @@ public class ReceiptTaskService { | @@ -282,7 +311,12 @@ public class ReceiptTaskService { | ||
282 | Location location = locationService.getLocationByCode(task.getToLocation(), ShiroUtils.getWarehouseCode()); | 311 | Location location = locationService.getLocationByCode(task.getToLocation(), ShiroUtils.getWarehouseCode()); |
283 | inventoryHeader.setZoneCode(location.getZoneCode()); | 312 | inventoryHeader.setZoneCode(location.getZoneCode()); |
284 | inventoryHeader.setTotalWeight(task.getWeight()); | 313 | inventoryHeader.setTotalWeight(task.getWeight()); |
285 | - inventoryHeader.setContainerCode(task.getContainerCode()); | 314 | + if(task.getZoneCode().equals("C")) { |
315 | + inventoryHeader.setContainerCode(containerCode); | ||
316 | + inventoryHeader.setUserDef2(task.getContainerCode()); | ||
317 | + } else { | ||
318 | + inventoryHeader.setContainerCode(task.getContainerCode()); | ||
319 | + } | ||
286 | inventoryHeader.setContainerStatus(QuantityConstant.STATUS_CONTAINER_SOME); | 320 | inventoryHeader.setContainerStatus(QuantityConstant.STATUS_CONTAINER_SOME); |
287 | inventoryHeader.setTotalQty(new BigDecimal(0)); | 321 | inventoryHeader.setTotalQty(new BigDecimal(0)); |
288 | inventoryHeader.setTotalLines(0); | 322 | inventoryHeader.setTotalLines(0); |
@@ -305,7 +339,6 @@ public class ReceiptTaskService { | @@ -305,7 +339,6 @@ public class ReceiptTaskService { | ||
305 | /*查询入库单明细*/ | 339 | /*查询入库单明细*/ |
306 | ReceiptDetail receiptDetail = receiptDetailService.getById(taskDetail.getBillDetailId()); | 340 | ReceiptDetail receiptDetail = receiptDetailService.getById(taskDetail.getBillDetailId()); |
307 | if (StringUtils.isNotNull(receiptDetail)) { | 341 | if (StringUtils.isNotNull(receiptDetail)) { |
308 | - | ||
309 | totalQty = this.addInventoryDetail(taskDetail, receiptDetail, inventoryHeader); | 342 | totalQty = this.addInventoryDetail(taskDetail, receiptDetail, inventoryHeader); |
310 | //修改组盘表状态为完成 | 343 | //修改组盘表状态为完成 |
311 | ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail(); | 344 | ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail(); |
@@ -323,6 +356,8 @@ public class ReceiptTaskService { | @@ -323,6 +356,8 @@ public class ReceiptTaskService { | ||
323 | receiptDetailService.updateById(receiptDetail); | 356 | receiptDetailService.updateById(receiptDetail); |
324 | receiptDetailService.updateReceiptHeaderLastStatus(receiptDetail.getReceiptId()); | 357 | receiptDetailService.updateReceiptHeaderLastStatus(receiptDetail.getReceiptId()); |
325 | materialWarningService.materialWarning(taskDetail.getMaterialCode(), taskDetail.getCompanyCode()); | 358 | materialWarningService.materialWarning(taskDetail.getMaterialCode(), taskDetail.getCompanyCode()); |
359 | + taskDetail.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); | ||
360 | + taskDetailService.updateById(taskDetail); | ||
326 | } | 361 | } |
327 | } | 362 | } |
328 | if (StringUtils.isNull(inventoryHeader)) { | 363 | if (StringUtils.isNull(inventoryHeader)) { |
@@ -338,7 +373,13 @@ public class ReceiptTaskService { | @@ -338,7 +373,13 @@ public class ReceiptTaskService { | ||
338 | 373 | ||
339 | //修改库位状态和对应的容器 | 374 | //修改库位状态和对应的容器 |
340 | Location location = new Location(); | 375 | Location location = new Location(); |
341 | - location.setContainerCode(task.getContainerCode()); | 376 | + if(task.getZoneCode().equals("C")) { |
377 | + location.setContainerCode(containerCode); | ||
378 | + location.setUserDef2(task.getContainerCode()); | ||
379 | + containerService.updateLocationCodeAndStatus(containerCode, task.getToLocation(), QuantityConstant.STATUS_CONTAINER_EMPTY); | ||
380 | + } else { | ||
381 | + location.setContainerCode(task.getContainerCode()); | ||
382 | + } | ||
342 | location.setWarehouseCode(ShiroUtils.getWarehouseCode()); | 383 | location.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
343 | location.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY); | 384 | location.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY); |
344 | LambdaUpdateWrapper<Location> locationLambdaUpdateWrapper = Wrappers.lambdaUpdate(); | 385 | LambdaUpdateWrapper<Location> locationLambdaUpdateWrapper = Wrappers.lambdaUpdate(); |
@@ -349,7 +390,9 @@ public class ReceiptTaskService { | @@ -349,7 +390,9 @@ public class ReceiptTaskService { | ||
349 | } | 390 | } |
350 | //修改容器状态和对应的库位 | 391 | //修改容器状态和对应的库位 |
351 | Container container = new Container(); | 392 | Container container = new Container(); |
352 | - container.setLocationCode(task.getToLocation()); | 393 | + if(!task.getZoneCode().equals("C")) { |
394 | + container.setLocationCode(task.getToLocation()); | ||
395 | + } | ||
353 | container.setStatus(QuantityConstant.STATUS_CONTAINER_SOME); | 396 | container.setStatus(QuantityConstant.STATUS_CONTAINER_SOME); |
354 | LambdaUpdateWrapper<Container> containerLambdaUpdateWrapper = Wrappers.lambdaUpdate(); | 397 | LambdaUpdateWrapper<Container> containerLambdaUpdateWrapper = Wrappers.lambdaUpdate(); |
355 | containerLambdaUpdateWrapper.eq(Container::getCode, task.getContainerCode()); | 398 | containerLambdaUpdateWrapper.eq(Container::getCode, task.getContainerCode()); |