dzpzk code
This commit is contained in:
parent
ad2c8ce2e3
commit
80978cf489
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* Copyright 2024 bejson.com
|
||||
*/
|
||||
package shkd.fi.fi.common.dzpzk.token;
|
||||
|
||||
/**
|
||||
* Auto-generated: 2024-08-01 17:31:18
|
||||
*
|
||||
* @author bejson.com (i@bejson.com)
|
||||
* @website http://www.bejson.com/java2pojo/
|
||||
*/
|
||||
public class DzpzTokenBean {
|
||||
|
||||
private String access_token;
|
||||
private String token_type;
|
||||
private String refresh_token;
|
||||
private int expires_in;
|
||||
private String scope;
|
||||
public void setAccess_token(String access_token) {
|
||||
this.access_token = access_token;
|
||||
}
|
||||
public String getAccess_token() {
|
||||
return access_token;
|
||||
}
|
||||
|
||||
public void setToken_type(String token_type) {
|
||||
this.token_type = token_type;
|
||||
}
|
||||
public String getToken_type() {
|
||||
return token_type;
|
||||
}
|
||||
|
||||
public void setRefresh_token(String refresh_token) {
|
||||
this.refresh_token = refresh_token;
|
||||
}
|
||||
public String getRefresh_token() {
|
||||
return refresh_token;
|
||||
}
|
||||
|
||||
public void setExpires_in(int expires_in) {
|
||||
this.expires_in = expires_in;
|
||||
}
|
||||
public int getExpires_in() {
|
||||
return expires_in;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package shkd.fi.fi.oa;
|
||||
import org.codehaus.xfire.client.*;
|
||||
public class OAInvoiceImpl {
|
||||
|
||||
public static void sendOA (){
|
||||
|
||||
// org.codehaus.xfire.client.Client client = new Client(new URL("http://127.0.0.1:8080/XFire_demo/services/XFireServer?wsdl"));
|
||||
// Object[] results11 = client.invoke("sayHello", new Object[]{"Jadyer22"});
|
||||
// System.out.println(results11[0]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,531 @@
|
|||
package shkd.fi.fi.opplugin;
|
||||
|
||||
import com.alibaba.druid.support.logging.Log;
|
||||
import com.alibaba.druid.support.logging.LogFactory;
|
||||
import com.sap.db.jdbc.packet.ErrorLevel;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.bos.util.StringUtils;
|
||||
import shkd.fi.fi.common.AppflgConstant;
|
||||
import shkd.fi.fi.sap.requst.docuentif.*;
|
||||
import shkd.fi.fi.sap.result.docuentif.Item;
|
||||
import shkd.fi.fi.sap.result.docuentif.MTDocumentIFRet;
|
||||
import shkd.fi.fi.util.HttpUtils;
|
||||
import shkd.fi.fi.util.LogBillUtils;
|
||||
import shkd.fi.fi.util.XmlUtils;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 凭证-->电子凭证库
|
||||
* 元:shkd_gl_voucher_ext
|
||||
*/
|
||||
public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
||||
private static final Log log = LogFactory.getLog(DzpzkOPPlugin.class);
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
String operationKey = e.getOperationKey();
|
||||
switch (operationKey){
|
||||
case "shkd_synchronizasap":
|
||||
synSap(e);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
public void synSap(AfterOperationArgs e){
|
||||
//1.校验,不满足条件的凭证,移除,不传输
|
||||
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");//凭证号
|
||||
//1.1.校验公司是否已映射SAP编码
|
||||
DynamicObject org = voucher.getDynamicObject("org");
|
||||
String org_shkd_sap_number = org.getString("shkd_sap_number");
|
||||
if (StringUtils.isEmpty(org_shkd_sap_number)) {
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("业务单元 ").append(org.getString("number")).append(" ").append(org.getString("name"));
|
||||
errStr.append(" 未维护SAP组织编码映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
//1.2.校验会计科目是否已映射SAP科目编码
|
||||
//1.3.核算维度校验:成本中心是否已映射SAP编码
|
||||
//1.4.核算维度校验:供应商是否已映射SAP编码
|
||||
//1.5.核算维度校验:客户是否已映射SAP编码
|
||||
DynamicObjectCollection entries = voucher.getDynamicObjectCollection("entries");
|
||||
boolean entryIsCheckPass = false;//分录是否校验通过
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
DynamicObject entry = entries.get(i);
|
||||
//总账科目
|
||||
DynamicObject account = entry.getDynamicObject("account");
|
||||
String account_shkd_sap_number = account.getString("shkd_sap_number");
|
||||
if (StringUtils.isEmpty(account_shkd_sap_number)) {
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("会计科目:").append(account.getString("number")).append(" ").append(account.getString("name"));
|
||||
errStr.append(" 未维护SAP编码映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
boolean shkd_sap_supplier_in = account.getBoolean("shkd_sap_supplier_in");//供应商是否必须
|
||||
// boolean shkd_sap_kostl_in = account.getBoolean("shkd_sap_kostl_in");//成本中心是否必须
|
||||
String shkd_sap_blart = account.getString("shkd_sap_blart");//SAP凭证类型
|
||||
String shkd_sap_bschl_j = account.getString("shkd_sap_bschl_j");//SAP记账代码(借)
|
||||
String shkd_sap_bschl_d = account.getString("shkd_sap_bschl_d");//SAP记账代码(贷)
|
||||
String shkd_sap_sup_num = account.getString("shkd_sap_sup_num");//SAP默认供应商编码
|
||||
if(StringUtils.isEmpty(shkd_sap_blart)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("会计科目:").append(account.getString("number")).append(" ").append(account.getString("name"));
|
||||
errStr.append(" 未维护SAP凭证类型映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
if(StringUtils.isEmpty(shkd_sap_bschl_j)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("会计科目:").append(account.getString("number")).append(" ").append(account.getString("name"));
|
||||
errStr.append(" 未维护SAP记账代码(借)映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
if(StringUtils.isEmpty(shkd_sap_bschl_d)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("会计科目:").append(account.getString("number")).append(" ").append(account.getString("name"));
|
||||
errStr.append(" 未维护SAP记账代码(贷)映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
String shkd_sap_sup_number = "";//核算维度 供应商编码
|
||||
String shkd_sap_cus_number = "";//核算维度 客户编码
|
||||
String shkd_sap_dep_number = "";//核算维度 部门编码
|
||||
DynamicObject assgrp = entry.getDynamicObject("assgrp");
|
||||
if (null != assgrp) {
|
||||
|
||||
|
||||
QFilter filter = new QFilter("hg.id", QCP.equals,assgrp.getPkValue());
|
||||
DynamicObjectCollection gl_assist_bd = QueryServiceHelper.query("gl_assist_bd", "hg.id,asstype,assval", new QFilter[]{filter});
|
||||
Map<Long,String> map = new HashMap<Long,String>();
|
||||
for (int j = 0; j < gl_assist_bd.size(); j++) {
|
||||
DynamicObject gl_assist_bdObject = gl_assist_bd.get(j);
|
||||
Long hgId = gl_assist_bdObject.getLong("hg.id");
|
||||
Long assval = gl_assist_bdObject.getLong("assval");//维度值
|
||||
String asstype = gl_assist_bdObject.getString("asstype");
|
||||
switch (asstype) {
|
||||
case "f0001":
|
||||
//客户
|
||||
DynamicObject customer = QueryServiceHelper.queryOne("bd_customer", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
shkd_sap_cus_number = customer.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_cus_number)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("客户:").append(customer.getString("number")).append(" ").append(customer.getString("name"));
|
||||
errStr.append(" 未维护SAP编码映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}else {
|
||||
entryIsCheckPass=true;
|
||||
}
|
||||
break;
|
||||
case "f000005":
|
||||
//供应商
|
||||
DynamicObject supplier = QueryServiceHelper.queryOne("bd_supplier", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
shkd_sap_sup_number = supplier.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_sup_number)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("供应商:").append(supplier.getString("number")).append(" ").append(supplier.getString("name"));
|
||||
errStr.append(" 未维护SAP编码映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}else {
|
||||
entryIsCheckPass=true;
|
||||
}
|
||||
break;
|
||||
case "f000009":
|
||||
//部门
|
||||
DynamicObject adminOrg = QueryServiceHelper.queryOne("bos_adminorg", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
shkd_sap_dep_number = adminOrg.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_dep_number)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("部门:").append(adminOrg.getString("number")).append(" ").append(adminOrg.getString("name"));
|
||||
errStr.append(" 未维护SAP编码映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}else {
|
||||
entryIsCheckPass=true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//如果 科目上 SAP供应商核算维度必须传,并且当前金蝶科目没核算维度为供应商,且科目上维护的SAP默认供应商编码为空,则校验不通过
|
||||
if(shkd_sap_supplier_in&&StringUtils.isEmpty(shkd_sap_sup_number)&&StringUtils.isEmpty(account.getString("shkd_sap_sup_num"))){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("会计科目:").append(account.getString("number")).append(" ").append(account.getString("name"));
|
||||
errStr.append(" SAP系统要求供应商必须,当前凭证上科目无供应商核算维度或科目映射未维护SAP默认供应商编码,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
entryIsCheckPass=true;
|
||||
|
||||
}
|
||||
if(entryIsCheckPass){
|
||||
voucherColl.add(voucher);
|
||||
}else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//数据校验不通过,则不进行同步
|
||||
if(StringUtils.isNotEmpty(errStr.toString())){
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
return;
|
||||
}
|
||||
Integer integer = 0;
|
||||
//2.组装转换参数
|
||||
for (DynamicObject dataEntity : voucherColl) {
|
||||
|
||||
//结构:ZFIS_YS_HEAD 库存-财务系统PI接口表头结构 (1-6)
|
||||
DT_DOCUMENT_IF_SRCDATAIS_HEADER header = new DT_DOCUMENT_IF_SRCDATAIS_HEADER();
|
||||
//结构:ZFIS_YS_ITEM 库存-财务系统PI接口行项目结构
|
||||
DT_DOCUMENT_IF_SRCDATAIT_ITEMITEM items = new DT_DOCUMENT_IF_SRCDATAIT_ITEMITEM();
|
||||
|
||||
// DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), "gl_voucher","id,billno,org,creator.name,entries.*");
|
||||
DynamicObject gl_voucher = dataEntity;
|
||||
|
||||
//1.公司代码(BUKRS)--核算组织(org)
|
||||
DynamicObject org = gl_voucher.getDynamicObject("org");
|
||||
String shkd_sap_number = org.getString("shkd_sap_number");
|
||||
|
||||
//2.创建日期(CRDATE)--当前时间
|
||||
Date date = new Date();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String crdate = simpleDateFormat.format(date);
|
||||
//3.创建人(CRNAME)--创建人名称(creator)
|
||||
DynamicObject creator = gl_voucher.getDynamicObject("creator");
|
||||
String crname = "";
|
||||
if (null != creator) {
|
||||
crname = creator.getString("name");
|
||||
}
|
||||
//4.记录条数(ZRTOALL)--所传数据的凭证分录总条数
|
||||
DynamicObjectCollection entries = gl_voucher.getDynamicObjectCollection("entries");
|
||||
integer += entries.size();
|
||||
//5.数据包唯一标识号(PACKGID)--格式:JDN+时间戳
|
||||
String packgid = "JDN" + date.getTime();
|
||||
//6.数据状态(T:测试运行,P:正式运行)(ZFLAG)--固定传T
|
||||
String zflag = "P";
|
||||
header.setBUKRS(shkd_sap_number);
|
||||
header.setCRDATE(crdate);
|
||||
header.setCRNAME(crname);
|
||||
header.setZRTOALL(integer.toString());
|
||||
header.setPACKGID(packgid);
|
||||
header.setZFLAG(zflag);
|
||||
|
||||
|
||||
//7.库存凭证号(DOCID)--凭证号_凭证ID
|
||||
Long id = gl_voucher.getLong("id");
|
||||
String billno = gl_voucher.getString("billno");
|
||||
String docid = id + "_" + billno;
|
||||
//9.数据处理状态 (I未处理V校验失败F过账失败S过账成功(写死"I未处理"))(ZSTATUS)--固定值I
|
||||
String zstatus = "I";
|
||||
//13.抬头文本(BKTXT)----凭证分录第一行摘要(如超长需截位,保留前25个字)(edescription)
|
||||
String bktxt = "";
|
||||
//14.货币码(WAERS)----币别基础资料的货币代码(currency)
|
||||
String waers = "";
|
||||
//16.凭证类型 SAP凭证类型(默认值:具体值待定)(BLART)--固定值SA
|
||||
String blart = "SA";
|
||||
//17.总账科目(HKONT)----取会计科目上SAP科目编码,测试时,可传9999999999(account)
|
||||
//18.记账代码y(BSCHL)----借贷方向,40=借方,50=贷方(entrydc)
|
||||
//19.凭证货币金额(WRBTR)----原币金额(oriamount)
|
||||
//19.按本位币计的金额(DMBTR)----原币金额(oriamount)
|
||||
//20.项目文本(SGTXT)----凭证行摘要(edescription)
|
||||
//21.成本中心(KOSTL)----金蝶核算维度:成本中心SAP编码()
|
||||
List<DT_DOCUMENT_IF_SRCDATAIT_ITEM> itemsList = new ArrayList<>();
|
||||
for (DynamicObject entry : entries) {
|
||||
DT_DOCUMENT_IF_SRCDATAIT_ITEM items1 = new DT_DOCUMENT_IF_SRCDATAIT_ITEM();
|
||||
|
||||
//8.库存行项目号(ITEMID)--凭证分录行号,从1开始
|
||||
String seq = "";
|
||||
seq = entry.getString("seq");
|
||||
|
||||
//10.公司代码----同1重复
|
||||
//11.凭证中的过账日期(BUDAT)--记账日期(bookeddate)20181031
|
||||
//12.凭证中的凭证日期(BLDAT)--记账日期
|
||||
//15.凭证中的凭证日期(WWERT)--记账日期
|
||||
Date bookeddate = gl_voucher.getDate("bookeddate");
|
||||
String budat = "";
|
||||
String bldat = "";
|
||||
String wwert = "";
|
||||
if (null != bookeddate) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
budat = simpleDateFormat.format(bookeddate);
|
||||
budat = budat.substring(0, 8);
|
||||
bldat = simpleDateFormat.format(bookeddate);
|
||||
bldat = bldat.substring(0, 8);
|
||||
wwert = simpleDateFormat.format(bookeddate);
|
||||
wwert = wwert.substring(0, 8);
|
||||
}
|
||||
|
||||
bktxt = entries.get(0).getString("edescription");
|
||||
if (bktxt.length() > 25) {
|
||||
bktxt = bktxt.substring(0, 25);//摘要
|
||||
}
|
||||
//币别
|
||||
DynamicObject currency = entries.get(0).getDynamicObject("currency");
|
||||
if (null != currency) {
|
||||
waers = currency.getString("number");
|
||||
}
|
||||
|
||||
//总账科目
|
||||
DynamicObject account = entry.getDynamicObject("account");
|
||||
String hkont = account.getString("shkd_sap_number");
|
||||
blart =account.getString("shkd_sap_blart");//SAP 科目-凭证类型
|
||||
//记账代码
|
||||
String bschl = "";
|
||||
//凭证货币金额
|
||||
BigDecimal oriamount = BigDecimal.ZERO;
|
||||
if ("1".equals(entry.getString("entrydc"))) {
|
||||
bschl = account.getString("shkd_sap_bschl_j");
|
||||
oriamount = entry.getBigDecimal("debitori");
|
||||
} else if ("-1".equals(entry.getString("entrydc"))) {
|
||||
bschl = account.getString("shkd_sap_bschl_d");;
|
||||
oriamount = entry.getBigDecimal("creditori");
|
||||
}
|
||||
String wrbtr = oriamount.toString();
|
||||
String dmbtr = oriamount.toString();
|
||||
//项目文本
|
||||
String sgtxt = entry.getString("edescription");
|
||||
if (sgtxt.length() > 25) {
|
||||
sgtxt = sgtxt.substring(0, 25);
|
||||
}
|
||||
|
||||
//todo
|
||||
DynamicObject assgrp = entry.getDynamicObject("assgrp");
|
||||
String KUNNR="";//客户
|
||||
String LIFNR="";//供应商
|
||||
String KOSTL="";//成本中心 部门
|
||||
if (null != assgrp) {
|
||||
QFilter filter = new QFilter("hg.id", QCP.equals,assgrp.getPkValue());
|
||||
DynamicObjectCollection gl_assist_bd = QueryServiceHelper.query("gl_assist_bd", "hg.id,asstype,assval", new QFilter[]{filter});
|
||||
for (int j = 0; j < gl_assist_bd.size(); j++) {
|
||||
DynamicObject gl_assist_bdObject = gl_assist_bd.get(j);
|
||||
Long hgId = gl_assist_bdObject.getLong("hg.id");
|
||||
Long assval = gl_assist_bdObject.getLong("assval");//维度值
|
||||
String asstype = gl_assist_bdObject.getString("asstype");
|
||||
switch (asstype) {
|
||||
case "f0001":
|
||||
//客户
|
||||
DynamicObject dynamicObject = QueryServiceHelper.queryOne("bd_customer", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
KUNNR = dynamicObject.getString("shkd_sap_number");
|
||||
|
||||
break;
|
||||
case "f000005":
|
||||
//供应商
|
||||
dynamicObject = QueryServiceHelper.queryOne("bd_supplier", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
LIFNR = dynamicObject.getString("shkd_sap_number");
|
||||
|
||||
break;
|
||||
case "f000009":
|
||||
//部门
|
||||
dynamicObject = QueryServiceHelper.queryOne("bos_adminorg", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
KOSTL = dynamicObject.getString("shkd_sap_number");
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//如果科目上维护了SAP默认供应商编码,则以科目维护的为准
|
||||
String shkd_sap_sup_num = account.getString("shkd_sap_sup_num");
|
||||
if(StringUtils.isNotEmpty(shkd_sap_sup_num)){
|
||||
LIFNR = shkd_sap_sup_num;
|
||||
}
|
||||
|
||||
items1.setDOCID(docid);
|
||||
items1.setITEMNO(seq);
|
||||
items1.setZSTATUS(zstatus);
|
||||
items1.setBUKRS(shkd_sap_number);
|
||||
items1.setBUDAT(budat);
|
||||
|
||||
items1.setBLDAT(budat);
|
||||
items1.setBKTXT(bktxt);
|
||||
items1.setWAERS(waers);
|
||||
items1.setWWERT(budat);
|
||||
items1.setBLART(blart);
|
||||
items1.setHKONT(hkont);
|
||||
items1.setBSCHL(bschl);
|
||||
items1.setUMSKZ("");
|
||||
items1.setWRBTR(wrbtr);
|
||||
items1.setDMBTR(dmbtr);
|
||||
items1.setZUONR("");
|
||||
items1.setSGTXT(sgtxt);
|
||||
items1.setKOSTL(KOSTL);
|
||||
items1.setPRCTR("");
|
||||
items1.setGSBER("");
|
||||
items1.setKUNNR(KUNNR);
|
||||
items1.setLIFNR(LIFNR);
|
||||
items1.setAUFNR("");
|
||||
items1.setVALUT("");
|
||||
items1.setXREF1("");
|
||||
items1.setXREF2("");
|
||||
items1.setXREF3("");
|
||||
items1.setVBUND("");
|
||||
items1.setZZCUSTOMER(KUNNR);
|
||||
items1.setZZVENDOR(LIFNR);
|
||||
items1.setZZFIELD1("");
|
||||
items1.setZZFIELD2("");
|
||||
items1.setZZFIELD3("");
|
||||
items1.setZZFIELD4("");
|
||||
items1.setZZFIELD5("");
|
||||
items1.setZZFIELD6("");
|
||||
items1.setHBKID("");
|
||||
items1.setHKTID("");
|
||||
items1.setXNEGP("");
|
||||
items1.setKIDNO("");
|
||||
|
||||
itemsList.add(items1);
|
||||
}
|
||||
items.setItems(itemsList);
|
||||
|
||||
//3.调用SAP接口
|
||||
try {
|
||||
DT_DOCUMENT_IF_SRC dt_document_if_src = setData(header, items);
|
||||
String xml = XmlUtils.getXml(dt_document_if_src).replaceAll("DT_DOCUMENT_IF_SRC", "urn:MT_DOCUMENT_IF_SRC");
|
||||
Map<String, String> headerMap = new HashMap<String, String>();
|
||||
String spa_user_pass = System.getProperty(AppflgConstant.SAP_USER_PASS);
|
||||
byte[] token = Base64.getEncoder().encode(spa_user_pass.getBytes());
|
||||
String tokenStr = new String(token);
|
||||
String sap_syn_voucher_url = System.getProperty(AppflgConstant.SAP_SYN_VOUCHER_URL);
|
||||
|
||||
String responseStr="";
|
||||
Map<String,Object> result = HttpUtils.sendPostToSAP(sap_syn_voucher_url,tokenStr, xml);
|
||||
if(null!=result){
|
||||
String status = String.valueOf(result.get(HttpUtils.STATUS));
|
||||
responseStr = String.valueOf(result.get(HttpUtils.RESPONSE_STRING));
|
||||
log.info(status);
|
||||
log.info(responseStr);
|
||||
//4.处理接口返回结果:解析记录结果到凭证上,
|
||||
if(status.equals("200")){//成功
|
||||
MTDocumentIFRet mtDocumentIFRet = XmlUtils.xmlToObject(MTDocumentIFRet.class, responseStr, XmlUtils.START_SUB_STR, XmlUtils.END_SUB_STR);
|
||||
if(null!=mtDocumentIFRet&&null!=mtDocumentIFRet.getData()
|
||||
&&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("同步成功");
|
||||
|
||||
}else {//失败
|
||||
//失败提示
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("同步失败:"+item.getPromsg());
|
||||
}
|
||||
//更新凭证上接口返回字段
|
||||
updateVoucher(gl_voucher,item);
|
||||
}
|
||||
}else{//失败
|
||||
//更新凭证上接口返回字段
|
||||
updateVoucher(gl_voucher,responseStr);
|
||||
}
|
||||
//5.记录到接口日志表
|
||||
LogBillUtils.SaveLogBill(sap_syn_voucher_url,responseStr,AppflgConstant.SAP_SYN_VOUCHER_URL_NNAME,xml);
|
||||
}
|
||||
} catch (JAXBException ex) {
|
||||
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
|
||||
// operateErrorInfo.setMessage(exc.getMessage());
|
||||
operateErrorInfo.setErrorLevel(ErrorLevel.Error.name());
|
||||
operateErrorInfo.setPkValue(dataEntity.getPkValue());
|
||||
this.operationResult.addErrorInfo(operateErrorInfo);
|
||||
throw new RuntimeException(ex);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
System.out.println(integer);
|
||||
}
|
||||
|
||||
public static void updateVoucher (DynamicObject voucher,Item item) {
|
||||
String zstatus = item.getZstatus();
|
||||
String packgid = item.getPackgid();
|
||||
String docid = item.getDocid();
|
||||
String promsg = item.getPromsg();
|
||||
String bukrs = item.getBukrs();
|
||||
String gjahr = item.getGjahr();
|
||||
String monat = item.getMonat();
|
||||
String belnr = item.getBelnr();
|
||||
String wbdate = item.getWbdate();
|
||||
voucher.set("shkd_zstatus","S".equals(zstatus)?"1":"0");
|
||||
voucher.set("shkd_packgid",packgid);
|
||||
voucher.set("shkd_docid",docid);
|
||||
voucher.set("shkd_promsg",promsg);
|
||||
voucher.set("shkd_bukrs",bukrs);
|
||||
voucher.set("shkd_gjahr",gjahr);
|
||||
voucher.set("shkd_monat",monat);
|
||||
voucher.set("shkd_belnr",belnr);
|
||||
voucher.set("shkd_wbdate",wbdate);
|
||||
SaveServiceHelper.save(new DynamicObject[]{voucher});
|
||||
}
|
||||
public static void updateVoucher (DynamicObject voucher,String resultStr) {
|
||||
voucher.set("zstatus","0");
|
||||
voucher.set("promsg",resultStr);
|
||||
SaveServiceHelper.save(new DynamicObject[]{voucher});
|
||||
}
|
||||
|
||||
public static DT_DOCUMENT_IF_SRC setData(DT_DOCUMENT_IF_SRCDATAIS_HEADER header, DT_DOCUMENT_IF_SRCDATAIT_ITEMITEM items){
|
||||
DT_DOCUMENT_IF_SRC srcData = new DT_DOCUMENT_IF_SRC();
|
||||
DT_DOCUMENT_IF_SRCDATA data = new DT_DOCUMENT_IF_SRCDATA();
|
||||
// build header
|
||||
data.setIS_HEADER(header);
|
||||
//build items1
|
||||
data.setIT_ITEM(items);
|
||||
|
||||
srcData.setDATA(data);
|
||||
return srcData;
|
||||
}
|
||||
}
|
|
@ -92,7 +92,7 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
// boolean shkd_sap_supplier_in = account.getBoolean("shkd_sap_supplier_in");//供应商是否必须
|
||||
boolean shkd_sap_supplier_in = account.getBoolean("shkd_sap_supplier_in");//供应商是否必须
|
||||
// boolean shkd_sap_kostl_in = account.getBoolean("shkd_sap_kostl_in");//成本中心是否必须
|
||||
String shkd_sap_blart = account.getString("shkd_sap_blart");//SAP凭证类型
|
||||
String shkd_sap_bschl_j = account.getString("shkd_sap_bschl_j");//SAP记账代码(借)
|
||||
|
@ -127,6 +127,9 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
}
|
||||
|
||||
|
||||
String shkd_sap_sup_number = "";//核算维度 供应商编码
|
||||
String shkd_sap_cus_number = "";//核算维度 客户编码
|
||||
String shkd_sap_dep_number = "";//核算维度 部门编码
|
||||
DynamicObject assgrp = entry.getDynamicObject("assgrp");
|
||||
if (null != assgrp) {
|
||||
|
||||
|
@ -142,11 +145,11 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
switch (asstype) {
|
||||
case "f0001":
|
||||
//客户
|
||||
DynamicObject dynamicObject = QueryServiceHelper.queryOne("bd_customer", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
String shkd_sap_number = dynamicObject.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_number)){
|
||||
DynamicObject customer = QueryServiceHelper.queryOne("bd_customer", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
shkd_sap_cus_number = customer.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_cus_number)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("客户:").append(dynamicObject.getString("number")).append(" ").append(dynamicObject.getString("name"));
|
||||
errStr.append("客户:").append(customer.getString("number")).append(" ").append(customer.getString("name"));
|
||||
errStr.append(" 未维护SAP编码映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
|
@ -158,11 +161,11 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
break;
|
||||
case "f000005":
|
||||
//供应商
|
||||
dynamicObject = QueryServiceHelper.queryOne("bd_supplier", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
shkd_sap_number = dynamicObject.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_number)){
|
||||
DynamicObject supplier = QueryServiceHelper.queryOne("bd_supplier", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
shkd_sap_sup_number = supplier.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_sup_number)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("供应商:").append(dynamicObject.getString("number")).append(" ").append(dynamicObject.getString("name"));
|
||||
errStr.append("供应商:").append(supplier.getString("number")).append(" ").append(supplier.getString("name"));
|
||||
errStr.append(" 未维护SAP编码映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
|
@ -174,11 +177,11 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
break;
|
||||
case "f000009":
|
||||
//部门
|
||||
dynamicObject = QueryServiceHelper.queryOne("bos_adminorg", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
shkd_sap_number = dynamicObject.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_number)){
|
||||
DynamicObject adminOrg = QueryServiceHelper.queryOne("bos_adminorg", "id,name,number,shkd_sap_number", new QFilter[]{new QFilter("id", QCP.equals, assval)});
|
||||
shkd_sap_dep_number = adminOrg.getString("shkd_sap_number");
|
||||
if(StringUtils.isEmpty(shkd_sap_dep_number)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("部门:").append(dynamicObject.getString("number")).append(" ").append(dynamicObject.getString("name"));
|
||||
errStr.append("部门:").append(adminOrg.getString("number")).append(" ").append(adminOrg.getString("name"));
|
||||
errStr.append(" 未维护SAP编码映射,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
|
@ -194,6 +197,16 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
}
|
||||
|
||||
}
|
||||
//如果 科目上 SAP供应商核算维度必须传,并且当前金蝶科目没核算维度为供应商,且科目上维护的SAP默认供应商编码为空,则校验不通过
|
||||
if(shkd_sap_supplier_in&&StringUtils.isEmpty(shkd_sap_sup_number)&&StringUtils.isEmpty(account.getString("shkd_sap_sup_num"))){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append("会计科目:").append(account.getString("number")).append(" ").append(account.getString("name"));
|
||||
errStr.append(" SAP系统要求供应商必须,当前凭证上科目无供应商核算维度或科目映射未维护SAP默认供应商编码,请先维护;").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
entryIsCheckPass=true;
|
||||
|
||||
}
|
||||
|
@ -242,7 +255,7 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
//5.数据包唯一标识号(PACKGID)--格式:JDN+时间戳
|
||||
String packgid = "JDN" + date.getTime();
|
||||
//6.数据状态(T:测试运行,P:正式运行)(ZFLAG)--固定传T
|
||||
String zflag = "T";
|
||||
String zflag = "P";
|
||||
header.setBUKRS(shkd_sap_number);
|
||||
header.setCRDATE(crdate);
|
||||
header.setCRNAME(crname);
|
||||
|
@ -308,15 +321,16 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
//总账科目
|
||||
DynamicObject account = entry.getDynamicObject("account");
|
||||
String hkont = account.getString("shkd_sap_number");
|
||||
blart =account.getString("shkd_sap_blart");//SAP 科目-凭证类型
|
||||
//记账代码
|
||||
String bschl = "";
|
||||
//凭证货币金额
|
||||
BigDecimal oriamount = BigDecimal.ZERO;
|
||||
if ("1".equals(entry.getString("entrydc"))) {
|
||||
bschl = "40";
|
||||
bschl = account.getString("shkd_sap_bschl_j");
|
||||
oriamount = entry.getBigDecimal("debitori");
|
||||
} else if ("-1".equals(entry.getString("entrydc"))) {
|
||||
bschl = "50";
|
||||
bschl = account.getString("shkd_sap_bschl_d");;
|
||||
oriamount = entry.getBigDecimal("creditori");
|
||||
}
|
||||
String wrbtr = oriamount.toString();
|
||||
|
@ -365,6 +379,11 @@ public class SynchronizaSapOPPlugin extends AbstractOperationServicePlugIn {
|
|||
}
|
||||
|
||||
}
|
||||
//如果科目上维护了SAP默认供应商编码,则以科目维护的为准
|
||||
String shkd_sap_sup_num = account.getString("shkd_sap_sup_num");
|
||||
if(StringUtils.isNotEmpty(shkd_sap_sup_num)){
|
||||
LIFNR = shkd_sap_sup_num;
|
||||
}
|
||||
|
||||
items1.setDOCID(docid);
|
||||
items1.setITEMNO(seq);
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
package shkd.fi.fi.sap.requst.docuentif;
|
||||
|
||||
import shkd.fi.fi.util.CharsetUtils;
|
||||
|
||||
public class DT_DOCUMENT_IF_SRCDATAIS_HEADER implements java.io.Serializable {
|
||||
private String BUKRS;
|
||||
|
||||
|
@ -45,7 +47,7 @@ public class DT_DOCUMENT_IF_SRCDATAIS_HEADER implements java.io.Serializable {
|
|||
* @return BUKRS
|
||||
*/
|
||||
public String getBUKRS() {
|
||||
return BUKRS;
|
||||
return CharsetUtils.getUtf8Str(BUKRS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +67,7 @@ public class DT_DOCUMENT_IF_SRCDATAIS_HEADER implements java.io.Serializable {
|
|||
* @return CRDATE
|
||||
*/
|
||||
public String getCRDATE() {
|
||||
return CRDATE;
|
||||
return CharsetUtils.getUtf8Str(CRDATE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +87,7 @@ public class DT_DOCUMENT_IF_SRCDATAIS_HEADER implements java.io.Serializable {
|
|||
* @return CRNAME
|
||||
*/
|
||||
public String getCRNAME() {
|
||||
return CRNAME;
|
||||
return CharsetUtils.getUtf8Str(CRNAME);
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,7 +107,7 @@ public class DT_DOCUMENT_IF_SRCDATAIS_HEADER implements java.io.Serializable {
|
|||
* @return ZRTOALL
|
||||
*/
|
||||
public String getZRTOALL() {
|
||||
return ZRTOALL;
|
||||
return CharsetUtils.getUtf8Str(ZRTOALL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,7 +127,7 @@ public class DT_DOCUMENT_IF_SRCDATAIS_HEADER implements java.io.Serializable {
|
|||
* @return PACKGID
|
||||
*/
|
||||
public String getPACKGID() {
|
||||
return PACKGID;
|
||||
return CharsetUtils.getUtf8Str(PACKGID);
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,7 +147,7 @@ public class DT_DOCUMENT_IF_SRCDATAIS_HEADER implements java.io.Serializable {
|
|||
* @return ZFLAG
|
||||
*/
|
||||
public String getZFLAG() {
|
||||
return ZFLAG;
|
||||
return CharsetUtils.getUtf8Str(ZFLAG);
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,68 +160,6 @@ public class DT_DOCUMENT_IF_SRCDATAIS_HEADER implements java.io.Serializable {
|
|||
this.ZFLAG = ZFLAG;
|
||||
}
|
||||
|
||||
private Object __equalsCalc = null;
|
||||
public synchronized boolean equals(Object obj) {
|
||||
if (!(obj instanceof DT_DOCUMENT_IF_SRCDATAIS_HEADER)) return false;
|
||||
DT_DOCUMENT_IF_SRCDATAIS_HEADER other = (DT_DOCUMENT_IF_SRCDATAIS_HEADER) obj;
|
||||
if (obj == null) return false;
|
||||
if (this == obj) return true;
|
||||
if (__equalsCalc != null) {
|
||||
return (__equalsCalc == obj);
|
||||
}
|
||||
__equalsCalc = obj;
|
||||
boolean _equals;
|
||||
_equals = true &&
|
||||
((this.BUKRS==null && other.getBUKRS()==null) ||
|
||||
(this.BUKRS!=null &&
|
||||
this.BUKRS.equals(other.getBUKRS()))) &&
|
||||
((this.CRDATE==null && other.getCRDATE()==null) ||
|
||||
(this.CRDATE!=null &&
|
||||
this.CRDATE.equals(other.getCRDATE()))) &&
|
||||
((this.CRNAME==null && other.getCRNAME()==null) ||
|
||||
(this.CRNAME!=null &&
|
||||
this.CRNAME.equals(other.getCRNAME()))) &&
|
||||
((this.ZRTOALL==null && other.getZRTOALL()==null) ||
|
||||
(this.ZRTOALL!=null &&
|
||||
this.ZRTOALL.equals(other.getZRTOALL()))) &&
|
||||
((this.PACKGID==null && other.getPACKGID()==null) ||
|
||||
(this.PACKGID!=null &&
|
||||
this.PACKGID.equals(other.getPACKGID()))) &&
|
||||
((this.ZFLAG==null && other.getZFLAG()==null) ||
|
||||
(this.ZFLAG!=null &&
|
||||
this.ZFLAG.equals(other.getZFLAG())));
|
||||
__equalsCalc = null;
|
||||
return _equals;
|
||||
}
|
||||
|
||||
private boolean __hashCodeCalc = false;
|
||||
public synchronized int hashCode() {
|
||||
if (__hashCodeCalc) {
|
||||
return 0;
|
||||
}
|
||||
__hashCodeCalc = true;
|
||||
int _hashCode = 1;
|
||||
if (getBUKRS() != null) {
|
||||
_hashCode += getBUKRS().hashCode();
|
||||
}
|
||||
if (getCRDATE() != null) {
|
||||
_hashCode += getCRDATE().hashCode();
|
||||
}
|
||||
if (getCRNAME() != null) {
|
||||
_hashCode += getCRNAME().hashCode();
|
||||
}
|
||||
if (getZRTOALL() != null) {
|
||||
_hashCode += getZRTOALL().hashCode();
|
||||
}
|
||||
if (getPACKGID() != null) {
|
||||
_hashCode += getPACKGID().hashCode();
|
||||
}
|
||||
if (getZFLAG() != null) {
|
||||
_hashCode += getZFLAG().hashCode();
|
||||
}
|
||||
__hashCodeCalc = false;
|
||||
return _hashCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
package shkd.fi.fi.sap.requst.docuentif;
|
||||
|
||||
import shkd.fi.fi.util.CharsetUtils;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
@ -189,7 +191,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return DOCID
|
||||
*/
|
||||
public String getDOCID() {
|
||||
return DOCID;
|
||||
return CharsetUtils.getUtf8Str(DOCID);
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,7 +211,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return ITEMNO
|
||||
*/
|
||||
public String getITEMNO() {
|
||||
return ITEMNO;
|
||||
return CharsetUtils.getUtf8Str(ITEMNO);
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,7 +231,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return ZSTATUS
|
||||
*/
|
||||
public String getZSTATUS() {
|
||||
return ZSTATUS;
|
||||
return CharsetUtils.getUtf8Str(ZSTATUS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -249,7 +251,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return BUKRS
|
||||
*/
|
||||
public String getBUKRS() {
|
||||
return BUKRS;
|
||||
return CharsetUtils.getUtf8Str(BUKRS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -269,7 +271,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return BUDAT
|
||||
*/
|
||||
public String getBUDAT() {
|
||||
return BUDAT;
|
||||
return CharsetUtils.getUtf8Str(BUDAT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -289,7 +291,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return BLDAT
|
||||
*/
|
||||
public String getBLDAT() {
|
||||
return BLDAT;
|
||||
return CharsetUtils.getUtf8Str(BLDAT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -309,7 +311,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return BKTXT
|
||||
*/
|
||||
public String getBKTXT() {
|
||||
return BKTXT;
|
||||
return CharsetUtils.getUtf8Str(BKTXT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -329,7 +331,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return WAERS
|
||||
*/
|
||||
public String getWAERS() {
|
||||
return WAERS;
|
||||
return CharsetUtils.getUtf8Str(WAERS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -349,7 +351,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return WWERT
|
||||
*/
|
||||
public String getWWERT() {
|
||||
return WWERT;
|
||||
return CharsetUtils.getUtf8Str(WWERT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -369,7 +371,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return BLART
|
||||
*/
|
||||
public String getBLART() {
|
||||
return BLART;
|
||||
return CharsetUtils.getUtf8Str(BLART);
|
||||
}
|
||||
|
||||
|
||||
|
@ -389,7 +391,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return HKONT
|
||||
*/
|
||||
public String getHKONT() {
|
||||
return HKONT;
|
||||
return CharsetUtils.getUtf8Str(HKONT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -409,7 +411,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return BSCHL
|
||||
*/
|
||||
public String getBSCHL() {
|
||||
return BSCHL;
|
||||
return CharsetUtils.getUtf8Str(BSCHL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -429,7 +431,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return UMSKZ
|
||||
*/
|
||||
public String getUMSKZ() {
|
||||
return UMSKZ;
|
||||
return CharsetUtils.getUtf8Str(UMSKZ);
|
||||
}
|
||||
|
||||
|
||||
|
@ -449,7 +451,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return WRBTR
|
||||
*/
|
||||
public String getWRBTR() {
|
||||
return WRBTR;
|
||||
return CharsetUtils.getUtf8Str(WRBTR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -469,7 +471,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return DMBTR
|
||||
*/
|
||||
public String getDMBTR() {
|
||||
return DMBTR;
|
||||
return CharsetUtils.getUtf8Str(DMBTR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -489,7 +491,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return ZUONR
|
||||
*/
|
||||
public String getZUONR() {
|
||||
return ZUONR;
|
||||
return CharsetUtils.getUtf8Str(ZUONR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -509,7 +511,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return SGTXT
|
||||
*/
|
||||
public String getSGTXT() {
|
||||
return SGTXT;
|
||||
return CharsetUtils.getUtf8Str(SGTXT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -529,7 +531,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return KOSTL
|
||||
*/
|
||||
public String getKOSTL() {
|
||||
return KOSTL;
|
||||
return CharsetUtils.getUtf8Str(KOSTL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -549,7 +551,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return PRCTR
|
||||
*/
|
||||
public String getPRCTR() {
|
||||
return PRCTR;
|
||||
return CharsetUtils.getUtf8Str(PRCTR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -569,7 +571,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return GSBER
|
||||
*/
|
||||
public String getGSBER() {
|
||||
return GSBER;
|
||||
return CharsetUtils.getUtf8Str(GSBER);
|
||||
}
|
||||
|
||||
|
||||
|
@ -589,7 +591,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return KUNNR
|
||||
*/
|
||||
public String getKUNNR() {
|
||||
return KUNNR;
|
||||
return CharsetUtils.getUtf8Str(KUNNR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -609,7 +611,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return LIFNR
|
||||
*/
|
||||
public String getLIFNR() {
|
||||
return LIFNR;
|
||||
return CharsetUtils.getUtf8Str(LIFNR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -629,7 +631,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return AUFNR
|
||||
*/
|
||||
public String getAUFNR() {
|
||||
return AUFNR;
|
||||
return CharsetUtils.getUtf8Str(AUFNR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -649,7 +651,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return VALUT
|
||||
*/
|
||||
public String getVALUT() {
|
||||
return VALUT;
|
||||
return CharsetUtils.getUtf8Str(VALUT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -669,7 +671,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return XREF1
|
||||
*/
|
||||
public String getXREF1() {
|
||||
return XREF1;
|
||||
return CharsetUtils.getUtf8Str(XREF1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -689,7 +691,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return XREF2
|
||||
*/
|
||||
public String getXREF2() {
|
||||
return XREF2;
|
||||
return CharsetUtils.getUtf8Str(XREF2);
|
||||
}
|
||||
|
||||
|
||||
|
@ -709,7 +711,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return XREF3
|
||||
*/
|
||||
public String getXREF3() {
|
||||
return XREF3;
|
||||
return CharsetUtils.getUtf8Str(XREF3);
|
||||
}
|
||||
|
||||
|
||||
|
@ -729,7 +731,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return VBUND
|
||||
*/
|
||||
public String getVBUND() {
|
||||
return VBUND;
|
||||
return CharsetUtils.getUtf8Str(VBUND);
|
||||
}
|
||||
|
||||
|
||||
|
@ -749,7 +751,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return ZZCUSTOMER
|
||||
*/
|
||||
public String getZZCUSTOMER() {
|
||||
return ZZCUSTOMER;
|
||||
return CharsetUtils.getUtf8Str(ZZCUSTOMER);
|
||||
}
|
||||
|
||||
|
||||
|
@ -769,7 +771,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return ZZVENDOR
|
||||
*/
|
||||
public String getZZVENDOR() {
|
||||
return ZZVENDOR;
|
||||
return CharsetUtils.getUtf8Str(ZZVENDOR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -789,7 +791,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return ZZFIELD1
|
||||
*/
|
||||
public String getZZFIELD1() {
|
||||
return ZZFIELD1;
|
||||
return CharsetUtils.getUtf8Str(ZZFIELD1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -809,7 +811,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return ZZFIELD2
|
||||
*/
|
||||
public String getZZFIELD2() {
|
||||
return ZZFIELD2;
|
||||
return CharsetUtils.getUtf8Str(ZZFIELD2);
|
||||
}
|
||||
|
||||
|
||||
|
@ -829,7 +831,7 @@ public class DT_DOCUMENT_IF_SRCDATAIT_ITEM implements java.io.Serializable {
|
|||
* @return ZZFIELD3
|
||||
*/
|
||||
public String getZZFIELD3() {
|
||||
return ZZFIELD3;
|
||||
return CharsetUtils.getUtf8Str(ZZFIELD3);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package shkd.fi.fi.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class CharsetUtils {
|
||||
|
||||
public static String getUtf8Str(String str){
|
||||
try {
|
||||
byte[] bytes = str.getBytes("UTF-8");
|
||||
String strUft8 = new String(bytes,"UTF-8");
|
||||
return strUft8;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// throw new RuntimeException(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package shkd.fi.fi.util;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
/**
|
||||
* 根据文件路径,获取文件16进制内容
|
||||
* @param filePath 文件路径
|
||||
* @return 16进制字符串
|
||||
*/
|
||||
public static String fileToHex(String filePath){
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package shkd.fi.fi.util;
|
||||
|
||||
import oadd.org.apache.calcite.avatica.org.apache.http.entity.StringEntity;
|
||||
import oadd.org.apache.commons.httpclient.HttpClient;
|
||||
import oadd.org.apache.commons.httpclient.methods.PostMethod;
|
||||
import oadd.org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
|
@ -31,10 +33,16 @@ public class HttpUtils {
|
|||
try{
|
||||
//设置请求头部类型
|
||||
myPost.setRequestHeader("Content-Type","application/xml");
|
||||
myPost.setRequestHeader("charset","utf-8");
|
||||
myPost.setRequestHeader("charset","UTF-8");
|
||||
myPost.setRequestHeader("Authorization", "Basic "+token);
|
||||
//设置请求体,即xml文本内容,一种是直接获取xml内容字符串,一种是读取xml文件以流的形式
|
||||
myPost.setRequestBody(xmlString);
|
||||
byte[] utf8Bytes = xmlString.getBytes("UTF-8");
|
||||
String utf8Str = new String(utf8Bytes, "UTF-8");
|
||||
// myPost.setRequestBody(utf8Str);
|
||||
// String content, String contentType, String charset
|
||||
StringRequestEntity requestEntity = new StringRequestEntity(utf8Str, "application/xml","UTF-8");
|
||||
myPost.setRequestEntity(requestEntity);
|
||||
|
||||
int status = client.executeMethod(myPost);
|
||||
resultMap.put(STATUS,status);
|
||||
InputStream inputStream = myPost.getResponseBodyAsStream();
|
||||
|
|
|
@ -47,7 +47,10 @@ public class XmlUtils {
|
|||
xml.append(xmlContent);
|
||||
xml.append("</soapenv:Body>");
|
||||
xml.append("</soapenv:Envelope>");
|
||||
return xml.toString();
|
||||
String xmlStr = xml.toString();
|
||||
byte[] utf8Bytes = xmlStr.getBytes("UTF-8");
|
||||
String utf8Str = new String(utf8Bytes, "UTF-8");
|
||||
return utf8Str;
|
||||
}
|
||||
|
||||
public static DT_DOCUMENT_IF_SRC setData(){
|
||||
|
|
Loading…
Reference in New Issue