Commit 5e1984ae by zhangtw

确认入库添加事务处理

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