This commit is contained in:
钱涛 2025-05-15 18:10:24 +08:00
commit 16e730e16a
40 changed files with 2476 additions and 0 deletions

45
README.md Normal file
View File

@ -0,0 +1,45 @@
# e-code 本地二开项目
## 项目搭建
本项目为本地开发模版,可在 IDEA 中直接打开。
## 调试
本地调试:[参考文档](https://www.e-cology.com.cn/ecode/playground/doc/share/view/916733818655342593#3.4.1%20%E6%9C%AC%E5%9C%B0%E4%BB%A3%E7%A0%81%E8%B0%83%E8%AF%95)
项目使用 gradle 进行构建,在项目根目录下直接运行 gradle build 即可
## 打包部署
### 多模块项目创建说明
> 子项目会集成根目录下的关联依赖可在build.gradle中进行修改
#### 创建子模块
> 在根目录下直接创建目录并在目录下创建对应的gradle文件
例如创建模块secondev-workflow-demo
1.创建目录 secondev-md-demo
2.创建gradle文件 secondev-md-demo/secondev-md-demo.gradle
```
root
|-secondev-custom-demo
| |-src
| | |--...
| |-secondev-custom-demo.gradle
| |
```
secondev-custom-demo.gradle 内容如下
```
description = "子模块demo项目"
dependencies {
// 子项目私有依赖添加
}
```
#### 接触子模块关联
> 在需要接触关联的子模块目录下 添加名为.disabled的文件即可内容为空即可 需要重新reload

64
build.gradle Normal file
View File

@ -0,0 +1,64 @@
plugins {
id 'java'
id 'com.weaver.ecode.gradle.plugin.BuildArchPlugin'
}
group 'com.weaver.seconddev'
version '1.0.0'
description ''
allprojects {
repositories {
// maven { url 'https://maven.aliyun.com/repository/public/' } //
mavenLocal()
mavenCentral()
}
}
def ignoredProjectNames = []
configure(allprojects) { project ->
apply plugin: 'java'
apply plugin: 'com.weaver.ecode.gradle.plugin.BuildArchPlugin'
compileJava {
options.encoding = 'UTF-8'
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
}
jar {
// apply plugin:'war'
from sourceSets.main.allJava
manifest {
attributes 'weaver-ecode-seconddev-id': rootProject.group + '-' + rootProject.name,
'Implementation-Version': rootProject.version,
'Implementation-Vendor-Id': rootProject.group,
'Implementation-Title': rootProject.name
}
}
if (!ignoredProjectNames.contains(project.name)) {
dependencies {
// implementation group: 'junit', name: 'junit', version: '4.12'
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
// implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
//
def includeType = ['**/*.jar', '**/*.class']
//class文件依赖
implementation files(rootProject.projectDir.getPath() + '/secDevClasses')
//jar包依赖
implementation fileTree(dir: rootProject.projectDir.getPath() + '/secDevLib', includes: includeType)
//
implementation fileTree(dir: rootProject.projectDir.getPath() + "/devLib", includes: includeType)
}
}
}

1
gradle.properties Normal file
View File

@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx8192m -XX:MaxPermSize=8192m

234
gradlew vendored Normal file
View File

@ -0,0 +1,234 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

89
gradlew.bat vendored Normal file
View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

Binary file not shown.

View File

@ -0,0 +1,8 @@
plugins{
id 'java'
}
description = ""
dependencies {
//
}

View File

@ -0,0 +1,8 @@
plugins{
id 'java'
}
description = "新页面demo项目"
dependencies {
//
}

View File

@ -0,0 +1,28 @@
package com.weaver.seconddev.page.action;
import cn.hutool.core.util.NumberUtil;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.common.hr.util.Util;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service("checkBcskjeAction")
public class CheckBcskjeAction implements EsbServerlessRpcRemoteInterface {
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
String bcskje = Util.null2String(params.get("bcskje"));
String htje = Util.null2String(params.get("htje"));
if (!NumberUtil.isNumber(bcskje) || !NumberUtil.isNumber(htje)) {
return WeaResult.fail("金额填写有误", true);
}
if (NumberUtil.compare(Double.parseDouble(bcskje), Double.parseDouble(htje)) > 0) {
return WeaResult.fail("本次收款金额大于合同总金额", true);
}
return WeaResult.success();
}
}

View File

@ -0,0 +1,37 @@
package com.weaver.seconddev.page.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 表单
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Form {
int labelId() default -1;
String label() default "";
int labelSpan() default 6;
boolean hide() default false;
String layout() default "";
String group() default "";
String tip() default "";
int tipLabel() default -1;
FormItem[] items();
}

View File

@ -0,0 +1,54 @@
package com.weaver.seconddev.page.annotation;
import com.weaver.common.component.form.item.WeaFormItemType;
import com.weaver.seconddev.page.enums.BaseEnum;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 表单项
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface FormItem {
WeaFormItemType itemType();
String name() default "";
String options() default "";
Class<? extends BaseEnum>[] optionsEnum() default {};
String optionsEnumMethod() default "name";
String browserType() default "";
String browserModule() default "";
String maxLength() default "";
boolean readOnly() default false;
boolean required() default false;
boolean browserMultiple() default false;
boolean langLine() default false;
long max() default Integer.MAX_VALUE;
long min() default Integer.MIN_VALUE;
int precision() default 5;
boolean needNumberSetting() default false;
}

View File

@ -0,0 +1,25 @@
package com.weaver.seconddev.page.annotation;
import com.weaver.common.component.form.item.WeaFormItemType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 多语言配置
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MultiLanguage {
String tablefield() default "";
WeaFormItemType itemType() default WeaFormItemType.LOCALE;
}

View File

@ -0,0 +1,36 @@
package com.weaver.seconddev.page.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 高级搜索
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface SearchCondition {
int labelId() default -1;
String label() default "";
int labelSpan() default 6;
String module() default "";
String quickSearchKey() default "";
boolean needQuickSearch() default false;
// 根据需要可动态忽略
boolean ignore() default false;
SearchConditionItem[] items();
}

View File

@ -0,0 +1,40 @@
package com.weaver.seconddev.page.annotation;
import com.weaver.common.component.search.item.WeaSearchConditionItemType;
import com.weaver.seconddev.page.enums.BaseEnum;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 高级搜索搜索项
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface SearchConditionItem {
WeaSearchConditionItemType itemType();
String name() default "";
String groupId() default "commonGroup";
String browserModule() default "";
String browserType() default "";
boolean browserMultiple() default false;
String options() default "";
Class<? extends BaseEnum>[] optionsEnum() default {};
boolean isRange() default false;
}

View File

@ -0,0 +1,30 @@
package com.weaver.seconddev.page.annotation;
import com.weaver.common.component.table.type.WeaTableTypeEnum;
import com.weaver.seconddev.page.constant.Constant;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 表格组件
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Table {
TableOperate[] value() default {};
WeaTableTypeEnum tableType() default WeaTableTypeEnum.NONE;
String module() default Constant.MODULE;
String pageUid() default "";
}

View File

@ -0,0 +1,27 @@
package com.weaver.seconddev.page.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 表格表头
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface TableColumn {
String width() default "";
boolean hide() default false;
String label() default "";
long labelId() default -1L;
}

View File

