Explorar o código

9573 销售出库单添加版本控制,参考订单中的版本控制

wu hai 1 mes
pai
achega
a14fa33b00

+ 70 - 0
src/custom/restcontroller/webmanage/sale/stockbill/stockbill.java

@@ -30,6 +30,8 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 
+import static restcontroller.webmanage.sale.stockbill.stockbill.updateStockBillWithVersion;
+
 /**
  * 出入库单
  */
@@ -49,6 +51,8 @@ public class stockbill extends Controller {
     public String changeabstract() throws YosException {
         Long st_stockbillid = content.getLong("st_stockbillid");
         String abstract1 = content.getString("abstract");
+        //通过版本更新订单表头数据
+        updateStockBillWithVersion(this);
 
         ArrayList<String> sqllist = new ArrayList<>();
 
@@ -201,6 +205,9 @@ public class stockbill extends Controller {
 
             sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "新增", "销售出库单新增成功").getSQL());
         } else {
+            //通过版本更新订单表头数据
+            updateStockBillWithVersion(this);
+
             Rows rows = dbConnect.runSqlQuery(
                     "SELECT status,sys_enterpriseid,paydiscountamount,payamount,sourceobject from st_stockbill WHERE st_stockbillid = "
                             + st_stockbillid);
@@ -263,6 +270,13 @@ public class stockbill extends Controller {
     @API(title = "单据日期调整", apiversion = R.ID2025102215133403.v1.class)
     public String billdateChange() throws YosException {
         JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        JSONArray st_stockbillids_v = content.getJSONArray("st_stockbillids_v");
+        for (Object object : st_stockbillids_v) {
+            JSONObject object_v = (JSONObject) object;
+            //通过版本更新订单表头数据
+            updateStockBillWithVersion(this, object_v);
+        }
+
         Date billdate = content.getDate("billdate");
         String period = getPeriod(false, billdate);
         BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, st_stockbillids.size());
@@ -529,6 +543,12 @@ public class stockbill extends Controller {
     public String delete() throws YosException {
 
         JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        JSONArray st_stockbillids_v = content.getJSONArray("st_stockbillids_v");
+        for (Object object : st_stockbillids_v) {
+            JSONObject object_v = (JSONObject) object;
+            //通过版本更新订单表头数据
+            updateStockBillWithVersion(this, object_v);
+        }
         BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, st_stockbillids.size());
         for (Object o : st_stockbillids) {
             long st_stockbillid = Long.parseLong(o.toString());
@@ -557,6 +577,12 @@ public class stockbill extends Controller {
     @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class, restcontroller.sale.stockbill.stockbill.class})
     public String check() throws YosException {
         JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        JSONArray st_stockbillids_v = content.getJSONArray("st_stockbillids_v");
+        for (Object object : st_stockbillids_v) {
+            JSONObject object_v = (JSONObject) object;
+            //通过版本更新订单表头数据
+            updateStockBillWithVersion(this, object_v);
+        }
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill", "billno", "st_stockbillid");
         querySQL.setTableAlias("t1");
         querySQL.setSiteid(siteid);
@@ -611,6 +637,12 @@ public class stockbill extends Controller {
     @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class, stockbill.class, restcontroller.sale.stockbill.stockbill.class})
     public String uncheck() throws YosException {
         JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        JSONArray st_stockbillids_v = content.getJSONArray("st_stockbillids_v");
+        for (Object object : st_stockbillids_v) {
+            JSONObject object_v = (JSONObject) object;
+            //通过版本更新订单表头数据
+            updateStockBillWithVersion(this, object_v);
+        }
         for (Object o : st_stockbillids) {
             long st_stockbillid = Long.parseLong(o.toString());
             Stockbill.check(this, st_stockbillid, false);
@@ -920,6 +952,13 @@ public class stockbill extends Controller {
     @API(title = "仓库确认", apiversion = R.ID2025050709505703.v1.class)
     public String confirm() throws YosException {
         JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        JSONArray st_stockbillids_v = content.getJSONArray("st_stockbillids_v");
+        for (Object object : st_stockbillids_v) {
+            JSONObject object_v = (JSONObject) object;
+            //通过版本更新订单表头数据
+            updateStockBillWithVersion(this, object_v);
+        }
+
         boolean isconfirm = content.getBooleanValue("isconfirm");
         if (st_stockbillids.isEmpty()) {
             return getErrReturnObject().setErrMsg("请选择需要操作的出入库单")
@@ -962,6 +1001,10 @@ public class stockbill extends Controller {
     @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class})
     public String hongc() throws YosException {
         long st_stockbillid = content.getLong("st_stockbillid");
+
+        //通过版本更新订单表头数据
+        updateStockBillWithVersion(this);
+
         ArrayList<String> sqlList = new ArrayList<>();
         Rows rows = dbConnect.runSqlQuery("select t1.*,ifnull(t2.sa_sendrepairid,0) sa_sendrepairid from st_stockbill t1 left join sa_sendrepair t2 on t1.st_stockbillid=t2.sourceid and t1.siteid=t2.siteid and t2.sourcetable='st_stockbill'  where t1.st_stockbillid ='"
                 + st_stockbillid + "' and  t1.siteid='" + siteid + "'");
@@ -2102,4 +2145,31 @@ public class stockbill extends Controller {
         }
         return strNum.matches("-?\\d+(\\.\\d+)?");
     }
+
+
+    public static void updateStockBillWithVersion(Controller controller) throws YosException {
+        if (controller.content.containsKey("st_stockbill_v")) {
+            int st_stockbill_v = controller.content.getIntValue("st_stockbill_v");
+            Long st_stockbillid = controller.content.getLong("st_stockbillid");
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, "st_stockbill");
+            updateSQL.setDataVersion(st_stockbill_v);
+            updateSQL.setValue("changeby", controller.username);
+            updateSQL.setWhere("st_stockbillid", st_stockbillid);
+            updateSQL.setWhere("siteid", controller.siteid);
+            updateSQL.update();
+        }
+    }
+
+    public static void updateStockBillWithVersion(Controller controller, JSONObject object) throws YosException {
+        if (object.containsKey("st_stockbill_v")) {
+            int st_stockbill_v = object.getIntValue("st_stockbill_v");
+            Long st_stockbillid = object.getLong("st_stockbillid");
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, "st_stockbill");
+            updateSQL.setDataVersion(st_stockbill_v);
+            updateSQL.setValue("changeby", controller.username);
+            updateSQL.setWhere("st_stockbillid", st_stockbillid);
+            updateSQL.setWhere("siteid", controller.siteid);
+            updateSQL.update();
+        }
+    }
 }

+ 7 - 0
src/custom/restcontroller/webmanage/sale/stockbill/stockbillitems.java

@@ -20,6 +20,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
+import static restcontroller.webmanage.sale.stockbill.stockbill.updateStockBillWithVersion;
+
 public class stockbillitems extends Controller {
     public stockbillitems(JSONObject content) throws YosException {
         super(content);
@@ -149,6 +151,9 @@ public class stockbillitems extends Controller {
     @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class})
     public String insertormodify_stcokbillItems() throws YosException {
         Long st_stockbillid = content.getLong("st_stockbillid");
+        //通过版本更新订单表头数据
+        updateStockBillWithVersion(this);
+
         JSONArray iteminfos = content.getJSONArray("iteminfos");
         ArrayList<String> sqlList = new ArrayList<>();
         Rows rowscount = dbConnect.runSqlQuery("select billno,status,sourceobject,stockid,type,name,phonenumber,address,departmentid from st_stockbill where st_stockbillid=" + st_stockbillid);
@@ -395,6 +400,8 @@ public class stockbillitems extends Controller {
     @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class})
     public String deletemx() throws YosException {
 
+        //通过版本更新订单表头数据
+        updateStockBillWithVersion(this);
 
         JSONArray st_stockbill_itemsids = content.getJSONArray("st_stockbill_itemsids");
         BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, st_stockbill_itemsids.size());