首页 > 其他分享 >2024/9/13日 日志

2024/9/13日 日志

时间:2024-09-13 23:13:34浏览次数:1  
标签:13 String int System 2024 plan println 日志 out

今天,系统的对代码进行了修改优化,对原有代码进行全面修改,并实现了工序对接功能。

点击查看代码
//信2305-2 -- 20234023 -- 张一衡
import java.awt.*;
import java.sql.SQLOutput;
import java.util.Scanner;
import java.util.Random;

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


class PlanInformation{

    private int id=-1;//日报流水号,依次加一
    private String planid="";//表示产品生产批次号(例如:2312-110,有8 位字符组成,前四位表示年月,后三位表示序号)。
    private String planname="";//产品名称
    private String process="";//当前工序名称
    private String nextprocess="";//表示下一接收工序名称。(例如:“11.00 .修蜡”含义同上)。
    private String operator="";//当前工序的操作者。
    private String recipient="";//下一道工序的接受者。
    private int plannumber=0;//该产品定要要求的产品数量。
    private int innumber=0; //从上一道工序的接收的合格产品总数。
    private int outnumber=0;//当前工序的产品转出总数。
    private int missnumber=0;//表示当前工序的产品丢失数量。
    private int badnumber=0;//表示当前工序的产品废品数量。
    private int inspectednumber=0;//表示当前工序的产品待检验数量。
    private int statement=0;//初始状态
    //构造函数
    public PlanInformation(){}

    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;
}
    //GetAndSet
    public int getId() {
        return id;
    }
    public String getPlanid() {
        return planid;
    }
    public String getPlanname() {
        return planname;
    }
    public String getProcess() {
        return process;
    }
    public String getNextprocess() {
        return nextprocess;
    }
    public String getOperator() {
        return operator;
    }
    public String getRecipient() {
        return recipient;
    }
    public int getPlannumber() {
        return plannumber;
    }
    public int getInnumber() {
        return innumber;
    }
    public int getOutnumber() {
        return outnumber;
    }
    public int getMissnumber() {
        return missnumber;
    }
    public int getBadnumber() {
        return badnumber;
    }
    public int getInspectednumber() {
        return inspectednumber;
    }
    public int getStatement() {
        return statement;
    }
    public void setId(int id) {
        this.id = id;
    }
    public void setPlanid(String planid) {
        this.planid = planid;
    }
    public void setPlanname(String planname) {
        this.planname = planname;
    }
    public void setProcess(String process) {
        this.process = process;
    }
    public void setNextprocess(String nextprocess) {
        this.nextprocess = nextprocess;
    }
    public void setOperator(String operator) {
        this.operator = operator;
    }
    public void setRecipient(String recipient) {
        this.recipient = recipient;
    }
    public void setPlannumber(int plumber) {
        this.plannumber = plumber;
    }
    public void setInnumber(int innumber) {
        this.innumber = innumber;
    }
    public void setOutnumber(int outnumber) {
        this.outnumber = outnumber;
    }
    public void setMissnumber(int missnumber) {
        this.missnumber = missnumber;
    }
    public void setBadnumber(int badnumber) {
        this.badnumber = badnumber;
    }
    public void setInspectednumber(int inspectednumber) {
        this.inspectednumber = inspectednumber;
    }
    public void setStatement(int statement) {
        this.statement = statement;
    }
}
class PlanManagement{
    String []processnames ={"","射蜡","修蜡","面层","封浆","熔化","切割","精磨","调型","检验",""};
    String []operators ={"","柳泽羽","藤艺哲","郝一诺","杨松铎","刘宇恒","陶攀印","阎琪文","郝正一","刘静一"};
    String []recipients ={"","藤艺哲","郝一诺","杨松铎","刘宇恒","陶攀印","阎琪文","郝正一","刘静一",""};
    PlanInformation[] plans = new PlanInformation[100];//存储数组
    Scanner sc=new Scanner(System.in);
    private int count=0;//当前记录数量
    private int nextId = 0;//下一个ID
    //验证产品批次号格式
    boolean FormatOrNot(String pid){
        return pid.matches("\\d{4}-\\d{3}$");
    }
    //查找产品计划
    private PlanInformation findPlanByPlanId(String planId) {
        for (PlanInformation plan : plans) {
            if (plan != null && plan.getPlanid().equals(planId)) {
                return plan;
            }
        }
        return null;
    }
    //生成计划信息
    void GeneratePlanInformation() {
        if (count >= plans.length) {
            System.out.println("计划数量已满,无法生成新的计划。");
            return;
        }
        System.out.println("***********************************************************");
        System.out.println("           石家庄铁道大学无限23软件开发有限公司               ");
        System.out.println("                     Mes系统2023版                          ");
        System.out.println("***********************************************************");
        String pid;
        do {
            System.out.print("              产品批次号(格式:YYYY-XXX):");
            pid = sc.nextLine();
            if (!FormatOrNot(pid)) {
                System.out.println("录入错误,请重新输入!");
            }
        }while (!FormatOrNot(pid)) ;
            System.out.print("                      产品名称:");
            String pname = sc.nextLine();
            System.out.print("                      计划数量:");
            int pnumber = sc.nextInt();
            sc.nextLine();
            System.out.println("生成计划成功,是否提交(Y/N):");
            String choice = sc.nextLine();
            if (choice.equalsIgnoreCase("Y")) {
                //创建新的计划信息
                PlanInformation plan = new PlanInformation(nextId++, pid, pname, "", "", "", "", pnumber, 0, 0, 0, 0, 0, 0);
                if(count==0){
                    plan.setProcess(processnames[1]);
                    plan.setOperator(operators[1]);
                }else{
                    plan.setProcess(processnames[count+1]);
                    plan.setOperator(operators[count+1]);
                }
                if (count + 2 < processnames.length) {
                    plan.setNextprocess(processnames[count + 2]);
                } else {
                    plan.setNextprocess("");
                }
                plan.setRecipient(recipients[count+1]);
                plans[count++] = plan;
                plan.setStatement(0);//设置为初始状态
                System.out.println("计划已提交。");
            } else {
                System.out.println("计划未提交,已取消。");
            }
    }
    void SubmitDailyReport(){
        System.out.println("***********************************************************");
        System.out.println("           石家庄铁道大学无限23软件开发有限公司               ");
        System.out.println("                     Mes系统2023版                          ");
        System.out.println("***********************************************************");
        System.out.print("                      请输入产品批次号:");
        String pid=sc.nextLine();
        System.out.println("***********************************************************");
        PlanInformation plan = findPlanByPlanId(pid);
        if(plan==null){
            System.out.println("库中没用该产品计划!");
            return;
        }
        if(plan.getStatement()!=0){
            System.out.println("该计划已提交或确认,无法再次提交日报。");
            return;
        }
        System.out.println("***********************************************************");
        System.out.println("           石家庄铁道大学无限23软件开发有限公司               ");
        System.out.println("                     Mes系统2023版                          ");
        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.print  ("           8、上一道工序转入数量(第一道工序为0):");
        plan.setInnumber(sc.nextInt());
        sc.nextLine();
        System.out.print("             9、转出总数:");
        plan.setOutnumber(sc.nextInt());
        sc.nextLine();
        System.out.print("            10、丢失数量:");
        plan.setMissnumber(sc.nextInt());
        sc.nextLine();
        System.out.print("            11、废品数量:");
        plan.setBadnumber(sc.nextInt());
        sc.nextLine();
        System.out.print("            12、待检验数量:");
        plan.setInspectednumber(sc.nextInt());
        sc.nextLine();

        //验证押平规则
        if(!"射蜡".equals(plan.getProcess())){
            while(plan.getInnumber()!=plan.getOutnumber()+plan.getMissnumber()+plan.getBadnumber()
                    +plan.getInspectednumber()){
                System.out.println("录入错误:上一道工序的转入数量不符合规则,请检查并重新输入!");
                System.out.println();
                System.out.print("             8、上一道工序转入数量(第一道工序为0):");
                int tempInnumber=sc.nextInt();
                sc.nextLine();
                System.out.print("             9、转出总数:");
                int tempOutnumber=sc.nextInt();
                sc.nextLine();
                System.out.print("            10、丢失数量:");
                int tempMissnumber=sc.nextInt();
                sc.nextLine();
                System.out.print("            11、废品数量:");
                int tempBadnumber=sc.nextInt();
                sc.nextLine();
                System.out.print("            12、待检验数量:");
                int tempInspectednumber=sc.nextInt();
                sc.nextLine();
                String choice = sc.nextLine();
                if (choice.equalsIgnoreCase("Y")) {
                    plan.setInnumber(tempInnumber);
                    plan.setOutnumber(tempOutnumber);
                    plan.setMissnumber(tempMissnumber);
                    plan.setBadnumber(tempBadnumber);
                    plan.setInspectednumber(tempInspectednumber);
                } else {
                    System.out.println("未保存修改,已取消。");
                    return;
                }
            }
        }
        plan.setStatement(1);//设置为初始状态
        System.out.println("日报信息保存提交成功!");
        //向下一工序推进
        int currentIndex = -1;
        for (int i = 0; i < processnames.length; i++) {
            if (processnames[i].equals(plan.getProcess())) {
                currentIndex = i;
                break;
            }
        }
        if (currentIndex + 1 < processnames.length) {
            plan.setProcess(processnames[currentIndex + 1]);
            if (currentIndex + 2 < processnames.length) {
                plan.setNextprocess(processnames[currentIndex + 2]);
            } else {
                plan.setNextprocess("");
            }
            plan.setOperator(operators[currentIndex + 1]);
            plan.setRecipient(recipients[currentIndex + 1]);
        } else {
            System.out.println("已到达最后一个工序,无法继续推进。");
        }
    }

