Просмотр исходного кода

出入库单修改单据日期及审核反审核接口改为批量

hu 6 месяцев назад
Родитель
Сommit
d3db8267e4
1 измененных файлов с 41 добавлено и 24 удалено
  1. 41 24
      src/custom/restcontroller/webmanage/sale/stockbill/stockbill.java

+ 41 - 24
src/custom/restcontroller/webmanage/sale/stockbill/stockbill.java

@@ -178,36 +178,47 @@ public class stockbill extends Controller {
 
     @API(title = "单据日期调整", apiversion = R.ID2025102215133403.v1.class)
     public String billdateChange() throws YosException {
-        Long st_stockbillid = content.getLong("st_stockbillid");
-        String billdate = content.getString("billdate");
+        JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        Date billdate = content.getDate("billdate");
+        String period = getPeriod(false,billdate);
+        BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, st_stockbillids.size());
         ArrayList<String> sqlList = new ArrayList<>();
-        Rows rows = dbConnect.runSqlQuery(
-                "SELECT status,period from st_stockbill WHERE st_stockbillid = "
-                        + st_stockbillid);
-        if(rows.isNotEmpty()){
-            if (rows.get(0).getString("status").equals("审核")) {
-                RowsMap rowsMap =dbConnect.runSqlQuery("select CONCAT(year, '-',LPAD(month, 2, '0')) period,isclose from st_period").toRowsMap("period");
-                if (rowsMap.containsKey(rows.get(0).getString("period"))) {
-                    if(rowsMap.get(rows.get(0).getString("period")).toRowsMap("isclose").containsKey("1")){
-                        return getErrReturnObject().setErrMsg("原单据会计期间已关闭,不可调整").toString();
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill", "*").setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("t1.st_stockbillid",st_stockbillids);
+        Rows rows = querySQL.query();
+        RowsMap rowsMap =rows.toRowsMap("st_stockbillid");
+        RowsMap periodrowsMap =dbConnect.runSqlQuery("select CONCAT(year, '-',LPAD(month, 2, '0')) period from st_period where isclose=1").toRowsMap("period");
+        if(periodrowsMap.containsKey(period)){
+            return getErrReturnObject().setErrMsg("原单据会计期间已关闭,不可调整").toString();
+        }
+        for (Object o : st_stockbillids) {
+            long st_stockbillid = Long.parseLong(o.toString());
+            if(rowsMap.containsKey(st_stockbillid)){
+                if(rowsMap.get(st_stockbillid).get(0).getString("status").equals("审核")){
+                    if (periodrowsMap.containsKey(period)) {
+                        if(rowsMap.get(period).toRowsMap("isclose").containsKey("1")){
+                            batchDeleteErr.addErr(st_stockbillid, "原单据会计期间已关闭,不可调整");
+                            continue;
+                        }
+                    }else{
+                        batchDeleteErr.addErr(st_stockbillid, "原单据会计期间未生成,不可调整");
+                        continue;
                     }
-                    sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "更新", "单据日期【"+billdate+"】调整成功").getSQL());
-                }else{
-                    return getErrReturnObject().setErrMsg("原单据会计期间未生成,不可调整").toString();
                 }
-
             }else{
-                sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "更新", "单据日期【"+billdate+"】调整成功").getSQL());
+                batchDeleteErr.addErr(st_stockbillid, "该单据不存在");
+                continue;
             }
-            sqlList.add("update st_stockbill set billdate='"+billdate+"' where st_stockbillid="+st_stockbillid);
-        } else {
-            return getErrReturnObject().setErrMsg("该出入库单不存在").toString();
+            sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "更新", "单据日期【"+billdate+"】调整成功").getSQL());
+            sqlList.add("update st_stockbill set billdate='"+billdate+"',period='"+period+"' where st_stockbillid="+st_stockbillid);
         }
         dbConnect.runSqlUpdate(sqlList);
-        return getSucReturnObject().toString();
+        return batchDeleteErr.getReturnObject().toString();
     }
 
 
+
     @API(title = "出入库单详情", apiversion = R.ID20230719153803.v1.class)
     @CACHEING
     public String queryStockbillMain() throws YosException {
@@ -382,16 +393,22 @@ public class stockbill extends Controller {
     @API(title = "审核", apiversion = R.ID20230719154103.v1.class)
     @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class, restcontroller.sale.stockbill.stockbill.class})
     public String check() throws YosException {
-        Long st_stockbillid = content.getLong("st_stockbillid");
-        Stockbill.check(this, st_stockbillid, true);
+        JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        for (Object o : st_stockbillids) {
+            long st_stockbillid = Long.parseLong(o.toString());
+            Stockbill.check(this, st_stockbillid, true);
+        }
         return getSucReturnObject().toString();
     }
 
     @API(title = "反审核", apiversion = R.ID20230719154203.v1.class)
     @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class, stockbill.class, restcontroller.sale.stockbill.stockbill.class})
     public String uncheck() throws YosException {
-        Long st_stockbillid = content.getLong("st_stockbillid");
-        Stockbill.check(this, st_stockbillid, false);
+        JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        for (Object o : st_stockbillids) {
+            long st_stockbillid = Long.parseLong(o.toString());
+            Stockbill.check(this, st_stockbillid, false);
+        }
         return getSucReturnObject().toString();
     }