Ver Fonte

Merge remote-tracking branch 'origin/develop' into develop

沈静伟 há 2 anos atrás
pai
commit
32390c9d0d
22 ficheiros alterados com 175 adições e 109 exclusões
  1. 3 3
      src/custom/restcontroller/sale/cashbill/SQL/资金流水账查询导出.sql
  2. 4 3
      src/custom/restcontroller/sale/cashbill/cashbill.java
  3. 1 1
      src/custom/restcontroller/sale/order/Order.java
  4. 16 6
      src/custom/restcontroller/webmanage/lsak3/aftersalesmag/aftersalesmag.java
  5. 1 1
      src/custom/restcontroller/webmanage/lsak3/agents/agents.java
  6. 20 20
      src/custom/restcontroller/webmanage/lsak3/cashbill/cashbill.java
  7. 14 6
      src/custom/restcontroller/webmanage/lsak3/dispatch/dispatch.java
  8. 3 3
      src/custom/restcontroller/webmanage/lsak3/item/item.java
  9. 2 2
      src/custom/restcontroller/webmanage/lsak3/itemPrice/itemPrice.java
  10. 1 1
      src/custom/restcontroller/webmanage/lsak3/order/order.java
  11. 8 8
      src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java
  12. 10 1
      src/custom/restcontroller/webmanage/sale/accountclass/SQL/营销大类列表查询.sql
  13. 1 1
      src/custom/restcontroller/webmanage/sale/databoard/SQL/订货额类别统计分析.sql
  14. 32 28
      src/custom/restcontroller/webmanage/sale/databoard/databoard.java
  15. 0 4
      src/custom/restcontroller/webmanage/sale/dispatch/SQL/发货单列表查询.sql
  16. 1 1
      src/custom/restcontroller/webmanage/sale/dispatch/SQL/商品发货数量汇总.sql
  17. 24 11
      src/custom/restcontroller/webmanage/sale/dispatch/dispatch.java
  18. 2 0
      src/custom/restcontroller/webmanage/sale/dispatch/dispatchItems.java
  19. 17 0
      src/custom/restcontroller/webmanage/sale/item/Item.java
  20. 1 1
      src/custom/restcontroller/webmanage/sale/order/Order.java
  21. 2 2
      src/custom/restcontroller/webmanage/sale/order/OrderItems.java
  22. 12 6
      src/custom/restcontroller/webmanage/sale/rebateaccount/rebateaccounthead.java

+ 3 - 3
src/custom/restcontroller/sale/cashbill/SQL/资金流水账查询导出.sql

@@ -4,10 +4,10 @@ select t1.billno,
        t4.accountname,
        t1.amount,
        ifnull(t1.balance,0) balance,
-       t1.remarks,
        t1.source,
-       t1.createby,
-       t1.createdate,
+       t1.class,
+       t1.subclass,
+       t1.remarks,
        t1.checkby,
        t1.checkdate 
 from sa_cashbill t1

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

@@ -935,8 +935,6 @@ public class cashbill extends Controller {
         if (isExport) {
             //去除不需要导出项
             rows.getFieldList().remove("sa_accountclassid");
-            rows.getFieldList().remove("createby");
-            rows.getFieldList().remove("createdate");
             Rows uploadRows = uploadExcelToObs("cashBill", "资金流水账列表", rows, getTitleMap());
             return getSucReturnObject().setData(uploadRows).toString();
         }
@@ -1157,9 +1155,12 @@ public class cashbill extends Controller {
         titleMap.put("amount", "收支金额");
         titleMap.put("balance", "账户结余");
         titleMap.put("source", "凭证来源");
+        titleMap.put("class", "分类");
+        titleMap.put("subclass", "分类明细");
+        titleMap.put("remarks", "备注");
         titleMap.put("checkby", "审核人");
         titleMap.put("checkdate", "审核时间");
-        titleMap.put("remarks", "备注");
+
         return titleMap;
     }
 }

+ 1 - 1
src/custom/restcontroller/sale/order/Order.java

@@ -102,7 +102,7 @@ public class Order extends Controller {
             Rows uploadRows = uploadExcelToObs("order", "订单列表", rows, getTitleMap());
             return getSucReturnObject().setData(uploadRows).toString();
         }
