利辛自动化小程序

This commit is contained in:
jjLv 2024-09-30 15:11:40 +08:00
parent de9658eaaf
commit ef91abf44d
2 changed files with 122 additions and 58 deletions

View File

@ -18,91 +18,91 @@ public class LogBean implements Serializable {
/**
* 最低气温 0/10
*/
private String minTemperature;
private String min_temperature;
/**
* 最高气温 0/10
*/
private String maxTemperature;
private String max_temperature;
/**
* 事件检测标题
*/
private String eventDetectionTitle;
private String event_detection_title;
/**
* 事件检测内容
*/
private String eventDetectionContent;
private String event_detection_content;
/**
* 保电工作标题
*/
private String powerWorkTitle;
private String power_work_title;
/**
* 保电工作内容
*/
private String powerWorkContent;
private String power_work_content;
/**
* 资源核查情况标题
*/
private String resourceCheckTitle;
private String resource_check_title;
/**
* 资源核查情况内容
*/
private String resourceCheckContent;
private String resource_check_content;
/**
* 通信测试标题
*/
private String communicationsTestTitle;
private String communications_test_title;
/**
* 通信测试内容
*/
private String communicationsTestContent;
private String communications_test_content;
/**
* 日常操作情况标题
*/
private String dailyOperationTitle;
private String daily_operation_title;
/**
* 日常操作情况内容
*/
private String dailyOperationContent;
private String daily_operation_content;
/**
* 日报提报情况标题
*/
private String dailySubmissionTitle;
private String daily_submission_title;
/**
* 日报提报情况内容
*/
private String dailySubmissionContent;
private String daily_submission_content;
/**
* 预警处置标题
*/
private String warningDisposalTitle;
private String warning_disposal_title;
/**
* 预警处置内容
*/
private String warningDisposalContent;
private String warning_disposal_content;
/**
* 一般记事标题
*/
private String generalChroniclesTitle;
private String general_chronicles_title;
/**
* 一般记事内容
*/
private String generalChroniclesContent;
private String general_chronicles_content;
}

View File

