修改一般贸易的详情查询数据来源
This commit is contained in:
@@ -115,4 +115,10 @@ public interface WmsServiceFeign {
|
||||
@RequestParam(value = "pushTime",required = false) String pushTime,
|
||||
@RequestParam(value = "pushBy",required = false) Long pushBy,
|
||||
@RequestParam(value = "pushByName",required = false) String pushByName);
|
||||
|
||||
/**
|
||||
* 根据物料ID列表批量查询物料信息
|
||||
*/
|
||||
@GetMapping("/materialBaseInfoApi/getBatchByIds")
|
||||
public TableDataInfo getBatchByIds(@RequestParam("materialBaseInfoIds") List<Long> materialBaseInfoIds);
|
||||
}
|
||||
+9
@@ -90,6 +90,15 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
|
||||
public AjaxResult<?> updateMaterialPushStatus(Long materialBaseInfoId, Integer pushStatus, String pushTime, Long pushBy, String pushByName) {
|
||||
return AjaxResult.error(cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo getBatchByIds(List<Long> materialBaseInfoIds) {
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setData(new ArrayList<>());
|
||||
tableDataInfo.setTotal(0);
|
||||
tableDataInfo.setCode(500);
|
||||
return tableDataInfo;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+42
@@ -2,6 +2,7 @@ package com.mhd.oms.application.service.materialInfo;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
@@ -9,6 +10,9 @@ import com.mhd.common.core.web.page.TableDataInfo;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.oms.domain.gwLog.entity.GwLog;
|
||||
import com.mhd.oms.domain.gwLog.repository.mapper.GwLogMapper;
|
||||
import com.mhd.oms.domain.materialPushRecord.entity.MaterialPushRecord;
|
||||
import com.mhd.oms.domain.materialPushRecord.repository.mapper.MaterialPushRecordMapper;
|
||||
import com.mhd.oms.domain.reservationStockInOrder.repository.po.MaterialBaseInfoPO;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper;
|
||||
import com.mhd.system.api.WmsServiceFeign;
|
||||
import com.mhd.system.api.domain.MaterialInfoDTO;
|
||||
@@ -45,6 +49,9 @@ public class MaterialInfoApplicationService {
|
||||
@Resource
|
||||
private BusinessDocumentOrderMapper businessDocumentOrderMapper;
|
||||
|
||||
@Resource
|
||||
private MaterialPushRecordMapper materialPushRecordMapper;
|
||||
|
||||
private final WmsServiceFeign wmsServiceFeign;
|
||||
|
||||
public MaterialInfoApplicationService(WmsServiceFeign wmsServiceFeign) {
|
||||
@@ -88,6 +95,7 @@ public class MaterialInfoApplicationService {
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
StringBuilder failMsg = new StringBuilder();
|
||||
List<Long> successIds = new ArrayList<>();
|
||||
|
||||
for (MaterialInfoDTO dto : dtoList) {
|
||||
Map<String, String> item = new HashMap<>();
|
||||
@@ -147,6 +155,7 @@ public class MaterialInfoApplicationService {
|
||||
gwLog.setStatus(2);
|
||||
updatePushStatus(dto.getMaterialBaseInfoId(), 3, new Date(), pushBy, pushByName);
|
||||
successCount++;
|
||||
successIds.add(dto.getMaterialBaseInfoId());
|
||||
} else {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(responseString);
|
||||
@@ -181,6 +190,39 @@ public class MaterialInfoApplicationService {
|
||||
}
|
||||
}
|
||||
|
||||
// 推送成功后,保存物料快照到物料推送记录表
|
||||
if (!successIds.isEmpty()) {
|
||||
try {
|
||||
Date now = new Date();
|
||||
TableDataInfo wmsResult = wmsServiceFeign.getBatchByIds(successIds);
|
||||
if (wmsResult != null && wmsResult.getData() != null) {
|
||||
List<MaterialBaseInfoPO> materialList = JSONArray.parseArray(
|
||||
JSONObject.toJSONString(wmsResult.getData()), MaterialBaseInfoPO.class);
|
||||
for (MaterialBaseInfoPO material : materialList) {
|
||||
MaterialPushRecord record = new MaterialPushRecord();
|
||||
record.setMaterialBaseInfoId(material.getMaterialBaseInfoId());
|
||||
record.setMaterialCode(material.getMaterialCode());
|
||||
record.setMaterialName(material.getMaterialName());
|
||||
record.setGoodsType(material.getGoodsType());
|
||||
record.setSpecificationModel(material.getSpecificationModel());
|
||||
record.setDeclarationUnit(material.getDeclarationUnit());
|
||||
record.setCurrency(material.getCurrency());
|
||||
record.setUnitPrice(material.getUnitPrice());
|
||||
record.setNetWeight(material.getWeightLimit());
|
||||
record.setGrossWeight(material.getGrossWeight());
|
||||
record.setPushTime(now);
|
||||
record.setDelFlag(1);
|
||||
record.setCreateBy(pushBy);
|
||||
record.setCreateTime(now);
|
||||
record.setUpdateTime(now);
|
||||
materialPushRecordMapper.insert(record);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存物料推送快照失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
String resultMsg = "推送完成: 成功" + successCount + "条, 失败" + failCount + "条";
|
||||
if (failCount > 0) {
|
||||
resultMsg += "[" + failMsg.toString() + "]";
|
||||
|
||||
+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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.mhd.oms.interfaces.facade.materialPushRecord;
|
||||
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.oms.domain.materialPushRecord.service.MaterialPushRecordService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "物料推送记录")
|
||||
@RestController
|
||||
@RequestMapping("/materialPushRecordApi")
|
||||
public class MaterialPushRecordApi {
|
||||
|
||||
@Resource
|
||||
private MaterialPushRecordService materialPushRecordService;
|
||||
|
||||
@ApiOperation("批量查询物料推送数据(优先查推送快照,没有则调WMS查实时数据)")
|
||||
@GetMapping("/getBatchByIds")
|
||||
public AjaxResult getBatchByIds(@RequestParam("materialBaseInfoIds") List<Long> materialBaseInfoIds) {
|
||||
return AjaxResult.success(materialPushRecordService.getBatchByIds(materialBaseInfoIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mhd.oms.domain.materialPushRecord.repository.mapper.MaterialPushRecordMapper">
|
||||
|
||||
<resultMap type="com.mhd.oms.domain.materialPushRecord.entity.MaterialPushRecord" id="MaterialPushRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="materialBaseInfoId" column="material_base_info_id" />
|
||||
<result property="materialCode" column="material_code" />
|
||||
<result property="materialName" column="material_name" />
|
||||
<result property="specificationModel" column="specification_model" />
|
||||
<result property="declarationUnit" column="declaration_unit" />
|
||||
<result property="cargoNum" column="cargo_num" />
|
||||
<result property="currency" column="currency" />
|
||||
<result property="unitPrice" column="unit_price" />
|
||||
<result property="netWeight" column="net_weight" />
|
||||
<result property="grossWeight" column="gross_weight" />
|
||||
<result property="goodsType" column="goods_type" />
|
||||
<result property="pushTime" column="push_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user