进出口单证查询

This commit is contained in:
zhaoqing
2026-05-14 18:45:13 +08:00
parent 9d483e3cc1
commit d91f3b646d
4 changed files with 121 additions and 17 deletions
@@ -797,4 +797,7 @@ public class BusinessDocumentOrderPO extends BaseVOEntity{
@ApiModelProperty("物料编码")
private String materialCode;
@ApiModelProperty("商品类型")
private Long productType;
}
@@ -9,6 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
public class OrderWithMaterialDTO {
@@ -804,4 +805,15 @@ public class OrderWithMaterialDTO {
@ApiModelProperty("推送人姓名")
private String pushByName;
@ApiModelProperty("物料id")
private Long materialBaseInfoId;
@ApiModelProperty("商品类型/货物类型(0料件,1半成品,2成品)")
private Integer productType;
@ApiModelProperty("物料ID列表")
private List<Long> materialBaseInfoIdList;
@ApiModelProperty("商品类型列表")
private List<Integer> productTypeList;
}
@@ -1,6 +1,7 @@
package com.mhd.oms.interfaces.facade.originalImportExportDocument;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mhd.common.core.utils.StringUtils;
@@ -8,6 +9,8 @@ import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.oms.application.service.businessDocumentOrder.BusinessDocumentOrderApplicationService;
import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCargoMulti;
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper;
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO;
import com.mhd.oms.interfaces.assembler.businessDocumentOrder.BusinessDocumentOrderAssembler;
@@ -23,10 +26,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Api(tags = "进出口原始单证")
@@ -34,6 +34,9 @@ import java.util.stream.Collectors;
@RequestMapping("/OriginalImportExportDocumentApi")
public class OriginalImportExportDocumentApi extends BaseController {
@Resource
BusinessDocumentCargoMultiMapper businessDocumentCargoMultiMapper;
@Resource
private BusinessDocumentOrderApplicationService businessDocumentOrderApplicationService;
@@ -85,18 +88,18 @@ public class OriginalImportExportDocumentApi extends BaseController {
}
private List<OrderWithMaterialDTO> convertToOrderWithMaterialList(List<BusinessDocumentOrderPO> orderList) {
List<OrderWithMaterialDTO> resultList = new ArrayList<>();
for (BusinessDocumentOrderPO order : orderList) {
OrderWithMaterialDTO orderWithMaterialDTO = new OrderWithMaterialDTO();
orderWithMaterialDTO.setMaterialCode(order.getMaterialCode());
orderWithMaterialDTO.setIeType(order.getIeType());
BeanUtils.copyProperties(order, orderWithMaterialDTO);
resultList.add(orderWithMaterialDTO);
}
return resultList;
}
// private List<OrderWithMaterialDTO> convertToOrderWithMaterialList(List<BusinessDocumentOrderPO> orderList) {
// List<OrderWithMaterialDTO> resultList = new ArrayList<>();
// for (BusinessDocumentOrderPO order : orderList) {
// OrderWithMaterialDTO orderWithMaterialDTO = new OrderWithMaterialDTO();
// orderWithMaterialDTO.setMaterialCode(order.getMaterialCode());
// orderWithMaterialDTO.setIeType(order.getIeType());
// BeanUtils.copyProperties(order, orderWithMaterialDTO);
// resultList.add(orderWithMaterialDTO);
// }
//
// return resultList;
// }
/**
* 调用WMS接口获取物料详细信息
@@ -193,4 +196,89 @@ public class OriginalImportExportDocumentApi extends BaseController {
//}
@ApiOperation("进出口原始单证查询列表")
@GetMapping("/list1")
public TableDataInfo list1(BusinessDocumentOrderDTO businessDocumentOrderDTO,
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
BusinessDocumentOrderDO businessDocumentOrderDO = businessDocumentOrderAssembler.toDO(businessDocumentOrderDTO);
PageHelper.startPage(pageNo, pageSize);
List<BusinessDocumentOrderPO> orderList = businessDocumentOrderApplicationService.queryListAndMaterial(businessDocumentOrderDO);
// ✅ 批量查询货物列表并设置到订单
fillCargoInfo(orderList);
// ✅ 获取分页信息
Page<BusinessDocumentOrderPO> page = (Page<BusinessDocumentOrderPO>) orderList;
List<OrderWithMaterialDTO> resultList = convertToOrderWithMaterialList(orderList);
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setData(resultList);
tableDataInfo.setTotal(page.getTotal());
tableDataInfo.setCode(200);
return tableDataInfo;
}
private void fillCargoInfo(List<BusinessDocumentOrderPO> orderList) {
if (orderList == null || orderList.isEmpty()) {
return;
}
// 1. 收集所有订单ID
List<Long> orderIds = orderList.stream()
.map(BusinessDocumentOrderPO::getId)
.distinct()
.collect(Collectors.toList());
// 2. 批量查询货物列表
List<BusinessDocumentCargoMulti> allCargoList = businessDocumentCargoMultiMapper.selectList(
new LambdaQueryWrapper<BusinessDocumentCargoMulti>()
.in(BusinessDocumentCargoMulti::getOrderId, orderIds)
);
// 3. 按订单ID分组
Map<Long, List<BusinessDocumentCargoMulti>> cargoMap = allCargoList.stream()
.collect(Collectors.groupingBy(c -> Long.valueOf(c.getOrderId())));
// 4. 设置到每个订单
for (BusinessDocumentOrderPO order : orderList) {
order.setBusinessDocumentCargoMultiList(cargoMap.get(order.getId()));
}
}
private List<OrderWithMaterialDTO> convertToOrderWithMaterialList(List<BusinessDocumentOrderPO> orderList) {
List<OrderWithMaterialDTO> resultList = new ArrayList<>();
for (BusinessDocumentOrderPO order : orderList) {
OrderWithMaterialDTO dto = new OrderWithMaterialDTO();
BeanUtils.copyProperties(order, dto);
// 设置货物列表信息(多个物料ID
List<BusinessDocumentCargoMulti> cargoList = order.getBusinessDocumentCargoMultiList();
if (cargoList != null && !cargoList.isEmpty()) {
// 物料ID列表
List<Long> materialIdList = cargoList.stream()
.map(BusinessDocumentCargoMulti::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toList());
dto.setMaterialBaseInfoIdList(materialIdList);
// 商品类型列表
List<Integer> productTypeList = cargoList.stream()
.map(BusinessDocumentCargoMulti::getProductType)
.filter(Objects::nonNull)
.collect(Collectors.toList());
dto.setProductTypeList(productTypeList);
// 取第一个货物的物料编码作为主显示
dto.setMaterialCode(cargoList.get(0).getMaterialCode());
}
resultList.add(dto);
}
return resultList;
}
}
@@ -174,6 +174,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="pushByName" column="PUSH_BY_NAME" />
<result property="pushStatus" column="PUSH_STATUS" />
<result property="pushTime" column="PUSH_TIME" />
<result property="productType" column="PRODUCT_TYPE" />
</resultMap>
@@ -692,7 +693,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select SALESPERSON_NC_CODE from NGWL_TEST_USER."USER" where USER_ID = #{salesmanCodeNc}</select>
<select id="queryListAndMaterial" parameterType="com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO" resultMap="BusinessDocumentOrderResult">
select o.*,a.material_code , a.material_base_info_id
select o.*,a.material_code , a.material_base_info_id ,a.product_type
from business_document_order as o
left join business_document_cargo_multi as a ON o.id = a.order_id
<include refid="selectBusinessDocumentOrderPo1"/>