首页 > 其他分享 >9.29

9.29

时间:2024-09-29 20:45:02浏览次数:7  
标签:String int 9.29 System println pi out

//20234096 韩坤 信2305-3
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class PlanManagement {
private static List records = new ArrayList<>();
private static Map<String, String[]> processFlow = new HashMap<>();
private static int recordCount = 0;

public static void main(String[] args) {
    initializeProcessFlow();
    PlanManagement ms = new PlanManagement();
    ms.menu();
}

// 初始化工艺流程表
private static void initializeProcessFlow() {
    processFlow.put("10. 射蜡", new String[]{"20. 修蜡", "柳泽羽", "藤艺哲"});
    processFlow.put("20. 修蜡", new String[]{"30. 面层", "藤艺哲", "郝一诺"});
    processFlow.put("30. 面层", new String[]{"40. 封浆", "郝一诺", "杨松铎"});
    processFlow.put("40. 封浆", new String[]{"50. 熔化", "杨松铎", "刘宇恒"});
    processFlow.put("50. 熔化", new String[]{"60. 切割", "刘宇恒", "陶攀印"});
    processFlow.put("60. 切割", new String[]{"70. 精磨", "陶攀印", "阎琪文"});
    processFlow.put("70. 精磨", new String[]{"80. 调型", "阎琪文", "郝正一"});
    processFlow.put("80. 调型", new String[]{"90. 检验", "郝正一", "刘静一"});
    processFlow.put("90. 检验", new String[]{null, "刘静一", null});
}

// 主菜单
public void menu() {
    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("**********************************************************");

        int option = scanner.nextInt();
        scanner.nextLine(); // Consume the newline

        switch (option) {
            case 1:
                generatePlan(scanner);
                break;
            case 2:
                submitReport(scanner);
                break;
            case 3:
                confirmReport(scanner);
                break;
            case 4:
                displayProgress(scanner);
                break;
            default:
                System.out.println("该选项不存在,请重新输入。");
        }
    }
}

// 生成计划
private void generatePlan(Scanner scanner) {
    if (recordCount >= 5) {
        System.out.println("记录已满,无法再生成计划。");
        return;
    }

    System.out.println("请输入产品批次(如:2305-003):");
    String planId = scanner.nextLine();
    if (!planId.matches("\\d{4}-\\d{3}")) {
        System.out.println("录入错误,请重新输入正确的产品批次号(如:2305-003)。");
        return;
    }

    System.out.println("请输入产品名称(如:表体):");
    String planName = scanner.nextLine();
    if (planName.isEmpty()) {
        System.out.println("录入错误,请重新输入正确的产品名称(如:表体)。");
        return;
    }

    System.out.println("请输入计划数量:");
    int planNumber;
    try {
        planNumber = scanner.nextInt();
    } catch (Exception e) {
        System.out.println("录入错误,请输入一个正确的数字。");
        scanner.nextLine(); // Consume the invalid input
        return;
    }
    scanner.nextLine(); // Consume the newline

    PlanInformation planInfo = new PlanInformation(recordCount + 1, planId, planName,
            "10. 射蜡", "20. 修蜡", "柳泽羽", "藤艺哲",
            planNumber, 0, 0, 0, 0, 0, 0);

    System.out.println("该产品入库操作已完成,是否提交(Y/N)");
    String submit = scanner.nextLine();

    if (submit.equalsIgnoreCase("Y")) {
        records.add(planInfo);
        recordCount++;
        System.out.println("记录已提交。");
    } else {
        System.out.println("记录已被忽略。");
    }
}

