add dzpzk code
This commit is contained in:
parent
cbe37efac5
commit
003fb6c7f6
|
@ -2,7 +2,9 @@ package shkd.fi.fi.opplugin;
|
|||
|
||||
import com.alibaba.druid.support.logging.Log;
|
||||
import com.alibaba.druid.support.logging.LogFactory;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.grapecity.documents.excel.J;
|
||||
import kd.bos.cache.CacheFactory;
|
||||
import kd.bos.cache.DistributeSessionlessCache;
|
||||
import kd.bos.cache.TempFileCache;
|
||||
|
@ -84,18 +86,10 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
StringBuffer errStr = new StringBuffer();
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
|
||||
for (DynamicObject voucher : dataEntities) {
|
||||
// DynamicObject voucher = BusinessDataServiceHelper.loadSingle(glvoucher.getPkValue(), "gl_voucher");
|
||||
for (DynamicObject glvoucher : dataEntities) {
|
||||
DynamicObject voucher = BusinessDataServiceHelper.loadSingle(glvoucher.getPkValue(), "gl_voucher");
|
||||
String voucherNo = voucher.getString("billno");//凭证号
|
||||
//校验:1.单据是否已审核;2.是否已同步到SAP;
|
||||
if(!"C".equals(voucher.getString("billstatus"))){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append(" 凭证未审核").append("\r");
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
if(!"1".equals(voucher.getString("shkd_zstatus"))){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足同步条件,原因:");
|
||||
errStr.append(" 凭证未同步到SAP ").append("\r");
|
||||
|
@ -535,19 +529,21 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
String jsonBody = JSONObject.toJSONString(guidangQueryReqBean);
|
||||
String postjson = HttpClientUtils.postjson(guidangUrl, header, jsonBody);
|
||||
LogBillUtils.SaveLogBill(guidangUrl, postjson, AppflgConstant.DZPZK_GUIDANG_RES_URL_NAME, jsonBody);
|
||||
GuidangQueryResBean guidangResponseBean = JSONObject.parseObject(postjson, GuidangQueryResBean.class);
|
||||
if(null!=guidangResponseBean){
|
||||
if("1".equals(guidangResponseBean.getProcessingResult())){
|
||||
List<GuidangQueryResBean> guidangQueryResBeans = JSONArray.parseArray(postjson, GuidangQueryResBean.class);
|
||||
|
||||
if(null!=guidangQueryResBeans&&guidangQueryResBeans.size()>0){
|
||||
GuidangQueryResBean guidangResponseBean = guidangQueryResBeans.get(0);
|
||||
if(1==guidangResponseBean.getProcessingResult()){
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(true);
|
||||
this.operationResult.setMessage("同步成功,成功生成了归档元素");
|
||||
voucher.set("shkd_dzpzkstatus","1");//附件归档成功
|
||||
SaveServiceHelper.save(new DynamicObject[]{voucher});
|
||||
}else if("0".equals(guidangResponseBean.getProcessingResult())) {
|
||||
}else if(0==guidangResponseBean.getProcessingResult()) {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(true);
|
||||
this.operationResult.setMessage("电子凭证库系统附件归档结果暂未处理,请稍等查询");
|
||||
} else if ("-1".equals(guidangResponseBean.getProcessingResult())) {
|
||||
} else if (-1==guidangResponseBean.getProcessingResult()) {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("电子凭证库系统附件归档结果未生成:"+guidangResponseBean.getErrorMessage());
|
||||
|
@ -811,7 +807,7 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
|
||||
for (DynamicObject voucher : voucherColl) {
|
||||
DynamicObject org = voucher.getDynamicObject("org");
|
||||
String shkd_gd_reqno = voucher.getString("shkd_gd_reqno");
|
||||
String shkd_pz_reqno = voucher.getString("shkd_pz_reqno");
|
||||
//同步
|
||||
try {
|
||||
String url = AppflgConstant.SHKD_DZPZK_BIZ_RES_URL(paramsMap);
|
||||
|
@ -830,31 +826,37 @@ public class DzpzkOPPlugin extends AbstractOperationServicePlugIn {
|
|||
head.setSourceSys(AppflgConstant.SYS_NUMBER);
|
||||
guidangQueryReqBean.setHead(head);
|
||||
shkd.fi.fi.common.dzpzk.guidangquery.req.Body body = new shkd.fi.fi.common.dzpzk.guidangquery.req.Body();
|
||||
body.setLinkRequestNo(shkd_gd_reqno);
|
||||
body.setLinkRequestNo(shkd_pz_reqno);
|
||||
guidangQueryReqBean.setBody(body);
|
||||
|
||||
String jsonBody = JSONObject.toJSONString(guidangQueryReqBean);
|
||||
String postjson = HttpClientUtils.postjson(url, header, jsonBody);
|
||||
LogBillUtils.SaveLogBill(url, postjson, AppflgConstant.SHKD_DZPZK_BIZ_RES_URL_NAME, jsonBody);
|
||||
BizdataQueryResBean bizdataQueryResBean = JSONObject.parseObject(postjson, BizdataQueryResBean.class);
|
||||
if(null==bizdataQueryResBean){
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("同步失败,电子凭证库系统凭证业务数据归档接口返回结果为空");
|
||||
}else {
|
||||
// BizdataQueryResBean bizdataQueryResBean = JSONObject.parseObject(postjson, BizdataQueryResBean.class);
|
||||
List<BizdataQueryResBean> bizdataQueryResBeans = JSONArray.parseArray(postjson, BizdataQueryResBean.class);
|
||||
if(null!=bizdataQueryResBeans&&bizdataQueryResBeans.size()>0){
|
||||
BizdataQueryResBean bizdataQueryResBean = bizdataQueryResBeans.get(0);
|
||||
if ("S".equals(bizdataQueryResBean.getProcessingResult())) {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(true);
|
||||
this.operationResult.setMessage("凭证归档同步成功");
|
||||
voucher.set("shkd_dzpzkstatus", "4");
|
||||
SaveServiceHelper.save(new DynamicObject[]{voucher});
|
||||
} else {
|
||||
} else if("N".equals(bizdataQueryResBean.getProcessingResult())){
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(true);
|
||||
this.operationResult.setMessage("电子凭证库系统凭证业务数据归档接口返回结果为:还未处理,请稍后查询");
|
||||
}else{
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("凭证归档同步失败:"+bizdataQueryResBean.getErrorMessage());
|
||||
this.operationResult.setMessage("电子凭证库系统凭证业务数据归档接口返回结果为:E处理错误,请联系管理员");
|
||||
voucher.set("shkd_dzpzkstatus", "5");
|
||||
SaveServiceHelper.save(new DynamicObject[]{voucher});
|
||||
}
|
||||
}else {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("同步失败,电子凭证库系统凭证业务数据归档接口返回结果为空");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
|
|
@ -14,6 +14,7 @@ import kd.bos.util.StringUtils;
|
|||
import shkd.fi.fi.common.AppflgConstant;
|
||||
import shkd.fi.fi.util.DateUtils;
|
||||
import shkd.fi.fi.util.HttpUtils;
|
||||
import shkd.fi.fi.util.LogBillUtils;
|
||||
import shkd.fi.fi.util.ParamsUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -49,6 +50,7 @@ public class SynOAInvoiceOPPlugin 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");//凭证号
|
||||
|
@ -64,13 +66,7 @@ public class SynOAInvoiceOPPlugin extends AbstractOperationServicePlugIn {
|
|||
this.operationResult.setMessage("数据校验不通过:"+errStr.toString());
|
||||
break;
|
||||
}
|
||||
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)){
|
||||
errStr.append("凭证号:").append(voucherNo).append("不满足冲销条件,原因:");
|
||||
errStr.append("凭证未同步到SAP ").append("\r");
|
||||
break;
|
||||
}
|
||||
|
||||
voucherColl.add(voucher);
|
||||
}
|
||||
//数据校验不通过,则不进行同步
|
||||
|
@ -86,17 +82,14 @@ public class SynOAInvoiceOPPlugin extends AbstractOperationServicePlugIn {
|
|||
Map<String, String> paramsMap = ParamsUtils.getParamsMap();
|
||||
String oaurl = AppflgConstant.OA_INV_URL(paramsMap);
|
||||
|
||||
String crdate = DateUtils.formatDate(new Date(),DateUtils.COMPACT_TIME);
|
||||
Random random = new Random();
|
||||
int randomNumber = 1000 + random.nextInt(9000); // 生成1000到9999之间的随机数
|
||||
String time_random = crdate+""+ randomNumber;
|
||||
for (DynamicObject gl_voucher : voucherColl) {
|
||||
DynamicObject org = gl_voucher.getDynamicObject("org");
|
||||
DynamicObject voucher = BusinessDataServiceHelper.loadSingle(gl_voucher.getPkValue(), "gl_voucher");
|
||||
DynamicObject org = voucher.getDynamicObject("org");
|
||||
String shkd_oa_orgid = org.getString("shkd_oa_orgid");
|
||||
String shkd_belnr = gl_voucher.getString("shkd_belnr");//sap凭证号
|
||||
String shkd_belnr = voucher.getString("shkd_belnr");//sap凭证号
|
||||
|
||||
//DAP关系
|
||||
QFilter filter = new QFilter("voucherid", QCP.equals,gl_voucher.getPkValue());
|
||||
QFilter filter = new QFilter("voucherid", QCP.equals,voucher.getPkValue());
|
||||
List<String> billTypeList = new ArrayList<String>();
|
||||
billTypeList.add(im_purinbill);
|
||||
billTypeList.add(ap_finapbill);
|
||||
|
@ -112,10 +105,10 @@ public class SynOAInvoiceOPPlugin extends AbstractOperationServicePlugIn {
|
|||
if(im_purinbill.equals(number)){//来源单据是采购入库单,需查询下游单据,财务应付单
|
||||
List<Long> apBillIdList = DzpzkOPPlugin.down(im_purinbill, sourcebillid);
|
||||
DynamicObject[] ap_invoices = BusinessDataServiceHelper.load(apBillIdList.toArray(), dynamicObject.getDynamicObjectType());
|
||||
getSynData(oaurl,ap_invoices, shkd_belnr,shkd_oa_orgid,gl_voucher);
|
||||
getSynData(oaurl,ap_invoices, shkd_belnr,shkd_oa_orgid,voucher);
|
||||
}else if(ap_finapbill.equals(number)){//来源单据是财务应付单
|
||||
DynamicObject[] ap_invoices = BusinessDataServiceHelper.load(new Long[]{sourcebillid}, dynamicObject.getDynamicObjectType());
|
||||
getSynData(oaurl,ap_invoices, shkd_belnr,shkd_oa_orgid,gl_voucher);
|
||||
getSynData(oaurl,ap_invoices, shkd_belnr,shkd_oa_orgid,voucher);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,7 +212,10 @@ public class SynOAInvoiceOPPlugin extends AbstractOperationServicePlugIn {
|
|||
xml.append("</soapenv:Envelope>");
|
||||
|
||||
|
||||
log.info("OA接口入参:"+xml.toString());
|
||||
String s = HttpUtils.sendPostToOA(oaurl, xml.toString());
|
||||
log.info("OA接口返回结果:"+s);
|
||||
LogBillUtils.SaveLogBill(oaurl,s,AppflgConstant.OA_INV_URL_NAME,xml.toString());
|
||||
if (s.contains("id>") && s.contains("</id")) {
|
||||
String id = s.substring(s.indexOf("id>") + 6, s.indexOf("</id"));
|
||||
try {
|
||||
|
@ -233,18 +229,18 @@ public class SynOAInvoiceOPPlugin extends AbstractOperationServicePlugIn {
|
|||
} else {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("同步失败:" + xml.toString());
|
||||
this.operationResult.setMessage("同步失败:" + s);
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("同步失败:" + xml.toString());
|
||||
this.operationResult.setMessage("同步失败:" + s);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.operationResult.setShowMessage(true);
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("同步失败:" + xml.toString());
|
||||
this.operationResult.setMessage("同步失败:" + s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue