parent
0184185764
commit
3eceda3c3b
@ -0,0 +1,97 @@
|
||||
package model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DataManager {
|
||||
private static DataManager instance;
|
||||
private Map<String, Goods> goodsMap;
|
||||
private List<String> suppliers;
|
||||
private Map<String, Integer> inventory;
|
||||
|
||||
private DataManager() {
|
||||
goodsMap = new HashMap<>();
|
||||
suppliers = new ArrayList<>();
|
||||
inventory = new HashMap<>();
|
||||
initializeData();
|
||||
}
|
||||
|
||||
public static DataManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DataManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void initializeData() {
|
||||
// 电子产品类
|
||||
addGoodsWithStock("G001", "苹果手机", "iPhone 15", "台", 6999.00, "电子产品", 50);
|
||||
addGoodsWithStock("G002", "联想笔记本", "ThinkPad T14", "台", 5999.00, "电子产品", 30);
|
||||
addGoodsWithStock("G003", "华为平板", "MatePad Pro", "台", 3999.00, "电子产品", 40);
|
||||
addGoodsWithStock("G004", "戴尔显示器", "27寸 4K", "台", 2399.00, "电子产品", 25);
|
||||
|
||||
// 办公家具类
|
||||
addGoodsWithStock("G005", "办公桌", "1.4米", "张", 799.00, "办公家具", 100);
|
||||
addGoodsWithStock("G006", "办公椅", "人体工学", "把", 599.00, "办公家具", 150);
|
||||
addGoodsWithStock("G007", "文件柜", "三层", "个", 459.00, "办公家具", 80);
|
||||
addGoodsWithStock("G008", "会议桌", "2.4米", "张", 1599.00, "办公家具", 20);
|
||||
|
||||
// 办公用品类
|
||||
addGoodsWithStock("G009", "打印纸", "A4 70g", "箱", 89.00, "办公用品", 200);
|
||||
addGoodsWithStock("G010", "签字笔", "0.5mm黑色", "盒", 15.00, "办公用品", 500);
|
||||
addGoodsWithStock("G011", "订书机", "标准型", "个", 35.00, "办公用品", 300);
|
||||
addGoodsWithStock("G012", "文件夹", "A4蓝色", "个", 8.00, "办公用品", 1000);
|
||||
|
||||
// 添加供应商
|
||||
suppliers.add("苹果官方旗舰店");
|
||||
suppliers.add("联想专卖店");
|
||||
suppliers.add("华为授权店");
|
||||
suppliers.add("戴尔官方店");
|
||||
suppliers.add("京东自营");
|
||||
suppliers.add("天猫超市");
|
||||
suppliers.add("办公伙伴专营店");
|
||||
suppliers.add("文具批发商");
|
||||
suppliers.add("家具城");
|
||||
suppliers.add("办公用品直营店");
|
||||
}
|
||||
|
||||
private void addGoodsWithStock(String id, String name, String specification,
|
||||
String unit, double price, String category, int initialStock) {
|
||||
Goods goods = new Goods(id, name, specification, unit, price, category);
|
||||
goodsMap.put(id, goods);
|
||||
inventory.put(id, initialStock);
|
||||
}
|
||||
|
||||
public void addGoods(Goods goods) {
|
||||
goodsMap.put(goods.getId(), goods);
|
||||
if (!inventory.containsKey(goods.getId())) {
|
||||
inventory.put(goods.getId(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
public Goods getGoods(String id) {
|
||||
return goodsMap.get(id);
|
||||
}
|
||||
|
||||
public List<Goods> getAllGoods() {
|
||||
return new ArrayList<>(goodsMap.values());
|
||||
}
|
||||
|
||||
public List<String> getSuppliers() {
|
||||
return new ArrayList<>(suppliers);
|
||||
}
|
||||
|
||||
public int getStock(String goodsId) {
|
||||
return inventory.getOrDefault(goodsId, 0);
|
||||
}
|
||||
|
||||
public void updateStock(String goodsId, int quantity) {
|
||||
inventory.put(goodsId, inventory.getOrDefault(goodsId, 0) + quantity);
|
||||
}
|
||||
|
||||
public Map<String, Integer> getAllStock() {
|
||||
return new HashMap<>(inventory);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package model;
|
||||
|
||||
public class Goods {
|
||||
private String id;
|
||||
private String name;
|
||||
private String specification;
|
||||
private String unit;
|
||||
private double price;
|
||||
private String category;
|
||||
|
||||
public Goods(String id, String name, String specification, String unit, double price, String category) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.specification = specification;
|
||||
this.unit = unit;
|
||||
this.price = price;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getSpecification() { return specification; }
|
||||
public void setSpecification(String specification) { this.specification = specification; }
|
||||
public String getUnit() { return unit; }
|
||||
public void setUnit(String unit) { this.unit = unit; }
|
||||
public double getPrice() { return price; }
|
||||
public void setPrice(double price) { this.price = price; }
|
||||
public String getCategory() { return category; }
|
||||
public void setCategory(String category) { this.category = category; }
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class InboundRecord {
|
||||
private String id;
|
||||
private String goodsId;
|
||||
private int quantity;
|
||||
private String supplier;
|
||||
private LocalDateTime inboundTime;
|
||||
private String operator;
|
||||
private String remark;
|
||||
|
||||
public InboundRecord(String id, String goodsId, int quantity, String supplier,
|
||||
LocalDateTime inboundTime, String operator, String remark) {
|
||||
this.id = id;
|
||||
this.goodsId = goodsId;
|
||||
this.quantity = quantity;
|
||||
this.supplier = supplier;
|
||||
this.inboundTime = inboundTime;
|
||||
this.operator = operator;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
public String getGoodsId() { return goodsId; }
|
||||
public void setGoodsId(String goodsId) { this.goodsId = goodsId; }
|
||||
public int getQuantity() { return quantity; }
|
||||
public void setQuantity(int quantity) { this.quantity = quantity; }
|
||||
public String getSupplier() { return supplier; }
|
||||
public void setSupplier(String supplier) { this.supplier = supplier; }
|
||||
public LocalDateTime getInboundTime() { return inboundTime; }
|
||||
public void setInboundTime(LocalDateTime inboundTime) { this.inboundTime = inboundTime; }
|
||||
public String getOperator() { return operator; }
|
||||
public void setOperator(String operator) { this.operator = operator; }
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
}
|
Loading…
Reference in new issue