Sfoglia il codice sorgente

创建年度任务逻辑调整

wu 1 settimana fa
parent
commit
abbf3a2e19
1 ha cambiato i file con 29 aggiunte e 1 eliminazioni
  1. 29 1
      src/custom/service/AutoCreateSurgeryForecast.java

+ 29 - 1
src/custom/service/AutoCreateSurgeryForecast.java

@@ -1,6 +1,7 @@
 package service;
 
 import common.ServiceController;
+import common.YosException;
 import common.data.InsertSQL;
 import common.data.Row;
 import common.data.Rows;
@@ -11,8 +12,13 @@ import java.util.ArrayList;
 public class AutoCreateSurgeryForecast extends ServiceController {
     @Override
     public void serviceRun() throws Exception {
+        currentyear();
+        nextyear();
 
-        Rows rows = dbConnect.runSqlQuery("SELECT siteid,sa_customersid,year(current_date)+1 nextyear from sa_customers ");
+    }
+
+    public void currentyear() throws YosException {
+        Rows rows = dbConnect.runSqlQuery("SELECT siteid,sa_customersid,year(current_date) nextyear from sa_customers ");
         ArrayList<String> sqlList = new ArrayList<>();
         for (Row row : rows) {
             String siteid = row.getString("siteid");
@@ -32,7 +38,29 @@ public class AutoCreateSurgeryForecast extends ServiceController {
             sqlList.add(insertSQL.getSQL());
         }
         dbConnect.runSqlUpdate(sqlList);
+    }
 
+    public void nextyear() throws YosException {
+        Rows rows = dbConnect.runSqlQuery("SELECT siteid,sa_customersid,year(current_date)+1 nextyear from sa_customers ");
+        ArrayList<String> sqlList = new ArrayList<>();
+        for (Row row : rows) {
+            String siteid = row.getString("siteid");
+            Long sa_customersid = row.getLong("sa_customersid");
+            int nextyear = row.getInteger("nextyear");
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(dbConnect, "sa_surgeryforecast");
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("sa_customersid", sa_customersid);
+            insertSQL.setValue("createuserid", "1");
+            insertSQL.setValue("createby", "admin");
+            insertSQL.setValue("createdate", getDateTime_Str());
+            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 + "')");
+            sqlList.add(insertSQL.getSQL());
+        }
+        dbConnect.runSqlUpdate(sqlList);
     }