wxr 2022-11-22 测试合并
commit
ba2867a669
|
@ -57,7 +57,16 @@ public class GCONST {
|
|||
private static Properties wsactionProp = null;
|
||||
private static Properties esbactionProp = null;
|
||||
private static Properties sapactionProp = null;
|
||||
/**
|
||||
* @author youHong.ai
|
||||
* 添加文件地址
|
||||
*/
|
||||
private static String systemFilePath = "";
|
||||
/**
|
||||
* @author youHong.ai
|
||||
* 添加日志地址
|
||||
*/
|
||||
private static String logPath = "";
|
||||
private static Properties coremailProp = null;
|
||||
public static String PROP_UTF8 = "UTF-8";
|
||||
public static String XML_UTF8 = "UTF-8";
|
||||
|
@ -177,8 +186,21 @@ public class GCONST {
|
|||
return propertyPath;
|
||||
}
|
||||
|
||||
public static void setLogPath(String _logPath) {
|
||||
logPath = _logPath;
|
||||
(new BaseBean()).writeLog("systemFilePath:" + getMyGrandpaStackTrace() + " value=" + _logPath);
|
||||
}
|
||||
|
||||
public static String getLogPath() {
|
||||
return ROOT_PATH + "log" + File.separatorChar;
|
||||
if("".equals(logPath)){
|
||||
return ROOT_PATH + "log" + File.separatorChar;
|
||||
}else{
|
||||
if(logPath.endsWith(String.valueOf(File.separatorChar))){
|
||||
return logPath;
|
||||
}else {
|
||||
return logPath + File.separatorChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPrintMoudlePath() {
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
package weaver.xiao.commons.config.dao;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.xiao.commons.config.entity.DocImageFile;
|
||||
import weaver.xiao.commons.config.entity.FieldMessage;
|
||||
import weaver.xiao.commons.config.entity.MappingDetail;
|
||||
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||
import weaver.xiao.commons.config.enumtype.DataSourceEnum;
|
||||
import weaver.xiao.commons.exception.ValueDealException;
|
||||
import weaver.xiao.commons.utils.SqlUtil;
|
||||
import weaver.zwl.common.ToolUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/12/29 9:46
|
||||
*/
|
||||
|
||||
public class ConfigMappingCMD {
|
||||
|
||||
private final ToolUtil toolUtil = new ToolUtil();
|
||||
private final String configTableName = "uf_request_config";
|
||||
private final SqlUtil sqlUtil = new SqlUtil();
|
||||
|
||||
public RequestMappingConfig selectByUniqueCode(String uniqueCode) {
|
||||
toolUtil.writeDebuggerLog("=======================查询配置列表=======================");
|
||||
RequestMappingConfig requestMappingConfig = new RequestMappingConfig();
|
||||
RecordSet recordSet = new RecordSet();
|
||||
String querySql = "select id,workflow,requestUrl,dataSource,uniqueCode, relationWorkFlow,cusWhereSql from " + configTableName + " where uniqueCode = ?";
|
||||
toolUtil.writeDebuggerLog("执行查询的sql query mainRequestMappingConfig list sql new>>>>" + querySql + " uniqueCode >>" + uniqueCode);
|
||||
recordSet.executeQuery(querySql, uniqueCode);
|
||||
if (recordSet.next()) {
|
||||
int mainId = Util.getIntValue(recordSet.getString("id"));
|
||||
requestMappingConfig = sqlUtil.recordSetToEntityByEntity(recordSet, RequestMappingConfig.class);
|
||||
this.setDetailMapping(mainId, requestMappingConfig);
|
||||
}
|
||||
return requestMappingConfig;
|
||||
}
|
||||
|
||||
private void setDetailMapping(int mainId, RequestMappingConfig requestMappingConfig) {
|
||||
// 查询明细1的信息
|
||||
RecordSet detail1RecordSet = new RecordSet();
|
||||
String dataSource = requestMappingConfig.getDataSource();
|
||||
if (Objects.isNull(dataSource) || "".equals(dataSource)) {
|
||||
dataSource = "0";
|
||||
}
|
||||
DataSourceEnum anEnum = DataSourceEnum.getEnum(dataSource);
|
||||
String queryDetail1Sql = "";
|
||||
switch (anEnum) {
|
||||
case CUS_TABLE:
|
||||
queryDetail1Sql = "select paramName,paramType,getValueType,dataSource,belongTo,workflowField,modelField,fieldName,valueContext," +
|
||||
" from " + configTableName + "_dt1 config ";
|
||||
break;
|
||||
case WORKFLOW:
|
||||
queryDetail1Sql = "select paramName,paramType,getValueType,dataSource,belongTo,workflowField,modelField,valueContext,relationWorkFlowField, " +
|
||||
" fv.id fieldId,fv.fieldname,fv.tablename,fv.indexdesc " +
|
||||
" from " + configTableName + "_dt1 config " +
|
||||
" left join workflow_field_table_view fv " +
|
||||
" on config.workflowField = fv.id or config.relationWorkFlowField = fv.id" +
|
||||
" where mainid = ? ";
|
||||
break;
|
||||
case MODEL:
|
||||
queryDetail1Sql = "select paramName,paramType,getValueType,dataSource,belongTo,workflowField,modelField,fieldName,valueContext, " +
|
||||
" fv.id fieldId,fv.fieldname,fv.tablename,fv.indexdesc " +
|
||||
" from " + configTableName + "_dt1 config " +
|
||||
" left join workflow_field_table_view fv on config.modelField = fv.id " +
|
||||
" where mainid = ? ";
|
||||
break;
|
||||
default:
|
||||
throw new ValueDealException("不支持的数据来源");
|
||||
}
|
||||
toolUtil.writeDebuggerLog("执行查询的明细1sql query detail1Sql >>>>" + queryDetail1Sql + " mainId:" + mainId);
|
||||
detail1RecordSet.executeQuery(queryDetail1Sql, mainId);
|
||||
List<MappingDetail> mappingDetails = new ArrayList<>();
|
||||
while (detail1RecordSet.next()) {
|
||||
MappingDetail mappingDetail = sqlUtil.recordSetToEntityByEntity(detail1RecordSet, MappingDetail.class);
|
||||
String getValueType = mappingDetail.getGetValueType();
|
||||
// 设置流程字段相关信息
|
||||
// if("0".equals(getValueType) || "4".equals(getValueType)){
|
||||
FieldMessage fieldMessage = sqlUtil.recordSetToEntityByEntity(detail1RecordSet, FieldMessage.class);
|
||||
mappingDetail.setFieldMassage(fieldMessage);
|
||||
// }
|
||||
mappingDetails.add(mappingDetail);
|
||||
}
|
||||
// 查询明细2的信息
|
||||
RecordSet detail2RecordSet = new RecordSet();
|
||||
String queryDetail2Sql = "select paramName,belongTo,childType,dataSource,detailId,cusWhereSql from uf_request_config_dt2 where mainid = ?";
|
||||
toolUtil.writeDebuggerLog("执行查询的明细sql query detail2Sql >>>>" + queryDetail2Sql + " mainId:" + mainId);
|
||||
detail2RecordSet.executeQuery(queryDetail2Sql, mainId);
|
||||
while (detail2RecordSet.next()) {
|
||||
MappingDetail mappingDetail = sqlUtil.recordSetToEntityByEntity(detail2RecordSet, MappingDetail.class);
|
||||
mappingDetail.setParamType("6");// 设置参数类型为List
|
||||
mappingDetails.add(mappingDetail);
|
||||
}
|
||||
// 查询明细3的信息
|
||||
RecordSet detail3RecordSet = new RecordSet();
|
||||
String queryDetail3Sql = "select paramName,belongTo from uf_request_config_dt3 where mainid = ?";
|
||||
toolUtil.writeDebuggerLog("执行查询的明细sql query detail3Sql >>>>" + queryDetail3Sql + " mainId:" + mainId);
|
||||
detail3RecordSet.executeQuery(queryDetail3Sql, mainId);
|
||||
while (detail3RecordSet.next()) {
|
||||
MappingDetail mappingDetail = sqlUtil.recordSetToEntityByEntity(detail3RecordSet, MappingDetail.class);
|
||||
mappingDetail.setParamType("5");// 设置参数类型为Object
|
||||
mappingDetails.add(mappingDetail);
|
||||
}
|
||||
requestMappingConfig.setConfigDetail(mappingDetails);
|
||||
// //查询明细4的信息
|
||||
// RecordSet detail4RecordSet = new RecordSet();
|
||||
// List<ResponseMapping> responseMappingList = new ArrayList<>();
|
||||
// String queryDetail4Sql = "select responseFieldName,workflowField,mainOrDetail,detailTableId,workflowFieldName from uf_request_config_dt4 where mainid = ?";
|
||||
// toolUtil.writeDebuggerLog("执行查询的明细sql query detail4Sql >>>>"+queryDetail4Sql+" mainId:"+mainId);
|
||||
// detail4RecordSet.executeQuery(queryDetail4Sql,mainId);
|
||||
// while (detail4RecordSet.next()){
|
||||
// ResponseMapping responseMapping = sqlUtil.recordSetToEntityByEntity(detail4RecordSet, ResponseMapping.class);
|
||||
// responseMappingList.add(responseMapping);
|
||||
// }
|
||||
// requestMappingConfig.setResponseMappingList(responseMappingList);
|
||||
requestMappingConfig.setConfigDetail(mappingDetails);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查询附件信息</h2>
|
||||
*
|
||||
* @param docIds 文档id
|
||||
* @return 附件信息
|
||||
* @author YouHong.ai
|
||||
*/
|
||||
public List<DocImageFile> selectDocImageFileList(String docIds) {
|
||||
String sql = "select docfile.IMAGEFILEID,docfile.IMAGEFILENAME,docfile.DOCID,docfile.ID, " +
|
||||
" imf.FILESIZE " +
|
||||
"from docimagefile docfile " +
|
||||
"left join imagefile imf on imf.IMAGEFILEID = docfile.IMAGEFILEID " +
|
||||
"where docid in (" + docIds + ")";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql);
|
||||
List<DocImageFile> docImageFileList = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
String IMAGEFILEID = rs.getString("IMAGEFILEID");
|
||||
String IMAGEFILENAME = rs.getString("IMAGEFILENAME");
|
||||
String DOCID = rs.getString("DOCID");
|
||||
String ID = rs.getString("ID");
|
||||
String fileSize = rs.getString("FILESIZE");
|
||||
DocImageFile docImageFile = new DocImageFile();
|
||||
docImageFile.setImageFileId(Util.getIntValue(IMAGEFILEID));
|
||||
docImageFile.setImageFileName(IMAGEFILENAME);
|
||||
docImageFile.setDocId(Util.getIntValue(DOCID));
|
||||
docImageFile.setId(Util.getIntValue(ID));
|
||||
docImageFile.setFileSize(Util.getIntValue(fileSize) / 1024L);
|
||||
docImageFileList.add(docImageFile);
|
||||
}
|
||||
if (docImageFileList.isEmpty()) {
|
||||
throw new NullPointerException("附件字段不存在值!请检查数据表或配置表数据类型是否正确!");
|
||||
}
|
||||
return docImageFileList;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package weaver.xiao.commons.config.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1>附件信息</h1>
|
||||
*
|
||||
* <p>create: 2022-11-21 10:55</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class DocImageFile {
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private Integer imageFileId;
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String imageFileName;
|
||||
/**
|
||||
* docId
|
||||
*/
|
||||
private Integer docId;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Long fileSize;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package weaver.xiao.commons.config.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import weaver.xiao.commons.utils.annotation.SqlFieldMapping;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/12/31 10:15
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class FieldMessage {
|
||||
|
||||
@SqlFieldMapping("fieldId")
|
||||
private String fieldId;
|
||||
|
||||
@SqlFieldMapping("fieldName")
|
||||
private String fieldName;
|
||||
|
||||
@SqlFieldMapping("indexDesc")
|
||||
private String indexDesc;
|
||||
|
||||
@SqlFieldMapping("tableName")
|
||||
private String tableName;
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package weaver.xiao.commons.config.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <h1>list分割暂存类</h1>
|
||||
*
|
||||
* <p>create: 2022-08-05 11:25</p>
|
||||
*
|
||||
* @author aiyh EBU7-dev-1
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class ListMapIndexValue {
|
||||
private String key;
|
||||
private Object value;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package weaver.xiao.commons.config.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import weaver.xiao.commons.utils.annotation.SqlFieldMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/12/28 17:45
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class MappingDetail {
|
||||
|
||||
@SqlFieldMapping("paramName")
|
||||
private String paramName;
|
||||
|
||||
@SqlFieldMapping("paramType")
|
||||
private String paramType;
|
||||
|
||||
@SqlFieldMapping("getValueType")
|
||||
private String getValueType;
|
||||
|
||||
@SqlFieldMapping("childType")
|
||||
private String childType;
|
||||
|
||||
@SqlFieldMapping("dataSource")
|
||||
private String dataSource;
|
||||
|
||||
@SqlFieldMapping("detailId")
|
||||
private String detailId;
|
||||
|
||||
@SqlFieldMapping("belongTo")
|
||||
private String belongTo;
|
||||
|
||||
@SqlFieldMapping("workflowField")
|
||||
private String workflowField;
|
||||
|
||||
@SqlFieldMapping("valueContext")
|
||||
private String valueContext;
|
||||
|
||||
@SqlFieldMapping("relationWorkFlowField")
|
||||
private String relationWorkFlowField;
|
||||
|
||||
@SqlFieldMapping("cusWhereSql")
|
||||
private String cusWhereSql;
|
||||
|
||||
private List<MappingDetail> childList;
|
||||
|
||||
private FieldMessage fieldMassage;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package weaver.xiao.commons.config.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2022-11-21 11:12</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
public class MultipartFile {
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
String fileName;
|
||||
/**
|
||||
* 上传文件的key
|
||||
*/
|
||||
String fileKey;
|
||||
/**
|
||||
* 文件流信息
|
||||
*/
|
||||
InputStream stream;
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
Long fileSize;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package weaver.xiao.commons.config.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import weaver.xiao.commons.utils.annotation.SqlFieldMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/12/28 17:43
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class RequestMappingConfig {
|
||||
|
||||
@SqlFieldMapping("workflow")
|
||||
private String workflow;
|
||||
|
||||
@SqlFieldMapping("requestUrl")
|
||||
private String requestUrl;
|
||||
|
||||
@SqlFieldMapping("uniqueCode")
|
||||
private String uniqueCode;
|
||||
|
||||
@SqlFieldMapping("dataSource")
|
||||
private String dataSource;
|
||||
|
||||
@SqlFieldMapping("modelId")
|
||||
private String modelId;
|
||||
|
||||
@SqlFieldMapping("tableName")
|
||||
private String tableName;
|
||||
|
||||
@SqlFieldMapping("urlDesc")
|
||||
private String urlDesc;
|
||||
|
||||
@SqlFieldMapping("relationWorkFlow")
|
||||
private String relationWorkFlow;
|
||||
|
||||
@SqlFieldMapping("cusWhereSql")
|
||||
private String cusWhereSql;
|
||||
|
||||
private List<MappingDetail> configDetail;
|
||||
|
||||
private List<ResponseMapping> responseMappingList;
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package weaver.xiao.commons.config.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/4/12 22:28
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class ResponseMapping {
|
||||
private String responseFieldName;
|
||||
private String workflowField;
|
||||
private String mainOrDetail;
|
||||
private String detailTableId;
|
||||
private String workflowFieldName;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package weaver.xiao.commons.config.enumtype;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/6/14 12:26
|
||||
*/
|
||||
|
||||
public enum DataSourceEnum {
|
||||
|
||||
WORKFLOW("0"),
|
||||
MODEL("1"),
|
||||
CUS_TABLE("2");
|
||||
|
||||
private static final Map<String, DataSourceEnum> LOOK_UP = new HashMap<>(8);
|
||||
|
||||
static {
|
||||
for (DataSourceEnum dataSource : EnumSet.allOf(DataSourceEnum.class)){
|
||||
LOOK_UP.put(dataSource.value,dataSource);
|
||||
}
|
||||
}
|
||||
public final String value;
|
||||
|
||||
DataSourceEnum(String value){
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static DataSourceEnum getEnum(String value){
|
||||
return LOOK_UP.get(value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package weaver.xiao.commons.config.enumtype;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/6/14 13:13
|
||||
*/
|
||||
|
||||
public enum GetValueTypeEnum {
|
||||
|
||||
WORKFLOW_FIELD("0"),
|
||||
DEFAULT_VALUE("1"),
|
||||
CURRENT_TIME("3"),
|
||||
CUS_SQL("4"),
|
||||
REQUEST_ID("5"),
|
||||
MAIN_DATA_ID("6"),
|
||||
RANDOM("7"),
|
||||
ATTACHMENT("8"),
|
||||
|
||||
CUS_INTERFACE("9"),
|
||||
|
||||
CUS_FIELD("10");
|
||||
|
||||
private static final Map<String, GetValueTypeEnum> LOOK_UP = new HashMap<>(8);
|
||||
|
||||
static {
|
||||
for (GetValueTypeEnum getValueTypeEnum : EnumSet.allOf(GetValueTypeEnum.class)) {
|
||||
LOOK_UP.put(getValueTypeEnum.value, getValueTypeEnum);
|
||||
}
|
||||
}
|
||||
|
||||
public final String value;
|
||||
|
||||
GetValueTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static GetValueTypeEnum getEnum(String value) {
|
||||
return LOOK_UP.get(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package weaver.xiao.commons.config.enumtype;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/6/14 12:56
|
||||
*/
|
||||
|
||||
public enum ParamTypeEnum {
|
||||
|
||||
STRING("0"),
|
||||
INT("1"),
|
||||
DOUBLE("2"),
|
||||
DATE("3"),
|
||||
DATE_TIME("4"),
|
||||
OBJECT("5"),
|
||||
LIST("6"),
|
||||
CUS_DATE_STR("7"),
|
||||
TIME_STAMP("8"),
|
||||
DATE_VAL("9"),
|
||||
Boolean("10");
|
||||
|
||||
|
||||
private static final Map<String, ParamTypeEnum> LOOK_UP = new HashMap<>(8);
|
||||
|
||||
static {
|
||||
for (ParamTypeEnum paramTypeEnum : EnumSet.allOf(ParamTypeEnum.class)){
|
||||
LOOK_UP.put(paramTypeEnum.value,paramTypeEnum);
|
||||
}
|
||||
}
|
||||
public final String value;
|
||||
|
||||
ParamTypeEnum(String value){
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static ParamTypeEnum getEnum(String value){
|
||||
return LOOK_UP.get(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package weaver.xiao.commons.config.interfacies;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.xiao.commons.utils.LogUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>自定义获取参数值</h1>
|
||||
*
|
||||
* @author EBU7-dev-1 aiyh
|
||||
* <p>create: 2022-07-25 14:18</p>
|
||||
*/
|
||||
|
||||
public interface CusInterfaceGetValue {
|
||||
|
||||
final String START_LEFT = "{";
|
||||
final String VAR_START_STR = "#{";
|
||||
final String MAIN = "main.";
|
||||
final String DETAIL = "detail.";
|
||||
final String END_STR = "}";
|
||||
|
||||
final String SQL_START = "#sql{";
|
||||
|
||||
final Logger log = LogUtil.getLogger();
|
||||
|
||||
/**
|
||||
* 获取参数值
|
||||
*
|
||||
* @param mainMap 主表数据
|
||||
* @param detailMap 明细表数据
|
||||
* @param currentValue 当前字段值
|
||||
* @param pathParam 路径参数
|
||||
* @return 最终返回参数
|
||||
*/
|
||||
Object execute(Map<String, Object> mainMap, Map<String, Object> detailMap, String currentValue,
|
||||
Map<String, String> pathParam);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package weaver.xiao.commons.config.interfacies;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>自定义数组数据来源</h1>
|
||||
*
|
||||
* <p>create: 2022-08-15 15:38</p>
|
||||
*
|
||||
* @author aiyh EBU7-dev-1
|
||||
*/
|
||||
|
||||
public interface CusInterfaceListValue {
|
||||
|
||||
/**
|
||||
* <h2>自定义数组数据来源</h2>
|
||||
*
|
||||
* @param pathParam 路径参数
|
||||
* @param mainMap 主表数据
|
||||
* @param mainTable 主表表明
|
||||
* @return 数组
|
||||
*/
|
||||
List<Object> execute(Map<String, String> pathParam, Map<String, Object> mainMap, String mainTable);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
|||
package weaver.xiao.commons.exception;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/1/12 11:06
|
||||
*/
|
||||
|
||||
public class RequestException extends RuntimeException{
|
||||
public RequestException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public RequestException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Throwable fillInStackTrace() {
|
||||
return super.fillInStackTrace();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package weaver.xiao.commons.exception;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/1/4 9:50
|
||||
*/
|
||||
|
||||
public class ValueDealException extends RuntimeException{
|
||||
|
||||
public ValueDealException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ValueDealException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Throwable fillInStackTrace() {
|
||||
return super.fillInStackTrace();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package weaver.xiao.commons.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/9/9 19:33
|
||||
*/
|
||||
|
||||
public class JsonResult {
|
||||
|
||||
private Integer code;
|
||||
private String message;
|
||||
private Object Data;
|
||||
|
||||
public JsonResult(Integer code, String message, Object data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public static String success(String message){
|
||||
return JSONObject.toJSONString(new JsonResult(200,message,null));
|
||||
}
|
||||
public static String success(){
|
||||
return JSONObject.toJSONString(new JsonResult(200,"success",null));
|
||||
}
|
||||
public static String successData(String message,Object data){
|
||||
return JSONObject.toJSONString(new JsonResult(200,message,data));
|
||||
}
|
||||
public static String successData(Object data){
|
||||
return JSONObject.toJSONString(new JsonResult(200,"success",data));
|
||||
}
|
||||
|
||||
public static String error(int code,String message){
|
||||
return JSONObject.toJSONString(new JsonResult(code,message,null));
|
||||
}
|
||||
public static String error(String message){
|
||||
return JSONObject.toJSONString(new JsonResult(500,message,null));
|
||||
}
|
||||
public static String error(){
|
||||
return JSONObject.toJSONString(new JsonResult(500,"fail",null));
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
Data = data;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package weaver.xiao.commons.utils;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/3/3 14:16
|
||||
*/
|
||||
|
||||
public class LogUtil {
|
||||
|
||||
private static volatile Logger log = null;
|
||||
|
||||
public static Logger getLogger(){
|
||||
return LogUtil.getLogger(weaver.general.GCONST.getLogPath() + "cus" + File.separator + "util_cus" + File.separator + "cus.log");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志对象
|
||||
* @return 日志对象
|
||||
*/
|
||||
public static Logger getLogger(String file) {
|
||||
if (log == null) {
|
||||
synchronized (LogUtil.class) {
|
||||
if (log == null) {
|
||||
DailyRollingFileAppender appender = new DailyRollingFileAppender();
|
||||
log = Logger.getLogger("xbk_cus");
|
||||
appender.setName("xbk_cus");
|
||||
appender.setEncoding("UTF-8");
|
||||
appender.setDatePattern("'_'yyyyMMdd'.log'");
|
||||
appender.setFile(file);
|
||||
appender.setThreshold(Priority.DEBUG);
|
||||
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [Thread:%t][%F.%M:%L] ==> : %m %x %n"));
|
||||
appender.setAppend(true);
|
||||
appender.activateOptions();
|
||||
log.addAppender(appender);
|
||||
boolean enableDebug = true;
|
||||
if (!enableDebug) {
|
||||
log.setLevel(Level.INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
public static Logger getSqlLogger(){
|
||||
return LogUtil.getLogger(weaver.general.GCONST.getLogPath() + "cus" + File.separator + "sql" + File.separator + "cussql.log");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取堆栈中的异常信息
|
||||
* @param throwable 异常
|
||||
* @return
|
||||
*/
|
||||
public static String getExceptionStr(Throwable throwable){
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
throwable.printStackTrace(new PrintWriter(stringWriter,true));
|
||||
String s = stringWriter.getBuffer().toString();
|
||||
try{
|
||||
stringWriter.close();
|
||||
}catch (Exception ignored){
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package weaver.xiao.commons.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/8/20 14:01
|
||||
*/
|
||||
|
||||
public class PreMap extends HashMap<String,Object> implements Map<String,Object> {
|
||||
|
||||
public PreMap(){
|
||||
super();
|
||||
}
|
||||
|
||||
public static PreMap create(){
|
||||
return new PreMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreMap put(String key, Object value){
|
||||
super.put(key,value);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package weaver.xiao.commons.utils;
|
||||
|
||||
import weaver.common.util.string.StringUtil;
|
||||
import weaver.general.GCONST;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/3/10 11:13
|
||||
*/
|
||||
|
||||
public class PropUtil {
|
||||
/**
|
||||
* 通过文件名获取到对应的配置文件map对象
|
||||
* @param fileName prop/文件夹下的文件名(不包含.properties)
|
||||
* @return 配置文件对应的map对象
|
||||
*/
|
||||
public static Map<String, Object> getProperties2Map(String fileName) {
|
||||
String propertyPath = GCONST.getPropertyPath();
|
||||
if (StringUtil.isNullOrEmpty(fileName)) {
|
||||
return null;
|
||||
}
|
||||
if (fileName.contains(".properties")) {
|
||||
fileName = fileName.replace(".properties", "");
|
||||
}
|
||||
String path = propertyPath + File.separator + fileName + ".properties";
|
||||
Properties prop = new Properties();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = new BufferedInputStream(new FileInputStream(path));
|
||||
prop.load(inputStream);
|
||||
Enumeration<?> enumeration = prop.propertyNames();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
String key = String.valueOf(enumeration.nextElement());
|
||||
map.put(key, prop.getProperty(key));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("找不到文件:" + path);
|
||||
} finally {
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package weaver.xiao.commons.utils;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/8/23 16:34
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class RequestBaseInfo{
|
||||
|
||||
private String type;
|
||||
private String url;
|
||||
private Object params;
|
||||
private InputStream[] inputStreams;
|
||||
private String[] fileNames;
|
||||
private String fileField;
|
||||
private Map<String,String > headers;
|
||||
|
||||
private static final Map<String,String > HEADER_NORMAL = new HashMap<>();
|
||||
private static final Map<String,Object > PARAMS_NORMAL = new HashMap<>();
|
||||
|
||||
|
||||
public static RequestBaseInfo create(String type, String url){
|
||||
return create(type,url,HEADER_NORMAL,PARAMS_NORMAL);
|
||||
}
|
||||
|
||||
public static RequestBaseInfo create(String type, String url, Map<String, String> headers){
|
||||
return create(type,url,headers,PARAMS_NORMAL);
|
||||
}
|
||||
|
||||
public static RequestBaseInfo create(String type, String url, Map<String, String> headers, Object params){
|
||||
RequestBaseInfo requestInfo = new RequestBaseInfo();
|
||||
requestInfo.setType(type.toUpperCase());
|
||||
requestInfo.setUrl(url);
|
||||
requestInfo.setParams(params);
|
||||
requestInfo.setHeaders(headers);
|
||||
return requestInfo;
|
||||
}
|
||||
|
||||
public static RequestBaseInfo createByFile(String type, String url, Map<String, String> headers, Object params, InputStream[] inputStreams, String fileField, String[] fileNames){
|
||||
RequestBaseInfo requestInfo = new RequestBaseInfo();
|
||||
requestInfo.setType(type.toUpperCase());
|
||||
requestInfo.setUrl(url);
|
||||
requestInfo.setParams(params);
|
||||
requestInfo.setHeaders(headers);
|
||||
requestInfo.setInputStreams(inputStreams);
|
||||
requestInfo.setFileNames(fileNames);
|
||||
requestInfo.setFileField(fileField);
|
||||
return requestInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
package weaver.xiao.commons.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.http.HttpEntity;
|
||||
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.DefaultHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import weaver.xiao.commons.exception.RequestException;
|
||||
import weaver.zwl.common.ToolUtil;
|
||||
import weaver.wechat.request.HttpManager;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/8/9 10:09
|
||||
*/
|
||||
|
||||
public class RequestUtil {
|
||||
|
||||
public static <T> T apiRequest(RequestBaseInfo requestInfo, Class<T> tClass){
|
||||
|
||||
Map<String,String> headers = requestInfo.getHeaders();
|
||||
T result = null;
|
||||
|
||||
switch(requestInfo.getType()){
|
||||
case "GET" :{
|
||||
String sendUrl = serializableUrl(requestInfo.getUrl(), (Map<String, Object>) requestInfo.getParams());
|
||||
HttpGet httpGet = new HttpGet(sendUrl);
|
||||
headers.forEach(httpGet::setHeader);
|
||||
result = apiSend(httpGet,tClass);
|
||||
}break;
|
||||
case "POST" :{
|
||||
HttpPost httpPost = new HttpPost(requestInfo.getUrl());
|
||||
headers.forEach(httpPost::setHeader);
|
||||
httpPost.setEntity(new StringEntity(JSON.toJSONString(requestInfo.getParams()),"UTF-8"));
|
||||
new ToolUtil().writeErrorLog("请求信息:url:"+requestInfo.getUrl()+" params:"+JSON.toJSONString(requestInfo.getParams()));
|
||||
result = apiSend(httpPost,tClass);}break;
|
||||
case "PUT" :{
|
||||
HttpPut httpPut = new HttpPut(requestInfo.getUrl());
|
||||
headers.forEach(httpPut::setHeader);
|
||||
httpPut.setEntity(new StringEntity(JSON.toJSONString(requestInfo.getParams()),"UTF-8"));
|
||||
result = apiSend(httpPut,tClass);}break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> T POSTBySerializableUrl(RequestBaseInfo requestInfo, Class<T> tClass){
|
||||
T result = null;
|
||||
Map<String,String> headers = requestInfo.getHeaders();
|
||||
String url = serializableUrl(requestInfo.getUrl(), (Map<String, Object>) requestInfo.getParams());
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
headers.forEach(httpPost::setHeader);
|
||||
new ToolUtil().writeErrorLog("请求信息:url:"+requestInfo.getUrl()+" params:"+JSON.toJSONString(requestInfo.getParams()));
|
||||
result = apiSend(httpPost,tClass);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> T apiUploadFileByInputStream(RequestBaseInfo requestInfo, Class<T> tClass){
|
||||
Map<String,Object> params = (Map<String, Object>) requestInfo.getParams();
|
||||
HttpPost httpPost = new HttpPost(requestInfo.getUrl());
|
||||
requestInfo.getHeaders().forEach(httpPost::setHeader);
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.setCharset(StandardCharsets.UTF_8);
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
InputStream[] inputStreams = requestInfo.getInputStreams();
|
||||
String[] fileNames = requestInfo.getFileNames();
|
||||
for (int i = 0; i < inputStreams.length; i++) {
|
||||
builder.addBinaryBody(requestInfo.getFileField(),inputStreams[i],ContentType.MULTIPART_FORM_DATA,fileNames[i]);
|
||||
}
|
||||
params.forEach((k,v)->{
|
||||
builder.addTextBody(k,JSON.toJSONString(v),ContentType.create(MediaType.TEXT_PLAIN,"UTF-8"));
|
||||
});
|
||||
HttpEntity entity = builder.build();
|
||||
httpPost.setEntity(entity);
|
||||
return apiSend(httpPost,tClass);
|
||||
}
|
||||
|
||||
public static <T> T apiSend(
|
||||
HttpUriRequest httpRequest,
|
||||
Class<T> resClass
|
||||
){
|
||||
DefaultHttpClient httpClient = HttpManager.getHttpClient();
|
||||
CloseableHttpResponse execute = null;
|
||||
T res = null;
|
||||
try {
|
||||
new ToolUtil().writeDebuggerLog("开始发送请求:request start -----------------");
|
||||
execute = httpClient.execute(httpRequest);
|
||||
if(execute.getStatusLine().getStatusCode() == 200){
|
||||
new ToolUtil().writeDebuggerLog("请求发送成功:request send success -----------------");
|
||||
HttpEntity entity = execute.getEntity();
|
||||
String response= EntityUtils.toString(entity,"utf-8");
|
||||
// ObjectMapper mapper = new ObjectMapper();
|
||||
// CollectionType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, Map.class);
|
||||
// List<Map<String,Object>> list = mapper.readValue(response, listType);
|
||||
// result.put("res",list);
|
||||
if(resClass.equals(String.class)){
|
||||
return (T) response;
|
||||
}else {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
res = objectMapper.readValue(response, resClass);
|
||||
}
|
||||
}else {
|
||||
HttpEntity entity = execute.getEntity();
|
||||
String response = EntityUtils.toString(entity,"utf-8");
|
||||
new ToolUtil().writeDebuggerLog("请求状态不为200,返回信息为:"+response);
|
||||
throw new RequestException("请求状态异常:"+response);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
new ToolUtil().writeDebuggerLog("请求发生异常 request error>>>"+e);
|
||||
try {
|
||||
if(execute != null) {
|
||||
execute.close();
|
||||
}
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
e.printStackTrace();
|
||||
throw new RequestException("请求调用异常:"+e);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String serializableUrl(String url,Map<String,Object> params){
|
||||
if(params == null || params.isEmpty()){
|
||||
return url;
|
||||
}
|
||||
url += "?";
|
||||
for (Map.Entry entry: params.entrySet()){
|
||||
url += entry.getKey() + "=" + entry.getValue() + "&";
|
||||
}
|
||||
return url.substring(0,url.length()-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取堆栈中的异常信息
|
||||
* @param throwable 异常
|
||||
* @return
|
||||
*/
|
||||
public static String getExceptionStr(Throwable throwable){
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
throwable.printStackTrace(new PrintWriter(stringWriter,true));
|
||||
String s = stringWriter.getBuffer().toString();
|
||||
try{
|
||||
stringWriter.close();
|
||||
}catch (Exception ignored){
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,260 @@
|
|||
package weaver.xiao.commons.utils;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.formmode.data.ModeDataIdUpdate;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.xiao.commons.utils.annotation.SqlFieldMapping;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2021/12/7 14:19
|
||||
*/
|
||||
|
||||
public class SqlUtil {
|
||||
|
||||
private final Logger logger = LogUtil.getSqlLogger();
|
||||
ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance();
|
||||
ModeRightInfo mri = new ModeRightInfo();
|
||||
|
||||
/**
|
||||
* 通过列名将数据库结果集转换成指定的实体类
|
||||
* @param recordSet 数据库结果集
|
||||
* @param tClass 实体类文件
|
||||
* @param <T> 泛型
|
||||
* @return
|
||||
*/
|
||||
public <T> T recordSetToEntityByEntity(RecordSet recordSet, Class<T> tClass){
|
||||
T res = null;
|
||||
try{
|
||||
String[] columnNames = recordSet.getColumnName();
|
||||
if(tClass.equals(Map.class)){
|
||||
Map<String,Object> tempRes = new HashMap<>();
|
||||
for (String columnName : columnNames) {
|
||||
tempRes.put(columnName,recordSet.getString(columnName));
|
||||
}
|
||||
res = (T) tempRes;
|
||||
}else {
|
||||
Field[] declaredFields = tClass.getDeclaredFields();
|
||||
res = tClass.newInstance();
|
||||
for (Field field : declaredFields) {
|
||||
field.setAccessible(true);
|
||||
SqlFieldMapping annotation = field.getAnnotation(SqlFieldMapping.class);
|
||||
Class<?> fieldType = field.getType();
|
||||
if(annotation != null){
|
||||
String value = annotation.value();
|
||||
int type = annotation.type();
|
||||
Object valueText = null;
|
||||
switch (type){
|
||||
case 1:{
|
||||
String tempValue = Util.null2String(recordSet.getString(value));
|
||||
valueText = this.getFieldVal(fieldType,tempValue);
|
||||
}break;
|
||||
case 2:{
|
||||
valueText = this.getFieldVal(fieldType,value);
|
||||
}break;
|
||||
}
|
||||
field.set(res,valueText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.info("转换实体类异常:"+e);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字段类型获取字段的值
|
||||
* @param fieldType 字段类型
|
||||
* @param tempValue 转换前的字符串值
|
||||
* @return
|
||||
*/
|
||||
public Object getFieldVal(Class<?> fieldType,String tempValue){
|
||||
Object fieldVal = null;
|
||||
if(fieldType.equals(int.class)){
|
||||
fieldVal = Util.getIntValue(tempValue);
|
||||
}else if(fieldType.equals(String.class)){
|
||||
fieldVal = Util.null2String(tempValue);
|
||||
}else if(fieldType.equals(boolean.class)){
|
||||
fieldVal = Boolean.parseBoolean(tempValue);
|
||||
}else {
|
||||
fieldVal = "";
|
||||
}
|
||||
return fieldVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建更新语句
|
||||
* @param tableName 表名
|
||||
* @param updateParam 更新参数
|
||||
* @param whereParam 条件参数
|
||||
* @return
|
||||
*/
|
||||
public boolean updateMode(String tableName, Map<String, Object> updateParam, Map<String, Object> whereParam) {
|
||||
RecordSet recordSet = new RecordSet();
|
||||
List<Object> paramList = new ArrayList<>();
|
||||
String updateSql = buildUpdateSql(tableName, updateParam, whereParam, paramList);
|
||||
logger.info("向表"+tableName+"更新数据>>>" + updateSql + " param:" + paramList);
|
||||
boolean updateFlag = recordSet.executeUpdate(updateSql, paramList);
|
||||
logger.info("更新标识:" + updateFlag);
|
||||
return updateFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建更新sql语句,收集参数信息
|
||||
* @param tableName 表名
|
||||
* @param updateParam 更新参数
|
||||
* @param whereParam 条件参数
|
||||
* @param paramList 参数集合
|
||||
* @return
|
||||
*/
|
||||
public String buildUpdateSql(String tableName, Map<String, Object> updateParam, Map<String, Object> whereParam,List<Object> paramList){
|
||||
StringBuilder updateBuilder = new StringBuilder("update ");
|
||||
updateBuilder.append(tableName).append(" set ");
|
||||
Set<Map.Entry<String, Object>> updateEntries = updateParam.entrySet();
|
||||
for (Map.Entry<String, Object> updateEntry : updateEntries) {
|
||||
updateBuilder.append(updateEntry.getKey())
|
||||
.append(" = ?,");
|
||||
paramList.add(updateEntry.getValue());
|
||||
}
|
||||
StringBuilder whereBuilder = new StringBuilder();
|
||||
Set<Map.Entry<String, Object>> whereEntries = whereParam.entrySet();
|
||||
for (Map.Entry<String, Object> whereEntry : whereEntries) {
|
||||
whereBuilder.append(" and ")
|
||||
.append(whereEntry.getKey())
|
||||
.append(" = ? ");
|
||||
paramList.add(whereEntry.getValue());
|
||||
}
|
||||
String preStr = updateBuilder.substring(0, updateBuilder.length() - 1) + " ";
|
||||
String fixStr = whereBuilder.toString();
|
||||
if(!"".equals(fixStr)){
|
||||
fixStr = fixStr.replaceFirst(" and "," where ");
|
||||
}
|
||||
return preStr + fixStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向表插入数据
|
||||
* @param tableName 表名
|
||||
* @param insertParam 插入参数
|
||||
* @return
|
||||
*/
|
||||
public boolean insertTable(String tableName, Map<String, Object> insertParam) {
|
||||
RecordSet recordSet = new RecordSet();
|
||||
//构建新建sql语句,收集参数信息
|
||||
List<Object> paramList = new ArrayList<>();
|
||||
String insertSql = buildInsetSql(tableName, insertParam, paramList);
|
||||
logger.info("向表"+tableName+"插入数据>>>" + insertSql + " param:" + paramList);
|
||||
boolean flag = recordSet.executeUpdate(insertSql, paramList);
|
||||
logger.info("插入标识:" + flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建新建sql语句,收集参数信息
|
||||
* @param tableName 表名
|
||||
* @param insertParam 插入参数
|
||||
* @param paramList 返回数据集合
|
||||
* @return
|
||||
*/
|
||||
public String buildInsetSql(String tableName, Map<String, Object> insertParam,List<Object> paramList){
|
||||
StringBuilder suffixBuilder = new StringBuilder();
|
||||
StringBuilder prefixBuilder = new StringBuilder();
|
||||
prefixBuilder.append("insert into ")
|
||||
.append(tableName).append("(");
|
||||
suffixBuilder.append(" values (");
|
||||
Set<Map.Entry<String, Object>> entries = insertParam.entrySet();
|
||||
for (Map.Entry<String, Object> entry : entries) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
prefixBuilder.append(key).append(",");
|
||||
suffixBuilder.append("?,");
|
||||
paramList.add(value);
|
||||
}
|
||||
String suffixString = suffixBuilder.substring(0, suffixBuilder.length() - 1);
|
||||
String prefixString = prefixBuilder.substring(0, prefixBuilder.length() - 1);
|
||||
String insertSql = prefixString + ")" + suffixString+")";
|
||||
return insertSql;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将接口调用信息插入至建模中
|
||||
* @param tableName 表名
|
||||
* @param param 插入信息
|
||||
* @param modeId 模块id
|
||||
* @return
|
||||
*/
|
||||
public int insertToMode(String tableName,Map<String,Object> param,String modeId){
|
||||
logger.info("=====插入建模信息====");
|
||||
if(modeId == null || "".equals(modeId)) {
|
||||
modeId = this.getModeIdByTableName(tableName);
|
||||
}
|
||||
logger.info("通过表名获取modeId ==>modeId"+modeId+" tableName==>"+tableName);
|
||||
Map<String,Object> whereParam = new HashMap<>();
|
||||
int dataId = mdu.getModeDataNewId(tableName, Util.getIntValue(modeId,-1), 1, 0, TimeUtil.getCurrentDateString(), TimeUtil.getOnlyCurrentTimeString());
|
||||
whereParam.put("id",dataId);
|
||||
boolean updateFlag = this.updateMode(tableName, param, whereParam);
|
||||
if(updateFlag){
|
||||
mri.rebuildModeDataShareByEdit(1, Util.getIntValue(modeId,-1),dataId);
|
||||
}else {
|
||||
logger.info("更新失败,从表==>"+tableName+" 删除数据:"+dataId);
|
||||
String deleteSql = "delete from "+tableName+" where id = ?";
|
||||
RecordSet deleteRecordSet = new RecordSet();
|
||||
deleteRecordSet.executeUpdate(deleteSql,dataId);
|
||||
}
|
||||
return dataId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将接口调用信息插入至建模中不做权限重构
|
||||
* @param tableName 表名
|
||||
* @param param 插入信息
|
||||
* @param modeId 模块id
|
||||
* @return
|
||||
*/
|
||||
public int insertToModeNoRight(String tableName,Map<String,Object> param,String modeId){
|
||||
logger.info("=====插入建模信息====");
|
||||
if(modeId == null || "".equals(modeId)) {
|
||||
modeId = this.getModeIdByTableName(tableName);
|
||||
}
|
||||
logger.info("通过表名获取modeId ==>modeId"+modeId+" tableName==>"+tableName);
|
||||
Map<String,Object> whereParam = new HashMap<>();
|
||||
int dataId = mdu.getModeDataNewId(tableName, Util.getIntValue(modeId,-1), 1, 0, TimeUtil.getCurrentDateString(), TimeUtil.getOnlyCurrentTimeString());
|
||||
whereParam.put("id",dataId);
|
||||
boolean updateFlag = this.updateMode(tableName, param, whereParam);
|
||||
if(updateFlag){
|
||||
return dataId;
|
||||
}else {
|
||||
logger.info("更新失败,从表==>"+tableName+" 删除数据:"+dataId);
|
||||
String deleteSql = "delete from "+tableName+" where id = ?";
|
||||
RecordSet deleteRecordSet = new RecordSet();
|
||||
deleteRecordSet.executeUpdate(deleteSql,dataId);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过表名查询模块id
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
public String getModeIdByTableName(String tableName){
|
||||
String modeId = "";
|
||||
String querySql = "select id from modeinfo where formid = (select id from workflow_bill where tablename = ?)";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeQuery(querySql,tableName);
|
||||
if(recordSet.next()){
|
||||
modeId = Util.null2String(recordSet.getString("id"));
|
||||
}
|
||||
return modeId;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package weaver.xiao.commons.utils.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author XiaoBokang
|
||||
* @create 2022/5/10 18:22
|
||||
*/
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface SqlFieldMapping {
|
||||
/** 字段所属 1:数据库值,2:默认值 */
|
||||
int type() default 1;
|
||||
/** 数据库字段名或默认值 */
|
||||
String value();
|
||||
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package weaver.youhong.ai.pcn.hrorganization.sftp;
|
||||
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.fileUtil.sftp.SftpConnectUtil;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
|
||||
/**
|
||||
* <h1>获取数据工具</h1>
|
||||
*
|
||||
|
@ -16,4 +20,20 @@ public class FetchDataUtil {
|
|||
|
||||
|
||||
|
||||
|
||||
public FetchDataUtil(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void downloadFile(SftpConnectUtil sftpConnectUtil,String fileName,
|
||||
String targetFile){
|
||||
try {
|
||||
sftpConnectUtil.get(fileName, targetFile);
|
||||
} catch (SftpException e) {
|
||||
throw new CustomerException("下载文件出错,down file error!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package weaver.zwl.common;
|
||||
|
||||
|
||||
import weaver.common.StringUtil;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.request.RequestManager;
|
||||
|
||||
/**
|
||||
* 自定义Action实现类,添加通用参数
|
||||
* @author bleach
|
||||
* @date 2019-10-09
|
||||
* @verion 1.0
|
||||
*/
|
||||
public abstract class CusBaseAction extends ToolUtil implements Action {
|
||||
//当前类名称
|
||||
private String className = this.getClass().getName();
|
||||
|
||||
|
||||
protected RequestInfo requestInfo;//流程请求信息实体类
|
||||
protected RecordSetTrans rsts = null;//流程操作事务数据集
|
||||
protected String tablename;//当前流程表单名称
|
||||
protected String requestId;//流程请求ID
|
||||
protected String workflowId;//流程类型ID
|
||||
protected User user = null;//当前用户
|
||||
protected int creater = -1;//流程创建人ID
|
||||
protected RequestManager reqManager = null;
|
||||
protected String[] baseArray = new String[3];
|
||||
|
||||
protected abstract String handle();//Action 具体操作
|
||||
|
||||
/**
|
||||
* 实现父类方法
|
||||
*
|
||||
* @param requestInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
this.requestInfo = requestInfo;
|
||||
|
||||
this.rsts = requestInfo.getRsTrans();
|
||||
if (this.rsts == null) {
|
||||
rsts = new RecordSetTrans();
|
||||
}
|
||||
this.initParam();
|
||||
return handle();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化常用参数
|
||||
*/
|
||||
private void initParam() {
|
||||
this.requestId = StringUtil.vString(requestInfo.getRequestid());
|
||||
this.workflowId = StringUtil.vString(requestInfo.getWorkflowid());
|
||||
this.reqManager = requestInfo.getRequestManager();
|
||||
this.user = reqManager.getUser();
|
||||
this.creater = reqManager.getCreater();
|
||||
|
||||
this.tablename = requestInfo.getRequestManager().getBillTableName();
|
||||
|
||||
//通过系统请求管理类获取表单名称失败,再次查询
|
||||
if ("".equals(this.tablename)) {
|
||||
tablename = getBillTableNameByWorkflowId(this.workflowId);
|
||||
}
|
||||
|
||||
//获取流程基础数据
|
||||
String select_base_sql = "select * from workflow_requestbase where requestid = ?";
|
||||
try {
|
||||
if (rsts == null) {
|
||||
rsts = new RecordSetTrans();
|
||||
}
|
||||
|
||||
String request_name = "";
|
||||
String request_mark = "";
|
||||
|
||||
if (rsts.executeQuery(select_base_sql, requestId)) {
|
||||
while (rsts.next()) {
|
||||
request_name = Util.null2String(rsts.getString("requestname"));
|
||||
request_mark = Util.null2String(rsts.getString("requestmark"));
|
||||
}
|
||||
}
|
||||
|
||||
baseArray[0] = this.requestId;
|
||||
baseArray[1] = request_name;
|
||||
baseArray[2] = request_mark;
|
||||
|
||||
this.writeNewDebuggerLog(className, "main_requestname:[" + request_name + "],main_requestmark:[" + request_mark + "],workflowid:[" + workflowId + "],requestid:[" + requestId + "],tablename:[" + tablename + "]");
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
this.writeNewDebuggerLog(className, "get workflow dataset error:[" + e1.getMessage() + "/" + e1.toString() + "]");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,501 @@
|
|||
package weaver.zwl.common;
|
||||
|
||||
import weaver.conn.ConnStatementDataSource;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.zwl.common.logging.Logger;
|
||||
import weaver.zwl.common.logging.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 常用工具方法-公用类
|
||||
* @author bleach
|
||||
* @date 2018-01-18
|
||||
* @version 2.0 Modify By Weilin.Zhu 添加日志级别 2018-12-05
|
||||
* @version 3.0 Modify By Weilin.Zhu 修改日志输出方式,使用log4j 2020-03-10
|
||||
*/
|
||||
public class ToolUtil extends BaseBean {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger("cus");
|
||||
|
||||
/**
|
||||
* 是否开启调试模式
|
||||
*/
|
||||
boolean isDebug = true;
|
||||
|
||||
/**
|
||||
* 日志层级 (0:调试[Debugger] 1:警告[Warning] 2:错误[Error]
|
||||
*/
|
||||
private int logLevel = 2;
|
||||
|
||||
private RecordSet rs = new RecordSet();
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
public ToolUtil() {
|
||||
// TODO Auto-generated constructor stub
|
||||
logger = LoggerFactory.getLogger("cus");
|
||||
//是否开启日志模式
|
||||
String isopen = getSystemParamValue("Debug_Mode");
|
||||
|
||||
//输出日志级别
|
||||
logLevel = Util.getIntValue(getSystemParamValue("Logger_Level"),-1);
|
||||
|
||||
if("1".equals(isopen)){
|
||||
isDebug = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程类型ID获取其对应的表单名称
|
||||
* @param workflowid 流程类型ID
|
||||
* @return 字符串
|
||||
*/
|
||||
public String getBillTableNameByWorkflowId(String workflowid){
|
||||
String tablename = "";
|
||||
|
||||
if(!"".equals(workflowid)){
|
||||
String select_data = "select tablename from workflow_bill where id in (select formid from workflow_base where id = ?)";
|
||||
|
||||
if(rs.executeQuery(select_data, workflowid)){
|
||||
if(rs.next()){
|
||||
tablename = Util.null2String(rs.getString(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tablename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询满足模糊查询的所有标识集合
|
||||
* @param likestr 模糊条件
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getSystemParamValueMap(String likestr){
|
||||
return getSystemParamList(likestr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统中所有参数配置
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getAllSystemParamValue(){
|
||||
return getSystemParamList("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取参数集合
|
||||
* @param likestr 模糊查询的条件
|
||||
* @return 集合
|
||||
*/
|
||||
private Map<String,String> getSystemParamList(String likestr){
|
||||
Map<String,String> param_map = new HashMap<String, String>();
|
||||
|
||||
String select_sql = "select uuid,paramvalue from uf_systemconfig";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
if(!"".equals(likestr)){
|
||||
select_sql += " where uuid like '%" + likestr + "%'";
|
||||
}
|
||||
|
||||
if(rs.execute(select_sql)){
|
||||
while(rs.next()){
|
||||
String uuid = Util.null2String(rs.getString(1));
|
||||
String paramvalue = Util.null2String(rs.getString(2));
|
||||
|
||||
param_map.put(uuid, paramvalue);
|
||||
}
|
||||
}
|
||||
|
||||
return param_map;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统参数设置值
|
||||
* @param uuid 参数标识
|
||||
* @return 返回配置值
|
||||
*/
|
||||
public String getSystemParamValue(String uuid){
|
||||
String paramvalue = "";
|
||||
|
||||
if(!"".equals(uuid)){
|
||||
String select_sql = "select paramvalue from uf_systemconfig where uuid = ?";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(select_sql,uuid);
|
||||
if(rs.next()){
|
||||
paramvalue = Util.null2String(rs.getString(1));
|
||||
}
|
||||
}
|
||||
|
||||
return paramvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用数据库值,根据规则转换,获取其最终结果
|
||||
* @param cus_sql 自定义转换的SQL
|
||||
* @param value 参数值
|
||||
* @return 配置值
|
||||
*/
|
||||
public String getValueByChangeRule(String cus_sql,String value){
|
||||
|
||||
return getValueByChangeRule(cus_sql,value,"");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用数据库值,根据规则转换,获取其最终结果
|
||||
* @param cus_sql 自定义转换的SQL
|
||||
* @param value 参数值
|
||||
* @param requestid 流程请求ID
|
||||
* @return
|
||||
*/
|
||||
public String getValueByChangeRule(String cus_sql,String value,String requestid){
|
||||
|
||||
return getValueByChangeRule(cus_sql,value,requestid,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用数据库值,根据规则转换,获取其最终结果
|
||||
* @param cus_sql 自定义转换的SQL
|
||||
* @param value 参数值
|
||||
* @param requestid 流程请求ID
|
||||
* @param detailKeyvalue 明细表主键值
|
||||
* @return
|
||||
*/
|
||||
public String getValueByChangeRule(String cus_sql,String value,String requestid,int detailKeyvalue){
|
||||
return getValueByChangeRule(cus_sql,value,requestid,detailKeyvalue,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用数据库值,根据规则转换,获取其最终结果
|
||||
* @param cus_sql 自定义转换的SQL
|
||||
* @param value 参数值
|
||||
* @param requestid 流程请求ID
|
||||
* @param detailKeyvalue 明细表主键值
|
||||
* @pram datasourceid 外部数据源ID
|
||||
* @return
|
||||
*/
|
||||
public String getValueByChangeRule(String cus_sql,String value,String requestid,int detailKeyvalue,String datasourceid){
|
||||
String endValue = "";
|
||||
|
||||
cus_sql = cus_sql.replace(" ", " ");
|
||||
|
||||
cus_sql = cus_sql.replace("{?dt.id}", String.valueOf(detailKeyvalue));
|
||||
|
||||
//参数进行替换
|
||||
String sqlString = cus_sql.replace("{?requestid}", requestid);
|
||||
|
||||
sqlString = sqlString.replace("?", value);
|
||||
|
||||
sqlString = ToDBC(sqlString);
|
||||
try {
|
||||
if(datasourceid != null && !"".equals(datasourceid)){
|
||||
ConnStatementDataSource csds = new ConnStatementDataSource(datasourceid);
|
||||
|
||||
csds.setStatementSql(sqlString);
|
||||
|
||||
csds.executeQuery();
|
||||
|
||||
if(csds.next()){
|
||||
endValue = Util.null2String(csds.getString(1));
|
||||
}
|
||||
|
||||
csds.close();
|
||||
}else{
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
if(rs.executeQuery(sqlString)){
|
||||
rs.next();
|
||||
|
||||
endValue = Util.null2String(rs.getString(1));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return endValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用数据库值,根据规则转换,获取其最终结果
|
||||
* @param cus_sql 自定义转换的SQL
|
||||
* @param value 参数值
|
||||
* @return
|
||||
*/
|
||||
public String getValueByChangeRule_SingleParam(String cus_sql,String value){
|
||||
String endValue = "";
|
||||
|
||||
cus_sql = cus_sql.replace(" ", " ");
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
if(rs.executeQuery(cus_sql,value)){
|
||||
rs.next();
|
||||
|
||||
endValue = Util.null2String(rs.getString(1));
|
||||
}
|
||||
|
||||
return endValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全角转半角
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public String ToDBC(String input) {
|
||||
char c[] = input.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (c[i] == '\u3000') {
|
||||
c[i] = ' ';
|
||||
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||
c[i] = (char) (c[i] - 65248);
|
||||
}
|
||||
}
|
||||
String returnString = new String(c);
|
||||
return returnString;
|
||||
}
|
||||
/**
|
||||
* 根据字段ID获取其对应的字段名称
|
||||
* @param fieldid
|
||||
* @return
|
||||
*/
|
||||
public String getFieldNameByFieldid(int fieldid){
|
||||
if(fieldid > 0){
|
||||
return getFieldNameByFieldid(String.valueOf(fieldid));
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字段ID获取其对应的字段名称
|
||||
* @param fieldid
|
||||
* @return
|
||||
*/
|
||||
public String getFieldNameByFieldid(String fieldid){
|
||||
String fieldname = "";
|
||||
|
||||
if(!"".equals(fieldid)){
|
||||
|
||||
if(fieldid.startsWith(",")){
|
||||
fieldid = fieldid.substring(1);
|
||||
}
|
||||
|
||||
if(fieldid.endsWith(",")){
|
||||
fieldid =fieldid.substring(0,fieldid.length() - 1);
|
||||
}
|
||||
|
||||
String select_sql = "select fieldname from workflow_billfield where id in (" + fieldid + ")";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
if(rs.execute(select_sql)){
|
||||
while(rs.next()){
|
||||
|
||||
fieldname += "," + Util.null2String(rs.getString(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldname.startsWith(",")){
|
||||
fieldname = fieldname.substring(1);
|
||||
}
|
||||
|
||||
return fieldname;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出调试日志
|
||||
* @param logstr 日志信息
|
||||
*/
|
||||
public void writeDebuggerLog(String logstr){
|
||||
if(logLevel >= 0){
|
||||
logger.info(logstr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出调试日志
|
||||
* @param className 类名称
|
||||
* @param logstr 日志信息
|
||||
*/
|
||||
public void writeDebuggerLog(String className,String logstr){
|
||||
if(logLevel >= 0){
|
||||
logger.info(logstr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出警告日志
|
||||
* @param logstr 日志信息
|
||||
*/
|
||||
public void writeWarningLog(String logstr){
|
||||
if(logLevel >= 1){
|
||||
logger.warn(logstr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 输出警告日志
|
||||
* @param className 类名称
|
||||
* @param logstr 日志信息
|
||||
*/
|
||||
public void writeWarningLog(String className,String logstr){
|
||||
if(logLevel >= 1){
|
||||
logger.warn(logstr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出错误日志
|
||||
* @param logstr 日志信息
|
||||
*/
|
||||
public void writeErrorLog(String logstr){
|
||||
logger.error(logstr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 输出错误日志
|
||||
* @param className 类名称
|
||||
* @param logstr 日志信息
|
||||
*/
|
||||
public void writeErrorLog(String className,String logstr){
|
||||
logger.error(logstr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 日志输出
|
||||
* @param logstr
|
||||
*/
|
||||
public void writeDebugLog(Object logstr){
|
||||
logger.info(logstr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志输出
|
||||
* @param logstr
|
||||
*/
|
||||
public void writeNewDebuggerLog(Object o,Object logstr){
|
||||
logger.info(logstr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入同步的日志文件
|
||||
* @param o
|
||||
* @param s
|
||||
* @deprecated 该写入文件的日志输出方式删除
|
||||
*/
|
||||
protected void writeNewLog(String o,String s){
|
||||
try {
|
||||
String filename = "cus_" + TimeUtil.getCurrentDateString() + "_ecology.log";
|
||||
|
||||
|
||||
String folder = GCONST.getRootPath() + "log" + File.separatorChar + "cus";
|
||||
|
||||
//this.writeDebugLog("folder:[" + folder + "]");
|
||||
|
||||
File f = new File(folder);
|
||||
|
||||
// 创建文件夹
|
||||
if (!f.exists()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
|
||||
f = new File(folder + File.separatorChar + filename);
|
||||
//文件不存在,则直接创建
|
||||
if(!f.exists()){
|
||||
f.createNewFile();
|
||||
}
|
||||
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f, true)));
|
||||
|
||||
out.write("[" + o + "][" + TimeUtil.getCurrentTimeString() + "]:"+ s + "\r\n");
|
||||
|
||||
//关闭写入流
|
||||
out.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
writeDebugLog("创建日志文件存在异常:[" + e.getMessage() + "/" + e.toString() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据建模模块ID获取其对应的表单名称
|
||||
* @param modeid 模块ID
|
||||
* @return 建模表单名称
|
||||
*/
|
||||
public String getTableNameByModeID(int modeid){
|
||||
String modeTableName = "";
|
||||
|
||||
if(modeid > 0){
|
||||
String select_sql = "select tablename from modeinfo m left join workflow_bill wb on m.formid = wb.id " +
|
||||
"left join ModeFormExtend me on me.formid = wb.id where m.id = ?";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
if(rs.executeQuery(select_sql,modeid)){
|
||||
if(rs.next()){
|
||||
modeTableName = Util.null2String(rs.getString(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return modeTableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程请求ID获取其对应的表单名称
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public String getTableNameByRequestID(int requestid) {
|
||||
String billTableName = "";
|
||||
if(requestid > 0) {
|
||||
String select_sql = "select wbi.tablename from workflow_requestbase wr inner join workflow_base wb on wr.workflowid = wb.id "
|
||||
+ "inner join workflow_bill wbi on wbi.id = wb.formid where wr.requestid = ?";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
if(rs.executeQuery(select_sql,requestid)){
|
||||
if(rs.next()){
|
||||
billTableName = Util.null2String(rs.getString(1));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return billTableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isDebug
|
||||
*/
|
||||
public boolean isDebug() {
|
||||
return isDebug;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package weaver.zwl.common.logging;
|
||||
|
||||
/**
|
||||
* 写日志(log4j)
|
||||
* @date 2020-03-10
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Log4JLogger implements Logger {
|
||||
|
||||
private org.apache.log4j.Logger log;
|
||||
//类名
|
||||
private String classname;
|
||||
|
||||
@Override
|
||||
public String getClassname() {
|
||||
return classname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassname(String classname) {
|
||||
this.classname = classname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return log.isDebugEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnabled() {
|
||||
return log.isInfoEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object message) {
|
||||
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
log.debug(classname+"."+method+"() - "+message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object message, Throwable exception) {
|
||||
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
log.debug(classname+"."+method+"() - "+message, exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object message) {
|
||||
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
log.info(classname+"."+method+"() - "+message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object message, Throwable exception) {
|
||||
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
log.info(classname+"."+method+"() - "+message, exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object message) {
|
||||
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
log.warn(classname+"."+method+"() - "+message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object message, Throwable exception) {
|
||||
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
log.warn(classname+"."+method+"() - "+message, exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object message) {
|
||||
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
log.error(classname+"."+method+"() - "+message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object message, Throwable exception) {
|
||||
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
log.error(classname+"."+method+"() - "+message, exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(String name) {
|
||||
if("".equals(name)) {
|
||||
name = "cuslog";
|
||||
}
|
||||
log = org.apache.log4j.Logger.getLogger(name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package weaver.zwl.common.logging;
|
||||
|
||||
/**
|
||||
* 日志接口(写)
|
||||
*
|
||||
* @author zwl
|
||||
* @date 2020-03-10
|
||||
*/
|
||||
public interface Logger {
|
||||
|
||||
public boolean isDebugEnabled();
|
||||
|
||||
/**
|
||||
* 打印debug日志
|
||||
* @param message 消息
|
||||
*/
|
||||
public void debug(Object message);
|
||||
|
||||
/**
|
||||
* 打印debug日志
|
||||
* @param message 消息
|
||||
* @param exception 异常
|
||||
*/
|
||||
public void debug(Object message, Throwable exception);
|
||||
|
||||
public boolean isInfoEnabled();
|
||||
|
||||
/**
|
||||
* 打印info日志
|
||||
* @param message 消息
|
||||
*/
|
||||
public void info(Object message);
|
||||
|
||||
|
||||
/**
|
||||
* 打印info日志
|
||||
* @param message 消息
|
||||
* @param exception 异常
|
||||
*/
|
||||
public void info(Object message, Throwable exception);
|
||||
|
||||
/**
|
||||
* 打印warn日志
|
||||
* @param message 消息
|
||||
*/
|
||||
public void warn(Object message);
|
||||
|
||||
/**
|
||||
* 打印warn日志
|
||||
* @param message 消息
|
||||
* @param exception 异常
|
||||
*/
|
||||
public void warn(Object message, Throwable exception);
|
||||
|
||||
/**
|
||||
* 打印error日志
|
||||
* @param message
|
||||
*/
|
||||
public void error(Object message);
|
||||
|
||||
/**
|
||||
* 打印error日志
|
||||
* @param message 消息
|
||||
* @param exception 异常
|
||||
*/
|
||||
public void error(Object message, Throwable exception);
|
||||
|
||||
public String getClassname();
|
||||
|
||||
public void setClassname(String classname);
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @param name logger名称
|
||||
*/
|
||||
public void init(String name);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package weaver.zwl.common.logging;
|
||||
|
||||
|
||||
/**
|
||||
* 日志工厂类
|
||||
*
|
||||
* @author zwl
|
||||
* @date 2020-03-10
|
||||
* @version 1.0
|
||||
*/
|
||||
public class LoggerFactory {
|
||||
private static final String loggerName = "cus";
|
||||
|
||||
public static Logger getLogger(String LogName, String clazz) {
|
||||
if("".equals(LogName)) {
|
||||
LogName = loggerName;
|
||||
}
|
||||
Logger logger = new Log4JLogger();
|
||||
logger.setClassname(clazz);
|
||||
logger.init(LogName);
|
||||
return logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定类的logger对象
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public static Logger getLogger(Class<?> clazz) {
|
||||
return getLogger(loggerName,clazz.getCanonicalName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定类的logger对象
|
||||
* @param className
|
||||
* @return
|
||||
*/
|
||||
public static Logger getLogger(String className) {
|
||||
return getLogger(loggerName,className);
|
||||
}
|
||||
/**
|
||||
* 获取未指定指定类的logger对象
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static Logger getLogger() {
|
||||
String className = Thread.currentThread().getStackTrace()[2].getClassName();
|
||||
return getLogger(loggerName, className);
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ public class BaseTest {
|
|||
GCONST.setServerName("ecology");
|
||||
GCONST.setRootPath("F:\\wxr\\e9-project-ebu7-dev1\\src\\main\\resources\\");
|
||||
GCONST.setSystemFilePath("F:\\wxr\\e9-project-ebu7-dev1\\src\\main\\resources\\file");
|
||||
// GCONST.setLogPath("/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/log");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package xuanran.wang.traffic_bank;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @Author xuanran.wang
|
||||
* @Date 2022/11/22 16:50
|
||||
*/
|
||||
public class TrafficBankTest {
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package youhong.ai.pcn;
|
||||
|
||||
import aiyh.utils.fileUtil.sftp.SftpConnectUtil;
|
||||
import baseTest.BaseTest;
|
||||
import org.junit.Test;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.youhong.ai.pcn.hrorganization.sftp.FetchDataUtil;
|
||||
|
||||
/**
|
||||
* <h1>测试类</h1>
|
||||
*
|
||||
* <p>create: 2022-11-22 15:56</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class TestOrganization extends BaseTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testSftp(){
|
||||
SftpConnectUtil sftpConnectUtil = new SftpConnectUtil(
|
||||
"HR Digital_PROD",
|
||||
"/Users/aoey.oct.22/company/Fan_wei/ssl/pcn/HR_Digital_PROD.ppk",null,"222.73.197.242",
|
||||
null,1000 * 10
|
||||
);
|
||||
FetchDataUtil fetchDataUtil = new FetchDataUtil();
|
||||
fetchDataUtil.downloadFile(sftpConnectUtil,
|
||||
"HRIS_DepartmentExport20200503", GCONST.getSysFilePath() + "HRIS_DepartmentExport20200503.csv");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue