物料查询解决total问题 以及其他页面是推送人名称问题
This commit is contained in:
+92
-41
@@ -1,6 +1,7 @@
|
||||
package com.mhd.oms.interfaces.facade.originalImportExportDocument;
|
||||
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.web.controller.BaseController;
|
||||
@@ -23,8 +24,10 @@ 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.stream.Collectors;
|
||||
|
||||
@Api(tags = "进出口原始单证")
|
||||
@RestController
|
||||
@@ -43,26 +46,27 @@ public class OriginalImportExportDocumentApi extends BaseController {
|
||||
@ApiOperation("进出口原始单证查询列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(BusinessDocumentOrderDTO businessDocumentOrderDTO,
|
||||
@RequestParam(value = "pageNo",required = false , defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize",required = false , defaultValue = "10") Integer pageSize){
|
||||
@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);
|
||||
PageHelper.startPage(pageNo, pageSize);
|
||||
List<BusinessDocumentOrderPO> orderList = businessDocumentOrderApplicationService.queryListAndMaterial(businessDocumentOrderDO);
|
||||
|
||||
Page<BusinessDocumentOrderPO> page = (Page<BusinessDocumentOrderPO>) orderList;
|
||||
List<OrderWithMaterialDTO> resultList = convertToOrderWithMaterialList(orderList);
|
||||
|
||||
fillMaterialInfo(resultList);
|
||||
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setData(resultList);
|
||||
tableDataInfo.setTotal(resultList.size());
|
||||
tableDataInfo.setTotal(page.getTotal());
|
||||
tableDataInfo.setCode(200);
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
@ApiOperation("删改单申请")
|
||||
@PostMapping("/reviseApply")
|
||||
public AjaxResult reviseApply(@RequestParam BusinessDocumentOrderDTO businessDocumentOrderDTO){
|
||||
public AjaxResult reviseApply(@RequestParam BusinessDocumentOrderDTO 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<>();
|
||||
for(BusinessDocumentOrderPO order:orderList){
|
||||
for (BusinessDocumentOrderPO order : orderList) {
|
||||
OrderWithMaterialDTO orderWithMaterialDTO = new OrderWithMaterialDTO();
|
||||
orderWithMaterialDTO.setMaterialCode(order.getMaterialCode());
|
||||
orderWithMaterialDTO.setIeType(order.getIeType());
|
||||
BeanUtils.copyProperties(order,orderWithMaterialDTO);
|
||||
BeanUtils.copyProperties(order, orderWithMaterialDTO);
|
||||
resultList.add(orderWithMaterialDTO);
|
||||
}
|
||||
|
||||
@@ -106,40 +103,94 @@ public class OriginalImportExportDocumentApi extends BaseController {
|
||||
* 根据materialCode查询,获取goodsType、grossWeight等字段
|
||||
*/
|
||||
private void fillMaterialInfo(List<OrderWithMaterialDTO> resultList) {
|
||||
for (OrderWithMaterialDTO dto : resultList) {
|
||||
// 只查询有物料编码的订单
|
||||
if (StringUtils.hasText(dto.getMaterialCode())) {
|
||||
try {
|
||||
// 构建查询参数
|
||||
MaterialInfoDTO queryDTO = new MaterialInfoDTO();
|
||||
queryDTO.setMaterialCode(dto.getMaterialCode());
|
||||
|
||||
// 调用WMS接口查询物料详情
|
||||
AjaxResult ajaxResult = wmsServiceFeign.getMaterialBaseInfoList(queryDTO);
|
||||
List<String> materialCodeList = resultList.stream()
|
||||
.map(OrderWithMaterialDTO::getMaterialCode)
|
||||
.filter(StringUtils::hasText)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 判断返回是否成功
|
||||
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);
|
||||
if (materialCodeList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 从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")); //净重
|
||||
// 2. 批量查询物料信息(一次查询所有物料)
|
||||
try {
|
||||
MaterialInfoDTO queryDTO = new MaterialInfoDTO();
|
||||
// 传入物料编码列表(逗号分隔或用其他方式)
|
||||
queryDTO.setMaterialCode(String.join(",", materialCodeList));
|
||||
|
||||
TableDataInfo tableDataInfo = wmsServiceFeign.getMaterialBaseInfoList(queryDTO);
|
||||
|
||||
if (tableDataInfo != null && tableDataInfo.getCode() == 200) {
|
||||
List<?> materialList = tableDataInfo.getData();
|
||||
|
||||
// 3. 把物料列表转成 Map(key = materialCode)
|
||||
Map<String, Map<?, ?>> materialMap = new HashMap<>();
|
||||
for (Object material : materialList) {
|
||||
Map<?, ?> m = (Map<?, ?>) material;
|
||||
String code = (String) m.get("materialCode");
|
||||
materialMap.put(code, m);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// 查询失败不影响主流程,打印日志
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 查询失败不影响主流程
|
||||
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();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user