@ -0,0 +1,31 @@
package com.weaver.seconddev.page.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 表格操作按钮
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Target({ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface TableOperate {
String text();
long labelId() default -1L;
String menuCode() default "";
String permissionSetCode() default "";
int index() default -1;
boolean outer() default true;
}

View File

@ -0,0 +1,63 @@
package com.weaver.seconddev.page.browser;
import com.weaver.common.component.browser.entity.BrowserEntity;
import com.weaver.common.component.browser.entity.BrowserParam;
import com.weaver.common.component.browser.rest.RemoteBrowserService;
import com.weaver.common.component.browser.service.Browser;
import com.weaver.common.component.browser.util.BrowserUtil;
import com.weaver.framework.util.JsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 标准浏览按钮
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Service("pageDemo_OrderTypeRemoteBrowserService")
public class OrderTypeRemoteBrowserService implements RemoteBrowserService {
private static final Logger log = LoggerFactory.getLogger(OrderTypeRemoteBrowserService.class);
@Override
public Map<String, List<BrowserEntity>> queryBrowserByParam(List<BrowserParam> param) {
log.info("SalaryRemoteBrowserService.queryBrowserByParam.param : {}", JsonUtil.toJsonString(param));
if (param == null || param.isEmpty()) {
return Collections.emptyMap();
}
log.info("SalaryRemoteBrowserService.queryBrowserByParam.param : {}", JsonUtil.toJsonString(param));
Map<String, List<BrowserEntity>> map = new HashMap<>();
for (BrowserParam browserParam : param) {
if (!map.containsKey(browserParam.getBrowserType())) {
map.put(browserParam.getBrowserType(), new ArrayList<>());
}
map.get(browserParam.getBrowserType()).addAll(assembleBrowser(browserParam));
}
log.info("SalaryRemoteBrowserService.queryBrowserByParam.result: {}", JsonUtil.toJsonString(map));
return map;
}
private List<BrowserEntity> assembleBrowser(BrowserParam param) {
try {
// 获取对应的浏览按钮
Browser browser = BrowserUtil.getBrowser(param.getBrowserType());
if (browser != null) {
Map<String,Object> object = new HashMap<>();
object.put("ids", param.getDataIds());
object.put("user", param.getUser());
return browser.getBrowserEntities(object);
}
} catch (Exception e) {
log.error("获取浏览按钮[{}]数据失败:{},{},{}", param.getBrowserType(), e.getMessage(),e.toString(), e.getLocalizedMessage());
}
return Collections.emptyList();
}
}

View File

@ -0,0 +1,21 @@
package com.weaver.seconddev.page.common;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* idname的基本数据格式
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Accessors(chain = true)
public class BaseDTO {
private String id;
private String name;
}

View File

@ -0,0 +1,36 @@
package com.weaver.seconddev.page.common;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 人员选项
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("人员选项")
public class OptionDTO {
@ApiModelProperty("人员ID")
private String id;
@ApiModelProperty("人员姓名")
private String content;
@ApiModelProperty("人员姓名")
private String name;
public OptionDTO(String id, String content) {
this.id = id;
this.content = content;
}
}

View File

@ -0,0 +1,29 @@
package com.weaver.seconddev.page.common;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* sql返回对象
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SqlResponse<T> {
private String sqlType;
private Integer code;
private List<T> records;
private Integer count;
private String message;
private String status;
}

View File

@ -0,0 +1,125 @@
package com.weaver.seconddev.page.config;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.weaver.common.component.browser.annotation.WeaBrowserTypeLink;
import com.weaver.common.component.browser.constant.WeaBrowserConstant;
import com.weaver.common.component.browser.constant.WeaBrowserDataType;
import com.weaver.common.component.browser.entity.BrowserEntity;
import com.weaver.common.component.browser.entity.WeaBrowserBaseBean;
import com.weaver.common.component.browser.service.AbstractWeaBrowserBaseService;
import com.weaver.common.component.table.page.Page;
import com.weaver.seconddev.page.constant.Constant;
import com.weaver.seconddev.page.entity.dto.OrderTypeListDTO;
import com.weaver.seconddev.page.entity.param.OrderTypeQueryParam;
import com.weaver.seconddev.page.service.DemoService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
* 工单类型浏览按钮
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Component
@WeaBrowserTypeLink(module = Constant.MODULE, type = "orderTypeBrowser")
public class OrderTypeBrowser extends AbstractWeaBrowserBaseService {
@Autowired
private DemoService demoService;
/**
* @param params
* @return
* @throws Exception
*/
@Override
public WeaBrowserBaseBean init(Map<String, Object> params) {
WeaBrowserBaseBean baseBean = new WeaBrowserBaseBean();
HashMap<String, Object> dialogPropsMap = Maps.newHashMap();
dialogPropsMap.put("title", "请选择工单类型");
baseBean.setBrowserDialogProps(dialogPropsMap);
baseBean.setHasAdvanceSearch(false);
baseBean.setQuickSearchName("keywords");
return baseBean;
}
@Override
public Map<String, Object> getBrowserData(Map<String, Object> params) {
Map<String, Object> resultMap = Maps.newHashMap();
if (MapUtils.isEmpty(params)) {
return resultMap;
}
Map<String, Object> quickSearchDataMap = (Map<String, Object>) params.get("quickSearchDatas");
Object name = Objects.isNull(quickSearchDataMap) ? null : quickSearchDataMap.get("keywords");
OrderTypeQueryParam queryParam = new OrderTypeQueryParam();
queryParam.setName(Objects.isNull(name) ? "" : name.toString());
queryParam.setCurrent(Long.parseLong(params.getOrDefault("current", "1").toString()));
queryParam.setPageSize(Long.parseLong(params.getOrDefault("pageSize", "10").toString()));
Page<OrderTypeListDTO>page = demoService.orderTypePage(queryParam);
resultMap.put(WeaBrowserConstant.BROWSER_RESULT_DATA, convert2BrowserData(page.getRecords()));
resultMap.put(WeaBrowserConstant.BROWSER_RESULT_TOTAL, page.getTotal());
resultMap.put(WeaBrowserConstant.BROWSER_RESULT_DATA_TYPE, WeaBrowserDataType.LIST_DATA.getType());
resultMap.put(WeaBrowserConstant.BROWSER_RESULT_PAGE_SIZE, page.getSize());
resultMap.put(WeaBrowserConstant.BROWSER_RESULT_CURRENT_PAGE, page.getCurrent());
return resultMap;
}
@Override
public Map<String, Object> browserAutoComplete(Map<String, Object> params){
Object name = params.get("searchValue");
OrderTypeQueryParam queryParam = new OrderTypeQueryParam();
queryParam.setName(Objects.isNull(name) ? "" : name.toString());
queryParam.setCurrent(Long.parseLong(params.getOrDefault("current", "1").toString()));
queryParam.setPageSize(Long.parseLong(params.getOrDefault("pageSize", "10").toString()));
Page<OrderTypeListDTO> page = demoService.orderTypePage(queryParam);
Map<String, Object> resultMap = Maps.newHashMap();
resultMap.put(WeaBrowserConstant.BROWSER_RESULT_TOTAL, page.getTotal());
resultMap.put(WeaBrowserConstant.BROWSER_RESULT_DATA, convert2BrowserData(page.getRecords()));
return resultMap;
}
private List<Map<String, Object>> convert2BrowserData(Collection<OrderTypeListDTO> salarySobs) {
if (CollectionUtils.isEmpty(salarySobs)) {
return Collections.emptyList();
}
return salarySobs.stream()
.map(e -> {
Map<String, Object> tempMap = Maps.newHashMap();
tempMap.put("id", e.getId().toString());
tempMap.put("name", e.getMc());
return tempMap;
}).collect(Collectors.toList());
}
@Override
public List<BrowserEntity> getBrowserEntities(Map<String, Object> params) {
List<BrowserEntity> browserEntityList = Lists.newArrayList();
Map<String, Object> browserData = getBrowserData(params);
if (MapUtils.isNotEmpty(browserData)) {
List<Object> list = (List<Object>) browserData.get(WeaBrowserConstant.BROWSER_RESULT_DATA);
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(list)) {
for (int i = 0; i < list.size(); i++) {
BrowserEntity browserEntity = new BrowserEntity();
Map<String, Object> userMap = (Map<String, Object>) list.get(i);
String idStr = (String) userMap.get("id");
String name = (String) userMap.get("name");
browserEntity.setDataId(idStr);
browserEntity.setContent(name);
browserEntityList.add(browserEntity);
}
}
}
return browserEntityList;
}
}

View File

@ -0,0 +1,18 @@
package com.weaver.seconddev.page.constant;
/**
* 常量
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class Constant {
/**
* 模块标识
*/
public static final String MODULE = "pageDemo";
}

View File

