货架名称 货架编码 货架位置 货架类型 所属仓库id 备注 根据上述字段生成100条数据,其中货架类型:1-6,所属仓库id包括CK001 CK002 CK003 CK004 CK005 CK006 CK007 CK008 CK009 CK010 CK011 CK012 CK013 CK014 CK015 CK016 CK017 CK018 CK019 CK020
时间: 2024-01-12 17:02:36 浏览: 11
以下是一个 Java 程序可以随机生成100条数据,用于模拟货架信息:
```java
import java.util.Random;
public class ShelfGenerator {
private static final String[] WAREHOUSE_IDS = {"CK001", "CK002", "CK003", "CK004", "CK005", "CK006", "CK007", "CK008", "CK009", "CK010", "CK011", "CK012", "CK013", "CK014", "CK015", "CK016", "CK017", "CK018", "CK019", "CK020"};
private static final String[] SHELF_TYPES = {"1", "2", "3", "4", "5", "6"};
private static final String[] LOCATIONS = {"A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3", "D1", "D2", "D3"};
public static void main(String[] args) {
Random random = new Random();
for (int i = 1; i <= 100; i++) {
String shelfName = "货架" + i;
String shelfCode = "S" + String.format("%04d", i);
String location = LOCATIONS[random.nextInt(LOCATIONS.length)];
String shelfType = SHELF_TYPES[random.nextInt(SHELF_TYPES.length)];
String warehouseId = WAREHOUSE_IDS[random.nextInt(WAREHOUSE_IDS.length)];
String remark = "备注" + i;
System.out.println(shelfName + "\t" + shelfCode + "\t" + location + "\t" + shelfType + "\t" + warehouseId + "\t" + remark);
}
}
}
```
上述程序定义了三个数组,分别保存了仓库 ID、货架类型和货架位置的可选值。然后使用 `java.util.Random` 类生成随机数,从数组中随机选择一个值作为生成的货架信息的属性值。最后使用 `System.out.println()` 方法输出货架信息。每次运行程序都会生成不同的100条数据。