利辛自动化小程序

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 * 最低气温 0/10
*/ */
private String minTemperature; private String min_temperature;
/** /**
* 最高气温 0/10 * 最高气温 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() { 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; InputStreamReader in = null;
String xml = null; String xml = null;
try { try {
@ -92,24 +92,24 @@ public class LogAction extends JFrame implements MouseListener {
xstream.alias("log", LogBean.class); xstream.alias("log", LogBean.class);
LogBean bean = (LogBean) xstream.fromXML(xml); LogBean bean = (LogBean) xstream.fromXML(xml);
weatherJt.setText(bean.getWeather()); weatherJt.setText(bean.getWeather());
lowTemperatureJt.setText(bean.getMinTemperature()); lowTemperatureJt.setText(bean.getMin_temperature());
temperatureJt.setText(bean.getMaxTemperature()); temperatureJt.setText(bean.getMax_temperature());
eventDetectionTitleJt.setText(bean.getEventDetectionTitle()); eventDetectionTitleJt.setText(bean.getEvent_detection_title());
eventDetectionContentJt.setText(bean.getEventDetectionContent()); eventDetectionContentJt.setText(bean.getEvent_detection_content());
powerWorkTitleJt.setText(bean.getPowerWorkTitle()); powerWorkTitleJt.setText(bean.getPower_work_title());
powerWorkContentJt.setText(bean.getPowerWorkContent()); powerWorkContentJt.setText(bean.getPower_work_content());
resourceCheckTitleJt.setText(bean.getResourceCheckTitle()); resourceCheckTitleJt.setText(bean.getResource_check_title());
resourceCheckContentJt.setText(bean.getResourceCheckContent()); resourceCheckContentJt.setText(bean.getResource_check_content());
communicationsTestTitleJt.setText(bean.getCommunicationsTestTitle()); communicationsTestTitleJt.setText(bean.getCommunications_test_title());
communicationsTestContentJt.setText(bean.getCommunicationsTestContent()); communicationsTestContentJt.setText(bean.getCommunications_test_content());
dailyOperationTitleJt.setText(bean.getDailyOperationTitle()); dailyOperationTitleJt.setText(bean.getDaily_operation_title());
dailyOperationContentJt.setText(bean.getDailyOperationContent()); dailyOperationContentJt.setText(bean.getDaily_operation_content());
dailySubmissionTitleJt.setText(bean.getDailySubmissionTitle()); dailySubmissionTitleJt.setText(bean.getDaily_submission_title());
dailySubmissionContentJt.setText(bean.getDailySubmissionContent()); dailySubmissionContentJt.setText(bean.getDaily_submission_content());
warningDisposalTitleJt.setText(bean.getWarningDisposalTitle()); warningDisposalTitleJt.setText(bean.getWarning_disposal_title());
warningDisposalContentJt.setText(bean.getWarningDisposalContent()); warningDisposalContentJt.setText(bean.getWarning_disposal_content());
generalChroniclesTitleJt.setText(bean.getGeneralChroniclesTitle()); generalChroniclesTitleJt.setText(bean.getGeneral_chronicles_title());
generalChroniclesContentJt.setText(bean.getGeneralChroniclesContent()); 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); eventDetectionContentJt=new JTextArea(7,26);
Placeholder placeholder0 = new Placeholder(eventDetectionContentJt, "请输入事件检测内容..."); Placeholder placeholder0 = new Placeholder(eventDetectionContentJt, "请输入事件检测内容...");
eventDetectionContentJt.setLineWrap(true); //设置文本域中的文本为自动换行 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); powerWorkContentJt=new JTextArea(7,26);
Placeholder placeholder1 = new Placeholder(powerWorkContentJt, "请输入保电工作内容..."); Placeholder placeholder1 = new Placeholder(powerWorkContentJt, "请输入保电工作内容...");
powerWorkContentJt.setLineWrap(true); //设置文本域中的文本为自动换行 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); resourceCheckContentJt=new JTextArea(7,26);
Placeholder placeholder2 = new Placeholder(resourceCheckContentJt, "请输入资源核查情况内容..."); Placeholder placeholder2 = new Placeholder(resourceCheckContentJt, "请输入资源核查情况内容...");
resourceCheckContentJt.setLineWrap(true); //设置文本域中的文本为自动换行 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); communicationsTestContentJt=new JTextArea(7,26);
Placeholder placeholder3 = new Placeholder(communicationsTestContentJt, "请输入通信测试情况内容..."); 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); dailyOperationContentJt=new JTextArea(7,26);
Placeholder placeholder4 = new Placeholder(dailyOperationContentJt, "请输入日常操作情况内容..."); 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); dailySubmissionContentJt=new JTextArea(7,26);
Placeholder placeholder5 = new Placeholder(dailySubmissionContentJt, "请输入日报提报情况内容..."); 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); warningDisposalContentJt=new JTextArea(7,26);
Placeholder placeholder6 = new Placeholder(warningDisposalContentJt, "请输入预警处置内容..."); 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); generalChroniclesContentJt=new JTextArea(7,26);
Placeholder placeholder7 = new Placeholder(generalChroniclesContentJt, "请输入一般记事内容..."); Placeholder placeholder7 = new Placeholder(generalChroniclesContentJt, "请输入一般记事内容...");
@ -474,20 +530,28 @@ public class LogAction extends JFrame implements MouseListener {
jp.add(temperatureJt); jp.add(temperatureJt);
jp.add(eventDetectionLabel); jp.add(eventDetectionLabel);
jp.add(eventDetectionTitleJt); jp.add(eventDetectionTitleJt);
// jp.add(eventDetectionContentJt);
jp.add(powerWorkLabel); jp.add(powerWorkLabel);
jp.add(powerWorkTitleJt); jp.add(powerWorkTitleJt);
// jp.add(powerWorkContentJt);
jp.add(resourceCheckLabel); jp.add(resourceCheckLabel);
jp.add(resourceCheckTitleJt); jp.add(resourceCheckTitleJt);
// jp.add(resourceCheckContentJt);
jp.add(communicationsTestLabel); jp.add(communicationsTestLabel);
jp.add(communicationsTestTitleJt); jp.add(communicationsTestTitleJt);
// jp.add(communicationsTestContentJt);
jp.add(dailyOperationLabel); jp.add(dailyOperationLabel);
jp.add(dailyOperationTitleJt); jp.add(dailyOperationTitleJt);
// jp.add(dailyOperationContentJt);
jp.add(dailySubmissionLabel); jp.add(dailySubmissionLabel);
jp.add(dailySubmissionTitleJt); jp.add(dailySubmissionTitleJt);
// jp.add(dailySubmissionContentJt);
jp.add(warningDisposalLabel); jp.add(warningDisposalLabel);
jp.add(warningDisposalTitleJt); jp.add(warningDisposalTitleJt);
// jp.add(warningDisposalContentJt);
jp.add(generalChroniclesLabel); jp.add(generalChroniclesLabel);
jp.add(generalChroniclesTitleJt); jp.add(generalChroniclesTitleJt);
// jp.add(generalChroniclesContentJt);
jp.add(btn); jp.add(btn);
return jp; return jp;
} }
@ -520,24 +584,24 @@ public class LogAction extends JFrame implements MouseListener {
private LogBean getLogBean() { private LogBean getLogBean() {
LogBean bean = new LogBean(); LogBean bean = new LogBean();
bean.setWeather(weatherJt.getText()); bean.setWeather(weatherJt.getText());
bean.setMinTemperature(lowTemperatureJt.getText()); bean.setMin_temperature(lowTemperatureJt.getText());
bean.setMaxTemperature(temperatureJt.getText()); bean.setMax_temperature(temperatureJt.getText());
bean.setEventDetectionTitle(eventDetectionTitleJt.getText()); bean.setEvent_detection_title(eventDetectionTitleJt.getText());
bean.setEventDetectionContent(eventDetectionContentJt.getText()); bean.setEvent_detection_content(eventDetectionContentJt.getText());
bean.setPowerWorkTitle(powerWorkTitleJt.getText()); bean.setPower_work_title(powerWorkTitleJt.getText());
bean.setPowerWorkContent(powerWorkContentJt.getText()); bean.setPower_work_content(powerWorkContentJt.getText());
bean.setResourceCheckTitle(resourceCheckTitleJt.getText()); bean.setResource_check_title(resourceCheckTitleJt.getText());
bean.setResourceCheckContent(resourceCheckContentJt.getText()); bean.setResource_check_content(resourceCheckContentJt.getText());
bean.setCommunicationsTestTitle(communicationsTestTitleJt.getText()); bean.setCommunications_test_title(communicationsTestTitleJt.getText());
bean.setCommunicationsTestContent(communicationsTestContentJt.getText()); bean.setCommunications_test_content(communicationsTestContentJt.getText());
bean.setDailyOperationTitle(dailyOperationTitleJt.getText()); bean.setDaily_operation_title(dailyOperationTitleJt.getText());
bean.setDailyOperationContent(dailyOperationContentJt.getText()); bean.setDaily_operation_content(dailyOperationContentJt.getText());
bean.setDailySubmissionTitle(dailySubmissionTitleJt.getText()); bean.setDaily_submission_title(dailySubmissionTitleJt.getText());
bean.setDailySubmissionContent(dailySubmissionContentJt.getText()); bean.setDaily_submission_content(dailySubmissionContentJt.getText());
bean.setWarningDisposalTitle(warningDisposalTitleJt.getText()); bean.setWarning_disposal_title(warningDisposalTitleJt.getText());
bean.setWarningDisposalContent(warningDisposalContentJt.getText()); bean.setWarning_disposal_content(warningDisposalContentJt.getText());
bean.setGeneralChroniclesTitle(generalChroniclesTitleJt.getText()); bean.setGeneral_chronicles_title(generalChroniclesTitleJt.getText());
bean.setGeneralChroniclesContent(generalChroniclesContentJt.getText()); bean.setGeneral_chronicles_content(generalChroniclesContentJt.getText());
return bean; return bean;
} }
@ -549,7 +613,7 @@ public class LogAction extends JFrame implements MouseListener {
try { try {
xml = xstream.toXML(logBean); xml = xstream.toXML(logBean);
// 将XML字符串写入文件并指定字符编码为UTF-8 // 将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"); OutputStreamWriter writer = new OutputStreamWriter(fos, "GBK");
writer.write(xml); writer.write(xml);
writer.close(); writer.close();
@ -557,7 +621,7 @@ public class LogAction extends JFrame implements MouseListener {
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(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); JOptionPane.showMessageDialog(jp, "日志保存成功!", "提示", 1);
System.exit(0); System.exit(0);
} }