诺诺发票推送

This commit is contained in:
lvleigang 2025-07-01 10:20:51 +08:00
parent 4f52aea52f
commit acedf4175b
6 changed files with 229 additions and 200 deletions

View File

@ -3,6 +3,8 @@ package com.hzya.frame.plugin.nuonuo.service.impl;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.plugin.nuonuo.dao.INuoNuoDao;
import com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity;
@ -13,10 +15,14 @@ import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.hzya.frame.basedao.service.impl.BaseService;
import org.springframework.beans.factory.annotation.Value;
import java.math.BigDecimal;
import java.util.List;
public class NuoNuoServiceImpl extends BaseService<NuoNuoEntity, String> implements INuoNuoService {
@Value("${zt.url}")
private String url;
private INuoNuoDao nuoNuoDao;
@ -36,115 +42,108 @@ public class NuoNuoServiceImpl extends BaseService<NuoNuoEntity, String> impleme
@Override
public JsonResultEntity sendNuoNuoFaPiao(JSONObject requestJson) {
logger.error(" 资金拨付流程结束回调:"+requestJson.toJSONString());
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
if(jsonStr == null ){
return BaseResult.getFailureMessageEntity("系统错误");
}
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
if(businessDataStr == null ){
return BaseResult.getFailureMessageEntity("系统错误");
}
JSONObject mainData = businessDataStr.getJSONObject("formmain_11951");
if(mainData == null ){
return BaseResult.getFailureMessageEntity("系统错误");
}
JSONArray detailArray = businessDataStr.getJSONArray("formson_11953");
if(mainData.getString("field0168") != null && "SJ".equals(mainData.getString("field0168"))){
return BaseResult.getSuccessMessageEntity("发票类型为SJ不传诺税通");
}
//组装发送数据
JSONObject sendData = getSendData(mainData,detailArray);
//发送数据
String tokenResult = HttpRequest.post(url).
header("appId", "800051").
header("apiCode", "8000510012").
header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj").
header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(sendData.toJSONString()).
execute().
body();
logger.error("推送诺诺发票返回:"+tokenResult);
JSONObject resoutJson = JSONObject.parseObject(tokenResult);
if(resoutJson.getBoolean("flag")){
return BaseResult.getSuccessMessageEntity("推送诺诺发票成功");
}else {
return BaseResult.getFailureMessageEntity("推送诺诺发票失败:"+resoutJson.getString("msg"));
}
}
//String dataSourceCode = requestJson.getString("apiDataSourceCode");//数据源
//String headerStr = requestJson.getString("headers");//表头
//String eventType = requestJson.getString("eventType");
//String summaryId = requestJson.getString("summaryId");
//Assert.notEmpty(dataSourceCode,"数据源不能为空");
//Assert.notEmpty(headerStr,"headers不能为空");
//Assert.notEmpty(eventType,"eventType不能为空");
//Assert.notEmpty(summaryId,"summaryId不能为空");
//JSONObject headers = requestJson.getJSONObject("headers");
//String formmainTableName = headers.getString("formmainTableName");
//JSONObject jsonStrObj = requestJson.getJSONObject("jsonStr");
//JSONObject businessData = jsonStrObj.getJSONObject("businessDataStr");
//JSONObject formmainData = businessData.getJSONObject(formmainTableName);
//if (null != formmainData){
// //税务系统id这个字段不为空时表示是税务推过来的单子
// String field0061 = formmainData.getString("field0061");
// //司库系统批次号
// String field0063 = formmainData.getString("field0063");
// //资金归集
// String field0062 = formmainData.getString("field0062");
// if (StrUtil.isNotEmpty(field0061) || StrUtil.isNotEmpty(field0063) || StrUtil.isNotEmpty(field0062)){
// //查询审批意见
// FundsAllocationEntity fundAllocation = new FundsAllocationEntity();
// fundAllocation.setCol_summary_id(summaryId);
// fundAllocation.setDataSourceCode(dataSourceCode);
// List<FundsAllocationEntity> fundsAllocationList = fundsAllocationService.queryCtpCommentList(fundAllocation);
// if (CollectionUtils.isNotEmpty(fundsAllocationList)){
// fundAllocation = fundsAllocationList.get(0);
// }
// String appId = "";//应用
// String apiCode = "";//api
// String param = "";//参数
// if (StrUtil.isNotEmpty(field0061)){
// appId = "800060";
// apiCode = "8000600008";
// //税务
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("transferOrderNumber",field0061);
// jsonObject.put("approvalUser",fundAllocation.getName());
// jsonObject.put("approvalTime",fundAllocation.getApproval_time());
// jsonObject.put("approvalRemark",StrUtil.isEmpty(fundAllocation.getContent()) ? "审批通过" : fundAllocation.getContent());
// if (ColEventTypeEnum.ONPROCESSFINISHED.getType().equals(eventType)){
// jsonObject.put("approvalStatus","2");
// }else if (ColEventTypeEnum.ONSTOP.getType().equals(eventType)){//审批终止
// jsonObject.put("approvalStatus","3");
// }
// param = jsonObject.toJSONString();
// }else if (StrUtil.isNotEmpty(field0063)){
// appId = "800058";
// apiCode = "8000580004";
// //司库
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("batchNo",field0063);
// jsonObject.put("reason",fundAllocation.getContent());
// if (ColEventTypeEnum.ONPROCESSFINISHED.getType().equals(eventType)){
// jsonObject.put("status","APPROVED");
// }else if (ColEventTypeEnum.ONSTOP.getType().equals(eventType)){//审批终止
// jsonObject.put("status","REJECTION");
// }
// JSONObject objectData = new JSONObject();
// objectData.put("data",jsonObject);
// logger.info("资金拨付审批回调司库请求参数明文:{}",objectData.toJSONString());
// String encrypt = SM2Util.encrypt(objectData.toJSONString(),publicKey);
// JSONObject jsonData = new JSONObject();
// jsonData.put("data",encrypt);
// param = jsonData.toJSONString();
// }else if (StrUtil.isNotEmpty(field0062)){
// appId = "800058";
// apiCode = "8000580004";
// //司库
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("batchNo",field0062);
// jsonObject.put("reason",fundAllocation.getContent());
// if (ColEventTypeEnum.ONPROCESSFINISHED.getType().equals(eventType)){
// jsonObject.put("status","APPROVED");
// }else if (ColEventTypeEnum.ONSTOP.getType().equals(eventType)){//审批终止
// jsonObject.put("status","REJECTION");
// }
// JSONObject objectData = new JSONObject();
// objectData.put("data",jsonObject);
// logger.info("资金归集审批回调司库请求参数明文:{}",objectData.toJSONString());
// String encrypt = SM2Util.encrypt(objectData.toJSONString(),publicKey);
// JSONObject jsonData = new JSONObject();
// jsonData.put("data",encrypt);
// param = jsonData.toJSONString();
// }
// if (StrUtil.isNotEmpty(appId) && StrUtil.isNotEmpty(apiCode) && StrUtil.isNotEmpty(param)){
// logger.info("回调有度/司库请求apiCode{},报文:{}",apiCode,param);
// String result = HttpRequest.post(interfaceUrl)
// .header("appId", appId)//税务/司库应用
// .header("apiCode", apiCode)//回调接口
// .header("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj")//OA公钥
// .header("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//OA密钥
// .body(param)//表单内容
// .timeout(30000)//超时毫秒
// .execute().body();
// logger.info("回调有度/司库返回报文:{}",result);
// return BaseResult.getSuccessMessageEntity(result);
// }else {
// logger.info("appId、apiCode、param 其中有参数是空的,不能执行");
// }
// }else {
// logger.info("不是有度税务/中信司库推过来的单子,不需要执行");
// }
//}
return BaseResult.getFailureMessageEntity("表单数据为空");
/**
* @Author lvleigang
* @Description 组装数据
* @Date 6:12 下午 2025/6/27
* @param mainData
* @param detailArray
* @return com.alibaba.fastjson.JSONObject
**/
private JSONObject getSendData(JSONObject mainData, JSONArray detailArray) {
JSONObject sendData = new JSONObject();
sendData.put("buyerName",mainData.getString("field0092"));//购方名称
sendData.put("buyerTaxnum",mainData.getString("field0146"));//购方税号
sendData.put("buyerAddress",mainData.getString("field0134"));//购方地址
sendData.put("buyerPhone",mainData.getString("field0135"));//购方电话
sendData.put("buyerBank",mainData.getString("field0128"));//购方开户行
sendData.put("buyerAccount",mainData.getString("field0139"));//购方银行账号
sendData.put("orderNo",mainData.getString("field0001"));//订单编号
//sendData.put("bizCallbackUrl","http://10.0.2.112:9021/kangarooDataCenterV3/entranceController/nuoNuoCallback");//回调地址测试
sendData.put("bizCallbackUrl","http://10.0.2.112:9011/kangarooDataCenterV3/entranceController/nuoNuoCallback");//回调地址正式
sendData.put("sellerName",mainData.getString("field0129"));//销方名称
sendData.put("sellerTaxnum",mainData.getString("field0162"));//销方税号
sendData.put("sellerAddress",mainData.getString("field0161"));//销方地址
sendData.put("sellerPhone",mainData.getString("field0163"));//销方电话
sendData.put("sellerBank",mainData.getString("field0164"));//销方开户银行
sendData.put("sellerAccount",mainData.getString("field0165"));//销方银行账号
sendData.put("invoiceLine",mainData.getString("field0168"));//发票种类bs:数电专票(电子),pc:数电普票(电子)
sendData.put("invoiceType",1);//开票类型1:蓝票2:红票
sendData.put("substituteFlag",0);//代开标志0:非代开;1:代开
sendData.put("listFlag",0);//清单标志0:非清单1:清单
sendData.put("notifyType",-1);//推送方式-1:不推送;0:邮箱;1:手机(默认);2:邮箱手机;3:根据交付手机邮箱动态交付
sendData.put("requestSrc",0);//请求来源0 :api接口
sendData.put("checkBlue",0);//开具红票时是否校验蓝票 0.校验蓝票是否存在诺税通 1.不校验蓝票是否存在诺税通但校验可冲红金额 2.不校验蓝票是否存在诺税通且不校验可冲红金额
JSONArray sendArray = new JSONArray();
if(detailArray != null && detailArray.size() > 0){
for (int i = 0; i < detailArray.size(); i++) {
JSONObject detail = new JSONObject();
detail.put("detailIndex",detailArray.getJSONObject(i).getString("field0147"));//明细序号数电票明细行必须从1开始编号
detail.put("detailType",0);//明细行性质:0,正常行;1,折扣行;2,被折扣行
detail.put("goodsName",detailArray.getJSONObject(i).getString("field0148"));//商品名称
if(detailArray.getJSONObject(i).getString("field0159") != null && !"".equals(detailArray.getJSONObject(i).getString("field0159"))
&& detailArray.getJSONObject(i).getBigDecimal("field0159").compareTo(BigDecimal.ONE) == 0 //税额
){
detail.put("withTaxFlag",0);//含税标志0:不含税,1:含税
}else {
detail.put("withTaxFlag",1);//含税标志0:不含税,1:含税
}
detail.put("goodsPrice",detailArray.getJSONObject(i).getString("field0154"));//含税单价
detail.put("taxFreePrice",detailArray.getJSONObject(i).getString("field0155"));//不含税单价
detail.put("goodsNum",detailArray.getJSONObject(i).getString("field0157"));//数量
detail.put("taxrate",detailArray.getJSONObject(i).getString("field0156"));//税率
detail.put("goodsCode",detailArray.getJSONObject(i).getString("field0158"));//税收分类编码
detail.put("favouredPolicyCode",detailArray.getJSONObject(i).getString("field0170"));//优惠政策编码
detail.put("deduction",detailArray.getJSONObject(i).getString("field0172"));//扣除额
detail.put("taxFreeAmount",detailArray.getJSONObject(i).getString("field0160"));//不含税金额
detail.put("tax",detailArray.getJSONObject(i).getString("field0159"));//税额
detail.put("taxAmount",detailArray.getJSONObject(i).getString("field0149"));//含税金额
if(detailArray.getJSONObject(i).getString("field0147") != null && !"".equals(detailArray.getJSONObject(i).getString("field0147"))){
detail.put("favouredPolicyFlag","1");//优惠政策标识0:不使用;1:使用 数电发票时为空仅传入优惠政策编码即可
}else {
detail.put("favouredPolicyFlag","0");//优惠政策标识0:不使用;1:使用 数电发票时为空仅传入优惠政策编码即可
}
sendArray.add(detail);
}
}
sendData.put("detail",sendArray);
return sendData;
}
}

