Commit 347a5e31cf56a7d76eac484c760821e52bb1d762
1 parent
d0711e21
fix: 修改出库回传字段数据
Showing
1 changed file
with
34 additions
and
27 deletions
src/main/java/com/huaheng/api/mes/controller/MesReceiptController.java
... | ... | @@ -566,15 +566,8 @@ public class MesReceiptController extends BaseController { |
566 | 566 | JSONArray jsonArray = new JSONArray(); |
567 | 567 | JSONObject Rd_In_S = new JSONObject(); |
568 | 568 | List<TaskDetail> taskDetails = taskDetailService.list(new LambdaQueryWrapper<TaskDetail>().eq(TaskDetail::getBillDetailId, receiptDetail.getId())); |
569 | - if (!taskDetails.isEmpty()) { | |
570 | - if (taskDetails.get(0).getFlat() != null && taskDetails.get(0).getFlat() == 1) { | |
571 | - Rd_In_S.put("cidefine10", "平库"); | |
572 | - } else { | |
573 | - Rd_In_S.put("cidefine10", "立库"); | |
574 | - } | |
575 | - } else { | |
576 | - Rd_In_S.put("cidefine10", "错误:未查询到任务!"); | |
577 | - } | |
569 | + String str = computeWarehouseType(taskDetails); | |
570 | + Rd_In_S.put("cidefine10", str); | |
578 | 571 | Rd_In_S.put("MGPK", receiptHeader.getMOMID()); |
579 | 572 | Rd_In_S.put("SGPK", receiptDetail.getMOMID()); |
580 | 573 | Rd_In_S.put("SNNO", receiptDetail.getSNNO()); |
... | ... | @@ -629,15 +622,8 @@ public class MesReceiptController extends BaseController { |
629 | 622 | for (ReceiptDetail receiptDetail : receiptDetails) { |
630 | 623 | OtherReceiptDetail detail = new OtherReceiptDetail(); |
631 | 624 | List<TaskDetail> taskDetails = taskDetailService.list(new LambdaQueryWrapper<TaskDetail>().eq(TaskDetail::getBillDetailId, receiptDetail.getId())); |
632 | - if (!taskDetails.isEmpty()) { | |
633 | - if (taskDetails.get(0).getFlat() != null && taskDetails.get(0).getFlat() == 1) { | |
634 | - detail.setIsFlat("平库"); | |
635 | - } else { | |
636 | - detail.setIsFlat("立库"); | |
637 | - } | |
638 | - } else { | |
639 | - detail.setIsFlat("错误:未查询到任务!"); | |
640 | - } | |
625 | + String str = computeWarehouseType(taskDetails); | |
626 | + detail.setIsFlat(str); | |
641 | 627 | detail.setMomIdByHeader(receiptHeader.getMOMID()); |
642 | 628 | detail.setMomId(receiptDetail.getMOMID()); |
643 | 629 | detail.setSnNo(receiptDetail.getSNNO()); |
... | ... | @@ -786,15 +772,8 @@ public class MesReceiptController extends BaseController { |
786 | 772 | Rd_Out_S.put("iFQuantity", shipmentDetail.getQty()); |
787 | 773 | Rd_Out_S.put("cwhcode", "035"); |
788 | 774 | List<TaskDetail> taskDetails = taskDetailService.list(new LambdaQueryWrapper<TaskDetail>().eq(TaskDetail::getBillDetailId, shipmentDetail.getId())); |
789 | - if (!taskDetails.isEmpty()) { | |
790 | - if (taskDetails.get(0).getFlat() != null && taskDetails.get(0).getFlat() == 1) { | |
791 | - Rd_Out_S.put("cidefine10", "平库"); | |
792 | - } else { | |
793 | - Rd_Out_S.put("cidefine10", "立库"); | |
794 | - } | |
795 | - } else { | |
796 | - Rd_Out_S.put("cidefine10", "错误:未查询到任务!"); | |
797 | - } | |
775 | + String str = computeWarehouseType(taskDetails); | |
776 | + Rd_Out_S.put("cidefine10", str); | |
798 | 777 | Rd_Out_S.put("MOCode", shipmentDetail.getNoticeNo()); |
799 | 778 | Rd_Out_S.put("ISUrgent", shipmentDetail.getIsUrgent()); |
800 | 779 | Rd_Out_S.put("updatedByNo", user.getLoginName()); |
... | ... | @@ -812,6 +791,34 @@ public class MesReceiptController extends BaseController { |
812 | 791 | return jsonArray; |
813 | 792 | } |
814 | 793 | |
794 | + | |
795 | + public String computeWarehouseType(List<TaskDetail> taskDetails) { | |
796 | + int flatCount = 0; | |
797 | + int uprightCount = 0; | |
798 | + BigDecimal flatQty = BigDecimal.ZERO; | |
799 | + BigDecimal uprightQty = BigDecimal.ZERO; | |
800 | + String str; | |
801 | + for (TaskDetail taskDetail : taskDetails) { | |
802 | + if (taskDetail.getFlat() != null && taskDetail.getFlat() == 1) { | |
803 | + flatCount++; | |
804 | + flatQty = flatQty.add(taskDetail.getQty()); | |
805 | + } else { | |
806 | + uprightCount++; | |
807 | + uprightQty = uprightQty.add(taskDetail.getQty()); | |
808 | + } | |
809 | + } | |
810 | + if (flatCount > 0 && uprightCount == 0) { | |
811 | + str = "平库"; | |
812 | + } else if (uprightCount > 0 && flatCount == 0) { | |
813 | + str = "立库"; | |
814 | + } else if (flatCount > 0 && uprightCount > 0) { | |
815 | + str = "平库" + flatCount + "/" + "立库" + uprightQty; | |
816 | + } else { | |
817 | + str = "错误:未查询到任务!"; | |
818 | + } | |
819 | + return str; | |
820 | + } | |
821 | + | |
815 | 822 | public JSONObject getRd_Out_M(@RequestBody ShipmentHeader shipmentHeader, String name) { |
816 | 823 | User user = userService.selectUserByEmail(shipmentHeader.getLastUpdatedBy()); |
817 | 824 | JSONObject Rd_Out_M = new JSONObject(); |
... | ... |