出库明细;

This commit is contained in:
王奎兴
2026-01-24 17:42:05 +08:00
parent cf19750fe0
commit 985effdaa3
13 changed files with 287 additions and 55 deletions
@@ -321,62 +321,62 @@ public class OutMaterialDetail extends BaseVOEntity {
*/
@ApiModelProperty("申报数量")
@Excel(name = "申报数量")
private Double declareQuantity;
private BigDecimal declareQuantity;
/**
* 箱数
*/
@ApiModelProperty("箱数")
@Excel(name = "箱数")
private Double caseCount;
private BigDecimal caseCount;
/**
* 件数
*/
@ApiModelProperty("件数")
@Excel(name = "件数")
private Double pieceCount;
private BigDecimal pieceCount;
/**
* 出库数量
*/
@ApiModelProperty("出库数量")
@Excel(name = "出库数量")
private Double outboundQuantity;
private BigDecimal outboundQuantity;
/**
* 总净重(KG)
*/
@ApiModelProperty("总净重(KG)")
@Excel(name = "总净重(KG)")
private Double totalNetWeight;
private BigDecimal totalNetWeight;
/**
* 总毛重(KG)
*/
@ApiModelProperty("总毛重(KG)")
@Excel(name = "总毛重(KG)")
private Double totalGrossWeight;
private BigDecimal totalGrossWeight;
/**
* 总体积(CBM)
*/
@ApiModelProperty("总体积(CBM)")
@Excel(name = "总体积(CBM)")
private Double totalVolume;
private BigDecimal totalVolume;
/**
* 总面积(SQM)
*/
@ApiModelProperty("总面积(SQM)")
@Excel(name = "总面积(SQM)")
private Double totalArea;
private BigDecimal totalArea;
/**
* 总价
*/
@ApiModelProperty("总价")
@Excel(name = "总价")
private Double totalAmount;
private BigDecimal totalAmount;
/**
* 单位
@@ -12,6 +12,10 @@ import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.core.utils.uuid.IdGenerator;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO;
import com.mhd.wms.domain.outMaterialDetail.entity.OutMaterialDetail;
import com.mhd.wms.domain.outMaterialDetail.repository.facade.IOutMaterialDetailService;
import com.mhd.wms.domain.outMaterialDetail.repository.mapper.OutMaterialDetailMapper;
@@ -52,6 +56,8 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
private IOutMaterialDetailSerialNumberService outMaterialDetailSerialNumberService;
@Autowired
private IdGenerator idGenerator;
@Autowired
private MaterialInventoryMapper materialInventoryMapper;
/**
* 查询物料明细列表
@@ -145,6 +151,7 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
outMaterialDetail.setCreateBy(loginUser.getUserid());
outMaterialDetail.setCreateByName(loginUser.getUsername());
outMaterialDetail.setCreateTime(new Date());
outMaterialDetail.setQuantity(outMaterialDetail.getOutboundQuantity());
outMaterialDetailList.add(outMaterialDetail);
}
return saveBatch(outMaterialDetailList);
@@ -271,6 +278,32 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
stockOutOrderPO.setAllocationQuantity(totalAllocationQuantity);
//保存物料明细信息
saveOrUpdateBatch(outMaterialDetailList);
synchronized (this) {
for (OutMaterialDetail outMaterialDetail : outMaterialDetailList) {
Long materialBaseInfoId = outMaterialDetail.getMaterialBaseInfoId();
BigDecimal allocationQuantity = outMaterialDetail.getAllocationQuantity();
MaterialInventoryDO materialInventoryDO = new MaterialInventoryDO();
materialInventoryDO.setMaterialBaseInfoId(materialBaseInfoId);
MaterialInventoryPO materialInventoryPO = materialInventoryMapper.selectOneByWhere(materialInventoryDO);
if (materialInventoryPO != null) {
//更新库存数量
//可用数量
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
//冻结数量
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
//分配后可用数量
BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(allocationQuantity);
//分配后冻结数量
BigDecimal newFreezeQuantity = oldFreezeQuantity.add(allocationQuantity);
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
MaterialInventory materialInventory = new MaterialInventory();
BeanUtils.copyProperties(materialInventoryPO, materialInventory);
materialInventoryMapper.updateById(materialInventory);
}
}
}
return stockOutOrderPO;
}
@@ -517,4 +550,4 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
BeanUtils.copyProperties(outMaterialDetail, outMaterialDetailPO);
return outMaterialDetailPO;
}
}
}
@@ -329,62 +329,62 @@ public class OutMaterialDetailPO extends StockOutOrderBaseDO {
*/
@ApiModelProperty("申报数量")
@Excel(name = "申报数量")
private Double declareQuantity;
private BigDecimal declareQuantity;
/**
* 箱数
*/
@ApiModelProperty("箱数")
@Excel(name = "箱数")
private Double caseCount;
private BigDecimal caseCount;
/**
* 件数
*/
@ApiModelProperty("件数")
@Excel(name = "件数")
private Double pieceCount;
private BigDecimal pieceCount;
/**
* 出库数量
*/
@ApiModelProperty("出库数量")
@Excel(name = "出库数量")
private Double outboundQuantity;
private BigDecimal outboundQuantity;
/**
* 总净重(KG)
*/
@ApiModelProperty("总净重(KG)")
@Excel(name = "总净重(KG)")
private Double totalNetWeight;
private BigDecimal totalNetWeight;
/**
* 总毛重(KG)
*/
@ApiModelProperty("总毛重(KG)")
@Excel(name = "总毛重(KG)")
private Double totalGrossWeight;
private BigDecimal totalGrossWeight;
/**
* 总体积(CBM)
*/
@ApiModelProperty("总体积(CBM)")
@Excel(name = "总体积(CBM)")
private Double totalVolume;
private BigDecimal totalVolume;
/**
* 总面积(SQM)
*/
@ApiModelProperty("总面积(SQM)")
@Excel(name = "总面积(SQM)")
private Double totalArea;
private BigDecimal totalArea;
/**
* 总价
*/
@ApiModelProperty("总价")
@Excel(name = "总价")
private Double totalAmount;
private BigDecimal totalAmount;
/**
* 单位
@@ -337,62 +337,62 @@ public class OutMaterialDetailDO extends BaseVOEntity {
*/
@ApiModelProperty("申报数量")
@Excel(name = "申报数量")
private Double declareQuantity;
private BigDecimal declareQuantity;
/**
* 箱数
*/
@ApiModelProperty("箱数")
@Excel(name = "箱数")
private Double caseCount;
private BigDecimal caseCount;
/**
* 件数
*/
@ApiModelProperty("件数")
@Excel(name = "件数")
private Double pieceCount;
private BigDecimal pieceCount;
/**
* 出库数量
*/
@ApiModelProperty("出库数量")
@Excel(name = "出库数量")
private Double outboundQuantity;
private BigDecimal outboundQuantity;
/**
* 总净重(KG)
*/
@ApiModelProperty("总净重(KG)")
@Excel(name = "总净重(KG)")
private Double totalNetWeight;
private BigDecimal totalNetWeight;
/**
* 总毛重(KG)
*/
@ApiModelProperty("总毛重(KG)")
@Excel(name = "总毛重(KG)")
private Double totalGrossWeight;
private BigDecimal totalGrossWeight;
/**
* 总体积(CBM)
*/
@ApiModelProperty("总体积(CBM)")
@Excel(name = "总体积(CBM)")
private Double totalVolume;
private BigDecimal totalVolume;
/**
* 总面积(SQM)
*/
@ApiModelProperty("总面积(SQM)")
@Excel(name = "总面积(SQM)")
private Double totalArea;
private BigDecimal totalArea;
/**
* 总价
*/
@ApiModelProperty("总价")
@Excel(name = "总价")
private Double totalAmount;
private BigDecimal totalAmount;
/**
* 单位
@@ -28,7 +28,7 @@ public class ExcelParseService {
* @param file 上传的Excel文件
* @return 解析后的出仓委托单对象
*/
public StockOutOrderDO parseOutboundOrderExcel(MultipartFile file) throws IOException {
public StockOutOrderDO parseOutboundOrderExcel(MultipartFile file, String warehouseName,String warehouseCode,Long warehouseId) throws IOException {
HeaderListener headerListener = new HeaderListener();
@@ -64,6 +64,9 @@ public class ExcelParseService {
StockOutOrderDO stockOutOrder = headerListener.getStockOutOrder();
stockOutOrder.setMaterialDetailList(itemListener.getItemList());
stockOutOrder.setWarehouseName(warehouseName);
stockOutOrder.setWarehouseCode(warehouseCode);
stockOutOrder.setWarehouseId(warehouseId);
stockOutOrderApplicationService.insert(stockOutOrder);
return stockOutOrder;
}
@@ -9,6 +9,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.mhd.common.core.domain.po.SysDictDataVo;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.UserServiceFeign;
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
import com.mhd.wms.domain.stockOutOrder.repository.todo.StockOutOrderDO;
import lombok.Getter;
@@ -34,6 +35,8 @@ public class HeaderListener extends AnalysisEventListener<Map<Integer, Object>>
private final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private UserServiceFeign userServiceFeign;
@Override
public void invoke(Map<Integer, Object> data, AnalysisContext context) {
@@ -54,7 +57,6 @@ public class HeaderListener extends AnalysisEventListener<Map<Integer, Object>>
case 5: // 第6行:承运方、tel、柜号、司机签名
stockOutOrder.setCarrier(getStringValue(rowData[2]));
stockOutOrder.setTel(getStringValue(rowData[5]));
stockOutOrder.setContainerNoName(getStringValue(rowData[12]));
if (ObjectUtil.isNotNull(getStringValue(rowData[12]))) {
stockOutOrder.setContainerNoName(getStringValue(rowData[12]));
AjaxResult transportMode = systemServiceFeign.selectListByDictType("cabinetNo");
@@ -2,8 +2,13 @@ package com.mhd.wms.domain.stockOutOrder.repository.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo;
import com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper;
import com.mhd.wms.domain.outMaterialDetail.repository.todo.OutMaterialDetailDO;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -17,6 +22,9 @@ import java.util.Collections;
public class ItemListener extends AnalysisEventListener<Map<Integer, Object>> {
private final List<OutMaterialDetailDO> itemList = new ArrayList<>();
@Autowired
private MaterialBaseInfoMapper materialBaseInfoMapper;
@Override
public void invoke(Map<Integer, Object> data, AnalysisContext context) {
// 将Map<Integer, Object>转换为Map<Integer, String>
@@ -27,9 +35,11 @@ public class ItemListener extends AnalysisEventListener<Map<Integer, Object>> {
// 提取序号(第一列),过滤空行和标题行
String serialNoStr = getStringValue(rowData[0]);
String materialNo = getStringValue(rowData[1]);
String commodityName = getStringValue(rowData[1]);
String specificationModel = getStringValue(rowData[2]);
if (materialNo.isEmpty() && specificationModel.isEmpty()) {
String skuCode = getStringValue(rowData[4]);
if (commodityName.isEmpty() && specificationModel.isEmpty()) {
return;
}
if (serialNoStr.isEmpty() || "序号".equals(serialNoStr) || !isSequenceNumber(serialNoStr)) {
@@ -38,6 +48,15 @@ public class ItemListener extends AnalysisEventListener<Map<Integer, Object>> {
OutMaterialDetailDO item = new OutMaterialDetailDO();
List<MaterialBaseInfo> materialBaseInfos = materialBaseInfoMapper.selectList(new LambdaQueryWrapper<MaterialBaseInfo>().eq(MaterialBaseInfo::getSkuCode, skuCode).eq(MaterialBaseInfo::getMaterialName, commodityName));
if (!materialBaseInfos.isEmpty()) {
if (materialBaseInfos.size() > 1) {
//return;
}
MaterialBaseInfo materialBaseInfo = materialBaseInfos.get(0);
item.setMaterialBaseInfoId(materialBaseInfo.getMaterialBaseInfoId());
}
// 填充商品明细数据
//商品名称 料号 规格型号/ITEM 商品SKU码 Invoice No. 申报数量 申报单位 升 箱数 件数 尺寸 仓库数量 "总净重
//(KG)" 总毛重 (KG) "总体积
@@ -47,24 +66,24 @@ public class ItemListener extends AnalysisEventListener<Map<Integer, Object>> {
item.setSpecificationModel(getStringValue(rowData[3]));
item.setSkucode(getStringValue(rowData[4]));
item.setInvoiceNo(getStringValue(rowData[5]));
item.setDeclareQuantity(parseBigDecimal(rowData[6]).doubleValue());
item.setDeclareQuantity(parseBigDecimal(rowData[6]));
item.setDeclareUnit(getStringValue(rowData[7]));
item.setLiter(getStringValue(rowData[8]));
item.setCaseCount(parseBigDecimal(rowData[9]).doubleValue());
item.setPieceCount(parseBigDecimal(rowData[10]).doubleValue());
item.setCaseCount(parseBigDecimal(rowData[9]));
item.setPieceCount(parseBigDecimal(rowData[10]));
item.setSize(getStringValue(rowData[11]));
//仓库数量 出库数量?
item.setOutboundQuantity(parseBigDecimal(rowData[12]).doubleValue());
item.setTotalNetWeight(parseBigDecimal(rowData[13]).doubleValue());
item.setTotalGrossWeight(parseBigDecimal(rowData[14]).doubleValue());
item.setTotalVolume(parseBigDecimal(rowData[15]).doubleValue());
item.setTotalArea(parseBigDecimal(rowData[16]).doubleValue());
item.setOutboundQuantity(parseBigDecimal(rowData[12]));
item.setTotalNetWeight(parseBigDecimal(rowData[13]));
item.setTotalGrossWeight(parseBigDecimal(rowData[14]));
item.setTotalVolume(parseBigDecimal(rowData[15]));
item.setTotalArea(parseBigDecimal(rowData[16]));
item.setBatchRefNo(getStringValue(rowData[17]));
item.setSheetRefNo(getStringValue(rowData[18]));
item.setCountryOfOrigin(getStringValue(rowData[19]));
item.setCasePalletNo(getStringValue(rowData[20]));
item.setTotalAmount(parseBigDecimal(rowData[21]).doubleValue());
item.setTotalAmount(parseBigDecimal(rowData[21]));
item.setCurrency(getStringValue(rowData[22]));
item.setRemark(getStringValue(rowData[23]));
@@ -128,8 +128,8 @@ public class StockOutOrderDomainService {
//统计种类
//stockOutOrderDO.setMaterialQuantity(stockOutOrderDO.getMaterialDetailList().size());
//统计总数量
//BigDecimal quantity = stockOutOrderDO.getMaterialDetailList().stream().map(OutMaterialDetailDO::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
//stockOutOrderDO.setQuantity(quantity);
BigDecimal quantity = stockOutOrderDO.getMaterialDetailList().stream().map(OutMaterialDetailDO::getOutboundQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
stockOutOrderDO.setQuantity(quantity);
//统计总重量
// BigDecimal weightLimit = stockOutOrderDO.getMaterialDetailList().stream().map(OutMaterialDetailDO::getWeightLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
// stockOutOrderDO.setWeightLimit(weightLimit);
@@ -953,7 +953,7 @@ public class StockOutOrderDomainService {
outMaterialDetailDO.setPackName(materialBaseInfoPO.getPackName());
//获取包装详情
AjaxResult packDetailResult = systemServiceFeign.getInfoByPackIdAndUnitCode(materialBaseInfoPO.getPackId(), "EA");
/*AjaxResult packDetailResult = systemServiceFeign.getInfoByPackIdAndUnitCode(materialBaseInfoPO.getPackId(), "EA");
if(!"200".equals(String.valueOf(packDetailResult.get("code")))){
throw new ServiceException("获取物料单位EA信息失败");
}
@@ -971,7 +971,7 @@ public class StockOutOrderDomainService {
throw new ServiceException("物料仓库控制信息不存在");
}
outMaterialDetailDO.setMaterialWarehouseControlId(materialWarehouseControlPO.getMaterialWarehouseControlId());
outMaterialDetailDO.setSerialNumberManage(materialWarehouseControlPO.getSerialNumberManage());
outMaterialDetailDO.setSerialNumberManage(materialWarehouseControlPO.getSerialNumberManage());*/
});
}