【同步】BOOT 和 CLOUD 的功能

This commit is contained in:
YunaiV 2025-11-25 12:58:25 +08:00
parent 739487e528
commit 8becb49a3b
13 changed files with 152 additions and 147 deletions

View File

@ -52,6 +52,7 @@ def load_and_clean(sql_file: str) -> str:
REPLACE_PAIR_LIST = (
(")\nVALUES ", ") VALUES "),
(" CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ", " "),
(" CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ", " "),
(" KEY `", " INDEX `"),
("UNIQUE INDEX", "UNIQUE KEY"),
("b'0'", "'0'"),
@ -61,6 +62,11 @@ def load_and_clean(sql_file: str) -> str:
content = open(sql_file, encoding="utf-8").read()
for replace_pair in REPLACE_PAIR_LIST:
content = content.replace(*replace_pair)
# 移除索引字段的前缀长度定义,例如: `name`(32) -> `name`
# 移除索引定义上的 USING BTREE COMMENT 部分
# 相关 issuehttps://t.zsxq.com/96IFc 、https://t.zsxq.com/rC3A3
content = re.sub(r'`([^`]+)`\(\d+\)', r'`\1`', content)
content = re.sub(r'\s+USING\s+BTREE\s+COMMENT\s+\'[^\']+\'', '', content)
content = re.sub(r"ENGINE.*COMMENT", "COMMENT", content)
content = re.sub(r"ENGINE.*;", ";", content)
return content
@ -262,10 +268,10 @@ class Convertor(ABC):
# 解析注释
for column in table_ddl["columns"]:
column["comment"] = bytes(column["comment"], "utf-8").decode(
"unicode_escape"
r"unicode_escape"
)[1:-1]
table_ddl["comment"] = bytes(table_ddl["comment"], "utf-8").decode(
"unicode_escape"
r"unicode_escape"
)[1:-1]
# 为每个表生成个6个基本部分

View File

@ -779,8 +779,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
*/
private void approveDelegateTask(BpmTaskApproveReqVO reqVO, Task task) {
// 1. 添加审批意见
AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId()).getCheckedData();
AdminUserRespDTO ownerUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData(); // 发起委托的用户
AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId());
AdminUserRespDTO ownerUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())); // 发起委托的用户
Assert.notNull(ownerUser, "委派任务找不到原审批人,需要检查数据");
taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_END.getType(),
BpmCommentTypeEnum.DELEGATE_END.formatComment(currentUser.getNickname(), ownerUser.getNickname(), reqVO.getReason()));
@ -949,11 +949,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
Set<String> needSimulateTaskDefinitionKeys = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement);
// 4. 执行驳回
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因
// 当多实例任务回退的时候有问题相关 issue: https://github.com/flowable/flowable-engine/issues/3944
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId原因当多实例任务回退的时候有问题
// 相关 issue: https://github.com/flowable/flowable-engine/issues/3944
// flowable 7.2.0 版本后继续使用 moveActivityIdsToSingleActivityId 方法原因flowable 7.2.0 版本修复了该问题
// 相关 issuehttps://github.com/YunaiV/ruoyi-vue-pro/issues/1018
runtimeService.createChangeActivityStateBuilder()
.processInstanceId(currentTask.getProcessInstanceId())
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
.moveActivityIdsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
// 设置需要预测的任务 ids 的流程变量用于辅助预测
.processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
// 设置流程变量local节点退回标记, 用于退回到节点不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略导致自动通过
@ -1000,13 +1002,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
throw exception(TASK_DELEGATE_FAIL_USER_REPEAT);
}
// 1.2 校验目标用户存在
AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId()).getCheckedData();
AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId());
if (delegateUser == null) {
throw exception(TASK_DELEGATE_FAIL_USER_NOT_EXISTS);
}
// 2. 添加委托意见
AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData();
AdminUserRespDTO currentUser = adminUserApi.getUser(userId);
taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_START.getType(),
BpmCommentTypeEnum.DELEGATE_START.formatComment(currentUser.getNickname(), delegateUser.getNickname(), reqVO.getReason()));
@ -1031,13 +1033,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
throw exception(TASK_TRANSFER_FAIL_USER_REPEAT);
}
// 1.2 校验目标用户存在
AdminUserRespDTO assigneeUser = adminUserApi.getUser(reqVO.getAssigneeUserId()).getCheckedData();
AdminUserRespDTO assigneeUser = adminUserApi.getUser(reqVO.getAssigneeUserId());
if (assigneeUser == null) {
throw exception(TASK_TRANSFER_FAIL_USER_NOT_EXISTS);
}
// 2. 添加委托意见
AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData();
AdminUserRespDTO currentUser = adminUserApi.getUser(userId);
taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.TRANSFER.getType(),
BpmCommentTypeEnum.TRANSFER.formatComment(currentUser.getNickname(), assigneeUser.getNickname(), reqVO.getReason()));
@ -1096,7 +1098,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
public void createSignTask(Long userId, BpmTaskSignCreateReqVO reqVO) {
// 1. 获取和校验任务
TaskEntityImpl taskEntity = validateTaskCanCreateSign(userId, reqVO);
List<AdminUserRespDTO> userList = adminUserApi.getUserList(reqVO.getUserIds()).getCheckedData();
List<AdminUserRespDTO> userList = adminUserApi.getUserList(reqVO.getUserIds());
if (CollUtil.isEmpty(userList)) {
throw exception(TASK_SIGN_CREATE_USER_NOT_EXIST);
}
@ -1123,7 +1125,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
createSignTaskList(convertList(reqVO.getUserIds(), String::valueOf), taskEntity);
// 4. 记录加签的评论到 task 任务
AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData();
AdminUserRespDTO currentUser = adminUserApi.getUser(userId);
String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getComment(),
currentUser.getNickname(), BpmTaskSignTypeEnum.nameOfType(reqVO.getType()),
String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason());
@ -1155,7 +1157,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
List<Long> currentAssigneeList = convertListByFlatMap(taskList, task -> // 需要考虑 owner 的情况因为向后加签时它暂时没 assignee 而是 owner
Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner())));
if (CollUtil.containsAny(currentAssigneeList, reqVO.getUserIds())) {
List<AdminUserRespDTO> userList = adminUserApi.getUserList(CollUtil.intersection(currentAssigneeList, reqVO.getUserIds())).getCheckedData();
List<AdminUserRespDTO> userList = adminUserApi.getUserList(CollUtil.intersection(currentAssigneeList, reqVO.getUserIds()));
throw exception(TASK_SIGN_CREATE_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname)));
}
return taskEntity;
@ -1217,10 +1219,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
// 1.2 校验取消人存在
AdminUserRespDTO cancelUser = null;
if (StrUtil.isNotBlank(task.getAssignee())) {
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())).getCheckedData();
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee()));
}
if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) {
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData();
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner()));
}
Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误");
@ -1234,7 +1236,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
taskService.deleteTasks(convertList(childTaskList, Task::getId));
// 3. 记录日志到父任务中先记录日志是因为通过 handleParentTask 方法之后任务可能被完成了并且不存在了会报异常所以先记录
AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData();
AdminUserRespDTO user = adminUserApi.getUser(userId);
taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(), BpmCommentTypeEnum.SUB_SIGN.getType(),
StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getComment(), user.getNickname(), cancelUser.getNickname()));
@ -1536,9 +1538,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
// 情况二转交给部门负责人审批
if (ObjectUtils.equalsAny(assignStartUserHandlerType,
BpmUserTaskAssignStartUserHandlerTypeEnum.TRANSFER_DEPT_LEADER.getType())) {
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData();
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId()));
Assert.notNull(startUser, "提交人({})信息为空", processInstance.getStartUserId());
DeptRespDTO dept = startUser.getDeptId() != null ? deptApi.getDept(startUser.getDeptId()).getCheckedData() : null;
DeptRespDTO dept = startUser.getDeptId() != null ? deptApi.getDept(startUser.getDeptId()) : null;
Assert.notNull(dept, "提交人({})部门({})信息为空", processInstance.getStartUserId(), startUser.getDeptId());
// 找不到部门负责人的情况下自动审批通过
// noinspection DataFlowIssue
@ -1560,7 +1562,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
}
// 注意需要基于 instance 设置租户编号避免 Flowable 内部异步时丢失租户编号
FlowableUtils.execute(processInstance.getTenantId(), () -> {
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData();
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId()));
messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task));
});
}

