物料查询解决total问题 以及其他页面是推送人名称问题

This commit is contained in:
zhaoqing
2026-05-14 16:36:22 +08:00
parent 0ee57f9858
commit 13caa83189
9 changed files with 129 additions and 56 deletions
@@ -2,6 +2,7 @@ package com.mhd.system.api;
import com.mhd.common.core.constant.ServiceNameConstants; import com.mhd.common.core.constant.ServiceNameConstants;
import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.system.api.domain.*; import com.mhd.system.api.domain.*;
import com.mhd.system.api.factory.RemoteWmsFallbackFactory; import com.mhd.system.api.factory.RemoteWmsFallbackFactory;
import com.mhd.system.api.feign.FeignAutoConfiguration; import com.mhd.system.api.feign.FeignAutoConfiguration;
@@ -98,7 +99,7 @@ public interface WmsServiceFeign {
@ApiOperation("oms查询物料列表") @ApiOperation("oms查询物料列表")
@GetMapping("/materialBaseInfoApi/queryList") @GetMapping("/materialBaseInfoApi/queryList")
public AjaxResult getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO); public TableDataInfo getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO);
@ApiOperation("oms物料列表推送-更新推送信息") @ApiOperation("oms物料列表推送-更新推送信息")
@PostMapping("/materialBaseInfoApi/updatePushStatus") @PostMapping("/materialBaseInfoApi/updatePushStatus")
@@ -48,5 +48,10 @@ public class MaterialInfoDTO {
@ApiModelProperty("推送时间止") @ApiModelProperty("推送时间止")
private String pushTimeEnd; private String pushTimeEnd;
@ApiModelProperty(value = "页码")
private Integer pageNum = 1;
@ApiModelProperty(value = "每页数量")
private Integer pageSize = 10;
} }
@@ -2,6 +2,7 @@ package com.mhd.system.api.factory;
import com.mhd.common.core.domain.entity.R; import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.system.api.WlhyServiceFeign; import com.mhd.system.api.WlhyServiceFeign;
import com.mhd.system.api.WmsServiceFeign; import com.mhd.system.api.WmsServiceFeign;
import com.mhd.system.api.domain.*; import com.mhd.system.api.domain.*;
@@ -11,6 +12,7 @@ import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -71,8 +73,12 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
} }
@Override @Override
public AjaxResult getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO) { public TableDataInfo getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO) {
return AjaxResult.error(cause.getMessage()); TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setData(new ArrayList<>());
tableDataInfo.setTotal(0);
tableDataInfo.setCode(500);
return tableDataInfo;
} }
@Override @Override
@@ -45,20 +45,22 @@ public class MaterialInfoApplicationService {
} }
public TableDataInfo queryList(MaterialInfoDTO materialInfoDTO) { public TableDataInfo queryList(MaterialInfoDTO materialInfoDTO) {
AjaxResult ajaxResult = wmsServiceFeign.getMaterialBaseInfoList(materialInfoDTO); try {
if(ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))){
List<?> data = (List<?>) ajaxResult.get("data"); TableDataInfo wmsTableDataInfo = wmsServiceFeign.getMaterialBaseInfoList(materialInfoDTO);
TableDataInfo tableDataInfo = new TableDataInfo(); TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setData(data); tableDataInfo.setData(wmsTableDataInfo.getData());
tableDataInfo.setTotal(wmsTableDataInfo.getTotal());
tableDataInfo.setCode(200); tableDataInfo.setCode(200);
tableDataInfo.setTotal(data.size());
return tableDataInfo; return tableDataInfo;
} } catch (Exception e) {
log.error("查询物料列表异常: {}", e.getMessage());
TableDataInfo tableDataInfo = new TableDataInfo(); TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setCode(500); tableDataInfo.setCode(500);
tableDataInfo.setMsg("查询失败");
return tableDataInfo; return tableDataInfo;
} }
}
public AjaxResult batchPush(List<MaterialInfoDTO> dtoList) { public AjaxResult batchPush(List<MaterialInfoDTO> dtoList) {
if (dtoList == null || dtoList.isEmpty()) { if (dtoList == null || dtoList.isEmpty()) {
@@ -33,6 +33,9 @@ public class ErpCountryPO {
@ApiModelProperty("推送人") @ApiModelProperty("推送人")
private Long pushBy; private Long pushBy;
@ApiModelProperty("推送人")
private String pushByName;
@ApiModelProperty("所属组织ID") @ApiModelProperty("所属组织ID")
private Long organizationId; private Long organizationId;
@@ -34,7 +34,10 @@ public class ErpEnterpriseUnitPO extends BaseVOEntity {
private Date pushTime; private Date pushTime;
@ApiModelProperty(value = "推送人") @ApiModelProperty(value = "推送人")
private String pushBy; private Long pushBy;
@ApiModelProperty(value = "推送人")
private String pushByName;
@ApiModelProperty(value = "所属组织ID") @ApiModelProperty(value = "所属组织ID")
private Long organizationId; private Long organizationId;
@@ -1,6 +1,7 @@
package com.mhd.oms.interfaces.facade.originalImportExportDocument; package com.mhd.oms.interfaces.facade.originalImportExportDocument;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.mhd.common.core.utils.StringUtils; import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.controller.BaseController; import com.mhd.common.core.web.controller.BaseController;
@@ -23,8 +24,10 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@Api(tags = "进出口原始单证") @Api(tags = "进出口原始单证")
@RestController @RestController
@@ -43,26 +46,27 @@ public class OriginalImportExportDocumentApi extends BaseController {
@ApiOperation("进出口原始单证查询列表") @ApiOperation("进出口原始单证查询列表")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(BusinessDocumentOrderDTO businessDocumentOrderDTO, public TableDataInfo list(BusinessDocumentOrderDTO businessDocumentOrderDTO,
@RequestParam(value = "pageNo",required = false , defaultValue = "1") Integer pageNo, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize",required = false , defaultValue = "10") Integer pageSize){ @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
BusinessDocumentOrderDO businessDocumentOrderDO = businessDocumentOrderAssembler.toDO(businessDocumentOrderDTO); BusinessDocumentOrderDO businessDocumentOrderDO = businessDocumentOrderAssembler.toDO(businessDocumentOrderDTO);
PageHelper.startPage(pageNo,pageSize); PageHelper.startPage(pageNo, pageSize);
List<BusinessDocumentOrderPO> orderList = businessDocumentOrderApplicationService.queryListAndMaterial(businessDocumentOrderDO); List<BusinessDocumentOrderPO> orderList = businessDocumentOrderApplicationService.queryListAndMaterial(businessDocumentOrderDO);
Page<BusinessDocumentOrderPO> page = (Page<BusinessDocumentOrderPO>) orderList;
List<OrderWithMaterialDTO> resultList = convertToOrderWithMaterialList(orderList); List<OrderWithMaterialDTO> resultList = convertToOrderWithMaterialList(orderList);
fillMaterialInfo(resultList); fillMaterialInfo(resultList);
TableDataInfo tableDataInfo = new TableDataInfo(); TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setData(resultList); tableDataInfo.setData(resultList);
tableDataInfo.setTotal(resultList.size()); tableDataInfo.setTotal(page.getTotal());
tableDataInfo.setCode(200); tableDataInfo.setCode(200);
return tableDataInfo; return tableDataInfo;
} }
@ApiOperation("删改单申请") @ApiOperation("删改单申请")
@PostMapping("/reviseApply") @PostMapping("/reviseApply")
public AjaxResult reviseApply(@RequestParam BusinessDocumentOrderDTO businessDocumentOrderDTO){ public AjaxResult reviseApply(@RequestParam BusinessDocumentOrderDTO businessDocumentOrderDTO) {
businessDocumentOrderApplicationService.reviseApply(businessDocumentOrderDTO); businessDocumentOrderApplicationService.reviseApply(businessDocumentOrderDTO);
@@ -81,20 +85,13 @@ public class OriginalImportExportDocumentApi extends BaseController {
} }
private List<OrderWithMaterialDTO> convertToOrderWithMaterialList(List<BusinessDocumentOrderPO> orderList) {
private List<OrderWithMaterialDTO> convertToOrderWithMaterialList(List<BusinessDocumentOrderPO> orderList){
List<OrderWithMaterialDTO> resultList = new ArrayList<>(); List<OrderWithMaterialDTO> resultList = new ArrayList<>();
for(BusinessDocumentOrderPO order:orderList){ for (BusinessDocumentOrderPO order : orderList) {
OrderWithMaterialDTO orderWithMaterialDTO = new OrderWithMaterialDTO(); OrderWithMaterialDTO orderWithMaterialDTO = new OrderWithMaterialDTO();
orderWithMaterialDTO.setMaterialCode(order.getMaterialCode()); orderWithMaterialDTO.setMaterialCode(order.getMaterialCode());
orderWithMaterialDTO.setIeType(order.getIeType()); orderWithMaterialDTO.setIeType(order.getIeType());
BeanUtils.copyProperties(order,orderWithMaterialDTO); BeanUtils.copyProperties(order, orderWithMaterialDTO);
resultList.add(orderWithMaterialDTO); resultList.add(orderWithMaterialDTO);
} }
@@ -106,40 +103,94 @@ public class OriginalImportExportDocumentApi extends BaseController {
* 根据materialCode查询,获取goodsType、grossWeight等字段 * 根据materialCode查询,获取goodsType、grossWeight等字段
*/ */
private void fillMaterialInfo(List<OrderWithMaterialDTO> resultList) { private void fillMaterialInfo(List<OrderWithMaterialDTO> resultList) {
for (OrderWithMaterialDTO dto : resultList) {
// 只查询有物料编码的订单 List<String> materialCodeList = resultList.stream()
if (StringUtils.hasText(dto.getMaterialCode())) { .map(OrderWithMaterialDTO::getMaterialCode)
.filter(StringUtils::hasText)
.distinct()
.collect(Collectors.toList());
if (materialCodeList.isEmpty()) {
return;
}
// 2. 批量查询物料信息(一次查询所有物料)
try { try {
// 构建查询参数
MaterialInfoDTO queryDTO = new MaterialInfoDTO(); MaterialInfoDTO queryDTO = new MaterialInfoDTO();
queryDTO.setMaterialCode(dto.getMaterialCode()); // 传入物料编码列表(逗号分隔或用其他方式)
queryDTO.setMaterialCode(String.join(",", materialCodeList));
// 调用WMS接口查询物料详情 TableDataInfo tableDataInfo = wmsServiceFeign.getMaterialBaseInfoList(queryDTO);
AjaxResult ajaxResult = wmsServiceFeign.getMaterialBaseInfoList(queryDTO);
// 判断返回是否成功 if (tableDataInfo != null && tableDataInfo.getCode() == 200) {
if ("200".equals(String.valueOf(ajaxResult.get("code")))) { List<?> materialList = tableDataInfo.getData();
List<?> materialList = (List<?>) ajaxResult.get("data");
if (materialList != null && !materialList.isEmpty()) {
// 取第一条物料记录
Map<?, ?> materialMap = (Map<?, ?>) materialList.get(0);
// 从WMS返回的Map中取值,填充到DTO // 3. 把物料列表转成 Mapkey = materialCode
dto.setMaterialName((String) materialMap.get("materialName")); // 物料名称 Map<String, Map<?, ?>> materialMap = new HashMap<>();
dto.setGoodsType((Integer) materialMap.get("goodsType")); // 货物类型 for (Object material : materialList) {
dto.setGrossWeight((java.math.BigDecimal) materialMap.get("grossWeight")); // 毛重 Map<?, ?> m = (Map<?, ?>) material;
dto.setDeclarationUnit((String) materialMap.get("declarationUnit")); // 申报单位 String code = (String) m.get("materialCode");
dto.setOriginCountry((String) materialMap.get("originCountry")); // 原产国 materialMap.put(code, m);
dto.setUnitPrice((BigDecimal) materialMap.get("unitPrice")); //单价 }
dto.setWeightLimit((BigDecimal) materialMap.get("weightLimit")); //净重
// 4. 遍历订单,匹配物料信息
for (OrderWithMaterialDTO dto : resultList) {
if (StringUtils.hasText(dto.getMaterialCode())) {
Map<?, ?> material = materialMap.get(dto.getMaterialCode());
if (material != null) {
dto.setMaterialName((String) material.get("materialName"));
dto.setGoodsType((Integer) material.get("goodsType"));
dto.setGrossWeight((BigDecimal) material.get("grossWeight"));
dto.setDeclarationUnit((String) material.get("declarationUnit"));
dto.setOriginCountry((String) material.get("originCountry"));
dto.setUnitPrice((BigDecimal) material.get("unitPrice"));
dto.setWeightLimit((BigDecimal) material.get("weightLimit"));
}
}
} }
} }
} catch (Exception e) { } catch (Exception e) {
// 查询失败不影响主流程,打印日志 // 查询失败不影响主流程
e.printStackTrace(); e.printStackTrace();
} }
} }
}
} // for (OrderWithMaterialDTO dto : resultList) {
// // 只查询有物料编码的订单
// if (StringUtils.hasText(dto.getMaterialCode())) {
// try {
// // 构建查询参数
// MaterialInfoDTO queryDTO = new MaterialInfoDTO();
// queryDTO.setMaterialCode(dto.getMaterialCode());
//
// // 调用WMS接口查询物料详情
// AjaxResult ajaxResult = wmsServiceFeign.getMaterialBaseInfoList(queryDTO);
//
// // 判断返回是否成功
// if ("200".equals(String.valueOf(ajaxResult.get("code")))) {
// List<?> materialList = (List<?>) ajaxResult.get("data");
// if (materialList != null && !materialList.isEmpty()) {
// // 取第一条物料记录
// Map<?, ?> materialMap = (Map<?, ?>) materialList.get(0);
//
// // 从WMS返回的Map中取值,填充到DTO
// dto.setMaterialName((String) materialMap.get("materialName")); // 物料名称
// dto.setGoodsType((Integer) materialMap.get("goodsType")); // 货物类型
// dto.setGrossWeight((java.math.BigDecimal) materialMap.get("grossWeight")); // 毛重
// dto.setDeclarationUnit((String) materialMap.get("declarationUnit")); // 申报单位
// dto.setOriginCountry((String) materialMap.get("originCountry")); // 原产国
// dto.setUnitPrice((BigDecimal) materialMap.get("unitPrice")); //单价
// dto.setWeightLimit((BigDecimal) materialMap.get("weightLimit")); //净重
// }
// }
// } catch (Exception e) {
// // 查询失败不影响主流程,打印日志
// e.printStackTrace();
// }
// }
//
// }
//}
} }
@@ -692,7 +692,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select SALESPERSON_NC_CODE from NGWL_TEST_USER."USER" where USER_ID = #{salesmanCodeNc}</select> 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 id="queryListAndMaterial" parameterType="com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO" resultMap="BusinessDocumentOrderResult">
select o.*,a.material_code select o.*,a.material_code , a.material_base_info_id
from business_document_order as o from business_document_order as o
left join business_document_cargo_multi as a ON o.id = a.order_id left join business_document_cargo_multi as a ON o.id = a.order_id
<include refid="selectBusinessDocumentOrderPo1"/> <include refid="selectBusinessDocumentOrderPo1"/>
@@ -1,6 +1,7 @@
package com.mhd.wms.interfaces.facadeApi.materialBaseInfo; package com.mhd.wms.interfaces.facadeApi.materialBaseInfo;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.Page;
import com.mhd.common.core.domain.entity.R; import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.exception.ServiceException; import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.StringUtils; import com.mhd.common.core.utils.StringUtils;
@@ -133,8 +134,9 @@ public class MaterialBaseInfoApi extends BaseController {
MaterialBaseInfoDO materialBaseInfoDO = materialBaseInfoAssembler.toDO(materialBaseInfoDTO); MaterialBaseInfoDO materialBaseInfoDO = materialBaseInfoAssembler.toDO(materialBaseInfoDTO);
startPage(); startPage();
List<MaterialBaseInfoPO> list = materialBaseInfoApplicationService.queryList(materialBaseInfoDO); List<MaterialBaseInfoPO> list = materialBaseInfoApplicationService.queryList(materialBaseInfoDO);
Page<MaterialBaseInfoPO> page = (Page<MaterialBaseInfoPO>) list;
TableDataInfo tableDataInfo = new TableDataInfo(); TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setTotal(list.size()); tableDataInfo.setTotal(page.getTotal());
tableDataInfo.setCode(200); tableDataInfo.setCode(200);
tableDataInfo.setData(list); tableDataInfo.setData(list);
return tableDataInfo; return tableDataInfo;