Commit 1976459d by yubin

导入修改

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