Explorar o código

订单明细、发货明细应用

hu %!s(int64=3) %!d(string=hai) anos
pai
achega
46b2227387

+ 34 - 0
src/custom/restcontroller/webmanage/sale/dispatch/SQL/发货单明细所有列表查询.sql

@@ -0,0 +1,34 @@
+SELECT t1.sa_dispatch_itemsid,
+       t1.sa_dispatchid,
+       t1.sa_orderitemsid,
+       t4.billno,
+       t4.status,
+       t8.sonum,
+       t10.enterprisename,
+       t9.agentnum,
+       t4.billdate,
+       t1.rowno,
+       t5.rowno                       orderRowno,
+       t1.itemid,
+       t2.itemno,
+       t2.itemname,
+       t3.unitname,
+       ifnull(t1.qty, 0) qty,
+       t1.remarks,
+       ifnull(t1.outwarehouseqty, 0) outwarehouseqty,
+       t1.batchno,
+       t5.price,
+       (ifnull(t1.qty, 0) * t5.price) amount,
+       t5.undeliqty,
+       t5.deliedqty
+FROM sa_dispatch_items t1
+         left join plm_item t2 on t1.itemid = t2.itemid and t1.siteid = t2.siteid
+         LEFT JOIN plm_unit t3 ON t3.unitid = t2.unitid AND t3.siteid = t2.siteid
+         LEFT JOIN sa_dispatch t4 ON t4.sa_dispatchid = t1.sa_dispatchid AND t4.siteid = t1.siteid
+         left join sa_orderitems t5 on t1.sa_orderitemsid = t5.sa_orderitemsid and t1.siteid = t5.siteid
+         left join sa_order t8 on t8.sa_orderid=t5.sa_orderid and t8.siteid=t5.siteid
+         left join plm_itemextend t6 on t2.siteid = t6.siteid and t2.itemid = t6.itemid
+        LEFT JOIN sa_agents t9 on t9.sys_enterpriseid = t4.sys_enterpriseid and t9.siteid = t4.siteid
+        LEFT JOIN sys_enterprise t10 on t10.sys_enterpriseid = t4.sys_enterpriseid and t10.siteid = t4.siteid
+where $where$
+  and t1.siteid = $siteid$ and t4.status in ('审核','复核','关闭')

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