View File

@ -91,9 +91,8 @@ public class FileTypeUtils {
}
// 针对 video 的特殊处理解决视频地址在移动端播放的兼容性问题
if (StrUtil.containsIgnoreCase(mineType, "video")) {
response.setHeader("Content-Length", String.valueOf(content.length));
response.setHeader("Content-Range", "bytes 0-" + (content.length - 1) + "/" + content.length);
response.setHeader("Accept-Ranges", "bytes");
response.setHeader("Content-Length", String.valueOf(content.length));
}
// 输出附件
IoUtil.write(response.getOutputStream(), false, content);

View File

@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { Rule } from 'ant-design-vue/es/form';
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
import { computed, ref } from 'vue';
@ -11,7 +11,7 @@ import { Tinymce as RichTextarea } from '#/components/tinymce';
import { ImageUpload, FileUpload } from "#/components/upload";
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
#if($table.templateType == 2)## 树表需要导入这些
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${table.businessName}';
import { handleTree } from '@vben/utils'
#end
## 特殊:主子表专属逻辑
@ -24,7 +24,7 @@ import { handleTree } from '@vben/utils'
#end
import { $t } from '#/locales';
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
const emit = defineEmits(['success']);

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
import { ref, h, reactive, onMounted, nextTick } from 'vue';
@ -7,12 +7,13 @@ import { Page, useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table';
import { cloneDeep, downloadFileFromBlobPart, formatDateTime } from '@vben/utils';
import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue';
import { cloneDeep, downloadFileFromBlobPart, formatDateTime, isEmpty } from '@vben/utils';
import { Button, Card, message, Tabs, Pagination, Form, RangePicker, DatePicker, Select, Input } from 'ant-design-vue';
import ${simpleClassName}Form from './modules/form.vue';
import { Download, Plus, RefreshCw, Search, Trash2 } from '@vben/icons';
import { ContentWrap } from '#/components/content-wrap';
import { DictTag } from '#/components/dict-tag';
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
import { getRangePickerDefaultProps } from '#/utils/rangePickerProps';
## 特殊:主子表专属逻辑
#if ( $table.templateType == 11 || $table.templateType == 12 )
@ -25,13 +26,11 @@ import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
import { $t } from '#/locales';
#if (${table.templateType} == 2)## 树表接口
import { handleTree,isEmpty } from '@vben/utils'
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { handleTree } from '@vben/utils'
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
#else## 标准表接口
import { isEmpty } from '@vben/utils';
import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}List,#end export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}List,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
#end
import { downloadFileFromBlobPart } from '@vben/utils';
#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况
/** 子表的列表 */
@ -211,7 +210,7 @@ onMounted(() => {
<Page auto-content-height>
<FormModal @success="getList" />
<ContentWrap v-if="!hiddenSearchBar">
<Card v-if="!hiddenSearchBar" class="mb-4">
<!-- 搜索工作栏 -->
<Form
:model="queryParams"
@ -292,10 +291,10 @@ onMounted(() => {
</Button>
</Form.Item>
</Form>
</ContentWrap>
</Card>
<!-- 列表 -->
<ContentWrap title="${table.classComment}">
<Card title="${table.classComment}">
<template #extra>
<VbenVxeTableToolbar
ref="tableToolbarRef"
@ -338,9 +337,9 @@ onMounted(() => {
批量删除
</Button>
#end
</TableToolbar>
</VbenVxeTableToolbar>
</template>
<vxe-table
<VxeTable
ref="tableRef"
:data="list"
#if ( $table.templateType == 2 )
@ -368,12 +367,12 @@ onMounted(() => {
#end
>
#if ($table.templateType != 2 && $deleteBatchEnable)
<vxe-column type="checkbox" width="40"></vxe-column>
<VxeColumn type="checkbox" width="40" />
#end
## 特殊:主子表专属逻辑
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
<!-- 子表的列表 -->
<vxe-column type="expand" width="60">
<VxeColumn type="expand" width="60">
<template #content="{ row }">
<!-- 子表的表单 -->
<Tabs v-model:active-key="subTabsName" class="mx-8">
@ -388,7 +387,7 @@ onMounted(() => {
#end
</Tabs>
</template>
</vxe-column>
</VxeColumn>
#end
#foreach($column in $columns)
#if ($column.listOperationResult)
@ -397,31 +396,31 @@ onMounted(() => {
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set ($comment=$column.columnComment)
#if ($column.javaType == "LocalDateTime")## 时间类型
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{row}">
{{formatDateTime(row.${javaField})}}
</template>
</vxe-column>
</VxeColumn>
#elseif($column.dictType && "" != $column.dictType)## 数据字典
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{row}">
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
</template>
</vxe-column>
</VxeColumn>
#elseif ($table.templateType == 2 && $javaField == $treeNameColumn.javaField)
<vxe-column field="${javaField}" title="${comment}" align="center" tree-node/>
<VxeColumn field="${javaField}" title="${comment}" align="center" tree-node/>
#else
<vxe-column field="${javaField}" title="${comment}" align="center" />
<VxeColumn field="${javaField}" title="${comment}" align="center" />
#end
#end
#end
<vxe-column field="operation" title="操作" align="center">
<VxeColumn field="operation" title="操作" align="center">
<template #default="{row}">
#if ( $table.templateType == 2 )
<Button
size="small"
type="link"
@click="handleAppend(row as any)"
@click="handleAppend(row)"
v-access:code="['${permissionPrefix}:create']"
>
新增下级
@ -430,7 +429,7 @@ onMounted(() => {
<Button
size="small"
type="link"
@click="handleEdit(row as any)"
@click="handleEdit(row)"
v-access:code="['${permissionPrefix}:update']"
>
{{ $t('ui.actionTitle.edit') }}
@ -443,14 +442,14 @@ onMounted(() => {
#if ( $table.templateType == 2 )
:disabled="!isEmpty(row?.children)"
#end
@click="handleDelete(row as any)"
@click="handleDelete(row)"
v-access:code="['${permissionPrefix}:delete']"
>
{{ $t('ui.actionTitle.delete') }}
</Button>
</template>
</vxe-column>
</vxe-table>
</VxeColumn>
</VxeTable>
#if ( $table.templateType != 2 )
<!-- 分页 -->
<div class="mt-2 flex justify-end">
@ -463,9 +462,9 @@ onMounted(() => {
/>
</div>
#end
</ContentWrap>
</Card>
#if ($table.templateType == 11) ## erp情况
<ContentWrap>
<Card>
<!-- 子表的表单 -->
<Tabs v-model:active-key="subTabsName">
#foreach ($subTable in $subTables)
@ -478,7 +477,7 @@ onMounted(() => {
</Tabs.TabPane>
#end
</Tabs>
</ContentWrap>
</Card>
#end
</Page>
</template>

View File

@ -4,21 +4,20 @@
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
<script lang="ts" setup>
import type { Rule } from 'ant-design-vue/es/form';
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { cloneDeep, formatDateTime } from '@vben/utils';
import { Tinymce as RichTextarea } from '#/components/tinymce';
import { ImageUpload, FileUpload } from "#/components/upload";
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
import { $t } from '#/locales';
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
const emit = defineEmits(['success']);
const getTitle = computed(() => {

View File

@ -5,25 +5,27 @@
#set ($subClassNameVar = $subClassNameVars.get($subIndex))
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
<script lang="ts" setup>
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
import { computed, ref, h, onMounted, watch, nextTick } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { message, Tabs, Form, Input, Textarea,Button, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue';
import { message, Tabs, Form, Input, Textarea, Button, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue';
import { $t } from '#/locales';
#if ($subTable.subJoinMany) ## 一对多
import type { VxeTableInstance } from '#/adapter/vxe-table';
import { Plus } from "@vben/icons";
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { ImageUpload, FileUpload } from "#/components/upload";
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
#else
import type { Rule } from 'ant-design-vue/es/form';
import { Tinymce as RichTextarea } from '#/components/tinymce';
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { ImageUpload, FileUpload } from "#/components/upload";
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
#end
const props = defineProps<{
@ -55,6 +57,7 @@ defineExpose({
(row) => !removeRecords.some((removed) => removed.id === row.id),
),
...insertRecords.map((row: any) => ({ ...row, id: undefined })),
];
},
});
@ -113,7 +116,7 @@ watch(
<template>
#if ($subTable.subJoinMany) ## 一对多
<vxe-table ref="tableRef" :data="list" show-overflow class="mx-4">
<VxeTable ref="tableRef" :data="list" show-overflow class="mx-4">
#foreach($column in $subColumns)
#if ($column.createOperation || $column.updateOperation)
#set ($comment = $column.columnComment)
@ -128,25 +131,25 @@ watch(
#end
#if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{ row }">
<Input v-model:value="row.${javaField}" />
</template>
</vxe-column>
</VxeColumn>
#elseif($column.htmlType == "imageUpload")## 图片上传
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{ row }">
<ImageUpload v-model:value="row.${javaField}" />
</template>
</vxe-column>
</VxeColumn>
#elseif($column.htmlType == "fileUpload")## 文件上传
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{ row }">
<FileUpload v-model:value="row.${javaField}" />
</template>
</vxe-column>
</VxeColumn>
#elseif($column.htmlType == "select")## 下拉框
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{ row }">
<Select v-model:value="row.${javaField}" placeholder="请选择${comment}">
#if ("" != $dictType)## 有数据字典
@ -162,9 +165,9 @@ watch(
#end
</Select>
</template>
</vxe-column>
</VxeColumn>
#elseif($column.htmlType == "checkbox")## 多选框
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{ row }">
<CheckboxGroup v-model:value="row.${javaField}">
#if ("" != $dictType)## 有数据字典
@ -180,9 +183,9 @@ watch(
#end
</CheckboxGroup>
</template>
</vxe-column>
</VxeColumn>
#elseif($column.htmlType == "radio")## 单选框
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{ row }">
<RadioGroup v-model:value="row.${javaField}">
#if ("" != $dictType)## 有数据字典
@ -198,9 +201,9 @@ watch(
#end
</RadioGroup>
</template>
</vxe-column>
</VxeColumn>
#elseif($column.htmlType == "datetime")## 时间框
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{ row }">
<DatePicker
v-model:value="row.${javaField}"
@ -209,30 +212,30 @@ watch(
valueFormat='x'
/>
</template>
</vxe-column>
</VxeColumn>
#elseif($column.htmlType == "textarea" || $column.htmlType == "editor")## 文本框
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{ row }">
<Textarea v-model:value="row.${javaField}" />
</template>
</vxe-column>
</VxeColumn>
#end
#end
#end
<vxe-column field="operation" title="操作" align="center">
<VxeColumn field="operation" title="操作" align="center">
<template #default="{ row }">
<Button
size="small"
type="link"
danger
@click="handleDelect(row)"
@click="handleDelete(row)"
v-access:code="['${permissionPrefix}:delete']"
>
{{ $t('ui.actionTitle.delete') }}
</Button>
</template>
</vxe-column>
</vxe-table>
</VxeColumn>
</VxeTable>
<div class="flex justify-center mt-4">
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${permissionPrefix}:create']">
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}

View File

@ -6,18 +6,18 @@
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($subIndex))
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
<script lang="ts" setup>
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
import type { VxeTableInstance } from '#/adapter/vxe-table';
import { reactive,ref, h, nextTick,watch,onMounted } from 'vue';
import { reactive, ref, h, nextTick, watch, onMounted } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { DictTag } from '#/components/dict-tag';
import { getRangePickerDefaultProps } from '#/utils';
import { getRangePickerDefaultProps } from '#/utils/rangePickerProps';
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
import { ContentWrap } from '#/components/content-wrap';
import { formatDateTime } from '@vben/utils';
#if ($table.templateType == 11) ## erp
import { useVbenModal } from '@vben/common-ui';
@ -25,19 +25,19 @@ import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table';
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
import { Tinymce as RichTextarea } from '#/components/tinymce';
import { ImageUpload, FileUpload } from "#/components/upload";
import { message,Button, Tabs,Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox,RangePicker, DatePicker, TreeSelect } from 'ant-design-vue';
import { message, Button, Card, Tabs, Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, RangePicker, DatePicker, TreeSelect } from 'ant-design-vue';
import { Plus, Trash2 } from '@vben/icons';
import { $t } from '#/locales';
#end
#if ($table.templateType == 11) ## erp
import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}List,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { isEmpty } from '@vben/utils';
import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}List,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
import { isEmpty, cloneDeep } from '@vben/utils';
#else
#if ($subTable.subJoinMany) ## 一对多
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
#else
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
#end
#end
@ -203,7 +203,7 @@ onMounted(() => {
#if ($table.templateType == 11) ## erp
<FormModal @success="getList" />
<div class="h-[600px]">
<ContentWrap v-if="!hiddenSearchBar">
<Card v-if="!hiddenSearchBar" class="mb-4">
<!-- 搜索工作栏 -->
<Form
:model="queryParams"
@ -284,10 +284,10 @@ onMounted(() => {
</Button>
</Form.Item>
</Form>
</ContentWrap>
</Card>
<!-- 列表 -->
<ContentWrap title="${table.classComment}">
<Card title="${table.classComment}">
<template #extra>
<VbenVxeTableToolbar
ref="tableToolbarRef"
@ -315,9 +315,9 @@ onMounted(() => {
批量删除
</Button>
#end
</TableToolbar>
</VbenVxeTableToolbar>
</template>
<vxe-table
<VxeTable
ref="tableRef"
:data="list"
show-overflow
@ -328,7 +328,7 @@ onMounted(() => {
#end
>
#if ($deleteBatchEnable)
<vxe-column type="checkbox" width="40"></vxe-column>
<VxeColumn type="checkbox" width="40" />
#end
#foreach($column in $subColumns)
#if ($column.listOperationResult)
@ -336,30 +336,30 @@ onMounted(() => {
#set ($javaField = $column.javaField)
#set ($comment=$column.columnComment)
#if ($column.javaType == "LocalDateTime")## 时间类型
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{row}">
{{formatDateTime(row.${javaField})}}
</template>
</vxe-column>
</VxeColumn>
#elseif($column.dictType && "" != $column.dictType)## 数据字典
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{row}">
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
</template>
</vxe-column>
</VxeColumn>
#elseif ($table.templateType == 2 && $javaField == $treeNameColumn.javaField)
<vxe-column field="${javaField}" title="${comment}" align="center" tree-node/>
<VxeColumn field="${javaField}" title="${comment}" align="center" tree-node/>
#else
<vxe-column field="${javaField}" title="${comment}" align="center" />
<VxeColumn field="${javaField}" title="${comment}" align="center" />
#end
#end
#end
<vxe-column field="operation" title="操作" align="center">
<VxeColumn field="operation" title="操作" align="center">
<template #default="{row}">
<Button
size="small"
type="link"
@click="handleEdit(row as any)"
@click="handleEdit(row)"
v-access:code="['${permissionPrefix}:update']"
>
{{ $t('ui.actionTitle.edit') }}
@ -369,14 +369,14 @@ onMounted(() => {
type="link"
danger
class="ml-2"
@click="handleDelete(row as any)"
@click="handleDelete(row)"
v-access:code="['${permissionPrefix}:delete']"
>
{{ $t('ui.actionTitle.delete') }}
</Button>
</template>
</vxe-column>
</vxe-table>
</VxeColumn>
</VxeTable>
<!-- 分页 -->
<div class="mt-2 flex justify-end">
<Pagination
@ -387,11 +387,11 @@ onMounted(() => {
@change="getList"
/>
</div>
</ContentWrap>
</Card>
</div>
#else
<ContentWrap title="${subTable.classComment}列表">
<vxe-table
<Card title="${subTable.classComment}列表">
<VxeTable
:data="list"
show-overflow
:loading="loading"
@ -402,23 +402,23 @@ onMounted(() => {
#set ($javaField = $column.javaField)
#set ($comment=$column.columnComment)
#if ($column.javaType == "LocalDateTime")## 时间类型
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{row}">
{{formatDateTime(row.${javaField})}}
</template>
</vxe-column>
</VxeColumn>
#elseif($column.dictType && "" != $column.dictType)## 数据字典
<vxe-column field="${javaField}" title="${comment}" align="center">
<VxeColumn field="${javaField}" title="${comment}" align="center">
<template #default="{row}">
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
</template>
</vxe-column>
</VxeColumn>
#else
<vxe-column field="${javaField}" title="${comment}" align="center" />
<VxeColumn field="${javaField}" title="${comment}" align="center" />
#end
#end
#end
</vxe-table>
</ContentWrap>
</VxeTable>
</Card>
#end
</template>

View File

@ -8,7 +8,7 @@
<script lang="ts" setup>
import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}';
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
import { computed, ref, h, onMounted, watch, nextTick } from 'vue';
import { $t } from '#/locales';
@ -16,7 +16,6 @@
import { Plus } from "@vben/icons";
import { Button, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue';
import { ImageUpload, FileUpload } from "#/components/upload";
import type { OnActionClickParams } from '#/adapter/vxe-table';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { use${subSimpleClassName}GridEditColumns } from '../data';
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
@ -31,22 +30,9 @@ const props = defineProps<{
}>()
#if ($subTable.subJoinMany) ## 一对多
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
}: OnActionClickParams<${apiName}.${subSimpleClassName}>) {
switch (code) {
case 'delete': {
handleDelete(row);
break;
}
}
}
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: use${subSimpleClassName}GridEditColumns(onActionClick),
columns: use${subSimpleClassName}GridEditColumns(),
border: true,
showOverflow: true,
autoResize: true,
@ -186,6 +172,17 @@ watch(
#end
#end
#end
<template #actions="{ row }">
<Button
size="small"
type="link"
danger
@click="handleDelete(row)"
v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:delete']"
>
{{ $t('ui.actionTitle.delete') }}
</Button>
</template>
</Grid>
<div class="flex justify-center -mt-4">
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">

View File

@ -82,7 +82,7 @@ async function handleDeleteBatch() {
try {
await delete${subSimpleClassName}List(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
@ -134,7 +134,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
#else
columns: use${subSimpleClassName}GridColumns(),
pagerConfig: {
nabled: false,
enabled: false,
},
toolbarConfig: {
enabled: false,

View File

@ -146,7 +146,7 @@ public class IotProductController {
public CommonResult<List<IotProductRespVO>> getProductSimpleList() {
List<IotProductDO> list = productService.getProductList();
return success(convertList(list, product -> // 只返回 idname 字段
new IotProductRespVO().setId(product.getId()).setName(product.getName())
new IotProductRespVO().setId(product.getId()).setName(product.getName()).setStatus(product.getStatus())
.setDeviceType(product.getDeviceType()).setLocationType(product.getLocationType())));
}

View File

@ -241,13 +241,13 @@ public class IotSceneRuleServiceImpl implements IotSceneRuleService {
*/
private List<IotSceneRuleDO> getMatchedSceneRuleListByMessage(IotDeviceMessage message) {
// 1.1 通过 deviceId 获取设备信息
IotDeviceDO device = getSelf().deviceService.getDeviceFromCache(message.getDeviceId());
IotDeviceDO device = deviceService.getDeviceFromCache(message.getDeviceId());
if (device == null) {
log.warn("[getMatchedSceneRuleListByMessage][设备({}) 不存在]", message.getDeviceId());
return ListUtil.of();
}
// 1.2 通过 productId 获取产品信息
IotProductDO product = getSelf().productService.getProductFromCache(device.getProductId());
IotProductDO product = productService.getProductFromCache(device.getProductId());
if (product == null) {
log.warn("[getMatchedSceneRuleListByMessage][产品({}) 不存在]", device.getProductId());
return ListUtil.of();

View File

@ -48,13 +48,13 @@ public class IotDeviceEventPostTriggerMatcher implements IotSceneRuleTriggerMatc
// 2. 对于事件触发器通常不需要检查操作符和值只要事件发生即匹配
// 但如果配置了操作符和值则需要进行条件匹配
if (StrUtil.isNotBlank(trigger.getOperator()) && StrUtil.isNotBlank(trigger.getValue())) {
Object eventData = message.getData();
if (eventData == null) {
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "消息中事件为空");
Object eventParams = message.getParams();
if (eventParams == null) {
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "消息中事件数为空");
return false;
}
boolean matched = IotSceneRuleMatcherHelper.evaluateCondition(eventData, trigger.getOperator(), trigger.getValue());
boolean matched = IotSceneRuleMatcherHelper.evaluateCondition(eventParams, trigger.getOperator(), trigger.getValue());
if (!matched) {
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "事件数据条件不匹配");
return false;