Commit 5e1984ae by zhangtw

确认入库添加事务处理

parent b0192161
...@@ -611,7 +611,6 @@ export default { ...@@ -611,7 +611,6 @@ export default {
getList() { getList() {
this.loading = true this.loading = true
listInbound(this.queryParams).then(response => { listInbound(this.queryParams).then(response => {
console.log(response.rows)
this.inboundList = response.rows this.inboundList = response.rows
this.total = response.total this.total = response.total
this.loading = false this.loading = false
......
...@@ -74,7 +74,7 @@ public class InboundOrdersController extends BaseController ...@@ -74,7 +74,7 @@ public class InboundOrdersController extends BaseController
{ {
List<InboundOrders> list = inboundOrdersService.selectInboundOrdersList(inboundOrders); List<InboundOrders> list = inboundOrdersService.selectInboundOrdersList(inboundOrders);
ExcelUtil<InboundOrders> util = new ExcelUtil<InboundOrders>(InboundOrders.class); ExcelUtil<InboundOrders> util = new ExcelUtil<InboundOrders>(InboundOrders.class);
util.exportExcel(response, list, "入库单数据"); util.exportExcel(response, list, "入库单导出数据");
} }
/** /**
......
...@@ -22,62 +22,63 @@ public class InboundOrders extends BaseEntity ...@@ -22,62 +22,63 @@ public class InboundOrders extends BaseEntity
private String id; private String id;
/** 入库单号 检索条件 */ /** 入库单号 检索条件 */
@Excel(name = "入库单号 检索条件") @Excel(name = "入库单号")
private String orderId; private String orderId;
/** 系统编号 检索条件 */ /** 系统编号 检索条件 */
@Excel(name = "系统编号 检索条件") @Excel(name = "系统编号")
private String systemNo; private String systemNo;
/** 入库类型 字典,检索条件 */ /** 入库类型 字典,检索条件 */
@Excel(name = "入库类型 字典,检索条件") @Excel(name = "入库类型")
private String orderTypeId; private String orderTypeId;
/** 批次ID 检索条件 */ /** 批次ID 检索条件 */
@Excel(name = "批次ID 检索条件") @Excel(name = "批次")
private String batchId; private String batchId;
/** 仓库ID 暂无用 */ /** 仓库ID 暂无用 */
@Excel(name = "仓库ID 暂无用") @Excel(name = "源仓库")
private String warehouseId; private String warehouseId;
private String warehouseName;
/** 货主ID */ /** 货主ID */
@Excel(name = "货主ID") @Excel(name = "货主")
private String ownerId; private String ownerId;
private String ownerName; private String ownerName;
/** 入库单状态1-草稿 2-已完成 3-已取消 字典,检索条件 */ /** 入库单状态1-草稿 2-已完成 3-已取消 字典,检索条件 */
@Excel(name = "入库单状态1-草稿 2-已完成 3-已取消 字典,检索条件") @Excel(name = "入库单状态")
private Long orderStatus; private Long orderStatus;
/** 入库日期 日期无时间 */ /** 入库日期 日期无时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "入库日期 日期无时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "入库日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date inboundDate; private Date inboundDate;
/** 订单类型 字典,检索条件 */ /** 订单类型 字典,检索条件 */
@Excel(name = "订单类型 字典,检索条件") @Excel(name = "订单类型")
private String orderType; private String orderType;
/** 计划量 暂无用 */ /** 计划量 暂无用 */
@Excel(name = "计划量 暂无用") @Excel(name = "计划量")
private Long totalPlannedQuantity; private Long totalPlannedQuantity;
/** 实际量 暂无用 */ /** 实际量 暂无用 */
@Excel(name = "实际量 暂无用") @Excel(name = "实际量")
private Long totalActualQuantity; private Long totalActualQuantity;
/** 总件数 暂无用 */ /** 总件数 暂无用 */
@Excel(name = "总件数 暂无用") @Excel(name = "总件数")
private Long totalPackages; private Long totalPackages;
/** 负责人 暂无用 */ /** 负责人 暂无用 */
@Excel(name = "负责人 暂无用") @Excel(name = "负责人")
private String opUserName; private String opUserName;
/** 应用数据1使用0删除 删除用 */ /** 应用数据1使用0删除 删除用 */
@Excel(name = "应用数据1使用0删除 删除用") @Excel(name = "应用数据")
private Long isUsed; private Long isUsed;
/** 排序 */ /** 排序 */
...@@ -293,6 +294,14 @@ public class InboundOrders extends BaseEntity ...@@ -293,6 +294,14 @@ public class InboundOrders extends BaseEntity
this.ownerName = ownerName; this.ownerName = ownerName;
} }
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
...@@ -180,4 +180,5 @@ public class Inventory extends BaseEntity ...@@ -180,4 +180,5 @@ public class Inventory extends BaseEntity
private String specialRequirements; private String specialRequirements;
private Double unitPrice; private Double unitPrice;
private String inboundOrderId;
} }
...@@ -94,6 +94,6 @@ public class InventoryTransactions extends BaseEntity ...@@ -94,6 +94,6 @@ public class InventoryTransactions extends BaseEntity
private String updateUserCode; private String updateUserCode;
@Excel(name = "单价") @Excel(name = "单价")
private String unitPrice; private Double unitPrice;
} }
...@@ -11,6 +11,7 @@ import com.ruoyi.inventory.domain.TO.StocktakeItemsTo; ...@@ -11,6 +11,7 @@ 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.OutboundOrderItemsMapper; import com.ruoyi.inventory.mapper.OutboundOrderItemsMapper;
import com.ruoyi.inventory.mapper.OutboundOrderLogMapper; import com.ruoyi.inventory.mapper.OutboundOrderLogMapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -39,6 +40,8 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -39,6 +40,8 @@ public class InventoryServiceImpl implements IInventoryService
private OutboundOrdersServiceImpl outboundOrderMapper; private OutboundOrdersServiceImpl outboundOrderMapper;
@Autowired @Autowired
private InventoryTransactionsServiceImpl insertInventoryTransactions; private InventoryTransactionsServiceImpl insertInventoryTransactions;
@Autowired
private InboundOrdersMapper inboundOrdersMapper;
...@@ -89,6 +92,12 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -89,6 +92,12 @@ public class InventoryServiceImpl implements IInventoryService
return inventoryMapper.insertInventory(inventory); return inventoryMapper.insertInventory(inventory);
} }
/**
* 批量库存
*
* @param inventoryList 库存
* @return 结果
*/
@Override @Override
public int insertInventoryList(List<Inventory> inventoryList) { public int insertInventoryList(List<Inventory> inventoryList) {
int count = 0; int count = 0;
...@@ -98,10 +107,12 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -98,10 +107,12 @@ public class InventoryServiceImpl implements IInventoryService
inventory.setId(UUID.randomUUID().toString()); inventory.setId(UUID.randomUUID().toString());
inventory.setCreateBy(SystemUtils.getUserName()); inventory.setCreateBy(SystemUtils.getUserName());
inventory.setCreateUserCode(SystemUtils.getUserName()); inventory.setCreateUserCode(SystemUtils.getUserName());
createInventoryInboundLog(inventory,inventory.getQuantity(),inventory.getCreateUserCode(),inventory.getCreateTime());
count = inventoryMapper.insertInventory(inventory); count = inventoryMapper.insertInventory(inventory);
} }
return count; return count;
} }
/** /**
* 修改库存 * 修改库存
* *
...@@ -133,7 +144,6 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -133,7 +144,6 @@ public class InventoryServiceImpl implements IInventoryService
Inventory inventory = new Inventory(); Inventory inventory = new Inventory();
inventory.setLockedQuantity(lockedQuantity); inventory.setLockedQuantity(lockedQuantity);
inventory.setId(inventoryId); inventory.setId(inventoryId);
inventoryMapper.updateInventory(inventory); inventoryMapper.updateInventory(inventory);
} }
return 1; return 1;
...@@ -169,7 +179,7 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -169,7 +179,7 @@ public class InventoryServiceImpl implements IInventoryService
transactions.setId(IdUtils.simpleUUID()); // 确保IdUtils工具类存在,若无则替换为UUID.randomUUID().toString() transactions.setId(IdUtils.simpleUUID()); // 确保IdUtils工具类存在,若无则替换为UUID.randomUUID().toString()
transactions.setTransactionType(2L); // 事务类型-出库 transactions.setTransactionType(2L); // 事务类型-出库
transactions.setBatchCode(outboundOrderItem.getBatchCode()); transactions.setBatchCode(outboundOrderItem.getBatchCode());
transactions.setUnitPrice(String.valueOf(outboundOrderItem.getUnitPrice())); transactions.setUnitPrice(outboundOrderItem.getUnitPrice());
transactions.setInventoryId(inventory.getId()); // 库存表Id transactions.setInventoryId(inventory.getId()); // 库存表Id
transactions.setReferenceId(outboundOrderItem.getOutboundOrderId()); // 关联出库单主表ID transactions.setReferenceId(outboundOrderItem.getOutboundOrderId()); // 关联出库单主表ID
transactions.setReferenceItemId(outboundOrderItem.getId()); // 关联出库单明细ID transactions.setReferenceItemId(outboundOrderItem.getId()); // 关联出库单明细ID
...@@ -195,6 +205,39 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -195,6 +205,39 @@ public class InventoryServiceImpl implements IInventoryService
insertInventoryTransactions.insertInventoryTransactions(transactions); insertInventoryTransactions.insertInventoryTransactions(transactions);
} }
//入库单确认入库日志
private void createInventoryInboundLog(Inventory inventory,
Long addQty, String createUser, Date createTime) {
InventoryTransactions transactions = new InventoryTransactions();
transactions.setId(IdUtils.simpleUUID()); // 确保IdUtils工具类存在,若无则替换为UUID.randomUUID().toString()
transactions.setTransactionType(1L); // 事务类型-入库
transactions.setBatchCode(inventory.getBatchId());
transactions.setUnitPrice(inventory.getUnitPrice());
transactions.setInventoryId(inventory.getId()); // 库存表Id
transactions.setReferenceId(inventory.getInboundOrderId()); // 关联出库单主表ID
transactions.setReferenceItemId(inventory.getId()); // 关联出库单明细ID
transactions.setMaterialId(inventory.getMaterialId());
transactions.setWarehouseId(inventory.getWarehousesId());
transactions.setLocationId(inventory.getLocationId());
transactions.setOwnerId(inventory.getOwnerId());
// 新建实体,查看该物料在库存中数量,避免其他条件干扰
Inventory inventoryBefore = new Inventory();
inventoryBefore.setMaterialId(inventory.getMaterialId());
inventoryBefore = inventoryMapper.selectInventory(inventoryBefore);
if (inventoryBefore == null) {
inventoryBefore = new Inventory();
inventoryBefore.setQuantity(0L);
}
transactions.setQuantityBefore(inventoryBefore.getQuantity());
transactions.setQuantityAfter(inventory.getQuantity() + addQty);
transactions.setQuantityChange(addQty);
transactions.setTransactionTime(createTime);
transactions.setOperatedBy(createUser);
// 插入日志
insertInventoryTransactions.insertInventoryTransactions(transactions);
}
@SerialExecution(group = "inventoryRefresh", fair = true) @SerialExecution(group = "inventoryRefresh", fair = true)
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论