開學考試

xxc666發表於2024-09-28

import java.util.Scanner;

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(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.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 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;
}

}

class PlanManagement {
private PlanInformation[] records;
private int recordCount;

public PlanManagement() {
    records = new PlanInformation[5]; // 儲存最多五個日報記錄
    recordCount = 0;
}

// 主介面
public void displayMainMenu() {
    Scanner scanner = new Scanner(System.in);
    while (true) {
        System.out.println("***********************************************************");
        System.out.println("石家莊鐵道大學無限23軟體開發有限公司");
        System.out.println("Mes系統2023版");
        System.out.println("***********************************************************");
        System.out.println("1、生成計劃");
        System.out.println("2、提交日報");
        System.out.println("3、確認日報");
        System.out.println("4、統計進度");
        System.out.println("***********************************************************");
        System.out.print("請選擇功能(1-4):");
        int choice = scanner.nextInt();
        switch (choice) {
            case 1:
                generatePlan();
                break;
            case 2:
                submitReport();
                break;
            case 3:
                confirmReport();
                break;
            case 4:
                statistics();
                break;
            default:
                System.out.println("該選項不存在,請重新選擇。");
                break;
        }
    }
}

// 生成計劃(方法體為空,可根據需求實現)
private void generatePlan() {
    // 生成計劃的邏輯
    System.out.println("生成計劃的功能尚未實現。");
}

// 提交日報
private void submitReport() {
    if (recordCount >= 5) {
        System.out.println("日報記錄已滿,無法提交新日報。");
        return;
    }

    Scanner scanner = new Scanner(System.in);
    System.out.print("請輸入產品批次(格式:yyyy-xxx,8位):");
    String planid = scanner.nextLine();
    System.out.print("請輸入產品名稱:");
    String planname = scanner.nextLine();
    System.out.print("請輸入當前工序:");
    String process = scanner.nextLine();
    System.out.print("請輸入下一工序:");
    String nextprocess = scanner.nextLine();
    System.out.print("請輸入操作員:");
    String operator = scanner.nextLine();
    System.out.print("請輸入接收員:");
    String recipient = scanner.nextLine();
    System.out.print("請輸入計劃數量:");
    int plannumber = scanner.nextInt();
    System.out.print("請輸入轉入數量:");
    int innumber = scanner.nextInt();
    System.out.print("請輸入轉出總數:");
    int outnumber = scanner.nextInt();
    System.out.print("請輸入丟失數量:");
    int missnumber = scanner.nextInt();
    System.out.print("請輸入廢品數量:");
    int badnumber = scanner.nextInt();
    System.out.print("請輸入待檢驗數量:");
    int inspectednumber = scanner.nextInt();
    int statement = 0; // 初始狀態

    PlanInformation newRecord = new PlanInformation(planid, planname, process, nextprocess, operator, recipient,
            plannumber, innumber, outnumber, missnumber, badnumber, inspectednumber, statement);
    records[recordCount++] = newRecord;
    System.out.println("日報提交成功!");
}

// 確認日報
private void confirmReport() {
    Scanner scanner = new Scanner(System.in);
    System.out.print("請輸入產品批次(格式:yyyy-xxx,8位):");
    String planid = scanner.nextLine();

    PlanInformation foundRecord = null;
    for (PlanInformation record : records) {
        if (record != null && record.getPlanid().equals(planid) && record.getStatement() == 1) {
            foundRecord = record;
            break;
        }
    }

    if (foundRecord == null) {
        System.out.println("庫中沒有該產品批次或狀態不正確。");
        return;
    }

    // 顯示日報資訊
    displayRecord(foundRecord);

    System.out.print("確認結果(Y/N):");
    String confirmation = scanner.next();
    if (confirmation.equalsIgnoreCase("Y")) {
        // 生成新的生產任務記錄邏輯
        foundRecord.setStatement(2); // 狀態設定為確認
        System.out.println("日報確認成功!");
        displayRecord(foundRecord); // 重新顯示確認後的日報資訊
    } else {
        System.out.println("返回確認日報介面。");
    }
}

private void displayRecord(PlanInformation record) {
    System.out.println("***********************************************************");
    System.out.println("產品批次:" + record.getPlanid());
    System.out.println("產品名稱:" + record.getPlanname());
    System.out.println("計劃數量:" + record.getPlannumber());
    System.out.println("當前工序:" + record.getProcess());
    System.out.println("下一工序:" + record.getNextprocess());
    System.out.println("操作員:" + record.getOperator());
    System.out.println("接收員:" + record.getRecipient());
    System.out.println("上一道工序轉入數量:" + (record.getId() == 1 ? "N/A" : record.getInnumber())); // 第一工序無需錄入
    System.out.println("轉出總數:" + record.getOutnumber());
    System.out.println("丟失數量:" + record.getMissnumber());
    System.out.println("廢品數量:" + record.getBadnumber());
    System.out.println("待檢驗數量:" + record.getInspectednumber());
    System.out.println("***********************************************************");
}

private void statistics() {
    Scanner scanner = new Scanner(System.in);
    System.out.print("請輸入產品批次:");
    String planid = scanner.nextLine();

    PlanInformation foundRecord = null;
    for (PlanInformation record : records) {
        if (record != null && record.getPlanid().equals(planid)) {
            foundRecord = record;
            break;
        }
    }

    if (foundRecord == null) {
        System.out.println("庫中沒有該產品批次資訊。");
        return;
    }

    int completedQuantity = foundRecord.getOutnumber();
    int remainingQuantity = foundRecord.getPlannumber() - completedQuantity;

  
    System.out.println("***********************************************************");
    System.out.println("產品批次:" + foundRecord.getPlanid());
    System.out.println("產品名稱:" + foundRecord.getPlanname());
    System.out.println("計劃數量:" + foundRecord.getPlannumber());
    System.out.println("完成數量:" + completedQuantity);
    System.out.println("剩餘數量:" + remainingQuantity);
    System.out.println("***********************************************************");
}

public static void main(String[] args) {
    PlanManagement planManagement = new PlanManagement();
    planManagement.displayMainMenu();
}

}

相關文章