Browse Source

收支凭证性能优化

shenjingwei 4 months ago
parent
commit
3d2c044a96
1 changed files with 4 additions and 59 deletions
  1. 4 59
      src/custom/restcontroller/sale/cashbill/cashbill.java

+ 4 - 59
src/custom/restcontroller/sale/cashbill/cashbill.java

@@ -482,34 +482,7 @@ public class cashbill extends Controller {
             }
         }
         pageSorting = " sa_cashbillid desc";
-        int oldpageSize = pageSize;
-        Rows rows = queryList(where, 1, "新建", pageSize, pageNumber).query();
-        Rows checkRows = new Rows();
-
-        if (rows.size() < pageSize) {
-            if (rows.size() % pageSize == 0) {
-                checkRows = queryList(where, 1, "审核", pageSize, pageNumber - Double.valueOf(Math.ceil((double) rows.totalRows / (double) pageSize)).intValue()).query();
-            } else {
-                checkRows = queryList(where, 1, "审核", pageSize - rows.size(), pageNumber - Double.valueOf(Math.ceil((double) rows.totalRows / (double) pageSize)).intValue() + 1).query();
-            }
-        } else {
-            checkRows.totalRows = queryList(where, 1, "审核", 1, 1).query().totalRows;
-        }
-        Rows voidRows = new Rows();
-        if (rows.size() + checkRows.size() < pageSize) {
-            if ((rows.size() + checkRows.size()) % pageSize == 0) {
-                voidRows = queryList(where, 1, "作废", pageSize, pageNumber - Double.valueOf(Math.ceil((double) (rows.totalRows + checkRows.totalRows) / (double) pageSize)).intValue()).query();
-            } else {
-                voidRows = queryList(where, 1, "作废", pageSize - rows.size() - checkRows.size(), pageNumber - Double.valueOf(Math.ceil((double) (rows.totalRows + checkRows.totalRows) / (double) pageSize)).intValue() + 1).query();
-            }
-        } else {
-            voidRows.totalRows = queryList(where, 1, "作废", 1, 1).query().totalRows;
-        }
-        rows.pageSize = oldpageSize;
-        rows.addAll(checkRows);
-        rows.addAll(voidRows);
-        rows.totalRows = rows.totalRows + checkRows.totalRows + voidRows.totalRows;
-        rows.totalPage = Double.valueOf(Math.ceil((double) rows.totalRows / (double) pageSize)).longValue();
+        Rows rows = queryList(where, 1).query();
 
         SQLFactory areasqlFactory = new SQLFactory(this, "收支凭证关联区域列表查询");
         areasqlFactory.addParameter("siteid", siteid);
@@ -579,35 +552,7 @@ public class cashbill extends Controller {
         }
 
         pageSorting = " sa_cashbillid desc";
-        int oldpageSize = pageSize;
-        Rows rows = queryList(where, 0, "新建", pageSize, pageNumber).query();
-        Rows checkRows = new Rows();
-
-        if (rows.size() < pageSize) {
-            if (rows.size() % pageSize == 0) {
-                checkRows = queryList(where, 0, "审核", pageSize, pageNumber - Double.valueOf(Math.ceil((double) rows.totalRows / (double) pageSize)).intValue()).query();
-            } else {
-                checkRows = queryList(where, 0, "审核", pageSize - rows.size(), pageNumber - Double.valueOf(Math.ceil((double) rows.totalRows / (double) pageSize)).intValue() + 1).query();
-            }
-        } else {
-            checkRows.totalRows = queryList(where, 0, "审核", 1, 1).query().totalRows;
-        }
-        Rows voidRows = new Rows();
-        if (rows.size() + checkRows.size() < pageSize) {
-            if ((rows.size() + checkRows.size()) % pageSize == 0) {
-                voidRows = queryList(where, 0, "作废", pageSize, pageNumber - Double.valueOf(Math.ceil((double) (rows.totalRows + checkRows.totalRows) / (double) pageSize)).intValue()).query();
-            } else {
-                voidRows = queryList(where, 0, "作废", pageSize - rows.size() - checkRows.size(), pageNumber - Double.valueOf(Math.ceil((double) (rows.totalRows + checkRows.totalRows) / (double) pageSize)).intValue() + 1).query();
-            }
-        } else {
-            voidRows.totalRows = queryList(where, 0, "作废", 1, 1).query().totalRows;
-        }
-        rows.pageSize = oldpageSize;
-        rows.addAll(checkRows);
-        rows.addAll(voidRows);
-        rows.totalRows = rows.totalRows + checkRows.totalRows + voidRows.totalRows;
-        rows.totalPage = Double.valueOf(Math.ceil((double) rows.totalRows / (double) pageSize)).longValue();
-
+        Rows rows = queryList(where, 0).query();
 
         SQLFactory areasqlFactory = new SQLFactory(this, "收支凭证关联区域列表查询");
         areasqlFactory.addParameter("siteid", siteid);
@@ -626,7 +571,7 @@ public class cashbill extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    public QuerySQL queryList(String where, int type, String status, int pageSize, int pageNumber) throws YosException {
+    public QuerySQL queryList(String where, int type) throws YosException {
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "*").setTableAlias("t1");
         if (type == 1) {
             querySQL.addQueryFields("unwriteoffamount", "t1.amount - t1.writeoffamount");
@@ -635,7 +580,7 @@ public class cashbill extends Controller {
         querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t4.sys_enterpriseid = t2.sys_enterpriseid and t4.siteid = t2.siteid", "agentnum");
         querySQL.addJoinTable(JOINTYPE.left, "sa_accountclass", "t3", "t1.sa_accountclassid = t3.sa_accountclassid and t1.siteid = t3.siteid and t3.isused = 1", "accountno", "accountname");
         querySQL.setWhere(where);
-        querySQL.setWhere("t1.status", status);
+        querySQL.setWhere("t1.status");
         querySQL.setWhere("type", type);
         querySQL.setSiteid(siteid);
         querySQL.setOrderBy(pageSorting);