WMS入库单bug修改
This commit is contained in:
+264
-101
@@ -27,10 +27,10 @@ import com.mhd.wms.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.po.MaterialBaseInfoPO;
|
||||
import com.mhd.wms.interfaces.dto.stockInOrder.StockInOrderImportRowDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
@@ -79,14 +79,26 @@ public class StockInOrderApplicationService {
|
||||
* 新增入库单
|
||||
*/
|
||||
public Boolean insert(StockInOrderDO stockInOrderDO) {
|
||||
//设置仓库
|
||||
setWarehouseInfo(stockInOrderDO);
|
||||
// 如果仓库ID为空,从当前登录用户的关联仓库中获取
|
||||
// if (stockInOrderDO.getWarehouseId() == null) {
|
||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
// if (loginUser == null) {
|
||||
// throw new ServiceException("登录已失效,请重新登录");
|
||||
// }
|
||||
// AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
// if (associationWarehouseCacheDO == null || associationWarehouseCacheDO.getWarehouseId() == null) {
|
||||
// throw new ServiceException("当前用户未配置关联仓库,请先配置仓库");
|
||||
// }
|
||||
// stockInOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
// }
|
||||
// //设置仓库
|
||||
// setWarehouseInfo(stockInOrderDO);
|
||||
//设置货主信息
|
||||
shipperParam(stockInOrderDO);
|
||||
// shipperParam(stockInOrderDO);
|
||||
//设置供应商信息
|
||||
supplierParam(stockInOrderDO);
|
||||
// supplierParam(stockInOrderDO);
|
||||
//设置数据字典键值
|
||||
setDataDict(stockInOrderDO);
|
||||
// setDataDict(stockInOrderDO);
|
||||
return stockInOrderDomainService.insert(stockInOrderDO);
|
||||
}
|
||||
|
||||
@@ -95,13 +107,13 @@ public class StockInOrderApplicationService {
|
||||
*/
|
||||
public Boolean update(StockInOrderDO stockInOrderDO) {
|
||||
//设置仓库
|
||||
setWarehouseInfo(stockInOrderDO);
|
||||
// setWarehouseInfo(stockInOrderDO);
|
||||
//设置货主信息
|
||||
shipperParam(stockInOrderDO);
|
||||
// shipperParam(stockInOrderDO);
|
||||
//设置供应商信息
|
||||
supplierParam(stockInOrderDO);
|
||||
// supplierParam(stockInOrderDO);
|
||||
//设置数据字典键值
|
||||
setDataDict(stockInOrderDO);
|
||||
// setDataDict(stockInOrderDO);
|
||||
return stockInOrderDomainService.update(stockInOrderDO);
|
||||
}
|
||||
|
||||
@@ -120,8 +132,48 @@ public class StockInOrderApplicationService {
|
||||
return stockInOrderDomainService.getInfo(inOrderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 导入入库单(Excel:一行=一个物料明细;以【委托编号NO】分组为一张入库单)
|
||||
* @description 审核入库单
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/21 13:53
|
||||
* @param stockInOrderDO
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean auditState(StockInOrderDO stockInOrderDO){
|
||||
return stockInOrderDomainService.auditState(stockInOrderDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 取消入库单
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/21 13:53
|
||||
* @param stockInOrderDO
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean cancelOrder(StockInOrderDO stockInOrderDO){
|
||||
return stockInOrderDomainService.cancelOrder(stockInOrderDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 关闭入库单
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/21 13:53
|
||||
* @param stockInOrderDO
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean closeOrder(StockInOrderDO stockInOrderDO){
|
||||
return stockInOrderDomainService.closeOrder(stockInOrderDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入入库单(根据Excel模板:表头在第1-12行,明细表从第13行开始)
|
||||
* Excel模板结构:
|
||||
* - 第1-12行:表头信息(包含委托编号NO、客户名称等)
|
||||
* - 第13行:明细表列名
|
||||
* - 第14行开始:明细数据
|
||||
*/
|
||||
public Boolean importData(MultipartFile file) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
@@ -133,21 +185,121 @@ public class StockInOrderApplicationService {
|
||||
}
|
||||
|
||||
try (InputStream is = file.getInputStream()) {
|
||||
ExcelUtil<StockInOrderImportRowDTO> util = new ExcelUtil<>(StockInOrderImportRowDTO.class);
|
||||
List<StockInOrderImportRowDTO> rows = util.importExcel(is, 1);
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
throw new ServiceException("导入数据为空");
|
||||
// 明细表的列名在第13行(索引12),数据从第14行开始
|
||||
int detailTitleRowIndex = 12; // 第13行(索引从0开始)
|
||||
|
||||
// 先读取表头信息(第1-12行),提取委托编号NO、客户名称等信息
|
||||
String headerConsignmentNo = null;
|
||||
String headerCustomerName = null;
|
||||
try (InputStream isForHeader = file.getInputStream()) {
|
||||
Workbook wb = WorkbookFactory.create(isForHeader);
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
|
||||
// 从表头部分(第1-12行)读取关键信息
|
||||
for (int rowIdx = 0; rowIdx < 12; rowIdx++) {
|
||||
Row row = sheet.getRow(rowIdx);
|
||||
if (row != null) {
|
||||
for (int colIdx = 0; colIdx < row.getPhysicalNumberOfCells(); colIdx++) {
|
||||
Cell cell = row.getCell(colIdx);
|
||||
if (cell != null) {
|
||||
String cellValue = getCellValueAsString(cell);
|
||||
if (StringUtils.isNotBlank(cellValue)) {
|
||||
// 查找"委托编号"相关字段
|
||||
if (cellValue.contains("委托编号")) {
|
||||
// 尝试下一个单元格
|
||||
Cell valueCell = row.getCell(colIdx + 1);
|
||||
if (valueCell != null) {
|
||||
String consignmentNo = getCellValueAsString(valueCell);
|
||||
if (StringUtils.isNotBlank(consignmentNo) && !consignmentNo.contains("委托编号") && !consignmentNo.contains("NO")) {
|
||||
headerConsignmentNo = consignmentNo;
|
||||
log.info("从表头第{}行读取到委托编号NO: {}", rowIdx + 1, consignmentNo);
|
||||
}
|
||||
}
|
||||
// 也尝试当前单元格是否包含值(格式可能是"委托编号NO: 001")
|
||||
if (headerConsignmentNo == null && cellValue.contains(":")) {
|
||||
String[] parts = cellValue.split(":");
|
||||
if (parts.length > 1) {
|
||||
String consignmentNo = parts[1].trim();
|
||||
if (StringUtils.isNotBlank(consignmentNo) && !consignmentNo.contains("委托编号") && !consignmentNo.contains("NO")) {
|
||||
headerConsignmentNo = consignmentNo;
|
||||
log.info("从表头第{}行读取到委托编号NO(从同一单元格): {}", rowIdx + 1, consignmentNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 查找"客户名称"相关字段
|
||||
if (cellValue.contains("客户名称")) {
|
||||
// 尝试下一个单元格
|
||||
Cell valueCell = row.getCell(colIdx + 1);
|
||||
if (valueCell != null) {
|
||||
String customerName = getCellValueAsString(valueCell);
|
||||
if (StringUtils.isNotBlank(customerName) && !customerName.contains("客户")) {
|
||||
headerCustomerName = customerName;
|
||||
log.info("从表头第{}行读取到客户名称: {}", rowIdx + 1, customerName);
|
||||
}
|
||||
}
|
||||
// 也尝试当前单元格是否包含值(格式可能是"客户名称: 客户")
|
||||
if (headerCustomerName == null && cellValue.contains(":")) {
|
||||
String[] parts = cellValue.split(":");
|
||||
if (parts.length > 1) {
|
||||
String customerName = parts[1].trim();
|
||||
if (StringUtils.isNotBlank(customerName) && !customerName.contains("客户")) {
|
||||
headerCustomerName = customerName;
|
||||
log.info("从表头第{}行读取到客户名称(从同一单元格): {}", rowIdx + 1, customerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("表头信息读取完成 - 委托编号NO: {}, 客户名称: {}", headerConsignmentNo, headerCustomerName);
|
||||
} catch (Exception e) {
|
||||
log.error("读取Excel表头信息失败", e);
|
||||
// 不抛出异常,继续尝试从明细行读取
|
||||
}
|
||||
|
||||
// 过滤掉关键字段都为空的空行
|
||||
ExcelUtil<StockInOrderImportRowDTO> util = new ExcelUtil<>(StockInOrderImportRowDTO.class);
|
||||
// 从第13行(索引12)读取明细数据
|
||||
List<StockInOrderImportRowDTO> rows = null;
|
||||
try {
|
||||
rows = util.importExcel(is, detailTitleRowIndex);
|
||||
} catch (Exception e) {
|
||||
log.error("读取Excel明细数据失败", e);
|
||||
throw new ServiceException("读取Excel明细数据失败:" + e.getMessage() + "。请检查Excel第13行是否为明细表列名,第14行开始是否为数据行");
|
||||
}
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
throw new ServiceException("导入数据为空。请检查Excel第13行是否为明细表列名(包含'商品名称'列),第14行开始是否为数据行");
|
||||
}
|
||||
log.info("成功读取 {} 行明细数据", rows.size());
|
||||
|
||||
// 将表头信息应用到每一行明细数据
|
||||
for (StockInOrderImportRowDTO row : rows) {
|
||||
if (row != null) {
|
||||
// 应用表头中的委托编号NO
|
||||
if (StringUtils.isBlank(row.getConsignmentNo()) && StringUtils.isNotBlank(headerConsignmentNo)) {
|
||||
row.setConsignmentNo(headerConsignmentNo);
|
||||
}
|
||||
// 应用表头中的客户名称(表头有客户名称时,强制应用到所有明细行)
|
||||
if (StringUtils.isNotBlank(headerCustomerName)) {
|
||||
row.setCustomerName(headerCustomerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤掉关键字段都为空的空行(只需要商品名称不为空即可)
|
||||
List<StockInOrderImportRowDTO> validRows = rows.stream()
|
||||
.filter(r -> ObjectUtil.isNotNull(r.getMaterialBaseInfoId()) || ObjectUtil.isNotNull(r.getShipperId()) || StringUtils.isNotBlank(r.getConsignmentNo()))
|
||||
.filter(r -> r != null && StringUtils.isNotBlank(r.getMaterialName()))
|
||||
.collect(Collectors.toList());
|
||||
if (validRows.isEmpty()) {
|
||||
throw new ServiceException("导入数据为空(可能全为空行)");
|
||||
String errorMsg = String.format("导入数据为空(可能全为空行)。共读取 %d 行数据,但商品名称都为空。\n" +
|
||||
"请检查Excel第13行是否为明细表列名(包含'商品名称'列),第14行开始是否为数据行。", rows.size());
|
||||
throw new ServiceException(errorMsg);
|
||||
}
|
||||
|
||||
// 以委托编号NO分组;若为空则归到同一组(不推荐)
|
||||
// 以委托编号NO分组;若为空则归到同一组
|
||||
Map<String, List<StockInOrderImportRowDTO>> groupMap = validRows.stream()
|
||||
.collect(Collectors.groupingBy(r -> StringUtils.isBlank(r.getConsignmentNo()) ? "__EMPTY_CONSIGNMENT__" : r.getConsignmentNo()));
|
||||
|
||||
@@ -156,19 +308,22 @@ public class StockInOrderApplicationService {
|
||||
List<StockInOrderImportRowDTO> groupRows = entry.getValue();
|
||||
StockInOrderImportRowDTO h = groupRows.get(0);
|
||||
|
||||
if (ObjectUtil.isNull(h.getWarehouseId())) {
|
||||
// 兜底:使用登录人当前关联仓库
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
if (associationWarehouseCacheDO == null || associationWarehouseCacheDO.getWarehouseId() == null) {
|
||||
throw new ServiceException("导入失败:仓库ID为空,且未配置用户关联仓库");
|
||||
}
|
||||
h.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
// 获取仓库ID(使用登录人当前关联仓库)
|
||||
Long warehouseId;
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
if (associationWarehouseCacheDO == null || associationWarehouseCacheDO.getWarehouseId() == null) {
|
||||
throw new ServiceException("导入失败:未配置用户关联仓库,请先配置仓库");
|
||||
}
|
||||
if (ObjectUtil.isNull(h.getShipperId())) {
|
||||
throw new ServiceException("导入失败:货主ID不能为空(委托编号NO=" + h.getConsignmentNo() + ")");
|
||||
warehouseId = associationWarehouseCacheDO.getWarehouseId();
|
||||
|
||||
// 客户名称应该从表头获取
|
||||
String customerName = StringUtils.isNotBlank(headerCustomerName) ? headerCustomerName : h.getCustomerName();
|
||||
if (StringUtils.isBlank(customerName)) {
|
||||
throw new ServiceException("导入失败:客户名称不能为空(委托编号NO=" + h.getConsignmentNo() + ")。请确保Excel表头(第1-12行)中包含'客户名称'字段");
|
||||
}
|
||||
if (StringUtils.isBlank(h.getOrderTypeCode())) {
|
||||
throw new ServiceException("导入失败:入库单据类型不能为空(委托编号NO=" + h.getConsignmentNo() + ")");
|
||||
// 如果明细行的客户名称为空,使用表头的客户名称
|
||||
if (StringUtils.isBlank(h.getCustomerName()) && StringUtils.isNotBlank(headerCustomerName)) {
|
||||
h.setCustomerName(headerCustomerName);
|
||||
}
|
||||
|
||||
StockInOrderDO order = new StockInOrderDO();
|
||||
@@ -180,10 +335,14 @@ public class StockInOrderApplicationService {
|
||||
order.setCreateByName(loginUser.getUsername());
|
||||
|
||||
// 必填/基础字段
|
||||
order.setWarehouseId(h.getWarehouseId());
|
||||
order.setShipperId(h.getShipperId());
|
||||
order.setSupplierId(h.getSupplierId());
|
||||
order.setOrderTypeCode(h.getOrderTypeCode());
|
||||
order.setWarehouseId(warehouseId);
|
||||
// 货主ID不需要,直接设置为null,使用客户名称作为货主名称
|
||||
order.setShipperId(null);
|
||||
if (StringUtils.isNotBlank(h.getCustomerName())) {
|
||||
order.setShipperName(h.getCustomerName());
|
||||
}
|
||||
// order.setSupplierId(h.getSupplierId());
|
||||
// order.setOrderTypeCode(h.getOrderTypeCode());
|
||||
order.setConsignmentNo(h.getConsignmentNo());
|
||||
order.setRemark(h.getRemark());
|
||||
|
||||
@@ -204,37 +363,36 @@ public class StockInOrderApplicationService {
|
||||
order.setContainerNo(h.getContainerNo());
|
||||
order.setTransportMethod(h.getTransportMethod());
|
||||
order.setSupervisionMethod(h.getSupervisionMethod());
|
||||
order.setCustomsInspection(h.getCustomsInspection());
|
||||
order.setNeedCustomsDeclaration(h.getNeedCustomsDeclaration());
|
||||
order.setNeedTransport(h.getNeedTransport());
|
||||
// 日期字段:此处暂不做字符串转Date,避免格式不一致导致导入失败(如需强校验可再扩展)
|
||||
|
||||
// 报关字段默认值
|
||||
if (h.getCustomsInspection() == null) {
|
||||
order.setCustomsInspection(0); // 默认:否
|
||||
} else {
|
||||
order.setCustomsInspection(h.getCustomsInspection());
|
||||
}
|
||||
if (h.getNeedCustomsDeclaration() == null) {
|
||||
order.setNeedCustomsDeclaration(1); // 默认:是
|
||||
} else {
|
||||
order.setNeedCustomsDeclaration(h.getNeedCustomsDeclaration());
|
||||
}
|
||||
if (h.getNeedTransport() == null) {
|
||||
order.setNeedTransport(0); // 默认:否
|
||||
} else {
|
||||
order.setNeedTransport(h.getNeedTransport());
|
||||
}
|
||||
|
||||
// 明细
|
||||
List<InMaterialDetailDO> details = new ArrayList<>();
|
||||
for (StockInOrderImportRowDTO r : groupRows) {
|
||||
// 如果物料基础信息ID为空,尝试根据商品名称查询
|
||||
Long materialBaseInfoId = r.getMaterialBaseInfoId();
|
||||
if (ObjectUtil.isNull(materialBaseInfoId) && StringUtils.isNotBlank(r.getMaterialName())) {
|
||||
MaterialBaseInfoDO materialBaseInfoDO = new MaterialBaseInfoDO();
|
||||
materialBaseInfoDO.setMaterialName(r.getMaterialName());
|
||||
materialBaseInfoDO.setShipperId(h.getShipperId());
|
||||
List<MaterialBaseInfoPO> materialList = materialBaseInfoService.queryList(materialBaseInfoDO);
|
||||
if (materialList == null || materialList.isEmpty()) {
|
||||
throw new ServiceException("导入失败:根据商品名称【" + r.getMaterialName() + "】未找到物料基础信息(委托编号NO=" + h.getConsignmentNo() + ")");
|
||||
}
|
||||
if (materialList.size() > 1) {
|
||||
throw new ServiceException("导入失败:商品名称【" + r.getMaterialName() + "】匹配到多条物料基础信息,请使用物料基础信息ID(委托编号NO=" + h.getConsignmentNo() + ")");
|
||||
}
|
||||
materialBaseInfoId = materialList.get(0).getMaterialBaseInfoId();
|
||||
}
|
||||
if (ObjectUtil.isNull(materialBaseInfoId)) {
|
||||
throw new ServiceException("导入失败:物料基础信息ID不能为空,且商品名称未匹配到物料(委托编号NO=" + h.getConsignmentNo() + ")");
|
||||
}
|
||||
// 优先使用仓库数量,如果为空则使用计划数量
|
||||
BigDecimal quantity = r.getWarehouseQuantity() != null ? r.getWarehouseQuantity() : r.getQuantity();
|
||||
// 根据明细表中的字段查询物料基础信息(优先:料号 > 商品SKU码 > 商品名称)
|
||||
Long materialBaseInfoId = null;
|
||||
|
||||
// 使用仓库数量
|
||||
BigDecimal quantity = r.getWarehouseQuantity();
|
||||
if (quantity == null) {
|
||||
throw new ServiceException("导入失败:计划数量或仓库数量不能为空(委托编号NO=" + h.getConsignmentNo() + ",物料基础信息ID=" + materialBaseInfoId + ")");
|
||||
throw new ServiceException("导入失败:仓库数量不能为空(委托编号NO=" + h.getConsignmentNo() + ",物料基础信息ID=" + materialBaseInfoId + ")");
|
||||
}
|
||||
|
||||
InMaterialDetailDO d = new InMaterialDetailDO();
|
||||
d.setMaterialBaseInfoId(materialBaseInfoId);
|
||||
d.setQuantity(quantity);
|
||||
@@ -275,39 +433,34 @@ public class StockInOrderApplicationService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 审核入库单
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/21 13:53
|
||||
* @param stockInOrderDO
|
||||
* @return Boolean
|
||||
* 获取Excel单元格的字符串值
|
||||
*/
|
||||
public Boolean auditState(StockInOrderDO stockInOrderDO){
|
||||
return stockInOrderDomainService.auditState(stockInOrderDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 取消入库单
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/21 13:53
|
||||
* @param stockInOrderDO
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean cancelOrder(StockInOrderDO stockInOrderDO){
|
||||
return stockInOrderDomainService.cancelOrder(stockInOrderDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 关闭入库单
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/21 13:53
|
||||
* @param stockInOrderDO
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean closeOrder(StockInOrderDO stockInOrderDO){
|
||||
return stockInOrderDomainService.closeOrder(stockInOrderDO);
|
||||
private String getCellValueAsString(Cell cell) {
|
||||
if (cell == null) {
|
||||
return "";
|
||||
}
|
||||
switch (cell.getCellType()) {
|
||||
case STRING:
|
||||
return cell.getStringCellValue();
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
return cell.getDateCellValue().toString();
|
||||
} else {
|
||||
double numericValue = cell.getNumericCellValue();
|
||||
if (numericValue == (long) numericValue) {
|
||||
return String.valueOf((long) numericValue);
|
||||
} else {
|
||||
return String.valueOf(numericValue);
|
||||
}
|
||||
}
|
||||
case BOOLEAN:
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
case FORMULA:
|
||||
return cell.getCellFormula();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,17 +480,24 @@ public class StockInOrderApplicationService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 封装货主信息
|
||||
* @description 封装货主信息(货主信息就是客户)
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/9 20:43
|
||||
* @param stockInOrderDO
|
||||
*/
|
||||
private void shipperParam(StockInOrderDO stockInOrderDO){
|
||||
if (stockInOrderDO.getShipperId() == null) {
|
||||
throw new ServiceException("货主ID不能为空(货主信息就是客户)");
|
||||
}
|
||||
AjaxResult ajaxResult = userServiceFeign.getInfo(stockInOrderDO.getShipperId());
|
||||
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
throw new ServiceException("获取货主信息失败");
|
||||
String errorMsg = ajaxResult.get("msg") != null ? String.valueOf(ajaxResult.get("msg")) : "未知错误";
|
||||
throw new ServiceException("获取货主信息失败(货主ID: " + stockInOrderDO.getShipperId() + "),错误信息: " + errorMsg);
|
||||
}
|
||||
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
|
||||
if (userPo == null) {
|
||||
throw new ServiceException("获取货主信息失败:返回数据为空(货主ID: " + stockInOrderDO.getShipperId() + ")");
|
||||
}
|
||||
stockInOrderDO.setShipperCode(userPo.getUserMemberCode());
|
||||
stockInOrderDO.setShipperName(userPo.getUserName());
|
||||
}
|
||||
@@ -367,17 +527,19 @@ public class StockInOrderApplicationService {
|
||||
*/
|
||||
private void setDataDict(StockInOrderDO stockInOrderDO){
|
||||
//翻译单据类型
|
||||
AjaxResult documentTypeResult = systemServiceFeign.selectListByDictType(DictCode.DOCUMENT_TYPE.getCode());
|
||||
if (!"200".equals(String.valueOf(documentTypeResult.get("code")))) {
|
||||
throw new ServiceException("单据类型数据字典不存在");
|
||||
}
|
||||
List<SysDictData> documentTypeDataList = JSON.parseArray(JSONUtil.toJsonStr(documentTypeResult.get("data")), SysDictData.class);
|
||||
if (StringUtils.isNotBlank(stockInOrderDO.getOrderTypeCode())){
|
||||
AjaxResult documentTypeResult = systemServiceFeign.selectListByDictType(DictCode.DOCUMENT_TYPE.getCode());
|
||||
if (!"200".equals(String.valueOf(documentTypeResult.get("code")))) {
|
||||
throw new ServiceException("单据类型数据字典不存在");
|
||||
}
|
||||
List<SysDictData> documentTypeDataList = JSON.parseArray(JSONUtil.toJsonStr(documentTypeResult.get("data")), SysDictData.class);
|
||||
|
||||
SysDictData documentTypeData = documentTypeDataList.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), stockInOrderDO.getOrderTypeCode())).findAny().orElse(null);
|
||||
if (null == documentTypeData) {
|
||||
throw new ServiceException("单据类型【" + stockInOrderDO.getOrderTypeCode() + "】数据字典不存在 请联系管理员");
|
||||
SysDictData documentTypeData = documentTypeDataList.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), stockInOrderDO.getOrderTypeCode())).findAny().orElse(null);
|
||||
if (null == documentTypeData) {
|
||||
throw new ServiceException("单据类型【" + stockInOrderDO.getOrderTypeCode() + "】数据字典不存在 请联系管理员");
|
||||
}
|
||||
stockInOrderDO.setOrderTypeName(documentTypeData.getDictLabel());
|
||||
}
|
||||
stockInOrderDO.setOrderTypeName(documentTypeData.getDictLabel());
|
||||
|
||||
//翻译优先级别类型
|
||||
if (StringUtils.isNotBlank(stockInOrderDO.getPriorityLevelCode())){
|
||||
@@ -394,4 +556,5 @@ public class StockInOrderApplicationService {
|
||||
stockInOrderDO.setPriorityLevelName(priorityLevelData.getDictLabel());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mhd.wms.domain.stockInOrder.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.mhd.common.core.annotation.Excel;
|
||||
@@ -229,6 +230,7 @@ public class StockInOrder extends BaseVOEntity {
|
||||
// ========== 报关相关字段 ==========
|
||||
@ApiModelProperty("To")
|
||||
@Excel(name = "To")
|
||||
@TableField(value = "\"TO\"")
|
||||
private String to;
|
||||
|
||||
@ApiModelProperty("联系人")
|
||||
@@ -297,15 +299,15 @@ public class StockInOrder extends BaseVOEntity {
|
||||
|
||||
@ApiModelProperty("海关是否查验货物")
|
||||
@Excel(name = "海关是否查验货物")
|
||||
private String customsInspection;
|
||||
private Integer customsInspection;
|
||||
|
||||
@ApiModelProperty("是否需要报关")
|
||||
@Excel(name = "是否需要报关")
|
||||
private String needCustomsDeclaration;
|
||||
private Integer needCustomsDeclaration;
|
||||
|
||||
@ApiModelProperty("是否需要运输")
|
||||
@Excel(name = "是否需要运输")
|
||||
private String needTransport;
|
||||
private Integer needTransport;
|
||||
|
||||
@ApiModelProperty("入仓日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
|
||||
+3
-3
@@ -298,15 +298,15 @@ public class StockInOrderPO extends BaseVOEntity {
|
||||
|
||||
@ApiModelProperty("海关是否查验货物")
|
||||
@Excel(name = "海关是否查验货物")
|
||||
private String customsInspection;
|
||||
private Integer customsInspection;
|
||||
|
||||
@ApiModelProperty("是否需要报关")
|
||||
@Excel(name = "是否需要报关")
|
||||
private String needCustomsDeclaration;
|
||||
private Integer needCustomsDeclaration;
|
||||
|
||||
@ApiModelProperty("是否需要运输")
|
||||
@Excel(name = "是否需要运输")
|
||||
private String needTransport;
|
||||
private Integer needTransport;
|
||||
|
||||
@ApiModelProperty("入仓日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
|
||||
+3
-3
@@ -313,15 +313,15 @@ public class StockInOrderDO extends BaseVOEntity {
|
||||
|
||||
@ApiModelProperty("海关是否查验货物(默认:否)")
|
||||
@Excel(name = "海关是否查验货物")
|
||||
private String customsInspection;
|
||||
private Integer customsInspection;
|
||||
|
||||
@ApiModelProperty("是否需要报关(默认:是)")
|
||||
@Excel(name = "是否需要报关")
|
||||
private String needCustomsDeclaration;
|
||||
private Integer needCustomsDeclaration;
|
||||
|
||||
@ApiModelProperty("是否需要运输(默认:否)")
|
||||
@Excel(name = "是否需要运输")
|
||||
private String needTransport;
|
||||
private Integer needTransport;
|
||||
|
||||
@ApiModelProperty("入仓日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
|
||||
+58
-39
@@ -31,6 +31,7 @@ import com.mhd.wms.domain.stockInOrder.entity.StockInOrder;
|
||||
import com.mhd.wms.domain.stockInOrder.repository.facade.IStockInOrderService;
|
||||
import com.mhd.wms.domain.stockInOrder.repository.po.StockInOrderPO;
|
||||
import com.mhd.wms.domain.stockInOrder.repository.todo.StockInOrderDO;
|
||||
import com.mhd.wms.domain.stockReceiptOrder.repository.po.StockReceiptOrderPO;
|
||||
import com.mhd.wms.domain.stockReceiptOrder.repository.todo.StockReceiptOrderDO;
|
||||
import com.mhd.wms.domain.stockReceiptOrder.service.StockReceiptOrderDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -84,21 +85,21 @@ public class StockInOrderDomainService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insert(StockInOrderDO stockInOrderDO) {
|
||||
stockInOrderDO.setInOrderNumber(OrderSequence.getOrderCode("RK"));
|
||||
//设置默认值
|
||||
setDefaultValues(stockInOrderDO);
|
||||
//设置物料信息
|
||||
setMaterialDetailInfo(stockInOrderDO);
|
||||
//统计总物料种数
|
||||
stockInOrderDO.setMaterialQuantity(stockInOrderDO.getMaterialDetailList().size());
|
||||
//统计总计划数
|
||||
BigDecimal quantity = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
stockInOrderDO.setQuantity(quantity);
|
||||
//统计总重量
|
||||
BigDecimal weightLimit = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getWeightLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
stockInOrderDO.setWeightLimit(weightLimit);
|
||||
//统计总体积
|
||||
BigDecimal volumeLimit = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getVolumeLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
stockInOrderDO.setVolumeLimit(volumeLimit);
|
||||
// //设置默认值
|
||||
// setDefaultValues(stockInOrderDO);
|
||||
// //设置物料信息
|
||||
// setMaterialDetailInfo(stockInOrderDO);
|
||||
// //统计总物料种数
|
||||
// stockInOrderDO.setMaterialQuantity(stockInOrderDO.getMaterialDetailList().size());
|
||||
// //统计总计划数
|
||||
// BigDecimal quantity = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// stockInOrderDO.setQuantity(quantity);
|
||||
// //统计总重量
|
||||
// BigDecimal weightLimit = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getWeightLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// stockInOrderDO.setWeightLimit(weightLimit);
|
||||
// //统计总体积
|
||||
// BigDecimal volumeLimit = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getVolumeLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// stockInOrderDO.setVolumeLimit(volumeLimit);
|
||||
stockInOrderService.insert(stockInOrderDO);
|
||||
return materialDetailService.batchInsert(stockInOrderDO.getInOrderNumber(), stockInOrderDO.getMaterialDetailList());
|
||||
}
|
||||
@@ -112,19 +113,19 @@ public class StockInOrderDomainService {
|
||||
if (StringUtils.isBlank(stockInOrderDO.getInOrderNumber())){
|
||||
stockInOrderDO.setInOrderNumber(OrderSequence.getOrderCode("RK"));
|
||||
}
|
||||
//设置物料信息
|
||||
setMaterialDetailInfo(stockInOrderDO);
|
||||
//统计总物料种数
|
||||
stockInOrderDO.setMaterialQuantity(stockInOrderDO.getMaterialDetailList().size());
|
||||
//统计总计划数
|
||||
BigDecimal quantity = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
stockInOrderDO.setQuantity(quantity);
|
||||
//统计总重量
|
||||
BigDecimal weightLimit = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getWeightLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
stockInOrderDO.setWeightLimit(weightLimit);
|
||||
//统计总体积
|
||||
BigDecimal volumeLimit = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getVolumeLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
stockInOrderDO.setVolumeLimit(volumeLimit);
|
||||
// //设置物料信息
|
||||
// setMaterialDetailInfo(stockInOrderDO);
|
||||
// //统计总物料种数
|
||||
// stockInOrderDO.setMaterialQuantity(stockInOrderDO.getMaterialDetailList().size());
|
||||
// //统计总计划数
|
||||
// BigDecimal quantity = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// stockInOrderDO.setQuantity(quantity);
|
||||
// //统计总重量
|
||||
// BigDecimal weightLimit = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getWeightLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// stockInOrderDO.setWeightLimit(weightLimit);
|
||||
// //统计总体积
|
||||
// BigDecimal volumeLimit = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getVolumeLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// stockInOrderDO.setVolumeLimit(volumeLimit);
|
||||
stockInOrderService.insert(stockInOrderDO);
|
||||
materialDetailService.batchInsert(stockInOrderDO.getInOrderNumber(), stockInOrderDO.getMaterialDetailList());
|
||||
}
|
||||
@@ -145,7 +146,7 @@ public class StockInOrderDomainService {
|
||||
//统计总物料种数
|
||||
stockInOrderDO.setMaterialQuantity(stockInOrderDO.getMaterialDetailList().size());
|
||||
//统计总计划数
|
||||
BigDecimal quantity = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal quantity = stockInOrderDO.getMaterialDetailList().stream().map(InMaterialDetailDO::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
stockInOrderPO.setQuantity(quantity);
|
||||
stockInOrderDO.setQuantity(quantity);
|
||||
//统计总重量
|
||||
@@ -306,7 +307,25 @@ public class StockInOrderDomainService {
|
||||
});
|
||||
//判断物流是否需要生成质检单
|
||||
genQualityInspection(stockReceiptOrderDOList);
|
||||
return stockReceiptOrderDomainService.batchInsert(stockReceiptOrderDOList);
|
||||
//生成收货单
|
||||
Boolean batchInsertResult = stockReceiptOrderDomainService.batchInsert(stockReceiptOrderDOList);
|
||||
if (!batchInsertResult) {
|
||||
throw new ServiceException("生成收货单失败");
|
||||
}
|
||||
//生成收货任务:根据入库单号查询刚生成的收货单
|
||||
List<StockReceiptOrderPO> stockReceiptOrderPOList = new ArrayList<>();
|
||||
for (String inOrderNumber : inOrderNumberList) {
|
||||
StockReceiptOrderDO stockReceiptOrderDOQuery = new StockReceiptOrderDO();
|
||||
stockReceiptOrderDOQuery.setInOrderNumber(inOrderNumber);
|
||||
List<StockReceiptOrderPO> receiptOrderList = stockReceiptOrderDomainService.queryList(stockReceiptOrderDOQuery);
|
||||
if (!CollectionUtils.isEmpty(receiptOrderList)) {
|
||||
stockReceiptOrderPOList.addAll(receiptOrderList);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(stockReceiptOrderPOList)) {
|
||||
stockReceiptOrderDomainService.genStockReceiptTaskOrder(stockReceiptOrderPOList);
|
||||
}
|
||||
return batchInsertResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,17 +430,17 @@ public class StockInOrderDomainService {
|
||||
* @param stockInOrderDO
|
||||
*/
|
||||
private void setDefaultValues(StockInOrderDO stockInOrderDO) {
|
||||
//海关是否查验货物(默认:否)
|
||||
if (StringUtils.isBlank(stockInOrderDO.getCustomsInspection())) {
|
||||
stockInOrderDO.setCustomsInspection("否");
|
||||
//海关是否查验货物(默认:0=否)
|
||||
if (stockInOrderDO.getCustomsInspection() == null) {
|
||||
stockInOrderDO.setCustomsInspection(0);
|
||||
}
|
||||
//是否需要报关(默认:是)
|
||||
if (StringUtils.isBlank(stockInOrderDO.getNeedCustomsDeclaration())) {
|
||||
stockInOrderDO.setNeedCustomsDeclaration("是");
|
||||
//是否需要报关(默认:1=是)
|
||||
if (stockInOrderDO.getNeedCustomsDeclaration() == null) {
|
||||
stockInOrderDO.setNeedCustomsDeclaration(1);
|
||||
}
|
||||
//是否需要运输(默认:否)
|
||||
if (StringUtils.isBlank(stockInOrderDO.getNeedTransport())) {
|
||||
stockInOrderDO.setNeedTransport("否");
|
||||
//是否需要运输(默认:0=否)
|
||||
if (stockInOrderDO.getNeedTransport() == null) {
|
||||
stockInOrderDO.setNeedTransport(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -310,15 +310,15 @@ public class StockInOrderDTO extends StockInOrderBaseDTO {
|
||||
|
||||
@ApiModelProperty("海关是否查验货物(默认:否)")
|
||||
@Excel(name = "海关是否查验货物")
|
||||
private String customsInspection;
|
||||
private Integer customsInspection;
|
||||
|
||||
@ApiModelProperty("是否需要报关(默认:是)")
|
||||
@Excel(name = "是否需要报关")
|
||||
private String needCustomsDeclaration;
|
||||
private Integer needCustomsDeclaration;
|
||||
|
||||
@ApiModelProperty("是否需要运输(默认:否)")
|
||||
@Excel(name = "是否需要运输")
|
||||
private String needTransport;
|
||||
private Integer needTransport;
|
||||
|
||||
@ApiModelProperty("入仓日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
|
||||
+1
-2
@@ -87,13 +87,12 @@ public class StockInOrderApi extends BaseController {
|
||||
* 导入入库单
|
||||
*/
|
||||
@ApiOperation("导入入库单")
|
||||
@PostMapping("/importData")
|
||||
@PostMapping(value = "/importData")
|
||||
public AjaxResult importData(MultipartFile file)
|
||||
{
|
||||
return AjaxResult.success(stockInOrderApplicationService.importData(file));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 审核入库单
|
||||
*/
|
||||
|
||||
@@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<sql id="joinStockInOrderPo">
|
||||
,b.notice_number, b.warehouse_id, b.warehouse_code, b.warehouse_name, b.shipper_id, b.shipper_code, b.shipper_name,
|
||||
b.order_type_code, b.order_type_name, b.supplier_id, b.supplier_code, b.supplier_name, b.expect_time, b.supply_chain_number, b.priority_level_code,
|
||||
b.priority_level_name, b.direct_warehouse, b.annex_url, b.material_quantity, b.quantity
|
||||
b.priority_level_name, b.direct_warehouse, b.annex_url, b.material_quantity as in_order_material_quantity, b.quantity as in_order_quantity
|
||||
</sql>
|
||||
|
||||
<sql id="joinStockInOrderPoWhere">
|
||||
@@ -345,13 +345,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="supervisionMethod != null and supervisionMethod != ''">
|
||||
and a.SUPERVISION_METHOD = #{supervisionMethod}
|
||||
</if>
|
||||
<if test="customsInspection != null and customsInspection != ''">
|
||||
<if test="customsInspection != null">
|
||||
and a.CUSTOMS_INSPECTION = #{customsInspection}
|
||||
</if>
|
||||
<if test="needCustomsDeclaration != null and needCustomsDeclaration != ''">
|
||||
<if test="needCustomsDeclaration != null">
|
||||
and a.NEED_CUSTOMS_DECLARATION = #{needCustomsDeclaration}
|
||||
</if>
|
||||
<if test="needTransport != null and needTransport != ''">
|
||||
<if test="needTransport != null">
|
||||
and a.NEED_TRANSPORT = #{needTransport}
|
||||
</if>
|
||||
<if test="warehouseDate != null">
|
||||
|
||||
@@ -18,9 +18,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="platformUseStartTime" column="platform_use_start_time" />
|
||||
<result property="platformUseEndTime" column="platform_use_end_time" />
|
||||
<result property="platformUseStatus" column="platform_use_status" />
|
||||
<result property="quantity" column="quantity" />
|
||||
<result property="receiptQuantity" column="receipt_quantity" />
|
||||
<result property="receiptMaterialQuantity" column="receipt_material_quantity" />
|
||||
<result property="materialQuantity" column="material_quantity" />
|
||||
<result property="abnormal" column="abnormal" />
|
||||
<result property="taskDistribution" column="task_distribution" />
|
||||
<result property="taskDistributionTime" column="task_distribution_time" />
|
||||
<result property="operatorsBy" column="operators_by" />
|
||||
<result property="operatorsName" column="operators_name" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
|
||||
Reference in New Issue
Block a user