新增:利元亨现场3方接口交互代码提交

This commit is contained in:
yangyang01000846
2025-12-22 13:41:00 +08:00
parent c7052e0b7e
commit b6a1fff060
13 changed files with 436 additions and 171 deletions

View File

@@ -1,13 +0,0 @@
package com.sdm.outbridge.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sdm.outbridge.entity.ViewLyricconfig;
/**
*
* @author author
* @since 2025-11-05
*/
public interface ViewLyricConfigMapper extends BaseMapper<ViewLyricconfig> {
}

View File

@@ -1,50 +0,0 @@
package com.sdm.outbridge.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* 测试查询视图
* </p>
*
* @author author
* @since 2025-12-01
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("view_lyricconfig")
@Schema(description = "测试查询视图")
public class ViewLyricconfig implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "自增主键")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@Schema(description = "占位符英文名称")
@TableField("keyEnName")
private String keyEnName;
@Schema(description = "占位符中文名称")
@TableField("keyCnName")
private String keyCnName;
@Schema(description = "创建时间")
@TableField(value = "createTime", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonIgnore
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,13 @@
package com.sdm.outbridge.mode;
import lombok.Data;
@Data
public class FreeLinkMsg {
private String id;
private String user;
private String pawd;
private String msg;
private String type;
private String freelinkAppId;
}

View File

@@ -0,0 +1,13 @@
package com.sdm.outbridge.mode;
import lombok.Data;
// 即时通推送消息实体类
@Data
public class FreelinkAndDingdingInformReq {
private String jobNo;
private FreeLinkMsg freeLinkMsg;
}

View File

@@ -0,0 +1,20 @@
package com.sdm.outbridge.mode;
import lombok.Data;
// 对象仅用于http传输
@Data
public class GetProcessDataCondition {
//"conditionColumn": {
// "project_number": "3176",
// "station_no": "02-98",
// "status": "处理中"
// }
private String project_number;
private String station_no;
private String status;
}

View File

@@ -0,0 +1,27 @@
package com.sdm.outbridge.mode;
import lombok.Data;
/*
*
* {
"queryColumn": "flow_inst_id",
"conditionColumn": {
"project_number": "3176",
"station_no": "02-98",
"status": "处理中"
}
}
* */
@Data
public class GetProcessDataReq {
private String jobNo;
private String queryColumn;
private GetProcessDataCondition conditionColumn;
}

View File

@@ -8,36 +8,36 @@ import java.util.List;
@Data
public class HkUploadFileReq {
@Schema(description = "权限编码")
public String filePower = "2456236750149124114";
@Schema(description = "权限编码")
public String filePower = "2456236750149124114";
@Schema(description = "是否加水印")
public boolean waterMarkFlag = false;
@Schema(description = "是否加水印")
public boolean waterMarkFlag = false;
@Schema(description = "水印内容")
public String waterMarkContent = "";
@Schema(description = "水印内容")
public String waterMarkContent = "";
@Schema(description = "系统ID")
public long sysId = 1691399963692630016L;
@Schema(description = "系统ID")
public long sysId = 1691399963692630016L;
@Schema(description = "表单ID")
public long formId = 1847115435993071616L;
@Schema(description = "表单ID")
public long formId = 1847115435993071616L;
@Schema(description = "控件ID")
public long componentInstId = 8000004142460000204L;
@Schema(description = "控件ID")
public long componentInstId = 8000004142460000204L;
@Schema(description = "表名称")
public String tableName = "oa_threee_d_review";
@Schema(description = "表名称")
public String tableName = "oa_threee_d_review";
@Schema(description = "字段名称")
public String columnName = "simulation_table;";
@Schema(description = "字段名称")
public String columnName = "simulation_table;";
@Schema(description = "项目号")
public String xmh = "";
@Schema(description = "项目号")
public String xmh = "";
@Schema(description = "工位号")
public String gwh = "";
@Schema(description = "工位号")
public String gwh = "";
@Schema(description = "上传文件")
public List<String> files = new ArrayList<String>();
@Schema(description = "上传文件")
public List<String> files = new ArrayList<String>();
}

View File

@@ -1,11 +0,0 @@
package com.sdm.outbridge.service.impl.lyric;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdm.outbridge.dao.ViewLyricConfigMapper;
import com.sdm.outbridge.entity.ViewLyricconfig;
import com.sdm.outbridge.service.lyric.IViewLyricConfigService;
import org.springframework.stereotype.Service;
@Service
public class ViewLyricConfigServiceImpl extends ServiceImpl<ViewLyricConfigMapper, ViewLyricconfig> implements IViewLyricConfigService {
}

View File

@@ -1,8 +0,0 @@
package com.sdm.outbridge.service.lyric;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sdm.outbridge.entity.ViewLyricconfig;
/* 这个接口只是测试的 */
public interface IViewLyricConfigService extends IService<ViewLyricconfig> {
}

View File

@@ -6,8 +6,13 @@ import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.utils.HttpUtil;
import com.sdm.outbridge.mode.FreeLinkMsg;
import com.sdm.outbridge.mode.FreelinkAndDingdingInformReq;
import com.sdm.outbridge.mode.GetProcessDataReq;
import com.sdm.outbridge.mode.HkUploadFileReq;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
@@ -19,6 +24,7 @@ import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
@@ -36,9 +42,8 @@ import java.sql.*;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service
@Slf4j
@@ -63,6 +68,9 @@ public class LyricIntegrateService {
//海葵云上传文件url后缀
@Value("${HK_UPLOAD_FILE_URL_SUFFIX}")
private String HK_UPLOAD_FILE_URL_SUFFIX;
//根据项目工位获取流程实例号url后缀
@Value("${HK_GET_PROCESS_DATA_SUFFIX}")
private String HK_GET_PROCESS_DATA_SUFFIX;
//EP系统URL
@Value("${EP_URL}")
private String EP_URL;
@@ -76,6 +84,14 @@ public class LyricIntegrateService {
@Value("${QUERY_TOD_ATTACHMENT_SUFFIX}")
private String QUERY_TOD_ATTACHMENT_SUFFIX;
// 即时通url
@Value("${FREELINK_URL}")
private String FREELINK_URL;
// 即时通推送消息url后缀
@Value("${FREELINK_PUSH_MSG_SUFFIX}")
private String FREELINK_PUSH_MSG_SUFFIX;
//生产环境
/**
@@ -122,15 +138,12 @@ public class LyricIntegrateService {
}
/**
* 获取根据工号获取用户token
*
* @param appKey
* @param appSecret
* 1. 获取根据工号获取用户token
* @param jobNo
* @param tokenUrl
* @return
*/
public String getHKCloudToken(String appKey, String appSecret, String jobNo, String tokenUrl) {
public String getHKCloudToken( String jobNo) {
String tokenUrl = HK_CLOUD_URL + HK_USER_TOKEN_URL_SUFFIX;
JSONObject jsonObject = new JSONObject();
jsonObject.put("appKey", appKey);
jsonObject.put("jobNo", jobNo);
@@ -142,7 +155,9 @@ public class LyricIntegrateService {
paramObject.put("appKey", appKey);
paramObject.put("sign", sign);
try {
String result = HttpUtil.httpPost(tokenUrl, null, jsonObject.toJSONString());
HashMap<String, String> headerMap = new HashMap<>();
headerMap.put("Content-Type","application/json");
String result = HttpUtil.httpPost(tokenUrl, headerMap, paramObject.toJSONString());
JSONObject resultJson = JSONObject.parseObject(result);
String code = resultJson.getString("code");
if (code.equals("0000")) {
@@ -158,15 +173,14 @@ public class LyricIntegrateService {
}
/**
* 获取当前用户的
* 2. 获取当前用户的信息
*
* @param jobNo
* @return
*/
public SdmResponse getHKCloudSimpleUserInfo(String jobNo) {
SdmResponse response = SdmResponse.success();
String tokenUrl = HK_CLOUD_URL + HK_USER_TOKEN_URL_SUFFIX;
String token = getHKCloudToken(appKey, appSecret, jobNo, tokenUrl);
String token = getHKCloudToken(jobNo);
if (token == null || token.isEmpty()) {
response = SdmResponse.failed("获取海葵云token失败");
} else {
@@ -227,8 +241,9 @@ public class LyricIntegrateService {
}
}
/**
* 上传仿真报告
* 3. 上传仿真报告
*
* @param jobNo
* @param hkUploadFileReq
@@ -236,20 +251,24 @@ public class LyricIntegrateService {
*/
public SdmResponse uploadHkFile(String jobNo, HkUploadFileReq hkUploadFileReq) {
SdmResponse response = SdmResponse.failed("文件上传失败");
String token = getHKCloudToken(appKey, appSecret, jobNo, HK_CLOUD_URL);
String token = getHKCloudToken( jobNo);
if (token == null || token.isEmpty())
{
response = SdmResponse.failed("获取token失败");
}
else
{
Map<String, String> headers = new HashMap<String, String>();
// headers.put("Content-Type","multipart/form-data");
headers.put("authorization", token);
String url = HK_CLOUD_URL + HK_UPLOAD_FILE_URL_SUFFIX;
HttpPost httpPost = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create()
.setCharset(StandardCharsets.UTF_8); // 解决中文乱码
// 添加普通参数
builder.addPart("filePower", new StringBody(hkUploadFileReq.filePower,
builder.addPart("filePower", new StringBody(hkUploadFileReq.getFilePower(),
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
builder.addPart("waterMarkFlag", new StringBody(String.valueOf(hkUploadFileReq.waterMarkFlag),
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
@@ -259,7 +278,7 @@ public class LyricIntegrateService {
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
builder.addPart("formId", new StringBody(String.valueOf(hkUploadFileReq.formId),
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
builder.addPart("ComponentInstId", new StringBody(String.valueOf(hkUploadFileReq.componentInstId),
builder.addPart("componentInstId", new StringBody(String.valueOf(hkUploadFileReq.componentInstId),
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
builder.addPart("tableName", new StringBody(hkUploadFileReq.tableName,
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
@@ -271,10 +290,16 @@ public class LyricIntegrateService {
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
// 追加多个文件同一字段名files
for (String filePath : hkUploadFileReq.files) {
for (String filePath : hkUploadFileReq.getFiles()) {
File file = new File(filePath);
if (file.exists())
builder.addPart("files", new FileBody(file, ContentType.DEFAULT_BINARY, file.getName()));
builder.addPart("files", new FileBody(file));
}
// 头请求设置
if (MapUtils.isNotEmpty(headers)) {
for (String key : headers.keySet()) {
httpPost.addHeader(key, headers.get(key));
}
}
// 构建HttpPost请求
@@ -284,16 +309,18 @@ public class LyricIntegrateService {
CloseableHttpClient httpclient = createHttpsClient();
CloseableHttpResponse fileResponse = httpclient.execute(httpPost);
String responseContent = EntityUtils.toString(fileResponse.getEntity(), StandardCharsets.UTF_8);
log.info("调用海葵云oa返回{}",responseContent);
if(responseContent != null && !responseContent.isEmpty())
{
JSONObject responseJson = JSONObject.parseObject(responseContent);
if(responseJson.containsKey("code"))
String code = responseJson.getString("code");
if(code != null && code.equals("0000"))
{
String code = responseJson.getString("code");
if(code != null && code.equals("0000"))
{
response = SdmResponse.success();
}
response = SdmResponse.success();
}else {
Object message = responseJson.get("message");
String msgStr = Objects.isNull(message)?"":message.toString();
response = SdmResponse.failed("上传oa文件失败,"+msgStr);
}
}
}
@@ -301,11 +328,108 @@ public class LyricIntegrateService {
{
e.printStackTrace();
response = SdmResponse.failed("上传文件异常");
log.error("上传文件异常:{}",e.getMessage());
}
}
return response;
}
/**
* 4.根据项目工号获取
{
"queryColumn": "flow_inst_id",
"conditionColumn": {
"project_number": "3176",
"station_no": "02-98",
"status": "处理中"
}
}
* @return
*/
public SdmResponse getProcessData(GetProcessDataReq req){
SdmResponse response = SdmResponse.success();
String token = getHKCloudToken(req.getJobNo());
if (token == null || token.isEmpty()) {
return SdmResponse.failed("获取海葵云token失败");
}
String getProcessDataUrl=HK_CLOUD_URL+HK_GET_PROCESS_DATA_SUFFIX;
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Content-Type","application/json");
headerMap.put("authorization", token);
try {
String result = HttpUtil.httpPost(getProcessDataUrl, headerMap, JSONObject.toJSONString(req));
JSONObject resultJson = JSONObject.parseObject(result);
String code = resultJson.getString("code");
if (code.equals("0000")) {
Object data = resultJson.get("data");
if (data != null) {
response.setData(data);
}
} else {
response = SdmResponse.failed("根据项目工位获取流程实例号失败");
log.warn("根据项目工位获取流程实例号失败,返回:{},入参:{}",result,JSONObject.toJSONString(req));
}
} catch (Exception e) {
e.printStackTrace();
log.warn("根据项目工位获取流程实例号异常,返回:{},入参:{}",JSONObject.toJSONString(req));
response = SdmResponse.failed("根据项目工位获取流程实例号异常");
}
return response;
}
/**
* 5.推送即时通消息
* @return
*/
public SdmResponse pushFreeLinkMsg(FreelinkAndDingdingInformReq req){
SdmResponse response = SdmResponse.success();
String token = getHKCloudToken(req.getJobNo());
if (token == null || token.isEmpty()) {
return SdmResponse.failed("获取海葵云token失败");
}
FreeLinkMsg freeLinkMsg = req.getFreeLinkMsg();
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("id",freeLinkMsg.getId()));
params.add(new BasicNameValuePair("user",freeLinkMsg.getUser()));
params.add(new BasicNameValuePair("pawd",freeLinkMsg.getPawd()));
params.add(new BasicNameValuePair("msg",freeLinkMsg.getMsg()));
params.add(new BasicNameValuePair("type",freeLinkMsg.getType()));
params.add(new BasicNameValuePair("freelinkAppId",freeLinkMsg.getFreelinkAppId()));
String getProcessDataUrl=FREELINK_URL+FREELINK_PUSH_MSG_SUFFIX;
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Content-Type","application/x-www-form-urlencoded");
headerMap.put("authorization", token);
try {
String result = HttpUtil.httpPostForm(getProcessDataUrl, headerMap, params);
JSONObject resultJson = JSONObject.parseObject(result);
Object code = resultJson.get("code");
if (Objects.equals(code,0)||Objects.equals(code,"0")) {
Object msgObject = resultJson.get("msg");
if (msgObject != null) {
response.setData(msgObject);
}
} else {
response = SdmResponse.failed("推送即时通消息失败");
log.warn("推送即时通消息失败,返回:{},入参:{}",result,JSONObject.toJSONString(req));
}
} catch (Exception e) {
e.printStackTrace();
log.warn("根推送即时通消息异常,返回:{},入参:{}",JSONObject.toJSONString(req));
response = SdmResponse.failed("根推送即时通消息异常");
}
return response;
}
/**
* 推送代办状态
* @param todoId
@@ -351,19 +475,24 @@ public class LyricIntegrateService {
}
/**
* 查询待办附件
* 6. 查询待办附件
* @param todoId
* @return
*/
public SdmResponse queryTodoAttachments(int todoId)
public SdmResponse queryTodoAttachments(Integer todoId)
{
SdmResponse response = SdmResponse.failed("获取待办附件失败");
String url = EP_URL+QUERY_TOD_ATTACHMENT_SUFFIX+"?todoId="+todoId;
// String url = EP_URL+QUERY_TOD_ATTACHMENT_SUFFIX+"?todoId="+todoId;
String url = EP_URL+QUERY_TOD_ATTACHMENT_SUFFIX;
Map<String,String> header = new HashMap<>();
header.put("Content-Type","application/x-www-form-urlencoded");
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("todoId",String.valueOf(todoId)));
try
{
String result = HttpUtil.httpPost(url, header, "");
String result = HttpUtil.httpPostForm(url, header, params);
if(result != null && !result.isEmpty())
{
JSONObject responseJson = JSONObject.parseObject(result);
@@ -372,7 +501,6 @@ public class LyricIntegrateService {
JSONArray data = responseJson.getJSONArray("data");
response = SdmResponse.success();
response.setData(data);
}
}
}

View File

@@ -1,12 +1,10 @@
spring:
application:
name: pbs
datasource:
second:
username: root
password: mysql
jdbc-url: jdbc:mysql://192.168.65.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
second:
username: root
password: mysql
jdbc-url: jdbc:mysql://192.168.65.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
# 测试开发环境
#appKey : 380ad3deb578424c9ca5178383f732c1
@@ -18,23 +16,29 @@ appKey : e9eb516aa02a43a29e227a0d901ec5f1
appSecret : 9fac43db08634aaf8a9fe5fb9468de9d
# 海葵云url
HK_CLOUD_URL : https://url.lyhhaikuicloud.com
# 海葵云获取用户token url后缀
# 1. 海葵云获取用户token url后缀
HK_USER_TOKEN_URL_SUFFIX : /merchant/openapi/user/login/jobNo
# 海葵云获取单个用户信息url后缀
# 2. 海葵云获取单个用户信息url后缀
HK_SIMPLE_USER_URL_SUFFIX : /merchant/api/user/getSimpleUserInfo
# 海葵云上传文件url后缀
# 3. 海葵云上传文件url后缀
HK_UPLOAD_FILE_URL_SUFFIX : /haikui-oa/autoCreateFlow/uploadFile
# 获取项目工位实例号
HK_GET_PROCESS_DATA_SUFFIX: todo
# EP系统URL
EP_URL : https://ep-url.dev.haikuicloud.com
# 推送代办状态url后缀
#EP_URL : https://ep-url.dev.haikuicloud.com
# 开发环境
EP_URL : https://ep-url-test.lyh.haikuicloud.com
# 推送代办状态url后缀 todo不用
QUERY_TODO_STATUS_SUFFIX : /todoApi/todo/emulation/dm/status
# 查询待办结果url后缀
# 查询待办结果url后缀 todo不用
QUERY_TODO_RESULT_SUFFIX : /todoApi/todo/emulation/dm/result
# 查询待办附加url后缀
# 6. 查询待办附加url后缀
QUERY_TOD_ATTACHMENT_SUFFIX : /todoApi/todo/emulation/dm/attachments
# 即时通消息通知
freeLinkUrl: http://freelink.haihui.com/wechat/InformApi/FreelinkAndDingdingInform
# 即时通url
FREELINK_URL: http://freelink.haikui.com
FREELINK_PUSH_MSG_SUFFIX: /webchat/InformApi/FreelinkAndDingdingInform
# 海葵云 数据库连接
URL : jdbc:mysql://127.0.0.1:3306/spdm_baseline?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true