import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<WarehouseInformation> ware = new ArrayList<>();
while (true) {
show();
System.out.print("请输入数字:");
int choice = sc.nextInt();
switch (choice) {
case 1 -> addshop(ware);
case 2 -> setshop(ware);
case 3 -> outshop(ware);
case 4 -> showAllshop(ware);
default -> System.out.println("该选项不存在");
}
}
}
public static void show() {
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司 ");
System.out.println(" 仓库管理系统2022版 ");
System.out.println("***********************************************************");
System.out.println(" 1、商品入库管理 ");
System.out.println(" 2、商品信息修改 ");
System.out.println(" 3、商品出库管理 ");
System.out.println(" 4、仓库盘点管理 ");
System.out.println("**********************************************************");
}
public static void show1(String itemno1, String itemname1, String shipmenttime1, String suppliername1, String warehousenumber1, String warehouseplace1, int itemnumber1) {
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司 ");
System.out.println(" 仓库管理系统2022版 ");
System.out.println("***********************************************************");
System.out.println(" 商品编号:" + itemno1);
System.out.println(" 商品名称:" + itemname1);
System.out.println(" 供货商信息:" + shipmenttime1);
System.out.println(" 入库时间:" + suppliername1);
System.out.println(" 存放仓库号:" + warehousenumber1);
System.out.println(" 存放位置信息:" + warehouseplace1);
System.out.println(" 入库商品数量:" + itemnumber1);
}
public static void show2() {
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司 ");
System.out.println(" 仓库管理系统2022版 ");
System.out.println("***********************************************************");
System.out.println(" 请输入商品编号:XXXXXXXX ");
System.out.println("***********************************************************");
}
public static void show3(WarehouseInformation W) {
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司 ");
System.out.println(" 仓库管理系统2022版 ");
System.out.println("***********************************************************");
System.out.println(" 1、商品编号:" + W.itemno);
System.out.println(" 2、商品名称:" + W.itemname);
System.out.println(" 3、供货商信息:" + W.suppliername);
System.out.println(" 4、入库时间:" + W.shipmenttime);
System.out.println(" 5、存放仓库号:" + W.warehousenumber);
System.out.println(" 6、存放位置信息:" + W.warehouseplace);
System.out.println(" 7、入库商品数量:" + W.itemnumber);
}
public static int addshop(ArrayList<WarehouseInformation> ware) {
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("请输入相关信息");//11111111 小米 小米公司 20230101 20230102 111 00001122 10 5
System.out.println("1商品编号2商品名称3供货商名称4入库时间5出库时间6仓库编号7存放商品的具体位置8入库商品的数量9出库商品的数量");
String itemno1 = sc.next();
String itemname1 = sc.next();
String suppliername1 = sc.next();
String warehousingtime1 = sc.next();
String shipmenttime1 = sc.next();
String warehousenumber1 = sc.next();
String warehouseplace1 = sc.next();
int itemnumber1 = sc.nextInt();
int outnumber1 = sc.nextInt();
if (!itemno1.matches("\\d{8}") || !warehousingtime1.matches("\\d{8}") || !warehousenumber1.matches(".{3}") || !shipmenttime1.matches("\\d{8}")) {
System.out.println("信息错误,请重新输入");
continue;
}
if (shipmenttime1.compareTo(warehousingtime1) < 0 || warehouseplace1.matches("^\\d{4}YY\\d{2}$")) {
System.out.println("信息错误,请重新输入");
continue;
}
show1(itemno1, itemname1, shipmenttime1, suppliername1, warehousenumber1, warehouseplace1, itemnumber1);
System.out.println("**********************************************************");
show1(itemno1, itemname1, shipmenttime1, suppliername1, warehousenumber1, warehouseplace1, itemnumber1);
System.out.println("该商品入库操作已完成,是否提交(Y/N)");
System.out.println("**********************************************************");
String choice1 = sc.next();
if (choice1.equals("N")) {
continue;
}
if (choice1.equals("Y")) {
WarehouseInformation Shop = new WarehouseInformation(itemno1, itemname1, suppliername1, warehousingtime1, shipmenttime1, warehousenumber1, warehouseplace1, itemnumber1, outnumber1);
ware.add(Shop);
System.out.println("商品录入成功");
return 0;
}
}
}
public static int setshop(ArrayList<WarehouseInformation> ware) {
Scanner sc = new Scanner(System.in);
while (true) {
show2();
System.out.println("请输入八位商品编号:");
String itemno = sc.next();
for (WarehouseInformation W : ware) {
if (W.itemno.equals(itemno)) {
show3(W);
System.out.println(" 请选择需要修改的信息编号(1-7):");
System.out.println("***********************************************************");
int choice2 = sc.nextInt();
show3(W);
System.out.println(" 请选择需要修改的信息编号(1-7):" + choice2);
if (choice2 > 7 || choice2 < 1) {
System.out.println("该选项不存在");
break;
}
String choice3[] = {"商品编号", "商品名称", "供货商信息", "入库时间", "存放仓库号", "存放位置信息", "商品数量"};
System.out.print("请输入修改后的" + choice3[choice2 - 1] + ":");
String s = null;
int s1 = 0;
if (choice2 != 7) {
s = sc.next();
} else {
s1 = sc.nextInt();
}
System.out.println("***********************************************************");
System.out.println("请输入Y/N:");
String s2 = sc.next();
if (s2.equals("Y")) {
switch (choice2) {
case 1:
W.itemno = s;
System.out.println("商品修改成功");
break;
case 2:
W.itemname = s;
System.out.println("商品修改成功");
break;
case 3:
W.suppliername = s;
System.out.println("商品修改成功");
break;
case 4:
W.warehousingtime = s;
System.out.println("商品修改成功");
break;
case 5:
W.warehousenumber = s;
System.out.println("商品修改成功");
break;
case 6:
W.warehouseplace = s;
System.out.println("商品修改成功");
break;
case 7:
W.itemnumber = s1;
System.out.println("商品修改成功");
break;
default:
System.out.println("该选项不存在");
break;
}
}
return 0;
}
}
System.out.println("该商品不存在");
}
}
public static int outshop(ArrayList<WarehouseInformation> ware) {
Scanner sc = new Scanner(System.in);
while (true) {
show2();
System.out.println("请输入商品编号:");
String s = sc.next();
for (WarehouseInformation W : ware) {
if (s.equals(W.itemno)) {
show3(W);
System.out.println("出库时间:XXXXXXXXX");
System.out.println("出库数量:xxx");
System.out.println("**********************************************************");
System.out.println("请输入出库时间和出库数量");
String s1 = sc.next();
int s2 = sc.nextInt();
if (s1.compareTo(W.warehousingtime) < 0 || W.itemnumber - W.outnumber - s2 < 0) {
System.out.println("日期不正确或出库数量过大,请重新输入");
continue;
}
System.out.println("请输入是否保存Y/N");
String s3 = sc.next();
if (s3.equals("N")) {
continue;
}
if (s3.equals("Y")) {
W.shipmenttime = s1;
W.outnumber = s2 + W.outnumber;
System.out.println("商品出库成功");
return 0;
}
}
}
System.out.println("未保存或没有该商品,请重新输入");
}
}
public static void showAllshop(ArrayList<WarehouseInformation> ware) {
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司 ");
System.out.println(" 仓库管理系统2022版 ");
int i = 0;
for (WarehouseInformation W : ware) {
i++;
int j = W.itemnumber - W.outnumber;
System.out.println(i + "、 " + "商品编号:" + W.itemno + "、商品名称:" + W.itemname + "、库存数量:" + j);
}
System.out.println("***********************************************************");
}
public static class WarehouseInformation {
String itemno;//商品编号
String itemname;//商品名称
String suppliername;//供货商名称
String warehousingtime;//入库时间
String shipmenttime;// 出库时间
String warehousenumber;//仓库编号
String warehouseplace;//存放商品的具体位置
int itemnumber;//入库商品的数量
int outnumber;//出库商品的数量
public String getItemno() {
return itemno;
}
public void setItemno(String itemno) {
this.itemno = itemno;
}
public String getItemname() {
return itemname;
}
public void setItemname(String itemname) {
this.itemname = itemname;
}
public String getSuppliername() {
return suppliername;
}
public void setSuppliername(String suppliername) {
this.suppliername = suppliername;
}
public String getWarehousingtime() {
return warehousingtime;
}
public void setWarehousingtime(String warehousingtime) {
this.warehousingtime = warehousingtime;
}
public String getShipmenttime() {
return shipmenttime;
}
public void setShipmenttime(String shipmenttime) {
this.shipmenttime = shipmenttime;
}
public String getWarehousenumber() {
return warehousenumber;
}
public void setWarehousenumber(String warehousenumber) {
this.warehousenumber = warehousenumber;
}
public String getWarehouseplace() {
return warehouseplace;
}
public void setWarehouseplace(String warehouseplace) {
this.warehouseplace = warehouseplace;
}
public int getItemnumber() {
return itemnumber;
}
public void setItemnumber(int itemnumber) {
this.itemnumber = itemnumber;
}
public int getOutnumber() {
return outnumber;
}
public void setOutnumber(int outnumber) {
this.outnumber = outnumber;
}
public WarehouseInformation() {
}
public WarehouseInformation(String itemno, String itemname, String suppliername, String warehousingtime, String shipmenttime, String warehousenumber, String warehouseplace, int itemnumber, int outnumber) {
this.itemno = itemno;
this.itemname = itemname;
this.suppliername = suppliername;
this.warehousingtime = warehousingtime;
this.shipmenttime = shipmenttime;
this.warehousenumber = warehousenumber;
this.warehouseplace = warehouseplace;
this.itemnumber = itemnumber;
this.outnumber = outnumber;
}
}
}