诺诺发票推送

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.lang.Assert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.plugin.nuonuo.dao.INuoNuoDao; import com.hzya.frame.plugin.nuonuo.dao.INuoNuoDao;
import com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity; import com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity;
@ -13,11 +15,15 @@ import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.hzya.frame.basedao.service.impl.BaseService; import com.hzya.frame.basedao.service.impl.BaseService;
import org.springframework.beans.factory.annotation.Value;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
public class NuoNuoServiceImpl extends BaseService<NuoNuoEntity, String> implements INuoNuoService { public class NuoNuoServiceImpl extends BaseService<NuoNuoEntity, String> implements INuoNuoService {
@Value("${zt.url}")
private String url;
private INuoNuoDao nuoNuoDao; private INuoNuoDao nuoNuoDao;
@Autowired @Autowired
@ -36,115 +42,108 @@ public class NuoNuoServiceImpl extends BaseService<NuoNuoEntity, String> impleme
@Override @Override
public JsonResultEntity sendNuoNuoFaPiao(JSONObject requestJson) { public JsonResultEntity sendNuoNuoFaPiao(JSONObject requestJson) {
logger.error(" 资金拨付流程结束回调:"+requestJson.toJSONString()); 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");//表头 * @Author lvleigang
//String eventType = requestJson.getString("eventType"); * @Description 组装数据
//String summaryId = requestJson.getString("summaryId"); * @Date 6:12 下午 2025/6/27
//Assert.notEmpty(dataSourceCode,"数据源不能为空"); * @param mainData
//Assert.notEmpty(headerStr,"headers不能为空"); * @param detailArray
//Assert.notEmpty(eventType,"eventType不能为空"); * @return com.alibaba.fastjson.JSONObject
//Assert.notEmpty(summaryId,"summaryId不能为空"); **/
//JSONObject headers = requestJson.getJSONObject("headers"); private JSONObject getSendData(JSONObject mainData, JSONArray detailArray) {
//String formmainTableName = headers.getString("formmainTableName"); JSONObject sendData = new JSONObject();
//JSONObject jsonStrObj = requestJson.getJSONObject("jsonStr"); sendData.put("buyerName",mainData.getString("field0092"));//购方名称
//JSONObject businessData = jsonStrObj.getJSONObject("businessDataStr"); sendData.put("buyerTaxnum",mainData.getString("field0146"));//购方税号
//JSONObject formmainData = businessData.getJSONObject(formmainTableName); sendData.put("buyerAddress",mainData.getString("field0134"));//购方地址
//if (null != formmainData){ sendData.put("buyerPhone",mainData.getString("field0135"));//购方电话
// //税务系统id这个字段不为空时表示是税务推过来的单子 sendData.put("buyerBank",mainData.getString("field0128"));//购方开户行
// String field0061 = formmainData.getString("field0061"); sendData.put("buyerAccount",mainData.getString("field0139"));//购方银行账号
// //司库系统批次号 sendData.put("orderNo",mainData.getString("field0001"));//订单编号
// String field0063 = formmainData.getString("field0063"); //sendData.put("bizCallbackUrl","http://10.0.2.112:9021/kangarooDataCenterV3/entranceController/nuoNuoCallback");//回调地址测试
// //资金归集 sendData.put("bizCallbackUrl","http://10.0.2.112:9011/kangarooDataCenterV3/entranceController/nuoNuoCallback");//回调地址正式
// String field0062 = formmainData.getString("field0062"); sendData.put("sellerName",mainData.getString("field0129"));//销方名称
// if (StrUtil.isNotEmpty(field0061) || StrUtil.isNotEmpty(field0063) || StrUtil.isNotEmpty(field0062)){ sendData.put("sellerTaxnum",mainData.getString("field0162"));//销方税号
// //查询审批意见 sendData.put("sellerAddress",mainData.getString("field0161"));//销方地址
// FundsAllocationEntity fundAllocation = new FundsAllocationEntity(); sendData.put("sellerPhone",mainData.getString("field0163"));//销方电话
// fundAllocation.setCol_summary_id(summaryId); sendData.put("sellerBank",mainData.getString("field0164"));//销方开户银行
// fundAllocation.setDataSourceCode(dataSourceCode); sendData.put("sellerAccount",mainData.getString("field0165"));//销方银行账号
// List<FundsAllocationEntity> fundsAllocationList = fundsAllocationService.queryCtpCommentList(fundAllocation); sendData.put("invoiceLine",mainData.getString("field0168"));//发票种类bs:数电专票(电子),pc:数电普票(电子)
// if (CollectionUtils.isNotEmpty(fundsAllocationList)){ sendData.put("invoiceType",1);//开票类型1:蓝票2:红票
// fundAllocation = fundsAllocationList.get(0); sendData.put("substituteFlag",0);//代开标志0:非代开;1:代开
// } sendData.put("listFlag",0);//清单标志0:非清单1:清单
// String appId = "";//应用 sendData.put("notifyType",-1);//推送方式-1:不推送;0:邮箱;1:手机(默认);2:邮箱手机;3:根据交付手机邮箱动态交付
// String apiCode = "";//api sendData.put("requestSrc",0);//请求来源0 :api接口
// String param = "";//参数 sendData.put("checkBlue",0);//开具红票时是否校验蓝票 0.校验蓝票是否存在诺税通 1.不校验蓝票是否存在诺税通但校验可冲红金额 2.不校验蓝票是否存在诺税通且不校验可冲红金额
// if (StrUtil.isNotEmpty(field0061)){ JSONArray sendArray = new JSONArray();
// 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("表单数据为空");
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 { public class NuoNuoCallbackEntity extends BaseEntity {
private String id; private String id;
private String fieldsum;//单据号
private String field0001;//单据号 private String field0001;//单据号
private String field0150;//发票号码 private String field0150;//发票号码
private String field0151;//开票日期 private String field0151;//开票日期
@ -13,6 +14,14 @@ public class NuoNuoCallbackEntity extends BaseEntity {
private String field0153;//电子发票 private String field0153;//电子发票
public String getFieldsum() {
return fieldsum;
}
public void setFieldsum(String fieldsum) {
this.fieldsum = fieldsum;
}
@Override @Override
public String getId() { public String getId() {
return id; 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="queryOaData" resultType="com.hzya.frame.seeyon.entity.NuoNuoCallbackEntity" parameterType="com.hzya.frame.seeyon.entity.NuoNuoCallbackEntity">
select SELECT a.id as id ,
id b.id as fieldsum
from formmain_11951 from formmain_11951 a
LEFT JOIN COL_SUMMARY b on a.id = b.FORM_RECORDID
<trim prefix="where" prefixOverrides="and"> <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> </trim>
</select> </select>
@ -21,7 +22,7 @@
<trim suffix="" suffixOverrides=","> <trim suffix="" suffixOverrides=",">
<if test="field0001 != null and field0001 !='' "> field0001 = #{field0001},</if> <if test="field0001 != null and field0001 !='' "> field0001 = #{field0001},</if>
<if test="field0150 != null and field0150 !='' "> field0150 = #{field0150},</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="field0188 != null and field0188 !='' "> field0188 = #{field0188},</if>
<if test="field0152 != null and field0152 !='' "> field0152 = #{field0152},</if> <if test="field0152 != null and field0152 !='' "> field0152 = #{field0152},</if>
<if test="field0153 != null and field0153 !='' "> field0153 = #{field0153},</if> <if test="field0153 != null and field0153 !='' "> field0153 = #{field0153},</if>

View File

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

View File

@ -9,6 +9,7 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.seeyon.dao.ISeeYonInterFaceDao; import com.hzya.frame.seeyon.dao.ISeeYonInterFaceDao;
import com.hzya.frame.seeyon.entity.OAWorkflowEventDataEntity; import com.hzya.frame.seeyon.entity.OAWorkflowEventDataEntity;
import com.hzya.frame.seeyon.entity.SeeYonInterFaceEntity; 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.database.entity.SysApplicationDatabaseEntity;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity; import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity; 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.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity; import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException; import com.hzya.frame.web.exception.BaseSystemException;
@ -201,10 +203,10 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
public JsonResultEntity thirdInterfaceSeeYonPlugInInterfaceEntrance(JSONObject requestData){ public JsonResultEntity thirdInterfaceSeeYonPlugInInterfaceEntrance(JSONObject requestData){
String jsonStr = requestData.getString("jsonStr"); String jsonStr = requestData.getString("jsonStr");
JSONObject jsonObject = requestData.getJSONObject("jsonStr"); JSONObject jsonObject = requestData.getJSONObject("jsonStr");
OAWorkflowEventDataEntity entity = JSON.parseObject(jsonStr,OAWorkflowEventDataEntity.class); OAWorkflowEventDataEntity entity = JSON.parseObject(jsonStr, OAWorkflowEventDataEntity.class);
logger.info("监听OA事件入参"+jsonObject.toJSONString()); logger.info("监听OA事件入参" + jsonObject.toJSONString());
JSONObject formBeanData = jsonObject.getJSONObject("businessDataStr"); JSONObject formBeanData = jsonObject.getJSONObject("businessDataStr");
String eventType = jsonObject.getString("eventType") ; String eventType = jsonObject.getString("eventType");
/** 流程ID*/ /** 流程ID*/
String summaryId = entity.getSummaryId(); String summaryId = entity.getSummaryId();
/** 节点ID*/ /** 节点ID*/
@ -223,73 +225,14 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
//formApp 最好过滤一下 //formApp 最好过滤一下
String result = null; JsonResultEntity result = null;
try { try {
//流程事件处理 //流程事件处理
result = colEventPost(jsonStr, formApp, eventType); result = colEventPost(jsonStr, formApp, eventType);
}catch (Exception e){ } catch (Exception e) {
return BaseResult.getFailureMessageEntity("传递失败",e.getMessage()); 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());
} }
return result;
} }
@ -480,27 +423,73 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
* @throws Exception * @throws Exception
*/ */
@Override @Override
public String colEventPost(String jsonStr, String formAppId, String eventType) throws Exception { public JsonResultEntity colEventPost(String jsonStr, String formAppId, String eventType) throws Exception {
if (StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)){ if (StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)) {
SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity(); SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity();
sysApplicationApiEntity.setHeaderIn(formAppId+"_"+eventType); sysApplicationApiEntity.setHeaderIn(formAppId + "_" + eventType);
List<SysApplicationApiEntity> applist = sysApplicationApiService.queryLike(sysApplicationApiEntity); List<SysApplicationApiEntity> applist = sysApplicationApiService.queryLike(sysApplicationApiEntity);
if (CollectionUtil.isNotEmpty(applist)){ if (CollectionUtil.isNotEmpty(applist)) {
if (applist.size() > 1){ if (applist.size() > 1) {
throw new BaseSystemException("根据formID" + formAppId+"查询出多条数据"); throw new BaseSystemException("根据formID" + formAppId + "查询出多条数据");
}
if (applist.size() == 0 ) {
throw new BaseSystemException("根据formID" + formAppId + "eventType:"+eventType+"未查询到API配置");
} }
SysApplicationApiEntity sysApp = applist.get(0); SysApplicationApiEntity sysApp = applist.get(0);
Map<String, String> headerMap = MapBuilder.<String, String>create(true) JSONArray headerArray = JSONArray.parseArray(sysApp.getHeaderIn());
.put("apiCode", String.valueOf(sysApp.getApiCode())) if (null != headerArray && headerArray.size() > 0) {
//这里用中台做为发送方 String plugId = null;
.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj") for (int i = 0; i < headerArray.size(); i++) {
.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=") JSONObject querys = headerArray.getJSONObject(i);
.put("appId",String.valueOf(sysApp.getAppCode())) //query 只有基本类型不用循环判断下级
.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); String parameterName = querys.getString("parameterName");
return body; 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; return null;
} }