新增:利元亨现场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,9 +1,13 @@
package com.sdm.common.utils; package com.sdm.common.utils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.Consts;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig; import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
@@ -14,6 +18,7 @@ import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustAllStrategy;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
@@ -28,11 +33,13 @@ import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.KeyStoreException; import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.List;
import java.util.Map; import java.util.Map;
@Slf4j @Slf4j
@@ -44,7 +51,7 @@ public class HttpUtil {
public static CloseableHttpClient createSSLClientDefault() throws Exception { public static CloseableHttpClient createSSLClientDefault() throws Exception {
//信任所有 //信任所有
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), NoopHostnameVerifier.INSTANCE SSLContexts.custom().loadTrustMaterial(null, new TrustAllStrategy()).build(), NoopHostnameVerifier.INSTANCE
); );
//创建自定义连接套接字工厂的注册表以支持 //创建自定义连接套接字工厂的注册表以支持
//协议方案。 //协议方案。
@@ -438,8 +445,7 @@ public class HttpUtil {
try { try {
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
//设置header //设置header
// httpPost.setHeader("Content-Type", "application/json"); if (MapUtils.isNotEmpty(headers)) {
if (headers.size() > 0) {
for (String key : headers.keySet()) { for (String key : headers.keySet()) {
httpPost.addHeader(key, headers.get(key)); httpPost.addHeader(key, headers.get(key));
} }
@@ -472,4 +478,50 @@ public class HttpUtil {
} }
return result; return result;
} }
public static String httpPostForm(String url, Map<String, String> headers, List<NameValuePair> params) throws Exception {
if (httpclient == null) {
httpclient = createSSLClientDefault();
}
CloseableHttpClient hp = httpclient;
CloseableHttpResponse response = null;
String result = "";
try {
HttpPost httpPost = new HttpPost(url);
//设置header
if (MapUtils.isNotEmpty(headers)) {
for (String key : headers.keySet()) {
httpPost.addHeader(key, headers.get(key));
}
}
//填充参数
UrlEncodedFormEntity paramEntity = new UrlEncodedFormEntity(params, Consts.UTF_8);
httpPost.setEntity(paramEntity);
//发起请求
response = hp.execute(httpPost);
HttpEntity entity = response.getEntity();
result = EntityUtils.toString(entity, "UTF-8");
//处理返回结果
if (response.getStatusLine().getStatusCode() < 200 || response.getStatusLine().getStatusCode() > 300) {
throw new Exception(result);
}
EntityUtils.consume(entity);
} catch (IOException e) {
log.error("httpclient IO error:" + e);
result = e.toString();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
response.close();
} catch (IOException e) {
log.error("释放response错误");
e.printStackTrace();
}
}
hp.close();
}
return result;
}
} }

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 @Data
public class HkUploadFileReq { public class HkUploadFileReq {
@Schema(description = "权限编码") @Schema(description = "权限编码")
public String filePower = "2456236750149124114"; public String filePower = "2456236750149124114";
@Schema(description = "是否加水印") @Schema(description = "是否加水印")
public boolean waterMarkFlag = false; public boolean waterMarkFlag = false;
@Schema(description = "水印内容") @Schema(description = "水印内容")
public String waterMarkContent = ""; public String waterMarkContent = "";
@Schema(description = "系统ID") @Schema(description = "系统ID")
public long sysId = 1691399963692630016L; public long sysId = 1691399963692630016L;
@Schema(description = "表单ID") @Schema(description = "表单ID")
public long formId = 1847115435993071616L; public long formId = 1847115435993071616L;
@Schema(description = "控件ID") @Schema(description = "控件ID")
public long componentInstId = 8000004142460000204L; public long componentInstId = 8000004142460000204L;
@Schema(description = "表名称") @Schema(description = "表名称")
public String tableName = "oa_threee_d_review"; public String tableName = "oa_threee_d_review";
@Schema(description = "字段名称") @Schema(description = "字段名称")
public String columnName = "simulation_table;"; public String columnName = "simulation_table;";
@Schema(description = "项目号") @Schema(description = "项目号")
public String xmh = ""; public String xmh = "";
@Schema(description = "工位号") @Schema(description = "工位号")
public String gwh = ""; public String gwh = "";
@Schema(description = "上传文件") @Schema(description = "上传文件")
public List<String> files = new ArrayList<String>(); 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.alibaba.fastjson2.JSONWriter;
import com.sdm.common.common.SdmResponse; import com.sdm.common.common.SdmResponse;
import com.sdm.common.utils.HttpUtil; 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 com.sdm.outbridge.mode.HkUploadFileReq;
import lombok.extern.slf4j.Slf4j; 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.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost; 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.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -36,9 +42,8 @@ import java.sql.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service @Service
@Slf4j @Slf4j
@@ -63,6 +68,9 @@ public class LyricIntegrateService {
//海葵云上传文件url后缀 //海葵云上传文件url后缀
@Value("${HK_UPLOAD_FILE_URL_SUFFIX}") @Value("${HK_UPLOAD_FILE_URL_SUFFIX}")
private String 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 //EP系统URL
@Value("${EP_URL}") @Value("${EP_URL}")
private String EP_URL; private String EP_URL;
@@ -76,6 +84,14 @@ public class LyricIntegrateService {
@Value("${QUERY_TOD_ATTACHMENT_SUFFIX}") @Value("${QUERY_TOD_ATTACHMENT_SUFFIX}")
private String 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 * 1. 获取根据工号获取用户token
*
* @param appKey
* @param appSecret
* @param jobNo * @param jobNo
* @param tokenUrl
* @return * @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 jsonObject = new JSONObject();
jsonObject.put("appKey", appKey); jsonObject.put("appKey", appKey);
jsonObject.put("jobNo", jobNo); jsonObject.put("jobNo", jobNo);
@@ -142,7 +155,9 @@ public class LyricIntegrateService {
paramObject.put("appKey", appKey); paramObject.put("appKey", appKey);
paramObject.put("sign", sign); paramObject.put("sign", sign);
try { 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); JSONObject resultJson = JSONObject.parseObject(result);
String code = resultJson.getString("code"); String code = resultJson.getString("code");
if (code.equals("0000")) { if (code.equals("0000")) {
@@ -158,15 +173,14 @@ public class LyricIntegrateService {
} }
/** /**
* 获取当前用户的 * 2. 获取当前用户的信息
* *
* @param jobNo * @param jobNo
* @return * @return
*/ */
public SdmResponse getHKCloudSimpleUserInfo(String jobNo) { public SdmResponse getHKCloudSimpleUserInfo(String jobNo) {
SdmResponse response = SdmResponse.success(); SdmResponse response = SdmResponse.success();
String tokenUrl = HK_CLOUD_URL + HK_USER_TOKEN_URL_SUFFIX; String token = getHKCloudToken(jobNo);
String token = getHKCloudToken(appKey, appSecret, jobNo, tokenUrl);
if (token == null || token.isEmpty()) { if (token == null || token.isEmpty()) {
response = SdmResponse.failed("获取海葵云token失败"); response = SdmResponse.failed("获取海葵云token失败");
} else { } else {
@@ -227,8 +241,9 @@ public class LyricIntegrateService {
} }
} }
/** /**
* 上传仿真报告 * 3. 上传仿真报告
* *
* @param jobNo * @param jobNo
* @param hkUploadFileReq * @param hkUploadFileReq
@@ -236,20 +251,24 @@ public class LyricIntegrateService {
*/ */
public SdmResponse uploadHkFile(String jobNo, HkUploadFileReq hkUploadFileReq) { public SdmResponse uploadHkFile(String jobNo, HkUploadFileReq hkUploadFileReq) {
SdmResponse response = SdmResponse.failed("文件上传失败"); SdmResponse response = SdmResponse.failed("文件上传失败");
String token = getHKCloudToken(appKey, appSecret, jobNo, HK_CLOUD_URL); String token = getHKCloudToken( jobNo);
if (token == null || token.isEmpty()) if (token == null || token.isEmpty())
{ {
response = SdmResponse.failed("获取token失败"); response = SdmResponse.failed("获取token失败");
} }
else 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; String url = HK_CLOUD_URL + HK_UPLOAD_FILE_URL_SUFFIX;
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create() MultipartEntityBuilder builder = MultipartEntityBuilder.create()
.setCharset(StandardCharsets.UTF_8); // 解决中文乱码 .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))); ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
builder.addPart("waterMarkFlag", new StringBody(String.valueOf(hkUploadFileReq.waterMarkFlag), builder.addPart("waterMarkFlag", new StringBody(String.valueOf(hkUploadFileReq.waterMarkFlag),
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8))); ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
@@ -259,7 +278,7 @@ public class LyricIntegrateService {
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8))); ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
builder.addPart("formId", new StringBody(String.valueOf(hkUploadFileReq.formId), builder.addPart("formId", new StringBody(String.valueOf(hkUploadFileReq.formId),
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8))); 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))); ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
builder.addPart("tableName", new StringBody(hkUploadFileReq.tableName, builder.addPart("tableName", new StringBody(hkUploadFileReq.tableName,
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8))); ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
@@ -271,10 +290,16 @@ public class LyricIntegrateService {
ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8))); ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8)));
// 追加多个文件同一字段名files // 追加多个文件同一字段名files
for (String filePath : hkUploadFileReq.files) { for (String filePath : hkUploadFileReq.getFiles()) {
File file = new File(filePath); File file = new File(filePath);
if (file.exists()) 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请求 // 构建HttpPost请求
@@ -284,16 +309,18 @@ public class LyricIntegrateService {
CloseableHttpClient httpclient = createHttpsClient(); CloseableHttpClient httpclient = createHttpsClient();
CloseableHttpResponse fileResponse = httpclient.execute(httpPost); CloseableHttpResponse fileResponse = httpclient.execute(httpPost);
String responseContent = EntityUtils.toString(fileResponse.getEntity(), StandardCharsets.UTF_8); String responseContent = EntityUtils.toString(fileResponse.getEntity(), StandardCharsets.UTF_8);
log.info("调用海葵云oa返回{}",responseContent);
if(responseContent != null && !responseContent.isEmpty()) if(responseContent != null && !responseContent.isEmpty())
{ {
JSONObject responseJson = JSONObject.parseObject(responseContent); 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"); response = SdmResponse.success();
if(code != null && code.equals("0000")) }else {
{ Object message = responseJson.get("message");
response = SdmResponse.success(); String msgStr = Objects.isNull(message)?"":message.toString();
} response = SdmResponse.failed("上传oa文件失败,"+msgStr);
} }
} }
} }
@@ -301,11 +328,108 @@ public class LyricIntegrateService {
{ {
e.printStackTrace(); e.printStackTrace();
response = SdmResponse.failed("上传文件异常"); response = SdmResponse.failed("上传文件异常");
log.error("上传文件异常:{}",e.getMessage());
} }
} }
return response; 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 * @param todoId
@@ -351,19 +475,24 @@ public class LyricIntegrateService {
} }
/** /**
* 查询待办附件 * 6. 查询待办附件
* @param todoId * @param todoId
* @return * @return
*/ */
public SdmResponse queryTodoAttachments(int todoId) public SdmResponse queryTodoAttachments(Integer todoId)
{ {
SdmResponse response = SdmResponse.failed("获取待办附件失败"); 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<>(); Map<String,String> header = new HashMap<>();
header.put("Content-Type","application/x-www-form-urlencoded"); header.put("Content-Type","application/x-www-form-urlencoded");
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("todoId",String.valueOf(todoId)));
try try
{ {
String result = HttpUtil.httpPost(url, header, ""); String result = HttpUtil.httpPostForm(url, header, params);
if(result != null && !result.isEmpty()) if(result != null && !result.isEmpty())
{ {
JSONObject responseJson = JSONObject.parseObject(result); JSONObject responseJson = JSONObject.parseObject(result);
@@ -372,7 +501,6 @@ public class LyricIntegrateService {
JSONArray data = responseJson.getJSONArray("data"); JSONArray data = responseJson.getJSONArray("data");
response = SdmResponse.success(); response = SdmResponse.success();
response.setData(data); response.setData(data);
} }
} }
} }