@@ -19,8 +19,10 @@ import restcontroller.webmanage.sale.order.Order;
 import restcontroller.webmanage.sale.order.OrderItems;
 import restcontroller.webmanage.sale.order.OrderItems;
 import utility.ERPDocking;
 import utility.ERPDocking;
 
 
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.HashMap;
 
 
 public class dispatchItems extends Controller {
 public class dispatchItems extends Controller {
 
 
@@ -253,6 +255,115 @@ public class dispatchItems extends Controller {
         return getSucReturnObject().setData(rows).toString();
         return getSucReturnObject().setData(rows).toString();
     }
     }
 
 
+    @API(title = "发货单商品所有明细列表", apiversion = R.ID20230508113003.v1.class)
+    @CACHEING
+    public String queryDispatchAllItemsList() throws YosException, IOException {
+        /*
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if(sys_enterpriseid>0) {
+            where.append(" and t4.sys_enterpriseid ='").append(sys_enterpriseid).append("' ");
+        }
+
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append(" t4.billno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t8.sonum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or  t9.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t10.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
+                where.append(" and t4.billdate >='").append(whereObject.getString("begindate")).append("' ");
+            }
+            if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
+                where.append(" and t4.billdate <='").append(whereObject.getString("enddate")).append("' ");
+            }
+        }
+        boolean isExport = content.getBooleanValue("isExport");
+        SQLFactory sqlFactory = new SQLFactory(this, "发货单明细所有列表查询", pageSize, pageNumber, pageSorting);
+        if(isExport){
+            sqlFactory = new SQLFactory(this, "发货单明细所有列表查询");
+        }
+        sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        RowsMap rowsMap =rows.toRowsMap("itemno");
+        ERPDocking erpDocking =new ERPDocking();
+        JSONArray jsonArray =new JSONArray();
+        if(rows.toJsonArray("itemno").size()!=0){
+            if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
+                jsonArray=erpDocking.getErpIcinvbalRows(200000, 1,rows.toJsonArray("itemno"));
+            }
+
+        }
+        SQLFactory sqlFactory1 =new SQLFactory(this,"商品发货数量汇总");
+        sqlFactory1.addParameter("siteid", siteid);
+        Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
+        RowsMap sumQtyRowsMap= sumQtyRows.toRowsMap("itemno");
+
+        if(!jsonArray.isEmpty()){
+            for (Object object:jsonArray) {
+                JSONObject jsonObject =(JSONObject)object;
+
+                if(rowsMap.containsKey(jsonObject.getString("fitemno"))){
+                    if(rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()){
+                        if(sumQtyRowsMap.containsKey(jsonObject.getString("fitemno"))){
+                            rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty").subtract( sumQtyRowsMap.get(jsonObject.getString("fitemno")).get(0).getBigDecimal("qty")));
+                        }else {
+                            rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty"));
+                        }
+                        rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
+                    }
+                }
+            }
+        }
+
+        for (Row row:rows) {
+            if(!row.containsKey("delinvbalqty")){
+                row.put("delinvbalqty", row.getBigDecimal("undeliqty").negate());
+                row.put("invbalqty", 0);
+            }
+        }
+
+        if (isExport) {
+            //去除不需要导出项
+            String[] removeFieldList = {"sa_dispatch_itemsid", "sa_dispatchid", "sa_orderitemsid", "rowno", "itemid",
+                    "outwarehouseqty", "batchno", "price", "amount", "undeliqty",
+                    "deliedqty", "invbalqty", "delinvbalqty"};
+            for (String key : removeFieldList) {
+                rows.getFieldList().remove(key);
+            }
+
+            Rows uploadRows = uploadExcelToObs("sa_dispatch", "发货单明细所有列表查询", rows, getTitleMap());
+            return getSucReturnObject().setData(uploadRows).toString();
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+    //返回导出的标题
+    public HashMap<String, String> getTitleMap() {
+        HashMap<String, String> titleMap = new HashMap<>();
+        titleMap.put("billno", "发货单号");
+        titleMap.put("status", "状态");
+        titleMap.put("sonum", "订单号");
+        titleMap.put("enterprisename", "企业名称");
+        titleMap.put("agentnum", "经销商编号");
+        titleMap.put("billdate", "发货日期");
+        titleMap.put("orderRowno", "订单行号");
+        titleMap.put("itemno", "产品编码");
+        titleMap.put("itemname", "品名");
+        titleMap.put("unitname", "单位");
+        titleMap.put("qty", "发货数量");
+        titleMap.put("remarks", "发货行备注");
+
+        return titleMap;
+    }
+
     @API(title = "删除明细", apiversion = R.ID20221115104803.v1.class)
     @API(title = "删除明细", apiversion = R.ID20221115104803.v1.class)
     @CACHEING_CLEAN(apiClass = {dispatchItems.class,dispatch.class})
     @CACHEING_CLEAN(apiClass = {dispatchItems.class,dispatch.class})
     public String deletemx() throws YosException {
     public String deletemx() throws YosException {

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

@@ -481,9 +481,12 @@ public class OrderItems extends Controller {
     }
     }
 
 
 
 
-    @API(title = "查询订单明细列表", apiversion = R.ID20230508111703.v1.class)
+    @API(title = "查询订单所有明细列表", apiversion = R.ID20230508111703.v1.class)
     public String selectAllList() throws YosException, IOException {
     public String selectAllList() throws YosException, IOException {
         StringBuffer where = new StringBuffer(" 1=1 ");
         StringBuffer where = new StringBuffer(" 1=1 ");
+        if(sys_enterpriseid>0) {
+            where.append(" and t5.sys_enterpriseid ='").append(sys_enterpriseid).append("' ");
+        }
         if (content.containsKey("where")) {
         if (content.containsKey("where")) {
             JSONObject whereObject = content.getJSONObject("where");
             JSONObject whereObject = content.getJSONObject("where");
             if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
             if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
@@ -496,10 +499,10 @@ public class OrderItems extends Controller {
                 where.append(")");
                 where.append(")");
             }
             }
             if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
             if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
-                where.append(" and t1.billdate >='").append(whereObject.getString("begindate")).append("' ");
+                where.append(" and t5.billdate >='").append(whereObject.getString("begindate")).append("' ");
             }
             }
             if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
             if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
-                where.append(" and t1.billdate <='").append(whereObject.getString("enddate")).append("' ");
+                where.append(" and t5.billdate <='").append(whereObject.getString("enddate")).append("' ");
             }
             }
         }
         }
 
 

+ 2 - 3
src/custom/restcontroller/webmanage/sale/order/SQL/订单商品明细_所有列表.sql

@@ -46,10 +46,9 @@ SELECT t1.sa_orderitemsid,
        t4.device,
        t4.device,
        t4.specalnote,
        t4.specalnote,
        t3.standards,
        t3.standards,
-       t5.sonum,
        t5.type,
        t5.type,
        t5.billdate,
        t5.billdate,
-       t5.sonum,
+       t5.status,
        t5.sonum,
        t5.sonum,
        t6.agentnum,
        t6.agentnum,
        t7.enterprisename,
        t7.enterprisename,
@@ -65,4 +64,4 @@ from sa_orderitems t1
          LEFT JOIN sa_agents t6 on t6.sys_enterpriseid = t5.sys_enterpriseid and t6.siteid = t5.siteid
          LEFT JOIN sa_agents t6 on t6.sys_enterpriseid = t5.sys_enterpriseid and t6.siteid = t5.siteid
           LEFT JOIN sys_enterprise t7 on t7.sys_enterpriseid = t5.sys_enterpriseid and t7.siteid = t5.siteid
           LEFT JOIN sys_enterprise t7 on t7.sys_enterpriseid = t5.sys_enterpriseid and t7.siteid = t5.siteid
 where t1.siteid = $siteid$
 where t1.siteid = $siteid$
-  and $where$
+  and $where$ and t5.status in ('审核','关闭')