shenjingwei 6 месяцев назад
Родитель
Сommit
a75f629476

+ 0 - 1
src/custom/beans/accountbalance/CashbillEntity.java

@@ -1,7 +1,6 @@
 package beans.accountbalance;
 
 import common.BaseClass;
-import org.apache.commons.lang.StringUtils;
 
 import java.math.BigDecimal;
 

+ 37 - 0
src/custom/beans/period/Period.java

@@ -0,0 +1,37 @@
+package beans.period;
+
+import common.Controller;
+import common.YosException;
+import common.data.Rows;
+import common.data.db.DBConnect;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class Period {
+
+    /**
+     * 根据日期获取会计期间
+     *
+     * @param controller
+     * @param date
+     * @return
+     * @throws YosException
+     */
+    public static String get(Controller controller, Date date) throws YosException {
+        return get(controller, new SimpleDateFormat("yyyy-MM-dd").format(date));
+    }
+
+    public static String get(Controller controller, String date) throws YosException {
+        return get(controller.dbConnect, controller.siteid, date);
+    }
+
+    public static String get(DBConnect dbConnect, String siteid, String date) throws YosException {
+        Rows rows = dbConnect.runSqlQuery("select CONCAT(year, '-',LPAD(month, 2, '0')) period from st_period where siteid='" + siteid + "' and begdate<='" + date + "' and '" + date + "'<=enddate");
+        if (rows.size() != 1) {
+            return "";
+        } else {
+            return rows.get(0).getString("period");
+        }
+    }
+}

+ 3 - 2
src/custom/service/GetStockBillFromU8.java

@@ -1,5 +1,6 @@
 package service;
 
+import beans.period.Period;
 import beans.stockbill.Stockbill;
 import common.ServiceController;
 import common.YosException;
@@ -107,13 +108,14 @@ public class GetStockBillFromU8 extends ServiceController {
                     stStockbill.setValue("siteid", "MD");
                     stStockbill.setValue("departmentid", departmentRowsMap.get("103").get(0).getLong("departmentid"));
                     stStockbill.setValue("billdate", ddate);
+                    stStockbill.setValue("period", Period.get(dbConnect, "MD", ddate));
+
                     stStockbill.setValue("stockid", stockid);
                     stStockbill.setValue("remarks", cmemo);
                     stStockbill.setValue("createby", "u8");
                     stStockbill.setValue("status", "新建");
                     stStockbill.setValue("rb", 1);
 
-
                     for (Row u8billmxRow : u8billmxRows) {
                         String cinvcode = u8billmxRow.getString("cinvcode");
                         String autoid = u8billmxRow.getString("autoid");
@@ -185,5 +187,4 @@ public class GetStockBillFromU8 extends ServiceController {
             }
         }
     }
-
 }