View File

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

View File

@@ -1,18 +1,19 @@
package com.sdm.pbs.controller; package com.sdm.pbs.controller;
import com.alibaba.fastjson2.JSONObject;
import com.sdm.common.common.SdmResponse; import com.sdm.common.common.SdmResponse;
import com.sdm.outbridge.entity.ViewLyricconfig; import com.sdm.outbridge.mode.FreelinkAndDingdingInformReq;
import com.sdm.outbridge.service.lyric.IViewLyricConfigService; import com.sdm.outbridge.mode.GetProcessDataReq;
import com.sdm.pbs.model.entity.SimulationCommandPlaceholder; import com.sdm.outbridge.mode.HkUploadFileReq;
import com.sdm.pbs.service.ISimulationCommandPlaceholderService; import com.sdm.outbridge.service.lyric.LyricIntegrateService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@RestController @RestController
@@ -20,24 +21,113 @@ import java.util.List;
@Tag(name = "测试外部模块系统交互", description = "测试外部模块系统交互") @Tag(name = "测试外部模块系统交互", description = "测试外部模块系统交互")
public class TestSecondDbController { public class TestSecondDbController {
/*利元亨现场对接接口方法*/
@Autowired @Autowired
private ISimulationCommandPlaceholderService simulationCommandPlaceholderService; private LyricIntegrateService lyricIntegrateService;
@Autowired
private IViewLyricConfigService viewLyricConfigService;
@GetMapping("/testSec") // mock
@Operation(summary = "测试多数据源") @PostMapping("/getHkUserInfo")
public SdmResponse<String> testSec() { @Operation(summary = "mock获取海葵用户信息")
// 查询主数据源 public SdmResponse getHkUserInfo(@RequestBody Map<String,Object> map) {
List<SimulationCommandPlaceholder> placeholders = simulationCommandPlaceholderService.lambdaQuery().list(); String jobNo = map.get("jobNo").toString();
// 查询从数据源 SdmResponse hkCloudSimpleUserInfo = lyricIntegrateService.getHKCloudSimpleUserInfo(jobNo);
List<ViewLyricconfig> seconds = viewLyricConfigService.lambdaQuery().list(); return hkCloudSimpleUserInfo;
System.out.println(JSONObject.toJSONString(placeholders)); }
System.out.println(JSONObject.toJSONString(seconds));
return SdmResponse.success(JSONObject.toJSONString(seconds)); @PostMapping("/uploadHkFile")
@Operation(summary = "mock上传海葵文件")
public SdmResponse uploadHkFile(@RequestBody Map<String,Object> map) {
// todo mock
HkUploadFileReq mockReq = new HkUploadFileReq();
mockReq.setFilePower("2456236750149124114");
mockReq.setWaterMarkFlag(false);
mockReq.setWaterMarkContent("spdm");
mockReq.setSysId(1691399963692630016L);
mockReq.setFormId(1847115435993071616L);
mockReq.setComponentInstId(8000004142460000204L);
mockReq.setTableName("oa_three_d_review");
mockReq.setColumnName("simulation_table");
//上面的暂时定就传上面mock的参数。下面是项目号和工位号jobNo,上传的文件压缩成zip的 根据实际情况赋值
mockReq.setXmh("3176");
mockReq.setGwh("02-98");
String jobNo = map.get("jobNo").toString();
List<String> files = new ArrayList<>();
files.add("D:\\PTC\\01-spdm\\spdmTest1220.zip");
mockReq.setFiles(files);
SdmResponse sdmResponse = lyricIntegrateService.uploadHkFile(jobNo, mockReq);
return sdmResponse;
}
@PostMapping("/getProcessData")
@Operation(summary = "mock获取工位流程实列号")
public SdmResponse getProcessData(@RequestBody GetProcessDataReq req ) {
SdmResponse sdmResponse = lyricIntegrateService.getProcessData(req);
return sdmResponse;
} }
@PostMapping("/pushFreeLinkMsg")
@Operation(summary = "mock推送消息")
public SdmResponse pushFreeLinkMsg(@RequestBody FreelinkAndDingdingInformReq req ) {
SdmResponse sdmResponse = lyricIntegrateService.pushFreeLinkMsg(req);
return sdmResponse;
}
@PostMapping("/queryTodoAttachments")
@Operation(summary = "mock查询代办附件")
public SdmResponse queryTodoAttachments(@RequestBody Map map ) {
Integer todoId = (Integer) map.get("todoId");
SdmResponse sdmResponse = lyricIntegrateService.queryTodoAttachments(todoId);
return sdmResponse;
}
// /*现场查询视图的方法mock */
// @GetMapping("/getTodoInfoDm") no usages
// @Operation(summary = "查询代办")
// public SdmResponse<List<LyricVTodoEmulationInfoDM>> getTodoInfoDm() {
// // 查询从数据源
// List<LyricVTodoEmulationInfoDM> todoInfoList = lyricVTodoInfoService.lambdaQuery().last(lastSql: "limit 2").list();
// return SdmResponse.success(todoInfoList);
// }
//
// @GetMapping("/getPdtDm") no usages
// @Operation(summary = "查询项目Pdt")
// public SdmResponse<List<LyricVPdtToDM>> getPdtDm() {
// // 查询从数据源
// List<LyricVPdtToDM> lyricVPdtToDMList = LyricVPdtDmService.lambdaQuery().last(lastSql: "limit 2").list();
// return SdmResponse.success(lyricVPdtToDMList);
// }
//
// @GetMapping("/getMain") no usages
// @Operation(summary = "查询主计划")
// public SdmResponse<List<LyricVMainPlanDM>> getMain() {
// // 查询从数据源
// List<LyricVMainPlanDM> mainPlanDMSList = lyricVMainPlanDMService.lambdaQuery().last(lastSql: "limit 2").list();
// return SdmResponse.success(mainPlanDMSList);
// }
//
// @GetMapping("/getProductLine") no usages
// @Operation(summary = "查询产线信息")
// public SdmResponse<List<LyricVProductionLineToDM>> getProductLine() {
// // 查询从数据源
// List<LyricVProductionLineToDM> productionLineToDMList = lyricVProductionLineToDmService
// .lambdaQuery().last(lastSql: "limit 2").list();
// return SdmResponse.success(productionLineToDMList);
// }
//
// @GetMapping("/getProjectInfo") no usages
// @Operation(summary = "查询项目信息")
// public SdmResponse<List<LyricVProjectToDM>> getProjectInfo() {
// // 查询从数据源
// List<LyricVProjectToDM> projectToDmList = LyricVProjectToDmService
// .lambdaQuery().last(lastSql: "limit 3").list();
// return SdmResponse.success(projectToDmList);
// }
} }