Browse Source

代码调整

wu 2 weeks ago
parent
commit
fb45968a02

+ 18 - 3
src/custom/restcontroller/webmanage/sale/salestarget2/salestargetbill.java

@@ -36,9 +36,9 @@ public class salestargetbill extends Controller {
 
         if (sa_salestargetbillid <= 0) {
 
-            if (dbConnect.runSqlQuery("SELECT * from sa_salestargetbill WHERE createuserid=" + userid + " and year='" + year + "' and sa_customersid=" + sa_customersid + " and siteid='" + siteid + "'").isNotEmpty()) {
-                throw new YosException("数据已存在");
-            }
+//            if (dbConnect.runSqlQuery("SELECT * from sa_salestargetbill WHERE createuserid=" + userid + " and year='" + year + "' and sa_customersid=" + sa_customersid + " and siteid='" + siteid + "'").isNotEmpty()) {
+//                throw new YosException("数据已存在");
+//            }
 
             sa_salestargetbillid = createTableID("sa_salestargetbill");
             InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_salestargetbill");
@@ -278,6 +278,21 @@ public class salestargetbill extends Controller {
             DataContrlLog.createLog(this, "sa_salestargetbill", Long.parseLong(sa_salestargetbillid.toString()), "审核", "审核成功");
         }
 
+        for (Object obj : sa_salestargetbillids) {
+            String sql = " SELECT * from sa_salestargetbill t1 " +
+                    " WHERE EXISTS (SELECT * from sa_salestargetbill WHERE sa_salestargetbillid=" + obj + " and t1.createuserid=createuserid and t1.sa_customersid=sa_customersid and t1.year=year )" +
+                    " and sa_salestargetbillid!=" + obj + " and t1.siteid='" + siteid + "'";
+            Rows rows = dbConnect.runSqlQuery(sql);
+            updateSQL = SQLFactory.createUpdateSQL(this, "sa_salestargetbill");
+            updateSQL.setSiteid(siteid);
+            updateSQL.setWhere("sa_salestargetbillid", rows.toArrayList("sa_salestargetbillid"));
+            updateSQL.setValue("status", "失效");
+            updateSQL.update();
+            for (Row row : rows) {
+                DataContrlLog.createLog(this, "sa_salestargetbill", row.getLong("sa_salestargetbillid"), "自动失效", "自动失效成功");
+            }
+        }
+
         return getSucReturnObject().toString();
     }