2026-03-07三峡旅游流程集成功能demo功能完成上传
This commit is contained in:
@@ -51,7 +51,6 @@ public class FineReportesso extends BaseController {
|
||||
log.info(url);
|
||||
response.sendRedirect(url);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ import com.seeyon.apps.src_flowIntegration.util.AesUtil;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.controller.BaseController;
|
||||
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
|
||||
import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import www.seeyon.com.utils.StringUtil;
|
||||
@@ -25,7 +23,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class FormRedirectController extends BaseController {
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.seeyon.apps.src_flowIntegration.controller;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.seeyon.apps.addressbook.manager.AddressBookCustomerFieldInfoManager;
|
||||
import com.seeyon.apps.addressbook.po.AddressBook;
|
||||
import com.seeyon.apps.common.config.ICstConfigApi;
|
||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||
import com.seeyon.apps.src_flowIntegration.config.FlowIntegrationConfigProvider;
|
||||
import com.seeyon.apps.src_flowIntegration.constants.FlowIntegrationConstants;
|
||||
import com.seeyon.apps.src_flowIntegration.dao.SrcFlowDao;
|
||||
import com.seeyon.apps.src_flowIntegration.util.AddressBookUtil;
|
||||
import com.seeyon.apps.src_flowIntegration.util.AesUtil;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.controller.BaseController;
|
||||
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import www.seeyon.com.utils.StringUtil;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class URLSkipController extends BaseController {
|
||||
|
||||
private static Log log = Log.get(URLSkipController.class);
|
||||
|
||||
@Inject
|
||||
private AddressBookCustomerFieldInfoManager addressBookCustomerFieldInfoManager;
|
||||
@Inject
|
||||
private SrcFlowDao srcFlowDao;
|
||||
@Autowired
|
||||
private FlowIntegrationConfigProvider configProvider;
|
||||
@Inject
|
||||
private EnumManager enumManagerNew;
|
||||
protected ICstConfigApi cstConfigApi = (ICstConfigApi) AppContext.getBean("cstConfigApi");
|
||||
|
||||
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
// String thirdPartyFlowId = request.getParameter("thirdPartyFlowId");//第三方系统流程ID
|
||||
String thirdPartyCode = request.getParameter("thirdPartyCode");//第三方系统编码
|
||||
String tableName = request.getParameter("tableName");//表单名称
|
||||
String recordId = request.getParameter("recordId");//按钮对应行ID
|
||||
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
System.out.println("进入表单跳转方法");
|
||||
ConfigVo config = cstConfigApi.getConfig(FlowIntegrationConstants.getPluginId());
|
||||
// 表单连接跳转处理方法。
|
||||
// 获取系统内置参数第三方系统主数据字段信息
|
||||
String extAttrLabel = configProvider.getBizConfigByKey(FlowIntegrationConstants.extAttrLabel);
|
||||
log.info("获取人员账号自定义字段名称"+extAttrLabel);
|
||||
// 获取当前登录账号的人员自定义主数据信息,通过主数据信息查询到BIP系统登录信息
|
||||
AddressBook addressBook = addressBookCustomerFieldInfoManager.getByMemberId(AppContext.currentUserId());
|
||||
if(null == addressBook) {
|
||||
log.info("人员自定义数据未维护,无法单点登录!");
|
||||
ModelAndView mav = exceptionRedirect("人员自定义数据未维护,无法单点登录!");
|
||||
return mav;
|
||||
}
|
||||
JSONObject addressBookjson = AddressBookUtil.appleAddressBook(addressBook,enumManagerNew);
|
||||
// 通过字段名称查询人员账号主数据数据库字段
|
||||
String extAttrName = srcFlowDao.getMetadataNameByLabel(extAttrLabel);
|
||||
String extAttrValue = addressBookjson.getString(extAttrName);
|
||||
log.info("查询对应人员账号"+extAttrValue);
|
||||
if(StringUtil.isEmpty(extAttrValue)){
|
||||
log.info(extAttrLabel+"未维护,无法单点登录!");
|
||||
ModelAndView mav = exceptionRedirect(extAttrLabel+"未维护,无法单点登录!");
|
||||
return mav;
|
||||
}
|
||||
// 获取第三方系统标识,通过第三方系统标识查询第三方系统的ip,端口,表单跳转地址,加密规则信息等
|
||||
// String thirdpartyCode = request.getParameter("thirdpartyCode");
|
||||
// 设置跳转参数
|
||||
JSONObject autoToken = new JSONObject();
|
||||
autoToken.put("thirdPartyLoginName",extAttrValue);
|
||||
autoToken.put("loginName",AppContext.currentUserLoginName());
|
||||
autoToken.put("time",new Date().getTime());
|
||||
log.info("第三方应用编码:"+thirdPartyCode+",设置连接跳转参数"+autoToken);
|
||||
// 根据第三方系统标识获取加密key和vi
|
||||
String paramValue = srcFlowDao.getThirdpartyParamByThirdpartyCode(thirdPartyCode);
|
||||
log.info("参数信息"+paramValue);
|
||||
if(StringUtil.isEmpty(paramValue)){
|
||||
log.info("当前第三方系统标识在系统中没有找到,请检查系统设置。");
|
||||
ModelAndView mav = exceptionRedirect("当前第三方系统标识在系统中没有找到,请检查系统设置。");
|
||||
return mav;
|
||||
}
|
||||
JSONObject paramjson = JSONObject.parseObject(paramValue);
|
||||
String secretKey = paramjson.getString("secretKey");
|
||||
String vi = paramjson.getString("vi");
|
||||
String encrypted = AesUtil.encrypt(autoToken.toString(),secretKey,vi);
|
||||
String formUrl = getToFormUrlByThirdPartyFlowId(tableName,recordId);
|
||||
URL url = new URL(formUrl);
|
||||
String query = url.getQuery();
|
||||
if (query == null || query.isEmpty()) {
|
||||
log.info("没有查询到请求参数,请检查");
|
||||
ModelAndView mav = exceptionRedirect("没有查询到请求参数,请检查");
|
||||
return mav;
|
||||
}
|
||||
Map<String, String> paramMap = parseQueryParams(query);
|
||||
String tourl = paramMap.get("tourl");
|
||||
// 连接地址转换,特殊标识符
|
||||
String encodedToken = URLEncoder.encode(encrypted, StandardCharsets.UTF_8.name());
|
||||
StringBuilder urlsb = new StringBuilder(tourl).append("&auth_token=").append(encodedToken);
|
||||
log.info("跳转链接为:"+urlsb);
|
||||
response.sendRedirect(urlsb.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
private ModelAndView exceptionRedirect(String popupContent){
|
||||
ModelAndView mav = new ModelAndView("popup");
|
||||
// 2. 向前端传递弹窗参数(可自定义字段)
|
||||
mav.addObject("showPopup", true); // 是否显示弹窗
|
||||
mav.addObject("popupTitle", "操作提示"); // 弹窗标题
|
||||
mav.addObject("popupContent", popupContent); // 弹窗内容
|
||||
mav.addObject("popupType", "success"); // 弹窗类型(成功/失败)
|
||||
return mav;
|
||||
}
|
||||
|
||||
private String getToFormUrlByThirdPartyFlowId(String tableName,String recordId){
|
||||
// 通过当前表单名称获取当前表单的所有字段信息
|
||||
String fieldInfoStr = srcFlowDao.getFieldInfoByFormName(tableName);
|
||||
// 通过所有字段信息查询出第三方系统ID字段名称及第三方系统编码
|
||||
JSONObject fieldInfoJson = JSONObject.parseObject(fieldInfoStr);
|
||||
JSONObject frontFormmain = fieldInfoJson.getJSONObject("front_formmain");
|
||||
// 查询相关链接明细表信息
|
||||
JSONArray formsons = fieldInfoJson.getJSONArray("formsons");
|
||||
// 根据相关明细名称获取对应明细表数据库名称
|
||||
JSONObject linkformson = new JSONObject();
|
||||
for(int i = 0 ; i < formsons.size();i++){
|
||||
JSONObject json = formsons.getJSONObject(i);
|
||||
if("相关链接".equals(json.getString("display"))){
|
||||
linkformson = json;
|
||||
}
|
||||
}
|
||||
// 未查询到对应明细表,返回连接为空
|
||||
if(linkformson.size()==0){
|
||||
log.info("未查询到对应相关链接明细表信息,返回连接信息为空");
|
||||
return "";
|
||||
}
|
||||
String linkSubTableName = linkformson.getString("tableName");
|
||||
// 获取需要查询的字段名称
|
||||
JSONArray linkFieldInfos = linkformson.getJSONArray("fieldInfo");
|
||||
String urlStrName = "";
|
||||
for(int i = 0 ; i < linkFieldInfos.size();i++){
|
||||
JSONObject linkFieldInfo = linkFieldInfos.getJSONObject(i);
|
||||
if("跳转链接".equals(linkFieldInfo.getString("display"))){
|
||||
urlStrName = linkFieldInfo.getString("name");
|
||||
}
|
||||
}
|
||||
if(StringUtil.isEmpty(urlStrName)){
|
||||
log.info("未查询到对应相关链接明细表中存在跳转链接信息,返回连接信息为空");
|
||||
return "";
|
||||
}
|
||||
// 通过表单,第三方系统ID,第三方系统编码查询出指定字段
|
||||
String[] fieldNameString = new String[]{urlStrName};
|
||||
Map<String,String> params = new HashMap<>();
|
||||
params.put("id",recordId);
|
||||
List<Map<String,Object>> formDatas = srcFlowDao.getFormDataByParam(linkSubTableName,fieldNameString,params);
|
||||
String urlStr = "";
|
||||
if(formDatas.size()>0){
|
||||
Map<String,Object> formData = formDatas.get(0);
|
||||
urlStr = formData.get(urlStrName)==null?"":formData.get(urlStrName).toString();
|
||||
}
|
||||
// 返回指定字段
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析查询参数字符串为Map(处理参数解码)
|
||||
*/
|
||||
private Map<String, String> parseQueryParams(String query) throws UnsupportedEncodingException {
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
// 按&拆分所有参数
|
||||
String[] paramPairs = query.split("&");
|
||||
for (String pair : paramPairs) {
|
||||
// 按=拆分参数名和值(处理没有值的情况,如?toUrl)
|
||||
String[] keyValue = pair.split("=", 2); // 限制拆分次数为2,避免值中包含=
|
||||
String key = URLDecoder.decode(keyValue[0],"UTF-8");
|
||||
String value = keyValue.length > 1
|
||||
? URLDecoder.decode(keyValue[1], "UTF-8")
|
||||
: "";
|
||||
paramMap.put(key, value);
|
||||
}
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class SrcFlowDao{
|
||||
private String getProcessLogsByProcessId = "select id,process_id,action_id,action_user_id,action_time,action_desc from ctp_process_log where process_id = ?";
|
||||
private String getColSummaryByFormRecordid = "select id,state,subject,start_member_id,process_id,templete_id,form_recordid,formid,form_appid from col_summary where form_recordid = ?";
|
||||
private String getCtpAffairBySummaryId = "select id,member_id,state,sub_state from ctp_affair where object_id = ?";
|
||||
private String getFieldInfoByFormName = "select field_info from CAP_FORM_DEFINITION where field_info like ?";
|
||||
|
||||
private String getMetadataNameByLabel = "select name from ctp_metadata_column where label = ? and is_enable = 1";
|
||||
|
||||
@@ -167,6 +168,7 @@ public class SrcFlowDao{
|
||||
String whereString = SQLParamUtil.mapToAndCondition(params);
|
||||
String replacedStr = sql.toString().replace("#{tableName}", tableName).replace("#{fieldName}", fieldName).replace("#{whereString}",whereString);
|
||||
sql = new StringBuilder(replacedStr);
|
||||
System.out.println(sql.toString());
|
||||
List<Object> p = new ArrayList<Object>();
|
||||
agent.execute(sql.toString(), p);
|
||||
List<Map> list = agent.resultSetToList();
|
||||
@@ -357,4 +359,31 @@ public class SrcFlowDao{
|
||||
return res;
|
||||
}
|
||||
|
||||
public String getFieldInfoByFormName(String tableName){
|
||||
String res = "";
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
try {
|
||||
StringBuilder sql = new StringBuilder(getFieldInfoByFormName);
|
||||
List<Object> p = new ArrayList<Object>();
|
||||
p.add("%"+tableName+"%");
|
||||
agent.execute(sql.toString(), p);
|
||||
List<Map> list = agent.resultSetToList();
|
||||
if (list != null && list.size() > 0) {
|
||||
Map<String,Object> map = list.get(0);
|
||||
Object obj = map.get("field_info");
|
||||
res = obj!=null?obj.toString():"";
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (agent != null) {
|
||||
agent.close();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -61,16 +61,6 @@ public class FlowStatusCallbackEvent extends ACommonWorkflowEvent {
|
||||
JSONObject req = JSONObject.parseObject(request);
|
||||
String url = req.getString("flowStatusCallbackUrl");
|
||||
context.setUrl(url);
|
||||
// {
|
||||
// "thirdFlowId": "2026013021110001",
|
||||
// "flowInfo": {
|
||||
// "flowStatus": "1",
|
||||
// "flowStatusTxt": "流程结束"
|
||||
// },
|
||||
// "formInfo": {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
JSONObject datajson = new JSONObject();
|
||||
datajson.put("thirdFlowId",req.getString("thirdFlowId"));
|
||||
JSONObject flowInfo = new JSONObject();
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.seeyon.apps.src_flowIntegration.fieldCtrl;
|
||||
|
||||
import com.seeyon.cap4.form.bean.ParamDefinition;
|
||||
import com.seeyon.cap4.form.bean.fieldCtrl.FormFieldCustomCtrl;
|
||||
import com.seeyon.cap4.form.util.Enums;
|
||||
import www.seeyon.com.utils.UUIDUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class URLSkipFieldCtrl extends FormFieldCustomCtrl {
|
||||
|
||||
/**
|
||||
* UUIDLong.longUUID()
|
||||
* UUIDUtil.getUUIDString()
|
||||
*/
|
||||
public String getKey() {
|
||||
return "7310965329196191710";
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(UUIDUtil.getUUIDLong());
|
||||
}
|
||||
|
||||
public String getFieldLength() {
|
||||
return "20";
|
||||
}
|
||||
|
||||
/**
|
||||
* 控件初始化接口,此接口在控件初始化的时候,会调用,主要用于定义控件所属插件id、在表单编辑器中的图标、表单编辑器中有哪些属性可以设置。
|
||||
* 使用举例:在接口中定义自定义控件在在表单编辑器中有哪些控件属性需要配置
|
||||
*/
|
||||
public void init() {
|
||||
setPluginId("urlSkip");
|
||||
setIcon("cap-icon-urlSkip");
|
||||
// 自定义参数
|
||||
ParamDefinition templateIdParam = new ParamDefinition();
|
||||
templateIdParam.setParamType(Enums.ParamType.button);
|
||||
addDefinition(templateIdParam);
|
||||
}
|
||||
|
||||
/** (non-Javadoc)
|
||||
* @see FormFieldCustomCtrl#getPCInjectionInfo()
|
||||
* PC端的资源文件路径
|
||||
*/
|
||||
public String getPCInjectionInfo() {
|
||||
return "{path:'apps_res/cap/customCtrlResources/urlSkipResources/',jsUri:'js/urlSkipUnflow.js',initMethod:'init',nameSpace:'field_" + getKey() + "'}";
|
||||
}
|
||||
|
||||
/** (non-Javadoc)
|
||||
* @see FormFieldCustomCtrl#getMBInjectionInfo()
|
||||
* 移动端的资源地址
|
||||
*/
|
||||
public String getMBInjectionInfo() {
|
||||
return "{path:'http://newwidget.v5.cmp/v1.0.0/',weixinpath:'newwidget',jsUri:'js/newwidget.js',initMethod:'init',nameSpace:'field_" + this.getKey() + "'}";
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return "表单跳转按钮";
|
||||
}
|
||||
|
||||
public boolean canBathUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String[]> getListShowDefaultVal(Integer externalType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始值生成接口
|
||||
*/
|
||||
public String[] getDefaultVal(String defaultValue) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public boolean canInjectionWord() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,10 +6,8 @@ import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import www.seeyon.com.utils.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class FlowIntegrationService {
|
||||
|
||||
@Autowired
|
||||
@@ -25,6 +23,7 @@ public class FlowIntegrationService {
|
||||
String thirdpartyCode = jsonObject.getString("thirdpartyCode");
|
||||
String flowStatusCallbackUrl = jsonObject.getString("flowStatusCallbackUrl");
|
||||
String flowAuditStatusCallbackUrl = jsonObject.getString("flowAuditStatusCallbackUrl");
|
||||
JSONObject relatedLinks = jsonObject.getJSONObject("relatedLinks");
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
JSONObject flowParam = new JSONObject();
|
||||
// 设置流程生成参数
|
||||
@@ -48,7 +47,7 @@ public class FlowIntegrationService {
|
||||
data.put("doTrigger",true);
|
||||
// 设置第三方信息字段内容
|
||||
JSONObject datajson = data.getJSONObject("data");
|
||||
thirdSysBizMapService.setTableData(datajson,templateCode,tirdFlowId,thirdpartyCode,flowStatusCallbackUrl,flowAuditStatusCallbackUrl);
|
||||
thirdSysBizMapService.setTableData(datajson,templateCode,tirdFlowId,thirdpartyCode,flowStatusCallbackUrl,flowAuditStatusCallbackUrl,relatedLinks);
|
||||
flowParam.put("data",data);
|
||||
|
||||
Map<String,Object> result = (Map<String,Object>) oaFlowCreateService.flowStart(tirdFlowId,flowParam,token);
|
||||
@@ -75,8 +74,6 @@ public class FlowIntegrationService {
|
||||
JSONObject flowInfo = oaFlowQueryService.getFlowInfo(String.valueOf (colSummary.get("id")));
|
||||
// 设置当前流程状态信息
|
||||
res.put("flowInfo",flowInfo);
|
||||
// 设置第三方系统流程ID字段
|
||||
res.put("flowInfo",thirdFlowId);
|
||||
JSONObject formInfo = oaFlowQueryService.getFormInfo(colSummary);
|
||||
// 设置流程表单数据
|
||||
res.put("formInfo",formInfo);
|
||||
|
||||
@@ -7,10 +7,6 @@ import com.seeyon.utils.http.OaResp;
|
||||
import com.seeyon.utils.http.OaRestClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OaFlowCreateService {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.seeyon.apps.src_flowIntegration.dao.SrcFlowDao;
|
||||
import com.seeyon.apps.src_flowIntegration.listener.FlowEventListener;
|
||||
import com.seeyon.apps.src_flowIntegration.util.AddressBookUtil;
|
||||
import com.seeyon.apps.src_flowIntegration.util.FieldUtil;
|
||||
import com.seeyon.apps.src_flowIntegration.util.TimestampConverter;
|
||||
import com.seeyon.apps.src_flowIntegration.util.TransitionAffairUtil;
|
||||
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
|
||||
import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
@@ -22,8 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import www.seeyon.com.utils.StringUtil;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -206,23 +203,29 @@ public class OaFlowQueryService {
|
||||
// 查询主表表单名称
|
||||
JSONObject frontFormmain = fieldInfoJson.getJSONObject("front_formmain");
|
||||
String formmainName = frontFormmain.getString("tableName");
|
||||
log.info("formmainName:"+formmainName);
|
||||
JSONArray fieldInfo = frontFormmain.getJSONArray("fieldInfo");
|
||||
// 整理主表字段
|
||||
List<String> fieldNames = new ArrayList<>();
|
||||
for(int i = 0 ; i < fieldInfo.size();i++){
|
||||
JSONObject field = fieldInfo.getJSONObject(i);
|
||||
String fieldName = field.getString("name");
|
||||
if("排序号".equals(field.getString("display"))){
|
||||
continue;
|
||||
}
|
||||
fieldNames.add(fieldName);
|
||||
}
|
||||
String[] fieldNameString = fieldNames.toArray(new String[fieldNames.size()]);
|
||||
|
||||
log.info("fieldNameString:"+fieldNameString.toString());
|
||||
Map<String,String> formmainParam = new HashMap<>();
|
||||
String formmainId = colSummary.get("form_recordid")==null?"":String.valueOf(colSummary.get("form_recordid"));
|
||||
formmainParam.put("id",formmainId);
|
||||
log.info("formmainId:"+formmainId);
|
||||
List<Map<String,Object>> formmainDatas = srcFlowDao.getFormDataByParam(formmainName,fieldNameString,formmainParam);
|
||||
Map<String,Object> formmainData = formmainDatas.get(0);
|
||||
// 设置主表字段
|
||||
JSONObject masterTable = toMasterTable(formmainName,fieldInfo,formmainData);
|
||||
log.info("masterTable:"+masterTable);
|
||||
// 查询从表表单数据
|
||||
JSONArray formsons = fieldInfoJson.getJSONArray("formsons");
|
||||
JSONObject subTables = new JSONObject();
|
||||
@@ -235,12 +238,16 @@ public class OaFlowQueryService {
|
||||
for(int n = 0 ; n < subFieldInfo.size();n++){
|
||||
JSONObject field = subFieldInfo.getJSONObject(n);
|
||||
String subFieldName = field.getString("name");
|
||||
if("排序号".equals(field.getString("display"))){
|
||||
continue;
|
||||
}
|
||||
subFieldNames.add(subFieldName);
|
||||
}
|
||||
String[] subFieldNameString = subFieldNames.toArray(new String[subFieldNames.size()]);
|
||||
|
||||
Map<String,String> formsonParam = new HashMap<>();
|
||||
formsonParam.put("formmain_id",formmainId);
|
||||
log.info("formsonParam:"+formsonParam+"formsonName:"+formsonName);
|
||||
List<Map<String,Object>> formsonDatas = srcFlowDao.getFormDataByParam(formsonName,subFieldNameString,formsonParam);
|
||||
// 设置从表数据
|
||||
JSONObject subTable = toSubTable(formsonName,subFieldInfo,formsonDatas);
|
||||
@@ -266,24 +273,11 @@ public class OaFlowQueryService {
|
||||
JSONObject mainFieldData = new JSONObject();
|
||||
mainFieldData.put("name",fieldName);
|
||||
mainFieldData.put("display",fieldInfoData.get("display"));
|
||||
log.info("显示名称"+fieldInfoData.get("display"));
|
||||
mainFieldData.put("value",formmainData.get(fieldName));
|
||||
// 判断字段类型,如果字段类型是附件则跳过当前字段
|
||||
if("image".equals(fieldInfoData.getString("type"))||"attachment".equals(fieldInfoData.getString("type"))){
|
||||
continue;
|
||||
}else if ("date".equals(fieldInfoData.getString("type"))){
|
||||
if(formmainData.get(fieldName)!=null){
|
||||
String dateStr = TimestampConverter.longToDateStr(Long.parseLong(formmainData.get(fieldName).toString()));
|
||||
mainFieldData.put("showvalue",dateStr);
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else if ("dateTime".equals(fieldInfoData.getString("type"))){
|
||||
if(formmainData.get(fieldName)!=null){
|
||||
String dateTimeStr = TimestampConverter.longToDateTimeStr(Long.parseLong(formmainData.get(fieldName).toString()));
|
||||
mainFieldData.put("showvalue",dateTimeStr);
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else if ("account".equals(fieldInfoData.getString("type"))){
|
||||
if(formmainData.get(fieldName)!=null){
|
||||
V3xOrgAccount v3xOrgAccount = orgManager.getAccountById(Long.parseLong(formmainData.get(fieldName).toString()));
|
||||
@@ -321,6 +315,7 @@ public class OaFlowQueryService {
|
||||
}
|
||||
}else if ("multiselect".equals(fieldInfoData.getString("type"))){
|
||||
// 下拉多选
|
||||
if(formmainData.get(fieldName)!=null){
|
||||
String value = String.valueOf(formmainData.get(fieldName));
|
||||
String[] values = value.split(",");
|
||||
StringBuilder showvalue = new StringBuilder();
|
||||
@@ -336,8 +331,12 @@ public class OaFlowQueryService {
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else if ("select".equals(fieldInfoData.getString("type"))){
|
||||
// 下拉单选
|
||||
if(formmainData.get(fieldName)!=null){
|
||||
String value = String.valueOf(formmainData.get(fieldName));
|
||||
CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(value));
|
||||
if(ctpEnumItem!=null){
|
||||
@@ -345,6 +344,9 @@ public class OaFlowQueryService {
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if(formmainData.get(fieldName)!=null){
|
||||
mainFieldData.put("showvalue",formmainData.get(fieldName));
|
||||
@@ -375,20 +377,6 @@ public class OaFlowQueryService {
|
||||
fieldData.put("value",formsonData.get(subField.getString("name"))==null?"":formsonData.get(subField.getString("name")));
|
||||
if("image".equals(subField.getString("type"))||"attachment".equals(subField.getString("type"))){
|
||||
continue;
|
||||
}else if ("date".equals(subField.getString("type"))){
|
||||
if(formsonData.get(fieldName)!=null){
|
||||
String dateStr = TimestampConverter.longToDateStr(Long.parseLong(formsonData.get(fieldName).toString()));
|
||||
fieldData.put("showvalue",dateStr);
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else if ("dateTime".equals(subField.getString("type"))){
|
||||
if(formsonData.get(fieldName)!=null){
|
||||
String dateTimeStr = TimestampConverter.longToDateTimeStr(Long.parseLong(formsonData.get(fieldName).toString()));
|
||||
fieldData.put("showvalue",dateTimeStr);
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else if ("account".equals(subField.getString("type"))){
|
||||
if(formsonData.get(fieldName)!=null){
|
||||
V3xOrgAccount v3xOrgAccount = orgManager.getAccountById(Long.parseLong(formsonData.get(fieldName).toString()));
|
||||
@@ -426,6 +414,7 @@ public class OaFlowQueryService {
|
||||
}
|
||||
}else if ("multiselect".equals(subField.getString("type"))){
|
||||
// 下拉多选
|
||||
if(formsonData.get(fieldName)!=null){
|
||||
String value = String.valueOf(formsonData.get(fieldName));
|
||||
String[] values = value.split(",");
|
||||
StringBuilder showvalue = new StringBuilder();
|
||||
@@ -441,8 +430,12 @@ public class OaFlowQueryService {
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else if ("select".equals(subField.getString("type"))){
|
||||
// 下拉单选
|
||||
if(formsonData.get(fieldName)!=null){
|
||||
String value = String.valueOf(formsonData.get(fieldName));
|
||||
CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(value));
|
||||
if(ctpEnumItem!=null){
|
||||
@@ -450,6 +443,9 @@ public class OaFlowQueryService {
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if(formsonData.get(fieldName)!=null){
|
||||
fieldData.put("showvalue",formsonData.get(fieldName));
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ThirdSysBizMapService {
|
||||
* @param flowStatusCallbackUrl
|
||||
* @param flowAuditStatusCallbackUrl
|
||||
*/
|
||||
public void setTableData(JSONObject data,String templateCode,String tirdFlowId,String thirdpartyCode,String flowStatusCallbackUrl,String flowAuditStatusCallbackUrl ){
|
||||
public void setTableData(JSONObject data,String templateCode,String tirdFlowId,String thirdpartyCode,String flowStatusCallbackUrl,String flowAuditStatusCallbackUrl,JSONObject relatedLinks){
|
||||
// 首先根据templateCode获取表单formId;
|
||||
String formId = getFormIdByTemplateCode(templateCode);
|
||||
// 通过formId信息查询表单中的字段,并且找到字段信息为第三方信息的字段
|
||||
@@ -82,6 +82,51 @@ public class ThirdSysBizMapService {
|
||||
flowAuditStatusCallbackUrljson.put("value",flowAuditStatusCallbackUrl);
|
||||
fields.add(flowAuditStatusCallbackUrljson);
|
||||
}
|
||||
// 设置相关链接明细表信息
|
||||
JSONArray formsons = fieldjson.getJSONArray("formsons");
|
||||
// 遍历所有明细表信息,查询明细表是否为相关链接
|
||||
String relatedLinkSubTableName = "";
|
||||
String linkNameFieldName ="" ,linkFieldName = "";
|
||||
for(int i = 0 ; i < formsons.size() ; i ++){
|
||||
JSONObject formson = formsons.getJSONObject(i);
|
||||
if("相关链接".equals(formson.getString("display"))){
|
||||
relatedLinkSubTableName = formson.getString("tableName");
|
||||
JSONArray subFieldInfos = formson.getJSONArray("fieldInfo");
|
||||
for(int n = 0 ; n < subFieldInfos.size() ; n++){
|
||||
JSONObject subFieldInfo = subFieldInfos.getJSONObject(n);
|
||||
if("跳转链接描述".equals(subFieldInfo.getString("display"))){
|
||||
linkNameFieldName = subFieldInfo.getString("name");
|
||||
}else if("跳转链接".equals(subFieldInfo.getString("display"))){
|
||||
linkFieldName = subFieldInfo.getString("name");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 遍历第三方传递的相关链接信息,将相关链接信息按照指定字段保存到data对象中。
|
||||
// 创建相关链接明细表jsonObject对象信息
|
||||
JSONObject relatedLinkFieldJson = new JSONObject();
|
||||
relatedLinkFieldJson.put("name",relatedLinkSubTableName);
|
||||
JSONArray relatedLinkRecords = new JSONArray();
|
||||
for (String key : relatedLinks.keySet()) {
|
||||
JSONObject relatedLinkRecord = new JSONObject();
|
||||
JSONArray relatedLinkFields = new JSONArray();
|
||||
// 描述字段赋值
|
||||
JSONObject describeField = new JSONObject();
|
||||
describeField.put("name",linkNameFieldName);
|
||||
describeField.put("value",key);
|
||||
relatedLinkFields.add(describeField);
|
||||
// 链接字段赋值
|
||||
JSONObject linkField = new JSONObject();
|
||||
linkField.put("name",linkFieldName);
|
||||
linkField.put("value",relatedLinks.getString(key));
|
||||
relatedLinkFields.add(linkField);
|
||||
relatedLinkRecord.put("fields",relatedLinkFields);
|
||||
relatedLinkRecords.add(relatedLinkRecord);
|
||||
}
|
||||
relatedLinkFieldJson.put("records",relatedLinkRecords);
|
||||
// 设置明细表字段,保存link信息
|
||||
JSONArray subTables = data.getJSONArray("subTables");
|
||||
subTables.add(relatedLinkFieldJson);
|
||||
}
|
||||
|
||||
public String uniqueDataValidation(String tirdFlowId,String templateCode){
|
||||
|
||||
@@ -46,8 +46,6 @@ public class ThirdFlowIntegrationController extends BaseResource {
|
||||
}else{
|
||||
return fail(r.getString("msg"));
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
@@ -60,13 +58,7 @@ public class ThirdFlowIntegrationController extends BaseResource {
|
||||
public Response flowquery(JSONObject params ,@QueryParam("token") String urlToken, @Context HttpHeaders headers) {
|
||||
try {
|
||||
// 获取当前请求中的token,可能通过url或者header中进行token获取
|
||||
// String tokenString = headers.getHeaderString("token");
|
||||
// String token = "";
|
||||
// if(StringUtil.isNotEmpty(urlToken)){
|
||||
// token = urlToken;
|
||||
// }else{
|
||||
// token = tokenString;
|
||||
// }
|
||||
|
||||
JSONObject r = flowIntegrationService.thirdFlowQuery(params);
|
||||
return success(r);
|
||||
}catch (Exception e) {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
public enum ClauseFactor {
|
||||
NEQ,//不相等
|
||||
EQ, //相等
|
||||
GT, //大于
|
||||
GE, //大于等于
|
||||
LT, //小于
|
||||
LE, //小于等于
|
||||
NULL, //空
|
||||
NOT_NULL, //非空
|
||||
LIKE, //模糊
|
||||
AND,
|
||||
OR,
|
||||
IN,
|
||||
NOT_IN
|
||||
;
|
||||
|
||||
|
||||
public boolean isNullType() {
|
||||
return this == NULL || this == NOT_NULL;
|
||||
}
|
||||
public boolean isInType() {
|
||||
return this == IN || this == NOT_IN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
import com.seeyon.cap4.form.bean.FormBean;
|
||||
import com.seeyon.cap4.form.bean.FormFieldBean;
|
||||
import com.seeyon.cap4.form.bean.FormTableBean;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
|
||||
import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumBean;
|
||||
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItem;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class EnumMapUtils {
|
||||
|
||||
public static String getEnumItemValueByDisplayValue(FormBean cap4FormBean,String fieldDisplay, String targetValue) {
|
||||
if(targetValue == null || "null".equals(targetValue) || "".equals(targetValue)){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
FormTableBean masterTableBean = cap4FormBean.getMasterTableBean();
|
||||
FormFieldBean beanByDisplay = masterTableBean.getFieldBeanByDisplay(fieldDisplay);
|
||||
if(beanByDisplay == null || beanByDisplay.getEnumId() == 0l) {
|
||||
return null;
|
||||
}
|
||||
return getEnumItemValueByEnumId(targetValue, beanByDisplay.getEnumId());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getEnumItemIdByGroupNameAndItemShowValue(String enumGroupName, String targetValue) {
|
||||
String sql = "SELECT * FROM ctp_enum ce let join ctp_enum_item cei on ce.`ID` = cei.REF_ENUMID where ce.`ENUMNAME` = ? and CEI.`SHOWVALUE` = ?";
|
||||
if(StringUtils.isAnyBlank(enumGroupName, targetValue)){
|
||||
return null;
|
||||
}
|
||||
Long enumId = null;
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
try {
|
||||
agent.execute(sql, Arrays.asList(enumGroupName,targetValue));
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) agent.resultSetToList();
|
||||
if(list == null || list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
Map map = list.get(0);
|
||||
enumId = (Long)map.get("ID");
|
||||
return enumId == null ? "" : enumId + "";
|
||||
} catch (Exception e) {
|
||||
|
||||
}finally {
|
||||
agent.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static String getEnumItemValueByRootPCode(String rootPCode, String groupValue, String targetValue) {
|
||||
if(targetValue == null || "null".equals(targetValue) || "".equals(targetValue)){
|
||||
return null;
|
||||
}
|
||||
String queryIdSql = "SELECT ce.ID FROM ctp_enum ce inner join ctp_enum cei on ce.`PARENT_ID` = cei.ID where CEI.`PROGRAM_CODE` = ? and ce.`ENUMNAME` = ?";
|
||||
Long enumId = null;
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
try {
|
||||
agent.execute(queryIdSql, Arrays.asList(rootPCode,groupValue));
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) agent.resultSetToList();
|
||||
if(list == null || list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
Map map = list.get(0);
|
||||
enumId = (Long)map.get("ID");
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}finally {
|
||||
agent.close();
|
||||
}
|
||||
EnumManager enumManagerNew = (EnumManager) AppContext.getBean("enumManagerNew");
|
||||
CtpEnumBean ctpEnumBean = enumManagerNew.getEnum(enumId);
|
||||
if(ctpEnumBean == null) {
|
||||
return null;
|
||||
}
|
||||
List<CtpEnumItem> ctpEnumItems = ctpEnumBean.getItems();
|
||||
if(ctpEnumBean.getItems() == null) {
|
||||
return null;
|
||||
}
|
||||
for (CtpEnumItem enumItem : ctpEnumItems) {
|
||||
if(enumItem.getShowvalue().equals(targetValue)) {
|
||||
return enumItem.getId() + "";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Set<String> getEnumItemValues(FormBean cap4FormBean, String fieldDisplay) {
|
||||
Set<String> set = new HashSet<>();
|
||||
try {
|
||||
FormTableBean masterTableBean = cap4FormBean.getMasterTableBean();
|
||||
FormFieldBean beanByDisplay = masterTableBean.getFieldBeanByDisplay(fieldDisplay);
|
||||
if(beanByDisplay == null || beanByDisplay.getEnumId() == 0l) {
|
||||
return set;
|
||||
}
|
||||
EnumManager enumManagerNew = (EnumManager) AppContext.getBean("enumManagerNew");
|
||||
CtpEnumBean ctpEnumBean = enumManagerNew.getEnum(beanByDisplay.getEnumId());
|
||||
|
||||
if(ctpEnumBean == null) {
|
||||
return set;
|
||||
}
|
||||
List<CtpEnumItem> ctpEnumItems = ctpEnumBean.getItems();
|
||||
if(ctpEnumBean.getItems() == null) {
|
||||
return set;
|
||||
}
|
||||
for (CtpEnumItem enumItem : ctpEnumItems) {
|
||||
set.add(enumItem.getShowvalue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public static String getEnumItemValueByEnumId(String showValue,long enumId) {
|
||||
EnumManager enumManagerNew = (EnumManager) AppContext.getBean("enumManagerNew");
|
||||
CtpEnumBean ctpEnumBean = enumManagerNew.getEnum(enumId);
|
||||
if(ctpEnumBean == null) {
|
||||
return null;
|
||||
}
|
||||
List<CtpEnumItem> ctpEnumItems = ctpEnumBean.getItems();
|
||||
if(ctpEnumBean.getItems() == null) {
|
||||
return null;
|
||||
}
|
||||
for (CtpEnumItem enumItem : ctpEnumItems) {
|
||||
if(enumItem.getShowvalue().equals(showValue)) {
|
||||
return enumItem.getId() + "";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getEnumShowValue(Object enumItemId) throws BusinessException {
|
||||
if(enumItemId == null) {
|
||||
return null;
|
||||
}
|
||||
Long temp = enumItemId instanceof Long ? (Long)enumItemId : (enumItemId instanceof String ? Long.parseLong((String)enumItemId) : null);
|
||||
if(temp == null) {
|
||||
return null;
|
||||
}
|
||||
EnumManager enumManagerNew = (EnumManager) AppContext.getBean("enumManagerNew");
|
||||
CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(temp);
|
||||
if(ctpEnumItem == null) {
|
||||
return null;
|
||||
}
|
||||
return ctpEnumItem.getShowvalue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FormColumn {
|
||||
|
||||
private String id;
|
||||
private List<FormFieldVo> vos = new ArrayList<>();
|
||||
private Map<String, Object> fieldsMap = new HashMap<>(); // 缓存字段map
|
||||
|
||||
public FormColumn() {}
|
||||
|
||||
public FormColumn(String id, List<FormFieldVo> vos) {
|
||||
this.id = id;
|
||||
setVos(vos);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
fieldsMap.put("id", id); // 同步到 map
|
||||
}
|
||||
|
||||
public List<FormFieldVo> getVos() {
|
||||
return vos;
|
||||
}
|
||||
|
||||
public void setVos(List<FormFieldVo> vos) {
|
||||
this.vos = vos != null ? vos : new ArrayList<>();
|
||||
rebuildFieldsMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段 map,按 displayName 映射 value
|
||||
*/
|
||||
public Map<String, Object> getFieldsMap() {
|
||||
return fieldsMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 displayName 获取值
|
||||
*/
|
||||
public Object getValue(String displayName) {
|
||||
return fieldsMap.get(displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新某个字段的值,同时同步到 map
|
||||
*/
|
||||
public void setValue(String displayName, Object value) {
|
||||
for (FormFieldVo vo : vos) {
|
||||
if (displayName.equals(vo.getDisplayName())) {
|
||||
vo.setValue(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fieldsMap.put(displayName, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部方法:根据 vos 重建 map
|
||||
*/
|
||||
private void rebuildFieldsMap() {
|
||||
fieldsMap.clear();
|
||||
for (FormFieldVo vo : vos) {
|
||||
fieldsMap.put(vo.getDisplayName(), vo.getValue());
|
||||
}
|
||||
fieldsMap.put("id", id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
public class FormFieldVo {
|
||||
private String displayName;
|
||||
private Object value;
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
import com.seeyon.ctp.services.ServiceException;
|
||||
import com.seeyon.v3x.services.form.FormFactory;
|
||||
import com.seeyon.v3x.services.form.bean.FormExport;
|
||||
import com.seeyon.v3x.services.form.bean.RecordExport;
|
||||
import com.seeyon.v3x.services.form.bean.SubordinateFormExport;
|
||||
import com.seeyon.v3x.services.form.bean.ValueExport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
//创建无流程表单数据处理工具类
|
||||
public class FormSaveUtil {
|
||||
|
||||
/**
|
||||
* 设置主表信息
|
||||
* @param map 设置主表字段。Map<主表显示名称,主表数据>
|
||||
* @return
|
||||
*/
|
||||
public static List<ValueExport> setFormValue(Map<String, Object> map ){
|
||||
// 创建返回值对象
|
||||
List<ValueExport> valueExports = new ArrayList<ValueExport>();
|
||||
ValueExport valueExport ;
|
||||
// 获取参数信息(显示名称)
|
||||
Set<String> keys = map.keySet();
|
||||
if(keys.size()>0) {
|
||||
// 对控件赋值
|
||||
for (String key : keys) {
|
||||
if(map.get(key) != null ){
|
||||
valueExport = new ValueExport();
|
||||
valueExport.setDisplayName(key);
|
||||
valueExport.setValue(map.get(key).toString());
|
||||
valueExports.add(valueExport);
|
||||
}
|
||||
}
|
||||
}
|
||||
return valueExports;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置从表信息
|
||||
* @param lists 设置主表字段。List<Map<显示名称,数据值>>
|
||||
*/
|
||||
public static List<SubordinateFormExport> setSubordinateFormValue(List<Map<String, Object>> lists){
|
||||
List<SubordinateFormExport> subordinateFormExports = new ArrayList<SubordinateFormExport>();
|
||||
SubordinateFormExport subordinateFormExport = new SubordinateFormExport();
|
||||
List<RecordExport> recordExports = new ArrayList<RecordExport>();
|
||||
List<ValueExport> valueExports;
|
||||
RecordExport recordExport;
|
||||
for(int i = 0 ; i < lists.size() ; i++) {
|
||||
recordExport = new RecordExport();
|
||||
valueExports = setFormValue(lists.get(i));
|
||||
recordExport.setRecord(valueExports);
|
||||
recordExports.add(recordExport);
|
||||
}
|
||||
subordinateFormExport.setValues(recordExports);
|
||||
subordinateFormExports.add(subordinateFormExport);
|
||||
|
||||
return subordinateFormExports;
|
||||
}
|
||||
|
||||
public static List<SubordinateFormExport> setAllSubordinateFormValue(List<Map<String,Object>> lists){
|
||||
List<SubordinateFormExport> subordinateFormExports = new ArrayList<SubordinateFormExport>();
|
||||
for (Map<String, Object> list : lists) {
|
||||
SubordinateFormExport subordinateFormExport = new SubordinateFormExport();
|
||||
List<RecordExport> recordExports = new ArrayList<RecordExport>();
|
||||
for (String key : list.keySet()) {
|
||||
List<Map<String,Object>> columns = (List<Map<String, Object>>) list.get(key);
|
||||
for(int i = 0 ; i < columns.size() ; i++) {
|
||||
List<ValueExport> valueExports = setFormValue(columns.get(i));
|
||||
RecordExport recordExport = new RecordExport();
|
||||
recordExport.setRecord(valueExports);
|
||||
recordExports.add(recordExport);
|
||||
}
|
||||
}
|
||||
subordinateFormExport.setValues(recordExports);
|
||||
subordinateFormExports.add(subordinateFormExport);
|
||||
}
|
||||
return subordinateFormExports;
|
||||
}
|
||||
|
||||
public static void formSave(String loginName, String formNo, FormFactory formFactory, Map<String,Object> mainFormData, List<Map<String,Object>> subFormDatas) throws ServiceException {
|
||||
FormExport formExport = new FormExport();
|
||||
FormSaveUtil formExportUtil = new FormSaveUtil();
|
||||
List<ValueExport> valueExport = formExportUtil.setFormValue(mainFormData);
|
||||
formExport.setValues(valueExport);
|
||||
if(subFormDatas != null) {
|
||||
formExport.setSubordinateForms(formExportUtil.setAllSubordinateFormValue(subFormDatas));
|
||||
}
|
||||
formFactory.importBusinessFormData(loginName, formNo,
|
||||
formExport, new String[] {});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,606 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
import com.seeyon.aicloud.common.JsonUtils;
|
||||
import com.seeyon.cap4.form.api.FormApi4Cap4;
|
||||
import com.seeyon.cap4.form.bean.FormBean;
|
||||
import com.seeyon.cap4.form.bean.FormFieldBean;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FormTableExecutor {
|
||||
|
||||
private static final Log log = LogFactory.getLog(FormTableExecutor.class);
|
||||
|
||||
/*获取主表定义bean对象*/
|
||||
public static TableContext master(String formNo) throws BusinessException {
|
||||
FormBean form = getForm(formNo);
|
||||
return new TableContext(form.getMasterTableBean());
|
||||
}
|
||||
|
||||
/*获取从表定义bean对象*/
|
||||
public static TableContext sub(String formNo, String subTable) throws BusinessException {
|
||||
FormBean form = getForm(formNo);
|
||||
return form.getSubTableBean().stream()
|
||||
.filter(t -> t.getTableName().equals(subTable) || t.getDisplay().equals(subTable))
|
||||
.findFirst()
|
||||
.map(TableContext::new)
|
||||
.orElseThrow(() -> new BusinessException("未找到子表:" + subTable));
|
||||
}
|
||||
|
||||
private static FormBean getForm(String formNo) throws BusinessException {
|
||||
FormApi4Cap4 api = (FormApi4Cap4) AppContext.getBean("formApi4Cap4");
|
||||
return api.getFormByFormCode(formNo);
|
||||
}
|
||||
|
||||
/*填充update字段fieldName*/
|
||||
private static void fillUpdateFields(TableContext ctx, List<FormUpdateField> updateFields) {
|
||||
if (updateFields == null) return;
|
||||
|
||||
for (FormUpdateField c : updateFields) {
|
||||
FormFieldBean field = ctx.getTableBean().getFieldBeanByDisplay(c.getDisplay());
|
||||
if (field != null) {
|
||||
c.setFieldName(field.getColumnName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*填充condition字段fieldName*/
|
||||
private static void fillConditionFields(TableContext ctx, List<FormWhereCondition> conditions) {
|
||||
if (conditions == null) return;
|
||||
|
||||
for (FormWhereCondition c : conditions) {
|
||||
FormFieldBean field = ctx.getTableBean().getFieldBeanByDisplay(c.getDisplay());
|
||||
if (field != null) {
|
||||
c.setFieldName(field.getColumnName());
|
||||
} else if ("ID".equalsIgnoreCase(c.getDisplay())) {
|
||||
c.setFieldName("ID");
|
||||
} else if ("formmain_id".equalsIgnoreCase(c.getDisplay())) {
|
||||
c.setFieldName("formmain_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*将查询列display转换为fieldName*/
|
||||
private static List<String> resolveQueryColumns(TableContext ctx, List<String> displays) {
|
||||
if (displays == null) return Collections.emptyList();
|
||||
return displays.stream()
|
||||
.map(ctx.getTableBean()::getFieldBeanByDisplay)
|
||||
.filter(Objects::nonNull)
|
||||
.map(FormFieldBean::getColumnName)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/* ========== 查询方法 ========== */
|
||||
|
||||
public static List<FormColumn> query(TableContext ctx,
|
||||
List<String> queryDisplays,
|
||||
List<FormWhereCondition> conditions,
|
||||
boolean changeEnum) {
|
||||
|
||||
fillConditionFields(ctx, conditions);
|
||||
List<String> columns = resolveQueryColumns(ctx, queryDisplays);
|
||||
SqlBuildParam param = new SqlBuildParam();
|
||||
param.setSqlType(SqlType.SELECT);
|
||||
param.setTableName(ctx.getTableName());
|
||||
param.setQueryColumns(columns);
|
||||
param.setConditions(conditions);
|
||||
Map<String, Object> sqlMap = generateSql(param);
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
|
||||
try {
|
||||
agent.execute((String) sqlMap.get("sql"), (List<Object>) sqlMap.get("params"));
|
||||
List<Map<String, Object>> rows = agent.resultSetToList();
|
||||
|
||||
return rows.stream()
|
||||
.map(row -> buildFormColumn(row, ctx, changeEnum))
|
||||
.collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
log.error("执行sql为: " + sqlMap.get("sql"));
|
||||
log.error("执行sql参数为: " + JsonUtils.toJSONString(sqlMap.get("params")));
|
||||
log.error(e.getMessage(),e);
|
||||
} finally {
|
||||
agent.close();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/*查询单条记录*/
|
||||
public static FormColumn queryOne(TableContext ctx,
|
||||
List<FormWhereCondition> conditions,
|
||||
boolean changeEnum) {
|
||||
|
||||
fillConditionFields(ctx, conditions);
|
||||
SqlBuildParam param = new SqlBuildParam();
|
||||
param.setSqlType(SqlType.SELECT);
|
||||
param.setTableName(ctx.getTableName());
|
||||
param.setConditions(conditions);
|
||||
Map<String, Object> sqlMap = generateSql(param);
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
|
||||
try {
|
||||
agent.execute((String) sqlMap.get("sql"), (List<Object>) sqlMap.get("params"));
|
||||
Map<String, Object> row = agent.resultSetToMap();
|
||||
if (row == null) return null;
|
||||
|
||||
return buildFormColumn(row, ctx, changeEnum);
|
||||
} catch (Exception e) {
|
||||
log.error("执行sql为: " + sqlMap.get("sql"));
|
||||
log.error("执行sql参数为: " + JsonUtils.toJSONString(sqlMap.get("params")));
|
||||
log.error(e.getMessage(),e);
|
||||
} finally {
|
||||
agent.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*分页查询*/
|
||||
public static List<FormColumn> pageQuery(TableContext ctx,
|
||||
List<String> displays,
|
||||
List<FormWhereCondition> conditions,
|
||||
int pageNo,
|
||||
int pageSize,
|
||||
boolean changeEnum) {
|
||||
|
||||
fillConditionFields(ctx, conditions);
|
||||
List<String> columns = resolveQueryColumns(ctx, displays);
|
||||
SqlBuildParam param = new SqlBuildParam();
|
||||
param.setSqlType(SqlType.SELECT);
|
||||
param.setTableName(ctx.getTableName());
|
||||
param.setQueryColumns(columns);
|
||||
param.setConditions(conditions);
|
||||
param.setPageNo(pageNo);
|
||||
param.setPageSize(pageSize);
|
||||
Map<String, Object> sqlMap = generateSql(param);;
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
|
||||
try {
|
||||
agent.execute((String) sqlMap.get("sql"), (List<Object>) sqlMap.get("params"));
|
||||
List<Map<String, Object>> rows = agent.resultSetToList();
|
||||
|
||||
return rows.stream()
|
||||
.map(r -> buildFormColumn(r, ctx, changeEnum))
|
||||
.collect(Collectors.toList());
|
||||
} catch (Exception e){
|
||||
log.error("执行sql为: " + sqlMap.get("sql"));
|
||||
log.error("执行sql参数为: " + JsonUtils.toJSONString(sqlMap.get("params")));
|
||||
log.error(e.getMessage(),e);
|
||||
} finally {
|
||||
agent.close();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/*统计数量*/
|
||||
public static long count(TableContext ctx,List<String> countField,List<FormWhereCondition> conditions) {
|
||||
fillConditionFields(ctx, conditions);
|
||||
List<String> countColumn = resolveQueryColumns(ctx,countField);
|
||||
SqlBuildParam param = new SqlBuildParam();
|
||||
param.setSqlType(SqlType.COUNT);
|
||||
param.setTableName(ctx.getTableName());
|
||||
param.setConditions(conditions);
|
||||
param.setCountField(countColumn.size() > 0 ? countColumn.get(0) : null);
|
||||
Map<String, Object> sqlMap = generateSql(param);
|
||||
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
try {
|
||||
agent.execute((String) sqlMap.get("sql"), (List<Object>) sqlMap.get("params"));
|
||||
return (Long) agent.resultSetToMap().get("countnum");
|
||||
} catch (Exception e) {
|
||||
log.error("执行sql为: " + sqlMap.get("sql"));
|
||||
log.error("执行sql参数为: " + JsonUtils.toJSONString(sqlMap.get("params")));
|
||||
log.error(e.getMessage(),e);
|
||||
return 0L;
|
||||
} finally {
|
||||
agent.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*更新操作*/
|
||||
public static int update(TableContext ctx, List<FormUpdateField> fields, List<FormWhereCondition> conditions) {
|
||||
if (fields == null || fields.isEmpty()) throw new IllegalArgumentException("更新字段不能为空");
|
||||
if (conditions == null || conditions.isEmpty()) throw new IllegalArgumentException("UPDATE必须带条件");
|
||||
fillConditionFields(ctx, conditions);
|
||||
fillUpdateFields(ctx,fields);
|
||||
SqlBuildParam param = new SqlBuildParam();
|
||||
param.setSqlType(SqlType.UPDATE);
|
||||
param.setTableName(ctx.getTableName());
|
||||
param.setConditions(conditions);
|
||||
param.setUpdateFields(fields);
|
||||
Map<String, Object> sqlMap = generateSql(param);
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
try {
|
||||
return agent.execute((String) sqlMap.get("sql"), (List<Object>) sqlMap.get("params"));
|
||||
} catch (Exception e){
|
||||
log.error("执行sql为: " + sqlMap.get("sql"));
|
||||
log.error("执行sql参数为: " + JsonUtils.toJSONString(sqlMap.get("params")));
|
||||
log.error(e.getMessage(),e);
|
||||
}finally {
|
||||
agent.close();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*删除操作*/
|
||||
public static int delete(TableContext ctx, List<FormWhereCondition> conditions) {
|
||||
if (conditions == null || conditions.isEmpty()) throw new IllegalArgumentException("DELETE必须带条件");
|
||||
fillConditionFields(ctx, conditions);
|
||||
SqlBuildParam param = new SqlBuildParam();
|
||||
param.setSqlType(SqlType.DELETE);
|
||||
param.setTableName(ctx.getTableName());
|
||||
param.setConditions(conditions);
|
||||
|
||||
Map<String, Object> sqlMap = generateSql(param);
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
try {
|
||||
return agent.execute((String) sqlMap.get("sql"), (List<Object>) sqlMap.get("params"));
|
||||
}catch (Exception e){
|
||||
log.error("执行sql为: " + sqlMap.get("sql"));
|
||||
log.error("执行sql参数为: " + JsonUtils.toJSONString(sqlMap.get("params")));
|
||||
log.error(e.getMessage(),e);
|
||||
}finally {
|
||||
agent.close();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* ========== 构建 FormColumn ========== */
|
||||
|
||||
/*填充结果字段*/
|
||||
private static FormColumn buildFormColumn(Map<String, Object> row,
|
||||
TableContext ctx,
|
||||
boolean changeEnum) {
|
||||
FormColumn column = new FormColumn();
|
||||
try {
|
||||
List<FormFieldVo> vos = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, Object> e : row.entrySet()) {
|
||||
FormFieldBean field = ctx.getFieldMap().get(e.getKey());
|
||||
if (field == null) continue;
|
||||
|
||||
Object value = e.getValue();
|
||||
if (changeEnum && field.isEnumField()) {
|
||||
value = EnumMapUtils.getEnumShowValue(value);
|
||||
}
|
||||
// 枚举、部门、成员等特殊字段处理
|
||||
// value = handleFieldSpecialType(field, value);
|
||||
FormFieldVo vo = new FormFieldVo();
|
||||
vo.setDisplayName(field.getDisplay());
|
||||
vo.setValue(value);
|
||||
vos.add(vo);
|
||||
}
|
||||
|
||||
column.setVos(vos);
|
||||
|
||||
Object idVal = row.get("ID");
|
||||
if (idVal == null) idVal = row.get("id");
|
||||
if (idVal != null) column.setId(String.valueOf(idVal));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("构建 FormColumn 失败", e);
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
private static Object handleFieldSpecialType(FormFieldBean field, Object value) throws BusinessException {
|
||||
if (value == null) return null;
|
||||
|
||||
switch (field.getInputType()) {
|
||||
case "select":
|
||||
if (field.isEnumField()) {
|
||||
return EnumMapUtils.getEnumShowValue(value);
|
||||
}
|
||||
break;
|
||||
case "department":
|
||||
case "account":
|
||||
case "member":
|
||||
case "radio":
|
||||
case "checkbox":
|
||||
case "date":
|
||||
case "text":
|
||||
case "image":
|
||||
case "attachment":
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Map<String, Object> buildCountSql(
|
||||
String countField,
|
||||
String tableName,
|
||||
List<FormWhereCondition> conditions) {
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT count(*) as countnum FROM ")
|
||||
.append(tableName);
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
sql.append(buildWhereClause(conditions, params));
|
||||
|
||||
return buildResult(sql, params);
|
||||
}
|
||||
|
||||
private static Map<String, Object> buildSelectSql(
|
||||
String tableName,
|
||||
List<String> queryColumns,
|
||||
List<FormWhereCondition> conditions,
|
||||
Integer limit,
|
||||
Integer offset,
|
||||
String orderField) {
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT ");
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (queryColumns == null || queryColumns.isEmpty()) {
|
||||
sql.append("*");
|
||||
} else {
|
||||
for (int i = 0; i < queryColumns.size(); i++) {
|
||||
sql.append(queryColumns.get(i));
|
||||
if (i < queryColumns.size() - 1) {
|
||||
sql.append(",");
|
||||
}
|
||||
}
|
||||
sql.append(",ID");
|
||||
}
|
||||
|
||||
sql.append(" FROM ").append(tableName);
|
||||
sql.append(buildWhereClause(conditions, params));
|
||||
if(orderField == null) {
|
||||
sql.append(" order by start_date desc");
|
||||
}else {
|
||||
sql.append(" order by "+ orderField +" desc");
|
||||
}
|
||||
if(limit != null && offset != null) {
|
||||
sql.append(" "+ offset + "," + limit);
|
||||
}
|
||||
sql.append(";");
|
||||
return buildResult(sql, params);
|
||||
}
|
||||
|
||||
private static Map<String, Object> buildUpdateSql(
|
||||
String tableName,
|
||||
List<FormUpdateField> fields,
|
||||
List<FormWhereCondition> conditions) {
|
||||
|
||||
if (fields == null || fields.isEmpty()) {
|
||||
throw new IllegalArgumentException("Update fields cannot be empty");
|
||||
}
|
||||
if (conditions == null || conditions.isEmpty()) {
|
||||
throw new IllegalArgumentException("UPDATE must have WHERE conditions");
|
||||
}
|
||||
|
||||
StringBuilder sql = new StringBuilder("UPDATE ")
|
||||
.append(tableName)
|
||||
.append(" SET ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
int count = 0;
|
||||
|
||||
for (FormUpdateField f : fields) {
|
||||
if (f.getValue() == null || "".equals(f.getValue()) || "null".equals(f.getValue())) {
|
||||
continue;
|
||||
}
|
||||
if (count++ > 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
if (f.getValue() instanceof String && ((String) f.getValue()).startsWith("DATE>")) {
|
||||
sql.append(f.getFieldName()).append(" = TO_DATE(?, 'YYYY-MM-DD')");
|
||||
params.add(((String) f.getValue()).substring(5));
|
||||
} else {
|
||||
sql.append(f.getFieldName()).append(" = ?");
|
||||
params.add(f.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
throw new IllegalArgumentException("No valid update fields");
|
||||
}
|
||||
|
||||
sql.append(buildWhereClause(conditions, params));
|
||||
return buildResult(sql, params);
|
||||
}
|
||||
|
||||
private static Map<String, Object> buildDeleteSql(
|
||||
String tableName,
|
||||
List<FormWhereCondition> conditions) {
|
||||
|
||||
if (conditions == null || conditions.isEmpty()) {
|
||||
throw new IllegalArgumentException("DELETE must have WHERE conditions");
|
||||
}
|
||||
|
||||
StringBuilder values = new StringBuilder();
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
StringBuilder sql = new StringBuilder("DELETE FROM ")
|
||||
.append(tableName);
|
||||
|
||||
sql.append(buildWhereClause(conditions, params));
|
||||
return buildResult(sql, params);
|
||||
}
|
||||
|
||||
private static Map<String, Object> buildInsertSql(
|
||||
String tableName,
|
||||
Map<String, Object> data) {
|
||||
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new IllegalArgumentException("Insert data cannot be empty");
|
||||
}
|
||||
|
||||
StringBuilder columns = new StringBuilder();
|
||||
StringBuilder values = new StringBuilder();
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, Object> e : data.entrySet()) {
|
||||
if (columns.length() > 0) {
|
||||
columns.append(",");
|
||||
values.append(",");
|
||||
}
|
||||
columns.append(e.getKey());
|
||||
values.append("?");
|
||||
params.add(e.getValue());
|
||||
}
|
||||
|
||||
StringBuilder sql = new StringBuilder("INSERT INTO ")
|
||||
.append(tableName)
|
||||
.append(" (")
|
||||
.append(columns)
|
||||
.append(") VALUES (")
|
||||
.append(values)
|
||||
.append(")");
|
||||
|
||||
return buildResult(sql, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态生成 WHERE 子句
|
||||
* @param conditions 条件集合
|
||||
* @param params 参数列表(引用传递)
|
||||
* @return 拼接后的 WHERE 子句(包含 WHERE 关键字)
|
||||
*/
|
||||
private static String buildWhereClause(List<FormWhereCondition> conditions, List<Object> params) {
|
||||
if (conditions == null || conditions.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder whereCause = new StringBuilder(" WHERE ");
|
||||
for (int i = 0; i < conditions.size(); i++) {
|
||||
FormWhereCondition c = conditions.get(i);
|
||||
// 左括号
|
||||
if (c.isStartWithBracket()) {
|
||||
whereCause.append("(");
|
||||
}
|
||||
String field = c.getFieldName();
|
||||
ClauseFactor factor = c.getClauseFactor();
|
||||
String operator = parseOperator(factor);
|
||||
// NULL / NOT NULL
|
||||
if (factor.isNullType()) {
|
||||
whereCause.append(field).append(" ").append(operator);
|
||||
} else if (factor.isInType()) {
|
||||
appendInClause(whereCause, field, operator, c.getValue(), params);
|
||||
} else {
|
||||
String placeholder = "?";
|
||||
// 函数模板(如 TO_DATE(?))
|
||||
if (c.getIndex() != null) {
|
||||
placeholder = c.getIndex();
|
||||
}
|
||||
whereCause.append(field).append(" ").append(operator).append(" ").append(placeholder);
|
||||
if (ClauseFactor.LIKE.equals(factor)) {
|
||||
params.add("%" + c.getValue() + "%");
|
||||
} else {
|
||||
params.add(c.getValue());
|
||||
}
|
||||
}
|
||||
// 右括号
|
||||
if (c.isEndWithBracket()) {
|
||||
whereCause.append(")");
|
||||
}
|
||||
// AND / OR
|
||||
if (i < conditions.size() - 1) {
|
||||
whereCause.append(" ").append(c.getConcatFactor()).append(" ");
|
||||
}
|
||||
}
|
||||
return whereCause.toString();
|
||||
}
|
||||
|
||||
private static void appendInClause(
|
||||
StringBuilder sql,
|
||||
String field,
|
||||
String operator,
|
||||
Object value,
|
||||
List<Object> params) {
|
||||
if (!(value instanceof Collection)) {
|
||||
throw new IllegalArgumentException("IN 条件的值必须是 Collection");
|
||||
}
|
||||
Collection<?> values = (Collection<?>) value;
|
||||
if (values.isEmpty()) {
|
||||
// 防止 SQL 语法错误
|
||||
sql.append("1 = 0");
|
||||
return;
|
||||
}
|
||||
sql.append(field).append(" ").append(operator).append(" (");
|
||||
int index = 0;
|
||||
for (Object v : values) {
|
||||
if (index > 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
params.add(v);
|
||||
index++;
|
||||
}
|
||||
sql.append(")");
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析运算符映射(eq -> =, lt -> < 等)
|
||||
*/
|
||||
private static String parseOperator(ClauseFactor factor) {
|
||||
if(factor == null) {
|
||||
return "=";
|
||||
}
|
||||
switch (factor) {
|
||||
case EQ: return "=";
|
||||
case GT: return ">";
|
||||
case GE: return ">=";
|
||||
case LT: return "<";
|
||||
case LE: return "<=";
|
||||
case LIKE: return "LIKE";
|
||||
case NULL: return "IS NULL"; // 空值判断
|
||||
case NOT_NULL: return "IS NOT NULL"; // 非空判断
|
||||
default: throw new UnsupportedOperationException("不支持的运算符: " + factor);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, Object> buildResult(StringBuilder sql, List<Object> params) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("sql", sql.toString());
|
||||
result.put("params", params);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, Object> generateSql(SqlBuildParam param) {
|
||||
|
||||
if (param == null || param.getSqlType() == null) {
|
||||
throw new IllegalArgumentException("SqlBuildParam or SqlType cannot be null");
|
||||
}
|
||||
|
||||
switch (param.getSqlType()) {
|
||||
case COUNT:
|
||||
return buildCountSql(
|
||||
param.getCountField(),
|
||||
param.getTableName(),
|
||||
param.getConditions()
|
||||
);
|
||||
case SELECT:
|
||||
return buildSelectSql(
|
||||
param.getTableName(),
|
||||
param.getQueryColumns(),
|
||||
param.getConditions(),
|
||||
param.getLimit(),
|
||||
param.getOffset(),
|
||||
param.getOrderField()
|
||||
);
|
||||
case UPDATE:
|
||||
return buildUpdateSql(
|
||||
param.getTableName(),
|
||||
param.getUpdateFields(),
|
||||
param.getConditions()
|
||||
);
|
||||
case INSERT:
|
||||
return buildInsertSql(
|
||||
param.getTableName(),
|
||||
param.getInsertData()
|
||||
);
|
||||
case DELETE:
|
||||
return buildDeleteSql(
|
||||
param.getTableName(),
|
||||
param.getConditions()
|
||||
);
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unsupported SqlType: " + param.getSqlType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
public class FormUpdateField {
|
||||
private String display;
|
||||
private String fieldName;
|
||||
private Object value;
|
||||
|
||||
public FormUpdateField(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public FormUpdateField() {
|
||||
}
|
||||
|
||||
public static FormUpdateField build() {
|
||||
return new FormUpdateField();
|
||||
}
|
||||
|
||||
public FormUpdateField display(String display) {
|
||||
this.display = display;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FormUpdateField value(String value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FormUpdateField fieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(String display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public void setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FormWhereCondition {
|
||||
private String display;
|
||||
private String fieldName; //字段名
|
||||
private Object value; //值
|
||||
private List<Object> values; //值
|
||||
private ClauseFactor clauseFactor; //条件因子 eq lt gt not_null null
|
||||
private ClauseFactor concatFactor = ClauseFactor.AND; //拼接因子
|
||||
private boolean startWithBracket = false; //是否以括号开头生成子条件
|
||||
private boolean endWithBracket = false; //是否以括号结尾结束子条件
|
||||
private String index;
|
||||
|
||||
public FormWhereCondition() {
|
||||
this.values = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(String display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public static FormWhereCondition build() {
|
||||
return new FormWhereCondition();
|
||||
}
|
||||
|
||||
public FormWhereCondition display(String display) {
|
||||
this.display = display;
|
||||
return this;
|
||||
}
|
||||
public FormWhereCondition value(Object value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
public FormWhereCondition clauseFactor(ClauseFactor clauseFactor) {
|
||||
this.clauseFactor = clauseFactor;
|
||||
return this;
|
||||
}
|
||||
public FormWhereCondition index(String index) {
|
||||
this.index = index;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FormWhereCondition startWithBracket(boolean startWithBracket) {
|
||||
this.startWithBracket = startWithBracket;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FormWhereCondition endWithBracket(boolean endWithBracket) {
|
||||
this.endWithBracket = endWithBracket;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FormWhereCondition concatFactor(ClauseFactor concatFactor) {
|
||||
this.concatFactor = concatFactor;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public FormWhereCondition(Object value, ClauseFactor clauseFactor) {
|
||||
this.value = value;
|
||||
this.clauseFactor = clauseFactor;
|
||||
}
|
||||
|
||||
public boolean isStartWithBracket() {
|
||||
return startWithBracket;
|
||||
}
|
||||
|
||||
public void setStartWithBracket(boolean startWithBracket) {
|
||||
this.startWithBracket = startWithBracket;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public void setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public ClauseFactor getClauseFactor() {
|
||||
return clauseFactor;
|
||||
}
|
||||
|
||||
public void setClauseFactor(ClauseFactor clauseFactor) {
|
||||
this.clauseFactor = clauseFactor;
|
||||
}
|
||||
|
||||
public ClauseFactor getConcatFactor() {
|
||||
return concatFactor;
|
||||
}
|
||||
|
||||
public void setConcatFactor(ClauseFactor concatFactor) {
|
||||
this.concatFactor = concatFactor;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(String index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public boolean isEndWithBracket() {
|
||||
return endWithBracket;
|
||||
}
|
||||
|
||||
public void setEndWithBracket(boolean endWithBracket) {
|
||||
this.endWithBracket = endWithBracket;
|
||||
}
|
||||
|
||||
public List<Object> getValues() {
|
||||
return values;
|
||||
}
|
||||
public FormWhereCondition addValue(Object value) {
|
||||
this.values.add(value);
|
||||
return this;
|
||||
}
|
||||
public void setValues(List<Object> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SqlBuildParam {
|
||||
|
||||
private SqlType sqlType;
|
||||
// 公共
|
||||
private String tableName;
|
||||
// SELECT / COUNT
|
||||
private List<String> queryColumns;
|
||||
private List<FormWhereCondition> conditions;
|
||||
// UPDATE
|
||||
private List<FormUpdateField> updateFields;
|
||||
// INSERT
|
||||
private Map<String, Object> insertData;
|
||||
private Integer pageNo;
|
||||
private Integer pageSize;
|
||||
private String orderField;
|
||||
private String countField;
|
||||
|
||||
public SqlType getSqlType() {
|
||||
return sqlType;
|
||||
}
|
||||
|
||||
public void setSqlType(SqlType sqlType) {
|
||||
this.sqlType = sqlType;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public List<String> getQueryColumns() {
|
||||
return queryColumns;
|
||||
}
|
||||
|
||||
public void setQueryColumns(List<String> queryColumns) {
|
||||
this.queryColumns = queryColumns;
|
||||
}
|
||||
|
||||
public List<FormWhereCondition> getConditions() {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
public void setConditions(List<FormWhereCondition> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
public List<FormUpdateField> getUpdateFields() {
|
||||
return updateFields;
|
||||
}
|
||||
|
||||
public void setUpdateFields(List<FormUpdateField> updateFields) {
|
||||
this.updateFields = updateFields;
|
||||
}
|
||||
|
||||
public Map<String, Object> getInsertData() {
|
||||
return insertData;
|
||||
}
|
||||
|
||||
public void setInsertData(Map<String, Object> insertData) {
|
||||
this.insertData = insertData;
|
||||
}
|
||||
|
||||
public Integer getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
public void setPageNo(Integer pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public String getOrderField() {
|
||||
return orderField;
|
||||
}
|
||||
|
||||
public void setOrderField(String orderField) {
|
||||
this.orderField = orderField;
|
||||
}
|
||||
public Integer getLimit() {
|
||||
if(this.pageSize == null) {
|
||||
return null;
|
||||
}
|
||||
return this.pageSize;
|
||||
}
|
||||
public Integer getOffset() {
|
||||
if(this.pageSize == null) {
|
||||
return null;
|
||||
}
|
||||
return (this.pageNo - 1) * this.pageSize;
|
||||
}
|
||||
|
||||
public String getCountField() {
|
||||
return countField;
|
||||
}
|
||||
|
||||
public void setCountField(String countField) {
|
||||
this.countField = countField;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
public enum SqlType {
|
||||
SELECT,
|
||||
COUNT,
|
||||
UPDATE,
|
||||
INSERT,
|
||||
DELETE
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.seeyon.utils.form;
|
||||
|
||||
import com.seeyon.cap4.form.bean.FormFieldBean;
|
||||
import com.seeyon.cap4.form.bean.FormTableBean;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class TableContext {
|
||||
|
||||
private final FormTableBean tableBean;
|
||||
private final String tableName;
|
||||
private final Map<String, FormFieldBean> fieldMap;
|
||||
|
||||
public TableContext(FormTableBean tableBean) {
|
||||
this.tableBean = tableBean;
|
||||
this.tableName = tableBean.getTableName();
|
||||
this.fieldMap = tableBean.getFieldMap4Name();
|
||||
}
|
||||
|
||||
public FormTableBean getTableBean() { return tableBean; }
|
||||
public String getTableName() { return tableName; }
|
||||
public Map<String, FormFieldBean> getFieldMap() { return fieldMap; }
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
package com.seeyon.utils.http;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.entity.mime.HttpMultipartMode;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @ClassName: HttpClient
|
||||
* @Description: HTTP请求工具类
|
||||
* @Author: GiikJc
|
||||
* @Date: 2022/7/12 15:03
|
||||
*/
|
||||
|
||||
/**
|
||||
* 发送Get请求:HttpResponse httpGet(String url,Map<String,String> headers,String encode)
|
||||
*发送Post请求,同表单Post提交:HttpResponse httpPostForm(String url,Map<String,String> params, Map<String,String> headers,String encode)
|
||||
*发送Post Raw请求:HttpResponse httpPostRaw(String url,String stringJson,Map<String,String> headers, String encode)
|
||||
*发送Put Raw请求:HttpResponse httpPutRaw(String url,String stringJson,Map<String,String> headers, String encode)
|
||||
*发送Delete请求:HttpResponse httpDelete(String url,Map<String,String> headers,String encode)
|
||||
*/
|
||||
public class HttpClient {
|
||||
|
||||
|
||||
/**
|
||||
* 发送 HTTP GET 请求下载文件
|
||||
* @param url 下载文件的 URL
|
||||
* @param headers 请求头
|
||||
* @param savePath 文件保存的路径
|
||||
* @param encode 文件内容的编码
|
||||
* @return 下载成功返回 true,失败返回 false
|
||||
*/
|
||||
public static boolean httpDownloadFile(String url, Map<String, String> headers, String savePath, String encode) {
|
||||
if (encode == null) {
|
||||
encode = "utf-8"; // 默认字符编码
|
||||
}
|
||||
|
||||
CloseableHttpClient httpClient = null;
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
|
||||
try {
|
||||
// 创建 HttpClient 实例
|
||||
httpClient = HttpClients.createDefault();
|
||||
HttpGet httpGet = new HttpGet(url);
|
||||
|
||||
// 设置请求头
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpGet.setHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// 执行请求
|
||||
httpResponse = httpClient.execute(httpGet);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
|
||||
// 检查响应状态码
|
||||
if (httpResponse.getStatusLine().getStatusCode() == 200) {
|
||||
inputStream = entity.getContent();
|
||||
|
||||
// 创建输出流,将文件保存到本地
|
||||
outputStream = new FileOutputStream(savePath);
|
||||
|
||||
// 设置缓冲区
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
// 文件下载成功
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("Download failed, HTTP error code: " + httpResponse.getStatusLine().getStatusCode());
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
}
|
||||
if (httpResponse != null) {
|
||||
httpResponse.close();
|
||||
}
|
||||
if (httpClient != null) {
|
||||
httpClient.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送http get请求
|
||||
*/
|
||||
public static String httpGet(String url,Map<String,String> headers,String encode){
|
||||
|
||||
if(encode == null){
|
||||
encode = "utf-8";
|
||||
}
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
CloseableHttpClient closeableHttpClient = null;
|
||||
String content = null;
|
||||
//since 4.3 不再使用 DefaultHttpClient
|
||||
try {
|
||||
closeableHttpClient = HttpClientBuilder.create().build();
|
||||
HttpGet httpGet = new HttpGet(url);
|
||||
//设置header
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpGet.setHeader(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
httpResponse = closeableHttpClient.execute(httpGet);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
content = EntityUtils.toString(entity, encode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
httpResponse.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try { //关闭连接、释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
/**
|
||||
* 发送 http post 请求,参数以form表单键值对的形式提交。
|
||||
*/
|
||||
public static String httpPostForm(String url,Map<String,String> params, Map<String,String> headers,String encode){
|
||||
|
||||
if(encode == null){
|
||||
encode = "utf-8";
|
||||
}
|
||||
|
||||
String content = null;
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
CloseableHttpClient closeableHttpClient = null;
|
||||
try {
|
||||
|
||||
closeableHttpClient = HttpClients.createDefault();
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
|
||||
//设置header
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpost.setHeader(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
//组织请求参数
|
||||
List<NameValuePair> paramList = new ArrayList <NameValuePair>();
|
||||
if(params != null && params.size() > 0){
|
||||
Set<String> keySet = params.keySet();
|
||||
for(String key : keySet) {
|
||||
paramList.add(new BasicNameValuePair(key, params.get(key)));
|
||||
}
|
||||
}
|
||||
httpost.setEntity(new UrlEncodedFormEntity(paramList, encode));
|
||||
|
||||
|
||||
httpResponse = closeableHttpClient.execute(httpost);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
content = EntityUtils.toString(entity, encode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
httpResponse.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try { //关闭连接、释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送 http post 请求,参数以原生字符串进行提交
|
||||
* @param url
|
||||
* @param encode
|
||||
* @return
|
||||
*/
|
||||
public static String httpPostRaw(String url,String stringJson,Map<String,String> headers, String encode){
|
||||
if(encode == null){
|
||||
encode = "utf-8";
|
||||
}
|
||||
String content = null;
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
CloseableHttpClient closeableHttpClient = null;
|
||||
try {
|
||||
|
||||
//HttpClients.createDefault()等价于 HttpClientBuilder.create().build();
|
||||
closeableHttpClient = HttpClients.createDefault();
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
|
||||
//设置header
|
||||
httpost.setHeader("Content-type", "application/json");
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpost.setHeader(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
//组织请求参数
|
||||
StringEntity stringEntity = new StringEntity(stringJson, encode);
|
||||
httpost.setEntity(stringEntity);
|
||||
|
||||
|
||||
//响应信息
|
||||
httpResponse = closeableHttpClient.execute(httpost);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
content = EntityUtils.toString(entity, encode);
|
||||
} catch (Exception e) {
|
||||
|
||||
}finally{
|
||||
try {
|
||||
httpResponse.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
try { //关闭连接、释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送 http put 请求,参数以原生字符串进行提交
|
||||
* @param url
|
||||
* @param encode
|
||||
* @return
|
||||
*/
|
||||
public static String httpPutRaw(String url,String stringJson,Map<String,String> headers, String encode){
|
||||
if(encode == null){
|
||||
encode = "utf-8";
|
||||
}
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
CloseableHttpClient closeableHttpClient = null;
|
||||
String content = null;
|
||||
//since 4.3 不再使用 DefaultHttpClient
|
||||
try {
|
||||
|
||||
//HttpClients.createDefault()等价于 HttpClientBuilder.create().build();
|
||||
closeableHttpClient = HttpClients.createDefault();
|
||||
HttpPut httpput = new HttpPut(url);
|
||||
|
||||
//设置header
|
||||
httpput.setHeader("Content-type", "application/json");
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpput.setHeader(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
//组织请求参数
|
||||
StringEntity stringEntity = new StringEntity(stringJson, encode);
|
||||
httpput.setEntity(stringEntity);
|
||||
//响应信息
|
||||
httpResponse = closeableHttpClient.execute(httpput);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
content = EntityUtils.toString(entity, encode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
httpResponse.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
closeableHttpClient.close(); //关闭连接、释放资源
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
/**
|
||||
* 发送http delete请求
|
||||
*/
|
||||
public static String httpDelete(String url,Map<String,String> headers,String encode){
|
||||
if(encode == null){
|
||||
encode = "utf-8";
|
||||
}
|
||||
String content = null;
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
CloseableHttpClient closeableHttpClient = null;
|
||||
try {
|
||||
//since 4.3 不再使用 DefaultHttpClient
|
||||
closeableHttpClient = HttpClientBuilder.create().build();
|
||||
HttpDelete httpdelete = new HttpDelete(url);
|
||||
//设置header
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpdelete.setHeader(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
httpResponse = closeableHttpClient.execute(httpdelete);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
content = EntityUtils.toString(entity, encode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
httpResponse.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try { //关闭连接、释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送 http post 请求,支持文件上传
|
||||
*/
|
||||
public static String httpPostFormMultipart(String url,Map<String,String> params, List<File> files,Map<String,String> headers,String encode){
|
||||
if(encode == null){
|
||||
encode = "utf-8";
|
||||
}
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
CloseableHttpClient closeableHttpClient = null;
|
||||
String content = null;
|
||||
//since 4.3 不再使用 DefaultHttpClient
|
||||
try {
|
||||
|
||||
closeableHttpClient = HttpClients.createDefault();
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
|
||||
//设置header
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpost.setHeader(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
MultipartEntityBuilder mEntityBuilder = MultipartEntityBuilder.create();
|
||||
mEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
mEntityBuilder.setCharset(Charset.forName(encode));
|
||||
|
||||
// 普通参数
|
||||
ContentType contentType = ContentType.create("text/plain",Charset.forName(encode));//解决中文乱码
|
||||
if (params != null && params.size() > 0) {
|
||||
Set<String> keySet = params.keySet();
|
||||
for (String key : keySet) {
|
||||
mEntityBuilder.addTextBody(key, params.get(key),contentType);
|
||||
}
|
||||
}
|
||||
//二进制参数
|
||||
if (files != null && files.size() > 0) {
|
||||
for (File file : files) {
|
||||
mEntityBuilder.addBinaryBody("file", file);
|
||||
}
|
||||
}
|
||||
httpost.setEntity(mEntityBuilder.build());
|
||||
httpResponse = closeableHttpClient.execute(httpost);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
content = EntityUtils.toString(entity, encode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
httpResponse.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try { //关闭连接、释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.seeyon.utils.http;
|
||||
|
||||
public class OaResp {
|
||||
|
||||
private Integer code;
|
||||
private String message;
|
||||
private Object data;
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.seeyon.utils.http;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.seeyon.aicloud.common.JsonUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class OaRestClient {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OaRestClient.class);
|
||||
private String oaHost;
|
||||
private String restName;
|
||||
private String restPwd;
|
||||
private Boolean cacheToken = false;
|
||||
private ConcurrentHashMap<String, String> tokenCache = new ConcurrentHashMap<>();
|
||||
|
||||
public OaRestClient(String oaHost, String restName, String restPwd, Boolean cacheToken) {
|
||||
this.oaHost = oaHost;
|
||||
this.restName = restName;
|
||||
this.restPwd = restPwd;
|
||||
this.cacheToken = cacheToken;
|
||||
}
|
||||
|
||||
public OaResp sendGet(String bizName, String url) throws Exception {
|
||||
Map<String,String> headers = new HashMap<>();
|
||||
headers.put("token",getToken());
|
||||
log.info(bizName + "请求链接为:" + url);
|
||||
String respStr = HttpClient.httpGet(oaHost + "/seeyon/rest" + url,headers,null);
|
||||
log.info(bizName + "响应结果为:" + respStr);
|
||||
return resovleResp(respStr);
|
||||
}
|
||||
|
||||
public OaResp sendPost(String bizName,String url,Map<String,Object> params,String token) throws Exception {
|
||||
Map<String,String> headers = new HashMap<>();
|
||||
headers.put("token",token);
|
||||
String paramStr = JsonUtils.toJSONString(params);
|
||||
log.info(bizName + "请求参数为:" + paramStr);
|
||||
String respStr = HttpClient.httpPostRaw(oaHost + "/seeyon/rest" + url,paramStr,headers,null);
|
||||
log.info(bizName + "响应结果为:" + respStr);
|
||||
return resovleResp(respStr);
|
||||
}
|
||||
|
||||
|
||||
public OaResp sendPost(String bizName,String url,Map<String,Object> params) throws Exception {
|
||||
// Map<String,String> headers = new HashMap<>();
|
||||
// headers.put("token",getToken());
|
||||
// String paramStr = JsonUtils.toJSONString(params);
|
||||
// log.info(bizName + "请求参数为:" + paramStr);
|
||||
// String respStr = HttpClient.httpPostRaw(oaHost + "/seeyon/rest" + url,paramStr,headers,null);
|
||||
// log.info(bizName + "响应结果为:" + respStr);
|
||||
// return resovleResp(respStr);
|
||||
return sendPost(bizName,url,params,getToken());
|
||||
}
|
||||
|
||||
OaResp resovleResp(String respStr){
|
||||
return JsonUtils.parseObject(respStr,OaResp.class);
|
||||
}
|
||||
|
||||
private String applyToken() {
|
||||
String url = oaHost +"/seeyon/rest/token/" + restName + "/" + restPwd + "?loginName=" + restName;
|
||||
DefaultHttpClient client = new DefaultHttpClient();
|
||||
String result = "";
|
||||
HttpGet get = new HttpGet(url);
|
||||
// 添加 Headers 信息
|
||||
get.addHeader(new BasicHeader("Accept", "application/json"));
|
||||
try {
|
||||
HttpResponse res = client.execute(get);
|
||||
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
result = EntityUtils.toString(res.getEntity());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String token = null;
|
||||
if(result.contains("{")) {
|
||||
JSONObject jsObj = JSONObject.parseObject(result);
|
||||
token = jsObj.get("id").toString();
|
||||
}else {
|
||||
token = result;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
private String getToken(){
|
||||
if(cacheToken) {
|
||||
String token = tokenCache.get(restName);
|
||||
if(token != null && !checkExpire(token)) {
|
||||
return token;
|
||||
}else {
|
||||
String tokenStr = applyToken();
|
||||
tokenCache.put(restName, tokenStr);
|
||||
return tokenStr;
|
||||
}
|
||||
}
|
||||
return applyToken();
|
||||
}
|
||||
|
||||
private boolean checkExpire(String token) {
|
||||
String url = oaHost + "/seeyon/rest/cap4/batch/refresh";
|
||||
try{
|
||||
Map<String,String> headers = new HashMap<>();
|
||||
headers.put("token",token);
|
||||
headers.put("loginName",restName);
|
||||
String respStr = HttpClient.httpPostRaw(url, null, headers,null);
|
||||
Map map = JsonUtils.parseObject(respStr, Map.class);
|
||||
if("0".equals(map.get("code"))) {
|
||||
return false;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,4 +2,5 @@
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans default-autowire="byName">
|
||||
<bean name="/formRedirectController.do" class="com.seeyon.apps.src_flowIntegration.controller.FormRedirectController" />
|
||||
<bean name="/urlSkipController.do" class="com.seeyon.apps.src_flowIntegration.controller.URLSkipController" />
|
||||
</beans>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans default-autowire="byName">
|
||||
<bean id="interestMeasurementFieldCtrl" class="com.seeyon.apps.src_flowIntegration.fieldCtrl.URLSkipFieldCtrl" />
|
||||
</beans>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
.customButton_class_box {
|
||||
width: 100%;
|
||||
line-height: 24px;
|
||||
height:24px;
|
||||
color: #1f85ec;
|
||||
cursor: pointer;
|
||||
font-family: "Microsoft YaHei"!important;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
word-break:keep-all;
|
||||
}
|
||||
.customButton_box_content{
|
||||
width: 100%;
|
||||
height: 24px;
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing : border-box;
|
||||
-moz-box-sizing : border-box;
|
||||
text-align: center;
|
||||
outline: none;
|
||||
border: 1px solid #1f85ec;
|
||||
background-color: #fff;
|
||||
border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
@@ -0,0 +1,13 @@
|
||||
.relation_container .panel_bottom .zidong_guanlian .guanlian_map{
|
||||
padding-left: 10px;
|
||||
}
|
||||
.relation_container .panel_bottom .zidong_guanlian .guanlian_map .error-title{
|
||||
margin: 0 2px;
|
||||
visibility: hidden;
|
||||
}
|
||||
.relation_container .panel_bottom .zidong_guanlian .guanlian_map .error-title.active{
|
||||
visibility: visible;
|
||||
}
|
||||
.relation_container .biz_groupguanlian .div_sel3.active{
|
||||
border-color: red;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
body{
|
||||
font-family: "microsoft yahei";
|
||||
}
|
||||
#tab {
|
||||
height: 26px;
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #666666;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
#tab span {
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
width: 50%;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
color: #666666;
|
||||
margin-right: 20px;
|
||||
padding: 0 5px 0 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#tab span.select {
|
||||
border-bottom: 2px solid #2453b3;
|
||||
color: #2453b3;
|
||||
}
|
||||
|
||||
.list{
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 14px;
|
||||
height: 310px;
|
||||
overflow: auto;
|
||||
}
|
||||
.list .active{
|
||||
background-color: #1F85EC;
|
||||
border: 1px solid #1F85EC;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.list li{
|
||||
cursor: pointer;
|
||||
margin: 3px 0 3px 0;
|
||||
}
|
||||
.list span{
|
||||
display: inline-block;
|
||||
background: url("img/icon16.png") -32px -240px no-repeat scroll transparent;
|
||||
margin-right: 2px;
|
||||
vertical-align: middle;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
.search-box {
|
||||
height: 20px;
|
||||
margin: 10px 0 10px 0;
|
||||
position: relative;
|
||||
}
|
||||
.cap-icon-sousuo {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 170px;
|
||||
color: #1F85EC;
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.cap-icon-sousuo:before {
|
||||
content: "";
|
||||
background: url("img/icon16.png") -192px -176px no-repeat;
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
width: 16px;
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.search-input {
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #D4D4D4;
|
||||
border-radius: 100px;
|
||||
min-height: 20px;
|
||||
width: 150px;
|
||||
padding-right: 35px;
|
||||
padding-left: 10px;
|
||||
outline: none;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="../css/setTemplate.css"/>
|
||||
<script src="/seeyon/m3/apps/v5/commons/jquery/jquery-2.1.4.min.js"></script>
|
||||
<script src="../js/setTemplate.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="tab">
|
||||
<span id="tab_queryList" class="select">选择底表</span>
|
||||
</div>
|
||||
|
||||
<div id="queryList">
|
||||
<div class="search-box">
|
||||
<i class="cap-icon-sousuo" onclick="search()"></i>
|
||||
<input type="text" class="search-input" id="search_query">
|
||||
</div>
|
||||
<ul class="list"></ul>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
//----------------------------------
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,188 @@
|
||||
//==本JS是加载Lodop插件或Web打印服务CLodop/Lodop7的综合示例,可直接使用,建议理解后融入自己程序==
|
||||
|
||||
//用双端口加载主JS文件Lodop.js(或CLodopfuncs.js兼容老版本)以防其中某端口被占:
|
||||
var MainJS ="CLodopfuncs.js",
|
||||
URL_WS1 = "ws://localhost:8000/"+MainJS, //ws用8000/18000
|
||||
URL_WS2 = "ws://localhost:18000/"+MainJS,
|
||||
URL_HTTP1 = "http://localhost:8000/"+MainJS, //http用8000/18000
|
||||
URL_HTTP2 = "http://localhost:18000/"+MainJS,
|
||||
URL_HTTP3 = "https://localhost.lodop.net:8443/"+MainJS; //https用8000/8443
|
||||
|
||||
var CreatedOKLodopObject, CLodopIsLocal, LoadJsState;
|
||||
|
||||
//==判断是否需要CLodop(那些不支持插件的浏览器):==
|
||||
function needCLodop() {
|
||||
try {
|
||||
var ua = navigator.userAgent;
|
||||
if (ua.match(/Windows\sPhone/i) ||
|
||||
ua.match(/iPhone|iPod|iPad/i) ||
|
||||
ua.match(/Android/i) ||
|
||||
ua.match(/Edge\D?\d+/i))
|
||||
return true;
|
||||
var verTrident = ua.match(/Trident\D?\d+/i);
|
||||
var verIE = ua.match(/MSIE\D?\d+/i);
|
||||
var verOPR = ua.match(/OPR\D?\d+/i);
|
||||
var verFF = ua.match(/Firefox\D?\d+/i);
|
||||
var x64 = ua.match(/x64/i);
|
||||
if ((!verTrident) && (!verIE) && (x64)) return true;
|
||||
else if (verFF) {
|
||||
verFF = verFF[0].match(/\d+/);
|
||||
if ((verFF[0] >= 41) || (x64)) return true;
|
||||
} else if (verOPR) {
|
||||
verOPR = verOPR[0].match(/\d+/);
|
||||
if (verOPR[0] >= 32) return true;
|
||||
} else if ((!verTrident) && (!verIE)) {
|
||||
var verChrome = ua.match(/Chrome\D?\d+/i);
|
||||
if (verChrome) {
|
||||
verChrome = verChrome[0].match(/\d+/);
|
||||
if (verChrome[0] >= 41) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (err) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//==检查加载成功与否,如没成功则用http(s)再试==
|
||||
//==低版本CLODOP6.561/Lodop7.043及前)用本方法==
|
||||
function checkOrTryHttp() {
|
||||
if (window.getCLodop) {
|
||||
LoadJsState = "complete";
|
||||
return true;
|
||||
}
|
||||
if (LoadJsState == "loadingB" || LoadJsState == "complete") return;
|
||||
LoadJsState = "loadingB";
|
||||
var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
|
||||
var JS1 = document.createElement("script")
|
||||
,JS2 = document.createElement("script")
|
||||
,JS3 = document.createElement("script");
|
||||
JS1.src = URL_HTTP1;
|
||||
JS2.src = URL_HTTP2;
|
||||
JS3.src = URL_HTTP3;
|
||||
JS1.onload = JS2.onload = JS3.onload = JS2.onerror = JS3.onerror=function(){LoadJsState = "complete";}
|
||||
JS1.onerror = function(e) {
|
||||
if (window.location.protocol !== 'https:')
|
||||
head.insertBefore(JS2, head.firstChild); else
|
||||
head.insertBefore(JS3, head.firstChild);
|
||||
}
|
||||
head.insertBefore(JS1,head.firstChild);
|
||||
}
|
||||
|
||||
//==加载Lodop对象的主过程:==
|
||||
(function loadCLodop(){
|
||||
if (!needCLodop()) return;
|
||||
CLodopIsLocal = !!((URL_WS1 + URL_WS2).match(/\/\/localho|\/\/127.0.0./i));
|
||||
LoadJsState = "loadingA";
|
||||
if (!window.WebSocket && window.MozWebSocket) window.WebSocket=window.MozWebSocket;
|
||||
//ws方式速度快(小于200ms)且可避免CORS错误,但要求Lodop版本足够新:
|
||||
try {
|
||||
var WSK1=new WebSocket(URL_WS1);
|
||||
WSK1.onopen = function(e) { setTimeout("checkOrTryHttp();",200); }
|
||||
WSK1.onmessage = function(e) {if (!window.getCLodop) eval(e.data);}
|
||||
WSK1.onerror = function(e) {
|
||||
var WSK2=new WebSocket(URL_WS2);
|
||||
WSK2.onopen = function(e) {setTimeout("checkOrTryHttp();",200);}
|
||||
WSK2.onmessage = function(e) {if (!window.getCLodop) eval(e.data);}
|
||||
WSK2.onerror= function(e) {checkOrTryHttp();}
|
||||
}
|
||||
} catch(e){
|
||||
checkOrTryHttp();
|
||||
}
|
||||
})();
|
||||
|
||||
//==获取LODOP对象主过程,判断是否安装、需否升级:==
|
||||
function getLodop(oOBJECT, oEMBED) {
|
||||
var strFontTag = "<br><font color='#FF00FF'>打印控件";
|
||||
var strLodopInstall = strFontTag + "未安装!点击这里<a href='install_lodop32.exe' target='_self'>执行安装</a>";
|
||||
var strLodopUpdate = strFontTag + "需要升级!点击这里<a href='install_lodop32.exe' target='_self'>执行升级</a>";
|
||||
var strLodop64Install = strFontTag + "未安装!点击这里<a href='install_lodop64.exe' target='_self'>执行安装</a>";
|
||||
var strLodop64Update = strFontTag + "需要升级!点击这里<a href='install_lodop64.exe' target='_self'>执行升级</a>";
|
||||
var strCLodopInstallA = "<br><font color='#FF00FF'>Web打印服务CLodop未安装启动,点击这里<a href='CLodop_Setup_for_Win32NT.exe' target='_self'>下载执行安装</a>";
|
||||
var strCLodopInstallB = "<br>(若此前已安装过,可<a href='CLodop.protocol:setup' target='_self'>点这里直接再次启动</a>)";
|
||||
var strCLodopUpdate = "<br><font color='#FF00FF'>Web打印服务CLodop需升级!点击这里<a href='CLodop_Setup_for_Win32NT.exe' target='_self'>执行升级</a>";
|
||||
var strLodop7FontTag = "<br><font color='#FF00FF'>Web打印服务Lodop7";
|
||||
var strLodop7HrefX86 = "点击这里<a href='Lodop7_Linux_X86_64.tar.gz' target='_self'>下载安装</a>(下载后解压,点击lodop文件开始执行)";
|
||||
var strLodop7HrefARM = "点击这里<a href='Lodop7_Linux_ARM64.tar.gz' target='_self'>下载安装</a>(下载后解压,点击lodop文件开始执行)";
|
||||
var strLodop7Install_X86 = strLodop7FontTag + "未安装启动," + strLodop7HrefX86;
|
||||
var strLodop7Install_ARM = strLodop7FontTag + "未安装启动," + strLodop7HrefARM;
|
||||
var strLodop7Update_X86 = strLodop7FontTag + "需升级," + strLodop7HrefX86;
|
||||
var strLodop7Update_ARM = strLodop7FontTag + "需升级," + strLodop7HrefARM;
|
||||
var strInstallOK = ",成功后请刷新本页面或重启浏览器。</font>";
|
||||
var LODOP;
|
||||
try {
|
||||
var isWinIE = (/MSIE/i.test(navigator.userAgent)) || (/Trident/i.test(navigator.userAgent));
|
||||
var isWinIE64 = isWinIE && (/x64/i.test(navigator.userAgent));
|
||||
var isLinuxX86 = (/Linux/i.test(navigator.platform)) && (/x86/i.test(navigator.platform));
|
||||
var isLinuxARM = (/Linux/i.test(navigator.platform)) && (/aarch/i.test(navigator.platform));
|
||||
|
||||
if (needCLodop() || isLinuxX86 || isLinuxARM) {
|
||||
try {
|
||||
LODOP = window.getCLodop();
|
||||
} catch (err) {}
|
||||
if (!LODOP && LoadJsState !== "complete") {
|
||||
if (!LoadJsState)
|
||||
alert("未曾加载Lodop主JS文件,请先调用loadCLodop过程."); else
|
||||
alert("网页还没下载完毕,请稍等一下再操作.");
|
||||
return;
|
||||
}
|
||||
var strAlertMessage;
|
||||
if (!LODOP) {
|
||||
if (isLinuxX86)
|
||||
strAlertMessage = strLodop7Install_X86;
|
||||
else if (isLinuxARM)
|
||||
strAlertMessage = strLodop7Install_ARM;
|
||||
else
|
||||
strAlertMessage = strCLodopInstallA + (CLodopIsLocal ? strCLodopInstallB : "");
|
||||
document.body.innerHTML = strAlertMessage + strInstallOK + document.body.innerHTML;
|
||||
return;
|
||||
} else {
|
||||
if (isLinuxX86 && LODOP.CVERSION < "7.0.4.3")
|
||||
strAlertMessage = strLodop7Update_X86;
|
||||
else if (isLinuxARM && LODOP.CVERSION < "7.0.4.3")
|
||||
strAlertMessage = strLodop7Update_ARM;
|
||||
else if (CLODOP.CVERSION < "6.5.7.1")
|
||||
strAlertMessage = strCLodopUpdate;
|
||||
|
||||
if (strAlertMessage)
|
||||
document.body.innerHTML = strAlertMessage + strInstallOK + document.body.innerHTML;
|
||||
}
|
||||
} else {
|
||||
//==如果页面有Lodop插件就直接使用,否则新建:==
|
||||
if (oOBJECT || oEMBED) {
|
||||
if (isWinIE)
|
||||
LODOP = oOBJECT;
|
||||
else
|
||||
LODOP = oEMBED;
|
||||
} else if (!CreatedOKLodopObject) {
|
||||
LODOP = document.createElement("object");
|
||||
LODOP.setAttribute("width", 0);
|
||||
LODOP.setAttribute("height", 0);
|
||||
LODOP.setAttribute("style", "position:absolute;left:0px;top:-100px;width:0px;height:0px;");
|
||||
if (isWinIE)
|
||||
LODOP.setAttribute("classid", "clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
|
||||
else
|
||||
LODOP.setAttribute("type", "application/x-print-lodop");
|
||||
document.documentElement.appendChild(LODOP);
|
||||
CreatedOKLodopObject = LODOP;
|
||||
} else
|
||||
LODOP = CreatedOKLodopObject;
|
||||
//==Lodop插件未安装时提示下载地址:==
|
||||
if ((!LODOP) || (!LODOP.VERSION)) {
|
||||
document.body.innerHTML = (isWinIE64 ? strLodop64Install : strLodopInstall) + strInstallOK + document.body.innerHTML;
|
||||
return LODOP;
|
||||
}
|
||||
if (LODOP.VERSION < "6.2.2.6") {
|
||||
document.body.innerHTML = (isWinIE64 ? strLodop64Update : strLodopUpdate) + strInstallOK + document.body.innerHTML;
|
||||
}
|
||||
}
|
||||
//===如下空白位置适合调用统一功能(如注册语句、语言选择等):=======================
|
||||
|
||||
|
||||
//===============================================================================
|
||||
return LODOP;
|
||||
} catch (err) {
|
||||
alert("getLodop出错:" + err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
var unflowList, param, loading, process;
|
||||
$(document).ready(function() {
|
||||
param = initParam().params;// 获取页面参数
|
||||
// 处理进度条
|
||||
process = top.$.progressBar({
|
||||
text : "加载中..."
|
||||
});
|
||||
loading = true;
|
||||
getUnflowList();
|
||||
});
|
||||
|
||||
|
||||
// 获取底表
|
||||
function getUnflowList() {
|
||||
$.ajax({
|
||||
url : "/seeyon/rest/cap4/unflow/select",
|
||||
async : true,
|
||||
success : function(data) {
|
||||
// 处理进度条
|
||||
if (loading)
|
||||
process.close();
|
||||
loading = false;
|
||||
//data = JSON.parse(data);
|
||||
var result = data.data;
|
||||
unflowList = result;
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
$("#queryList ul").append(
|
||||
$("<li id='"
|
||||
+ result[i].id
|
||||
+ "'><span class='icon'></span>"
|
||||
+ result[i].name
|
||||
+ "</li>").attr("info",
|
||||
JSON.stringify(result[i])));
|
||||
}
|
||||
$("#queryList ul").delegate(
|
||||
"li",
|
||||
"click",
|
||||
function() {
|
||||
$(this).siblings().removeClass('active').end()
|
||||
.addClass('active');
|
||||
});
|
||||
if (param && param.id) { // 激活当前项
|
||||
$('#' + param.id).trigger('click');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function search() {
|
||||
var searchValue = $("#search_query").val();
|
||||
$("#queryList ul").empty();
|
||||
for (var i = 0; i < unflowList.length; i++) {
|
||||
if (unflowList[i].name.indexOf(searchValue) != -1) {
|
||||
$("#queryList ul").append(
|
||||
$("<li><span class='icon'></span>"
|
||||
+ unflowList[i].name + "</li>").attr(
|
||||
"info", JSON.stringify(unflowList[i])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回参数获取
|
||||
function getResult() {
|
||||
return JSON.parse($("#queryList ul").find(".active").attr("info")
|
||||
|| "{}");
|
||||
}
|
||||
|
||||
// --------------------以下为固定方法,需要实现返回参数获取--------------
|
||||
|
||||
// 获取弹窗传递过来的参数
|
||||
function initParam() {
|
||||
var obj = window.parentDialogObj && (window.parentDialogObj["ctrlDialog"]);// 获取窗口对象
|
||||
if (obj && obj.getTransParams) {
|
||||
// 然后通过V5方法获取弹窗传递过来的参数
|
||||
return obj.getTransParams();
|
||||
}
|
||||
}
|
||||
|
||||
// 确定按钮调用方法,返回需要的json数据
|
||||
function OK() {
|
||||
var result = getResult();
|
||||
|
||||
if (param && param.designId !== result.designId)
|
||||
return {
|
||||
valid : true,
|
||||
data : {
|
||||
customParam : {
|
||||
templateId : result,
|
||||
mapping : null
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
valid : true,
|
||||
data : result
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
(function(f){
|
||||
var nameSpace = 'field_7310965329196191710';
|
||||
if(!window[nameSpace]){
|
||||
var Builder = f();
|
||||
window[nameSpace] = {
|
||||
instance: {}
|
||||
};
|
||||
window[nameSpace].init = function (options) {
|
||||
window[nameSpace].instance[options.privateId] = new Builder(options);
|
||||
};
|
||||
}
|
||||
})(function(){
|
||||
/**
|
||||
* 构造函数
|
||||
* @param options
|
||||
* @constructor
|
||||
*/
|
||||
function App(options) {
|
||||
var self = this;
|
||||
//初始化参数
|
||||
self.initParams(options);
|
||||
//初始化dom
|
||||
self.initDom();
|
||||
//事件
|
||||
self.events();
|
||||
}
|
||||
|
||||
App.prototype = {
|
||||
initParams : function (options) {
|
||||
var self = this;
|
||||
self.adaptation = options.adaptation;
|
||||
self.adaptation.formMessage = options.formMessage;
|
||||
self.privateId = options.privateId;
|
||||
self.messageObj = options.getData;
|
||||
self.preUrl = options.url_prefix;
|
||||
},
|
||||
initDom : function () {
|
||||
var self = this;
|
||||
dynamicLoading.css(self.preUrl + 'css/formQueryBtn.css');
|
||||
self.appendChildDom();
|
||||
},
|
||||
events : function () {
|
||||
var self = this;
|
||||
// 监听是否数据刷新
|
||||
|
||||
$(".field0313__").css("background-color","#008BFF");
|
||||
$(".field0313__").css("color","#FFFFFF");
|
||||
$(".field0313__").css("border-radius","10px");
|
||||
$(".field0313__").mouseover(function (e) {
|
||||
var $this = $(this);// 当前触发事件的标签对象
|
||||
}).mouseout(function (e) {
|
||||
$(".field0313__").css("background-color","#008BFF");
|
||||
}).mousemove(function (e) {
|
||||
$(".field0313__").css("background-color","#005297");
|
||||
});
|
||||
|
||||
},
|
||||
appendChildDom : function () {
|
||||
var self = this;
|
||||
var domStructure = '<section class="customButton_box_content">'+
|
||||
'<div class="customButton_class_box '+ self.privateId + '" title="' + self.messageObj.display.escapeHTML() + '">'+ self.messageObj.display.escapeHTML() +'</div>'+
|
||||
'</section>';
|
||||
document.querySelector('#' + self.privateId).innerHTML = domStructure;
|
||||
var jumpFun = function() {
|
||||
var s = self;
|
||||
var tableName = s.messageObj.formdata.alldata.tableInfo.formmain.tableName;
|
||||
var recordId = s.messageObj.recordId;
|
||||
const fieldInfo = s.messageObj.formdata.alldata.tableInfo.formmain.fieldInfo;
|
||||
var thirdPartyFlowId = "";
|
||||
var thirdPartyCode = "";
|
||||
for (const key in fieldInfo) {
|
||||
const field = fieldInfo[key];
|
||||
if (field.display === "第三方系统流程ID") {
|
||||
thirdPartyFlowId = field.value;
|
||||
} else if (field.display === "第三方系统标识"){
|
||||
thirdPartyCode = field.value;
|
||||
}
|
||||
}
|
||||
var url2 = window.location.origin;
|
||||
// window.open(url2+'/seeyon/urlSkipController.do?thirdPartyFlowId='+thirdPartyFlowId+'&thirdPartyCode='+thirdPartyCode+'&tableName='+tableName+'&recordId='+recordId, '_blank');
|
||||
window.open(url2+'/seeyon/urlSkipController.do?thirdPartyCode='+thirdPartyCode+'&tableName='+tableName+'&recordId='+recordId, '_blank');
|
||||
|
||||
console.log(s);
|
||||
|
||||
var content = self.messageObj.formdata.content;
|
||||
|
||||
};
|
||||
document.querySelector('.' + self.privateId).removeEventListener('click', jumpFun);
|
||||
document.querySelector('.' + self.privateId).addEventListener('click', jumpFun);
|
||||
//渲染隐藏权限
|
||||
if (self.messageObj.auth === 'hide') {
|
||||
document.querySelector('#' + self.privateId).innerHTML = '<div class="cap4-text__browse" style="line-height: 1.8; color: rgb(0, 0, 0) !important;">***</div>';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var dynamicLoading = {
|
||||
css: function(path) {
|
||||
if(!path || path.length === 0) {
|
||||
throw new Error('argument "path" is required !');
|
||||
}
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var link = document.createElement('link');
|
||||
link.href = path;
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
head.appendChild(link);
|
||||
},
|
||||
js: function(path) {
|
||||
if(!path || path.length === 0) {
|
||||
throw new Error('argument "path" is required !');
|
||||
}
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var script = document.createElement('script');
|
||||
script.src = path;
|
||||
script.type = 'text/javascript';
|
||||
head.appendChild(script);
|
||||
}
|
||||
}
|
||||
|
||||
return App;
|
||||
});
|
||||
Reference in New Issue
Block a user