|
@@ -1,5 +1,6 @@
|
|
|
package net.chenlin.dp.common.openapi4j.examples.voucher;
|
|
|
|
|
|
+import net.chenlin.dp.common.utils.DateUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -8,6 +9,8 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
|
|
|
import net.chenlin.dp.common.openapi4j.service.VoucherService;
|
|
|
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
|
|
|
* Copyright(c) 2015-2015 by yonyouup. All Rights Reserved 凭证
|
|
|
*
|
|
@@ -20,12 +23,84 @@ public class VoucherAdd {
|
|
|
|
|
|
final static Logger logger = LoggerFactory.getLogger(VoucherAdd.class);
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- String to_account = args[0];
|
|
|
- String jsonBody = args[1];
|
|
|
+
|
|
|
+ * 新增凭证
|
|
|
+ * @param map 数据
|
|
|
+ * @param biz_id 唯一来源id
|
|
|
+ */
|
|
|
+ public static void addVoucher(Map<String,Object> map,String biz_id) {
|
|
|
+
|
|
|
+ Map<String,Object> jsonBodyMap = new HashMap<>();
|
|
|
+ Map<String,Object> voucher = new HashMap<>();
|
|
|
+
|
|
|
+ voucher.put("voucher_type","记");
|
|
|
+
|
|
|
+
|
|
|
+ voucher.put("date", DateUtils.format(new Date()));
|
|
|
+ voucher.put("enter","DingDing_"+map.get("申请人"));
|
|
|
+ voucher.put("cashier",map.get("出纳"));
|
|
|
+
|
|
|
+ Map<String,Object> credit = new HashMap<>();
|
|
|
+ List<Map<String,Object>> entryCredit = new ArrayList<>();
|
|
|
+ Map<String,Object> entryCreditMap = new HashMap<>();
|
|
|
+ List<Map<String,Object>> cash_flowListCredit = new ArrayList<>();
|
|
|
+ Map<String,Object> cash_flowMapCredit = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ entryCreditMap.put("abstract",map.get("事由"));
|
|
|
+ entryCreditMap.put("account_code","1001");
|
|
|
+
|
|
|
+ entryCreditMap.put("natural_credit_currency",map.get("申请金额(元)"));
|
|
|
+
|
|
|
+ entryCredit.add(entryCreditMap);
|
|
|
+ credit.put("entry",entryCredit);
|
|
|
+ voucher.put("credit",credit);
|
|
|
+
|
|
|
+ Map<String,Object> debit = new HashMap<>();
|
|
|
+ List<Map<String,Object>> entryDebit = new ArrayList<>();
|
|
|
+ Map<String,Object> entryDebitMap = new HashMap<>();
|
|
|
+ List<Map<String,Object>> cash_flowListDebit = new ArrayList<>();
|
|
|
+ Map<String,Object> cash_flowMapDebit = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ entryDebitMap.put("abstract",map.get("事由"));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ entryDebitMap.put("account_code","1001");
|
|
|
+
|
|
|
+ entryDebitMap.put("natural_debit_currency",map.get("申请金额(元)"));
|
|
|
+
|
|
|
+
|
|
|
+ entryDebit.add(entryDebitMap);
|
|
|
+
|
|
|
+ debit.put("entry",entryDebit);
|
|
|
+ voucher.put("debit",debit);
|
|
|
+
|
|
|
+ jsonBodyMap.put("voucher",voucher);
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject(jsonBodyMap);
|
|
|
+ String jsonBody = json.toJSONString();
|
|
|
+
|
|
|
VoucherService voucherService = new VoucherService();
|
|
|
try {
|
|
|
- JSONObject record = voucherService.add(jsonBody, to_account);
|
|
|
+ JSONObject record = voucherService.add(jsonBody, biz_id);
|
|
|
logger.info(record.toString());
|
|
|
} catch (OpenAPIException e) {
|
|
|
e.printStackTrace();
|