@ -0,0 +1,41 @@
package com.weaver.seconddev.page.controller;
import com.weaver.common.authority.annotation.WeaPermission;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.common.component.search.WeaSearchCondition;
import com.weaver.common.component.table.WeaTable;
import com.weaver.seconddev.page.entity.dto.DemoListDTO;
import com.weaver.seconddev.page.entity.param.DemoQueryParam;
import com.weaver.seconddev.page.service.DemoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/secondev/page/demo")
@WeaPermission(publicPermission = true)
public class DemoController {
@Autowired
private DemoService demoService;
@GetMapping("/getSearchCondition")
@ApiOperation("列表的高级搜索")
public WeaResult<WeaSearchCondition> getSearchCondition() {
return WeaResult.success(demoService.getSearchCondition());
}
@PostMapping("/list")
@ApiOperation("列表")
public WeaResult<WeaTable<DemoListDTO>> list(@RequestBody DemoQueryParam queryParam) {
return WeaResult.success(demoService.list(queryParam));
}
@GetMapping("/getForm")
@ApiOperation("获取表单")
public WeaResult<?> getFrom(@RequestParam(value = "id", required = false) Long id) {
return WeaResult.success(demoService.getForm(id));
}
}

View File

@ -0,0 +1,125 @@
package com.weaver.seconddev.page.entity.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.weaver.common.component.form.item.WeaFormItemType;
import com.weaver.seconddev.page.annotation.Form;
import com.weaver.seconddev.page.annotation.FormItem;
import com.weaver.seconddev.page.annotation.TableColumn;
import com.weaver.seconddev.page.common.BaseDTO;
import com.weaver.seconddev.page.constant.Constant;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 表单
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DemoFormDTO {
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@Form(
label = "标题",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.INPUT, required = true)
},
group = "baseInfo",
layout = "one",
labelSpan = 10
)
private String bt;
@Form(
label = "发起人",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.BROWSER, browserModule = Constant.MODULE,
browserType = "resource", required = true)
}
)
private BaseDTO fqr;
@Form(
label = "部门",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.BROWSER, browserModule = Constant.MODULE,
browserType = "department", required = true)
}
)
private BaseDTO bm;
@Form(
label = "工单类型",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.BROWSER, browserModule = Constant.MODULE,
browserType = "orderTypeBrowser", required = true)
}
)
private BaseDTO gdlx;
@Form(
label = "EB浏览框",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.BROWSER, browserModule = Constant.MODULE,
browserType = "performance_grade_detail", required = true)
}
)
private BaseDTO ebllk;
@Form(
label = "创建日期",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.DATEPICKER, required = true)
},
group = "baseInfo"
)
@TableColumn(label = "创建日期", labelId = 100377, width = "150")
private String cjrq;
@Form(
label = "文档",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.UPLOAD, browserModule = Constant.MODULE)
}
)
private String wd;
@Form(
label = "流程",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.BROWSER, browserModule = Constant.MODULE,
browserType = "department", required = true)
}
)
private String lc;
@Form(
label = "问题描述",
labelId = 0,
items = {
@FormItem(itemType = WeaFormItemType.TEXTAREA, required = true)
}
)
private String wtms;
}

View File

@ -0,0 +1,54 @@
package com.weaver.seconddev.page.entity.dto;
import com.weaver.common.component.table.type.WeaTableTypeEnum;
import com.weaver.seconddev.page.annotation.Table;
import com.weaver.seconddev.page.annotation.TableColumn;
import com.weaver.seconddev.page.annotation.TableOperate;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(pageUid = "demoList",
tableType = WeaTableTypeEnum.CHECKBOX,
value = {
@TableOperate(index = 0, text = "查看明细", labelId = 0),
@TableOperate(index = 1, text = "编辑", labelId = 0, outer = false),
@TableOperate(index = 2, text = "删除", labelId = 0, outer = false)
})
public class DemoListDTO {
private Long id;
@TableColumn(label = "标题", labelId = 0, width = "150")
private String bt;
@TableColumn(label = "工单类型", labelId = 0, width = "150")
private String gdlx;
@TableColumn(label = "创建日期", labelId = 0, width = "150")
private String cjrq;
@TableColumn(label = "发起人", labelId = 0, width = "150")
private String username;
private String fqr;
@TableColumn(label = "部门", labelId = 0, width = "150")
private String bmName;
private String bm;
@TableColumn(label = "问题描述", labelId = 0, width = "150")
private String wtms;
@TableColumn(label = "文档", labelId = 0, width = "150")
private String wd;
@TableColumn(label = "流程", labelId = 0, width = "150")
private String lc;
}

View File

@ -0,0 +1,58 @@
package com.weaver.seconddev.page.entity.dto;
import com.weaver.common.component.search.item.WeaSearchConditionItemType;
import com.weaver.seconddev.page.annotation.SearchCondition;
import com.weaver.seconddev.page.annotation.SearchConditionItem;
import com.weaver.seconddev.page.constant.Constant;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DemoSearchConditionDTO {
@SearchCondition(
label = "创建人",
labelId = 0,
needQuickSearch = true,
quickSearchKey = "username",
items = {
@SearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "username"),
}
)
private String username;
@SearchCondition(
label = "部门",
labelId = 0,
needQuickSearch = true,
items = {
@SearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER,
browserType = "department", browserMultiple = true, name = "department", browserModule = Constant.MODULE),
}
)
private String department;
@SearchCondition(
label = "工单类型",
labelId = 0,
items = @SearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER,
browserType = "orderTypeBrowser", name = "orderType", browserModule = Constant.MODULE)
)
private String orderType;
@SearchCondition(
label = "创建日期",
labelId = 0,
items = {
@SearchConditionItem(itemType = WeaSearchConditionItemType.DATEPICKER, name = "createTime"),
}
)
private String createTime;
}

View File

@ -0,0 +1,18 @@
package com.weaver.seconddev.page.entity.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderTypeListDTO {
private Long id;
private String mc;
}

View File

@ -0,0 +1,94 @@
package com.weaver.seconddev.page.entity.param;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.Collection;
import java.util.List;
/**
* 查询参数
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DemoQueryParam {
@ApiModelProperty("当前页码")
private Long current ;
@ApiModelProperty("每页数据条数")
private Long pageSize ;
@ApiModelProperty("总条数")
private Integer total ;
@ApiModelProperty("主键id")
private Collection<Long> ids;
@ApiModelProperty("关键字(姓名、部门、工号)")
private String keyword;
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("申报年月")
private List<YearMonth> declareMonth;
/**
* 申报年月
*/
@JsonIgnore
private List<LocalDate> declareMonthDate;
@ApiModelProperty("姓名")
private String username;
@ApiModelProperty("员工id")
private Long employeeId;
@ApiModelProperty("个税扣缴义务人的主键id")
private Long taxAgentId;
@ApiModelProperty("部门id")
private List<Long> departmentIds;
@ApiModelProperty("工号")
private String jobNum;
@ApiModelProperty("身份证号码")
private String idNo;
/**
* 是否允许查询身份证号码
*/
@JsonIgnore
private boolean isSearchIdNo;
@ApiModelProperty("入职日期")
private List<LocalDate> hiredate;
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("导入校验字段 1.工号 2.身份证号码")
private Integer importCheckType;
@ApiModelProperty("excel密码")
private String sharePassword;
@ApiModelProperty("自定义列")
private List<String> customColumns;
}

View File

@ -0,0 +1,34 @@
package com.weaver.seconddev.page.entity.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 查询参数
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderTypeQueryParam {
@ApiModelProperty("当前页码")
private Long current ;
@ApiModelProperty("每页数据条数")
private Long pageSize ;
@ApiModelProperty("总条数")
private Integer total ;
@ApiModelProperty("名字")
private String name ;
}

View File

