|
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpResponse;
|
|
import cn.hutool.http.HttpResponse;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@@ -40,8 +41,10 @@ import org.springframework.stereotype.Service;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
|
+import java.time.LocalDate;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -93,6 +96,9 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
@Value("${u8.appSecret}")
|
|
@Value("${u8.appSecret}")
|
|
private String u8AppSecret;
|
|
private String u8AppSecret;
|
|
|
|
|
|
|
|
+ //结算方式
|
|
|
|
+ public final static String PAY_TYPE = "JSFS001";
|
|
|
|
+
|
|
//审批实例url前缀(卡倍亿)
|
|
//审批实例url前缀(卡倍亿)
|
|
private static final String PROC_INST_PREFIX_URL = "https://aflow.dingtalk.com/dingtalk/web/query/pchomepage.htm?from=oflow&op=true&corpid=dingc3a744cb591a7346f2c783f7214b6d69#/plainapproval?procInstId=";
|
|
private static final String PROC_INST_PREFIX_URL = "https://aflow.dingtalk.com/dingtalk/web/query/pchomepage.htm?from=oflow&op=true&corpid=dingc3a744cb591a7346f2c783f7214b6d69#/plainapproval?procInstId=";
|
|
|
|
|
|
@@ -821,7 +827,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
error.put("ds_sequence",dsSequence);
|
|
error.put("ds_sequence",dsSequence);
|
|
error.put("error_count",errorCodes.size());
|
|
error.put("error_count",errorCodes.size());
|
|
//errorCodes逗号分隔
|
|
//errorCodes逗号分隔
|
|
- error.put("error_codes",errorCodes.stream().collect(Collectors.joining(",")));
|
|
|
|
|
|
+ error.put("errcodes",errorCodes.stream().collect(Collectors.joining(",")));
|
|
errorList.add(error);
|
|
errorList.add(error);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -837,7 +843,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
formData.put("numberField_m21oifwo",time);
|
|
formData.put("numberField_m21oifwo",time);
|
|
//换行分隔errorList
|
|
//换行分隔errorList
|
|
String errorStr = errorList.stream().map(item -> {
|
|
String errorStr = errorList.stream().map(item -> {
|
|
- String s = "数据源序号:" + item.get("ds_sequence") + ",错误数量:" + item.get("error_count") + ",发货单codes:" + item.get("error_codes");
|
|
|
|
|
|
+ String s = "数据源序号:" + item.get("ds_sequence") + ",错误数量:" + item.get("error_count") + ",发货单codes:" + item.get("errcodes");
|
|
return s;
|
|
return s;
|
|
}).collect(Collectors.joining("\n"));
|
|
}).collect(Collectors.joining("\n"));
|
|
formData.put("textareaField_m21oifwj",errorStr);
|
|
formData.put("textareaField_m21oifwj",errorStr);
|
|
@@ -881,6 +887,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void addVoucher(Map map) {
|
|
public void addVoucher(Map map) {
|
|
|
|
+ MDC.put("MDC_KEY_PID","1002");
|
|
if (Objects.isNull(map.get("formInstId"))){
|
|
if (Objects.isNull(map.get("formInstId"))){
|
|
log.info("formInstId不能为空!");
|
|
log.info("formInstId不能为空!");
|
|
return;
|
|
return;
|
|
@@ -891,9 +898,604 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
.formInstId(formInstId)
|
|
.formInstId(formInstId)
|
|
.build(), YDConf.FORM_QUERY.retrieve_id);
|
|
.build(), YDConf.FORM_QUERY.retrieve_id);
|
|
Map formData = ddrNew.getFormData();
|
|
Map formData = ddrNew.getFormData();
|
|
|
|
+ String type = formData.get("selectField_m2sdpe2p").toString();
|
|
|
|
+ int dsSequence = (int) formData.get("numberField_m2o5b8sh");
|
|
|
|
+ String createUser = ((Map)ddrNew.getOriginator().get("name")).get("nameInChinese").toString();
|
|
|
|
+
|
|
|
|
+ Map data = new HashMap();
|
|
|
|
+ switch (type){
|
|
|
|
+ case "资金审批流程":data = process131(formData,dsSequence,createUser);break;
|
|
|
|
+ case "采购部专用资金审批":data = process136(formData,dsSequence,createUser);break;
|
|
|
|
+
|
|
|
|
+// case "信息化建设专用资金审批":data = process138(formData,dsSequence,createUser);break;//20241112 暂时不推送13.8
|
|
|
|
+ default:break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取交易号
|
|
|
|
+ Map tradeParam = new HashMap();
|
|
|
|
+ tradeParam.put("from_account",fromAccount);
|
|
|
|
+ tradeParam.put("app_key", u8AppKey);
|
|
|
|
+ tradeParam.put("token", getU8Token());
|
|
|
|
+ Map<String, Object> tradeMap = get("https://api.yonyouup.com/system/tradeid", tradeParam, null);
|
|
|
|
+ Map trade = (Map) tradeMap.get("trade");
|
|
|
|
+ String tradeId = getString(trade.get("id"));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //推送凭证
|
|
|
|
+ Map<String, Object> pushParam = new HashMap<>();
|
|
|
|
+ pushParam.put("from_account", fromAccount);
|
|
|
|
+ pushParam.put("to_account", toAccount);
|
|
|
|
+ pushParam.put("app_key", u8AppKey);
|
|
|
|
+ pushParam.put("token", getU8Token());
|
|
|
|
+ pushParam.put("tradeid", tradeId);
|
|
|
|
+ pushParam.put("sync", 1);
|
|
|
|
+ pushParam.put("ds_sequence",dsSequence);
|
|
|
|
+
|
|
|
|
+ Map result = post("https://api.yonyouup.com/api/voucher/add", pushParam, null, data);
|
|
|
|
+
|
|
|
|
+ if (!"0".equals(result.get("errcode").toString())){
|
|
|
|
+ log.info("推送凭证失败:{}",result.get("errmsg").toString());
|
|
|
|
+ throw new RuntimeException("推送凭证失败:"+result.get("errmsg").toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Map process138(Map formData, int dsSequence, String createUser) {
|
|
|
|
+ String schPayAccount = getString(formData.get("selectField_lxydz0ub"));//付款方账号
|
|
|
|
+
|
|
|
|
+ String revName = getString(formData.get("textField_lxwwvggc"));//收款人名称
|
|
|
|
+
|
|
|
|
+ String company = getString(formData.get("selectField_lxwwvggb"));//公司抬头
|
|
|
|
+
|
|
|
|
+ String purpose = getString(formData.get("textField_lxwwvggy"));//付款理由
|
|
|
|
+
|
|
|
|
+ String summary = revName + "/" + purpose;//摘要
|
|
|
|
+
|
|
|
|
+ String deptName = getString(formData.get("textField_m2sekyf7"));//部门
|
|
|
|
+
|
|
|
|
+ String currency = getString(formData.get("textField_m2sekyfi"));//币种
|
|
|
|
+
|
|
|
|
+ List<String> sepVoucherCompany = Arrays.asList("宁波卡倍亿电气技术股份有限公司", "宁波卡倍亿新材料科技有限公司", "宁波卡倍亿铜线有限公司", "湖北卡倍亿电气技术有限公司");
|
|
|
|
+
|
|
|
|
+ String voucherType =sepVoucherCompany.contains(company) ? "付" : "记";//凭证类型
|
|
|
|
+
|
|
|
|
+ String applyAmount = getString(formData.get("numberField_lxwwvggi"));//本次支付金额(元)
|
|
|
|
+
|
|
|
|
+ String producer = createUser;//制单人
|
|
|
|
+
|
|
|
|
+ //获取供应商信息
|
|
|
|
+ Map<String,Object> supplierParam = new HashMap<>();
|
|
|
|
+ supplierParam.put("from_account",fromAccount);
|
|
|
|
+ supplierParam.put("to_account",toAccount);
|
|
|
|
+ supplierParam.put("app_key", u8AppKey);
|
|
|
|
+ supplierParam.put("token", getU8Token());
|
|
|
|
+ supplierParam.put("page_index", 1);
|
|
|
|
+ supplierParam.put("rows_per_page", 50);
|
|
|
|
+ supplierParam.put("ds_sequence", dsSequence);
|
|
|
|
+ supplierParam.put("name", revName);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> supplierMap = get("https://api.yonyouup.com/api/vendor/batch_get", supplierParam, null);
|
|
|
|
+ if (!"0".equals(supplierMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取供应商信息失败:{},{}",supplierMap.get("errmsg").toString(),revName);
|
|
|
|
+ throw new RuntimeException("获取供应商信息失败:"+supplierMap.get("errmsg").toString()+","+revName);
|
|
|
|
+ }
|
|
|
|
+ List<Map> vendorList = (List<Map>) supplierMap.get("vendor");
|
|
|
|
+ String supplierCode = getString(vendorList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ //获取部门信息
|
|
|
|
+ Map<String,Object> deptParam = new HashMap<>();
|
|
|
|
+ deptParam.put("from_account",fromAccount);
|
|
|
|
+ deptParam.put("to_account",toAccount);
|
|
|
|
+ deptParam.put("app_key", u8AppKey);
|
|
|
|
+ deptParam.put("token", getU8Token());
|
|
|
|
+ deptParam.put("page_index", 1);
|
|
|
|
+ deptParam.put("rows_per_page", 50);
|
|
|
|
+ deptParam.put("ds_sequence", dsSequence);
|
|
|
|
+ deptParam.put("name", deptName);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> deptMap = get("https://api.yonyouup.com/api/department/batch_get", deptParam, null);
|
|
|
|
+ if (!"0".equals(deptMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取部门信息失败:{},{}",deptMap.get("errmsg").toString(),deptName);
|
|
|
|
+ throw new RuntimeException("获取部门信息失败:"+deptMap.get("errmsg").toString()+","+deptName);
|
|
|
|
+ }
|
|
|
|
+ List<Map> deptList = (List<Map>) deptMap.get("department");
|
|
|
|
+ String deptCode = getString(deptList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ Map resultMap = new HashMap();
|
|
|
|
+ Map topInfoMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ //记账类型
|
|
|
|
+ topInfoMap.put("voucher_type",voucherType);
|
|
|
|
+ topInfoMap.put("enter",producer); //制单人
|
|
|
|
+
|
|
|
|
+ //credit entry信息 贷方
|
|
|
|
+ Map infoMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ Map<String,Object> subjectParam = new HashMap<>();
|
|
|
|
+ subjectParam.put("from_account",fromAccount);
|
|
|
|
+ subjectParam.put("to_account",toAccount);
|
|
|
|
+ subjectParam.put("app_key", u8AppKey);
|
|
|
|
+ subjectParam.put("token", getU8Token());
|
|
|
|
+ subjectParam.put("page_index", 1);
|
|
|
|
+ subjectParam.put("rows_per_page", 50);
|
|
|
|
+ subjectParam.put("ds_sequence", dsSequence);
|
|
|
|
+ subjectParam.put("name", schPayAccount);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> subjectMap = get("https://api.yonyouup.com/api/code/batch_get", subjectParam, null);
|
|
|
|
+ if (!"0".equals(subjectMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取科目信息失败:{},{}",supplierMap.get("errmsg").toString(),schPayAccount);
|
|
|
|
+ throw new RuntimeException("获取科目信息失败:"+supplierMap.get("errmsg").toString()+","+schPayAccount);
|
|
|
|
+ }
|
|
|
|
+ List<Map> subjectList = (List<Map>) subjectMap.get("code");
|
|
|
|
+ String subjectCode = getString(subjectList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ //贷方科目编码
|
|
|
|
+ infoMap.put("account_code", subjectCode);
|
|
|
|
+ //摘要
|
|
|
|
+ infoMap.put("abstract", summary);
|
|
|
|
+ //币种
|
|
|
|
+ infoMap.put("currency", currency);
|
|
|
|
+
|
|
|
|
+ //本币借方发生额*与本币贷方发生额不能同时为空
|
|
|
|
+ infoMap.put("natural_credit_currency", applyAmount);
|
|
|
|
+
|
|
|
|
+ List<Map> creditCashFlowList = new ArrayList<>();
|
|
|
|
+ Map creditCashFlow = new HashMap();
|
|
|
|
+ //币种
|
|
|
|
+ creditCashFlow.put("cexch_name", currency);
|
|
|
|
+ //本币借方发生额*与本币贷方发生额不能同时为空
|
|
|
|
+ creditCashFlow.put("natural_credit_currency", applyAmount);
|
|
|
|
+ //凭证类别字
|
|
|
|
+ creditCashFlow.put("csign", voucherType);
|
|
|
|
+ //科目编码 - 根据CBS 方,实际打款账户和公司来确定
|
|
|
|
+ creditCashFlow.put("ccode", subjectCode);
|
|
|
|
+ //贷方金额
|
|
|
|
+ creditCashFlow.put("mc", applyAmount);
|
|
|
|
+/* //现金项目
|
|
|
|
+ creditCashFlow.put("cCashItem", cashItem);
|
|
|
|
+ //现金项目
|
|
|
|
+ creditCashFlow.put("cash_item", cashItem);*/
|
|
|
|
+ creditCashFlow.put("iyear", LocalDate.now().getYear());
|
|
|
|
+ creditCashFlow.put("RowGuid", UUID.randomUUID().toString());
|
|
|
|
+
|
|
|
|
+ creditCashFlowList.add(creditCashFlow);
|
|
|
|
+
|
|
|
|
+ infoMap.put("cash_flow", creditCashFlowList);
|
|
|
|
+
|
|
|
|
+ Map credit = new HashMap();
|
|
|
|
+ credit.put("entry", infoMap);
|
|
|
|
+ log.info("贷方credit:{}", credit);
|
|
|
|
+
|
|
|
|
+ //debit entry信息 借方
|
|
|
|
+ Map debit = new HashMap();
|
|
|
|
+ List<Map> entryMapList = new ArrayList<>();
|
|
|
|
+ List<Map> details = (List<Map>) formData.get("tableField_lyiffepf");
|
|
|
|
+ String taxesSummary = ""; // 税金摘要
|
|
|
|
+ for (Map detail : details) {
|
|
|
|
+
|
|
|
|
+ String remark = getString(detail.get("textField_lyiffepn"));//备注
|
|
|
|
+ String payType = "其他";//支付类型
|
|
|
|
+
|
|
|
|
+ taxesSummary = revName + "/" + remark;
|
|
|
|
+
|
|
|
|
+ BigDecimal taxesAmount = new BigDecimal(getString(detail.get("numberField_m38g47en")));//金额
|
|
|
|
+
|
|
|
|
+ Map entryMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ //科目编号
|
|
|
|
+ entryMap.put("account_code", "110110");//科目:其他 类型:资产
|
|
|
|
+ //摘要
|
|
|
|
+ entryMap.put("abstract", taxesSummary);
|
|
|
|
+ //本币贷方发生额*与本币借方发生额不能同时为空
|
|
|
|
+ entryMap.put("natural_debit_currency", taxesAmount);
|
|
|
|
+
|
|
|
|
+ Map auxiliaryMap = new HashMap();
|
|
|
|
+ auxiliaryMap.put("dept_id", deptCode);//部门
|
|
|
|
+ auxiliaryMap.put("supplier_id", supplierCode);//供应商
|
|
|
|
+ entryMap.put("auxiliary", auxiliaryMap);
|
|
|
|
+
|
|
|
|
+ entryMapList.add(entryMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ debit.put("entry", entryMapList);
|
|
|
|
+ log.info("借方debit:{}", debit);
|
|
|
|
+
|
|
|
|
+ topInfoMap.put("debit",debit);
|
|
|
|
+ topInfoMap.put("credit",credit);
|
|
|
|
+ resultMap.put("voucher", topInfoMap);
|
|
|
|
+ log.info("voucher:{}", resultMap);
|
|
|
|
+
|
|
|
|
+ return resultMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Map process136(Map formData, int dsSequence, String createUser) {
|
|
|
|
+ String schPayAccount = getString(formData.get("selectField_lxydz0ub"));//付款方账号
|
|
|
|
+
|
|
|
|
+ String revName = getString(formData.get("textField_lxwwvggc"));//收款人名称
|
|
|
|
+
|
|
|
|
+ String company = getString(formData.get("selectField_lxwwvggb"));//公司抬头
|
|
|
|
+
|
|
|
|
+ String purpose = getString(formData.get("textField_lxwwvggy"));//付款理由
|
|
|
|
+
|
|
|
|
+ String summary = revName + "/" + purpose;//摘要
|
|
|
|
+
|
|
|
|
+ String deptName = getString(formData.get("textField_m2sekyf7"));//部门
|
|
|
|
+
|
|
|
|
+ String currency = getString(formData.get("textField_m2sekyfi"));//币种
|
|
|
|
+
|
|
|
|
+ List<String> sepVoucherCompany = Arrays.asList("宁波卡倍亿电气技术股份有限公司", "宁波卡倍亿新材料科技有限公司", "宁波卡倍亿铜线有限公司", "湖北卡倍亿电气技术有限公司");
|
|
|
|
+
|
|
|
|
+ String voucherType =sepVoucherCompany.contains(company) ? "付" : "记";//凭证类型
|
|
|
|
+
|
|
|
|
+ String applyAmount = getString(formData.get("numberField_lxwwvggi"));//本次支付金额(元)
|
|
|
|
+
|
|
|
|
+ String producer = createUser;//制单人
|
|
|
|
+
|
|
|
|
+ String cashItem = getString(formData.get("textField_m2sekyfg"));//现金项目
|
|
|
|
+
|
|
|
|
+ //获取供应商信息
|
|
|
|
+ Map<String,Object> supplierParam = new HashMap<>();
|
|
|
|
+ supplierParam.put("from_account",fromAccount);
|
|
|
|
+ supplierParam.put("to_account",toAccount);
|
|
|
|
+ supplierParam.put("app_key", u8AppKey);
|
|
|
|
+ supplierParam.put("token", getU8Token());
|
|
|
|
+ supplierParam.put("page_index", 1);
|
|
|
|
+ supplierParam.put("rows_per_page", 50);
|
|
|
|
+ supplierParam.put("ds_sequence", dsSequence);
|
|
|
|
+ supplierParam.put("name", revName);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> supplierMap = get("https://api.yonyouup.com/api/vendor/batch_get", supplierParam, null);
|
|
|
|
+ if (!"0".equals(supplierMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取供应商信息失败:{},{}",supplierMap.get("errmsg").toString(),revName);
|
|
|
|
+ throw new RuntimeException("获取供应商信息失败:"+supplierMap.get("errmsg").toString()+","+revName);
|
|
|
|
+ }
|
|
|
|
+ List<Map> vendorList = (List<Map>) supplierMap.get("vendor");
|
|
|
|
+ String supplierCode = getString(vendorList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ //获取部门信息
|
|
|
|
+ Map<String,Object> deptParam = new HashMap<>();
|
|
|
|
+ deptParam.put("from_account",fromAccount);
|
|
|
|
+ deptParam.put("to_account",toAccount);
|
|
|
|
+ deptParam.put("app_key", u8AppKey);
|
|
|
|
+ deptParam.put("token", getU8Token());
|
|
|
|
+ deptParam.put("page_index", 1);
|
|
|
|
+ deptParam.put("rows_per_page", 50);
|
|
|
|
+ deptParam.put("ds_sequence", dsSequence);
|
|
|
|
+ deptParam.put("name", deptName);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> deptMap = get("https://api.yonyouup.com/api/department/batch_get", deptParam, null);
|
|
|
|
+ if (!"0".equals(deptMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取部门信息失败:{},{}",deptMap.get("errmsg").toString(),deptName);
|
|
|
|
+ throw new RuntimeException("获取部门信息失败:"+deptMap.get("errmsg").toString()+","+deptName);
|
|
|
|
+ }
|
|
|
|
+ List<Map> deptList = (List<Map>) deptMap.get("department");
|
|
|
|
+ String deptCode = getString(deptList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ Map resultMap = new HashMap();
|
|
|
|
+ Map topInfoMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ //记账类型
|
|
|
|
+ topInfoMap.put("voucher_type",voucherType);
|
|
|
|
+ topInfoMap.put("enter",producer); //制单人
|
|
|
|
+
|
|
|
|
+ //credit entry信息 贷方
|
|
|
|
+ Map infoMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ Map<String,Object> subjectParam = new HashMap<>();
|
|
|
|
+ subjectParam.put("from_account",fromAccount);
|
|
|
|
+ subjectParam.put("to_account",toAccount);
|
|
|
|
+ subjectParam.put("app_key", u8AppKey);
|
|
|
|
+ subjectParam.put("token", getU8Token());
|
|
|
|
+ subjectParam.put("page_index", 1);
|
|
|
|
+ subjectParam.put("rows_per_page", 50);
|
|
|
|
+ subjectParam.put("ds_sequence", dsSequence);
|
|
|
|
+ subjectParam.put("name", schPayAccount);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> subjectMap = get("https://api.yonyouup.com/api/code/batch_get", subjectParam, null);
|
|
|
|
+ if (!"0".equals(subjectMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取科目信息失败:{},{}",supplierMap.get("errmsg").toString(),schPayAccount);
|
|
|
|
+ throw new RuntimeException("获取科目信息失败:"+supplierMap.get("errmsg").toString()+","+schPayAccount);
|
|
|
|
+ }
|
|
|
|
+ List<Map> subjectList = (List<Map>) subjectMap.get("code");
|
|
|
|
+ String subjectCode = getString(subjectList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ //贷方科目编码
|
|
|
|
+ infoMap.put("account_code", subjectCode);
|
|
|
|
+ //摘要
|
|
|
|
+ infoMap.put("abstract", summary);
|
|
|
|
+ //币种
|
|
|
|
+ infoMap.put("currency", currency);
|
|
|
|
+
|
|
|
|
+ //本币借方发生额*与本币贷方发生额不能同时为空
|
|
|
|
+ infoMap.put("natural_credit_currency", applyAmount);
|
|
|
|
+
|
|
|
|
+ List<Map> creditCashFlowList = new ArrayList<>();
|
|
|
|
+ Map creditCashFlow = new HashMap();
|
|
|
|
+ //币种
|
|
|
|
+ creditCashFlow.put("cexch_name", currency);
|
|
|
|
+ //本币借方发生额*与本币贷方发生额不能同时为空
|
|
|
|
+ creditCashFlow.put("natural_credit_currency", applyAmount);
|
|
|
|
+ //凭证类别字
|
|
|
|
+ creditCashFlow.put("csign", voucherType);
|
|
|
|
+ //科目编码 - 根据CBS 方,实际打款账户和公司来确定
|
|
|
|
+ creditCashFlow.put("ccode", subjectCode);
|
|
|
|
+ //贷方金额
|
|
|
|
+ creditCashFlow.put("mc", applyAmount);
|
|
|
|
+ //现金项目
|
|
|
|
+ creditCashFlow.put("cCashItem", cashItem);
|
|
|
|
+ //现金项目
|
|
|
|
+ creditCashFlow.put("cash_item", cashItem);
|
|
|
|
+ creditCashFlow.put("iyear", LocalDate.now().getYear());
|
|
|
|
+ creditCashFlow.put("RowGuid", UUID.randomUUID().toString());
|
|
|
|
+
|
|
|
|
+ creditCashFlowList.add(creditCashFlow);
|
|
|
|
+
|
|
|
|
+ infoMap.put("cash_flow", creditCashFlowList);
|
|
|
|
+
|
|
|
|
+ Map credit = new HashMap();
|
|
|
|
+ credit.put("entry", infoMap);
|
|
|
|
+ log.info("贷方credit:{}", credit);
|
|
|
|
+
|
|
|
|
+ //debit entry信息 借方
|
|
|
|
+ Map debit = new HashMap();
|
|
|
|
+ List<Map> entryMapList = new ArrayList<>();
|
|
|
|
+ List<Map> details = (List<Map>) formData.get("tableField_lxwwvggl");
|
|
|
|
+ String taxesSummary = ""; // 税金摘要
|
|
|
|
+ for (Map detail : details) {
|
|
|
|
+
|
|
|
|
+ String productName = getString(detail.get("textField_lxwwvggm"));//货物或劳务名称
|
|
|
|
+ String payType = getString(detail.get("selectField_m2sekyfa")).split("-")[0].split("\\(")[0];//支付类型
|
|
|
|
+
|
|
|
|
+ taxesSummary = revName + "/" + productName;
|
|
|
|
+
|
|
|
|
+ BigDecimal taxesAmount = new BigDecimal(getString(detail.get("numberField_lxwwvggo")));//金额
|
|
|
|
+
|
|
|
|
+ Map entryMap = new HashMap();
|
|
|
|
+ //科目编号
|
|
|
|
+ subjectParam.put("name",payType);
|
|
|
|
+ subjectMap = get("https://api.yonyouup.com/api/code/batch_get", subjectParam, null);
|
|
|
|
+
|
|
|
|
+ if (!"0".equals(subjectMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取科目信息失败:{},{}",supplierMap.get("errmsg").toString(),productName);
|
|
|
|
+ throw new RuntimeException("获取科目信息失败:"+supplierMap.get("errmsg").toString()+","+productName);
|
|
|
|
+ }
|
|
|
|
+ subjectList = (List<Map>) subjectMap.get("code");
|
|
|
|
+ subjectCode = getString(subjectList.get(0).get("code"));
|
|
|
|
+ //科目编号
|
|
|
|
+ entryMap.put("account_code", subjectCode);
|
|
|
|
+ //摘要
|
|
|
|
+ entryMap.put("abstract", taxesSummary);
|
|
|
|
+ //本币贷方发生额*与本币借方发生额不能同时为空
|
|
|
|
+ entryMap.put("natural_debit_currency", taxesAmount);
|
|
|
|
+
|
|
|
|
+ Map auxiliaryMap = new HashMap();
|
|
|
|
+ auxiliaryMap.put("dept_id", deptCode);//部门
|
|
|
|
+ auxiliaryMap.put("supplier_id", supplierCode);//供应商
|
|
|
|
+ entryMap.put("auxiliary", auxiliaryMap);
|
|
|
|
+
|
|
|
|
+ entryMapList.add(entryMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ debit.put("entry", entryMapList);
|
|
|
|
+ log.info("借方debit:{}", debit);
|
|
|
|
+
|
|
|
|
+ topInfoMap.put("debit",debit);
|
|
|
|
+ topInfoMap.put("credit",credit);
|
|
|
|
+ resultMap.put("voucher", topInfoMap);
|
|
|
|
+ log.info("voucher:{}", resultMap);
|
|
|
|
+
|
|
|
|
+ return resultMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Map process131(Map formData,int dsSequence,String createUser) {
|
|
|
|
+ String schPayAccount = getString(formData.get("selectField_lxydz0ub"));//付款方账号
|
|
|
|
+
|
|
|
|
+ String revName = getString(formData.get("textField_lxwwvggc"));//收款人名称
|
|
|
|
+
|
|
|
|
+ String company = getString(formData.get("selectField_lxwwvggb"));//公司抬头
|
|
|
|
+
|
|
|
|
+ String purpose = getString(formData.get("textField_lxydz0ug"));//用途
|
|
|
|
+
|
|
|
|
+ String summary = revName + "/" + purpose;//摘要
|
|
|
|
+
|
|
|
|
+ String deptName = getString(formData.get("textField_m2sekyf7"));//部门
|
|
|
|
+
|
|
|
|
+ String currency = getString(formData.get("textField_m2sekyfi"));//币种
|
|
|
|
+
|
|
|
|
+ List<String> sepVoucherCompany = Arrays.asList("宁波卡倍亿电气技术股份有限公司", "宁波卡倍亿新材料科技有限公司", "宁波卡倍亿铜线有限公司", "湖北卡倍亿电气技术有限公司");
|
|
|
|
+
|
|
|
|
+ String voucherType =sepVoucherCompany.contains(company) ? "付" : "记";//凭证类型
|
|
|
|
+
|
|
|
|
+ String applyAmount = getString(formData.get("numberField_lxwwvggi"));//本次支付金额(元)
|
|
|
|
+
|
|
|
|
+ String producer = createUser;//制单人
|
|
|
|
+
|
|
|
|
+ String cashItem = getString(formData.get("textField_m2sekyfg"));//现金项目
|
|
|
|
+
|
|
|
|
+ //获取供应商信息
|
|
|
|
+ Map<String,Object> supplierParam = new HashMap<>();
|
|
|
|
+ supplierParam.put("from_account",fromAccount);
|
|
|
|
+ supplierParam.put("to_account",toAccount);
|
|
|
|
+ supplierParam.put("app_key", u8AppKey);
|
|
|
|
+ supplierParam.put("token", getU8Token());
|
|
|
|
+ supplierParam.put("page_index", 1);
|
|
|
|
+ supplierParam.put("rows_per_page", 50);
|
|
|
|
+ supplierParam.put("ds_sequence", dsSequence);
|
|
|
|
+ supplierParam.put("name", revName);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> supplierMap = get("https://api.yonyouup.com/api/vendor/batch_get", supplierParam, null);
|
|
|
|
+ if (!"0".equals(supplierMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取供应商信息失败:{},{}",supplierMap.get("errmsg").toString(),revName);
|
|
|
|
+ throw new RuntimeException("获取供应商信息失败:"+supplierMap.get("errmsg").toString()+","+revName);
|
|
|
|
+ }
|
|
|
|
+ List<Map> vendorList = (List<Map>) supplierMap.get("vendor");
|
|
|
|
+ String supplierCode = getString(vendorList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ //获取部门信息
|
|
|
|
+ Map<String,Object> deptParam = new HashMap<>();
|
|
|
|
+ deptParam.put("from_account",fromAccount);
|
|
|
|
+ deptParam.put("to_account",toAccount);
|
|
|
|
+ deptParam.put("app_key", u8AppKey);
|
|
|
|
+ deptParam.put("token", getU8Token());
|
|
|
|
+ deptParam.put("page_index", 1);
|
|
|
|
+ deptParam.put("rows_per_page", 50);
|
|
|
|
+ deptParam.put("ds_sequence", dsSequence);
|
|
|
|
+ deptParam.put("name", deptName);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> deptMap = get("https://api.yonyouup.com/api/department/batch_get", deptParam, null);
|
|
|
|
+ if (!"0".equals(deptMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取部门信息失败:{},{}",deptMap.get("errmsg").toString(),deptName);
|
|
|
|
+ throw new RuntimeException("获取部门信息失败:"+deptMap.get("errmsg").toString()+","+deptName);
|
|
|
|
+ }
|
|
|
|
+ List<Map> deptList = (List<Map>) deptMap.get("department");
|
|
|
|
+ String deptCode = getString(deptList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ Map resultMap = new HashMap();
|
|
|
|
+ Map topInfoMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ //记账类型
|
|
|
|
+ topInfoMap.put("voucher_type",voucherType);
|
|
|
|
+ topInfoMap.put("enter",producer); //制单人
|
|
|
|
+
|
|
|
|
+ //credit entry信息 贷方
|
|
|
|
+ Map infoMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ Map<String,Object> subjectParam = new HashMap<>();
|
|
|
|
+ subjectParam.put("from_account",fromAccount);
|
|
|
|
+ subjectParam.put("to_account",toAccount);
|
|
|
|
+ subjectParam.put("app_key", u8AppKey);
|
|
|
|
+ subjectParam.put("token", getU8Token());
|
|
|
|
+ subjectParam.put("page_index", 1);
|
|
|
|
+ subjectParam.put("rows_per_page", 50);
|
|
|
|
+ subjectParam.put("ds_sequence", dsSequence);
|
|
|
|
+ subjectParam.put("name", schPayAccount);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> subjectMap = get("https://api.yonyouup.com/api/code/batch_get", subjectParam, null);
|
|
|
|
+ if (!"0".equals(subjectMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取科目信息失败:{},{}",supplierMap.get("errmsg").toString(),schPayAccount);
|
|
|
|
+ throw new RuntimeException("获取科目信息失败:"+supplierMap.get("errmsg").toString()+","+schPayAccount);
|
|
|
|
+ }
|
|
|
|
+ List<Map> subjectList = (List<Map>) subjectMap.get("code");
|
|
|
|
+ String subjectCode = getString(subjectList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ //贷方科目编码
|
|
|
|
+ infoMap.put("account_code", subjectCode);
|
|
|
|
+ //摘要
|
|
|
|
+ infoMap.put("abstract", summary);
|
|
|
|
+ //币种
|
|
|
|
+ infoMap.put("currency", currency);
|
|
|
|
+
|
|
|
|
+ //本币借方发生额*与本币贷方发生额不能同时为空
|
|
|
|
+ infoMap.put("natural_credit_currency", applyAmount);
|
|
|
|
+
|
|
|
|
+ Map auxiliary = new HashMap();
|
|
|
|
+
|
|
|
|
+// //项目档案-现流编号
|
|
|
|
+ auxiliary.put("item_class", "05");
|
|
|
|
+ infoMap.put("auxiliary", auxiliary);
|
|
|
|
+
|
|
|
|
+ List<Map> creditCashFlowList = new ArrayList<>();
|
|
|
|
+ Map creditCashFlow = new HashMap();
|
|
|
|
+ //币种
|
|
|
|
+ creditCashFlow.put("cexch_name", currency);
|
|
|
|
+ //本币借方发生额*与本币贷方发生额不能同时为空
|
|
|
|
+ creditCashFlow.put("natural_credit_currency", applyAmount);
|
|
|
|
+ //凭证类别字
|
|
|
|
+ creditCashFlow.put("csign", voucherType);
|
|
|
|
+
|
|
|
|
+ creditCashFlow.put("ccode", subjectCode);
|
|
|
|
+ //贷方金额
|
|
|
|
+ creditCashFlow.put("mc", applyAmount);
|
|
|
|
+ //现金项目
|
|
|
|
+ creditCashFlow.put("cCashItem", cashItem);
|
|
|
|
+ //现金项目
|
|
|
|
+ creditCashFlow.put("cash_item", cashItem);
|
|
|
|
+ creditCashFlow.put("iyear", LocalDate.now().getYear());
|
|
|
|
+ creditCashFlow.put("RowGuid", UUID.randomUUID().toString());
|
|
|
|
+
|
|
|
|
+ creditCashFlowList.add(creditCashFlow);
|
|
|
|
+ infoMap.put("cash_flow", creditCashFlowList);
|
|
|
|
+
|
|
|
|
+ Map credit = new HashMap();
|
|
|
|
+ credit.put("entry", infoMap);
|
|
|
|
+ log.info("贷方credit:{}", credit);
|
|
|
|
+ //debit entry信息 借方
|
|
|
|
+ Map debit = new HashMap();
|
|
|
|
+ List<Map> entryMapList = new ArrayList<>();
|
|
|
|
+ List<Map> details = (List<Map>) formData.get("tableField_lxwwvggl");
|
|
|
|
+ BigDecimal taxesSum = BigDecimal.ZERO; // 税金总计
|
|
|
|
+ String taxesSummary = ""; // 税金摘要
|
|
|
|
+ for (Map detail : details) {
|
|
|
|
+ String productName = getString(detail.get("textField_lxwwvggm"));//货物或劳务名称
|
|
|
|
+ String payType = getString(detail.get("selectField_m2sekyfa")).split("-")[0].split("\\(")[0];//支付类型
|
|
|
|
+
|
|
|
|
+ taxesSummary = revName + "/" + productName;
|
|
|
|
+
|
|
|
|
+ BigDecimal taxesAmount = new BigDecimal(getString(detail.get("numberField_lxwwvggo")));//金额
|
|
|
|
+
|
|
|
|
+ BigDecimal taxes = new BigDecimal(getString(detail.get("numberField_m2sekyf8")));//税金金额
|
|
|
|
+
|
|
|
|
+ taxesSum = taxesSum.add(taxes);
|
|
|
|
+ Map entryMap = new HashMap();
|
|
|
|
+ //科目编号
|
|
|
|
+ subjectParam.put("name",payType);
|
|
|
|
+ subjectMap = get("https://api.yonyouup.com/api/code/batch_get", subjectParam, null);
|
|
|
|
+
|
|
|
|
+ if (!"0".equals(subjectMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取科目信息失败:{},{}",supplierMap.get("errmsg").toString(),productName);
|
|
|
|
+ throw new RuntimeException("获取科目信息失败:"+supplierMap.get("errmsg").toString()+","+productName);
|
|
|
|
+ }
|
|
|
|
+ subjectList = (List<Map>) subjectMap.get("code");
|
|
|
|
+ subjectCode = getString(subjectList.get(0).get("code"));
|
|
|
|
+ entryMap.put("account_code", subjectCode);
|
|
|
|
+
|
|
|
|
+ //摘要
|
|
|
|
+ entryMap.put("abstract", revName + "/" + productName);
|
|
|
|
+
|
|
|
|
+ //本币贷方发生额*与本币借方发生额不能同时为空
|
|
|
|
+ entryMap.put("natural_debit_currency", taxesAmount.subtract(taxes).toPlainString());
|
|
|
|
|
|
- System.out.println(formData);
|
|
|
|
|
|
+ Map auxiliaryMap = new HashMap();
|
|
|
|
+ auxiliaryMap.put("dept_id", deptCode);//部门
|
|
|
|
+ auxiliaryMap.put("supplier_id", supplierCode);//供应商
|
|
|
|
+ entryMap.put("auxiliary", auxiliaryMap);
|
|
|
|
|
|
|
|
+ entryMapList.add(entryMap);
|
|
|
|
+ }
|
|
|
|
+ // 添加税金科目
|
|
|
|
+ if (taxesSum.compareTo(BigDecimal.ZERO) == 1) { // 税金总和大于0
|
|
|
|
+ Map entryMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ subjectParam.put("name","进项税额");
|
|
|
|
+ subjectMap = get("https://api.yonyouup.com/api/code/batch_get", subjectParam, null);
|
|
|
|
+ if (!"0".equals(subjectMap.get("errcode").toString())){
|
|
|
|
+ log.info("获取科目信息失败:{},{}",supplierMap.get("errmsg").toString(),"进项税额");
|
|
|
|
+ throw new RuntimeException("获取科目信息失败:"+supplierMap.get("errmsg").toString()+","+"进项税额");
|
|
|
|
+ }
|
|
|
|
+ subjectList = (List<Map>) subjectMap.get("code");
|
|
|
|
+ subjectCode = getString(subjectList.get(0).get("code"));
|
|
|
|
+
|
|
|
|
+ //科目编号
|
|
|
|
+ entryMap.put("account_code", subjectCode); // 税金
|
|
|
|
+ //摘要
|
|
|
|
+ entryMap.put("abstract", taxesSummary);
|
|
|
|
+ //本币贷方发生额*与本币借方发生额不能同时为空
|
|
|
|
+ entryMap.put("natural_debit_currency", taxesSum.toPlainString());
|
|
|
|
+
|
|
|
|
+ Map auxiliaryMap = new HashMap();
|
|
|
|
+ auxiliaryMap.put("dept_id", deptCode);//部门
|
|
|
|
+ auxiliaryMap.put("supplier_id", supplierCode);//供应商
|
|
|
|
+ entryMap.put("auxiliary", auxiliaryMap);
|
|
|
|
+ entryMapList.add(entryMap);
|
|
|
|
+ }
|
|
|
|
+ debit.put("entry", entryMapList);
|
|
|
|
+ log.info("借方debit:{}", debit);
|
|
|
|
+
|
|
|
|
+ topInfoMap.put("debit",debit);
|
|
|
|
+ topInfoMap.put("credit",credit);
|
|
|
|
+ resultMap.put("voucher", topInfoMap);
|
|
|
|
+ log.info("voucher:{}", resultMap);
|
|
|
|
+
|
|
|
|
+ return resultMap;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -928,6 +1530,55 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 封装POST请求
|
|
|
|
+ *
|
|
|
|
+ * @param url 请求的URL
|
|
|
|
+ * @param params 请求参数
|
|
|
|
+ * @param headers 请求头
|
|
|
|
+ * @param body 请求体
|
|
|
|
+ * @return 响应内容
|
|
|
|
+ */
|
|
|
|
+ public static Map<String, Object> post(String url, Map<String, Object> params, Map<String, String> headers, Map<String, Object> body) {
|
|
|
|
+ log.info("POST 请求url:{}, 请求参数:{}, 请求头:{}, 请求体:{}", url, params, headers, body);
|
|
|
|
+
|
|
|
|
+ String newUrl = url;
|
|
|
|
+ StringBuffer param = new StringBuffer();
|
|
|
|
+ for (String key : params.keySet()) {
|
|
|
|
+ param.append(key + "=" + params.get(key).toString() + "&");
|
|
|
|
+ }
|
|
|
|
+ String paramStr = param.toString();
|
|
|
|
+ paramStr = paramStr.substring(0, paramStr.length() - 1);
|
|
|
|
+ if (newUrl.indexOf("?") >= 0) {
|
|
|
|
+ newUrl += "&" + paramStr;
|
|
|
|
+ } else {
|
|
|
|
+ newUrl += "?" + paramStr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ HttpRequest request = HttpUtil.createPost(newUrl);
|
|
|
|
+ /*if (params != null) {
|
|
|
|
+ request.form(params);
|
|
|
|
+ }*/
|
|
|
|
+ if (headers != null) {
|
|
|
|
+ request.addHeaders(headers);
|
|
|
|
+ }
|
|
|
|
+ if (body != null) {
|
|
|
|
+ request.body(JSONUtil.toJsonStr(body), "application/json");
|
|
|
|
+ }
|
|
|
|
+ HttpResponse response = request.execute();
|
|
|
|
+// Map<String,Object> result = JSONUtil.toBean(response.body(), Map.class);
|
|
|
|
+ Map<String, Object> result = null;
|
|
|
|
+ try {
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
+ result = objectMapper.readValue(response.body(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ log.info("响应结果: {}", result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
private String getU8Token(){
|
|
private String getU8Token(){
|
|
String accessToken = UtilToken.get("u8-token");
|
|
String accessToken = UtilToken.get("u8-token");
|
|
if (StringUtils.isNotBlank(accessToken)) {
|
|
if (StringUtils.isNotBlank(accessToken)) {
|