|
@@ -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];//提供方id
|
|
|
- String jsonBody = args[1];//请求body体数据
|
|
|
+ /**
|
|
|
+ * 新增凭证
|
|
|
+ * @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("fiscal_year","2021");//凭证所属的会计年度,不填写取当前年
|
|
|
+// voucher.put("accounting_period","1");//所属的会计期间,不填写取当前月份
|
|
|
+ voucher.put("date", DateUtils.format(new Date()));//制单日期
|
|
|
+ voucher.put("enter","DingDing_"+map.get("申请人"));//制单人名称
|
|
|
+ voucher.put("cashier",map.get("出纳"));//出纳名称
|
|
|
+
|
|
|
+ Map<String,Object> credit = new HashMap<>(); //voucher > credit
|
|
|
+ List<Map<String,Object>> entryCredit = new ArrayList<>(); //voucher > credit > entryCredit
|
|
|
+ Map<String,Object> entryCreditMap = new HashMap<>(); //voucher > credit > entryCredit > entryCreditMap
|
|
|
+ List<Map<String,Object>> cash_flowListCredit = new ArrayList<>();//voucher > credit > entryCredit > entryCreditMap > cash_flowListCredit
|
|
|
+ Map<String,Object> cash_flowMapCredit = new HashMap<>(); //voucher > credit > entryCredit > entryCreditMap > cash_flowListCredit > cash_flowMapCredit
|
|
|
+
|
|
|
+// cash_flowMapCredit.put("natural_credit_currency","0.00");
|
|
|
+// cash_flowMapCredit.put("natural_debit_currency","4.00");
|
|
|
+// cash_flowListCredit.add(cash_flowMapCredit);
|
|
|
+// entryCreditMap.put("cash_flow",cash_flowListCredit);
|
|
|
+
|
|
|
+// entryCreditMap.put("auxiliary",new HashMap<String,Object>());
|
|
|
+// entryCreditMap.put("credit_quantity","0");
|
|
|
+// entryCreditMap.put("document_date","2021-09-18");
|
|
|
+// entryCreditMap.put("document_id","321654");
|
|
|
+// entryCreditMap.put("exchange_rate2","0");
|
|
|
+ entryCreditMap.put("abstract",map.get("事由"));
|
|
|
+ entryCreditMap.put("account_code","1001");
|
|
|
+// entryCreditMap.put("entry_id","0");//
|
|
|
+ entryCreditMap.put("natural_credit_currency",map.get("申请金额(元)"));//本币贷方发生额*与本币借方发生额不能同时为空
|
|
|
+// entryCreditMap.put("primary_credit_amount","0");//
|
|
|
+ entryCredit.add(entryCreditMap);
|
|
|
+ credit.put("entry",entryCredit);
|
|
|
+ voucher.put("credit",credit);//扩展
|
|
|
+
|
|
|
+ Map<String,Object> debit = new HashMap<>(); //voucher > debit
|
|
|
+ List<Map<String,Object>> entryDebit = new ArrayList<>(); //voucher > debit > entryDebit
|
|
|
+ Map<String,Object> entryDebitMap = new HashMap<>(); //voucher > debit > entryDebit > entryDebitMap
|
|
|
+ List<Map<String,Object>> cash_flowListDebit = new ArrayList<>();//voucher > debit > entryDebit > entryDebitMap > cash_flowListDebit
|
|
|
+ Map<String,Object> cash_flowMapDebit = new HashMap<>(); //voucher > debit > entryDebit > entryDebitMap > cash_flowListDebit > cash_flowMapDebit
|
|
|
+
|
|
|
+// cash_flowMapDebit.put("natural_credit_currency","0.00");
|
|
|
+// cash_flowMapDebit.put("natural_debit_currency","4.00");
|
|
|
+// cash_flowListDebit.add(cash_flowMapDebit);
|
|
|
+// entryDebitMap.put("cash_flow",cash_flowListDebit);
|
|
|
+//
|
|
|
+// entryDebitMap.put("auxiliary",new HashMap<String,Object>());
|
|
|
+// entryDebitMap.put("settlement","8");
|
|
|
+ entryDebitMap.put("abstract",map.get("事由"));
|
|
|
+// entryDebitMap.put("debit_quantity","0");
|
|
|
+// entryDebitMap.put("document_date","2021-09-18");
|
|
|
+// entryDebitMap.put("document_id","123456");
|
|
|
+// entryDebitMap.put("exchange_rate2","0");
|
|
|
+ entryDebitMap.put("account_code","1001");
|
|
|
+//
|
|
|
+ entryDebitMap.put("natural_debit_currency",map.get("申请金额(元)"));//本币贷方发生额*与本币借方发生额不能同时为空
|
|
|
+// entryDebitMap.put("primary_debit_amount","0");//
|
|
|
+// entryDebitMap.put("entry_id","0");//
|
|
|
+ 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();
|