add dzpzk code
This commit is contained in:
parent
cdf8418cd1
commit
ef4dd86c90
|
@ -91,7 +91,7 @@ public class AppflgConstant {
|
|||
*/
|
||||
public static String getDzpzkTokenURL(){
|
||||
|
||||
return System.getProperty("DZPZK_TOKE_URL")+"&client_id="+System.getProperty(AppflgConstant.DZPZK_CLIENT_ID)+"&client_secret="+
|
||||
return System.getProperty(AppflgConstant.DZPZK_TOKE_URL)+"&client_id="+System.getProperty(AppflgConstant.DZPZK_CLIENT_ID)+"&client_secret="+
|
||||
System.getProperty(AppflgConstant.DZPZK_CLIENT_SECRET)+"&username="+System.getProperty(AppflgConstant.DZPZK_USERNAME)+"&password="+
|
||||
System.getProperty(AppflgConstant.DZPZK_PASSWORD);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ package shkd.fi.fi.common.dzpzk.guidang.req;
|
|||
public class PartyAttachmentList {
|
||||
|
||||
private String fileName;
|
||||
private int fileSize;
|
||||
private long fileSize;
|
||||
private String numeration;
|
||||
private String fileHexString;
|
||||
public void setFileName(String fileName) {
|
||||
|
@ -22,10 +22,10 @@ public class PartyAttachmentList {
|
|||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileSize(int fileSize) {
|
||||
public void setFileSize(long fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
public int getFileSize() {
|
||||
public long getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package shkd.fi.fi.common.orc;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -128,7 +129,7 @@ public class Response {
|
|||
/**
|
||||
* 价税合计
|
||||
*/
|
||||
private double amountTax;
|
||||
private BigDecimal amountTax;
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
|
@ -370,11 +371,11 @@ public class Response {
|
|||
return hasSeal;
|
||||
}
|
||||
|
||||
public void setAmountTax(double amountTax) {
|
||||
public void setAmountTax(BigDecimal amountTax) {
|
||||
this.amountTax = amountTax;
|
||||
}
|
||||
|
||||
public double getAmountTax() {
|
||||
public BigDecimal getAmountTax() {
|
||||
return amountTax;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ApFinapbillFormPlugin extends AbstractBillPlugIn {
|
|||
OperateOption option = OperateOption.create();
|
||||
option.setVariableValue(OperateOptionConst.ISHASRIGHT, "true");
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, "true");
|
||||
if ("inventry".equals(entryPropName)) {
|
||||
if ("shkd_i_deleteentry".equals(entryPropName)) {
|
||||
int[] rowIndexs = e.getRowIndexs();
|
||||
if (rowIndexs.length > 0) {
|
||||
int row = rowIndexs[0];
|
||||
|
|
|
@ -41,6 +41,7 @@ import shkd.fi.fi.util.LogBillUtils;
|
|||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
@ -234,7 +235,7 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
|||
compliancecollectHeader.put("Authorization", "Bearer " + token);
|
||||
//2.2.发票合规查验接口请求体
|
||||
JSONObject compliancecollectBody = new JSONObject();
|
||||
compliancecollectBody.put("TaxNo", "91310115607321695H");// purchaserTaxNo
|
||||
compliancecollectBody.put("TaxNo", response.getSaleTaxNo());// purchaserTaxNo
|
||||
compliancecollectBody.put("InvoiceCode", response.getInvoiceCode());
|
||||
compliancecollectBody.put("InvoiceNumber", response.getInvoiceNo());
|
||||
String checkCode = response.getCheckCode();
|
||||
|
@ -242,7 +243,7 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
|||
checkCode = checkCode.substring(checkCode.length() - 6);
|
||||
}
|
||||
compliancecollectBody.put("CheckCode_6", checkCode);// checkCode后6位数
|
||||
compliancecollectBody.put("TotalAmount", "");
|
||||
compliancecollectBody.put("TotalAmount", response.getAmountTax().setScale(2, RoundingMode.HALF_UP));
|
||||
Date invoiceDate = response.getInvoiceDate();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String format = simpleDateFormat.format(invoiceDate);
|
||||
|
@ -266,6 +267,7 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
|||
//2.4.发票合规查验接口调用失败
|
||||
if (!success) {
|
||||
this.getView().showMessage(message);
|
||||
return;
|
||||
}
|
||||
this.getView().showMessage("发票已识别验真通过,生成发票明细成功");
|
||||
//2.5.发票合规查验接口调用成功 生成发票识别单据
|
||||
|
@ -330,38 +332,38 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
|||
//回写发票信息到财务应付单发票明细
|
||||
if (!returnDataList.isEmpty()) {
|
||||
ap_finapbill.set("istaxdeduction", false);//进项税抵扣
|
||||
DynamicObjectCollection inventry = ap_finapbill.getDynamicObjectCollection("inventry");
|
||||
DynamicObjectCollection inventry = ap_finapbill.getDynamicObjectCollection("shkd_inventry");
|
||||
// inventry.clear();
|
||||
|
||||
IFormView parentView = this.getView().getParentView();
|
||||
for (DynamicObject dynamicObject : returnDataList) {
|
||||
DynamicObject addNew = inventry.addNew();
|
||||
addNew.set("i_invoicetypef7", dynamicObject.get("shkd_invoicetypef7"));
|
||||
addNew.set("i_invoicetype", dynamicObject.get("shkd_invoicetype"));
|
||||
addNew.set("i_invoicecode", dynamicObject.get("shkd_invoicecode"));
|
||||
addNew.set("i_invoiceno", dynamicObject.get("shkd_invoiceno"));
|
||||
addNew.set("i_invoicedate", dynamicObject.get("shkd_invoicedate"));
|
||||
addNew.set("i_currency", dynamicObject.get("shkd_currency"));
|
||||
addNew.set("i_pricetaxtotal", dynamicObject.get("shkd_pricetaxtotal"));
|
||||
addNew.set("shkd_i_invoicetypef7", dynamicObject.get("shkd_invoicetypef7"));
|
||||
addNew.set("shkd_i_invoicetype", dynamicObject.get("shkd_invoicetype"));
|
||||
addNew.set("shkd_i_invoicecode", dynamicObject.get("shkd_invoicecode"));
|
||||
addNew.set("shkd_i_invoiceno", dynamicObject.get("shkd_invoiceno"));
|
||||
addNew.set("shkd_i_invoicedate", dynamicObject.get("shkd_invoicedate"));
|
||||
addNew.set("shkd_i_currency", dynamicObject.get("shkd_currency"));
|
||||
addNew.set("shkd_i_pricetaxtotal", dynamicObject.get("shkd_pricetaxtotal"));
|
||||
String shkd_taxrate1 = dynamicObject.getString("shkd_taxrate1");
|
||||
if (shkd_taxrate1.contains("%")) {
|
||||
shkd_taxrate1 = shkd_taxrate1.substring(0, shkd_taxrate1.indexOf("%"));
|
||||
}
|
||||
addNew.set("i_taxrate", shkd_taxrate1);
|
||||
addNew.set("i_tax", dynamicObject.get("shkd_tax"));
|
||||
addNew.set("i_amount", dynamicObject.get("shkd_amount"));
|
||||
addNew.set("i_asstactname", dynamicObject.get("shkd_asstactname"));
|
||||
addNew.set("i_buyername", dynamicObject.get("shkd_buyername"));
|
||||
addNew.set("i_istaxdeduction", dynamicObject.get("shkd_istaxdeduction"));
|
||||
addNew.set("i_remark", dynamicObject.get("shkd_remark"));
|
||||
addNew.set("i_canuseamt", dynamicObject.get("shkd_canuseamt"));//可占用金额 隐藏
|
||||
addNew.set("i_usedamt", dynamicObject.get("shkd_usedamt"));
|
||||
addNew.set("i_srctype", "1");//行来源 1-发票采集
|
||||
addNew.set("i_issupplement", dynamicObject.get("shkd_issupplement"));//后补发票 下拉 隐藏
|
||||
addNew.set("i_billno", dynamicObject.get("shkd_billno"));//
|
||||
addNew.set("i_invoicestatus", dynamicObject.get("shkd_invoicestatus"));//
|
||||
addNew.set("invid", dynamicObject.get("shkd_invid"));//发票id 隐藏
|
||||
addNew.set("i_serialno", dynamicObject.get("shkd_serialno"));//发票流水号 隐藏
|
||||
addNew.set("shkd_i_taxrate", shkd_taxrate1);
|
||||
addNew.set("shkd_i_tax", dynamicObject.get("shkd_tax"));
|
||||
addNew.set("shkd_i_amount", dynamicObject.get("shkd_amount"));
|
||||
addNew.set("shkd_i_asstactname", dynamicObject.get("shkd_asstactname"));
|
||||
addNew.set("shkd_i_buyername", dynamicObject.get("shkd_buyername"));
|
||||
addNew.set("shkd_i_istaxdeduction", dynamicObject.get("shkd_istaxdeduction"));
|
||||
addNew.set("shkd_i_remark", dynamicObject.get("shkd_remark"));
|
||||
addNew.set("shkd_i_canuseamt", dynamicObject.get("shkd_canuseamt"));//可占用金额 隐藏
|
||||
addNew.set("shkd_i_usedamt", dynamicObject.get("shkd_usedamt"));
|
||||
addNew.set("shkd_i_srctype", "1");//行来源 1-发票采集
|
||||
addNew.set("shkd_i_issupplement", dynamicObject.get("shkd_issupplement"));//后补发票 下拉 隐藏
|
||||
addNew.set("shkd_i_billno", dynamicObject.get("shkd_billno"));//
|
||||
addNew.set("shkd_i_invoicestatus", dynamicObject.get("shkd_invoicestatus"));//
|
||||
addNew.set("shkd_invid", dynamicObject.get("shkd_invid"));//发票id 隐藏
|
||||
addNew.set("shkd_i_serialno", UUID.randomUUID().toString());//发票流水号 隐藏
|
||||
addNew.set("shkd_invoicereceipt", dynamicObject);//
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.bos.util.StringUtils;
|
||||
import shkd.fi.fi.common.AppflgConstant;
|
||||
import shkd.fi.fi.sap.result.docuentif.Item;
|
||||
import shkd.fi.fi.sap.result.docuentif.MTDocumentIFRet;
|
||||
import shkd.fi.fi.sap.result.docuentif.cxdocuentif.MT_CXDOCUMENT_IF_RET;
|
||||
import shkd.fi.fi.util.DateUtils;
|
||||
import shkd.fi.fi.util.HttpUtils;
|
||||
|
@ -48,6 +50,7 @@ public class CxSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
//1.校验,不满足冲销条件的凭证,移除,不传输,校验是否满足冲销条件:必须是已同步过SAP的凭证才允许冲销
|
||||
DynamicObjectCollection voucherColl = new DynamicObjectCollection();
|
||||
StringBuffer errStr = new StringBuffer();
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
for (DynamicObject glvoucher : dataEntities) {
|
||||
DynamicObject voucher = BusinessDataServiceHelper.loadSingle(glvoucher.getPkValue(), "gl_voucher");
|
||||
String voucherNo = voucher.getString("billno");//凭证号
|
||||
|
@ -65,7 +68,7 @@ public class CxSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
}
|
||||
String shkd_zstatus = voucher.getString("shkd_zstatus");
|
||||
String shkd_belnr = voucher.getString("shkd_belnr");
|
||||
if(StringUtils.isEmpty(shkd_zstatus)||StringUtils.isEmpty(shkd_belnr)||!"1".equals(shkd_belnr)){
|
||||
if(StringUtils.isEmpty(shkd_zstatus)||StringUtils.isEmpty(shkd_belnr)||!"1".equals(shkd_zstatus)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足冲销条件,原因:");
|
||||
errStr.append("凭证未同步到SAP ").append("\r");
|
||||
break;
|
||||
|
@ -97,10 +100,11 @@ public class CxSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
String shkd_sap_number = org.getString("shkd_sap_number");
|
||||
DynamicObject creator = gl_voucher.getDynamicObject("creator");
|
||||
String packgId = System.getProperty(AppflgConstant.SYS_NUMBER)+time_random;
|
||||
|
||||
// String packgid = System.getProperty(AppflgConstant.SYS_NUMBER) + date.getTime();
|
||||
String billno = gl_voucher.getString("billno");
|
||||
String shkd_belnr = gl_voucher.getString("shkd_belnr");
|
||||
Date bookeddate = gl_voucher.getDate("bookeddate");
|
||||
String cx_year = DateUtils.format(bookeddate, DateUtils.COMPACT_YEAR);
|
||||
String zbudat = DateUtils.format(bookeddate, DateUtils.COMPACT_DATE);//冲销日期
|
||||
xml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:coscoshipping:shhy:2020\">");
|
||||
xml.append(" <soapenv:Header/>");
|
||||
|
@ -110,13 +114,13 @@ public class CxSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
xml.append(" <IS_HEADER>");
|
||||
xml.append(" <BUKRS>").append(shkd_sap_number).append("</BUKRS>");
|
||||
xml.append(" <CRDATE>").append(crdate).append("</CRDATE>");
|
||||
xml.append(" <CRNAME>").append(creator).append("</CRNAME>");
|
||||
xml.append(" <CRNAME>").append(creator.getString("name")).append("</CRNAME>");
|
||||
xml.append(" <ZRTOALL>1</ZRTOALL>");
|
||||
xml.append(" <PACKGID>").append(time_random).append("</PACKGID>");
|
||||
xml.append(" <PACKGID>").append(packgId).append("</PACKGID>");
|
||||
xml.append(" <ZFLAG>P</ZFLAG>");
|
||||
xml.append(" </IS_HEADER>");
|
||||
xml.append(" <IT_ITEM>");
|
||||
xml.append(createItem(shkd_sap_number, billno, shkd_belnr, zbudat));
|
||||
xml.append(createItem(shkd_sap_number, shkd_belnr, cx_year, zbudat));
|
||||
xml.append(" </IT_ITEM>");
|
||||
xml.append(" </DATA>");
|
||||
xml.append(" </urn:MT_CXDOCUMENT_IF_SRC>");
|
||||
|
@ -124,7 +128,7 @@ public class CxSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
xml.append("</soapenv:Envelope>");
|
||||
|
||||
try {
|
||||
Map<String, Object> result = HttpUtils.sendPostToSAP(sap_cx_voucher_url, "tokenStr", xml.toString());
|
||||
Map<String, Object> result = HttpUtils.sendPostToSAP(sap_cx_voucher_url, tokenStr, xml.toString());
|
||||
String responseStr = "";
|
||||
if (null != result) {
|
||||
String status = String.valueOf(result.get(HttpUtils.STATUS));
|
||||
|
@ -133,29 +137,27 @@ public class CxSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
log.info(responseStr);
|
||||
//4.处理接口返回结果:解析记录结果到凭证上,
|
||||
if (status.equals("200")) {//成功
|
||||
MT_CXDOCUMENT_IF_RET mtDocumentIFRet = XmlUtils.xmlToObject(MT_CXDOCUMENT_IF_RET.class, responseStr, XmlUtils.START_SUB_STR, XmlUtils.END_SUB_STR);
|
||||
MTDocumentIFRet mtDocumentIFRet = XmlUtils.xmlToObject(MTDocumentIFRet.class, responseStr.replaceAll("MT_CXDOCUMENT_IF_RET","MT_DOCUMENT_IF_RET"), XmlUtils.START_SUB_STR, XmlUtils.END_SUB_STR);
|
||||
if(null!=mtDocumentIFRet&&null!=mtDocumentIFRet.getData()
|
||||
&& null != mtDocumentIFRet.getData().getOtRetn()
|
||||
&& null != mtDocumentIFRet.getData().getOtRetn().getItemList()) {
|
||||
List<MT_CXDOCUMENT_IF_RET.ITEM> itemList = mtDocumentIFRet.getData().getOtRetn().getItemList();
|
||||
for (int i = 0; i < itemList.size(); i++) {
|
||||
MT_CXDOCUMENT_IF_RET.ITEM item = itemList.get(i);
|
||||
&&null!=mtDocumentIFRet.getData().getOtRETN()
|
||||
&&null!=mtDocumentIFRet.getData().getOtRETN().getItem()){
|
||||
Item item = mtDocumentIFRet.getData().getOtRETN().getItem();
|
||||
String zstatus1 = item.getZstatus();
|
||||
if("S".equals(zstatus1.toUpperCase())){//成功
|
||||
//成功提示
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(true);
|
||||
this.operationResult.setMessage("同步成功");
|
||||
|
||||
gl_voucher.set("shkd_zstatus","2");
|
||||
gl_voucher.set("shkd_promsg",item.getPromsg());
|
||||
SaveServiceHelper.save(new DynamicObject[]{gl_voucher});
|
||||
}else {//失败
|
||||
//失败提示
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("同步失败:"+item.getPromsg());
|
||||
}
|
||||
//更新凭证上接口返回字段
|
||||
updateVoucher(gl_voucher, item);
|
||||
|
||||
gl_voucher.set("shkd_promsg",item.getPromsg());
|
||||
SaveServiceHelper.save(new DynamicObject[]{gl_voucher});
|
||||
}
|
||||
}
|
||||
} else {//失败
|
||||
|
@ -205,16 +207,11 @@ public class CxSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
|
||||
public static void updateVoucher (DynamicObject voucher,MT_CXDOCUMENT_IF_RET.ITEM item) {
|
||||
String zstatus = item.getZstatus();
|
||||
String packgid = item.getPackgid();
|
||||
String promsg = item.getPromsg();
|
||||
String belnr = item.getBelnr();
|
||||
String wbdate = item.getWbdate();
|
||||
//TODO:元数据 增加下拉框,已冲销,下拉框值为2
|
||||
voucher.set("shkd_zstatus","S".equals(zstatus)?"2":"0");
|
||||
voucher.set("shkd_packgid",packgid);
|
||||
if("S".equals(zstatus)){
|
||||
voucher.set("shkd_zstatus","2");//已冲销,下拉框值为2
|
||||
}
|
||||
voucher.set("shkd_promsg",promsg);
|
||||
voucher.set("shkd_belnr",belnr);
|
||||
voucher.set("shkd_wbdate",wbdate);
|
||||
SaveServiceHelper.save(new DynamicObject[]{voucher});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,16 @@ import com.alibaba.druid.support.logging.LogFactory;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.cache.CacheFactory;
|
||||
import kd.bos.cache.DistributeSessionlessCache;
|
||||
import kd.bos.cache.TempFileCache;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.botp.runtime.BFRow;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.fileservice.FileServiceFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.AttachmentDto;
|
||||
import kd.bos.servicehelper.AttachmentServiceHelper;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
|
||||
|
@ -29,7 +32,7 @@ import shkd.fi.fi.util.DateUtils;
|
|||
import shkd.fi.fi.util.FileUtils;
|
||||
import shkd.fi.fi.util.LogBillUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -78,7 +81,7 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
// DynamicObject voucher = BusinessDataServiceHelper.loadSingle(glvoucher.getPkValue(), "gl_voucher");
|
||||
String voucherNo = voucher.getString("billno");//凭证号
|
||||
//校验:1.单据是否已审核;2.是否已同步到SAP;
|
||||
if("C".equals(voucher.getString("billstatus"))){
|
||||
if(!"C".equals(voucher.getString("billstatus"))){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append(" 凭证未审核").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
|
@ -86,7 +89,7 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
if("1".equals(voucher.getString("shkd_zstatus"))){
|
||||
if(!"1".equals(voucher.getString("shkd_zstatus"))){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append(" 凭证未同步到SAP ").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
|
@ -132,7 +135,7 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
}else if(ap_finapbill.equals(number)){//来源单据是财务应付单
|
||||
DynamicObject[] ap_finapbillObjects = BusinessDataServiceHelper.load(new Long[]{sourcebillid}, dynamicObject.getDynamicObjectType());
|
||||
for (DynamicObject apBillObj : ap_finapbillObjects) {
|
||||
DynamicObjectCollection inventry = apBillObj.getDynamicObjectCollection("inventry");
|
||||
DynamicObjectCollection inventry = apBillObj.getDynamicObjectCollection("shkd_inventry");
|
||||
if(inventry.size()<=0){
|
||||
errStr.append("凭证号:").append(voucherNo).append(" 来源单据财务应付单 ").append(apBillObj.getString("billno"));
|
||||
errStr.append("无发票附件,无需同步电子凭证库系统").append("\r");
|
||||
|
@ -254,8 +257,11 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
//1.3.通过接口调用获取token
|
||||
|
||||
try {
|
||||
String getTokenResult = HttpClientUtils.post(AppflgConstant.getDzpzkTokenURL(), null, null);
|
||||
LogBillUtils.SaveLogBill(AppflgConstant.getDzpzkTokenURL(), getTokenResult, AppflgConstant.DZPZK_TOKE_URL_NAME, "");
|
||||
Map<String, String> hd = new HashMap<>();
|
||||
Map<String, Object> bd = new HashMap<>();
|
||||
String dzpzkTokenURL = AppflgConstant.getDzpzkTokenURL();
|
||||
String getTokenResult = HttpClientUtils.post(dzpzkTokenURL, hd,bd);
|
||||
LogBillUtils.SaveLogBill(dzpzkTokenURL, getTokenResult, AppflgConstant.DZPZK_TOKE_URL_NAME, "");
|
||||
if (StringUtils.isEmpty(getTokenResult)) {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
|
@ -306,10 +312,12 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
private static Elements buildElements(DynamicObject[] sourcebillid, String org_shkd_sap_number, DynamicObject org, DynamicObject voucher, Elements elements) {
|
||||
DynamicObject[] ap_finapbillObjects = sourcebillid;
|
||||
for (DynamicObject apBillObj : ap_finapbillObjects) {
|
||||
DynamicObjectCollection inventry = apBillObj.getDynamicObjectCollection("inventry");
|
||||
DynamicObjectCollection inventry = apBillObj.getDynamicObjectCollection("shkd_inventry");
|
||||
for (DynamicObject apInvoice: inventry) {
|
||||
Attr attr = new Attr();
|
||||
DynamicObject invoiceBill = apInvoice.getDynamicObject("shkd_invoicereceipt");//发票识别单
|
||||
DynamicObject shkd_invoicereceipt = apInvoice.getDynamicObject("shkd_invoicereceipt");//发票识别单
|
||||
DynamicObject invoiceBill = BusinessDataServiceHelper.loadSingle(shkd_invoicereceipt.getPkValue(), "shkd_invoicereceipt");
|
||||
|
||||
attr.setInvoiceCode(invoiceBill.getString("shkd_invoicecode"));
|
||||
attr.setInvoiceNumber(invoiceBill.getString("shkd_invoiceno"));
|
||||
attr.setInvoiceType("");
|
||||
|
@ -336,10 +344,34 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
List<Map<String, Object>> attachments = AttachmentServiceHelper.getAttachments("shkd_invoicereceipt", invoiceBill.getPkValue(), "attachmentpanel");
|
||||
for (Map<String,Object> attach:attachments) {
|
||||
PartyAttachmentList fileVo = new PartyAttachmentList();
|
||||
String url = (String)attach.get("url");
|
||||
String fileHexString = FileUtils.fileToHex(url);
|
||||
// String url = (String)attach.get("url");
|
||||
Object attPkId = attach.get("attPkId");
|
||||
AttachmentDto attachmentDto = AttachmentServiceHelper.getAttachmentInfoByAttPk(attPkId);
|
||||
String url = attachmentDto.getResourcePath();
|
||||
String fileHexString = "";
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
FileServiceFactory.getAttachmentFileService().download(url,out,null);
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(out.toByteArray());
|
||||
|
||||
try {
|
||||
byte[] data = new byte[bis.available()];
|
||||
bis.read(data);
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte b : data) {
|
||||
String hex = Integer.toHexString(0xff & b);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
fileHexString = hexString.toString();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// String fileHexString = FileUtils.fileToHex((FileInputStream)inputStream);
|
||||
String name = (String)attach.get("name");
|
||||
Integer size = (Integer)attach.get("size");
|
||||
Long size = (Long)attach.get("size");
|
||||
fileVo.setFileName(name);
|
||||
fileVo.setFileSize(size);
|
||||
fileVo.setNumeration("HEX");
|
||||
|
@ -362,7 +394,7 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
|
||||
for (DynamicObject voucher : dataEntities) {
|
||||
String voucherNo = voucher.getString("billno");//凭证号
|
||||
if("C".equals(voucher.getString("billstatus"))){
|
||||
if(!"C".equals(voucher.getString("billstatus"))){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append(" 凭证未审核").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
|
@ -370,7 +402,7 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
if("0".equals(voucher.getString("shkd_dzpzkstatus"))){
|
||||
if(!"0".equals(voucher.getString("shkd_dzpzkstatus"))){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足查询条件,原因:");
|
||||
errStr.append(" 凭证归档状态不是 附件已归档待处理").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
|
@ -386,7 +418,7 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
|
||||
voucherColl.add(voucher);
|
||||
}
|
||||
//数据校验不通过,则不进行同步
|
||||
if(StringUtils.isNotEmpty(errStr.toString())){
|
||||
|
@ -398,9 +430,10 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
//2.组装转换参数
|
||||
for (DynamicObject voucher : voucherColl) {
|
||||
DynamicObject org = voucher.getDynamicObject("org");
|
||||
String shkd_gd_reqno = org.getString("shkd_gd_reqno");
|
||||
String shkd_gd_reqno = voucher.getString("shkd_gd_reqno");
|
||||
//同步
|
||||
//1.缓存有token 则取缓存里的token
|
||||
//1.缓存有token 则取缓存里的token
|
||||
String token ="";
|
||||
if (cache.contains(AppflgConstant.DZPZK_TOKEN)) {
|
||||
token = cache.get(AppflgConstant.DZPZK_TOKEN);
|
||||
|
@ -410,8 +443,11 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
//1.3.通过接口调用获取token
|
||||
|
||||
try {
|
||||
String getTokenResult = HttpClientUtils.post(AppflgConstant.getDzpzkTokenURL(), null, null);
|
||||
LogBillUtils.SaveLogBill(AppflgConstant.getDzpzkTokenURL(), getTokenResult, AppflgConstant.DZPZK_TOKE_URL_NAME, "");
|
||||
Map<String, String> hd = new HashMap<>();
|
||||
Map<String, Object> bd = new HashMap<>();
|
||||
String dzpzkTokenURL = AppflgConstant.getDzpzkTokenURL();
|
||||
String getTokenResult = HttpClientUtils.post(dzpzkTokenURL, hd,bd);
|
||||
LogBillUtils.SaveLogBill(dzpzkTokenURL, getTokenResult, AppflgConstant.DZPZK_TOKE_URL_NAME, "");
|
||||
if (StringUtils.isEmpty(getTokenResult)) {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
|
|
|
@ -35,4 +35,29 @@ public class FileUtils {
|
|||
}
|
||||
return hexString;
|
||||
}
|
||||
|
||||
public static String fileToHex(FileInputStream fis){
|
||||
String hexString ="";
|
||||
try {
|
||||
// FileInputStream fis = new FileInputStream(filePath);
|
||||
List<Integer> hexValues = new ArrayList<>();
|
||||
|
||||
int b;
|
||||
while ((b = fis.read()) != -1) {
|
||||
hexValues.add(b);
|
||||
}
|
||||
|
||||
StringBuilder hexBuilder = new StringBuilder();
|
||||
for (int value : hexValues) {
|
||||
hexBuilder.append(String.format("%02x", value));
|
||||
}
|
||||
hexString = hexBuilder.toString();
|
||||
// System.out.println(hexString);
|
||||
fis.close();
|
||||
// return hexString;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return hexString;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package shkd.fi.fi.util;
|
|||
|
||||
import shkd.fi.fi.sap.requst.docuentif.*;
|
||||
import shkd.fi.fi.sap.result.docuentif.MTDocumentIFRet;
|
||||
import shkd.fi.fi.sap.result.docuentif.cxdocuentif.MT_CXDOCUMENT_IF_RET;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
@ -19,8 +20,9 @@ public class XmlUtils {
|
|||
public static final String START_SUB_STR="<SOAP:Body>";
|
||||
public static final String END_SUB_STR="</SOAP:Body>";
|
||||
public static void main(String[] args) throws JAXBException, UnsupportedEncodingException {
|
||||
System.out.println(getXml(setData()).replaceAll("DT_DOCUMENT_IF_SRC", "urn:MT_DOCUMENT_IF_SRC"));
|
||||
|
||||
// System.out.println(getXml(setData()).replaceAll("DT_DOCUMENT_IF_SRC", "urn:MT_DOCUMENT_IF_SRC"));
|
||||
xmlToOjbectTest();
|
||||
resultXmlToOjbectTest();
|
||||
}
|
||||
|
||||
public synchronized static String getXml(Object object) throws JAXBException, UnsupportedEncodingException {
|
||||
|
@ -225,6 +227,46 @@ public class XmlUtils {
|
|||
|
||||
System.out.println("PACKGID: " + mtdoc.getData().getOtRETN().getItem().getPackgid());
|
||||
}
|
||||
public static void resultXmlToOjbectTest() throws JAXBException {
|
||||
StringBuffer xml = new StringBuffer();
|
||||
xml.append("<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">");
|
||||
xml.append(" <SOAP:Header/>");
|
||||
xml.append(" <SOAP:Body>");
|
||||
xml.append(" <ns1:MT_DOCUMENT_IF_RET xmlns:ns1=\"urn:coscoshipping:shhy:2020\">");
|
||||
xml.append(" <DATA>");
|
||||
xml.append(" <OT_RETN>");
|
||||
xml.append(" <ITEM>");
|
||||
xml.append(" <PACKGID>JDN10002</PACKGID>");
|
||||
xml.append(" <BELNR>0100000000</BELNR>");
|
||||
xml.append(" <ZSTATUS>S</ZSTATUS>");
|
||||
xml.append(" <PROMSG>SAP凭证号:0100000000冲销成功,冲销凭证:0100000001</PROMSG>");
|
||||
xml.append(" <WBDATE>20240708</WBDATE>");
|
||||
xml.append(" </ITEM>");
|
||||
// xml.append(" <ITEM>");
|
||||
// xml.append(" <PACKGID>JDN10002</PACKGID>");
|
||||
// xml.append(" <BELNR>0100000000</BELNR>");
|
||||
// xml.append(" <ZSTATUS>F</ZSTATUS>");
|
||||
// xml.append(" <PROMSG>凭证已冲销:010000000121L62024</PROMSG>");
|
||||
// xml.append(" <WBDATE>20240708</WBDATE>");
|
||||
// xml.append(" </ITEM>");
|
||||
xml.append(" </OT_RETN>");
|
||||
xml.append(" </DATA>");
|
||||
xml.append(" </ns1:MT_DOCUMENT_IF_RET>");
|
||||
xml.append(" </SOAP:Body>");
|
||||
xml.append("</SOAP:Envelope>");
|
||||
String string = xml.toString();
|
||||
System.out.println(string.contains("<SOAP:Body>"));
|
||||
System.out.println(string.contains("</SOAP:Body>"));
|
||||
string=string.substring(string.indexOf("<SOAP:Body>")+11, string.indexOf("</SOAP:Body>")-1);
|
||||
System.out.println(string);
|
||||
|
||||
MTDocumentIFRet mtdoc = XmlUtils.xmlToObject(MTDocumentIFRet.class, xml.toString(), XmlUtils.START_SUB_STR, XmlUtils.END_SUB_STR);
|
||||
|
||||
// System.out.println("PACKGID: " + mtDocumentIFRet.getData().getOtRetn().getItemList().get(0).getPackgid());
|
||||
System.out.println("PACKGID: " + mtdoc.getData().getOtRETN().getItem().getPackgid());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue