Selaa lähdekoodia

调拨单审核优化

shenjingwei 1 kuukausi sitten
vanhempi
commit
a8514b589d

+ 14 - 1
src/custom/restcontroller/webmanage/sale/dbstockbill/dbstockbillreceive.java

@@ -10,7 +10,9 @@ import common.data.*;
 import restcontroller.R;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 
 public class dbstockbillreceive extends Controller {
     public dbstockbillreceive(JSONObject content) throws YosException {
@@ -123,7 +125,8 @@ public class dbstockbillreceive extends Controller {
         insertSQL.setDateValue("createdate");
         insertSQL.setValue("checkby", username);
         insertSQL.setDateValue("checkdate");
-        insertSQL.setValue("billdate", rows.get(0).getLong("billdate"));
+        insertSQL.setValue("billdate", rows.get(0).getString("billdate"));
+        insertSQL.setValue("period", getPeriod(rows.get(0).getDate("billdate")));
         sqllist.add(insertSQL.getSQL());
         int j = 1;
         for (Row row : dbstockbilldetail) {
@@ -165,6 +168,16 @@ public class dbstockbillreceive extends Controller {
         return getSucReturnObject().toString();
     }
 
+    public String getPeriod(Date date) throws YosException {
+        String preioddate = new SimpleDateFormat("yyyy-MM-dd").format(date);
+        Rows rows = dbConnect.runSqlQuery("select CONCAT_WS('-', year, LPAD(month, 2, '0')) period from st_period where begdate<='" + preioddate + "' and enddate>='" + preioddate + "'");
+        if (rows.size() != 1) {
+            throw new YosException("单据日期所属会计期间未生成");
+        } else {
+            return rows.get(0).getString("period");
+        }
+    }
+
     public ArrayList<String> updateIcinvbal(boolean ischeck, boolean isinstock, Rows dbstockbilldetail) throws YosException {
         ArrayList<String> sqlList = new ArrayList();
         ArrayList<Long> itemids = new ArrayList<Long>();

+ 14 - 1
src/custom/restcontroller/webmanage/sale/sendrepair/sendrepair.java

@@ -16,7 +16,9 @@ import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 
 @API(title = "送修单")
 public class sendrepair extends Controller {
@@ -834,7 +836,7 @@ public class sendrepair extends Controller {
      */
     public ArrayList<String> updatefitemno(boolean istrue, Row sendrepairdetail) throws YosException {
         ArrayList<String> sqlList = new ArrayList<>();
-        Rows skurows = dbConnect.runSqlQuery("select * from sa_itemsku where sku='" + sendrepairdetail.getString("sku") + "' and status!='报废'");
+        Rows skurows = dbConnect.runSqlQuery("select * from sa_itemsku where siteid='"+siteid+"' and sku='" + sendrepairdetail.getString("sku") + "' and status!='报废'");
         if (skurows.isEmpty()) {
             throw new YosException("序列号不存在或已作废");
         }
@@ -1008,6 +1010,7 @@ public class sendrepair extends Controller {
             insertSQL.setValue("createby", username);
             insertSQL.setDateValue("createdate");
             insertSQL.setDateValue("billdate");
+            insertSQL.setValue("period", getPeriod(getDate()));
             insertSQL.setValue("checkby", username);
             insertSQL.setDateValue("checkdate");
             sqlList.add(insertSQL.getSQL());
@@ -1054,6 +1057,16 @@ public class sendrepair extends Controller {
         return sqlList;
     }
 
+    public String getPeriod(Date date) throws YosException {
+        String preioddate = new SimpleDateFormat("yyyy-MM-dd").format(date);
+        Rows rows = dbConnect.runSqlQuery("select CONCAT_WS('-', year, LPAD(month, 2, '0')) period from st_period where begdate<='" + preioddate + "' and enddate>='" + preioddate + "'");
+        if (rows.size() != 1) {
+            throw new YosException("单据日期所属会计期间未生成");
+        } else {
+            return rows.get(0).getString("period");
+        }
+    }
+
     /**
      * 正品入库
      */