@ -67,9 +67,9 @@ public class LogAction extends JFrame implements MouseListener {
}
private void initData() {
if (new File(DataConfig.FILE_PATH + "\\log.xml").exists()) {
if (new File(DataConfig.filePath + "\\log.xml").exists()) {
// 反序列化--> 解决乱码问题
File file = new File(DataConfig.FILE_PATH + "\\log.xml");
File file = new File(DataConfig.filePath + "\\log.xml");
InputStreamReader in = null;
String xml = null;
try {
@ -92,24 +92,24 @@ public class LogAction extends JFrame implements MouseListener {
xstream.alias("log", LogBean.class);
LogBean bean = (LogBean) xstream.fromXML(xml);
weatherJt.setText(bean.getWeather());
lowTemperatureJt.setText(bean.getMinTemperature());
temperatureJt.setText(bean.getMaxTemperature());
eventDetectionTitleJt.setText(bean.getEventDetectionTitle());
eventDetectionContentJt.setText(bean.getEventDetectionContent());
powerWorkTitleJt.setText(bean.getPowerWorkTitle());
powerWorkContentJt.setText(bean.getPowerWorkContent());
resourceCheckTitleJt.setText(bean.getResourceCheckTitle());
resourceCheckContentJt.setText(bean.getResourceCheckContent());
communicationsTestTitleJt.setText(bean.getCommunicationsTestTitle());
communicationsTestContentJt.setText(bean.getCommunicationsTestContent());
dailyOperationTitleJt.setText(bean.getDailyOperationTitle());
dailyOperationContentJt.setText(bean.getDailyOperationContent());
dailySubmissionTitleJt.setText(bean.getDailySubmissionTitle());
dailySubmissionContentJt.setText(bean.getDailySubmissionContent());
warningDisposalTitleJt.setText(bean.getWarningDisposalTitle());
warningDisposalContentJt.setText(bean.getWarningDisposalContent());
generalChroniclesTitleJt.setText(bean.getGeneralChroniclesTitle());
generalChroniclesContentJt.setText(bean.getGeneralChroniclesContent());
lowTemperatureJt.setText(bean.getMin_temperature());
temperatureJt.setText(bean.getMax_temperature());
eventDetectionTitleJt.setText(bean.getEvent_detection_title());
eventDetectionContentJt.setText(bean.getEvent_detection_content());
powerWorkTitleJt.setText(bean.getPower_work_title());
powerWorkContentJt.setText(bean.getPower_work_content());
resourceCheckTitleJt.setText(bean.getResource_check_title());
resourceCheckContentJt.setText(bean.getResource_check_content());
communicationsTestTitleJt.setText(bean.getCommunications_test_title());
communicationsTestContentJt.setText(bean.getCommunications_test_content());
dailyOperationTitleJt.setText(bean.getDaily_operation_title());
dailyOperationContentJt.setText(bean.getDaily_operation_content());
dailySubmissionTitleJt.setText(bean.getDaily_submission_title());
dailySubmissionContentJt.setText(bean.getDaily_submission_content());
warningDisposalTitleJt.setText(bean.getWarning_disposal_title());
warningDisposalContentJt.setText(bean.getWarning_disposal_content());
generalChroniclesTitleJt.setText(bean.getGeneral_chronicles_title());
generalChroniclesContentJt.setText(bean.getGeneral_chronicles_content());
}
}
@ -196,6 +196,13 @@ public class LogAction extends JFrame implements MouseListener {
/**
* 事件检测内容输入框
*/
// eventDetectionContentJt = new JTextField();
// setTextFiledColor(eventDetectionContentJt);
// int eventDetectionContentJtY = eventDetectionJly + 120;
// eventDetectionContentJt.setBounds(eventDetectionJlx, eventDetectionContentJtY, 1310, 120);
// if (StringHelper.isEmptyAndNull(eventDetectionContentJt.getText())) {
// eventDetectionContentJt.addFocusListener(new MyFocusListener("请输入事件检测内容", eventDetectionContentJt));
// }
eventDetectionContentJt=new JTextArea(7,26);
Placeholder placeholder0 = new Placeholder(eventDetectionContentJt, "请输入事件检测内容...");
eventDetectionContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
@ -232,6 +239,13 @@ public class LogAction extends JFrame implements MouseListener {
/**
* 保电工作内容输入框
*/
// powerWorkContentJt = new JTextField();
// setTextFiledColor(powerWorkContentJt);
//
// powerWorkContentJt.setBounds(powerWorkJlx, powerWorkContentJtY, 1310, 120);
// if (StringHelper.isEmptyAndNull(powerWorkContentJt.getText())) {
// powerWorkContentJt.addFocusListener(new MyFocusListener("请输入保电工作内容", powerWorkContentJt));
// }
powerWorkContentJt=new JTextArea(7,26);
Placeholder placeholder1 = new Placeholder(powerWorkContentJt, "请输入保电工作内容...");
powerWorkContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
@ -267,6 +281,13 @@ public class LogAction extends JFrame implements MouseListener {
/**
* 资源核查情况内容输入框
*/
// resourceCheckContentJt = new JTextField();
// setTextFiledColor(resourceCheckContentJt);
// int resourceCheckContentJtY = resourceCheckJly + 120;
// resourceCheckContentJt.setBounds(resourceCheckJlx, resourceCheckContentJtY, 1310, 120);
// if (StringHelper.isEmptyAndNull(resourceCheckContentJt.getText())) {
// resourceCheckContentJt.addFocusListener(new MyFocusListener("请输入资源核查情况内容", resourceCheckContentJt));
// }
resourceCheckContentJt=new JTextArea(7,26);
Placeholder placeholder2 = new Placeholder(resourceCheckContentJt, "请输入资源核查情况内容...");
resourceCheckContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
@ -301,6 +322,13 @@ public class LogAction extends JFrame implements MouseListener {
/**
* 通信测试情况内容输入框
*/
// communicationsTestContentJt = new JTextField();
// setTextFiledColor(communicationsTestContentJt);
// int communicationsTestContentJtY = communicationsTestJly + 120;
// communicationsTestContentJt.setBounds(communicationsTestJlx, communicationsTestContentJtY, 1310, 120);
// if (StringHelper.isEmptyAndNull(communicationsTestContentJt.getText())) {
// communicationsTestContentJt.addFocusListener(new MyFocusListener("请输入通信测试情况内容", communicationsTestContentJt));
// }
communicationsTestContentJt=new JTextArea(7,26);
Placeholder placeholder3 = new Placeholder(communicationsTestContentJt, "请输入通信测试情况内容...");
@ -337,6 +365,13 @@ public class LogAction extends JFrame implements MouseListener {
/**
* 日常操作情况内容输入框
*/
// dailyOperationContentJt = new JTextField();
// setTextFiledColor(dailyOperationContentJt);
// int dailyOperationContentJtY = dailyOperationJly + 120;
// dailyOperationContentJt.setBounds(dailyOperationJlx, dailyOperationContentJtY, 1310, 120);
// if (StringHelper.isEmptyAndNull(dailyOperationContentJt.getText())) {
// dailyOperationContentJt.addFocusListener(new MyFocusListener("请输入日常操作情况内容", dailyOperationContentJt));
// }
dailyOperationContentJt=new JTextArea(7,26);
Placeholder placeholder4 = new Placeholder(dailyOperationContentJt, "请输入日常操作情况内容...");
@ -373,6 +408,13 @@ public class LogAction extends JFrame implements MouseListener {
/**
* 日报提报情况内容输入框
*/
// dailySubmissionContentJt = new JTextField();
// setTextFiledColor(dailySubmissionContentJt);
// int dailySubmissionContentJtY = dailySubmissionJly + 120;
// dailySubmissionContentJt.setBounds(dailySubmissionJlx, dailySubmissionContentJtY, 1310, 120);
// if (StringHelper.isEmptyAndNull(dailySubmissionContentJt.getText())) {
// dailySubmissionContentJt.addFocusListener(new MyFocusListener("请输入日报提报情况内容", dailySubmissionContentJt));
// }
dailySubmissionContentJt=new JTextArea(7,26);
Placeholder placeholder5 = new Placeholder(dailySubmissionContentJt, "请输入日报提报情况内容...");
@ -409,6 +451,13 @@ public class LogAction extends JFrame implements MouseListener {
/**
* 预警处置内容输入框
*/
// warningDisposalContentJt = new JTextField();
// setTextFiledColor(warningDisposalContentJt);
// int warningDisposalContentJtY = warningDisposalJly + 120;
// warningDisposalContentJt.setBounds(warningDisposalJlx, warningDisposalContentJtY, 1310, 120);
// if (StringHelper.isEmptyAndNull(warningDisposalContentJt.getText())) {
// warningDisposalContentJt.addFocusListener(new MyFocusListener("请输入预警处置内容", warningDisposalContentJt));
// }
warningDisposalContentJt=new JTextArea(7,26);
Placeholder placeholder6 = new Placeholder(warningDisposalContentJt, "请输入预警处置内容...");
@ -445,6 +494,13 @@ public class LogAction extends JFrame implements MouseListener {
/**
* 一般记事内容输入框
*/
// generalChroniclesContentJt = new JTextField();
// setTextFiledColor(generalChroniclesContentJt);
// int generalChroniclesContentJtY = generalChroniclesJly + 120;
// generalChroniclesContentJt.setBounds(generalChroniclesJlx, generalChroniclesContentJtY, 1310, 120);
// if (StringHelper.isEmptyAndNull(generalChroniclesContentJt.getText())) {
// generalChroniclesContentJt.addFocusListener(new MyFocusListener("请输入一般记事内容", generalChroniclesContentJt));
// }
generalChroniclesContentJt=new JTextArea(7,26);
Placeholder placeholder7 = new Placeholder(generalChroniclesContentJt, "请输入一般记事内容...");
@ -474,20 +530,28 @@ public class LogAction extends JFrame implements MouseListener {
jp.add(temperatureJt);
jp.add(eventDetectionLabel);
jp.add(eventDetectionTitleJt);
// jp.add(eventDetectionContentJt);
jp.add(powerWorkLabel);
jp.add(powerWorkTitleJt);
// jp.add(powerWorkContentJt);
jp.add(resourceCheckLabel);
jp.add(resourceCheckTitleJt);
// jp.add(resourceCheckContentJt);
jp.add(communicationsTestLabel);
jp.add(communicationsTestTitleJt);
// jp.add(communicationsTestContentJt);
jp.add(dailyOperationLabel);
jp.add(dailyOperationTitleJt);
// jp.add(dailyOperationContentJt);
jp.add(dailySubmissionLabel);
jp.add(dailySubmissionTitleJt);
// jp.add(dailySubmissionContentJt);
jp.add(warningDisposalLabel);
jp.add(warningDisposalTitleJt);
// jp.add(warningDisposalContentJt);
jp.add(generalChroniclesLabel);
jp.add(generalChroniclesTitleJt);
// jp.add(generalChroniclesContentJt);
jp.add(btn);
return jp;
}
@ -520,24 +584,24 @@ public class LogAction extends JFrame implements MouseListener {
private LogBean getLogBean() {
LogBean bean = new LogBean();
bean.setWeather(weatherJt.getText());
bean.setMinTemperature(lowTemperatureJt.getText());
bean.setMaxTemperature(temperatureJt.getText());
bean.setEventDetectionTitle(eventDetectionTitleJt.getText());
bean.setEventDetectionContent(eventDetectionContentJt.getText());
bean.setPowerWorkTitle(powerWorkTitleJt.getText());
bean.setPowerWorkContent(powerWorkContentJt.getText());
bean.setResourceCheckTitle(resourceCheckTitleJt.getText());
bean.setResourceCheckContent(resourceCheckContentJt.getText());
bean.setCommunicationsTestTitle(communicationsTestTitleJt.getText());
bean.setCommunicationsTestContent(communicationsTestContentJt.getText());
bean.setDailyOperationTitle(dailyOperationTitleJt.getText());
bean.setDailyOperationContent(dailyOperationContentJt.getText());
bean.setDailySubmissionTitle(dailySubmissionTitleJt.getText());
bean.setDailySubmissionContent(dailySubmissionContentJt.getText());
bean.setWarningDisposalTitle(warningDisposalTitleJt.getText());
bean.setWarningDisposalContent(warningDisposalContentJt.getText());
bean.setGeneralChroniclesTitle(generalChroniclesTitleJt.getText());
bean.setGeneralChroniclesContent(generalChroniclesContentJt.getText());
bean.setMin_temperature(lowTemperatureJt.getText());
bean.setMax_temperature(temperatureJt.getText());
bean.setEvent_detection_title(eventDetectionTitleJt.getText());
bean.setEvent_detection_content(eventDetectionContentJt.getText());
bean.setPower_work_title(powerWorkTitleJt.getText());
bean.setPower_work_content(powerWorkContentJt.getText());
bean.setResource_check_title(resourceCheckTitleJt.getText());
bean.setResource_check_content(resourceCheckContentJt.getText());
bean.setCommunications_test_title(communicationsTestTitleJt.getText());
bean.setCommunications_test_content(communicationsTestContentJt.getText());
bean.setDaily_operation_title(dailyOperationTitleJt.getText());
bean.setDaily_operation_content(dailyOperationContentJt.getText());
bean.setDaily_submission_title(dailySubmissionTitleJt.getText());
bean.setDaily_submission_content(dailySubmissionContentJt.getText());
bean.setWarning_disposal_title(warningDisposalTitleJt.getText());
bean.setWarning_disposal_content(warningDisposalContentJt.getText());
bean.setGeneral_chronicles_title(generalChroniclesTitleJt.getText());
bean.setGeneral_chronicles_content(generalChroniclesContentJt.getText());
return bean;
}
@ -549,7 +613,7 @@ public class LogAction extends JFrame implements MouseListener {
try {
xml = xstream.toXML(logBean);
// 将XML字符串写入文件并指定字符编码为UTF-8
FileOutputStream fos = new FileOutputStream(DataConfig.FILE_PATH + "\\log.xml");
FileOutputStream fos = new FileOutputStream(DataConfig.filePath + "\\log.xml");
OutputStreamWriter writer = new OutputStreamWriter(fos, "GBK");
writer.write(xml);
writer.close();
@ -557,7 +621,7 @@ public class LogAction extends JFrame implements MouseListener {
} catch (IOException e) {
throw new RuntimeException(e);
}
if (new File(DataConfig.FILE_PATH + "\\log.xml").exists()) {
if (new File(DataConfig.filePath + "\\log.xml").exists()) {
JOptionPane.showMessageDialog(jp, "日志保存成功!", "提示", 1);
System.exit(0);
}