    void ConfirmDailyReport(){
        System.out.println("***********************************************************");
        System.out.println("           石家庄铁道大学无限23软件开发有限公司               ");
        System.out.println("                     Mes系统2023版                          ");
        System.out.println("***********************************************************");
        System.out.print("                       请输入产品批次号:");
        String pid=sc.nextLine();
        PlanInformation plan=findPlanByPlanId(pid);
        System.out.println("***********************************************************");
        if(plan==null){
            System.out.println("库中没用该产品计划!");
            return;
        }
        if(plan.getStatement()!=1){
            System.out.println("该计划未提交,无法确认日报。");
            return;
        }
        System.out.println("***********************************************************");
        System.out.println("           石家庄铁道大学无限23软件开发有限公司               ");
        System.out.println("                     Mes系统2023版                          ");
        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 choice = sc.nextLine();
        if (choice.equalsIgnoreCase("Y")) {
            plan.setStatement(2); // 设置为已确认
            // 生成新的生产任务记录
            if (plan.getNextprocess()!= null &&!plan.getNextprocess().isEmpty()) {
                PlanInformation newPlan = new PlanInformation();
                newPlan.setId(nextId++);
                newPlan.setPlanid(plan.getPlanid());
                newPlan.setPlanname(plan.getPlanname());
                newPlan.setProcess(plan.getNextprocess());
                newPlan.setNextprocess(getNextProcessName(plan.getNextprocess()));
                newPlan.setOperator(getOperatorForProcess(plan.getNextprocess()));
                newPlan.setRecipient(getRecipientForProcess(plan.getNextprocess()));
                plans[count++] = newPlan;
            } else {
                System.out.println("已完成所有工序,无需生成新任务记录。");
            }
            System.out.println("日报确认成功,已生成新任务记录!");
        } else {
            System.out.println("确认已取消。");
        }
    }
    //下一工序
    private String getNextProcessName(String currentProcess) {
        int currentIndex = -1;
        for (int i = 0; i < processnames.length; i++) {
            if (processnames[i].equals(currentProcess)) {
                currentIndex = i;
                break;
            }
        }
        if (currentIndex + 1 < processnames.length) {
            return processnames[currentIndex + 1];
        } else {
            return "";
        }
    }
    //操作员
    private String getOperatorForProcess(String process) {
        int index = -1;
        for (int i = 0; i < processnames.length; i++) {
            if (processnames[i].equals(process)) {
                index = i;
                break;
            }
        }
        if (index >= 0 && index < operators.length) {
            return operators[index];
        } else {
            return "";
        }
    }
    //接收员
    private String getRecipientForProcess(String process) {
        int index = -1;
        for (int i = 0; i < processnames.length; i++) {
            if (processnames[i].equals(process)) {
                index = i;
                break;
            }
        }
        if (index >= 0 && index < recipients.length) {
            return recipients[index];
        } else {
            return "";
        }
    }
    // 显示进度
    void NowProgress(){
        System.out.println("***********************************************************");
        System.out.println("           石家庄铁道大学无限23软件开发有限公司               ");
        System.out.println("                       Mes系统2023版                        ");
        System.out.println("***********************************************************");
        for (int i= 0;i< count;i++) {
            if (plans[i] != null&&plans[i].getPlannumber()!=0) {
                System.out.println("产品批次:" + plans[i].getPlanid());
                System.out.println("产品名称:" + plans[i].getPlanname());
                System.out.println("计划数量:" + plans[i].getPlannumber());
                System.out.println("完成数量:" + plans[i].getOutnumber());
                System.out.println("剩余数量:" + (plans[i].getPlannumber() - plans[i].getOutnumber()));
                System.out.println("***********************************************************");
            }
        }
    }
    void Menu(){
        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("请输入操作选项:");
    }
    void runMenu(){
        do{
            Menu();
            int choice=sc.nextInt();
            sc.nextLine();// Consume newline
            switch(choice){
                case 1: GeneratePlanInformation() ;break;
                case 2: SubmitDailyReport();break;
                case 3: ConfirmDailyReport();break;
                case 4: NowProgress();break;
                default: System.out.println("该选项不存在,请你重新输入!");
            }
        }while(true);
    }
}
此外,继续对java课程内容进行学习。

