calyrex 4.27 和信创建流程接口
parent
9ed47b7c11
commit
3951fc6502
@ -0,0 +1,35 @@
|
|||||||
|
package com.weaver.seconddev.entity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: calyrex
|
||||||
|
* @CreateTime: 2025-04-25
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DataOptions {
|
||||||
|
|
||||||
|
|
||||||
|
private String optionId;
|
||||||
|
|
||||||
|
private Long dataKey;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选项类型
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private Boolean matchByName;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,186 @@
|
|||||||
|
package com.weaver.seconddev.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.weaver.common.hrm.util.Util;
|
||||||
|
import com.weaver.common.i18n.tool.util.I18nContextUtil;
|
||||||
|
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||||
|
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||||
|
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||||
|
import com.weaver.framework.rpc.context.impl.TenantRpcContext;
|
||||||
|
import com.weaver.seconddev.entity.DataOptions;
|
||||||
|
import com.weaver.seconddev.entity.FormDataDuty;
|
||||||
|
import com.weaver.verupgrade.conn.RecordSet;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: calyrex
|
||||||
|
* @CreateTime: 2025-04-25
|
||||||
|
* @Description: 数据操作工具
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class DataOperateUtil {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataSetService dataSetService;
|
||||||
|
|
||||||
|
public List<Long> getDetailFormId(String workflowId) {
|
||||||
|
log.error("getDetailFormId start : " + workflowId );
|
||||||
|
List<Long> formIdList = new ArrayList();
|
||||||
|
String sourceType = String.valueOf(SourceType.LOGIC);
|
||||||
|
String groupId = "weaver-basic-schedule-service";
|
||||||
|
try {
|
||||||
|
String sql = "select form_id from ecology10.dbo.form_table where form_id in (select id from e10_core_business.dbo.sub_form where form_id in (select relatekey from e10_core_business.dbo.wfp_relateform where workflowid = '"+workflowId+"'))";
|
||||||
|
log.info("getConfig sql-->" + sql);
|
||||||
|
Map<String, Object> datas = executeForQuery(sourceType, groupId, sql);
|
||||||
|
// log.info("getConfig datas-->" + datas);
|
||||||
|
if(String.valueOf(datas.get("status")).equals("OK")){
|
||||||
|
List<Map<String,Object>> records = (List<Map<String,Object>>)datas.get("records");
|
||||||
|
for (int i = 0; i < records.size(); i++) {
|
||||||
|
Map<String, Object> map = records.get(i);
|
||||||
|
String formId = map.get("form_id").toString();
|
||||||
|
formIdList.add(Long.valueOf(formId));
|
||||||
|
}
|
||||||
|
return formIdList;
|
||||||
|
}else {
|
||||||
|
log.error("getConfig status-->"+ datas.get("status"));
|
||||||
|
return formIdList;
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("getConfig e--> ",e);
|
||||||
|
return formIdList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfig(String key,String tenantKey){
|
||||||
|
String sourceType = String.valueOf(SourceType.LOGIC);
|
||||||
|
String groupId = "weaver-basic-schedule-service";
|
||||||
|
try {
|
||||||
|
String sql = "select configvalue from ecology10.dbo.uf_config where configkey = '" + key + "' and zhkey = '"+tenantKey+"'";
|
||||||
|
log.info("getConfig sql-->" + sql);
|
||||||
|
Map<String, Object> datas = executeForQuery(sourceType, groupId, sql);
|
||||||
|
// log.info("getConfig datas-->" + datas);
|
||||||
|
if(String.valueOf(datas.get("status")).equals("OK")){
|
||||||
|
List<Map<String,Object>> records = (List<Map<String,Object>>)datas.get("records");
|
||||||
|
Map<String, Object> map = records.get(0);
|
||||||
|
return map.get("config_value").toString();
|
||||||
|
}else {
|
||||||
|
log.error("getConfig status-->"+ datas.get("status"));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("getConfig e--> ",e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql) {
|
||||||
|
// log.info("executeForQuery sourceType-->" + sourceType + ",groupId-->" + groupId + ",sql-->" + sql);
|
||||||
|
TenantRpcContext.setTargetTenantKey("temkc46eme");
|
||||||
|
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||||
|
executeSqlEntity.setSql(cn.hutool.core.codec.Base64.encode(sql));
|
||||||
|
executeSqlEntity.setGroupId(groupId); //groupid,可以访问 E10地址/api/datasource/ds/group?sourceType=LOGIC 获取
|
||||||
|
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||||
|
// log.info("executeForQuery executeSqlEntity-->"+executeSqlEntity.getSql()+"-->"+executeSqlEntity.getGroupId()+"-->"+executeSqlEntity.getSourceType());
|
||||||
|
Map<String, Object> datas = dataSetService.executeSql(executeSqlEntity);
|
||||||
|
// log.info("executeForQuery datas-->" + datas);
|
||||||
|
TenantRpcContext.removeTargetTenantKey();
|
||||||
|
return datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单字段构建
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JSONObject getFromDataByDataDetails(List<FormDataDuty> formDataDutyList) {
|
||||||
|
JSONObject formData = new JSONObject();
|
||||||
|
formData.put("module","workflow");
|
||||||
|
|
||||||
|
JSONArray dataDetails = new JSONArray();
|
||||||
|
formData.put("dataDetails", dataDetails);
|
||||||
|
|
||||||
|
formDataDutyList.forEach(formDataDuty -> {
|
||||||
|
if (formDataDuty.getSubFormId() != null) {
|
||||||
|
//明细表
|
||||||
|
if (formDataDuty.getDataOptions() == null) {
|
||||||
|
//普通字段
|
||||||
|
JSONObject inputDataKey = new JSONObject();
|
||||||
|
inputDataKey.put("dataKey", formDataDuty.getDataKey());
|
||||||
|
inputDataKey.put("dataIndex", formDataDuty.getDataIndex());
|
||||||
|
inputDataKey.put("content", formDataDuty.getContent());
|
||||||
|
inputDataKey.put("subFormId", formDataDuty.getSubFormId());
|
||||||
|
dataDetails.add(inputDataKey);
|
||||||
|
}else {
|
||||||
|
JSONObject details = new JSONObject();
|
||||||
|
dataDetails.add(details);
|
||||||
|
|
||||||
|
JSONArray dataOptions = new JSONArray();
|
||||||
|
details.put("dataKey", formDataDuty.getDataKey());
|
||||||
|
details.put("dataIndex", formDataDuty.getDataIndex());
|
||||||
|
details.put("subFormId", formDataDuty.getSubFormId());
|
||||||
|
|
||||||
|
details.put("dataOptions", dataOptions);
|
||||||
|
List<DataOptions> dataOptions1 = formDataDuty.getDataOptions();
|
||||||
|
dataOptions1.forEach(e -> {
|
||||||
|
JSONObject option = new JSONObject();
|
||||||
|
option.put("optionId", e.getOptionId());
|
||||||
|
dataOptions.add(option);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
//主表
|
||||||
|
if (formDataDuty.getDataOptions() == null) {
|
||||||
|
//普通字段
|
||||||
|
JSONObject inputDataKey = new JSONObject();
|
||||||
|
inputDataKey.put("dataKey", formDataDuty.getDataKey());
|
||||||
|
inputDataKey.put("content", formDataDuty.getContent());
|
||||||
|
dataDetails.add(inputDataKey);
|
||||||
|
}else {
|
||||||
|
//浏览按钮字段
|
||||||
|
// 浏览按钮
|
||||||
|
JSONObject details = new JSONObject();
|
||||||
|
dataDetails.add(details);
|
||||||
|
|
||||||
|
JSONArray dataOptions = new JSONArray();
|
||||||
|
details.put("dataKey", formDataDuty.getDataKey());
|
||||||
|
details.put("dataOptions", dataOptions);
|
||||||
|
|
||||||
|
List<DataOptions> dataOptions1 = formDataDuty.getDataOptions();
|
||||||
|
dataOptions1.forEach(e -> {
|
||||||
|
JSONObject option = new JSONObject();
|
||||||
|
option.put("optionId", e.getOptionId());
|
||||||
|
//fieldType 3为附件
|
||||||
|
if (formDataDuty.getFieldType() == 3) {
|
||||||
|
option.put("content", e.getContent());
|
||||||
|
}
|
||||||
|
dataOptions.add(option);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return formData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String null2String(String s){
|
||||||
|
return s == null ? "" : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String null2String(Object o){
|
||||||
|
return o == null ? "" : o.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String null2String(String s1,String s2){
|
||||||
|
return s1 == null ? (s2 == null ? "" : s2) : s1;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.weaver.seconddev.util;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import okhttp3.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: calyrex
|
||||||
|
* @CreateTime: 2025-04-25
|
||||||
|
* @Description: 接口信息获取工具
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class InterInfoAchieveUtil {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataOperateUtil dataOperateUtil;
|
||||||
|
|
||||||
|
public String getCode(String tenantKey){
|
||||||
|
try {
|
||||||
|
String corpid = dataOperateUtil.null2String(dataOperateUtil.getConfig("corpid",tenantKey));
|
||||||
|
String response_type = "code";
|
||||||
|
String state = "xxx";
|
||||||
|
String url = dataOperateUtil.null2String(dataOperateUtil.getConfig("oa_address",tenantKey)) + "/papi/openapi/oauth2/authorize?corpid=" +
|
||||||
|
corpid + "&response_type=" + response_type + "&state=" + state;
|
||||||
|
String body = HttpRequest.get(url).execute().body();
|
||||||
|
// log.info("getCode body-->" + body);
|
||||||
|
return body;
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("getCode error--> " + e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken(String code,String tenantKey) throws IOException {
|
||||||
|
String app_key = dataOperateUtil.null2String(dataOperateUtil.getConfig("app_key",tenantKey));
|
||||||
|
String app_secret = dataOperateUtil.null2String(dataOperateUtil.getConfig("app_secret",tenantKey));
|
||||||
|
String grant_type = "authorization_code";
|
||||||
|
// JSONObject params = new JSONObject();
|
||||||
|
// params.put("app_key",app_key);
|
||||||
|
// params.put("app_secret",app_secret);
|
||||||
|
// params.put("grant_type",grant_type);
|
||||||
|
// params.put("code",code);
|
||||||
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
|
.build();
|
||||||
|
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
||||||
|
String params = "app_key="+app_key+"&app_secret="+app_secret+"&grant_type="+grant_type+"&code="+code;
|
||||||
|
String url = dataOperateUtil.null2String(dataOperateUtil.getConfig("oa_address",tenantKey)) + "/papi/openapi/oauth2/access_token";
|
||||||
|
// log.info("getToken params-->" + params);
|
||||||
|
RequestBody body = RequestBody.create(mediaType, params);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
.build();
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
return response.body().string();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
package com.weaver.seconddev.webservice;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.weaver.verupgrade.workflow.workflow.WorkflowAllComInfo;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service("demoService")
|
|
||||||
public class DemoService {
|
|
||||||
private final static Logger log = LoggerFactory.getLogger(DemoService.class);
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WorkflowAllComInfo workflowAllComInfo;
|
|
||||||
|
|
||||||
public String demo(String detailTables){
|
|
||||||
log.error("DemoService start");
|
|
||||||
String workcodeId = "100003460000005676";
|
|
||||||
|
|
||||||
String detailTable = detailTables;
|
|
||||||
log.error("detailTable" + detailTables);
|
|
||||||
|
|
||||||
log.error("DemoService end");
|
|
||||||
return detailTable;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue