|
|
@@ -8,8 +8,9 @@ import common.data.Rows;
|
|
|
import common.data.SQLFactory;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
|
|
|
- public class AutoCreateSurgeryForecast extends ServiceController {
|
|
|
+public class AutoCreateSurgeryForecast extends ServiceController {
|
|
|
@Override
|
|
|
public void serviceRun() throws Exception {
|
|
|
currentyear();
|
|
|
@@ -17,12 +18,14 @@ import java.util.ArrayList;
|
|
|
}
|
|
|
|
|
|
public void currentyear() throws YosException {
|
|
|
- Rows rows = dbConnect.runSqlQuery("SELECT siteid,sa_customersid,year(current_date) nextyear from sa_customers ");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT siteid,sa_customersid from sa_customers as t");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
for (Row row : rows) {
|
|
|
String siteid = row.getString("siteid");
|
|
|
Long sa_customersid = row.getLong("sa_customersid");
|
|
|
- String nextyear = row.getString("nextyear");
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(dbConnect, "sa_surgeryforecast");
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
insertSQL.setValue("sa_customersid", sa_customersid);
|
|
|
@@ -32,8 +35,8 @@ import java.util.ArrayList;
|
|
|
insertSQL.setValue("changeuserid", 1);
|
|
|
insertSQL.setValue("changeby", "admin");
|
|
|
insertSQL.setValue("changedate", getDateTime_Str());
|
|
|
- insertSQL.setValue("year", nextyear);
|
|
|
- insertSQL.setWhere(" not exists(select 1 from sa_surgeryforecast where siteid='" + siteid + "' and year=" + nextyear + " and sa_customersid='" + sa_customersid + "')");
|
|
|
+ insertSQL.setValue("year", year);
|
|
|
+ insertSQL.setWhere(" not exists(select 1 from sa_surgeryforecast where siteid='" + siteid + "' and year='" + year + "' and sa_customersid='" + sa_customersid + "')");
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|