hu 5 mesiacov pred
rodič
commit
1d4370d58b

+ 4 - 1
src/custom/restcontroller/webmanage/sale/stock/SQL/仓库列表查询.sql

@@ -7,7 +7,10 @@ select stockid,
        createdate,
        changeuserid,
        changeby,
-       changedate
+       changedate,
+       type,
+       isintotalstock,
+       isnegative
 from st_stock
 where siteid = $siteid$
   and $where$

+ 1 - 1
src/custom/restcontroller/webmanage/sale/stock/SQL/仓库删除.sql

@@ -1,4 +1,4 @@
 delete
 from st_stock
 where siteid = $siteid$
-  and stockid in $stockids$
+  and stockid = $stockid$

+ 2 - 2
src/custom/restcontroller/webmanage/sale/stock/SQL/仓库新增.sql

@@ -1,4 +1,4 @@
 insert into st_stock(stockid, siteid,stockno, stockname, issalestock, isused, createby, createdate, changeuserid, changeby,
-                     changedate)
+                     changedate,type,isintotalstock,isnegative)
 values ($stockid$, $siteid$,$stockno$, $stockname$, $issalestock$, $isused$, $username$, CURRENT_TIME, $userid$, $username$,
-        CURRENT_TIME)
+        CURRENT_TIME,$type$,$isintotalstock$,$isnegative$)

+ 4 - 1
src/custom/restcontroller/webmanage/sale/stock/SQL/仓库更新.sql

@@ -5,6 +5,9 @@ set stockname=$stockname$,
     changeuserid=$userid$,
     stockno=$stockno$,
     changeby=$username$,
-    changedate=CURRENT_TIME
+    changedate=CURRENT_TIME,
+    type=$type$,
+    isintotalstock=$isintotalstock$,
+    isnegative=$isnegative$
 where siteid = $siteid$
   and stockid = $stockid$

+ 19 - 5
src/custom/restcontroller/webmanage/sale/stock/Stock.java

@@ -52,11 +52,15 @@ public class Stock extends Controller {
         Long stockid = content.getLong("stockid");
         String stockname = content.getString("stockname");
         String stockno = content.getString("stockno");
-        Long isused = content.getLong("isused");
-        Long issalestock = content.getLong("issalestock");
+        Long isused = content.getLongValue("isused");
+        Long issalestock = content.getLongValue("issalestock");
+        String type = content.getStringValue("type");
+        boolean isnegative = content.getBooleanValue("isnegative");
+        boolean isintotalstock = content.getBooleanValue("isintotalstock");
         Rows rows = dbConnect.runSqlQuery("select stockid from st_stock where siteid='" + siteid + "' and stockname = '" + stockname + "'");
         SQLFactory sqlFactory = new SQLFactory(this, "仓库新增");
-        if (stockid == 0 || dbConnect.runSqlQuery("select 1 from st_stock where siteid='" + siteid + "' and stockid=" + stockid).isEmpty()) {
+        Rows stockrows = dbConnect.runSqlQuery("select * from st_stock where siteid='" + siteid + "' and stockid=" + stockid);
+        if (stockid <= 0 || stockrows.isEmpty()) {
             if (rows.isNotEmpty()) {
                 return getErrReturnObject().setErrMsg("该仓库已存在").toString();
             }
@@ -65,6 +69,9 @@ public class Stock extends Controller {
             if (rows.isNotEmpty() && stockid != rows.get(0).getLong("stockid")) {
                 return getErrReturnObject().setErrMsg("该仓库已存在").toString();
             }
+            if(stockrows.get(0).getBoolean("isused")){
+                return getErrReturnObject().setErrMsg("该仓库已启用,无法更新").toString();
+            }
             sqlFactory = new SQLFactory(this, "仓库更新");
         }
         sqlFactory.addParameter("siteid", siteid);
@@ -75,6 +82,9 @@ public class Stock extends Controller {
         sqlFactory.addParameter("stockno", stockno);
         sqlFactory.addParameter("isused", isused);
         sqlFactory.addParameter("issalestock", issalestock);
+        sqlFactory.addParameter("type",type);
+        sqlFactory.addParameter("isnegative",isnegative);
+        sqlFactory.addParameter("isintotalstock",isintotalstock);
         dbConnect.runSqlUpdate(sqlFactory.getSQL());
         return getSucReturnObject().toString();
     }
@@ -100,10 +110,14 @@ public class Stock extends Controller {
     @API(title = "删除", apiversion = R.ID20230104095004.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20230104094604.v1.class})
     public String delete() throws YosException {
-        JSONArray stockids = content.getJSONArray("stockids");
+        long stockid = content.getLong("stockid");
+        Rows rows =dbConnect.runSqlQuery("select * from st_invbal where stockid="+stockid+" and siteid='"+siteid+"'");
+        if(rows.isNotEmpty()){
+            return getErrReturnObject().setErrMsg("已有库存数据的仓库不允许删除").toString();
+        }
         SQLFactory sqlFactory = new SQLFactory(this, "仓库删除");
         sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter_in("stockids", stockids.toArray());
+        sqlFactory.addParameter("stockid", stockid);
         dbConnect.runSqlUpdate(sqlFactory.getSQL());
         return getSucReturnObject().toString();
     }