seeyonExt OA同步U8

This commit is contained in:
xiang2lin 2024-05-16 14:18:21 +08:00
parent d33cff5e43
commit 92a1f8bed7
4 changed files with 252 additions and 1 deletions

View File

@ -0,0 +1,29 @@
package com.hzya.frame.seeyon.service;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
/**
* @Description seeyon扩展类
* @Author xiangerlin
* @Date 2024/5/14 14:04
**/
public interface ISeeyonExtService {
/**
* @Since 3.0
* 英德赛 OA档案传U8
* 根据不同formApp来调U8不同接口
* @param entity
* @return
*/
SysExtensionApiEntity ydcSeeyon2u8(SysExtensionApiEntity entity);
/**
* @Since 3.0
* 回调方法
* @param logEntity
*/
void ydcSeeyon2u8CallBack(SysMessageManageLogEntity logEntity);
}

View File

@ -418,7 +418,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
object.put("summaryId","");
object.put("currentActivityId","");
object.put("id",forMainId);
object.put("extData",requestData.getJSONObject("extData"));
object.put("hzyaExtData",requestData.getJSONObject("hzyaExtData"));
logger.info("Method:thirdInterfaceSeeYonDefinitionRePush 组装seeYonBean DATA: {}",seeYonBean.toJSONString());
rePushRequestData.put("jsonStr",object);

View File

