import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n;
Scanner ru = new Scanner(System.in);
WarehouseManagement tool = new WarehouseManagement();
while(true){
tool.show();
System.out.println("请输入要进行的操作:");
n = ru.nextInt();
switch (n){
case 1:
tool.case1();
break;
case 2:
tool.case2();
break;
case 3:
tool.case3();
break;
case 4:
tool.case4();
break;
case 5:
System.out.println("欢迎再次使用");
return;
default:
System.out.println("该选项不存在!");
break;
}
}
}
}
public class WarehouseInformation {
private String itemno;
private String itemname;
private String suppliername;
private String warehousingtime;
private String shipmenttime;
private String warehousenumber;
private String warehouseplace;
private int itemnuber = 0;
private int outnumber;
public WarehouseInformation(String value1, String value2,String value3,String value4,String value5,String value6, String value7,int value8,int value9){
itemno = value1;
itemname = value2;
suppliername = value3;
warehousingtime = value4;
shipmenttime = value5;
warehousenumber = value6;
warehouseplace = value7;
itemnuber = value8;
outnumber = value9;
}
public int getOutnumber() {
return outnumber;
}
public void setOutnumber(int outnumber) {
this.outnumber = outnumber;
}
public int getItemnuber() {
return itemnuber;
}
public void setItemnuber(int itemnuber) {
this.itemnuber = itemnuber;
}
public String getWarehouseplace() {
return warehouseplace;
}
public void setWarehouseplace(String warehouseplace) {
this.warehouseplace = warehouseplace;
}
public String getWarehousenumber() {
return warehousenumber;
}
public void setWarehousenumber(String warehousenumber) {
this.warehousenumber = warehousenumber;
}
public String getItemname() {
return itemname;
}
public void setItemname(String itemname) {
this.itemname = itemname;
}
public String getShipmenttime() {
return shipmenttime;
}
public void setShipmenttime(String shipmenttime) {
this.shipmenttime = shipmenttime;
}
public String getWarehousingtime() {
return warehousingtime;
}
public void setWarehousingtime(String warehousingtime) {
this.warehousingtime = warehousingtime;
}
public String getSuppliername() {
return suppliername;
}
public void setSuppliername(String suppliername) {
this.suppliername = suppliername;
}
public String getItemno() {
return itemno;
}
public void setItemno(String itemno) {
this.itemno = itemno;
}
}
import java.util.Scanner;
public class WarehouseManagement {
private WarehouseInformation[] arr = new WarehouseInformation[10];
private int i = 5;
Scanner ru = new Scanner(System.in);
public WarehouseManagement() {
arr[0] = new WarehouseInformation("00000000", "巧克力", "晨光", "20230904", "20230904", "111", "00001122", 10, 0);
arr[1] = new WarehouseInformation("00000001", "巧克力", "晨光", "20230904", "20230904", "111", "00001122", 20, 10);
arr[2] = new WarehouseInformation("00000002", "巧克力", "晨光", "20230904", "20230904", "111", "00001122", 50, 39);
arr[3] = new WarehouseInformation("00000003", "巧克力", "晨光", "20230904", "20230904", "111", "00001122", 30, 3);
arr[4] = new WarehouseInformation("00000004", "巧克力", "晨光", "20230904", "20230904", "111", "00001122", 20, 15);
}
public 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(" 5、退出系统");
System.out.println("**********************************************************");
}
public void useshow() {
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
}
public void case1() {
arr[i] = new WarehouseInformation("00000000", "巧克力", "晨光", "20230904", "20230904", "111", "00001122", 10, 0);
useshow();
String value1,value2,value3,value4,value5,value6;
int value7;
while (true) {
System.out.println("请输入商品编号:");
value1 = ru.next();
if (value1.length() == 8) {
//arr[i].setItemno(temp);
break;
}else System.out.println("输入有误,请重新输入");
}
System.out.println("请输入商品名称:");
value2 = ru.next();
//arr[i].setItemname(temp);
System.out.println("请输入供货商信息:");
value3 = ru.next();
//arr[i].setSuppliername(temp);
while(true) {
System.out.println("请输入入库时间:");
value4 = ru.next();
if(value4.length() == 8) {
//arr[i].setWarehousingtime(temp);
break;
}else System.out.println("输入有误,请重新输入");
}
while(true) {
System.out.println("请输入存放仓库号");
value5 = ru.next();
if(value5.length() == 3) {
//arr[i].setWarehousenumber(temp);
break;
}else System.out.println("输入有误,请重新输入");
}
while(true) {
System.out.println("请输入存放位置信息:");
value6 = ru.next();
if(value6.length() == 8) {
//arr[i].setWarehouseplace(temp);
break;
}else System.out.println("输入有误,请重新输入");
}
System.out.println("请输入入库商品数量:");
value7 = ru.nextInt();
//arr[i].setItemnuber(m);
useshow();
System.out.println(" 商品编号:" + value1);
System.out.println(" 商品名称:" + value2);
System.out.println(" 供货商信息:" + value3);
System.out.println(" 入库时间:" + value4);
System.out.println(" 存放仓库号:" + value5);
System.out.println(" 存放位置信息:" + value6);
System.out.println(" 入库商品数量:" + value7);
System.out.println(" 该商品入库操作已完成,是否提交(Y/N)");
System.out.println("**********************************************************");
String ch = ru.next();
if(ch.equals("N"))
return;
else{
arr[i].setItemno(value1);
arr[i].setItemname(value2);
arr[i].setSuppliername(value3);
arr[i].setWarehousingtime(value4);
arr[i].setWarehousenumber(value5);
arr[i].setWarehouseplace(value6);
arr[i].setItemnuber(value7);
System.out.println("录入成功!");
i++;
}
}
public void case2(){
while(true) {
useshow();
String temp, ch;
int flag = 0, choice, num;
System.out.println(" 请输入商品编号:");
System.out.println("**********************************************************");
temp = ru.next();
for (int j = 0; j < i; j++) {
if (temp.equals(arr[j].getItemno())) {
flag = 1;
useshow();
System.out.println(" 1、商品编号:" + arr[j].getItemno());
System.out.println(" 2、商品名称:" + arr[j].getItemname());
System.out.println(" 3、供货商信息:" + arr[j].getSuppliername());
System.out.println(" 4、入库时间:" + arr[j].getShipmenttime());
System.out.println(" 5、存放仓库号:" + arr[j].getWarehousenumber());
System.out.println(" 6、存放位置信息:" + arr[j].getWarehouseplace());
System.out.println(" 7、入库商品数量:" + arr[j].getItemnuber());
System.out.println(" 请选择需要修改的信息编号(1-7):");
System.out.println("**********************************************************");
choice = ru.nextInt();
switch (choice){
case 1:
while (true) {
useshow();
System.out.println("请输入修改后的商品编号:");
temp = ru.next();
if (temp.length() == 8) {
System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");
ch = ru.next();
if(ch.equals("Y"))
arr[j].setItemno(temp);
else System.out.println("已退出");
break;
}else System.out.println("输入有误,请重新输入");
}
break;
case 2:
useshow();
System.out.println("请输入修改后的商品名称:");
temp = ru.next();
System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");
ch = ru.next();
if(ch.equals("Y"))
arr[j].setItemname(temp);
else System.out.println("已退出");
break;
case 3:
useshow();
System.out.println("请输入修改后的供应商信息:");
temp = ru.next();
System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");
ch = ru.next();
if(ch.equals("Y"))
arr[j].setSuppliername(temp);
else System.out.println("已退出");
break;
case 4:
while (true) {
useshow();
System.out.println("请输入修改后的入库时间:");
temp = ru.next();
if (temp.length() == 8) {
System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");
ch = ru.next();
if(ch.equals("Y"))
arr[j].setShipmenttime(temp);
else System.out.println("已退出");
break;
}else System.out.println("输入有误,请重新输入");
}
break;
case 5:
while (true) {
useshow();
System.out.println("请输入修改后的仓库号:");
temp = ru.next();
if (temp.length() == 3) {
System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");
ch = ru.next();
if(ch.equals("Y"))
arr[j].setWarehousenumber(temp);
else System.out.println("已退出");
break;
}else System.out.println("输入有误,请重新输入");
}
break;
case 6:
while (true) {
useshow();
System.out.println("请输入修改后的存放位置信息:");
temp = ru.next();
if (temp.length() == 8) {
System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");
ch = ru.next();
if(ch.equals("Y"))
arr[j].setWarehouseplace(temp);
else System.out.println("已退出");
break;
}else System.out.println("输入有误,请重新输入");
}
break;
case 7:
useshow();
System.out.println("请输入修改后的入库商品数量:");
num = ru.nextInt();
System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");
ch = ru.next();
if(ch.equals("Y"))
arr[j].setItemnuber(num);
else System.out.println("已退出");
break;
default:
System.out.println("输入错误");
break;
}
flag = 1;
break;
}
}
if(flag == 0) System.out.println("该商品不存在");
else break;
}
}
public void case3() {
while (true) {
useshow();
int flag = 0;
String outtime;
int outnumber;
System.out.println(" 请输入商品编号:");
System.out.println("**********************************************************");
String temp = ru.next();
for (int j = 0; j < i; j++) {
if (temp.equals(arr[j].getItemno())) {
flag = 1;
useshow();
System.out.println(" 1、商品编号:" + arr[j].getItemno());
System.out.println(" 2、商品名称:" + arr[j].getItemname());
System.out.println(" 3、供货商信息:" + arr[j].getSuppliername());
System.out.println(" 4、入库时间:" + arr[j].getShipmenttime());
System.out.println(" 5、存放仓库号:" + arr[j].getWarehousenumber());
System.out.println(" 6、存放位置信息:" + arr[j].getWarehouseplace());
System.out.println(" 7、入库商品数量:" + arr[j].getItemnuber());
System.out.println("**********************************************************");
while (true) {
System.out.println("请输入出库时间:");
outtime = ru.next();
if (outtime.length() == 8)
break;
else
System.out.println("输入有误,请重新输入");
}
while (true) {
System.out.println("请输入出库数量:");
outnumber = ru.nextInt();
if (outnumber <= arr[j].getItemnuber())
break;
else
System.out.println("输入有误,请重新输入");
}
useshow();
System.out.println(" 1、商品编号:" + arr[j].getItemno());
System.out.println(" 2、商品名称:" + arr[j].getItemname());
System.out.println(" 3、供货商信息:" + arr[j].getSuppliername());
System.out.println(" 4、入库时间:" + arr[j].getShipmenttime());
System.out.println(" 5、存放仓库号:" + arr[j].getWarehousenumber());
System.out.println(" 6、存放位置信息:" + arr[j].getWarehouseplace());
System.out.println(" 7、入库商品数量:" + arr[j].getItemnuber());
System.out.println(" 出库时间:" + outtime);
System.out.println(" 出库数量:" + outnumber);
System.out.println("**********************************************************");
System.out.println("选择“Y”保存结果,返回系统主界面。选择“N”, 返回当前界面。");
temp = ru.next();
if (temp.equals("Y")) {
arr[j].setWarehousingtime(outtime);
arr[j].setOutnumber(outnumber);
System.out.println("已保存");
break;
} else break;
}
}
if (flag == 0) {
System.out.println("未搜索到此商品");
} else break;
}
}
public void case4(){
useshow();
for(int j = 0; j < i; j++){
System.out.println(j+1 + "、 商品编号:" + arr[j].getItemno() + "、 商品名称:" + arr[j].getItemname() + "、 库存数量:" + (arr[j].getItemnuber() - arr[j].getOutnumber()));
}
System.out.println("**********************************************************");
}
}