修改一般贸易的详情查询数据来源
This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
package com.mhd.oms.domain.materialPushRecord.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 物料推送记录表
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "物料推送记录对象")
|
||||
@TableName("material_push_record")
|
||||
public class MaterialPushRecord extends BaseVOEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("物料ID")
|
||||
private Long materialBaseInfoId;
|
||||
|
||||
@ApiModelProperty("物料编码")
|
||||
private String materialCode;
|
||||
|
||||
@ApiModelProperty("物料名称")
|
||||
private String materialName;
|
||||
|
||||
@ApiModelProperty("规格型号")
|
||||
private String specificationModel;
|
||||
|
||||
@ApiModelProperty("申报单位")
|
||||
private String declarationUnit;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private BigDecimal cargoNum;
|
||||
|
||||
@ApiModelProperty("币制")
|
||||
private String currency;
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty("净重(kg)")
|
||||
private BigDecimal netWeight;
|
||||
|
||||
@ApiModelProperty("毛重(kg)")
|
||||
private BigDecimal grossWeight;
|
||||
|
||||
@ApiModelProperty("商品类型(0物料,1半成品,2成品)")
|
||||
private Integer goodsType;
|
||||
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("删除标志(1-正常,2-删除)")
|
||||
private Integer delFlag;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.mhd.oms.domain.materialPushRecord.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.oms.domain.materialPushRecord.entity.MaterialPushRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MaterialPushRecordMapper extends BaseMapper<MaterialPushRecord> {
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package com.mhd.oms.domain.materialPushRecord.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhd.common.core.web.page.TableDataInfo;
|
||||
import com.mhd.oms.domain.materialPushRecord.entity.MaterialPushRecord;
|
||||
import com.mhd.oms.domain.materialPushRecord.repository.mapper.MaterialPushRecordMapper;
|
||||
import com.mhd.system.api.WmsServiceFeign;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MaterialPushRecordService {
|
||||
|
||||
@Resource
|
||||
private MaterialPushRecordMapper materialPushRecordMapper;
|
||||
|
||||
@Resource
|
||||
private WmsServiceFeign wmsServiceFeign;
|
||||
|
||||
/**
|
||||
* 按物料ID列表查询物料数据
|
||||
* 优先查物料推送快照,没有则调WMS查实时数据
|
||||
*/
|
||||
public TableDataInfo getBatchByIds(List<Long> materialBaseInfoIds) {
|
||||
if (materialBaseInfoIds == null || materialBaseInfoIds.isEmpty()) {
|
||||
TableDataInfo emptyResult = new TableDataInfo();
|
||||
emptyResult.setData(new ArrayList<>());
|
||||
emptyResult.setTotal(0);
|
||||
emptyResult.setCode(200);
|
||||
return emptyResult;
|
||||
}
|
||||
|
||||
// 1. 先查物料推送记录表
|
||||
List<MaterialPushRecord> pushRecords = materialPushRecordMapper.selectList(
|
||||
new LambdaQueryWrapper<MaterialPushRecord>()
|
||||
.in(MaterialPushRecord::getMaterialBaseInfoId, materialBaseInfoIds)
|
||||
.eq(MaterialPushRecord::getDelFlag, 1));
|
||||
|
||||
if (pushRecords != null && !pushRecords.isEmpty()) {
|
||||
// 检查是否所有请求的物料ID都查到了
|
||||
Set<Long> foundIds = pushRecords.stream()
|
||||
.map(MaterialPushRecord::getMaterialBaseInfoId)
|
||||
.collect(Collectors.toSet());
|
||||
if (foundIds.containsAll(materialBaseInfoIds)) {
|
||||
// 全部ID都有推送快照,直接返回
|
||||
TableDataInfo result = new TableDataInfo();
|
||||
result.setData(pushRecords);
|
||||
result.setTotal(pushRecords.size());
|
||||
result.setCode(200);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 有物料没有推送数据,调WMS查全部实时数据
|
||||
try {
|
||||
return wmsServiceFeign.getBatchByIds(materialBaseInfoIds);
|
||||
} catch (Exception e) {
|
||||
log.error("调用WMS查询物料信息失败: {}", e.getMessage());
|
||||
TableDataInfo errorResult = new TableDataInfo();
|
||||
errorResult.setData(new ArrayList<>());
|
||||
errorResult.setTotal(0);
|
||||
errorResult.setCode(500);
|
||||
return errorResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user