@ -0,0 +1,214 @@
package com.hzya.frame.seeyon.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.seeyon.entity.OAWorkflowEventDataEntity;
import com.hzya.frame.seeyon.service.ISeeyonExtService;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity;
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogStatusEnum;
import com.hzya.frame.u8.util.U8Util;
import com.hzya.frame.uuid.UUIDLong;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @Description seeyon扩展类
* @Author xiangerlin
* @Date 2024/5/14 14:04
**/
@Service(value = "seeyonExt")
public class SeeyonExtServiceImpl implements ISeeyonExtService {
Logger logger = LogManager.getLogger(getClass());
@Autowired
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
/**
* 英德赛 OA档案传U8
* 根据不同formApp来调U8不同接口
* @Since 3.0
* @param entity
* @return
*/
@Override
public SysExtensionApiEntity ydcSeeyon2u8(SysExtensionApiEntity entity) {
String bodys = entity.getBodys();
if (StrUtil.isNotEmpty(bodys)){
try {
OAWorkflowEventDataEntity dataEntity = JSON.parseObject(bodys,OAWorkflowEventDataEntity.class);
String businessDataStr = dataEntity.getBusinessDataStr();//oa表单参数
JSONObject businessData = JSON.parseObject(businessDataStr);
String formApp = dataEntity.getFormApp();
SysExtensionApiEntity param = new SysExtensionApiEntity();
Map<String, String> headerMap = entity.getHeaders();
JSONObject hzyaExtData = dataEntity.getHzyaExtData();//扩展参数
if (null == hzyaExtData){
hzyaExtData = new JSONObject();
}
//根据forApp组装不同参数
switch (formApp){
case "4728403652378707515"://
hzyaExtData.put("billCode", "cunhuoabc123456");
getInventory(businessData,param);
break;
case "供应商":
hzyaExtData.put("billCode", "");
getSupplier(businessData,param);
break;
case "客户":
hzyaExtData.put("billCode", "");
getCustomer(businessData,param);
break;
default:
param.setBodys("未匹配到表单当前formID"+ formApp);
logger.error("未匹配到表单当前formID"+formApp);
}
headerMap.put("hzyaExtData", JSON.toJSONString(hzyaExtData));
return param;
}catch (Exception e){
e.printStackTrace();
logger.error("执行英德赛OA存货同步U8接口报错{}", e);
}
}
return null;
}
/**
* 回调方法
* @Since 3.0
* @param logEntity
*/
@Override
public void ydcSeeyon2u8CallBack(SysMessageManageLogEntity logEntity) {
//在这里记录日志
JSONObject targetData = JSON.parseObject(logEntity.getTargetData());//这个对象里的body是 发送到u8的请求报文
JSONObject sourceData = JSON.parseObject(logEntity.getSourceData());
JSONObject sourceHeaders = sourceData.getJSONObject("header");//源数据header
JSONObject sourceBody = sourceData.getJSONObject("body");//源数据body
JSONObject hzyaExtData = sourceHeaders.getJSONObject("hzyaExtData");
JSONArray formMainIds = new JSONArray();
formMainIds.add(sourceBody.getString("id"));
JSONObject param = new JSONObject();
param.put("formAppId",sourceBody.getString("formApp"));
param.put("formMainIds",formMainIds);
param.put("dataSourceCode","ht_oa_sqlserver");
param.put("eventType",sourceBody.getString("eventType"));
IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity();
logDetails.setRootAppPk(JSON.toJSONString(param));
logDetails.setRootAppBill(hzyaExtData.getString("billCode"));
logDetails.setNewTransmitInfo(logEntity.getReturnData());
logDetails.setNewPushDate(new Date());
logDetails.setRootAppNewData(targetData.getString("body"));
//logDetails.setNewState(SysMessageManageLogStatusEnum.statusGetValue(logEntity.getStatus()));
logDetails.setPluginId("SeeyonExtPlugin");
try {
if (StrUtil.isEmpty(hzyaExtData.getString("integration_task_living_details_id"))){
if (SysMessageManageLogStatusEnum.SUCCESS.getType().equals(logEntity.getStatus())) {//成功
taskLivingDetailsService.saveLogToSuccess(logDetails);
}else {
taskLivingDetailsService.saveLogToFail(logDetails);//失败
}
}else {
logDetails.setId(hzyaExtData.getString("integration_task_living_details_id"));
if (SysMessageManageLogStatusEnum.SUCCESS.getType().equals(logEntity.getStatus())) {//成功
taskLivingDetailsService.saveLogFailToSuccess(logDetails);
}else {
taskLivingDetailsService.updateLogFailToSuccess(logDetails);//失败
}
}
}catch (Exception e){
logger.error("保存日志出错:{}",e);
}
}
//存货参数组装
private SysExtensionApiEntity getInventory(JSONObject businessData,SysExtensionApiEntity param){
if (null != businessData){
JSONObject jsonObject = new JSONObject();
jsonObject.put("Token", "Hzya1314_CheckSkip");
jsonObject.put("billid", "123");
jsonObject.put("AccId", "005");
JSONObject oArchives = new JSONObject();
oArchives.put("cInvCode", "cyp12");
oArchives.put("cInvCCode", "0101");
oArchives.put("cInvName", "测试");
oArchives.put("cGroupCode", "01");
oArchives.put("cComUnitCode", "0101");
jsonObject.put("oArchives", oArchives);
param.setBodys(JSON.toJSONString(jsonObject));
}
return param;
}
//供应商参数组装
private SysExtensionApiEntity getSupplier(JSONObject businessData,SysExtensionApiEntity param){
if (null != businessData){
JSONObject jsonObject = new JSONObject();
jsonObject.put("billid", "123");
jsonObject.put("AccId", "888");
jsonObject.put("Token", U8Util.getToken());
JSONObject oArchives = new JSONObject();
oArchives.put("cVenCode", "0001");
oArchives.put("cVenName ", "测试0001");
oArchives.put("cVenAbbName", "测试0001简称");
oArchives.put("cVCCode", "01");
oArchives.put("cVenExch_name", "人民币");
oArchives.put("bVenTax", "false");
oArchives.put("bLicenceDate", "false");
oArchives.put("bBusinessDate", "false");
oArchives.put("bProxyDate", "false");
oArchives.put("bPassGMP", "false");
oArchives.put("bVenCargo", "false");
oArchives.put("bProxyForeign", "true");
oArchives.put("bVenService", "true");
oArchives.put("iVenGSPType", "0");
oArchives.put("bVenOverseas", "false");
oArchives.put("bVenAccPeriodMng", "false");
oArchives.put("bVenHomeBranch", "false");
oArchives.put("dVenCreateDatetime", "2023-01-04 10:00");
oArchives.put("cVenRegCode", "税号");
oArchives.put("cVenBank", "开户银行");
oArchives.put("cVenAccount", "银行账号");
jsonObject.put("oArchives", oArchives);
param.setBodys(JSON.toJSONString(jsonObject));
}
return param;
}
//客户参数组装
private SysExtensionApiEntity getCustomer(JSONObject businessData,SysExtensionApiEntity param){
if (null != businessData){
JSONObject jsonObject = new JSONObject();
jsonObject.put("billid", "123");
jsonObject.put("AccId", "888");
jsonObject.put("Token", "Hzya1314_CheckSkip");
JSONObject oArchives = new JSONObject();
oArchives.put("cCusCode", "0001");
oArchives.put("cCusName", "测试0001");
oArchives.put("cCusAbbName", "测试0001");
oArchives.put("cCCCode", "01");
oArchives.put("cCusExch_name", "人民币");
oArchives.put("cCusMngTypeCode", "999");
jsonObject.put("oArchives", oArchives);
param.setBodys(JSON.toJSONString(jsonObject));
}
return param;
}
}

View File

@ -71,6 +71,14 @@
,def4
,def5
</sql>
<!--通过ID获取数据 -->
<select id="entity_get" resultMap="get-IntegrationTaskLivingDetailsEntity-result">
select
<include refid="IntegrationTaskLivingDetailsEntity_Base_Column_List" />
from integration_task_living_details where id = #{ id } and sts='Y'
</select>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-IntegrationTaskLivingDetailsEntity-result" parameterType = "com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity">
select