-        if (systemclient.equals("web")) {
+        if (systemclient.equalsIgnoreCase("web")) {
             return getSucReturnObject().setData(rows).toString();
         }
 

+ 16 - 6
src/custom/restcontroller/webmanage/lsak3/aftersalesmag/aftersalesmag.java

@@ -7,6 +7,7 @@ import common.YosException;
 import common.annotation.API;
 import common.data.Row;
 import common.data.Rows;
+import common.data.RowsMap;
 import restcontroller.R;
 
 import java.util.ArrayList;
@@ -28,15 +29,24 @@ public class aftersalesmag extends Controller {
     @API(title = "获取DRP返退单", apiversion = R.ID20230715093903.v1.class,accesstoken = false)
     public String getAftersalesmag() throws YosException{
         Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.sa_aftersalesmagid salereturnbillid,t1.billno fbillnum,t1.createby,ifnull(t1.billdate,CURRENT_DATE) fdate,t2.agentnum fagentnum,t1.reason fnotes from sa_aftersalesmag t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001' and t1.siteid='lsa1986'");
-        for (Row row : rows) {
-            String sa_aftersalesmagid = row.getString("sa_aftersalesmagid");
-            Rows detailRows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.st_stockbill_itemsid salereturnbilldeid,t2.itemno fitemno,t1.qty fqty,t1.price fprice,t1.reason fnotes,t4.billno fsaleissuebillno, t3.rowno fsaleissuebillentryid from sa_aftersalesmag_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join st_stockbill_items t3 on t1.st_stockbill_itemsid=t3.st_stockbill_itemsid and t1.siteid=t3.siteid left join st_stockbill t4 on t3.st_stockbillid=t4.st_stockbillid and t3.siteid=t4.siteid where t1.sa_aftersalesmagid='" + sa_aftersalesmagid + "' and t1.siteid='lsa1986'");
-            row.put("salereturnbilldetil", detailRows.toJsonArray());
-        }
         if(rows.isEmpty()) {
             JSONArray array = new JSONArray();
             return array.toString();
+        }else{
+            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_aftersalesmagid,t2.k3outcode fk3outcode,t1.st_stockbill_itemsid salereturnbilldeid,t2.itemno fitemno,t1.qty fqty,t1.price fprice,t1.reason fnotes,t4.billno fsaleissuebillno, t3.rowno fsaleissuebillentryid from sa_aftersalesmag_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join st_stockbill_items t3 on t1.st_stockbill_itemsid=t3.st_stockbill_itemsid and t1.siteid=t3.siteid left join st_stockbill t4 on t3.st_stockbillid=t4.st_stockbillid and t3.siteid=t4.siteid where t1.sa_aftersalesmagid in" + rows.toJsonArray("salereturnbillid").toJSONString().replace("[", "(").replace("]", ")")  + " and t1.siteid='lsa1986'");
+            RowsMap rowsMap =detailRows.toRowsMap("sa_aftersalesmagid");
+            for (Row row : rows) {
+                String salereturnbillid = row.getString("salereturnbillid");
+                if(rowsMap.containsKey(salereturnbillid)){
+                    row.put("salereturnbilldetil", rowsMap.get(salereturnbillid));
+                }else{
+                    row.put("salereturnbilldetil", new JSONArray());
+                }
+
+            }
         }
+
+
         return rows.toJsonArray().toString();
     }
 
@@ -51,7 +61,7 @@ public class aftersalesmag extends Controller {
         ArrayList<String> sqllist = new ArrayList<>();
         for (Object object:idsarray) {
             String id = (String) object;
-            sqllist.add("update sa_aftersalesmag set updatek3flag='1' where siteid='lsa' and  sa_aftersalesmagid=" + id);
+            sqllist.add("update sa_aftersalesmag set updatek3flag='1' where siteid='lsa1986' and  sa_aftersalesmagid=" + id);
         }
 
         int count =dbConnect.runSqlUpdate(sqllist);

+ 1 - 1
src/custom/restcontroller/webmanage/lsak3/agents/agents.java

@@ -82,7 +82,7 @@ public class agents extends Controller {
             String changedate = content.getString("changedate");
 
 
-            Rows agentsRows = dbConnect.runSqlQuery("select * from sa_agents where siteid='lsa' and agentnum ='"+fagentnum+"'");
+            Rows agentsRows = dbConnect.runSqlQuery("select * from sa_agents where siteid='lsa1986' and agentnum ='"+fagentnum+"'");
             SQLFactory sqlFactory;
             if(agentsRows.isEmpty()){
                 SQLFactory sqlFactory1 = new SQLFactory(this, "企业新增");

+ 20 - 20
src/custom/restcontroller/webmanage/lsak3/cashbill/cashbill.java

@@ -49,8 +49,8 @@ public class cashbill extends Controller {
             // 经销商编号
             String agentnum = content.getString("fagentnum");
             long sys_enterpriseid=0;
-            if(dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa' and  agentnum='"+agentnum+"'").isNotEmpty()){
-                sys_enterpriseid=dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa' and  agentnum='"+agentnum+"'").get(0).getLong("sys_enterpriseid");
+            if(dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa1986' and  agentnum='"+agentnum+"'").isNotEmpty()){
+                sys_enterpriseid=dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa1986' and  agentnum='"+agentnum+"'").get(0).getLong("sys_enterpriseid");
             }else{
                 msg ="yos中不存在【"+agentnum+"】经销商";
                 return  getErrReturnObject().setErrMsg(msg).toString();
@@ -62,8 +62,8 @@ public class cashbill extends Controller {
             // 账户编号
             long sa_accountclassid=0;
             String faccclsnum = content.getString("faccclsnum");
-            if(dbConnect.runSqlQuery("select sa_accountclassid from sa_accountclass where siteid='lsa' and  accountno='"+faccclsnum+"'").isNotEmpty()){
-                sa_accountclassid=dbConnect.runSqlQuery("select sa_accountclassid from sa_accountclass where siteid='lsa' and  accountno='"+faccclsnum+"'").get(0).getLong("sa_accountclassid");
+            if(dbConnect.runSqlQuery("select sa_accountclassid from sa_accountclass where siteid='lsa1986' and  accountno='"+faccclsnum+"'").isNotEmpty()){
+                sa_accountclassid=dbConnect.runSqlQuery("select sa_accountclassid from sa_accountclass where siteid='lsa1986' and  accountno='"+faccclsnum+"'").get(0).getLong("sa_accountclassid");
             }else{
                 msg ="yos中不存在【"+faccclsnum+"】的账户";
                 return  getErrReturnObject().setErrMsg(msg).toString();
@@ -127,7 +127,7 @@ public class cashbill extends Controller {
                     BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
                     Rows rowsaccountbalance = dbConnect.runSqlQuery(
                             "select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='"
-                                    + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                                    + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
 
                     if (rowsaccountbalance.isEmpty()) {
                         SQLFactory accountbalanceaddSqlFactory = new SQLFactory(new Accountbalance(), "营销账户余额新增");
@@ -144,7 +144,7 @@ public class cashbill extends Controller {
                         BigDecimal newbalance = amount.add(rowsaccountbalance.get(0).getBigDecimal("balance"));
                         sqlList.add("update sa_accountbalance set balance='" + newbalance
                                 + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid
-                                + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                                + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         balance = newbalance;
                     }
                     sqlFactory.addParameter("balance", balance);
@@ -156,16 +156,16 @@ public class cashbill extends Controller {
                      * DRP存在收入凭证,且中间表状态为审核且不在删除状态时,DRP中需将当前收入凭证先反审核,修改内容后再进行审核
                      */
                     long sa_cashbillid= cashbillRows.get(0).getLong("sa_cashbillid");
-                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa'");
+                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa1986'");
 
                     BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
                     if (!rows.isEmpty()) {
                          sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
                          sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
-                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));
                         balance = newbalance;
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "收入凭证反审核成功").getSQL());
                     }
 
@@ -185,16 +185,16 @@ public class cashbill extends Controller {
                      * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入凭证先反审核
                      */
                     long sa_cashbillid= cashbillRows.get(0).getLong("sa_cashbillid");
-                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa'");
+                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa1986'");
 
                     BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
                     if (!rows.isEmpty()) {
                         sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
                         sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
-                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));
                         balance = newbalance;
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "收入凭证反审核成功").getSQL());
                     }
 
@@ -246,7 +246,7 @@ public class cashbill extends Controller {
                     BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
                     Rows rowsaccountbalance = dbConnect.runSqlQuery(
                             "select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='"
-                                    + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                                    + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                     if(rowsaccountbalance.isEmpty()){
                         JSONObject returnObject=new JSONObject();
                         returnObject.put("msg", "账户不存在,支出凭证无法审核");
@@ -254,7 +254,7 @@ public class cashbill extends Controller {
                         return returnObject.toString();
                     }
                     BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(amount);
-                    sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                    sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                     balance = newbalance;
                     sqlFactory.addParameter("balance", balance);
                     sqlFactory.addParameter("updatek3flag", "");
@@ -265,16 +265,16 @@ public class cashbill extends Controller {
                      * DRP存在收入凭证,且中间表状态为审核且不在删除状态时,DRP中需将当前收入凭证先反审核,修改内容后再进行审核
                      */
                     long sa_cashbillid= cashbillRows.get(0).getLong("sa_cashbillid");
-                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa'");
+                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa1986'");
 
                     BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
                     if (!rows.isEmpty()) {
                         sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
                         sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
-                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").add(rows.get(0).getBigDecimal("amount"));
                         balance = newbalance;
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "支出凭证反审核成功").getSQL());
                     }
 
@@ -293,16 +293,16 @@ public class cashbill extends Controller {
                      * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入凭证先反审核
                      */
                     long sa_cashbillid= cashbillRows.get(0).getLong("sa_cashbillid");
-                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa'");
+                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa1986'");
 
                     BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
                     if (!rows.isEmpty()) {
                         sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
                         sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
-                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").add(rows.get(0).getBigDecimal("amount"));
                         balance = newbalance;
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
+                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa1986'");
                         sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "支出凭证反审核成功").getSQL());
                     }
 

+ 14 - 6
src/custom/restcontroller/webmanage/lsak3/dispatch/dispatch.java

@@ -7,6 +7,7 @@ import common.YosException;
 import common.annotation.API;
 import common.data.Rows;
 import common.data.Row;
+import common.data.RowsMap;
 import restcontroller.R;
 
 import java.util.ArrayList;
@@ -28,15 +29,22 @@ public class dispatch extends Controller {
     @API(title = "获取DRP发货单", apiversion = R.ID20230715091603.v1.class,accesstoken = false)
     public String getDispatch() throws YosException{
         Rows rows = dbConnect.runSqlQuery("select t3.sonum fsonum,t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.billno finvonum,t1.sa_dispatchid sainvoiceid,t1.createby,t1.trantype ftrantype,ifnull(t1.billdate,CURRENT_DATE) fdate,t2.agentnum fagentnum,t1.remarks fnotes from sa_dispatch t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sa_order t3 on  t3.sa_orderid=t1.sa_orderid and t3.siteid=t1.siteid  where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001'  and t1.siteid='lsa1986'");
-        for (Row row : rows) {
-            String sa_dispatchid = row.getString("sa_dispatchid");
-            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid sainvoicedetailid,t2.itemno fitemno,t2.k3outcode fk3outcode,t3.qty fqty,t3.price fprice,t1.remarks fnotes,t3.customproperties,t2.spec flong from sa_dispatch_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t1.sa_orderitemsid=t3.sa_orderitemsid and t1.siteid=t3.siteid where t1.sa_dispatchid='" + sa_dispatchid + "'  and t1.siteid='lsa1986'");
-            row.put("sainvoicedetail", detailRows.toJsonArray());
-        }
         if(rows.isEmpty()) {
             JSONArray array = new JSONArray();
             return array.toString();
+        }else{
+            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_dispatchid,t1.sa_dispatch_itemsid sainvoicedetailid,t2.itemno fitemno,t2.k3outcode fk3outcode,t3.qty fqty,t3.price fprice,t1.remarks fnotes,t3.customproperties,t2.spec flong from sa_dispatch_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t1.sa_orderitemsid=t3.sa_orderitemsid and t1.siteid=t3.siteid where t1.sa_dispatchid in" + rows.toJsonArray("sainvoiceid").toJSONString().replace("[", "(").replace("]", ")") + "  and t1.siteid='lsa1986'");
+            RowsMap rowsMap =detailRows.toRowsMap("sa_dispatchid");
+            for (Row row : rows) {
+                String sainvoiceid = row.getString("sainvoiceid");
+                if(rowsMap.containsKey(sainvoiceid)){
+                    row.put("sainvoicedetail", rowsMap.get(sainvoiceid));
+                }
+
+            }
         }
+
+
         return rows.toJsonArray().toString();
     }
 
@@ -51,7 +59,7 @@ public class dispatch extends Controller {
         ArrayList<String> sqllist = new ArrayList<>();
         for (Object object:idsarray) {
             String id = (String) object;
-            sqllist.add("update sa_dispatch set updatek3flag='1' where siteid='lsa' and  sa_dispatchid=" + id);
+            sqllist.add("update sa_dispatch set updatek3flag='1' where siteid='lsa1986' and  sa_dispatchid=" + id);
         }
 
         int count =dbConnect.runSqlUpdate(sqllist);

+ 3 - 3
src/custom/restcontroller/webmanage/lsak3/item/item.java

@@ -32,7 +32,7 @@ public class item extends Controller {
         int code = 1;
         ArrayList<String> sqllist = new ArrayList<>();
         //单位
-        Rows unitRows = dbConnect.runSqlQuery("SELECT unitid,unitname from  plm_unit WHERE siteid = 'lsa'");
+        Rows unitRows = dbConnect.runSqlQuery("SELECT unitid,unitname from  plm_unit WHERE siteid = 'lsa1986'");
         RowsMap unitRowsMap = unitRows.toRowsMap("unitname");
         try {
             // 商品编号
@@ -107,7 +107,7 @@ public class item extends Controller {
             //功率
             String fgl = content.getString("fgl");
 
-            Rows itemRows = dbConnect.runSqlQuery("select * from plm_item where siteid='lsa' and itemno='"+fitemno+"'");
+            Rows itemRows = dbConnect.runSqlQuery("select * from plm_item where siteid='lsa1986' and itemno='"+fitemno+"'");
             SQLFactory sqlFactory;
             if(itemRows.isEmpty()){
                 long itemid = createTableID("plm_item");
@@ -141,7 +141,7 @@ public class item extends Controller {
                 long itemid = itemRows.get(0).getLong("itemid");
                 sqlFactory = new SQLFactory(this,"货品档案更新");
                 sqlFactory.addParameter("itemid",itemid);
-                Rows itemextendRows= dbConnect.runSqlQuery("select * from plm_itemextend where siteid='lsa' and itemid="+itemid);
+                Rows itemextendRows= dbConnect.runSqlQuery("select * from plm_itemextend where siteid='lsa1986' and itemid="+itemid);
                 SQLFactory sqlFactory1;
                 if(itemextendRows.isEmpty()){
                     sqlFactory1 = new SQLFactory(this, "货品档案-扩展新增");

+ 2 - 2
src/custom/restcontroller/webmanage/lsak3/itemPrice/itemPrice.java

@@ -40,12 +40,12 @@ public class itemPrice extends Controller {
             String fprice = content.getString("fprice");
 
 
-            Rows itemRows = dbConnect.runSqlQuery("select * from plm_item where siteid='lsa' and itemno='"+fitemno+"'");
+            Rows itemRows = dbConnect.runSqlQuery("select * from plm_item where siteid='lsa1986' and itemno='"+fitemno+"'");
             if(itemRows.isEmpty()){
                 code=0;
                 msg="商品不存在,无法新增商品价格";
             }else{
-                Rows itempriceRows = dbConnect.runSqlQuery("select * from sa_itemprice where siteid='lsa' and pricegrade='" + fpricegrade + "' and itemid="+itemRows.get(0).getLong("itemid"));
+                Rows itempriceRows = dbConnect.runSqlQuery("select * from sa_itemprice where siteid='lsa1986' and pricegrade='" + fpricegrade + "' and itemid="+itemRows.get(0).getLong("itemid"));
                 SQLFactory sqlFactory;
                 if(itempriceRows.isEmpty()){
                     sqlFactory = new SQLFactory(this,"商品价格新增");

+ 1 - 1
src/custom/restcontroller/webmanage/lsak3/order/order.java

@@ -53,7 +53,7 @@ public class order extends Controller {
         ArrayList<String> sqllist = new ArrayList<>();
         for (Object object:idsarray) {
             String id = (String) object;
-            sqllist.add("update sa_order set updatek3flag='1' where siteid='lsa' and  sa_orderid=" + id);
+            sqllist.add("update sa_order set updatek3flag='1' where siteid='lsa1986' and  sa_orderid=" + id);
         }
 
 

+ 8 - 8
src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java

@@ -46,8 +46,8 @@ public class stockbill extends Controller {
             // 经销商编号
             String fagentnum = content.getString("fagentnum");
             long sys_enterpriseid=0;
-            if(dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa' and  agentnum='"+fagentnum+"'").isNotEmpty()){
-                sys_enterpriseid=dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa' and  agentnum='"+fagentnum+"'").get(0).getLong("sys_enterpriseid");
+            if(dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa1986' and  agentnum='"+fagentnum+"'").isNotEmpty()){
+                sys_enterpriseid=dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa1986' and  agentnum='"+fagentnum+"'").get(0).getLong("sys_enterpriseid");
             }else{
                 msg ="yos中不存在【"+fagentnum+"】经销商";
                 return  getErrReturnObject().setErrMsg(msg).toString();
@@ -80,7 +80,7 @@ public class stockbill extends Controller {
             siteid="lsa";
 
 
-            Rows stockbillRows = dbConnect.runSqlQuery("select * from st_stockbill where siteid='lsa' and status='审核' and billno='"+fbillnum+"'");
+            Rows stockbillRows = dbConnect.runSqlQuery("select * from st_stockbill where siteid='lsa1986' and status='审核' and billno='"+fbillnum+"'");
             if(stockbillRows.isEmpty()  && "0".equals(isdelete) && "审核".equals(fstatus)){
                 /**
                  * DRP不存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需新增该销售出库单
@@ -104,9 +104,9 @@ public class stockbill extends Controller {
                 sqlList.add(sqlFactory.getSQL());
 
                 JSONArray detailarray = content.getJSONArray("icstockbilldetails");
-                Rows rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='lsa' ");
+                Rows rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='lsa1986' ");
                 RowsMap itemRowsMap =rows.toRowsMap("itemno");
-                Rows distiptchRows = dbConnect.runSqlQuery("select t2.price,t1.sa_dispatch_itemsid from sa_dispatch_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid inner join sa_dispatch t3 on t1.sa_dispatchid=t3.sa_dispatchid and t1.siteid=t3.siteid  where t3.status in('审核','复核','关闭') and  t1.siteid='lsa' ");
+                Rows distiptchRows = dbConnect.runSqlQuery("select t2.price,t1.sa_dispatch_itemsid from sa_dispatch_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid inner join sa_dispatch t3 on t1.sa_dispatchid=t3.sa_dispatchid and t1.siteid=t3.siteid  where t3.status in('审核','复核','关闭') and  t1.siteid='lsa1986' ");
                 RowsMap distiptchRowsMap =distiptchRows.toRowsMap("sa_dispatch_itemsid");
                 BigDecimal amountTotal=BigDecimal.ZERO;
                 for (Object object:detailarray) {
@@ -166,7 +166,7 @@ public class stockbill extends Controller {
                 entity.setRemarks("销售出库单" + fbillnum + "返利");
                 sqlList.addAll(Accountbalance.createCashbillIncome(this,sys_enterpriseid,Long.valueOf(icstockbillrebateaccount).longValue(),entity,true));
 
-                sqlList.add("update st_stockbill set status='审核',checkby='"+checkby+"',checkdate=CURRENT_TIMESTAMP where st_stockbillid = "+st_stockbillid+" and siteid='lsa'");
+                sqlList.add("update st_stockbill set status='审核',checkby='"+checkby+"',checkdate=CURRENT_TIMESTAMP where st_stockbillid = "+st_stockbillid+" and siteid='lsa1986'");
             }else if (!stockbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(fstatus)) {
                 /**
                  * DRP存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需将当前销售出库单先反审核,修改内容后再进行审核
@@ -194,7 +194,7 @@ public class stockbill extends Controller {
                 entity.setRemarks("销售出库单" + fbillnum + "反返利");
                 sqlList.addAll(Accountbalance.createCashbillIncome(this,sys_enterpriseid,Long.valueOf(icstockbillrebateaccount).longValue(),entity,true));
 
-                sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = "+stockbillRows.get(0).getLong("st_stockbillid")+" and siteid='lsa'");
+                sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = "+stockbillRows.get(0).getLong("st_stockbillid")+" and siteid='lsa1986'");
                 msg = "DRP单据状态为审核,现已反审核,下次同步时进行审核操作";
                 code = 0;
             }else if (!stockbillRows.isEmpty() && ("1".equals(isdelete) || "新建".equals(fstatus))) {
@@ -225,7 +225,7 @@ public class stockbill extends Controller {
                 sqlList.addAll(Accountbalance.createCashbillIncome(this,sys_enterpriseid,Long.valueOf(icstockbillrebateaccount).longValue(),entity,true));
 
 
-                sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = "+stockbillRows.get(0).getLong("st_stockbillid")+" and siteid='lsa'");
+                sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = "+stockbillRows.get(0).getLong("st_stockbillid")+" and siteid='lsa1986'");
 
             }
         } catch (Exception e) {

+ 10 - 1
src/custom/restcontroller/webmanage/sale/accountclass/SQL/营销大类列表查询.sql

@@ -1,4 +1,13 @@
-select *  from plm_itemclass t1 where siteid=$siteid$ and parentid=0 and not exists (
+select  itemclassid,itemclassname,0 isused from plm_itemclass t1 where siteid=$siteid$ and parentid=0 and classtype='营销' and not exists (
+SELECT
+	t.v
+FROM
+	sa_accountclass,
+	JSON_TABLE(bindingcategories,"$[*]" COLUMNS ( v VARCHAR (128) PATH "$")) t where t.v=t1.itemclassid)
+
+	UNION ALL
+
+	select  itemclassid,itemclassname,1 isused from plm_itemclass t1 where siteid=$siteid$ and parentid=0 and classtype='营销' and  exists (
 SELECT
 	t.v
 FROM

+ 1 - 1
src/custom/restcontroller/webmanage/sale/databoard/SQL/订货额类别统计分析.sql

@@ -1 +1 @@
-select cast(ifnull(sum(if(t2.isclose,t2.deliedqty*t2.price,t2.amount)),0) AS DECIMAL(16,6)) typestatistics  from sa_order t1 inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid where t1.siteid=$siteid$ and $where$ and t1.status not in('新建','提交') and exists(select * from sa_itemsaleclass s1 where s1.itemid=t2.itemid  and s1.itemclassid in $itemclassid$)
+select ifnull(t4.itemclassname,'其他') marketingcategory,sum(cast(ifnull(if(t2.isclose,t2.deliedqty*t2.price,t2.amount),0) AS DECIMAL(16,6))) typestatistics  from sa_order t1 inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid left join plm_item t3 on t2.itemid=t3.itemid and t2.siteid=t3.siteid left join plm_itemclass t4 on t3.marketingcategory=t4.itemclassid where t1.siteid=$siteid$ and $where$ and t1.status not in('新建','提交') group by t4.itemclassname

+ 32 - 28
src/custom/restcontroller/webmanage/sale/databoard/databoard.java

@@ -9,6 +9,7 @@ import common.annotation.API;
 import common.annotation.CACHEING;
 import common.data.Row;
 import common.data.Rows;
+import common.data.RowsMap;
 import common.data.SQLFactory;
 import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
@@ -215,7 +216,7 @@ public class databoard extends Controller {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 
         if (begindate != "") {
-            where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(begindate).append("' ");
+            where.append(" and t1.checkdate >='").append(begindate).append(" 00:00:00'");
             Date date = sdf.parse(begindate);
             //创建Calendar实例
             Calendar cal = Calendar.getInstance();
@@ -223,10 +224,10 @@ public class databoard extends Controller {
             cal.setTime(date);
             //在当前时间基础上减一年
             cal.add(Calendar.YEAR, -1);
-            whereLastYear.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(sdf.format(cal.getTime())).append("' ");
+            whereLastYear.append(" and t1.checkdate >='").append(sdf.format(cal.getTime())).append(" 00:00:00'");
         }
         if (enddate != "") {
-            where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(enddate).append("' ");
+            where.append(" and t1.checkdate <='").append(enddate).append(" 23:59:59'");
             Date date = sdf.parse(enddate);
             //创建Calendar实例
             Calendar cal = Calendar.getInstance();
@@ -234,7 +235,7 @@ public class databoard extends Controller {
             cal.setTime(date);
             //在当前时间基础上减一年
             cal.add(Calendar.YEAR, -1);
-            whereLastYear.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(sdf.format(cal.getTime())).append("' ");
+            whereLastYear.append(" and t1.checkdate <='").append(sdf.format(cal.getTime())).append(" 23:59:59'");
         }
 
         JSONArray jsonArray = new JSONArray();
@@ -383,7 +384,7 @@ public class databoard extends Controller {
         }
         list = supplementDate(Integer.parseInt(year), list);
         list = supplementDate(Integer.parseInt(lastyear), list);
-
+        list.sort(Comparator.comparingLong(o -> Long.parseLong(StringUtils.isBlank(o.getMonth())?"9999":o.getMonth())));
         return getSucReturnObject().setData(list).toString();
     }
 
@@ -543,28 +544,31 @@ public class databoard extends Controller {
         }
 
 
-        Rows topItemclassRows = dbConnect.runSqlQuery("select itemclassid,itemclassname marketingcategory from plm_itemclass where classtype='营销' and siteid='" + siteid + "' and ifnull(parentid,0)=0");
-        for (Row row : topItemclassRows) {
-            ArrayList<Long> itemclassids = ItemClass.getSubItemClassIds(this, row.getLong("itemclassid"));
-            SQLFactory factory = new SQLFactory(this, "订货额类别统计分析");
-            factory.addParameter("siteid", siteid);
-            factory.addParameter_SQL("where", where);
-            factory.addParameter_in("itemclassid", itemclassids);
-            Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
-
-            SQLFactory factoryLastYear = new SQLFactory(this, "订货额类别统计分析");
-            factoryLastYear.addParameter("siteid", siteid);
-            factoryLastYear.addParameter_SQL("where", whereLastYear);
-            factoryLastYear.addParameter_in("itemclassid", itemclassids);
-            Rows rowsLastYear = dbConnect.runSqlQuery(factoryLastYear.getSQL(false));
+        //Rows topItemclassRows = dbConnect.runSqlQuery("select itemclassid,itemclassname marketingcategory from plm_itemclass where classtype='营销' and siteid='" + siteid + "' and ifnull(parentid,0)=0");
+        SQLFactory factory = new SQLFactory(this, "订货额类别统计分析");
+        factory.addParameter("siteid", siteid);
+        factory.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
+
+        SQLFactory factoryLastYear = new SQLFactory(this, "订货额类别统计分析");
+        factoryLastYear.addParameter("siteid", siteid);
+        factoryLastYear.addParameter_SQL("where", whereLastYear);
+        Rows rowsLastYear = dbConnect.runSqlQuery(factoryLastYear.getSQL(false));
+        RowsMap rowsLastYearMap =rowsLastYear.toRowsMap("marketingcategory");
+
+        for (Row row : rows) {
             if (rows.isNotEmpty()) {
-                row.put("amount", rows.get(0).getBigDecimal("typestatistics"));
+                row.put("amount", row.getBigDecimal("typestatistics"));
             } else {
                 row.put("amount", BigDecimal.ZERO);
             }
-            if (rowsLastYear.isNotEmpty()) {
-                row.put("lastyearamount", rowsLastYear.get(0).getBigDecimal("typestatistics"));
-            } else {
+            if(rowsLastYearMap.containsKey(row.getString("marketingcategory"))){
+                if(rowsLastYearMap.get(row.getString("marketingcategory")).isNotEmpty()){
+                    row.put("lastyearamount", rowsLastYearMap.get(row.getString("marketingcategory")).get(0).getBigDecimal("typestatistics"));
+                }else {
+                    row.put("lastyearamount", BigDecimal.ZERO);
+                }
+            }else{
                 row.put("lastyearamount", BigDecimal.ZERO);
             }
             if (row.getBigDecimal("lastyearamount").compareTo(BigDecimal.ZERO) == 0) {
@@ -573,17 +577,17 @@ public class databoard extends Controller {
                 row.put("yearonyear", (row.getBigDecimal("amount").subtract(row.getBigDecimal("lastyearamount"))).divide(row.getBigDecimal("lastyearamount"), 4, BigDecimal.ROUND_HALF_UP));
             }
         }
-        BigDecimal sumamount = topItemclassRows.sum("amount");
-        for (Row row : topItemclassRows) {
+        BigDecimal sumamount = rows.sum("amount");
+        for (Row row : rows) {
             if (sumamount.compareTo(BigDecimal.ZERO) == 0) {
                 row.put("proportion", BigDecimal.ZERO);
             } else {
                 row.put("proportion", row.getBigDecimal("amount").divide(sumamount, 4, BigDecimal.ROUND_HALF_UP));
             }
         }
-        topItemclassRows.sort(Comparator.comparingDouble(o ->o.getDouble("amount")));
-        Collections.reverse(topItemclassRows);
-        return getSucReturnObject().setData(topItemclassRows).toString();
+        rows.sort(Comparator.comparingDouble(o ->o.getDouble("amount")));
+        Collections.reverse(rows);
+        return getSucReturnObject().setData(rows).toString();
     }
 
     /**

+ 0 - 4
src/custom/restcontroller/webmanage/sale/dispatch/SQL/发货单列表查询.sql

@@ -27,15 +27,11 @@ SELECT t1.billno,
        t1.closedate,
        t1.billdate,
        t7.agentnum,
-       t8.erpbillno,
-       case when t3.type='项目订单' then t9.projectname else t3.projectnote end projectname,
        t1.isreport
 FROM sa_dispatch t1
          LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid AND t1.siteid = t2.siteid
          LEFT JOIN sa_order t3 ON t1.sa_orderid = t3.sa_orderid AND t1.siteid = t3.siteid
          LEFT JOIN sys_enterprise_contacts t5 ON t1.rec_contactsid = t5.contactsid AND t1.siteid = t5.siteid
          LEFT JOIN sa_agents t7 ON t7.sys_enterpriseid = t1.sys_enterpriseid AND t1.siteid = t7.siteid
-         LEFT JOIN sys_dataextend t8 ON t8.ownertable = 'sa_dispatch' and t8.ownerid = t1.sa_dispatchid AND t1.siteid = t8.siteid
-         LEFT JOIN sa_project t9 ON t9.sa_projectid = t3.sa_projectid AND t9.siteid = t3.siteid 
 where t1.siteid = $siteid$
   and $where$

+ 1 - 1
src/custom/restcontroller/webmanage/sale/dispatch/SQL/商品发货数量汇总.sql

@@ -3,4 +3,4 @@ SELECT  t3.itemno,
 FROM sa_dispatch_items t1
          inner join sa_dispatch t2 on t1.siteid = t2.siteid and t1.sa_dispatchid = t2.sa_dispatchid
          inner join plm_item t3 on t1.siteid = t3.siteid and t1.itemid = t3.itemid
-WHERE t2.STATUS in ('审核','复核') and t1.siteid=$siteid$ group by t3.itemno
+WHERE t2.STATUS in ('审核','复核') and t1.siteid=$siteid$ and t3.itemno in $itemno$ group by t3.itemno

+ 24 - 11
src/custom/restcontroller/webmanage/sale/dispatch/dispatch.java

@@ -20,6 +20,7 @@ import restcontroller.sale.cashbill.cashbill;
 import restcontroller.webmanage.executorService.Executor;
 import restcontroller.webmanage.sale.order.Order;
 import restcontroller.webmanage.sale.order.OrderItems;
+import sun.awt.AWTIcon32_security_icon_yellow32_png;
 import utility.ERPDocking;
 import utility.tools.WebRequest;
 
@@ -274,16 +275,12 @@ public class dispatch extends Controller {
         querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid AND t1.siteid = t2.siteid",
                 "enterprisename", "abbreviation");
         querySQL.addQueryFields("enterprisephonenumber", "t2.phonenumber");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t3", "t1.sa_orderid = t3.sa_orderid AND t1.siteid = t3.siteid");
-        querySQL.addQueryFields("projectname", "case when t3.type='项目订单' then t9.projectname else t3.projectnote end ");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t3", "t1.sa_orderid = t3.sa_orderid AND t1.siteid = t3.siteid", "sonum");
         querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t5", "t1.rec_contactsid = t5.contactsid AND t1.siteid = t5.siteid",
                 "province", "city", "county", "address");
         querySQL.addQueryFields("contactsphonenumber", "t5.phonenumber");
         querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t7", "t7.sys_enterpriseid = t1.sys_enterpriseid AND t1.siteid = t7.siteid",
                 "agentnum");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t8", "t8.ownertable = 'sa_dispatch' and t8.ownerid = t1.sa_dispatchid AND t1.siteid = t8.siteid",
-                "erpbillno");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_project", "t9", "t9.sa_projectid = t3.sa_projectid AND t9.siteid = t3.siteid");
         querySQL.setWhere("t1.siteid", siteid);
         querySQL.setWhere(where);
         return querySQL;
@@ -306,12 +303,28 @@ public class dispatch extends Controller {
             }
         }
 
-        SQLFactory sqlFactory = new SQLFactory(this, "经销商合作企业查询", pageSize, pageNumber, pageSorting);
-        sqlFactory.addParameter_SQL("where", where);
-        sqlFactory.addParameter("siteid", siteid);
-
-        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL(false));
-
+        //SQLFactory sqlFactory = new SQLFactory(this, "经销商合作企业查询", pageSize, pageNumber, pageSorting);
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order","sys_enterpriseid");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t3", "t3.sys_enterpriseid = t1.sys_enterpriseid and t3.siteid = t1.siteid",
+                "enterprisename", "contact","address","province","city","phonenumber","county");
+        querySQL.addJoinTable(JOINTYPE.inner, "sa_agents", "t4", "t3.siteid = t4.siteid and t3.sys_enterpriseid = t4.sys_enterpriseid",
+                "agentnum");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere(where.toString());
+        querySQL.setWhere(" exists(select 1 from  sa_orderitems where sa_orderid=t1.sa_orderid and undeliqty>0 )");
+        querySQL.addGroupBy(" t1.sys_enterpriseid,\n" +
+                "         t3.enterprisename,\n" +
+                "         t3.contact,\n" +
+                "         t3.address,\n" +
+                "         t3.province,\n" +
+                "         t3.city,\n" +
+                "         t3.county,\n" +
+                "         t3.phonenumber,\n" +
+                "         t4.agentnum");
+        querySQL.setOrderBy(pageSorting);
+        querySQL.setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
 
         return getSucReturnObject().setData(rows).toString();
     }

+ 2 - 0
src/custom/restcontroller/webmanage/sale/dispatch/dispatchItems.java

@@ -238,6 +238,7 @@ public class dispatchItems extends Controller {
         }
         SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
         sqlFactory1.addParameter("siteid", siteid);
+        sqlFactory1.addParameter_in("itemno", rows.toArrayList("itemno",new ArrayList<>()));
         Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
         RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
 
@@ -339,6 +340,7 @@ public class dispatchItems extends Controller {
         }
         SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
         sqlFactory1.addParameter("siteid", siteid);
+        sqlFactory1.addParameter_in("itemno", rows.toArrayList("itemno",new ArrayList<>()));
         Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
         RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
 

+ 17 - 0
src/custom/restcontroller/webmanage/sale/item/Item.java

@@ -22,6 +22,7 @@ import org.apache.poi.xssf.usermodel.*;
 import restcontroller.R;
 import restcontroller.webmanage.sale.itemgroup.itemgroup;
 import utility.ERPDocking;
+import utility.tools.WebRequest;
 
 
 import java.io.IOException;
@@ -311,8 +312,24 @@ public class Item extends Controller {
 
             }
         }
+        JSONObject object = new JSONObject();
+        object.put("classname", "getIcinvbal");
+        object.put("method", "getMsg");
 
+        JSONObject content = new JSONObject();
+        content.put("fitemnos",  rows.toJsonArray("itemno"));
+        object.put("content", content);
+
+        WebRequest request = new WebRequest();
+        String result = request.doPost(object.toString(),
+                "http://60.190.151.198:8089/BYESB/jaxrs/webclientrest");
         for (Row row : rows) {
+            JSONArray jsonArrayResult = JSONArray.parseArray(result);
+            if(!jsonArrayResult.isEmpty()){
+                row.put("invbal_qty",((JSONObject)jsonArrayResult.get(0)).getBigDecimal("fqty"));
+            }else{
+                row.put("invbal_qty",0);
+            }
             if (attRowsMap.getOrDefault(row.getString("itemid"), new Rows()).isEmpty()) {
                 row.put("attinfos", defaultImageRows);
             } else {

+ 1 - 1
src/custom/restcontroller/webmanage/sale/order/Order.java

@@ -2839,7 +2839,7 @@ public class Order extends Controller {
 //        }
         JSONArray jsonArray =new JSONArray();
         BigDecimal orderSumamount = BigDecimal.ZERO;
-        Rows classamountrows = dbConnect.runSqlQuery("select t2.marketingcategory topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount  from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid   where t1.sa_orderid='"+sa_orderid+"' group by t2.marketingcategory,t1.siteid");
+        Rows classamountrows = dbConnect.runSqlQuery("select t2.marketingcategory topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount  from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid   where t1.sa_orderid='"+sa_orderid+"'  and t1.siteid='"+siteid+"' group by t2.marketingcategory,t1.siteid");
         for (Row classamountrow:classamountrows) {
             orderSumamount=orderSumamount.add(classamountrow.getBigDecimal("sumamount"));
         }

+ 2 - 2
src/custom/restcontroller/webmanage/sale/order/OrderItems.java

@@ -188,7 +188,7 @@ public class OrderItems extends Controller {
             } else {
                 sqlFactory = new SQLFactory(this, "订单商品明细_更新");
             }
-            sqlFactory.addParameter("customproperties", customproperties.toJSONString().replace("[", "").replace("]", ""));
+            sqlFactory.addParameter("customproperties", customproperties.toJSONString().replace("[", "").replace("]", "").replace("\"", ""));
             sqlFactory.addParameter("siteid", siteid);
             sqlFactory.addParameter("userid", userid);
             sqlFactory.addParameter("username", username);
@@ -353,7 +353,7 @@ public class OrderItems extends Controller {
         }
         JSONArray jsonArray = new JSONArray();
         BigDecimal orderSumamount = BigDecimal.ZERO;
-        Rows classamountrows = dbConnect.runSqlQuery("select t2.marketingcategory topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount  from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid   where t1.sa_orderid='" + sa_orderid + "' group by t2.marketingcategory,t1.siteid");
+        Rows classamountrows = dbConnect.runSqlQuery("select t2.marketingcategory topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount  from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid   where t1.sa_orderid='" + sa_orderid + "' and t1.siteid='"+siteid+"' group by t2.marketingcategory,t1.siteid");
         for (Row classamountrow : classamountrows) {
             orderSumamount = orderSumamount.add(classamountrow.getBigDecimal("sumamount"));
         }

+ 12 - 6
src/custom/restcontroller/webmanage/sale/rebateaccount/rebateaccounthead.java

@@ -493,17 +493,19 @@ public class rebateaccounthead extends Controller {
     public BigDecimal CalculateAmount(String begindate, String enddate, long sys_enterpriseid, ArrayList<Long> itemclsids,String agentitemclsnums,
                                   String itemids) throws YosException {
         Rows rows = null;
+        itemclsids.addAll(ItemClass.getSubItemClassIds(this,itemclsids));
+        itemclsids.add(0l);
         if (itemids .equals("()")) {
             rows = dbConnect.runSqlQuery("select SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
                     "inner join sa_order t2 on  t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
                     "inner join plm_item t3 on  t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
-                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + ItemClass.getSubItemClassIds(this,itemclsids).toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
+                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
 
         } else {
             rows = dbConnect.runSqlQuery("select SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
                     "inner join sa_order t2 on  t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
                     "inner join plm_item t3 on  t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
-                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid not in" + itemids + " and  t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + ItemClass.getSubItemClassIds(this,itemclsids).toString().replace("[", "(").replace("]", ")")+" )   and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
+                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid not in" + itemids + " and  t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" )   and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
 
         }
         if (rows.isEmpty()) {
@@ -516,17 +518,19 @@ public class rebateaccounthead extends Controller {
     public Rows QuerySaorderNum(String begindate, String enddate, long sys_enterpriseid, ArrayList<Long> itemclsids,String agentitemclsnums,
                                 String itemids) throws YosException {
         Rows rows = null;
+        itemclsids.addAll(ItemClass.getSubItemClassIds(this,itemclsids));
+        itemclsids.add(0l);
         if (itemids .equals("()")) {
             rows = dbConnect.runSqlQuery("select t2.sa_orderid,SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
                     "inner join sa_order t2 on  t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
                     "inner join plm_item t3 on  t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
-                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + ItemClass.getSubItemClassIds(this,itemclsids).toString().replace("[", "(").replace("]", ")")+" )  and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sa_orderid ");
+                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" )  and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sa_orderid ");
 
         } else {
             rows = dbConnect.runSqlQuery("select t2.sa_orderid,SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
                     "inner join sa_order t2 on  t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
                     "inner join plm_item t3 on  t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
-                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid not in" + itemids + " and  t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + ItemClass.getSubItemClassIds(this,itemclsids).toString().replace("[", "(").replace("]", ")")+" )  and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sa_orderid");
+                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid not in" + itemids + " and  t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" )  and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sa_orderid");
 
 
         }
@@ -536,17 +540,19 @@ public class rebateaccounthead extends Controller {
     public String QuerySaorderDetailId(String begindate, String enddate, long sys_enterpriseid, ArrayList<Long> itemclsids,String agentitemclsnums,
                                        String itemids) throws YosException {
         Rows rows = null;
+        itemclsids.addAll(ItemClass.getSubItemClassIds(this,itemclsids));
+        itemclsids.add(0l);
         if (itemids .equals("()")) {
             rows = dbConnect.runSqlQuery("select t1.sa_orderitemsid  from sa_orderitems t1 \n" +
                     "inner join sa_order t2 on  t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
                     "inner join plm_item t3 on  t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
-                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + ItemClass.getSubItemClassIds(this,itemclsids).toString().replace("[", "(").replace("]", ")")+" )  and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
+                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" )  and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
 
         } else {
             rows = dbConnect.runSqlQuery("select t1.sa_orderitemsid from sa_orderitems t1 \n" +
                     "inner join sa_order t2 on  t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
                     "inner join plm_item t3 on  t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
-                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid not in" + itemids + " and  t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" +ItemClass.getSubItemClassIds(this,itemclsids).toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
+                    "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"'  and t2.status in('关闭') and t1.itemid not in" + itemids + " and  t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" +itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
 
 
         }