Commit 736e7ec28175d3fc5db865b80f46e063cc52ffd0
1 parent
5055f20a
add 移动端有表单入库
Showing
3 changed files
with
134 additions
and
32 deletions
src/main/java/com/huaheng/mobile/receipt/MobileBatchReceiptController.java
... | ... | @@ -3,6 +3,7 @@ package com.huaheng.mobile.receipt; |
3 | 3 | import com.alibaba.fastjson.JSONException; |
4 | 4 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
5 | 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
6 | +import com.huaheng.api.general.domain.Receipt; | |
6 | 7 | import com.huaheng.common.constant.QuantityConstant; |
7 | 8 | import com.huaheng.api.general.domain.ReceiptDomain; |
8 | 9 | import com.huaheng.common.constant.QuantityConstant; |
... | ... | @@ -30,6 +31,8 @@ import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail; |
30 | 31 | import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService; |
31 | 32 | import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader; |
32 | 33 | import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService; |
34 | +import com.huaheng.pc.system.dict.domain.DictData; | |
35 | +import com.huaheng.pc.system.dict.service.IDictDataService; | |
33 | 36 | import com.huaheng.pc.task.taskDetail.domain.TaskDetail; |
34 | 37 | import com.huaheng.pc.task.taskDetail.service.TaskDetailService; |
35 | 38 | import com.huaheng.pc.task.taskHeader.domain.TaskHeader; |
... | ... | @@ -42,9 +45,8 @@ import org.springframework.web.bind.annotation.*; |
42 | 45 | |
43 | 46 | import javax.annotation.Resource; |
44 | 47 | import java.math.BigDecimal; |
45 | -import java.util.Date; | |
46 | -import java.util.List; | |
47 | -import java.util.Map; | |
48 | +import java.text.SimpleDateFormat; | |
49 | +import java.util.*; | |
48 | 50 | |
49 | 51 | /** |
50 | 52 | * |
... | ... | @@ -77,6 +79,8 @@ public class MobileBatchReceiptController { |
77 | 79 | private TaskDetailService taskDetailService; |
78 | 80 | @Resource |
79 | 81 | private CompanyService companyService; |
82 | + @Resource | |
83 | + private IDictDataService dictDataService; | |
80 | 84 | |
81 | 85 | |
82 | 86 | @PostMapping("/scanContainer") |
... | ... | @@ -327,6 +331,70 @@ public class MobileBatchReceiptController { |
327 | 331 | return AjaxResult.success("收货成功"); |
328 | 332 | } |
329 | 333 | |
334 | + @PostMapping("/listReceipt") | |
335 | + @ApiOperation("移动端根据表单整盘入库") | |
336 | + @Log(title = "移动端根据表单整盘入库", action = BusinessType.OTHER) | |
337 | + @Transactional(rollbackFor = Exception.class) | |
338 | + public AjaxResult listReceipt(@RequestBody @ApiParam(value="收货单") List<ReceiptBill> receiptBills) throws Exception { | |
339 | + if (receiptBills == null || receiptBills.size() <=0) { | |
340 | + throw new JSONException("没有收货信息"); | |
341 | + } | |
342 | + String containerCode = receiptBills.get(0).receiptContainerCode; | |
343 | + String companyCode = receiptBills.get(0).getCompanyCode(); | |
344 | + String receiptDetailId = receiptBills.get(0).getReceiptDetailId(); | |
345 | + String locationCode = receiptBills.get(0).locationCode; | |
346 | + | |
347 | + LambdaQueryWrapper<Container> containerQueryWrapper = Wrappers.lambdaQuery(); | |
348 | + containerQueryWrapper.eq(Container::getCode, containerCode); | |
349 | + Container container = containerService.getOne(containerQueryWrapper); | |
350 | + if(container == null) { | |
351 | + throw new JSONException("不存在这个托盘"); | |
352 | + } | |
353 | + | |
354 | + if(locationCode != null) { | |
355 | + LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
356 | + locationLambdaQueryWrapper.eq(Location::getCode, locationCode); | |
357 | + Location location = locationService.getOne(locationLambdaQueryWrapper); | |
358 | + if(location == null) { | |
359 | + throw new JSONException("不存在这个托盘"); | |
360 | + } | |
361 | + | |
362 | + if(!location.getStatus().equals("empty")) { | |
363 | + throw new JSONException("库位状态不是空闲"); | |
364 | + } | |
365 | + } | |
366 | + | |
367 | + LambdaQueryWrapper<ReceiptDetail> receiptDetailQueryWrapper = Wrappers.lambdaQuery(); | |
368 | + receiptDetailQueryWrapper.eq(ReceiptDetail::getId, receiptDetailId); | |
369 | + ReceiptDetail receiptDetail = receiptDetailService.getOne(receiptDetailQueryWrapper); | |
370 | + if(receiptDetail == null) { | |
371 | + throw new JSONException("没有找到入库单详情"); | |
372 | + } | |
373 | + | |
374 | + LambdaQueryWrapper<ReceiptHeader> receiptHeaderQueryWrapper = Wrappers.lambdaQuery(); | |
375 | + receiptHeaderQueryWrapper.eq(ReceiptHeader::getId, receiptDetail.getReceiptId()); | |
376 | + ReceiptHeader receiptHeader = receiptHeaderService.getOne(receiptHeaderQueryWrapper); | |
377 | + if(receiptHeader == null) { | |
378 | + throw new JSONException("没有找到入库单"); | |
379 | + } | |
380 | + | |
381 | + List<ReceiptContainerView> receiptContainerViewList = new ArrayList<>(); | |
382 | + for(ReceiptBill receiptBill : receiptBills) { | |
383 | + ReceiptContainerView receiptContainerView = new ReceiptContainerView(); | |
384 | + receiptContainerView.setLocationCode(receiptBill.getLocationCode()); | |
385 | + receiptContainerView.setCompanyCode(receiptBill.getCompanyCode()); | |
386 | + receiptContainerView.setReceiptContainerCode(receiptBill.getReceiptContainerCode()); | |
387 | + receiptContainerView.setReceiptDetailId(Integer.parseInt(receiptBill.getReceiptDetailId())); | |
388 | + receiptContainerView.setQty(receiptBill.getQty()); | |
389 | + receiptContainerView.setTaskType((short)100); | |
390 | + receiptContainerViewList.add(receiptContainerView); | |
391 | + } | |
392 | + receiptContainerHeaderService.batchSave(receiptContainerViewList); | |
393 | + AjaxResult retResult = taskHeaderService.createQuickTask(containerCode); | |
394 | + | |
395 | + return retResult; | |
396 | + } | |
397 | + | |
330 | 398 | @PostMapping("/findReceipt") |
331 | 399 | @ApiOperation("移动端查询入库单") |
332 | 400 | @Log(title = "移动端查询入库单", action = BusinessType.OTHER) |
... | ... | @@ -338,9 +406,6 @@ public class MobileBatchReceiptController { |
338 | 406 | } else if (StringUtils.isNull(companyCode)){ |
339 | 407 | return AjaxResult.error("公司编码为空"); |
340 | 408 | } |
341 | -// else if (StringUtils.isNull(referType)) { | |
342 | -// return AjaxResult.error("上游系统关联单类型为空"); | |
343 | -// } | |
344 | 409 | |
345 | 410 | /* 查询入库单,如果数据库中不存在,则调用ERP接口拉取单据,成功后再次查询返回结果*/ |
346 | 411 | LambdaQueryWrapper<ReceiptHeader> receiptLambdaQueryWrapper = Wrappers.lambdaQuery(); |
... | ... | @@ -434,4 +499,36 @@ public class MobileBatchReceiptController { |
434 | 499 | |
435 | 500 | return AjaxResult.success(taskHeader.getId()); |
436 | 501 | } |
502 | + | |
503 | + @PostMapping("/searchReceipt") | |
504 | + @ApiOperation("移动端查询入库单") | |
505 | + @Log(title = "移动端查询入库单", action = BusinessType.OTHER) | |
506 | + public AjaxResult searchReceipt(@RequestBody @ApiParam(value = "物料号") Map<String, String> param){ | |
507 | + String companyCode = param.get("companyCode"); | |
508 | + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
509 | + String now = df.format(new Date()); | |
510 | + Calendar c = Calendar.getInstance(); | |
511 | + c.setTime(new Date()); | |
512 | + c.add(Calendar.DATE, -7); | |
513 | + Date first = c.getTime(); | |
514 | + String start = df.format(first);//前一天 | |
515 | + LambdaQueryWrapper<ReceiptHeader> receiptHeaderQueryWrapper = Wrappers.lambdaQuery(); | |
516 | + receiptHeaderQueryWrapper.eq(ReceiptHeader::getCompanyCode, companyCode) | |
517 | + .eq(ReceiptHeader::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
518 | + .le(ReceiptHeader::getCreated, now) | |
519 | + .gt(ReceiptHeader::getCreated, start); | |
520 | + List<ReceiptHeader> receiptHeaderList = receiptHeaderService.list(receiptHeaderQueryWrapper); | |
521 | + return AjaxResult.success(receiptHeaderList); | |
522 | + } | |
523 | + | |
524 | + @PostMapping("/getDictListData") | |
525 | + @ApiOperation("移动端查询字典信息") | |
526 | + @Log(title = "移动端查询字典信息", action = BusinessType.OTHER) | |
527 | + public AjaxResult getDictListData(@RequestBody @ApiParam(value = "物料号") Map<String, String> param){ | |
528 | + String dictType = param.get("dictType"); | |
529 | + List<DictData> dictDataList = dictDataService.selectDictDataByType(dictType); | |
530 | + return AjaxResult.success(dictDataList); | |
531 | + } | |
532 | + | |
533 | + | |
437 | 534 | } |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/service/ReceiptContainerHeaderServiceImpl.java
... | ... | @@ -101,7 +101,10 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
101 | 101 | receiptContainerHeader.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
102 | 102 | receiptContainerHeader.setCompanyCode(receiptDetail.getCompanyCode()); |
103 | 103 | receiptContainerHeader.setContainerCode(containerCode); |
104 | - Container container = containerService.findAllByCode(containerCode); | |
104 | + Container condition = new Container(); | |
105 | + condition.setCode(containerCode); | |
106 | + LambdaQueryWrapper<Container> containerHeaderQueryWrapper = Wrappers.lambdaQuery(condition); | |
107 | + Container container = containerService.getOne(containerHeaderQueryWrapper); | |
105 | 108 | receiptContainerHeader.setContainerType(container.getContainerType()); |
106 | 109 | receiptContainerHeader.setTaskType(String.valueOf(taskType)); |
107 | 110 | if (taskType.equals(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT)) { |
... | ... | @@ -240,10 +243,12 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
240 | 243 | if (checkLocationCode(list.get(0).getLocationCode(), list.get(0).getLocationCode(), Integer.valueOf(list.get(0).getTaskType())) == true) { |
241 | 244 | locationService.updateStatus(list.get(0).getLocationCode(), "lock"); |
242 | 245 | } |
243 | - ReceiptContainerView view = list.get(0); | |
244 | - AjaxResult ajaxResult = saveCountain(view.getReceiptCode(), view.getReceiptContainerCode(), | |
245 | - view.getReceiptDetailId(), view.getLocationCode(), view.getQty().intValue(), null); | |
246 | - return null; | |
246 | + AjaxResult ajaxResult = null; | |
247 | + for (ReceiptContainerView receiptContainerView : list) { | |
248 | + ajaxResult = saveCountain(receiptContainerView.getReceiptCode(), receiptContainerView.getReceiptContainerCode(), | |
249 | + receiptContainerView.getReceiptDetailId(), receiptContainerView.getLocationCode(), receiptContainerView.getQty().intValue(), null); | |
250 | + } | |
251 | + return ajaxResult; | |
247 | 252 | } |
248 | 253 | |
249 | 254 | /** |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
... | ... | @@ -362,33 +362,33 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
362 | 362 | if (containerDetailList.isEmpty()) { |
363 | 363 | throw new SecurityException("没有组盘明细,请先组盘"); |
364 | 364 | } |
365 | - if (receiptContainerHeader.getStatus().equals(QuantityConstant.RECEIPT_HEADER_BUILD)) { | |
365 | + if (receiptContainerHeader.getStatus() == QuantityConstant.RECEIPT_HEADER_BUILD.shortValue()) { | |
366 | 366 | String ids = String.valueOf(receiptContainerHeader.getId()); |
367 | 367 | if (StringUtils.isEmpty(ids)){ |
368 | 368 | return AjaxResult.error("id不能为空"); |
369 | 369 | } |
370 | 370 | List<Integer> idList = Arrays.asList(Convert.toIntArray(ids)); |
371 | - for (int i = 0; i<idList.size(); i++){ | |
372 | - LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery(); | |
373 | - lambda.eq(ReceiptContainerDetail::getReceiptContainerId, idList.get(i)); | |
374 | - List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(lambda); | |
375 | - for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetails){ | |
376 | - receivingService.position(receiptContainerDetail); | |
377 | - } | |
378 | - | |
379 | - } | |
371 | +// for (int i = 0; i<idList.size(); i++){ | |
372 | +// LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery(); | |
373 | +// lambda.eq(ReceiptContainerDetail::getReceiptContainerId, idList.get(i)); | |
374 | +// List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(lambda); | |
375 | +// for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetails){ | |
376 | +// receivingService.position(receiptContainerDetail); | |
377 | +// } | |
378 | +// | |
379 | +// } | |
380 | 380 | if (StringUtils.isEmpty(ids)){ |
381 | 381 | return AjaxResult.error("id不能为空"); |
382 | 382 | } |
383 | - for (int i = 0; i<idList.size(); i++){ | |
384 | - LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery(); | |
385 | - lambda.eq(ReceiptContainerDetail::getReceiptContainerId, idList.get(i)); | |
386 | - List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(lambda); | |
387 | - for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetails){ | |
388 | - receivingService.position(receiptContainerDetail); | |
389 | - } | |
390 | - | |
391 | - } | |
383 | +// for (int i = 0; i<idList.size(); i++){ | |
384 | +// LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery(); | |
385 | +// lambda.eq(ReceiptContainerDetail::getReceiptContainerId, idList.get(i)); | |
386 | +// List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(lambda); | |
387 | +// for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetails){ | |
388 | +// receivingService.position(receiptContainerDetail); | |
389 | +// } | |
390 | +// | |
391 | +// } | |
392 | 392 | |
393 | 393 | Integer maxId = idList.stream().max(Comparator.comparing(Integer::intValue)).orElse(null); |
394 | 394 | |
... | ... | @@ -398,7 +398,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
398 | 398 | .le(ReceiptContainerHeader::getId, maxId); |
399 | 399 | return taskHeaderService.createReceiptTask(idList); |
400 | 400 | } |
401 | - return null; | |
401 | + return AjaxResult.error("生成入库任务失败"); | |
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
... | ... | @@ -1526,7 +1526,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1526 | 1526 | } |
1527 | 1527 | } |
1528 | 1528 | } |
1529 | - return AjaxResult.success("生成上架任务成功!"); | |
1529 | + return AjaxResult.success("生成上架任务成功"); | |
1530 | 1530 | } |
1531 | 1531 | |
1532 | 1532 | /** |
... | ... |