// 提交日报方法
private void submitReport(Scanner scanner) {
    System.out.println("请输入产品批次号:");
    String planId = scanner.nextLine();

    PlanInformation pi = findPlan(planId);
    if (pi == null) {
        System.out.println("库中没有该产品计划。");
        return;
    }

    if (pi.getStatement() == 0) {
        System.out.println("1、产品批次:" + pi.getPlanId());
        System.out.println("2、产品名称:" + pi.getPlanName());
        System.out.println("3、计划数量:" + pi.getPlanNumber());

        System.out.println("请输入当前工序(如:“10. 射蜡”):");
        pi.setProcess(scanner.nextLine());

        String[] details = processFlow.get(pi.getProcess());
        if (details == null) {
            System.out.println("工序信息错误,请重新输入。");
            return;
        }
        pi.setNextProcess(details[0]);
        pi.setOperator(details[1]);
        pi.setRecipient(details[2]);

        if (!pi.getProcess().equals("10. 射蜡")) {
            System.out.println("请输入上一道工序转入数量:");
            pi.setInNumber(scanner.nextInt());
        }

        System.out.println("请输入转出总数:");
        pi.setOutNumber(scanner.nextInt());

        System.out.println("请输入丢失数量:");
        pi.setMissNumber(scanner.nextInt());

        System.out.println("请输入废品数量:");
        pi.setBadNumber(scanner.nextInt());

        pi.setInspectedNumber(pi.getOutNumber() - pi.getMissNumber() - pi.getBadNumber());
        scanner.nextLine(); // Consume the newline

        System.out.println("数据录入完毕,是否提交(Y/N)");
        String submit = scanner.nextLine();

        if (submit.equalsIgnoreCase("Y")) {
            pi.setStatement(1);
            printReport(pi);
        } else {
            System.out.println("数据未保存。");
        }
    } else if (pi.getStatement() == 2) {
        // 已确认过的批次日报显示
        System.out.println("1、产品批次:" + pi.getPlanId());
        System.out.println("2、产品名称:" + pi.getPlanName());
        System.out.println("3、计划数量:" + pi.getPlanNumber());
        System.out.println("4、当前工序:" + pi.getProcess());
        System.out.println("5、下一工序:" + pi.getNextProcess());
        System.out.println("6、操作员:" + pi.getOperator());
        System.out.println("7、接收员:" + pi.getRecipient());
        System.out.println("8、上一道工序转入数量:" + pi.getInNumber());
        System.out.println("9、转出总数:" + pi.getOutNumber());
        System.out.println("10、丢失数量:" + pi.getMissNumber());
        System.out.println("11、废品数量:" + pi.getBadNumber());
        System.out.println("12、待检数量:" + pi.getInspectedNumber());
    }
}

// 确认日报方法
private void confirmReport(Scanner scanner) {
    System.out.println("请输入产品批次号:");
    String planId = scanner.nextLine();

    PlanInformation pi = findPlan(planId);
    if (pi == null || pi.getStatement() != 1) {
        System.out.println("库中没有该产品批次或该批次状态不可确认。");
        return;
    }

    System.out.println("1、产品批次:" + pi.getPlanId());
    System.out.println("2、产品名称:" + pi.getPlanName());
    System.out.println("3、计划数量:" + pi.getPlanNumber());
    System.out.println("4、当前工序:" + pi.getProcess());
    System.out.println("5、下一工序:" + pi.getNextProcess());
    System.out.println("6、操作员:" + pi.getOperator());
    System.out.println("7、接收员:" + pi.getRecipient());
    System.out.println("8、上一道工序转入数量:" + pi.getInNumber());
    System.out.println("9、转出总数:" + pi.getOutNumber());
    System.out.println("10、丢失数量:" + pi.getMissNumber());
    System.out.println("11、废品数量:" + pi.getBadNumber());
    System.out.println("12、待检数量:" + pi.getInspectedNumber());

    System.out.println("确认以上数据是否准确(Y/N)");
    String confirm = scanner.nextLine();

    if (confirm.equalsIgnoreCase("Y")) {
        pi.setStatement(2);
        String[] nextProcessDetails = processFlow.get(pi.getNextProcess());
        pi.setProcess(pi.getNextProcess());
        pi.setNextProcess(nextProcessDetails[0]);
        pi.setOperator(nextProcessDetails[1]);
        pi.setRecipient(nextProcessDetails[2]);
        pi.setInNumber(pi.getOutNumber() - pi.getMissNumber() - pi.getBadNumber() - pi.getInspectedNumber());
        printReport(pi);
    } else {
        System.out.println("数据未确认。");
    }
}

// 显示进度方法
private void displayProgress(Scanner scanner) {
    System.out.println("请输入产品批次号:");
    String planId = scanner.nextLine();

    PlanInformation pi = findPlan(planId);
    if (pi == null) {
        System.out.println("库中没有该产品批次。");
        return;
    }

    int completedQuantity = (pi.getProcess().equals("90. 检验")) ? pi.getOutNumber() : 0;
    int remainingQuantity = pi.getPlanNumber() - completedQuantity;

    System.out.println("1、产品批次:" + pi.getPlanId());
    System.out.println("2、产品名称:" + pi.getPlanName());
    System.out.println("3、计划数量:" + pi.getPlanNumber());
    System.out.println("4、完成数量:" + completedQuantity);
    System.out.println("5、剩余数量:" + remainingQuantity);
}