标签:13,String,int,System,2024,plan,println,日志,out
From: https://www.cnblogs.com/MoonbeamsC/p/18413075

相关文章

  • Acunetix v24.8 - 29 Aug 2024 高级版漏洞扫描器(最新版) 附Windows/Linux下载链接
    前言AcunetixPremium是一种Web应用程序安全解决方案,用于管理多个网站、Web应用程序和API的安全。集成功能允许您自动化DevOps和问题管理基础架构。AcunetixPremium:全面的Web应用程序安全解决方案Web应用程序对于企业和组织与客户、合作伙伴和员工的联系至关......
  • 代码随想录算法训练营,9月13日 | 654.最大二叉树,617.合并二叉树,700.二叉搜索树中的搜索
    654.最大二叉树题目链接:654.最大二叉树文档讲解︰代码随想录(programmercarl.com)视频讲解︰最大二叉树日期:2024-09-13想法:根据昨天中后序列构造二叉树的经验,要找到数组中的最大值的位置,可以设置两个指针表示子树的范围(左闭右开)Java代码如下:classSolution{publicTreeNo......
  • 0913
    高数三重积分:投影穿线法(先dz,再dxdy);定限截面法(先dxdy,再dz)“后积先定限,限内画条线。先交写下线,后交写上限” 柱面坐标系法(P477),联想二重积分换元,换元要考虑“三换”,见P349球面坐标系法(P477) 三重积分换元法三换P478 重积分应用:求Ω体积;求Ω重心(质心)或型心;求引......
  • 2024.09.13练习总结
    没有参与比赛练习,所以没有赛时总结。$T1,T2$比较简单,似乎是签到题。$T3$题意不是很懂。首先将题目中的要求转换为人话:当两个区间有交,他们必须长度相同。注意到题目中说有$n$个人要上下电梯,且每站只会有一个人的状态改变。那么不难发现对于一段区间$[l,r]$......
  • 2024.9.13训练记录
    下午ARC104模拟短时赛:T1、T2:T1签到题。T2签到题,\(O(n^2)\)乱做。但是实际上可以空间换时间开桶到\(O(n)\)。也非常简单。T3:考场没有做出。思考的关键在于想到可以对于区间单独判断是否满足条件。知道了如何判断区间是否满足条件后,可以做一次\(O(n)\)的\(dp\)。每次枚......
  • CSP2024-19
    C题意:给定一棵树,定义简单路径\(x\toy\)是好的当且仅当\(x\)是路径中编号最小值,\(y\)是路径中编号最大值。\(n\le10^6\)。赛时双log做法:点分治,设路径端点\(x\)到分治之间的最小值为\(\min\),最大值为\(\max\)。如果\(x=\min\),A中加入二元组\((x,\max)\);\(x=......
  • 学习笔记 韩顺平 零基础30天学会Java(2024.9.13)
    P545TreeMap源码解读     TreeSet的k-v其中的v是一个静态的对象,但是TreeMap的v是可以变化的     TreeMap使用默认构造器取出的顺序和添加的顺序是不一样的,但是有构造器实现了Comparator接口的匿名内部类,可以按顺序排序P546Collections工具类1P547Collect......
  • 2024年09月随便做做
    测试题目选集2024/09/09qoj#8822.GuessTheSequence2给出长度为\(n\)的排列\(a\),需要选择一个\([1,n]\)上的一些子区间构成的集合,然后对于集合中的每个区间返回\(a\)上这段区间的\(a_i\)最大值。如果通过这些信息可以唯一确定排列\(a\),那么称这个集合是好的。需......
  • 8200-1312 蒸汽轮机数字调速器控制
    特性和功能集成图形前面板HMI屏幕多语言屏幕(包括中文),便于操作员使用、诊断和控制大屏幕允许轻松导航和图标查看参数和性能操作员和工程师可在本地查看实时趋势带有当前操作点视图的图形蒸汽图,用于提取和进入可配置的标签名称,可轻松识别连接内部“涡轮机模拟器”,用于在系统......
  • 基于SpringBoot的学生网上选课系统(11355)
     有需要的同学,源代码和配套文档领取,加文章最下方的名片哦一、项目演示项目演示视频二、资料介绍完整源代码(前后端源代码+SQL脚本)配套文档(LW+PPT+开题报告)远程调试控屏包运行三、技术介绍Java语言SSM框架SpringBoot框架Vue框架JSP页面Mysql数据库IDEA/Eclipse开发四、项......