
4 changed files with 219 additions and 295 deletions
@ -0,0 +1,31 @@ |
|||
package com.yxt.anrui.fin.biz.kingdee; |
|||
|
|||
import cn.hutool.core.io.FileUtil; |
|||
|
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
public class KingDeeUtils { |
|||
public static String readJsonFile(String filename) { //#传文件的路径
|
|||
String jsonStr = ""; |
|||
try { |
|||
BufferedReader br= FileUtil.getUtf8Reader(filename); |
|||
StringBuffer sb = new StringBuffer(); |
|||
String data = null; |
|||
while((data = br.readLine()) != null) { |
|||
sb.append((String) data); |
|||
} |
|||
return sb.toString(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
public static String replaceTemplateParams(String template, Map<String, String> params) { |
|||
for (Map.Entry<String, String> entry : params.entrySet()) { |
|||
template = template.replace("@KD_"+entry.getKey(),entry.getValue()); |
|||
} |
|||
return template; |
|||
} |
|||
} |
@ -1,246 +1,170 @@ |
|||
package com.yxt.anrui.fin.biz.kingdee.entrybill; |
|||
|
|||
import cn.hutool.core.io.FileUtil; |
|||
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.api.kingdee.kingdeedata.*; |
|||
import com.yxt.anrui.fin.api.kingdee.appayable.APPayable; |
|||
import com.yxt.anrui.fin.api.kingdee.appayable.kingdeedata.*; |
|||
import com.yxt.anrui.fin.biz.kingdee.KingDeeUtils; |
|||
|
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 封装转换的类 |
|||
*/ |
|||
public class EntryBillCastToKingDeeBillFields { |
|||
/** |
|||
* 入账的数据对象转换成金蝶数据对象 |
|||
* @param source |
|||
* @param target |
|||
* 构造金蝶需要的数据结构 并对字段赋值 |
|||
* |
|||
* @param map_fEntityModel_ |
|||
* @param vehicleList |
|||
* @return |
|||
*/ |
|||
public static void cast(APPayable source, Data target) { |
|||
target.setCreator(source.getUserSid()); |
|||
public static String getKingDeeData(Map<String,String> map_fEntityModel_,List<Map<String,String>> vehicleList){ |
|||
/** |
|||
* InterationFlags:交互标志集合,字符串类型,分号分隔,格式:"flag1;flag2;..."(非必录),例如(允许负库存标识:STK_InvCheckResult) |
|||
* 取模板 |
|||
*/ |
|||
target.setInterationflags(" "); |
|||
/** |
|||
* IsDeleteEntry:是否删除已存在的分录,布尔类型,默认true(非必录) |
|||
*/ |
|||
target.setIsdeleteentry("True "); |
|||
/** |
|||
* IsEntryBatchFill:是否批量填充分录,默认true(非必录) |
|||
*/ |
|||
target.setIsentrybatchfill("True "); |
|||
/** |
|||
* IsVerifyBaseDataField:是否验证所有的基础资料有效性,布尔类,默认false(非必录) |
|||
*/ |
|||
target.setIsverifybasedatafield("false "); |
|||
/** |
|||
* 构造model |
|||
*/ |
|||
createModel(source,target); |
|||
/** |
|||
* 需返回结果的字段集合,数组类型,格式:[key,entitykey.key,...](非必录),注(返回单据体字段格式:entitykey.key) |
|||
*/ |
|||
List<String> needreturnfields =new ArrayList<>(); |
|||
target.setNeedreturnfields(needreturnfields); |
|||
/** |
|||
* NeedUpDateFields:需要更新的字段,数组类型,格式:[key1,key2,...](非必录),注(更新单据体字段得加上单据体key) |
|||
*/ |
|||
List<String> needupdatefields=new ArrayList<>(); |
|||
target.setNeedupdatefields(needupdatefields); |
|||
/** |
|||
* 是否用编码搜索基础资料,布尔类型,默认true(非必录) |
|||
*/ |
|||
target.setNumbersearch("True "); |
|||
/** |
|||
* SubSystemId:表单所在的子系统内码,字符串类型(非必录) |
|||
*/ |
|||
target.setSubsystemid(" "); |
|||
/** |
|||
* ValidateFlag:是否验证标志,布尔类型,默认true(非必录) |
|||
*/ |
|||
target.setValidateflag("True "); |
|||
} |
|||
String readJsonFile = KingDeeUtils.readJsonFile("com/yxt/anrui/fin/biz/kingdee/entrybill/entrybilldata.json"); |
|||
String fEntityData_ = KingDeeUtils.readJsonFile("com/yxt/anrui/fin/biz/kingdee/entrybill/entrybilldata_data.json"); |
|||
String fEntityModel_ = KingDeeUtils.readJsonFile("com/yxt/anrui/fin/biz/kingdee/entrybill/entrybilldata_model.json"); |
|||
String fEntityDetail_ = KingDeeUtils.readJsonFile("com/yxt/anrui/fin/biz/kingdee/entrybill/entrybilldata_FEntityDetail.json"); |
|||
|
|||
/** |
|||
* 创建 Model |
|||
* @param target |
|||
*/ |
|||
private static void createModel(APPayable source, Data target) { |
|||
/** |
|||
* Model:表单数据包,Json类型(必录) |
|||
*/ |
|||
Model model=new Model(); |
|||
model.setFid(0); |
|||
/** |
|||
* 单据类型:FBillTypeID (必填项) |
|||
*/ |
|||
Fbilltypeid fbilltypeid=new Fbilltypeid(); |
|||
fbilltypeid.setFnumber("YFD01_SYS "); |
|||
model.setFbilltypeid(fbilltypeid); |
|||
/** |
|||
* |
|||
*/ |
|||
model.setFbillno(source.getApplicationCode()); |
|||
/** |
|||
* 是否期初单据:FISINIT |
|||
*/ |
|||
model.setFisinit(false); |
|||
/** |
|||
* 业务日期:FDATE (必填项) |
|||
*/ |
|||
model.setFdate("2022-07-16 00:00:00 "); |
|||
/** |
|||
* 到期日:FENDDATE_H |
|||
*/ |
|||
model.setFenddateH("2022-07-16 00:00:00 "); |
|||
/** |
|||
* 单据状态:FDOCUMENTSTATUS (必填项) |
|||
*/ |
|||
model.setFdocumentstatus("Z "); |
|||
/** |
|||
* 供应商:FSUPPLIERID (必填项) |
|||
*/ |
|||
Fsupplierid fsupplierid=new Fsupplierid(); |
|||
fsupplierid.setFnumber("010001 "); |
|||
model.setFsupplierid(fsupplierid); |
|||
/** |
|||
* 币别:FCURRENCYID (必填项) |
|||
*/ |
|||
Fcurrencyid fcurrencyid=new Fcurrencyid(); |
|||
fcurrencyid.setFnumber( "PRE001 "); |
|||
model.setFcurrencyid( fcurrencyid); |
|||
/** |
|||
* 付款条件:FPayConditon |
|||
*/ |
|||
Fpayconditon fpayconditon=new Fpayconditon(); |
|||
fpayconditon.setFnumber("FKTJ01_SYS "); |
|||
model.setFpayconditon(fpayconditon) ; |
|||
/** |
|||
* 价外税:FISPRICEEXCLUDETAX |
|||
*/ |
|||
model.setFispriceexcludetax(true); |
|||
/** |
|||
* 业务类型:FBUSINESSTYPE (必填项) |
|||
*/ |
|||
model.setFbusinesstype("CG ") ; |
|||
/** |
|||
* 按含税单价录入:FISTAX |
|||
*/ |
|||
model.setFistax(true); |
|||
/** |
|||
* 表头基本 -未付款核销金额(作废):FNOTWRITTENOFFAMOUNTFOR |
|||
* 结算组织:FSETTLEORGID (必填项) |
|||
*/ |
|||
Fsettleorgid fsettleorgid=new Fsettleorgid(); |
|||
fsettleorgid.setFnumber("101 "); |
|||
model.setFsettleorgid(fsettleorgid); |
|||
/** |
|||
* 付款组织:FPAYORGID (必填项) |
|||
*/ |
|||
Fpayorgid fpayorgid=new Fpayorgid(); |
|||
fpayorgid.setFnumber("101 "); |
|||
model.setFpayorgid(fpayorgid); |
|||
/** |
|||
* 立账类型:FSetAccountType |
|||
*/ |
|||
model.setFsetaccounttype("2 ") ; |
|||
/** |
|||
* 税额计入成本:FISTAXINCOST |
|||
*/ |
|||
model.setFistaxincost(false) ; |
|||
/** |
|||
* 备注:FAP_Remark |
|||
*/ |
|||
model.setFapRemark("122112 "); |
|||
/** |
|||
* 参与暂估应付核销:FISHookMatch |
|||
*/ |
|||
model.setFishookmatch(false); |
|||
/** |
|||
* 采购部门:FPURCHASEDEPTID (必填项) |
|||
*/ |
|||
Fpurchasedeptid fpurchasedeptid=new Fpurchasedeptid(); |
|||
fpurchasedeptid.setFnumber("02 "); |
|||
model.setFpurchasedeptid(fpurchasedeptid); |
|||
/** |
|||
* 作废状态:FCancelStatus (必填项) |
|||
*/ |
|||
model.setFcancelstatus("A ") ; |
|||
/** |
|||
*是发票审核自动生成:FISBYIV |
|||
*/ |
|||
model.setFisbyiv(false); |
|||
/** |
|||
* 是否需要成本调整:FISGENHSADJ |
|||
*/ |
|||
model.setFisgenhsadj(false) ; |
|||
/** |
|||
* 先到票后入库:FISINVOICEARLIER |
|||
*/ |
|||
model.setFisinvoicearlier(false); |
|||
/** |
|||
* 发票号码:F_PAEZ_Text |
|||
*/ |
|||
model.setFPaezText("1221121212 ") ; |
|||
/** |
|||
* 项目类别:F_PMZC_Assistant1 |
|||
*/ |
|||
FPmzcAssistant1 fPmzcAssistant1=new FPmzcAssistant1 (); |
|||
fPmzcAssistant1.setFnumber("00 "); |
|||
model.setFPmzcAssistant1( fPmzcAssistant1); |
|||
/** |
|||
* |
|||
*/ |
|||
Fsubheadsuppiler fsubheadsuppiler=new Fsubheadsuppiler (); |
|||
Forderid forderid=new Forderid(); |
|||
forderid.setFnumber("010001 "); |
|||
fsubheadsuppiler.setForderid( forderid); |
|||
Ftransferid ftransferid=new Ftransferid(); |
|||
ftransferid.setFnumber("010001 "); |
|||
fsubheadsuppiler.setFtransferid( ftransferid); |
|||
Fchargeid fchargeid=new Fchargeid(); |
|||
fchargeid.setFnumber("010001 "); |
|||
fsubheadsuppiler.setFchargeid( fchargeid); |
|||
model.setFsubheadsuppiler(fsubheadsuppiler) ; |
|||
//模板字符创转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); |
|||
|
|||
Fsubheadfinc fsubheadfinc=new Fsubheadfinc(); |
|||
List<JSONObject> list_fEntityDetail_=new ArrayList<>(); |
|||
|
|||
fsubheadfinc.setFaccnttimejudgetime("2022-07-16 00:00:00 ") ; |
|||
//对模板字段赋值 根据传递进来的map数据的集合进行赋值
|
|||
for(int i=0;i<vehicleList.size();i++){ |
|||
Map<String,String> params=vehicleList.get(i); |
|||
Map<String,String> map_fEntityDetail_=new HashMap<>(); |
|||
for (Map.Entry<String, String> entry : params.entrySet()) { |
|||
map_fEntityDetail_.put(entry.getKey(),entry.getValue()); |
|||
} |
|||
fEntityDetail_ =KingDeeUtils.replaceTemplateParams(fEntityDetail_, map_fEntityDetail_); |
|||
list_fEntityDetail_.add(JSONObject.parseObject(fEntityDetail_,Feature.OrderedField)); |
|||
} |
|||
|
|||
/** |
|||
* 本位币:FMAINBOOKSTDCURRID |
|||
*/ |
|||
Fmainbookstdcurrid fmainbookstdcurrid=new Fmainbookstdcurrid(); |
|||
fmainbookstdcurrid.setFnumber("PRE001 "); |
|||
fsubheadfinc.setFmainbookstdcurrid(fmainbookstdcurrid); |
|||
/** |
|||
* 汇率类型:FEXCHANGETYPE |
|||
*/ |
|||
Fexchangetype fexchangetype=new Fexchangetype(); |
|||
fexchangetype.setFnumber("HLTX01_SYS "); |
|||
fsubheadfinc.setFexchangetype(fexchangetype); |
|||
/** |
|||
* 汇率:FExchangeRate |
|||
*/ |
|||
fsubheadfinc.setFexchangerate(1) ; |
|||
/** |
|||
* 税额:FTaxAmountFor |
|||
*/ |
|||
fsubheadfinc.setFtaxamountfor(1.0) ; |
|||
/** |
|||
* 不含税金额:FNoTaxAmountFor |
|||
*/ |
|||
fsubheadfinc.setFnotaxamountfor( 1.98) ; |
|||
model.setFsubheadfinc(fsubheadfinc); |
|||
List<Fentitydetail> fentitydetail=new ArrayList<>(); |
|||
model.setFentitydetail(fentitydetail); |
|||
List<Fentityplan> fentityplan=new ArrayList<>(); |
|||
model.setFentityplan(fentityplan); |
|||
/** |
|||
* Model:表单数据包,Json类型(必录) |
|||
*/ |
|||
target.setModel(model); |
|||
jsonFEntityModel_.put("FEntityDetail", JSONArray.parseArray(JSON.toJSONString(list_fEntityDetail_))); |
|||
jsonFEntityData_.put("Model",JSONObject.parseObject(JSON.toJSONString(jsonFEntityModel_),Feature.OrderedField)); |
|||
jsonObj.put("data",jsonFEntityData_.toJSONString()); |
|||
|
|||
return jsonObj.toJSONString(); |
|||
} |
|||
/** |
|||
* 业务实体类按照模板进行装换 |
|||
* @param params |
|||
* @param readJsonFile |
|||
* @param fEntityDetail_ |
|||
* @param fEntityPlan_ |
|||
* @return |
|||
*/ |
|||
/* public static String cloneKingDeeParams(Map<String,Object> params, String readJsonFile, String fEntityDetail_, String fEntityPlan_){ |
|||
readJsonFile = readJsonFile.replace("@KD_Creator", "zs"); |
|||
//单据类型:FBillTypeID (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FBillTypeID", "YFD01_SYS"); |
|||
//业务日期:FDATE (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FDATE", "2022-07-26"); |
|||
//单据状态:FDOCUMENTSTATUS (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FDOCUMENTSTATUS", "Z"); |
|||
//供应商:FSUPPLIERID (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FSUPPLIERID", "010001"); |
|||
//币别:FCURRENCYID (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FCURRENCYID", "PRE001"); |
|||
//付款条件:FPayConditon
|
|||
readJsonFile = readJsonFile.replace("@KD_FPayConditon", ""); |
|||
//业务类型:FBUSINESSTYPE (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FBUSINESSTYPE", "CG"); |
|||
//结算组织:FSETTLEORGID (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FSETTLEORGID", "101"); |
|||
//付款组织:FPAYORGID (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FPAYORGID", "101"); |
|||
//采购部门:FPURCHASEDEPTID (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FPURCHASEDEPTID", "01"); |
|||
//作废状态:FCancelStatus (必填项)
|
|||
readJsonFile = readJsonFile.replace("@KD_FCancelStatus", "A"); |
|||
StringBuilder sb=new StringBuilder(); |
|||
for(int i=0;i<1;i++){ |
|||
String fEntityDetail=fEntityDetail_.toString(); |
|||
//物料编码:FMATERIALID
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FMATERIALID", " JX091054"); |
|||
//物料说明:FMaterialDesc
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FMaterialDesc", "X牵引6*4-550超"); |
|||
//计价单位:FPRICEUNITID
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FPRICEUNITID", " liang"); |
|||
//单价:FPrice
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FPrice@", "312500.0"); |
|||
//计价数量:FPriceQty
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FPriceQty", "2.0"); |
|||
//含税单价:FTaxPrice
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FTaxPrice@", "350000.0"); |
|||
//含税净价:FPriceWithTax
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FPriceWithTax", "346500.0"); |
|||
//税率(%):FEntryTaxRate
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FEntryTaxRate", "12.0"); |
|||
//运输编号:F_PMZC_Assistant
|
|||
fEntityDetail = fEntityDetail.replace("@KD_F_PMZC_Assistant", "1904110789"); |
|||
//物流车辆:F_PMZC_Base
|
|||
fEntityDetail = fEntityDetail.replace("@KD_F_PMZC_Base", "0001F"); |
|||
//物流项目:F_PMZC_Base1
|
|||
fEntityDetail = fEntityDetail.replace("@KD_F_PMZC_Base1", "01.001"); |
|||
//折扣率(%):FEntryDiscountRate
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FEntryDiscountRate", "1.0"); |
|||
//折扣额:FDISCOUNTAMOUNTFOR
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FDISCOUNTAMOUNTFOR", "7000.0"); |
|||
//不含税金额:FNoTaxAmountFor_D
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FNoTaxAmountFor_D", "618750.0"); |
|||
//税额:FTAXAMOUNTFOR_D
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FTAXAMOUNTFOR_D", "74250.0"); |
|||
//价税合计:FALLAMOUNTFOR_D
|
|||
fEntityDetail = fEntityDetail.replace("@KD_F_PMZC_Base1", "693000.0"); |
|||
//库存单位:FStockUnitId
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FStockUnitId", "liang"); |
|||
//库存数量:FStockQty
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FStockQty", "2.0"); |
|||
//库存基本数量:FStockBaseQty
|
|||
fEntityDetail = fEntityDetail.replace("@KD_F_PMZC_Base1", "2.0"); |
|||
//计价基本分母:FPriceBaseDen
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FPriceBaseDen", "1.0"); |
|||
//库存基本分子:FStockBaseNum
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FStockBaseNum", "1.0"); |
|||
//含税单价:FTaxPrice
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FTaxPrice@", "350000.0"); |
|||
//税率(%):FEntryTaxRate
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FEntryTaxRate", "12.0"); |
|||
//价税合计:FALLAMOUNTFOR_D
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FALLAMOUNTFOR_D", "693000.0"); |
|||
//库存基本数量:FStockBaseQty
|
|||
fEntityDetail = fEntityDetail.replace("@KD_FStockBaseQty", "2.0"); |
|||
sb.append(fEntityDetail).append(","); |
|||
} |
|||
String sbs=sb.substring(0,sb.length()-1); |
|||
readJsonFile=readJsonFile.replace("@KD_FEntityDetail",sbs); |
|||
StringBuilder sb_fEntityPlan=new StringBuilder(); |
|||
for(int i=0;i<1;i++){ |
|||
String fEntityPlan=fEntityPlan_.toString(); |
|||
//应付金额:FPAYAMOUNTFOR
|
|||
fEntityPlan = fEntityPlan.replace("@KD_FPAYAMOUNTFOR", "693000.00"); |
|||
//应付比例(%):FPAYRATE
|
|||
fEntityPlan = fEntityPlan.replace("@KD_FPAYRATE", "100.00000"); |
|||
//表头计划 - 到期日:FENDDATE
|
|||
fEntityPlan = fEntityPlan.replace("@KD_FENDDATE", "2022-07-22 00:00:00"); |
|||
sb_fEntityPlan.append(fEntityPlan).append(","); |
|||
} |
|||
String sb_fEntityPlans=sb_fEntityPlan.substring(0,sb_fEntityPlan.length()-1); |
|||
readJsonFile=readJsonFile.replace("@KD_FEntityPlan",sb_fEntityPlans); |
|||
return readJsonFile; |
|||
}*/ |
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
{ |
|||
"sid": "63", |
|||
"userSid": "73", |
|||
"applicationDate": "2022-08-01 06:22:08", |
|||
"applicationCode": "1659335563", |
|||
"vehicleList": [ |
|||
{ |
|||
"sid": "25", |
|||
"applySid": "11", |
|||
"modelSid": " JX091054", |
|||
"vinNo": " JX091054", |
|||
"remarks": "X牵引6*4-550超" |
|||
} |
|||
] |
|||
} |
Loading…
Reference in new issue