物料查询解决total问题 以及其他页面是推送人名称问题
This commit is contained in:
@@ -2,6 +2,7 @@ package com.mhd.system.api;
|
||||
|
||||
import com.mhd.common.core.constant.ServiceNameConstants;
|
||||
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.factory.RemoteWmsFallbackFactory;
|
||||
import com.mhd.system.api.feign.FeignAutoConfiguration;
|
||||
@@ -98,7 +99,7 @@ public interface WmsServiceFeign {
|
||||
|
||||
@ApiOperation("oms查询物料列表")
|
||||
@GetMapping("/materialBaseInfoApi/queryList")
|
||||
public AjaxResult getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO);
|
||||
public TableDataInfo getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO);
|
||||
|
||||
@ApiOperation("oms物料列表推送-更新推送信息")
|
||||
@PostMapping("/materialBaseInfoApi/updatePushStatus")
|
||||
|
||||
@@ -48,5 +48,10 @@ public class MaterialInfoDTO {
|
||||
@ApiModelProperty("推送时间止")
|
||||
private String pushTimeEnd;
|
||||
|
||||
@ApiModelProperty(value = "页码")
|
||||
private Integer pageNum = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数量")
|
||||
private Integer pageSize = 10;
|
||||
|
||||
}
|
||||
|
||||
+8
-2
@@ -2,6 +2,7 @@ package com.mhd.system.api.factory;
|
||||
|
||||
import com.mhd.common.core.domain.entity.R;
|
||||
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.WmsServiceFeign;
|
||||
import com.mhd.system.api.domain.*;
|
||||
@@ -11,6 +12,7 @@ import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -71,8 +73,12 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO) {
|
||||
return AjaxResult.error(cause.getMessage());
|
||||
public TableDataInfo getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO) {
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setData(new ArrayList<>());
|
||||
tableDataInfo.setTotal(0);
|
||||
tableDataInfo.setCode(500);
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-7
@@ -45,20 +45,22 @@ public class MaterialInfoApplicationService {
|
||||
}
|
||||
|
||||
public TableDataInfo queryList(MaterialInfoDTO materialInfoDTO) {
|
||||
AjaxResult ajaxResult = wmsServiceFeign.getMaterialBaseInfoList(materialInfoDTO);
|
||||
if(ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
List<?> data = (List<?>) ajaxResult.get("data");
|
||||
try {
|
||||
|
||||
TableDataInfo wmsTableDataInfo = wmsServiceFeign.getMaterialBaseInfoList(materialInfoDTO);
|
||||
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setData(data);
|
||||
tableDataInfo.setData(wmsTableDataInfo.getData());
|
||||
tableDataInfo.setTotal(wmsTableDataInfo.getTotal());
|
||||
tableDataInfo.setCode(200);
|
||||
tableDataInfo.setTotal(data.size());
|
||||
return tableDataInfo;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("查询物料列表异常: {}", e.getMessage());
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(500);
|
||||
tableDataInfo.setMsg("查询失败");
|
||||
return tableDataInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public AjaxResult batchPush(List<MaterialInfoDTO> dtoList) {
|
||||
if (dtoList == null || dtoList.isEmpty()) {
|
||||
|
||||
@@ -33,6 +33,9 @@ public class ErpCountryPO {
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private String pushByName;
|
||||
|
||||
@ApiModelProperty("所属组织ID")
|
||||
private Long organizationId;
|
||||
|
||||
|
||||
+4
-1
@@ -34,7 +34,10 @@ public class ErpEnterpriseUnitPO extends BaseVOEntity {
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty(value = "推送人")
|
||||
private String pushBy;
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty(value = "推送人")
|
||||
private String pushByName;
|
||||
|
||||
@ApiModelProperty(value = "所属组织ID")
|
||||
private Long organizationId;
|
||||
|
||||
+90
-39
@@ -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())) {
|
||||
|
||||
List<String> materialCodeList = resultList.stream()
|
||||
.map(OrderWithMaterialDTO::getMaterialCode)
|
||||
.filter(StringUtils::hasText)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (materialCodeList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 批量查询物料信息(一次查询所有物料)
|
||||
try {
|
||||
// 构建查询参数
|
||||
MaterialInfoDTO queryDTO = new MaterialInfoDTO();
|
||||
queryDTO.setMaterialCode(dto.getMaterialCode());
|
||||
// 传入物料编码列表(逗号分隔或用其他方式)
|
||||
queryDTO.setMaterialCode(String.join(",", materialCodeList));
|
||||
|
||||
// 调用WMS接口查询物料详情
|
||||
AjaxResult ajaxResult = wmsServiceFeign.getMaterialBaseInfoList(queryDTO);
|
||||
TableDataInfo tableDataInfo = 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);
|
||||
if (tableDataInfo != null && tableDataInfo.getCode() == 200) {
|
||||
List<?> materialList = tableDataInfo.getData();
|
||||
|
||||
// 从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")); //净重
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 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
|
||||
left join business_document_cargo_multi as a ON o.id = a.order_id
|
||||
<include refid="selectBusinessDocumentOrderPo1"/>
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
package com.mhd.wms.interfaces.facadeApi.materialBaseInfo;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.mhd.common.core.domain.entity.R;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
@@ -133,8 +134,9 @@ public class MaterialBaseInfoApi extends BaseController {
|
||||
MaterialBaseInfoDO materialBaseInfoDO = materialBaseInfoAssembler.toDO(materialBaseInfoDTO);
|
||||
startPage();
|
||||
List<MaterialBaseInfoPO> list = materialBaseInfoApplicationService.queryList(materialBaseInfoDO);
|
||||
Page<MaterialBaseInfoPO> page = (Page<MaterialBaseInfoPO>) list;
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setTotal(list.size());
|
||||
tableDataInfo.setTotal(page.getTotal());
|
||||
tableDataInfo.setCode(200);
|
||||
tableDataInfo.setData(list);
|
||||
return tableDataInfo;
|
||||
|
||||
Reference in New Issue
Block a user