Compare commits

...

8 Commits

4 changed files with 158 additions and 67 deletions

View File

@ -3,19 +3,19 @@ logging:
#日志级别 指定目录级别 #日志级别 指定目录级别
level: level:
root: info root: info
encodings: UTF-8 encodings: gbk
file: file:
# 日志保存路径 # 日志保存路径
path: /Users/xiangerlin/work/app/logs/ydc path: D:\yongansystem\logs
spring: spring:
datasource: datasource:
dynamic: dynamic:
datasource: datasource:
master: master:
url: jdbc:mysql://hzya.ufyct.com:9096/businesscenternew?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true url: jdbc:mysql://127.0.0.1:3306/businesscenternew?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
username: root username: root
password: bd993088e8a7c3dc5f44441617f9b4bf password: 62e4295b615a30dbf3b8ee96f41c820b
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置 driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
savefile: savefile:
# 文件保存路径 # 文件保存路径
path: /Users/xiangerlin/work/app/logs/ydc path: D:\yongansystem\ydc

View File

@ -216,7 +216,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
Object summaryObj = entity.getSummaryObj(); Object summaryObj = entity.getSummaryObj();
String deeCfgId = entity.getDeeCfgId(); String deeCfgId = entity.getDeeCfgId();
String currentNodeLast = entity.getCurrentNodeLast(); String currentNodeLast = entity.getCurrentNodeLast();
Map<String, Object> businessData = JSON.parseObject(entity.getBusinessDataStr(), Map.class); JSONObject businessData = JSON.parseObject(entity.getBusinessDataStr());
Map<String, Object> extData = entity.getExtData(); Map<String, Object> extData = entity.getExtData();
/** 表单表的FORM ID,用此字段标记是哪个流程*/ /** 表单表的FORM ID,用此字段标记是哪个流程*/
String formApp = entity.getFormApp(); String formApp = entity.getFormApp();
@ -248,14 +248,38 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
/** 结束事件*/ /** 结束事件*/
case "onProcessFinished": case "onProcessFinished":
if (StrUtil.isNotEmpty(formApp)){ if (StrUtil.isNotEmpty(formApp)){
String type = "_add";
switch (formApp){
case "-8691606453890363968"://存货
JSONObject formmain0227 = businessData.getJSONObject("formmain_0227");
//新增还是修改
type = formmain0227.getString("field0014");
break;
case "6223456019738676230"://供应商
JSONObject formmain0225 = businessData.getJSONObject("formmain_0225");
type = formmain0225.getString("field0019");
break;
case "-9122508232154527168"://客户
JSONObject formmain0226 = businessData.getJSONObject("formmain_0226");
type = formmain0226.getString("field0024");
break;
}
//这个枚举代表修改
if (type.equals("7858843591961101741")){
type = "_add";
}else {
type = "_edit";
}
SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity(); SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity();
sysApplicationApiEntity.setHeaderIn(formApp); sysApplicationApiEntity.setHeaderIn(formApp+type);
List<SysApplicationApiEntity> applist = sysApplicationApiService.queryByLike(sysApplicationApiEntity); List<SysApplicationApiEntity> applist = sysApplicationApiService.queryByLike(sysApplicationApiEntity);
if (CollectionUtil.isNotEmpty(applist)){ if (CollectionUtil.isNotEmpty(applist)){
if (applist.size() > 1){ if (applist.size() > 1){
return BaseResult.getFailureMessageEntity("根据formID" + formApp+"查询出多条数据", ""); return BaseResult.getFailureMessageEntity("根据formApp" + formApp+"查询出多条数据", "");
} }
SysApplicationApiEntity sysApp = applist.get(0); SysApplicationApiEntity sysApp = applist.get(0);
//存货要循环调用
if (!formApp.equals("-8691606453890363968")){
Map<String, String> headerMap = MapBuilder.<String, String>create(true) Map<String, String> headerMap = MapBuilder.<String, String>create(true)
.put("apiCode", String.valueOf(sysApp.getApiCode())) .put("apiCode", String.valueOf(sysApp.getApiCode()))
.put("publicKey","ZJYAlF4yjkjZaXmjLOUqsoGzTHAlWpoTdqT7/AEYaXIwpXNCe7eDIk+3zDUT+v578prj") .put("publicKey","ZJYAlF4yjkjZaXmjLOUqsoGzTHAlWpoTdqT7/AEYaXIwpXNCe7eDIk+3zDUT+v578prj")
@ -264,6 +288,26 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
.build(); .build();
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(jsonStr).timeout(60000).execute().body(); String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(jsonStr).timeout(60000).execute().body();
logger.info("调用中台返回的参数:{}",body); logger.info("调用中台返回的参数:{}",body);
}else {
//物料主表
JSONObject formmain0227 = businessData.getJSONObject("formmain_0227");
//物料明细表
JSONArray formson0228Arr = businessData.getJSONArray("formson_0228");
for (int i=0; i< formson0228Arr.size(); i++){
JSONObject param = new JSONObject();
param.put("formmain_0227",formmain0227);
param.put("formson_0228",formson0228Arr.getJSONObject(i));
entity.setBusinessDataStr(JSON.toJSONString(param));
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
.put("apiCode", String.valueOf(sysApp.getApiCode()))
.put("publicKey","ZJYAlF4yjkjZaXmjLOUqsoGzTHAlWpoTdqT7/AEYaXIwpXNCe7eDIk+3zDUT+v578prj")
.put("secretKey","RJTPEoOSDdaBeoxoMs465tcTqy38bRag+12S7kIv2Lxd38wgLeVfWVl/ipVKVu8Qj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
.put("appId","800018")
.build();
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(JSON.toJSONString(entity)).timeout(60000).execute().body();
logger.info("调用中台返回的参数:{}",body);
}
}
} }
} }
break; break;

View File

@ -1,7 +1,11 @@
package com.hzya.frame.seeyon.service.impl; package com.hzya.frame.seeyon.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
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;
@ -19,9 +23,7 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.Map;
/** /**
* @Description seeyon扩展类 * @Description seeyon扩展类
@ -31,7 +33,7 @@ import java.util.Map;
@Service(value = "seeyonExt") @Service(value = "seeyonExt")
public class SeeyonExtServiceImpl implements ISeeyonExtService { public class SeeyonExtServiceImpl implements ISeeyonExtService {
static final String KEY = "`o7eotan9ws8c:aj";
Logger logger = LogManager.getLogger(getClass()); Logger logger = LogManager.getLogger(getClass());
@Autowired @Autowired
@ -53,7 +55,7 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
String businessDataStr = dataEntity.getBusinessDataStr();//oa表单参数 String businessDataStr = dataEntity.getBusinessDataStr();//oa表单参数
JSONObject businessData = JSON.parseObject(businessDataStr); JSONObject businessData = JSON.parseObject(businessDataStr);
String formApp = dataEntity.getFormApp(); String formApp = dataEntity.getFormApp();
SysExtensionApiEntity param = new SysExtensionApiEntity(); // SysExtensionApiEntity param = new SysExtensionApiEntity();
Map<String, String> headerMap = entity.getHeaders(); Map<String, String> headerMap = entity.getHeaders();
JSONObject hzyaExtData = dataEntity.getHzyaExtData();//扩展参数 JSONObject hzyaExtData = dataEntity.getHzyaExtData();//扩展参数
if (null == hzyaExtData){ if (null == hzyaExtData){
@ -62,21 +64,21 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
//根据forApp组装不同参数 //根据forApp组装不同参数
switch (formApp){ switch (formApp){
case "-8691606453890363968":// case "-8691606453890363968"://
hzyaExtData.put("billCode", "cunhuoabc123456"); getInventory(businessData,entity,hzyaExtData);
getInventory(businessData,param);
break; break;
case "6223456019738676230": case "6223456019738676230":
getSupplier(businessData,param,hzyaExtData); getSupplier(businessData,entity,hzyaExtData);
break; break;
case "-9122508232154527168": case "-9122508232154527168":
getCustomer(businessData,param,hzyaExtData); getCustomer(businessData,entity,hzyaExtData);
break; break;
default: default:
param.setBodys("未匹配到表单当前formID"+ formApp); entity.setBodys("未匹配到表单当前formID"+ formApp);
logger.error("未匹配到表单当前formID"+formApp); logger.error("未匹配到表单当前formID"+formApp);
} }
headerMap.put("hzyaExtData", JSON.toJSONString(hzyaExtData)); headerMap.put("hzyaExtData", JSON.toJSONString(hzyaExtData));
return param; entity.setHeaders(headerMap);
return entity;
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
logger.error("执行英德赛OA存货同步U8接口报错{}", e); logger.error("执行英德赛OA存货同步U8接口报错{}", e);
@ -98,30 +100,56 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
JSONObject targetData = JSON.parseObject(logEntity.getTargetData());//这个对象里的body是 发送到u8的请求报文 JSONObject targetData = JSON.parseObject(logEntity.getTargetData());//这个对象里的body是 发送到u8的请求报文
JSONObject sourceData = JSON.parseObject(logEntity.getSourceData()); JSONObject sourceData = JSON.parseObject(logEntity.getSourceData());
JSONObject sourceHeaders = sourceData.getJSONObject("header");//源数据header JSONObject sourceHeaders = sourceData.getJSONObject("header");//源数据header
JSONObject targetHeaders = targetData.getJSONObject("header");//源数据header
JSONObject sourceBody = sourceData.getJSONObject("body");//源数据body JSONObject sourceBody = sourceData.getJSONObject("body");//源数据body
JSONObject hzyaExtData = sourceHeaders.getJSONObject("hzyaExtData"); JSONObject hzyaExtData = targetHeaders.getJSONObject("hzyaExtData");// 这里刚开始用sourceHeaders取的2024-06-04 14:24:19改成从target里取因为从apipost请求后在source里取不到
JSONArray formMainIds = new JSONArray(); JSONArray formMainIds = new JSONArray();
formMainIds.add(sourceBody.getString("id")); formMainIds.add(sourceBody.getString("id"));
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
String formApp = sourceBody.getString("formApp"); String formApp = sourceBody.getString("formApp");
param.put("formAppId",formApp); param.put("formAppId",formApp);
param.put("formMainIds",formMainIds); param.put("formMainIds",formMainIds);
param.put("dataSourceCode","ht_oa_sqlserver"); param.put("dataSourceCode","ydc_oa_sqlserver");
param.put("eventType",sourceBody.getString("eventType")); param.put("eventType",sourceBody.getString("eventType"));
//把返回的单号更新到oa档案表 //把返回的单号更新到oa档案表
String returnDataStr = logEntity.getReturnData();
if (JSONUtil.isTypeJSON(returnDataStr)){
JSONObject returnData = JSONObject.parseObject(returnDataStr);
String success = returnData.getString("success");
if ("true".equals(success)){
JSONArray dataArr = returnData.getJSONArray("data");
if (null != dataArr){
String code = dataArr.getString(0);
String sql = ""; String sql = "";
switch (formApp){ switch (formApp){
case "-8691606453890363968"://存货 case "-8691606453890363968"://存货
//todo 这里要看一下循环调用的时候 参数是什么样的再决定
sql = ""; sql = "";
break; break;
case "6223456019738676230"://供应商 case "6223456019738676230"://供应商
sql = "update formmain_0229 set field0002 = '' where field0001 = "+hzyaExtData.getString("billCode"); sql = "update formmain_0229 set field0002 = "+ code + " where field0001 = "+hzyaExtData.getString("billCode");
break; break;
case "-9122508232154527168"://客户 case "-9122508232154527168"://客户
sql = "update formmain_0230 set field0002 = '' where field0001 = "+hzyaExtData.getString("billCode"); sql = "update formmain_0230 set field0002 = "+ code + " where field0001 = "+hzyaExtData.getString("billCode");
break; break;
} }
if (StrUtil.isNotEmpty(sql)){
String sign = SecureUtil.md5(sql);
String data = SecureUtil.aes(KEY.getBytes()).encryptHex(sql);
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
.put("apiCode", "8000190001")
.put("publicKey","ZJYAlF4yjkjZaXmjLOUqsoGzTHAlWpoTdqT7/AEYaXIwpXNCe7eDIk+3zDUT+v578prj")
.put("secretKey","RJTPEoOSDdaBeoxoMs465tcTqy38bRag+12S7kIv2Lxd38wgLeVfWVl/ipVKVu8Qj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
.put("appId","800019")
.build();
JSONObject params = new JSONObject();
params.put("sign",sign);
params.put("data",data);
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(JSON.toJSONString(params)).timeout(60000).execute().body();
}
}
}
}
IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity(); IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity();
logDetails.setRootAppPk(JSON.toJSONString(param)); logDetails.setRootAppPk(JSON.toJSONString(param));
logDetails.setRootAppBill(hzyaExtData.getString("billCode")); logDetails.setRootAppBill(hzyaExtData.getString("billCode"));
@ -151,17 +179,29 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
} }
//存货参数组装 //存货参数组装
private SysExtensionApiEntity getInventory(JSONObject businessData,SysExtensionApiEntity param){ private SysExtensionApiEntity getInventory(JSONObject businessData,SysExtensionApiEntity param,JSONObject hzyaExtData){
if (null != businessData){ if (null != businessData){
//物料主表
JSONObject formmain0227 = businessData.getJSONObject("formmain_0227"); JSONObject formmain0227 = businessData.getJSONObject("formmain_0227");
JSONArray formson0228Arr = businessData.getJSONArray("formson_0228"); //物料明细表 上层方法处理了这里是单条传
for (int i=0; i< formson0228Arr.size(); i++){ JSONObject formson0228 = businessData.getJSONObject("formson_0228");
JSONObject formson0228 = formson0228Arr.getJSONObject(i);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("Token", "Hzya1314_CheckSkip"); jsonObject.put("Token", "Hzya1314_CheckSkip");
jsonObject.put("billid", formson0228.getString("id")); jsonObject.put("billid", formson0228.getString("id"));
jsonObject.put("AccId", formmain0227.getString("field0015")); jsonObject.put("AccId", formmain0227.getString("field0015"));
/**
* bPurchase 是否外购
* bComsume 是否生产耗用
* bSale 是否销售
* bSelf 是否自制
* bService 应税劳务
* bInvAsset 资产
*
* iSupplyType 供应类型 默认领用 0
* iDrawType 领料方式 默认申请领用
* cValueType 计价方式 默认 全月平均法 全月平均法
* iImpTaxRate 进项税率 默认13
*/
JSONObject oArchives = new JSONObject(); JSONObject oArchives = new JSONObject();
oArchives.put("cInvCode", formson0228.getString("field0002")); oArchives.put("cInvCode", formson0228.getString("field0002"));
oArchives.put("cInvCCode", formson0228.getString("field0005")); oArchives.put("cInvCCode", formson0228.getString("field0005"));
@ -169,10 +209,10 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
//todo 这个没值 //todo 这个没值
oArchives.put("cGroupCode", "01"); oArchives.put("cGroupCode", "01");
oArchives.put("cComUnitCode", formson0228.getString("field0006")); oArchives.put("cComUnitCode", formson0228.getString("field0006"));
jsonObject.put("oArchives", oArchives); jsonObject.put("oArchives", oArchives);
param.setBodys(JSON.toJSONString(jsonObject)); param.setBodys(JSON.toJSONString(jsonObject));
} hzyaExtData.put("billCode",formson0228.getString("id"));
hzyaExtData.put("formmainId",formmain0227.getString("id"));
} }
return param; return param;
} }
@ -183,7 +223,8 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("billid", formmain0225.getString("id")); jsonObject.put("billid", formmain0225.getString("id"));
jsonObject.put("AccId", formmain0225.getString("field0020")); jsonObject.put("AccId", formmain0225.getString("field0020"));
jsonObject.put("Token", U8Util.getToken()); //jsonObject.put("Token", U8Util.getToken());
jsonObject.put("Token", "Hzya1314_CheckSkip");
JSONObject oArchives = new JSONObject(); JSONObject oArchives = new JSONObject();
oArchives.put("cVenCode", formmain0225.getString("field0002")); oArchives.put("cVenCode", formmain0225.getString("field0002"));
oArchives.put("cVenName", formmain0225.getString("field0003")); oArchives.put("cVenName", formmain0225.getString("field0003"));
@ -206,6 +247,10 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
oArchives.put("cVenRegCode", formmain0225.getString("field0009")); oArchives.put("cVenRegCode", formmain0225.getString("field0009"));
oArchives.put("cVenBank", formmain0225.getString("field0011")); oArchives.put("cVenBank", formmain0225.getString("field0011"));
oArchives.put("cVenAccount", formmain0225.getString("field0012")); oArchives.put("cVenAccount", formmain0225.getString("field0012"));
//专管业务员
oArchives.put("cVenPPerson",formmain0225.getString("field0016"));
//分管部门
oArchives.put("cVenDepart",formmain0225.getString("field0013"));
jsonObject.put("oArchives", oArchives); jsonObject.put("oArchives", oArchives);
param.setBodys(JSON.toJSONString(jsonObject)); param.setBodys(JSON.toJSONString(jsonObject));
hzyaExtData.put("billCode", formmain0225.getString("field0001")); hzyaExtData.put("billCode", formmain0225.getString("field0001"));
@ -228,9 +273,10 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
oArchives.put("cCusAbbName", formmain0226.getString("field0008")); oArchives.put("cCusAbbName", formmain0226.getString("field0008"));
oArchives.put("cCCCode", formmain0226.getString("field0012")); oArchives.put("cCCCode", formmain0226.getString("field0012"));
oArchives.put("cCusExch_name", formmain0226.getString("field0013")); oArchives.put("cCusExch_name", formmain0226.getString("field0013"));
// todo 这个字段没值 //客户管理类型 默认 999
oArchives.put("cCusMngTypeCode", "999"); oArchives.put("cCusMngTypeCode", "999");
//bCusOverseas 是否国外
//bCusDomestic 是否国内
jsonObject.put("oArchives", oArchives); jsonObject.put("oArchives", oArchives);
param.setBodys(JSON.toJSONString(jsonObject)); param.setBodys(JSON.toJSONString(jsonObject));
hzyaExtData.put("billCode",formmain0226.getString("field0001")); hzyaExtData.put("billCode",formmain0226.getString("field0001"));

View File

@ -18,9 +18,10 @@ public class U8Util {
//获取token //获取token
public static String getToken() { public static String getToken() {
String url = "http://127.0.0.1:51910/Api/Base/GetToken"; String url = "http://192.168.2.240:8099/Api/Base/GetToken";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("secretkey", "L1NhkDrQhtBDzTxFxPI0jxWcBzTBSPvaI5xZusRRi9ofS9d6ngxrj1erwbdjxtUT"); jsonObject.put("appid","");
jsonObject.put("secretkey", "lDihm+RTN8y9digs7f/KtU2pyoJkYyoT+8rNL2TxBEj+QbXU6dvw6fGcy4VDZWi8");
logger.info("获取U8token参数:{}", jsonObject.toJSONString()); logger.info("获取U8token参数:{}", jsonObject.toJSONString());
String token = HttpRequest.post( url).body(jsonObject.toJSONString()).timeout(60000).execute().body(); String token = HttpRequest.post( url).body(jsonObject.toJSONString()).timeout(60000).execute().body();
logger.info("token返回参数:{}", jsonObject.toJSONString()); logger.info("token返回参数:{}", jsonObject.toJSONString());