库存分配时如果没有库存抛异常
导入模版没有物料抛异常
This commit is contained in:
+63
-4
@@ -1,9 +1,14 @@
|
||||
package com.mhd.wms.interfaces.facadeApi.materialInventory;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.web.controller.BaseController;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.core.web.page.TableDataInfo;
|
||||
import com.mhd.system.api.UserServiceFeign;
|
||||
import com.mhd.wms.application.service.materialInventory.MaterialInventoryApplicationService;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO;
|
||||
@@ -13,6 +18,7 @@ import com.mhd.wms.interfaces.assember.materialInventory.MaterialInventoryAssemb
|
||||
import com.mhd.wms.interfaces.dto.materialInventory.MaterialInventoryDTO;
|
||||
import com.mhd.wms.interfaces.dto.materialInventory.MaterialInventoryQueryListDTO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -27,6 +33,7 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/materialInventoryApi")
|
||||
@Slf4j
|
||||
public class MaterialInventoryApi extends BaseController {
|
||||
@Autowired
|
||||
private MaterialInventoryApplicationService materialInventoryApplicationService;
|
||||
@@ -34,6 +41,9 @@ public class MaterialInventoryApi extends BaseController {
|
||||
@Resource
|
||||
private MaterialInventoryAssembler materialInventoryAssembler;
|
||||
|
||||
@Autowired
|
||||
private UserServiceFeign userServiceFeign;
|
||||
|
||||
/**
|
||||
* 分页查询物料库存列表
|
||||
*/
|
||||
@@ -42,9 +52,26 @@ public class MaterialInventoryApi extends BaseController {
|
||||
public TableDataInfo list(MaterialInventoryDTO materialInventoryDTO,
|
||||
@RequestParam(value = "customerName", required = false) String customerName)
|
||||
{
|
||||
// 出库分配前端传的是客户名称 customerName,这里转成货主筛选条件(模糊匹配货主编码 / 名称)
|
||||
if (StringUtils.isNotBlank(customerName) && StringUtils.isBlank(materialInventoryDTO.getShipperInfo())) {
|
||||
materialInventoryDTO.setShipperInfo(customerName);
|
||||
// 出库分配前端传的是客户名称 customerName,这里通过名称查询货主ID,使用精确匹配(不模糊匹配)
|
||||
String shipperName = null; // 保存查询到的货主名称
|
||||
if (StringUtils.isNotBlank(customerName) && materialInventoryDTO.getShipperId() == null) {
|
||||
try {
|
||||
AjaxResult ajaxResult = userServiceFeign.getInfoByName(customerName);
|
||||
if ("200".equals(String.valueOf(ajaxResult.get("code"))) && ajaxResult.get("data") != null) {
|
||||
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
|
||||
if (userPo != null && userPo.getUserId() != null) {
|
||||
materialInventoryDTO.setShipperId(userPo.getUserId());
|
||||
// 获取货主名称:优先使用企业名称,如果没有则使用用户名称
|
||||
shipperName = StringUtils.isNotBlank(userPo.getShipperEnterpriseName())
|
||||
? userPo.getShipperEnterpriseName()
|
||||
: userPo.getUserName();
|
||||
log.info("根据客户名称查询到货主信息,客户名称:{},货主ID:{},货主名称:{}",
|
||||
customerName, userPo.getUserId(), shipperName);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("根据客户名称查询货主ID失败,客户名称:{},错误:{}", customerName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//转换实体
|
||||
@@ -52,7 +79,39 @@ public class MaterialInventoryApi extends BaseController {
|
||||
startPage();
|
||||
// 使用带批次属性的查询方法,批次属性值从库存表中获取
|
||||
List<MaterialInventoryPO> list = materialInventoryApplicationService.queryListWithBatchAttributes(materialInventoryDO);
|
||||
return getDataTable(list);
|
||||
TableDataInfo tableDataInfo = getDataTable(list);
|
||||
// 如果查询结果为空,抛出异常提示用户该物料在库存中不存在
|
||||
if (tableDataInfo.getTotal() == 0) {
|
||||
StringBuilder errorMsg = new StringBuilder("该物料在库存中不存在");
|
||||
// 如果有物料信息,添加到提示中
|
||||
if (StringUtils.isNotBlank(materialInventoryDTO.getMaterialName())) {
|
||||
errorMsg.append(",物料名称:").append(materialInventoryDTO.getMaterialName());
|
||||
} else if (StringUtils.isNotBlank(materialInventoryDTO.getMaterialCode())) {
|
||||
errorMsg.append(",物料编码:").append(materialInventoryDTO.getMaterialCode());
|
||||
} else if (StringUtils.isNotBlank(materialInventoryDTO.getBarCode())) {
|
||||
errorMsg.append(",物料条码:").append(materialInventoryDTO.getBarCode());
|
||||
}
|
||||
// 如果有货主信息,添加到提示中(优先显示查询到的货主名称,否则显示客户名称)
|
||||
if (StringUtils.isNotBlank(shipperName)) {
|
||||
errorMsg.append(",货主:").append(shipperName);
|
||||
} else if (StringUtils.isNotBlank(customerName)) {
|
||||
errorMsg.append(",货主:").append(customerName);
|
||||
}
|
||||
// 如果有批次参考号,添加到提示中
|
||||
if (StringUtils.isNotBlank(materialInventoryDTO.getBatchRefNo())) {
|
||||
errorMsg.append(",Batch Ref NO's:").append(materialInventoryDTO.getBatchRefNo());
|
||||
}
|
||||
// 如果有单据参考号,添加到提示中
|
||||
if (StringUtils.isNotBlank(materialInventoryDTO.getSheetRefNo())) {
|
||||
errorMsg.append(",Sheet Ref NO's:").append(materialInventoryDTO.getSheetRefNo());
|
||||
}
|
||||
// 如果有箱号/卡板号,添加到提示中
|
||||
if (StringUtils.isNotBlank(materialInventoryDTO.getBoxPalletNo())) {
|
||||
errorMsg.append(",箱号/卡板号:").append(materialInventoryDTO.getBoxPalletNo());
|
||||
}
|
||||
throw new ServiceException(errorMsg.toString());
|
||||
}
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
@ApiOperation("查询物料库存列表不分页")
|
||||
|
||||
Reference in New Issue
Block a user