updateData界面,功能完成

This commit is contained in:
huliang 2025-03-27 19:39:55 +08:00
parent 01bbf3e70c
commit 4db9712804
8 changed files with 9 additions and 120 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module name="solarInsertDB-rt" bajaVersion="0" vendor="MJM" vendorVersion="1.0" description="tsmc-solarInsertDB" preferredSymbol="mjmSolar" nre="true" autoload="true" installable="true" buildMillis="1742829288335" buildHost="WIN-VB61HI6M32L" moduleName="solarInsertDB" runtimeProfile="rt">
<module name="solarInsertDB-rt" bajaVersion="0" vendor="MJM" vendorVersion="1.0" description="tsmc-solarInsertDB" preferredSymbol="mjmSolar" nre="true" autoload="true" installable="true" buildMillis="1743074649620" buildHost="WIN-VB61HI6M32L" moduleName="solarInsertDB" runtimeProfile="rt">
<dependencies>
<dependency name="baja" vendor="Tridium" vendorVersion="4.10"/>
</dependencies>

View File

@ -23,11 +23,7 @@ import java.util.*;
{
@NiagaraProperty(name = "DatabaseInformation", type = "BDatabaseInformation", defaultValue = "new BDatabaseInformation()", flags = Flags.SUMMARY),
@NiagaraProperty(name = "disable", type = "boolean", defaultValue = "true", flags = Flags.SUMMARY),
// @NiagaraProperty(name = "exception", type = "boolean", defaultValue = "false", flags = Flags.SUMMARY),
// @NiagaraProperty(name = "working", type = "boolean", defaultValue = "false", flags = Flags.SUMMARY),
@NiagaraProperty(name = "showMessage", type = "boolean", defaultValue = "true", flags = Flags.SUMMARY),
// @NiagaraProperty(name = "path", type = "String", defaultValue = "", flags = Flags.SUMMARY),
// @NiagaraProperty(name = "fileName", type = "String", defaultValue = "", flags = Flags.SUMMARY)
@NiagaraProperty(name = "showMessage", type = "boolean", defaultValue = "true", flags = Flags.SUMMARY)
},
actions =
{

View File

@ -26,11 +26,7 @@ import java.util.*;
{
@NiagaraProperty(name = "DatabaseInformation", type = "BDatabaseInformation", defaultValue = "new BDatabaseInformation()", flags = Flags.SUMMARY),
@NiagaraProperty(name = "disable", type = "boolean", defaultValue = "true", flags = Flags.SUMMARY),
@NiagaraProperty(name = "exception", type = "boolean", defaultValue = "false", flags = Flags.SUMMARY),
@NiagaraProperty(name = "working", type = "boolean", defaultValue = "false", flags = Flags.SUMMARY),
@NiagaraProperty(name = "showMessage", type = "boolean", defaultValue = "true", flags = Flags.SUMMARY),
@NiagaraProperty(name = "path", type = "String", defaultValue = "", flags = Flags.SUMMARY),
@NiagaraProperty(name = "fileName", type = "String", defaultValue = "", flags = Flags.SUMMARY)
@NiagaraProperty(name = "showMessage", type = "boolean", defaultValue = "true", flags = Flags.SUMMARY)
},
actions =
{
@ -42,8 +38,8 @@ import java.util.*;
public class BUpdateData extends BComponent {
/*+ ------------ BEGIN BAJA AUTO GENERATED CODE ------------ +*/
/*@ $com.mjm.solarInsertDB.BUpdateData(2177564192)1.0$ @*/
/* Generated Mon Mar 10 19:48:33 CST 2025 by Slot-o-Matic (c) Tridium, Inc. 2012 */
/*@ $com.mjm.solarInsertDB.BUpdateData(3014327933)1.0$ @*/
/* Generated Wed Mar 26 21:11:32 CST 2025 by Slot-o-Matic (c) Tridium, Inc. 2012 */
////////////////////////////////////////////////////////////////
// Property "DatabaseInformation"
@ -91,52 +87,6 @@ public class BUpdateData extends BComponent {
*/
public void setDisable(boolean v) { setBoolean(disable, v, null); }
////////////////////////////////////////////////////////////////
// Property "exception"
////////////////////////////////////////////////////////////////
/**
* Slot for the {@code exception} property.
* @see #getException
* @see #setException
*/
public static final Property exception = newProperty(Flags.SUMMARY, false, null);
/**
* Get the {@code exception} property.
* @see #exception
*/
public boolean getException() { return getBoolean(exception); }
/**
* Set the {@code exception} property.
* @see #exception
*/
public void setException(boolean v) { setBoolean(exception, v, null); }
////////////////////////////////////////////////////////////////
// Property "working"
////////////////////////////////////////////////////////////////
/**
* Slot for the {@code working} property.
* @see #getWorking
* @see #setWorking
*/
public static final Property working = newProperty(Flags.SUMMARY, false, null);
/**
* Get the {@code working} property.
* @see #working
*/
public boolean getWorking() { return getBoolean(working); }
/**
* Set the {@code working} property.
* @see #working
*/
public void setWorking(boolean v) { setBoolean(working, v, null); }
////////////////////////////////////////////////////////////////
// Property "showMessage"
////////////////////////////////////////////////////////////////
@ -160,52 +110,6 @@ public class BUpdateData extends BComponent {
*/
public void setShowMessage(boolean v) { setBoolean(showMessage, v, null); }
////////////////////////////////////////////////////////////////
// Property "path"
////////////////////////////////////////////////////////////////
/**
* Slot for the {@code path} property.
* @see #getPath
* @see #setPath
*/
public static final Property path = newProperty(Flags.SUMMARY, "", null);
/**
* Get the {@code path} property.
* @see #path
*/
public String getPath() { return getString(path); }
/**
* Set the {@code path} property.
* @see #path
*/
public void setPath(String v) { setString(path, v, null); }
////////////////////////////////////////////////////////////////
// Property "fileName"
////////////////////////////////////////////////////////////////
/**
* Slot for the {@code fileName} property.
* @see #getFileName
* @see #setFileName
*/
public static final Property fileName = newProperty(Flags.SUMMARY, "", null);
/**
* Get the {@code fileName} property.
* @see #fileName
*/
public String getFileName() { return getString(fileName); }
/**
* Set the {@code fileName} property.
* @see #fileName
*/
public void setFileName(String v) { setString(fileName, v, null); }
////////////////////////////////////////////////////////////////
// Action "update"
////////////////////////////////////////////////////////////////
@ -250,6 +154,7 @@ public class BUpdateData extends BComponent {
BDatabaseInformation databaseInformation = null;
public void started() {
@ -278,13 +183,12 @@ public class BUpdateData extends BComponent {
List<String> conditionName = new ArrayList<String>();
List<String> conditionValue = new ArrayList<String>();
if (this.getDisable() || this.getException()) {
if (this.getDisable()) {
if (this.getShowMessage()) {
System.out.println("disable or exception");
}
} else {
try {
this.setWorking(true);
Property property[] = this.getDynamicPropertiesArray();
for (int i = 0; i < property.length; i++) {
@ -320,10 +224,8 @@ public class BUpdateData extends BComponent {
}
} catch (Exception e) {
System.out.println(e);
this.setException(true);
e.printStackTrace();
} finally {
this.setWorking(false);
}
}
} else {
@ -355,7 +257,7 @@ public class BUpdateData extends BComponent {
SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String strDate = sdFormat.format(date);
String outputFile = "../../shared/" + this.getPath() + strDate + this.getFileName();
String outputFile = "../../shared/";
// before we open the file check to see if it already exists
boolean alreadyExists = new File(outputFile).exists();
@ -363,15 +265,6 @@ public class BUpdateData extends BComponent {
// use FileWriter constructor that specifies open for appending
if (!alreadyExists) {
deleteFile();
if (!this.getPath().equals("")) {
File file = new File(outputFile);
file.getParentFile().mkdir();
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
CsvWriter csvOutput = new CsvWriter(new FileWriter(outputFile, true), ',');
@ -408,7 +301,7 @@ public class BUpdateData extends BComponent {
Date sDate = sdf.parse(before90);
long beforeTimestamp = sDate.getTime() / 1000;
// System.out.println(beforeTimestamp);
String fullpath = "../../shared/" + this.getPath();
String fullpath = "../../shared/";
File a = new File(fullpath);
if (a.isDirectory()) {
String[] filenames = a.list();