Commit 1976459d by yubin

导入修改

parent 517a4784
......@@ -100,7 +100,7 @@
style="width: 150px"
>
<el-option
v-for="dict in dict.type.inbound_outbound_type"
v-for="dict in dict.type.outbound_order_type"
:key="dict.value"
:label="dict.label"
:value="Number(dict.value)"
......@@ -174,7 +174,7 @@
<el-table-column label="系统编号" align="center" prop="systemNo" min-width="150" />
<el-table-column label="出库类型" align="center" prop="orderTypeId" min-width="120">
<template slot-scope="scope">
<dict-tag v-if="dict.type.inbound_outbound_type" :options="dict.type.inbound_outbound_type" :value="scope.row.orderTypeId"/>
<dict-tag v-if="dict.type.outbound_order_type" :options="dict.type.outbound_order_type" :value="scope.row.orderTypeId"/>
<span v-else>-</span>
</template>
</el-table-column>
......@@ -280,7 +280,7 @@
<el-form-item label="出库类型" prop="orderTypeId">
<el-select v-model="form.orderTypeId" placeholder="请选择出库类型" :disabled="isViewDetail || formDisabled.orderTypeId" style="width: 100%">
<el-option
v-for="item in dict.type.inbound_outbound_type"
v-for="item in dict.type.outbound_order_type"
:key="item.value"
:label="item.label"
:value="item.value"
......@@ -521,7 +521,7 @@ import PageTitle from "@/components/PageTitle"
import ImportExcel from "@/components/ImportExcel/index"
export default {
name: "Orders",
dicts: ['inbound_outbound_type', 'inbound_order_type', 'outbound_order_status', 'label_color','order_type'],
dicts: ['outbound_order_type', 'outbound_order_status', 'label_color','order_type'],
components: {
OutboundOrderFormWithItems,
WarehouseSelector,
......
......@@ -70,6 +70,8 @@ public class Inventory extends BaseEntity
@Excel(name = "锁定数量")
private Long lockedQuantity;
/** 单位重量 */
@Excel(name = "单位重量")
private Double unitWeight;
......
......@@ -32,7 +32,7 @@ public class OutboundOrders extends BaseEntity
private String systemNo;
/** 入库类型 字典,检索条件 */
@Excel(name = "入库类型 字典,检索条件")
@Excel(name = "出库分类 字典,检索条件")
private String orderTypeId;
/** 批次ID 检索条件 */
......
......@@ -27,6 +27,9 @@ public class OutboundTemplateVO extends BaseEntity {
@Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date inboundDate;
@Excel(name = "出库分类", width = 30,dictType = "outbound_order_type")
private Date String;
/** SAP号 */
@Excel(name = "SAP No")
private String sapNo;
......
......@@ -11,14 +11,12 @@ import com.ruoyi.inventory.domain.TO.StocktakeItemsTo;
import com.ruoyi.inventory.domain.vo.InventoryExceedWarnVO;
import com.ruoyi.inventory.domain.vo.InventorySummaryVO;
import com.ruoyi.inventory.domain.vo.InventoryVo;
import com.ruoyi.inventory.mapper.InboundOrdersMapper;
import com.ruoyi.inventory.mapper.OutboundOrderItemsMapper;
import com.ruoyi.inventory.mapper.OutboundOrderLogMapper;
import com.ruoyi.inventory.mapper.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.SystemUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.InventoryMapper;
import com.ruoyi.inventory.service.IOutboundOrdersService;
import com.ruoyi.inventory.service.IInventoryService;
/**
......@@ -37,7 +35,7 @@ public class InventoryServiceImpl implements IInventoryService
@Autowired
private OutboundOrderItemsMapper outboundOrderItemsMapper;
@Autowired
private OutboundOrdersServiceImpl outboundOrderMapper;
private IOutboundOrdersService outboundOrdersService;
@Autowired
private InventoryTransactionsServiceImpl insertInventoryTransactions;
@Autowired
......@@ -190,7 +188,7 @@ public class InventoryServiceImpl implements IInventoryService
transactions.setLocationId(outboundOrderItem.getLocationId());
// 补充货主ID(从出库单主表查询)
OutboundOrders outboundOrders = outboundOrderMapper.selectOutboundOrdersById(outboundOrderItem.getOutboundOrderId());
OutboundOrders outboundOrders = outboundOrdersService.selectOutboundOrdersById(outboundOrderItem.getOutboundOrderId());
if (outboundOrders != null) {
transactions.setOwnerId(outboundOrders.getOwnerId());
}
......
......@@ -167,7 +167,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
String updateUser = SystemUtils.getUserName();
Date updateTime = DateUtils.getNowDate();
for (OutboundOrderItems item : outboundOrderItems) {
item.setItemStatus(3L);
item.setItemStatus(1L);
item.setUpdateBy(updateUser);
item.setUpdateTime(updateTime);
outboundOrderItemsMapper.updateOutboundOrderItems(item);
......@@ -177,7 +177,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
outboundOrderLogMapper.updateOutboundOrderLog(outboundOrderLog);
}
outboundOrders.setOrderStatus(2L);
outboundOrders.setOrderStatus(1L);
outboundOrders.setUpdateTime(updateTime);
outboundOrders.setUpdateUserCode(updateUser);
outboundOrdersMapper.updateOutboundOrders(outboundOrders);
......@@ -273,9 +273,10 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
if (lastInv == null) {
throw new ServiceException(String.format("物料[%s]库存类型[%s]扣减负数时未找到目标库存", materialId, inventoryType));
}
lastInv.setQuantity(lastInv.getQuantity() - remainDeductQty);
lastInv.setInventoryStatus(0L);
// 使用可用库存(quantity - lockedQuantity)计算后,将“预占/锁定量”进行调整(沿用原来逐步扣减的遍历逻辑)
Long currentLocked = Optional.ofNullable(lastInv.getLockedQuantity()).orElse(0L);
lastInv.setLockedQuantity(currentLocked + remainDeductQty);
lastInv.setInventoryStatus(1L);
lastInv.setUpdateBy(updateUser);
lastInv.setUpdateTime(updateTime);
toUpdateInventoryMap.put(lastInvId, lastInv);
......@@ -369,7 +370,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
OutboundOrderLog log = new OutboundOrderLog();
BeanUtils.copyProperties(item, log);
log.setOrderId(item.getOutboundOrderId());
log.setItemStatus(3L);
log.setItemStatus(1L);
return log;
}).collect(Collectors.toList());
outboundOrderLogMapper.batchOutboundOrderLog(logList);
......@@ -421,8 +422,9 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
Map<String, Inventory> toUpdateInventoryMap,
List<Map<String, Object>> tempDeductRecords) {
List<Inventory> invList = inventoryGroupMap.getOrDefault(inventoryKey, new ArrayList<>());
// 如果该维度下没有任何库存,按新的策略应直接报错(不再新增库存)
if (CollectionUtils.isEmpty(invList)) {
return deductQty;
throw new ServiceException(String.format("维度[%s]无可用库存,请确认库存是否存在", inventoryKey));
}
// 同维度库存按数量从多到少排序(优先扣减数量多的)
......@@ -435,19 +437,24 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
Long remainDeduct = deductQty;
for (Inventory inv : invList) {
if (remainDeduct <= 0) break;
String currentInvId = inv.getId(); // 提取当前要扣减的库存ID
Long currentQty = Optional.ofNullable(inv.getQuantity()).orElse(0L);
Long canDeduct = Math.min(remainDeduct, currentQty); // 实际扣减数量
Long currentLocked = Optional.ofNullable(inv.getLockedQuantity()).orElse(0L);
// 可用库存 = quantity - lockedQuantity
Long available = Math.max(0L, currentQty - currentLocked);
Long canDeduct = Math.min(remainDeduct, available); // 实际可预占/锁定数量
if (canDeduct <= 0) {
continue; // 当前库存无可用量,跳过
}
// 更新库存对象
inv.setQuantity(currentQty - canDeduct);
inv.setInventoryStatus(inv.getQuantity() > 0 ? 1L : 0L);
// 更新库存对象:不直接减少实际库存quantity,而是调整锁定数量(预占)
inv.setLockedQuantity(currentLocked + canDeduct);
inv.setUpdateBy(updateUser);
inv.setUpdateTime(updateTime);
toUpdateInventoryMap.put(currentInvId, inv);
// 仅记录当前被扣减的库存ID(扣哪个记哪个)
// 仅记录当前被扣减(预占/锁定)的库存ID(扣哪个记哪个)
Map<String, Object> record = buildDeductRecord(inv, inv.getInventoryType().toString(), canDeduct);
tempDeductRecords.add(record);
......@@ -715,7 +722,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
// 填充主表必填字段
mainDO.setId(UUID.randomUUID().toString());
mainDO.setOrderId(orderId);
mainDO.setOrderStatus(2L);
mainDO.setOrderStatus(1L);
mainDO.setCreateBy(operId);
mainDO.setCreateTime(now);
mainDO.setOrderTypeId(String.valueOf(orderType));
......@@ -745,7 +752,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
itemDO.setCreateTime(now);
itemDO.setCreateUserCode(operId);
itemDO.setSortNo(0L);
itemDO.setItemStatus(3L);
itemDO.setItemStatus(1L);
itemDO.setShippedAt(mainDO.getInboundDate());
// 物料SAP校验
......@@ -910,7 +917,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
OutboundOrderLog log = new OutboundOrderLog();
BeanUtils.copyProperties(item, log);
log.setOrderId(item.getOutboundOrderId());
log.setItemStatus(3L);
log.setItemStatus(1L);
return log;
}).collect(Collectors.toList());
outboundOrderLogMapper.batchOutboundOrderLog(logList);
......
......@@ -596,6 +596,7 @@ and inventory_status = '1'
UPDATE inventory
<set>
quantity = #{item.quantity},
locked_quantity = #{item.lockedQuantity},
inventory_status = #{item.inventoryStatus},
update_user_code = #{item.updateBy},
update_time = #{item.updateTime}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论