入库管理修改bug
This commit is contained in:
+74
-5
@@ -1439,17 +1439,86 @@ public class StockInOrderApplicationService {
|
||||
* @param stockInOrderDO
|
||||
*/
|
||||
private void shipperParam(StockInOrderDO stockInOrderDO){
|
||||
if (stockInOrderDO.getShipperId() == null) {
|
||||
throw new ServiceException("货主ID不能为空(货主信息就是客户)");
|
||||
Long shipperId = stockInOrderDO.getShipperId();
|
||||
String shipperName = stockInOrderDO.getShipperName();
|
||||
String shipperCode = stockInOrderDO.getShipperCode();
|
||||
|
||||
// 如果货主ID为空,尝试根据货主名称或编号查找
|
||||
if (shipperId == null) {
|
||||
if (StringUtils.isNotEmpty(shipperName) || StringUtils.isNotEmpty(shipperCode)) {
|
||||
// 尝试从货主列表中查找
|
||||
try {
|
||||
AjaxResult shipperListResult = userServiceFeign.userShipperListAll();
|
||||
if ("200".equals(String.valueOf(shipperListResult.get("code"))) && shipperListResult.get("data") != null) {
|
||||
Object data = shipperListResult.get("data");
|
||||
List<Map<String, Object>> shipperList = null;
|
||||
// 尝试解析为列表
|
||||
if (data instanceof List) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> rawList = (List<Object>) data;
|
||||
shipperList = new ArrayList<>();
|
||||
for (Object item : rawList) {
|
||||
if (item instanceof Map) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> mapItem = (Map<String, Object>) item;
|
||||
shipperList.add(mapItem);
|
||||
} else {
|
||||
// 如果不是Map,尝试转换为Map
|
||||
Map<String, Object> mapItem = JSON.parseObject(JSONObject.toJSONString(item), Map.class);
|
||||
shipperList.add(mapItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 如果不是列表,尝试转换为列表
|
||||
String jsonStr = JSONObject.toJSONString(data);
|
||||
shipperList = JSON.parseObject(jsonStr, new com.alibaba.fastjson.TypeReference<List<Map<String, Object>>>(){});
|
||||
}
|
||||
if (shipperList != null && !shipperList.isEmpty()) {
|
||||
for (Map<String, Object> shipper : shipperList) {
|
||||
Object userId = shipper.get("userId");
|
||||
Object userName = shipper.get("userName");
|
||||
// 根据名称匹配
|
||||
if (StringUtils.isNotEmpty(shipperName) &&
|
||||
userName != null &&
|
||||
shipperName.equals(String.valueOf(userName))) {
|
||||
if (userId != null) {
|
||||
shipperId = Long.valueOf(String.valueOf(userId));
|
||||
log.info("根据货主名称找到货主ID,货主名称:{},货主ID:{}", shipperName, shipperId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("根据货主名称查找货主ID失败,货主名称:{},错误:{}", shipperName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 如果仍然找不到货主ID,抛出异常
|
||||
if (shipperId == null) {
|
||||
String errorMsg = "货主ID不能为空(货主信息就是客户)";
|
||||
if (StringUtils.isNotEmpty(shipperName)) {
|
||||
errorMsg += "。已提供货主名称:" + shipperName + ",但未找到对应的货主ID,请确保货主名称正确或直接提供货主ID";
|
||||
} else if (StringUtils.isNotEmpty(shipperCode)) {
|
||||
errorMsg += "。已提供货主编号:" + shipperCode + ",但未找到对应的货主ID,请确保货主编号正确或直接提供货主ID";
|
||||
} else {
|
||||
errorMsg += "。请提供货主ID、货主名称或货主编号";
|
||||
}
|
||||
throw new ServiceException(errorMsg);
|
||||
}
|
||||
stockInOrderDO.setShipperId(shipperId);
|
||||
}
|
||||
AjaxResult ajaxResult = userServiceFeign.getInfo(stockInOrderDO.getShipperId());
|
||||
|
||||
// 根据货主ID获取详细信息
|
||||
AjaxResult ajaxResult = userServiceFeign.getInfo(shipperId);
|
||||
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
String errorMsg = ajaxResult.get("msg") != null ? String.valueOf(ajaxResult.get("msg")) : "未知错误";
|
||||
throw new ServiceException("获取货主信息失败(货主ID: " + stockInOrderDO.getShipperId() + "),错误信息: " + errorMsg);
|
||||
throw new ServiceException("获取货主信息失败(货主ID: " + shipperId + "),错误信息: " + errorMsg);
|
||||
}
|
||||
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
|
||||
if (userPo == null) {
|
||||
throw new ServiceException("获取货主信息失败:返回数据为空(货主ID: " + stockInOrderDO.getShipperId() + ")");
|
||||
throw new ServiceException("获取货主信息失败:返回数据为空(货主ID: " + shipperId + ")");
|
||||
}
|
||||
stockInOrderDO.setShipperCode(userPo.getUserMemberCode());
|
||||
stockInOrderDO.setShipperName(userPo.getUserName());
|
||||
|
||||
@@ -317,10 +317,6 @@ public class InMaterialDetail extends BaseVOEntity {
|
||||
@Excel(name = "入库数量")
|
||||
private BigDecimal inboundQuantity;
|
||||
|
||||
@ApiModelProperty("出库数量")
|
||||
@Excel(name = "出库数量")
|
||||
private BigDecimal outboundQuantity;
|
||||
|
||||
@ApiModelProperty("总净重(KG)")
|
||||
@Excel(name = "总净重(KG)")
|
||||
private BigDecimal totalNetWeight;
|
||||
|
||||
+126
-6
@@ -14,6 +14,10 @@ import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.SystemServiceFeign;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mhd.wms.domain.inMaterialDetail.entity.InMaterialDetail;
|
||||
import com.mhd.wms.domain.inMaterialDetail.repository.facade.IInMaterialDetailService;
|
||||
import com.mhd.wms.domain.inMaterialDetail.repository.po.InMaterialDetailPO;
|
||||
import com.mhd.wms.domain.inMaterialDetailSerialNumber.entity.InMaterialDetailSerialNumber;
|
||||
import com.mhd.wms.domain.inMaterialDetailSerialNumber.repository.facade.IInMaterialDetailSerialNumberService;
|
||||
import com.mhd.wms.domain.inMaterialDetailSerialNumber.repository.todo.InMaterialDetailSerialNumberDO;
|
||||
@@ -58,6 +62,8 @@ public class ReceiptMaterialDetailImpl extends ServiceImpl<ReceiptMaterialDetail
|
||||
@Autowired
|
||||
private IMaterialMoreDetailService IMaterialMoreDetailService;
|
||||
@Autowired
|
||||
private IInMaterialDetailService iInMaterialDetailService;
|
||||
@Autowired
|
||||
private IdGenerator idGenerator;
|
||||
@Resource
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
@@ -92,6 +98,8 @@ public class ReceiptMaterialDetailImpl extends ServiceImpl<ReceiptMaterialDetail
|
||||
materialMoreDetailList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), MaterialMoreDetailPO.class);
|
||||
}
|
||||
}
|
||||
// 从入库单明细表中获取InvoiceNo、BatchRefNo、SheetRefNo、BoxPalletNo字段的值
|
||||
fillAttributeValueFromInMaterialDetail(receiptMaterialDetailPO, materialMoreDetailList);
|
||||
receiptMaterialDetailPO.setMaterialMoreDetailList(materialMoreDetailList);
|
||||
});
|
||||
// 获取查询的层级
|
||||
@@ -102,17 +110,18 @@ public class ReceiptMaterialDetailImpl extends ServiceImpl<ReceiptMaterialDetail
|
||||
List<ReceiptMaterialDetailPO> children = getChildren(materialDetailPO.getUniqueId(), receiptMaterialDetailPOList, 2);
|
||||
children.forEach(childrenDetailPO -> {
|
||||
MaterialMoreDetailDO materialMoreDetailDO = new MaterialMoreDetailDO();
|
||||
materialMoreDetailDO.setMaterialDetailUniqueId(childrenDetailPO.getMaterialDetailId());
|
||||
materialMoreDetailDO.setMaterialDetailUniqueId(childrenDetailPO.getUniqueId());
|
||||
List<MaterialMoreDetailPO> materialMoreDetailList = IMaterialMoreDetailService.queryList(materialMoreDetailDO);
|
||||
//如果收货单的物料批属性还没存入值,那么需要从批属性表获取
|
||||
AjaxResult ajaxResult = null;
|
||||
if (CollectionUtils.isEmpty(materialMoreDetailList)) {
|
||||
ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(childrenDetailPO.getMaterialDetailId());
|
||||
|
||||
}
|
||||
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
|
||||
materialMoreDetailList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), MaterialMoreDetailPO.class);
|
||||
ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(childrenDetailPO.getMaterialBaseInfoId());
|
||||
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
|
||||
materialMoreDetailList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), MaterialMoreDetailPO.class);
|
||||
}
|
||||
}
|
||||
// 从入库单明细表中获取InvoiceNo、BatchRefNo、SheetRefNo、BoxPalletNo字段的值
|
||||
fillAttributeValueFromInMaterialDetail(childrenDetailPO, materialMoreDetailList);
|
||||
childrenDetailPO.setMaterialMoreDetailList(materialMoreDetailList);
|
||||
});
|
||||
|
||||
@@ -253,6 +262,117 @@ public class ReceiptMaterialDetailImpl extends ServiceImpl<ReceiptMaterialDetail
|
||||
if (!CollectionUtils.isEmpty(materialDetailSerialNumberList)){
|
||||
inMaterialDetailSerialNumberService.saveBatch(materialDetailSerialNumberList);
|
||||
}
|
||||
//从materialMoreDetailList中根据attributeOption提取字段值并更新入库单明细
|
||||
updateInMaterialDetailFromAttributeOption(receiptMaterialDetailDOList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 从materialMoreDetailList中根据attributeOption提取字段值并更新入库单明细
|
||||
* @author Auto
|
||||
* @date 2026/1/24
|
||||
* @param receiptMaterialDetailDOList
|
||||
* @return void
|
||||
*/
|
||||
private void updateInMaterialDetailFromAttributeOption(List<ReceiptMaterialDetailDO> receiptMaterialDetailDOList) {
|
||||
if (CollectionUtils.isEmpty(receiptMaterialDetailDOList)) {
|
||||
return;
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
for (ReceiptMaterialDetailDO receiptMaterialDetailDO : receiptMaterialDetailDOList) {
|
||||
Long inUniqueId = receiptMaterialDetailDO.getInUniqueId();
|
||||
if (inUniqueId == null) {
|
||||
continue;
|
||||
}
|
||||
List<MaterialMoreDetailDO> materialMoreDetailList = receiptMaterialDetailDO.getMaterialMoreDetailList();
|
||||
if (CollectionUtils.isEmpty(materialMoreDetailList)) {
|
||||
continue;
|
||||
}
|
||||
// 构建UpdateWrapper
|
||||
UpdateWrapper<InMaterialDetail> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.lambda().eq(InMaterialDetail::getUniqueId, inUniqueId);
|
||||
boolean hasUpdate = false;
|
||||
|
||||
// 遍历materialMoreDetailList,根据attributeOption映射到对应字段
|
||||
for (MaterialMoreDetailDO materialMoreDetail : materialMoreDetailList) {
|
||||
String attributeOption = materialMoreDetail.getAttributeOption();
|
||||
String attributeValue = materialMoreDetail.getAttributeValue();
|
||||
|
||||
// 如果attributeValue为空,跳过
|
||||
if (attributeValue == null || attributeValue.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 根据attributeOption映射到入库单明细表的字段
|
||||
if ("InvoiceNo".equalsIgnoreCase(attributeOption)) {
|
||||
updateWrapper.lambda().set(InMaterialDetail::getInvoiceNo, attributeValue);
|
||||
hasUpdate = true;
|
||||
} else if ("BatchRefNo".equalsIgnoreCase(attributeOption)) {
|
||||
updateWrapper.lambda().set(InMaterialDetail::getBatchRefNo, attributeValue);
|
||||
hasUpdate = true;
|
||||
} else if ("SheetRefNo".equalsIgnoreCase(attributeOption)) {
|
||||
updateWrapper.lambda().set(InMaterialDetail::getSheetRefNo, attributeValue);
|
||||
hasUpdate = true;
|
||||
} else if ("BoxPalletNo".equalsIgnoreCase(attributeOption)) {
|
||||
updateWrapper.lambda().set(InMaterialDetail::getBoxPalletNo, attributeValue);
|
||||
hasUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有字段需要更新,则执行更新
|
||||
if (hasUpdate) {
|
||||
updateWrapper.lambda()
|
||||
.set(InMaterialDetail::getUpdateBy, loginUser.getUserid())
|
||||
.set(InMaterialDetail::getUpdateByName, loginUser.getUsername())
|
||||
.set(InMaterialDetail::getUpdateTime, new Date());
|
||||
iInMaterialDetailService.update(updateWrapper);
|
||||
}
|
||||
|
||||
// 处理子项
|
||||
List<ReceiptMaterialDetailDO> children = receiptMaterialDetailDO.getChildren();
|
||||
if (!CollectionUtils.isEmpty(children)) {
|
||||
updateInMaterialDetailFromAttributeOption(children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 从入库单明细表中获取InvoiceNo、BatchRefNo、SheetRefNo、BoxPalletNo字段的值并填充到materialMoreDetailList的attributeValue中
|
||||
* @author Auto
|
||||
* @date 2026/1/24
|
||||
* @param receiptMaterialDetailPO
|
||||
* @param materialMoreDetailList
|
||||
* @return void
|
||||
*/
|
||||
private void fillAttributeValueFromInMaterialDetail(ReceiptMaterialDetailPO receiptMaterialDetailPO, List<MaterialMoreDetailPO> materialMoreDetailList) {
|
||||
if (CollectionUtils.isEmpty(materialMoreDetailList) || receiptMaterialDetailPO.getInUniqueId() == null) {
|
||||
return;
|
||||
}
|
||||
// 查询入库单明细
|
||||
QueryWrapper<InMaterialDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("unique_id", receiptMaterialDetailPO.getInUniqueId());
|
||||
queryWrapper.eq("del_flag", 1);
|
||||
InMaterialDetail inMaterialDetail = iInMaterialDetailService.getOne(queryWrapper);
|
||||
if (inMaterialDetail == null) {
|
||||
return;
|
||||
}
|
||||
// 根据attributeOption从入库单明细中获取对应的值并填充到attributeValue
|
||||
for (MaterialMoreDetailPO materialMoreDetail : materialMoreDetailList) {
|
||||
String attributeOption = materialMoreDetail.getAttributeOption();
|
||||
// 如果attributeValue已经有值,跳过
|
||||
if (materialMoreDetail.getAttributeValue() != null && !materialMoreDetail.getAttributeValue().trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 根据attributeOption映射到入库单明细表的字段
|
||||
if ("InvoiceNo".equalsIgnoreCase(attributeOption)) {
|
||||
materialMoreDetail.setAttributeValue(inMaterialDetail.getInvoiceNo());
|
||||
} else if ("BatchRefNo".equalsIgnoreCase(attributeOption)) {
|
||||
materialMoreDetail.setAttributeValue(inMaterialDetail.getBatchRefNo());
|
||||
} else if ("SheetRefNo".equalsIgnoreCase(attributeOption)) {
|
||||
materialMoreDetail.setAttributeValue(inMaterialDetail.getSheetRefNo());
|
||||
} else if ("BoxPalletNo".equalsIgnoreCase(attributeOption)) {
|
||||
materialMoreDetail.setAttributeValue(inMaterialDetail.getBoxPalletNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+16
@@ -232,6 +232,22 @@ public class ReceiptMaterialDetailPO extends BaseVOEntity {
|
||||
@Excel(name = "总面积(SQM)")
|
||||
private BigDecimal totalArea;
|
||||
|
||||
@ApiModelProperty("Invoice No.")
|
||||
@Excel(name = "Invoice No.")
|
||||
private String invoiceNo;
|
||||
|
||||
@ApiModelProperty("Batch Ref NO's")
|
||||
@Excel(name = "Batch Ref NO's")
|
||||
private String batchRefNo;
|
||||
|
||||
@ApiModelProperty("Sheet Ref NO's")
|
||||
@Excel(name = "Sheet Ref NO's")
|
||||
private String sheetRefNo;
|
||||
|
||||
@ApiModelProperty("箱号/卡板号")
|
||||
@Excel(name = "箱号/卡板号")
|
||||
private String boxPalletNo;
|
||||
|
||||
@ApiModelProperty("物料明细子集")
|
||||
private List<ReceiptMaterialDetailPO> children;
|
||||
|
||||
|
||||
+179
@@ -32,6 +32,8 @@ import com.mhd.wms.domain.inOrderAbnormal.repository.facade.IInOrderAbnormalServ
|
||||
import com.mhd.wms.domain.inOrderAbnormal.repository.todo.InOrderAbnormalBaseDO;
|
||||
import com.mhd.wms.domain.inventoryStandingDetail.repository.facade.IInventoryStandingDetailService;
|
||||
import com.mhd.wms.domain.inventoryStandingDetail.repository.todo.InventoryStandingDetailDO;
|
||||
import com.mhd.wms.domain.inventoryStandingReport.repository.facade.IInventoryStandingReportService;
|
||||
import com.mhd.wms.domain.inventoryStandingReport.repository.todo.InventoryStandingReportDO;
|
||||
import com.mhd.wms.domain.materialGoodsRule.entity.MaterialGoodsRule;
|
||||
import com.mhd.wms.domain.materialGoodsRule.repository.facade.IMaterialGoodsRuleService;
|
||||
import com.mhd.wms.domain.materialMoreDetail.repository.facade.IMaterialMoreDetailService;
|
||||
@@ -110,6 +112,8 @@ public class StockReceiptOrderDomainService {
|
||||
@Autowired
|
||||
private IInventoryStandingDetailService inventoryStandingDetailService;
|
||||
@Autowired
|
||||
private IInventoryStandingReportService inventoryStandingReportService;
|
||||
@Autowired
|
||||
private IdGenerator idGenerator;
|
||||
@Autowired
|
||||
private IContainerUsageRecordService containerUsageRecordService;
|
||||
@@ -376,6 +380,8 @@ public class StockReceiptOrderDomainService {
|
||||
}
|
||||
//保存容器使用记录
|
||||
genContainerUsageRecord(stockReceiptOrderDO);
|
||||
//生成库存台账报表记录(收货虚拟库存)- 需要在batchReceiptUpdate之前调用,因为batchReceiptUpdate会将状态更新为3
|
||||
genInventoryStandingReport(stockReceiptOrderPO, stockReceiptOrderDO);
|
||||
//修改物料明细信息
|
||||
receiptMaterialDetailService.batchReceiptUpdate(stockReceiptOrderDO);
|
||||
//生成 收货作业单
|
||||
@@ -498,6 +504,8 @@ public class StockReceiptOrderDomainService {
|
||||
|
||||
//生成收货追溯记录
|
||||
genInventoryStandingDetail(stockReceiptOrderPO);
|
||||
//生成库存台账报表记录(收货虚拟库存)
|
||||
genInventoryStandingReport(stockReceiptOrderPO);
|
||||
//存在异常 生成记录
|
||||
if (abnormal == 1){
|
||||
genInOrderAbnormal(stockReceiptOrderPO);
|
||||
@@ -981,6 +989,177 @@ public class StockReceiptOrderDomainService {
|
||||
inventoryStandingDetailService.batchInsert(inventoryStandingDetailDOList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 生成库存台账报表记录(收货虚拟库存)
|
||||
* @author Auto
|
||||
* @date 2026/1/24
|
||||
* @param stockReceiptOrderPO
|
||||
*/
|
||||
public void genInventoryStandingReport(StockReceiptOrderPO stockReceiptOrderPO){
|
||||
genInventoryStandingReport(stockReceiptOrderPO, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 生成库存台账报表记录(收货虚拟库存)- 重载方法,支持从stockReceiptOrderDO获取数据
|
||||
* @author Auto
|
||||
* @date 2026/1/24
|
||||
* @param stockReceiptOrderPO
|
||||
* @param stockReceiptOrderDO 如果提供,则从该对象中获取receipt_quantity,否则从数据库查询
|
||||
*/
|
||||
public void genInventoryStandingReport(StockReceiptOrderPO stockReceiptOrderPO, StockReceiptOrderDO stockReceiptOrderDO){
|
||||
try {
|
||||
// 重新查询最新的收货单信息,确保获取到最新的数据
|
||||
StockReceiptOrderPO latestStockReceiptOrderPO = stockReceiptOrderService.getInfo(stockReceiptOrderPO.getReceiptOrderId());
|
||||
if (latestStockReceiptOrderPO == null) {
|
||||
log.warn("生成库存台账报表记录失败,收货单不存在,收货单ID:{}", stockReceiptOrderPO.getReceiptOrderId());
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果提供了stockReceiptOrderDO,则从该对象中获取数据,否则从数据库查询
|
||||
List<ReceiptMaterialDetailPO> receiptMaterialDetailPOList;
|
||||
if (stockReceiptOrderDO != null && !CollectionUtils.isEmpty(stockReceiptOrderDO.getMaterialDetailList())) {
|
||||
// 从stockReceiptOrderDO中获取数据,转换为ReceiptMaterialDetailPO
|
||||
receiptMaterialDetailPOList = new ArrayList<>();
|
||||
log.info("从stockReceiptOrderDO获取收货明细,收货单号:{},明细数量:{}",
|
||||
latestStockReceiptOrderPO.getReceiptOrderNumber(),
|
||||
stockReceiptOrderDO.getMaterialDetailList().size());
|
||||
for (ReceiptMaterialDetailDO receiptMaterialDetailDO : stockReceiptOrderDO.getMaterialDetailList()) {
|
||||
// 记录原始数据
|
||||
log.debug("处理收货明细DO,物料编码:{},物料名称:{},收货数量:{},收货状态:{}",
|
||||
receiptMaterialDetailDO.getMaterialCode(),
|
||||
receiptMaterialDetailDO.getMaterialName(),
|
||||
receiptMaterialDetailDO.getReceiptQuantity(),
|
||||
receiptMaterialDetailDO.getReceiptStatus());
|
||||
|
||||
// 优先使用receiptMaterialDetailDO.getReceiptQuantity()的值(本次收货数量)
|
||||
// 如果receiptQuantity为null或<=0,跳过该记录
|
||||
if (receiptMaterialDetailDO.getReceiptQuantity() == null ||
|
||||
receiptMaterialDetailDO.getReceiptQuantity().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
log.debug("跳过收货明细(收货数量为空或<=0),物料编码:{},收货数量:{}",
|
||||
receiptMaterialDetailDO.getMaterialCode(),
|
||||
receiptMaterialDetailDO.getReceiptQuantity());
|
||||
continue;
|
||||
}
|
||||
|
||||
ReceiptMaterialDetailPO receiptMaterialDetailPO = new ReceiptMaterialDetailPO();
|
||||
BeanUtils.copyProperties(receiptMaterialDetailDO, receiptMaterialDetailPO);
|
||||
// 设置收货单号
|
||||
receiptMaterialDetailPO.setReceiptOrderNumber(latestStockReceiptOrderPO.getReceiptOrderNumber());
|
||||
// 确保receiptQuantity字段被正确设置(使用DO中的值,因为已经验证过不为null且>0)
|
||||
receiptMaterialDetailPO.setReceiptQuantity(receiptMaterialDetailDO.getReceiptQuantity());
|
||||
// 如果receipt_status为空,则设置为2(收货中),因为这是在batchReceiptUpdate之前调用的
|
||||
if (receiptMaterialDetailPO.getReceiptStatus() == null) {
|
||||
receiptMaterialDetailPO.setReceiptStatus(2);
|
||||
}
|
||||
receiptMaterialDetailPOList.add(receiptMaterialDetailPO);
|
||||
log.debug("添加收货明细PO到列表,物料编码:{},收货数量:{}",
|
||||
receiptMaterialDetailPO.getMaterialCode(),
|
||||
receiptMaterialDetailPO.getReceiptQuantity());
|
||||
}
|
||||
log.info("从stockReceiptOrderDO转换后的收货明细数量:{}", receiptMaterialDetailPOList.size());
|
||||
} else {
|
||||
// 从数据库查询
|
||||
log.info("从数据库查询收货明细,收货单号:{}", latestStockReceiptOrderPO.getReceiptOrderNumber());
|
||||
ReceiptMaterialDetailDO receiptMaterialDetailDO = new ReceiptMaterialDetailDO();
|
||||
receiptMaterialDetailDO.setReceiptOrderNumber(latestStockReceiptOrderPO.getReceiptOrderNumber());
|
||||
receiptMaterialDetailPOList = receiptMaterialDetailService.queryList(receiptMaterialDetailDO);
|
||||
log.info("从数据库查询到的收货明细数量:{}", receiptMaterialDetailPOList != null ? receiptMaterialDetailPOList.size() : 0);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(receiptMaterialDetailPOList)) {
|
||||
log.warn("生成库存台账报表记录失败,收货明细为空,收货单号:{}", latestStockReceiptOrderPO.getReceiptOrderNumber());
|
||||
return;
|
||||
}
|
||||
|
||||
// 按物料、货主、仓库分组统计收货数量
|
||||
Map<String, InventoryStandingReportDO> reportMap = new HashMap<>();
|
||||
log.info("开始生成库存台账报表记录,收货单号:{},收货明细数量:{}",
|
||||
latestStockReceiptOrderPO.getReceiptOrderNumber(), receiptMaterialDetailPOList.size());
|
||||
for (ReceiptMaterialDetailPO receiptMaterialDetailPO : receiptMaterialDetailPOList){
|
||||
// 记录每个明细的详细信息
|
||||
log.debug("处理收货明细,物料编码:{},物料名称:{},收货数量:{},收货状态:{}",
|
||||
receiptMaterialDetailPO.getMaterialCode(),
|
||||
receiptMaterialDetailPO.getMaterialName(),
|
||||
receiptMaterialDetailPO.getReceiptQuantity(),
|
||||
receiptMaterialDetailPO.getReceiptStatus());
|
||||
|
||||
// 只统计有收货数量的记录
|
||||
if (receiptMaterialDetailPO.getReceiptQuantity() == null ||
|
||||
receiptMaterialDetailPO.getReceiptQuantity().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
log.debug("跳过收货明细(收货数量为空或<=0),物料编码:{},收货数量:{}",
|
||||
receiptMaterialDetailPO.getMaterialCode(),
|
||||
receiptMaterialDetailPO.getReceiptQuantity());
|
||||
continue;
|
||||
}
|
||||
// 只统计收货状态为1(待收货)或2(收货中)的记录
|
||||
// 注意:在receivingGoods调用时,我们从stockReceiptOrderDO中获取数据,状态设置为2
|
||||
if (receiptMaterialDetailPO.getReceiptStatus() == null ||
|
||||
receiptMaterialDetailPO.getReceiptStatus() < 1 ||
|
||||
receiptMaterialDetailPO.getReceiptStatus() > 2) {
|
||||
log.debug("跳过收货明细(收货状态不符合要求),物料编码:{},收货状态:{}(需要1或2)",
|
||||
receiptMaterialDetailPO.getMaterialCode(),
|
||||
receiptMaterialDetailPO.getReceiptStatus());
|
||||
continue;
|
||||
}
|
||||
|
||||
// 生成唯一key:物料编码_货主ID_仓库ID
|
||||
String key = receiptMaterialDetailPO.getMaterialCode() + "_"
|
||||
+ latestStockReceiptOrderPO.getShipperId() + "_"
|
||||
+ latestStockReceiptOrderPO.getWarehouseId();
|
||||
|
||||
InventoryStandingReportDO reportDO = reportMap.get(key);
|
||||
if (reportDO == null) {
|
||||
reportDO = new InventoryStandingReportDO();
|
||||
reportDO.setOrganizationId(latestStockReceiptOrderPO.getOrganizationId());
|
||||
reportDO.setOrganizationName(latestStockReceiptOrderPO.getOrganizationName());
|
||||
reportDO.setTopOrganizationId(latestStockReceiptOrderPO.getTopOrganizationId());
|
||||
reportDO.setMaterialCode(receiptMaterialDetailPO.getMaterialCode());
|
||||
reportDO.setMaterialName(receiptMaterialDetailPO.getMaterialName());
|
||||
reportDO.setBarCode(receiptMaterialDetailPO.getBarCode());
|
||||
reportDO.setShipperId(latestStockReceiptOrderPO.getShipperId());
|
||||
reportDO.setShipperCode(latestStockReceiptOrderPO.getShipperCode());
|
||||
reportDO.setShipperName(latestStockReceiptOrderPO.getShipperName());
|
||||
reportDO.setWarehouseId(latestStockReceiptOrderPO.getWarehouseId());
|
||||
reportDO.setWarehouseCode(latestStockReceiptOrderPO.getWarehouseCode());
|
||||
reportDO.setWarehouseName(latestStockReceiptOrderPO.getWarehouseName());
|
||||
reportDO.setNodeStatus(1); // 1-收货
|
||||
reportDO.setMaterialQuantity(BigDecimal.ZERO);
|
||||
reportMap.put(key, reportDO);
|
||||
}
|
||||
// 累加收货数量
|
||||
reportDO.setMaterialQuantity(reportDO.getMaterialQuantity().add(receiptMaterialDetailPO.getReceiptQuantity()));
|
||||
}
|
||||
|
||||
// 批量插入或更新库存台账报表记录
|
||||
int successCount = 0;
|
||||
for (InventoryStandingReportDO reportDO : reportMap.values()) {
|
||||
try {
|
||||
Boolean result = inventoryStandingReportService.insert(reportDO);
|
||||
if (result) {
|
||||
successCount++;
|
||||
log.info("生成库存台账报表记录成功,收货单号:{},物料编码:{},物料名称:{},数量:{}",
|
||||
latestStockReceiptOrderPO.getReceiptOrderNumber(),
|
||||
reportDO.getMaterialCode(),
|
||||
reportDO.getMaterialName(),
|
||||
reportDO.getMaterialQuantity());
|
||||
} else {
|
||||
log.warn("生成库存台账报表记录失败,返回false,收货单号:{},物料编码:{}",
|
||||
latestStockReceiptOrderPO.getReceiptOrderNumber(), reportDO.getMaterialCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("生成库存台账报表记录异常,收货单号:{},物料编码:{},物料名称:{}",
|
||||
latestStockReceiptOrderPO.getReceiptOrderNumber(),
|
||||
reportDO.getMaterialCode(),
|
||||
reportDO.getMaterialName(), e);
|
||||
}
|
||||
}
|
||||
log.info("生成库存台账报表记录完成,收货单号:{},成功:{},总计:{}",
|
||||
latestStockReceiptOrderPO.getReceiptOrderNumber(), successCount, reportMap.size());
|
||||
} catch (Exception e) {
|
||||
log.error("生成库存台账报表记录异常,收货单号:{}", stockReceiptOrderPO.getReceiptOrderNumber(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 收货生成任务下发
|
||||
* @author ZhouGY
|
||||
|
||||
+18
-3
@@ -413,13 +413,28 @@ public class StockShelfOrderDomainService {
|
||||
public void shelfAddMaterialInventory(List<ShelfMaterialDetail> shelfMaterialDetailList){
|
||||
List<MaterialInventoryDO> materialInventoryDOList = new ArrayList<>();
|
||||
for (ShelfMaterialDetail shelfMaterialDetail : shelfMaterialDetailList){
|
||||
// 使用shelvesQuantity(本次上架数量)来增加库存
|
||||
// 如果shelvesQuantity为空,则使用alreadyShelvesQuantity(累计上架数量)作为备选
|
||||
BigDecimal shelvesQuantity = shelfMaterialDetail.getShelvesQuantity() != null
|
||||
? shelfMaterialDetail.getShelvesQuantity()
|
||||
: (shelfMaterialDetail.getAlreadyShelvesQuantity() != null
|
||||
? shelfMaterialDetail.getAlreadyShelvesQuantity()
|
||||
: BigDecimal.ZERO);
|
||||
|
||||
// 如果数量为0或空,跳过该记录
|
||||
if (shelvesQuantity.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MaterialInventoryDO materialInventoryDO = new MaterialInventoryDO();
|
||||
BeanUtils.copyProperties(shelfMaterialDetail, materialInventoryDO);
|
||||
materialInventoryDO.setInventoryQuantity(shelfMaterialDetail.getShelvesQuantity());
|
||||
materialInventoryDO.setAllocationQuantity(shelfMaterialDetail.getShelvesQuantity());
|
||||
materialInventoryDO.setInventoryQuantity(shelvesQuantity);
|
||||
materialInventoryDO.setAllocationQuantity(shelvesQuantity);
|
||||
materialInventoryDOList.add(materialInventoryDO);
|
||||
}
|
||||
materialInventoryService.updateMaterialInventoryInfo(materialInventoryDOList, 1);
|
||||
if (!CollectionUtils.isEmpty(materialInventoryDOList)) {
|
||||
materialInventoryService.updateMaterialInventoryInfo(materialInventoryDOList, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSerialNumberforInventory(List<ShelfMaterialDetail> shelfMaterialDetailList){
|
||||
|
||||
+2
-1
@@ -63,13 +63,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
sio1.top_organization_id,
|
||||
1 AS node_status,
|
||||
"收货" AS node_name,
|
||||
SUM( rmd.quantity ) AS material_quantity
|
||||
SUM( rmd.receipt_quantity ) AS material_quantity
|
||||
FROM
|
||||
receipt_material_detail rmd
|
||||
LEFT JOIN stock_receipt_order sro1 ON sro1.receipt_order_number = rmd.receipt_order_number
|
||||
LEFT JOIN stock_in_order sio1 ON sro1.in_order_number = sio1.in_order_number
|
||||
WHERE
|
||||
rmd.receipt_status IN ( 1, 2 )
|
||||
AND rmd.receipt_quantity > 0
|
||||
GROUP BY
|
||||
rmd.material_base_info_id,
|
||||
sio1.shipper_id,
|
||||
|
||||
+6
-2
@@ -61,12 +61,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="totalGrossWeight" column="total_gross_weight" />
|
||||
<result property="totalVolume" column="total_volume" />
|
||||
<result property="totalArea" column="total_area" />
|
||||
<result property="invoiceNo" column="invoice_no" />
|
||||
<result property="batchRefNo" column="batch_ref_no" />
|
||||
<result property="sheetRefNo" column="sheet_ref_no" />
|
||||
<result property="boxPalletNo" column="box_pallet_no" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="selectReceiptMaterialDetailPo">
|
||||
select a.MATERIAL_DETAIL_ID, a.ORGANIZATION_ID, a.ORGANIZATION_NAME, a.TOP_ORGANIZATION_ID, a.UNIQUE_ID, a.RECEIPT_ORDER_NUMBER, a.MATERIAL_BASE_INFO_ID, a.MATERIAL_CODE, a.MATERIAL_NAME, a.BAR_CODE, a.QUANTITY, a.ALREADY_RECEIPT_QUANTITY, a.RECEIPT_QUANTITY, a.RECEIPT_STATUS, a.PACK_ID, a.PACK_CODE, a.PACK_NAME, a.PACK_DETAIL_ID, a.UNIT_CODE, a.UNIT_NAME, a.UNIT_NUMBER, a.MATERIAL_WAREHOUSE_CONTROL_ID, a.SERIAL_NUMBER_MANAGE, a.QUALITY_INSPECTION_MANAGE, a.QUALITY_INSPECTION_STAGE, a.QUALITY_INSPECTION_RULE, a.QUALITY_INSPECTION_RATIO, a.QUALITY_INSPECTION_TERM, a.QUALITY_INSPECTION_RESULTS, a.ALLOW_OVERCHARGE, a.OVERCHARGE_RATIO, a.BATCH_NUMBER, a.MATERIAL_STATUS_CODE, a.MATERIAL_STATUS_NAME, a.DISTRIBUTE_RULE_ID, a.DISTRIBUTE_RULE_CODE, a.DISTRIBUTE_RULE_NAME, a.CONTAINER_ID, a.CONTAINER_CODE, a.CONTAINER_TYPE, a.CONTAINER_TYPE_NAME, a.LEVEL, a.PARENT_UNIQUE_ID, a.IN_UNIQUE_ID, a.ALLOW_MODIFY, a.REMARK, a.CREATE_TIME, a.CREATE_BY, a.CREATE_BY_NAME, a.UPDATE_TIME, a.UPDATE_BY, a.UPDATE_BY_NAME, a.GEN_STOCK_SHELF, a.DEL_FLAG,
|
||||
b.TOTAL_NET_WEIGHT, b.TOTAL_GROSS_WEIGHT, b.TOTAL_VOLUME, b.TOTAL_AREA
|
||||
select a.MATERIAL_DETAIL_ID, a.ORGANIZATION_ID, a.ORGANIZATION_NAME, a.TOP_ORGANIZATION_ID, a.UNIQUE_ID, a.RECEIPT_ORDER_NUMBER, a.MATERIAL_BASE_INFO_ID, a.MATERIAL_CODE, a.MATERIAL_NAME, a.BAR_CODE, a.QUANTITY, a.ALREADY_RECEIPT_QUANTITY, a.RECEIPT_QUANTITY, a.RECEIPT_STATUS, a.PACK_ID, a.PACK_CODE, a.PACK_NAME, a.PACK_DETAIL_ID, a.UNIT_CODE, a.UNIT_NAME, a.UNIT_NUMBER, a.MATERIAL_WAREHOUSE_CONTROL_ID, a.SERIAL_NUMBER_MANAGE, a.QUALITY_INSPECTION_MANAGE, a.QUALITY_INSPECTION_STAGE, a.QUALITY_INSPECTION_RULE, a.QUALITY_INSPECTION_RATIO, a.QUALITY_INSPECTION_TERM, a.QUALITY_INSPECTION_RESULTS, a.ALLOW_OVERCHARGE, a.OVERCHARGE_RATIO, a.BATCH_NUMBER, a.MATERIAL_STATUS_CODE, a.MATERIAL_STATUS_NAME, a.DISTRIBUTE_RULE_ID, a.DISTRIBUTE_RULE_CODE, a.DISTRIBUTE_RULE_NAME, a.CONTAINER_ID, a.CONTAINER_CODE, a.CONTAINER_TYPE, a.CONTAINER_TYPE_NAME, a.LEVEL, a.PARENT_UNIQUE_ID, a.IN_UNIQUE_ID, a.ALLOW_MODIFY, a.REMARK, a.CREATE_TIME, a.CREATE_BY, a.CREATE_BY_NAME, a.UPDATE_TIME, a.UPDATE_BY, a.UPDATE_BY_NAME, a.GEN_STOCK_SHELF, a.DEL_FLAG,
|
||||
b.TOTAL_NET_WEIGHT, b.TOTAL_GROSS_WEIGHT, b.TOTAL_VOLUME, b.TOTAL_AREA, b.INVOICE_NO, b.BATCH_REF_NO, b.SHEET_REF_NO, b.BOX_PALLET_NO
|
||||
from RECEIPT_MATERIAL_DETAIL a
|
||||
LEFT JOIN IN_MATERIAL_DETAIL b ON a.IN_UNIQUE_ID = b.UNIQUE_ID AND b.DEL_FLAG = 1
|
||||
</sql>
|
||||
|
||||
Reference in New Issue
Block a user