// 查找计划
private PlanInformation findPlan(String planId) {
    for (PlanInformation pi : records) {
        if (pi.getPlanId().equals(planId)) {
            return pi;
        }
    }
    return null;
}

    private void printReport(PlanInformation pi) {
    System.out.println("1、产品批次:" + pi.getPlanId());
    System.out.println("2、产品名称:" + pi.getPlanName());
    System.out.println("3、计划数量:" + pi.getPlanNumber());
    System.out.println("4、当前工序:" + pi.getProcess());
    System.out.println("5、下一工序:" + pi.getNextProcess());
    System.out.println("6、操作员:" + pi.getOperator());
    System.out.println("7、接收员:" + pi.getRecipient());
    System.out.println("8、上一道工序转入数量:" + pi.getInNumber());
    System.out.println("9、转出总数:" + pi.getOutNumber());
    System.out.println("10、丢失数量:" + pi.getMissNumber());
    System.out.println("11、废品数量:" + pi.getBadNumber());
    System.out.println("12、待检数量:" + pi.getInspectedNumber());
}


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

    // Getter 和 Setter 方法
    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;
    }
}

}

标签:String,int,9.29,System,println,pi,out
From: https://www.cnblogs.com/WOZHENDEAIJAVA/p/18440721

相关文章

  • 牛客 9.29 对标 ABC 比赛题面
    ABCDEF(E'shard)输入52214331524G......
  • 9.29每日总结
    今天做完了“四则运算”和“生成验证码”,其中“生成验证码”这道题暑假的时候跟着网课做过初级版的,今天又加以改进了不少,为此把黑马的字符串章节差不多看完了,收获比较大的除了StringBuilder和StringJoiner之外,就是“验证码”这道题中用到的字符串转为字符数组(toCharArray),而“四......
  • 9.29学习日志
    一.Python列表(list)Python支持多种复合数据类型,可将不同值组合在一起。最常用的**列表**,是用方括号标注,逗号分隔的一组值。列表可以包含不同类型的元素,但一般情况下,各个元素的类型相同#列表,是一种复合数据(数据容器)x=[10,20,3.14,10+20j,True,"a"]print(x)1、访问列......
  • 9.29Python基础-列表、元组
    Python列表(list)1.列表的定义和初始化列表是一种复合数据类型,可以包含不同类型的元素。x=[10,20,3.14,10+2j,True,False,"hqyj"]print(x)2.访问列表中的值2.1索引列表的索引从0开始,可以正向或反向访问。y1=x[0]#访问第一个元素y2=x[-1]#访......
  • 杂项乱写 9.29
    因为没有模拟赛,所以考虑捡捡之前漏下的小点。注:LCA之后的讲解中可能会出现一些自由的文字,酌情阅读。dfs序求LCA倍增LCA的常数还是过于大了,虽然好记但会导致我们在一些数据奇异的题中比其它方式求LCA的人的得分要低。所以就有了这个用dfs序求lca的高科技,在时间效率......
  • 2024.9.29 计划
    项目学习ROS第三章背包问题求具体方案能量石金明的预算方案(有依赖的背包问题)总结......
  • 9.23 ~ 9.29
    9.23集训第一天。早晨因为太多人没拿早读资料被老登D了。不是哥们你不早说现在我上哪给你找资料去......
  • 9.22~9.29
    9.22刚回到学校,还没有摆脱浮躁之气,决心先做一个调整,把准方向首先,文化课学习要进行大调,主攻数学,英语常客,语文辅助数学规定每天一小时,前25分钟学习1~3小章不等,后25分钟专注刷本章书后习题然后周六周日规定每晚8~9点对本周数学情况进行整理,并专项练习语文每天晨间早饭诵读一遍,10......
  • 9.25-9.29
      9.25周一上了java课,学会了很多java的知识9.26正常上课9.27今天没课,歇息一下,看会Java9.28课太多了,正常上课9.29上两节课,回来把作业写了,少看了会算法......
  • 9.29~10.1总结
    9.30上午RoundC4:A题签到。B题脑抽sum没清零痛失50。C题考场写了个N方DP,不知道为啥3,4点WA了。正解其实只需二分查找优化DP到\(O(nlogn)\)即可。D题没弄懂正解。下午补题。然后练习了下线段树,基本是面向题解编程了,还是没掌握。晚上ZROI第一题打完就走了,一个贪心。然......