View File

@ -5,6 +5,7 @@ import com.hzya.frame.web.entity.BaseEntity;
public class NuoNuoCallbackEntity extends BaseEntity {
private String id;
private String fieldsum;//单据号
private String field0001;//单据号
private String field0150;//发票号码
private String field0151;//开票日期
@ -13,6 +14,14 @@ public class NuoNuoCallbackEntity extends BaseEntity {
private String field0153;//电子发票
public String getFieldsum() {
return fieldsum;
}
public void setFieldsum(String fieldsum) {
this.fieldsum = fieldsum;
}
@Override
public String getId() {
return id;

View File

@ -8,11 +8,12 @@
<!-- 查询 采用==查询 -->
<select id="queryOaData" resultType="com.hzya.frame.seeyon.entity.NuoNuoCallbackEntity" parameterType="com.hzya.frame.seeyon.entity.NuoNuoCallbackEntity">
select
id
from formmain_11951
SELECT a.id as id ,
b.id as fieldsum
from formmain_11951 a
LEFT JOIN COL_SUMMARY b on a.id = b.FORM_RECORDID
<trim prefix="where" prefixOverrides="and">
<if test="field00001 != null and field00001 !='' ">field00001 = #{field00001} </if>
<if test="field0001 != null and field0001 !='' ">a.field0001 = #{field0001} </if>
</trim>
</select>
@ -21,7 +22,7 @@
<trim suffix="" suffixOverrides=",">
<if test="field0001 != null and field0001 !='' "> field0001 = #{field0001},</if>
<if test="field0150 != null and field0150 !='' "> field0150 = #{field0150},</if>
<if test="field0151 != null and field0151 !='' "> field0151 = #{field0151},</if>
<if test="field0151 != null and field0151 !='' "> field0151 = TO_DATE(#{field0151}, 'YYYY-MM-DD HH24:MI:SS') ,</if>
<if test="field0188 != null and field0188 !='' "> field0188 = #{field0188},</if>
<if test="field0152 != null and field0152 !='' "> field0152 = #{field0152},</if>
<if test="field0153 != null and field0153 !='' "> field0153 = #{field0153},</if>

View File

@ -80,5 +80,5 @@ public interface ISeeYonInterFace {
* @return
* @throws Exception
*/
String colEventPost(String jsonStr,String formAppId,String eventType)throws Exception;
JsonResultEntity colEventPost(String jsonStr,String formAppId,String eventType)throws Exception;
}

View File

@ -79,23 +79,29 @@ public class NuoNuoCallbackServiceImpl implements INuoNuoCallbackService {
String invoiceCode = jsonObject.getString("invoiceCode");//发票代码
String invoiceNumber = jsonObject.getString("invoiceNumber");//发票号码
String orderNo = jsonObject.getString("orderNo");//订单编号
logger.error("诺诺发票回调接口1:"+invoiceTime);
if(invoiceTime != null && !"".equals(invoiceTime)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(jsonObject.getLong("invoiceTime"));
invoiceTime = sdf.format(date);
}
logger.error("诺诺发票回调接口2:"+orderNo);
if(orderNo == null || "".equals(orderNo)){
JSONObject returnData = new JSONObject();
returnData.put("code","9999");
returnData.put("message","订单编号不存在");
return returnData;
}
logger.error("诺诺发票回调接口3:"+successFlag);
if(successFlag == null || "".equals(successFlag)){
JSONObject returnData = new JSONObject();
returnData.put("code","9999");
returnData.put("message","开票状态不存在");
return returnData;
}
logger.error("诺诺发票回调接口4:"+errorMessage);
if(jsonObject.getBoolean("successFlag")){
errorMessage = "开票成功";
}else {
@ -106,11 +112,15 @@ public class NuoNuoCallbackServiceImpl implements INuoNuoCallbackService {
return returnData;
}
}
logger.error("诺诺发票回调接口5:"+errorMessage);
//查找单据上传附件
NuoNuoCallbackEntity queryData = new NuoNuoCallbackEntity();
queryData.setDataSourceCode("SW-OA");
queryData.setField0001(orderNo);
List<NuoNuoCallbackEntity> entityList = nuoNuoCallbackDao.queryOaData(queryData);
logger.error("诺诺发票回调接口6:"+entityList.size());
if(entityList == null || entityList.size() == 0){
JSONObject returnData = new JSONObject();
returnData.put("code","9999");
@ -123,6 +133,8 @@ public class NuoNuoCallbackServiceImpl implements INuoNuoCallbackService {
returnData.put("message","根据订单编号查找到多条单据");
return returnData;
}
logger.error("诺诺发票回调接口7:"+entityList.size());
NuoNuoCallbackEntity nuoNuoCallbackEntity = entityList.get(0);
nuoNuoCallbackEntity.setDataSourceCode("SW-OA");
nuoNuoCallbackEntity.setField0001(orderNo);//单据号
@ -131,40 +143,59 @@ public class NuoNuoCallbackServiceImpl implements INuoNuoCallbackService {
nuoNuoCallbackEntity.setField0188(invoiceCode);//发票代码
nuoNuoCallbackEntity.setField0152(errorMessage);//开票结果
String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
logger.error("诺诺发票回调接口8:"+pdfUrl);
if(pdfUrl != null){
String urlData = sendFileUpload(pdfUrl);
logger.error("诺诺发票回调接口9:"+urlData);
if(urlData != null){
//保存关联表
nuoNuoCallbackEntity.setField0153(urluuid);//发票文件
logger.error("诺诺发票回调接口10:"+nuoNuoCallbackEntity.getFieldsum());
try {
ctpAttachmentService.saveAttachment(urlData,nuoNuoCallbackEntity.getId(),urluuid,nuoNuoCallbackEntity.getDataSourceCode());
ctpAttachmentService.saveAttachment(urlData,nuoNuoCallbackEntity.getFieldsum(),urluuid,nuoNuoCallbackEntity.getDataSourceCode());
} catch (Exception e) {
logger.error("诺诺发票回调接口10error"+e.getMessage());
JSONObject returnData = new JSONObject();
returnData.put("code","9999");
returnData.put("message","根据订单编号上传附件失败");
return returnData;
}
logger.error("诺诺发票回调接口11:"+urlData);
}
}
logger.error("诺诺发票回调接口12:"+imageUrl);
if(imageUrl != null){
logger.error("诺诺发票回调接口13:"+imageUrl);
String urlData = sendFileUpload(imageUrl);
logger.error("诺诺发票回调接口14:"+imageUrl);
if(urlData != null){
//保存关联表
nuoNuoCallbackEntity.setField0153(urluuid);//发票文件
logger.error("诺诺发票回调接口15:"+imageUrl);
try {
ctpAttachmentService.saveAttachment(urlData,nuoNuoCallbackEntity.getId(),urluuid,nuoNuoCallbackEntity.getDataSourceCode());
ctpAttachmentService.saveAttachment(urlData,nuoNuoCallbackEntity.getFieldsum(),urluuid,nuoNuoCallbackEntity.getDataSourceCode());
} catch (Exception e) {
JSONObject returnData = new JSONObject();
returnData.put("code","9999");
returnData.put("message","根据订单编号上传附件失败");
return returnData;
}
logger.error("诺诺发票回调接口16:"+imageUrl);
}
}
//修改单据信息
nuoNuoCallbackEntity.setDataSourceCode("master");
logger.error("诺诺发票回调接口17:"+imageUrl);
nuoNuoCallbackDao.updateNuoNuo(nuoNuoCallbackEntity);
logger.error("诺诺发票回调接口18:"+imageUrl);
JSONObject returnData = new JSONObject();
returnData.put("code","0000");
returnData.put("message","业务方接收同步成功");

View File

@ -9,6 +9,7 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.seeyon.dao.ISeeYonInterFaceDao;
import com.hzya.frame.seeyon.entity.OAWorkflowEventDataEntity;
import com.hzya.frame.seeyon.entity.SeeYonInterFaceEntity;
@ -19,6 +20,7 @@ import com.hzya.frame.sysnew.application.database.dao.ISysApplicationDatabaseDao
import com.hzya.frame.sysnew.application.database.entity.SysApplicationDatabaseEntity;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.util.PluginUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException;
@ -201,10 +203,10 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
public JsonResultEntity thirdInterfaceSeeYonPlugInInterfaceEntrance(JSONObject requestData){
String jsonStr = requestData.getString("jsonStr");
JSONObject jsonObject = requestData.getJSONObject("jsonStr");
OAWorkflowEventDataEntity entity = JSON.parseObject(jsonStr,OAWorkflowEventDataEntity.class);
logger.info("监听OA事件入参"+jsonObject.toJSONString());
OAWorkflowEventDataEntity entity = JSON.parseObject(jsonStr, OAWorkflowEventDataEntity.class);
logger.info("监听OA事件入参" + jsonObject.toJSONString());
JSONObject formBeanData = jsonObject.getJSONObject("businessDataStr");
String eventType = jsonObject.getString("eventType") ;
String eventType = jsonObject.getString("eventType");
/** 流程ID*/
String summaryId = entity.getSummaryId();
/** 节点ID*/
@ -223,73 +225,14 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
//formApp 最好过滤一下
String result = null;
JsonResultEntity result = null;
try {
//流程事件处理
result = colEventPost(jsonStr, formApp, eventType);
}catch (Exception e){
return BaseResult.getFailureMessageEntity("传递失败",e.getMessage());
}
try {
/** 根据事件类型处理相关事件*/
switch (eventType) {
/** 发起前事件*/
case "onBeforeStart":
break;
/** 发起事件*/
case "onStart":
//流程发起 新增grpu8单据
break;
/** 终止前事件*/
case "onBeforeStop":
break;
/** 终止事件*/
case "onStop":
//流程终止更新grpu8单据
break;
/** 撤销前事件*/
case "onBeforeCancel":
break;
/** 撤销事件*/
case "onCancel":
//流程撤销更新grpu8单据
break;
/** 结束事件*/
case "onProcessFinished":
break;
/** 处理前事件*/
case "onBeforeFinishWorkitem":
/** 根据form处理相关业务表单的数据*/
switch (formApp) {
case "abc123":
break;
default:
return BaseResult.getFailureMessageEntity("未匹配到表单当前formID" + formApp, "");
}
break;
/** 处理事件*/
case "onFinishWorkitem":
break;
/** 回退前事件*/
case "onBeforeStepBack":
break;
/** 回退事件*/
case "onStepBack":
break;
/** 取回前事件*/
case "onBeforeTakeBack":
break;
/** 取回事件*/
case "onTakeBack":
break;
default:
// throw new RuntimeException("传入了非法事件类型!请参照:" + eventTypeBuffer.toString());
return BaseResult.getFailureMessageEntity("传入了非法事件类型!请参照:" + eventTypeBuffer.toString(), "", "");
}
return BaseResult.getSuccessMessageEntity("传递成功", result);
}catch (Exception e){
return BaseResult.getFailureMessageEntity("传递失败",e.getMessage());
} catch (Exception e) {
return BaseResult.getFailureMessageEntity("传递失败", e.getMessage());
}
return result;
}
@ -480,28 +423,74 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
* @throws Exception
*/
@Override
public String colEventPost(String jsonStr, String formAppId, String eventType) throws Exception {
if (StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)){
public JsonResultEntity colEventPost(String jsonStr, String formAppId, String eventType) throws Exception {
if (StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)) {
SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity();
sysApplicationApiEntity.setHeaderIn(formAppId+"_"+eventType);
sysApplicationApiEntity.setHeaderIn(formAppId + "_" + eventType);
List<SysApplicationApiEntity> applist = sysApplicationApiService.queryLike(sysApplicationApiEntity);
if (CollectionUtil.isNotEmpty(applist)){
if (applist.size() > 1){
throw new BaseSystemException("根据formID" + formAppId+"查询出多条数据");
if (CollectionUtil.isNotEmpty(applist)) {
if (applist.size() > 1) {
throw new BaseSystemException("根据formID" + formAppId + "查询出多条数据");
}
if (applist.size() == 0 ) {
throw new BaseSystemException("根据formID" + formAppId + "eventType:"+eventType+"未查询到API配置");
}
SysApplicationApiEntity sysApp = applist.get(0);
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
.put("apiCode", String.valueOf(sysApp.getApiCode()))
//这里用中台做为发送方
.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")
.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
.put("appId",String.valueOf(sysApp.getAppCode()))
.build();
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(jsonStr).timeout(60000).execute().body();
logger.info("调用中台返回的参数:{}",body);
return body;
JSONArray headerArray = JSONArray.parseArray(sysApp.getHeaderIn());
if (null != headerArray && headerArray.size() > 0) {
String plugId = null;
for (int i = 0; i < headerArray.size(); i++) {
JSONObject querys = headerArray.getJSONObject(i);
//query 只有基本类型不用循环判断下级
//判断参数是否有值
//获取对象下面的层级数据
String parameterName = querys.getString("parameterName");
if (null != parameterName && "plugId".equals(parameterName)) {
plugId = querys.getString("example");
break;
}
}
if (null == plugId) {
throw new BaseSystemException("根据formID" + formAppId + "未获取到head参数");
} else {
PluginBaseEntity pluginBaseEntity = null;
JsonResultEntity result;
pluginBaseEntity = PluginUtils.getPluginsById(plugId);
if (null == pluginBaseEntity) {
throw new BaseSystemException("根据ID获取插件错误请传入正确的 pluginId");
} else {
//执行业务逻辑代码
JSONObject reqJson = new JSONObject();
reqJson.put("jsonStr",jsonStr);
reqJson.put("formAppId",formAppId);
reqJson.put("eventType",eventType);
result = pluginBaseEntity.executeBusiness(reqJson);
return result;
}
}
} else {
throw new BaseSystemException("根据formID" + formAppId + "未获取到head参数");
}
// Map<String, String> headerMap = MapBuilder.<String, String>create(true)
// .put("apiCode", String.valueOf(sysApp.getApiCode()))
// //这里用中台做为发送方
// .put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")
// .put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
// .put("appId",String.valueOf(sysApp.getAppCode()))
// .build();
// String body = HttpRequest.post("http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(jsonStr).timeout(60000).execute().body();
// logger.info("调用中台返回的参数:{}",body);
// return body;
}
}else{
// StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)
logger.info("jsonStr,formAppId,eventType为空执行错误"+jsonStr+formAppId+eventType);
throw new BaseSystemException("jsonStr,formAppId,eventType为空执行错误");
}
return null;
}
}