石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版
WarehouseInformation类
商品信息类
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 String itemnumber;//入库数量
private String outnumber;//出库数量
public WarehouseInformation() {
}
public WarehouseInformation(String itemno, String itemname, String suppliername, String warehousingtime, String warehousenumber, String warehouseplace, String itemnumber) {
this.itemno = itemno;
this.itemname = itemname;
this.suppliername = suppliername;
this.warehousingtime = warehousingtime;
this.warehousenumber = warehousenumber;
this.warehouseplace = warehouseplace;
this.itemnumber = itemnumber;
}
public WarehouseInformation(String itemno, String itemname, String suppliername, String warehousingtime, String shipmenttime, String warehousenumber, String warehouseplace, String itemnumber, String 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;
}
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 String getItemnumber() {
return itemnumber;
}
public void setItemnumber(String itemnumber) {
this.itemnumber = itemnumber;
}
public String getOutnumber() {
return outnumber;
}
public void setOutnumber(String outnumber) {
this.outnumber = outnumber;
}
}
WarehouseManagement
管理类
import org.junit.Test;
import java.util.ArrayList;
import java.util.Scanner;
public class WarehouseManagement {
public ArrayList<WarehouseInformation> wa=new ArrayList<>();
public WarehouseManagement() {
WarehouseInformation a1=new WarehouseInformation("20223965","sd","ds","20220930","20221130","203","08111111","100","0");
WarehouseInformation a2=new WarehouseInformation("20223966","sd","ds","20220930","20221130","203","08162351","200","0");
wa.add(a1);
wa.add(a2);
}
@Test
private void Title()
{
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
}
@Test
private void Menu()
{
System.out.println("\t\t\t\t1.商品入库管理");
System.out.println("\t\t\t\t2.商品信息修改");
System.out.println("\t\t\t\t3.商品出库管理");
System.out.println("\t\t\t\t4.仓库盘点管理");
//System.out.println("\t\t\t\t5.退出");
System.out.println("***********************************************************");
}
public void mainFrame()
{
while(true)
{
Scanner sc=new Scanner(System.in);
this.Title();
this.Menu();
System.out.print("请输入你的选择:");
int n=sc.nextInt();
switch(n){
case 1:
this.goodsWarehousing();
break;
case 2:
this.modifyWarehouse();
break;
case 3:
this.outboundWarehouse();
break;
case 4:
this.countGoods();
break;
case 5:
System.out.println("谢谢你的使用!");
System.exit(0);
default:
System.out.println("该选项不存在,请重新输入");
break;
}
}
}
@Test
public void goodsWarehousing()
{
this.Title();
Scanner sc=new Scanner(System.in);
String a,b,c,d,e,f,g;
System.out.printf("\t\t\t\t商品编号:");
a=sc.nextLine();
System.out.printf("\t\t\t\t商品名称:");
b=sc.nextLine();
System.out.printf("\t\t\t\t供货商信息:");
c=sc.nextLine();
System.out.printf("\t\t\t\t入库时间:");
d=sc.nextLine();
System.out.printf("\t\t\t\t存放仓库号:");
e=sc.nextLine();
System.out.printf("\t\t\t\t存放位置信息:");
f=sc.nextLine();
System.out.printf("\t\t\t\t入库商品数量:");
g=sc.nextLine();
if(a.length()!=8&&d.length()!=8&&e.length()!=3&&f.length()!=8)
{
System.out.println("输入有误,请重新输入!");
this.goodsWarehousing();
}
WarehouseInformation w=new WarehouseInformation(a,b,c,d,e,f,g);
System.out.println("\t\t\t\t商品编号:"+a);
System.out.println("\t\t\t\t商品名称:"+b);
System.out.println("\t\t\t\t供货商信息:"+c);
System.out.println("\t\t\t\t入库时间:"+d);
System.out.println("\t\t\t\t存放仓库号:"+e);
System.out.println("\t\t\t\t存放位置信息:"+f);
System.out.println("\t\t\t\t入库商品数量:"+g);
System.out.println("该商品入库操作已经完成,是否提交(Y/N)");
System.out.println("***********************************************************");
String op=sc.nextLine();
if(op.equals("Y")){
wa.add(w);
}
}
public void modifyWarehouse()
{
this.Title();
Scanner sc=new Scanner(System.in);
System.out.printf("\t\t\t请输入商品编号:");
String no=sc.nextLine();
boolean cunzai=false;
int ele=-1;
for (int i = 0; i < wa.size(); i++) {
if(wa.get(i).getItemno().equals(no)){
cunzai=true;
ele=i;
break;
}
}
if(cunzai) {
System.out.println("***********************************************************");
System.out.println("\t\t\t\t1.商品编号:"+wa.get(ele).getItemno());
System.out.println("\t\t\t\t2.商品名称:"+wa.get(ele).getItemname());
System.out.println("\t\t\t\t3.供货商信息:"+wa.get(ele).getSuppliername());
System.out.println("\t\t\t\t4.入库时间:"+wa.get(ele).getWarehousingtime());
System.out.println("\t\t\t\t5.存放仓库号:"+wa.get(ele).getWarehousenumber());
System.out.println("\t\t\t\t6.存放位置信息:"+wa.get(ele).getWarehouseplace());
System.out.println("\t\t\t\t7.入库商品数量:"+wa.get(ele).getItemnumber());
System.out.printf("\t\t\t\t请选择需要修改的信息编号(1-7):");
String n=sc.nextLine();
if(n.equals("1")) {
System.out.printf("请输入修改后的商品编号:");
String a=sc.nextLine();
System.out.println("(Y/N)");
String op=sc.nextLine();
if(op.equals("Y")) {
wa.get(ele).setItemno(a);
}
} else if (n.equals("2")) {
System.out.printf("请输入修改后的商品名称:");
String b=sc.nextLine();
System.out.println("(Y/N)");
String op1=sc.nextLine();
if (op1.equals("Y")) {
wa.get(ele).setItemname(b);
}
} else if (n.equals("3")) {
System.out.printf("请输入修改后的供货商信息:");
String c=sc.nextLine();
System.out.println("(Y/N)");
String op2=sc.nextLine();
if(op2.equals("Y")) {
wa.get(ele).setSuppliername(c);
}
} else if (n.equals("4")) {
System.out.printf("请输入修改后的入库时间:");
String d= sc.nextLine();
System.out.println("(Y/N)");
String op2=sc.nextLine();
if(op2.equals("Y")) {
wa.get(ele).setWarehousingtime(d);
}
} else if (n.equals("5")) {
System.out.printf("请输入修改后的存放仓库号");
String e=sc.nextLine();
System.out.println("(Y/N)");
String op2=sc.nextLine();
if(op2.equals("Y")) {
wa.get(ele).setWarehousenumber(e);
}
} else if (n.equals("6")) {
System.out.printf("请输入修改后的存放位置信息:");
String f=sc.nextLine();
System.out.println("(Y/N)");
String op2=sc.nextLine();
if(op2.equals("Y")) {
wa.get(ele).setWarehouseplace(f);
}
} else if (n.equals("7")) {
System.out.printf("请输入修改后的商品数量");
String g=sc.nextLine();
System.out.println("(Y/N)");
String op2=sc.nextLine();
if(op2.equals("Y")) {
wa.get(ele).setItemnumber(g);
}
}else {
System.out.println("该信息不存在");
}
}
else{
System.out.println("没有找到对应的商品编号");
}
}
public void outboundWarehouse()
{
this.Title();
Scanner sc=new Scanner(System.in);
System.out.printf("\t\t\t请输入商品编号:");
String no=sc.nextLine();
boolean cunzai=false;
int ele=-1;
for (int i = 0; i < wa.size(); i++) {
if(wa.get(i).getItemno().equals(no)){
cunzai=true;
ele=i;
break;
}
}
if(cunzai){
System.out.println("***********************************************************");
System.out.println("\t\t\t\t1.商品编号:"+wa.get(ele).getItemno());
System.out.println("\t\t\t\t2.商品名称:"+wa.get(ele).getItemname());
System.out.println("\t\t\t\t3.供货商信息:"+wa.get(ele).getSuppliername());
System.out.println("\t\t\t\t4.入库时间:"+wa.get(ele).getWarehousingtime());
System.out.println("\t\t\t\t5.存放仓库号:"+wa.get(ele).getWarehousenumber());
System.out.println("\t\t\t\t6.存放位置信息:"+wa.get(ele).getWarehouseplace());
System.out.println("\t\t\t\t7.入库商品数量:"+wa.get(ele).getItemnumber());
System.out.printf("\t\t\t\t出库时间:");
String i= sc.nextLine();
System.out.printf("\t\t\t\t出库数量:");
String j=sc.nextLine();
int m1=Integer.parseInt(i);//出库时间
int n1=Integer.parseInt(wa.get(ele).getWarehousingtime());
int m2=Integer.parseInt(j);//出库数量
int n2=Integer.parseInt(wa.get(ele).getItemnumber());
if(m1>n1&&m2<=n2){
System.out.println("(Y/N)");
String op=sc.nextLine();
if(op.equals("Y")){
wa.get(ele).setShipmenttime(i);
wa.get(ele).setOutnumber(j);
}
else{
}
}
else{
System.out.println("输入的出库时间或出库数量不符合实际");
}
}
else{
System.out.println("没有找到该商品信息");
}
}
@Test
public void countGoods(){
this.Title();
for (int i = 0; i < wa.size(); i++) {
int a=Integer.parseInt(wa.get(i).getOutnumber());
int b=Integer.parseInt(wa.get(i).getItemnumber());
System.out.printf("%d. 商品编号:%s, 商品名称:%s, 库存数量:%d\n",i+1,wa.get(i).getItemno(),wa.get(i).getItemname(),b-a);
}
}
}
Main类
调用所有的方法
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
WarehouseManagement p=new WarehouseManagement();
p.mainFrame();
}
}
标签:String,System,sc,测试,println,优化,public,out
From: https://www.cnblogs.com/gyg1222/p/17707806.html