所有修改细节

master
王城 6 months ago
parent c7452b6eec
commit 9f0b592da3

Binary file not shown.

@ -69,7 +69,7 @@ public class DML {
try (Connection conn = DriverManager.getConnection(URL); try (Connection conn = DriverManager.getConnection(URL);
Statement stmt = conn.createStatement()) { Statement stmt = conn.createStatement()) {
String sql = "DELETE FROM 表名"; String sql = "DELETE FROM operation_logs";
int result = stmt.executeUpdate(sql); int result = stmt.executeUpdate(sql);
System.out.println("已清空数据表,删除了 " + result + " 条记录"); System.out.println("已清空数据表,删除了 " + result + " 条记录");
@ -93,35 +93,4 @@ public class DML {
e.printStackTrace(); e.printStackTrace();
} }
} //删除指定数据表 } //删除指定数据表
@Test
public void createGoodsTable() {
try (Connection conn = DriverManager.getConnection(URL);
Statement stmt = conn.createStatement()) {
// 创建货物信息表
String sql = "CREATE TABLE IF NOT EXISTS goods (" +
"id TEXT PRIMARY KEY NOT NULL," +
"name TEXT NOT NULL," +
"specification TEXT," +
"unit TEXT," +
"price REAL," +
"category TEXT," +
"quantity INTEGER," +
"remark TEXT," +
"inbound_time TIMESTAMP," +
"operator TEXT," +
"supplier TEXT" +
");";
stmt.execute(sql);
System.out.println("货物信息表创建成功");
} catch (Exception e) {
e.printStackTrace();
}
}
} }

