|
|
@ -7,6 +7,7 @@ import com.yxt.anrui.fin.api.kingdee.appayable.APPayable; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.kingdeedata.Data; |
|
|
|
import com.yxt.anrui.fin.biz.kingdee.entrybill.EntryBillCastToKingDeeBillFields; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -22,10 +23,12 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class FinKingDeeFeignService { |
|
|
|
private static final Logger log = LoggerFactory.getLogger(FinKingDeeFeignService.class); |
|
|
|
public String readJsonFile(String Filename) { //#传文件的路径
|
|
|
|
public String readJsonFile(String filename) { //#传文件的路径
|
|
|
|
String jsonStr = ""; |
|
|
|
try { |
|
|
|
File file = ResourceUtils.getFile("classpath:"+Filename); |
|
|
|
File file = new File(filename) ; |
|
|
|
String content = FileUtils.readFileToString(file,"UTF-8"); |
|
|
|
/* File file = ResourceUtils.getFile("classpath:"+Filename); |
|
|
|
FileInputStream fis = new FileInputStream(file); |
|
|
|
InputStreamReader isr = new InputStreamReader(fis); |
|
|
|
BufferedReader br = new BufferedReader(isr); |
|
|
@ -33,12 +36,12 @@ public class FinKingDeeFeignService { |
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
|
while((data = br.readLine()) != null) { |
|
|
|
sb.append((String) data); |
|
|
|
} |
|
|
|
jsonStr = sb.toString(); |
|
|
|
}*/ |
|
|
|
/* jsonStr = sb.toString(); |
|
|
|
br.close(); |
|
|
|
isr.close(); |
|
|
|
fis.close(); |
|
|
|
return jsonStr; |
|
|
|
fis.close();*/ |
|
|
|
return content; |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return null; |
|
|
@ -51,103 +54,12 @@ public class FinKingDeeFeignService { |
|
|
|
*/ |
|
|
|
public ResultBean draftEntryBill(APPayable aPPayable) { |
|
|
|
ResultBean rb=ResultBean.fireFail(); |
|
|
|
String readJsonFile = readJsonFile("kingdeetemplete/entrybilldata.json"); |
|
|
|
log.info(readJsonFile); |
|
|
|
readJsonFile = readJsonFile.replace("@KD_Creator", "zs"); |
|
|
|
//单据类型:FBillTypeID (必填项)
|
|
|
|
readJsonFile = readJsonFile.replace("@KD_FBillTypeID", "YFD01_SYS"); |
|
|
|
//业务日期:FDATE (必填项)
|
|
|
|
readJsonFile = readJsonFile.replace("@KD_FDATE", aPPayable.getApplicationDate()); |
|
|
|
//单据状态: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"); |
|
|
|
log.info(readJsonFile); |
|
|
|
String fEntityDetail_ = readJsonFile("kingdeetemplete/entrybilldata_FEntityDetail.json"); |
|
|
|
StringBuilder sb=new StringBuilder(); |
|
|
|
for(int i=0;i<1;i++){ |
|
|
|
String fEntityDetail=fEntityDetail_.toString(); |
|
|
|
log.info(fEntityDetail); |
|
|
|
//物料编码: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_FMATERIALID", "350000.0"); |
|
|
|
//含税净价:FPriceWithTax
|
|
|
|
fEntityDetail = fEntityDetail.replace("@KD_FMATERIALID", "346500.0"); |
|
|
|
//税率(%):FEntryTaxRate
|
|
|
|
fEntityDetail = fEntityDetail.replace("@KD_FMATERIALID", "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"); |
|
|
|
|
|
|
|
log.info(fEntityDetail); |
|
|
|
sb.append(fEntityDetail).append(","); |
|
|
|
} |
|
|
|
String sbs=sb.substring(0,sb.length()-1); |
|
|
|
readJsonFile.replace("@KD_FEntityDetail",sbs); |
|
|
|
|
|
|
|
String fEntityPlan_ = readJsonFile("kingdeetemplete/entrybilldata_FEntityPlan.json"); |
|
|
|
StringBuilder sb_fEntityPlan=new StringBuilder(); |
|
|
|
for(int i=0;i<1;i++){ |
|
|
|
String fEntityPlan=fEntityPlan_.toString(); |
|
|
|
log.info(fEntityPlan); |
|
|
|
//应付金额: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"); |
|
|
|
log.info(fEntityPlan); |
|
|
|
sb_fEntityPlan.append(fEntityPlan).append(","); |
|
|
|
} |
|
|
|
String sb_fEntityPlans=sb_fEntityPlan.substring(0,sb_fEntityPlan.length()-1); |
|
|
|
readJsonFile.replace("@KD_FEntityPlan",sb_fEntityPlans); |
|
|
|
|
|
|
|
String readJsonFile = readJsonFile("./src/main/java/com/yxt/anrui/fin/biz/kingdee/entrybill/entrybilldata.json"); |
|
|
|
String fEntityDetail_ = readJsonFile("./src/main/java/com/yxt/anrui/fin/biz/kingdee/entrybill/entrybilldata_FEntityDetail.json"); |
|
|
|
String fEntityPlan_ = readJsonFile("./src/main/java/com/yxt/anrui/fin/biz/kingdee/entrybill/entrybilldata_FEntityPlan.json"); |
|
|
|
Map<String,Object> map=new HashMap<>(); |
|
|
|
map.put("@KD_FDATE",aPPayable.getApplicationDate()); |
|
|
|
APPayable.cloneKingDeeParams(map,readJsonFile,fEntityDetail_,fEntityPlan_); |
|
|
|
try { |
|
|
|
return saveBill(KingDeeBillId.AP_PAYABLE.getID(),readJsonFile); |
|
|
|
} catch (Exception e) { |
|
|
|