From f95310163ace308f804d4e530d7f9c13d3e30cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 5 Feb 2024 16:30:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96elog=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/elog/LoggerTableController.java | 15 + .../engine/salary/elog/annotation/Elog.java | 23 + .../elog/annotation/ElogDetailField.java | 14 + .../elog/annotation/ElogDetailTable.java | 13 + .../salary/elog/annotation/ElogField.java | 23 + .../elog/annotation/ElogPrimaryKey.java | 9 + .../salary/elog/annotation/ElogTable.java | 14 + .../salary/elog/annotation/ElogTransform.java | 29 + .../salary/elog/annotation/HandleElog.java | 17 + .../salary/elog/annotation/LoggerTarget.java | 22 + .../salary/elog/annotation/OperateType.java | 15 + .../elog/async/LoggerMessageListener.java | 30 + .../engine/salary/elog/config/ELogCache.java | 25 + .../salary/elog/config/ELogTableChecker.java | 44 + .../salary/elog/entity/dto/CancelContext.java | 25 + .../salary/elog/entity/dto/DataTypeEnum.java | 16 + .../salary/elog/entity/dto/ElogBean.java | 116 ++ .../elog/entity/dto/FilterConditionDto.java | 91 ++ .../engine/salary/elog/entity/dto/Like.java | 31 + .../salary/elog/entity/dto/LoggerContext.java | 890 ++++++++++ .../elog/entity/dto/LoggerDetailContext.java | 316 ++++ .../elog/entity/dto/ReadInfoEntity.java | 40 + .../salary/elog/entity/dto/RedoContext.java | 24 + .../salary/elog/entity/dto/ShowColumsDto.java | 105 ++ .../elog/entity/dto/TableChangeBean.java | 153 ++ .../elog/entity/dto/TableColumnBean.java | 155 ++ .../elog/entity/param/ELogGetLogParam.java | 35 + .../entity/param/GetDetailChangesParam.java | 29 + .../engine/salary/elog/enums/ElogConsts.java | 22 + .../salary/elog/enums/FromTerminalType.java | 48 + .../engine/salary/elog/enums/LinkType.java | 173 ++ .../salary/elog/enums/OperateAuditType.java | 14 + .../elog/service/ILocalElogService.java | 13 + .../elog/service/ILoggerTableService.java | 41 + .../elog/service/impl/LocalElogService.java | 435 +++++ .../elog/service/impl/LoggerTableService.java | 1453 +++++++++++++++++ .../elog/threadlocal/ElogThreadLocal.java | 75 + .../salary/elog/util/ElogServiceUtils.java | 92 ++ .../elog/util/ElogSeviceSwitchUtils.java | 1402 ++++++++++++++++ .../salary/elog/util/ElogSeviceUtils.java | 513 ++++++ .../engine/salary/elog/util/ElogUtils.java | 713 ++++++++ .../engine/salary/elog/util/FieldNameMap.java | 94 ++ .../salary/elog/util/LoggerTemplate.java | 631 +++++++ .../elog/util/LoggerTemplateBuilder.java | 21 + .../salary/elog/util/ResponseResult.java | 135 ++ .../salary/elog/util/SalaryI18nUtil.java | 50 + .../salary/elog/util/db/IdGenerator.java | 46 + .../elog/util/db/MapperProxyFactory.java | 79 + .../engine/salary/elog/util/page/Column.java | 23 + .../salary/elog/util/page/DataSource.java | 9 + .../salary/elog/util/page/PageInfo.java | 62 + .../salary/elog/util/page/SalaryPageUtil.java | 117 ++ .../salary/elog/util/page/TableTitle.java | 13 + .../elog/web/LoggerTableController.java | 200 +++ .../mapper/elog/ElogTableCheckerMapper.java | 30 + .../mapper/elog/ElogTableCheckerMapper.xml | 451 +++++ .../mapper/elog/LocalElogAopDaoMapper.java | 45 + .../mapper/elog/LocalElogAopDaoMapper.xml | 170 ++ .../mapper/elog/LocalElogDaoMapper.java | 219 +++ .../salary/mapper/elog/LocalElogDaoMapper.xml | 412 +++++ .../mapper/elog/QueryCurretValusMapper.java | 8 + .../mapper/elog/QueryCurretValusMapper.xml | 9 + 62 files changed, 10137 insertions(+) create mode 100644 src/com/api/salary/elog/LoggerTableController.java create mode 100644 src/com/engine/salary/elog/annotation/Elog.java create mode 100644 src/com/engine/salary/elog/annotation/ElogDetailField.java create mode 100644 src/com/engine/salary/elog/annotation/ElogDetailTable.java create mode 100644 src/com/engine/salary/elog/annotation/ElogField.java create mode 100644 src/com/engine/salary/elog/annotation/ElogPrimaryKey.java create mode 100644 src/com/engine/salary/elog/annotation/ElogTable.java create mode 100644 src/com/engine/salary/elog/annotation/ElogTransform.java create mode 100644 src/com/engine/salary/elog/annotation/HandleElog.java create mode 100644 src/com/engine/salary/elog/annotation/LoggerTarget.java create mode 100644 src/com/engine/salary/elog/annotation/OperateType.java create mode 100644 src/com/engine/salary/elog/async/LoggerMessageListener.java create mode 100644 src/com/engine/salary/elog/config/ELogCache.java create mode 100644 src/com/engine/salary/elog/config/ELogTableChecker.java create mode 100644 src/com/engine/salary/elog/entity/dto/CancelContext.java create mode 100644 src/com/engine/salary/elog/entity/dto/DataTypeEnum.java create mode 100644 src/com/engine/salary/elog/entity/dto/ElogBean.java create mode 100644 src/com/engine/salary/elog/entity/dto/FilterConditionDto.java create mode 100644 src/com/engine/salary/elog/entity/dto/Like.java create mode 100644 src/com/engine/salary/elog/entity/dto/LoggerContext.java create mode 100644 src/com/engine/salary/elog/entity/dto/LoggerDetailContext.java create mode 100644 src/com/engine/salary/elog/entity/dto/ReadInfoEntity.java create mode 100644 src/com/engine/salary/elog/entity/dto/RedoContext.java create mode 100644 src/com/engine/salary/elog/entity/dto/ShowColumsDto.java create mode 100644 src/com/engine/salary/elog/entity/dto/TableChangeBean.java create mode 100644 src/com/engine/salary/elog/entity/dto/TableColumnBean.java create mode 100644 src/com/engine/salary/elog/entity/param/ELogGetLogParam.java create mode 100644 src/com/engine/salary/elog/entity/param/GetDetailChangesParam.java create mode 100644 src/com/engine/salary/elog/enums/ElogConsts.java create mode 100644 src/com/engine/salary/elog/enums/FromTerminalType.java create mode 100644 src/com/engine/salary/elog/enums/LinkType.java create mode 100644 src/com/engine/salary/elog/enums/OperateAuditType.java create mode 100644 src/com/engine/salary/elog/service/ILocalElogService.java create mode 100644 src/com/engine/salary/elog/service/ILoggerTableService.java create mode 100644 src/com/engine/salary/elog/service/impl/LocalElogService.java create mode 100644 src/com/engine/salary/elog/service/impl/LoggerTableService.java create mode 100644 src/com/engine/salary/elog/threadlocal/ElogThreadLocal.java create mode 100644 src/com/engine/salary/elog/util/ElogServiceUtils.java create mode 100644 src/com/engine/salary/elog/util/ElogSeviceSwitchUtils.java create mode 100644 src/com/engine/salary/elog/util/ElogSeviceUtils.java create mode 100644 src/com/engine/salary/elog/util/ElogUtils.java create mode 100644 src/com/engine/salary/elog/util/FieldNameMap.java create mode 100644 src/com/engine/salary/elog/util/LoggerTemplate.java create mode 100644 src/com/engine/salary/elog/util/LoggerTemplateBuilder.java create mode 100644 src/com/engine/salary/elog/util/ResponseResult.java create mode 100644 src/com/engine/salary/elog/util/SalaryI18nUtil.java create mode 100644 src/com/engine/salary/elog/util/db/IdGenerator.java create mode 100644 src/com/engine/salary/elog/util/db/MapperProxyFactory.java create mode 100644 src/com/engine/salary/elog/util/page/Column.java create mode 100644 src/com/engine/salary/elog/util/page/DataSource.java create mode 100644 src/com/engine/salary/elog/util/page/PageInfo.java create mode 100644 src/com/engine/salary/elog/util/page/SalaryPageUtil.java create mode 100644 src/com/engine/salary/elog/util/page/TableTitle.java create mode 100644 src/com/engine/salary/elog/web/LoggerTableController.java create mode 100644 src/com/engine/salary/mapper/elog/ElogTableCheckerMapper.java create mode 100644 src/com/engine/salary/mapper/elog/ElogTableCheckerMapper.xml create mode 100644 src/com/engine/salary/mapper/elog/LocalElogAopDaoMapper.java create mode 100644 src/com/engine/salary/mapper/elog/LocalElogAopDaoMapper.xml create mode 100644 src/com/engine/salary/mapper/elog/LocalElogDaoMapper.java create mode 100644 src/com/engine/salary/mapper/elog/LocalElogDaoMapper.xml create mode 100644 src/com/engine/salary/mapper/elog/QueryCurretValusMapper.java create mode 100644 src/com/engine/salary/mapper/elog/QueryCurretValusMapper.xml diff --git a/src/com/api/salary/elog/LoggerTableController.java b/src/com/api/salary/elog/LoggerTableController.java new file mode 100644 index 0000000..56bd6a5 --- /dev/null +++ b/src/com/api/salary/elog/LoggerTableController.java @@ -0,0 +1,15 @@ +package com.api.salary.elog; + +import javax.ws.rs.Path; + +/** + * 日志列表公共接口暴漏 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Path("/bs/hrmsalary/elog") +public class LoggerTableController extends com.engine.salary.elog.web.LoggerTableController{ +} diff --git a/src/com/engine/salary/elog/annotation/Elog.java b/src/com/engine/salary/elog/annotation/Elog.java new file mode 100644 index 0000000..7e00ca2 --- /dev/null +++ b/src/com/engine/salary/elog/annotation/Elog.java @@ -0,0 +1,23 @@ +package com.engine.salary.elog.annotation; + +import java.lang.annotation.*; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +public @interface Elog { + + String module(); + + String function(); + + String operateType(); + + String operateTypeName(); + + String sql() default ""; + + boolean isLocal() default true; + + String infoMethod() default ""; +} diff --git a/src/com/engine/salary/elog/annotation/ElogDetailField.java b/src/com/engine/salary/elog/annotation/ElogDetailField.java new file mode 100644 index 0000000..129c57d --- /dev/null +++ b/src/com/engine/salary/elog/annotation/ElogDetailField.java @@ -0,0 +1,14 @@ +package com.engine.salary.elog.annotation; + +import java.lang.annotation.*; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface ElogDetailField { + + String fieldType() default "varchar"; + String length() default "50"; + String fieldName(); + String desc() default "自定义字段"; +} diff --git a/src/com/engine/salary/elog/annotation/ElogDetailTable.java b/src/com/engine/salary/elog/annotation/ElogDetailTable.java new file mode 100644 index 0000000..d5054b7 --- /dev/null +++ b/src/com/engine/salary/elog/annotation/ElogDetailTable.java @@ -0,0 +1,13 @@ +package com.engine.salary.elog.annotation; + +import java.lang.annotation.*; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface ElogDetailTable { + + String module(); + + String function() default "common"; +} diff --git a/src/com/engine/salary/elog/annotation/ElogField.java b/src/com/engine/salary/elog/annotation/ElogField.java new file mode 100644 index 0000000..a60c1f6 --- /dev/null +++ b/src/com/engine/salary/elog/annotation/ElogField.java @@ -0,0 +1,23 @@ +package com.engine.salary.elog.annotation; + +import com.engine.salary.elog.entity.dto.DataTypeEnum; + +import java.lang.annotation.*; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface ElogField { + + DataTypeEnum dataType() default DataTypeEnum.VARCHAR; + + int length() default 50; + + String comment() default "自定义字段"; + + String defaultValue() default ""; + + boolean isNull() default true; + + boolean isKey() default false; +} diff --git a/src/com/engine/salary/elog/annotation/ElogPrimaryKey.java b/src/com/engine/salary/elog/annotation/ElogPrimaryKey.java new file mode 100644 index 0000000..291f825 --- /dev/null +++ b/src/com/engine/salary/elog/annotation/ElogPrimaryKey.java @@ -0,0 +1,9 @@ +package com.engine.salary.elog.annotation; + +import java.lang.annotation.*; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.PARAMETER}) +public @interface ElogPrimaryKey { +} diff --git a/src/com/engine/salary/elog/annotation/ElogTable.java b/src/com/engine/salary/elog/annotation/ElogTable.java new file mode 100644 index 0000000..480caf4 --- /dev/null +++ b/src/com/engine/salary/elog/annotation/ElogTable.java @@ -0,0 +1,14 @@ +package com.engine.salary.elog.annotation; + +import java.lang.annotation.*; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) + +public @interface ElogTable { + + String module(); + + String function() default "common"; +} diff --git a/src/com/engine/salary/elog/annotation/ElogTransform.java b/src/com/engine/salary/elog/annotation/ElogTransform.java new file mode 100644 index 0000000..120c41d --- /dev/null +++ b/src/com/engine/salary/elog/annotation/ElogTransform.java @@ -0,0 +1,29 @@ +package com.engine.salary.elog.annotation; + +import java.lang.annotation.*; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.TYPE}) +@Inherited +public @interface ElogTransform { + + String tablename() default ""; + + String name(); + + int labelId() default -1; + + String type() default ""; + + String valuesKVPairs() default ""; + + boolean ignore() default false; + + boolean analyticSubclass() default false; + + boolean analyticList() default false; + + Class analyticListClass() default void.class; + +} diff --git a/src/com/engine/salary/elog/annotation/HandleElog.java b/src/com/engine/salary/elog/annotation/HandleElog.java new file mode 100644 index 0000000..387666b --- /dev/null +++ b/src/com/engine/salary/elog/annotation/HandleElog.java @@ -0,0 +1,17 @@ +package com.engine.salary.elog.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface HandleElog { + + String modulename() default ""; + + String functionname() default ""; + + String service() default ""; +} diff --git a/src/com/engine/salary/elog/annotation/LoggerTarget.java b/src/com/engine/salary/elog/annotation/LoggerTarget.java new file mode 100644 index 0000000..701d4f8 --- /dev/null +++ b/src/com/engine/salary/elog/annotation/LoggerTarget.java @@ -0,0 +1,22 @@ +package com.engine.salary.elog.annotation; + +import java.lang.annotation.*; + +/** + * @ClassName: LoggerTarget + * @Description 日志构造器-自定义注解 + * @Author tanghj + * @Date 2021/2/10 14:18 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface LoggerTarget { +// @AliasFor("module") + String value() default ""; + +// @AliasFor("value") + String module() default ""; + + String function() default "common"; +} diff --git a/src/com/engine/salary/elog/annotation/OperateType.java b/src/com/engine/salary/elog/annotation/OperateType.java new file mode 100644 index 0000000..7dbb843 --- /dev/null +++ b/src/com/engine/salary/elog/annotation/OperateType.java @@ -0,0 +1,15 @@ +package com.engine.salary.elog.annotation; + +public class OperateType { + public static final String view = "view"; + public static final String viewSpan = "查看"; + + public static final String add = "add"; + public static final String addSpan = "新增"; + + public static final String update = "update"; + public static final String updateSpan = "更新"; + + public static final String delete = "delete"; + public static final String deleteSpan = "删除"; +} diff --git a/src/com/engine/salary/elog/async/LoggerMessageListener.java b/src/com/engine/salary/elog/async/LoggerMessageListener.java new file mode 100644 index 0000000..2bf5dc9 --- /dev/null +++ b/src/com/engine/salary/elog/async/LoggerMessageListener.java @@ -0,0 +1,30 @@ +package com.engine.salary.elog.async; + +import com.engine.salary.elog.config.ELogTableChecker; +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.service.impl.LocalElogService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @ClassName: LoggerMessageListener + * @Description 本地日志存储消息队列监听类 + * @Author tanghj + * @Date 2021/2/10 14:18 + */ +public class LoggerMessageListener { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + LocalElogService localElogService = new LocalElogService(); + + public String receiveold(LoggerContext messageBean) { + + new ELogTableChecker().check(messageBean); + localElogService.insertLocalElog(messageBean); + + return ""; + } + + +} diff --git a/src/com/engine/salary/elog/config/ELogCache.java b/src/com/engine/salary/elog/config/ELogCache.java new file mode 100644 index 0000000..3affa8c --- /dev/null +++ b/src/com/engine/salary/elog/config/ELogCache.java @@ -0,0 +1,25 @@ +package com.engine.salary.elog.config; + +import com.engine.salary.mapper.elog.ElogTableCheckerMapper; +import com.engine.salary.elog.util.db.MapperProxyFactory; + +import java.util.HashMap; +import java.util.Map; + +public class ELogCache { + + private Map tableCache = new HashMap<>(); + + private ElogTableCheckerMapper getTableCheckerMapper() { + return MapperProxyFactory.getProxy(ElogTableCheckerMapper.class); + } + + public Long getVersion(String mainTable) { + Long version = tableCache.get(mainTable); + if (version == null) { + version = getTableCheckerMapper().getVersion(mainTable); + tableCache.put(mainTable, version); + } + return version; + } +} diff --git a/src/com/engine/salary/elog/config/ELogTableChecker.java b/src/com/engine/salary/elog/config/ELogTableChecker.java new file mode 100644 index 0000000..3c4b5b9 --- /dev/null +++ b/src/com/engine/salary/elog/config/ELogTableChecker.java @@ -0,0 +1,44 @@ +package com.engine.salary.elog.config; + +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.mapper.elog.ElogTableCheckerMapper; +import com.engine.salary.elog.util.db.IdGenerator; +import com.engine.salary.elog.util.db.MapperProxyFactory; + + +public class ELogTableChecker { + private static final long version = 0; + private ELogCache eLogCache = new ELogCache(); + + private ElogTableCheckerMapper getTableCheckerMapper() { + return MapperProxyFactory.getProxy(ElogTableCheckerMapper.class); + } + + public void check(LoggerContext loggerContext) { + String module = loggerContext.getModuleName(); + String function = loggerContext.getFunctionName(); + String mainTable = String.format("%s_%slogs", module, function); + Long v = eLogCache.getVersion(mainTable); + boolean noTable = v == null; + if (noTable) { + this.initTable(mainTable); + v = version; + } else { + this.checkVersion(mainTable, v); + } + + } + + private void checkVersion(String mainTable, Long v) { + if (v == version) { + return; + } + } + + + private void initTable(String mainTable) { + getTableCheckerMapper().recordVersion(IdGenerator.generate(), mainTable, version); + getTableCheckerMapper().createMainTable(mainTable); + getTableCheckerMapper().createDetailTable(mainTable + "_detail"); + } +} diff --git a/src/com/engine/salary/elog/entity/dto/CancelContext.java b/src/com/engine/salary/elog/entity/dto/CancelContext.java new file mode 100644 index 0000000..d7ecccb --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/CancelContext.java @@ -0,0 +1,25 @@ +package com.engine.salary.elog.entity.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * @ClassName: CancelContext + * @Description 撤销实体类 + * @Author tanghj + * @Date 2021/2/10 14:18 + */ +@ApiModel("撤销实体类") +public class CancelContext { + + @ApiModelProperty("撤销参数") + private T cancleParams; + + public T getCancleParams() { + return cancleParams; + } + + public void setCancleParams(T cancleParams) { + this.cancleParams = cancleParams; + } +} diff --git a/src/com/engine/salary/elog/entity/dto/DataTypeEnum.java b/src/com/engine/salary/elog/entity/dto/DataTypeEnum.java new file mode 100644 index 0000000..b31b8e4 --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/DataTypeEnum.java @@ -0,0 +1,16 @@ +package com.engine.salary.elog.entity.dto; + +public enum DataTypeEnum { + VARCHAR, + BIGINT, + INT, + DATETIME, + TEXT, + LONGTEXT, + DOUBLE, + DECIMAL, + TINYINT, + FLOAT; + + +} diff --git a/src/com/engine/salary/elog/entity/dto/ElogBean.java b/src/com/engine/salary/elog/entity/dto/ElogBean.java new file mode 100644 index 0000000..84a24cf --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/ElogBean.java @@ -0,0 +1,116 @@ +package com.engine.salary.elog.entity.dto; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @Date: 2022/5/2 21:51 + * @Author: deli.xu + * @Description: 日志中心bean + **/ +public class ElogBean implements Serializable { + + + private static final long serialVersionUID = 5357552376749564256L; + private String module; + private String function; + private String current; + private String pageSize; + private String dataset; + private String searchMap; + private List showColumns = new ArrayList<>(); + private List filterConditionDtos = new ArrayList<>(); + private String downloadSize; + private String transMethod; + private Map authParamsJson; + + public String getModule() { + return module; + } + + public void setModule(String module) { + this.module = module; + } + + public String getFunction() { + return function; + } + + public void setFunction(String function) { + this.function = function; + } + + public String getCurrent() { + return current; + } + + public void setCurrent(String current) { + this.current = current; + } + + public String getPageSize() { + return pageSize; + } + + public void setPageSize(String pageSize) { + this.pageSize = pageSize; + } + + public String getDataset() { + return dataset; + } + + public void setDataset(String dataset) { + this.dataset = dataset; + } + + public String getSearchMap() { + return searchMap; + } + + public void setSearchMap(String searchMap) { + this.searchMap = searchMap; + } + + public List getShowColumns() { + return showColumns; + } + + public void setShowColumns(List showColumns) { + this.showColumns = showColumns; + } + + public List getFilterConditionDtos() { + return filterConditionDtos; + } + + public void setFilterConditionDtos(List filterConditionDtos) { + this.filterConditionDtos = filterConditionDtos; + } + + public String getDownloadSize() { + return downloadSize; + } + + public void setDownloadSize(String downloadSize) { + this.downloadSize = downloadSize; + } + + public String getTransMethod() { + return transMethod; + } + + public void setTransMethod(String transMethod) { + this.transMethod = transMethod; + } + + public Map getAuthParamsJson() { + return authParamsJson; + } + + public void setAuthParamsJson(Map authParamsJson) { + this.authParamsJson = authParamsJson; + } +} diff --git a/src/com/engine/salary/elog/entity/dto/FilterConditionDto.java b/src/com/engine/salary/elog/entity/dto/FilterConditionDto.java new file mode 100644 index 0000000..28cb451 --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/FilterConditionDto.java @@ -0,0 +1,91 @@ +package com.engine.salary.elog.entity.dto; + +import java.io.Serializable; + +/** + * @date: 2021/5/25 17:23 + * @author: deli.xu + * @description: + */ +public class FilterConditionDto implements Serializable { + + private static final long serialVersionUID = -3399942468474767859L; + + /** + * 列名 + */ + private String columIndex; + /** + * 值 + */ + private String value; + + /** + * 过滤类型 + */ + private String type; + + /** + * 模糊搜索 + */ + private Like like; + + /** + * 关联条件 + */ + private String connectCondition; + + /** + * sql条件 + */ + private String sql; + + + public String getColumIndex() { + return columIndex; + } + + public void setColumIndex(String columIndex) { + this.columIndex = columIndex; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Like getLike() { + return like; + } + + public void setLike(Like like) { + this.like = like; + } + + public String getConnectCondition() { + return connectCondition; + } + + public void setConnectCondition(String connectCondition) { + this.connectCondition = connectCondition; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } +} diff --git a/src/com/engine/salary/elog/entity/dto/Like.java b/src/com/engine/salary/elog/entity/dto/Like.java new file mode 100644 index 0000000..2caead7 --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/Like.java @@ -0,0 +1,31 @@ +package com.engine.salary.elog.entity.dto; + +import java.io.Serializable; + +/** + * @date: 2021/6/1 17:50 + * @author: deli.xu + * @description: + */ +public class Like implements Serializable { + private static final long serialVersionUID = -3399942468474767851L; + private String prefix; + private String suffix; + + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getSuffix() { + return suffix; + } + + public void setSuffix(String suffix) { + this.suffix = suffix; + } +} diff --git a/src/com/engine/salary/elog/entity/dto/LoggerContext.java b/src/com/engine/salary/elog/entity/dto/LoggerContext.java new file mode 100644 index 0000000..f9be10c --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/LoggerContext.java @@ -0,0 +1,890 @@ +package com.engine.salary.elog.entity.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import com.engine.salary.elog.annotation.ElogField; +import com.engine.salary.elog.annotation.ElogTable; +import com.engine.salary.elog.enums.ElogConsts; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @ClassName: LoggerContext + * @Description 日志实体类。支持通过泛型扩展日志字段 + * @Author tanghj + * @Date 2021/2/10 14:18 + */ +@ElogTable(module = ElogConsts.BASE_TABLE) +@ApiModel("日志实体类") +public class LoggerContext implements Serializable { + + private static final long serialVersionUID = 15869325700230992L; + + private User user; + + @ElogField(comment = "ID", dataType = DataTypeEnum.BIGINT, isKey = true) + @ApiModelProperty("日志ID") + private long id; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 36, comment = "日志UUID") + @ApiModelProperty("日志UUID") + private String uuid = ""; + + @ApiModelProperty("自定义日志字段信息") + private T customInfo; + @ElogField(dataType = DataTypeEnum.DATETIME, comment = "操作时间") + @ApiModelProperty("操作时间") + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + private Date date = new Date(); + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 500, comment = "终端信息") + @ApiModelProperty("终端信息") + private String device = ""; + + @ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "-1", comment = "操作人") + @ApiModelProperty("操作人") + private String operator = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "操作人姓名") + @ApiModelProperty("操作人姓名") + private String operatorName = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 10, comment = "租户id") + @ApiModelProperty("租户id") + private String tenant_key = ""; + + /** + * 要操作的对象在表中的主键值 + */ + @ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "-1", comment = "操作目标id") + @ApiModelProperty("操作目标id") + private String targetId = ""; + + @ElogField(dataType = DataTypeEnum.TEXT, comment = "操作目标名称") + @ApiModelProperty("操作目标名称(用于显示)") + private String targetName = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "模块") + @ApiModelProperty("目标对象类型(大分类,模块,服务)") + private String moduleName;// 模块 + + /** + * 目标对象类型(小分类,模块/服务下的子功能。子项目) + * 数据存储是以模块名_子项目名作为最基本的存储单元 + * 如果是子项目下的子项目 命名为:子项目名_子项目名_子项目名(全部小写) + */ + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "服务(方法)") + @ApiModelProperty("目标对象类型(小分类,模块/服务下的子功能。子项目)") + private String functionName; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "访问接口名") + @ApiModelProperty("访问接口名") + private String interfaceName = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "请求全路径") + @ApiModelProperty("请求全路径") + private String requestUrl = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "请求地址") + @ApiModelProperty("请求地址") + private String requestUri = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 50, comment = "操作类型") + @ApiModelProperty("操作类型(增删改查等)") + private String operateType = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "操作类型名称") + @ApiModelProperty("操作类型名称") + private String operateTypeName = ""; + + /** + * 每个TableChangeBean 为一张表,支持记录多张表的前后值 + */ + @ApiModelProperty("修改前、后的值") + private List changeValues;// 操作表名,[字段名,值] + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 3000, comment = "操作详细说明") + @ApiModelProperty("操作详细说明") + private String operatedesc = ""; + + @ElogField(dataType = DataTypeEnum.LONGTEXT, comment = "涉及的相关参数") + @ApiModelProperty("涉及的相关参数") + private Map params; + + @ApiModelProperty("涉及的相关参数-转string存储") + private String paramsStr; + + /** + * 当作为主表,belongMainId不赋值 + */ + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 36, comment = "所属主表uuid") + @ApiModelProperty("所属主表uuid") + private String belongMainId = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 50, comment = "操作IP") + @ApiModelProperty("操作IP") + private String clientIp = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 50, comment = "分组") + @ApiModelProperty("分组") + private String groupId = ""; + + /*@ApiModelProperty("是否明显表") + private boolean isDetail;*/ + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 1000, comment = "分组标题") + @ApiModelProperty("分组标题") + private String groupNameLabel = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "重做业务接口") + @ApiModelProperty("重做业务接口") + private String redoService = ""; + + @ElogField(dataType = DataTypeEnum.LONGTEXT, comment = "重做参数") + @ApiModelProperty("重做参数") + private RedoContext redoContext; + + @ApiModelProperty("重做参数-转String存储") + private String redoContextStr; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "撤销业务接口") + @ApiModelProperty("撤销业务接口") + private String cancelService = ""; + + @ElogField(dataType = DataTypeEnum.LONGTEXT, comment = "撤销参数") + @ApiModelProperty("撤销参数") + private CancelContext cancelContext; + + @ApiModelProperty("撤销参数-转String存储") + private String cancelContextStr; + + @ApiModelProperty("日志明细列表(值变化列表-自动赋值、或者自定义字段)") + private List detailContexts; + + @ElogField(dataType = DataTypeEnum.DATETIME, defaultValue = "CURRENT_TIMESTAMP", comment = "创建时间") + @ApiModelProperty("创建时间") + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + private Date create_time; + + @ElogField(dataType = DataTypeEnum.DATETIME, defaultValue = "CURRENT_TIMESTAMP", comment = "修改时间") + @ApiModelProperty("修改时间") + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + private Date update_time; + + @ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "-1", comment = "创建人id") + @ApiModelProperty("创建人id") + private long creator; + + @ElogField(dataType = DataTypeEnum.INT, defaultValue = "0", comment = "是否删除") + @ApiModelProperty("是否删除") + private int delete_type; + + @ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "0", comment = "总运行时长") + @ApiModelProperty("总运行时长") + private long totalRunTime; + + @ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "0", comment = "主方法运行时长") + @ApiModelProperty("主方法运行时长") + private long mainRunTime; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, defaultValue = "", comment = "运行结果标识") + @ApiModelProperty("运行结果标识") + private String result = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, defaultValue = "", comment = "来自pc web") + @ApiModelProperty("来自终端") + private String fromTerminal = ""; + + @ElogField(dataType = DataTypeEnum.TEXT, comment = "运行结果描述") + @ApiModelProperty("运行结果描述") + private String resultDesc = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 3000, comment = "原先内容") + @ApiModelProperty("原先内容(et用)") + private String old_content = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 20, comment = "链接类型") + @ApiModelProperty("链接类型(et用)") + private String link_type = ""; + + @ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "0", comment = "链接id") + @ApiModelProperty("链接id(et用)") + private long link_id; + + @ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "0", comment = "原先链接id") + @ApiModelProperty("原先链接id(et用)") + private long old_link_id; + + /** + * 开发可以自由传中间临时参数,不会入库 + */ + @ApiModelProperty("临时参数") + private Object tempParams; + + /** + * 是否忽略该日志,不进行数据记录 + */ + @ApiModelProperty("是否忽略该日志,不进行数据记录") + private boolean logIgnore; + + /** + * 审计操作类型 + */ + @ApiModelProperty("审计操作类型") + protected String operateAuditType; + + /** + * 操作人账号 + */ + @ApiModelProperty("操作人账号") + protected String operateAccount; + + @ApiModelProperty("操作人id(兼容数据库用)") + protected long logOperator; + + @ApiModelProperty("操作人id(兼容数据库用)") + protected long logTargetid; + + @ApiModelProperty("ES存储大字段功能标识") + protected Boolean esFunction; + + @ApiModelProperty("params参数是否忽略记录") + private Boolean paramsIgnore = Boolean.FALSE; + + @ApiModelProperty("params请求体keys") + private List paramsBodyKeys; + + @ApiModelProperty("日志弱控记录") + private Boolean weakElogReocrd = Boolean.FALSE; + + private List clobFieldList; + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public List getClobFieldList() { + return clobFieldList; + } + + public void setClobFieldList(List clobFieldList) { + this.clobFieldList = clobFieldList; + } + + public Boolean getWeakElogReocrd() { + return weakElogReocrd; + } + + public void setWeakElogReocrd(Boolean weakElogReocrd) { + this.weakElogReocrd = weakElogReocrd; + } + + public Boolean getParamsIgnore() { + return paramsIgnore; + } + + public void setParamsIgnore(Boolean paramsIgnore) { + this.paramsIgnore = paramsIgnore; + } + + public List getParamsBodyKeys() { + return paramsBodyKeys; + } + + public void setParamsBodyKeys(List paramsBodyKeys) { + this.paramsBodyKeys = paramsBodyKeys; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public T getCustomInfo() { + return customInfo; + } + + public void setCustomInfo(T customInfo) { + this.customInfo = customInfo; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getDevice() { + return device; + } + + public void setDevice(String device) { + this.device = device; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getTenant_key() { + return tenant_key; + } + + public void setTenant_key(String tenant_key) { + this.tenant_key = tenant_key; + } + + public String getTargetId() { + return targetId; + } + + public void setTargetId(String targetId) { + this.targetId = targetId; + } + + public String getTargetName() { + return targetName; + } + + public void setTargetName(String targetName) { + this.targetName = targetName; + } + + public String getModuleName() { + return moduleName; + } + + public void setModuleName(String moduleName) { + this.moduleName = moduleName; + } + + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(String functionName) { + this.functionName = functionName; + } + + public String getInterfaceName() { + return interfaceName; + } + + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + + public String getOperateType() { + return operateType; + } + + public void setOperateType(String operateType) { + this.operateType = operateType; + } + + public List getChangeValues() { + return changeValues; + } + + public void setChangeValues(List changeValues) { + this.changeValues = changeValues; + } + + public String getOperatedesc() { + return operatedesc; + } + + public void setOperatedesc(String operatedesc) { + this.operatedesc = operatedesc; + } + + public Map getParams() { + return params; + } + + public void setParams(Map params) { + this.params = params; + } + + /*public String getMainId() { + return mainId; + } + + public void setMainId(String mainId) { + this.mainId = mainId; + } + + public String getBelongMainId() { + return belongMainId; + } + + public void setBelongMainId(String belongMainId) { + this.belongMainId = belongMainId; + }*/ + + public String getClientIp() { + return clientIp; + } + + public void setClientIp(String clientIp) { + this.clientIp = clientIp; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + +/* public boolean isDetail() { + return isDetail; + } + + public void setDetail(boolean detail) { + isDetail = detail; + }*/ + + public String getGroupNameLabel() { + return groupNameLabel; + } + + public void setGroupNameLabel(String groupNameLabel) { + this.groupNameLabel = groupNameLabel; + } + + public String getRedoService() { + return redoService; + } + + public void setRedoService(String redoService) { + this.redoService = redoService; + } + + public RedoContext getRedoContext() { + return redoContext; + } + + public void setRedoContext(RedoContext redoContext) { + this.redoContext = redoContext; + } + + public CancelContext getCancelContext() { + return cancelContext; + } + + public void setCancelContext(CancelContext cancelContext) { + this.cancelContext = cancelContext; + } + + public String getCancelService() { + return cancelService; + } + + public void setCancelService(String cancelService) { + this.cancelService = cancelService; + } + + public List getDetailContexts() { + return detailContexts; + } + + public void setDetailContexts(List detailContexts) { + this.detailContexts = detailContexts; + } + + public void addDetailContext(LoggerDetailContext loggerDetailContext) { + if (this.detailContexts != null) { + this.detailContexts.add(loggerDetailContext); + } else { + this.detailContexts = new ArrayList<>(); + this.detailContexts.add(loggerDetailContext); + } + } + + public void addDetailContext(List list) { + if (this.detailContexts != null) { + this.detailContexts.addAll(list); + } else { + this.detailContexts = new ArrayList<>(); + this.detailContexts.addAll(list); + } + } + + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } + + public void setOldValues(Object object) { + TableChangeBean bean = new TableChangeBean(); + bean.setOldValue(object); + getChangeList().add(bean); + } + + public void setOldValueList(List list) { + if (list != null) + list.stream().forEach(obj -> setOldValues(obj)); + } + + public void setNewValueList(List list) { + if (list != null) + list.stream().forEach(obj -> setNewValues(obj)); + } + + public void setNewValues(Object object) { + List list = getChangeList(); + + boolean handled = false; + for (TableChangeBean bean : list) { + if (bean.getNewValue() == null) { + bean.setNewValue(object); + handled = true; + break; + } + } + if (!handled) { + TableChangeBean bean = new TableChangeBean(); + bean.setNewValue(object); + list.add(bean); + } + } + + public void setOldValues(Object object, String tableName, String dataId, String belongDataid) { + setOldValues(object, tableName, dataId, belongDataid, false); + } + + public void setOldValues(Object object, String tableName, String dataId, String belongDataid, boolean isDetail) { + TableChangeBean bean = new TableChangeBean(); + if (StringUtils.isNotEmpty(tableName)) + bean.setTableName(tableName); + if (StringUtils.isNotEmpty(dataId)) + bean.setDataid(dataId); + if (StringUtils.isNotEmpty(belongDataid)) + bean.setBelongDataid(belongDataid); + if (isDetail) + bean.setIsDetail(1); + bean.setOldValue(object); + getChangeList().add(bean); + } + + public void setOldValueList(List list, String tableName, String dataId, String belongDataid) { + setOldValueList(list, tableName, dataId, belongDataid, false); + } + + public void setNewValueList(List list, String tableName, String dataId, String belongDataid) { + setNewValueList(list, tableName, dataId, belongDataid, false); + } + + public void setOldValueList(List list, String tableName, String dataId, String belongDataid, boolean isDetail) { + if (list != null) + list.stream().forEach(obj -> setOldValues(obj, tableName, dataId, belongDataid, isDetail)); + } + + public void setNewValueList(List list, String tableName, String dataId, String belongDataid, boolean isDetail) { + if (list != null) + list.stream().forEach(obj -> setNewValues(obj, tableName, dataId, belongDataid, isDetail)); + } + + public void setNewValues(Object object, String tableName, String dataId, String belongDataid) { + setNewValues(object, tableName, dataId, belongDataid, false); + } + + public void setNewValues(Object object, String tableName, String dataId, String belongDataid, boolean isDetail) { + List list = getChangeList(); + + boolean handled = false; + for (TableChangeBean bean : list) { + if (bean.getNewValue() == null) { + bean.setNewValue(object); + if (StringUtils.isNotEmpty(tableName)) + bean.setTableName(tableName); + if (StringUtils.isNotEmpty(dataId)) + bean.setDataid(dataId); + if (StringUtils.isNotEmpty(belongDataid)) + bean.setBelongDataid(belongDataid); + if (isDetail) + bean.setIsDetail(1); + handled = true; + break; + } + } + if (!handled) { + TableChangeBean bean = new TableChangeBean(); + if (StringUtils.isNotEmpty(tableName)) + bean.setTableName(tableName); + if (StringUtils.isNotEmpty(dataId)) + bean.setDataid(dataId); + if (StringUtils.isNotEmpty(belongDataid)) + bean.setBelongDataid(belongDataid); + if (isDetail) + bean.setIsDetail(1); + bean.setNewValue(object); + list.add(bean); + } + } + + public List getChangeList() { + + if (this.changeValues == null) { + this.changeValues = new ArrayList<>(); + } + + return this.changeValues; + + } + + public Object getParam(String id) { + return this.params.get(id); + } + + public String getOperateTypeName() { + return operateTypeName; + } + + public void setOperateTypeName(String operateTypeName) { + this.operateTypeName = operateTypeName; + } + + public String getParamsStr() { + return paramsStr; + } + + public void setParamsStr(String paramsStr) { + this.paramsStr = paramsStr; + } + + public String getRedoContextStr() { + return redoContextStr; + } + + public void setRedoContextStr(String redoContextStr) { + this.redoContextStr = redoContextStr; + } + + public String getCancelContextStr() { + return cancelContextStr; + } + + public void setCancelContextStr(String cancelContextStr) { + this.cancelContextStr = cancelContextStr; + } + + public String getBelongMainId() { + return belongMainId; + } + + public void setBelongMainId(String belongMainId) { + this.belongMainId = belongMainId; + } + + public String getRequestUrl() { + return requestUrl; + } + + public void setRequestUrl(String requestUrl) { + this.requestUrl = requestUrl; + } + + public String getRequestUri() { + return requestUri; + } + + public void setRequestUri(String requestUri) { + this.requestUri = requestUri; + } + + public Date getCreate_time() { + return create_time; + } + + public void setCreate_time(Date create_time) { + this.create_time = create_time; + } + + public Date getUpdate_time() { + return update_time; + } + + public void setUpdate_time(Date update_time) { + this.update_time = update_time; + } + + public long getCreator() { + return creator; + } + + public void setCreator(long creator) { + this.creator = creator; + } + + public int getDelete_type() { + return delete_type; + } + + public void setDelete_type(int delete_type) { + this.delete_type = delete_type; + } + + public long getTotalRunTime() { + return totalRunTime; + } + + public void setTotalRunTime(long totalRunTime) { + this.totalRunTime = totalRunTime; + } + + public long getMainRunTime() { + return mainRunTime; + } + + public void setMainRunTime(long mainRunTime) { + this.mainRunTime = mainRunTime; + } + + public Object getTempParams() { + return tempParams; + } + + public void setTempParams(Object tempParams) { + this.tempParams = tempParams; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public String getFromTerminal() { + return fromTerminal; + } + + public void setFromTerminal(String fromTerminal) { + this.fromTerminal = fromTerminal; + } + + public String getResultDesc() { + return resultDesc; + } + + public void setResultDesc(String resultDesc) { + this.resultDesc = resultDesc; + } + + public String getOld_content() { + return old_content; + } + + public void setOld_content(String old_content) { + this.old_content = old_content; + } + + public String getLink_type() { + return link_type; + } + + public void setLink_type(String link_type) { + this.link_type = link_type; + } + + public long getLink_id() { + return link_id; + } + + public void setLink_id(long link_id) { + this.link_id = link_id; + } + + public long getOld_link_id() { + return old_link_id; + } + + public void setOld_link_id(long old_link_id) { + this.old_link_id = old_link_id; + } + + public String getOperateAuditType() { + return operateAuditType; + } + + public void setOperateAuditType(String operateAuditType) { + this.operateAuditType = operateAuditType; + } + + public String getOperateAccount() { + return operateAccount; + } + + public void setOperateAccount(String operateAccount) { + this.operateAccount = operateAccount; + } + + public long getLogOperator() { + return logOperator; + } + + public void setLogOperator(long logOperator) { + this.logOperator = logOperator; + } + + public long getLogTargetid() { + return logTargetid; + } + + public void setLogTargetid(long logTargetid) { + this.logTargetid = logTargetid; + } + + public boolean getLogIgnore() { + return logIgnore; + } + + public void setLogIgnore(boolean logIgnore) { + this.logIgnore = logIgnore; + } + + public Boolean getEsFunction() { + return esFunction; + } + + public void setEsFunction(Boolean esFunction) { + this.esFunction = esFunction; + } + +} + diff --git a/src/com/engine/salary/elog/entity/dto/LoggerDetailContext.java b/src/com/engine/salary/elog/entity/dto/LoggerDetailContext.java new file mode 100644 index 0000000..ef4a665 --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/LoggerDetailContext.java @@ -0,0 +1,316 @@ +package com.engine.salary.elog.entity.dto; + +import com.engine.salary.elog.annotation.ElogDetailTable; +import com.engine.salary.elog.annotation.ElogField; +import com.engine.salary.elog.enums.ElogConsts; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.Date; + +/** + * @ClassName: ValueChangeBean + * @Description 值变化实体类(自动将表字段值变更类转换为该类) + * @Author tanghj + * @Date 2021/3/9 11:06 + */ +@ElogDetailTable(module = ElogConsts.BASE_TABLE) +@ApiModel("值变化实体类") +public class LoggerDetailContext implements Serializable { + + private static final long serialVersionUID = 15869325700230992L; + + @ElogField(comment = "ID", dataType = DataTypeEnum.BIGINT, isKey = true) + @ApiModelProperty("ID") + private long id; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 36,comment = "日志UUID") + @ApiModelProperty("同一个bean转换的数据,uuid相同,作为区分标识") + private String uuid = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 36,comment = "主表id") + @ApiModelProperty("主表id") + private String mainid = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 50,comment = "数据id") + @ApiModelProperty("数据id") + private String dataid = ""; + + /** + * 当作为主表,belongDataId不赋值 + */ + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 50,comment = "主表数据id") + @ApiModelProperty("主表数据id") + private String belongDataid = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 200,comment = "表名") + @ApiModelProperty("表名") + private String tableName =""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, defaultValue = "-1", length = 50,comment = "表名labelid") + @ApiModelProperty("表名labelid") + private String tableNameLabelId = "-1"; + @ElogField(dataType = DataTypeEnum.VARCHAR, defaultValue="",isNull = false,length = 50,comment = "对应数据库的表") + @ApiModelProperty("对应数据库的表") + private String tableNameDesc = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 200,comment = "字段名") + @ApiModelProperty("字段名") + private String fieldName =""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, defaultValue = "-1", length = 50,comment = "字段名labelid") + @ApiModelProperty("字段名labelid") + private String fieldNameLabelId = "-1"; + + @ElogField(dataType = DataTypeEnum.LONGTEXT,comment = "更新后的值") + @ApiModelProperty("更新后的值") + private String newValue = ""; + + @ElogField(dataType = DataTypeEnum.LONGTEXT,comment = "更新前的值") + @ApiModelProperty("更新前的值") + private String oldValue = ""; + + @ElogField(dataType = DataTypeEnum.LONGTEXT,comment = "更新后的显示值") + @ApiModelProperty("更新后的显示值") + private String newRealValue = ""; + + @ElogField(dataType = DataTypeEnum.LONGTEXT,comment = "更新前的显示值") + @ApiModelProperty("更新前的显示值") + private String oldRealValue = ""; + + @ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "字段名") + @ApiModelProperty("字段描述") + private String fieldDesc = ""; + + @ElogField(dataType = DataTypeEnum.INT, comment = "字段名") + @ApiModelProperty("字段展示顺序") + private int showorder = 0; + + @ApiModelProperty("自定义字段") + private T customDetailInfo; + + @ElogField(dataType = DataTypeEnum.DATETIME, defaultValue = "CURRENT_TIMESTAMP", comment = "创建时间") + @ApiModelProperty("创建时间") + private Date create_time; + + @ElogField(dataType = DataTypeEnum.DATETIME, defaultValue = "CURRENT_TIMESTAMP", comment = "修改时间") + @ApiModelProperty("修改时间") + private Date update_time; + + @ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "-1", comment = "创建人id") + @ApiModelProperty("创建人id") + private long creator; + + @ElogField(dataType = DataTypeEnum.INT, defaultValue = "0" , comment = "是否删除") + @ApiModelProperty("是否删除") + private int delete_type; + + @ElogField(dataType = DataTypeEnum.VARCHAR,length = 10,comment = "租户id") + @ApiModelProperty("租户id") + private String tenant_key = ""; + + @ElogField(dataType = DataTypeEnum.INT, defaultValue = "0" , comment = "是否明细字段") + @ApiModelProperty("是否明细字段") + private int isDetail = 0; + + + private String cusValus; + + public String getCusValus() { + return cusValus; + } + + public void setCusValus(String cusValus) { + this.cusValus = cusValus; + } + + + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getMainid() { + return mainid; + } + + public void setMainid(String mainid) { + this.mainid = mainid; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getNewValue() { + return newValue; + } + + public void setNewValue(String newValue) { + this.newValue = newValue; + } + + public String getOldValue() { + return oldValue; + } + + public void setOldValue(String oldValue) { + this.oldValue = oldValue; + } + + public String getFieldDesc() { + return fieldDesc; + } + + public void setFieldDesc(String fieldDesc) { + this.fieldDesc = fieldDesc; + } + + public int getShoworder() { + return showorder; + } + + public void setShoworder(int showorder) { + this.showorder = showorder; + } + + public T getCustomDetailInfo() { + return customDetailInfo; + } + + public void setCustomDetailInfo(T customDetailInfo) { + this.customDetailInfo = customDetailInfo; + } + + public String getDataid() { + return dataid; + } + + public void setDataid(String dataid) { + this.dataid = dataid; + } + + public String getBelongDataid() { + return belongDataid; + } + + public void setBelongDataid(String belongDataid) { + this.belongDataid = belongDataid; + } + + public Date getCreate_time() { + return create_time; + } + + public void setCreate_time(Date create_time) { + this.create_time = create_time; + } + + public Date getUpdate_time() { + return update_time; + } + + public void setUpdate_time(Date update_time) { + this.update_time = update_time; + } + + public long getCreator() { + return creator; + } + + public void setCreator(long creator) { + this.creator = creator; + } + + public int getDelete_type() { + return delete_type; + } + + public void setDelete_type(int delete_type) { + this.delete_type = delete_type; + } + + public String getTenant_key() { + return tenant_key; + } + + public void setTenant_key(String tenant_key) { + this.tenant_key = tenant_key; + } + + public int getIsDetail() { + return isDetail; + } + + public void setIsDetail(int isDetail) { + this.isDetail = isDetail; + } + + public String getNewRealValue() { + return newRealValue; + } + + public void setNewRealValue(String newRealValue) { + this.newRealValue = newRealValue; + } + + public String getOldRealValue() { + return oldRealValue; + } + + public void setOldRealValue(String oldRealValue) { + this.oldRealValue = oldRealValue; + } + + public String getTableNameLabelId() { + return tableNameLabelId; + } + + public void setTableNameLabelId(String tableNameLabelId) { + this.tableNameLabelId = tableNameLabelId; + } + + public String getFieldNameLabelId() { + return fieldNameLabelId; + } + + public void setFieldNameLabelId(String fieldNameLabelId) { + this.fieldNameLabelId = fieldNameLabelId; + } + + public String getTableNameDesc() { + return tableNameDesc; + } + + public void setTableNameDesc(String tableNameDesc) { + this.tableNameDesc = tableNameDesc; + } + + + +} diff --git a/src/com/engine/salary/elog/entity/dto/ReadInfoEntity.java b/src/com/engine/salary/elog/entity/dto/ReadInfoEntity.java new file mode 100644 index 0000000..3f7a364 --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/ReadInfoEntity.java @@ -0,0 +1,40 @@ +package com.engine.salary.elog.entity.dto; + +import java.io.Serializable; +import java.util.Date; + +/** + * @date: 2022/5/14 13:52 + * @author: deli.xu + * @description: + */ + +public class ReadInfoEntity implements Serializable { + private static final long serialVersionUID = -8890667941835568289L; + private Long employeeId; + private Date date; + + public Long getEmployeeId() { + return this.employeeId; + } + + public void setEmployeeId(Long employeeId) { + this.employeeId = employeeId; + } + + public Date getDate() { + return this.date; + } + + public void setDate(Date date) { + this.date = date; + } + + public ReadInfoEntity() { + } + + public ReadInfoEntity(Long employeeId, Date date) { + this.employeeId = employeeId; + this.date = date; + } +} \ No newline at end of file diff --git a/src/com/engine/salary/elog/entity/dto/RedoContext.java b/src/com/engine/salary/elog/entity/dto/RedoContext.java new file mode 100644 index 0000000..3ec87ad --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/RedoContext.java @@ -0,0 +1,24 @@ +package com.engine.salary.elog.entity.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * @ClassName: RedoContext + * @Description 重做实体类 + * @Author tanghj + * @Date 2021/2/10 14:18 + */ +@ApiModel("重做实体类") +public class RedoContext { + @ApiModelProperty("重做参数") + private T redoParams; + + public T getRedoParams() { + return redoParams; + } + + public void setRedoParams(T redoParams) { + this.redoParams = redoParams; + } +} diff --git a/src/com/engine/salary/elog/entity/dto/ShowColumsDto.java b/src/com/engine/salary/elog/entity/dto/ShowColumsDto.java new file mode 100644 index 0000000..b5f47e0 --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/ShowColumsDto.java @@ -0,0 +1,105 @@ +package com.engine.salary.elog.entity.dto; + + +import java.io.Serializable; + +/** + * @date: 2021/5/11 18:46 + * @author: deli.xu + * @description: 显示列对象 + */ +public class ShowColumsDto implements Serializable { + + private static final long serialVersionUID = 4650449925605408753L; + + /** + * 列名 + */ + private String columName; + /** + * 列别名 + */ + private String aliasColumName; + + /** + * 列名index + */ + private String columIndex; + + /** + * 是否隐藏 默认显示 + */ + private boolean isHide = false; + + /** + * 宽度 + */ + private String width; + + /** + * 是否转多语言 + */ + private boolean isTransfLanguage = false; + + /** + * 是否换行 + * @param width + */ + private boolean newLine = false; + + public void setWidth(String width){ + this.width =width; + } + + public String getWidth(){ + return width; + } + public String getColumName() { + return columName; + } + + public void setColumName(String columName) { + this.columName = columName; + } + + public String getAliasColumName() { + return aliasColumName; + } + + public void setAliasColumName(String aliasColumName) { + this.aliasColumName = aliasColumName; + } + + public boolean isHide() { + return isHide; + } + + public void setHide(boolean hide) { + isHide = hide; + } + + public String getColumIndex() { + return columIndex; + } + + public void setColumIndex(String columIndex) { + this.columIndex = columIndex; + } + + public boolean isTransfLanguage() { + return isTransfLanguage; + } + + public boolean isNewLine() { + return newLine; + } + + public void setNewLine(boolean newLine) { + this.newLine = newLine; + } + + public void setTransfLanguage(boolean transfLanguage) { + + isTransfLanguage = transfLanguage; + } +} diff --git a/src/com/engine/salary/elog/entity/dto/TableChangeBean.java b/src/com/engine/salary/elog/entity/dto/TableChangeBean.java new file mode 100644 index 0000000..445bd85 --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/TableChangeBean.java @@ -0,0 +1,153 @@ +package com.engine.salary.elog.entity.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +/** + * @ClassName: TableChangeBean + * @Description 表更新前后值类 + * @Author tanghj + * @Date 2021/3/8 15:58 + */ +@ApiModel("表更新前后值类") +public class TableChangeBean implements Serializable { + + private static final long serialVersionUID = 15869325700230992L; + + @ApiModelProperty("表名") + private String tableName; + + @ApiModelProperty("数据id") + private String dataid; + + @ApiModelProperty("所属主表数据id") + private String belongDataid; + + @ApiModelProperty("是否为明细表(0,否;1,是)") + private int isDetail = 0; + + /** + * 泛型必须是具体的实体类 + */ + @ApiModelProperty("更新前的值") + private T oldValue; + + /** + * 泛型必须是具体的实体类 + */ + @ApiModelProperty("更新后的值") + private T newValue; + + /** + * 泛型必须是具体的实体类 + */ + @ApiModelProperty("更新前显示的值") + private T oldRealValue; + + /** + * 泛型必须是具体的实体类 + */ + @ApiModelProperty("更新后显示的值") + private T newRealValue; + + + @ApiModelProperty("字段对应的labelid") + private String fieldNameLabelId; + + @ApiModelProperty("表对应的labelid") + private String tableNameLabelId; + + @ApiModelProperty("对应数据库的表") + private String tableNameDesc; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public T getOldValue() { + return oldValue; + } + + public void setOldValue(T oldValue) { + this.oldValue = oldValue; + } + + public T getNewValue() { + return newValue; + } + + public void setNewValue(T newValue) { + this.newValue = newValue; + } + + public String getDataid() { + return dataid; + } + + public void setDataid(String dataid) { + this.dataid = dataid; + } + + public String getBelongDataid() { + return belongDataid; + } + + public void setBelongDataid(String belongDataid) { + this.belongDataid = belongDataid; + } + + public int getIsDetail() { + return isDetail; + } + + public void setIsDetail(int isDetail) { + this.isDetail = isDetail; + } + + public T getOldRealValue() { + return oldRealValue; + } + + public void setOldRealValue(T oldRealValue) { + this.oldRealValue = oldRealValue; + } + + public T getNewRealValue() { + return newRealValue; + } + + public String getFieldNameLabelId() { + return fieldNameLabelId; + } + + public void setFieldNameLabelId(String fieldNameLabelId) { + this.fieldNameLabelId = fieldNameLabelId; + } + + public String getTableNameLabelId() { + return tableNameLabelId; + } + + public void setTableNameLabelId(String tableNameLabelId) { + this.tableNameLabelId = tableNameLabelId; + } + + public String getTableNameDesc() { + return tableNameDesc; + } + + public void setTableNameDesc(String tableNameDesc) { + this.tableNameDesc = tableNameDesc; + } + + public void setNewRealValue(T newRealValue) { + this.newRealValue = newRealValue; + } +} diff --git a/src/com/engine/salary/elog/entity/dto/TableColumnBean.java b/src/com/engine/salary/elog/entity/dto/TableColumnBean.java new file mode 100644 index 0000000..a6fdf61 --- /dev/null +++ b/src/com/engine/salary/elog/entity/dto/TableColumnBean.java @@ -0,0 +1,155 @@ +package com.engine.salary.elog.entity.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * @ClassName: TableColumnBean + * @Description 表字段类 + * @Author tanghj + * @Date 2021/3/12 11:44 + */ +@ApiModel("表字段类") +public class TableColumnBean { + + @ApiModelProperty("列名") + private String columnName; + + /** + * varchar(20) + */ + @ApiModelProperty("数据类型") + private String columnType; + + @ApiModelProperty("字段类型-字符串") + private String dataTypeStr; + + @ApiModelProperty("字段类型") + private DataTypeEnum dataType; + + @ApiModelProperty("长度") + private long fieldLength; + + @ApiModelProperty("是否为空") + private boolean isNullable; + + @ApiModelProperty("是否为空-字符串") + private String isNullableStr; + + @ApiModelProperty("默认值") + private Object columnDefault; + + @ApiModelProperty("备注") + private String columnComment; + + public String getColumnName() { + return columnName; + } + + public void setColumnName(String columnName) { + this.columnName = columnName; + } + + public String getColumnType() { + return columnType; + } + + public void setColumnType(String columnType) { + this.columnType = columnType; + } + + public DataTypeEnum getDataType() { + return dataType; + } + + public void setDataType(DataTypeEnum dataType) { + this.dataType = dataType; + } + + public long getFieldLength() { + return fieldLength; + } + + public void setFieldLength(long fieldLength) { + this.fieldLength = fieldLength; + } + + public boolean isNullable() { + return isNullable; + } + + public void setNullable(boolean nullable) { + isNullable = nullable; + } + + public Object getColumnDefault() { + return columnDefault; + } + + public void setColumnDefault(Object columnDefault) { + this.columnDefault = columnDefault; + } + + public String getColumnComment() { + return columnComment; + } + + public void setColumnComment(String columnComment) { + this.columnComment = columnComment; + } + + public String getDataTypeStr() { + return dataTypeStr; + } + + public void setDataTypeStr(String dataTypeStr) { + this.dataTypeStr = dataTypeStr; + } + + public String getIsNullableStr() { + return isNullableStr; + } + + public void setIsNullableStr(String isNullableStr) { + this.isNullableStr = isNullableStr; + } + + public boolean equals(TableColumnBean tableColumnBean) { + + return this.toSql().equals(tableColumnBean.toSql()); + } + + public String toSql() { + + StringBuilder sb = new StringBuilder(this.columnName.toLowerCase()).append(" "); + + if (this.dataType == null) { + return "类型为空"; + } + switch (this.dataType) { + case BIGINT: + case INT: + case TEXT: + case LONGTEXT: + case DATETIME: + case FLOAT: + case TINYINT: + case DOUBLE: + sb.append(this.dataType.name().toLowerCase()).append(" "); + break; + case VARCHAR: + sb.append(this.dataType.name().toLowerCase()).append("(").append(this.fieldLength).append(") "); + break; + case DECIMAL: + long length = (this.fieldLength < 0 || this.fieldLength > 38) ? 0 : this.fieldLength; + sb.append(this.dataType.name().toLowerCase()).append("(").append(38 - length).append(",").append(length).append(") "); + break; + default: + sb.append("varchar").append("(").append(10).append(") "); + } + + sb.append("comment ").append("'").append(this.columnComment).append("' "); + + return sb.toString(); + } +} diff --git a/src/com/engine/salary/elog/entity/param/ELogGetLogParam.java b/src/com/engine/salary/elog/entity/param/ELogGetLogParam.java new file mode 100644 index 0000000..77132c9 --- /dev/null +++ b/src/com/engine/salary/elog/entity/param/ELogGetLogParam.java @@ -0,0 +1,35 @@ +package com.engine.salary.elog.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ELogGetLogParam { + /** + * 服务(模块)名 + */ + String module; + /** + * 方法名 + */ + String function; + /** + * 查询条件 + */ + String condition; + /** + * 每页多少数据 + */ + String pageSize; + /** + * ' + * 当前页 + */ + String current; + +} diff --git a/src/com/engine/salary/elog/entity/param/GetDetailChangesParam.java b/src/com/engine/salary/elog/entity/param/GetDetailChangesParam.java new file mode 100644 index 0000000..aec1582 --- /dev/null +++ b/src/com/engine/salary/elog/entity/param/GetDetailChangesParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.elog.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetDetailChangesParam { + /** + * 服务(模块)名 + */ + String module; + /** + * 方法名 + */ + String function; + /** + * 主键id + */ + String mainid; + /** + * 转换方法 + */ + String detailTransMethod; +} diff --git a/src/com/engine/salary/elog/enums/ElogConsts.java b/src/com/engine/salary/elog/enums/ElogConsts.java new file mode 100644 index 0000000..a895b95 --- /dev/null +++ b/src/com/engine/salary/elog/enums/ElogConsts.java @@ -0,0 +1,22 @@ +package com.engine.salary.elog.enums; + +/** + * @date: 2022/3/30 20:32 + * @author: deli.xu + * @description: 日志常量 + */ +public class ElogConsts { + + public static final String ORACLE = "oracle"; + public static final String SQLSERVER = "sqlserver"; + public static final String MYSQL = "mysql"; + public static final String POSTGRESQL = "postgresql"; + + public static final String BASE_TABLE = "BASE_ELOG_TABLE"; + + public static final String TABLE_SPACER = "_"; + public static final String TABLE_SUFFIX = "logs"; + public static final String DETAIL_TABLE_SUFFIX = "_detail"; + + public static final String ES = "ES"; +} diff --git a/src/com/engine/salary/elog/enums/FromTerminalType.java b/src/com/engine/salary/elog/enums/FromTerminalType.java new file mode 100644 index 0000000..d637bb0 --- /dev/null +++ b/src/com/engine/salary/elog/enums/FromTerminalType.java @@ -0,0 +1,48 @@ +package com.engine.salary.elog.enums; + +/** + * @ClassName: FromTerminalType + * @Description TODO + * @Author tanghj + * @Date 2021/6/8 11:35 + */ +public enum FromTerminalType { + PC("pc","来自 pc web"), + ANDROID("android","来自 安卓"), + IOS("ios","来自 iphone"), + IPHONE("iphone","来自 iphone"), + PC_CLIENT("pc_client","来自 windows客户端"), + MAC_CLIENT("mac_client","来自 mac客户端"), + H5("H5","来自 手机H5"), + MOBILEWEB("mobileWeb","来自 手机H5"), + MICO_MSG("mico_msg","来自 微信"), + WECHAT("wechat","来自 企业微信"), + APP_H5("app_h5","来自 app_h5"), + BROWSER("browser", "来自 网页"), + MOBILE("mobile","来自 移动端"); + + private String code; + private String face; + + FromTerminalType(String code, String face) { + this.code = code; + this.face = face; + } + + public String getCode() { + return code; + } + + public String getFace() { + return face; + } + + public static FromTerminalType fromString(String name) { + try { + FromTerminalType type = FromTerminalType.valueOf(name); + return type; + } catch (Exception e) { + return null; + } + } +} diff --git a/src/com/engine/salary/elog/enums/LinkType.java b/src/com/engine/salary/elog/enums/LinkType.java new file mode 100644 index 0000000..ff78362 --- /dev/null +++ b/src/com/engine/salary/elog/enums/LinkType.java @@ -0,0 +1,173 @@ +package com.engine.salary.elog.enums; + +/** + * @date: 2022/5/13 21:13 + * @author: deli.xu + * @description: 链接类型 用之前老eteams-base-bean + */ + +/** + * 链接类型 + * + * @author gk + */ +public enum LinkType { + + // 主线 + mainline("项目"), + + blog("工作日报"), + + workreport("计划报告"), + + clue("线索"), + + crmcontact("联系人-用于全局搜索"), + + marketactivity("活动"), + + crmSummary("报表"), + + statisticalReport("统计报表"), + + attend("出勤"), + + singalForm("表单应用"), + + biaoge("表格"), + + // 标签 + tag("标签"), + + // 表单标签 + formtag("表单标签"), + + // 附件 + attachment("附件"), + + // 用户 + user("用户"), + + // 任务 + task("任务"), + + // 子任务 + subtask("子任务"), + + // 文档 + document("文档"), + + // 文件夹 + folder("文件夹"), + + // 客户 + customer("客户"), + + // 联系人 + contact("联系人"), + + // 销售商机 + saleChance("销售商机"), + + // 产品 + production("产品"), + + // 合同 + contract("合同"), + + // 竞争对手 + competitor("竞争对手"), + + // 公告 + placard("公告"), + + // 审批 + workflow("审批"), + + // 部门 + department("部门"), + + // 岗位 + position("岗位"), + + // 日程 + calendar("日程"), + + // 群组 + group("群组"), + + // 合同 + hrcontract("人事合同"), + + //人事管理 + hr("人事"), + + //KPI + kpi("绩效考核"),kpiFlow("绩效考核流程"), + + // 全部 + all("所有人"), + + formdatareport("数据上报"), + + form("表单"), + + userSetting("不可见成员"), + + sms("短信"), + + wechatEnterprise("企业微信"), + + wechatService("微信服务号"), + + salarybill("工资单"), + + staffPosition("员工位置")/*定制化模块*/, + + app("应用")/*自定义应用*/, + + email("邮件"), + + workTrends("工作动态"), + + tenantLogo("个性化定制"), + + module("模块"), + + orderform("订单"), + + price("价格"), + + capital("资金"), + + quote("报价"), + + room("会议室管理"), + + //模板任务 + mtTask("模板任务"), + + watchMe("关注我的"), + // crm + crm("CRM"), + + // 空 + blank(""), + + role("角色"), + + externalUser("外部联系人"), + + subcompany("分部"); + + private String displayName; + + LinkType(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + +} diff --git a/src/com/engine/salary/elog/enums/OperateAuditType.java b/src/com/engine/salary/elog/enums/OperateAuditType.java new file mode 100644 index 0000000..5d3850c --- /dev/null +++ b/src/com/engine/salary/elog/enums/OperateAuditType.java @@ -0,0 +1,14 @@ +package com.engine.salary.elog.enums; + +public class OperateAuditType { + //自动 + public static final String AUTO = "AUTO"; + //信息 + public static final String INFO = "INFO"; + //错误 + public static final String ERROR = "ERROR"; + //警告 + public static final String WARNING = "WARNING"; + //重大事件 + public static final String EVENT = "EVENT"; +} \ No newline at end of file diff --git a/src/com/engine/salary/elog/service/ILocalElogService.java b/src/com/engine/salary/elog/service/ILocalElogService.java new file mode 100644 index 0000000..af12b54 --- /dev/null +++ b/src/com/engine/salary/elog/service/ILocalElogService.java @@ -0,0 +1,13 @@ +package com.engine.salary.elog.service; + +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.entity.dto.LoggerDetailContext; + +public interface ILocalElogService { + + int insertLocalElog(LoggerContext context); + + int insertElogDetail(LoggerDetailContext loggerDetailContext, String mainId, String detailTableName); + +// void rollBackElog(LoggerContext context); +} diff --git a/src/com/engine/salary/elog/service/ILoggerTableService.java b/src/com/engine/salary/elog/service/ILoggerTableService.java new file mode 100644 index 0000000..11e166d --- /dev/null +++ b/src/com/engine/salary/elog/service/ILoggerTableService.java @@ -0,0 +1,41 @@ +package com.engine.salary.elog.service; + +import com.cloudstore.eccom.pc.table.WeaTable; +import com.engine.salary.elog.entity.param.ELogGetLogParam; +import com.engine.salary.elog.entity.param.GetDetailChangesParam; +import com.engine.salary.elog.util.page.PageInfo; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Map; + +public interface ILoggerTableService { + PageInfo queryLogs(String data); + + WeaTable queryLogsPapi(String data, HttpServletRequest request); + + List getDetailChanges(GetDetailChangesParam param); + + List getDetailChangesPapi(String module, String function, String mainid, String transMethod, HttpServletRequest request); + + List queryLogList(ELogGetLogParam param); + + List queryCardLogList(String data); + + Map countLog(String module, String function); + + List queryDetailLogList(String module, String function, String current, String pageSize, String condition, String mainId); + + Map countDestailLog(String module, String function, String mainId); + + WeaTable queryElogTraceInfo(String traceId, String module, String function, Integer currentPage, Integer pageSize,String traceTransMethod); + + List queryLogInfoByCustom(String module, String function, String field, String value, boolean isDetail); + + List queryLogInfoByCustom(String module, String function, String field, String value); + +// BatchDocumentMessage downloadLog(String data); + + WeaTable getDetailChangePages(String module, String function, String mainid, String detailTransMethod, String current, String pageSize); + +} diff --git a/src/com/engine/salary/elog/service/impl/LocalElogService.java b/src/com/engine/salary/elog/service/impl/LocalElogService.java new file mode 100644 index 0000000..bcb34a5 --- /dev/null +++ b/src/com/engine/salary/elog/service/impl/LocalElogService.java @@ -0,0 +1,435 @@ +package com.engine.salary.elog.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.entity.dto.LoggerDetailContext; +import com.engine.salary.elog.enums.ElogConsts; +import com.engine.salary.elog.service.ILocalElogService; +import com.engine.salary.elog.util.ElogUtils; +import com.engine.salary.mapper.elog.LocalElogAopDaoMapper; +import com.engine.salary.elog.util.db.IdGenerator; +import com.engine.salary.elog.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.CollectionUtils; +import weaver.conn.RecordSet; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; + +/** + * @ClassName: LocalElogService + * @Description 日志本地持久化 + * @Author tanghj + * @Date 2021/2/24 11:03 + */ +public class LocalElogService implements ILocalElogService { + + private static final Logger logger = LoggerFactory.getLogger(LocalElogService.class); + + private LocalElogAopDaoMapper getLocalElogAopDaoMapper() { + return MapperProxyFactory.getProxy(LocalElogAopDaoMapper.class); + } + +// private RestHighLevelClient client; +// +// private LazyRollBack lazyRollBack; + + //数据库类型 + private static final String databaseId = new RecordSet().getDBType(); + + /** + * @param context + * @param + * @return + */ + @Override + public int insertLocalElog(LoggerContext context) { +// logger.error("接收到的数据,context:{}",JSONObject.toJSONString(context)); +// logger.info("接收到数据的时间:log_date:{}",context.getDate()); + if (StringUtils.isEmpty(context.getUuid())) { + context.setUuid(UUID.randomUUID().toString().replace("-", "")); + } + + String cusColumns = ""; + String cusValus = ""; + if (context.getCustomInfo() != null) { + JSONObject custom = JSONObject.parseObject(JSON.toJSONString(context.getCustomInfo())); + List clobFieldList = context.getClobFieldList(); + for (String key : (Set) custom.keySet()) { + cusColumns = cusColumns + ", " + key; + String keystr = custom.getString(key); + //如果keystr包含单引号,将单引号去掉 + if (StringUtils.isNotEmpty(keystr) && keystr.contains("'")) { + keystr = keystr.replace("'", "''"); + } + //如果是Oracle数据库 + if (ElogConsts.ORACLE.equals(databaseId)) { + //clob字段集合不为空且包含此字段 + if (!CollectionUtils.isEmpty(clobFieldList) && clobFieldList.contains(key)) { + String clobColumnStr = ElogUtils.handleClobColumn(keystr); + cusValus = cusValus + ",TO_CLOB( " + clobColumnStr + " )"; + } else if (checkStrIsDate(keystr)) { + //并且字符串为时间类型格式 则进行特殊处理 + cusValus = cusValus + ",TO_DATE('" + keystr + "', 'SYYYY-MM-DD HH24:MI:SS')"; + } else { + cusValus = cusValus + ",'" + keystr + "'"; + } + } else { + cusValus = cusValus + ",'" + keystr + "'"; + } + } + + } + + normalizationContext(context); + + String tableName = context.getModuleName() + "_" + context.getFunctionName() + "logs"; + //context.setId(IdGenerator.generate()); + Integer id = getLocalElogAopDaoMapper().queryElogContextById(context.getId(), tableName); + if (id != null) { + return 1; + } +// logger.info("插入前的数据:context:{}",JSONObject.toJSONString(context)); + int count = getLocalElogAopDaoMapper().insertElogContext(context, cusColumns, cusValus, tableName); + if (context.getDetailContexts() != null) { + String detailTableName = context.getModuleName() + "_" + context.getFunctionName() + "logs_detail"; + insertBatchDetailPrepared(detailTableName, context); + + } + return count; + } + + /** + * 预编译 + * + * @param detailTableName + * @param context + */ + private void insertBatchDetailPrepared(String detailTableName, LoggerContext context) { + // 用mapper + //分两种 有无自定义字段 + List detailContexts = context.getDetailContexts(); + Boolean hasCustonInfo = false; + String cusColumns = ""; + if (Objects.nonNull(detailContexts.get(0).getCustomDetailInfo())) { + hasCustonInfo = true; + //有自定义明细字段 + JSONObject custom = JSONObject.parseObject(JSON.toJSONString(detailContexts.get(0).getCustomDetailInfo())); + for (String key : (Set) custom.keySet()) { + cusColumns = cusColumns + ", " + key; + } + + } + for (LoggerDetailContext detailContext : detailContexts) { + if (StringUtils.isNotEmpty(detailContext.getNewValue())) { + String str = detailContext.getNewValue().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", ""); + detailContext.setNewValue(str); + } + if (StringUtils.isNotEmpty(detailContext.getOldValue())) { + String str = detailContext.getOldValue().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", ""); + detailContext.setOldValue(str); + } + if (StringUtils.isNotEmpty(detailContext.getNewRealValue())) { + String str = detailContext.getNewRealValue().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", ""); + detailContext.setNewRealValue(str); + } + if (StringUtils.isNotEmpty(detailContext.getOldRealValue())) { + String str = detailContext.getOldRealValue().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", ""); + detailContext.setOldRealValue(str); + } + + + detailContext.setTenant_key(context.getTenant_key()); + detailContext.setCreate_time(new Date()); + detailContext.setUpdate_time(new Date()); + detailContext.setCreator(context.getLogOperator()); + detailContext.setId(IdGenerator.generate()); + if (hasCustonInfo) { + String cusValus = ""; + //如果有明细 + JSONObject custom = JSONObject.parseObject(JSON.toJSONString(detailContext.getCustomDetailInfo())); + for (String key : (Set) custom.keySet()) { + String keystr = custom.getString(key); + //如果keystr包含单引号,将单引号去掉 + if (StringUtils.isNotEmpty(keystr) && keystr.contains("'")) { + keystr = keystr.replace("'", "''"); + } + cusValus = cusValus + ",'" + keystr + "'"; + } + detailContext.setCusValus(cusValus); + } + } + + + if (hasCustonInfo) { + getLocalElogAopDaoMapper().insertElogDetailPreparedHasCustonInfo(detailTableName, detailContexts, context.getUuid(), cusColumns); + } else { + getLocalElogAopDaoMapper().insertElogDetailPrepared(detailTableName, detailContexts, context.getUuid()); + } + } + + + private void normalizationContext(LoggerContext context) { + String params = ""; + if (StringUtils.isNotEmpty(context.getParamsStr())) { + params = context.getParamsStr(); + } else if (context.getParams() != null) { + params = ElogUtils.compress(JSONObject.toJSONString(context.getParams())); + } + + context.setParamsStr(params); + if (StringUtils.isBlank(context.getCancelContextStr())) { + context.setCancelContextStr(context.getCancelContext() == null ? "" : JSONObject.toJSONString(context.getCancelContext())); + } + if (StringUtils.isBlank(context.getRedoContextStr())) { + context.setRedoContextStr(context.getRedoContext() == null ? "" : JSONObject.toJSONString(context.getRedoContext())); + } + + if (StringUtils.isEmpty(context.getOperatedesc())) { + context.setOperatedesc(""); + } else { + //todo 兼容emojo特殊字符 没有时间 先暴力替换 + String str = context.getOperatedesc().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", ""); + context.setOperatedesc(str); + } + + if (Objects.isNull(context.getDate())) { + context.setDate(new Date()); + } + + if (StringUtils.isEmpty(context.getOperator())) { + context.setLogOperator(-1l); + } else { + context.setLogOperator(Long.parseLong(context.getOperator())); + } + if (StringUtils.isEmpty(context.getTargetId())) { + context.setLogTargetid(-1l); + } else { + context.setLogTargetid(Long.parseLong(context.getTargetId())); + } + if (StringUtils.isEmpty(context.getClientIp())) { + context.setClientIp("127.0.0.1"); + } + if (Objects.isNull(context.getCreate_time())) { + context.setCreate_time(new Date()); + } + if (Objects.isNull(context.getUpdate_time())) { + context.setUpdate_time(new Date()); + } + if (Objects.isNull(context.getDelete_type())) { + context.setDelete_type(0); + } + } + + private void insertBatchDetailSql(String detailTableName, LoggerContext context) { + String standardField = "id, mainid, uuid, tablename, fieldname, newvalue, oldvalue, fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue, oldRealValue,tableNameDesc, tableNameLabelId,fieldNameLabelId, create_time, update_time"; + + Boolean hasCustonInfo = false; + StringBuilder sb = new StringBuilder(); + sb.append("INSERT INTO ").append(detailTableName).append("(").append(standardField); + //List collect = detailContexts.stream().filter(s -> Objects.nonNull(s.getCustomDetailInfo())).collect(Collectors.toList()); + List detailContexts = context.getDetailContexts(); + if (Objects.nonNull(detailContexts.get(0).getCustomDetailInfo())) { + hasCustonInfo = true; + //有自定义明细字段 + String cusColumns = ""; + JSONObject custom = JSONObject.parseObject(JSON.toJSONString(detailContexts.get(0).getCustomDetailInfo())); + for (String key : (Set) custom.keySet()) { + cusColumns = cusColumns + ", " + key; + } + sb.append(cusColumns); + } + sb.append(")"); + if ("oracle".equalsIgnoreCase(databaseId)) { + sb.append(" ").append(String.join(" UNION ALL ", getBatchInsertValue(context, hasCustonInfo, true))); + } else { + sb.append(" VALUES ").append(String.join(",", getBatchInsertValue(context, hasCustonInfo, false))); + } + + try { + getLocalElogAopDaoMapper().batchInsertDetail(sb.toString()); + } catch (Exception e) { + logger.error("明细批量添加sql是:{},批量插入明细失败,{}", sb.toString(), e.getMessage(), e); + } + + + } + + + private List getBatchInsertValue(LoggerContext context, boolean hasCustomInfo, boolean isOracle) { + + LocalDateTime localDateTime = LocalDateTime.now(); + String nowDate = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + + List detailContexts = context.getDetailContexts(); + List batchValue = new ArrayList<>(); + for (LoggerDetailContext detailContext : detailContexts) { + detailContext.setTenant_key(context.getTenant_key()); + detailContext.setCreator(context.getLogOperator()); + detailContext.setId(IdGenerator.generate()); + + StringBuilder sb = new StringBuilder(); + sb.append(isOracle ? " SELECT " : " ( "); + sb.append(detailContext.getId()) + .append(",'").append(context.getUuid()).append("'") + .append(",'").append(detailContext.getUuid()).append("'") + .append(",'").append(detailContext.getTableName()).append("'") + .append(",'").append(detailContext.getFieldName()).append("'") + .append(",'").append(transferString(detailContext.getNewValue())).append("'") + .append(",'").append(transferString(detailContext.getOldValue())).append("'") + .append(",'").append(detailContext.getFieldDesc()).append("'") + .append(",'").append(detailContext.getShoworder()).append("'") + .append(",'").append(detailContext.getDataid()).append("'") + .append(",'").append(detailContext.getBelongDataid()).append("'") + .append(",'").append(detailContext.getIsDetail()).append("'") + .append(",'").append(detailContext.getTenant_key()).append("'") + .append(",'").append(detailContext.getCreator()).append("'") + .append(",'").append(transferString(detailContext.getNewRealValue())).append("'") + .append(",'").append(transferString(detailContext.getOldRealValue())).append("'") + .append(",'").append(detailContext.getTableNameDesc()).append("'") + .append(",'").append(detailContext.getTableNameLabelId()).append("'") + .append(",'").append(detailContext.getFieldNameLabelId()).append("'") + .append(",").append(handleValue(nowDate, databaseId)) + .append(",").append(handleValue(nowDate, databaseId)); + + if (hasCustomInfo) { + String cusValus = ""; + //如果有明细 + JSONObject custom = JSONObject.parseObject(JSON.toJSONString(detailContext.getCustomDetailInfo())); + for (String key : (Set) custom.keySet()) { + String keystr = custom.getString(key); + //如果keystr包含单引号,将单引号去掉 + if (StringUtils.isNotEmpty(keystr) && keystr.contains("'")) { + keystr = keystr.replace("'", "''"); + } + cusValus = cusValus + ",'" + keystr + "'"; + } + sb.append(cusValus); + } + String sql = isOracle ? sb.append(" from dual ").toString() : sb.append(")").toString(); + + batchValue.add(sql); + } + + return batchValue; + } + + private String transferString(String str) { + if (StringUtils.isNotEmpty(str)) { + str = str.replaceAll("#\\{", "\\\\\\\\#{"); + if (str.contains("'")) { + str = str.replace("'", "''"); + } + } + return str; + } + + + private String handleValue(String nowDate, String databaseId) { + switch (databaseId) { + case "mysql": + return "'" + nowDate + "'"; + case "oracle": + return "TO_DATE('" + nowDate + "','YYYY-MM-DD HH24:MI:SS')"; + case "sqlserver": + return "'" + nowDate + "'"; + case "postgresql": + return "'" + nowDate + "'"; + + } + return nowDate; + } + +// private void insertESElogCenter(LoggerContext context, String customInfo, String tableName) { +// //将数据转换为ES的数据格式 +// LogESDoc logESDoc = LogESDoc.context2Doc(context, customInfo, tableName); +// String json = JSON.toJSONString(logESDoc); +// String elogESTableName = ElogEsUtils.getElogESTableName(true, ElogEsUtils.getDateStr(context.getDate())); +// IndexRequest indexRequest = new IndexRequest(elogESTableName).id(logESDoc.getId().toString()); +// indexRequest.source(json, XContentType.JSON); +// +// try { +// client.index(indexRequest, RequestOptions.DEFAULT); +// } catch (IOException e) { +//// logger.info("主表数据添加失败:{}",e.getMessage()); +// } +// } + + + @Override + public int insertElogDetail(LoggerDetailContext loggerDetailContext, String mainId, String detailTableName) { + String cusColumns = ""; + String cusValus = ""; + if (loggerDetailContext.getCustomDetailInfo() != null) { + JSONObject custom = JSONObject.parseObject(JSON.toJSONString(loggerDetailContext.getCustomDetailInfo())); + + for (String key : (Set) custom.keySet()) { + cusColumns = cusColumns + ", " + key; + String keystr = custom.getString(key); + //如果keystr包含单引号,将单引号去掉 + if (StringUtils.isNotEmpty(keystr) && keystr.contains("'")) { + keystr = keystr.replace("'", "''"); + } + cusValus = cusValus + ",'" + keystr + "'"; + } + } + loggerDetailContext.setId(IdGenerator.generate()); + return getLocalElogAopDaoMapper().insertElogDetail(loggerDetailContext, mainId, cusColumns, cusValus, detailTableName); + + } + +// @Override +// public void rollBackElog(LoggerContext context) { +// //根据ID 判断数据是否存在 +// +// String tableName = getElogTableName(context.getModuleName(), context.getFunctionName()); +// Integer id = getLocalElogAopDaoMapper().queryElogContextById(context.getId(), tableName); +// //没查到就直接返回 +// if (id == null) { +// lazyRollBack.delayedRollBack(context); +// return; +// } +// getLocalElogAopDaoMapper().rollBackElogById(context.getId(), tableName); +// +//// if (context.getDetailContexts() != null) { +// String detailTableName = context.getModuleName() + "_" + context.getFunctionName() + "logs_detail"; +// //根据uuid回滚 +// getLocalElogAopDaoMapper().rollBackDetailElogByUUID(context.getUuid(), detailTableName); +//// } +// +// +// } + + /** + * 判断字符串是否为日期格式 + */ + public static Boolean checkStrIsDate(String str) { + if (StringUtils.isBlank(str)) { + return false; + } else { + try { + LocalDateTime.parse(str, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + return true; + } catch (Exception e) { + return false; + } + } + } + + private String getElogTableName(String moduleName, String functionName) { + +// List list = Arrays.asList("meetingTopic", "meetingService", "meetingDecision", "meetingSign", "meetingSignSet", "meetingMember", "meetingShare"); + +// if (list.contains(moduleName)) { +// return "meeting"+ "_" + functionName + "logs"; +// } + + return moduleName + "_" + functionName + "logs"; + + } + +} diff --git a/src/com/engine/salary/elog/service/impl/LoggerTableService.java b/src/com/engine/salary/elog/service/impl/LoggerTableService.java new file mode 100644 index 0000000..25346be --- /dev/null +++ b/src/com/engine/salary/elog/service/impl/LoggerTableService.java @@ -0,0 +1,1453 @@ +package com.engine.salary.elog.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.core.impl.Service; +import com.engine.salary.elog.annotation.OperateType; +import com.engine.salary.elog.entity.dto.ElogBean; +import com.engine.salary.elog.entity.dto.FilterConditionDto; +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.entity.dto.ShowColumsDto; +import com.engine.salary.elog.entity.param.ELogGetLogParam; +import com.engine.salary.elog.entity.param.GetDetailChangesParam; +import com.engine.salary.elog.enums.ElogConsts; +import com.engine.salary.elog.service.ILoggerTableService; +import com.engine.salary.elog.util.ElogServiceUtils; +import com.engine.salary.elog.util.ElogSeviceSwitchUtils; +import com.engine.salary.elog.util.ElogSeviceUtils; +import com.engine.salary.elog.util.FieldNameMap; +import com.engine.salary.mapper.elog.LocalElogDaoMapper; +import com.engine.salary.elog.util.SalaryI18nUtil; +import com.engine.salary.elog.util.db.MapperProxyFactory; +import com.engine.salary.elog.util.page.Column; +import com.engine.salary.elog.util.page.PageInfo; +import com.engine.salary.elog.util.page.SalaryPageUtil; +import com.github.pagehelper.Page; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; +import java.util.stream.Collectors; + +public class LoggerTableService extends Service implements ILoggerTableService { + + private static final Logger logger = LoggerFactory.getLogger(LoggerTableService.class); + + private LocalElogDaoMapper getLocalElogDaoMapper() { + return MapperProxyFactory.getProxy(LocalElogDaoMapper.class); + } + + // +// private ComInfoCache comInfoCache; +// +// +// private HrmCommonUtil hrmCommonUtil; +// +// +// private QueryCommonTabeMapper queryCommonTabeMapper; +// +// +// private RestHighLevelClient restHighLevelClient; +// +// @Resource +// private BatchExportSender batchExportSender; +// +// +// @Resource +// private DateRangeTransformer dateRangeTransformer; +// +// +// private HrmCommonEmployeeService hrmCommonEmployeeService; +// +// + private final String databaseId = new RecordSet().getDBType(); + + @Override + public PageInfo queryLogs(String data) { + //解析数据 + ElogBean elogBean = ElogServiceUtils.getElogBean(data); + // columIndex统一转为小写 + Optional.ofNullable(elogBean.getShowColumns()) + .ifPresent(list -> { + list.forEach(x -> { + if (StringUtils.isNotBlank(x.getColumIndex())) { + x.setColumIndex(x.getColumIndex().toLowerCase()); + } + }); + }); + + List showColums = elogBean.getShowColumns(); + String module = elogBean.getModule(); + String function = elogBean.getFunction(); + String searchMap = elogBean.getSearchMap(); + String pageSize = elogBean.getPageSize(); + String pageNum = elogBean.getCurrent(); + String downloadSize = elogBean.getDownloadSize(); + List filterConditionDtos = elogBean.getFilterConditionDtos(); + String transMethod = elogBean.getTransMethod(); + Map authParamsJson = elogBean.getAuthParamsJson(); + + //获取 context 数据 + LoggerContext context = new LoggerContext(); + context.setModuleName(module); + context.setFunctionName(function); + context.setTenant_key(getTenantKey()); +// context.setOperator(getEmployeeId()); + //获取主表 + String tableName = ElogSeviceUtils.getTableName(module, function); + //获取weaTable + List columns = getWeaColumns(data, showColums, module, function); + //获取条件sql + String searchMapsql = getSearchMapSql(searchMap, module, function, elogBean.getShowColumns()); + String sb = getQueryCondition(filterConditionDtos); + sb = searchMapsql.concat(sb); + String customSql = getCustomSql(transMethod, sb, "before"); + + // 分页 + Page page = null; + if (StringUtils.isEmpty(downloadSize)) { + page = new Page(ElogSeviceUtils.getIntValue(pageNum, 1), ElogSeviceUtils.getIntValue(pageSize, 10)); + } else { + int pagesize = ElogSeviceUtils.getIntValue(downloadSize, 5000); + page = new Page(1, pagesize); + } + + List list = getLocalElogDaoMapper().queryElogList(page, context, null, tableName, customSql, "*"); + Map countMap = getLocalElogDaoMapper().elogCount(context, tableName, customSql); + + if ("st".equals(databaseId)) { + //st数据库 date类型特殊处理 + list.forEach(map -> { + map.forEach((k, v) -> { + if (v instanceof Date) { + map.put(k, DateUtil.format((Date) v, "yyyy-MM-dd HH:mm:ss")); + } + }); + }); + + } + //处理转换其他数据库类型值 + list = ElogSeviceSwitchUtils.getSwitchDatabaseData(list); + //处理用户信息Data + + // 大小写转换 + ElogSeviceSwitchUtils.changKey2Lower(list); + + // 存放结果集 + PageInfo pageInfo = SalaryPageUtil.buildPage(page.getPageNum(), page.getPageSize(), switchString(list)); + pageInfo.setTotal(ElogSeviceUtils.getLongValue(countMap.get("counts") + "", 0)); + pageInfo.setColumns(columns); + return pageInfo; + } + + @Override + public WeaTable queryLogsPapi(String data, HttpServletRequest request) { + return null; + } + + @Override + public List getDetailChangesPapi(String module, String function, String mainid, String transMethod, HttpServletRequest request) { + return null; + } + + + private String getshowColumsStr(List showColums) { + StringBuffer sb = new StringBuffer(); + sb.append("id,uuid,targetid,params,operatetype,link_id,link_type,"); + for (ShowColumsDto showColum : showColums) { + String columIndex = showColum.getColumIndex(); + if ("date".equalsIgnoreCase(columIndex) || "createdate".equalsIgnoreCase(columIndex)) { + columIndex = "log_date"; + } else if ("operator".equalsIgnoreCase(columIndex)) { + columIndex = "log_operator"; + } else if ("modulenamespan".equalsIgnoreCase(columIndex)) { + columIndex = "modulename"; + } else if ("functionnameespan".equalsIgnoreCase(columIndex)) { + columIndex = "functionname"; + } else if ("avatar".equals(columIndex)) { + continue; + } + sb.append(columIndex).append(","); + } + String substring = sb.toString().substring(0, sb.toString().length() - 1); + return substring; + } + +// private PermissionParams getPermissionParams(Map hashMap) { +// PermissionParams permissionParams = new PermissionParams(); +// String permissionId = getPermissionStr(hashMap, "permissionId"); +// String permissionType = getPermissionStr(hashMap, "permissionType"); +// String mainDataTableAlias = getPermissionStr(hashMap, "mainDataTableAlias"); +// String mainDataTable = getPermissionStr(hashMap, "mainDataTable"); +// String primaryKey = getPermissionStr(hashMap, "primaryKey"); +// String permissionTargetId = getPermissionStr(hashMap, "permissionTargetId"); +// String permissionConfigSourceId = getPermissionStr(hashMap, "permissionConfigSourceId"); +// +// permissionParams.setPermissionId(permissionId); +// permissionParams.setPermissionType(permissionType); +// permissionParams.setMainDataTableAlias(mainDataTableAlias); +// permissionParams.setMainDataTable(mainDataTable); +// permissionParams.setPrimaryKey(primaryKey); +// permissionParams.setPermissionTargetId(permissionTargetId); +// permissionParams.setPermissionConfigSourceId(permissionConfigSourceId); +// +// return permissionParams; +// +// } + + private List getWeaColumns(String data, List showColums, String module, String function) { + List columns = new ArrayList<>(); + if (showColums != null && showColums.size() > 0) { + for (ShowColumsDto showColum : showColums) { + if (StringUtils.isNotBlank(showColum.getAliasColumName())) { + columns.add(new Column(showColum.getAliasColumName(), showColum.getColumIndex(), showColum.getColumIndex())); + } else if (StringUtils.isNotBlank(showColum.getColumName())) { + columns.add(new Column(FieldNameMap.getMainFieldNameMap(data, function, showColum.getColumName()), showColum.getColumIndex(), showColum.getColumIndex())); + } + } + } else { + columns.add(new Column(FieldNameMap.getMainFieldNameMap(module, function, "moduleName"), "modulenamespan", "modulenamespan")); + columns.add(new Column(FieldNameMap.getMainFieldNameMap(module, function, "functionName"), "functionnamespan", "functionnamespan")); + columns.add(new Column(FieldNameMap.getMainFieldNameMap(module, function, "clientIp"), "clientip", "clientip")); + columns.add(new Column(FieldNameMap.getMainFieldNameMap(module, function, "operateTypeName"), "operatetypename", "operatetypename")); + columns.add(new Column(FieldNameMap.getMainFieldNameMap(module, function, "targetName"), "targetname", "targetname")); + columns.add(new Column(FieldNameMap.getMainFieldNameMap(module, function, "date"), "createdate", "createdate")); + columns.add(new Column(FieldNameMap.getMainFieldNameMap(module, function, "operatorName"), "operatorname", "operatorname")); + } + return columns; + } + + private String getTargetid(List filterConditionDtos) { + if (!filterConditionDtos.isEmpty()) { + for (FilterConditionDto filterConditionDto : filterConditionDtos) { + if ("targetid".equalsIgnoreCase(filterConditionDto.getColumIndex())) { + return filterConditionDto.getValue(); + } + } + } + return ""; + } + + private String getPermissionStr(Map hashMap, String str) { + if (hashMap != null && hashMap.size() > 0) { + Object obj = hashMap.get(str); + if (obj != null) { + return obj.toString(); + } + } + return ""; + } + +// private Map getCustomAuthSql(String transMethod, Map params, String prefix) { +// MethodHandler beforeMethodHandler = ElogMethodHandler.loadMethodHandler(prefix + transMethod); +// Map hashMap = new HashMap<>(); +// if (beforeMethodHandler != null) { +// try { +// hashMap.put("flag", true); +// hashMap.put("msg", ""); +// hashMap.putAll(params); +// Object execute = beforeMethodHandler.execute(hashMap); +// if (execute != null && execute instanceof Map) { +// Map map = (Map) execute; +// return map; +// } +// } catch (Exception e) { +// logger.error("转换出错:" + e); +// throw new RuntimeException(e.getMessage()); +// } +// } +// return hashMap; +// } + + + private String getCustomSql(String transMethod, String sql, String prefix) { +// MethodHandler beforeMethodHandler = ElogMethodHandler.loadMethodHandler(prefix + transMethod); +// boolean flag = false; +// if (beforeMethodHandler != null) { +// try { +// String subSql = ""; +// if (sql.length() > 5) { +// flag = true; +// subSql = sql.substring(5, sql.length()); +// } +// Object execute = beforeMethodHandler.execute(subSql); +// if (execute != null) { +// if (execute instanceof String) { +// StringBuffer sb = null; +// if(execute.toString().length()==0){ +// sb = new StringBuffer(); +// } else if (flag || execute.toString().length() > 0) { +// sb = new StringBuffer(" and "); +// } else { +// sb = new StringBuffer(); +// } +// +// sb.append(execute.toString()); +// return sb.toString(); +// } +// } +// } catch (Exception e) { +// logger.error("转换出错:" + e); +// throw new RuntimeException(e.getMessage()); +// } +// } + return sql; + } + + private void transUserInfo(List list) { +// List operators = new ArrayList<>(); +// if (list != null && list.size() > 0) { +// for (Map map : list) { +// //避免暴露内网地址 +// map.remove("requesturl"); +// +// Object operator = map.get("operator"); +// if (operator != null && StringUtils.isNotBlank(operator.toString())) { +// operators.add(ElogSeviceUtils.getLongValue(operator.toString())); +// } +// } +// } +// List cacheList = comInfoCache.getCacheList(HrmEmployeeComInfo.class, operators); +// Map infoHashMap = new HashMap<>(); +// if (cacheList != null && cacheList.size() > 0) { +// for (HrmEmployeeComInfo hrmEmployeeComInfo : cacheList) { +// HrmAvatarComInfo hrmAvatarComInfo = (HrmAvatarComInfo) comInfoCache.getCacheById(HrmAvatarComInfo.class, hrmEmployeeComInfo.getAvatar()); +// ElogHrmSimpleEmployeeInfo info = new ElogHrmSimpleEmployeeInfo(); +// if (hrmAvatarComInfo != null) { +// info.setAvatarP3Id(hrmAvatarComInfo.getP3()); +// } +// info.setId(hrmEmployeeComInfo.getId()); +// info.setUserName(hrmEmployeeComInfo.getUsername()); +// infoHashMap.put(hrmEmployeeComInfo.getId(), info); +// } +// } +// if (list != null && list.size() > 0) { +// for (Map map : list) { +// Object operator = map.get("operator"); +// if (map.get("params") != null && map.get("params").toString().startsWith("H4s")) { +// map.put("params", ElogSeviceUtils.uncompress(map.get("params").toString())); +// } +// map.put("dboperatorname", Util.null2String(map.get("operatorname"))); +// if (operator != null && StringUtils.isNotBlank(operator.toString())) { +// Map i18nOperatorMap = new HashMap<>(); +// ElogHrmSimpleEmployeeInfo hrmEmployeeComInfo = infoHashMap.get(Long.parseLong(operator.toString())); +// if (hrmEmployeeComInfo != null) { +// //获取最新的人员名称并进行多语言转换 +// i18nOperatorMap.put(Long.parseLong(operator.toString()), hrmEmployeeComInfo.getUserName()); +// Map parseI18nOperator = HrmI18nUtil.batchCovertEmployee(i18nOperatorMap, map.get("tenant_key").toString()); +// map.put("operatorname", parseI18nOperator.get(Long.parseLong(operator.toString()))); +// +//// if (StringUtils.isNotEmpty(hrmEmployeeComInfo.getUserName())) { +//// map.put("operatorname", hrmEmployeeComInfo.getUserName()); +//// } +// if (hrmEmployeeComInfo.getAvatarP3Id() != null) { +// map.put("avatar", hrmEmployeeComInfo.getAvatarP3Id()); +// } +// } +// } +// } +// } + } + + /** + * 获取宽度 + * + * @param showColum + * @return + */ + private String getColumnsWidth(ShowColumsDto showColum) { + if (StringUtils.isBlank(showColum.getWidth())) { + return "5%"; + } else { + return showColum.getWidth(); + } + } + + private String getTenantKey() { +// User currentUser = UserContext.getCurrentUser(); +// if (currentUser != null) { +// return currentUser.getTenantKey(); +// } else { +// String tenantKey = TenantRpcContext.getTenantKey(); +// if (StringUtils.isNotBlank(tenantKey)) { +// return tenantKey; +// } +// } + return "all_teams"; + } + +// private String getEmployeeId() { +// +// User currentUser = UserContext.getCurrentUser(); +// if (currentUser != null && !currentUser.isAdmin()) { +// String employeeId = TenantRpcContext.getEmployeeId(); +// return StringUtils.isNotBlank(employeeId) ? employeeId : ""; +// } +// return ""; +// } +// +// private String getUserId() { +// User currentUser = UserContext.getCurrentUser(); +// if (currentUser != null) { +// return currentUser.getEmployeeId().toString(); +// } +// String employeeId = TenantRpcContext.getEmployeeId(); +// return StringUtils.isNotBlank(employeeId) ? employeeId : ""; +// } + + /** + * 拼接搜索条件 + * + * @param searchMap + * @param module + * @param function + * @return + */ + private String getSearchMapSql(String searchMap, String module, String function, List showColumns) { + StringBuffer sb = new StringBuffer(); + Map map = JSON.parseObject(searchMap); + if (map == null) return sb.toString(); + Iterator> iterators = map.entrySet().iterator(); + while (iterators.hasNext()) { + Map.Entry next = iterators.next(); + String key = next.getKey(); +// SecurityUtil.sqlCheck(key); + if ("date".equals(key) || "createdate".equals(key)) { + Object date = next.getValue(); + if (date != null) { + if (StringUtils.isNotBlank(date.toString())) { + List dates = (List) date; +// if (dates != null && dates.size() == 2) { +// Object startDate = dates.get(0); +// Object endDate = dates.get(1); +// startDate = ElogSeviceUtils.checkValSql(startDate.toString()); +// endDate = ElogSeviceUtils.checkValSql(endDate.toString()); +// if (StringUtils.isNotBlank(startDate.toString()) && StringUtils.isNotBlank(endDate.toString())) { +// startDate = startDate.toString().replaceAll("'", "''"); +// endDate = endDate.toString().replaceAll("'", "''"); +// String dateRangeAfter = dateRangeTransformer.getDateRangeAfter(startDate.toString()); +// String dateRangeBefore = dateRangeTransformer.getDateRangeBefore(endDate.toString()); +// sb.append(" and log_date ").append(" between ").append(getSwithDatabaseDate(dateRangeAfter)).append(" and ").append(getSwithDatabaseDate(dateRangeBefore)).append(" "); +// } else if (StringUtils.isNotBlank(startDate.toString())) { +// String dateRangeAfter = dateRangeTransformer.getDateRangeAfter(startDate.toString()); +// sb.append(" and log_date ").append(" >= ").append(getSwithDatabaseDate(dateRangeAfter)).append(" "); +// } else if (StringUtils.isNotBlank(endDate.toString())) { +// String dateRangeBefore = dateRangeTransformer.getDateRangeBefore(endDate.toString()); +// sb.append(" and log_date ").append(" <= ").append(getSwithDatabaseDate(dateRangeBefore)).append(" "); +// } +// } + } + } + } else if ("operator".equals(next.getKey())) { + Object operator = next.getValue(); + if (operator != null) { + if (StringUtils.isNotBlank(operator.toString())) { + operator = ElogSeviceUtils.checkValSql(operator.toString()); + operator = operator.toString().replaceAll("'", "''"); + if (StringUtils.isNumeric(operator.toString()) && operator.toString().length() > 15) { + sb.append(" and log_operator = ").append(operator.toString()).append(" "); + } + +// else { +// List likeNameHrmEmployeeList = hrmCommonEmployeeService.queryEmpsByCondidtion( +// new HrmOrgEmpCondition().setNameLikeList(Arrays.asList(operator.toString())).setTenantKey(getTenantKey()), +// HrmConditionResultType.BEAN.name()); +// if (likeNameHrmEmployeeList != null && likeNameHrmEmployeeList.size() > 0) { +// List ids = likeNameHrmEmployeeList.stream().map(HrmEmployee::getId).collect(Collectors.toList()); +// if (ids != null && ids.size() > 0) { +// sb.append(" and ( operatorname like '%").append(operator.toString()).append("%' ") +// .append(" or log_operator in (").append(StringUtils.join(ids, ",")).append(")) "); +// } +// } else { +// sb.append(" and operatorname like '%").append(operator.toString()).append("%' "); +// } +// } + } + } + } else if ("modulename".equals(next.getKey())) { + Object moduleName = next.getValue(); + if (moduleName != null) { + moduleName = moduleName.toString().replaceAll("'", "''"); + if (StringUtils.isNotBlank(moduleName.toString())) { + moduleName = ElogSeviceUtils.checkValSql(moduleName.toString()); + //sb.append(" and modulename = '").append(moduleName.toString()).append("' "); + StringBuffer stringBuffer = new StringBuffer(); + if (isEnglish(moduleName.toString())) { + Map moduleMap = ElogSeviceSwitchUtils.moduleMap; + Iterator> iterator = moduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry nextObj = iterator.next(); + if (nextObj.getKey().contains(moduleName.toString())) { + stringBuffer.append("'").append(nextObj.getKey()).append("',"); + } + } + + } else { + Map moduleMap = ElogSeviceSwitchUtils.moduleMap; + Iterator> iterator = moduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry nextObj = iterator.next(); + String val = ElogSeviceSwitchUtils.getModuleName(nextObj.getValue() + ""); + if (val.contains(moduleName.toString())) { + stringBuffer.append("'").append(nextObj.getKey()).append("',"); + } + } + } + String str = ""; + if (stringBuffer.toString().length() > 0) { + str = stringBuffer.substring(0, stringBuffer.length() - 1); + String inVals = str.toString().replaceAll("''", "'"); + sb.append(" and modulename in (").append(inVals).append(") "); + } else { + sb.append(" and modulename = '").append(moduleName.toString()).append("' "); + } + } + } + } else if (databaseId.equalsIgnoreCase(ElogConsts.POSTGRESQL) && "targetid".equalsIgnoreCase(next.getKey())) { + //兼容PG环境int类型不支持模糊搜索的问题 + String value = next.getValue().toString().replaceAll("'", "''"); + value = ElogSeviceUtils.checkValSql(value.toString()); + if (value.startsWith("_")) { + value = value.replace("_", "\\_"); + } + //将类型转为varchar再进行查询 + sb.append(" and ").append("cast(").append(key).append(" as VARCHAR(255) )").append(" like '%").append(value).append("%' "); + } else { + + if (next.getValue() != null && StringUtils.isNotBlank(key) && StringUtils.isNotBlank(next.getValue().toString())) { + String value = next.getValue().toString().replaceAll("'", "''"); + value = ElogSeviceUtils.checkValSql(value.toString()); + StringBuilder stringBuffer = new StringBuilder(); +// if (isLikeSearch(showColumns, key)) { +// String logSearchSql = I18nUtil.getLogSearchSql(ElogSeviceUtils.getTableName(module, function), key, value); +// String sql = logSearchSql.replaceAll("%_", "%\\\\_"); +// try { +// List maps = queryCommonTabeMapper.queryLabelIds(sql); +// if (maps != null && maps.size() > 0) { +// for (Map map1 : maps) { +// Object indexid = map1.get(key); +// if (indexid == null || StringUtils.isEmpty(indexid.toString())) { +// indexid = map1.get(key.toLowerCase()); +// } +// if (indexid != null && StringUtils.isNotEmpty(indexid.toString())) { +// String val = indexid.toString().replace("'", "''"); +// if (ElogSeviceUtils.checkIsNumber(map.get(key))) { +// val = "-" + val; +// value = "-" + value; +// } +// stringBuffer.append("'").append(val).append("',"); +// } +// } +// } +// } catch (Exception e) { +// logger.error("i18查询sql报错:{}", e.getMessage(), e); +// } +// +// } + String str = ""; + if (stringBuffer.toString().length() > 0) { + str = stringBuffer.substring(0, stringBuffer.length() - 1); + if (value.startsWith("_")) { + value = value.replace("_", "\\_"); + } + sb.append(" and (").append(key).append(" like '%").append(value).append("%' "); + //String inVals = str.toString().replaceAll("''", "'"); + if (str.startsWith("_")) { + str = str.replace("_", "\\_"); + } + if ("operatetypename".equals(key)) { + String s = ElogSeviceUtils.checkValSql(next.getValue().toString()); + sb.append(matchOperatetype(s)); + } + sb.append(" or ").append(key).append(" in (").append(str).append(")) "); + } else { + if ("operatetypename".equals(key)) { + sb.append(" and (").append(key).append(" like '%").append(value).append("%' "); + String s = ElogSeviceUtils.checkValSql(next.getValue().toString()); + sb.append(matchOperatetype(s)).append(")"); + } else { + if (value.startsWith("_")) { + value = value.replace("_", "\\_"); + } + sb.append(" and ").append(key).append(" like '%").append(value).append("%' "); + } + } + + } + } + } + return sb.toString(); + } + +// /** +// * 是否模糊搜索 +// * +// * @param showColumns +// * @param key +// * @return +// */ +// private boolean isLikeSearch(List showColumns, String key) { +// for (ShowColumsDto showColumn : showColumns) { +// if (key.equalsIgnoreCase(showColumn.getColumIndex()) && showColumn.isTransfLanguage()) { +// return true; +// } +// } +// return false; +// } + +// private String getSwithDatabaseDate(String date) { +// if (ElogConsts.ORACLE.equals(DatabaseUtil.getDatabaseId())) { +// return " to_date('" + date + "','yyyy-mm-dd hh24:mi:ss') "; +// } else if (ElogConsts.POSTGRESQL.equals(DatabaseUtil.getDatabaseId())) { +// return " to_timestamp('" + date + "', 'YYYY-MM-DD HH24:MI:SS') "; +// } else if (ElogConsts.SQLSERVER.equals(DatabaseUtil.getDatabaseId())) { +// return " convert(nvarchar(19),'" + date + "',120) "; +// } else { +// return " DATE_FORMAT('" + date + "','%Y-%m-%d %H:%i:%s') "; +// } +// } + + public String matchOperatetype(String str) { +// if (ElogSeviceUtils.currentLanguage() != 8) { +// return ""; +// } + List list = new ArrayList(); + list.add(OperateType.add); + list.add(OperateType.update); + list.add(OperateType.view); + list.add(OperateType.delete); + + StringBuffer sb = new StringBuffer(); + for (String o : list) { + if (o.toLowerCase().contains(str.toLowerCase())) { + sb.append("'").append(o).append("',"); + } + } + if ("new".toLowerCase().contains(str.toLowerCase())) { + sb.append("'add',"); + } + String sql = ""; + if (sb.length() > 0) { + sql = sb.toString().substring(0, sb.length() - 1); + sql = "or operatetype in (" + sql + ")"; + } + + return sql; + + } + + + public static boolean isEnglish(String charaString) { + return charaString.matches("^[a-zA-Z]*"); + + } + + /** + * 获取搜索条件 + * + * @param filterConditionDtos + * @return + */ + private String getQueryCondition(List filterConditionDtos) { + StringBuffer sb = new StringBuffer(); + if (filterConditionDtos != null && filterConditionDtos.size() > 0) { + for (FilterConditionDto filterConditionDto : filterConditionDtos) { + if (StringUtils.isNotBlank(filterConditionDto.getColumIndex())) { + sb.append(getsql(filterConditionDto)); + } + } + } + return sb.toString(); + } + + /** + * 拼接sql + * + * @param filterConditionDto + * @return + */ + private String getsql(FilterConditionDto filterConditionDto) { + StringBuffer sb = new StringBuffer(); + filterConditionDto.setConnectCondition(ElogSeviceUtils.checkConditionSql(filterConditionDto.getConnectCondition())); + filterConditionDto.setType(ElogSeviceUtils.checkTypeSql(filterConditionDto.getType())); + filterConditionDto.setValue(ElogSeviceUtils.checkValSql(filterConditionDto.getValue())); + switchDatabaseFieldIndex(filterConditionDto); + if ("LIKE".equalsIgnoreCase(filterConditionDto.getType())) { + if (filterConditionDto.getLike() != null) { + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(" '"). + append(filterConditionDto.getLike().getPrefix() != null ? filterConditionDto.getLike().getPrefix() : ""). + append(filterConditionDto.getValue()). + append(filterConditionDto.getLike().getSuffix() != null ? filterConditionDto.getLike().getSuffix() : ""). + append("' "); + } + } else if ("IN".equalsIgnoreCase(filterConditionDto.getType())) { + String[] split = filterConditionDto.getValue().split("\",\""); + if (split.length > 0) { + StringBuffer str = new StringBuffer("("); + String value = ""; + if ("targetid".equals(filterConditionDto.getColumIndex()) || "log_operator".equals(filterConditionDto.getColumIndex())) { + List list = JSONArray.parseArray(filterConditionDto.getValue(), String.class); + for (String s : list) { + str.append(s).append(","); + } + } else { + List list = JSONArray.parseArray(filterConditionDto.getValue(), String.class); + for (String s : list) { + str.append("'").append(s).append("',"); + } + } + + value = str.toString().substring(0, str.length() - 1); + value += ")"; + switchDatabaseFieldIndex(filterConditionDto); + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(value). + append(" "); + + } else if (split.length == 0) { + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(" ('"). + append(filterConditionDto.getValue()). + append("') "); + } + } else if ("IS NULL".equalsIgnoreCase(filterConditionDto.getType()) || "IS NOT NULL".equalsIgnoreCase(filterConditionDto.getType())) { + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(" "); + } else if ("BETWEEN".equalsIgnoreCase(filterConditionDto.getType())) { + String[] split = filterConditionDto.getValue().split("\",\""); + StringBuffer stringBuffer = new StringBuffer(); + if (split.length > 0) { + List list = JSONArray.parseArray(filterConditionDto.getValue(), String.class); + String str = ""; + for (String s : list) { + stringBuffer.append(" '").append(s).append("' AND"); + } + str = stringBuffer.toString().substring(0, stringBuffer.length() - 3); + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(str). + append(" "); + } else if (split.length == 0) { + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(" '"). + append(filterConditionDto.getValue()). + append("' "); + } + } else { + if ("targetid".equals(filterConditionDto.getColumIndex()) || "log_operator".equals(filterConditionDto.getColumIndex())) { + if (StringUtils.isNotBlank(filterConditionDto.getValue())) { + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(" "). + append(filterConditionDto.getValue()). + append(" "); + } else { + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(" "). + append(-1). + append(" "); + } + } else { + sb.append(" "). + append(getConnectCondition(filterConditionDto.getConnectCondition())). + append(" "). + append(filterConditionDto.getColumIndex()). + append(" "). + append(getQueryType(filterConditionDto.getType())). + append(" '"). + append(filterConditionDto.getValue()). + append("' "); + } + + } + return sb.toString(); + } + + private void switchDatabaseFieldIndex(FilterConditionDto filterConditionDto) { + if ("operator".equalsIgnoreCase(filterConditionDto.getColumIndex())) { + filterConditionDto.setColumIndex("log_operator"); + } else if ("date".equalsIgnoreCase(filterConditionDto.getColumIndex())) { + filterConditionDto.setColumIndex("log_date"); + } else if ("result".equalsIgnoreCase(filterConditionDto.getColumIndex())) { + filterConditionDto.setColumIndex("log_result"); + } + } + + + /** + * 获取查询类型 + * + * @param type + * @return + */ + private String getQueryType(String type) { + //如果不填默认是= + if (StringUtils.isBlank(type)) { + return " = "; + } + return type; + } + + /** + * 获取连接条件 + * + * @param connectCondition + * @return + */ + private String getConnectCondition(String connectCondition) { + //如果不填默认是AND + if (StringUtils.isBlank(connectCondition)) { + return " AND "; + } + return connectCondition; + } + + @Override + public List> getDetailChanges(GetDetailChangesParam param) { + return getDetailChangesMethod(param.getModule(), param.getFunction(), param.getMainid(), param.getDetailTransMethod(), null); + } + + /** + * 明细分页查询 + * + * @param module + * @param function + * @param mainid + * @param detailTransMethod + * @param current + * @param pageSize + * @return + */ + @Override + public WeaTable getDetailChangePages(String module, String function, String mainid, String detailTransMethod, String current, String pageSize) { + + Integer pageNum = Util.getIntValue(current, 1); + Integer size = Util.getIntValue(pageSize, 10); + Page page = new Page(pageNum, size); + + List> list = getDetailChangesMethod(module, function, mainid, null, page); + + //查询分页总数 + String tableName = ElogSeviceUtils.getTableName(module, function, true); + Integer total = getLocalElogDaoMapper().queryAllChangesPageCounts(tableName, mainid); + WeaTable weaTable = new WeaTable(); + weaTable.setColumns(getDetailColumns(list)); + + + PageInfo pageInfo = SalaryPageUtil.buildPage(pageNum, size, list); + pageInfo.setTotal(total); + + return weaTable; + } + + private List getDetailColumns(List> list) { + + List columns = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(list)) { + List detailcontexts = (List) list.get(0).get("detailcontexts"); + if (CollectionUtils.isNotEmpty(detailcontexts)) { + for (Map map : detailcontexts) { + WeaTableColumn weaTableColumn = new WeaTableColumn(); + // 列表属性名 + weaTableColumn.setColumn((String) map.get("fieldname")); + //显示名称 多语言转换 fieldnamelabelid + weaTableColumn.setText((String) map.get("fieldname")); + columns.add(weaTableColumn); + } + } + } + return columns; + } + + public List> getDetailChangesMethod(String module, String function, String mainid, String detailTransMethod, Page page) { + + List list = new ArrayList<>(); + String tableName = ElogSeviceUtils.getTableName(module, function, true); + String maintableName = ElogSeviceUtils.getTableName(module, function, false); + List maps = getLocalElogDaoMapper().queryAllMainData(maintableName, mainid); + + maps = ElogSeviceSwitchUtils.getSwitchDatabaseData(maps); + ElogSeviceSwitchUtils.changKey2Lower(maps); + List allChangesData = new ArrayList<>(); + //如果有分页数据则走分页方法 + if (Objects.nonNull(page)) { +// Integer offset = (pageNum - 1) * size; + //分页查询明细数据 + allChangesData = getLocalElogDaoMapper().queryAllChangesDataPages(tableName, mainid, page); + } else { + //没有被则不分页 + allChangesData = getLocalElogDaoMapper().queryAllChangesData(tableName, mainid); + } + ElogSeviceSwitchUtils.changKey2Lower(allChangesData); + allChangesData = ElogSeviceSwitchUtils.getSwitchDatabaseData(allChangesData); + List mainlist = new ArrayList<>(); + List detaillist = new ArrayList<>(); + if (allChangesData != null && allChangesData.size() > 0) { + for (Map allChangesDatum : allChangesData) { + Object o = allChangesDatum.get("isdetail"); + if (o != null) { + if ("0".equals(o.toString())) { + mainlist.add(allChangesDatum); + } else { + detaillist.add(allChangesDatum); + } + } + } + } +// List mainlist = getLocalElogDaoMapper().queryAllMainChanges(tableName, mainid); +// List detaillist = getLocalElogDaoMapper().queryAllDetailChanges(tableName, mainid); + //List moduleInfo = queryCommonTabeMapper.queryModuleNameInfo(module); + List moduleInfo = new ArrayList<>(); + processDetailInfo(mainlist, detaillist, moduleInfo); + Map map = ElogSeviceSwitchUtils.switchChangeValue(mainlist, maps); + Map detailMap = ElogSeviceSwitchUtils.switchDetailChangeValue(detaillist); + map.putAll(detailMap); + if (maps != null && maps.size() > 0) { + Map maininfoMap = maps.get(0); + String operatetypename = (String) maininfoMap.get("operatetypename"); + String targetname = (String) maininfoMap.get("targetname"); + //长度大于1避免部分模块为1,2,3这类的操作类型 + if (StringUtils.isNumeric(operatetypename) && operatetypename.length() > 1 && operatetypename.length() < 10) { + String transfOperatetypename = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(operatetypename), operatetypename); + maininfoMap.put("operatetypename", transfOperatetypename); + } + if (StringUtils.isNumeric(targetname) && targetname.length() > 1 && targetname.length() < 10) { + String transfTargetname = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(targetname), targetname); + maininfoMap.put("targetname", transfTargetname); + } + map.put("maininfo", maininfoMap); + + map.put("detailtitle", ""); + } + + list.add(map); + //List transfLanguageData = ElogSeviceSwitchUtils.transfLanguageData(list); + return list; + + } + + /** + * 处理修改详情转多语言(主表和明细表) + * + * @param mainlist + * @param detaillist + * @param commonTableInfo + * @return + */ + private void processDetailInfo(List mainlist, List detaillist, List commonTableInfo) { + Map tablenameMap = new HashMap<>(); + Map fieldnameMap = new HashMap<>(); + Map valueMap = new HashMap<>(); + + if (commonTableInfo != null && commonTableInfo.size() > 0) { + for (Map commonTableInfoMap : commonTableInfo) { + JSONObject commonTableInfoMapJs = JSONObject.parseObject(JSONObject.toJSONString(commonTableInfoMap)); + String tablename = commonTableInfoMapJs.getString("table_name"); + String tablename_labelid = commonTableInfoMapJs.getString("tablename_labelid"); + String fieldname = commonTableInfoMapJs.getString("field_name"); + String fieldname_labelid = commonTableInfoMapJs.getString("fieldname_labelid"); + String values_kvpairs = commonTableInfoMapJs.getString("values_kvpairs"); + fieldnameMap.put(fieldname, fieldname_labelid); + if (StringUtils.isNotBlank(fieldname) && StringUtils.isNotBlank(values_kvpairs)) { + JSONObject jsonObject = JSONObject.parseObject(values_kvpairs); + valueMap.put(fieldname, jsonObject); + } + Object tablenameObj = tablenameMap.get(tablename); + if (tablenameObj == null) { + tablenameMap.put(tablename, tablename_labelid); + } + } + } + + + if (mainlist != null && mainlist.size() > 0 && fieldnameMap.size() > 0 && valueMap.size() > 0) { + for (Map mainlistMap : mainlist) { + JSONObject mainMapJs = JSONObject.parseObject(JSONObject.toJSONString(mainlistMap)); + String fielddesc = mainMapJs.getString("fielddesc"); + String oldvalue = mainMapJs.getString("oldvalue"); + String newvalue = mainMapJs.getString("newvalue"); + if (fieldnameMap.get(fielddesc) != null) { + mainlistMap.put("fielddesc", ElogSeviceSwitchUtils.transfLanguageLableid(ElogSeviceUtils.getLongValue(fieldnameMap.get(fielddesc).toString()), fieldnameMap.get(fielddesc).toString())); + } + if (valueMap.get(fielddesc) != null) { + JSONObject jsonObject = JSONObject.parseObject(valueMap.get(fielddesc).toString()); + String oldvalueStr = jsonObject.getString(oldvalue); + String newvalueStr = jsonObject.getString(newvalue); + if (StringUtils.isNotBlank(oldvalueStr)) { + mainlistMap.put("oldvalue", ElogSeviceSwitchUtils.transfLanguageLableid(ElogSeviceUtils.getLongValue(oldvalueStr), oldvalue)); + } + if (StringUtils.isNotBlank(newvalueStr)) { + mainlistMap.put("newvalue", ElogSeviceSwitchUtils.transfLanguageLableid(ElogSeviceUtils.getLongValue(newvalueStr), newvalue)); + } + } + } + } + + if (detaillist != null && detaillist.size() > 0 && fieldnameMap.size() > 0 && valueMap.size() > 0) { + for (Map detaillistMap : detaillist) { + JSONObject mainMapJs = JSONObject.parseObject(JSONObject.toJSONString(detaillistMap)); + String tablename = mainMapJs.getString("tablename"); + String fielddesc = mainMapJs.getString("fielddesc"); + String oldvalue = mainMapJs.getString("oldvalue"); + String newvalue = mainMapJs.getString("newvalue"); + if (tablenameMap.get(tablename) != null) { + detaillistMap.put("tablename", ElogSeviceSwitchUtils.transfLanguageLableid(ElogSeviceUtils.getLongValue(tablenameMap.get(tablename).toString()), tablenameMap.get(tablename).toString())); + } + if (fieldnameMap.get(fielddesc) != null) { + detaillistMap.put("fielddesc", ElogSeviceSwitchUtils.transfLanguageLableid(ElogSeviceUtils.getLongValue(fieldnameMap.get(fielddesc).toString()), fieldnameMap.get(fielddesc).toString())); + } + if (valueMap.get(fielddesc) != null) { + JSONObject jsonObject = JSONObject.parseObject(valueMap.get(fielddesc).toString()); + String oldvalueStr = jsonObject.getString(oldvalue); + String newvalueStr = jsonObject.getString(newvalue); + if (StringUtils.isNotBlank(oldvalueStr)) { + detaillistMap.put("oldvalue", ElogSeviceSwitchUtils.transfLanguageLableid(ElogSeviceUtils.getLongValue(oldvalueStr), oldvalue)); + } + if (StringUtils.isNotBlank(newvalueStr)) { + detaillistMap.put("newvalue", ElogSeviceSwitchUtils.transfLanguageLableid(ElogSeviceUtils.getLongValue(newvalueStr), newvalue)); + } + } + } + } + + } + + @Override + public List queryLogList(ELogGetLogParam param) { + LoggerContext context = new LoggerContext(); + context.setModuleName(param.getModule()); + context.setFunctionName(param.getFunction()); + int pagenum = Util.getIntValue(param.getCurrent(), 1) - 1; + int size = Util.getIntValue(param.getPageSize(), 10); + int start = pagenum * size; + int end = start + size; + Page page = new Page(pagenum, size); + String limit = " limit " + start + "," + (end - start); + + String tableName = ElogSeviceUtils.getTableName(param.getModule(), param.getFunction()); + List list = getLocalElogDaoMapper().queryElogList(page, context, null, tableName, null, "*"); + list = ElogSeviceSwitchUtils.getSwitchDatabaseData(list); + return switchString(list); + } + + @Override + public List queryCardLogList(String data) { + JSONObject map = JSONObject.parseObject(data); + String module = ""; + String function = ""; + String pageNum = ""; + String pageSize = ""; + String dataset = ""; + String searchMap = ""; + String sColum = ""; + String fColum = ""; + String transMethod = null; + List showColums = new ArrayList<>(); + List filterConditionDtos = new ArrayList<>(); + String authParams = ""; + Map jsonObject = new HashMap(); + if (map != null) { + module = map.getString("module"); + function = map.getString("function"); + pageNum = map.getString("pageNum"); + pageSize = map.getString("pageSize"); + //dataset = map.get("dataset").toString(); + searchMap = map.getString("searchMap"); + sColum = map.getString("showColums"); + showColums = JSONArray.parseArray(sColum, ShowColumsDto.class); + fColum = map.getString("filterConditions"); + transMethod = map.getString("transMethod"); + filterConditionDtos = JSONArray.parseArray(fColum, FilterConditionDto.class); + authParams = map.getString("authParams"); + jsonObject = JSONObject.parseObject(authParams); + } + LoggerContext context = new LoggerContext(); + context.setModuleName(module); + context.setFunctionName(function); + context.setTenant_key(getTenantKey().toLowerCase()); + // 分页 + //Page pages = ElogSeviceUtils.getPage(); + String sb = getQueryCondition(filterConditionDtos); + logger.info("elog查询条件拼接sql:{}", sb); + // 消费到消息,通过MethodHandler调用对应的方法 + String customSql = getCustomSql(transMethod, sb, "before"); + + Page pages = new Page(ElogSeviceUtils.getIntValue(pageNum, 1), ElogSeviceUtils.getIntValue(pageSize, 10)); + int page = Util.getIntValue(pages.getPageNum() + "", 1) - 1; + int size = Util.getIntValue(pages.getPageSize() + "", 10); + int start = page * size; + int end = start + size; + String limit = " limit " + start + "," + (end - start); + String tableName = ElogSeviceUtils.getTableName(module, function); + + //String columns = getshowColumsStr(showColums); + List list = new ArrayList<>(); + Map countMap = new HashMap<>(); + list = getLocalElogDaoMapper().queryElogList(pages, context, null, tableName, customSql, "*"); + countMap = getLocalElogDaoMapper().elogCount(context, tableName, customSql); + list = ElogSeviceSwitchUtils.getSwitchDatabaseData(list); + + if (list != null && list.size() > 0) { + //if ("1".equals(pageNum)){ + list.get(0).put("total", ElogSeviceUtils.getLongValue(countMap.get("counts") + "", 0)); + //} + } + transUserInfo(list); + //System.out.println("elog查询名称和头像耗时:{}"+ (l3-l2)); + transfLanguageData(list, showColums); + List res = switchString(list); + return res; + } + + /** + * 转换数据成多语言,结合前端转 + * + * @param lists + * @param showColums + */ + public static List transfLanguageData(List lists, List showColums) { + if (lists != null && lists.size() > 0) { + for (Map map : lists) { + if (map != null) { + Iterator> iterator = map.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + for (ShowColumsDto showColum : showColums) { + if (StringUtils.isNotBlank(showColum.getColumIndex()) && showColum.isTransfLanguage() && entry.getKey().equals(showColum.getColumIndex()) && !Objects.isNull(entry.getValue()) && StringUtils.isNumeric(entry.getValue().toString())) { + if (entry.getValue() instanceof Integer || entry.getValue() instanceof Long || entry.getValue() instanceof String) { + map.put(entry.getKey(), ElogSeviceSwitchUtils.transfLanguageLableid(ElogSeviceUtils.getLongValue(entry.getValue().toString()), entry.getValue().toString())); + } else { + //map.put(entry.getKey(), ElogSeviceSwitchUtils.handlerBaseDataMethod(entry.getValue().toString())); + map.put(entry.getKey(), entry.getValue()); + } + } else if (StringUtils.isNotBlank(showColum.getColumIndex()) && showColum.isTransfLanguage() && entry.getKey().equals(showColum.getColumIndex()) && !Objects.isNull(entry.getValue())) { + //read view add edit update delete + if ("add".equals(entry.getValue().toString()) || "创建".equals(entry.getValue().toString())) { + map.put(entry.getKey(), SalaryI18nUtil.getI18nLabel(1111111, "新增")); + } else if ("read".equals(entry.getValue().toString()) || "view".equals(entry.getValue().toString()) || "查看".equals(entry.getValue().toString())) { + map.put(entry.getKey(), SalaryI18nUtil.getI18nLabel(1111111, "查看")); + } else if ("edit".equals(entry.getValue().toString()) || "update".equals(entry.getValue().toString()) || "更新".equals(entry.getValue().toString())) { + map.put(entry.getKey(), SalaryI18nUtil.getI18nLabel(1111111, "修改")); + } else if ("delete".equals(entry.getValue().toString()) || "删除".equals(entry.getValue().toString())) { + map.put(entry.getKey(), SalaryI18nUtil.getI18nLabel(63254, "删除")); + } else if (entry.getValue().toString().contains("取消关联标签 ")) { + String val = entry.getValue().toString().replace("取消关联标签 ", SalaryI18nUtil.getI18nLabel(1111111, "取消关联标签 ") + " "); + map.put(entry.getKey(), val); + } else if (entry.getValue().toString().contains("关联标签 ")) { + String val = entry.getValue().toString().replace("关联标签 ", SalaryI18nUtil.getI18nLabel(1111111, "关联标签 ") + " "); + map.put(entry.getKey(), val); + } + } + } + } + } + } + } + return lists; + } + + + @Override + public Map countLog(String module, String function) { + LoggerContext context = new LoggerContext(); + context.setModuleName(module); + context.setFunctionName(function); + context.setTenant_key(getTenantKey()); + String tableName = ElogSeviceUtils.getTableName(module, function); + return getLocalElogDaoMapper().elogCount(context, tableName, null); + } + + @Override + public List queryDetailLogList(String module, String function, String current, String pageSize, String condition, String mainId) { + LoggerContext context = new LoggerContext(); + context.setModuleName(module); + context.setFunctionName(function); + context.setTenant_key(getTenantKey()); + context.setUuid(mainId); + int page = Util.getIntValue(current, 1) - 1; + int size = Util.getIntValue(pageSize, 10); + int start = page * size; + int end = start + size; + String limit = " limit " + start + "," + (end - start); + // 还需要支持下查询 + String tableName = ElogSeviceUtils.getTableName(module, function, true); + List list = getLocalElogDaoMapper().queryDetailElogList(context, limit, tableName, null); + list = ElogSeviceSwitchUtils.getSwitchDatabaseData(list); + return switchString(list); + } + + @Override + public Map countDestailLog(String module, String function, String mainId) { + LoggerContext context = new LoggerContext(); + context.setModuleName(module); + context.setFunctionName(function); + context.setTenant_key(getTenantKey()); + context.setUuid(mainId); + String tableName = ElogSeviceUtils.getTableName(module, function, true); + return getLocalElogDaoMapper().elogDetailCount(context, tableName, null); + } + + @Override + public WeaTable queryElogTraceInfo(String traceId, String module, String function, Integer currentPage, Integer pageSize, String traceTransMethod) { + WeaTable weaTable = new WeaTable(); + if (StringUtils.isNotEmpty(traceId)) { + String tableName = ElogSeviceUtils.getTableName(module, function); + Integer offset = (currentPage - 1) * pageSize; + List list = getLocalElogDaoMapper().queryElogTraceInfo(traceId, tableName, offset, pageSize); + for (Map map : list) { + if (map.get("modulename") != null) { + map.put("modulenamespan", ElogSeviceSwitchUtils.getModuleName(map.get("modulename").toString())); + } + } + //list = ElogSeviceSwitchUtils.getSwitchDatabaseData(list); + int count = getLocalElogDaoMapper().queryElogTraceInfoCount(traceId, tableName); + PageInfo pageInfo = SalaryPageUtil.buildPage(currentPage, pageSize, list); +// pageInfo.setColumns(); + pageInfo.setTotal(count); + } + + return weaTable; + } + + @Override + public List queryLogInfoByCustom(String module, String function, String field, String value, boolean isDetail) { + List list = new ArrayList(); + String tableName = ElogSeviceUtils.getTableName(module, function, isDetail); + if (StringUtils.isNotBlank(field) && StringUtils.isNotBlank(value)) { + StringBuffer sql = new StringBuffer(); + sql.append(field).append(" = '").append(value).append("' "); + + list = getLocalElogDaoMapper().queryLogInfoByCustom(tableName, sql.toString()); + } + return list; + } + + + @Override + public List queryLogInfoByCustom(String module, String function, String field, String value) { + return queryLogInfoByCustom(module, function, field, value, false); + } + + public List switchString(List list) { + if (list != null) { + return list.stream().map(m -> { + Set en = m.entrySet(); + for (Map.Entry entry : en) { + if (entry.getValue() != null) { + entry.setValue(String.valueOf(entry.getValue())); + } + } + return m; + }).collect(Collectors.toList()); + } else { + return list; + } + } + +// @Override +// public BatchDocumentMessage downloadLog(String data) { +// JSONObject jsonObject = JSONObject.parseObject(data); +// String module = jsonObject.getString("downloadmodule"); +// String function = jsonObject.getString("function"); +// String serviceName = jsonObject.getString("serviceName"); +// String fileName = jsonObject.getString("fileName"); +// String passWord = jsonObject.getString("passWord"); +// +// if (StringUtils.isEmpty(fileName)) { +// fileName = SalaryI18nUtil.getI18nLabel(191432, "日志记录"); +// } +// +// BatchDocumentMessage batchDocumentMessage = new BatchDocumentMessage(); +// WeaTable weaTable = queryLogs(data); +// List columns = weaTable.getColumns(); +// List headers = new ArrayList<>(); +// if (columns != null && !columns.isEmpty()) { +// for (WeaTableColumn column : columns) { +// Map header = new HashMap<>(); +// header.put("key", column.getDataIndex()); +// header.put("name", column.getTitle()); +// headers.add(header); +// } +// } +// List> dataList = weaTable.getData(); +// List> maps = new ArrayList<>(); +// if (dataList != null && !dataList.isEmpty()) { +// dataList.stream().forEach(m -> { +// Map map = new HashMap<>(); +// headers.stream().forEach(h -> { +// map.put(h.get("key").toString(), m.get(h.get("key"))); +// }); +// maps.add(map); +// }); +// } +// +// //必传--业务id +// batchDocumentMessage.setBizId(IdGenerator.generate() + ""); +// //必传-处理名称 +// batchDocumentMessage.setHandlerName("ebatchdemo"); +// //必传-服务名称 +// batchDocumentMessage.setServiceName(serviceName); +// //必传-数据类型 +// batchDocumentMessage.setDataType(fileName); +// //任务id +// batchDocumentMessage.setBatchTaskId(IdGenerator.generate()); +// //必传-模块 +// batchDocumentMessage.setModule(module); //com.weaver.teams.domain.EntityType 中的module(没有的话需要找温明刚维护下) +// //必传-功能 +// batchDocumentMessage.setFunction(function); +// //必传-eteamsid +// batchDocumentMessage.setEteamsId(TenantRpcContext.getEteamsId()); +// +// //非必传 +// if (StringUtils.isNotBlank(passWord)) { +// batchDocumentMessage.setPassword(passWord); +// } +// +// //必传 +// BatchFile batchFile = new BatchFile(); +// batchFile.setName(fileName); +// //必传 +// batchFile.setFileType(FileType.EXCEL); +// //必传 +// batchFile.setHandlerFileMethod(HandlerFileMethod.HANDLER_EXCEL_WITH_DATA); +// batchFile.setTemplateId(1l); +// List excelSheets = new ArrayList<>(); +// ExcelSheet excelSheet = new ExcelSheet(); +// +// excelSheet.setHeader(headers); +// excelSheet.setData(maps); +// excelSheet.setName(fileName); +// excelSheets.add(excelSheet); +// batchFile.setExcelSheets(excelSheets); +// batchDocumentMessage.setBatchFile(batchFile); +// batchDocumentMessage.setChunk(false);//不分片 +// batchExportSender.sendBatchExport(batchDocumentMessage); +// +// return batchDocumentMessage; +// } +// + + private String[] getESfields(String value) { + String[] split = value.split(","); + List list = new ArrayList<>(); + for (String s : split) { + switch (s.toLowerCase()) { + case "interfacename": + list.add("interfacename"); + break; + case "operatetype": + list.add("operatetype"); + break; + case "operatedesc": + list.add("operatedesc"); + break; + case "params": + list.add("params"); + break; + case "clientip": + list.add("clientip"); + break; + case "groupnamelabel": + list.add("groupnamelabel"); + break; + case "redoservice": + list.add("redoservice"); + break; + case "redocontext": + list.add("redocontext"); + break; + case "cancelservice": + list.add("cancelservice"); + break; + case "cancelcontext": + list.add("cancelcontext"); + break; + case "device": + list.add("device"); + break; + case "groupid": + list.add("groupid"); + break; + case "belongmainid": + list.add("belongmainid"); + break; + case "requesturl": + list.add("requesturl"); + break; + case "requesturi": + list.add("requesturi"); + break; + case "log_result": + list.add("logResult"); + break; + case "fromterminal": + list.add("fromterminal"); + break; + case "resultdesc": + list.add("resultdesc"); + break; + case "old_content": + list.add("oldContent"); + break; + case "link_type": + list.add("linkType"); + break; + } + } + //list转为数组 + if (list.size() > 0) { + String[] strings = list.toArray(new String[list.size()]); + return strings; + } + return null; + } + +} diff --git a/src/com/engine/salary/elog/threadlocal/ElogThreadLocal.java b/src/com/engine/salary/elog/threadlocal/ElogThreadLocal.java new file mode 100644 index 0000000..63e1889 --- /dev/null +++ b/src/com/engine/salary/elog/threadlocal/ElogThreadLocal.java @@ -0,0 +1,75 @@ +package com.engine.salary.elog.threadlocal; + +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.elog.entity.dto.LoggerContext; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Date: 2022/5/18 20:26 + * @Author: deli.xu + * @Description: + **/ +public class ElogThreadLocal { + + private static final ThreadLocal> loggerContextList = new ThreadLocal<>(); + private static final ThreadLocal requestBody = new ThreadLocal<>(); + + public static LoggerContext currentLoggerContext() { + List list = loggerContextList.get(); + + if(list == null || list.size() == 0) { + return null; + } else { + return list.get(list.size() -1); + } + } + + public static void addLoggerContext(LoggerContext loggerContext) { + if(loggerContext == null) + return; + List list = loggerContextList.get(); + if(list == null) { + list = new ArrayList<>(); + loggerContextList.set(list); + } + + list.add(loggerContext); + + } + + public static List getLoggerContextList() { + return loggerContextList.get(); + } + + public static void clear() { + loggerContextList.set(null); + } + + public static void removeLast() { + List list = loggerContextList.get(); + + if(list != null) { + int size = list.size(); + if(size > 0) + list.remove(size - 1); + } + } + + public static void remove() { + loggerContextList.remove(); + } + + public static JSONObject getRequestBody() { + return requestBody.get(); + } + + public static void setRequestBody(JSONObject json) { + requestBody.set(json); + } + + public static void removeRequestBody() { + requestBody.remove(); + } +} diff --git a/src/com/engine/salary/elog/util/ElogServiceUtils.java b/src/com/engine/salary/elog/util/ElogServiceUtils.java new file mode 100644 index 0000000..fb2ecaf --- /dev/null +++ b/src/com/engine/salary/elog/util/ElogServiceUtils.java @@ -0,0 +1,92 @@ +package com.engine.salary.elog.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.elog.entity.dto.ElogBean; +import com.engine.salary.elog.entity.dto.FilterConditionDto; +import com.engine.salary.elog.entity.dto.ShowColumsDto; +import com.engine.salary.elog.enums.ElogConsts; + +import java.util.List; +import java.util.Map; + +/** + * @Date: 2022/5/18 19:19 + * @Author: deli.xu + * @Description: elog服务工具类 + **/ +public class ElogServiceUtils { + + public static String getTableName(String module, String function) { + return getTableName(module, function, false); + } + + public static String getTableName(String module, String function, boolean isDetail) { + String tablename = module + ElogConsts.TABLE_SPACER + function + ElogConsts.TABLE_SUFFIX + (isDetail ? ElogConsts.DETAIL_TABLE_SUFFIX : ""); + sqlCheck(tablename); + return tablename; + } + + public static void sqlCheck(String value) { + if (value != null) { + if (!value.matches("^[A-Za-z][a-zA-Z0-9_\\.,]{0,31}$")) { + throw new RuntimeException("sqlCheck failed ! value :" + value); + } + } + } + + public static ElogBean getElogBean(String data) { + JSONObject datas = JSONObject.parseObject(data); + ElogBean elogBean = new ElogBean(); + String module = datas.getString("module"); + String function = datas.getString("function"); + String pageNum = datas.getString("current"); + String pageSize = datas.getString("pageSize"); + String searchMap = datas.getString("searchMap"); + String transMethod = datas.getString("transMethod"); + String authParams = datas.getString("authParams"); + String showColums = datas.getString("showColums"); + String filterConditions = datas.getString("filterConditions"); + String downloadSize = datas.getString("downloadSize"); + List showColumsDtos = JSONArray.parseArray(showColums, ShowColumsDto.class); + List filterConditionDtos = JSONArray.parseArray(filterConditions, FilterConditionDto.class); + Map authParamsJson = JSONObject.parseObject(authParams); + elogBean.setModule(module); + elogBean.setFunction(function); + elogBean.setCurrent(pageNum); + elogBean.setPageSize(pageSize); + elogBean.setSearchMap(searchMap); + elogBean.setTransMethod(transMethod); + elogBean.setDownloadSize(downloadSize); + elogBean.setShowColumns(showColumsDtos); + elogBean.setFilterConditionDtos(filterConditionDtos); + elogBean.setAuthParamsJson(authParamsJson); + return elogBean; + } + + public static int getIntValue(String v) { + return getIntValue(v, -1); + } + + public static int getIntValue(String v, int def) { + try { + return Integer.parseInt(v); + } catch (Exception var3) { + return def; + } + } + + public static long getLongValue(String v) { + return getLongValue(v, -1l); + } + + public static long getLongValue(String v, long def) { + try { + return Long.parseLong(v); + } catch (Exception var3) { + return def; + } + } + + +} diff --git a/src/com/engine/salary/elog/util/ElogSeviceSwitchUtils.java b/src/com/engine/salary/elog/util/ElogSeviceSwitchUtils.java new file mode 100644 index 0000000..f874205 --- /dev/null +++ b/src/com/engine/salary/elog/util/ElogSeviceSwitchUtils.java @@ -0,0 +1,1402 @@ +package com.engine.salary.elog.util; + +import cn.hutool.core.map.CaseInsensitiveMap; +import com.alibaba.druid.proxy.jdbc.ClobProxyImpl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.elog.annotation.OperateType; +import com.engine.salary.elog.enums.ElogConsts; +import com.engine.salary.elog.util.SalaryI18nUtil; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.conn.RecordSet; + +import java.sql.Clob; +import java.util.*; + +/** + * @Date: 2022/5/18 19:34 + * @Author: deli.xu + * @Description: elog服务转换类 + **/ +public class ElogSeviceSwitchUtils { + + private static final Logger logger = LoggerFactory.getLogger(ElogSeviceSwitchUtils.class); + // TODO 后续需要考虑多语言label写法 + public static final Map moduleMap = new HashMap<>(); + + private static final Map> moduleFuctionMap = new HashMap<>(); + + static { + /*moduleMap.put("elog", SalaryI18nUtil.getI18nLabel(62975, ElogSeviceUtils.currentLanguage(), "日志")); + moduleMap.put("report", SalaryI18nUtil.getI18nLabel(62976, ElogSeviceUtils.currentLanguage(), "报表")); + moduleMap.put("edc", SalaryI18nUtil.getI18nLabel(62977, ElogSeviceUtils.currentLanguage(), "数据中心")); + moduleMap.put("hrm", SalaryI18nUtil.getI18nLabel(62978, ElogSeviceUtils.currentLanguage(), "人力资源")); + moduleMap.put("crm", SalaryI18nUtil.getI18nLabel(62979, ElogSeviceUtils.currentLanguage(), "资产")); + moduleMap.put("demo", SalaryI18nUtil.getI18nLabel(62980, ElogSeviceUtils.currentLanguage(), "示例")); + moduleMap.put("attc", SalaryI18nUtil.getI18nLabel(62981, ElogSeviceUtils.currentLanguage(), "出勤打卡")); + moduleMap.put("attm", SalaryI18nUtil.getI18nLabel(62982, ElogSeviceUtils.currentLanguage(), "出勤机")); + moduleMap.put("attw", SalaryI18nUtil.getI18nLabel(62983, ElogSeviceUtils.currentLanguage(), "出勤报表")); + moduleMap.put("auth", SalaryI18nUtil.getI18nLabel(62984, ElogSeviceUtils.currentLanguage(), "系统权限")); + moduleMap.put("bank", SalaryI18nUtil.getI18nLabel(62985, ElogSeviceUtils.currentLanguage(), "银企直联")); + moduleMap.put("bap", SalaryI18nUtil.getI18nLabel(62986, ElogSeviceUtils.currentLanguage(), "云办公")); + moduleMap.put("base", SalaryI18nUtil.getI18nLabel(62987, ElogSeviceUtils.currentLanguage(), "应用管理")); + moduleMap.put("batc", SalaryI18nUtil.getI18nLabel(62988, ElogSeviceUtils.currentLanguage(), "导入导出")); + moduleMap.put("blog", SalaryI18nUtil.getI18nLabel(62989, ElogSeviceUtils.currentLanguage(), "日报微博")); + moduleMap.put("cld", SalaryI18nUtil.getI18nLabel(62990, ElogSeviceUtils.currentLanguage(), "日程管理")); + moduleMap.put("cmca", SalaryI18nUtil.getI18nLabel(62991, ElogSeviceUtils.currentLanguage(), "资金管理")); + moduleMap.put("cmcl", SalaryI18nUtil.getI18nLabel(62992, ElogSeviceUtils.currentLanguage(), "线索管理")); + moduleMap.put("cmco", SalaryI18nUtil.getI18nLabel(62993, ElogSeviceUtils.currentLanguage(), "联系人管理")); + moduleMap.put("cmcp", SalaryI18nUtil.getI18nLabel(62994, ElogSeviceUtils.currentLanguage(), "对手管理")); + moduleMap.put("cmcu", SalaryI18nUtil.getI18nLabel(62995, ElogSeviceUtils.currentLanguage(), "客户管理")); + moduleMap.put("cmex", SalaryI18nUtil.getI18nLabel(62996, ElogSeviceUtils.currentLanguage(), "批量操作")); + moduleMap.put("cmmk", SalaryI18nUtil.getI18nLabel(62997, ElogSeviceUtils.currentLanguage(), "营销管理")); + moduleMap.put("cmor", SalaryI18nUtil.getI18nLabel(62998, ElogSeviceUtils.currentLanguage(), "订单管理")); + moduleMap.put("cmpc", SalaryI18nUtil.getI18nLabel(62999, ElogSeviceUtils.currentLanguage(), "价格管理")); + moduleMap.put("cmpr", SalaryI18nUtil.getI18nLabel(63000, ElogSeviceUtils.currentLanguage(), "产品管理")); + moduleMap.put("cmpt", SalaryI18nUtil.getI18nLabel(63001, ElogSeviceUtils.currentLanguage(), "外部门户")); + moduleMap.put("cmqu", SalaryI18nUtil.getI18nLabel(63002, ElogSeviceUtils.currentLanguage(), "报价管理")); + moduleMap.put("cmsa", SalaryI18nUtil.getI18nLabel(63003, ElogSeviceUtils.currentLanguage(), "商机管理")); + moduleMap.put("cmtr", SalaryI18nUtil.getI18nLabel(63004, ElogSeviceUtils.currentLanguage(), "合同管理")); + moduleMap.put("comp", SalaryI18nUtil.getI18nLabel(63005, ElogSeviceUtils.currentLanguage(), "文档对比")); + moduleMap.put("cs", SalaryI18nUtil.getI18nLabel(63006, ElogSeviceUtils.currentLanguage(), "云商店")); + moduleMap.put("cowork", SalaryI18nUtil.getI18nLabel(63007, ElogSeviceUtils.currentLanguage(), "协作区")); + moduleMap.put("dbs", SalaryI18nUtil.getI18nLabel(63008, ElogSeviceUtils.currentLanguage(), "文档公共模块")); + moduleMap.put("dcad", SalaryI18nUtil.getI18nLabel(63009, ElogSeviceUtils.currentLanguage(), "数据中心运行")); + moduleMap.put("dcap", SalaryI18nUtil.getI18nLabel(63010, ElogSeviceUtils.currentLanguage(), "数据中心分析开发配置")); + moduleMap.put("dcrd", SalaryI18nUtil.getI18nLabel(63011, ElogSeviceUtils.currentLanguage(), "数据中心开发配置")); + moduleMap.put("dcre", SalaryI18nUtil.getI18nLabel(63012, ElogSeviceUtils.currentLanguage(), "数据中心分析生产运行")); + moduleMap.put("dcs", SalaryI18nUtil.getI18nLabel(63013, ElogSeviceUtils.currentLanguage(), "文档目录模块")); + moduleMap.put("dds", SalaryI18nUtil.getI18nLabel(63014, ElogSeviceUtils.currentLanguage(), "文档模块")); + moduleMap.put("dps", SalaryI18nUtil.getI18nLabel(63015, ElogSeviceUtils.currentLanguage(), "文档权限模块")); + moduleMap.put("drle", SalaryI18nUtil.getI18nLabel(63016, ElogSeviceUtils.currentLanguage(), "数据规则库")); + moduleMap.put("ds", SalaryI18nUtil.getI18nLabel(63017, ElogSeviceUtils.currentLanguage(), "数据安全")); + moduleMap.put("dw_etl", SalaryI18nUtil.getI18nLabel(63018, ElogSeviceUtils.currentLanguage(), "ETL(抽取,转换,治理)")); + moduleMap.put("dw_model", SalaryI18nUtil.getI18nLabel(63019, ElogSeviceUtils.currentLanguage(), "建模服务")); + moduleMap.put("dw_process", SalaryI18nUtil.getI18nLabel(63020, ElogSeviceUtils.currentLanguage(), "计算服务")); + moduleMap.put("dw_search", SalaryI18nUtil.getI18nLabel(63021, ElogSeviceUtils.currentLanguage(), "查询服务")); + moduleMap.put("dw_sync", SalaryI18nUtil.getI18nLabel(63022, ElogSeviceUtils.currentLanguage(), "数据抽取")); + moduleMap.put("eb", SalaryI18nUtil.getI18nLabel(63023, ElogSeviceUtils.currentLanguage(), "云桥")); + moduleMap.put("ebda", SalaryI18nUtil.getI18nLabel(62987, ElogSeviceUtils.currentLanguage(), "应用管理")); + moduleMap.put("ebdd", SalaryI18nUtil.getI18nLabel(63024, ElogSeviceUtils.currentLanguage(), "页面设计")); + moduleMap.put("ebdf", SalaryI18nUtil.getI18nLabel(63025, ElogSeviceUtils.currentLanguage(), "表单服务")); + moduleMap.put("ebdp", SalaryI18nUtil.getI18nLabel(63026, ElogSeviceUtils.currentLanguage(), "页面管理")); + moduleMap.put("ecod", SalaryI18nUtil.getI18nLabel(63027, ElogSeviceUtils.currentLanguage(), "ecode")); + moduleMap.put("ei", SalaryI18nUtil.getI18nLabel(63028, ElogSeviceUtils.currentLanguage(), "数据导出导入")); + moduleMap.put("em", SalaryI18nUtil.getI18nLabel(63029, ElogSeviceUtils.currentLanguage(), "移动相关")); + moduleMap.put("es", SalaryI18nUtil.getI18nLabel(63030, ElogSeviceUtils.currentLanguage(), "微搜搜索")); + moduleMap.put("esa", SalaryI18nUtil.getI18nLabel(63031, ElogSeviceUtils.currentLanguage(), "微搜文件分析")); + moduleMap.put("esb", SalaryI18nUtil.getI18nLabel(63032, ElogSeviceUtils.currentLanguage(), "ESB")); + moduleMap.put("esch", SalaryI18nUtil.getI18nLabel(63033, ElogSeviceUtils.currentLanguage(), "计划任务")); + moduleMap.put("esd", SalaryI18nUtil.getI18nLabel(63034, ElogSeviceUtils.currentLanguage(), "微搜索引数据")); + moduleMap.put("exfo", SalaryI18nUtil.getI18nLabel(63035, ElogSeviceUtils.currentLanguage(), "excel函数引擎")); + moduleMap.put("fbdg", SalaryI18nUtil.getI18nLabel(63036, ElogSeviceUtils.currentLanguage(), "预算编制")); + moduleMap.put("fdt", SalaryI18nUtil.getI18nLabel(63037, ElogSeviceUtils.currentLanguage(), "表单数据")); + moduleMap.put("fexs", SalaryI18nUtil.getI18nLabel(63038, ElogSeviceUtils.currentLanguage(), "费用管理")); + moduleMap.put("file", SalaryI18nUtil.getI18nLabel(63039, ElogSeviceUtils.currentLanguage(), "文件服务")); + moduleMap.put("finc", SalaryI18nUtil.getI18nLabel(63040, ElogSeviceUtils.currentLanguage(), "微报账")); + moduleMap.put("fnar", SalaryI18nUtil.getI18nLabel(63041, ElogSeviceUtils.currentLanguage(), "财务报表")); + moduleMap.put("fomo", SalaryI18nUtil.getI18nLabel(63042, ElogSeviceUtils.currentLanguage(), "表单监控")); + moduleMap.put("form", SalaryI18nUtil.getI18nLabel(63043, ElogSeviceUtils.currentLanguage(), "表单服务")); + moduleMap.put("frpt", SalaryI18nUtil.getI18nLabel(63043, ElogSeviceUtils.currentLanguage(), "业务表单")); + moduleMap.put("fvou", SalaryI18nUtil.getI18nLabel(63044, ElogSeviceUtils.currentLanguage(), "凭证集成")); + moduleMap.put("hp", SalaryI18nUtil.getI18nLabel(63045, ElogSeviceUtils.currentLanguage(), "门户")); + moduleMap.put("hr", SalaryI18nUtil.getI18nLabel(63046, ElogSeviceUtils.currentLanguage(), "人事档案")); + moduleMap.put("ic", SalaryI18nUtil.getI18nLabel(63047, ElogSeviceUtils.currentLanguage(), "集成服务")); + moduleMap.put("il", SalaryI18nUtil.getI18nLabel(63048, ElogSeviceUtils.currentLanguage(), "集成登录")); + moduleMap.put("im", SalaryI18nUtil.getI18nLabel(63049, ElogSeviceUtils.currentLanguage(), "IM相关服务")); + moduleMap.put("inc", SalaryI18nUtil.getI18nLabel(63050, ElogSeviceUtils.currentLanguage(), "发票云服务")); + moduleMap.put("iua", SalaryI18nUtil.getI18nLabel(63051, ElogSeviceUtils.currentLanguage(), "统一认证")); + moduleMap.put("iut", SalaryI18nUtil.getI18nLabel(63052, ElogSeviceUtils.currentLanguage(), "统一待办")); + moduleMap.put("mail", SalaryI18nUtil.getI18nLabel(63053, ElogSeviceUtils.currentLanguage(), "邮件服务")); + moduleMap.put("mc", SalaryI18nUtil.getI18nLabel(63054, ElogSeviceUtils.currentLanguage(), "消息服务")); + moduleMap.put("mt", SalaryI18nUtil.getI18nLabel(63055, ElogSeviceUtils.currentLanguage(), "会议管理")); + moduleMap.put("my", SalaryI18nUtil.getI18nLabel(63056, ElogSeviceUtils.currentLanguage(), "关注&收藏&标签")); + moduleMap.put("odoc", SalaryI18nUtil.getI18nLabel(63057, ElogSeviceUtils.currentLanguage(), "公文管理")); + moduleMap.put("odoc_exchange", SalaryI18nUtil.getI18nLabel(63058, ElogSeviceUtils.currentLanguage(), "公文交换平台")); + moduleMap.put("open", SalaryI18nUtil.getI18nLabel(63059, ElogSeviceUtils.currentLanguage(), "开放平台")); + moduleMap.put("pr", SalaryI18nUtil.getI18nLabel(63060, ElogSeviceUtils.currentLanguage(), "工作画像")); + moduleMap.put("proj", SalaryI18nUtil.getI18nLabel(63061, ElogSeviceUtils.currentLanguage(), "项目管理")); + moduleMap.put("prt", SalaryI18nUtil.getI18nLabel(63062, ElogSeviceUtils.currentLanguage(), "打印服务")); + moduleMap.put("pspt", SalaryI18nUtil.getI18nLabel(63063, ElogSeviceUtils.currentLanguage(), "系统登录")); + moduleMap.put("rptc", SalaryI18nUtil.getI18nLabel(63064, ElogSeviceUtils.currentLanguage(), "数据协作")); + moduleMap.put("rpts", SalaryI18nUtil.getI18nLabel(63065, ElogSeviceUtils.currentLanguage(), "上报调查")); + moduleMap.put("sala", SalaryI18nUtil.getI18nLabel(63066, ElogSeviceUtils.currentLanguage(), "薪资管理")); + moduleMap.put("sign", SalaryI18nUtil.getI18nLabel(63067, ElogSeviceUtils.currentLanguage(), "印控中心")); + moduleMap.put("sms", SalaryI18nUtil.getI18nLabel(63068, ElogSeviceUtils.currentLanguage(), "短信")); + moduleMap.put("task", SalaryI18nUtil.getI18nLabel(63069, ElogSeviceUtils.currentLanguage(), "任务管理")); + moduleMap.put("tnt", SalaryI18nUtil.getI18nLabel(63070, ElogSeviceUtils.currentLanguage(), "租户管理")); + moduleMap.put("wf", SalaryI18nUtil.getI18nLabel(63071, ElogSeviceUtils.currentLanguage(), "路径定义")); + moduleMap.put("wfc", SalaryI18nUtil.getI18nLabel(63072, ElogSeviceUtils.currentLanguage(), "流程流转")); + moduleMap.put("wfr", SalaryI18nUtil.getI18nLabel(63073, ElogSeviceUtils.currentLanguage(), "流程规则路由")); + moduleMap.put("wrgm", SalaryI18nUtil.getI18nLabel(63074, ElogSeviceUtils.currentLanguage(), "目标管理")); + moduleMap.put("wrgp", SalaryI18nUtil.getI18nLabel(63075, ElogSeviceUtils.currentLanguage(), "绩效考核")); + moduleMap.put("wrpr", SalaryI18nUtil.getI18nLabel(63076, ElogSeviceUtils.currentLanguage(), "计划报告")); + moduleMap.put("doc", SalaryI18nUtil.getI18nLabel(63077, ElogSeviceUtils.currentLanguage(), "文档服务")); + moduleMap.put("placard", SalaryI18nUtil.getI18nLabel(63078, ElogSeviceUtils.currentLanguage(), "团队公告")); + moduleMap.put("fna", SalaryI18nUtil.getI18nLabel(135042, ElogSeviceUtils.currentLanguage(), "云报销")); + moduleMap.put("meeting", SalaryI18nUtil.getI18nLabel(63080, ElogSeviceUtils.currentLanguage(), "会议")); + moduleMap.put("wfp", SalaryI18nUtil.getI18nLabel(63081, ElogSeviceUtils.currentLanguage(), "流程")); + moduleMap.put("portal", SalaryI18nUtil.getI18nLabel(63045, ElogSeviceUtils.currentLanguage(), "门户")); + moduleMap.put("workreport", SalaryI18nUtil.getI18nLabel(63082, ElogSeviceUtils.currentLanguage(), "工作报告")); + moduleMap.put("goal", SalaryI18nUtil.getI18nLabel(63074, ElogSeviceUtils.currentLanguage(), "目标管理")); + moduleMap.put("performance", SalaryI18nUtil.getI18nLabel(63075, ElogSeviceUtils.currentLanguage(), "绩效考核")); + moduleMap.put("intlogin", SalaryI18nUtil.getI18nLabel(63083, ElogSeviceUtils.currentLanguage(), "集成登录设置")); + moduleMap.put("i18n", SalaryI18nUtil.getI18nLabel(64559, ElogSeviceUtils.currentLanguage(), "国际化")); + moduleMap.put("timecard", SalaryI18nUtil.getI18nLabel(63085, ElogSeviceUtils.currentLanguage(), "出勤")); + moduleMap.put("market", SalaryI18nUtil.getI18nLabel(63086, ElogSeviceUtils.currentLanguage(), "营销")); + moduleMap.put("excelformula", SalaryI18nUtil.getI18nLabel(64560, ElogSeviceUtils.currentLanguage(), "函数服务")); + moduleMap.put("ic_ldap", SalaryI18nUtil.getI18nLabel(70081, ElogSeviceUtils.currentLanguage(), "Ldap集成")); + moduleMap.put("iut_c_c", SalaryI18nUtil.getI18nLabel(70303, ElogSeviceUtils.currentLanguage(), "统一待办推送设置")); + moduleMap.put("plan", SalaryI18nUtil.getI18nLabel(70303, ElogSeviceUtils.currentLanguage(), "计划报告")); + moduleMap.put("document", SalaryI18nUtil.getI18nLabel(34218, ElogSeviceUtils.currentLanguage(), "文档")); + moduleMap.put("taskCustStatus", SalaryI18nUtil.getI18nLabel(73988, ElogSeviceUtils.currentLanguage(), "任务状态")); + moduleMap.put("project", SalaryI18nUtil.getI18nLabel(55158, ElogSeviceUtils.currentLanguage(), "项目")); + moduleMap.put("calendar", SalaryI18nUtil.getI18nLabel(74186, ElogSeviceUtils.currentLanguage(), "日历")); + moduleMap.put("web", SalaryI18nUtil.getI18nLabel(75598, ElogSeviceUtils.currentLanguage(), "浏览")); + moduleMap.put("formdatareport", SalaryI18nUtil.getI18nLabel(76068, ElogSeviceUtils.currentLanguage(), "来自上报数据")); + moduleMap.put("mainline", SalaryI18nUtil.getI18nLabel(31898, ElogSeviceUtils.currentLanguage(), "主线")); + moduleMap.put("customer", SalaryI18nUtil.getI18nLabel(32726, ElogSeviceUtils.currentLanguage(), "客户")); + moduleMap.put("contract", SalaryI18nUtil.getI18nLabel(32864, ElogSeviceUtils.currentLanguage(), "合同")); + moduleMap.put("group", SalaryI18nUtil.getI18nLabel(19426, ElogSeviceUtils.currentLanguage(), "分组")); + moduleMap.put("workflow", SalaryI18nUtil.getI18nLabel(81851, ElogSeviceUtils.currentLanguage(), "工作流程")); + moduleMap.put("biaoge", SalaryI18nUtil.getI18nLabel(30919, ElogSeviceUtils.currentLanguage(), "表格")); + moduleMap.put("clue", SalaryI18nUtil.getI18nLabel(28908, ElogSeviceUtils.currentLanguage(), "线索")); + moduleMap.put("competitor", SalaryI18nUtil.getI18nLabel(81852, ElogSeviceUtils.currentLanguage(), "竞争对手")); + moduleMap.put("kpiFlow", SalaryI18nUtil.getI18nLabel(81853, ElogSeviceUtils.currentLanguage(), "kpil流程")); + moduleMap.put("mainlineCustStatus", SalaryI18nUtil.getI18nLabel(81854, ElogSeviceUtils.currentLanguage(), "主线客户状态")); + moduleMap.put("marketactivity", SalaryI18nUtil.getI18nLabel(34221, ElogSeviceUtils.currentLanguage(), "市场活动")); + moduleMap.put("mtPhase", SalaryI18nUtil.getI18nLabel(81855, ElogSeviceUtils.currentLanguage(), "mt阶段")); + moduleMap.put("production", SalaryI18nUtil.getI18nLabel(29329, ElogSeviceUtils.currentLanguage(), "产品")); + moduleMap.put("quote", SalaryI18nUtil.getI18nLabel(34231, ElogSeviceUtils.currentLanguage(), "报价")); + moduleMap.put("saleChance", SalaryI18nUtil.getI18nLabel(32863, ElogSeviceUtils.currentLanguage(), "商机")); + moduleMap.put("orderform", SalaryI18nUtil.getI18nLabel(34230, ElogSeviceUtils.currentLanguage(), "订单")); + moduleMap.put("contact", SalaryI18nUtil.getI18nLabel(32711, ElogSeviceUtils.currentLanguage(), "联系人")); + moduleMap.put("price", SalaryI18nUtil.getI18nLabel(31922, ElogSeviceUtils.currentLanguage(), "价格")); + moduleMap.put("capital", SalaryI18nUtil.getI18nLabel(83428, ElogSeviceUtils.currentLanguage(), "资金")); + moduleMap.put("ice", SalaryI18nUtil.getI18nLabel(94360, ElogSeviceUtils.currentLanguage(), "日程会议集成")); + moduleMap.put("ic_hr", SalaryI18nUtil.getI18nLabel(84284, ElogSeviceUtils.currentLanguage(), "HR同步")); + moduleMap.put("intunifyauth", SalaryI18nUtil.getI18nLabel(84467, ElogSeviceUtils.currentLanguage(), "统一认证接入管理")); + moduleMap.put("signcenter", SalaryI18nUtil.getI18nLabel(84691, ElogSeviceUtils.currentLanguage(), "电子签")); + moduleMap.put("iut_s_c", SalaryI18nUtil.getI18nLabel(91503, ElogSeviceUtils.currentLanguage(), "统一待办-异构系统")); + moduleMap.put("iut_s_c1", SalaryI18nUtil.getI18nLabel(91503, ElogSeviceUtils.currentLanguage(), "统一待办-应用系统")); + moduleMap.put("iut_s_c2", SalaryI18nUtil.getI18nLabel(91503, ElogSeviceUtils.currentLanguage(), "统一待办中心")); + moduleMap.put("iut_s_c3", SalaryI18nUtil.getI18nLabel(91503, ElogSeviceUtils.currentLanguage(), "统一待办-应用系统-流程类型")); + moduleMap.put("ic_mail", SalaryI18nUtil.getI18nLabel(100715, ElogSeviceUtils.currentLanguage(), "邮箱集成")); + moduleMap.put("hrsa", SalaryI18nUtil.getI18nLabel(105038, ElogSeviceUtils.currentLanguage(), "薪酬管理")); + moduleMap.put("icc", SalaryI18nUtil.getI18nLabel(113884, ElogSeviceUtils.currentLanguage(), "转换规则")); + moduleMap.put("basicserver", SalaryI18nUtil.getI18nLabel(113885, ElogSeviceUtils.currentLanguage(), "整体基础")); + moduleMap.put("dw", SalaryI18nUtil.getI18nLabel(115549, ElogSeviceUtils.currentLanguage(), "数据仓库")); + moduleMap.put("msg", SalaryI18nUtil.getI18nLabel(115563, ElogSeviceUtils.currentLanguage(), "工作消息")); + moduleMap.put("intunifybase", SalaryI18nUtil.getI18nLabel(115599, ElogSeviceUtils.currentLanguage(), "统一认证服务")); + moduleMap.put("esearch", SalaryI18nUtil.getI18nLabel(21694, ElogSeviceUtils.currentLanguage(), "全文检索")); + moduleMap.put("iaauthserver", SalaryI18nUtil.getI18nLabel(115603, ElogSeviceUtils.currentLanguage(), "统一认证注册应用")); + moduleMap.put("excel", SalaryI18nUtil.getI18nLabel(115543, ElogSeviceUtils.currentLanguage(), "excel函数")); + moduleMap.put("scene", SalaryI18nUtil.getI18nLabel(115539, ElogSeviceUtils.currentLanguage(), "绘图")); + moduleMap.put("bcw", SalaryI18nUtil.getI18nLabel(115651, ElogSeviceUtils.currentLanguage(), "公共模块")); + moduleMap.put("folder", SalaryI18nUtil.getI18nLabel(10734, ElogSeviceUtils.currentLanguage(), "文件夹")); + moduleMap.put("pdfcnv", SalaryI18nUtil.getI18nLabel(115957, ElogSeviceUtils.currentLanguage(), "PDF转换服务")); + moduleMap.put("ebform", SalaryI18nUtil.getI18nLabel(121462, ElogSeviceUtils.currentLanguage(), "e-Builder表单")); + moduleMap.put("statistics", SalaryI18nUtil.getI18nLabel(17745, ElogSeviceUtils.currentLanguage(), "自定义统计")); + moduleMap.put("edcapp", SalaryI18nUtil.getI18nLabel(121631, ElogSeviceUtils.currentLanguage(), "多级填报")); + + */ + + moduleMap.put("elog", 62975); + moduleMap.put("report", 62976); + moduleMap.put("edc", 52689); + moduleMap.put("hrm", 62978); + moduleMap.put("crm", 62979); + moduleMap.put("demo", 62980); + moduleMap.put("attc", 62981); + moduleMap.put("attm", 62982); + moduleMap.put("attw", 62983); + moduleMap.put("auth", 62984); + moduleMap.put("bank", 62985); + moduleMap.put("bap", 62986); + moduleMap.put("base", 62987); + moduleMap.put("batc", 62988); + moduleMap.put("blog", 62989); + moduleMap.put("cld", 62990); + moduleMap.put("cmca", 62991); + moduleMap.put("cmcl", 62992); + moduleMap.put("cmco", 62993); + moduleMap.put("cmcp", 62994); + moduleMap.put("cmcu", 62995); + moduleMap.put("cmex", 62996); + moduleMap.put("cmmk", 62997); + moduleMap.put("cmor", 62998); + moduleMap.put("cmpc", 62999); + moduleMap.put("cmpr", 63000); + moduleMap.put("cmpt", 63001); + moduleMap.put("cmqu", 63002); + moduleMap.put("cmsa", 63003); + moduleMap.put("cmtr", 63004); + moduleMap.put("comp", 63005); + moduleMap.put("cs", 63006); + moduleMap.put("cowork", 63007); + moduleMap.put("dbs", 63008); + moduleMap.put("dcad", 63009); + moduleMap.put("dcap", 63010); + moduleMap.put("dcrd", 63011); + moduleMap.put("dcre", 63012); + moduleMap.put("dcs", 63013); + moduleMap.put("dds", 63014); + moduleMap.put("dps", 63015); + moduleMap.put("drle", 63016); + moduleMap.put("ds", 63017); + moduleMap.put("dw_etl", 63018); + moduleMap.put("dw_model", 63019); + moduleMap.put("dw_process", 63020); + moduleMap.put("dw_search", 63021); + moduleMap.put("dw_sync", 63022); + moduleMap.put("eb", 63023); + moduleMap.put("ebda", 62987); + moduleMap.put("ebdd", 63024); + moduleMap.put("ebdf", 63025); + moduleMap.put("ebdp", 63026); + moduleMap.put("ecod", 63027); + moduleMap.put("ei", 63028); + moduleMap.put("em", 63029); + moduleMap.put("es", 63030); + moduleMap.put("esa", 63031); + moduleMap.put("esb", 63032); + moduleMap.put("esch", 63033); + moduleMap.put("esd", 63034); + moduleMap.put("exfo", 63035); + moduleMap.put("fbdg", 63036); + moduleMap.put("fdt", 63037); + moduleMap.put("fexs", 63038); + moduleMap.put("file", 63039); + moduleMap.put("finc", 63040); + moduleMap.put("fnar", 63041); + moduleMap.put("fomo", 63042); + moduleMap.put("form", 63043); + moduleMap.put("frpt", 63043); + moduleMap.put("fvou", 63044); + moduleMap.put("hp", 63045); + moduleMap.put("hr", 63046); + moduleMap.put("ic", 63047); + moduleMap.put("il", 63048); + moduleMap.put("im", 63049); + moduleMap.put("inc", 63050); + moduleMap.put("iua", 63051); + moduleMap.put("iut", 63052); + moduleMap.put("mail", 63053); + moduleMap.put("mc", 63054); + moduleMap.put("mt", 63055); + moduleMap.put("my", 63056); + moduleMap.put("odoc", 63057); + moduleMap.put("odoc_exchange", 63058); + moduleMap.put("open", 63059); + moduleMap.put("pr", 63060); + moduleMap.put("proj", 63061); + moduleMap.put("prt", 63062); + moduleMap.put("pspt", 63063); + moduleMap.put("rptc", 63064); + moduleMap.put("rpts", 63065); + moduleMap.put("sala", 63066); + moduleMap.put("sign", 63067); + moduleMap.put("sms", 63068); + moduleMap.put("task", 63069); + moduleMap.put("tnt", 63070); + moduleMap.put("wf", 63071); + moduleMap.put("wfc", 63072); + moduleMap.put("wfr", 63073); + moduleMap.put("wrgm", 63074); + moduleMap.put("wrgp", 63075); + moduleMap.put("wrpr", 63076); + moduleMap.put("doc", 63077); + moduleMap.put("placard", 63078); + moduleMap.put("fna", 135042); + moduleMap.put("meeting", 63080); + moduleMap.put("wfp", 63081); + moduleMap.put("portal", 63045); + moduleMap.put("workreport", 63082); + moduleMap.put("goal", 63074); + moduleMap.put("performance", 63075); + moduleMap.put("intlogin", 63083); + moduleMap.put("i18n", 64559); + moduleMap.put("timecard", 63085); + moduleMap.put("market", 63086); + moduleMap.put("excelformula", 64560); + moduleMap.put("ebatch", 69280); + moduleMap.put("ic_ldap", 70081); + moduleMap.put("iut_c_c", 96493); + moduleMap.put("plan", 63076); + moduleMap.put("document", 34218); + moduleMap.put("taskCustStatus", 73988); + moduleMap.put("calendar", 74186); + moduleMap.put("batch", 69280); + moduleMap.put("project", 55158); + moduleMap.put("web", 75598); + moduleMap.put("formdatareport", 76068); + moduleMap.put("mainline", 31898); + moduleMap.put("customer", 32726); + moduleMap.put("contract", 32864); + moduleMap.put("group", 19426); + moduleMap.put("workflow", 81851); + moduleMap.put("biaoge", 30919); + moduleMap.put("clue", 28908); + moduleMap.put("competitor", 81852); + moduleMap.put("kpiFlow", 81853); + moduleMap.put("mainlineCustStatus", 81854); + moduleMap.put("marketactivity", 34221); + moduleMap.put("mtPhase", 81855); + moduleMap.put("production", 29329); + moduleMap.put("quote", 34231); + moduleMap.put("saleChance", 32863); + moduleMap.put("orderform", 34230); + moduleMap.put("contact", 32711); + moduleMap.put("price", 31922); + moduleMap.put("capital", 83428); + moduleMap.put("ice", 87722); + moduleMap.put("ic_hr", 84284); + moduleMap.put("intunifyauth", 84508); + moduleMap.put("signcenter", 84691); + moduleMap.put("iut_s_c", 91503); + moduleMap.put("iut_s_c1", 95218); + moduleMap.put("iut_s_c2", 95219); + moduleMap.put("iut_s_c3", 95220); + moduleMap.put("iut_c_log", 96494); + moduleMap.put("ic_mail", 100715); + moduleMap.put("hrsa", 105038); + moduleMap.put("icc", 113884); + moduleMap.put("basicserver", 113885); + moduleMap.put("dw", 115549); + moduleMap.put("msg", 115563); + moduleMap.put("intunifybase", 115599); + moduleMap.put("esearch", 21694); + moduleMap.put("iaauthserver", 115603); + moduleMap.put("excel", 115543); + moduleMap.put("scene", 115539); + moduleMap.put("bcw", 115651); + moduleMap.put("folder", 10734); + moduleMap.put("pdfcnv", 115957); + moduleMap.put("login", 63063); + moduleMap.put("ebform", 121462); + moduleMap.put("statistics", 17745); + moduleMap.put("edcapp", 121631); + moduleMap.put("cusapp", 16381); + moduleMap.put("e10-allinone-base", 141083); + moduleMap.put("voice", 142713); + moduleMap.put("filter", 147832); + moduleMap.put("ias", 146674); + moduleMap.put("device", 153666); + moduleMap.put("meetingTopic", 180274); + moduleMap.put("meetingService", 180276); + moduleMap.put("meetingDecision", 180277); + moduleMap.put("meetingSign", 180278); + moduleMap.put("meetingSignSet", 61601); + moduleMap.put("meetingMember", 180280); + moduleMap.put("meetingShare", 180281); + moduleMap.put("int", 40031); + moduleMap.put("print", 160051); + moduleMap.put("wcwIconUpdate", 182661); + moduleMap.put("wcwIconRelease", 183123); + moduleMap.put("wcwIconUse", 183124); + moduleMap.put("wcw", 29385); + moduleMap.put("component", 115651); + moduleMap.put("ic_exchange", 87722); + moduleMap.put("iut_c_c", 240048); + moduleMap.put("iut_c_set", 240049); + + Map elogMap = new HashMap<>(); + Map reportMap = new HashMap<>(); + Map edcMap = new HashMap<>(); + Map hrmMap = new HashMap<>(); + Map crmMap = new HashMap<>(); + Map demoMap = new HashMap<>(); + + moduleFuctionMap.put("elog", elogMap); + moduleFuctionMap.put("report", reportMap); + moduleFuctionMap.put("edc", edcMap); + moduleFuctionMap.put("hrm", hrmMap); + moduleFuctionMap.put("crm", crmMap); + moduleFuctionMap.put("demo", demoMap); + + + elogMap.put("operator", "日志操作"); + elogMap.put("reportcusinfo", "报表自定义"); + edcMap.put("dataset", "数据集合"); + + demoMap.put("reportcusinfo", "报表自定义字段"); + } + + /** + * 获取模块名称 + * + * @param module + * @return + */ + public static String getModuleName(String module) { +// String modulename = ElogSeviceUtils.null2String(moduleMap.get(module), module); +// return ElogSeviceUtils.isLongValue(modulename) ? SalaryI18nUtil.getI18nLabel(ElogSeviceUtils.getLongValue(modulename), modulename) : modulename; + return module; + } + + /** + * 获取模块名称 + * + * @param module + * @return + */ + public static String getModuleNamePapi(String module) { +// String modulename = ElogSeviceUtils.null2String(moduleMap.get(module), module); +// return ElogSeviceUtils.isLongValue(modulename) ? SalaryI18nUtil.getI18nLabel(ElogSeviceUtils.getLongValue(modulename), modulename) : modulename; + return module; + } + + + /** + * 获取方法名称 + * + * @param module + * @param function + * @return + */ + public static String getFunctionName(String module, String function) { +// Map functionMap = moduleFuctionMap.get(module); +// +// if (functionMap != null) +// function = ElogSeviceUtils.null2String(functionMap.get(function), function); +// +// return ElogSeviceUtils.isLongValue(function) ? SalaryI18nUtil.getI18nLabel(ElogSeviceUtils.getLongValue(function), function) : function; + return function; + } + + public static void switchValues(List resultMap, List recordColumns) { + + switchValues(resultMap, recordColumns, false); + + } + + + public static void switchValues(List list, List recordColumns, boolean islocal) { +// if(!islocal) { +// changKey2Lower(list); +// } + for (Map map : list) { + Iterator> iterator = map.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry next = iterator.next(); + for (String recordColumn : recordColumns) { + if (next.getKey().equals(recordColumn) && next.getValue() instanceof String) { + map.put(next.getKey(), transfi18Method(next.getValue())); + } + } + } + map.put("modulenamespan", getModuleName(map.get("modulename"))); + //map.put("functionnamespan", getFunctionName(map.get("modulename"), map.get("functionname"))); + //switchDatabaseField(map); + } + + } + + public static void switchDatabaseField(Map map) { + map.put("date", map.get("log_date")); + map.put("operator", map.get("log_operator")); + map.put("result", map.get("log_result")); + } + + /** + * 转换数据成多语言 + * + * @param lists + */ + public static List transfLanguageData(List lists) { + if (lists != null && lists.size() > 0) { + for (Map map : lists) { + if (map != null) { + Iterator> iterator = map.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + if (entry.getValue() instanceof Integer || entry.getValue() instanceof Long || entry.getValue() instanceof String) { + map.put(entry.getKey(), transfLanguageLableid(ElogSeviceUtils.getLongValue(entry.getValue().toString()), entry.getValue().toString())); + } else { + map.put(entry.getKey(), entry.getValue()); + } + } + } + } + } + return lists; + } + + public static String transfi18Method(String str) { + if ("新增".equals(str)) { + return transfLanguageLableid(63252l, str); + } else if ("查看".equals(str)) { + return transfLanguageLableid(55172l, str); + } else if ("修改".equals(str)) { + return transfLanguageLableid(63253l, str); + } else if ("更新".equals(str)) { + return transfLanguageLableid(29540l, str); + } else if ("删除".equals(str)) { + return transfLanguageLableid(63254l, str); + } else if (StringUtils.isNumeric(str) && str.length() < 10) { + return transfLanguageLableid(Long.parseLong(str), str); + } else { + return str; + } + } + + public static String transfLanguageLableid(Long lableid) { + return SalaryI18nUtil.getI18nLabel(Integer.parseInt(lableid.toString()), lableid.toString()); + } + + /** + * 转换多语言 + * + * @param lableid + * @param def + * @return + */ + public static String transfLanguageLableid(Long lableid, String def) { + return SalaryI18nUtil.getI18nLabel(Integer.parseInt(lableid.toString()), def); + } + + + /** + * 日志本地服务-更新明细转换 + * + * @param mainlist + * @param list + * @return + */ + public static Map switchChangeValue(List mainlist, List list) { + Map res = new HashMap<>(); + StringBuilder valuesChange = new StringBuilder(); + List valuesChanges = new ArrayList<>(); + String values = ""; + String operatetypeName = ""; + int oldCount = 0; + int newCount = 0; + String operatetype = ""; + CaseInsensitiveMap map = null; + if (list != null && list.size() > 0) { + for (Map hashmap : list) { + map = new CaseInsensitiveMap<>(hashmap); + Object obj = map.get("operatetype"); + if (obj != null) { + operatetype = obj.toString(); + } + } + } + if (mainlist != null && mainlist.size() > 0) { + for (Map hashMap : mainlist) { + map = new CaseInsensitiveMap<>(hashMap); + Object isdetail = map.get("isdetail"); + if (isdetail != null) { + if (StringUtils.isBlank(isdetail.toString()) || !"0".equals(isdetail.toString())) { + continue; + } + } else { + continue; + } + Object oldvalue = map.get("oldvalue"); + if (oldvalue != null) { + if (StringUtils.isNotBlank(oldvalue.toString())) { + oldCount++; + } + } + + Object newvalue = map.get("newvalue"); + if (newvalue != null) { + if (StringUtils.isNotBlank(newvalue.toString())) { + newCount++; + } + } + + } + } + CaseInsensitiveMap jo = null; + for (int i = 0; i < mainlist.size(); i++) { + Map jomap = mainlist.get(i); + jo = new CaseInsensitiveMap<>(jomap); + String fieldName = jo.get("fielddesc"); + String oldvalue = obj2String(jo.get("oldvalue")); + String oldrealvalue = obj2String(jo.get("oldrealvalue")); + String newValue = obj2String(jo.get("newvalue")); + String newrealvalue = obj2String(jo.get("newrealvalue")); + // oracle.sql.CLOB类型处理 + jomap.put("oldvalue", oldvalue); + jomap.put("oldrealvalue", oldrealvalue); + jomap.put("newvalue", newValue); + jomap.put("newrealvalue", newrealvalue); + + String fieldNameLabelId = jo.get("fieldnamelabelid"); + if (StringUtils.isNotBlank(fieldNameLabelId) && StringUtils.isNumeric(fieldNameLabelId)) { + fieldName = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(fieldNameLabelId), fieldName); + } else if (StringUtils.isNotBlank(fieldNameLabelId) && !StringUtils.isNumeric(fieldNameLabelId) && !"-1".equals(fieldNameLabelId)) { + fieldName = fieldNameLabelId; + } else if (StringUtils.isNotBlank(fieldName) && StringUtils.isNumeric(fieldName)) { + fieldName = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(fieldName), fieldName); + } + if (StringUtils.isNotBlank(oldrealvalue) && StringUtils.isNumeric(oldrealvalue)) { + oldvalue = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(oldrealvalue), oldvalue); + } else if (StringUtils.isNotBlank(oldrealvalue) && !StringUtils.isNumeric(oldrealvalue)) { + oldvalue = oldrealvalue; + } + if (StringUtils.isNotBlank(newrealvalue) && StringUtils.isNumeric(newrealvalue)) { + newValue = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(newrealvalue), newValue); + } else if (StringUtils.isNotBlank(newrealvalue) && !StringUtils.isNumeric(newrealvalue)) { + newValue = newrealvalue; + } + + //oldvalue,newValue 避免xss漏洞 分别进行转义 +// oldvalue = StringConversionForXSS(oldvalue); +// newValue = StringConversionForXSS(newValue); + + if (oldCount != 0) { + valuesChanges.add(String.format(valueChangeFormat(), fieldName, oldvalue, newValue)); + + } else if (oldCount == 0 || newCount == 0 || operatetype.startsWith(OperateType.add) || operatetype.startsWith(OperateType.delete)) { + valuesChanges.add(String.format(valueChangeNewFormat(), fieldName, newValue)); + + } else { + valuesChanges.add(String.format(valueChangeFormat(), fieldName, oldvalue, newValue)); + } + //} + /*if (valuesChange.length() > 3) { + values = valuesChange.substring(0, valuesChange.length() - 3); + }*/ + } + + res.put("valueschanges", valuesChanges); + res.put("detailcontexts", mainlist); + return res; + } + + private static String obj2String(Object o) { + if (o == null) { + return ""; + } + if (o instanceof String) { + return (String) o; + } + return JSON.toJSONString(o); + } + + /** + * 服务中心结果集转换 + */ + public static void switchChangeValues(List list) { + CaseInsensitiveMap map = null; + for (Map hashMap : list) { + map = new CaseInsensitiveMap<>(hashMap); + int count = 0; + StringBuilder valuesChange = new StringBuilder(); + List valuesChanges = new ArrayList(); + Object detailContexts = map.get("detailcontexts"); + if (detailContexts != null) { + JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(detailContexts)); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jo = jsonArray.getJSONObject(i); + String isDetail = jo.getString("isDetail"); + if (StringUtils.isBlank(isDetail) || !"0".equals(isDetail)) { + continue; + } + String oldvalue = jo.getString("oldValue"); + if (StringUtils.isNotBlank(oldvalue)) { + count++; + } + } + } + + if (detailContexts != null) { + JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(detailContexts)); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jo = jsonArray.getJSONObject(i); + String isDetail = jo.getString("isDetail"); + if (StringUtils.isBlank(isDetail) || !"0".equals(isDetail)) { + continue; + } + String fieldName = jo.getString("fieldDesc"); + String oldvalue = jo.getString("oldValue"); + String oldrealvalue = jo.getString("oldRealValue"); + String newValue = jo.getString("newValue"); + String newrealvalue = jo.getString("newRealValue"); + String fieldNameLabelId = jo.getString("fieldNameLabelId"); + if (StringUtils.isNotBlank(fieldNameLabelId) && StringUtils.isNumeric(fieldNameLabelId)) { + fieldName = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(fieldNameLabelId)); + } + if (StringUtils.isNotBlank(oldrealvalue) && StringUtils.isNumeric(oldrealvalue)) { + oldvalue = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(oldrealvalue)); + } + if (StringUtils.isNotBlank(newrealvalue) && StringUtils.isNumeric(newrealvalue)) { + newValue = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(newrealvalue)); + } + if (count == 0) { + valuesChanges.add(String.format(valueChangeNewFormat(), fieldName, newValue)); + } else { + valuesChanges.add(String.format(valueChangeFormat(), fieldName, oldvalue, newValue)); + } + + } + /*String values = ""; + if (valuesChange.length() > 3) { + values = valuesChange.substring(0, valuesChange.length() - 3); + }*/ + + map.put("valueschanges", valuesChanges); + } + + } + } + + public static String valueChangeNewFormat() { + return "【%s】:%s"; + } + + public static String valueChangeFormat() { + return "【%s】:" + SalaryI18nUtil.getI18nLabel(61695, "由") + + "[%s] " + SalaryI18nUtil.getI18nLabel(61697, "改为") + " [%s]"; + } + + public static void changKey2Lower(List list) { + + List newList = new ArrayList<>(); + for (Map orgMap : list) { + Map resultMap = new HashMap<>(); + + if (orgMap == null || orgMap.isEmpty()) { + newList.add(resultMap); + continue; + } + + Set keySet = orgMap.keySet(); + for (String key : keySet) { + resultMap.put(key != null ? key.toLowerCase() : "", orgMap.get(key)); + } + newList.add(resultMap); + } + list.clear(); + list.addAll(newList); + } + + /** + * 查看详细表的数据 + * + * @param list + */ + public static Map switchDetailChangeValue(List list) { + Map res = new HashMap<>(); + List> lists = new ArrayList<>(); + HashMap repeatTableName = new HashMap<>(); + CaseInsensitiveMap map = null; + for (Map hashMap : list) { + map = new CaseInsensitiveMap<>(hashMap); + List detailmap = new ArrayList<>(); + HashMap detailoldMap = new HashMap<>(); + detailoldMap.put("operator", SalaryI18nUtil.getI18nLabel(63248, "操作(旧)")); + detailoldMap.put("dataid", map.get("dataid")); + HashMap detailnewMap = new HashMap<>(); + detailnewMap.put("operator", SalaryI18nUtil.getI18nLabel(63249, "操作(新)")); + detailnewMap.put("dataid", map.get("dataid")); + detailmap.add(detailoldMap); + detailmap.add(detailnewMap); + WeaTable wea = new WeaTable(); + wea.getColumns().add(new WeaTableColumn("5%",SalaryI18nUtil.getI18nLabel(63250, "操作"), "operator")); +// wea.getColumns().add(new WeaTableColumn("dataid", "dataid", true)); + Object tablename = map.get("tablename"); + Object tablenamelabelid = map.get("tablenamelabelid"); + if (tablenamelabelid != null) { + if (StringUtils.isNotBlank(tablenamelabelid.toString()) && StringUtils.isNumeric(tablenamelabelid.toString())) { + tablename = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(tablenamelabelid.toString())); + } + } + Map m = new HashMap<>(); + if (tablename != null && StringUtils.isNotBlank(tablename.toString())) { + String temptablename = repeatTableName.get(tablename.toString()); + if (tablename.toString().equals(temptablename)) { + continue; + } + repeatTableName.put(tablename.toString(), tablename.toString()); + m.put("tablename", tablename.toString()); + m.put("detailmap", detailmap); + m.put("column", wea); + lists.add(m); + } else { + tablename = tablename != null ? tablename : ""; + String temptablename = repeatTableName.get(tablename.toString()); + if (tablename.toString().equals(temptablename)) { + continue; + } + repeatTableName.put(tablename.toString(), tablename.toString()); + m.put("tablename", ""); + m.put("detailmap", detailmap); + m.put("column", wea); + lists.add(m); + } + } + + for (Map hashMap : list) { + map = new CaseInsensitiveMap<>(hashMap); + Object isDetail = map.get("isdetail"); + if (isDetail != null) { + if ("0".equals(isDetail.toString())) { + continue; + } + } else { + continue; + } + String title = ""; + String dataIndex = ""; + String oldValue = ""; + String newValue = ""; + String tableName = ""; + String dataId = ""; + + Object fieldDesc = map.get("fielddesc"); + if (fieldDesc != null) { + if (StringUtils.isNotBlank(fieldDesc.toString())) { + title = fieldDesc.toString(); + } + } + + Object fieldnamelabelid = map.get("fieldnamelabelid"); + if (fieldnamelabelid != null) { + if (StringUtils.isNotBlank(fieldnamelabelid.toString()) && StringUtils.isNumeric(fieldnamelabelid.toString())) { + title = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(fieldnamelabelid.toString())); + } + } + + Object fieldName = map.get("fieldname"); + if (fieldName != null) { + if (StringUtils.isNotBlank(fieldName.toString())) { + dataIndex = fieldName.toString(); + } + } + Object oValue = map.get("oldvalue"); + if (oValue != null) { + if (StringUtils.isNotBlank(oValue.toString())) { + oldValue = oValue.toString(); + } + } + Object nValue = map.get("newvalue"); + if (nValue != null) { + if (StringUtils.isNotBlank(nValue.toString())) { + newValue = nValue.toString(); + } + } + Object oldRealValue = map.get("oldrealvalue"); + if (oldRealValue != null) { + if (StringUtils.isNotBlank(oldRealValue.toString()) && StringUtils.isNumeric(oldRealValue.toString())) { + oldValue = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(oldRealValue.toString())); + } + } + + Object newrealvalue = map.get("newrealvalue"); + if (newrealvalue != null) { + if (StringUtils.isNotBlank(newrealvalue.toString()) && StringUtils.isNumeric(newrealvalue.toString())) { + newValue = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(newrealvalue.toString())); + } + } + + Object tablename = map.get("tablename"); + if (StringUtils.isNotBlank(tablename.toString())) { + tableName = tablename.toString(); + } else { + tableName = ""; + } + Object tablenamelabelid = map.get("tablenamelabelid"); + if (tablenamelabelid != null) { + if (tablenamelabelid != null) { + if (StringUtils.isNotBlank(tablenamelabelid.toString()) && StringUtils.isNumeric(tablenamelabelid.toString())) { + tableName = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(tablenamelabelid.toString())); + } + } + } + Object dataid = map.get("dataid"); + if (StringUtils.isNotBlank(dataid.toString())) { + dataId = dataid.toString(); + } else { + dataId = ""; + } + for (Map m : lists) { + Object o = m.get("tablename"); + if (o != null) { + if (tableName.equals(o)) { + List details = (List) m.get("detailmap"); + List newDetails = new ArrayList<>(); + if (details != null && details.size() > 0) { + for (Map detail : details) { + Object data_id = detail.get("dataid"); + if (data_id != null) { + if (dataId.equals(data_id)) { + Object operator = detail.get("operator"); + if (operator != null) { + if (SalaryI18nUtil.getI18nLabel(63248, "操作(旧)").equals(operator.toString())) { + detail.put(dataIndex, oldValue); + } else if (SalaryI18nUtil.getI18nLabel(63249, "操作(新)").equals(operator.toString())) { + detail.put(dataIndex, newValue); + } + } + } else { + if (newDetails.size() > 2) { + for (Map newDetail : newDetails) { + if (dataId.equals(newDetail.get("dataid"))) { + Object operator = detail.get("operator"); + if (operator != null) { + if (SalaryI18nUtil.getI18nLabel(63248, "操作(旧)").equals(operator.toString())) { + detail.put(dataIndex, oldValue); + } else if (SalaryI18nUtil.getI18nLabel(63249, "操作(新)").equals(operator.toString())) { + detail.put(dataIndex, newValue); + } + } + } else { + HashMap detailoldMap = new HashMap<>(); + detailoldMap.put("operator", SalaryI18nUtil.getI18nLabel(63248, "操作(旧)")); + detailoldMap.put("dataid", map.get("dataid")); + detailoldMap.put(dataIndex, oldValue); + HashMap detailnewMap = new HashMap<>(); + detailnewMap.put("operator", SalaryI18nUtil.getI18nLabel(63249, "操作(新)")); + detailnewMap.put("dataid", map.get("dataid")); + detailnewMap.put(dataIndex, newValue); + newDetails.add(detailoldMap); + newDetails.add(detailnewMap); + } + } + } else if (newDetails.size() == 0) { + int count = 0; + for (Map mapdetail : details) { + Object dataid_ = mapdetail.get("dataid"); + if (dataid_ != null && dataid_.equals(dataId)) { + count++; + } + } + if (count == 0) { + HashMap detailoldMap = new HashMap<>(); + detailoldMap.put("operator", SalaryI18nUtil.getI18nLabel(63248, "操作(旧)")); + detailoldMap.put("dataid", map.get("dataid")); + detailoldMap.put(dataIndex, oldValue); + HashMap detailnewMap = new HashMap<>(); + detailnewMap.put("operator", SalaryI18nUtil.getI18nLabel(63249, "操作(新)")); + detailnewMap.put("dataid", map.get("dataid")); + detailnewMap.put(dataIndex, newValue); + newDetails.add(detailoldMap); + newDetails.add(detailnewMap); + } + } + } + } + } + } + if (newDetails.size() > 0) { + details.addAll(newDetails); + newDetails.clear(); + } + + WeaTable column = (WeaTable) m.get("column"); + if (column != null) { + List columns = column.getColumns(); + if (columns != null && columns.size() > 0) { + Boolean flag = true; + for (Object object : columns) { + WeaTableColumn weaTableColumn = JSONObject.parseObject(JSON.toJSONString(object), WeaTableColumn.class); + if (weaTableColumn != null) { + String title1 = weaTableColumn.getText(); + if (title.equals(title1)) { + flag = false; + break; + } + } + } + if (flag) { + column.getColumns().add(new WeaTableColumn(title, dataIndex, "5%")); + m.put("column", column); + } + } + } + } + } + } + } + res.put("detail", lists); + return res; + } + + + public static void switchDetailChangeValues(List list) { + for (Map map : list) { + Map repeatTableName = new HashMap<>(); + List detailContexts = (List) map.get("detailcontexts"); + List lists = new ArrayList<>(); + if (detailContexts != null) { + for (Map detailContext : detailContexts) { + List detailmap = new ArrayList<>(); + HashMap detailoldMap = new HashMap<>(); + detailoldMap.put("operator", SalaryI18nUtil.getI18nLabel(63248, "操作(旧)")); + detailoldMap.put("dataid", detailContext.get("dataid")); + HashMap detailnewMap = new HashMap<>(); + detailnewMap.put("operator", SalaryI18nUtil.getI18nLabel(63249, "操作(新)")); + detailnewMap.put("dataid", detailContext.get("dataid")); + detailmap.add(detailoldMap); + detailmap.add(detailnewMap); + WeaTable wea = new WeaTable(); + wea.getColumns().add(new WeaTableColumn(SalaryI18nUtil.getI18nLabel(63250, "操作"), "operator", "5%")); +// wea.getColumns().add(new WeaTableColumn("dataid", "dataid", true)); + Object tableName = detailContext.get("tableName"); + Object tablenamelabelid = detailContext.get("tableNameLabelId"); + if (tablenamelabelid != null) { + if (StringUtils.isNotBlank(tablenamelabelid.toString()) && StringUtils.isNumeric(tablenamelabelid.toString())) { + tableName = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(tablenamelabelid.toString())); + } + } + Map m = new HashMap<>(); + if (StringUtils.isNotBlank(tableName.toString())) { + String temptablename = repeatTableName.get(tableName.toString()); + if (tableName.toString().equals(temptablename)) { + continue; + } + repeatTableName.put(tableName.toString(), tableName.toString()); + m.put("tablename", tableName.toString()); + m.put("detailmap", detailmap); + m.put("column", wea); + lists.add(m); + map.put("detail", lists); + } else { + String temptablename = repeatTableName.get(tableName.toString()); + if (tableName.toString().equals(temptablename)) { + continue; + } + repeatTableName.put(tableName.toString(), tableName.toString()); + m.put("tablename", ""); + m.put("detailmap", detailmap); + m.put("column", wea); + lists.add(m); + map.put("detail", lists); + } + } + } + List details = (List) map.get("detail"); + if (details != null) { + int size = details.size(); + int start = 0; + while (start < size) { + start++; + + for (int i = 0; i < size; i++) { + Map detail = details.get(i); + + //for (Map detail : details) { + if (details.size() > size) { + break; + } + for (Map detailContext : detailContexts) { + Object isDetail = detailContext.get("isDetail"); + if (isDetail != null) { + if ("0".equals(isDetail.toString())) { + continue; + } + } else { + continue; + } + String title = ""; + String dataIndex = ""; + String oldValue = ""; + String newValue = ""; + String tableName = ""; + String dataId = ""; + Object fieldDesc = detailContext.get("fieldDesc"); + if (StringUtils.isNotBlank(fieldDesc.toString())) { + title = fieldDesc.toString(); + } + Object fieldnamelabelid = detailContext.get("fieldNameLabelId"); + if (fieldnamelabelid != null) { + if (StringUtils.isNotBlank(fieldnamelabelid.toString()) && StringUtils.isNumeric(fieldnamelabelid.toString())) { + title = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(fieldnamelabelid.toString())); + } + } + Object fieldName = detailContext.get("fieldName"); + if (StringUtils.isNotBlank(fieldName.toString())) { + dataIndex = fieldName.toString(); + } + Object oValue = detailContext.get("oldValue"); + if (StringUtils.isNotBlank(oValue.toString())) { + oldValue = oValue.toString(); + } + Object nValue = detailContext.get("newValue"); + if (StringUtils.isNotBlank(nValue.toString())) { + newValue = nValue.toString(); + } + Object oldRealValue = detailContext.get("oldRealValue"); + if (oldRealValue != null) { + if (StringUtils.isNotBlank(oldRealValue.toString()) && StringUtils.isNumeric(oldRealValue.toString())) { + oldValue = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(oldRealValue.toString())); + } + } + + Object newrealvalue = detailContext.get("newRealValue"); + if (newrealvalue != null) { + if (StringUtils.isNotBlank(newrealvalue.toString()) && StringUtils.isNumeric(newrealvalue.toString())) { + newValue = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(newrealvalue.toString())); + } + } + Object tablename = detailContext.get("tableName"); + if (StringUtils.isNotBlank(tablename.toString())) { + tableName = tablename.toString(); + } else { + tableName = ""; + } + Object tablenamelabelid = detailContext.get("tableNameLabelId"); + if (tablenamelabelid != null) { + if (tablenamelabelid != null) { + if (StringUtils.isNotBlank(tablenamelabelid.toString()) && StringUtils.isNumeric(tablenamelabelid.toString())) { + tableName = ElogSeviceSwitchUtils.transfLanguageLableid(Long.parseLong(tablenamelabelid.toString())); + } + } + } + Object dataid = detailContext.get("dataid"); + if (StringUtils.isNotBlank(dataid.toString())) { + dataId = dataid.toString(); + } else { + dataId = ""; + } + Object detailtablename = detail.get("tablename"); + if (detailtablename != null) { + if (tableName.equals(detailtablename.toString())) { + List detailmap = (List) detail.get("detailmap"); + List newDetails = new ArrayList<>(); + if (detailmap != null && detailmap.size() > 0) { + for (Map d : detailmap) { + Object data_id = d.get("dataid"); + if (data_id != null) { + if (dataId.equals(data_id)) { + Object operator = d.get("operator"); + if (operator != null) { + if (SalaryI18nUtil.getI18nLabel(63248, "操作(旧)").equals(operator.toString())) { + d.put(dataIndex, oldValue); + } else if (SalaryI18nUtil.getI18nLabel(63249, "操作(新)").equals(operator.toString())) { + d.put(dataIndex, newValue); + } + } + } else { + if (newDetails.size() > 2) { + for (Map newDetail : newDetails) { + if (dataId.equals(newDetail.get("dataid"))) { + Object operator = d.get("operator"); + if (operator != null) { + if (SalaryI18nUtil.getI18nLabel(63248, "操作(旧)").equals(operator.toString())) { + d.put(dataIndex, oldValue); + } else if (SalaryI18nUtil.getI18nLabel(63249, "操作(新)").equals(operator.toString())) { + d.put(dataIndex, newValue); + } + } + } else { + HashMap detailoldMap = new HashMap<>(); + detailoldMap.put("operator", SalaryI18nUtil.getI18nLabel(63248, "操作(旧)")); + detailoldMap.put("dataid", detailContext.get("dataid")); + detailoldMap.put(dataIndex, oldValue); + HashMap detailnewMap = new HashMap<>(); + detailnewMap.put("operator", SalaryI18nUtil.getI18nLabel(63249, "操作(新)")); + detailnewMap.put("dataid", detailContext.get("dataid")); + detailnewMap.put(dataIndex, newValue); + newDetails.add(detailoldMap); + newDetails.add(detailnewMap); + } + } + } else if (newDetails.size() == 0) { + int count = 0; + for (Map mapdetail : detailmap) { + Object dataid_ = mapdetail.get("dataid"); + if (dataid_ != null && dataid_.equals(dataId)) { + count++; + } + } + if (count == 0) { + HashMap detailoldMap = new HashMap<>(); + detailoldMap.put("operator", SalaryI18nUtil.getI18nLabel(63248, "操作(旧)")); + detailoldMap.put("dataid", detailContext.get("dataid")); + detailoldMap.put(dataIndex, oldValue); + HashMap detailnewMap = new HashMap<>(); + detailnewMap.put("operator", SalaryI18nUtil.getI18nLabel(63249, "操作(新)")); + detailnewMap.put("dataid", detailContext.get("dataid")); + detailnewMap.put(dataIndex, newValue); + newDetails.add(detailoldMap); + newDetails.add(detailnewMap); + } + } + } + } + } + } + if (newDetails.size() > 0) { + details.addAll(newDetails); + newDetails.clear(); + //detailmap = new ArrayList<>(); + //detail.put("detailmap", detailmap); + } + + WeaTable column = (WeaTable) detail.get("column"); + if (column != null) { + List columns = column.getColumns(); + if (columns != null && columns.size() > 0) { + Boolean flag = true; + for (Object object : columns) { + WeaTableColumn weaTableColumn = JSONObject.parseObject(JSON.toJSONString(object), WeaTableColumn.class); + if (weaTableColumn != null) { + String title1 = weaTableColumn.getText(); + if (title.equals(title1)) { + flag = false; + break; + } else { + flag = true; + } + } + } + if (flag) { + column.getColumns().add(new WeaTableColumn(title, dataIndex, "5%")); + detail.put("column", column); + } + } + } + } + } + } + } + } + } + } + } + + public static List getSwitchDatabaseData(List list) { + String databaseId = new RecordSet().getDBType(); + if (ElogConsts.ORACLE.equalsIgnoreCase(databaseId) || ElogConsts.SQLSERVER.equalsIgnoreCase(databaseId)) { + List arrayList = new ArrayList<>(); + for (Map map : list) { + Set en = map.entrySet(); + Map hashMap = new HashMap<>(); + for (Map.Entry entry : en) { + Object key = entry.getKey(); + Object val = null; + if ("PARAMS".equalsIgnoreCase(key.toString()) || "CUSTOMINFO".equalsIgnoreCase(key.toString()) + || entry.getValue() instanceof ClobProxyImpl || entry.getValue() instanceof Clob) { + val = JSONObject.toJSON(entry.getValue()); + } else { + val = entry.getValue(); + } + hashMap.put(key.toString().toLowerCase(), val); + } + switchDatabaseField(hashMap); + arrayList.add(hashMap); + } + return arrayList; + } else { + for (Map map : list) { + switchDatabaseField(map); + } + return list; + } + } + + public static List getSwitchDatabaseAnalysisData(List list, Map keys) { + String databaseId = new RecordSet().getDBType(); + if (!ElogConsts.MYSQL.equalsIgnoreCase(databaseId)) { + List arrayList = new ArrayList<>(); + + for (Map map : list) { + Set en = map.entrySet(); + Map hashMap = new HashMap<>(); + for (Map.Entry entry : en) { + Object key = entry.getKey(); + Object val = entry.getValue(); + if (key.toString().equalsIgnoreCase(keys.get(key.toString().toLowerCase()))) { + key = keys.get(key.toString().toLowerCase()); + } else { + key = key.toString().toLowerCase(); + } + hashMap.put(key.toString(), val); + } + arrayList.add(hashMap); + } + return arrayList; + } + return list; + } + + /** + * 获取多个模块名称 + * + * @param modules + * @return + */ + public static Map getModuleNames(List modules) { + Map hashMap = new HashMap<>(); + if (modules == null || modules.size() == 0) { + return hashMap; + } + for (String module : modules) { + String modulenum = ElogSeviceUtils.null2String(moduleMap.get(module), module); + String modulename = ElogSeviceUtils.isLongValue(modulenum) ? SalaryI18nUtil.getI18nLabel(Integer.parseInt(modulenum), modulenum) : modulenum; + hashMap.put(module, modulename); + } + return hashMap; + + } + +// private static String StringConversionForXSS(String str) { +// if (StringUtils.isBlank(str)) +// return str; +// //判断是否是json串 是json串的话也直接返回 +// if (isJSONString(str)) +// return str; +// // 判断是否为前端标签类型字符串或带< 或 >的字符串,用false方法 /<(\\w+)[^>]*>(.*?<\\/\\1>)?/ +// Pattern pattern = Pattern.compile("[<>]"); +// Matcher matcher = pattern.matcher(str); +// if (matcher.find()) +// return SecurityUtil.encodeForHtml(str, false); +// //都不是则用true方法 +// return SecurityUtil.encodeForHtml(str, true); +// +// } + + + /** + * 判断是否为json字符串 + * + * @param content + * @return + */ + public static boolean isJSONString(String content) { + if (StringUtils.isEmpty(content)) { + return false; + } + if (!content.startsWith("{") || !content.endsWith("}")) { + if (!content.startsWith("[") || !content.endsWith("]")) { + return false; + } + } + try { + JSONObject.parse(content); + return true; + } catch (Exception e) { + return false; + } + } + + public static List getNameModule(String module) { + if (StringUtils.isBlank(module)) { + return new ArrayList<>(); + } + Map> dataMap = new HashMap<>(); + moduleMap.forEach((k, v) -> { + List list = new ArrayList<>(); + Integer moduleCode = moduleMap.get(k); + String htmlLabelName = SalaryI18nUtil.getI18nLabel(moduleCode, ""); + if (dataMap.containsKey(htmlLabelName)) { + list = dataMap.get(htmlLabelName); + list.add(k); + } else { + list.add(k); + } + dataMap.put(htmlLabelName, list); + }); + return Objects.isNull(dataMap.get(module)) ? Arrays.asList(module) : dataMap.get(module); + } +} diff --git a/src/com/engine/salary/elog/util/ElogSeviceUtils.java b/src/com/engine/salary/elog/util/ElogSeviceUtils.java new file mode 100644 index 0000000..11a47d3 --- /dev/null +++ b/src/com/engine/salary/elog/util/ElogSeviceUtils.java @@ -0,0 +1,513 @@ +package com.engine.salary.elog.util; + + +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.enums.FromTerminalType; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.HttpServletRequest; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +/** + * @Date: 2022/5/18 23:34 + * @Author: deli.xu + * @Description: elog服务工具类 + **/ +public class ElogSeviceUtils { + + private static final Logger logger = LoggerFactory.getLogger(ElogSeviceUtils.class); + + /*@Autowired + private ComInfoCache comInfoCache; + private static ComInfoCache baseComInfoCache; + + @PostConstruct + public void init() { + baseComInfoCache = comInfoCache; + }*/ + + private static final String TABLE_SPACER = "_"; + private static final String TABLE_SUFFIX = "logs"; + private static final String DETAIL_TABLE_SUFFIX = "_detail"; + public static final String BASE_TABLE = "BASE_ELOG_TABLE"; + + + public static String getTableName(String module, String function) { + return getTableName(module, function, false); + } + + public static String getTableName(String module, String function, boolean isDetail) { + String tablename = module + TABLE_SPACER + function + TABLE_SUFFIX + (isDetail ? DETAIL_TABLE_SUFFIX : ""); +// SecurityUtil.sqlCheck(tablename); + return tablename; + } + + /** + * String 转枚举 + * + * @param c + * @param string + * @param + * @return + */ + public static > T getEnumFromString(Class c, String string) { + if (c != null && string != null) { + try { + return Enum.valueOf(c, string.trim().toUpperCase()); + } catch (IllegalArgumentException ex) { + } + } + return null; + } + + /** + * 获取ip地址 + * + * @param request + * @return + */ + public static String getIp(HttpServletRequest request) { + String ipAddress = request.getHeader("x-forwarded-for"); + String unknown = "unknown"; + if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("WL-Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) { + ipAddress = request.getRemoteAddr(); + String benji = "127.0.0.1"; + String bj = "0:0:0:0:0:0:0:1"; + if (benji.equals(ipAddress) || bj.equals(ipAddress)) { + ///根据网卡取本机配置的IP + InetAddress inet = null; + try { + inet = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + logger.error("UnknownHostException", e); + } + if (inet != null) { + ipAddress = inet.getHostAddress(); + } + } + } + ///对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 + int i = 15; + String s = ","; + if (ipAddress != null && ipAddress.length() > i) { + if (ipAddress.indexOf(s) > 0) { + ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); + } + } + return ipAddress; + } + + /** + * 获取设备信息 + * + * @param request + * @return + */ + public static String getDevice(HttpServletRequest request) { + return request.getHeader("User-Agent"); + } + + /** + * 获取来自终端的信息 + * + * @param context + * @param request + * @return + */ + public static void getFromTerminal(LoggerContext context, HttpServletRequest request) { + String fromTerminal = context.getFromTerminal(); + if (StringUtils.isEmpty(fromTerminal)) { + String device = getDevice(request); + String setFT = ""; + if (StringUtils.isNotEmpty(device)) { + context.setFromTerminal(getFromTerminal(device)); + } + } + } + + + private static String getTraceId(HttpServletRequest request) { + String traceId = request.getHeader("traceId"); + if (StringUtils.isNotBlank(traceId)) { + //System.out.println("traceId:====="+traceId); + return traceId; + } + return ""; + } + + /** + * @param request + * @return localhost:9080/api/fs/demo/updateReport + */ + public static String getRequestUrl(HttpServletRequest request) { + if (Objects.isNull(request) || Objects.isNull(request.getRequestURL())) { + return null; + } + return request.getRequestURL().toString(); + } + + /** + * @param request + * @return /api/fs/demo/updateReport + */ + public static String getRequestUri(HttpServletRequest request) { + return request.getRequestURI(); + } + + /** + * @param request + * @return GET/POST + */ + public static String getRequestMethod(HttpServletRequest request) { + return request.getMethod(); + } + + +// /** +// * 获取当前方法中的日志实体类 +// * @return +// */ +// public static LoggerContext currentElogContext() { +// return ElogThreadLocal.currentLoggerContext(); +// } + + + public static int getIntValue(String v) { + return getIntValue(v, -1); + } + + public static int getIntValue(String v, int def) { + try { + return Integer.parseInt(v); + } catch (Exception var3) { + return def; + } + } + + public static long getLongValue(String v) { + return getLongValue(v, -1l); + } + + public static long getLongValue(String v, long def) { + try { + return Long.parseLong(v); + } catch (Exception var3) { + return def; + } + } + + public static boolean isLongValue(String v) { + try { + Long.parseLong(v); + } catch (Exception e) { + return false; + } + return true; + } + + +// /** +// * 获取request请求 +// * +// * @return +// */ +// public static HttpServletRequest getRequest() { +// return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); +// } + + /** + * 将对象转换程字符串 + * + * @param obj 目标对象 + * @param def 如果为null时的默认值 + * @return + */ + public static String null2String(Object obj, String def) { + return obj == null ? def : obj.toString(); + } + + public static String null2String(Object obj) { + return null2String(obj, ""); + } + + public static int getIntValue(Object obj, int def) { + try { + return Integer.parseInt(null2String(obj)); + } catch (Exception ex) { + return def; + } + } + +// public static Page getPage() { +// HttpServletRequest request = getRequest(); +// String num = request.getParameter("pageNum"); +// String size = request.getParameter("pageSize"); +// +// Page page = new Page(ElogSeviceUtils.getIntValue(num, 1), ElogSeviceUtils.getIntValue(size, 10)); +// return page; +// } + +// public static void main(String[] args) { +// //System.out.println(getTableName("select", "from")); +// //DataTypeEnum columnTypeEnum = getEnumFromString(DataTypeEnum.class, "varchar"); +// } + + public static List switchString(List list) { + if (list != null) { + return list.stream().map(m -> { + Set en = m.entrySet(); + for (Map.Entry entry : en) { + if (entry.getValue() != null) { + entry.setValue(String.valueOf(entry.getValue())); + } + } + return m; + }).collect(Collectors.toList()); + } else { + return list; + } + } + + public static List switchComplexString(List list) { + if (list != null) { + return list.stream().map(m -> { + Iterator iterator = m.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry next = iterator.next(); + if (next.getValue() != null) { + if (next.getValue() instanceof Map && "parmas".equals(next.getKey())) { + next.setValue(String.valueOf(next.getValue())); + } + if (next.getValue() instanceof List) { + } else { + next.setValue(String.valueOf(next.getValue())); + } + } + } + return m; + }).collect(Collectors.toList()); + } else { + return list; + } + } + + public static String getTenantKey() { + return "all_teams"; + } + + public static String getEmployeeId() { + return ""; + } + +// public static String getUserName() { +// +// String employeeId = getEmployeeId(); +// if (StringUtils.isNotEmpty(employeeId)) { +// SimpleEmployee simpleEmployee = null; +// try { +// HrmCommonUtil hrmCommonUtil = (HrmCommonUtil) ApplicationContextProvider.getBean("hrmCommonUtil"); +// simpleEmployee = hrmCommonUtil.getSimpleEmployee(ElogSeviceUtils.getLongValue(employeeId)); +// } catch (Exception e) { +// logger.error("Exception", e); +// } +// if (simpleEmployee != null) { +// if (StringUtils.isNotBlank(simpleEmployee.getUsername())) { +// return simpleEmployee.getUsername(); +// } +// } +// } +// +// +// return ""; +// } + +// /** +// * 获取rpc信息(客户端ip和来源设备) +// * +// * @param context +// */ +// public static void initRpcInfo(LoggerContext context) { +// String device = ""; +// String clientIp = ""; +// String traceId = ""; +// try { +// device = RpcContext.getContext().getAttachment(EteamsConstant.DEVICE); +// clientIp = RpcContext.getContext().getAttachment(EteamsConstant.CLIENT_IP); +// traceId = RpcContext.getContext().getAttachment(ApmConstant.TRACE_ID); +// logger.info("rpc调用获取到 device:{},clientIp:{},traceId:{}", device, clientIp, traceId); +// } catch (Exception e) { +// logger.error("Exception", e); +// } +// if (StringUtils.isEmpty(context.getDevice()) && StringUtils.isNotEmpty(device)) { +// context.setDevice(device); +// } +// if (StringUtils.isEmpty(context.getFromTerminal()) && StringUtils.isNotEmpty(device)) { +// context.setFromTerminal(getFromTerminal(device)); +// } +// +// if (StringUtils.isEmpty(context.getClientIp()) && StringUtils.isNotEmpty(clientIp)) { +// context.setClientIp(clientIp); +// } +// if (StringUtils.isEmpty(context.getBelongMainId()) && StringUtils.isNotEmpty(traceId)) { +// context.setBelongMainId(traceId); +// } +// } + + public static String getFromTerminal(String device) { + String setFT = ""; + if (StringUtils.isNotEmpty(device)) { + if (!device.contains("wxwork") && device.contains("MicroMessenger")) {//来自微信 + setFT = FromTerminalType.MICO_MSG.getCode(); + } else if (device.contains("wxwork") && device.contains("MicroMessenger")) {//企业微信 + setFT = FromTerminalType.WECHAT.getCode(); + } else if (device.contains("iPhone") && device.contains("Mac")) {//来自 Iphone + setFT = FromTerminalType.IOS.getCode(); + } else if (device.contains("Mac OS") && !device.contains("iPhone") && device.contains("weapp-pc")) {//来自 mac_client + setFT = FromTerminalType.MAC_CLIENT.getCode();//mac_client + } else if (!device.contains("wxwork") && device.contains("Mobile")) {//移动端 + setFT = FromTerminalType.H5.getCode(); + } else if (device.contains("Android") && !device.contains("wxwork")) {//来自安卓 包含安卓并且不包含微信 + setFT = FromTerminalType.ANDROID.getCode(); + } else {//pc + setFT = FromTerminalType.PC.getCode(); + } + } + return setFT; + } + + /** + * sql连接条件注入sql + * + * @param condition + * @return + */ + public static String checkConditionSql(String condition) { + if ("AND".equalsIgnoreCase(condition) || "OR".equalsIgnoreCase(condition)) { + return condition; + } + return "AND"; + } + + public static String checkTypeSql(String type) { + if ("LIKE".equalsIgnoreCase(type) || "IN".equalsIgnoreCase(type) || "!<>".equalsIgnoreCase(type) || "!=".equalsIgnoreCase(type) || "BETWEEN".equalsIgnoreCase(type) || "IS NULL".equalsIgnoreCase(type) || "IS NULL".equalsIgnoreCase(type) || "=".equalsIgnoreCase(type) || "IS NOT NULL".equalsIgnoreCase(type)) { + return type; + } + return "="; + } + + /** + * sql条件防止注入 + * + * @param value + * @return + */ + public static String checkValSql(String value) { + if (StringUtils.isBlank(value)) { + return ""; + } + Pattern p = Pattern.compile("\\s+"); + Matcher m = p.matcher(value); + String val = m.replaceAll(" "); + String[] keywords = {"master ", "truncate ", "declare ", "alert ", "create ", "drop ", " version", "show ", "table ", "index ", "insert ", "into ", "from ", "select ", "delete ", "update ", "mid ", "master ", "char ", "union "}; + + String replaceStr = val.replaceAll(" ", ""); + if (replaceStr.contains("1=1") || replaceStr.contains(";")) { + return "-1"; + } + int count = 0; + String filterVal = ""; + for (String keyddlword : keywords) { + if (val.toLowerCase().contains(keyddlword)) { + count++; + if (count == 1) { + filterVal = keyddlword; + } + } + } + + if (count > 2) { + return filterVal; + } +// value = SecurityUtil.ecodeForSql(value); + + return value; + } + + /** + * 压缩工具类- + * + * @param str + * @return desc:version 0.0.1 基于jdk自带 GZIP 压缩。最后转成base64。 + * 市面上有其他压缩像jdk 的 deflate 可以设置压缩级别,但是都是主动的,需要改业务方法, + * snappy 压缩适用于大数据压缩。大数据量比较快 hadoop首选,但是压缩后比例比较大。 + * xz 下的 压缩比率大,但是解压比较慢-不提倡,空间换时间了 + * common下的压缩其实和jdk差不多,网上说优于jdk,但是相差不大。 + * weaver 压缩基于jdk + */ + public static String compress(String str) { + if (str == null || str.trim().length() == 0) { + return str; + } + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out)) { + gzip.write(str.getBytes()); + gzip.close(); + return Base64.getEncoder().encodeToString(out.toByteArray()); + } catch (Exception e) { + logger.error("压缩失败", e.getMessage()); + return str; + } + + } + + + /** + * 解压缩 + * + * @param str + * @return + */ + public static String uncompress(String str) { + byte[] decode = Base64.getDecoder().decode(str); + if (str == null || str.trim().length() == 0) { + return str; + } + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(decode)) { + GZIPInputStream ungzip = new GZIPInputStream(in); + byte[] buffer = new byte[2048]; + int n; + while ((n = ungzip.read(buffer)) >= 0) { + out.write(buffer, 0, n); + } + return new String(out.toByteArray()); + } catch (Exception e) { + logger.error("解缩失败:{}", e.getMessage()); + return str; + } + } + + public static Boolean checkIsNumber(Object obj) { + if (obj == null) { + return false; + } + + return StringUtils.isNumeric(obj.toString()); + + } +} diff --git a/src/com/engine/salary/elog/util/ElogUtils.java b/src/com/engine/salary/elog/util/ElogUtils.java new file mode 100644 index 0000000..38edd82 --- /dev/null +++ b/src/com/engine/salary/elog/util/ElogUtils.java @@ -0,0 +1,713 @@ +package com.engine.salary.elog.util; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.enums.FromTerminalType; +import com.engine.salary.elog.threadlocal.ElogThreadLocal; +import org.apache.commons.lang3.StringUtils; +import org.apache.dubbo.common.utils.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +/** + * @ClassName: ElogUtils + * @Description TODO + * @Author tanghj + * @Date 2021/3/12 14:17 + */ +@Component +public class ElogUtils { + + private static final Logger logger = LoggerFactory.getLogger(ElogUtils.class); + + + + private static final String TABLE_SPACER = "_"; + private static final String TABLE_SUFFIX = "logs"; + private static final String DETAIL_TABLE_SUFFIX = "_detail"; + public static final String BASE_TABLE = "BASE_ELOG_TABLE"; + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + +// @Value("${spring.application.name}") + public static String applicationName; + + + + public static String getTableName(String module, String function) { + return getTableName(module, function, false); + } + + public static String getTableName(String module, String function, boolean isDetail) { + String tablename = module + TABLE_SPACER + function + TABLE_SUFFIX + (isDetail ? DETAIL_TABLE_SUFFIX : ""); +// SecurityUtil.sqlCheck(tablename); + return tablename; + } + + /** + * String 转枚举 + * + * @param c + * @param string + * @param + * @return + */ + public static > T getEnumFromString(Class c, String string) { + if (c != null && string != null) { + try { + return Enum.valueOf(c, string.trim().toUpperCase()); + } catch (IllegalArgumentException ex) { + } + } + return null; + } + + /** + * 获取ip地址 + * + * @param request + * @return + */ + public static String getIp(HttpServletRequest request) { + String ipAddress = request.getHeader("x-forwarded-for"); + String unknown = "unknown"; + if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("WL-Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) { + ipAddress = request.getRemoteAddr(); + String benji = "127.0.0.1"; + String bj = "0:0:0:0:0:0:0:1"; + if (benji.equals(ipAddress) || bj.equals(ipAddress)) { + ///根据网卡取本机配置的IP + InetAddress inet = null; + try { + inet = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + logger.error("UnknownHostException", e); + } + if (inet != null) { + ipAddress = inet.getHostAddress(); + } + } + } + ///对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 + int i = 15; + String s = ","; + if (ipAddress != null && ipAddress.length() > i) { + if (ipAddress.indexOf(s) > 0) { + ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); + } + } + return ipAddress; + } + + /** + * 获取设备信息 + * + * @param request + * @return + */ + public static String getDevice(HttpServletRequest request) { + return request.getHeader("User-Agent"); + } + + /** + * 获取来自终端的信息 + * + * @param context + * @param request + * @return + */ + public static void getFromTerminal(LoggerContext context, HttpServletRequest request) { + String fromTerminal = context.getFromTerminal(); + if (StringUtils.isEmpty(fromTerminal)) { + String device = getDevice(request); + String setFT = ""; + if (StringUtils.isNotEmpty(device)) { + context.setFromTerminal(getFromTerminal(device)); + } + } + } + + public static void initRequestInfo(HttpServletRequest request, LoggerContext context) { + if (StringUtils.isEmpty(context.getRequestUrl())) { + context.setRequestUrl(getRequestUrl(request)); + } + if (StringUtils.isEmpty(context.getRequestUri())) { + context.setRequestUri(getRequestMethod(request) + ":" + getRequestUri(request)); + } + //if (context.getParams() == null) { + //默认记录params,此参数给true时 或报表服务,不记录 + if (!context.getParamsIgnore() && !applicationName.equalsIgnoreCase("weaver-edcreportd-service")) { + context.setParams(getRequstParam(request,context)); + } + // } + if (StringUtils.isEmpty(context.getClientIp())) { + context.setClientIp(getIp(request)); + } + if (StringUtils.isEmpty(context.getDevice())) { + context.setDevice(getDevice(request)); + } + if (StringUtils.isEmpty(context.getFromTerminal())) { + context.setFromTerminal(getFromTerminal(getDevice(request))); + } + if (StringUtils.isEmpty(context.getBelongMainId())) { + context.setBelongMainId(getTraceId(request)); + } + + } + + private static String getTraceId(HttpServletRequest request) { + String traceId = request.getHeader("traceId"); + if (StringUtils.isNotBlank(traceId)) { + //System.out.println("traceId:====="+traceId); + return traceId; + } + return ""; + } + + /** + * @param request + * @return localhost:9080/api/fs/demo/updateReport + */ + public static String getRequestUrl(HttpServletRequest request) { + if (Objects.isNull(request) || Objects.isNull(request.getRequestURL())) { + return null; + } + return request.getRequestURL().toString(); + } + + /** + * @param request + * @return /api/fs/demo/updateReport + */ + public static String getRequestUri(HttpServletRequest request) { + return request.getRequestURI(); + } + + /** + * @param request + * @return GET/POST + */ + public static String getRequestMethod(HttpServletRequest request) { + return request.getMethod(); + } + + public static Map getRequstParam(HttpServletRequest request, LoggerContext context) { + return request2Map(request, context); + } + + /** + * 获取当前方法中的日志实体类 + * + * @return + */ + public static LoggerContext currentElogContext() { + return ElogThreadLocal.currentLoggerContext(); + } + + public static Map request2Map(HttpServletRequest request, LoggerContext context) { + // 参数Map + Map properties = request.getParameterMap(); + // 返回值Map + Map returnMap = new HashMap(); + Iterator entries = properties.entrySet().iterator(); + Map.Entry entry; + String name = ""; + Object value = null; + while (entries.hasNext()) { + entry = (Map.Entry) entries.next(); + name = (String) entry.getKey(); + Object valueObj = entry.getValue(); + if (null == valueObj) { + value = null; + } else if (valueObj instanceof String[]) { + String[] values = (String[]) valueObj; + if (values.length == 1) { + value = values[0]; + } else { + value = values; + } + } else { + value = valueObj.toString(); + } + returnMap.put(name, value); + } + //放入ip + returnMap.put("param_ip", getIp(request)); + returnMap.put("request_header_user_agent", request.getHeader("user-agent")); + JSONObject body = ElogThreadLocal.getRequestBody(); + if (body != null) { +// returnMap.put("request_body", body); + setReturnMapBody(returnMap,context.getParamsBodyKeys(),body); + } + return returnMap; + } + + public static void setReturnMapBody(Map returnMap,List keys,JSONObject body) { + //模块没设置则全部记录 + if (CollectionUtils.isEmpty(keys)) { + returnMap.put("request_body", body); + }else { + JSONObject newBody = new JSONObject(); + for (String key : keys) { + newBody.put(key,body.get(key)); + } + returnMap.put("request_body", newBody); + } + } + + public static int getIntValue(String v) { + return getIntValue(v, -1); + } + + public static int getIntValue(String v, int def) { + try { + return Integer.parseInt(v); + } catch (Exception var3) { + return def; + } + } + + public static long getLongValue(String v) { + return getLongValue(v, -1l); + } + + public static long getLongValue(String v, long def) { + try { + return Long.parseLong(v); + } catch (Exception var3) { + return def; + } + } + + + /** + * 将对象转换程字符串 + * + * @param obj 目标对象 + * @param def 如果为null时的默认值 + * @return + */ + public static String null2String(Object obj, String def) { + return obj == null ? def : obj.toString(); + } + + public static String null2String(Object obj) { + return null2String(obj, ""); + } + + public static int getIntValue(Object obj, int def) { + try { + return Integer.parseInt(null2String(obj)); + } catch (Exception ex) { + return def; + } + } + +// public static Page getPage() { +// HttpServletRequest request = getRequest(); +// String num = request.getParameter("pageNum"); +// String size = request.getParameter("pageSize"); +// +// Page page = new Page(ElogUtils.getIntValue(num, 1), ElogUtils.getIntValue(size, 10)); +// return page; +// } + +// public static void main(String[] args) { +// //System.out.println(getTableName("select", "from")); +// //DataTypeEnum columnTypeEnum = getEnumFromString(DataTypeEnum.class, "varchar"); +// } + + public static List switchString(List list) { + if (list != null) { + return list.stream().map(m -> { + Set en = m.entrySet(); + for (Map.Entry entry : en) { + if (entry.getValue() != null) { + entry.setValue(String.valueOf(entry.getValue())); + } + } + return m; + }).collect(Collectors.toList()); + } else { + return list; + } + } + + public static List switchComplexString(List list) { + if (list != null) { + return list.stream().map(m -> { + Iterator iterator = m.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry next = iterator.next(); + if (next.getValue() != null) { + if (next.getValue() instanceof Map && "parmas".equals(next.getKey())) { + next.setValue(String.valueOf(next.getValue())); + } + if (next.getValue() instanceof List) { + } else { + next.setValue(String.valueOf(next.getValue())); + } + } + } + return m; + }).collect(Collectors.toList()); + } else { + return list; + } + } + + /** + * 获取rpc信息(客户端ip和来源设备) + * + * @param context + */ + public static void initRpcInfo(LoggerContext context) { + User user = context.getUser(); + if(user == null){ + return; + } + String device = user.getLogintype(); + String clientIp = user.getLoginip(); + String traceId = ""; + if (StringUtils.isEmpty(context.getDevice()) && StringUtils.isNotEmpty(device)) { + context.setDevice(device); + } + if (StringUtils.isEmpty(context.getFromTerminal()) && StringUtils.isNotEmpty(device)) { + context.setFromTerminal(getFromTerminal(device)); + } + + if (StringUtils.isEmpty(context.getClientIp()) && StringUtils.isNotEmpty(clientIp)) { + context.setClientIp(clientIp); + } + if (StringUtils.isEmpty(context.getBelongMainId()) && StringUtils.isNotEmpty(traceId)) { + context.setBelongMainId(traceId); + } + } + + public static String getFromTerminal(String device) { + String setFT = ""; + if (StringUtils.isNotEmpty(device)) { + if (!device.contains("wxwork") && device.contains("MicroMessenger")) {//来自微信 + setFT = FromTerminalType.MICO_MSG.getCode(); + } else if (device.contains("wxwork") && device.contains("MicroMessenger")) {//企业微信 + setFT = FromTerminalType.WECHAT.getCode(); + } else if (device.contains("iPhone") && device.contains("Mac")) {//来自 Iphone + setFT = FromTerminalType.IOS.getCode(); + } else if (device.contains("Mac OS") && !device.contains("iPhone") && device.contains("weapp-pc")) {//来自 mac_client + setFT = FromTerminalType.MAC_CLIENT.getCode();//mac_client + } else if (!device.contains("wxwork") && device.contains("Mobile")) {//移动端 + setFT = FromTerminalType.H5.getCode(); + } else if (device.contains("Android") && !device.contains("wxwork")) {//来自安卓 包含安卓并且不包含微信 + setFT = FromTerminalType.ANDROID.getCode(); + } else {//pc + setFT = FromTerminalType.PC.getCode(); + } + } + return setFT; + } + + /** + * sql连接条件注入sql + * + * @param condition + * @return + */ + public static String checkConditionSql(String condition) { + if ("AND".equalsIgnoreCase(condition) || + "OR".equalsIgnoreCase(condition) + ) { + return condition; + } + return "AND"; + } + + public static String checkTypeSql(String type) { + if ("LIKE".equalsIgnoreCase(type) || + "IN".equalsIgnoreCase(type) || + "!<>".equalsIgnoreCase(type) || + "!=".equalsIgnoreCase(type) || + "BETWEEN".equalsIgnoreCase(type) || + "IS NULL".equalsIgnoreCase(type) || + "IS NULL".equalsIgnoreCase(type) || + "=".equalsIgnoreCase(type) || + "IS NOT NULL".equalsIgnoreCase(type)) { + return type; + } + return "="; + } + + /** + * sql条件防止注入 + * + * @param value + * @return + */ + public static String checkValSql(String value) { + Pattern p = Pattern.compile("\\s+"); + Matcher m = p.matcher(value); + String val = m.replaceAll(" "); + String[] keywords = {"master", "truncate", "declare", "alert", "create", "drop", "version", + "show", "table", "index", "insert", "into", "from", + "insert", "select", "delete", "update", "chr", "mid", "master", "truncate", "char", "declare", "union"}; + + + int count = 0; + String filterVal = ""; + for (String keyddlword : keywords) { + if (val.toLowerCase().contains(keyddlword)) { + count++; + if (count == 1) { + filterVal = keyddlword; + } + } + } + + if (count > 2) { + return filterVal; + } +// value = SecurityUtil.ecodeForSql(value); + + return value; + } + + /** + * 压缩工具类- + * + * @param str + * @return desc:version 0.0.1 基于jdk自带 GZIP 压缩。最后转成base64。 + * 市面上有其他压缩像jdk 的 deflate 可以设置压缩级别,但是都是主动的,需要改业务方法, + * snappy 压缩适用于大数据压缩。大数据量比较快 hadoop首选,但是压缩后比例比较大。 + * xz 下的 压缩比率大,但是解压比较慢-不提倡,空间换时间了 + * common下的压缩其实和jdk差不多,网上说优于jdk,但是相差不大。 + * weaver 压缩基于jdk + */ + public static String compress(String str) { + if (str == null || str.trim().length() == 0) { + return str; + } + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + GZIPOutputStream gzip = new GZIPOutputStream(out)) { + gzip.write(str.getBytes()); + gzip.close(); + return Base64.getEncoder().encodeToString(out.toByteArray()); + } catch (Exception e) { + logger.error("压缩失败", e.getMessage()); + return str; + } + + } + + + /** + * 解压缩 + * + * @param str + * @return + */ + public static String uncompress(String str) { + byte[] decode = Base64.getDecoder().decode(str); + if (str == null || str.trim().length() == 0) { + return str; + } + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + ByteArrayInputStream in = new ByteArrayInputStream(decode)) { + GZIPInputStream ungzip = new GZIPInputStream(in); + byte[] buffer = new byte[2048]; + int n; + while ((n = ungzip.read(buffer)) >= 0) { + out.write(buffer, 0, n); + } + return new String(out.toByteArray()); + } catch (Exception e) { + logger.error("解缩失败:{}", e.getMessage()); + return str; + } + } + + public static LoggerContext getEsField(LoggerContext context, String field) { + + switch (field.toLowerCase()) { + case "interfacename": + context.setInterfaceName(""); + break; + case "operatetype": + context.setOperateType(""); + break; + case "operatedesc": + context.setOperatedesc(""); + break; + case "params": + context.setParamsStr("ES"); + break; + case "clientip": + context.setClientIp(""); + break; + case "groupnamelabel": + context.setGroupNameLabel(""); + break; + case "redoservice": + context.setRedoService(""); + break; + case "redocontext": + context.setRedoContextStr(""); + break; + case "cancelservice": + context.setCancelService(""); + break; + case "cancelcontext": + context.setCancelContextStr(""); + break; + case "device": + context.setDevice(""); + break; + case "groupid": + context.setGroupId(""); + break; + case "belongmainid": + context.setBelongMainId(""); + break; + case "requesturl": + context.setRequestUrl(""); + break; + case "requesturi": + context.setRequestUri(""); + break; + case "log_result": + context.setResult(""); + break; + case "fromterminal": + context.setFromTerminal(""); + break; + case "resultdesc": + context.setResultDesc(""); + break; + case "old_content": + context.setOld_content(""); + break; + case "link_type": + context.setLink_type(""); + break; + } + + return context; + } + + public static String[] getESfields(String value) { + String[] split = value.split(","); + List list = new ArrayList<>(); + for (String s : split) { + switch (s.toLowerCase()) { + case "interfacename": + list.add("interfacename"); + break; + case "operatetype": + list.add("operatetype"); + break; + case "operatedesc": + list.add("operatedesc"); + break; + case "params": + list.add("params"); + break; + case "clientip": + list.add("clientip"); + break; + case "groupnamelabel": + list.add("groupnamelabel"); + break; + case "redoservice": + list.add("redoservice"); + break; + case "redocontext": + list.add("redocontext"); + break; + case "cancelservice": + list.add("cancelservice"); + break; + case "cancelcontext": + list.add("cancelcontext"); + break; + case "device": + list.add("device"); + break; + case "groupid": + list.add("groupid"); + break; + case "belongmainid": + list.add("belongmainid"); + break; + case "requesturl": + list.add("requesturl"); + break; + case "requesturi": + list.add("requesturi"); + break; + case "log_result": + list.add("logResult"); + break; + case "fromterminal": + list.add("fromterminal"); + break; + case "resultdesc": + list.add("resultdesc"); + break; + case "old_content": + list.add("oldContent"); + break; + case "link_type": + list.add("linkType"); + break; + } + } + //list转为数组 + if (list.size() > 0) { + String[] strings = list.toArray(new String[list.size()]); + return strings; + } + return null; + } + + public static String handleClobColumn(String value) { + // 处理超长字符串,oracle插入报错ORA-01704: string literal too long + if (StringUtils.isBlank(value)){ + return ""; + } + StringBuilder formatValue = new StringBuilder(); + String[] split = StrUtil.split(value, 1000); + for (int i = 0; i < split.length; i++) { + formatValue.append("TO_CLOB('").append(split[i]).append("')"); + if (i != split.length - 1) { + formatValue.append("||"); + } + } + return formatValue.toString(); + } + +} diff --git a/src/com/engine/salary/elog/util/FieldNameMap.java b/src/com/engine/salary/elog/util/FieldNameMap.java new file mode 100644 index 0000000..dcde025 --- /dev/null +++ b/src/com/engine/salary/elog/util/FieldNameMap.java @@ -0,0 +1,94 @@ +package com.engine.salary.elog.util; + +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName: FieldNameMap + * @Description TODO + * @Author tanghj + * @Date 2021/3/31 14:27 + */ +public class FieldNameMap { + + private static Map mainFieldNameMap = new HashMap<>(); + + private static Map detailFieldNameMap = new HashMap<>(); + + private static Map> mainCusFieldNameMap = new HashMap<>(); + + private static Map> detailCusFieldNameMap = new HashMap<>(); + + + public static void setMainFieldName(Map fieldNameMap) { + mainFieldNameMap.putAll(fieldNameMap); + } + + public static void setDetailFieldName(Map fieldNameMap) { + detailFieldNameMap.putAll(fieldNameMap); + } + + public static void setMainCusFieldName(String module, String function, Map fieldNameMap) { + mainCusFieldNameMap.put(getKey(module, function), fieldNameMap); + } + + public static void setDetailCusFieldName(String module, String function, Map fieldNameMap) { + detailCusFieldNameMap.put(getKey(module, function), fieldNameMap); + } + + + public static String getMainFieldNameMap(String module, String function, String key) { + + String str = key.toLowerCase(); + if(mainFieldNameMap.containsKey(str)) { + return StringUtils.isNotEmpty(mainFieldNameMap.get(str)) ? mainFieldNameMap.get(str) : key; + } else { + return getMainCusFieldNameMap(module, function,key); + } + } + + public static String getDetailFieldNameMap(String module, String function, String key) { + key = key.toLowerCase(); + if(detailFieldNameMap.containsKey(key)) { + return StringUtils.isNotEmpty(detailFieldNameMap.get(key)) ? detailFieldNameMap.get(key) : key; + } else { + return getDetailCusFieldNameMap(module, function, key); + } + } + + public static String getMainCusFieldNameMap(String module, String function, String key) { + + if(mainCusFieldNameMap.containsKey(getKey(module, function))) { + if(mainCusFieldNameMap.get(getKey(module, function)).containsKey(key)) { + return StringUtils.isNotEmpty(mainCusFieldNameMap.get(getKey(module, function)).get(key)) ? + mainCusFieldNameMap.get(getKey(module, function)).get(key) : + key; + } else { + return key; + } + } else { + return key; + } + } + + public static String getDetailCusFieldNameMap(String module, String function, String key) { + + if(detailCusFieldNameMap.containsKey(getKey(module, function))) { + if(detailCusFieldNameMap.get(getKey(module, function)).containsKey(key)) { + return StringUtils.isNotEmpty(detailCusFieldNameMap.get(getKey(module, function)).get(key)) ? + detailCusFieldNameMap.get(getKey(module, function)).get(key) : + key; + } else { + return key; + } + } else { + return key; + } + } + + private static String getKey(String module, String function) { + return module + "@" + function; + } +} diff --git a/src/com/engine/salary/elog/util/LoggerTemplate.java b/src/com/engine/salary/elog/util/LoggerTemplate.java new file mode 100644 index 0000000..508a861 --- /dev/null +++ b/src/com/engine/salary/elog/util/LoggerTemplate.java @@ -0,0 +1,631 @@ +package com.engine.salary.elog.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.Feature; +import com.alibaba.fastjson.serializer.SerializerFeature; + +import com.engine.salary.elog.annotation.ElogTransform; +import com.engine.salary.elog.async.LoggerMessageListener; +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.entity.dto.LoggerDetailContext; +import com.engine.salary.elog.entity.dto.TableChangeBean; +import com.engine.salary.elog.util.db.IdGenerator; +import com.engine.salary.elog.util.db.IdGenerator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.hrm.User; + +import java.lang.reflect.Field; +import java.util.*; + +/** + * @ClassName: LoggerTemplate + * @Description 日志基本功能类 + * @Author tanghj + * @Date 2021/2/10 14:18 + */ +//@Component +public class LoggerTemplate { + protected String function = "common"; + + protected String module; + + protected String logCenterQueue = "Elog_cneterlogQueue"; + + public static final String AUDITLOGQUEUE = "AuditLog"; + public static final String ELOG = "Elog"; + + protected String localQueue; + + protected String moduleName; + + protected static String applicationName; + + public void setApplicationName(String applicationName) { + LoggerTemplate.applicationName = applicationName; + } + + public String getApplicationName() { + return applicationName; + } + + private static final Logger logger = LoggerFactory.getLogger(LoggerTemplate.class); + + protected static String publishkitGroup; + + public void setPublishkitGroup(String publishkitGroup) { + LoggerTemplate.publishkitGroup = publishkitGroup; + } + + public String getPublishkitGroup() { + return publishkitGroup; + } + + + LoggerMessageListener loggerMessageListener = new LoggerMessageListener(); + + /** + * 写入日志消息队列 + * + * @param context 日志实体 + */ + public void write(LoggerContext context) { + this.write(context, true); + } + + /** + * 写入日志消息队列 + * + * @param context 日志实体 + * @param isLocal true 存储本地, false不存储本地 + */ + public void write(LoggerContext context, boolean isLocal) { + String elogLocalQueue = ELOG + this.applicationName; + if (StringUtils.isEmpty(this.localQueue)) + this.localQueue = (StringUtils.isNotEmpty(this.moduleName) ? this.moduleName : elogLocalQueue) + "LocalQueue" + this.publishkitGroup; + try { + handleContext(context); + } catch (Exception e) { + logger.error("handleContext方法异常!{}", e.getMessage(), e); + } + loggerMessageListener.receiveold(context); + + } + +// public void writeLocal(LoggerContext context){ +// String elogLocalQueue = ELOG + this.applicationName; +// if(StringUtils.isEmpty(this.localQueue)) +// this.localQueue = (StringUtils.isNotEmpty(this.moduleName) ? this.moduleName : elogLocalQueue) + "LocalQueue" + this.publishkitGroup; +// AsyncBean asyncBean = new AsyncBean<>(); +// handleContext(context); +// if (context.getWeakElogReocrd() && CollectionUtils.isEmpty(context.getDetailContexts() )) { +// logger.info("日志弱控且没有明细记录,不记录日志,modulename:{},functionname:{}",context.getModuleName(),context.getFunctionName()); +// return; +// } +// +// try { +// asyncBean.setMessage(context); +// asyncBean.setQueue(localQueue); +// asyncClient.send(asyncBean); +// } catch (Exception e) { +// logger.error("发送writeLocal-mq消息异常!{}",e.getMessage(),e); +// } +// } + + +// public void checkAsyncBean(AsyncBean asyncBean) { +// int length = JSON.toJSON(asyncBean).toString().getBytes(StandardCharsets.UTF_8).length / 1000; +// boolean checkPass = length <= 5120; +// if (!checkPass) +// throw new RuntimeException("消息体超出5M,不支持发送!"); +// } + +// /** +// * 没有明细变化可以不写入日志 +// * @param context 日志信息 +// * @param isLocal 是否写入本地 +// * @param notChangeDetailSendLog 没有明细变化不写入日志 +// */ +// public void write(LoggerContext context, boolean isLocal,boolean notChangeDetailSendLog){ +// String elogLocalQueue = ELOG + this.applicationName; +// if(StringUtils.isEmpty(this.localQueue)) +// this.localQueue = (StringUtils.isNotEmpty(this.moduleName) ? this.moduleName : elogLocalQueue) + "LocalQueue"; +// AsyncBean asyncBean = new AsyncBean<>(); +// handleContext(context); +// +// if (notChangeDetailSendLog && (context.getDetailContexts() == null || context.getDetailContexts().size() == 0)) { +// return; +// } +// try { +// asyncBean.setMessage(context); +// asyncBean.setQueue(logCenterQueue); +// asyncClient.send(asyncBean); +// writeHrmLog(context); +// if(isLocal) { +// asyncBean.setQueue(localQueue); +// asyncClient.send(asyncBean); +// } +// } catch (Exception e) { +// logger.error("发送mq消息异常!{}",e.getMessage(),e); +// } +// +// } + +// /** +// * 支持了向其他模块服务发送业务日志 +// * @param context +// * @param isLocal +// * @param moduleName +// */ +// public void write(LoggerContext context, boolean isLocal, String moduleName){ +// +// if(StringUtils.isNotEmpty(moduleName)) { +// String localQueue = moduleName + "LocalQueue"; +// // context.setModuleName(moduleName); +// AsyncBean asyncBean = new AsyncBean<>(); +// handleContext(context); +// try { +// asyncBean.setMessage(context); +// asyncBean.setQueue(logCenterQueue); +// asyncClient.send(asyncBean); +// writeHrmLog(context); +// if(isLocal) { +// asyncBean.setQueue(localQueue); +// asyncClient.send(asyncBean); +// } +// } catch (Exception e) { +// logger.error("发送mq消息异常!:{}",e.getMessage()); +// } +// } else { +// write(context, isLocal); +// } +// +// } + +// public void writeHrmLog(LoggerContext context) { +// AsyncBean asyncBean = new AsyncBean<>(); +// handleContext(context); +// asyncBean.setMessage(context); +// //asyncBean.setTopic(WRITEAUDITLOGTOPIC); +// asyncBean.setQueue(AUDITLOGQUEUE); +// asyncClient.send(asyncBean); +// +// } + +// /** +// * 支持了向其他模块服务发送业务日志 +// * @param context +// * @param isLocal +// * @param moduleName +// */ +// public void write(LoggerContext context, boolean isLocal, String moduleName,String functionName,String queueName){ +// +// if (StringUtils.isNotEmpty(moduleName) && StringUtils.isNotEmpty(functionName)) { +// context.setModuleName(moduleName); +// context.setFunctionName(functionName); +// this.localQueue = queueName + "LocalQueue"; +// AsyncBean asyncBean = new AsyncBean<>(); +// handleContext(context); +// try { +// asyncBean.setMessage(context); +// asyncBean.setQueue(logCenterQueue); +// asyncClient.send(asyncBean); +// writeHrmLog(context); +// if (isLocal) { +// asyncBean.setQueue(localQueue); +// asyncClient.send(asyncBean); +// } +// } catch (Exception e) { +// logger.error("发送mq消息异常!,{}!",e); +// } +// } else { +// write(context, isLocal); +// } +// +// } + + private void handleContext(LoggerContext context) { + if (StringUtils.isEmpty(context.getModuleName())) + context.setModuleName(module); + if (StringUtils.isEmpty(context.getFunctionName())) + context.setFunctionName(function); + if (!(context.getId() > 0)) + context.setId(IdGenerator.generate()); + if (StringUtils.isEmpty(context.getUuid())) { + context.setUuid(UUID.randomUUID().toString().replace("-", "")); + } + + context.setTempParams(null); + String employeeId = Optional.ofNullable(context.getUser()).map(User::getUID).orElse(0).toString(); + String tenantKey = "all_teams"; + String userName = Optional.ofNullable(context.getUser()).map(User::getUsername).orElse("").toString(); + if (StringUtils.isEmpty(context.getOperator()) && StringUtils.isNotEmpty(employeeId)) { + context.setOperator(employeeId + ""); + } + if (StringUtils.isEmpty(context.getTenant_key()) && StringUtils.isNotEmpty(tenantKey)) { + context.setTenant_key(tenantKey); + } + if (StringUtils.isEmpty(context.getOperatorName()) && StringUtils.isNotEmpty(userName)) { + context.setOperatorName(userName); + } + //} + + if (StringUtils.isBlank(context.getOperator()) || "null".equals(context.getOperator())) { + context.setOperator("-1"); + } + if (StringUtils.isBlank(context.getTargetId()) || "null".equals(context.getTargetId())) { + context.setTargetId("-1"); + } + +// RequestAttributes requestAttributes = SalaryContext.get().getRequestAttributesSafely(); +// if ((requestAttributes instanceof ServletRequestAttributes)) { +// HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); +// ElogUtils.initRequestInfo(request, context); +// } else { +// if (StringUtils.isEmpty(context.getRequestUrl())) { +// context.setRequestUrl("非http请求"); +// } +// ElogUtils.initRpcInfo(context); +// } + ElogUtils.initRpcInfo(context); + + List changeBeans = context.getChangeValues(); + + List valueChangeList = new ArrayList<>(); + int showOrder = 0; + if (changeBeans != null) + for (TableChangeBean changeBean : changeBeans) { + if (changeBean != null && (changeBean.getNewValue() != null || changeBean.getOldValue() != null)) { + String uuid = UUID.randomUUID().toString().replace("-", ""); + ApiModel apiModel = null; + ElogTransform tableTransform = null; + JSONObject newJo = new JSONObject(); + JSONObject oldJo = new JSONObject(); + JSONObject valueChange = JSONObject.parseObject(JSONObject.toJSONString(changeBean, SerializerFeature.WriteDateUseDateFormat), Feature.OrderedField); + Field[] fields = null; + if (changeBean.getNewValue() != null) { + apiModel = changeBean.getNewValue().getClass().getAnnotation(ApiModel.class); + tableTransform = changeBean.getNewValue().getClass().getAnnotation(ElogTransform.class); + //fields = changeBean.getNewValue().getClass().getDeclaredFields(); + fields = getAllFields(changeBean.getNewValue().getClass()); + newJo = valueChange.getJSONObject("newValue"); + } else { + apiModel = changeBean.getOldValue().getClass().getAnnotation(ApiModel.class); + tableTransform = changeBean.getOldValue().getClass().getAnnotation(ElogTransform.class); + //fields = changeBean.getOldValue().getClass().getDeclaredFields(); + fields = getAllFields(changeBean.getOldValue().getClass()); + } + if (changeBean.getOldValue() != null) { + oldJo = valueChange.getJSONObject("oldValue"); + } + if ((apiModel != null || tableTransform != null) && fields != null) { + + for (Field field : fields) { + if (StringUtils.isEmpty(newJo.getString(field.getName())) && StringUtils.isEmpty(oldJo.getString(field.getName()))) { + continue; + } + if (StringUtils.isNotEmpty(newJo.getString(field.getName())) && newJo.getString(field.getName()).equals(oldJo.getString(field.getName()))) { + continue; + } + + ApiModelProperty apiModelProperty = field.getAnnotation(ApiModelProperty.class); + ElogTransform fieldElogTransform = field.getAnnotation(ElogTransform.class); + LoggerDetailContext valueChangeBean = new LoggerDetailContext(); + if (fieldElogTransform != null && fieldElogTransform.ignore()) { + continue; + } + + //todo 若analyticList为true 且 新旧值属于JSONArray 解析List + if (fieldElogTransform != null && fieldElogTransform.analyticList() && fieldElogTransform.analyticListClass() != void.class) { + analyticListMethod(field, newJo, oldJo, valueChangeList, fieldElogTransform); + continue; + } + + valueChangeBean.setUuid(uuid); + valueChangeBean.setTableName(tableTransform != null && StringUtils.isNotEmpty(tableTransform.name()) ? tableTransform.name() : changeBean.getTableName()); + valueChangeBean.setTableNameDesc(tableTransform != null && StringUtils.isNotEmpty(tableTransform.tablename()) ? tableTransform.tablename() : ""); + valueChangeBean.setTableNameLabelId(tableTransform != null && tableTransform.labelId() != -1 ? tableTransform.labelId() + "" : ""); + valueChangeBean.setIsDetail(changeBean.getIsDetail()); + valueChangeBean.setFieldName(field.getName()); + valueChangeBean.setFieldDesc(fieldElogTransform != null ? fieldElogTransform.name() : apiModelProperty != null ? apiModelProperty.value() : field.getName()); + valueChangeBean.setFieldNameLabelId(fieldElogTransform != null ? fieldElogTransform.labelId() + "" : "-1"); + valueChangeBean.setDataid(StringUtils.isNotEmpty(changeBean.getDataid()) ? changeBean.getDataid() : + StringUtils.isNoneEmpty(newJo.getString("id")) ? newJo.getString("id") : oldJo.getString("id")); + valueChangeBean.setBelongDataid(StringUtils.isNotEmpty(changeBean.getBelongDataid()) ? changeBean.getBelongDataid() : ""); + + valueChangeBean.setNewValue(newJo.getString(field.getName())); + valueChangeBean.setOldValue(oldJo.getString(field.getName())); + valueChangeBean.setCreator(-1l); + try { + extracted(newJo, oldJo, field, fieldElogTransform, valueChangeBean); + } catch (Exception e) { + logger.error("转换出错:{}", e); + //System.out.println("转换出错:" + e.getMessage()); + } + + + valueChangeBean.setShoworder(showOrder++); + valueChangeList.add(valueChangeBean); + } + } else { + Set keys = new HashSet<>(); + for (String key : (Set) newJo.keySet()) { + keys.add(key); + if (newJo.getString(key).equals(oldJo.getString(key))) { + continue; + } + LoggerDetailContext valueChangeBean = new LoggerDetailContext(); + valueChangeBean.setUuid(uuid); + valueChangeBean.setTableName(changeBean.getTableName()); + valueChangeBean.setIsDetail(changeBean.getIsDetail()); + valueChangeBean.setDataid(StringUtils.isNotEmpty(changeBean.getDataid()) ? changeBean.getDataid() : + StringUtils.isNoneEmpty(newJo.getString("id")) ? newJo.getString("id") : oldJo.getString("id")); + valueChangeBean.setBelongDataid(StringUtils.isNotEmpty(changeBean.getBelongDataid()) ? changeBean.getBelongDataid() : ""); + valueChangeBean.setFieldName(key); + valueChangeBean.setFieldDesc(key); + valueChangeBean.setNewValue(newJo.getString(key)); + valueChangeBean.setOldValue(oldJo.getString(key)); + valueChangeBean.setShoworder(showOrder++); + valueChangeBean.setCreator(-1l); + valueChangeList.add(valueChangeBean); + } + for (String key : (Set) oldJo.keySet()) { + if (keys.contains(key)) + continue; + keys.add(key); + if (oldJo.getString(key).equals(newJo.getString(key))) { + continue; + } + LoggerDetailContext valueChangeBean = new LoggerDetailContext(); + valueChangeBean.setTableName(changeBean.getTableName()); + valueChangeBean.setIsDetail(changeBean.getIsDetail()); + valueChangeBean.setFieldName(key); + valueChangeBean.setFieldDesc(key); + valueChangeBean.setNewValue(newJo.getString(key)); + valueChangeBean.setOldValue(oldJo.getString(key)); + valueChangeBean.setShoworder(showOrder++); + valueChangeBean.setCreator(-1l); + valueChangeList.add(valueChangeBean); + } + } + } + } + + if (valueChangeList.size() > 0) + context.setDetailContexts(valueChangeList); + } + + + private void analyticListMethod(Field field, JSONObject newJo, JSONObject oldJo, List valueChangeList, ElogTransform tableTransform) { + JSONArray newValueArr = newJo.get(field.getName()) == null ? new JSONArray() : (JSONArray) newJo.get(field.getName()); + JSONArray oldvalueArr = oldJo.get(field.getName()) == null ? new JSONArray() : (JSONArray) oldJo.get(field.getName()); + Field[] allFields = getAllFields(tableTransform.analyticListClass()); + + + Boolean oldvalueIsNull = false; + Boolean newvalueIsNull = false; + + if (oldvalueArr.size() == 0) { + oldvalueIsNull = true; + } + if (newValueArr.size() == 0) { + newvalueIsNull = true; + } + if ((oldvalueIsNull && newvalueIsNull) || (!oldvalueIsNull && !newvalueIsNull && oldvalueArr.size() != newValueArr.size())) { + //如果新、旧没值或新旧值list数量对不上 直接返回 + return; + } + + JSONArray foreachArr = oldvalueIsNull ? newValueArr : oldvalueArr; + + //遍历list + for (int i = 0; i < foreachArr.size(); i++) { + //默认另一个list关系是一一对应的 + JSONObject oldValue = oldvalueIsNull ? new JSONObject() : (JSONObject) oldvalueArr.get(i); + JSONObject newValue = newvalueIsNull ? new JSONObject() : (JSONObject) newValueArr.get(i); + + //dataid uuid showOrder + long dataid = IdGenerator.generate(); + String uuid = UUID.randomUUID().toString().replace("-", ""); + int showOrder = 0; + + //遍历字段 + for (Field allField : allFields) { + if (StringUtils.isEmpty(newValue.getString(allField.getName())) && StringUtils.isEmpty(oldValue.getString(allField.getName()))) { + continue; + } + if (StringUtils.isNotEmpty(newValue.getString(allField.getName())) && newValue.getString(allField.getName()).equals(oldValue.getString(allField.getName()))) { + continue; + } + + ApiModelProperty apiModelProperty = allField.getAnnotation(ApiModelProperty.class); + ElogTransform fieldElogTransform = allField.getAnnotation(ElogTransform.class); + LoggerDetailContext valueChangeBean = new LoggerDetailContext(); + + valueChangeBean.setUuid(uuid); + valueChangeBean.setTableName(tableTransform != null && StringUtils.isNotEmpty(tableTransform.name()) ? tableTransform.name() : field.getName()); + valueChangeBean.setTableNameDesc(tableTransform != null && StringUtils.isNotEmpty(tableTransform.tablename()) ? tableTransform.tablename() : ""); + valueChangeBean.setTableNameLabelId(tableTransform != null && tableTransform.labelId() != -1 ? tableTransform.labelId() + "" : ""); + valueChangeBean.setIsDetail(1); + valueChangeBean.setFieldName(allField.getName()); + valueChangeBean.setNewValue(newValue.getString(allField.getName())); + valueChangeBean.setOldValue(oldValue.getString(allField.getName())); + valueChangeBean.setCreator(-1l); + valueChangeBean.setBelongDataid(""); + valueChangeBean.setDataid(String.valueOf(dataid)); + + if (fieldElogTransform != null) { + if (fieldElogTransform.ignore()) { + continue; + } + + valueChangeBean.setFieldDesc(fieldElogTransform != null ? fieldElogTransform.name() : apiModelProperty != null ? apiModelProperty.value() : field.getName()); + valueChangeBean.setFieldNameLabelId(fieldElogTransform != null ? fieldElogTransform.labelId() + "" : "-1"); + + try { + extracted(newValue, oldValue, allField, fieldElogTransform, valueChangeBean); + } catch (Exception e) { + logger.error("转换出错", e); + //System.out.println("转换出错:" + e.getMessage()); + } + + valueChangeBean.setShoworder(showOrder++); + } else { + valueChangeBean.setFieldDesc(allField.getName()); + valueChangeBean.setShoworder(showOrder++); + + } + valueChangeList.add(valueChangeBean); + } + } + } + + private void extracted(JSONObject newJo, JSONObject oldJo, Field field, ElogTransform fieldElogTransform, LoggerDetailContext valueChangeBean) { + JSONObject jo = null; + if (fieldElogTransform != null && StringUtils.isNotEmpty(fieldElogTransform.valuesKVPairs())) { + jo = JSONObject.parseObject(fieldElogTransform.valuesKVPairs()); + if (jo != null) { + valueChangeBean.setNewRealValue(jo.getString(newJo.getString(field.getName()))); + valueChangeBean.setOldRealValue(jo.getString(oldJo.getString(field.getName()))); + } + } + } + + public void setModuleName(String moduleName) { + this.moduleName = moduleName; + } + + public void setLocalQueue(String localQueue) { + this.localQueue = localQueue; + } + + public String getFunction() { + return function; + } + + public void setFunction(String function) { + this.function = function; + } + + public String getModule() { + return module; + } + + /** + * 获取日志实体类 + * + * @return + */ + public LoggerContext getContext() { + + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUuid(UUID.randomUUID().toString().replace("-", "")); + loggerContext.setModuleName(this.module); + loggerContext.setFunctionName(this.function); + + return loggerContext; + + } + + public void setModule(String module) { + this.module = module; + } + +// public void setAsyncClient(AsyncClient asyncClient) { +// this.asyncClient = asyncClient; +// } + + + public static Field[] getAllFields(Class obj) { + Class superclass = obj.getSuperclass(); + Field[] superField = null; + //获取父类 + if (superclass != Object.class) { + superField = superclass.getDeclaredFields(); + } + //获取当前类 + Field[] nowfield = obj.getDeclaredFields(); + return addFields(superField, nowfield); + } + + public static Field[] addFields(Field[] superFields, Field[] fields) { + + return ArrayUtils.addAll(superFields, fields); + + } + + public void write(List context, boolean isLocal) { + context.forEach(loggerContext -> { + this.write(loggerContext, isLocal); + }); + } + + + public void write(List context) { + context.forEach(loggerContext -> { + this.write(loggerContext); + }); + } + +// public void writeAsync(LoggerContext context, boolean isLocal){ +// String applicationNameBak = this.applicationName; +// String localQueueBak = this.localQueue; +// String moduleNameBak = this.moduleName; +// String pk = this.publishkitGroup; +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// String localQueueBakBak = localQueueBak; +// String elogLocalQueue = ELOG + applicationNameBak; +// if(StringUtils.isEmpty(localQueueBakBak)) +// localQueueBakBak = (StringUtils.isNotEmpty(moduleNameBak) ? moduleNameBak : elogLocalQueue) + "LocalQueue" + pk; +// AsyncBean asyncBean = new AsyncBean<>(); +// handleContext(context); +// if (context.getWeakElogReocrd() && CollectionUtils.isEmpty(context.getDetailContexts() )) { +// logger.info("日志弱控且没有明细记录,不记录日志,modulename:{},functionname:{}",context.getModuleName(),context.getFunctionName()); +// return; +// } +// try { +// asyncBean.setMessage(context); +// asyncBean.setQueue(logCenterQueue); +// checkAsyncBean(asyncBean);//检查消息体大小 +// asyncClient.send(asyncBean); +// writeHrmLog(context); +// if(isLocal) { +// asyncBean.setQueue(localQueueBakBak); +// asyncClient.send(asyncBean); +// } +// } catch (Exception e) { +// logger.error("发送mq消息异常!{}",e.getMessage(),e); +// } +// } +// }; +// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "LoggerTemplate_writeAsync", localRunnable); +// +// } +// +// /** +// * 回滚队列 +// * +// * @param context +// */ +// public void writeRollBack(LoggerContext context){ +// String elogRollBackQueue = ELOG + this.applicationName + "RollBackQueue" + this.publishkitGroup; +// AsyncBean asyncBean = new AsyncBean<>(); +// +// try { +// asyncBean.setMessage(context); +// asyncBean.setQueue(elogRollBackQueue); +// checkAsyncBean(asyncBean);//检查消息体大小 +// asyncClient.send(asyncBean); +// } catch (Exception e) { +// logger.error("发送mq消息异常!{}",e.getMessage(),e); +// } +// } + +} diff --git a/src/com/engine/salary/elog/util/LoggerTemplateBuilder.java b/src/com/engine/salary/elog/util/LoggerTemplateBuilder.java new file mode 100644 index 0000000..14ae299 --- /dev/null +++ b/src/com/engine/salary/elog/util/LoggerTemplateBuilder.java @@ -0,0 +1,21 @@ +package com.engine.salary.elog.util; + +/** + * @ClassName: LoggerTemplateBuilder + * @Description 日志基本类构造器 + * @Author tanghj + * @Date 2021/2/10 14:18 + */ +public class LoggerTemplateBuilder { + + public static LoggerTemplate build(String module){ + return build(module, "common"); + } + public static LoggerTemplate build(String module, String function){ + LoggerTemplate loggerTemplate = new LoggerTemplate(); + loggerTemplate.setFunction(function); + loggerTemplate.setModule(module); + + return loggerTemplate; + } +} diff --git a/src/com/engine/salary/elog/util/ResponseResult.java b/src/com/engine/salary/elog/util/ResponseResult.java new file mode 100644 index 0000000..8b94e66 --- /dev/null +++ b/src/com/engine/salary/elog/util/ResponseResult.java @@ -0,0 +1,135 @@ +package com.engine.salary.elog.util; + + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * 请求执行器 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class ResponseResult { + + private static final long serialVersionUID = 1L; + + private final User user; + + public ResponseResult(User user) { + this.user = user; + } + + + /** + * 统一返回方法 + */ + public String run(Function f, T t) { + try { + return Ok(f.apply(t)); + } catch (RuntimeException e) { + log.error("salary api run fail , param {}", t, e); + return Error(e.getMessage()); + } catch (Exception e) { + log.error("salary api run fail , param {}", t, e); + return Error("系统异常!"); + } + } + + /** + * 统一返回方法(有参无返回) + */ + public String run(Consumer f, T t) { + try { + f.accept(t); + return Ok(); + } catch (RuntimeException e) { + log.error("salary api run fail , param {}", t, e); + return Error(e.getMessage()); + } catch (Exception e) { + log.error("salary api run fail , param {}", t, e); + return Error("系统异常!", e); + } + } + + + /** + * 统一返回方法(无参有返回) + */ + public String run(Supplier f) { + try { + return Ok(f.get()); + } catch (RuntimeException e) { + log.error("salary api run fail", e); + return Error(e.getMessage()); + } catch (Exception e) { + log.error("salary api run fail", e); + return Error("系统异常!", e); + } + } + + + private static String getJsonString(Object apidatas) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(apidatas); + } + + /** + * 成功返回 + */ + private String Ok() { + Map apidatas = new HashMap<>(); + apidatas.put("status", true); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + /** + * 成功返回 + */ + private String Ok(R r) throws JsonProcessingException { + Map apidatas = new HashMap<>(); + apidatas.put("status", true); + apidatas.put("data", r); + String success = getJsonString(apidatas); + return success; + } + + + /** + * 失败返回 + */ + private static String Error(String message) { + Map apidatas = new HashMap<>(); + apidatas.put("status", false); + apidatas.put("errormsg", message); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + /** + * 系统异常失败返回 + */ + private static String Error(String message, Exception e) { + Map apidatas = new HashMap<>(); + apidatas.put("status", false); + apidatas.put("errormsg", message); + apidatas.put("error", e.getMessage()); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + +} diff --git a/src/com/engine/salary/elog/util/SalaryI18nUtil.java b/src/com/engine/salary/elog/util/SalaryI18nUtil.java new file mode 100644 index 0000000..444c2c5 --- /dev/null +++ b/src/com/engine/salary/elog/util/SalaryI18nUtil.java @@ -0,0 +1,50 @@ +package com.engine.salary.elog.util; + +/** + * 多语言工具类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryI18nUtil { + + /** + * 获取多语言信息 + * + * @param labelId 多语言对应的labelId + * @param defaultLabel 默认中文 + * @return + */ + public static String getI18nLabel(int labelId, String defaultLabel) { + return defaultLabel; + } +// +// /** +// * 获取多语言信息 +// * +// * @param tenantKey 租户key +// * @param employeeId 人员id +// * @param labelId 多语言对应的labelId +// * @param defaultLabel 默认中文 +// * @return +// */ +// public static String getI18nLabel(String tenantKey, Long employeeId, int labelId, String defaultLabel) { +// int languageId = I18nLanguageUtil.getLangId(employeeId); +// return SalaryI18nUtil.getI18nLabel(labelId, languageId, tenantKey, defaultLabel); +// } +// +// /** +// * 获取多语言信息 +// * +// * @param simpleEmployee 租户信息 +// * @param labelId 多语言对应的labelId +// * @param defaultLabel 默认中文 +// * @return +// */ +// public static String getI18nLabel(DataCollectionEmployee simpleEmployee, int labelId, String defaultLabel) { +// int languageId = I18nLanguageUtil.getLangId(simpleEmployee.getEmployeeId()); +// return SalaryI18nUtil.getI18nLabel(labelId, languageId, simpleEmployee.getTenantKey(), defaultLabel); +// } +} diff --git a/src/com/engine/salary/elog/util/db/IdGenerator.java b/src/com/engine/salary/elog/util/db/IdGenerator.java new file mode 100644 index 0000000..0226fc6 --- /dev/null +++ b/src/com/engine/salary/elog/util/db/IdGenerator.java @@ -0,0 +1,46 @@ +package com.engine.salary.elog.util.db; + +import java.util.concurrent.atomic.AtomicLong; + +public class IdGenerator { + private static AtomicLong next = new AtomicLong(1L); + public static final int ID_LENGTH_36 = 36; + + public IdGenerator() { + } + + public static long generate() { + return System.currentTimeMillis() + next.getAndIncrement(); + } + + public static String generateId() { + return System.currentTimeMillis() + String.valueOf(next.getAndIncrement()); + } + + public static String generateStrId() { + return System.currentTimeMillis() + generateStrId(36); + } + + public static String generateStrId(int idLength) { + if (idLength >= 1 && idLength <= 36) { + char[] srcChars = new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'g', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + char[] chars = new char[idLength]; + + for(int i = 0; i < idLength; ++i) { + if (i != 8 && i != 13 && i != 18 && i != 23) { + if (i == 0) { + chars[i] = srcChars[(int)(Math.random() * 26.0D) % 26]; + } else { + chars[i] = srcChars[(int)(Math.random() * 36.0D) % 36]; + } + } else { + chars[i] = '_'; + } + } + + return new String(chars); + } else { + return ""; + } + } +} diff --git a/src/com/engine/salary/elog/util/db/MapperProxyFactory.java b/src/com/engine/salary/elog/util/db/MapperProxyFactory.java new file mode 100644 index 0000000..fed074d --- /dev/null +++ b/src/com/engine/salary/elog/util/db/MapperProxyFactory.java @@ -0,0 +1,79 @@ +/** + * + */ +package com.engine.salary.elog.util.db; + +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +/** + * mapper代理工厂 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class MapperProxyFactory implements InvocationHandler { + private Class clazz; + private boolean enableTransactions = false; + private SqlSession session; + + public MapperProxyFactory(Class clazz) { + this.clazz = clazz; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Exception { + this.session = MyBatisFactory.sqlSessionFactory.openSession(); + try { + Object target = session.getMapper(clazz); + return method.invoke(target, args); + } finally { + if (!enableTransactions) { + session.commit(); + session.close(); + } + } + } + + public Object getProxy() { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + Class[] interfaces = new Class[1]; + interfaces[0] = this.clazz; + return Proxy.newProxyInstance(loader, interfaces, this); + } + + public Object getProxy(boolean enableTransactions) { + this.enableTransactions = enableTransactions; + return this.getProxy(); + } + + public void commit() { + if (this.session != null) { + this.session.commit(); + this.session.close(); + } + } + + public void rollback() { + if (this.session != null) { + this.session.rollback(); + this.session.close(); + } + } + + public static T getProxy(Class clazz) { + MapperProxyFactory handle = new MapperProxyFactory(clazz); + return (T) handle.getProxy(); + } + + public static T getProxy(Class clazz, boolean enableTransactions) { + MapperProxyFactory handle = new MapperProxyFactory(clazz); + return (T) handle.getProxy(enableTransactions); + } +} diff --git a/src/com/engine/salary/elog/util/page/Column.java b/src/com/engine/salary/elog/util/page/Column.java new file mode 100644 index 0000000..df6f348 --- /dev/null +++ b/src/com/engine/salary/elog/util/page/Column.java @@ -0,0 +1,23 @@ +package com.engine.salary.elog.util.page; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Column { + String title; + String dataIndex; + String key; + boolean display; + + public Column(String title, String dataIndex, String key) { + this.title = title; + this.dataIndex = dataIndex; + this.key = key; + } +} diff --git a/src/com/engine/salary/elog/util/page/DataSource.java b/src/com/engine/salary/elog/util/page/DataSource.java new file mode 100644 index 0000000..d684473 --- /dev/null +++ b/src/com/engine/salary/elog/util/page/DataSource.java @@ -0,0 +1,9 @@ +package com.engine.salary.elog.util.page; + +import lombok.Data; + +@Data +public class DataSource { + String key; + String title; +} diff --git a/src/com/engine/salary/elog/util/page/PageInfo.java b/src/com/engine/salary/elog/util/page/PageInfo.java new file mode 100644 index 0000000..19d502d --- /dev/null +++ b/src/com/engine/salary/elog/util/page/PageInfo.java @@ -0,0 +1,62 @@ +package com.engine.salary.elog.util.page; + +import com.engine.salary.elog.util.page.Column; +import com.engine.salary.elog.util.page.DataSource; +import lombok.Data; +import lombok.ToString; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +@Data +@ToString +public class PageInfo extends com.github.pagehelper.PageInfo { + Class clazz; + + public void setColumns(List columns) { + this.columns.addAll(columns); + } + + List columns = new ArrayList<>(); + List dataSource = new ArrayList<>(); + + public PageInfo() { + } + + public PageInfo(Class clazz) { + this.clazz = clazz; + this.columns = buildColumns(); + } + + public PageInfo(List list) { + super(list); + } + + public PageInfo(List list, Class clazz) { + super(list); + this.clazz = clazz; + this.columns = buildColumns(); + } + + + public List buildColumns() { + if(clazz==null){ + return this.columns; + } + Field[] fields = clazz.getDeclaredFields(); + for (Field f : fields) { + boolean isanno = f.isAnnotationPresent(TableTitle.class); + if (isanno) { + TableTitle annotation = f.getAnnotation(TableTitle.class); + String title = annotation.title(); + String dataIndex = annotation.dataIndex(); + String key = annotation.key(); + boolean display = annotation.display(); + Column column = Column.builder().title(title).dataIndex(dataIndex).key(key).display(display).build(); + columns.add(column); + } + } + return columns; + } +} diff --git a/src/com/engine/salary/elog/util/page/SalaryPageUtil.java b/src/com/engine/salary/elog/util/page/SalaryPageUtil.java new file mode 100644 index 0000000..325df53 --- /dev/null +++ b/src/com/engine/salary/elog/util/page/SalaryPageUtil.java @@ -0,0 +1,117 @@ +package com.engine.salary.elog.util.page; + +import com.engine.salary.elog.util.page.PageInfo; +import com.github.pagehelper.PageHelper; +import org.apache.commons.collections4.CollectionUtils; + +import java.awt.*; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class SalaryPageUtil { + + public static void start(Integer pageNum, Integer pageSize) { + pageNum = pageNum == null || pageNum <= 0 ? 1 : pageNum; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + PageHelper.startPage(pageNum, pageSize); + } + + + public static com.engine.salary.elog.util.page.PageInfo buildPage(Integer pageNo, Integer pageSize) { + pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + com.engine.salary.elog.util.page.PageInfo pageInfo = new com.engine.salary.elog.util.page.PageInfo<>(); + pageInfo.setPageNum(pageNo); + pageInfo.setPageSize(pageSize); + pageInfo.setList(new ArrayList<>()); + return pageInfo; + } + + public static com.engine.salary.elog.util.page.PageInfo buildPage(Integer pageNo, Integer pageSize, Class clazz) { + pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + com.engine.salary.elog.util.page.PageInfo pageInfo = new com.engine.salary.elog.util.page.PageInfo<>(clazz); + pageInfo.setPageNum(pageNo); + pageInfo.setPageSize(pageSize); + pageInfo.setList(new ArrayList<>()); + return pageInfo; + } + + public static com.engine.salary.elog.util.page.PageInfo buildPage(Integer pageNo, Integer pageSize, List totalCollection) { + com.engine.salary.elog.util.page.PageInfo pageInfo = new com.engine.salary.elog.util.page.PageInfo<>(); + pageInfo.setTotal(totalCollection.size()); + totalCollection = subList(pageNo, pageSize, totalCollection); + pageInfo.setPageNum(pageNo); + pageInfo.setPageSize(pageSize); + pageInfo.setList(totalCollection); + return pageInfo; + } + + /** + * 内存分页 + * + * @param pageNo + * @param pageSize + * @param source + * @param clazz + * @param + * @return + */ + public static com.engine.salary.elog.util.page.PageInfo buildPage(Integer pageNo, Integer pageSize, List source, Class clazz) { + pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + com.engine.salary.elog.util.page.PageInfo pageInfo = new PageInfo<>(clazz); + pageInfo.setPageNum(pageNo); + pageInfo.setPageSize(pageSize); + pageInfo.setTotal(source == null ? 0 : source.size()); + pageInfo.setList(subList(pageNo, pageSize, source)); + return pageInfo; + } + + + /** + * 分页 + * + * @param pageNo 页码(从1开始) + * @param pageSize 每页条数 + * @param source 待分页的数据 + * @param 范型制定类 + * @return + */ + public static List subList(Integer pageNo, Integer pageSize, List source) { + if (CollectionUtils.isEmpty(source)) { + return Collections.emptyList(); + } + pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + int endIndex = pageNo * pageSize; + int startIndex = (pageNo - 1) * pageSize; + startIndex = startIndex < 0 ? 0 : startIndex; + return source.subList(startIndex > source.size() ? source.size() : startIndex, + endIndex > source.size() ? source.size() : endIndex); + } + + + static Font font = new Font("Arial", Font.PLAIN, 12); // 设置字体样式、大小等属性 + static FontRenderContext frc = new FontRenderContext(null, true, false); +// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + + /** + * 自适应文字长度 + * @param chars + * @param width + * @return + */ + public static String selfAdaption(String chars, Integer width) { + if (width != null && width != 0) { + return width + ""; + } + Rectangle2D bounds = font.getStringBounds(chars, frc); + int pxLength = (int) Math.ceil(bounds.getWidth()); + return pxLength + 55 + ""; + } +} diff --git a/src/com/engine/salary/elog/util/page/TableTitle.java b/src/com/engine/salary/elog/util/page/TableTitle.java new file mode 100644 index 0000000..ab98463 --- /dev/null +++ b/src/com/engine/salary/elog/util/page/TableTitle.java @@ -0,0 +1,13 @@ +package com.engine.salary.elog.util.page; + +import java.lang.annotation.*; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface TableTitle { + String title(); + String dataIndex(); + String key(); + boolean display() default true; +} diff --git a/src/com/engine/salary/elog/web/LoggerTableController.java b/src/com/engine/salary/elog/web/LoggerTableController.java new file mode 100644 index 0000000..da8e6a8 --- /dev/null +++ b/src/com/engine/salary/elog/web/LoggerTableController.java @@ -0,0 +1,200 @@ +package com.engine.salary.elog.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.elog.entity.param.ELogGetLogParam; +import com.engine.salary.elog.entity.param.GetDetailChangesParam; +import com.engine.salary.elog.service.ILoggerTableService; +import com.engine.salary.elog.service.impl.LoggerTableService; +import com.engine.salary.elog.util.ResponseResult; +import com.engine.salary.elog.util.page.PageInfo; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +public class LoggerTableController { + + private ILoggerTableService getLoggerTableService(User user) { + return ServiceUtil.getService(LoggerTableService.class, user); + } + + /** + * 获取日志 + * + * @param request + * @param response + * @param data + * @return + */ + @POST + @Path("/getLogs") + @Produces(MediaType.APPLICATION_JSON) + public String getLogs(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String data) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getLoggerTableService(user)::queryLogs, data); + } + + /** + * 获取日志(卡片) + * + * @param request + * @param response + * @param data + * @return + */ + @POST + @Path("/getCardLogs") + @Produces(MediaType.APPLICATION_JSON) + public String carddatas(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String data) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getLoggerTableService(user)::queryCardLogList, data); + } + + /** + * 获取单条操作记录的更新明细 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/getDetailChanges") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailChanges(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody GetDetailChangesParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getLoggerTableService(user)::getDetailChanges, param); + } +// @ApiOperation("获取单条操作记录的更新明细") +// @POST +// @Path("/getDetailChanges") +// @Produces(MediaType.APPLICATION_JSON) +// public String getDetailChanges(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String data) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult>>(user).run(getLoggerTableService(user)::getDetailChanges, data); +// } +// +// /** +// * 获取单条操作记录的更新明细(分页) +// * +// * @param module 服务(模块)名 +// * @param function 方法名 +// * @param mainid 主键id +// * @param detailTransMethod 转换方法 +// * @param current 页码 +// * @param pageSize 每页条数 +// * @return WeaTable +// */ +// @ApiOperation("获取单条操作记录的更新明细(分页)") +// @RequestMapping(path = "getDetailChangePages", method = {RequestMethod.GET, RequestMethod.POST}) +// @WeaPermission(publicPermission = true) +// public WeaResult getDetailChangePages(@PathVariable("module") @ApiParam("服务(模块)名") String module, +// @PathVariable("function") @ApiParam("方法名") String function, +// @RequestParam("mainid") @ApiParam("主键id") String mainid, +// @RequestParam("detailTransMethod") @ApiParam("转换方法") String detailTransMethod, +// @RequestParam("page") @ApiParam("页码") String current, +// @RequestParam("pageSize") @ApiParam("每页条数") String pageSize) { +// return WeaResult.success(getLoggerTableService(user).getDetailChangePages(module, function, mainid, detailTransMethod, current, pageSize)); +// } + + /** + * 获取日志列表 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/datas") + @Produces(MediaType.APPLICATION_JSON) + public String datas(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ELogGetLogParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getLoggerTableService(user)::queryLogList, param); + } + + +// @ApiOperation("获取日志总数") +// @RequestMapping(path = "counts", method = {RequestMethod.GET, RequestMethod.POST}) +// @WeaPermission(publicPermission = true) +// public WeaResult> counts(@PathVariable("module") @ApiParam("服务(模块)名") String module, +// @PathVariable("function") @ApiParam("方法名") String function) { +// return WeaResult.success(getLoggerTableService(user).countLog(module, function), "success"); +// } +// +// @ApiOperation("获取明细日志列表") +// @RequestMapping(path = "detaildatas", method = {RequestMethod.GET, RequestMethod.POST}) +// @WeaPermission(publicPermission = true) +// public WeaResult>> detaildatas(@PathVariable("module") @ApiParam("服务(模块)名") String module, +// @PathVariable("function") @ApiParam("方法名") String function, +// @Param("pageSize") @ApiParam("每页多少数据") String pageSize, +// @Param("current") @ApiParam("当前页") String current, +// @Param("mainId") @ApiParam("主表id") String mainId, +// @ApiParam("查询条件") String condition) { +// +// if ("datasecurity".equals(module) && "auditLog".equals(function)) { +// try { +// ILoggerTableService tableService = ApplicationContextProvider.getBean("auditLogService", ILoggerTableService.class); +// if (tableService != null) { +// List> list = tableService.queryDetailLogList(module, function, current, pageSize, condition, mainId); +// return WeaResult.success(list); +// } +// } catch (Exception e) { +// +// } +// } +// List> list = getLoggerTableService(user).queryDetailLogList(module, function, current, pageSize, condition, mainId); +// return WeaResult.success(list); +// } +// +// @ApiOperation("获取日志总数") +// @RequestMapping(path = "detailcounts", method = {RequestMethod.GET, RequestMethod.POST}) +// @WeaPermission(publicPermission = true) +// public WeaResult> detailcounts(@PathVariable("module") @ApiParam("服务(模块)名") String module, +// @PathVariable("function") @ApiParam("方法名") String function, +// @Param("mainId") @ApiParam("主表id") String mainId) { +// return WeaResult.success(getLoggerTableService(user).countDestailLog(module, function, mainId), "success"); +// } +// +// @ApiOperation("根据traceId获取链路列表") +// @RequestMapping(path = "queryLogTraceInfo", method = {RequestMethod.GET, RequestMethod.POST}) +// @WeaPermission(publicPermission = true) +// public WeaResult queryLogTraceInfo(@PathVariable("module") @ApiParam("服务(模块)名") String module, +// @PathVariable("function") @ApiParam("方法名") String function, +// @Param("traceId") @ApiParam("traceId") String traceId, +// @Param("currentPage") @ApiParam("currentPage") Integer currentPage, +// @Param("pageSize") @ApiParam("pageSize") Integer pageSize, +// @Param("traceTransMethod") @ApiParam("traceTransMethod") String traceTransMethod +// ) { +// +// if ("datasecurity".equals(module) && "auditLog".equals(function)) { +// try { +// ILoggerTableService tableService = ApplicationContextProvider.getBean("auditLogService", ILoggerTableService.class); +// if (tableService != null) { +// return WeaResult.success(tableService.queryElogTraceInfo(traceId, module, function, currentPage, pageSize, traceTransMethod), "success"); +// } +// } catch (Exception e) { +// +// } +// } +// +// return WeaResult.success(getLoggerTableService(user).queryElogTraceInfo(traceId, module, function, currentPage, pageSize, traceTransMethod), "success"); +// } +// +// @ApiOperation("日志下载") +// @RequestMapping(path = "downloadLog", method = {RequestMethod.GET, RequestMethod.POST}) +// @WeaPermission(publicPermission = true) +// public WeaResult downloadLog(@RequestBody(required = false) @ApiParam("数据") String data) { +// +// BatchDocumentMessage message = getLoggerTableService(user).downloadLog(data); +// return WeaResult.success(message); +// } +} diff --git a/src/com/engine/salary/mapper/elog/ElogTableCheckerMapper.java b/src/com/engine/salary/mapper/elog/ElogTableCheckerMapper.java new file mode 100644 index 0000000..c5547e7 --- /dev/null +++ b/src/com/engine/salary/mapper/elog/ElogTableCheckerMapper.java @@ -0,0 +1,30 @@ +package com.engine.salary.mapper.elog; + +import com.engine.salary.elog.entity.dto.TableColumnBean; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public interface ElogTableCheckerMapper { + Long getVersion(@Param("mainTable") String mainTable); + + void recordVersion(@Param("id") long id, @Param("mainTable") String mainTable, @Param("version") long version); + + void createMainTable(@Param("mainTable") String mainTable); + + void createDetailTable(@Param("detailTable") String detailTable); + + List getTableStructure(@Param("tableName") String tableName); + + void createElogTable(@Param("createElogSql") String createElogSql); + + Map getTableIndex(@Param("tableName") String tableName, @Param("columnName") String columnName); + + Map getDataBase(); + + void createTableIndex(@Param("tableName") String tableName, @Param("columnName") String columnName, @Param("id") long id); + + List getAllExistTables(@Param("tableNames") Set tables); +} diff --git a/src/com/engine/salary/mapper/elog/ElogTableCheckerMapper.xml b/src/com/engine/salary/mapper/elog/ElogTableCheckerMapper.xml new file mode 100644 index 0000000..3581e10 --- /dev/null +++ b/src/com/engine/salary/mapper/elog/ElogTableCheckerMapper.xml @@ -0,0 +1,451 @@ + + + + + insert into hrsa_elog_version (id, maintable, version) values (#{id},#{mainTable},#{version}) + + + + create table ${mainTable} + ( + id bigint comment 'ID', + create_time datetime default current_timestamp , + update_time datetime default current_timestamp , + creator bigint, + delete_type int, + tenant_key varchar(10), + uuid char(36), + log_date datetime default current_timestamp , + log_operator varchar(50), + operatorName varchar(50), + targetId varchar(50), + targetName text, + modulename varchar(100), + functionname varchar(100), + interfaceName varchar(100), + requesturl varchar(200), + requesturi varchar(200), + operateType varchar(50), + operatetypename varchar(100), + operatedesc varchar(1000), + params longtext, + belongmainid varchar(36), + clientIp varchar(50), + groupid varchar(50), + device varchar(200), + groupNameLabel varchar(500), + redoService varchar(200), + redoContext longtext, + cancelService varchar(200), + cancelContext longtext, + totalruntime bigint, + mainruntime bigint, + log_result varchar(100), + fromterminal varchar(100), + resultdesc text, + old_content varchar(1000), + link_type varchar(20), + link_id bigint, + old_link_id bigint, + PRIMARY KEY (id) + ) + + + + create table ${mainTable} + ( + id number(*,0) not null primary key, + create_time date default sysdate, + update_time date default sysdate, + creator number(*,0), + delete_type number(*,0), + tenant_key varchar2(10), + uuid varchar2(36), + log_date date default sysdate, + log_operator varchar2(50), + operatorName varchar2(50), + targetId varchar2(50), + targetName varchar2(4000), + modulename varchar2(100), + functionname varchar2(100), + interfaceName varchar2(100), + requesturl varchar2(200), + requesturi varchar2(200), + operateType varchar2(50), + operatetypename varchar2(100), + operatedesc varchar2(1000), + params clob, + belongmainid varchar2(36), + clientIp varchar2(200), + groupid varchar2(50), + device varchar2(200), + groupNameLabel varchar2(500), + redoService varchar2(200), + redoContext varchar2(4000), + cancelService varchar2(200), + cancelContext varchar2(4000), + totalruntime number(*,0), + mainruntime number(*,0), + log_result varchar2(4000), + fromterminal varchar2(100), + resultdesc varchar2(4000), + old_content varchar2(1000), + link_type varchar2(20), + link_id number(*,0), + old_link_id number(*,0) + ) + + + create table ${mainTable} + ( + id bigint not null primary key, + create_time datetime default getdate(), + update_time datetime default getdate(), + creator bigint default '-1', + delete_type bigint default 0, + tenant_key nvarchar(10), + uuid nvarchar(36), + log_date datetime default getdate(), + device nvarchar(500), + log_operator bigint default '-1', + operatorname nvarchar(100), + targetid bigint default '-1', + targetname nvarchar(3000), + modulename nvarchar(100), + functionname nvarchar(100), + interfacename nvarchar(100), + requesturl nvarchar(200), + requesturi nvarchar(200), + operatetype nvarchar(50), + operatetypename nvarchar(100), + operatedesc nvarchar(3000), + params nvarchar(max), + belongmainid nvarchar(36), + clientip nvarchar(200), + groupid nvarchar(50), + groupnamelabel nvarchar(1000), + redoservice nvarchar(200), + redocontext nvarchar(3000), + cancelservice nvarchar(200), + cancelcontext nvarchar(3000), + totalruntime bigint default 0, + mainruntime bigint default 0, + log_result nvarchar(100), + fromterminal nvarchar(100), + resultdesc nvarchar(3000), + old_content nvarchar(3000), + link_type nvarchar(20), + link_id bigint default 0, + old_link_id bigint default 0 + ) + + + create table ${mainTable} + ( + id int8 not null primary key, + create_time timestamp default current_timestamp, + update_time timestamp default current_timestamp, + creator int8, + delete_type int, + tenant_key varchar(10), + uuid varchar(36), + log_date timestamp default current_timestamp, + log_operator varchar(50), + operatorName varchar(50), + targetId varchar(50), + targetName text, + modulename varchar(100), + functionname varchar(100), + interfaceName varchar(100), + requesturl varchar(200), + requesturi varchar(200), + operateType varchar(50), + operatetypename varchar(100), + operatedesc varchar(1000), + params text, + belongmainid varchar(36), + clientIp varchar(200), + groupid varchar(50), + device varchar(200), + groupNameLabel varchar(500), + redoService varchar(200), + redoContext text, + cancelService varchar(200), + cancelContext text, + totalruntime int4, + mainruntime int4, + log_result varchar(100), + fromterminal varchar(100), + resultdesc text, + old_content varchar(1000), + link_type varchar(20), + link_id int4, + old_link_id int4 + ) + + + create table ${detailTable} + ( + id bigint not null primary key, + create_time datetime default current_timestamp , + update_time datetime default current_timestamp , + creator bigint, + delete_type int, + tenant_key varchar(10), + uuid varchar(36), + mainid varchar(36), + dataid varchar(50), + belongdataid varchar(50), + tableName varchar(200), + tablenamelabelid varchar(50), + tablenamedesc varchar(50), + fieldName varchar(200), + fieldnamelabelid varchar(200), + newValue longtext, + oldValue longtext, + newrealvalue longtext, + oldrealvalue longtext, + fieldDesc varchar(200), + showorder int default 0, + isdetail int default 0 + ) + + + create table ${detailTable} + ( + id int8 not null primary key, + create_time timestamp default current_timestamp , + update_time timestamp default current_timestamp , + creator int8, + delete_type int8, + tenant_key varchar(10), + uuid varchar(36), + mainid varchar(36), + dataid varchar(50), + belongdataid varchar(50), + tableName varchar(200), + tablenamelabelid varchar(50), + tablenamedesc varchar(50), + fieldName varchar(200), + fieldnamelabelid varchar(200), + newValue text, + oldValue text, + newrealvalue text, + oldrealvalue text, + fieldDesc varchar(200), + showorder int8 default 0, + isdetail int8 default 0 + ) + + + create table ${detailTable} + ( + id number(*,0) not null primary key, + create_time date default sysdate, + update_time date default sysdate, + creator number(*,0), + delete_type number(*,0), + tenant_key varchar2(10), + uuid varchar2(36), + mainid varchar2(36), + dataid varchar2(50), + belongdataid varchar2(50), + tableName varchar2(200), + tablenamelabelid varchar2(50), + tablenamedesc varchar2(50), + fieldName varchar2(200), + fieldnamelabelid varchar2(200), + newValue CLOB, + oldValue CLOB, + newrealvalue CLOB, + oldrealvalue CLOB, + fieldDesc varchar2(200), + showorder number(*,0) default 0, + isdetail number(*,0) default 0 + ) + + + create table ${detailTable} + ( + id bigint not null primary key, + create_time datetime default getdate(), + update_time datetime default getdate(), + creator bigint, + delete_type bigint, + tenant_key nvarchar(10), + uuid nvarchar(36), + mainid nvarchar(36), + dataid nvarchar(50), + belongdataid nvarchar(50), + tableName nvarchar(200), + tablenamelabelid nvarchar(50), + tablenamedesc nvarchar(50), + fieldName nvarchar(200), + fieldnamelabelid nvarchar(200), + newValue nvarchar(max), + oldValue nvarchar(max), + newrealvalue nvarchar(max), + oldrealvalue nvarchar(max), + fieldDesc varchar(200), + showorder bigint default 0, + isdetail bigint default 0 + ) + + + + + + + + + + + ${createElogSql} + + + + + + + + + + + + + + + + create index idx${id} on ${tableName} (${columnName}) + + + + create index idx${id} on ${tableName} (${columnName}) + + + + create index idx${id} on ${tableName} (${columnName}) + + + + + + + + + + diff --git a/src/com/engine/salary/mapper/elog/LocalElogAopDaoMapper.java b/src/com/engine/salary/mapper/elog/LocalElogAopDaoMapper.java new file mode 100644 index 0000000..eda527e --- /dev/null +++ b/src/com/engine/salary/mapper/elog/LocalElogAopDaoMapper.java @@ -0,0 +1,45 @@ +package com.engine.salary.mapper.elog; + + +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.entity.dto.LoggerDetailContext; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @ClassName: LocalElogAopDaoMapper + * @Description 本地操作日志持久层 + * @Author tanghj + * @Date 2021/2/24 9:35 + */ +public interface LocalElogAopDaoMapper { + + int insertElogContext(@Param(value="logContent") LoggerContext loggerContext, + @Param(value="cusColumns")String cusColumns , + @Param(value="cusValus")String cusValus, + @Param(value="tableName")String tableName); + + + + int insertElogDetail(@Param(value="detailContext") LoggerDetailContext loggerDetailContext, + @Param(value="mainid")String mainid, + @Param(value="cusColumns")String cusColumns , + @Param(value="cusValus")String cusValus, + @Param(value="detailTableName")String tableName); + + + Integer queryElogContextById(@Param(value="id")Long id, + @Param(value="tableName")String tableName); + + void batchInsertDetail(@Param("sql") String sql); + + void insertElogDetailPrepared(@Param("tablename") String detailTableName, @Param("list") List detailContexts, @Param("mainid") String mainid); + + void insertElogDetailPreparedHasCustonInfo(@Param("tablename") String detailTableName, @Param("list") List detailContexts, @Param("mainid") String mainid, @Param(value="cusColumns")String cusColumns); + + void rollBackElogById(@Param("id") Long id,@Param("tableName") String tableName); + + void rollBackDetailElogByUUID(@Param("mainid") String uuid,@Param("tableName") String detailTableName); + +} diff --git a/src/com/engine/salary/mapper/elog/LocalElogAopDaoMapper.xml b/src/com/engine/salary/mapper/elog/LocalElogAopDaoMapper.xml new file mode 100644 index 0000000..81eb589 --- /dev/null +++ b/src/com/engine/salary/mapper/elog/LocalElogAopDaoMapper.xml @@ -0,0 +1,170 @@ + + + + + + insert into ${tableName} (id, uuid, log_date, tenant_key, modulename, functionName, operatetypename, + log_operator, operatorname, targetid, targetname, interfacename, operatetype, + operatedesc, + params, clientIp, groupnamelabel, redoservice, redocontext, cancelservice, + cancelcontext, device, groupid, + belongMainId, requestUrl, requestUri, totalRunTime, mainRunTime, log_result, + fromTerminal, resultDesc, old_content, + link_type, link_id, old_link_id, create_time, update_time, delete_type, creator + ${cusColumns}) + values (#{logContent.id}, #{logContent.uuid}, #{logContent.date}, + #{logContent.tenant_key}, #{logContent.moduleName}, #{logContent.functionName}, + #{logContent.operateTypeName}, #{logContent.logOperator}, #{logContent.operatorName}, + #{logContent.logTargetid} + , #{logContent.targetName}, #{logContent.interfaceName}, #{logContent.operateType}, + #{logContent.operatedesc}, + #{logContent.paramsStr}, #{logContent.clientIp}, #{logContent.groupNameLabel}, + #{logContent.redoService}, + #{logContent.redoContextStr}, #{logContent.cancelService}, #{logContent.cancelContextStr}, + #{logContent.device}, #{logContent.groupId}, + #{logContent.belongMainId}, #{logContent.requestUrl}, #{logContent.requestUri}, + #{logContent.totalRunTime}, #{logContent.mainRunTime} + , #{logContent.result}, #{logContent.fromTerminal}, #{logContent.resultDesc}, + #{logContent.old_content}, #{logContent.link_type} + , #{logContent.link_id}, #{logContent.old_link_id}, #{logContent.create_time}, + #{logContent.update_time}, #{logContent.delete_type}, #{logContent.logOperator} + ${cusValus}) + + + + insert into ${detailTableName} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue, + fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key, creator, + newRealValue, oldRealValue, tableNameDesc, + tableNameLabelId, fieldNameLabelId, create_time, update_time + ${cusColumns}) + values (#{detailContext.id}, #{mainid}, #{detailContext.uuid}, #{detailContext.tableName}, + #{detailContext.fieldName}, #{detailContext.newValue}, + #{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, + #{detailContext.dataid}, + #{detailContext.belongDataid}, #{detailContext.isDetail}, #{detailContext.tenant_key}, + #{detailContext.creator}, #{detailContext.newRealValue} + , #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId}, + #{detailContext.fieldNameLabelId}, #{detailContext.create_time}, #{detailContext.update_time} + ${cusValus}) + + + ${sql} + + + + + + + + insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue, + fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue, + oldRealValue,tableNameDesc, + tableNameLabelId,fieldNameLabelId, create_time, update_time,delete_type) + values + + ( #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName}, + #{detailContext.fieldName}, #{detailContext.newValue}, + #{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid}, + #{detailContext.belongDataid}, #{detailContext.isDetail}, + #{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue} + , #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId}, + #{detailContext.fieldNameLabelId} + , #{detailContext.create_time}, #{detailContext.update_time}, #{detailContext.delete_type}) + + + + + + insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue, + fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue, + oldRealValue,tableNameDesc, + tableNameLabelId,fieldNameLabelId, create_time, update_time,delete_type) + VALUES + ( + #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName}, + #{detailContext.fieldName}, #{detailContext.newValue}, + #{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid}, + #{detailContext.belongDataid}, #{detailContext.isDetail}, + #{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue} + , #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId}, + #{detailContext.fieldNameLabelId} + , #{detailContext.create_time}, #{detailContext.update_time}, #{detailContext.delete_type} + ) + + + + + insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue, + fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue, + oldRealValue,tableNameDesc, + tableNameLabelId,fieldNameLabelId, create_time, update_time + ${cusColumns}) + values + + ( #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName}, + #{detailContext.fieldName}, #{detailContext.newValue}, + #{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid}, + #{detailContext.belongDataid}, #{detailContext.isDetail}, + #{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue} + , #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId}, + #{detailContext.fieldNameLabelId} + , #{detailContext.create_time}, #{detailContext.update_time} + ${detailContext.cusValus}) + + + + + update ${tableName} + set delete_type = 3 + where id = #{id} + + + update ${tableName} + set delete_type = 3 + where mainid = #{mainid} + + + + insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue, + fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue, + oldRealValue,tableNameDesc, + tableNameLabelId,fieldNameLabelId, create_time, update_time,delete_type) + + SELECT #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName}, + #{detailContext.fieldName}, #{detailContext.newValue}, + #{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid}, + #{detailContext.belongDataid}, #{detailContext.isDetail}, + #{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue} + , #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId}, + #{detailContext.fieldNameLabelId} + , #{detailContext.create_time}, #{detailContext.update_time}, #{detailContext.delete_type} + FROM DUAL + + + + + insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue, + fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue, + oldRealValue,tableNameDesc, + tableNameLabelId,fieldNameLabelId, create_time, update_time + ${cusColumns}) + + SELECT #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName}, + #{detailContext.fieldName}, #{detailContext.newValue}, + #{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid}, + #{detailContext.belongDataid}, #{detailContext.isDetail}, + #{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue} + , #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId}, + #{detailContext.fieldNameLabelId} + , #{detailContext.create_time}, #{detailContext.update_time} + ${detailContext.cusValus} + FROM DUAL + + + + diff --git a/src/com/engine/salary/mapper/elog/LocalElogDaoMapper.java b/src/com/engine/salary/mapper/elog/LocalElogDaoMapper.java new file mode 100644 index 0000000..70807d8 --- /dev/null +++ b/src/com/engine/salary/mapper/elog/LocalElogDaoMapper.java @@ -0,0 +1,219 @@ +package com.engine.salary.mapper.elog; + +import com.engine.salary.elog.entity.dto.LoggerContext; +import com.engine.salary.elog.entity.dto.ReadInfoEntity; +import com.github.pagehelper.Page; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: LocalElogDao + * @Description 本地操作日志持久层 + * @Author tanghj + * @Date 2021/2/24 9:35 + */ +public interface LocalElogDaoMapper { + + + List> queryCardElogList(@Param(value = "logContent") LoggerContext loggerContext, + @Param("limit") String limit, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql); + + List queryElogList(@Param(value = "page") Page page, + @Param(value = "logContent") LoggerContext loggerContext, + @Param("limit") String limit, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql, + @Param(value = "columns") String columns); + + List queryElogListPapi(@Param(value = "page") Page page, + @Param(value = "logContent") LoggerContext loggerContext, + @Param("limit") String limit, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql, + @Param(value = "columns") String columns); + + // @WeaDataPermission(mainDataTable = "#{mainDataTable}", +// permissionId = "#{permissionId}", +// permissionType = "#{permissionType}", +// mainDataTableAlias = "#{mainDataTableAlias}", +// primaryKey = "#{primaryKey}", +// permissionTargetId = "#{permissionTargetId}", +// permissionConfigSourceId = "#{permissionConfigSourceId}", +// permissionExcept = "true") + List queryElogList(@Param(value = "page") Page page, @Param(value = "logContent") LoggerContext loggerContext, + @Param("limit") String limit, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql, + @Param(value = "mainDataTable") String mainDataTable, + @Param(value = "permissionId") String permissionId, + @Param(value = "permissionType") String permissionType, + @Param(value = "mainDataTableAlias") String mainDataTableAlias, + @Param(value = "primaryKey") String primaryKey, + @Param(value = "permissionTargetId") String permissionTargetId, + @Param(value = "permissionConfigSourceId") String permissionConfigSourceId, + @Param(value = "columns") String columns + ); + + // @WeaDataPermission(mainDataTable = "#{mainDataTable}", +// permissionId = "#{permissionId}", +// permissionType = "#{permissionType}", +// mainDataTableAlias = "#{mainDataTableAlias}", +// primaryKey = "#{primaryKey}", +// permissionExcept = "true") + List queryElogListPapi(@Param(value = "page") Page page, @Param(value = "logContent") LoggerContext loggerContext, + @Param("limit") String limit, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql, + @Param(value = "mainDataTable") String mainDataTable, + @Param(value = "permissionId") String permissionId, + @Param(value = "permissionType") String permissionType, + @Param(value = "mainDataTableAlias") String mainDataTableAlias, + @Param(value = "primaryKey") String primaryKey, + @Param(value = "columns") String columns + ); + + List queryAllChanges(@Param(value = "tableName") String tableName, @Param("mainid") String mainid); + + Map elogCount(@Param(value = "logContent") LoggerContext loggerContext, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql); + + Map elogCountPapi(@Param(value = "logContent") LoggerContext loggerContext, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql); + + + // @WeaDataPermission(mainDataTable = "#{mainDataTable}", +// permissionId = "#{permissionId}", +// permissionType = "#{permissionType}", +// mainDataTableAlias = "#{mainDataTableAlias}", +// primaryKey = "#{primaryKey}", +// permissionTargetId = "#{permissionTargetId}", +// permissionConfigSourceId = "#{permissionConfigSourceId}", +// permissionExcept = "true") + Map elogCountByMorePermission(@Param(value = "logContent") LoggerContext loggerContext, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql, + @Param(value = "mainDataTable") String mainDataTable, + @Param(value = "permissionId") String permissionId, + @Param(value = "permissionType") String permissionType, + @Param(value = "mainDataTableAlias") String mainDataTableAlias, + @Param(value = "primaryKey") String primaryKey, + @Param(value = "permissionTargetId") String permissionTargetId, + @Param(value = "permissionConfigSourceId") String permissionConfigSourceId); + + // @WeaDataPermission(mainDataTable = "#{mainDataTable}", +// permissionId = "#{permissionId}", +// permissionType = "#{permissionType}", +// mainDataTableAlias = "#{mainDataTableAlias}", +// primaryKey = "#{primaryKey}", +// permissionTargetId = "#{permissionTargetId}", +// permissionConfigSourceId = "#{permissionConfigSourceId}", +// permissionCount = "count(*)", +// permissionExcept = "true") + Long elogCountOnlyNum(@Param(value = "logContent") LoggerContext loggerContext, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql, + @Param(value = "mainDataTable") String mainDataTable, + @Param(value = "permissionId") String permissionId, + @Param(value = "permissionType") String permissionType, + @Param(value = "mainDataTableAlias") String mainDataTableAlias, + @Param(value = "primaryKey") String primaryKey, + @Param(value = "permissionTargetId") String permissionTargetId, + @Param(value = "permissionConfigSourceId") String permissionConfigSourceId); + + + // @WeaDataPermission(mainDataTable = "#{mainDataTable}", +// permissionId = "#{permissionId}", +// permissionType = "#{permissionType}", +// mainDataTableAlias = "#{mainDataTableAlias}", +// primaryKey = "#{primaryKey}", +// permissionExcept = "true") + Map elogCount(@Param(value = "logContent") LoggerContext loggerContext, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql, + @Param(value = "mainDataTable") String mainDataTable, + @Param(value = "permissionId") String permissionId, + @Param(value = "permissionType") String permissionType, + @Param(value = "mainDataTableAlias") String mainDataTableAlias, + @Param(value = "primaryKey") String primaryKey); + + // @WeaDataPermission(mainDataTable = "#{mainDataTable}", +// permissionId = "#{permissionId}", +// permissionType = "#{permissionType}", +// mainDataTableAlias = "#{mainDataTableAlias}", +// primaryKey = "#{primaryKey}", +// permissionExcept = "true") + Map elogCountPapi(@Param(value = "logContent") LoggerContext loggerContext, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql, + @Param(value = "mainDataTable") String mainDataTable, + @Param(value = "permissionId") String permissionId, + @Param(value = "permissionType") String permissionType, + @Param(value = "mainDataTableAlias") String mainDataTableAlias, + @Param(value = "primaryKey") String primaryKey); + + + List queryDetailElogList(@Param(value = "logContent") LoggerContext loggerContext, + @Param("limit") String limit, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql); + + Map elogDetailCount(@Param(value = "logContent") LoggerContext loggerContext, + @Param(value = "tableName") String tableName, + @Param(value = "conditionSql") String conditionSql); + +// List queryOperators(@Param(value = "tableName") String tableName, +// @Param(value = "targetId") String targetId, +// @Param(value = "operateType") String operateType); + + List queryReadInfoOperators(@Param(value = "tableName") String tableName, + @Param(value = "targetId") String targetId, + @Param(value = "operateType") String operateType, + @Param(value = "flag") Boolean flag); + + List queryReadInfoDateOperators(@Param(value = "tableName") String tableName, + @Param(value = "targetId") String targetId, + @Param(value = "operateType") String operateType, + @Param(value = "flag") Boolean flag, + @Param(value = "startDate") String startDate, + @Param(value = "endDate") String endDate); + + List queryAllMainData(@Param(value = "tableName") String tableName, @Param("uuid") String uuid); + + List queryAllMainChanges(@Param(value = "tableName") String tableName, @Param("mainid") String mainid); + + List queryAllDetailChanges(@Param(value = "tableName") String tableName, @Param("mainid") String mainid); + + Integer queryElogContextById(@Param(value = "id") Long id, + @Param(value = "tableName") String tableName); + + List queryElogTraceInfo(@Param(value = "traceId") String traceId, + @Param(value = "tableName") String tableName, + @Param(value = "offset") Integer offset, + @Param(value = "pageSize") Integer pageSize); + + int queryElogTraceInfoCount(@Param(value = "traceId") String traceId, + @Param(value = "tableName") String tableName); + + List queryLogInfoByCustom(@Param(value = "tableName") String tableName, + @Param(value = "sql") String sql); + + List queryAllChangesData(@Param("tableName") String tableName, @Param("mainid") String mainid); + + List queryTenantKeyOperators(@Param(value = "tableName") String tableName, + @Param(value = "tenantKey") String tenantKey, + @Param(value = "targetId") String targetId, + @Param(value = "operateType") String operateType, + @Param(value = "flag") Boolean flag); + + List queryAllChangesDataPages(@Param("tableName") String tableName, + @Param("mainid") String mainid, + @Param(value = "page") Page page); + + Integer queryAllChangesPageCounts(@Param("tableName") String tableName, @Param("mainid") String mainid); +} diff --git a/src/com/engine/salary/mapper/elog/LocalElogDaoMapper.xml b/src/com/engine/salary/mapper/elog/LocalElogDaoMapper.xml new file mode 100644 index 0000000..93c2338 --- /dev/null +++ b/src/com/engine/salary/mapper/elog/LocalElogDaoMapper.xml @@ -0,0 +1,412 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/elog/QueryCurretValusMapper.java b/src/com/engine/salary/mapper/elog/QueryCurretValusMapper.java new file mode 100644 index 0000000..0a8e149 --- /dev/null +++ b/src/com/engine/salary/mapper/elog/QueryCurretValusMapper.java @@ -0,0 +1,8 @@ +package com.engine.salary.mapper.elog; + +import java.util.Map; + +public interface QueryCurretValusMapper { + + Map queryValues(String sql); +} diff --git a/src/com/engine/salary/mapper/elog/QueryCurretValusMapper.xml b/src/com/engine/salary/mapper/elog/QueryCurretValusMapper.xml new file mode 100644 index 0000000..c3d7a16 --- /dev/null +++ b/src/com/engine/salary/mapper/elog/QueryCurretValusMapper.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file