
12 changed files with 366 additions and 0 deletions
@ -0,0 +1,45 @@ |
|||
package com.yxt.anrui.fin.api.kingdee.voucher; |
|||
|
|||
import com.yxt.common.core.dto.Dto; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.awt.print.Book; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author Administrator |
|||
* @description |
|||
* @date 2023/9/12 18:13 |
|||
*/ |
|||
@Data |
|||
public class Voucher { |
|||
@ApiModelProperty("账簿") |
|||
public String accountBook; |
|||
@ApiModelProperty("业务日期") |
|||
public String bussDate; |
|||
@ApiModelProperty("凭证字") |
|||
public String voucherWord; |
|||
@ApiModelProperty("凭证号") |
|||
public String voucherNo; |
|||
@ApiModelProperty("收款明细") |
|||
public List<Voucher.VoucherResultDetailDto> resultDetails; |
|||
|
|||
@Data |
|||
public static class VoucherResultDetailDto implements Dto { |
|||
|
|||
|
|||
@ApiModelProperty("摘要") |
|||
public String remark; |
|||
@ApiModelProperty("科目编码") |
|||
public String subjectNo; |
|||
@ApiModelProperty("核算维度部门") |
|||
public String dimensionDept; |
|||
@ApiModelProperty("核算维度客户") |
|||
public String dimensionCustom; |
|||
@ApiModelProperty("借方金额") |
|||
public String debit; |
|||
@ApiModelProperty("贷方金额") |
|||
public String credit; |
|||
} |
|||
} |
@ -0,0 +1,59 @@ |
|||
package com.yxt.anrui.fin.biz.kingdee.voucher; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.alibaba.fastjson.parser.Feature; |
|||
import com.yxt.anrui.fin.biz.kingdee.KingDeeUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 封装转换的类 |
|||
*/ |
|||
public class VoucherCastToKingDeeBillFields { |
|||
/** |
|||
* 构造金蝶需要的数据结构 并对字段赋值 |
|||
* |
|||
* @param map_fEntityModel_ |
|||
* @param vehicleList |
|||
* @return |
|||
*/ |
|||
public static String getKingDeeData(Map<String,String> map_fEntityModel_,List<Map<String,String>> vehicleList){ |
|||
/** |
|||
* 取模板 |
|||
*/ |
|||
String readJsonFile = KingDeeUtils.readJsonFile("com/yxt/anrui/fin/biz/kingdee/voucher/data.json"); |
|||
String fEntityData_ = KingDeeUtils.readJsonFile("com/yxt/anrui/fin/biz/kingdee/voucher/data_data1.json"); |
|||
String fEntityModel_ = KingDeeUtils.readJsonFile("com/yxt/anrui/fin/biz/kingdee/voucher/data_model.json"); |
|||
|
|||
//模板字符创转json
|
|||
JSONObject jsonObj= JSONObject.parseObject(readJsonFile, Feature.OrderedField); |
|||
JSONObject jsonFEntityData_= JSONObject.parseObject(fEntityData_,Feature.OrderedField); |
|||
fEntityModel_ =KingDeeUtils.replaceTemplateParams(fEntityModel_, map_fEntityModel_); |
|||
JSONObject jsonFEntityModel_= JSONObject.parseObject(fEntityModel_,Feature.OrderedField); |
|||
|
|||
List<JSONObject> list_fEntity_=new ArrayList<>(); |
|||
|
|||
//对模板字段赋值 根据传递进来的map数据的集合进行赋值
|
|||
for(int i=0;i<vehicleList.size();i++){ |
|||
String fEntity_ = KingDeeUtils.readJsonFile("com/yxt/anrui/fin/biz/kingdee/voucher/data_FEntity.json"); |
|||
Map<String,String> params=vehicleList.get(i); |
|||
Map<String,String> map_fEntity_=new HashMap<>(); |
|||
for (Map.Entry<String, String> entry : params.entrySet()) { |
|||
map_fEntity_.put(entry.getKey(),entry.getValue()); |
|||
} |
|||
fEntity_ =KingDeeUtils.replaceTemplateParams(fEntity_, map_fEntity_); |
|||
list_fEntity_.add(JSONObject.parseObject(fEntity_,Feature.OrderedField)); |
|||
} |
|||
|
|||
jsonFEntityModel_.put("FEntity", JSONArray.parseArray(JSON.toJSONString(list_fEntity_))); |
|||
jsonFEntityData_.put("Model",JSONObject.parseObject(JSON.toJSONString(jsonFEntityModel_),Feature.OrderedField)); |
|||
jsonObj.put("data",jsonFEntityData_.toJSONString()); |
|||
|
|||
return jsonObj.toJSONString(); |
|||
} |
|||
} |
@ -0,0 +1,98 @@ |
|||
package com.yxt.anrui.fin.biz.kingdee.voucher; |
|||
|
|||
import com.yxt.anrui.fin.api.kingdee.KingDeeBillId; |
|||
import com.yxt.anrui.fin.api.kingdee.KingDeeBillUrl; |
|||
import com.yxt.anrui.fin.api.kingdee.otherarreceivable.OtherReceivable; |
|||
import com.yxt.anrui.fin.api.kingdee.voucher.Voucher; |
|||
import com.yxt.anrui.fin.biz.kingdee.FinKingDeeService; |
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class VoucherService extends FinKingDeeService { |
|||
|
|||
/** |
|||
* 生成的凭证的数据,推送到金蝶的平台中 |
|||
* |
|||
* @param voucher |
|||
* @return |
|||
*/ |
|||
public ResultBean saveVoucher(Voucher voucher) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
//业务表的主表数据集合
|
|||
Map<String, String> map_fEntityModel_ = new HashMap<>(); |
|||
//物料的数组集合
|
|||
//账簿
|
|||
if (StringUtils.isBlank(voucher.getAccountBook())) { |
|||
return rb.setMsg("账簿不能为空"); |
|||
} |
|||
map_fEntityModel_.put("FAccountBookID", voucher.getAccountBook()); |
|||
//业务日期
|
|||
if (StringUtils.isBlank(voucher.getBussDate())) { |
|||
return rb.setMsg("业务日期不能为空"); |
|||
} |
|||
map_fEntityModel_.put("FDate", voucher.getBussDate()); |
|||
//凭证字
|
|||
if (StringUtils.isBlank(voucher.getVoucherWord())) { |
|||
return rb.setMsg("凭证字不能为空"); |
|||
} |
|||
map_fEntityModel_.put("FVOUCHERGROUPID", voucher.getVoucherWord()); |
|||
//凭证号
|
|||
if (StringUtils.isBlank(voucher.getVoucherNo())) { |
|||
return rb.setMsg("凭证号不能为空"); |
|||
} |
|||
map_fEntityModel_.put("FVOUCHERGROUPNO", voucher.getVoucherNo()); |
|||
|
|||
List<Voucher.VoucherResultDetailDto> voucherResultDetailDtos = voucher.getResultDetails() == null ? new ArrayList<>() : voucher.getResultDetails(); |
|||
//准备 物料列表的数据
|
|||
ResultBean<List<Map<String, String>>> vehicleListMap = createVehicleListsForReceivableBill(voucherResultDetailDtos); |
|||
if (!vehicleListMap.getSuccess()) { |
|||
return rb.setMsg(vehicleListMap.getMsg()); |
|||
} |
|||
String kingDeeData = VoucherCastToKingDeeBillFields.getKingDeeData(map_fEntityModel_, vehicleListMap.getData()); |
|||
try { |
|||
ResultBean<String> resultBean1 = accessKingDeeInterface(KingDeeBillId.GL_VOUCHER.getID(), kingDeeData, KingDeeBillUrl.SAVE_URL.getURL()); |
|||
if (!resultBean1.getSuccess()) { |
|||
log.info("凭证保存失败!"); |
|||
return rb.setMsg("凭证保存失败!"); |
|||
} |
|||
log.info("凭证保存成功!"); |
|||
// String submitKD = getSubmitKD(resultBean1.getData(), KingDeeBillId.AR_OTHERRECEIVABLE.getID());
|
|||
// ResultBean<String> resultBean2 = accessKingDeeInterface(KingDeeBillId.AR_OTHERRECEIVABLE.getID(), submitKD, KingDeeBillUrl.SUBMIT_URL.getURL());
|
|||
// if (!resultBean2.getSuccess()) {
|
|||
// log.info("凭证提交失败!");
|
|||
// return rb.setMsg("凭证提交失败!");
|
|||
// }
|
|||
// log.info("凭证提交成功!");
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return rb.success(); |
|||
} |
|||
|
|||
public ResultBean<List<Map<String, String>>> createVehicleListsForReceivableBill(List<Voucher.VoucherResultDetailDto> voucherResultDetailDtos) { |
|||
ResultBean<List<Map<String, String>>> rb = ResultBean.fireFail(); |
|||
List<Map<String, String>> voucherDetailMap = new ArrayList<>(); |
|||
for (int i = 0; i < voucherResultDetailDtos.size(); i++) { |
|||
Voucher.VoucherResultDetailDto c = voucherResultDetailDtos.get(i); |
|||
Map<String, String> m = new HashMap<>(); |
|||
if (StringUtils.isBlank(c.getSubjectNo())) { |
|||
return rb.setMsg("科目编码不能为空"); |
|||
} |
|||
m.put("FEXPLANATION", c.getRemark()); |
|||
m.put("FACCOUNTID", c.getSubjectNo()); |
|||
m.put("FFLEX5", c.getDimensionDept()); |
|||
m.put("FFLEX6", c.getDimensionCustom()); |
|||
m.put("FDEBIT", c.getDebit()); |
|||
m.put("FCREDIT", c.getCredit()); |
|||
voucherDetailMap.add(m); |
|||
} |
|||
return rb.success().setData(voucherDetailMap); |
|||
} |
|||
} |
@ -0,0 +1,4 @@ |
|||
{ |
|||
"formId": "GL_VOUCHER", |
|||
"data": "@KD_data" |
|||
} |
@ -0,0 +1,24 @@ |
|||
{ |
|||
"FEXPLANATION": "@KD_FEXPLANATION", |
|||
"FACCOUNTID": { |
|||
"FNumber": "@KD_FACCOUNTID" |
|||
}, |
|||
"FDetailID": { |
|||
"FDETAILID__FFLEX5": { |
|||
"FNumber": "@KD_FFLEX5" |
|||
}, |
|||
"FDETAILID__FFLEX6": { |
|||
"FNumber": "@KD_FFLEX6" |
|||
} |
|||
}, |
|||
"FCURRENCYID": { |
|||
"FNumber": "PRE001" |
|||
}, |
|||
"FEXCHANGERATETYPE": { |
|||
"FNumber": "HLTX01_SYS" |
|||
}, |
|||
"FEXCHANGERATE": 1, |
|||
"FAMOUNTFOR": "", |
|||
"FDEBIT": "@KD_FDEBIT", |
|||
"FCREDIT": "@KD_FCREDIT" |
|||
} |
@ -0,0 +1,13 @@ |
|||
{ |
|||
"Creator": "", |
|||
"NeedUpDateFields": [], |
|||
"NeedReturnFields": [], |
|||
"IsDeleteEntry": "True", |
|||
"SubSystemId": "", |
|||
"IsVerifyBaseDataField": "false", |
|||
"IsEntryBatchFill": "True", |
|||
"ValidateFlag": "True", |
|||
"NumberSearch": "True", |
|||
"InterationFlags": "", |
|||
"Model": {} |
|||
} |
@ -0,0 +1,13 @@ |
|||
{ |
|||
"FVOUCHERID": 0, |
|||
"FAccountBookID": { |
|||
"FNumber": "@KD_FAccountBookID" |
|||
}, |
|||
"FDate": "@KD_FDate", |
|||
"FVOUCHERGROUPID": { |
|||
"FNumber": "@KD_FVOUCHERGROUPID" |
|||
}, |
|||
"FVOUCHERGROUPNO": "@KD_FVOUCHERGROUPNO", |
|||
|
|||
"FEntity": [] |
|||
} |
@ -0,0 +1,81 @@ |
|||
请求参数说明: |
|||
1.formid:业务对象表单Id,字符串类型(必录) |
|||
2.data:Json格式数据(详情参考Json格式数据)(必录) |
|||
2.1.Creator:创建者内码(非必录) |
|||
2.2.NeedUpDateFields:需要更新的字段,数组类型,格式:[key1,key2,...](非必录),注(更新单据体字段得加上单据体key) |
|||
2.3.NeedReturnFields:需返回结果的字段集合,数组类型,格式:[key,entitykey.key,...](非必录),注(返回单据体字段格式:entitykey.key) |
|||
2.4.IsDeleteEntry:是否删除已存在的分录,布尔类型,默认true(非必录) |
|||
2.5.SubSystemId:表单所在的子系统内码,字符串类型(非必录) |
|||
2.6.IsVerifyBaseDataField:是否验证所有的基础资料有效性,布尔类,默认false(非必录) |
|||
2.7.IsEntryBatchFill:是否批量填充分录,默认true(非必录) |
|||
2.8.ValidateFlag:是否验证标志,布尔类型,默认true(非必录) |
|||
2.9.NumberSearch:是否用编码搜索基础资料,布尔类型,默认true(非必录) |
|||
2.10.InterationFlags:交互标志集合,字符串类型,分号分隔,格式:"flag1;flag2;..."(非必录),例如(允许负库存标识:STK_InvCheckResult) |
|||
2.11.Model:表单数据包,Json类型(必录) |
|||
|
|||
字段说明: |
|||
核算维度:FDetailID |
|||
币别:FCURRENCYID (必填项) |
|||
摘要:FEXPLANATION |
|||
科目编码:FACCOUNTID (必填项) |
|||
原币金额:FAMOUNTFOR |
|||
借方金额:FDEBIT |
|||
汇率类型:FEXCHANGERATETYPE (必填项) |
|||
汇率:FEXCHANGERATE |
|||
调整期间:FADJPRD |
|||
引入版本号:FIMPORTVERSION |
|||
合计: :FAmountDisplay |
|||
打印次数:FPRINTTIMES |
|||
转存信息-转入:FDepositIn |
|||
转存信息-转出:FDepositOut |
|||
当前年度:FCurrentYear |
|||
当前期间:FCurrentPeriod |
|||
单价:FPrice |
|||
单位:FUnitId |
|||
科目全名:FAcctFullName |
|||
数量:FQty |
|||
上移下移之前的分录内码:FOldEntryId |
|||
现金流量#分录ID:FEXPORTENTRYID |
|||
科目单位数量:FAcctUnitQty |
|||
计量单位数量:FBaseUnitQty |
|||
结算方式:FSettleTypeID |
|||
本位币金额:FAmount |
|||
贷方金额:FCREDIT |
|||
借贷方向:FDC |
|||
是否已指定现金流量:FCASHFLOWITEM |
|||
是否参与多栏账汇总:FISMULTICOLLECT |
|||
结算号:FSETTLENO |
|||
科目名称:FACCOUNTNAME |
|||
修改日期:FModifyDate |
|||
作废状态:FInvalid |
|||
用户组:FCreaterGroup |
|||
借方总金额:FDEBITTOTAL |
|||
贷方总金额:FCREDITTOTAL |
|||
出纳:FCASHIERID |
|||
审核日期:FAuditDate |
|||
审核:FCHECKERID |
|||
过账:FPOSTERID |
|||
日期:FDate (必填项) |
|||
外币:FISFOREIGNCUR |
|||
凭证编号:FBillNo |
|||
账簿:FAccountBookID (必填项) |
|||
会计年度:FYEAR |
|||
期间:FPERIOD |
|||
凭证字:FVOUCHERGROUPID (必填项) |
|||
附件数:FATTACHMENTS |
|||
核算组织:FACCBOOKORGID |
|||
已指定现金流量项目:FISCASHFLOW |
|||
业务类型:FSourceBillKey |
|||
本位币(辅助):FBASECURRENCYID |
|||
数量金额核算:FIsQty |
|||
修改人:FModifierId |
|||
是否拆分:FIsSplit |
|||
凭证号:FVOUCHERGROUPNO (必填项) |
|||
创建日期:FCreateDate |
|||
操作类型:FOperateType |
|||
审核状态:FDocumentStatus (必填项) |
|||
制单:FCreatorId |
|||
取消复核操(作辅助):FCancleRecheck |
|||
来源系统:FSystemID |
|||
是否调整期凭证:FISADJUSTVOUCHER |
|||
出纳复核操作(辅助):FCashierRecheck |
Loading…
Reference in new issue