hu 3 سال پیش
والد
کامیت
981ad38162

+ 8 - 0
src/custom/restcontroller/R.java

@@ -4662,6 +4662,14 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20230408091703 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230408101803 {
+        public static class v1 {
+        }
+    }
 
 }
 

+ 6 - 0
src/custom/restcontroller/webmanage/sale/invbal/SQL/商品发货数量汇总.sql

@@ -0,0 +1,6 @@
+SELECT  t3.itemno,
+        SUM(t1.qty-ifnull(t1.outwarehouseqty,0)) qty
+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

+ 19 - 0
src/custom/restcontroller/webmanage/sale/invbal/SQL/未发货订单明细列表.sql

@@ -0,0 +1,19 @@
+SELECT t3.sonum,
+       t3.sa_orderid,
+       t5.enterprisename,
+       t2.itemno,
+       t2.itemname,
+       t3.checkdate,
+       t4.unitname,
+       t1.qty,
+       t1.undeliqty
+FROM sa_orderitems t1
+         inner join plm_item t2 on t1.siteid = t2.siteid and t1.itemid = t2.itemid
+         inner join sa_order t3 on t1.siteid=t3.siteid and t1.sa_orderid=t3.sa_orderid
+         left join plm_unit t4 on t2.unitid=t4.unitid and t2.siteid=t4.siteid
+         left join sys_enterprise t5 on t3.sys_enterpriseid=t5.sys_enterpriseid and t3.sys_enterpriseid=t5.sys_enterpriseid
+WHERE t3.STATUS = '审核'
+  and ifnull(t1.undeliqty, 0) !=0
+  and t2.itemno=$itemno$
+	AND t1.siteid = $siteid$
+	AND ifnull( t1.isclose, 0 )= 0

+ 14 - 0
src/custom/restcontroller/webmanage/sale/invbal/SQL/订单明细未发商品列表.sql

@@ -0,0 +1,14 @@
+SELECT distinct t2.itemno,
+       t2.itemname,
+       t2.isonsale,
+       t4.unitname,
+       t2.packageqty
+FROM sa_orderitems t1
+         inner join plm_item t2 on t1.siteid = t2.siteid and t1.itemid = t2.itemid
+         inner join sa_order t3 on t1.siteid=t3.siteid and t1.sa_orderid=t3.sa_orderid
+         left join plm_unit t4 on t2.unitid=t4.unitid and t2.siteid=t4.siteid
+WHERE t3.STATUS = '审核'
+  and ifnull(t1.undeliqty, 0) !=0
+	AND t1.siteid = $siteid$
+	AND ifnull( t1.isclose, 0 )= 0
+	and ($where$)

+ 76 - 0
src/custom/restcontroller/webmanage/sale/invbal/invbal.java

@@ -1,5 +1,6 @@
 package restcontroller.webmanage.sale.invbal;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.HashMap;
@@ -18,7 +19,9 @@ import common.data.Rows;
 import common.data.RowsMap;
 import common.data.SQLFactory;
 import common.data.db.DBConnect;
+import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
+import utility.ERPDocking;
 
 @API(title = "库存管理")
 public class invbal extends Controller {
@@ -106,5 +109,78 @@ public class invbal extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
+	@API(title = "查询Erp库存列表", apiversion = R.ID20230408091703.v1.class)
+	public String queryErpInvbalList() throws YosException {
+		String itemno = content.getString("itemno");
+		String itemname = content.getString("itemname");
+		JSONArray itemclassids = content.getJSONArray("itemclassids");
+		String where ="1=2";
+		if(!StringUtils.isBlank(itemno)){
+			where=where+" or t2.itemno like '%"+itemno+"%'";
+		}
+		if(!StringUtils.isBlank(itemname)){
+			where=where+" or t2.itemname like '%"+itemname+"%' ";
+		}
+		if (itemclassids.size() > 0) {
+			String sql = " or t1.itemid in ( SELECT itemid from sa_itemsaleclass WHERE itemclassid IN " + itemclassids + "  and siteid='" + siteid + "')";
+			sql = sql.replace("[", "(").replace("]", ")");
+			where=where+sql;
+		}
+
+		SQLFactory sqlFactory =new SQLFactory(this,"订单明细未发商品列表");
+		sqlFactory.addParameter("siteid", siteid);
+		sqlFactory.addParameter_SQL("where", where);
+		Rows rows = dbConnect.runSqlQuery(sqlFactory);
+		 System.out.println(rows.size());
+		Rows rowsitemclass = dbConnect.runSqlQuery(" select  t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 LEFT JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='" + siteid + "'");
+		RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
+
+		RowsMap rowsMap =rows.toRowsMap("itemno");
+
+
+		SQLFactory sqlFactory1 =new SQLFactory(this,"商品发货数量汇总");
+		sqlFactory1.addParameter("siteid", siteid);
+		Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
+		RowsMap sumQtyRowsMap= sumQtyRows.toRowsMap("itemno");
+
+
+		ERPDocking erpDocking =new ERPDocking();
+		JSONArray jsonArray = erpDocking.getErpIcinvbalRows(200000, 1,rows.toJsonArray("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()){
+						rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
+				}
+				}
+			}
+		}
+		for (Row row:rows) {
+			row.put("itemclass", itemclassRowsMap.get(row.getString("itemid")));
+			if(sumQtyRowsMap.containsKey(row.getString("itemno"))){
+				if(sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
+					row.put("unsoldqty", sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty"));
+				}else {
+					row.put("unsoldqty", BigDecimal.ZERO);
+				}
+				if(!row.containsKey("invbalqty")){
+					row.put("invbalqty",BigDecimal.ZERO);
+				}
+			}
+		}
+		return getSucReturnObject().setData(rows).toString();
+	}
+	@API(title = "查询指定商品对应的未发货订单明细", apiversion = R.ID20230408101803.v1.class)
+	public String queryOrderDetailList() throws YosException {
+		String itemno = content.getString("itemno");
+
+
+		SQLFactory sqlFactory =new SQLFactory(this,"未发货订单明细列表");
+		sqlFactory.addParameter("siteid", siteid);
+		sqlFactory.addParameter("itemno", itemno);
+		Rows rows = dbConnect.runSqlQuery(sqlFactory);
+		return getSucReturnObject().setData(rows).toString();
+	}
 
 }

+ 5 - 5
src/custom/utility/ERPDocking.java

@@ -74,9 +74,9 @@ public class ERPDocking {
 
         HashMap<String, String> map = new HashMap<>();
         map.put("content-Type", "application/json");
-        String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/public", map);
+        String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
         JSONObject resultobject = JSONObject.parseObject(result);
-        return resultobject.getJSONObject("data").getJSONArray("rows");
+        return resultobject.getJSONObject("results").getJSONArray("list");
     }
 
     /**
@@ -87,7 +87,7 @@ public class ERPDocking {
      * @return
      * @throws YosException
      */
-    public JSONArray getErpIcinvbalRows( String pagerows, String pagenum,JSONArray fitemnos) throws YosException {
+    public JSONArray getErpIcinvbalRows( int pagerows, int pagenum,JSONArray fitemnos) throws YosException {
         {
 
             JSONObject object= new JSONObject();
@@ -106,9 +106,9 @@ public class ERPDocking {
 
             HashMap<String, String> map = new HashMap<>();
             map.put("content-Type", "application/json");
-            String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/public", map);
+            String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
             JSONObject resultobject = JSONObject.parseObject(result);
-            return resultobject.getJSONObject("data").getJSONArray("rows");
+            return resultobject.getJSONObject("results").getJSONArray("list");
         }
     }
 //    /**