mapper优化,流程条件赋值action
parent
e9fedf8b8f
commit
63bf2a1642
|
@ -447,7 +447,7 @@ $(() => {
|
||||||
$(() => {
|
$(() => {
|
||||||
const config = {
|
const config = {
|
||||||
table: 'detail_1',
|
table: 'detail_1',
|
||||||
field: ['fj']
|
field: ['qswj']
|
||||||
}
|
}
|
||||||
|
|
||||||
function check() {
|
function check() {
|
||||||
|
@ -456,7 +456,7 @@ $(() => {
|
||||||
try {
|
try {
|
||||||
rowIndexArr.forEach(item => {
|
rowIndexArr.forEach(item => {
|
||||||
config.field.forEach(field => {
|
config.field.forEach(field => {
|
||||||
let value = WfForm.getFieldValue(WfForm.convertFieldNameToId(field, <table></table>) + "_" + item)
|
let value = WfForm.getFieldValue(WfForm.convertFieldNameToId(field, config.table) + "_" + item)
|
||||||
if (value == '' || value == null) {
|
if (value == '' || value == null) {
|
||||||
throw field + " is can not be null!";
|
throw field + " is can not be null!";
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,196 +29,195 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GenerateFileUtil {
|
public class GenerateFileUtil {
|
||||||
|
|
||||||
private static final Logger log = Util.getLogger();
|
private static final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>根据Action类生成Action配置文档</h2>
|
* <h2>根据Action类生成Action配置文档</h2>
|
||||||
*
|
*
|
||||||
* @param tClass Action类
|
* @param tClass Action类
|
||||||
* @param <T> Action接口
|
* @param <T> Action接口
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public static <T extends Action> void createActionDocument(Class<T>... tClass) {
|
public static <T extends Action> void createActionDocument(Class<T>... tClass) {
|
||||||
for (Class<T> aClass : tClass) {
|
for (Class<T> aClass : tClass) {
|
||||||
createDocument(aClass, 1);
|
createDocument(aClass, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>根据定时任务类生成定时任务配置文档</h2>
|
* <h2>根据定时任务类生成定时任务配置文档</h2>
|
||||||
*
|
*
|
||||||
* @param tClass 定时任务类
|
* @param tClass 定时任务类
|
||||||
* @param <T> Action接口
|
* @param <T> Action接口
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public static <T extends BaseCronJob> void createCronJobDocument(Class<T>... tClass) {
|
public static <T extends BaseCronJob> void createCronJobDocument(Class<T>... tClass) {
|
||||||
for (Class<T> aClass : tClass) {
|
for (Class<T> aClass : tClass) {
|
||||||
createDocument(aClass, 2);
|
createDocument(aClass, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>根据类生成配置文档</h2>
|
* <h2>根据类生成配置文档</h2>
|
||||||
*
|
*
|
||||||
* @param tClass 类
|
* @param tClass 类
|
||||||
* @param <T> 接口
|
* @param <T> 接口
|
||||||
*/
|
*/
|
||||||
private static <T> void createDocument(Class<T> tClass, Integer type) {
|
private static <T> void createDocument(Class<T> tClass, Integer type) {
|
||||||
if (tClass == null) {
|
if (tClass == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!tClass.isAnnotationPresent(ActionDesc.class)) {
|
if (!tClass.isAnnotationPresent(ActionDesc.class)) {
|
||||||
log.info(Util.logStr("[{}] has not ActionDesc annotation!", tClass.getName()));
|
throw new CustomerException(Util.logStr("[{}] has not ActionDesc annotation!", tClass.getName()));
|
||||||
return;
|
}
|
||||||
}
|
ActionDesc actionDesc = tClass.getAnnotation(ActionDesc.class);
|
||||||
ActionDesc actionDesc = tClass.getAnnotation(ActionDesc.class);
|
String author = actionDesc.author();
|
||||||
String author = actionDesc.author();
|
String actionDescValue = actionDesc.value();
|
||||||
String actionDescValue = actionDesc.value();
|
String actionName = tClass.getSimpleName();
|
||||||
String actionName = tClass.getSimpleName();
|
String actionAllPathName = tClass.getName();
|
||||||
String actionAllPathName = tClass.getName();
|
List<Map<String, String>> paramList = new ArrayList<>();
|
||||||
List<Map<String, String>> paramList = new ArrayList<>();
|
for (Field declaredField : tClass.getDeclaredFields()) {
|
||||||
for (Field declaredField : tClass.getDeclaredFields()) {
|
boolean hasRequired = declaredField.isAnnotationPresent(RequiredMark.class);
|
||||||
boolean hasRequired = declaredField.isAnnotationPresent(RequiredMark.class);
|
String name = declaredField.getName();
|
||||||
String name = declaredField.getName();
|
if (hasRequired) {
|
||||||
if (hasRequired) {
|
|
||||||
// 必填参数
|
// 必填参数
|
||||||
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
|
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
|
||||||
String fieldDesc = requiredMark.value();
|
String fieldDesc = requiredMark.value();
|
||||||
Map<String, String> param = new HashMap<>();
|
Map<String, String> param = new HashMap<>();
|
||||||
param.put("name", name);
|
param.put("name", name);
|
||||||
param.put("desc", fieldDesc);
|
param.put("desc", fieldDesc);
|
||||||
param.put("isRequired", "是");
|
param.put("isRequired", "是");
|
||||||
boolean hasDefaultTestValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
|
boolean hasDefaultTestValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
|
||||||
if (hasDefaultTestValue) {
|
if (hasDefaultTestValue) {
|
||||||
// 示例值
|
// 示例值
|
||||||
ActionDefaultTestValue defaultTestValue = declaredField.getAnnotation(ActionDefaultTestValue.class);
|
ActionDefaultTestValue defaultTestValue = declaredField.getAnnotation(ActionDefaultTestValue.class);
|
||||||
param.put("example", defaultTestValue.value());
|
param.put("example", defaultTestValue.value());
|
||||||
}
|
}
|
||||||
paramList.add(param);
|
paramList.add(param);
|
||||||
} else {
|
} else {
|
||||||
// 非必填参数
|
// 非必填参数
|
||||||
boolean hasActionOptional = declaredField.isAnnotationPresent(ActionOptionalParam.class);
|
boolean hasActionOptional = declaredField.isAnnotationPresent(ActionOptionalParam.class);
|
||||||
if (hasActionOptional) {
|
if (hasActionOptional) {
|
||||||
// 可选参数
|
// 可选参数
|
||||||
ActionOptionalParam actionOptionalParam = declaredField.getAnnotation(ActionOptionalParam.class);
|
ActionOptionalParam actionOptionalParam = declaredField.getAnnotation(ActionOptionalParam.class);
|
||||||
String fieldDesc = actionOptionalParam.desc();
|
String fieldDesc = actionOptionalParam.desc();
|
||||||
String defaultValue = actionOptionalParam.value();
|
String defaultValue = actionOptionalParam.value();
|
||||||
Map<String, String> param = new HashMap<>();
|
Map<String, String> param = new HashMap<>();
|
||||||
param.put("name", name);
|
param.put("name", name);
|
||||||
param.put("desc", fieldDesc);
|
param.put("desc", fieldDesc);
|
||||||
param.put("isRequired", "否");
|
param.put("isRequired", "否");
|
||||||
param.put("defaultValue", defaultValue);
|
param.put("defaultValue", defaultValue);
|
||||||
paramList.add(param);
|
paramList.add(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, Object> vmParam = new HashMap<>();
|
Map<String, Object> vmParam = new HashMap<>();
|
||||||
vmParam.put("author", author);
|
vmParam.put("author", author);
|
||||||
vmParam.put("actionDesc", actionDescValue);
|
vmParam.put("actionDesc", actionDescValue);
|
||||||
vmParam.put("actionName", actionName);
|
vmParam.put("actionName", actionName);
|
||||||
vmParam.put("actionAllPathName", actionAllPathName);
|
vmParam.put("actionAllPathName", actionAllPathName);
|
||||||
vmParam.put("paramList", paramList);
|
vmParam.put("paramList", paramList);
|
||||||
vmParam.put("type", type);
|
vmParam.put("type", type);
|
||||||
vmParam.put("createTime", Util.getTime("yyyy-MM-dd HH:mm:ss"));
|
vmParam.put("createTime", Util.getTime("yyyy-MM-dd HH:mm:ss"));
|
||||||
VelocityEngine ve = new VelocityEngine();
|
VelocityEngine ve = new VelocityEngine();
|
||||||
ve.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
|
ve.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
|
||||||
String path = weaver.general.GCONST.getPropertyPath().replace("prop", "vm");
|
String path = weaver.general.GCONST.getPropertyPath().replace("prop", "vm");
|
||||||
ve.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
|
ve.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
|
||||||
/* ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath")
|
/* ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath")
|
||||||
ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());*/
|
ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());*/
|
||||||
try {
|
try {
|
||||||
ve.init();
|
ve.init();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// 获取模板文件
|
// 获取模板文件
|
||||||
try {
|
try {
|
||||||
Template template = ve.getTemplate("ActionConfigTemplate.md.vm", "UTF-8");
|
Template template = ve.getTemplate("ActionConfigTemplate.md.vm", "UTF-8");
|
||||||
String prefix = type == 1 ? "Action" : "定时任务";
|
String prefix = type == 1 ? "Action" : "定时任务";
|
||||||
String fileName = prefix + "部署配置文档-" + actionName + "-" + author + "-" + Util.getTime("yyyyMMddHHmmss") + ".md";
|
String fileName = prefix + "部署配置文档-" + actionName + "-" + author + "-" + Util.getTime("yyyyMMddHHmmss") + ".md";
|
||||||
File saveFile = new File(path + "outFile" + File.separator + fileName);
|
File saveFile = new File(path + "outFile" + File.separator + fileName);
|
||||||
if (!saveFile.getParentFile().exists()) {
|
if (!saveFile.getParentFile().exists()) {
|
||||||
saveFile.getParentFile().mkdirs();
|
saveFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
// 创建文件输出流
|
// 创建文件输出流
|
||||||
FileOutputStream outStream = new FileOutputStream(saveFile);
|
FileOutputStream outStream = new FileOutputStream(saveFile);
|
||||||
// 因为模板整合的时候,需要提供一个Writer,所以创建一个Writer
|
// 因为模板整合的时候,需要提供一个Writer,所以创建一个Writer
|
||||||
OutputStreamWriter writer = new OutputStreamWriter(outStream);
|
OutputStreamWriter writer = new OutputStreamWriter(outStream);
|
||||||
// 创建一个缓冲流
|
// 创建一个缓冲流
|
||||||
BufferedWriter bufferWriter = new BufferedWriter(writer);
|
BufferedWriter bufferWriter = new BufferedWriter(writer);
|
||||||
|
|
||||||
VelocityContext ctx = new VelocityContext(vmParam);
|
VelocityContext ctx = new VelocityContext(vmParam);
|
||||||
// 5 合并模板和数据并输出
|
// 5 合并模板和数据并输出
|
||||||
template.merge(ctx, bufferWriter);
|
template.merge(ctx, bufferWriter);
|
||||||
// 强制刷新
|
// 强制刷新
|
||||||
bufferWriter.flush();
|
bufferWriter.flush();
|
||||||
outStream.close();
|
outStream.close();
|
||||||
bufferWriter.close();
|
bufferWriter.close();
|
||||||
System.out.println("\n\t文件生成成功:" + path + "outFile" + File.separator + fileName + "\n");
|
System.out.println("\n\t文件生成成功:" + path + "outFile" + File.separator + fileName + "\n");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CustomerException("创建模版文件失败!", e);
|
throw new CustomerException("创建模版文件失败!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>生成Action模版代码</h2>
|
* <h2>生成Action模版代码</h2>
|
||||||
*
|
*
|
||||||
* @param actionTemplate action模版必要参数
|
* @param actionTemplate action模版必要参数
|
||||||
*/
|
*/
|
||||||
public static void createActionTemplate(ActionTemplate actionTemplate) {
|
public static void createActionTemplate(ActionTemplate actionTemplate) {
|
||||||
File directory = new File("");
|
File directory = new File("");
|
||||||
String courseFile = null;
|
String courseFile = null;
|
||||||
try {
|
try {
|
||||||
courseFile = directory.getCanonicalPath();
|
courseFile = directory.getCanonicalPath();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new CustomerException("无法获取当前项目的路径所在位置!");
|
throw new CustomerException("无法获取当前项目的路径所在位置!");
|
||||||
}
|
}
|
||||||
String targetPath = courseFile + File.separator +
|
String targetPath = courseFile + File.separator +
|
||||||
actionTemplate.getSrcDirectory().replaceAll("\\.", File.separator);
|
actionTemplate.getSrcDirectory().replaceAll("\\.", File.separator);
|
||||||
targetPath = targetPath + File.separator + actionTemplate.getPackageName().replaceAll("\\.", File.separator);
|
targetPath = targetPath + File.separator + actionTemplate.getPackageName().replaceAll("\\.", File.separator);
|
||||||
String fileName = targetPath + File.separator + actionTemplate.getActionName() + ".java";
|
String fileName = targetPath + File.separator + actionTemplate.getActionName() + ".java";
|
||||||
|
|
||||||
Map<String, Object> vmParam = new HashMap<>();
|
Map<String, Object> vmParam = new HashMap<>();
|
||||||
vmParam.put("author", actionTemplate.getAuthor());
|
vmParam.put("author", actionTemplate.getAuthor());
|
||||||
vmParam.put("actionDesc", actionTemplate.getActionDesc());
|
vmParam.put("actionDesc", actionTemplate.getActionDesc());
|
||||||
vmParam.put("fileName", actionTemplate.getActionName());
|
vmParam.put("fileName", actionTemplate.getActionName());
|
||||||
vmParam.put("package", actionTemplate.getPackageName());
|
vmParam.put("package", actionTemplate.getPackageName());
|
||||||
vmParam.put("createTime", Util.getTime("yyyy-MM-dd HH:mm:ss"));
|
vmParam.put("createTime", Util.getTime("yyyy-MM-dd HH:mm:ss"));
|
||||||
VelocityEngine ve = new VelocityEngine();
|
VelocityEngine ve = new VelocityEngine();
|
||||||
try {
|
try {
|
||||||
ve.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
|
ve.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
|
||||||
String path = weaver.general.GCONST.getPropertyPath().replace("prop", "vm");
|
String path = weaver.general.GCONST.getPropertyPath().replace("prop", "vm");
|
||||||
ve.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
|
ve.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
|
||||||
ve.init();
|
ve.init();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// 获取模板文件
|
// 获取模板文件
|
||||||
try {
|
try {
|
||||||
Template template = ve.getTemplate("ActionJavaFileTemplate.java.vm", "UTF-8");
|
Template template = ve.getTemplate("ActionJavaFileTemplate.java.vm", "UTF-8");
|
||||||
File saveFile = new File(fileName);
|
File saveFile = new File(fileName);
|
||||||
if (!saveFile.getParentFile().exists()) {
|
if (!saveFile.getParentFile().exists()) {
|
||||||
saveFile.getParentFile().mkdirs();
|
saveFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
if (saveFile.exists()) {
|
if (saveFile.exists()) {
|
||||||
throw new CustomerException("文件:" + fileName + " is exists;");
|
throw new CustomerException("文件:" + fileName + " is exists;");
|
||||||
}
|
}
|
||||||
FileOutputStream outStream = new FileOutputStream(saveFile);
|
FileOutputStream outStream = new FileOutputStream(saveFile);
|
||||||
OutputStreamWriter writer = new OutputStreamWriter(outStream);
|
OutputStreamWriter writer = new OutputStreamWriter(outStream);
|
||||||
BufferedWriter bufferWriter = new BufferedWriter(writer);
|
BufferedWriter bufferWriter = new BufferedWriter(writer);
|
||||||
VelocityContext ctx = new VelocityContext(vmParam);
|
VelocityContext ctx = new VelocityContext(vmParam);
|
||||||
template.merge(ctx, bufferWriter);
|
template.merge(ctx, bufferWriter);
|
||||||
bufferWriter.flush();
|
bufferWriter.flush();
|
||||||
outStream.close();
|
outStream.close();
|
||||||
bufferWriter.close();
|
bufferWriter.close();
|
||||||
System.out.println("\n\t文件生成成功:" + fileName + "\n");
|
System.out.println("\n\t文件生成成功:" + fileName + "\n");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CustomerException("创建模版文件失败!", e);
|
throw new CustomerException("创建模版文件失败!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3345,63 +3345,63 @@ public class Util extends weaver.general.Util {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
action = cronJobClass.newInstance();
|
action = cronJobClass.newInstance();
|
||||||
for (Field declaredField : declaredFields) {
|
for (Field declaredField : declaredFields) {
|
||||||
// 必填参数验证
|
// 必填参数验证
|
||||||
boolean hasRequiredMark = declaredField.isAnnotationPresent(RequiredMark.class);
|
boolean hasRequiredMark = declaredField.isAnnotationPresent(RequiredMark.class);
|
||||||
String name = declaredField.getName();
|
String name = declaredField.getName();
|
||||||
String setMethodName = getSetMethodName(name);
|
String setMethodName = getSetMethodName(name);
|
||||||
String value = params.get(name);
|
String value = params.get(name);
|
||||||
boolean hasDefaultValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
|
boolean hasDefaultValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
|
||||||
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
|
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
|
||||||
ActionDefaultTestValue defaultTestValue = declaredField.getAnnotation(ActionDefaultTestValue.class);
|
ActionDefaultTestValue defaultTestValue = declaredField.getAnnotation(ActionDefaultTestValue.class);
|
||||||
boolean hasOptional = declaredField.isAnnotationPresent(ActionOptionalParam.class);
|
boolean hasOptional = declaredField.isAnnotationPresent(ActionOptionalParam.class);
|
||||||
// 如果存在默认值,并且是必填参数
|
// 如果存在默认值,并且是必填参数
|
||||||
if (hasDefaultValue && hasRequiredMark) {
|
if (hasDefaultValue && hasRequiredMark) {
|
||||||
// 如果参数map中没有则赋值为默认值
|
// 如果参数map中没有则赋值为默认值
|
||||||
if (null == value) {
|
if (null == value) {
|
||||||
// 获取默认值赋值
|
// 获取默认值赋值
|
||||||
String defaultValue = defaultTestValue.value();
|
String defaultValue = defaultTestValue.value();
|
||||||
if (defaultValue == null) {
|
if (defaultValue == null) {
|
||||||
throw new CustomerException(String.format("必填参数[%s]未填写:%s", name, requiredMark.value()));
|
throw new CustomerException(String.format("必填参数[%s]未填写:%s", name, requiredMark.value()));
|
||||||
}
|
}
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
// 如果没有默认值,并且是必填参数
|
// 如果没有默认值,并且是必填参数
|
||||||
} else if (!hasDefaultValue && hasRequiredMark) {
|
} else if (!hasDefaultValue && hasRequiredMark) {
|
||||||
// 如果没有从param中获取到,则抛出异常
|
// 如果没有从param中获取到,则抛出异常
|
||||||
if (Util.isNullOrEmpty(value)) {
|
if (Util.isNullOrEmpty(value)) {
|
||||||
throw new CustomerException(String.format("必填参数[%s]未填写:%s", name, requiredMark.value()));
|
throw new CustomerException(String.format("必填参数[%s]未填写:%s", name, requiredMark.value()));
|
||||||
}
|
}
|
||||||
// 如果有默认值,并且没有从params中获得,则赋值
|
// 如果有默认值,并且没有从params中获得,则赋值
|
||||||
} else if (hasDefaultValue) {
|
} else if (hasDefaultValue) {
|
||||||
if (null == value) {
|
if (null == value) {
|
||||||
value = defaultTestValue.value();
|
value = defaultTestValue.value();
|
||||||
}
|
}
|
||||||
} else if (hasOptional) {
|
} else if (hasOptional) {
|
||||||
// 如果存在可选值
|
// 如果存在可选值
|
||||||
ActionOptionalParam optionalParam = declaredField.getAnnotation(ActionOptionalParam.class);
|
ActionOptionalParam optionalParam = declaredField.getAnnotation(ActionOptionalParam.class);
|
||||||
String defaultValue = optionalParam.value();
|
String defaultValue = optionalParam.value();
|
||||||
// 可选值没有在param中存在
|
// 可选值没有在param中存在
|
||||||
if (null == value) {
|
if (null == value) {
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// 都不符合必填和默认值的参数,判断params中是否存在,如果不存在则直接跳过
|
// 都不符合必填和默认值的参数,判断params中是否存在,如果不存在则直接跳过
|
||||||
if (null == value) {
|
if (null == value) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
value = params.get(name);
|
value = params.get(name);
|
||||||
}
|
}
|
||||||
Method method = cronJobClass.getMethod(setMethodName, String.class);
|
Method method = cronJobClass.getMethod(setMethodName, String.class);
|
||||||
method.invoke(action, value);
|
method.invoke(action, value);
|
||||||
}
|
}
|
||||||
action.execute();
|
action.execute();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CustomerException("计划任务执行异常!异常信息:\n" + Util.getErrString(e));
|
throw new CustomerException("计划任务执行异常!异常信息:\n" + Util.getErrString(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().info(Util.logStr("\n\t计划任务 [{}] getDataId success!\n", cronJobClass.getName()));
|
getLogger().info(Util.logStr("\n\t计划任务 [{}] execute success!\n", cronJobClass.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3424,45 +3424,46 @@ public class Util extends weaver.general.Util {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
action = actionClass.newInstance();
|
action = actionClass.newInstance();
|
||||||
for (Field declaredField : declaredFields) {
|
for (Field declaredField : declaredFields) {
|
||||||
// 必填参数验证
|
// 必填参数验证
|
||||||
boolean hasRequiredMark = declaredField.isAnnotationPresent(RequiredMark.class);
|
boolean hasRequiredMark = declaredField.isAnnotationPresent(RequiredMark.class);
|
||||||
String name = declaredField.getName();
|
String name = declaredField.getName();
|
||||||
String setMethodName = getSetMethodName(name);
|
String setMethodName = getSetMethodName(name);
|
||||||
String value = params.get(name);
|
String value = params.get(name);
|
||||||
boolean hasDefaultValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
|
boolean hasDefaultValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
|
||||||
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
|
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
|
||||||
ActionDefaultTestValue defaultTestValue = declaredField.getAnnotation(ActionDefaultTestValue.class);
|
ActionDefaultTestValue defaultTestValue = declaredField.getAnnotation(ActionDefaultTestValue.class);
|
||||||
if (hasDefaultValue && hasRequiredMark) {
|
if (hasDefaultValue && hasRequiredMark) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
String defaultValue = defaultTestValue.value();
|
String defaultValue = defaultTestValue.value();
|
||||||
if (defaultValue == null) {
|
if (defaultValue == null) {
|
||||||
throw new CustomerException(String.format("必填参数[%s]未填写:%s", name, requiredMark.value()));
|
throw new CustomerException(String.format("必填参数[%s]未填写:%s", name, requiredMark.value()));
|
||||||
}
|
}
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
} else if (!hasDefaultValue && hasRequiredMark) {
|
} else if (!hasDefaultValue && hasRequiredMark) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new CustomerException(String.format("必填参数[%s]未填写:%s", name, requiredMark.value()));
|
throw new CustomerException(String.format("必填参数[%s]未填写:%s", name, requiredMark.value()));
|
||||||
}
|
}
|
||||||
} else if (hasDefaultValue) {
|
} else if (hasDefaultValue) {
|
||||||
value = defaultTestValue.value();
|
value = defaultTestValue.value();
|
||||||
}
|
}
|
||||||
if (!params.containsKey(name) && Util.isNullOrEmpty(value)) {
|
if (!params.containsKey(name) && Util.isNullOrEmpty(value)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (params.containsKey(name)) {
|
if (params.containsKey(name)) {
|
||||||
value = params.get(name);
|
value = params.get(name);
|
||||||
}
|
}
|
||||||
Method method = actionClass.getMethod(setMethodName, String.class);
|
Method method = actionClass.getMethod(setMethodName, String.class);
|
||||||
method.invoke(action, value);
|
method.invoke(action, value);
|
||||||
}
|
}
|
||||||
RequestService requestService = new RequestService();
|
RequestService requestService = new RequestService();
|
||||||
requestInfo = requestService.getRequest(requestId);
|
requestInfo = requestService.getRequest(requestId);
|
||||||
if (null == requestInfo) {
|
if (null == requestInfo) {
|
||||||
throw new CustomerException("没有查找到对应的请求requestId : " + requestId);
|
throw new CustomerException("没有查找到对应的请求requestId : " + requestId);
|
||||||
}
|
}
|
||||||
requestInfo.getRequestManager().setSrc(runType);
|
requestInfo.getRequestManager().setSrc(runType);
|
||||||
|
requestInfo.getRequestManager().setUser(new User(1));
|
||||||
execute = action.execute(requestInfo);
|
execute = action.execute(requestInfo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CustomerException("action执行异常!异常信息:\n" + Util.getErrString(e));
|
throw new CustomerException("action执行异常!异常信息:\n" + Util.getErrString(e));
|
||||||
|
@ -3470,7 +3471,7 @@ public class Util extends weaver.general.Util {
|
||||||
if (Action.FAILURE_AND_CONTINUE.equals(execute)) {
|
if (Action.FAILURE_AND_CONTINUE.equals(execute)) {
|
||||||
throw new CustomerException("action执行失败,失败原因:\n" + requestInfo.getRequestManager().getMessagecontent());
|
throw new CustomerException("action执行失败,失败原因:\n" + requestInfo.getRequestManager().getMessagecontent());
|
||||||
}
|
}
|
||||||
getLogger().info(Util.logStr("\n\n\tAction [{}] getDataId success!\n", actionClass.getName()));
|
getLogger().info(Util.logStr("\n\n\tAction [{}] execute success!\n", actionClass.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSetMethodName(String fieldName) {
|
public static String getSetMethodName(String fieldName) {
|
||||||
|
@ -3638,12 +3639,52 @@ public class Util extends weaver.general.Util {
|
||||||
return o.execute(pathParam, requestId, billTable, workflowId, user, requestInfo);
|
return o.execute(pathParam, requestId, billTable, workflowId, user, requestInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>通过表fromid查询表名</h2>
|
||||||
|
*
|
||||||
|
* @param fromId fromid
|
||||||
|
* @return 表名
|
||||||
|
*/
|
||||||
public static String selectBillTableByFromId(String fromId) {
|
public static String selectBillTableByFromId(String fromId) {
|
||||||
return mapper.selectBillTableByFromId(fromId);
|
return mapper.selectBillTableByFromId(fromId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>删除表数据</h2>
|
||||||
|
*
|
||||||
|
* @param tableName 表
|
||||||
|
* @param dataId 数据id
|
||||||
|
*/
|
||||||
public static void deleteModeId(String tableName, Integer dataId) {
|
public static void deleteModeId(String tableName, Integer dataId) {
|
||||||
mapper.deleteModeId(tableName, dataId);
|
mapper.deleteModeId(tableName, dataId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>首字母大写</h2>
|
||||||
|
*
|
||||||
|
* @param str 字符串
|
||||||
|
* @return 转换后字符串
|
||||||
|
*/
|
||||||
|
public static String firstUpperCase(String str) {
|
||||||
|
if (Strings.isNullOrEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>通过fieldViewInfo对象获取map的值 </h2>
|
||||||
|
*
|
||||||
|
* @param fieldInfo 字段信息对象
|
||||||
|
* @param workflowData 流程值
|
||||||
|
* @return 值
|
||||||
|
*/
|
||||||
|
public static Object getValueByFieldViwInfo(FieldViewInfo fieldInfo, Map<String, Object> workflowData) {
|
||||||
|
String tableName = fieldInfo.getTableName();
|
||||||
|
String[] dts = tableName.split("_dt");
|
||||||
|
if (dts.length == 2) {
|
||||||
|
return Util.getValueByKeyStr("detail_" + dts[1] + "." + fieldInfo.getFieldName(), workflowData);
|
||||||
|
}
|
||||||
|
return Util.getValueByKeyStr("main." + fieldInfo.getFieldName(), workflowData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,317 +21,317 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract class CusBaseAction implements Action {
|
public abstract class CusBaseAction implements Action {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局日志对象
|
* 全局日志对象
|
||||||
*/
|
*/
|
||||||
protected final Logger log = Util.getLogger();
|
protected final Logger log = Util.getLogger();
|
||||||
private final Map<String, CusBaseActionHandleFunction> actionHandleMethod = new HashMap<>();
|
private final Map<String, CusBaseActionHandleFunction> actionHandleMethod = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* 全局requestInfo对象
|
* 全局requestInfo对象
|
||||||
*/
|
*/
|
||||||
protected RequestInfo globalRequestInfo;
|
protected RequestInfo globalRequestInfo;
|
||||||
/**
|
/**
|
||||||
* <h2>线程局部变量</h2>
|
* <h2>线程局部变量</h2>
|
||||||
**/
|
**/
|
||||||
protected static ThreadLocal<RequestInfo> requestInfoThreadLocal = new ThreadLocal<>();
|
protected static ThreadLocal<RequestInfo> requestInfoThreadLocal = new ThreadLocal<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>初始化流程默认的处理方法</h2>
|
* <h2>初始化流程默认的处理方法</h2>
|
||||||
*/
|
*/
|
||||||
private void initHandleMethod() {
|
private void initHandleMethod() {
|
||||||
// 提交
|
// 提交
|
||||||
actionHandleMethod.put(ActionRunType.SUBMIT, this::doSubmit);
|
actionHandleMethod.put(ActionRunType.SUBMIT, this::doSubmit);
|
||||||
// 退回
|
// 退回
|
||||||
actionHandleMethod.put(ActionRunType.REJECT, this::doReject);
|
actionHandleMethod.put(ActionRunType.REJECT, this::doReject);
|
||||||
// 撤回
|
// 撤回
|
||||||
actionHandleMethod.put(ActionRunType.WITHDRAW, this::doWithdraw);
|
actionHandleMethod.put(ActionRunType.WITHDRAW, this::doWithdraw);
|
||||||
// 强制收回
|
// 强制收回
|
||||||
actionHandleMethod.put(ActionRunType.DRAW_BACK, this::doDrawBack);
|
actionHandleMethod.put(ActionRunType.DRAW_BACK, this::doDrawBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String execute(RequestInfo requestInfo) {
|
public final String execute(RequestInfo requestInfo) {
|
||||||
requestInfoThreadLocal.set(requestInfo);
|
requestInfoThreadLocal.set(requestInfo);
|
||||||
this.globalRequestInfo = requestInfo;
|
this.globalRequestInfo = requestInfo;
|
||||||
RequestManager requestManager = requestInfo.getRequestManager();
|
RequestManager requestManager = requestInfo.getRequestManager();
|
||||||
String billTable = requestManager.getBillTableName();
|
String billTable = requestManager.getBillTableName();
|
||||||
String requestId = requestInfo.getRequestid();
|
String requestId = requestInfo.getRequestid();
|
||||||
User user = requestInfo.getRequestManager().getUser();
|
User user = requestInfo.getRequestManager().getUser();
|
||||||
int workflowId = requestManager.getWorkflowid();
|
int workflowId = requestManager.getWorkflowid();
|
||||||
// 操作类型 submit - 提交 reject - 退回 等
|
// 操作类型 submit - 提交 reject - 退回 等
|
||||||
String src = requestManager.getSrc();
|
String src = requestManager.getSrc();
|
||||||
if ("".equals(billTable)) {
|
if ("".equals(billTable)) {
|
||||||
WorkflowComInfo workflowComInfo = new WorkflowComInfo();
|
WorkflowComInfo workflowComInfo = new WorkflowComInfo();
|
||||||
String formId = workflowComInfo.getFormId(String.valueOf(workflowId));
|
String formId = workflowComInfo.getFormId(String.valueOf(workflowId));
|
||||||
WorkflowBillComInfo workflowBillComInfo = new WorkflowBillComInfo();
|
WorkflowBillComInfo workflowBillComInfo = new WorkflowBillComInfo();
|
||||||
billTable = workflowBillComInfo.getTablename(formId);
|
billTable = workflowBillComInfo.getTablename(formId);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Util.verifyRequiredField(this);
|
Util.verifyRequiredField(this);
|
||||||
if (StringUtils.isEmpty(src)) {
|
if (StringUtils.isEmpty(src)) {
|
||||||
src = "submit";
|
src = "submit";
|
||||||
}
|
}
|
||||||
// 初始化默认的流程处理方法
|
// 初始化默认的流程处理方法
|
||||||
initHandleMethod();
|
initHandleMethod();
|
||||||
// 提供自定义注册处理方法
|
// 提供自定义注册处理方法
|
||||||
registerHandler(actionHandleMethod);
|
registerHandler(actionHandleMethod);
|
||||||
// 获取流程对应的处理方法
|
// 获取流程对应的处理方法
|
||||||
CusBaseActionHandleFunction cusBaseActionHandleFunction = actionHandleMethod.get(src);
|
CusBaseActionHandleFunction cusBaseActionHandleFunction = actionHandleMethod.get(src);
|
||||||
// 默认没有直接成功不做拦截
|
// 默认没有直接成功不做拦截
|
||||||
if (null == cusBaseActionHandleFunction) {
|
if (null == cusBaseActionHandleFunction) {
|
||||||
return Action.SUCCESS;
|
return Action.SUCCESS;
|
||||||
}
|
}
|
||||||
cusBaseActionHandleFunction.handle(requestId, billTable, workflowId, user, requestManager);
|
cusBaseActionHandleFunction.handle(requestId, billTable, workflowId, user, requestManager);
|
||||||
} catch (CustomerException e) {
|
} catch (CustomerException e) {
|
||||||
if (e.getCode() != null && e.getCode() == 500) {
|
if (e.getCode() != null && e.getCode() == 500) {
|
||||||
Util.actionFail(requestManager, e.getMessage());
|
Util.actionFail(requestManager, e.getMessage());
|
||||||
return Action.FAILURE_AND_CONTINUE;
|
return Action.FAILURE_AND_CONTINUE;
|
||||||
}
|
}
|
||||||
if (this.exceptionCallback(e, requestManager)) {
|
if (this.exceptionCallback(e, requestManager)) {
|
||||||
return Action.FAILURE_AND_CONTINUE;
|
return Action.FAILURE_AND_CONTINUE;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (this.exceptionCallback(e, requestManager)) {
|
if (this.exceptionCallback(e, requestManager)) {
|
||||||
return Action.FAILURE_AND_CONTINUE;
|
return Action.FAILURE_AND_CONTINUE;
|
||||||
}
|
}
|
||||||
}finally {
|
} finally {
|
||||||
// 无论成功还是失败 都将该线程的requestInfo进行移除
|
// 无论成功还是失败 都将该线程的requestInfo进行移除
|
||||||
requestInfoThreadLocal.remove();
|
requestInfoThreadLocal.remove();
|
||||||
}
|
}
|
||||||
return Action.SUCCESS;
|
return Action.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>程序执行异常回调</h2>
|
* <h2>程序执行异常回调</h2>
|
||||||
*
|
*
|
||||||
* @param e 异常信息
|
* @param e 异常信息
|
||||||
* @param requestManager requestManager对象
|
* @param requestManager requestManager对象
|
||||||
* @return 是否阻止action往下提交,true- 阻止, false-放行
|
* @return 是否阻止action往下提交,true- 阻止, false-放行
|
||||||
*/
|
*/
|
||||||
public boolean exceptionCallback(Exception e, RequestManager requestManager) {
|
public boolean exceptionCallback(Exception e, RequestManager requestManager) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error(Util.logStr("getDataId action fail, exception message is [{}], error stack trace msg is: \n{}",
|
log.error(Util.logStr("execute action fail, exception message is [{}], error stack trace msg is: \n{}",
|
||||||
e.getMessage(), Util.getErrString(e)));
|
e.getMessage(), Util.getErrString(e)));
|
||||||
Util.actionFail(requestManager, e.getMessage());
|
Util.actionFail(requestManager, e.getMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>流程其他流转类型处理方法注册</h2>
|
* <h2>流程其他流转类型处理方法注册</h2>
|
||||||
*
|
*
|
||||||
* @param actionHandleMethod 处理方法对应map
|
* @param actionHandleMethod 处理方法对应map
|
||||||
*/
|
*/
|
||||||
public void registerHandler(Map<String, CusBaseActionHandleFunction> actionHandleMethod) {
|
public void registerHandler(Map<String, CusBaseActionHandleFunction> actionHandleMethod) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>action 提交流程业务处理方法</h2>
|
* <h2>action 提交流程业务处理方法</h2>
|
||||||
* <p>具体业务逻辑实现
|
* <p>具体业务逻辑实现
|
||||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param requestId 流程请求ID
|
* @param requestId 流程请求ID
|
||||||
* @param billTable 流程对应主表名称
|
* @param billTable 流程对应主表名称
|
||||||
* @param workflowId 流程对应流程ID
|
* @param workflowId 流程对应流程ID
|
||||||
* @param user 当前节点操作者用户
|
* @param user 当前节点操作者用户
|
||||||
* @param requestManager 请求管理对象
|
* @param requestManager 请求管理对象
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract void doSubmit(String requestId, String billTable, int workflowId,
|
public abstract void doSubmit(String requestId, String billTable, int workflowId,
|
||||||
User user, RequestManager requestManager);
|
User user, RequestManager requestManager);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>action 退回流程业务处理方法</h2>
|
* <h2>action 退回流程业务处理方法</h2>
|
||||||
* <p>具体业务逻辑实现
|
* <p>具体业务逻辑实现
|
||||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param requestId 流程请求ID
|
* @param requestId 流程请求ID
|
||||||
* @param billTable 流程对应主表名称
|
* @param billTable 流程对应主表名称
|
||||||
* @param workflowId 流程对应流程ID
|
* @param workflowId 流程对应流程ID
|
||||||
* @param user 当前节点操作者用户
|
* @param user 当前节点操作者用户
|
||||||
* @param requestManager 请求管理对象
|
* @param requestManager 请求管理对象
|
||||||
*/
|
*/
|
||||||
public void doReject(String requestId, String billTable, int workflowId,
|
public void doReject(String requestId, String billTable, int workflowId,
|
||||||
User user, RequestManager requestManager) {
|
User user, RequestManager requestManager) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>action 撤回、撤回流程流程业务处理方法</h2>
|
* <h2>action 撤回、撤回流程流程业务处理方法</h2>
|
||||||
* <p>具体业务逻辑实现
|
* <p>具体业务逻辑实现
|
||||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param requestId 流程请求ID
|
* @param requestId 流程请求ID
|
||||||
* @param billTable 流程对应主表名称
|
* @param billTable 流程对应主表名称
|
||||||
* @param workflowId 流程对应流程ID
|
* @param workflowId 流程对应流程ID
|
||||||
* @param user 当前节点操作者用户
|
* @param user 当前节点操作者用户
|
||||||
* @param requestManager 请求管理对象
|
* @param requestManager 请求管理对象
|
||||||
*/
|
*/
|
||||||
public void doWithdraw(String requestId, String billTable, int workflowId,
|
public void doWithdraw(String requestId, String billTable, int workflowId,
|
||||||
User user, RequestManager requestManager) {
|
User user, RequestManager requestManager) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>action 强制收回流程业务处理方法</h2>
|
* <h2>action 强制收回流程业务处理方法</h2>
|
||||||
* <p>具体业务逻辑实现
|
* <p>具体业务逻辑实现
|
||||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param requestId 流程请求ID
|
* @param requestId 流程请求ID
|
||||||
* @param billTable 流程对应主表名称
|
* @param billTable 流程对应主表名称
|
||||||
* @param workflowId 流程对应流程ID
|
* @param workflowId 流程对应流程ID
|
||||||
* @param user 当前节点操作者用户
|
* @param user 当前节点操作者用户
|
||||||
* @param requestManager 请求管理对象
|
* @param requestManager 请求管理对象
|
||||||
*/
|
*/
|
||||||
public void doDrawBack(String requestId, String billTable, int workflowId,
|
public void doDrawBack(String requestId, String billTable, int workflowId,
|
||||||
User user, RequestManager requestManager) {
|
User user, RequestManager requestManager) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取流程主表数据</h2>
|
* <h2>获取流程主表数据</h2>
|
||||||
*
|
*
|
||||||
* @return 流程主表数据
|
* @return 流程主表数据
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected Map<String, String> getMainTableValue() {
|
protected Map<String, String> getMainTableValue() {
|
||||||
// 获取主表数据
|
// 获取主表数据
|
||||||
Property[] propertyArr = globalRequestInfo.getMainTableInfo().getProperty();
|
Property[] propertyArr = globalRequestInfo.getMainTableInfo().getProperty();
|
||||||
return getStringMap(propertyArr);
|
return getStringMap(propertyArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取流程主表数据</h2>
|
* <h2>获取流程主表数据</h2>
|
||||||
*
|
*
|
||||||
* @return 流程主表数据
|
* @return 流程主表数据
|
||||||
*/
|
*/
|
||||||
protected Map<String, String> getMainTableValue(RequestInfo requestInfo) {
|
protected Map<String, String> getMainTableValue(RequestInfo requestInfo) {
|
||||||
// 获取主表数据
|
// 获取主表数据
|
||||||
Property[] propertyArr = requestInfo.getMainTableInfo().getProperty();
|
Property[] propertyArr = requestInfo.getMainTableInfo().getProperty();
|
||||||
return getStringMap(propertyArr);
|
return getStringMap(propertyArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Map<String, String> getStringMap(Property[] propertyArr) {
|
private Map<String, String> getStringMap(Property[] propertyArr) {
|
||||||
if (null == propertyArr) {
|
if (null == propertyArr) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
Map<String, String> mainTable = new HashMap<>((int) Math.ceil(propertyArr.length * 1.4));
|
Map<String, String> mainTable = new HashMap<>((int) Math.ceil(propertyArr.length * 1.4));
|
||||||
for (Property property : propertyArr) {
|
for (Property property : propertyArr) {
|
||||||
String fieldName = property.getName();
|
String fieldName = property.getName();
|
||||||
String value = property.getValue();
|
String value = property.getValue();
|
||||||
mainTable.put(fieldName, value);
|
mainTable.put(fieldName, value);
|
||||||
}
|
}
|
||||||
return mainTable;
|
return mainTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取所有明细数据</h2>
|
* <h2>获取所有明细数据</h2>
|
||||||
*
|
*
|
||||||
* @return 以明细表需要为键,以明细表数据为值的键值对明细数据信息
|
* @return 以明细表需要为键,以明细表数据为值的键值对明细数据信息
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected Map<String, List<Map<String, String>>> getDetailTableValue() {
|
protected Map<String, List<Map<String, String>>> getDetailTableValue() {
|
||||||
DetailTable[] detailTableArr = globalRequestInfo.getDetailTableInfo().getDetailTable();
|
DetailTable[] detailTableArr = globalRequestInfo.getDetailTableInfo().getDetailTable();
|
||||||
return getListMap(detailTableArr);
|
return getListMap(detailTableArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取所有明细数据</h2>
|
* <h2>获取所有明细数据</h2>
|
||||||
*
|
*
|
||||||
* @return 以明细表需要为键,以明细表数据为值的键值对明细数据信息
|
* @return 以明细表需要为键,以明细表数据为值的键值对明细数据信息
|
||||||
*/
|
*/
|
||||||
protected Map<String, List<Map<String, String>>> getDetailTableValue(RequestInfo requestInfo) {
|
protected Map<String, List<Map<String, String>>> getDetailTableValue(RequestInfo requestInfo) {
|
||||||
DetailTable[] detailTableArr = requestInfo.getDetailTableInfo().getDetailTable();
|
DetailTable[] detailTableArr = requestInfo.getDetailTableInfo().getDetailTable();
|
||||||
return getListMap(detailTableArr);
|
return getListMap(detailTableArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Map<String, List<Map<String, String>>> getListMap(DetailTable[] detailTableArr) {
|
private Map<String, List<Map<String, String>>> getListMap(DetailTable[] detailTableArr) {
|
||||||
Map<String, List<Map<String, String>>> detailDataList = new HashMap<>((int) Math.ceil(detailTableArr.length * 1.4));
|
Map<String, List<Map<String, String>>> detailDataList = new HashMap<>((int) Math.ceil(detailTableArr.length * 1.4));
|
||||||
for (DetailTable detailTable : detailTableArr) {
|
for (DetailTable detailTable : detailTableArr) {
|
||||||
List<Map<String, String>> detailData = getDetailValue(detailTable);
|
List<Map<String, String>> detailData = getDetailValue(detailTable);
|
||||||
detailDataList.put(detailTable.getId(), detailData);
|
detailDataList.put(detailTable.getId(), detailData);
|
||||||
}
|
}
|
||||||
return detailDataList;
|
return detailDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取指定明细表的表数据</h2>
|
* <h2>获取指定明细表的表数据</h2>
|
||||||
*
|
*
|
||||||
* @param detailNo 明细表编号
|
* @param detailNo 明细表编号
|
||||||
* @return 明细数据
|
* @return 明细数据
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected List<Map<String, String>> getDetailTableValueByDetailNo(int detailNo) {
|
protected List<Map<String, String>> getDetailTableValueByDetailNo(int detailNo) {
|
||||||
DetailTable detailTable = globalRequestInfo.getDetailTableInfo().getDetailTable(detailNo);
|
DetailTable detailTable = globalRequestInfo.getDetailTableInfo().getDetailTable(detailNo);
|
||||||
return getDetailValue(detailTable);
|
return getDetailValue(detailTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取指定明细表的表数据</h2>
|
* <h2>获取指定明细表的表数据</h2>
|
||||||
*
|
*
|
||||||
* @param detailNo 明细表编号
|
* @param detailNo 明细表编号
|
||||||
* @return 明细数据
|
* @return 明细数据
|
||||||
*/
|
*/
|
||||||
protected List<Map<String, String>> getDetailTableValueByDetailNo(int detailNo, RequestInfo requestInfo) {
|
protected List<Map<String, String>> getDetailTableValueByDetailNo(int detailNo, RequestInfo requestInfo) {
|
||||||
DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(detailNo);
|
DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(detailNo);
|
||||||
return getDetailValue(detailTable);
|
return getDetailValue(detailTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>根据明细表信息获取明细表数据</h2>
|
* <h2>根据明细表信息获取明细表数据</h2>
|
||||||
*
|
*
|
||||||
* @param detailTable 明细表对象
|
* @param detailTable 明细表对象
|
||||||
* @return 明细表数据
|
* @return 明细表数据
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<Map<String, String>> getDetailValue(DetailTable detailTable) {
|
private List<Map<String, String>> getDetailValue(DetailTable detailTable) {
|
||||||
Row[] rowArr = detailTable.getRow();
|
Row[] rowArr = detailTable.getRow();
|
||||||
List<Map<String, String>> detailData = new ArrayList<>(rowArr.length);
|
List<Map<String, String>> detailData = new ArrayList<>(rowArr.length);
|
||||||
for (Row row : rowArr) {
|
for (Row row : rowArr) {
|
||||||
Cell[] cellArr = row.getCell();
|
Cell[] cellArr = row.getCell();
|
||||||
Map<String, String> rowData = new HashMap<>((int) Math.ceil(cellArr.length * (1 + 0.4)));
|
Map<String, String> rowData = new HashMap<>((int) Math.ceil(cellArr.length * (1 + 0.4)));
|
||||||
rowData.put("id", row.getId());
|
rowData.put("id", row.getId());
|
||||||
for (Cell cell : cellArr) {
|
for (Cell cell : cellArr) {
|
||||||
String fieldName = cell.getName();
|
String fieldName = cell.getName();
|
||||||
String value = cell.getValue();
|
String value = cell.getValue();
|
||||||
rowData.put(fieldName, value);
|
rowData.put(fieldName, value);
|
||||||
}
|
}
|
||||||
detailData.add(rowData);
|
detailData.add(rowData);
|
||||||
}
|
}
|
||||||
return detailData;
|
return detailData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final class ActionRunType {
|
public static final class ActionRunType {
|
||||||
/**
|
/**
|
||||||
* 退回
|
* 退回
|
||||||
*/
|
*/
|
||||||
public static final String REJECT = "reject";
|
public static final String REJECT = "reject";
|
||||||
/**
|
/**
|
||||||
* 撤回
|
* 撤回
|
||||||
*/
|
*/
|
||||||
public static final String WITHDRAW = "withdraw";
|
public static final String WITHDRAW = "withdraw";
|
||||||
/**
|
/**
|
||||||
* 强制收回
|
* 强制收回
|
||||||
*/
|
*/
|
||||||
public static final String DRAW_BACK = "drawBack";
|
public static final String DRAW_BACK = "drawBack";
|
||||||
/**
|
/**
|
||||||
* 提交
|
* 提交
|
||||||
*/
|
*/
|
||||||
public static final String SUBMIT = "submit";
|
public static final String SUBMIT = "submit";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import weaver.workflow.workflow.WorkflowBillComInfo;
|
||||||
import weaver.workflow.workflow.WorkflowComInfo;
|
import weaver.workflow.workflow.WorkflowComInfo;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>基础的action,实现一些基础的参数</h1>
|
* <h1>基础的action,实现一些基础的参数</h1>
|
||||||
|
@ -228,6 +229,23 @@ public abstract class SafeCusBaseAction implements Action {
|
||||||
return getListMap(detailTableArr);
|
return getListMap(detailTableArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>获取所有明细数据</h2>
|
||||||
|
*
|
||||||
|
* @return 以明细表需要为键,以明细表数据为值的键值对明细数据信息
|
||||||
|
*/
|
||||||
|
protected Map<String, List<Map<String, Object>>> getDetailTableObjValue(RequestInfo requestInfo) {
|
||||||
|
DetailTable[] detailTableArr = requestInfo.getDetailTableInfo().getDetailTable();
|
||||||
|
Map<String, List<Map<String, String>>> listMap = getListMap(detailTableArr);
|
||||||
|
Map<String, List<Map<String, Object>>> result = new HashMap<>(listMap.size());
|
||||||
|
for (Map.Entry<String, List<Map<String, String>>> entry : listMap.entrySet()) {
|
||||||
|
List<Map<String, String>> list = entry.getValue();
|
||||||
|
List<Map<String, Object>> collect = list.stream().map(item -> new HashMap<String, Object>(item)).collect(Collectors.toList());
|
||||||
|
result.put(entry.getKey(), collect);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Map<String, List<Map<String, String>>> getListMap(DetailTable[] detailTableArr) {
|
private Map<String, List<Map<String, String>>> getListMap(DetailTable[] detailTableArr) {
|
||||||
|
@ -251,6 +269,18 @@ public abstract class SafeCusBaseAction implements Action {
|
||||||
return getDetailValue(detailTable);
|
return getDetailValue(detailTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>获取指定明细表的表数据</h2>
|
||||||
|
*
|
||||||
|
* @param detailNo 明细表编号
|
||||||
|
* @return 明细数据
|
||||||
|
*/
|
||||||
|
protected List<Map<String, Object>> getDetailTableObjValueByDetailNo(int detailNo, RequestInfo requestInfo) {
|
||||||
|
DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(detailNo);
|
||||||
|
List<Map<String, String>> detailValue = getDetailValue(detailTable);
|
||||||
|
return detailValue.stream().map(item -> new HashMap<String, Object>(item)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>根据明细表信息获取明细表数据</h2>
|
* <h2>根据明细表信息获取明细表数据</h2>
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package aiyh.utils.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>方法编号</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 23:24</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface MethodRuleNo {
|
||||||
|
int value();
|
||||||
|
|
||||||
|
String desc();
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package aiyh.utils.annotation.recordset;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>association注解</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 13:49</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.ANNOTATION_TYPE)
|
||||||
|
@Documented
|
||||||
|
public @interface Association {
|
||||||
|
|
||||||
|
String property();
|
||||||
|
|
||||||
|
String column();
|
||||||
|
|
||||||
|
String select();
|
||||||
|
|
||||||
|
Id id();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package aiyh.utils.annotation.recordset;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>association方法</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/20 11:55</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Documented
|
||||||
|
public @interface AssociationMethod {
|
||||||
|
int value();
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package aiyh.utils.annotation.recordset;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>实体映射注解</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 21:50</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Documented
|
||||||
|
public @interface Associations {
|
||||||
|
Association[] value();
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package aiyh.utils.annotation.recordset;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>association注解</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 13:49</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.ANNOTATION_TYPE)
|
||||||
|
@Documented
|
||||||
|
public @interface CollectionMapping {
|
||||||
|
/** 实体字段名 */
|
||||||
|
String property();
|
||||||
|
|
||||||
|
/** 数据库字段名 */
|
||||||
|
String column();
|
||||||
|
|
||||||
|
/** 查询方法全限定类名 */
|
||||||
|
String select() default "";
|
||||||
|
|
||||||
|
/** collection查询的id信息 */
|
||||||
|
Id id();
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package aiyh.utils.annotation.recordset;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>映射</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 15:39</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Documented
|
||||||
|
public @interface CollectionMappings {
|
||||||
|
CollectionMapping[] value();
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package aiyh.utils.annotation.recordset;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>association方法</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/20 11:55</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Documented
|
||||||
|
public @interface CollectionMethod {
|
||||||
|
int value();
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package aiyh.utils.annotation.recordset;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>association和collection对应id</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 14:41</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.ANNOTATION_TYPE)
|
||||||
|
@Documented
|
||||||
|
public @interface Id {
|
||||||
|
/** 查询方法名的唯一键的Java类型 */
|
||||||
|
Class<?> value();
|
||||||
|
|
||||||
|
/** 方法id */
|
||||||
|
int methodId() default -1;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package aiyh.utils.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1></h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/20 11:01</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class FieldViewInfo {
|
||||||
|
|
||||||
|
/** 字段id */
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/** 字段名 */
|
||||||
|
private String fieldName;
|
||||||
|
|
||||||
|
/** 字段表名 */
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
/** 表id */
|
||||||
|
private Integer billId;
|
||||||
|
|
||||||
|
/** 字段类型 */
|
||||||
|
private Integer fieldType;
|
||||||
|
|
||||||
|
/** 字段类型名称 */
|
||||||
|
private String fieldHtmlType;
|
||||||
|
}
|
|
@ -16,6 +16,11 @@ public class CustomerException extends RuntimeException {
|
||||||
private Throwable throwable;
|
private Throwable throwable;
|
||||||
private Integer code = -1;
|
private Integer code = -1;
|
||||||
|
|
||||||
|
public CustomerException(Throwable throwable) {
|
||||||
|
super(throwable);
|
||||||
|
this.msg = throwable.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
public CustomerException(String msg) {
|
public CustomerException(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
|
|
|
@ -19,351 +19,357 @@ import java.util.function.Supplier;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class Try<T> {
|
public abstract class Try<T> {
|
||||||
|
|
||||||
protected Try() {
|
protected Try() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <U> Try<U> ofFailable(TrySupplier<U> f) {
|
public static <U> Try<U> ofFailable(TrySupplier<U> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Try.successful(f.get());
|
return Try.successful(f.get());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
return Try.failure(t);
|
return Try.failure(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform success or pass on failure.
|
* Transform success or pass on failure.
|
||||||
* Takes an optional type parameter of the new type.
|
* Takes an optional type parameter of the new type.
|
||||||
* You need to be specific about the new type if changing type
|
* You need to be specific about the new type if changing type
|
||||||
*
|
* <p>
|
||||||
* Try.ofFailable(() -> "1").<Integer>map((x) -> Integer.valueOf(x))
|
* Try.ofFailable(() -> "1").<Integer>map((x) -> Integer.valueOf(x))
|
||||||
*
|
*
|
||||||
* @param f function to apply to successful value.
|
* @param f function to apply to successful value.
|
||||||
* @param <U> new type (optional)
|
* @param <U> new type (optional)
|
||||||
* @return Success<U> or Failure<U>
|
* @return Success<U> or Failure<U>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract <U> Try<U> map(TryMapFunction<? super T, ? extends U> f);
|
public abstract <U> Try<U> map(TryMapFunction<? super T, ? extends U> f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform success or pass on failure, taking a Try<U> as the result.
|
* Transform success or pass on failure, taking a Try<U> as the result.
|
||||||
* Takes an optional type parameter of the new type.
|
* Takes an optional type parameter of the new type.
|
||||||
* You need to be specific about the new type if changing type.
|
* You need to be specific about the new type if changing type.
|
||||||
*
|
* <p>
|
||||||
* Try.ofFailable(() -> "1").<Integer>flatMap((x) -> Try.ofFailable(() -> Integer.valueOf(x)))
|
* Try.ofFailable(() -> "1").<Integer>flatMap((x) -> Try.ofFailable(() -> Integer.valueOf(x)))
|
||||||
* returns Integer(1)
|
* returns Integer(1)
|
||||||
*
|
*
|
||||||
* @param f function to apply to successful value.
|
* @param f function to apply to successful value.
|
||||||
* @param <U> new type (optional)
|
* @param <U> new type (optional)
|
||||||
* @return new composed Try
|
* @return new composed Try
|
||||||
*/
|
*/
|
||||||
public abstract <U> Try<U> flatMap(TryMapFunction<? super T, Try<U>> f);
|
public abstract <U> Try<U> flatMap(TryMapFunction<? super T, Try<U>> f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a result to use in case of failure.
|
* Specifies a result to use in case of failure.
|
||||||
* Gives access to the exception which can be pattern matched on.
|
* Gives access to the exception which can be pattern matched on.
|
||||||
*
|
* <p>
|
||||||
* Try.ofFailable(() -> "not a number")
|
* Try.ofFailable(() -> "not a number")
|
||||||
* .<Integer>flatMap((x) -> Try.ofFailable(() ->Integer.valueOf(x)))
|
* .<Integer>flatMap((x) -> Try.ofFailable(() ->Integer.valueOf(x)))
|
||||||
* .recover((t) -> 1)
|
* .recover((t) -> 1)
|
||||||
* returns Integer(1)
|
* returns Integer(1)
|
||||||
*
|
*
|
||||||
* @param f function to getDataId on successful result.
|
* @param f function to execute on successful result.
|
||||||
* @return new composed Try
|
* @return new composed Try
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract T recover(Function<? super Throwable, T> f);
|
public abstract T recover(Function<? super Throwable, T> f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try applying f(t) on the case of failure.
|
* Try applying f(t) on the case of failure.
|
||||||
* @param f function that takes throwable and returns result
|
*
|
||||||
* @return a new Try in the case of failure, or the current Success.
|
* @param f function that takes throwable and returns result
|
||||||
*/
|
* @return a new Try in the case of failure, or the current Success.
|
||||||
public abstract Try<T> recoverWith(TryMapFunction<? super Throwable, Try<T>> f);
|
*/
|
||||||
|
public abstract Try<T> recoverWith(TryMapFunction<? super Throwable, Try<T>> f);
|
||||||
/**
|
|
||||||
* Return a value in the case of a failure.
|
/**
|
||||||
* This is similar to recover but does not expose the exception type.
|
* Return a value in the case of a failure.
|
||||||
*
|
* This is similar to recover but does not expose the exception type.
|
||||||
* @param value return the try's value or else the value specified.
|
*
|
||||||
* @return new composed Try
|
* @param value return the try's value or else the value specified.
|
||||||
*/
|
* @return new composed Try
|
||||||
public abstract T orElse(T value);
|
*/
|
||||||
|
public abstract T orElse(T value);
|
||||||
/**
|
|
||||||
* Return another try in the case of failure.
|
/**
|
||||||
* Like recoverWith but without exposing the exception.
|
* Return another try in the case of failure.
|
||||||
*
|
* Like recoverWith but without exposing the exception.
|
||||||
* @param f return the value or the value from the new try.
|
*
|
||||||
* @return new composed Try
|
* @param f return the value or the value from the new try.
|
||||||
*/
|
* @return new composed Try
|
||||||
public abstract Try<T> orElseTry(TrySupplier<T> f);
|
*/
|
||||||
|
public abstract Try<T> orElseTry(TrySupplier<T> f);
|
||||||
/**
|
|
||||||
* Gets the value T on Success or throws the cause of the failure.
|
/**
|
||||||
*
|
* Gets the value T on Success or throws the cause of the failure.
|
||||||
* @return T
|
*
|
||||||
* @throws Throwable produced by the supplier function argument
|
* @return T
|
||||||
*/
|
* @throws Throwable produced by the supplier function argument
|
||||||
|
*/
|
||||||
public abstract <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X;
|
|
||||||
|
public abstract <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X;
|
||||||
/**
|
|
||||||
* Gets the value T on Success or throws the cause of the failure.
|
/**
|
||||||
*
|
* Gets the value T on Success or throws the cause of the failure.
|
||||||
* @return T
|
*
|
||||||
* @throws Throwable
|
* @return T
|
||||||
*/
|
* @throws Throwable
|
||||||
public abstract T get() throws Throwable;
|
*/
|
||||||
|
public abstract T get() throws Throwable;
|
||||||
/**
|
|
||||||
* Gets the value T on Success or throws the cause of the failure wrapped into a RuntimeException
|
/**
|
||||||
* @return T
|
* Gets the value T on Success or throws the cause of the failure wrapped into a RuntimeException
|
||||||
* @throws RuntimeException
|
*
|
||||||
*/
|
* @return T
|
||||||
public abstract T getUnchecked();
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
public abstract boolean isSuccess();
|
public abstract T getUnchecked();
|
||||||
|
|
||||||
/**
|
public abstract boolean isSuccess();
|
||||||
* Performs the provided action, when successful
|
|
||||||
* @param action action to run
|
/**
|
||||||
* @return new composed Try
|
* Performs the provided action, when successful
|
||||||
* @throws E if the action throws an exception
|
*
|
||||||
*/
|
* @param action action to run
|
||||||
public abstract <E extends Throwable> Try<T> onSuccess(TryConsumer<T, E> action) throws E;
|
* @return new composed Try
|
||||||
|
* @throws E if the action throws an exception
|
||||||
/**
|
*/
|
||||||
* Performs the provided action, when failed
|
public abstract <E extends Throwable> Try<T> onSuccess(TryConsumer<T, E> action) throws E;
|
||||||
* @param action action to run
|
|
||||||
* @return new composed Try
|
/**
|
||||||
* @throws E if the action throws an exception
|
* Performs the provided action, when failed
|
||||||
*/
|
*
|
||||||
public abstract <E extends Throwable> Try<T> onFailure(TryConsumer<Throwable, E> action) throws E;
|
* @param action action to run
|
||||||
|
* @return new composed Try
|
||||||
/**
|
* @throws E if the action throws an exception
|
||||||
* If a Try is a Success and the predicate holds true, the Success is passed further.
|
*/
|
||||||
* Otherwise (Failure or predicate doesn't hold), pass Failure.
|
public abstract <E extends Throwable> Try<T> onFailure(TryConsumer<Throwable, E> action) throws E;
|
||||||
* @param pred predicate applied to the value held by Try
|
|
||||||
* @return For Success, the same success if predicate holds true, otherwise Failure
|
/**
|
||||||
*/
|
* If a Try is a Success and the predicate holds true, the Success is passed further.
|
||||||
public abstract Try<T> filter(Predicate<T> pred);
|
* Otherwise (Failure or predicate doesn't hold), pass Failure.
|
||||||
|
*
|
||||||
/**
|
* @param pred predicate applied to the value held by Try
|
||||||
* Try contents wrapped in Optional.
|
* @return For Success, the same success if predicate holds true, otherwise Failure
|
||||||
* @return Optional of T, if Success, Empty if Failure or null value
|
*/
|
||||||
*/
|
public abstract Try<T> filter(Predicate<T> pred);
|
||||||
public abstract Optional<T> toOptional();
|
|
||||||
|
/**
|
||||||
/**
|
* Try contents wrapped in Optional.
|
||||||
* Factory method for failure.
|
*
|
||||||
*
|
* @return Optional of T, if Success, Empty if Failure or null value
|
||||||
* @param e throwable to create the failed Try with
|
*/
|
||||||
* @param <U> Type
|
public abstract Optional<T> toOptional();
|
||||||
* @return a new Failure
|
|
||||||
*/
|
/**
|
||||||
|
* Factory method for failure.
|
||||||
public static <U> Try<U> failure(Throwable e) {
|
*
|
||||||
return new Failure<>(e);
|
* @param e throwable to create the failed Try with
|
||||||
}
|
* @param <U> Type
|
||||||
|
* @return a new Failure
|
||||||
/**
|
*/
|
||||||
* Factory method for success.
|
|
||||||
*
|
public static <U> Try<U> failure(Throwable e) {
|
||||||
* @param x value to create the successful Try with
|
return new Failure<>(e);
|
||||||
* @param <U> Type
|
}
|
||||||
* @return a new Success
|
|
||||||
*/
|
/**
|
||||||
public static <U> Try<U> successful(U x) {
|
* Factory method for success.
|
||||||
return new Success<>(x);
|
*
|
||||||
}
|
* @param x value to create the successful Try with
|
||||||
|
* @param <U> Type
|
||||||
|
* @return a new Success
|
||||||
|
*/
|
||||||
|
public static <U> Try<U> successful(U x) {
|
||||||
|
return new Success<>(x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Success<T> extends Try<T> {
|
class Success<T> extends Try<T> {
|
||||||
private final T value;
|
private final T value;
|
||||||
|
|
||||||
public Success(T value) {
|
public Success(T value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U> Try<U> flatMap(TryMapFunction<? super T, Try<U>> f) {
|
public <U> Try<U> flatMap(TryMapFunction<? super T, Try<U>> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
try {
|
try {
|
||||||
return f.apply(value);
|
return f.apply(value);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
return Try.failure(t);
|
return Try.failure(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T recover(Function<? super Throwable, T> f) {
|
public T recover(Function<? super Throwable, T> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Try<T> recoverWith(TryMapFunction<? super Throwable, Try<T>> f) {
|
public Try<T> recoverWith(TryMapFunction<? super Throwable, Try<T>> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T orElse(T value) {
|
public T orElse(T value) {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Try<T> orElseTry(TrySupplier<T> f) {
|
public Try<T> orElseTry(TrySupplier<T> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
|
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get() throws Throwable {
|
public T get() throws Throwable {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getUnchecked() {
|
public T getUnchecked() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U> Try<U> map(TryMapFunction<? super T, ? extends U> f) {
|
public <U> Try<U> map(TryMapFunction<? super T, ? extends U> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
try {
|
try {
|
||||||
return new Success<>(f.apply(value));
|
return new Success<>(f.apply(value));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
return Try.failure(t);
|
return Try.failure(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E extends Throwable> Try<T> onSuccess(TryConsumer<T, E> action) throws E {
|
public <E extends Throwable> Try<T> onSuccess(TryConsumer<T, E> action) throws E {
|
||||||
action.accept(value);
|
action.accept(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Try<T> filter(Predicate<T> p) {
|
public Try<T> filter(Predicate<T> p) {
|
||||||
Objects.requireNonNull(p);
|
Objects.requireNonNull(p);
|
||||||
|
|
||||||
if (p.test(value)) {
|
if (p.test(value)) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
return Try.failure(new NoSuchElementException("Predicate does not match for " + value));
|
return Try.failure(new NoSuchElementException("Predicate does not match for " + value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<T> toOptional() {
|
public Optional<T> toOptional() {
|
||||||
return Optional.ofNullable(value);
|
return Optional.ofNullable(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E extends Throwable> Try<T> onFailure(TryConsumer<Throwable, E> action) {
|
public <E extends Throwable> Try<T> onFailure(TryConsumer<Throwable, E> action) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Failure<T> extends Try<T> {
|
class Failure<T> extends Try<T> {
|
||||||
private final Throwable e;
|
private final Throwable e;
|
||||||
|
|
||||||
Failure(Throwable e) {
|
Failure(Throwable e) {
|
||||||
this.e = e;
|
this.e = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U> Try<U> map(TryMapFunction<? super T, ? extends U> f) {
|
public <U> Try<U> map(TryMapFunction<? super T, ? extends U> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
return Try.failure(e);
|
return Try.failure(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U> Try<U> flatMap(TryMapFunction<? super T, Try<U>> f) {
|
public <U> Try<U> flatMap(TryMapFunction<? super T, Try<U>> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
return Try.failure(e);
|
return Try.failure(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T recover(Function<? super Throwable, T> f) {
|
public T recover(Function<? super Throwable, T> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
return f.apply(e);
|
return f.apply(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Try<T> recoverWith(TryMapFunction<? super Throwable, Try<T>> f) {
|
public Try<T> recoverWith(TryMapFunction<? super Throwable, Try<T>> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
try{
|
try {
|
||||||
return f.apply(e);
|
return f.apply(e);
|
||||||
}catch(Throwable t){
|
} catch (Throwable t) {
|
||||||
return Try.failure(t);
|
return Try.failure(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T orElse(T value) {
|
public T orElse(T value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Try<T> orElseTry(TrySupplier<T> f) {
|
public Try<T> orElseTry(TrySupplier<T> f) {
|
||||||
Objects.requireNonNull(f);
|
Objects.requireNonNull(f);
|
||||||
return Try.ofFailable(f);
|
return Try.ofFailable(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
|
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
|
||||||
throw exceptionSupplier.get();
|
throw exceptionSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get() throws Throwable {
|
public T get() throws Throwable {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getUnchecked() {
|
public T getUnchecked() {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E extends Throwable> Try<T> onSuccess(TryConsumer<T, E> action) {
|
public <E extends Throwable> Try<T> onSuccess(TryConsumer<T, E> action) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Try<T> filter(Predicate<T> pred) {
|
public Try<T> filter(Predicate<T> pred) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<T> toOptional() {
|
public Optional<T> toOptional() {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E extends Throwable> Try<T> onFailure(TryConsumer<Throwable, E> action) throws E {
|
public <E extends Throwable> Try<T> onFailure(TryConsumer<Throwable, E> action) throws E {
|
||||||
action.accept(e);
|
action.accept(e);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -75,10 +75,11 @@ public class HttpManager {
|
||||||
return true;
|
return true;
|
||||||
}).build();
|
}).build();
|
||||||
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
|
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
|
||||||
sslsf = new SSLConnectionSocketFactory(sslContext,
|
sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
|
||||||
new String[]{"TLSv1"},
|
// sslsf = new SSLConnectionSocketFactory(sslContext,
|
||||||
null,
|
// new String[]{"TLSv1"},
|
||||||
hostnameVerifier);
|
// null,
|
||||||
|
// hostnameVerifier);
|
||||||
} catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
|
} catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package aiyh.utils.mapper;
|
||||||
|
|
||||||
import aiyh.utils.annotation.recordset.*;
|
import aiyh.utils.annotation.recordset.*;
|
||||||
import aiyh.utils.entity.DocImageInfo;
|
import aiyh.utils.entity.DocImageInfo;
|
||||||
|
import aiyh.utils.entity.FieldViewInfo;
|
||||||
import aiyh.utils.entity.SelectValueEntity;
|
import aiyh.utils.entity.SelectValueEntity;
|
||||||
import aiyh.utils.entity.WorkflowNodeConfig;
|
import aiyh.utils.entity.WorkflowNodeConfig;
|
||||||
|
|
||||||
|
@ -17,139 +18,158 @@ import java.util.Map;
|
||||||
|
|
||||||
@SqlMapper
|
@SqlMapper
|
||||||
public interface UtilMapper {
|
public interface UtilMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询日志级别是否开启Debug模式
|
* 查询日志级别是否开启Debug模式
|
||||||
*
|
*
|
||||||
* @return 是否开启Debug模式
|
* @return 是否开启Debug模式
|
||||||
*/
|
*/
|
||||||
@Select("select param_value from $t{configTableName} where only_mark = 'enableDebugLog'")
|
@Select("select param_value from $t{configTableName} where only_mark = 'enableDebugLog'")
|
||||||
public Boolean selectLogLevel(@ParamMapper("configTableName") String configTableName);
|
Boolean selectLogLevel(@ParamMapper("configTableName") String configTableName);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据唯一标识查询参数值
|
* 根据唯一标识查询参数值
|
||||||
*
|
*
|
||||||
* @param onlyMark 唯一标识
|
* @param onlyMark 唯一标识
|
||||||
* @return 参数值
|
* @return 参数值
|
||||||
*/
|
*/
|
||||||
@Select("select param_value from $t{configTableName} where only_mark = #{onlyMark} and enable_param = 1")
|
@Select("select param_value from $t{configTableName} where only_mark = #{onlyMark} and enable_param = 1")
|
||||||
public String selectCusConfigParam(@ParamMapper("onlyMark") String onlyMark,
|
String selectCusConfigParam(@ParamMapper("onlyMark") String onlyMark,
|
||||||
@ParamMapper("configTableName") String cusConfigTableName);
|
@ParamMapper("configTableName") String cusConfigTableName);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询文件名
|
* 查询文件名
|
||||||
*
|
*
|
||||||
* @param imageFileId 查询文件名
|
* @param imageFileId 查询文件名
|
||||||
* @return 文件名
|
* @return 文件名
|
||||||
*/
|
*/
|
||||||
@Select("select imagefilename from imagefile where imagefileid = #{imageFileId}")
|
@Select("select imagefilename from imagefile where imagefileid = #{imageFileId}")
|
||||||
String selectFileNameByImageFileId(@ParamMapper("imageFileId") int imageFileId);
|
String selectFileNameByImageFileId(@ParamMapper("imageFileId") int imageFileId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询流程主表
|
* 查询流程主表
|
||||||
*
|
*
|
||||||
* @param workflowId 流程id
|
* @param workflowId 流程id
|
||||||
* @return 流程表名
|
* @return 流程表名
|
||||||
*/
|
*/
|
||||||
@Select("select bill.tablename from workflow_bill bill join workflow_base base on base.formid = bill.id where base.id = #{workflowId}")
|
@Select("select bill.tablename from workflow_bill bill join workflow_base base on base.formid = bill.id where base.id = #{workflowId}")
|
||||||
String selectWorkfowMainTable(@ParamMapper("workflowId") String workflowId);
|
String selectWorkfowMainTable(@ParamMapper("workflowId") String workflowId);
|
||||||
|
|
||||||
|
|
||||||
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid = #{docId}")
|
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid = #{docId}")
|
||||||
DocImageInfo selectDocImageInfo(@ParamMapper("docId") String docId);
|
DocImageInfo selectDocImageInfo(@ParamMapper("docId") String docId);
|
||||||
|
|
||||||
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid in ($t{docIds})")
|
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid in ($t{docIds})")
|
||||||
List<DocImageInfo> selectDocImageInfos(@ParamMapper("docIds") String docIds);
|
List<DocImageInfo> selectDocImageInfos(@ParamMapper("docIds") String docIds);
|
||||||
|
|
||||||
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid in (${docIds})")
|
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid in (${docIds})")
|
||||||
List<DocImageInfo> selectDocImageInfos(@ParamMapper("docIds") String[] docIds);
|
List<DocImageInfo> selectDocImageInfos(@ParamMapper("docIds") String[] docIds);
|
||||||
|
|
||||||
|
|
||||||
@Select("select id,workflow_type,mark_only,workflow_nodes,enable_nodes from uf_node_config where enable_nodes = 1 and workflow_type in ($t{allVersion}) and mark_only = #{markOnly}")
|
@Select("select id,workflow_type,mark_only,workflow_nodes,enable_nodes from uf_node_config where enable_nodes = 1 and workflow_type in ($t{allVersion}) and mark_only = #{markOnly}")
|
||||||
WorkflowNodeConfig selectNodeConfig(@ParamMapper("allVersion") String allVersion, @ParamMapper("markOnly") String markOnly);
|
WorkflowNodeConfig selectNodeConfig(@ParamMapper("allVersion") String allVersion, @ParamMapper("markOnly") String markOnly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询下拉框值
|
* 查询下拉框值
|
||||||
*
|
*
|
||||||
* @param tableName 表明
|
* @param tableName 表明
|
||||||
* @param fileName 字段名
|
* @param fileName 字段名
|
||||||
* @return 下拉框
|
* @return 下拉框
|
||||||
*/
|
*/
|
||||||
@Select("select wbf.id,wbf.fieldname,wbf.fieldlabel,wb.tablename, ws.selectname,ws.selectvalue " +
|
@Select("select wbf.id,wbf.fieldname,wbf.fieldlabel,wb.tablename, ws.selectname,ws.selectvalue " +
|
||||||
"from workflow_billfield wbf left join workflow_bill wb on wbf.billid = wb.id " +
|
"from workflow_billfield wbf left join workflow_bill wb on wbf.billid = wb.id " +
|
||||||
"left join workflow_selectitem ws on ws.fieldid = wbf.id where wb.tablename = #{tableName} and fieldname = #{fileName}")
|
"left join workflow_selectitem ws on ws.fieldid = wbf.id where wb.tablename = #{tableName} and fieldname = #{fileName}")
|
||||||
List<SelectValueEntity> selectSelectFieldValue(@ParamMapper("tableName") String tableName, @ParamMapper("fileName") String fileName);
|
List<SelectValueEntity> selectSelectFieldValue(@ParamMapper("tableName") String tableName, @ParamMapper("fileName") String fileName);
|
||||||
|
|
||||||
@Select("select ws.selectname " +
|
@Select("select ws.selectname " +
|
||||||
"from workflow_billfield wbf left join workflow_bill wb on wbf.billid = wb.id " +
|
"from workflow_billfield wbf left join workflow_bill wb on wbf.billid = wb.id " +
|
||||||
"left join workflow_selectitem ws on ws.fieldid = wbf.id where wb.tablename = #{tableName} and fieldname = #{fileName} and selectvalue = #{value}")
|
"left join workflow_selectitem ws on ws.fieldid = wbf.id where wb.tablename = #{tableName} and fieldname = #{fileName} and selectvalue = #{value}")
|
||||||
String selectSelectFieldValueByValue(@ParamMapper("tableName") String tableName, @ParamMapper("fileName") String fileName,
|
String selectSelectFieldValueByValue(@ParamMapper("tableName") String tableName, @ParamMapper("fileName") String fileName,
|
||||||
@ParamMapper("value") String value);
|
@ParamMapper("value") String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询文件信息
|
* 查询文件信息
|
||||||
*
|
*
|
||||||
* @param imageFileId 查询文件名
|
* @param imageFileId 查询文件名
|
||||||
* @return 文件名
|
* @return 文件名
|
||||||
*/
|
*/
|
||||||
@Select("select * from imagefile where imagefileid = #{imageFileId}")
|
@Select("select * from imagefile where imagefileid = #{imageFileId}")
|
||||||
Map<String, Object> selectFileInfoByImageFileId(@ParamMapper("imageFileId") int imageFileId);
|
Map<String, Object> selectFileInfoByImageFileId(@ParamMapper("imageFileId") int imageFileId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除文件信息
|
* 删除文件信息
|
||||||
*
|
*
|
||||||
* @param imageFileId 文件ID
|
* @param imageFileId 文件ID
|
||||||
* @return 是否删除成功
|
* @return 是否删除成功
|
||||||
*/
|
*/
|
||||||
@Delete("delete from imagefile where imagefileid = #{imageFileId}")
|
@Delete("delete from imagefile where imagefileid = #{imageFileId}")
|
||||||
boolean deleteImageFileInfo(@ParamMapper("imageFileId") Integer imageFileId);
|
boolean deleteImageFileInfo(@ParamMapper("imageFileId") Integer imageFileId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>插入自定义配置数据</h2>
|
* <h2>插入自定义配置数据</h2>
|
||||||
*
|
*
|
||||||
* @param onlyMark 唯一标识
|
* @param onlyMark 唯一标识
|
||||||
* @param value 参数值
|
* @param value 参数值
|
||||||
* @param desc 描述
|
* @param desc 描述
|
||||||
* @return 是否插入成功
|
* @return 是否插入成功
|
||||||
*/
|
*/
|
||||||
@Update("update $t{configTableName} set only_mark = #{onlyMark},param_value = #{paramValue}, \n" +
|
@Update("update $t{configTableName} set only_mark = #{onlyMark},param_value = #{paramValue}, \n" +
|
||||||
"param_desc = #{paramDesc} where id = #{id}")
|
"param_desc = #{paramDesc} where id = #{id}")
|
||||||
boolean updateConfigValueById(@ParamMapper("onlyMark") String onlyMark,
|
boolean updateConfigValueById(@ParamMapper("onlyMark") String onlyMark,
|
||||||
@ParamMapper("paramValue") String value,
|
@ParamMapper("paramValue") String value,
|
||||||
@ParamMapper("paramDesc") String desc,
|
@ParamMapper("paramDesc") String desc,
|
||||||
@ParamMapper("id") String id,
|
@ParamMapper("id") String id,
|
||||||
@ParamMapper("configTableName") String configTableName);
|
@ParamMapper("configTableName") String configTableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>修改自定义配置数据</h2>
|
* <h2>修改自定义配置数据</h2>
|
||||||
*
|
*
|
||||||
* @param onlyMark 唯一标识
|
* @param onlyMark 唯一标识
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @param desc 描述
|
* @param desc 描述
|
||||||
* @return 是否更新成功
|
* @return 是否更新成功
|
||||||
*/
|
*/
|
||||||
@Update("update $t{configTableName} set param_value = #{paramValue}, \n" +
|
@Update("update $t{configTableName} set param_value = #{paramValue}, \n" +
|
||||||
"param_desc = #{paramDesc} where only_mark = #{onlyMark}")
|
"param_desc = #{paramDesc} where only_mark = #{onlyMark}")
|
||||||
boolean updateConfigValueByOnlyMark(@ParamMapper("onlyMark") String onlyMark,
|
boolean updateConfigValueByOnlyMark(@ParamMapper("onlyMark") String onlyMark,
|
||||||
@ParamMapper("paramValue") String value,
|
@ParamMapper("paramValue") String value,
|
||||||
@ParamMapper("paramDesc") String desc,
|
@ParamMapper("paramDesc") String desc,
|
||||||
@ParamMapper("configTableName") String configTableName);
|
@ParamMapper("configTableName") String configTableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>selectBillTableByFromId 根据fromId查询billTable表明</h2>
|
* <h2>selectBillTableByFromId 根据fromId查询billTable表明</h2>
|
||||||
* <i>2023/2/6 13:40</i>
|
* <i>2023/2/6 13:40</i>
|
||||||
* ************************************************************
|
* ************************************************************
|
||||||
*
|
*
|
||||||
* @param fromId fromId
|
* @param fromId fromId
|
||||||
* @return String 表名
|
* @return String 表名
|
||||||
* @author youHong.ai
|
* @author youHong.ai
|
||||||
* ******************************************
|
* ******************************************
|
||||||
*/
|
*/
|
||||||
@Select("select * from workflow_bill where id = #{fromId}")
|
@Select("select * from workflow_bill where id = #{fromId}")
|
||||||
String selectBillTableByFromId(@ParamMapper("fromId") String fromId);
|
String selectBillTableByFromId(@ParamMapper("fromId") String fromId);
|
||||||
|
|
||||||
@Delete("delete from $t{tableName} where id = #{dataId}")
|
/**
|
||||||
void deleteModeId(@ParamMapper("tableName") String tableName, @ParamMapper("dataId") Integer dataId);
|
* <h2>删除指定表数据</h2>
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @param dataId 数据id
|
||||||
|
*/
|
||||||
|
@Delete("delete from $t{tableName} where id = #{dataId}")
|
||||||
|
void deleteModeId(@ParamMapper("tableName") String tableName, @ParamMapper("dataId") Integer dataId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>根据字段id查询字段信息</h2>
|
||||||
|
*
|
||||||
|
* @param id 字段id
|
||||||
|
* @return 字段信息
|
||||||
|
*/
|
||||||
|
@Select("select id,fieldname field_name,tablename table_name,\n" +
|
||||||
|
" billid bill_id,fieldtype field_type,\n" +
|
||||||
|
" fieldhtmltype field_html_type\n" +
|
||||||
|
"from workflow_field_table_view where id = #{id}")
|
||||||
|
FieldViewInfo selectFieldInfo(Integer id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,463 +21,478 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class RecordsetUtil implements InvocationHandler {
|
public class RecordsetUtil implements InvocationHandler {
|
||||||
|
|
||||||
|
|
||||||
public static final String SQL_LOG = "sql_log";
|
public static final String SQL_LOG = "sql_log";
|
||||||
private final RsThreadLocalManager rsManager = new RsThreadLocalManager();
|
private final RsThreadLocalManager rsManager = new RsThreadLocalManager();
|
||||||
|
|
||||||
private boolean autoCommit = true;
|
private boolean autoCommit = true;
|
||||||
|
|
||||||
public <T> T getMapper(Class<T> tClass) {
|
public <T> T getMapper(Class<T> tClass) {
|
||||||
return getMapper(tClass, true);
|
return getMapper(tClass, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getMapper(Class<T> tClass, boolean autoCommit) {
|
public <T> T getMapper(Class<T> tClass, boolean autoCommit) {
|
||||||
if (tClass == null) {
|
if (tClass == null) {
|
||||||
throw new BindingException("class is null!");
|
throw new BindingException("class is null!");
|
||||||
}
|
}
|
||||||
if (tClass.getAnnotation(SqlMapper.class) == null) {
|
if (tClass.getAnnotation(SqlMapper.class) == null) {
|
||||||
throw new BindingException("can not find SqlMapper annotation!");
|
throw new BindingException("can not find SqlMapper annotation!");
|
||||||
}
|
}
|
||||||
this.autoCommit = autoCommit;
|
this.autoCommit = autoCommit;
|
||||||
return (T) Proxy.newProxyInstance(tClass.getClassLoader(), new Class[]{tClass}, this);
|
return (T) Proxy.newProxyInstance(tClass.getClassLoader(), new Class[]{tClass}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||||
if (autoCommit) {
|
if (autoCommit) {
|
||||||
return invokeRs(proxy, method, args);
|
return invokeRs(proxy, method, args, "");
|
||||||
}
|
}
|
||||||
return invokeRsTrans(proxy, method, args);
|
return invokeRsTrans(proxy, method, args, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object invoke(Object proxy, Method method, Object[] args, String name) {
|
||||||
private Object invokeRs(Object proxy, Method method, Object[] args) {
|
if (autoCommit) {
|
||||||
RecordSet rs = rsManager.getRs(method.getDeclaringClass().getName());
|
return invokeRs(proxy, method, args, name);
|
||||||
if (rs == null) {
|
}
|
||||||
rsManager.setRecordSet(method.getDeclaringClass().getName());
|
return invokeRsTrans(proxy, method, args, name);
|
||||||
rs = rsManager.getRs(method.getDeclaringClass().getName());
|
}
|
||||||
}
|
|
||||||
SqlHandler sqlHandler = new SqlHandler();
|
|
||||||
ResultMapper resultMapper = new ResultMapper();
|
private Object invokeRs(Object proxy, Method method, Object[] args, String name) {
|
||||||
Select select = method.getAnnotation(Select.class);
|
String mapperKey = method.getDeclaringClass().getName();
|
||||||
if (select != null) {
|
if (!"".equals(name) && null != name) {
|
||||||
// 查询
|
mapperKey += "." + name;
|
||||||
String sql = select.value();
|
}
|
||||||
boolean custom = select.custom();
|
RecordSet rs = rsManager.getRs(mapperKey);
|
||||||
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
if (rs == null) {
|
||||||
if (!handler.getSqlStr().trim().toLowerCase().startsWith("select ")) {
|
rsManager.setRecordSet(mapperKey);
|
||||||
throw new CustomerException("The sql statement does not match, the @Select annotation can only getDataId the select statement, please check whether the sql statement matches!");
|
rs = rsManager.getRs(mapperKey);
|
||||||
}
|
}
|
||||||
Util.getLogger(SQL_LOG).info("解析sql===>" + handler);
|
SqlHandler sqlHandler = new SqlHandler();
|
||||||
if (handler.getArgs().isEmpty()) {
|
ResultMapper resultMapper = new ResultMapper();
|
||||||
rs.executeQuery(handler.getSqlStr());
|
Select select = method.getAnnotation(Select.class);
|
||||||
} else {
|
if (select != null) {
|
||||||
rs.executeQuery(handler.getSqlStr(), handler.getArgs());
|
// 查询
|
||||||
}
|
String sql = select.value();
|
||||||
return resultMapper.mapperResult(rs, method, method.getReturnType());
|
boolean custom = select.custom();
|
||||||
}
|
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
||||||
Update update = method.getAnnotation(Update.class);
|
if (!handler.getSqlStr().trim().toLowerCase().startsWith("select ")) {
|
||||||
if (update != null) {
|
throw new CustomerException("The sql statement does not match, the @Select annotation can only execute the select statement, please check whether the sql statement matches!");
|
||||||
// 查询
|
}
|
||||||
String sql = update.value();
|
Util.getLogger(SQL_LOG).info("解析sql===>" + handler);
|
||||||
boolean custom = update.custom();
|
if (handler.getArgs().isEmpty()) {
|
||||||
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
rs.executeQuery(handler.getSqlStr());
|
||||||
if (!handler.getSqlStr().trim().toLowerCase().startsWith("update ")) {
|
} else {
|
||||||
throw new CustomerException("The sql statement does not match, the @Update annotation can only getDataId the update statement, please check whether the sql statement matches!");
|
rs.executeQuery(handler.getSqlStr(), handler.getArgs());
|
||||||
}
|
}
|
||||||
Util.getLogger(SQL_LOG).info(handler.toString());
|
return resultMapper.mapperResult(rs, method, method.getReturnType(), this);
|
||||||
Class<?> returnType = method.getReturnType();
|
}
|
||||||
boolean b;
|
Update update = method.getAnnotation(Update.class);
|
||||||
if (handler.getArgs().isEmpty()) {
|
if (update != null) {
|
||||||
b = rs.executeUpdate(handler.getSqlStr());
|
// 查询
|
||||||
} else {
|
String sql = update.value();
|
||||||
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
boolean custom = update.custom();
|
||||||
}
|
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
||||||
if (returnType.equals(void.class)) {
|
if (!handler.getSqlStr().trim().toLowerCase().startsWith("update ")) {
|
||||||
return null;
|
throw new CustomerException("The sql statement does not match, the @Update annotation can only execute the update statement, please check whether the sql statement matches!");
|
||||||
}
|
}
|
||||||
if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
|
Util.getLogger(SQL_LOG).info(handler.toString());
|
||||||
if (b) {
|
Class<?> returnType = method.getReturnType();
|
||||||
return 1;
|
boolean b;
|
||||||
} else {
|
if (handler.getArgs().isEmpty()) {
|
||||||
return 0;
|
b = rs.executeUpdate(handler.getSqlStr());
|
||||||
}
|
} else {
|
||||||
}
|
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
}
|
||||||
return b;
|
if (returnType.equals(void.class)) {
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
Insert insert = method.getAnnotation(Insert.class);
|
if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
|
||||||
if (insert != null) {
|
if (b) {
|
||||||
// 查询
|
return 1;
|
||||||
String sql = insert.value();
|
} else {
|
||||||
boolean custom = insert.custom();
|
return 0;
|
||||||
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
}
|
||||||
if (!handler.getSqlStr().trim().toLowerCase().startsWith("insert ")) {
|
}
|
||||||
throw new CustomerException("The sql statement does not match, the @Insert annotation can only getDataId the insert statement, please check whether the sql statement matches!");
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
}
|
return b;
|
||||||
Util.getLogger(SQL_LOG).info(handler.toString());
|
}
|
||||||
Class<?> returnType = method.getReturnType();
|
}
|
||||||
boolean b;
|
Insert insert = method.getAnnotation(Insert.class);
|
||||||
if (handler.getArgs().isEmpty()) {
|
if (insert != null) {
|
||||||
b = rs.executeUpdate(handler.getSqlStr());
|
// 查询
|
||||||
} else {
|
String sql = insert.value();
|
||||||
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
boolean custom = insert.custom();
|
||||||
}
|
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
||||||
if (returnType.equals(void.class)) {
|
if (!handler.getSqlStr().trim().toLowerCase().startsWith("insert ")) {
|
||||||
return null;
|
throw new CustomerException("The sql statement does not match, the @Insert annotation can only execute the insert statement, please check whether the sql statement matches!");
|
||||||
}
|
}
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
Util.getLogger(SQL_LOG).info(handler.toString());
|
||||||
return b;
|
Class<?> returnType = method.getReturnType();
|
||||||
}
|
boolean b;
|
||||||
}
|
if (handler.getArgs().isEmpty()) {
|
||||||
Delete delete = method.getAnnotation(Delete.class);
|
b = rs.executeUpdate(handler.getSqlStr());
|
||||||
if (delete != null) {
|
} else {
|
||||||
// 查询
|
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
||||||
String sql = delete.value();
|
}
|
||||||
boolean custom = delete.custom();
|
if (returnType.equals(void.class)) {
|
||||||
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
return null;
|
||||||
if (!handler.getSqlStr().trim().toLowerCase().startsWith("delete ")) {
|
}
|
||||||
throw new CustomerException("The sql statement does not match, the @Delete annotation can only getDataId the delete statement, please check whether the sql statement matches!");
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
}
|
return b;
|
||||||
Util.getLogger(SQL_LOG).info(handler.toString());
|
}
|
||||||
Class<?> returnType = method.getReturnType();
|
}
|
||||||
boolean b;
|
Delete delete = method.getAnnotation(Delete.class);
|
||||||
if (handler.getArgs().isEmpty()) {
|
if (delete != null) {
|
||||||
b = rs.executeUpdate(handler.getSqlStr());
|
// 查询
|
||||||
} else {
|
String sql = delete.value();
|
||||||
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
boolean custom = delete.custom();
|
||||||
}
|
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
||||||
if (returnType.equals(void.class)) {
|
if (!handler.getSqlStr().trim().toLowerCase().startsWith("delete ")) {
|
||||||
return null;
|
throw new CustomerException("The sql statement does not match, the @Delete annotation can only execute the delete statement, please check whether the sql statement matches!");
|
||||||
}
|
}
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
Util.getLogger(SQL_LOG).info(handler.toString());
|
||||||
return b;
|
Class<?> returnType = method.getReturnType();
|
||||||
}
|
boolean b;
|
||||||
}
|
if (handler.getArgs().isEmpty()) {
|
||||||
boolean hasBatchInsert = method.isAnnotationPresent(BatchInsert.class);
|
b = rs.executeUpdate(handler.getSqlStr());
|
||||||
if (hasBatchInsert) {
|
} else {
|
||||||
BatchInsert batchInsert = method.getAnnotation(BatchInsert.class);
|
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
||||||
String sql = batchInsert.value();
|
}
|
||||||
Class<?> returnType = method.getReturnType();
|
if (returnType.equals(void.class)) {
|
||||||
boolean custom = batchInsert.custom();
|
return null;
|
||||||
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
}
|
||||||
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
if (batchSqlResult.getBatchList().isEmpty()) {
|
return b;
|
||||||
throw new CustomerException("getDataId batch sql error , batch sql args is empty!");
|
}
|
||||||
}
|
}
|
||||||
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("insert ")) {
|
boolean hasBatchInsert = method.isAnnotationPresent(BatchInsert.class);
|
||||||
throw new CustomerException("The sql statement does not match, the @Insert annotation can only getDataId the insert statement, please check whether the sql statement matches!");
|
if (hasBatchInsert) {
|
||||||
}
|
BatchInsert batchInsert = method.getAnnotation(BatchInsert.class);
|
||||||
boolean b = rs.executeBatchSql(batchSqlResult.getSqlStr(), batchSqlResult.getBatchList());
|
String sql = batchInsert.value();
|
||||||
if (returnType.equals(void.class)) {
|
Class<?> returnType = method.getReturnType();
|
||||||
return null;
|
boolean custom = batchInsert.custom();
|
||||||
}
|
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
||||||
return b;
|
if (batchSqlResult.getBatchList().isEmpty()) {
|
||||||
}
|
throw new CustomerException("execute batch sql error , batch sql args is empty!");
|
||||||
|
}
|
||||||
}
|
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("insert ")) {
|
||||||
boolean hasBatchUpdate = method.isAnnotationPresent(BatchUpdate.class);
|
throw new CustomerException("The sql statement does not match, the @Insert annotation can only execute the insert statement, please check whether the sql statement matches!");
|
||||||
if (hasBatchUpdate) {
|
}
|
||||||
BatchUpdate batchUpdate = method.getAnnotation(BatchUpdate.class);
|
boolean b = rs.executeBatchSql(batchSqlResult.getSqlStr(), batchSqlResult.getBatchList());
|
||||||
String sql = batchUpdate.value();
|
if (returnType.equals(void.class)) {
|
||||||
Class<?> returnType = method.getReturnType();
|
return null;
|
||||||
boolean custom = batchUpdate.custom();
|
}
|
||||||
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
return b;
|
||||||
if (batchSqlResult.getBatchList().isEmpty()) {
|
}
|
||||||
throw new CustomerException("getDataId batch sql error , batch sql args is empty!");
|
|
||||||
}
|
}
|
||||||
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("update ")) {
|
boolean hasBatchUpdate = method.isAnnotationPresent(BatchUpdate.class);
|
||||||
throw new CustomerException("The sql statement does not match, the @Update annotation can only getDataId the update statement, please check whether the sql statement matches!");
|
if (hasBatchUpdate) {
|
||||||
}
|
BatchUpdate batchUpdate = method.getAnnotation(BatchUpdate.class);
|
||||||
boolean b = rs.executeBatchSql(batchSqlResult.getSqlStr(), batchSqlResult.getBatchList());
|
String sql = batchUpdate.value();
|
||||||
if (returnType.equals(void.class)) {
|
Class<?> returnType = method.getReturnType();
|
||||||
return null;
|
boolean custom = batchUpdate.custom();
|
||||||
}
|
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
||||||
return b;
|
if (batchSqlResult.getBatchList().isEmpty()) {
|
||||||
}
|
throw new CustomerException("execute batch sql error , batch sql args is empty!");
|
||||||
|
}
|
||||||
}
|
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("update ")) {
|
||||||
boolean hasBatchDelete = method.isAnnotationPresent(BatchDelete.class);
|
throw new CustomerException("The sql statement does not match, the @Update annotation can only execute the update statement, please check whether the sql statement matches!");
|
||||||
if (hasBatchDelete) {
|
}
|
||||||
BatchDelete batchDelete = method.getAnnotation(BatchDelete.class);
|
boolean b = rs.executeBatchSql(batchSqlResult.getSqlStr(), batchSqlResult.getBatchList());
|
||||||
String sql = batchDelete.value();
|
if (returnType.equals(void.class)) {
|
||||||
Class<?> returnType = method.getReturnType();
|
return null;
|
||||||
boolean custom = batchDelete.custom();
|
}
|
||||||
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
return b;
|
||||||
if (batchSqlResult.getBatchList().isEmpty()) {
|
}
|
||||||
throw new CustomerException("getDataId batch sql error , batch sql args is empty!");
|
|
||||||
}
|
}
|
||||||
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("delete ")) {
|
boolean hasBatchDelete = method.isAnnotationPresent(BatchDelete.class);
|
||||||
throw new CustomerException("The sql statement does not match, the @Delete annotation can only getDataId the delete statement, please check whether the sql statement matches!");
|
if (hasBatchDelete) {
|
||||||
}
|
BatchDelete batchDelete = method.getAnnotation(BatchDelete.class);
|
||||||
boolean b = rs.executeBatchSql(batchSqlResult.getSqlStr(), batchSqlResult.getBatchList());
|
String sql = batchDelete.value();
|
||||||
if (returnType.equals(void.class)) {
|
Class<?> returnType = method.getReturnType();
|
||||||
return null;
|
boolean custom = batchDelete.custom();
|
||||||
}
|
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
||||||
return b;
|
if (batchSqlResult.getBatchList().isEmpty()) {
|
||||||
}
|
throw new CustomerException("execute batch sql error , batch sql args is empty!");
|
||||||
|
}
|
||||||
}
|
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("delete ")) {
|
||||||
throw new CustomerException("该方法没有添加注解!请检查是否正确添加注解!@Select、@Update、@Insert、@Delete、@BatchUpdate、@BatchInsert、@BatchDelete");
|
throw new CustomerException("The sql statement does not match, the @Delete annotation can only execute the delete statement, please check whether the sql statement matches!");
|
||||||
}
|
}
|
||||||
|
boolean b = rs.executeBatchSql(batchSqlResult.getSqlStr(), batchSqlResult.getBatchList());
|
||||||
private Object invokeRsTrans(Object proxy, Method method, Object[] args) {
|
if (returnType.equals(void.class)) {
|
||||||
RecordSetTrans rs = rsManager.getTrans(method.getDeclaringClass().getName());
|
return null;
|
||||||
if (rs == null) {
|
}
|
||||||
rsManager.setRecordSetTrans(method.getDeclaringClass().getName());
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
rs = rsManager.getTrans(method.getDeclaringClass().getName());
|
return b;
|
||||||
}
|
}
|
||||||
SqlHandler sqlHandler = new SqlHandler();
|
|
||||||
ResultMapper resultMapper = new ResultMapper();
|
}
|
||||||
Select select = method.getAnnotation(Select.class);
|
throw new CustomerException("该方法没有添加注解!请检查是否正确添加注解!@Select、@Update、@Insert、@Delete、@BatchUpdate、@BatchInsert、@BatchDelete");
|
||||||
if (select != null) {
|
}
|
||||||
// 查询
|
|
||||||
String sql = select.value();
|
private Object invokeRsTrans(Object proxy, Method method, Object[] args, String name) {
|
||||||
boolean custom = select.custom();
|
String mapperKey = method.getDeclaringClass().getName();
|
||||||
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
if (!"".equals(name) && null != name) {
|
||||||
if (!handler.getSqlStr().trim().toLowerCase().startsWith("select ")) {
|
mapperKey += "." + name;
|
||||||
throw new CustomerException("The sql statement does not match, the @Select annotation can only getDataId the select statement, please check whether the sql statement matches!");
|
}
|
||||||
}
|
RecordSetTrans rs = rsManager.getTrans(mapperKey);
|
||||||
Util.getLogger(SQL_LOG).info("解析sql===>" + handler);
|
if (rs == null) {
|
||||||
try {
|
rsManager.setRecordSetTrans(mapperKey);
|
||||||
if (handler.getArgs().isEmpty()) {
|
rs = rsManager.getTrans(mapperKey);
|
||||||
rs.executeQuery(handler.getSqlStr());
|
}
|
||||||
} else {
|
SqlHandler sqlHandler = new SqlHandler();
|
||||||
rs.executeQuery(handler.getSqlStr(), handler.getArgs());
|
ResultMapper resultMapper = new ResultMapper();
|
||||||
}
|
Select select = method.getAnnotation(Select.class);
|
||||||
} catch (Exception e) {
|
if (select != null) {
|
||||||
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
// 查询
|
||||||
throw new CustomerException("execute sql error!" + e.getMessage());
|
String sql = select.value();
|
||||||
}
|
boolean custom = select.custom();
|
||||||
return resultMapper.mapperResult(rs, method, method.getReturnType());
|
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
||||||
}
|
if (!handler.getSqlStr().trim().toLowerCase().startsWith("select ")) {
|
||||||
|
throw new CustomerException("The sql statement does not match, the @Select annotation can only execute the select statement, please check whether the sql statement matches!");
|
||||||
Update update = method.getAnnotation(Update.class);
|
}
|
||||||
if (update != null) {
|
Util.getLogger(SQL_LOG).info("解析sql===>" + handler);
|
||||||
// 查询
|
try {
|
||||||
String sql = update.value();
|
if (handler.getArgs().isEmpty()) {
|
||||||
boolean custom = update.custom();
|
rs.executeQuery(handler.getSqlStr());
|
||||||
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
} else {
|
||||||
if (!handler.getSqlStr().trim().toLowerCase().startsWith("update ")) {
|
rs.executeQuery(handler.getSqlStr(), handler.getArgs());
|
||||||
throw new CustomerException("The sql statement does not match, the @Update annotation can only getDataId the update statement, please check whether the sql statement matches!");
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
Util.getLogger(SQL_LOG).info(handler.toString());
|
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
||||||
Class<?> returnType = method.getReturnType();
|
throw new CustomerException("execute sql error!" + e.getMessage());
|
||||||
boolean b;
|
}
|
||||||
try {
|
return resultMapper.mapperResult(rs, method, method.getReturnType(), this);
|
||||||
if (handler.getArgs().isEmpty()) {
|
}
|
||||||
b = rs.executeUpdate(handler.getSqlStr());
|
|
||||||
} else {
|
Update update = method.getAnnotation(Update.class);
|
||||||
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
if (update != null) {
|
||||||
}
|
// 查询
|
||||||
} catch (Exception e) {
|
String sql = update.value();
|
||||||
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
boolean custom = update.custom();
|
||||||
throw new CustomerException("execute sql error!" + e.getMessage());
|
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
||||||
}
|
if (!handler.getSqlStr().trim().toLowerCase().startsWith("update ")) {
|
||||||
if (returnType.equals(void.class)) {
|
throw new CustomerException("The sql statement does not match, the @Update annotation can only execute the update statement, please check whether the sql statement matches!");
|
||||||
return null;
|
}
|
||||||
}
|
Util.getLogger(SQL_LOG).info(handler.toString());
|
||||||
if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
|
Class<?> returnType = method.getReturnType();
|
||||||
if (b) {
|
boolean b;
|
||||||
return 1;
|
try {
|
||||||
} else {
|
if (handler.getArgs().isEmpty()) {
|
||||||
return 0;
|
b = rs.executeUpdate(handler.getSqlStr());
|
||||||
}
|
} else {
|
||||||
}
|
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
}
|
||||||
return b;
|
} catch (Exception e) {
|
||||||
}
|
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
||||||
}
|
throw new CustomerException("execute sql error!" + e.getMessage());
|
||||||
Insert insert = method.getAnnotation(Insert.class);
|
}
|
||||||
if (insert != null) {
|
if (returnType.equals(void.class)) {
|
||||||
// 查询
|
return null;
|
||||||
String sql = insert.value();
|
}
|
||||||
boolean custom = insert.custom();
|
if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
|
||||||
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
if (b) {
|
||||||
if (!handler.getSqlStr().trim().toLowerCase().startsWith("insert ")) {
|
return 1;
|
||||||
throw new CustomerException("The sql statement does not match, the @Insert annotation can only getDataId the insert statement, please check whether the sql statement matches!");
|
} else {
|
||||||
}
|
return 0;
|
||||||
Util.getLogger(SQL_LOG).info(handler.toString());
|
}
|
||||||
Class<?> returnType = method.getReturnType();
|
}
|
||||||
boolean b;
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
try {
|
return b;
|
||||||
if (handler.getArgs().isEmpty()) {
|
}
|
||||||
b = rs.executeUpdate(handler.getSqlStr());
|
}
|
||||||
} else {
|
Insert insert = method.getAnnotation(Insert.class);
|
||||||
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
if (insert != null) {
|
||||||
}
|
// 查询
|
||||||
} catch (Exception e) {
|
String sql = insert.value();
|
||||||
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
boolean custom = insert.custom();
|
||||||
throw new CustomerException("execute sql error!" + e.getMessage());
|
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
||||||
}
|
if (!handler.getSqlStr().trim().toLowerCase().startsWith("insert ")) {
|
||||||
if (returnType.equals(void.class)) {
|
throw new CustomerException("The sql statement does not match, the @Insert annotation can only execute the insert statement, please check whether the sql statement matches!");
|
||||||
return null;
|
}
|
||||||
}
|
Util.getLogger(SQL_LOG).info(handler.toString());
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
Class<?> returnType = method.getReturnType();
|
||||||
return b;
|
boolean b;
|
||||||
}
|
try {
|
||||||
}
|
if (handler.getArgs().isEmpty()) {
|
||||||
Delete delete = method.getAnnotation(Delete.class);
|
b = rs.executeUpdate(handler.getSqlStr());
|
||||||
if (delete != null) {
|
} else {
|
||||||
// 查询
|
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
||||||
String sql = delete.value();
|
}
|
||||||
boolean custom = delete.custom();
|
} catch (Exception e) {
|
||||||
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
||||||
if (!handler.getSqlStr().trim().toLowerCase().startsWith("delete ")) {
|
throw new CustomerException("execute sql error!" + e.getMessage());
|
||||||
throw new CustomerException("The sql statement does not match, the @Delete annotation can only getDataId the delete statement, please check whether the sql statement matches!");
|
}
|
||||||
}
|
if (returnType.equals(void.class)) {
|
||||||
Util.getLogger(SQL_LOG).info(handler.toString());
|
return null;
|
||||||
Class<?> returnType = method.getReturnType();
|
}
|
||||||
boolean b;
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
try {
|
return b;
|
||||||
if (handler.getArgs().isEmpty()) {
|
}
|
||||||
b = rs.executeUpdate(handler.getSqlStr());
|
}
|
||||||
} else {
|
Delete delete = method.getAnnotation(Delete.class);
|
||||||
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
if (delete != null) {
|
||||||
}
|
// 查询
|
||||||
} catch (Exception e) {
|
String sql = delete.value();
|
||||||
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
boolean custom = delete.custom();
|
||||||
throw new CustomerException("execute sql error!" + e.getMessage());
|
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
|
||||||
}
|
if (!handler.getSqlStr().trim().toLowerCase().startsWith("delete ")) {
|
||||||
if (returnType.equals(void.class)) {
|
throw new CustomerException("The sql statement does not match, the @Delete annotation can only execute the delete statement, please check whether the sql statement matches!");
|
||||||
return null;
|
}
|
||||||
}
|
Util.getLogger(SQL_LOG).info(handler.toString());
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
Class<?> returnType = method.getReturnType();
|
||||||
return b;
|
boolean b;
|
||||||
}
|
try {
|
||||||
}
|
if (handler.getArgs().isEmpty()) {
|
||||||
boolean hasBatchInsert = method.isAnnotationPresent(BatchInsert.class);
|
b = rs.executeUpdate(handler.getSqlStr());
|
||||||
if (hasBatchInsert) {
|
} else {
|
||||||
BatchInsert batchInsert = method.getAnnotation(BatchInsert.class);
|
b = rs.executeUpdate(handler.getSqlStr(), handler.getArgs());
|
||||||
String sql = batchInsert.value();
|
}
|
||||||
Class<?> returnType = method.getReturnType();
|
} catch (Exception e) {
|
||||||
boolean custom = batchInsert.custom();
|
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
||||||
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
throw new CustomerException("execute sql error!" + e.getMessage());
|
||||||
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
}
|
||||||
List<List> batchList = batchSqlResult.getBatchList();
|
if (returnType.equals(void.class)) {
|
||||||
if (batchList.isEmpty()) {
|
return null;
|
||||||
throw new CustomerException("getDataId batch sql error , batch sql args is empty!");
|
}
|
||||||
}
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
List<List<Object>> batchListTrans = new ArrayList<>();
|
return b;
|
||||||
for (List list : batchList) {
|
}
|
||||||
List<Object> listItem = new ArrayList<>();
|
}
|
||||||
for (Object o : list) {
|
boolean hasBatchInsert = method.isAnnotationPresent(BatchInsert.class);
|
||||||
listItem.add(o);
|
if (hasBatchInsert) {
|
||||||
}
|
BatchInsert batchInsert = method.getAnnotation(BatchInsert.class);
|
||||||
batchListTrans.add(listItem);
|
String sql = batchInsert.value();
|
||||||
}
|
Class<?> returnType = method.getReturnType();
|
||||||
|
boolean custom = batchInsert.custom();
|
||||||
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("insert ")) {
|
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
||||||
throw new CustomerException("The sql statement does not match, the @Insert annotation can only getDataId the insert statement, please check whether the sql statement matches!");
|
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
||||||
}
|
List<List> batchList = batchSqlResult.getBatchList();
|
||||||
boolean b = true;
|
if (batchList.isEmpty()) {
|
||||||
try {
|
throw new CustomerException("execute batch sql error , batch sql args is empty!");
|
||||||
rs.executeBatchSql(batchSqlResult.getSqlStr(), batchListTrans);
|
}
|
||||||
} catch (Exception e) {
|
List<List<Object>> batchListTrans = new ArrayList<>();
|
||||||
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
for (List list : batchList) {
|
||||||
throw new CustomerException("execute sql error!" + e.getMessage());
|
List<Object> listItem = new ArrayList<>();
|
||||||
}
|
for (Object o : list) {
|
||||||
if (returnType.equals(void.class)) {
|
listItem.add(o);
|
||||||
return null;
|
}
|
||||||
}
|
batchListTrans.add(listItem);
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
}
|
||||||
return b;
|
|
||||||
}
|
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("insert ")) {
|
||||||
|
throw new CustomerException("The sql statement does not match, the @Insert annotation can only execute the insert statement, please check whether the sql statement matches!");
|
||||||
}
|
}
|
||||||
boolean hasBatchUpdate = method.isAnnotationPresent(BatchUpdate.class);
|
boolean b = true;
|
||||||
if (hasBatchUpdate) {
|
try {
|
||||||
BatchUpdate batchUpdate = method.getAnnotation(BatchUpdate.class);
|
rs.executeBatchSql(batchSqlResult.getSqlStr(), batchListTrans);
|
||||||
String sql = batchUpdate.value();
|
} catch (Exception e) {
|
||||||
Class<?> returnType = method.getReturnType();
|
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
||||||
boolean custom = batchUpdate.custom();
|
throw new CustomerException("execute sql error!" + e.getMessage());
|
||||||
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
}
|
||||||
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
if (returnType.equals(void.class)) {
|
||||||
if (batchSqlResult.getBatchList().isEmpty()) {
|
return null;
|
||||||
throw new CustomerException("getDataId batch sql error , batch sql args is empty!");
|
}
|
||||||
}
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("update ")) {
|
return b;
|
||||||
throw new CustomerException("The sql statement does not match, the @Update annotation can only getDataId the update statement, please check whether the sql statement matches!");
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
List<List> batchList = batchSqlResult.getBatchList();
|
boolean hasBatchUpdate = method.isAnnotationPresent(BatchUpdate.class);
|
||||||
if (batchList.isEmpty()) {
|
if (hasBatchUpdate) {
|
||||||
throw new CustomerException("getDataId batch sql error , batch sql args is empty!");
|
BatchUpdate batchUpdate = method.getAnnotation(BatchUpdate.class);
|
||||||
}
|
String sql = batchUpdate.value();
|
||||||
List<List<Object>> batchListTrans = new ArrayList<>();
|
Class<?> returnType = method.getReturnType();
|
||||||
for (List list : batchList) {
|
boolean custom = batchUpdate.custom();
|
||||||
List<Object> listItem = new ArrayList<>();
|
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
||||||
for (Object o : list) {
|
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
||||||
listItem.add(o);
|
if (batchSqlResult.getBatchList().isEmpty()) {
|
||||||
}
|
throw new CustomerException("execute batch sql error , batch sql args is empty!");
|
||||||
batchListTrans.add(listItem);
|
}
|
||||||
}
|
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("update ")) {
|
||||||
try {
|
throw new CustomerException("The sql statement does not match, the @Update annotation can only execute the update statement, please check whether the sql statement matches!");
|
||||||
rs.executeBatchSql(batchSqlResult.getSqlStr(), batchListTrans);
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
List<List> batchList = batchSqlResult.getBatchList();
|
||||||
throw new CustomerException("execute sql error!" + e.getMessage());
|
if (batchList.isEmpty()) {
|
||||||
}
|
throw new CustomerException("execute batch sql error , batch sql args is empty!");
|
||||||
if (returnType.equals(void.class)) {
|
}
|
||||||
return null;
|
List<List<Object>> batchListTrans = new ArrayList<>();
|
||||||
}
|
for (List list : batchList) {
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
List<Object> listItem = new ArrayList<>();
|
||||||
return true;
|
for (Object o : list) {
|
||||||
}
|
listItem.add(o);
|
||||||
|
}
|
||||||
}
|
batchListTrans.add(listItem);
|
||||||
boolean hasBatchDelete = method.isAnnotationPresent(BatchDelete.class);
|
}
|
||||||
if (hasBatchDelete) {
|
try {
|
||||||
BatchDelete batchDelete = method.getAnnotation(BatchDelete.class);
|
rs.executeBatchSql(batchSqlResult.getSqlStr(), batchListTrans);
|
||||||
String sql = batchDelete.value();
|
} catch (Exception e) {
|
||||||
Class<?> returnType = method.getReturnType();
|
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
||||||
boolean custom = batchDelete.custom();
|
throw new CustomerException("execute sql error!" + e.getMessage());
|
||||||
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
}
|
||||||
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
if (returnType.equals(void.class)) {
|
||||||
if (batchSqlResult.getBatchList().isEmpty()) {
|
return null;
|
||||||
throw new CustomerException("getDataId batch sql error , batch sql args is empty!");
|
}
|
||||||
}
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("delete ")) {
|
return true;
|
||||||
throw new CustomerException("The sql statement does not match, the @Delete annotation can only getDataId the delete statement, please check whether the sql statement matches!");
|
}
|
||||||
}
|
|
||||||
List<List> batchList = batchSqlResult.getBatchList();
|
}
|
||||||
if (batchList.isEmpty()) {
|
boolean hasBatchDelete = method.isAnnotationPresent(BatchDelete.class);
|
||||||
throw new CustomerException("getDataId batch sql error , batch sql args is empty!");
|
if (hasBatchDelete) {
|
||||||
}
|
BatchDelete batchDelete = method.getAnnotation(BatchDelete.class);
|
||||||
List<List<Object>> batchListTrans = new ArrayList<>();
|
String sql = batchDelete.value();
|
||||||
for (List list : batchList) {
|
Class<?> returnType = method.getReturnType();
|
||||||
List<Object> listItem = new ArrayList<>();
|
boolean custom = batchDelete.custom();
|
||||||
for (Object o : list) {
|
BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args);
|
||||||
listItem.add(o);
|
Util.getLogger(SQL_LOG).info(batchSqlResult.toString());
|
||||||
}
|
if (batchSqlResult.getBatchList().isEmpty()) {
|
||||||
batchListTrans.add(listItem);
|
throw new CustomerException("execute batch sql error , batch sql args is empty!");
|
||||||
}
|
}
|
||||||
try {
|
if (!batchSqlResult.getSqlStr().trim().toLowerCase().startsWith("delete ")) {
|
||||||
rs.executeBatchSql(batchSqlResult.getSqlStr(), batchListTrans);
|
throw new CustomerException("The sql statement does not match, the @Delete annotation can only execute the delete statement, please check whether the sql statement matches!");
|
||||||
} catch (Exception e) {
|
}
|
||||||
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
List<List> batchList = batchSqlResult.getBatchList();
|
||||||
throw new CustomerException("execute sql error!" + e.getMessage());
|
if (batchList.isEmpty()) {
|
||||||
}
|
throw new CustomerException("execute batch sql error , batch sql args is empty!");
|
||||||
if (returnType.equals(void.class)) {
|
}
|
||||||
return null;
|
List<List<Object>> batchListTrans = new ArrayList<>();
|
||||||
}
|
for (List list : batchList) {
|
||||||
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
List<Object> listItem = new ArrayList<>();
|
||||||
return true;
|
for (Object o : list) {
|
||||||
}
|
listItem.add(o);
|
||||||
|
}
|
||||||
}
|
batchListTrans.add(listItem);
|
||||||
throw new CustomerException("该方法没有添加注解!请检查是否正确添加注解!@Select、@Update、@Insert、@Delete、@BatchUpdate、@BatchInsert、@BatchDelete");
|
}
|
||||||
}
|
try {
|
||||||
|
rs.executeBatchSql(batchSqlResult.getSqlStr(), batchListTrans);
|
||||||
public RsThreadLocalManager getRsManager() {
|
} catch (Exception e) {
|
||||||
return rsManager;
|
Util.getLogger(SQL_LOG).error("execute sql error! " + Util.getErrString(e));
|
||||||
}
|
throw new CustomerException("execute sql error!" + e.getMessage());
|
||||||
|
}
|
||||||
|
if (returnType.equals(void.class)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
throw new CustomerException("该方法没有添加注解!请检查是否正确添加注解!@Select、@Update、@Insert、@Delete、@BatchUpdate、@BatchInsert、@BatchDelete");
|
||||||
|
}
|
||||||
|
|
||||||
|
public RsThreadLocalManager getRsManager() {
|
||||||
|
return rsManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -44,4 +44,33 @@ public class RaceTrackController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/get/stage-info")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public String getStageInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
try {
|
||||||
|
return ApiResult.success(service.getStageInfo(user));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("race track get event list error!\n" + Util.getErrString(e));
|
||||||
|
return ApiResult.error("race track get event list error!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/get/status")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public String getUserStatus(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
return ApiResult.success(user.getStatus());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("get usr status fail!\n" + Util.getErrString(e));
|
||||||
|
return ApiResult.error("get usr status fail!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.api.youhong.ai.pcn.racetrack.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>直道图数据库对象</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/17 11:41</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
public class RaceTrackStage {
|
||||||
|
/** id */
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
/** 一阶段 */
|
||||||
|
private String oneStage;
|
||||||
|
|
||||||
|
/** 二阶段 */
|
||||||
|
private String towStage;
|
||||||
|
|
||||||
|
/** 三阶段 */
|
||||||
|
private String threeStage;
|
||||||
|
/** 四阶段 */
|
||||||
|
private String fourStage;
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
import aiyh.utils.annotation.recordset.Select;
|
import aiyh.utils.annotation.recordset.Select;
|
||||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
import com.api.youhong.ai.pcn.racetrack.dto.RaceTrackEvent;
|
import com.api.youhong.ai.pcn.racetrack.dto.RaceTrackEvent;
|
||||||
|
import com.api.youhong.ai.pcn.racetrack.dto.RaceTrackStage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -47,4 +48,19 @@ public interface RacetrackMapper {
|
||||||
*/
|
*/
|
||||||
@Select("select companyworkyear from hrmresource where id = #{userId}")
|
@Select("select companyworkyear from hrmresource where id = #{userId}")
|
||||||
String selectLengthOfEntryTime(@ParamMapper("userId") Integer userId);
|
String selectLengthOfEntryTime(@ParamMapper("userId") Integer userId);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select id, $t{raceTrackStageOneField} one_stage," +
|
||||||
|
"$t{raceTrackStageTwoField} tow_stage," +
|
||||||
|
"$t{raceTrackStageThreeField} three_stage ," +
|
||||||
|
"$t{raceTrackStageFourField} four_stage " +
|
||||||
|
"from $t{raceTrackStageTable} " +
|
||||||
|
"where $t{raceTrackStageUserField} = #{userId}")
|
||||||
|
RaceTrackStage selectStageInfoByUserId(@ParamMapper("userId") int uid,
|
||||||
|
@ParamMapper("raceTrackStageTable") String raceTrackStageTable,
|
||||||
|
@ParamMapper("raceTrackStageUserField") String raceTrackStageUserField,
|
||||||
|
@ParamMapper("raceTrackStageOneField") String raceTrackStageOneField,
|
||||||
|
@ParamMapper("raceTrackStageTwoField") String raceTrackStageTwoField,
|
||||||
|
@ParamMapper("raceTrackStageThreeField") String raceTrackStageThreeField,
|
||||||
|
@ParamMapper("raceTrackStageFourField") String raceTrackStageFourField);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
package com.api.youhong.ai.pcn.racetrack.service;
|
package com.api.youhong.ai.pcn.racetrack.service;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import cn.hutool.core.lang.Assert;
|
import aiyh.utils.tool.Assert;
|
||||||
import com.api.youhong.ai.pcn.racetrack.dto.RaceTrackEvent;
|
import com.api.youhong.ai.pcn.racetrack.dto.RaceTrackEvent;
|
||||||
|
import com.api.youhong.ai.pcn.racetrack.dto.RaceTrackStage;
|
||||||
import com.api.youhong.ai.pcn.racetrack.mapper.RacetrackMapper;
|
import com.api.youhong.ai.pcn.racetrack.mapper.RacetrackMapper;
|
||||||
|
import com.api.youhong.ai.pcn.racetrack.vo.RaceTrackStageVo;
|
||||||
import com.api.youhong.ai.pcn.racetrack.vo.RaceTrackVo;
|
import com.api.youhong.ai.pcn.racetrack.vo.RaceTrackVo;
|
||||||
|
import com.api.youhong.ai.pcn.racetrack.vo.StageInfoVo;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import ebu7common.youhong.ai.bean.Builder;
|
import ebu7common.youhong.ai.bean.Builder;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,6 +59,114 @@ public class RaceTrackService {
|
||||||
return Builder.builder(RaceTrackVo::new)
|
return Builder.builder(RaceTrackVo::new)
|
||||||
.with(RaceTrackVo::setEventList, raceTrackEventList)
|
.with(RaceTrackVo::setEventList, raceTrackEventList)
|
||||||
.with(RaceTrackVo::setLengthOfEntryTime, lengthOfEntryTime)
|
.with(RaceTrackVo::setLengthOfEntryTime, lengthOfEntryTime)
|
||||||
|
.with(RaceTrackVo::setUserStatus, user.getStatus())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>获取阶段信息列表</h2>
|
||||||
|
*
|
||||||
|
* @param user 当前用户
|
||||||
|
* @return 阶段信息列表
|
||||||
|
*/
|
||||||
|
public Object getStageInfo(User user) {
|
||||||
|
// 直到图数据表
|
||||||
|
String raceTrackStageTable = Util.getCusConfigValue("RACE_TRACK_STAGE_TABLE");
|
||||||
|
// 数据表用户字段
|
||||||
|
String raceTrackStageUserField = Util.getCusConfigValue("RACE_TRACK_STAGE_USER_FIELD");
|
||||||
|
// 一阶段列名
|
||||||
|
String raceTrackStageOneField = Util.getCusConfigValue("RACE_TRACK_STAGE_ONE_FIELD");
|
||||||
|
// 二阶段列名
|
||||||
|
String raceTrackStageTwoField = Util.getCusConfigValue("RACE_TRACK_STAGE_TWO_FIELD");
|
||||||
|
// 三阶段列名
|
||||||
|
String raceTrackStageThreeField = Util.getCusConfigValue("RACE_TRACK_STAGE_THREE_FIELD");
|
||||||
|
// 四阶段列名
|
||||||
|
String raceTrackStageFourField = Util.getCusConfigValue("RACE_TRACK_STAGE_Four_FIELD");
|
||||||
|
Assert.notBlank(raceTrackStageTable,
|
||||||
|
"race track stage info table can not be null! check configuration [RACE_TRACK_STAGE_TABLE] in uf_cus_dev_config table!");
|
||||||
|
Assert.notBlank(raceTrackStageUserField,
|
||||||
|
"race track stage info user field can not be null! check configuration [RACE_TRACK_STAGE_USER_FIELD] in uf_cus_dev_config table!");
|
||||||
|
Assert.notBlank(raceTrackStageOneField,
|
||||||
|
"race track stage info one stage filed can not be null! check configuration [RACE_TRACK_STAGE_ONE_FIELD] in uf_cus_dev_config table!");
|
||||||
|
Assert.notBlank(raceTrackStageTwoField,
|
||||||
|
"race track stage info tow stage field can not be null! check configuration [RACE_TRACK_STAGE_TWO_FIELD] in uf_cus_dev_config table!");
|
||||||
|
Assert.notBlank(raceTrackStageThreeField,
|
||||||
|
"race track stage info three stage field can not be null! check configuration [RACE_TRACK_STAGE_THREE_FIELD] in uf_cus_dev_config table!");
|
||||||
|
Assert.notBlank(raceTrackStageFourField,
|
||||||
|
"race track stage info four stage field can not be null! check configuration [RACE_TRACK_STAGE_Four_FIELD] in uf_cus_dev_config table!");
|
||||||
|
RaceTrackStage raceTrackStage = mapper.selectStageInfoByUserId(user.getUID(), raceTrackStageTable,
|
||||||
|
raceTrackStageUserField,
|
||||||
|
raceTrackStageOneField,
|
||||||
|
raceTrackStageTwoField,
|
||||||
|
raceTrackStageThreeField,
|
||||||
|
raceTrackStageFourField);
|
||||||
|
List<StageInfoVo> stageInfoVos = pushRaceTrackVo(raceTrackStage);
|
||||||
|
return Builder.builder(RaceTrackStageVo::new)
|
||||||
|
.with(RaceTrackStageVo::setStageVoList, stageInfoVos)
|
||||||
|
.with(RaceTrackStageVo::setStatus, user.getStatus())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>添加阶段信息</h2>
|
||||||
|
*
|
||||||
|
* @param raceTrackStage 阶段信息
|
||||||
|
* @return 阶段信息列表
|
||||||
|
*/
|
||||||
|
private List<StageInfoVo> pushRaceTrackVo(RaceTrackStage raceTrackStage) {
|
||||||
|
List<StageInfoVo> raceTrackVos = new ArrayList<>();
|
||||||
|
String oneStage = raceTrackStage.getOneStage();
|
||||||
|
String towStage = raceTrackStage.getTowStage();
|
||||||
|
String threeStage = raceTrackStage.getThreeStage();
|
||||||
|
String fourStage = raceTrackStage.getFourStage();
|
||||||
|
setRaceTrackValue(raceTrackVos, oneStage);
|
||||||
|
setRaceTrackValue(raceTrackVos, towStage);
|
||||||
|
setRaceTrackValue(raceTrackVos, threeStage);
|
||||||
|
setRaceTrackValue(raceTrackVos, fourStage);
|
||||||
|
for (int i = 0; i < raceTrackVos.size(); i++) {
|
||||||
|
StageInfoVo item = raceTrackVos.get(i);
|
||||||
|
if (i < raceTrackVos.size() - 1) {
|
||||||
|
if (item == null) {
|
||||||
|
raceTrackVos.set(i, Builder.builder(StageInfoVo::new)
|
||||||
|
.with(StageInfoVo::setFailedToArrive, true)
|
||||||
|
.build());
|
||||||
|
} else {
|
||||||
|
item.setActive(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (item == null) {
|
||||||
|
item = Builder.builder(StageInfoVo::new)
|
||||||
|
.with(StageInfoVo::setFailedToArrive, true)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
StageInfoVo nextItem = raceTrackVos.get(i + 1);
|
||||||
|
if (nextItem == null) {
|
||||||
|
item.setActive(true);
|
||||||
|
item.setFailedToArrive(false);
|
||||||
|
} else {
|
||||||
|
item.setPass(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return raceTrackVos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>阶段信息值设置</h2>
|
||||||
|
*
|
||||||
|
* @param raceTrackVos 阶段信息列表
|
||||||
|
* @param stage 阶段字段值
|
||||||
|
*/
|
||||||
|
private static void setRaceTrackValue(List<StageInfoVo> raceTrackVos, String stage) {
|
||||||
|
if (Strings.isNullOrEmpty(stage)) {
|
||||||
|
raceTrackVos.add(null);
|
||||||
|
} else {
|
||||||
|
raceTrackVos.add(
|
||||||
|
Builder.builder(StageInfoVo::new)
|
||||||
|
.with(StageInfoVo::setTime, stage)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.api.youhong.ai.pcn.racetrack.vo;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>直道图阶段信息</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/17 11:06</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class RaceTrackStageVo {
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int status;
|
||||||
|
|
||||||
|
private List<StageInfoVo> stageVoList;
|
||||||
|
}
|
|
@ -24,4 +24,7 @@ public class RaceTrackVo {
|
||||||
|
|
||||||
/** 入职时长 */
|
/** 入职时长 */
|
||||||
private String lengthOfEntryTime;
|
private String lengthOfEntryTime;
|
||||||
|
|
||||||
|
|
||||||
|
private int userStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.api.youhong.ai.pcn.racetrack.vo;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>阶段信息</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/17 11:21</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class StageInfoVo {
|
||||||
|
/** 时间 */
|
||||||
|
private String time;
|
||||||
|
/** 通过 */
|
||||||
|
private boolean pass;
|
||||||
|
/** 是否当前节点 */
|
||||||
|
private boolean active;
|
||||||
|
/** 未到达标识 */
|
||||||
|
private boolean failedToArrive;
|
||||||
|
}
|
|
@ -2,13 +2,11 @@ package weaver.youhong.ai.intellectualproperty.action;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.action.SafeCusBaseAction;
|
import aiyh.utils.action.SafeCusBaseAction;
|
||||||
import aiyh.utils.annotation.ActionDefaultTestValue;
|
import aiyh.utils.annotation.*;
|
||||||
import aiyh.utils.annotation.ActionOptionalParam;
|
|
||||||
import aiyh.utils.annotation.PrintParamMark;
|
|
||||||
import aiyh.utils.annotation.RequiredMark;
|
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
import aiyh.utils.httpUtil.ResponeVo;
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
@ -16,8 +14,13 @@ import weaver.hrm.User;
|
||||||
import weaver.soa.workflow.request.RequestInfo;
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||||
import weaver.xiao.commons.config.service.DealWithMapping;
|
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||||
|
import weaver.youhong.ai.intellectualproperty.mapper.CaElectronicSignatureMapper;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +33,11 @@ import java.util.Map;
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
|
@ActionDesc(value = "电子签action", author = "youhong.ai")
|
||||||
public class CaElectronicSignatureAction extends SafeCusBaseAction {
|
public class CaElectronicSignatureAction extends SafeCusBaseAction {
|
||||||
|
|
||||||
|
public static final ThreadLocal<String> docName = new ThreadLocal<>();
|
||||||
|
public static final int SUCCESS_CODE = 200;
|
||||||
@PrintParamMark
|
@PrintParamMark
|
||||||
@ActionOptionalParam(value = "false", desc = "是否自动提交流程")
|
@ActionOptionalParam(value = "false", desc = "是否自动提交流程")
|
||||||
@ActionDefaultTestValue("false")
|
@ActionDefaultTestValue("false")
|
||||||
|
@ -46,10 +53,23 @@ public class CaElectronicSignatureAction extends SafeCusBaseAction {
|
||||||
@RequiredMark("请求接口参数配置表中的唯一标识字段的值")
|
@RequiredMark("请求接口参数配置表中的唯一标识字段的值")
|
||||||
private String onlyMark;
|
private String onlyMark;
|
||||||
|
|
||||||
|
|
||||||
|
@PrintParamMark
|
||||||
|
@ActionOptionalParam(value = "", desc = "签署后文件存储字段,只支持主表字段")
|
||||||
|
private String signFileField;
|
||||||
|
|
||||||
|
|
||||||
|
@PrintParamMark
|
||||||
|
@ActionOptionalParam(value = "", desc = "签署文件的文件唯一编号存储字段,只支持主表字段")
|
||||||
|
private String signFileNoField;
|
||||||
|
|
||||||
private final DealWithMapping dealWithMapping = new DealWithMapping();
|
private final DealWithMapping dealWithMapping = new DealWithMapping();
|
||||||
|
|
||||||
private final HttpUtils httpUtils = new HttpUtils();
|
private final HttpUtils httpUtils = new HttpUtils();
|
||||||
|
|
||||||
|
|
||||||
|
private final CaElectronicSignatureMapper mapper = Util.getMapper(CaElectronicSignatureMapper.class);
|
||||||
|
|
||||||
{
|
{
|
||||||
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON);
|
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +83,19 @@ public class CaElectronicSignatureAction extends SafeCusBaseAction {
|
||||||
String requestUrl = requestMappingConfig.getRequestUrl();
|
String requestUrl = requestMappingConfig.getRequestUrl();
|
||||||
Map<String, Object> requestParam = dealWithMapping.getRequestParam(super.getObjMainTableValue(requestInfo), requestMappingConfig);
|
Map<String, Object> requestParam = dealWithMapping.getRequestParam(super.getObjMainTableValue(requestInfo), requestMappingConfig);
|
||||||
ResponeVo responeVo = httpUtils.apiPost(requestUrl, requestParam);
|
ResponeVo responeVo = httpUtils.apiPost(requestUrl, requestParam);
|
||||||
|
if (responeVo.getCode() != SUCCESS_CODE) {
|
||||||
|
throw new CustomerException(responeVo.getCode() + ", fetch ca sign fail! ");
|
||||||
|
}
|
||||||
Map<String, Object> responseMap = responeVo.getResponseMap();
|
Map<String, Object> responseMap = responeVo.getResponseMap();
|
||||||
|
String documentNo = Util.null2String(responseMap.get("document_no"));
|
||||||
|
String pdf = Util.null2String(responseMap.get("pdf"));
|
||||||
|
InputStream inputStream = base64ContentToFile(pdf);
|
||||||
|
String docCategorys = Util.getDocCategorysByTable(String.valueOf(workflowId), signFileField, billTable);
|
||||||
|
String[] docCategoryArr = docCategorys.split(",");
|
||||||
|
int docCategory = Integer.parseInt(docCategoryArr[docCategoryArr.length - 1]);
|
||||||
|
int docId = Util.createDoc(Strings.isNullOrEmpty(docName.get()) ? "sign.pdf" : docName.get(), docCategory, inputStream, 1);
|
||||||
|
docName.remove();
|
||||||
|
writeBack(documentNo, billTable, requestId, docId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Boolean.parseBoolean(block)) {
|
if (Boolean.parseBoolean(block)) {
|
||||||
throw new CustomerException(e.getMessage(), e);
|
throw new CustomerException(e.getMessage(), e);
|
||||||
|
@ -75,7 +107,49 @@ public class CaElectronicSignatureAction extends SafeCusBaseAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>回写数据</h2>
|
||||||
|
*
|
||||||
|
* @param documentNo 文档编号
|
||||||
|
* @param billTable 表名
|
||||||
|
* @param requestId 请求ID
|
||||||
|
* @param docId 文档id
|
||||||
|
*/
|
||||||
|
public void writeBack(String documentNo, String billTable, String requestId, int docId) {
|
||||||
|
if (!mapper.updateDocumentAndNo(billTable, signFileNoField, documentNo, signFileField, docId, requestId)) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
|
||||||
|
}
|
||||||
|
// 再次尝试
|
||||||
|
if (!mapper.updateDocumentAndNo(billTable, signFileNoField, documentNo, signFileField, docId, requestId)) {
|
||||||
|
throw new CustomerException("can not update sign file to workflow!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>提交流程</h2>
|
||||||
|
*
|
||||||
|
* @param requestId 请求id
|
||||||
|
* @param userId 用户id
|
||||||
|
*/
|
||||||
public void submitWorkflow(String requestId, Integer userId) {
|
public void submitWorkflow(String requestId, Integer userId) {
|
||||||
Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "电子签自动提交流程");
|
Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "电子签自动提交流程");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 4. Base64字符串 转 文件(图片、pdf) -- 多用于测试
|
||||||
|
*
|
||||||
|
* @param base64Content Base64 字符串
|
||||||
|
*/
|
||||||
|
public InputStream base64ContentToFile(String base64Content) {
|
||||||
|
// Base64解码到字符数组
|
||||||
|
byte[] bytes = Base64.getDecoder().decode(base64Content);
|
||||||
|
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes);
|
||||||
|
return new BufferedInputStream(byteInputStream);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package weaver.youhong.ai.intellectualproperty.cusgetvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.entity.DocImageInfo;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.file.ImageFileManager;
|
||||||
|
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
|
||||||
|
import weaver.youhong.ai.intellectualproperty.action.CaElectronicSignatureAction;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>自定义接口获取值</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/17 15:44</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class FileToBase64CusGetValue implements CusInterfaceGetValue {
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(Map<String, Object> mainMap, Map<String, Object> detailMap,
|
||||||
|
String currentValue, Map<String, String> pathParam) {
|
||||||
|
try {
|
||||||
|
DocImageInfo docImageInfo = Util.selectImageInfoByDocId(currentValue);
|
||||||
|
InputStream inputStream = ImageFileManager.getInputStreamById(docImageInfo.getImageFileId());
|
||||||
|
byte[] src = new byte[inputStream.available()];
|
||||||
|
inputStream.read(src);
|
||||||
|
String fileBase64 = Base64.getEncoder().encodeToString(src);
|
||||||
|
CaElectronicSignatureAction.docName.set(docImageInfo.getImageFileName());
|
||||||
|
return fileBase64;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("convert file to base64 fail!" + e.getMessage() + "\n" + Util.getErrString(e));
|
||||||
|
throw new CustomerException("convert file to base64 fail!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package weaver.youhong.ai.intellectualproperty.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.Update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1></h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/17 15:27</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@SqlMapper
|
||||||
|
public interface CaElectronicSignatureMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新回写文件信息</h2>
|
||||||
|
*
|
||||||
|
* @param billTable 表明
|
||||||
|
* @param documentNoField 文件编号存储字段
|
||||||
|
* @param documentNo 文档编号
|
||||||
|
* @param documentField 文档存储字段
|
||||||
|
* @param documentId 文档id
|
||||||
|
* @param requestId 请求id
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
@Update("update $t{billTable} set $t{documentNoField} = #{documentNo}, " +
|
||||||
|
" $t{documentField} = #{documentId} where requestId = #{requestId}")
|
||||||
|
boolean updateDocumentAndNo(@ParamMapper("billTable") String billTable,
|
||||||
|
@ParamMapper("documentNoField") String documentNoField,
|
||||||
|
@ParamMapper("documentNo") String documentNo,
|
||||||
|
@ParamMapper("documentField") String documentField,
|
||||||
|
@ParamMapper("documentId") int documentId,
|
||||||
|
@ParamMapper("requestId") String requestId);
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.action.SafeCusBaseAction;
|
||||||
|
import aiyh.utils.annotation.*;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import ebu7common.youhong.ai.bean.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.UpdateDetailRowDto;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.service.WorkflowConditionsSetValueService;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>流程字段条件赋值action</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 13:27</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@ActionDesc(value = "流程字段根据不同条件赋值", author = "youhong.ai")
|
||||||
|
public class WorkflowConditionsSetValueAction extends SafeCusBaseAction {
|
||||||
|
|
||||||
|
@RequiredMark("流程条件赋值配置表唯一标识字段值")
|
||||||
|
@PrintParamMark
|
||||||
|
@ActionDefaultTestValue("test")
|
||||||
|
private String onlyMark;
|
||||||
|
|
||||||
|
@ActionOptionalParam(desc = "条件修改所在明细表,1-明细1,2-明细2", value = "")
|
||||||
|
@PrintParamMark
|
||||||
|
@ActionDefaultTestValue("1")
|
||||||
|
private String detailNo;
|
||||||
|
|
||||||
|
@PrintParamMark
|
||||||
|
@ActionOptionalParam(value = "false", desc = "是否自动提交流程")
|
||||||
|
private String submitAction = "false";
|
||||||
|
|
||||||
|
@PrintParamMark
|
||||||
|
@ActionOptionalParam(value = "true", desc = "是否失败后阻断流程")
|
||||||
|
private String block = "true";
|
||||||
|
|
||||||
|
private final WorkflowConditionsSetValueService service = new WorkflowConditionsSetValueService();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> workflowData = new HashMap<>(16);
|
||||||
|
Map<String, Object> workflowMainData = super.getObjMainTableValue(requestInfo);
|
||||||
|
if (Strings.isNullOrEmpty(detailNo)) {
|
||||||
|
/* ******************* 数据修改主表 ******************* */
|
||||||
|
Map<String, Object> conditionsValue = service.getConditionsValue(onlyMark, workflowData).get(billTable);
|
||||||
|
service.updateWorkflowData(conditionsValue, billTable, requestId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* ******************* 明细表 ******************* */
|
||||||
|
List<Map<String, Object>> detailData = super.getDetailTableObjValueByDetailNo(Integer.parseInt(detailNo), requestInfo);
|
||||||
|
workflowData.put("main", workflowMainData);
|
||||||
|
workflowData.put("_user_", user);
|
||||||
|
workflowData.put("_workflowId_", workflowId);
|
||||||
|
workflowData.put("_requestId_", requestId);
|
||||||
|
workflowData.put("_billTable_", billTable);
|
||||||
|
List<UpdateDetailRowDto> main = new ArrayList<>();
|
||||||
|
List<UpdateDetailRowDto> detail = new ArrayList<>();
|
||||||
|
for (Map<String, Object> detailDatum : detailData) {
|
||||||
|
workflowData.put("detail_" + detailNo, detailDatum);
|
||||||
|
Map<String, Map<String, Object>> conditionsValues = service.getConditionsValue(onlyMark, workflowData);
|
||||||
|
Map<String, Object> mainConditions = conditionsValues.get(billTable);
|
||||||
|
if (!Objects.isNull(mainConditions) && !mainConditions.isEmpty()) {
|
||||||
|
main.add(Builder.builder(UpdateDetailRowDto::new)
|
||||||
|
.with(UpdateDetailRowDto::setWhereValue, requestId)
|
||||||
|
.with(UpdateDetailRowDto::setWhereField, "requestid")
|
||||||
|
.with(UpdateDetailRowDto::setUpdateData, mainConditions)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
Map<String, Object> detailCondition = conditionsValues.get(billTable + "_dt" + detailNo);
|
||||||
|
if (!Objects.isNull(detailCondition) && !detailCondition.isEmpty()) {
|
||||||
|
detail.add(Builder.builder(UpdateDetailRowDto::new)
|
||||||
|
.with(UpdateDetailRowDto::setWhereValue, detailDatum.get("id"))
|
||||||
|
.with(UpdateDetailRowDto::setWhereField, "id")
|
||||||
|
.with(UpdateDetailRowDto::setUpdateData, detailCondition)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
service.updateWorkflowDetailData(main, billTable, null);
|
||||||
|
service.updateWorkflowDetailData(detail, billTable + "_dt" + detailNo, detailNo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (Boolean.parseBoolean(block)) {
|
||||||
|
throw new CustomerException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.submitWorkflow(requestId, user.getUID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitWorkflow(String requestId, Integer userId) {
|
||||||
|
Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "邮件发送附件提交流程!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>条件值dto</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 19:57</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class ConditionValueDto {
|
||||||
|
/** 字段名称 */
|
||||||
|
private String fieldName;
|
||||||
|
|
||||||
|
/** 对应值 */
|
||||||
|
private Object value;
|
||||||
|
|
||||||
|
/** 表名称 */
|
||||||
|
private String tableName;
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>更新明细数据</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/20 13:46</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class UpdateDetailRowDto {
|
||||||
|
private String whereField;
|
||||||
|
|
||||||
|
private Object whereValue;
|
||||||
|
|
||||||
|
private Map<String, Object> updateData;
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity;
|
||||||
|
|
||||||
|
import aiyh.utils.entity.FieldViewInfo;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>流程条件赋值配置明细行</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 16:19</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
public class ConditionItem {
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/** 赋值字段 */
|
||||||
|
private FieldViewInfo targetField;
|
||||||
|
/** 条件取值字段 */
|
||||||
|
private FieldViewInfo conditionsField;
|
||||||
|
/** 条件 */
|
||||||
|
private Integer conditions;
|
||||||
|
/** 条件对比方式 */
|
||||||
|
private Integer conditionsType;
|
||||||
|
/** 条件对比字段 */
|
||||||
|
private FieldViewInfo conditionsContrastField;
|
||||||
|
/** 条件自定义值 */
|
||||||
|
private String customerConditionsValue;
|
||||||
|
/** 赋值规则 */
|
||||||
|
private Integer valueSetRules;
|
||||||
|
/** 自定义赋值 */
|
||||||
|
private String customerSetValue;
|
||||||
|
|
||||||
|
/** 取值字段 */
|
||||||
|
private FieldViewInfo valueField;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>流程条件赋值配置主表</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 13:43</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
public class ConditionsSetValueConfigMain {
|
||||||
|
|
||||||
|
/** id */
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/** 唯一标识 */
|
||||||
|
private String onlyMark;
|
||||||
|
|
||||||
|
/** 流程类型 */
|
||||||
|
private Integer workflowType;
|
||||||
|
|
||||||
|
/** 明细配置表,条件配置 */
|
||||||
|
private List<ConditionItem> conditionItemList;
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.*;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionItem;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionsSetValueConfigMain;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>流程字段条件值赋值mapper</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 13:37</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@SqlMapper
|
||||||
|
public interface WorkflowConditionsSetValueMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>根据唯一标识查询条件赋值配置数据</h2>
|
||||||
|
*
|
||||||
|
* @param onlyMark 唯一标识
|
||||||
|
* @return 配置数据
|
||||||
|
*/
|
||||||
|
@Select("select * from uf_wf_conditi_assig where only_mark = #{onlyMark}")
|
||||||
|
@CollectionMappings({
|
||||||
|
@CollectionMapping(property = "conditionItemList",
|
||||||
|
column = "id",
|
||||||
|
id = @Id(value = Integer.class, methodId = 1))
|
||||||
|
})
|
||||||
|
ConditionsSetValueConfigMain selectConfigByOnlyMark(@ParamMapper("onlyMark") String onlyMark);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>根据主表id查询明细表数据</h2>
|
||||||
|
*
|
||||||
|
* @param mainId 主表ID
|
||||||
|
* @return 明细数据
|
||||||
|
*/
|
||||||
|
@Select("select * from uf_wf_conditi_assig_dt1 where mainid = #{mainId}")
|
||||||
|
@Associations({
|
||||||
|
@Association(property = "targetField",
|
||||||
|
column = "target_field",
|
||||||
|
select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo",
|
||||||
|
id = @Id(Integer.class)),
|
||||||
|
@Association(property = "conditionsField",
|
||||||
|
column = "conditions_field",
|
||||||
|
select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo",
|
||||||
|
id = @Id(Integer.class)),
|
||||||
|
@Association(property = "conditionsContrastField",
|
||||||
|
column = "conditions_contrast_field",
|
||||||
|
select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo",
|
||||||
|
id = @Id(Integer.class)),
|
||||||
|
@Association(property = "valueField",
|
||||||
|
column = "value_field",
|
||||||
|
select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo",
|
||||||
|
id = @Id(Integer.class))
|
||||||
|
})
|
||||||
|
@CollectionMethod(1)
|
||||||
|
List<ConditionItem> selectConditionItemsByMainId(Integer mainId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询自定义sql</h2>
|
||||||
|
*
|
||||||
|
* @param sql 自定义sql
|
||||||
|
* @param workflowData 流程数据
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
@Select(custom = true)
|
||||||
|
String selectCustomerSql(@SqlString String sql, Map<String, Object> workflowData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新流程表单数据</h2>
|
||||||
|
*
|
||||||
|
* @param sql 自定义sql
|
||||||
|
* @param conditionData 条件值
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
@Update(custom = true)
|
||||||
|
boolean updateWorkflowData(@SqlString String sql, Map<String, Object> conditionData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>批量更新数据</h2>
|
||||||
|
*
|
||||||
|
* @param sql sql
|
||||||
|
* @param updateBatchData 批量参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@BatchUpdate(custom = true)
|
||||||
|
boolean batchUpdateWorkflowData(@SqlString String sql, @BatchSqlArgs List<Map<String, Object>> updateBatchData);
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.service;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.tool.Assert;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.UpdateDetailRowDto;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionItem;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionsSetValueConfigMain;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.mapper.WorkflowConditionsSetValueMapper;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.util.ConditionsTreatment;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.util.ConditionsTypeTreatment;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.util.ValueSetRulesTreatment;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>流程字段值条件赋值service</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 13:37</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class WorkflowConditionsSetValueService {
|
||||||
|
private final WorkflowConditionsSetValueMapper mapper = Util.getMapper(WorkflowConditionsSetValueMapper.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>获取条件赋值映射规则处理后的字段值</h2>
|
||||||
|
*
|
||||||
|
* @param onlyMark 配置表唯一标识
|
||||||
|
* @param workflowData 流程表数据
|
||||||
|
* @return 映射结果
|
||||||
|
*/
|
||||||
|
public Map<String, Map<String, Object>> getConditionsValue(String onlyMark, Map<String, Object> workflowData) {
|
||||||
|
|
||||||
|
/* ******************* 查询配置表 ******************* */
|
||||||
|
ConditionsSetValueConfigMain conditionsSetValueConfigMain = mapper.selectConfigByOnlyMark(onlyMark);
|
||||||
|
Assert.notNull(conditionsSetValueConfigMain, "can not query configuration by onlyMark [{}]", onlyMark);
|
||||||
|
List<ConditionItem> conditionItemList = conditionsSetValueConfigMain.getConditionItemList();
|
||||||
|
Assert.notEmpty(conditionItemList, "can not query conditionItemList by onlyMark [{}]", onlyMark);
|
||||||
|
/* ******************* 映射规则处理 ,责任链初始化 ******************* */
|
||||||
|
ConditionsTypeTreatment conditionsTypeTreatment = new ConditionsTypeTreatment(
|
||||||
|
new ConditionsTreatment(
|
||||||
|
new ValueSetRulesTreatment()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// 映射值处理
|
||||||
|
List<ConditionValueDto> valueDtoList = new ArrayList<>();
|
||||||
|
for (ConditionItem conditionItem : conditionItemList) {
|
||||||
|
ConditionValueDto conditionValueDto = conditionsTypeTreatment.conditionsTypeTreatment(conditionItem, workflowData);
|
||||||
|
if (!Objects.isNull(conditionValueDto)) {
|
||||||
|
valueDtoList.add(conditionValueDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, List<ConditionValueDto>> collect = valueDtoList.stream().collect(Collectors.groupingBy(ConditionValueDto::getTableName));
|
||||||
|
|
||||||
|
// 最终结果转为map
|
||||||
|
Map<String, Map<String, Object>> result = new HashMap<>(valueDtoList.size());
|
||||||
|
for (Map.Entry<String, List<ConditionValueDto>> entry : collect.entrySet()) {
|
||||||
|
Map<String, Object> map = new HashMap<>(valueDtoList.size());
|
||||||
|
for (ConditionValueDto item : entry.getValue()) {
|
||||||
|
map.put(item.getFieldName(), item.getValue());
|
||||||
|
}
|
||||||
|
result.put(entry.getKey(), map);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新明细表数据</h2>
|
||||||
|
*
|
||||||
|
* @param updateDetailRowDtoList 更新数据
|
||||||
|
* @param billTable 表
|
||||||
|
* @param detailNo 明细号
|
||||||
|
*/
|
||||||
|
public void updateWorkflowDetailData(List<UpdateDetailRowDto> updateDetailRowDtoList, String billTable, String detailNo) {
|
||||||
|
if (updateDetailRowDtoList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdateDetailRowDto updateDetailRow = updateDetailRowDtoList.get(0);
|
||||||
|
if (Objects.isNull(detailNo)) {
|
||||||
|
// 主表
|
||||||
|
updateWorkflowData(updateDetailRow.getUpdateData(), billTable, Util.null2String(updateDetailRow.getWhereValue()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Map<String, Object>> updateBatchData = new ArrayList<>(updateDetailRowDtoList.size());
|
||||||
|
for (UpdateDetailRowDto updateDetailRowDto : updateDetailRowDtoList) {
|
||||||
|
Map<String, Object> updateData = updateDetailRowDto.getUpdateData();
|
||||||
|
updateData.put("_id_", updateDetailRow.getWhereValue());
|
||||||
|
updateBatchData.add(updateData);
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder("update ");
|
||||||
|
sb.append(billTable).append(" set ");
|
||||||
|
for (Map.Entry<String, Object> entry : updateBatchData.get(0).entrySet()) {
|
||||||
|
sb.append(entry.getKey())
|
||||||
|
.append(" = #{item.")
|
||||||
|
.append(entry.getKey())
|
||||||
|
.append("},");
|
||||||
|
}
|
||||||
|
sb.deleteCharAt(sb.length() - 1);
|
||||||
|
sb.append(" where ")
|
||||||
|
.append(updateDetailRow.getWhereField())
|
||||||
|
.append(" = #{item._id_}");
|
||||||
|
String sql = sb.toString();
|
||||||
|
boolean flag = mapper.batchUpdateWorkflowData(sql, updateBatchData);
|
||||||
|
if (!flag) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException ignore) {
|
||||||
|
}
|
||||||
|
mapper.batchUpdateWorkflowData(sql, updateBatchData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新流程表单数据</h2>
|
||||||
|
*
|
||||||
|
* @param conditionData 条件值
|
||||||
|
* @param billTable 表单表名
|
||||||
|
* @param requestId 当前请求ID
|
||||||
|
*/
|
||||||
|
public void updateWorkflowData(Map<String, Object> conditionData, String billTable, String requestId) {
|
||||||
|
if (conditionData.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder("update ");
|
||||||
|
sb.append(billTable).append(" set ");
|
||||||
|
for (Map.Entry<String, Object> entry : conditionData.entrySet()) {
|
||||||
|
sb.append(entry.getKey())
|
||||||
|
.append(" = #{")
|
||||||
|
.append(entry.getKey())
|
||||||
|
.append("},");
|
||||||
|
}
|
||||||
|
sb.deleteCharAt(sb.length() - 1);
|
||||||
|
sb.append(" where requestid = ")
|
||||||
|
.append(requestId);
|
||||||
|
String sql = sb.toString();
|
||||||
|
boolean flag = mapper.updateWorkflowData(sql, conditionData);
|
||||||
|
if (!flag) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException ignore) {
|
||||||
|
}
|
||||||
|
mapper.updateWorkflowData(sql, conditionData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.util;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.annotation.MethodRuleNo;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionItem;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>条件处理</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 17:41</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class ConditionsTreatment {
|
||||||
|
|
||||||
|
private final ValueSetRulesTreatment valueSetRulesTreatment;
|
||||||
|
|
||||||
|
private static final Map<Integer, BiFunction<String, String, Boolean>> METHOD_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
/* ******************* 初始化策略方法 ******************* */ {
|
||||||
|
Class<ConditionsTreatment> valueRuleMethodClass = ConditionsTreatment.class;
|
||||||
|
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
|
||||||
|
for (Method method : methods) {
|
||||||
|
if (method.isAnnotationPresent(MethodRuleNo.class)) {
|
||||||
|
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
|
||||||
|
int value = annotation.value();
|
||||||
|
METHOD_MAP.put(value, (sourceValue, conditionValue) -> {
|
||||||
|
try {
|
||||||
|
return (Boolean) method.invoke(this, sourceValue, conditionValue);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionsTreatment(ValueSetRulesTreatment valueSetRulesTreatment) {
|
||||||
|
this.valueSetRulesTreatment = valueSetRulesTreatment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionValueDto executeTreatment(ConditionItem conditionItem, Object value) {
|
||||||
|
Map<String, Object> workflowData = ConditionsTypeTreatment.WORKFLOW_DATA.get();
|
||||||
|
Object sourceValue = workflowData.get(conditionItem.getConditionsField().getFieldName());
|
||||||
|
Boolean apply = METHOD_MAP.get(conditionItem.getConditions()).apply(
|
||||||
|
Util.null2String(sourceValue),
|
||||||
|
Util.null2String(value)
|
||||||
|
);
|
||||||
|
if (apply) {
|
||||||
|
return this.valueSetRulesTreatment.createConditionValue(conditionItem);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 0, desc = "不等于")
|
||||||
|
private boolean notEqual(String sourceValue, String value) {
|
||||||
|
return !sourceValue.equals(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 1, desc = "等于")
|
||||||
|
private boolean equalTo(String sourceValue, String value) {
|
||||||
|
return sourceValue.equals(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 2, desc = "大于")
|
||||||
|
private boolean greaterThan(String sourceValue, String value) {
|
||||||
|
return Double.parseDouble(sourceValue) > Double.parseDouble(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 3, desc = "小于")
|
||||||
|
private boolean lessThen(String sourceValue, String value) {
|
||||||
|
return Double.parseDouble(sourceValue) < Double.parseDouble(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.util;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.annotation.MethodRuleNo;
|
||||||
|
import aiyh.utils.entity.FieldViewInfo;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionItem;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.mapper.WorkflowConditionsSetValueMapper;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>条件对比方式</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 17:44</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class ConditionsTypeTreatment {
|
||||||
|
|
||||||
|
private final WorkflowConditionsSetValueMapper mapper = Util.getMapper(WorkflowConditionsSetValueMapper.class);
|
||||||
|
|
||||||
|
private final ConditionsTreatment conditionsTreatment;
|
||||||
|
|
||||||
|
public final static ThreadLocal<Map<String, Object>> WORKFLOW_DATA = new ThreadLocal<>();
|
||||||
|
|
||||||
|
private static final Map<Integer, BiFunction<ConditionItem, Map<String, Object>, Object>> METHOD_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
public ConditionsTypeTreatment(ConditionsTreatment conditionsTreatment) {
|
||||||
|
this.conditionsTreatment = conditionsTreatment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ******************* 初始化策略方法 ******************* */ {
|
||||||
|
Class<ConditionsTypeTreatment> valueRuleMethodClass = ConditionsTypeTreatment.class;
|
||||||
|
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
|
||||||
|
for (Method method : methods) {
|
||||||
|
if (method.isAnnotationPresent(MethodRuleNo.class)) {
|
||||||
|
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
|
||||||
|
int value = annotation.value();
|
||||||
|
METHOD_MAP.put(value, (conditionItem, workflowData) -> {
|
||||||
|
try {
|
||||||
|
return method.invoke(this, conditionItem, workflowData);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionValueDto conditionsTypeTreatment(ConditionItem conditionItem, Map<String, Object> workflowData) {
|
||||||
|
WORKFLOW_DATA.set(workflowData);
|
||||||
|
Object conditionValue = METHOD_MAP.get(conditionItem.getConditionsType()).apply(conditionItem, workflowData);
|
||||||
|
ConditionValueDto conditionValueDto = this.conditionsTreatment.executeTreatment(conditionItem, conditionValue);
|
||||||
|
WORKFLOW_DATA.remove();
|
||||||
|
return conditionValueDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 0, desc = "流程字段")
|
||||||
|
private Object workflowField(ConditionItem conditionItem, Map<String, Object> workflowData) {
|
||||||
|
FieldViewInfo fieldInfo = conditionItem.getConditionsContrastField();
|
||||||
|
return Util.getValueByFieldViwInfo(fieldInfo, workflowData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 1, desc = "固定值")
|
||||||
|
private Object fixValue(ConditionItem conditionItem, Map<String, Object> workflowData) {
|
||||||
|
return conditionItem.getCustomerConditionsValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 2, desc = "自定义sql")
|
||||||
|
private Object customerSql(ConditionItem conditionItem, Map<String, Object> workflowData) {
|
||||||
|
return mapper.selectCustomerSql(conditionItem.getCustomerConditionsValue(), workflowData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.util;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.annotation.MethodRuleNo;
|
||||||
|
import aiyh.utils.entity.FieldViewInfo;
|
||||||
|
import ebu7common.youhong.ai.bean.Builder;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionItem;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.mapper.WorkflowConditionsSetValueMapper;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>赋值规则处理</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 17:46</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class ValueSetRulesTreatment {
|
||||||
|
|
||||||
|
private static final Map<Integer, BiFunction<ConditionItem, Map<String, Object>, Object>> METHOD_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
private final WorkflowConditionsSetValueMapper mapper = Util.getMapper(WorkflowConditionsSetValueMapper.class);
|
||||||
|
|
||||||
|
/* ******************* 初始化策略方法 ******************* */ {
|
||||||
|
Class<ValueSetRulesTreatment> valueRuleMethodClass = ValueSetRulesTreatment.class;
|
||||||
|
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
|
||||||
|
for (Method method : methods) {
|
||||||
|
if (method.isAnnotationPresent(MethodRuleNo.class)) {
|
||||||
|
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
|
||||||
|
int value = annotation.value();
|
||||||
|
METHOD_MAP.put(value, (conditionItem, workflowData) -> {
|
||||||
|
try {
|
||||||
|
return method.invoke(this, conditionItem, workflowData);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionValueDto createConditionValue(ConditionItem conditionItem) {
|
||||||
|
Map<String, Object> workflowData = ConditionsTypeTreatment.WORKFLOW_DATA.get();
|
||||||
|
Object value = METHOD_MAP.get(conditionItem.getValueSetRules()).apply(conditionItem, workflowData);
|
||||||
|
return Builder.builder(ConditionValueDto::new)
|
||||||
|
.with(ConditionValueDto::setFieldName, conditionItem.getTargetField().getFieldName())
|
||||||
|
.with(ConditionValueDto::setValue, value)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 0, desc = "固定值")
|
||||||
|
private Object fixValue(ConditionItem conditionItem, Map<String, Object> workflowData) {
|
||||||
|
return conditionItem.getCustomerSetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 1, desc = "流程字段")
|
||||||
|
private Object workflowField(ConditionItem conditionItem, Map<String, Object> workflowData) {
|
||||||
|
FieldViewInfo fieldInfo = conditionItem.getValueField();
|
||||||
|
return Util.getValueByFieldViwInfo(fieldInfo, workflowData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@MethodRuleNo(value = 2, desc = "自定义sql")
|
||||||
|
private Object customerSql(ConditionItem conditionItem, Map<String, Object> workflowData) {
|
||||||
|
return mapper.selectCustomerSql(conditionItem.getCustomerSetValue(), workflowData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package youhong.ai.intellectualproperty;
|
||||||
|
|
||||||
|
import aiyh.utils.GenerateFileUtil;
|
||||||
|
import basetest.BaseTest;
|
||||||
|
import org.junit.Test;
|
||||||
|
import weaver.youhong.ai.intellectualproperty.action.CaElectronicSignatureAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>测试</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/18 14:32</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class TestAction extends BaseTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
GenerateFileUtil.createActionDocument(CaElectronicSignatureAction.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package youhong.ai.pcn;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import basetest.BaseTest;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import org.junit.Test;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionsSetValueConfigMain;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.mapper.WorkflowConditionsSetValueMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>查询测试</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/2/19 16:33</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class MapperTest extends BaseTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
WorkflowConditionsSetValueMapper mapper = Util.getMapper(WorkflowConditionsSetValueMapper.class);
|
||||||
|
ConditionsSetValueConfigMain conditionsSetValueConfigMain = mapper.selectConfigByOnlyMark("test");
|
||||||
|
System.out.println(JSON.toJSONString(conditionsSetValueConfigMain));
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import com.engine.common.util.ServiceUtil;
|
||||||
import com.engine.hrm.service.impl.RolesMembersServiceImpl;
|
import com.engine.hrm.service.impl.RolesMembersServiceImpl;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.WorkflowConditionsSetValueAction;
|
||||||
import weaver.youhong.ai.pcn.schedule.addrolebyhasundering.RegisterRoleMemberByHasUnderingCronJob;
|
import weaver.youhong.ai.pcn.schedule.addrolebyhasundering.RegisterRoleMemberByHasUnderingCronJob;
|
||||||
import weaver.youhong.ai.pcn.schedule.addrolemember.RegisterRoleMemberCronJob;
|
import weaver.youhong.ai.pcn.schedule.addrolemember.RegisterRoleMemberCronJob;
|
||||||
|
|
||||||
|
@ -22,20 +23,20 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RolesTest extends BaseTest {
|
public class RolesTest extends BaseTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
User user = new User(1);
|
User user = new User(1);
|
||||||
RolesMembersServiceImpl service = ServiceUtil.getService(RolesMembersServiceImpl.class, user);
|
RolesMembersServiceImpl service = ServiceUtil.getService(RolesMembersServiceImpl.class, user);
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("roleId", 2);
|
map.put("roleId", 2);
|
||||||
map.put("resourcetype", 1);
|
map.put("resourcetype", 1);
|
||||||
map.put("resourceid", 90);
|
map.put("resourceid", 90);
|
||||||
map.put("rolelevel", 2);
|
map.put("rolelevel", 2);
|
||||||
map.put("cmd", "addRolesMembers");
|
map.put("cmd", "addRolesMembers");
|
||||||
Map<String, Object> stringObjectMap = service.saveRolesMembers(map, user);
|
Map<String, Object> stringObjectMap = service.saveRolesMembers(map, user);
|
||||||
System.out.println(stringObjectMap);
|
System.out.println(stringObjectMap);
|
||||||
/* String sql = " INSERT INTO HrmRoleMembers ( roleid ,resourceid ,rolelevel ,resourcetype ,alllevel ," +
|
/* String sql = " INSERT INTO HrmRoleMembers ( roleid ,resourceid ,rolelevel ,resourcetype ,alllevel ," +
|
||||||
" seclevelfrom ,seclevelto ,subdepid ,jobtitlelevel) " +
|
" seclevelfrom ,seclevelto ,subdepid ,jobtitlelevel) " +
|
||||||
" VALUES ( " + roleId + ", " + arrObjIds[i] + " , '" + rolelevel + "', '" + resourcetype + "', " +
|
" VALUES ( " + roleId + ", " + arrObjIds[i] + " , '" + rolelevel + "', '" + resourcetype + "', " +
|
||||||
|
@ -44,18 +45,36 @@ public class RolesTest extends BaseTest {
|
||||||
" " + (seclevelto.length() == 0 ? "null" : seclevelto) + ", " +
|
" " + (seclevelto.length() == 0 ? "null" : seclevelto) + ", " +
|
||||||
(subdepid.length() == 0 ? "null" : "'" + subdepid + "'") + "," +
|
(subdepid.length() == 0 ? "null" : "'" + subdepid + "'") + "," +
|
||||||
(jobtitlelevel.length() == 0 ? "null" : jobtitlelevel) + ")";*/
|
(jobtitlelevel.length() == 0 ? "null" : jobtitlelevel) + ")";*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCronJob() {
|
public void testCronJob() {
|
||||||
Util.cronJobTest(RegisterRoleMemberCronJob.class);
|
Util.cronJobTest(RegisterRoleMemberCronJob.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generateDoc() {
|
public void generateDoc() {
|
||||||
GenerateFileUtil.createCronJobDocument(RegisterRoleMemberByHasUnderingCronJob.class);
|
GenerateFileUtil.createCronJobDocument(RegisterRoleMemberByHasUnderingCronJob.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test3() {
|
||||||
|
String value = "1";
|
||||||
|
System.out.println(Double.parseDouble(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWorkflowConditionSetValue() {
|
||||||
|
Util.actionTest(WorkflowConditionsSetValueAction.class, 86088);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateFile() {
|
||||||
|
GenerateFileUtil.createActionDocument(WorkflowConditionsSetValueAction.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,18 +17,18 @@ import lombok.ToString;
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
public class Student {
|
public class Student {
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@SqlDbFieldAnn("a")
|
@SqlDbFieldAnn("WOLFLOWTYPE")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
@SqlDbFieldAnn("b")
|
@SqlDbFieldAnn("b")
|
||||||
private String test;
|
private String test;
|
||||||
|
|
||||||
@SqlDbFieldAnn("c")
|
@SqlDbFieldAnn("c")
|
||||||
private String bcd;
|
private String bcd;
|
||||||
|
|
||||||
private int age;
|
private int age;
|
||||||
private int sex;
|
private int sex;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue