oa对接u8扩展类
This commit is contained in:
parent
6997fb81ba
commit
ef6eb4b807
|
@ -1,7 +1,11 @@
|
|||
package com.hzya.frame.seeyon.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapBuilder;
|
||||
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.JSONArray;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description seeyon扩展类
|
||||
|
@ -31,7 +33,7 @@ import java.util.Map;
|
|||
@Service(value = "seeyonExt")
|
||||
public class SeeyonExtServiceImpl implements ISeeyonExtService {
|
||||
|
||||
|
||||
static final String KEY = "`o7eotan9ws8c:aj";
|
||||
Logger logger = LogManager.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
|
@ -53,7 +55,7 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
|
|||
String businessDataStr = dataEntity.getBusinessDataStr();//oa表单参数
|
||||
JSONObject businessData = JSON.parseObject(businessDataStr);
|
||||
String formApp = dataEntity.getFormApp();
|
||||
SysExtensionApiEntity param = new SysExtensionApiEntity();
|
||||
// SysExtensionApiEntity param = new SysExtensionApiEntity();
|
||||
Map<String, String> headerMap = entity.getHeaders();
|
||||
JSONObject hzyaExtData = dataEntity.getHzyaExtData();//扩展参数
|
||||
if (null == hzyaExtData){
|
||||
|
@ -62,21 +64,21 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
|
|||
//根据forApp组装不同参数
|
||||
switch (formApp){
|
||||
case "-8691606453890363968"://
|
||||
hzyaExtData.put("billCode", "cunhuoabc123456");
|
||||
getInventory(businessData,param);
|
||||
getInventory(businessData,entity,hzyaExtData);
|
||||
break;
|
||||
case "6223456019738676230":
|
||||
getSupplier(businessData,param,hzyaExtData);
|
||||
getSupplier(businessData,entity,hzyaExtData);
|
||||
break;
|
||||
case "-9122508232154527168":
|
||||
getCustomer(businessData,param,hzyaExtData);
|
||||
getCustomer(businessData,entity,hzyaExtData);
|
||||
break;
|
||||
default:
|
||||
param.setBodys("未匹配到表单!当前formID:"+ formApp);
|
||||
entity.setBodys("未匹配到表单!当前formID:"+ formApp);
|
||||
logger.error("未匹配到表单!当前formID:"+formApp);
|
||||
}
|
||||
headerMap.put("hzyaExtData", JSON.toJSONString(hzyaExtData));
|
||||
return param;
|
||||
entity.setHeaders(headerMap);
|
||||
return entity;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
logger.error("执行英德赛OA存货同步U8接口报错:{}", e);
|
||||
|
@ -98,8 +100,9 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
|
|||
JSONObject targetData = JSON.parseObject(logEntity.getTargetData());//这个对象里的body是 发送到u8的请求报文
|
||||
JSONObject sourceData = JSON.parseObject(logEntity.getSourceData());
|
||||
JSONObject sourceHeaders = sourceData.getJSONObject("header");//源数据header
|
||||
JSONObject targetHeaders = targetData.getJSONObject("header");//源数据header
|
||||
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();
|
||||
formMainIds.add(sourceBody.getString("id"));
|
||||
JSONObject param = new JSONObject();
|
||||
|
@ -108,20 +111,45 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
|
|||
param.put("formMainIds",formMainIds);
|
||||
param.put("dataSourceCode","ydc_oa_sqlserver");
|
||||
param.put("eventType",sourceBody.getString("eventType"));
|
||||
|
||||
//把返回的单号更新到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 = "";
|
||||
switch (formApp){
|
||||
case "-8691606453890363968"://存货
|
||||
//todo 这里要看一下循环调用的时候 参数是什么样的,再决定
|
||||
sql = "";
|
||||
break;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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();
|
||||
logDetails.setRootAppPk(JSON.toJSONString(param));
|
||||
logDetails.setRootAppBill(hzyaExtData.getString("billCode"));
|
||||
|
@ -151,11 +179,16 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
|
|||
}
|
||||
|
||||
//存货参数组装
|
||||
private SysExtensionApiEntity getInventory(JSONObject businessData,SysExtensionApiEntity param){
|
||||
private SysExtensionApiEntity getInventory(JSONObject businessData,SysExtensionApiEntity param,JSONObject hzyaExtData){
|
||||
if (null != businessData){
|
||||
//物料主表
|
||||
JSONObject formmain0227 = businessData.getJSONObject("formmain_0227");
|
||||
//物料明细表
|
||||
JSONArray formson0228Arr = businessData.getJSONArray("formson_0228");
|
||||
//用来放物料明细表的id
|
||||
List<SysExtensionApiEntity> sysExtensionList = new ArrayList<>();
|
||||
for (int i=0; i< formson0228Arr.size(); i++){
|
||||
SysExtensionApiEntity sysExtensionApiEntity = new SysExtensionApiEntity();
|
||||
JSONObject formson0228 = formson0228Arr.getJSONObject(i);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("Token", "Hzya1314_CheckSkip");
|
||||
|
@ -169,10 +202,17 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
|
|||
//todo 这个没值
|
||||
oArchives.put("cGroupCode", "01");
|
||||
oArchives.put("cComUnitCode", formson0228.getString("field0006"));
|
||||
|
||||
jsonObject.put("oArchives", oArchives);
|
||||
param.setBodys(JSON.toJSONString(jsonObject));
|
||||
sysExtensionApiEntity.setBodys(JSON.toJSONString(jsonObject));
|
||||
JSONObject hzyaExt = new JSONObject();
|
||||
hzyaExt.put("billCode",formson0228.getString("id"));
|
||||
hzyaExt.put("formsonId",formson0228.getString("id"));
|
||||
Map<String,String> headers = new HashMap<>();
|
||||
headers.put("hzyaExtData",JSONObject.toJSONString(hzyaExt));
|
||||
sysExtensionApiEntity.setHeaders(headers);
|
||||
sysExtensionList.add(sysExtensionApiEntity);
|
||||
}
|
||||
param.setList(sysExtensionList);
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
@ -210,7 +250,7 @@ public class SeeyonExtServiceImpl implements ISeeyonExtService {
|
|||
//专管业务员
|
||||
oArchives.put("cVenPPerson",formmain0225.getString("field0016"));
|
||||
//分管部门
|
||||
oArchives.put("cVenDepart","field0013");
|
||||
oArchives.put("cVenDepart",formmain0225.getString("field0013"));
|
||||
jsonObject.put("oArchives", oArchives);
|
||||
param.setBodys(JSON.toJSONString(jsonObject));
|
||||
hzyaExtData.put("billCode", formmain0225.getString("field0001"));
|
||||
|
|
Loading…
Reference in New Issue