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

Merge remote-tracking branch 'origin/develop' into develop

shenjingwei 2 месяцев назад
Родитель
Сommit
10756c4e89

+ 11 - 0
src/custom/beans/stockbill/bills/BasicBill.java

@@ -1,5 +1,6 @@
 package beans.stockbill.bills;
 
+import beans.datacontrllog.DataContrlLog;
 import common.Controller;
 import common.UserInfo;
 import common.YosException;
@@ -22,6 +23,7 @@ public abstract class BasicBill {
     String siteid;
     String status;
     int rb;
+    String period;
     Row billRow;
     Rows itemRows;
     Rows codeRows;
@@ -81,6 +83,14 @@ public abstract class BasicBill {
             if (!status.equals("新建")) {
                 throw new YosException("单号为:【" + billno + "】的出入库单为非新建状态,无法审核");
             }
+            RowsMap rowsMap =dbConnect.runSqlQuery("select CONCAT(year, '-',LPAD(month, 2, '0')) period,isclose from st_period").toRowsMap("period");
+            if (rowsMap.containsKey(period)) {
+                if(rowsMap.get(period).toRowsMap("isclose").containsKey("1")){
+                    throw new YosException("原单据会计期间已关闭,不可调整");
+                }
+            }else{
+                throw new YosException("原单据会计期间未生成,不可调整");
+            }
             if (itemRows.isEmpty()) {
                 throw new YosException("表体为空");
             }
@@ -312,6 +322,7 @@ public abstract class BasicBill {
         this.rb = billRow.getInteger("rb");
         this.siteid = billRow.getString("siteid");
         this.status = billRow.getString("status");
+        this.period = billRow.getString("period");
         itemRows = dbConnect.runSqlQuery("select t1.* from st_stockbill_items t1 where t1.st_stockbillid ='" + st_stockbillid + "'");
         codeRows = dbConnect.runSqlQuery("select t1.* from st_stockbill_items_sku t1 where t1.st_stockbillid ='" + st_stockbillid + "'");
     }

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

@@ -6786,6 +6786,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025102215133403 {
+        public static class v1 {
+        }
+    }
 }
 
 

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

@@ -16,6 +16,7 @@ import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
 import common.data.*;
 import org.apache.commons.lang.StringUtils;
+import org.apache.poi.hssf.record.DVALRecord;
 import restcontroller.R;
 import restcontroller.webmanage.sale.order.Order;
 import restcontroller.webmanage.sale.order.OrderItems;
@@ -174,6 +175,38 @@ public class stockbill extends Controller {
         return queryStockbillMain();
     }
 
+    @API(title = "单据日期调整", apiversion = R.ID2025102215133403.v1.class)
+    public String billdateChange() throws YosException {
+        Long st_stockbillid = content.getLong("st_stockbillid");
+        String billdate = content.getString("billdate");
+        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();
+                    }
+                    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());
+            }
+            sqlList.add("update st_stockbill set billdate='"+billdate+"' where st_stockbillid="+st_stockbillid);
+        } else {
+            return getErrReturnObject().setErrMsg("该出入库单不存在").toString();
+        }
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
+
+
     @API(title = "出入库单详情", apiversion = R.ID20230719153803.v1.class)
     @CACHEING
     public String queryStockbillMain() throws YosException {