@ -27,8 +27,8 @@ public class DataGoods {
} }
private void initializeData() { private void initializeData() {
// 电子产品类 // 电子产品类
addGoodsWithStock("G001", "苹果手机", "iPhone 15", "台", 6999.00, "电子产品", 50); addGoodsWithStock("NO00000000001", "苹果手机", "iPhone 15", "台", 6999.00, "电子产品", 50);
addGoodsWithStock("G002", "联想笔记本", "ThinkPad T14", "台", 5999.00, "电子产品", 30); addGoodsWithStock("NO00000000002", "联想笔记本", "ThinkPad T14", "台", 5999.00, "电子产品", 30);
addGoodsWithStock("G003", "华为平板", "MatePad Pro", "台", 3999.00, "电子产品", 40); addGoodsWithStock("G003", "华为平板", "MatePad Pro", "台", 3999.00, "电子产品", 40);
addGoodsWithStock("G004", "戴尔显示器", "27寸 4K", "台", 2399.00, "电子产品", 25); addGoodsWithStock("G004", "戴尔显示器", "27寸 4K", "台", 2399.00, "电子产品", 25);

@ -110,21 +110,17 @@ public class DataManager {
Statement stmt = conn.createStatement()) { Statement stmt = conn.createStatement()) {
String sql = "SELECT " + String sql = "SELECT " +
" goods_id, " + " w1.id, " +
" goods_id as goods_name, " + " w1.goods_id as goods_name, " +
" SUM(quantity) as total_quantity, " + " w1.quantity as total_quantity, " +
" GROUP_CONCAT(DISTINCT supplier) as supplier, " + " w1.supplier, " +
" CASE " + " w1.remark " +
" WHEN SUM(quantity) < 10 THEN '库存偏低' " + "FROM warehouse w1 " +
" ELSE '库存正常' " + "ORDER BY w1.id"; // 不再使用GROUP BY直接显示所有记录
" END as remark " +
"FROM warehouse " +
"GROUP BY goods_id " +
"ORDER BY goods_id";
ResultSet rs = stmt.executeQuery(sql); ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) { while (rs.next()) {
String goodsId = rs.getString("goods_id"); String goodsId = rs.getString("id");
String goodsName = rs.getString("goods_name"); String goodsName = rs.getString("goods_name");
int totalQuantity = rs.getInt("total_quantity"); int totalQuantity = rs.getInt("total_quantity");
String supplier = rs.getString("supplier"); String supplier = rs.getString("supplier");
@ -165,7 +161,7 @@ public class DataManager {
} }
public void addOperationLog(String operationType, String operationTarget, String operator, String details) { public void addOperationLog(String operationType, String operationTarget, String operator, String details) {
String id = "LOG" + System.currentTimeMillis(); String id = String.format("NO%014d", System.currentTimeMillis());
OperationLog log = new OperationLog(id, operationType, operationTarget, OperationLog log = new OperationLog(id, operationType, operationTarget,
operator, LocalDateTime.now(), details); operator, LocalDateTime.now(), details);
operationLogs.add(log); operationLogs.add(log);
@ -189,7 +185,7 @@ public class DataManager {
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
showAlert("错误", "存操作日志失败:" + e.getMessage()); showAlert("错误", "<EFBFBD><EFBFBD><EFBFBD>存操作日志失败:" + e.getMessage());
} }
} }

@ -45,86 +45,42 @@ public class CategoryManagementView extends AnchorPane {
ObservableList<Goods> allGoods = FXCollections.observableArrayList(dataGoods.getAllGoods()); ObservableList<Goods> allGoods = FXCollections.observableArrayList(dataGoods.getAllGoods());
ObservableList<String> categories = FXCollections.observableArrayList(dataGoods.getAllCategories()); ObservableList<String> categories = FXCollections.observableArrayList(dataGoods.getAllCategories());
// 对商品按照价格进行排序
allGoods.sort((g1, g2) -> Double.compare(g1.getPrice(), g2.getPrice()));
// 构建树结构 // 构建树结构
TreeItem<String> root = new TreeItem<>("Root"); // 设置根节点 TreeItem<String> root = new TreeItem<>("Root"); // 设置根节点
// 使用嵌套的 Map 结构来存储类别和价格区间 // 使用Map来存储类别节点
Map<String, Map<String, TreeItem<String>>> categoryPriceRangeItems = new HashMap<>(); Map<String, TreeItem<String>> categoryItems = new HashMap<>();
goodsMap = new HashMap<>(); // 初始化商品映射 goodsMap = new HashMap<>(); // 初始化商品映射
// 首先创建所有类别节点
for (String category : categories) {
TreeItem<String> categoryItem = new TreeItem<>(category);
categoryItems.put(category, categoryItem);
root.getChildren().add(categoryItem);
}
// 然后将商品添加到对应的类别下
for (Goods goods : allGoods) { for (Goods goods : allGoods) {
String category = goods.getCategory(); String category = goods.getCategory();
int price = (int) goods.getPrice(); TreeItem<String> categoryItem = categoryItems.get(category);
int rangeStart = (price / 1000) * 1000;
String priceRange = rangeStart + "-" + (rangeStart + 999); if (categoryItem != null) {
// 构建显示文本
// 获取或创建类别分类 String displayText = goods.getName() + " (" + goods.getSpecification() + ")";
Map<String, TreeItem<String>> priceRangeItems = categoryPriceRangeItems.get(category); TreeItem<String> goodsItem = new TreeItem<>(displayText);
if (priceRangeItems == null) { categoryItem.getChildren().add(goodsItem);
priceRangeItems = new HashMap<>();
categoryPriceRangeItems.put(category, priceRangeItems); // 将商品存储到映射中以便快速查找
goodsMap.put(displayText, goods);
// 创建类别节点并添加到根节点
TreeItem<String> categoryItem = new TreeItem<>(category);
root.getChildren().add(categoryItem);
} }
// 获取或创建价格区间分类
TreeItem<String> priceRangeItem = priceRangeItems.get(priceRange);
if (priceRangeItem == null) {
priceRangeItem = new TreeItem<>(priceRange);
priceRangeItems.put(priceRange, priceRangeItem);
// 获取类别节点并添加价格区间节点
TreeItem<String> categoryItem = root.getChildren().stream()
.filter(item -> item.getValue().equals(category))
.findFirst()
.orElse(null);
if (categoryItem != null) {
categoryItem.getChildren().add(priceRangeItem);
}
}
// 获取库存和价格
int stock = dataGoods.getStock(goods.getId());
// 构建显示文本
String displayText = goods.getName() + " (" + goods.getSpecification() + ")";
TreeItem<String> goodsItem = new TreeItem<>(displayText);
priceRangeItem.getChildren().add(goodsItem);
// 将商品存储到映射中以便快速查找
goodsMap.put(displayText, goods);
} }
categoryTreeView.setRoot(root); categoryTreeView.setRoot(root);
// 展开所有一级节点(类别) // 展开所有类别节点
for (TreeItem<String> categoryItem : root.getChildren()) { for (TreeItem<String> categoryItem : root.getChildren()) {
categoryItem.setExpanded(true); categoryItem.setExpanded(true);
} }
// 为 TreeView 添加鼠标点击事件监听器
categoryTreeView.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if (event.getClickCount() == 2) { // 双击事件
TreeItem<String> selectedItem = categoryTreeView.getSelectionModel().getSelectedItem();
if (selectedItem != null && !selectedItem.isLeaf()) {
// 如果点击的是分类或价格区间,不显示详细信息
return;
}
if (selectedItem != null) {
Goods selectedGoods = goodsMap.get(selectedItem.getValue());
if (selectedGoods != null) {
showGoodsDetails(selectedGoods);
}
}
}
}
});
} }
private void showGoodsDetails(Goods goods) { private void showGoodsDetails(Goods goods) {
@ -135,10 +91,18 @@ public class CategoryManagementView extends AnchorPane {
Label nameLabel = new Label("名称: " + goods.getName()); Label nameLabel = new Label("名称: " + goods.getName());
Label specificationLabel = new Label("规格: " + goods.getSpecification()); Label specificationLabel = new Label("规格: " + goods.getSpecification());
Label categoryLabel = new Label("类别: " + goods.getCategory()); Label categoryLabel = new Label("类别: " + goods.getCategory());
Label priceLabel = new Label("价格: " + goods.getPrice()); Label quantityLabel = new Label("数量: " + DataGoods.getInstance().getStock(goods.getId()));
Label stockLabel = new Label("库存: " + DataGoods.getInstance().getStock(goods.getId())); Label supplierLabel = new Label("供应商: " + goods.getSupplier());
Label remarkLabel = new Label("备注: " + goods.getRemark());
detailsBox.getChildren().addAll(nameLabel, specificationLabel, categoryLabel, priceLabel, stockLabel);
detailsBox.getChildren().addAll(
nameLabel,
specificationLabel,
categoryLabel,
quantityLabel,
supplierLabel,
remarkLabel
);
// 添加返回按钮 // 添加返回按钮
Button backButton = new Button("返回"); Button backButton = new Button("返回");

@ -21,8 +21,9 @@ public class GoodsManagementView extends BorderPane {
private TextField idField; private TextField idField;
private TextField nameField; private TextField nameField;
private TextField priceField;
private TextField quantityField; private TextField quantityField;
private TextField supplierField;
private TextField remarkField;
private TableView<Goods> tableView; private TableView<Goods> tableView;
public GoodsManagementView() { public GoodsManagementView() {
@ -41,7 +42,7 @@ public class GoodsManagementView extends BorderPane {
// 加载现有货物数据 // 加载现有货物数据
loadGoodsData(); loadGoodsData();
// 添加双击事件填充文本字段 // 添加双击事件填充文本字段
tableView.setOnMouseClicked(event -> { tableView.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) { if (event.getClickCount() == 2) {
Goods selectedGoods = tableView.getSelectionModel().getSelectedItem(); Goods selectedGoods = tableView.getSelectionModel().getSelectedItem();
@ -61,31 +62,29 @@ public class GoodsManagementView extends BorderPane {
basicInfo.setHgap(10); basicInfo.setHgap(10);
basicInfo.setVgap(10); basicInfo.setVgap(10);
Label idLabel = new Label("货物ID"); Label idLabel = new Label("单号");
idField = new TextField(); idField = new TextField();
idField.setPromptText("请输入货物ID"); idField.setPromptText("请输入单号");
Label nameLabel = new Label("货物名称:"); Label nameLabel = new Label("货物名称:");
nameField = new TextField(); nameField = new TextField();
nameField.setPromptText("请输入货物名称"); nameField.setPromptText("请输入货物名称");
Label priceLabel = new Label("价格:");
priceField = new TextField();
priceField.setPromptText("请输入价格");
basicInfo.addRow(0, idLabel, idField, nameLabel, nameField);
basicInfo.addRow(1, priceLabel, priceField);
// 库存信息
GridPane stockInfo = new GridPane();
stockInfo.setHgap(10);
stockInfo.setVgap(10);
Label quantityLabel = new Label("数量:"); Label quantityLabel = new Label("数量:");
quantityField = new TextField(); quantityField = new TextField();
quantityField.setPromptText("请输入数量"); quantityField.setPromptText("请输入数量");
stockInfo.addRow(0, quantityLabel, quantityField); Label supplierLabel = new Label("供应商:");
supplierField = new TextField();
supplierField.setPromptText("请输入供应商");
Label remarkLabel = new Label("备注:");
remarkField = new TextField();
remarkField.setPromptText("请输入备注信息");
basicInfo.addRow(0, idLabel, idField, nameLabel, nameField);
basicInfo.addRow(1, quantityLabel, quantityField, supplierLabel, supplierField);
basicInfo.addRow(2, remarkLabel, remarkField);
// 设置列宽 // 设置列宽
ColumnConstraints column1 = new ColumnConstraints(); ColumnConstraints column1 = new ColumnConstraints();
@ -93,8 +92,7 @@ public class GoodsManagementView extends BorderPane {
ColumnConstraints column2 = new ColumnConstraints(); ColumnConstraints column2 = new ColumnConstraints();
column2.setMinWidth(200); column2.setMinWidth(200);
basicInfo.getColumnConstraints().addAll(column1, column2); basicInfo.getColumnConstraints().addAll(column1, column2, column1, column2);
stockInfo.getColumnConstraints().addAll(column1, column2);
// 操作按钮 // 操作按钮
HBox buttonBox = new HBox(10); HBox buttonBox = new HBox(10);
@ -109,40 +107,36 @@ public class GoodsManagementView extends BorderPane {
buttonBox.getChildren().addAll(saveButton, clearButton); buttonBox.getChildren().addAll(saveButton, clearButton);
topArea.getChildren().addAll(basicInfo, stockInfo, buttonBox); topArea.getChildren().addAll(basicInfo, buttonBox);
return topArea; return topArea;
} }
private TableView<Goods> createTableView() { private TableView<Goods> createTableView() {
TableView<Goods> table = new TableView<>(); TableView<Goods> table = new TableView<>();
TableColumn<Goods, String> idCol = new TableColumn<>("货物ID"); TableColumn<Goods, String> idCol = new TableColumn<>("单号");
idCol.setCellValueFactory(new PropertyValueFactory<>("id")); idCol.setCellValueFactory(new PropertyValueFactory<>("id"));
TableColumn<Goods, String> nameCol = new TableColumn<>("货物名称"); TableColumn<Goods, String> nameCol = new TableColumn<>("货物名称");
nameCol.setCellValueFactory(new PropertyValueFactory<>("name")); nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
TableColumn<Goods, Double> priceCol = new TableColumn<>("价格");
priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
TableColumn<Goods, Integer> quantityCol = new TableColumn<>("数量"); TableColumn<Goods, Integer> quantityCol = new TableColumn<>("数量");
quantityCol.setCellValueFactory(new PropertyValueFactory<>("quantity")); quantityCol.setCellValueFactory(new PropertyValueFactory<>("quantity"));
// 新增的列
TableColumn<Goods, LocalDateTime> inboundTimeCol = new TableColumn<>("入库时间");
inboundTimeCol.setCellValueFactory(new PropertyValueFactory<>("inboundTime"));
TableColumn<Goods, String> operatorCol = new TableColumn<>("入库操作员");
operatorCol.setCellValueFactory(new PropertyValueFactory<>("operator"));
TableColumn<Goods, String> supplierCol = new TableColumn<>("供应商"); TableColumn<Goods, String> supplierCol = new TableColumn<>("供应商");
supplierCol.setCellValueFactory(new PropertyValueFactory<>("supplier")); supplierCol.setCellValueFactory(new PropertyValueFactory<>("supplier"));
TableColumn<Goods, LocalDateTime> timeCol = new TableColumn<>("入库时间");
timeCol.setCellValueFactory(new PropertyValueFactory<>("inboundTime"));
TableColumn<Goods, String> operatorCol = new TableColumn<>("操作员");
operatorCol.setCellValueFactory(new PropertyValueFactory<>("operator"));
TableColumn<Goods, String> remarkCol = new TableColumn<>("备注"); TableColumn<Goods, String> remarkCol = new TableColumn<>("备注");
remarkCol.setCellValueFactory(new PropertyValueFactory<>("remark")); remarkCol.setCellValueFactory(new PropertyValueFactory<>("remark"));
table.getColumns().addAll(idCol, nameCol, priceCol, quantityCol, table.getColumns().addAll(idCol, nameCol, quantityCol, supplierCol,
inboundTimeCol, operatorCol, supplierCol, remarkCol); timeCol, operatorCol, remarkCol);
return table; return table;
} }
@ -151,15 +145,18 @@ public class GoodsManagementView extends BorderPane {
String url = "jdbc:sqlite:db/dbuml.db3"; String url = "jdbc:sqlite:db/dbuml.db3";
List<Goods> goodsList = new ArrayList<>(); List<Goods> goodsList = new ArrayList<>();
try (Connection conn = DriverManager.getConnection(url)) { try (Connection conn = DriverManager.getConnection(url)) {
String sql = "SELECT goods_id, SUM(quantity) as total_quantity, supplier, inbound_time, operator, remark FROM warehouse GROUP BY goods_id"; String sql = "SELECT id, goods_id as name, quantity, " +
"supplier, inbound_time, operator, remark " +
"FROM warehouse " +
"ORDER BY id"; // 不再使用GROUP BY直接显示所有记录
try (Statement stmt = conn.createStatement(); try (Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql)) { ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) { while (rs.next()) {
Goods goods = new Goods( Goods goods = new Goods(
rs.getString("goods_id"), rs.getString("id"),
rs.getString("goods_id"), // Assuming goods_id is also the name in inbound_records rs.getString("name"),
rs.getInt("total_quantity"), rs.getInt("quantity"),
rs.getString("remark") rs.getString("remark")
); );
goods.setInboundTime(LocalDateTime.parse(rs.getString("inbound_time"))); goods.setInboundTime(LocalDateTime.parse(rs.getString("inbound_time")));
@ -179,28 +176,17 @@ public class GoodsManagementView extends BorderPane {
try { try {
String id = idField.getText().trim(); String id = idField.getText().trim();
String name = nameField.getText().trim(); String name = nameField.getText().trim();
String priceText = priceField.getText().trim();
String quantityText = quantityField.getText().trim(); String quantityText = quantityField.getText().trim();
String supplier = supplierField.getText().trim();
String remark = remarkField.getText().trim();
// 输入验证 // 输入验证
if (id.isEmpty() || name.isEmpty() || priceText.isEmpty() || quantityText.isEmpty()) { if (id.isEmpty() || name.isEmpty() || quantityText.isEmpty() || supplier.isEmpty()) {
showAlert("错误", "请填写货物ID、名称、价格和数量"); showAlert("错误", "请填写完整的货物信息");
return; return;
} }
double price;
int quantity; int quantity;
try {
price = Double.parseDouble(priceText);
if (price <= 0) {
showAlert("错误", "价格必须大于0");
return;
}
} catch (NumberFormatException e) {
showAlert("错误", "请输入有效的价格!");
return;
}
try { try {
quantity = Integer.parseInt(quantityText); quantity = Integer.parseInt(quantityText);
if (quantity <= 0) { if (quantity <= 0) {
@ -216,18 +202,18 @@ public class GoodsManagementView extends BorderPane {
Goods existingGoods = DataManager.getInstance().getGoods(id); Goods existingGoods = DataManager.getInstance().getGoods(id);
if (existingGoods == null) { if (existingGoods == null) {
// 插入新货物 // 插入新货物
Goods newGoods = new Goods(id, name, "", "", price, "", quantity, ""); Goods newGoods = new Goods(String.format("NO%014d", System.currentTimeMillis()),
name, quantity, remark);
newGoods.setInboundTime(LocalDateTime.now()); newGoods.setInboundTime(LocalDateTime.now());
newGoods.setOperator("当前用户"); newGoods.setOperator("当前用户");
newGoods.setSupplier(supplier);
DataManager.getInstance().addGoodsToDatabase(newGoods); DataManager.getInstance().addGoodsToDatabase(newGoods);
} else { } else {
// 更新现有货物 // 更新现有货物
existingGoods.setName(name); existingGoods.setName(name);
existingGoods.setSpecification("");
existingGoods.setUnit("");
existingGoods.setPrice(price);
existingGoods.setCategory("");
existingGoods.setQuantity(quantity); existingGoods.setQuantity(quantity);
existingGoods.setSupplier(supplier);
existingGoods.setRemark(remark);
DataManager.getInstance().updateGoodsInDatabase(existingGoods); DataManager.getInstance().updateGoodsInDatabase(existingGoods);
} }
@ -241,22 +227,24 @@ public class GoodsManagementView extends BorderPane {
} catch (Exception e) { } catch (Exception e) {
showAlert("错误", "保存失败:" + e.getMessage()); showAlert("错误", "保存失败:" + e.getMessage());
e.printStackTrace(); // 添加堆栈跟踪以便调试 e.printStackTrace();
} }
} }
private void handleClear() { private void handleClear() {
idField.clear(); idField.clear();
nameField.clear(); nameField.clear();
priceField.clear();
quantityField.clear(); quantityField.clear();
supplierField.clear();
remarkField.clear();
} }
private void fillFields(Goods goods) { private void fillFields(Goods goods) {
idField.setText(goods.getId()); idField.setText(goods.getId());
nameField.setText(goods.getName()); nameField.setText(goods.getName());
priceField.setText(String.valueOf(goods.getPrice()));
quantityField.setText(String.valueOf(goods.getQuantity())); quantityField.setText(String.valueOf(goods.getQuantity()));
supplierField.setText(goods.getSupplier());
remarkField.setText(goods.getRemark());
} }
private void showAlert(String title, String content) { private void showAlert(String title, String content) {

@ -105,7 +105,7 @@ public class InboundView extends BorderPane {
private TableView<InboundRecord> createTableView() { private TableView<InboundRecord> createTableView() {
TableView<InboundRecord> table = new TableView<>(); TableView<InboundRecord> table = new TableView<>();
TableColumn<InboundRecord, String> idCol = new TableColumn<>("入库单号"); TableColumn<InboundRecord, String> idCol = new TableColumn<>("单号");
idCol.setCellValueFactory(new PropertyValueFactory<>("id")); idCol.setCellValueFactory(new PropertyValueFactory<>("id"));
TableColumn<InboundRecord, String> goodsCol = new TableColumn<>("货物名称"); TableColumn<InboundRecord, String> goodsCol = new TableColumn<>("货物名称");
@ -182,7 +182,7 @@ public class InboundView extends BorderPane {
} }
// 创建入库记录 // 创建入库记录
String id = "IN" + System.currentTimeMillis(); String id = String.format("NO%014d", System.currentTimeMillis());
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// 修改数据库连接为相对路径 // 修改数据库连接为相对路径
@ -218,7 +218,7 @@ public class InboundView extends BorderPane {
// 添加到表格 // 添加到表格
tableView.getItems().add(record); tableView.getItems().add(record);
// <EFBFBD><EFBFBD>新总计 // 新总计
updateTotal(); updateTotal();
// 清空输入 // 清空输入

@ -36,7 +36,7 @@ public class InventoryReportView extends BorderPane {
private TableView<InventoryReport> createTableView() { private TableView<InventoryReport> createTableView() {
TableView<InventoryReport> table = new TableView<>(); TableView<InventoryReport> table = new TableView<>();
TableColumn<InventoryReport, String> goodsIdCol = new TableColumn<>("货物编号"); TableColumn<InventoryReport, String> goodsIdCol = new TableColumn<>("号");
goodsIdCol.setCellValueFactory(new PropertyValueFactory<>("goodsId")); goodsIdCol.setCellValueFactory(new PropertyValueFactory<>("goodsId"));
TableColumn<InventoryReport, String> goodsNameCol = new TableColumn<>("货物名称"); TableColumn<InventoryReport, String> goodsNameCol = new TableColumn<>("货物名称");

@ -92,7 +92,7 @@ public class InventoryView extends BorderPane {
private TableView<Goods> createTableView() { private TableView<Goods> createTableView() {
TableView<Goods> table = new TableView<>(); TableView<Goods> table = new TableView<>();
TableColumn<Goods, String> idCol = new TableColumn<>("货物ID"); TableColumn<Goods, String> idCol = new TableColumn<>("单号");
idCol.setCellValueFactory(new PropertyValueFactory<>("id")); idCol.setCellValueFactory(new PropertyValueFactory<>("id"));
TableColumn<Goods, String> nameCol = new TableColumn<>("货物名称"); TableColumn<Goods, String> nameCol = new TableColumn<>("货物名称");
@ -158,7 +158,7 @@ public class InventoryView extends BorderPane {
} }
// 创建货物对象 // 创建货物对象
String id = "G" + System.currentTimeMillis(); String id = String.format("NO%014d", System.currentTimeMillis());
Goods goods = new Goods(id, goodsName, quantity, remark); Goods goods = new Goods(id, goodsName, quantity, remark);
// 添加到库存管理器 // 添加到库存管理器

@ -70,7 +70,7 @@ public class OperationLogView extends BorderPane {
private TableView<OperationLog> createTableView() { private TableView<OperationLog> createTableView() {
TableView<OperationLog> table = new TableView<>(); TableView<OperationLog> table = new TableView<>();
TableColumn<OperationLog, String> idCol = new TableColumn<>("日志ID"); TableColumn<OperationLog, String> idCol = new TableColumn<>("单号");
idCol.setCellValueFactory(new PropertyValueFactory<>("id")); idCol.setCellValueFactory(new PropertyValueFactory<>("id"));
TableColumn<OperationLog, String> typeCol = new TableColumn<>("操作类型"); TableColumn<OperationLog, String> typeCol = new TableColumn<>("操作类型");

@ -103,7 +103,7 @@ public class OutboundView extends BorderPane {
private TableView<OutboundRecord> createTableView() { private TableView<OutboundRecord> createTableView() {
TableView<OutboundRecord> table = new TableView<>(); TableView<OutboundRecord> table = new TableView<>();
TableColumn<OutboundRecord, String> idCol = new TableColumn<>("出库单号"); TableColumn<OutboundRecord, String> idCol = new TableColumn<>("单号");
idCol.setCellValueFactory(new PropertyValueFactory<>("id")); idCol.setCellValueFactory(new PropertyValueFactory<>("id"));
TableColumn<OutboundRecord, String> goodsCol = new TableColumn<>("货物名称"); TableColumn<OutboundRecord, String> goodsCol = new TableColumn<>("货物名称");
@ -180,7 +180,7 @@ public class OutboundView extends BorderPane {
} }
// 创建出库记录 // 创建出库记录
String id = "OUT" + System.currentTimeMillis(); String id = String.format("NO%014d", System.currentTimeMillis());
OutboundRecord record = new OutboundRecord( OutboundRecord record = new OutboundRecord(
id, id,
goodsName, goodsName,
@ -205,7 +205,7 @@ public class OutboundView extends BorderPane {
// 在handleSave方法中添加日志记录 // 在handleSave方法中添加日志记录
String details = String.format("出库货物:%s数量%d客户%s", String details = String.format("出库货物:%s数量%d客户%s",
goodsName, quantity, customer); goodsName, quantity, customer);
DataManager.getInstance().addOperationLog("出库", goodsName, "当前户", details); DataManager.getInstance().addOperationLog("出库", goodsName, "当前<EFBFBD><EFBFBD>户", details);
} catch (Exception e) { } catch (Exception e) {
showAlert("错误", "保存失败:" + e.getMessage()); showAlert("错误", "保存失败:" + e.getMessage());

Loading…
Cancel
Save