在今天,正式开课。 在上午初次学习了算法与数据结构,了解数据结构的重要性。后面学习了马克思主义理论。
下午,我们进行了Java的课堂测试,算是对暑假学习的检验,这一次的检测让我知道了我自己在暑期学习中诸多不足。同时通过这次测试也让我知道了Java的程序结构与C++十分相似。
下面为我的代码:
点击查看代码
package qixun;
public class PlanInformation {
private int id;//表示日报流水号
private String planId;//表示产品生产批次号
private String planName;//表示产品名称
private String process;//表示当前工序名称
private String nextProcess;//表示下一接收工序名称
private String operator;//表示当前工序的操作者
private String recipient;//表示下一道工序的接受者
private int planNumber;//表示该产品定要要求的产品数量
private int inNumber;//表示从上一道工序的接收的合格产品总数
private int outNumber;//表示当前工序的产品转出总数。
private int missNumber;//表示当前工序的产品丢失数量。
private int badNumber;//表示当前工序的产品废品数量。
private int inspectedNumber;//表示当前工序的产品待检验数量。
private int statement;//表示该日报记录的状态,
public PlanInformation(int id, String planId, String planName, String process, String nextProcess, String operator,
String recipient, int planNumber, int inNumber, int outNumber, int missNumber,
int badNumber, int inspectedNumber, int statement) {
this.id = id;
this.planId = planId;
this.planName = planName;
this.process = process;
this.nextProcess = nextProcess;
this.operator = operator;
this.recipient = recipient;
this.planNumber = planNumber;
this.inNumber = inNumber;
this.outNumber = outNumber;
this.missNumber = missNumber;
this.badNumber = badNumber;
this.inspectedNumber = inspectedNumber;
this.statement = statement;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPlanId() {
return planId;
}
public void setPlanId(String planId) {
this.planId = planId;
}
public String getPlanName() {
return planName;
}
public void setPlanName(String planName) {
this.planName = planName;
}
public String getProcess() {
return process;
}
public void setProcess(String process) {
this.process = process;
}
public String getNextProcess() {
return nextProcess;
}
public void setNextProcess(String nextProcess) {
this.nextProcess = nextProcess;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getRecipient() {
return recipient;
}
public void setRecipient(String recipient) {
this.recipient = recipient;
}
public int getPlanNumber() {
return planNumber;
}
public void setPlanNumber(int planNumber) {
this.planNumber = planNumber;
}
public int getInNumber() {
return inNumber;
}
public void setInNumber(int inNumber) {
this.inNumber = inNumber;
}
public int getOutNumber() {
return outNumber;
}
public void setOutNumber(int outNumber) {
this.outNumber = outNumber;
}
public int getMissNumber() {
return missNumber;
}
public void setMissNumber(int missNumber) {
this.missNumber = missNumber;
}
public int getBadNumber() {
return badNumber;
}
public void setBadNumber(int badNumber) {
this.badNumber = badNumber;
}
public int getInspectedNumber() {
return inspectedNumber;
}
public void setInspectedNumber(int inspectedNumber) {
this.inspectedNumber = inspectedNumber;
}
public int getStatement() {
return statement;
}
public void setStatement(int statement) {
this.statement = statement;
}
}
package qixun;
import java.util.Scanner;
import qixun.PlanInformation;
import java.util.*;
import java.util.Scanner;
public class PlanManagement {
private PlanInformation[] plans = new PlanInformation[5];
private int count = 0;
public void Header(){
System.out.println("***********************************************************");
System.out.println("石家庄铁道大学无限23软件开发有限公司");
System.out.println("Mes系统2023版");
System.out.println("***********************************************************");
}
public void mainMenu() {
Scanner scanner = new Scanner(System.in);
while (true) {
Header();
System.out.println("1、生成计划");
System.out.println("2、提交日报");
System.out.println("3、确认日报");
System.out.println("4、统计进度");
System.out.println("**********************************************************");
int choice = scanner.nextInt();
switch (choice) {
case 1:
createPlan();
break;
case 2:
submitReport();
break;
case 3:
confirmReport();
break;
case 4:
progressStatistics();
break;
default:
System.out.println("该选项不存在,请重新选择!");
}
}
}
private void createPlan() {
Header();
if (count >= 5) {
System.out.println("已达存储上限!");
return;
}
Scanner scanner = new Scanner(System.in);
System.out.println("生成计划管理");
System.out.println("请输入产品批次号:");
String planId = scanner.nextLine();
if (planId.length() != 8) {
System.out.println("录入错误,批次号必须是8位!");
return;
}
System.out.println("请输入产品名称:");
String planName = scanner.nextLine();
System.out.println("请输入计划数量:");
int planNumber = scanner.nextInt();
int inNumber=planNumber;
PlanInformation newPlan = new PlanInformation(count + 1, planId, planName, "10. 射蜡",
"20. 修蜡", "柳泽羽", "藤艺哲", planNumber,inNumber,
0, 0, 0, 0, 0);
plans[count] = newPlan;
count++;
System.out.println("***********************************************************");
System.out.println("产品批次:" + planId);
System.out.println("产品名称:" + planName);
System.out.println("计划数量:" + planNumber);
System.out.println("该产品入库操作已完成,是否提交(Y/N)");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
System.out.println("计划已提交!");
} else {
count--;
}
}
private void submitReport() {
if (count == 0) {
System.out.println("没有任何产品计划!");
return;
}
Scanner scanner = new Scanner(System.in);
Header();
System.out.println("请输入产品批次号:XXXXXXXX");
String inputPlanId = scanner.nextLine();
PlanInformation plan = null;
for (int i = 0; i < count; i++) {
if (plans[i].getPlanId().equals(inputPlanId)) {
plan = plans[i];
break;
}
}
if (plan == null) {
System.out.println("库中没有该产品计划,返回到提交界面。");
return;
}
if (plan.getStatement() == 2) {
System.out.println("该产品计划已经确认,无法再次提交!");
return;
}
System.out.println("***********************************************************");
System.out.println("1、产品批次:" + plan.getPlanId());
System.out.println("2、产品名称:" + plan.getPlanName());
System.out.println("3、计划数量:" + plan.getPlanNumber());
System.out.println("4、当前工序:" + plan.getProcess());
System.out.println("5、下一工序:" + plan.getNextProcess());
System.out.println("6、操作员:" + plan.getOperator());
System.out.println("7、接收员:" + plan.getRecipient());
int inNumber = 0;
if (!plan.getProcess().startsWith("10")) {
System.out.println("8、上一道工序转入数量:");
inNumber = scanner.nextInt();
if (inNumber > plan.getPlanNumber()) {
System.out.println("转入数量不能大于计划数量,返回到提交界面。");
return;
}
plan.setInNumber(inNumber);
}
System.out.println("9、转出总数:");
int outNumber = scanner.nextInt();
if (outNumber > plan.getInNumber()) {
System.out.println("转出总数不能大于上一道工序转入数量,返回到提交界面。");
return;
}
plan.setOutNumber(outNumber);
System.out.println("10、丢失数量:");
int missNumber = scanner.nextInt();
System.out.println("11、废品数量:");
int badNumber = scanner.nextInt();
System.out.println("12、待检验数量:");
int inspectedNumber = scanner.nextInt();
if (plan.getInNumber() != (missNumber + badNumber + inspectedNumber + outNumber)) {
System.out.println("数据押平错误,请确保转入总数=转出总数+丢失数量+废品数量+待检验数量!");
return;
}
plan.setMissNumber(missNumber);
plan.setBadNumber(badNumber);
plan.setInspectedNumber(inspectedNumber);
System.out.println("是否提交修改的信息?(Y/N)");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
plan.setStatement(1);
System.out.println("日报提交成功!");
} else {
System.out.println("操作取消,返回主界面。");
}
}
private void confirmReport() {
if (count == 0) {
System.out.println("没有任何产品计划!");
return;
}
Scanner scanner = new Scanner(System.in);
Header();
System.out.println("请输入产品批次号:XXXXXXXX");
String inputPlanId = scanner.nextLine();
PlanInformation plan = null;
for (int i = 0; i < count; i++) {
if (plans[i].getPlanId().equals(inputPlanId)) {
plan = plans[i];
break;
}
}
if (plan == null) {
System.out.println("库中没有该产品批次,返回到确认日报界面。");
return;
}
if (plan.getStatement() != 1) {
System.out.println("该产品批次未提交或已确认,无法再次确认!");
return;
}
System.out.println("***********************************************************");
System.out.println("1、产品批次:" + plan.getPlanId());
System.out.println("2、产品名称:" + plan.getPlanName());
System.out.println("3、计划数量:" + plan.getPlanNumber());
System.out.println("4、当前工序:" + plan.getProcess());
System.out.println("5、下一工序:" + plan.getNextProcess());
System.out.println("6、操作员:" + plan.getOperator());
System.out.println("7、接收员:" + plan.getRecipient());
System.out.println("8、上一道工序转入数量:" + plan.getInNumber());
System.out.println("9、转出总数:" + plan.getOutNumber());
System.out.println("10、丢失数量:" + plan.getMissNumber());
System.out.println("11、废品数量:" + plan.getBadNumber());
System.out.println("12、待检验数量:" + plan.getInspectedNumber());
System.out.println("***********************************************************");
System.out.println("是否确认该日报信息?(Y/N)");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
// Transition to the next process
String currentProcess = plan.getProcess();
String nextProcess = plan.getNextProcess();
if (nextProcess != null && !nextProcess.isEmpty()) {
// Set the next process as the current process
plan.setProcess(nextProcess);
// Automatically set the new operator and recipient based on process
switch (nextProcess.split("\\.")[0]) {
case "20": plan.setOperator("藤艺哲"); plan.setRecipient("郝一诺"); break;
case "30": plan.setOperator("郝一诺"); plan.setRecipient("杨松铎"); break;
case "40": plan.setOperator("杨松铎"); plan.setRecipient("刘宇恒"); break;
case "50": plan.setOperator("刘宇恒"); plan.setRecipient("陶攀印"); break;
case "60": plan.setOperator("陶攀印"); plan.setRecipient("阎琪文"); break;
case "70": plan.setOperator("阎琪文"); plan.setRecipient("郝正一"); break;
case "80": plan.setOperator("郝正一"); plan.setRecipient("刘静一"); break;
case "90": plan.setOperator("刘静一"); plan.setRecipient("N/A"); break; // Last process
default: System.out.println("无效工序!");
}
} else {
System.out.println("该产品已经完成所有工序。");
}
// Set batch status to 2 (confirmed)
plan.setStatement(2);
// Update the incoming number for the next process
int nextInNumber = plan.getOutNumber() - plan.getMissNumber() - plan.getBadNumber() - plan.getInspectedNumber();
plan.setInNumber(nextInNumber);
System.out.println("日报确认成功,并生成新的生产任务记录!");
} else {
System.out.println("操作取消,返回主界面。");
}
}
private void progressStatistics() {
if (count == 0) {
System.out.println("没有任何产品计划!");
return;
}
Header();
for (int i = 0; i < count; i++) {
PlanInformation plan = plans[i];
int completedQuantity = plan.getOutNumber();
int remainingQuantity = plan.getPlanNumber() - completedQuantity;
System.out.println("1、产品批次:" + plan.getPlanId());
System.out.println("2、产品名称:" + plan.getPlanName());
System.out.println("3、计划数量:" + plan.getPlanNumber());
System.out.println("4、完成数量:" + completedQuantity);
System.out.println("5、剩余数量:" + remainingQuantity);
System.out.println("***********************************************************");
}
}
public static void main(String[] args) {
PlanManagement management = new PlanManagement();
management.mainMenu();
}
}