@ -0,0 +1,20 @@
package com.weaver.seconddev.page.enums;
/**
* 基础枚举
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface BaseEnum<T> {
String name();
T getValue();
Integer getLabelId();
String getDefaultLabel();
}

View File

@ -0,0 +1,21 @@
package com.weaver.seconddev.page.service;
import com.weaver.common.component.form.WeaForm;
import com.weaver.common.component.search.WeaSearchCondition;
import com.weaver.common.component.table.WeaTable;
import com.weaver.common.component.table.page.Page;
import com.weaver.seconddev.page.entity.dto.DemoListDTO;
import com.weaver.seconddev.page.entity.dto.OrderTypeListDTO;
import com.weaver.seconddev.page.entity.param.DemoQueryParam;
import com.weaver.seconddev.page.entity.param.OrderTypeQueryParam;
public interface DemoService {
WeaSearchCondition getSearchCondition();
WeaTable<DemoListDTO> list(DemoQueryParam queryParam);
Page<OrderTypeListDTO> orderTypePage(OrderTypeQueryParam queryParam);
WeaForm getForm(Long id);
}

View File

@ -0,0 +1,108 @@
package com.weaver.seconddev.page.service.impl;
import cn.hutool.core.codec.Base64;
import com.weaver.common.component.form.WeaForm;
import com.weaver.common.component.search.WeaSearchCondition;
import com.weaver.common.component.table.WeaTable;
import com.weaver.common.component.table.page.Page;
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
import com.weaver.ebuilder.datasource.api.enums.SourceType;
import com.weaver.ebuilder.datasource.api.service.DataSetService;
import com.weaver.framework.spring.annotation.AopClass;
import com.weaver.seconddev.page.common.SqlResponse;
import com.weaver.seconddev.page.entity.dto.DemoFormDTO;
import com.weaver.seconddev.page.entity.dto.DemoListDTO;
import com.weaver.seconddev.page.entity.dto.DemoSearchConditionDTO;
import com.weaver.seconddev.page.entity.dto.OrderTypeListDTO;
import com.weaver.seconddev.page.entity.param.DemoQueryParam;
import com.weaver.seconddev.page.entity.param.OrderTypeQueryParam;
import com.weaver.seconddev.page.service.DemoService;
import com.weaver.seconddev.page.util.EntityUtil;
import com.weaver.seconddev.page.util.FormatUtil;
import com.weaver.seconddev.page.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
@AopClass
public class DemoServiceImpl implements DemoService {
@Autowired
private DataSetService dataSetService;
@Override
public WeaSearchCondition getSearchCondition() {
WeaSearchCondition weaSearchCondition = FormatUtil.<DemoSearchConditionDTO>getInstance()
.buildCondition(DemoSearchConditionDTO.class, new DemoSearchConditionDTO(), "demoPage_SearchCondition");
return weaSearchCondition;
}
@Override
public WeaTable<DemoListDTO> list(DemoQueryParam queryParam) {
String sql = "select t.id,t.bt,cjrq,fqr,bm,wtms,wd,e.username,d.shortname as bmName from uf_gdjcxx t " +
"LEFT JOIN eteams.EMPLOYEE e ON e.id = t.fqr " +
"LEFT JOIN eteams.DEPARTMENT d ON d.id = e.department " +
"where e.TENANT_KEY = 'tma3ktp1q7' ";
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(Base64.encode(sql));
executeSqlEntity.setGroupId("weaver-ebuilder-app-service");
executeSqlEntity.setSourceType(SourceType.LOGIC);
Map<String, Object> map = dataSetService.executeSql(executeSqlEntity);
SqlResponse<DemoListDTO> sqlResponse = EntityUtil.map2Entity(map, DemoListDTO.class);
List<DemoListDTO> list = sqlResponse.getRecords();
Page<DemoListDTO> page = PageUtil.buildPage(list, queryParam.getCurrent(), queryParam.getPageSize());
WeaTable<DemoListDTO> table = FormatUtil.<DemoListDTO>getInstance().buildTable(DemoListDTO.class, page);
return table;
}
@Override
public Page<OrderTypeListDTO> orderTypePage(OrderTypeQueryParam queryParam) {
String sql = "select t.id,t.mc,from uf_gdlx t where e.TENANT_KEY = 'tma3ktp1q7' ";
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(Base64.encode(sql));
executeSqlEntity.setGroupId("weaver-ebuilder-app-service");
executeSqlEntity.setSourceType(SourceType.LOGIC);
Map<String, Object> map = dataSetService.executeSql(executeSqlEntity);
SqlResponse<OrderTypeListDTO> sqlResponse = EntityUtil.map2Entity(map, OrderTypeListDTO.class);
List<OrderTypeListDTO> list = sqlResponse.getRecords();
Page<OrderTypeListDTO> page = PageUtil.buildPage(list, queryParam.getCurrent(), queryParam.getPageSize());
return page;
}
@Override
public WeaForm getForm(Long id) {
DemoListDTO dataFormDTO = new DemoListDTO();
if (id != null) {
String sql = "select t.id,t.bt,cjrq,fqr,bm,wtms,wd,e.username,d.shortname as bmName from uf_gdjcxx t " +
"LEFT JOIN eteams.EMPLOYEE e ON e.id = t.fqr " +
"LEFT JOIN eteams.DEPARTMENT d ON d.id = e.department " +
"where t.TENANT_KEY = 'tma3ktp1q7' and t.id= " + id;
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(Base64.encode(sql));
executeSqlEntity.setGroupId("weaver-ebuilder-app-service");
executeSqlEntity.setSourceType(SourceType.LOGIC);
Map<String, Object> map = dataSetService.executeSql(executeSqlEntity);
SqlResponse<DemoListDTO> sqlResponse = EntityUtil.map2Entity(map, DemoListDTO.class);
List<DemoListDTO> list = sqlResponse.getRecords();
dataFormDTO = list.get(0);
}
WeaForm weaForm = FormatUtil.<DemoFormDTO>getInstance().buildForm(DemoFormDTO.class, dataFormDTO);
return weaForm;
}
}

View File

@ -0,0 +1,203 @@
package com.weaver.seconddev.page.util;
import cn.hutool.core.codec.Base64;
import cn.hutool.json.JSONUtil;
import com.weaver.datasource.utils.rest.CommonRestService;
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
import com.weaver.ebuilder.datasource.api.enums.SourceType;
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Component
public class DataSetUtil {
@Autowired
private CommonRestService commonRestService;
public static String base64(String sql) {
return Base64.encode(sql);
}
/**
* 根据数据库类型 找到对应数据库
*
* @param sourceType sourceType 枚举类
* ETEAMS :数据仓库
* FORM: ebuilder表单
* LOGIC: 各模块提供业务数据(逻辑表)
* EXTERNAL 外部数据源
* @return
*/
public Map<String, Object> getDataGroups(String sourceType) {
try {
//拼接参数
MultiValueMap<String, Object> valueMap = new LinkedMultiValueMap<>();
valueMap.add("sourceType", sourceType);
return commonRestService.postForObject("/sapi/datasource/ds/group", MediaType.APPLICATION_FORM_URLENCODED, Map.class, valueMap);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
}
/**
* 执行服务内部sql:/sapi/secondev/ds/executeSql
* sourceType :LOGIC
* groupId : weaver-ebuilder-app-service 可以通过group接口获取
* sql : select * from ebda_app limit 10
* @param sourceType LOGIC: 各模块提供业务数据(逻辑表)
* @param groupId
* @param sql
* @return
*/
public Map<String, Object> executeLogicSql(SourceType sourceType, String groupId, String sql) {
//拼接参数
Map<String, Object> valueMap = new HashMap<>();
valueMap.put("sourceType", sourceType);
valueMap.put("groupId", groupId);
//sql select * from table where tenant_key = '租户key' and delete_dype = 0 and id in (1,2,3)
valueMap.put("sql", base64(sql));
try {
return commonRestService.getForObject("/sapi/secondev/ds/executeSql", valueMap, MediaType.APPLICATION_FORM_URLENCODED, Map.class);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
}
/**
* 执行外部数据库sql: /sapi/datasearch/external/data/executeSql
* sourceType : EXTERNAL: 外部数据源
* groupId : 842668710322556928L 通过group接口获取数据加工内配置的连接id
* sql : select * from ebda_app limit 10
*
* @param
* @return
*/
public Map<String, Object> executeExternalSql(SourceType sourceType, String groupId, String sql, List<SqlParamEntity> sqlParams) {
//执行sql 参数sourceType groupId sql
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(base64(sql));
executeSqlEntity.setGroupId(groupId);
executeSqlEntity.setSourceType(sourceType);
//若通过占位符方式查询外部数据库,需增加此参数
//占位符list 的顺序 要与 sql ?占位符顺序一致
if (sqlParams != null && !sqlParams.isEmpty()) {
executeSqlEntity.setParams(sqlParams);
}
//拼接参数
Map<String, Object> valueMap = new HashMap<>();
valueMap.put("params", JSONUtil.toJsonStr(executeSqlEntity));
try {
return commonRestService.postForForm("/sapi/datasearch/external/data/executeSql", Map.class, valueMap);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
}
/**
* 构建占位符参数
* 注意:list的参数顺序 必须要与 sql内的占位符参数顺序一致
* 此案例构建的json字符串 是提供给sql:select * from table where tenant_key = ? and delete_dype = ? and id in (?, ?, ?) 使用
* @return
*/
public List<SqlParamEntity> getSqlParams() {
List<SqlParamEntity> sqlParams = new ArrayList<>();
SqlParamEntity sqlParam1 = new SqlParamEntity();
sqlParam1.setParamType(SqlParamType.VARCHAR);
sqlParam1.setValue("thsv5s4n2c");
sqlParams.add(sqlParam1);
SqlParamEntity sqlParam2 = new SqlParamEntity();
sqlParam2.setParamType(SqlParamType.INTEGER);
sqlParam2.setValue("0");
sqlParams.add(sqlParam2);
List<Long> ids = new ArrayList<>();
ids.add(1054407582048280585L);
ids.add(1054407345976074241L);
ids.add(1054406667262189570L);
for (Long id : ids) {
SqlParamEntity sqlParam3 = new SqlParamEntity();
sqlParam3.setParamType(SqlParamType.LONG);
sqlParam3.setValue(String.valueOf(id));
sqlParams.add(sqlParam3);
}
return sqlParams;
}
//1201基线后支持的接口---------------------------------------------------
/**
* 1201基线后支持的聚合执行接口
* LOGIC:支持普通sql与预编译sql执行,支持带事务执行
* EXTERNAL:支持普通sql与预编译sql执行,不支持带事务执行
* @param sourceType 连接类型
* @param groupId 连接id
* @param sql sql语句
* @param sqlParams 预编译sql参数
* @param transId 事务id
* @param startTrans 是否开启事务
* @param commit 是否提交事务
* @param rollback 是否回滚事务
*/
public Map<String, Object> executeSqlWithTrans(SourceType sourceType, String groupId, String sql, List<SqlParamEntity> sqlParams, String transId, Boolean startTrans, Boolean commit, Boolean rollback) {
//执行sql 参数sourceType groupId sql
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(base64(sql));
executeSqlEntity.setGroupId(groupId);
executeSqlEntity.setSourceType(sourceType);
//若通过占位符方式查询外部数据库,需增加此参数
//占位符list 的顺序 要与 sql ?占位符顺序一致
if (sqlParams != null && !sqlParams.isEmpty()) {
executeSqlEntity.setParams(sqlParams);
}
//设置事务id
if (transId != null && !transId.isEmpty()) {
executeSqlEntity.setTransactionId(transId);
}
//是否开启事务
if (startTrans != null && startTrans) {
executeSqlEntity.setStartTransaction(true);
}
//是否提交事务
if (commit != null && commit) {
executeSqlEntity.setCommitTransaction(true);
}
//是否回滚事务
if (rollback != null && rollback) {
executeSqlEntity.setRollbackTransaction(true);
}
//拼接参数
Map<String, Object> valueMap = new HashMap<>();
valueMap.put("entity", JSONUtil.toJsonStr(executeSqlEntity));
try {
return commonRestService.postForForm("/sapi/secondev/ds/executeSqlAll", Map.class, valueMap);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
}
}

View File

@ -0,0 +1,17 @@
package com.weaver.seconddev.page.util;
import com.alibaba.fastjson.JSON;
import com.weaver.seconddev.page.common.SqlResponse;
import java.util.List;
import java.util.Map;
public class EntityUtil {
public static <T> SqlResponse<T> map2Entity(Map<String, Object> map, Class<T> clazz) {
String s = JSON.toJSONString(map);
SqlResponse<T> sqlResponse = JSON.parseObject(s, SqlResponse.class);
List<T> list = JSON.parseArray(JSON.toJSONString(map.get("records")), clazz);
sqlResponse.setRecords(list);
return sqlResponse;
}
}

View File

@ -0,0 +1,482 @@
package com.weaver.seconddev.page.util;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.weaver.common.authority.annotation.WeaPermissionMetadata;
import com.weaver.common.authority.context.PermissionContext;
import com.weaver.common.authority.format.WeaSearchConditionWapper;
import com.weaver.common.authority.service.AuthorityService;
import com.weaver.common.authority.service.MenuPermissionSetDTO;
import com.weaver.common.component.browser.combination.TypesBrowserOption;
import com.weaver.common.component.browser.entity.WeaBrowserBean;
import com.weaver.common.component.browser.entity.WeaTypesBrowserBean;
import com.weaver.common.component.form.WeaForm;
import com.weaver.common.component.form.group.WeaFormGroup;
import com.weaver.common.component.form.item.WeaFormItem;
import com.weaver.common.component.form.item.WeaFormItemType;
import com.weaver.common.component.form.item.WeaFormOption;
import com.weaver.common.component.form.layout.WeaFormLayout;
import com.weaver.common.component.search.WeaSearchCondition;
import com.weaver.common.component.search.item.WeaSearchConditionItem;
import com.weaver.common.component.search.item.WeaSearchConditionItemType;
import com.weaver.common.component.search.item.WeaSearchConditionOption;
import com.weaver.common.component.search.layout.WeaSearchConditionLayout;
import com.weaver.common.component.table.WeaTable;
import com.weaver.common.component.table.column.WeaTableColumn;
import com.weaver.common.component.table.operate.WeaTableOperate;
import com.weaver.common.component.table.page.Page;
import com.weaver.common.component.table.permission.Permission;
import com.weaver.common.component.table.type.WeaTableTypeEnum;
import com.weaver.common.i18n.tool.util.I18nContextUtil;
import com.weaver.framework.rpc.context.impl.TenantRpcContext;
import com.weaver.framework.util.JsonUtil;
import com.weaver.seconddev.page.annotation.*;
import com.weaver.seconddev.page.constant.Constant;
import com.weaver.seconddev.page.enums.BaseEnum;
import com.weaver.teams.security.context.TenantContext;
import com.weaver.teams.security.context.UserContext;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
/**
* 前后端组件数据格式化
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@SuppressWarnings("all")
public class FormatUtil<T> {
private static final Logger logger = LoggerFactory.getLogger(FormatUtil.class);
private FormatUtil() {
}
public static <T> FormatUtil<T> getInstance() {
return new FormatUtil<T>();
}
public WeaTable<T> buildTable(Class<T> clazz, Page page) {
Long employeeId = TenantRpcContext.getEmployeeIdLong();
String tenantKey = TenantRpcContext.getCurrentTenantKey();
if (employeeId == null) {
employeeId = TenantRpcContext.getEmployeeIdLong();
}
if (tenantKey == null) {
tenantKey = TenantRpcContext.getCurrentTenantKey();
}
// 加载权限项
AuthorityService authorityService = I18nContextUtil.getBean(AuthorityService.class);
List<MenuPermissionSetDTO> menuPermissionSets = new ArrayList<>();
WeaPermissionMetadata currentPermissionMetadata = PermissionContext.getCurrentPermissionMetadata();
if (currentPermissionMetadata != null) {
menuPermissionSets = currentPermissionMetadata.getMenuPermissionSetDTOList();
}
WeaTable<T> weaTable = new WeaTable<>();
weaTable.setCheckBoxPermission(Collections.emptyList());
weaTable.setPageUid(UUID.randomUUID().toString());
weaTable.setModule(Constant.MODULE);
if (clazz.isAnnotationPresent(Table.class)) {
Table tableAnnotation = clazz.getAnnotation(Table.class);
weaTable.setModule(tableAnnotation.module());
if (StringUtils.isNotEmpty(tableAnnotation.pageUid())) {
weaTable.setPageUid(tableAnnotation.pageUid());
}
weaTable.setTableType(tableAnnotation.tableType());
// 构筑operate
TableOperate[] tableOperates = tableAnnotation.value();
for (TableOperate tableOperate : tableOperates) {
WeaTableOperate weaTableOperate = new WeaTableOperate(I18nUtil.getI18nLabel(tenantKey, employeeId, (int) tableOperate.labelId(), tableOperate.text()), tableOperate.index());
String permissionSetCode = tableOperate.permissionSetCode();
weaTableOperate.setOuter(tableOperate.outer());
if (StringUtils.isEmpty(permissionSetCode)) {
weaTableOperate.setVisible(true);
} else {
if (CollectionUtils.isNotEmpty(menuPermissionSets)) {
boolean visible = menuPermissionSets.stream().anyMatch(e -> StringUtils.equals(e.getCode(), permissionSetCode));
weaTableOperate.setVisible(visible);
} else {
weaTableOperate.setVisible(authorityService.checkPermissionSet(tableOperate.menuCode(), permissionSetCode));
}
}
weaTable.getOperates().add(weaTableOperate);
}
}
List<List<Permission>> operatePermissionList = new ArrayList<>();
List<Permission> checkBoxPermission = new ArrayList<>();
for (Object record : page.getRecords()) {
List<Permission> permissionList = new ArrayList<>();
for (WeaTableOperate operate : weaTable.getOperates()) {
Permission permission = new Permission(operate.isVisible(), false);
permissionList.add(permission);
}
operatePermissionList.add(permissionList);
checkBoxPermission.add(new Permission(true, false));
}
weaTable.setOperatesPermission(operatePermissionList);
// 构筑checkbox permission
if (weaTable.getTableType() == WeaTableTypeEnum.CHECKBOX) {
weaTable.setCheckBoxPermission(checkBoxPermission);
}
List<WeaTableColumn> weaTableColumns = new ArrayList<>();
this.buildTableColumns(clazz, employeeId, tenantKey, weaTableColumns);
weaTable.getColumns().addAll(weaTableColumns);
weaTable.setData(page.getRecords());
weaTable.setDisplayData(page.getRecords());
weaTable.setCurrent(page.getCurrent());
weaTable.setTotal(page.getTotal());
weaTable.setPageSize(page.getSize());
return weaTable;
}
private void buildTableColumns(Class<? super T> clazz, Long employeeId, String tenantKey, List<WeaTableColumn> weaTableColumns) {
if (clazz.equals(Object.class)) {
return;
}
buildTableColumns(clazz.getSuperclass(), employeeId, tenantKey, weaTableColumns);
Field[] declaredFields = clazz.getDeclaredFields();
for (Field declaredField : declaredFields) {
if (!declaredField.isAnnotationPresent(TableColumn.class)) {
continue;
}
TableColumn annotation = declaredField.getAnnotation(TableColumn.class);
WeaTableColumn weaTableColumn = new WeaTableColumn(I18nUtil.getI18nLabel(tenantKey, employeeId, (int) annotation.labelId(), annotation.label()), declaredField.getName());
weaTableColumn.setHide(annotation.hide());
weaTableColumn.setWidth(annotation.width());
weaTableColumns.add(weaTableColumn);
}
}
// @SneakyThrows
// public EditableTable<T> buildEditTable(Class<T> clazz, Page page) {
// WeaTable<T> weaTable = buildTable(clazz, page);
// EditableTable<T> editableTable = new EditableTable<>(weaTable);
// List<SalaryWeaTableColumn> columns = new ArrayList<>();
// for (WeaTableColumn column : weaTable.getColumns()) {
// SalaryWeaTableColumn salaryWeaTableColumn = new SalaryWeaTableColumn();
// BeanUtils.copyProperties(column, salaryWeaTableColumn);
// salaryWeaTableColumn.setComKey(column.getDataIndex());
// columns.add(salaryWeaTableColumn);
// }
// editableTable.setColumns(columns);
//
// Map<String, EditableTableItem> comProps = new HashMap<>();
//
// Field[] declaredFields = clazz.getDeclaredFields();
// for (Field declaredField : declaredFields) {
// if (!declaredField.isAnnotationPresent(SalaryEditTableItem.class)) {
// continue;
// }
// SalaryEditTableItem annotation = declaredField.getAnnotation(SalaryEditTableItem.class);
//
// EditableTableItem editableTableItem = new EditableTableItem(annotation.itemType(),
// annotation.defaultValue(), annotation.readOnly(), annotation.required());
// comProps.put(declaredField.getName(), editableTableItem);
//
// Class<? extends BaseEnum> optionsEnum = Arrays.stream(annotation.optionsEnum()).findFirst().orElse(null);
// if (optionsEnum != null) {
// Method method = null;
// if (StringUtils.isNotEmpty(annotation.optionsEnumMethod())){
// method = optionsEnum.getMethod(annotation.optionsEnumMethod());
// } else {
// method = optionsEnum.getMethod("name");
// }
// BaseEnum[] enumConstants = optionsEnum.getEnumConstants();
// List<WeaFormOption> options = Lists.newArrayListWithExpectedSize(enumConstants.length);
// for (BaseEnum enumConstant : enumConstants) {
// Object value = method.invoke(enumConstant);
// options.add(new WeaFormOption(value.toString(),
// I18nUtil.getI18nLabel(enumConstant.getLabelId(), enumConstant.getDefaultLabel())));
// }
// editableTableItem.setData(options);
// }
// }
// editableTable.setComProps(comProps);
// return editableTable;
// }
public WeaForm buildForm(Class<T> clazz, Object source) {
try {
if (source == null) {
source = clazz.newInstance();
}
T t = source.getClass().equals(clazz) ? (T) source : null;
if (t == null) {
t = clazz.newInstance();
BeanUtils.copyProperties(source, t);
}
Long employeeId = UserContext.getCurrentEmployeeId();
String tenantKey = TenantContext.getCurrentTenantKey();
WeaForm weaForm = new WeaForm();
Map<String, Object> dataMap = JsonUtil.parseMap(source, Object.class);
Map<String, Object> stringDataMap = Maps.newHashMapWithExpectedSize(dataMap.size());
dataMap.forEach((k, v) -> {
if (v instanceof Long) {
stringDataMap.put(k, Objects.isNull(v) ? "" : ((Long) v).toString());
} else {
stringDataMap.put(k, v);
}
});
weaForm.setData(stringDataMap);
String id = stringDataMap.getOrDefault("id", "0").toString();
List<WeaFormLayout> layouts = Lists.newArrayList();
List<WeaFormGroup> groups = Lists.newArrayList();
Map<String, List<WeaFormLayout>> layoutMap = Maps.newLinkedHashMap();
Field[] declaredFields = clazz.getDeclaredFields();
for (Field f : declaredFields) {
if (!f.isAnnotationPresent(Form.class)) {
continue;
}
Form formAnnotation = f.getAnnotation(Form.class);
for (FormItem itemAnnotation : formAnnotation.items()) {
WeaFormItem weaFormItem = new WeaFormItem(itemAnnotation.itemType());
weaFormItem.setReadOnly(itemAnnotation.readOnly());
weaFormItem.setRequired(itemAnnotation.required());
weaFormItem.setMaxLength(itemAnnotation.maxLength());
switch (itemAnnotation.itemType()) {
case BROWSER:
WeaBrowserBean weaBrowserBean = new WeaBrowserBean(itemAnnotation.browserModule(), itemAnnotation.browserType());
weaBrowserBean.setMultiple(itemAnnotation.browserMultiple());
if (Lists.newArrayList("app", "ebuilderForm", "ebuilderField").contains(weaBrowserBean.getType())) {
weaBrowserBean.setCommonParams(ImmutableMap.of("publishStatus", "ALL"));
weaBrowserBean.setCompleteParams(ImmutableMap.of("publishStatus", "ALL"));
weaBrowserBean.setRequestHeaderParams(ImmutableMap.of("ebBusinessid", "10000000000000000"));
}
weaFormItem.setBrowserBean(weaBrowserBean);
break;
case TYPESBROWSER:
WeaTypesBrowserBean weaTypesBrowserBean = new WeaTypesBrowserBean(itemAnnotation.browserModule(), itemAnnotation.browserType());
weaTypesBrowserBean.setMultiple(itemAnnotation.browserMultiple());
weaFormItem.setTypesBrowserBean(weaTypesBrowserBean);
break;
case SHAREBROWSER:
WeaBrowserBean shareBrowserBean = new WeaBrowserBean(itemAnnotation.browserModule(), itemAnnotation.browserType());
shareBrowserBean.setMultiple(itemAnnotation.browserMultiple());
weaFormItem.setShareBrowserBean(shareBrowserBean);
weaFormItem.setOtherParams(ImmutableMap.of("showShareDetail", "true"));
break;
case LOCALE:
String tablefield = "";
MultiLanguage languageAnnotation = f.getAnnotation(MultiLanguage.class);
if (languageAnnotation != null) {
tablefield = languageAnnotation.tablefield();
}
Map<String, Object> otherParamsMap = Maps.newHashMap();
// todo 多语言
// otherParamsMap.put("getUrl", itemAnnotation.langLine() ? SalaryMultiLangConstant.GET_URL_LINE : SalaryMultiLangConstant.GET_URL);
// otherParamsMap.put("getUrlData", ImmutableMap.of("module", SalaryConstant.MODULE,"tablefield", tablefield, "targetId", Util.null2String(id)));
// otherParamsMap.put("saveUrl", itemAnnotation.langLine() ? SalaryMultiLangConstant.SAVE_URL_LINE : SalaryMultiLangConstant.SAVE_URL);
// otherParamsMap.put("saveUrlData", ImmutableMap.of("module",SalaryConstant.MODULE,"tablefield", tablefield, "targetId", Util.null2String(id)));
otherParamsMap.put("useDefaultLangConfig", true);
if (languageAnnotation.itemType() != WeaFormItemType.LOCALE) {
otherParamsMap.put("filedType", languageAnnotation.itemType().name());
}
weaFormItem.setOtherParams(otherParamsMap);
break;
case INPUTNUMBER:
if (itemAnnotation.needNumberSetting()) {
Map<String, Object> numberOtherParamsMap = Maps.newHashMap();
numberOtherParamsMap.put("max", itemAnnotation.max());
numberOtherParamsMap.put("min", itemAnnotation.min());
numberOtherParamsMap.put("precision", itemAnnotation.precision());
weaFormItem.setOtherParams(numberOtherParamsMap);
}
break;
default:
break;
}
Class<? extends BaseEnum> optionsEnum = Arrays.stream(itemAnnotation.optionsEnum()).findFirst().orElse(null);
if (StringUtils.isNotEmpty(itemAnnotation.options())) {
Method declaredMethod = clazz.getDeclaredMethod(itemAnnotation.options().replaceAll("\\(", "").replaceAll("\\)", ""));
declaredMethod.setAccessible(true);
Object options = declaredMethod.invoke(t);
if (options instanceof List) {
List optionsTemp = ((List) options);
if (CollectionUtils.isNotEmpty(optionsTemp)) {
// 获取泛型list真实类型
Object temp = optionsTemp.get(0);
if (temp instanceof WeaFormOption) {
weaFormItem.setOptions((List<WeaFormOption>) options);
} else if (temp instanceof TypesBrowserOption) {
weaFormItem.getTypesBrowserBean().setOptions((List<TypesBrowserOption>) options);
}
}
}
} else if (optionsEnum != null) {
Method method = null;
if (StringUtils.isNotEmpty(itemAnnotation.optionsEnumMethod())) {
method = optionsEnum.getMethod(itemAnnotation.optionsEnumMethod());
} else {
method = optionsEnum.getMethod("name");
}
BaseEnum[] enumConstants = optionsEnum.getEnumConstants();
List<WeaFormOption> options = Lists.newArrayListWithExpectedSize(enumConstants.length);
for (BaseEnum enumConstant : enumConstants) {
Object value = method.invoke(enumConstant);
options.add(new WeaFormOption(value.toString(),
I18nUtil.getI18nLabel(tenantKey, employeeId, enumConstant.getLabelId(), enumConstant.getDefaultLabel())));
}
weaFormItem.setOptions(options);
}
weaForm.getItems().put(StringUtils.isEmpty(itemAnnotation.name()) ? f.getName() : itemAnnotation.name(), weaFormItem);
}
List<String> items = Arrays.stream(formAnnotation.items()).map(FormItem::name).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
if (CollectionUtils.isEmpty(items)) {
items = Lists.newArrayList(f.getName());
}
WeaFormLayout weaFormLayout = new WeaFormLayout(f.getName(), I18nUtil.getI18nLabel(tenantKey, employeeId, formAnnotation.labelId(), formAnnotation.label()), items.toArray(new String[items.size()]));
weaFormLayout.setHide(formAnnotation.hide());
weaFormLayout.setLabelSpan(formAnnotation.labelSpan());
weaFormLayout.setGroupId(formAnnotation.group());
Map<String, Object> otherParamsMap = Maps.newHashMap();
otherParamsMap.put("helpfulTip", I18nUtil.getI18nLabel(formAnnotation.tipLabel(), formAnnotation.tip()));
weaFormLayout.setOtherParams(otherParamsMap);
List<WeaFormLayout> weaFormLayouts = layoutMap.computeIfAbsent(StringUtils.isEmpty(formAnnotation.layout()) ? f.getName() : formAnnotation.layout(), e -> Lists.newArrayList());
weaFormLayouts.add(weaFormLayout);
}
weaForm.getLayout().addAll(layoutMap.values());
weaForm.getGroups().addAll(groups);
return weaForm;
} catch (Exception e) {
logger.error("转换成表单数据格式化失败:{}", e.getMessage(), e);
}
return null;
}
public WeaSearchCondition buildCondition(Class<T> clazz, Object source) {
return this.buildCondition(clazz, source, null);
}
public WeaSearchCondition buildCondition(Class<T> clazz, Object source, String conditionId) {
try {
T t = source.getClass().equals(clazz) ? (T) source : null;
if (t == null) {
t = clazz.newInstance();
BeanUtils.copyProperties(source, t);
}
Long employeeId = UserContext.getCurrentEmployeeId();
String tenantKey = TenantContext.getCurrentTenantKey();
WeaSearchConditionWapper weaSearchCondition = new WeaSearchConditionWapper(StringUtils.isEmpty(conditionId) ? UUID.randomUUID().toString() : conditionId);
List<WeaSearchConditionLayout> otherLayouts = Lists.newArrayListWithExpectedSize(2);
List<WeaSearchConditionLayout> commonLayouts = Lists.newArrayListWithExpectedSize(2);
List<String> quickSearchKeys = Lists.newArrayList();
String module = Constant.MODULE;
Field[] declaredFields = clazz.getDeclaredFields();
for (Field f : declaredFields) {
if (!f.isAnnotationPresent(SearchCondition.class)) {
continue;
}
SearchCondition conditionAnnotation = f.getAnnotation(SearchCondition.class);
// 忽略
if (conditionAnnotation.ignore()) {
continue;
}
SearchConditionItem[] items = conditionAnnotation.items();
for (SearchConditionItem itemAnnotation : items) {
WeaSearchConditionItem weaSearchConditionItem = new WeaSearchConditionItem(itemAnnotation.itemType());
switch (itemAnnotation.itemType()) {
case BROWSER:
WeaBrowserBean weaBrowserBean = new WeaBrowserBean(itemAnnotation.browserModule(), itemAnnotation.browserType());
weaBrowserBean.setMultiple(itemAnnotation.browserMultiple());
weaSearchConditionItem.setBrowserBean(weaBrowserBean);
break;
case TYPESBROWSER:
WeaTypesBrowserBean weaTypesBrowserBean = new WeaTypesBrowserBean(itemAnnotation.browserModule(), itemAnnotation.browserType());
weaTypesBrowserBean.setMultiple(itemAnnotation.browserMultiple());
weaSearchConditionItem.setTypesBrowserBean(weaTypesBrowserBean);
break;
default:
break;
}
if (itemAnnotation.itemType() == WeaSearchConditionItemType.DATEPICKER && itemAnnotation.isRange()) {
Map<String, Object> otherParams = new HashMap<>();
otherParams.put("isRange", true);
weaSearchConditionItem.setOtherParams(otherParams);
}
Class<? extends BaseEnum> optionsEnum = Arrays.stream(itemAnnotation.optionsEnum()).findFirst().orElse(null);
if (StringUtils.isNotEmpty(itemAnnotation.options())) {
Method declaredMethod = clazz.getDeclaredMethod(itemAnnotation.options().replaceAll("\\(", "").replaceAll("\\)", ""));
declaredMethod.setAccessible(true);
Object options = declaredMethod.invoke(t);
if (options instanceof List) {
List optionsTemp = ((List) options);
if (CollectionUtils.isNotEmpty(optionsTemp)) {
// 获取泛型list真实类型
Object temp = optionsTemp.get(0);
if (temp instanceof WeaSearchConditionOption) {
weaSearchConditionItem.setOptions((List<WeaSearchConditionOption>) options);
} else if (temp instanceof TypesBrowserOption) {
weaSearchConditionItem.getTypesBrowserBean().setOptions((List<TypesBrowserOption>) options);
}
}
}
} else if (optionsEnum != null) {
BaseEnum[] enumConstants = optionsEnum.getEnumConstants();
List<WeaSearchConditionOption> options = Lists.newArrayListWithExpectedSize(enumConstants.length);
for (BaseEnum enumConstant : enumConstants) {
options.add(new WeaSearchConditionOption(enumConstant.name(),
I18nUtil.getI18nLabel(tenantKey, employeeId, enumConstant.getLabelId(), enumConstant.getDefaultLabel())));
}
weaSearchConditionItem.setOptions(options);
}
weaSearchCondition.getItems().put(itemAnnotation.name(), weaSearchConditionItem);
}
Map<String, List<SearchConditionItem>> itemMapByGroupId = Lists.newArrayList(items).stream()
.collect(Collectors.groupingBy(SearchConditionItem::groupId));
itemMapByGroupId.forEach((k, v) -> {
WeaSearchConditionLayout weaSearchConditionLayout = new WeaSearchConditionLayout(f.getName(),
I18nUtil.getI18nLabel(tenantKey, employeeId, conditionAnnotation.labelId(), conditionAnnotation.label()), k,
v.stream().map(SearchConditionItem::name).collect(Collectors.toList()).toArray(new String[v.size()]));
weaSearchConditionLayout.setLabelSpan(conditionAnnotation.labelSpan());
weaSearchConditionLayout.setNeedQuickSearch(conditionAnnotation.needQuickSearch());
if (StringUtils.equals(k, "commonGroup")) {
commonLayouts.add(weaSearchConditionLayout);
if (commonLayouts.size() == 2) {
weaSearchCondition.getLayout().add(new ArrayList<>(commonLayouts));
commonLayouts.clear();
}
}
if (StringUtils.equals(k, "otherGroup")) {
otherLayouts.add(weaSearchConditionLayout);
if (otherLayouts.size() == 2) {
weaSearchCondition.getLayout().add(new ArrayList<>(otherLayouts));
otherLayouts.clear();
}
}
});
if (StringUtils.isNotEmpty(conditionAnnotation.quickSearchKey())) {
quickSearchKeys.add(conditionAnnotation.quickSearchKey());
}
}
weaSearchCondition.setModule(module);
weaSearchCondition.setQuickSearchKey(StringUtils.join(quickSearchKeys.toArray(), ","));
if (CollectionUtils.isNotEmpty(commonLayouts)) {
weaSearchCondition.getLayout().add(new ArrayList<>(commonLayouts));
}
if (CollectionUtils.isNotEmpty(otherLayouts)) {
weaSearchCondition.getLayout().add(new ArrayList<>(otherLayouts));
}
return weaSearchCondition;
} catch (Exception e) {
logger.error("前后端组件数据格式化失败:{}", e.getMessage(), e);
}
return null;
}
}

View File

@ -0,0 +1,41 @@
package com.weaver.seconddev.page.util;
import com.weaver.common.i18n.label.SystemEnv;
import com.weaver.common.i18n.tool.util.I18nLanguageUtil;
/**
* 多语言工具类
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class I18nUtil {
/**
* 获取多语言信息
*
* @param labelId 多语言对应的labelId
* @param defaultLabel 默认中文
* @return
*/
@Deprecated
public static String getI18nLabel(int labelId, String defaultLabel) {
return SystemEnv.getHtmlLabelName(labelId, 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 SystemEnv.getHtmlLabelName(labelId, languageId, tenantKey, defaultLabel);
}
}

View File

@ -0,0 +1,69 @@
package com.weaver.seconddev.page.util;
import com.weaver.common.component.table.page.Page;
import com.weaver.common.component.util.CommonPageUtil;
import org.apache.commons.collections4.CollectionUtils;
import java.util.Collections;
import java.util.List;
/**
* 分页相关的工具类
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class PageUtil {
private PageUtil() {
throw new IllegalStateException("Utility class");
}
public static <T> Page<T> buildPage(Long pageNo, Long pageSize) {
pageNo = pageNo == null || pageNo <= 0 ? 1L : pageNo;
pageSize = pageSize == null || pageSize <= 0 ? 10L : pageSize;
return new Page<>(pageNo, pageSize, true);
}
public static <T> Page<T> buildPage(List<T> list, Long pageNo, Long pageSize) {
Page<T> dtoPage = buildPage(pageNo, pageSize);
// 填充总数和当页数据
dtoPage.setTotal(list.size());
dtoPage.setRecords(subList((int) dtoPage.getCurrent(), (int) dtoPage.getSize(), list));
return dtoPage;
}
/**
* 分页
*
* @param pageNo 页码从1开始
* @param pageSize 每页条数
* @param source 待分页的数据
* @param <T> 范型制定类
* @return
*/
public static <T> List<T> subList(int pageNo, int pageSize, List<T> source) {
if (CollectionUtils.isEmpty(source)) {
return Collections.emptyList();
}
int endIndex = pageNo * pageSize;
int startIndex = (pageNo - 1) * pageSize;
startIndex = Math.max(startIndex, 0);
return source.subList(Math.min(startIndex, source.size()),
Math.min(endIndex, source.size()));
}
public static Long getPageSize(String pageUid) {
return getPageSize(pageUid, 10L);
}
public static Long getPageSize(String pageUid, long defaultPageSize) {
long pageSize = CommonPageUtil.getPageSize(pageUid);
return pageSize > 0 ? pageSize : defaultPageSize;
}
}

View File

@ -0,0 +1,8 @@
plugins{
id 'java'
}
description = ""
dependencies {
//
}

34
settings.gradle Normal file
View File

@ -0,0 +1,34 @@
//
rootProject.name = 'secondev-demo'
def projectNames = []
def discoverProjects
discoverProjects = { File directory, String prefix ->
directory.eachDir { subDir ->
def buildFilePath = new File(subDir.getCanonicalPath(), subDir.name + ".gradle");
if (buildFilePath.exists()) {
def projectPath = buildFilePath.getParentFile().getCanonicalPath();
// .disabled文件
if (new File(projectPath + File.separator + ".disabled").exists()) {
return;
}
projectNames.add(projectPath)
} else if (subDir.isDirectory()) {
discoverProjects(new File(subDir.getPath()), prefix + subDir.name + ":")
}
}
}
discoverProjects(rootProject.projectDir, "")
println('root dir: ' + rootDir)
projectNames.forEach { projectName ->
def proj = new File((String) projectName)
//
def rel_path = proj.getCanonicalPath().replace(rootDir.toString() + File.separator, "")
def include_path = rel_path.replace(File.separator, ":");
println("include: ${rel_path}, ref: ${include_path}")
include include_path
project(":${include_path}").buildFileName = proj.getName() + ".gradle"
}