| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.module.erp.api.sale.ErpSaleOrderApi; |
| | | import cn.iocoder.yudao.module.erp.api.sale.dto.ErpSaleOrderItemRespDTO; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | private MdmItemApi mdmItemApi; |
| | | @Resource |
| | | private MdmUnitMeasureApi mdmUnitMeasureApi; |
| | | @Resource |
| | | private ErpSaleOrderApi saleOrderApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建发货通知单行") |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得发货通知单行") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:query')") |
| | | public CommonResult<MesWmSalesNoticeLineRespVO> getSalesNoticeLine(@RequestParam("id") Long id) { |
| | | MesWmSalesNoticeLineDO line = salesNoticeLineService.getSalesNoticeLine(id); |
| | | if (line == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得发货通知单行分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:query')") |
| | | public CommonResult<PageResult<MesWmSalesNoticeLineRespVO>> getSalesNoticeLinePage( |
| | | @Valid MesWmSalesNoticeLinePageReqVO pageReqVO) { |
| | | PageResult<MesWmSalesNoticeLineDO> pageResult = salesNoticeLineService.getSalesNoticeLinePage(pageReqVO); |
| | |
| | | Map<Long, MdmUnitMeasureRespDTO> unitMeasureMap = mdmUnitMeasureApi.getUnitMeasureList( |
| | | convertSet(itemMap.values(), MdmItemRespDTO::getUnitMeasureId)).getCheckedData() |
| | | .stream().collect(java.util.stream.Collectors.toMap(MdmUnitMeasureRespDTO::getId, e -> e)); |
| | | Map<Long, ErpSaleOrderItemRespDTO> saleItems = new HashMap<>(); |
| | | for (Long itemId : convertSet(list, MesWmSalesNoticeLineDO::getSaleOrderItemId)) { |
| | | if (itemId != null) saleItems.put(itemId, saleOrderApi.getSaleOrderItem(itemId).getCheckedData()); |
| | | } |
| | | // 2. 构建结果 |
| | | return BeanUtils.toBean(list, MesWmSalesNoticeLineRespVO.class, vo -> { |
| | | MapUtils.findAndThen(saleItems, vo.getSaleOrderItemId(), item -> vo.setReelNo(item.getReelNo())); |
| | | MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { |
| | | vo.setItemCode(item.getCode()).setItemName(item.getName()).setSpecification(item.getSpecification()); |
| | | MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), |