仓库管理系统 修改
'''
package 仓库管理系统;
public class WarehouseInformation {
private String itemno; //表示商品编号(有8 位数字组成)
private String itemname; //表示商品名称
private String suppliername; //表示供货商名称
private String warehousingtime; //表示入库时间,长度八位例如:20230904
private String shipmenttime; //表示出库时间,长度八位例如:20230904如果该商品未出库,则出库时间为空,如果该商品已出库,则要求出库时间必须晚于入库时间
private String warehousenumber; //表示仓库编号。长度三位
private String warehouseplace; //表示存放商品的具体位置,长度八位数字XXXXYYZZ,其中XXXX表示货架号,YY表示货架的层号,ZZ表示存放在该货架该层的商品顺序号
private int itemnumber; //表示入库商品的数量
private int outnumber = 0; //表示出库商品的数量
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;
}
// public WarehouseInformation(String itemno, String itemname, String suppliername){
// this.itemno = itemno;
// this.itemname = itemname;
// this.suppliername = suppliername;
// }
/**
* 获取
* @return itemno
*/
public String getItemno() {
return itemno;
}
/**
* 设置
* @param itemno
*/
public void setItemno(String itemno) {
this.itemno = itemno;
}
/**
* 获取
* @return itemname
*/
public String getItemname() {
return itemname;
}
/**
* 设置
* @param itemname
*/
public void setItemname(String itemname) {
this.itemname = itemname;
}
/**
* 获取
* @return suppliername
*/
public String getSuppliername() {
return suppliername;
}
/**
* 设置
* @param suppliername
*/
public void setSuppliername(String suppliername) {
this.suppliername = suppliername;
}
/**
* 获取
* @return warehousingtime
*/
public String getWarehousingtime() {
return warehousingtime;
}
/**
* 设置
* @param warehousingtime
*/
public void setWarehousingtime(String warehousingtime) {
this.warehousingtime = warehousingtime;
}
/**
* 获取
* @return shipmenttime
*/
public String getShipmenttime() {
return shipmenttime;
}
/**
* 设置
* @param shipmenttime
*/
public void setShipmenttime(String shipmenttime) {
this.shipmenttime = shipmenttime;
}
/**
* 获取
* @return warehousenumber
*/
public String getWarehousenumber() {
return warehousenumber;
}
/**
* 设置
* @param warehousenumber
*/
public void setWarehousenumber(String warehousenumber) {
this.warehousenumber = warehousenumber;
}
/**
* 获取
* @return warehouseplace
*/
public String getWarehouseplace() {
return warehouseplace;
}
/**
* 设置
* @param warehouseplace
*/
public void setWarehouseplace(String warehouseplace) {
this.warehouseplace = warehouseplace;
}
/**
* 获取
* @return itemnumber
*/
public int getItemnumber() {
return itemnumber;
}
/**
* 设置
* @param itemnumber
*/
public void setItemnumber(int itemnumber) {
this.itemnumber = itemnumber;
}
/**
* 获取
* @return outnumber
*/
public int getOutnumber() {
return outnumber;
}
/**
* 设置
* @param outnumber
*/
public void setOutnumber(int outnumber) {
this.outnumber += outnumber;
}
public void show(){
System.out.println("1.商品编号:" + this.itemno);
System.out.println("2.商品名称:" +this.itemname );
System.out.println("3.供货商信息:" + this.suppliername);
System.out.println("4.入库时间:" + this.warehousingtime);
System.out.println("5.存放仓库号:" + this.warehousenumber);
System.out.println("6.存放位置信息:" + this.warehouseplace);
System.out.println("7.入库商品数量:" + this.itemnumber);
}
// public String toString() {
// return "WarehouseInformation{itemno = " + itemno + ", itemname = " + itemname + ", suppliername = " + suppliername + ", warehousingtime = " + warehousingtime + ", shipmenttime = " + shipmenttime + ", warehousenumber = " + warehousenumber + ", warehouseplace = " + warehouseplace + ", itemnumber = " + itemnumber + ", outnumber = " + outnumber + "}";
// }
}
'''
'''
package 仓库管理系统;
import java.util.ArrayList;
import java.util.Scanner;
public class WarehouseManagement {
public static void main(String[] args) {
WarehouseInformation[] s = new WarehouseInformation[5];
WarehouseInformation s1 = new WarehouseInformation("20223827","李宏威","李宏威_","00000000","00000001","001","00000000",100,10);
WarehouseInformation s2 = new WarehouseInformation("20223828","张三三","张三三_","00000001","00000002","002","00000001",100,20);
WarehouseInformation s3 = new WarehouseInformation("20223829","李四四","李四四_","00000002","00000003","005","00000002",100,30);
WarehouseInformation s4 = new WarehouseInformation("20223826","王五五","王五五_","00000003","00000004","004","00000003",100,40);
s[0] = s1;
s[1] = s2;
s[2] = s3;
s[3] = s4;
// ArrayList<WarehouseInformation> s = new ArrayList<>();
WarehouseInformation s5 = new WarehouseInformation();
s[4] = s5;
// s.add(s1);
// s.add(s2);
// s.add(s3);
// s.add(s4);
Scanner sc = new Scanner(System.in);
while (true){
Display_homepage();
int n = sc.nextInt();
switch (n) {
case 1 -> {wareHouse(s);}
case 2 -> {inFomod(s);}
case 3 -> {outBound(s);}
case 4 -> {showWarehouse(s);return;}
default -> {System.out.println("该选项不存在");}
}
}
}
public static void Display_homepage(){
System.out.println("""
***********************************************************
石家庄铁道大学前进22软件开发有限公司
仓库管理系统2022版
***********************************************************
1、商品入库管理
2、商品信息修改
3、商品出库管理
4、仓库盘点管理
**********************************************************
""");
} //展示首页
public static void page() {
System.out.println("""
***********************************************************
石家庄铁道大学前进22软件开发有限公司
仓库管理系统2022版
***********************************************************
""");
} //展示开头
public static void wareHouse(WarehouseInformation[] s){
WarehouseInformation w = new WarehouseInformation();
page();
String no;
String name;
String supplier;
String wtime;
String wnum;
String place;
int num;
Scanner sc = new Scanner(System.in);
while(true) {
System.out.print("商品编号:");
no = sc.next();
System.out.print("商品名称:");
name = sc.next();
System.out.print("供货商信息:");
supplier = sc.next();
System.out.print("入库时间:");
wtime = sc.next();
System.out.print("存放仓库号:");
wnum = sc.next();
System.out.print("存放位置信息:");
place = sc.next();
System.out.print("入库商品数量:");
num = sc.nextInt();
System.out.println("***********************************************************");
if(no.length() == 8 && wtime.length() == 8 && wnum.length() == 3 && place.length() == 8){
break;
}
System.out.println("录入错误");
}
page();
System.out.println("商品编号:" + no);
System.out.println("商品名称:" + name);
System.out.println("供货商信息:" + supplier);
System.out.println("入库时间:" + wtime);
System.out.println("存放仓库号:" + wnum);
System.out.println("存放位置信息:" + place);
System.out.println("入库商品数量:" + num);
System.out.println("该商品入库操作已完成,是否提交(Y/N)");
String str = sc.next();
if(str.equals("Y")) {
// w.setItemno(no);
// w.setItemname(name);
// w.setSuppliername(supplier);
// w.setWarehousingtime(wtime);
// w.setWarehousenumber(wnum);
// w.setWarehouseplace(place);
// w.setItemnumber(num);
// s.add(w);
s[4].setItemno(no);
s[4].setItemname(name);
s[4].setSuppliername(supplier);
s[4].setWarehousingtime(wtime);
s[4].setWarehousenumber(wnum);
s[4].setWarehouseplace(place);
s[4].setItemnumber(num);
}
} //入库管理
public static void inFomod(WarehouseInformation[] s){
page();
String no;
String name;
String supplier;
String wtime;
String wnum;
String place;
int num;
int flag = 0;
Scanner sc = new Scanner(System.in);
System.out.print("请输入商品编号:");
String str = sc.next();
System.out.println("**********************************************************");
for (int i = 0; i < s.length; i++) {
if(s[i].getItemno().equals(str)){
flag = 1;
page();
s[i].show();
System.out.print("请选择需要修改的信息编号:");
int n = sc.nextInt();
switch (n){
case 1->{
System.out.print("请输入修改后的商品编号:");
no = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setItemno(no);
}
}
case 2->{
System.out.print("请输入修改后的商品名称:");
name = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setItemname(name);
}
}
case 3->{
System.out.print("请输入修改后的供货商信息:");
supplier = sc.next();
String str1 = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
if(str1.equals("Y")) {
s[i].setSuppliername(supplier);
}
}
case 4->{
System.out.print("请输入修改后的入库时间:");
wtime = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setWarehousingtime(wtime);
}
}
case 5->{
System.out.print("请输入修改后的存放仓库号:");
wnum = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setWarehousenumber(wnum);
}
}
case 6->{
System.out.print("请输入修改后的存放位置信息:");
place = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setWarehouseplace(place);
}
}
case 7->{
System.out.print("请输入修改后的商品数量:");
num = sc.nextInt();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setItemnumber(num);
}
}
default -> {
System.out.println("该选项不存在");
}
}
break;
}
}
if(flag == 0){
inFomod(s);
}
} //信息修改
public static void outBound(WarehouseInformation[] s){
page();
int flag = 0;
String stime;
int onum;
Scanner sc = new Scanner(System.in);
System.out.print("请输入商品编号:");
String str = sc.next();
System.out.println("**********************************************************");
for (int i = 0; i < s.length; i++) {
if(s[i].getItemno().equals(str)){
flag = 1;
page();
s[i].show();
while(true) {
System.out.print("出库时间:");
stime = sc.next();
System.out.print("出库数量:");
onum = sc.nextInt();
System.out.println("**********************************************************");
if (onum <= (s[i].getItemnumber() - s[i].getOutnumber()) && stime.length() == 8 && (Integer.parseInt(stime) > Integer.parseInt(s[i].getWarehousingtime()))) {
break;
}
}
System.out.println("该商品出库操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setOutnumber(onum);
}
break;
}
}
if(flag == 0){
outBound(s);
}
} //出库管理
public static void showWarehouse(WarehouseInformation[] s){
page();
for (int i = 0; i < s.length; i++) {
System.out.println(i + 1 + "、 商品编号: " + s[i].getItemno() + "、商品名称: " + s[i].getItemname() + "、库存数量: " + (s[i].getItemnumber() - s[i].getOutnumber()));
}
System.out.println("…………………………………………………");
System.out.println("**********************************************************");
} //仓库盘点
}'''