28 Commits

Author SHA1 Message Date
e0833d3cbd Merge branch '生产及设备基础资料' 2026-05-19 10:17:03 +08:00
geht
67ca5287e2 修改后端运行端口,改为8888,前端调用后端接口也同步改成8888 2026-05-18 18:20:10 +08:00
geht
50b74f484f 实现原料入场条码与批次号生成逻辑,离线时支持本地兜底;并在后续处理前补充入场记录必要标识校验。 2026-05-18 17:57:47 +08:00
geht
a102ed46f2 Merge branch 'SCADA系统测试' 2026-05-18 17:32:22 +08:00
geht
2ed796c1a1 桌面端打包优化 2026-05-18 17:31:18 +08:00
4a4bcb3fab Merge branch 'main' of http://27.223.88.102:33000/chenx/qhmes 2026-05-18 16:59:45 +08:00
a1181e49fc 原材料送检记录 2026-05-18 16:59:34 +08:00
34009b8900 设备管理基础资料准备 2026-05-18 16:36:04 +08:00
geht
c11f3104cb 优化桌面端无用菜单和地磅数据可手动功能。 2026-05-18 15:55:11 +08:00
5800b6b61c 原材料汇总页面修复 2026-05-18 14:26:02 +08:00
geht
878961649d Merge branch 'main' of http://27.223.88.102:33000/chenx/qhmes 2026-05-18 14:19:41 +08:00
geht
9461ba39e0 Update login mini assets: replace logo and ad text images, and enhance home.less styles for better layout and responsiveness. 2026-05-18 14:19:36 +08:00
36015f26d9 Merge remote-tracking branch 'origin/生产及设备基础资料' 2026-05-18 14:17:47 +08:00
6733f5f641 Merge branch 'cxversion' 2026-05-18 14:15:15 +08:00
23a6b717d7 Merge branch 'main' of http://27.223.88.102:33000/chenx/qhmes 2026-05-18 14:14:39 +08:00
f2bfb001f2 Merge remote-tracking branch 'origin/main' into cxversion 2026-05-18 14:13:47 +08:00
geht
2ffb3b4ebe Update logo assets across multiple directories with new versions for improved branding consistency. 2026-05-18 14:08:23 +08:00
a22a573c0d feat(xslmes): 停机分类与设备/工序基础资料菜单及权限完善
新增停机大类、停机类型 CRUD(含 Flyway 与独立 db 脚本);调整工序/设备分类/设备类型菜单归属与权限;同步厂家信息菜单脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-18 14:02:37 +08:00
geht
21ffca5ded Merge remote-tracking branch 'origin/SCADA系统测试' 2026-05-18 12:58:12 +08:00
geht
4571208ad9 Merge remote-tracking branch 'origin/生产基础资料' into SCADA系统测试 2026-05-18 12:57:24 +08:00
geht
5b3c59b632 Merge branch 'SCADA系统测试' 2026-05-18 12:20:02 +08:00
geht
890f7ea666 测试带有明细表的打印绑定是否生效 2026-05-18 11:13:55 +08:00
geht
2e034eb6f2 新增原材料检验标准实体中的检验标准明细列表,优化 MesRawMaterialInspectStdPage 以继承该明细。更新相关注释以提升代码可读性。 2026-05-15 18:08:08 +08:00
geht
8032f4c39c 更新 YY.Admin_Setup_1.1.0_win-x64.exe 安装程序,包含最新的功能和修复,确保应用程序的稳定性和兼容性。 2026-05-15 17:44:22 +08:00
e3b6915fbe Merge branch 'main' of http://27.223.88.102:33000/code/qhmes 2026-05-15 17:35:21 +08:00
530a0f13e7 原材料库存记录 2026-05-15 17:34:31 +08:00
geht
3bfaec8cbc Merge remote-tracking branch 'origin/SCADA系统测试' 2026-05-15 17:31:46 +08:00
geht
1b280af9e2 增强应用程序异常处理机制,新增未处理异常日志记录功能,确保在启动和运行期间捕获并记录异常信息。同时,重构配置文件加载逻辑,支持用户目录覆盖默认配置,优化 SQLite 数据库连接字符串处理,确保在不同环境下的兼容性和稳定性。 2026-05-15 17:30:30 +08:00
165 changed files with 10344 additions and 1720 deletions

View File

@@ -148,3 +148,60 @@ WHERE id IN (
'1860000000000000041',
'1860000000000000051'
);
-- ======================================================
-- 新增菜单原材料检验项目
-- ======================================================
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, menu_type, perms, perms_type, sort_no, is_route, is_leaf, hidden, status, del_flag, keep_alive, internal_or_external, create_by, create_time)
VALUES ('1860000000000000061', '1860000000000000001', '原材料检验项目', '/mes/rawmaterialinspectitem', 'mes/material/MesRawMaterialInspectItemList', 'MesRawMaterialInspectItemList', 1, NULL, '1', 6, 1, 1, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), url=VALUES(url), component=VALUES(component), component_name=VALUES(component_name),
menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type), sort_no=VALUES(sort_no),
is_route=VALUES(is_route), is_leaf=VALUES(is_leaf), hidden=VALUES(hidden), status=VALUES(status), del_flag=VALUES(del_flag),
keep_alive=VALUES(keep_alive), internal_or_external=VALUES(internal_or_external);
INSERT INTO sys_permission(id,parent_id,name,menu_type,perms,perms_type,status,del_flag,create_by,create_time) VALUES
('1860000000000000062','1860000000000000061','新增',2,'mes:mes_raw_material_inspect_item:add','1','1',0,'admin',NOW()),
('1860000000000000063','1860000000000000061','编辑',2,'mes:mes_raw_material_inspect_item:edit','1','1',0,'admin',NOW()),
('1860000000000000064','1860000000000000061','删除',2,'mes:mes_raw_material_inspect_item:delete','1','1',0,'admin',NOW()),
('1860000000000000065','1860000000000000061','批量删除',2,'mes:mes_raw_material_inspect_item:deleteBatch','1','1',0,'admin',NOW()),
('1860000000000000066','1860000000000000061','导出',2,'mes:mes_raw_material_inspect_item:exportXls','1','1',0,'admin',NOW()),
('1860000000000000067','1860000000000000061','导入',2,'mes:mes_raw_material_inspect_item:importExcel','1','1',0,'admin',NOW())
ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type),
status=VALUES(status), del_flag=VALUES(del_flag);
-- ======================================================
-- 新增菜单原材料检验标准
-- ======================================================
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, menu_type, perms, perms_type, sort_no, is_route, is_leaf, hidden, status, del_flag, keep_alive, internal_or_external, create_by, create_time)
VALUES ('1860000000000000071', '1860000000000000001', '原材料检验标准', '/mes/rawmaterialinspectstd', 'mes/material/MesRawMaterialInspectStdList', 'MesRawMaterialInspectStdList', 1, NULL, '1', 7, 1, 1, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), url=VALUES(url), component=VALUES(component), component_name=VALUES(component_name),
menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type), sort_no=VALUES(sort_no),
is_route=VALUES(is_route), is_leaf=VALUES(is_leaf), hidden=VALUES(hidden), status=VALUES(status), del_flag=VALUES(del_flag),
keep_alive=VALUES(keep_alive), internal_or_external=VALUES(internal_or_external);
INSERT INTO sys_permission(id,parent_id,name,menu_type,perms,perms_type,status,del_flag,create_by,create_time) VALUES
('1860000000000000072','1860000000000000071','新增',2,'mes:mes_raw_material_inspect_std:add','1','1',0,'admin',NOW()),
('1860000000000000073','1860000000000000071','编辑',2,'mes:mes_raw_material_inspect_std:edit','1','1',0,'admin',NOW()),
('1860000000000000074','1860000000000000071','删除',2,'mes:mes_raw_material_inspect_std:delete','1','1',0,'admin',NOW()),
('1860000000000000075','1860000000000000071','批量删除',2,'mes:mes_raw_material_inspect_std:deleteBatch','1','1',0,'admin',NOW()),
('1860000000000000076','1860000000000000071','启用停用',2,'mes:mes_raw_material_inspect_std:enable','1','1',0,'admin',NOW()),
('1860000000000000077','1860000000000000071','导出',2,'mes:mes_raw_material_inspect_std:exportXls','1','1',0,'admin',NOW()),
('1860000000000000078','1860000000000000071','导入',2,'mes:mes_raw_material_inspect_std:importExcel','1','1',0,'admin',NOW())
ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type),
status=VALUES(status), del_flag=VALUES(del_flag);
-- 新增菜单授权admin
INSERT INTO sys_role_permission(id, role_id, permission_id, operate_date, operate_ip)
SELECT REPLACE(UUID(),'-',''), 'f6817f48af4fb3af11b9e8bf182f618b', p.id, NOW(), '127.0.0.1'
FROM sys_permission p
WHERE p.id IN (
'1860000000000000061','1860000000000000062','1860000000000000063','1860000000000000064','1860000000000000065','1860000000000000066','1860000000000000067',
'1860000000000000071','1860000000000000072','1860000000000000073','1860000000000000074','1860000000000000075','1860000000000000076','1860000000000000077','1860000000000000078'
) AND NOT EXISTS (
SELECT 1
FROM sys_role_permission rp
WHERE rp.role_id = 'f6817f48af4fb3af11b9e8bf182f618b'
AND rp.permission_id = p.id
);

View File

@@ -32,19 +32,19 @@ VALUES ('1860000000000000060', @mes_base_pid, '工序管理', '/xslmes/mesXslPro
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0,
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000061', '1860000000000000060', '新增', 2, 'mes:mes_process_operation:add', '1', '1', 0, 'admin', NOW()),
('1860000000000000062', '1860000000000000060', '编辑', 2, 'mes:mes_process_operation:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000000063', '1860000000000000060', '删除', 2, 'mes:mes_process_operation:delete', '1', '1', 0, 'admin', NOW()),
('1860000000000000064', '1860000000000000060', '批量删除', 2, 'mes:mes_process_operation:deleteBatch', '1', '1', 0, 'admin', NOW()),
('1860000000000000065', '1860000000000000060', '导出', 2, 'mes:mes_process_operation:exportXls', '1', '1', 0, 'admin', NOW()),
('1860000000000000066', '1860000000000000060', '导入', 2, 'mes:mes_process_operation:importExcel', '1', '1', 0, 'admin', NOW())
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000061', '1860000000000000060', '新增', 2, 'mes:mes_process_operation:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000062', '1860000000000000060', '编辑', 2, 'mes:mes_process_operation:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000063', '1860000000000000060', '删除', 2, 'mes:mes_process_operation:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000064', '1860000000000000060', '批量删除', 2, 'mes:mes_process_operation:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000065', '1860000000000000060', '导出', 2, 'mes:mes_process_operation:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000066', '1860000000000000060', '导入', 2, 'mes:mes_process_operation:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
`is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'

View File

@@ -0,0 +1,82 @@
-- MES 停机主类型字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权可整文件一次执行
-- 权限前缀与 Controller前端 v-auth 一致mes:mes_xsl_downtime_main_type:*
-- 父菜单MES基础资料 / MES资料修改租户改 SET @mes_tenant_id
-- 新环境也可依赖 FlywayV3.9.2_64__mes_xsl_downtime_main_type.sql
SET NAMES utf8mb4;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES停机主类型是否启用', 'xslmes_downtime_main_type_status', '0启用1停用', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_downtime_main_type_status' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '启用', '0', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_main_type_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '0');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '停用', '1', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_main_type_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
CREATE TABLE IF NOT EXISTS `mes_xsl_downtime_main_type` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id',
`process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
`downtime_type` varchar(500) NOT NULL COMMENT '停机类型同租户未删除数据中唯一',
`display_order` int NOT NULL DEFAULT '0' COMMENT '显示顺序升序',
`distinguish_color` varchar(500) DEFAULT NULL COMMENT '区分颜色十六进制色值#1890ff',
`status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用字典xslmes_downtime_main_type_status0启用1停用',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mdmt_tenant_type` (`tenant_id`, `downtime_type`),
KEY `idx_mdmt_process` (`process_operation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES停机主类型';
SET @mes_tenant_id = 1002;
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000119', @mes_equip_pid, '停机主类型', '/xslmes/mesXslDowntimeMainType', 'xslmes/mesXslDowntimeMainType/MesXslDowntimeMainTypeList', NULL, 1, NULL, '1', 9, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:partition-outlined';
UPDATE `sys_permission` SET `icon` = 'ant-design:partition-outlined' WHERE `id` = '1860000000000000119' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000120', '1860000000000000119', '新增', 2, 'mes:mes_xsl_downtime_main_type:add', '1', '1', 0, 'admin', NOW()),
('1860000000000000121', '1860000000000000119', '编辑', 2, 'mes:mes_xsl_downtime_main_type:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000000122', '1860000000000000119', '删除', 2, 'mes:mes_xsl_downtime_main_type:delete', '1', '1', 0, 'admin', NOW()),
('1860000000000000123', '1860000000000000119', '批量删除', 2, 'mes:mes_xsl_downtime_main_type:deleteBatch', '1', '1', 0, 'admin', NOW()),
('1860000000000000124', '1860000000000000119', '导出', 2, 'mes:mes_xsl_downtime_main_type:exportXls', '1', '1', 0, 'admin', NOW()),
('1860000000000000125', '1860000000000000119', '导入', 2, 'mes:mes_xsl_downtime_main_type:importExcel', '1', '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000119',
'1860000000000000120', '1860000000000000121', '1860000000000000122', '1860000000000000123',
'1860000000000000124', '1860000000000000125'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,22 @@
-- 仅建表 mes_xsl_downtime_main_type完整初始化请执行 mes-xsl-downtime-main-type-menu-permission.sql
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `mes_xsl_downtime_main_type` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id',
`process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
`downtime_type` varchar(500) NOT NULL COMMENT '停机类型同租户未删除数据中唯一',
`display_order` int NOT NULL DEFAULT '0' COMMENT '显示顺序升序',
`distinguish_color` varchar(500) DEFAULT NULL COMMENT '区分颜色十六进制色值#1890ff',
`status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用字典xslmes_downtime_main_type_status0启用1停用',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mdmt_tenant_type` (`tenant_id`, `downtime_type`),
KEY `idx_mdmt_process` (`process_operation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES停机主类型';

View File

@@ -0,0 +1,90 @@
-- MES 停机类型字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权可整文件一次执行
-- 权限前缀mes:mes_xsl_downtime_type:*
-- 依赖mes_xsl_process_operationmes_xsl_downtime_main_type父菜单 MES基础资料
-- FlywayV3.9.2_65__mes_xsl_downtime_type.sql
SET NAMES utf8mb4;
-- 责任区分故障等级为手填不初始化字典已上线库请执行 mes-xsl-downtime-type-remove-unused-dict.sql
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES停机类型是否启用', 'xslmes_downtime_type_status', '0启用1停用', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_downtime_type_status' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '启用', '0', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_type_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '0');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '停用', '1', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_type_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
CREATE TABLE IF NOT EXISTS `mes_xsl_downtime_type` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id',
`process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
`downtime_main_type_id` varchar(32) NOT NULL COMMENT '所属主类型 mes_xsl_downtime_main_type.id',
`downtime_main_type_name` varchar(500) DEFAULT NULL COMMENT '主类型名称冗余停机主类型.downtime_type',
`downtime_type` varchar(500) NOT NULL COMMENT '停机类型同租户未删除数据中唯一',
`display_order` int NOT NULL DEFAULT '0' COMMENT '显示顺序升序必填',
`distinguish_color` varchar(500) DEFAULT NULL COMMENT '区分颜色十六进制色值',
`responsibility_distinct` varchar(500) DEFAULT NULL COMMENT '责任区分手填',
`fault_level` varchar(500) DEFAULT NULL COMMENT '故障等级手填',
`downtime_maintenance` varchar(1) DEFAULT '0' COMMENT '是否停机维修字典yn1是0否',
`status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用字典xslmes_downtime_type_status0启用1停用',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mdt_tenant_type` (`tenant_id`, `downtime_type`),
KEY `idx_mdt_process` (`process_operation_id`),
KEY `idx_mdt_main_type` (`downtime_main_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES停机类型';
SET @mes_tenant_id = 1002;
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000126', @mes_equip_pid, '停机类型', '/xslmes/mesXslDowntimeType', 'xslmes/mesXslDowntimeType/MesXslDowntimeTypeList', NULL, 1, NULL, '1', 10, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:pause-circle-outlined';
UPDATE `sys_permission` SET `icon` = 'ant-design:pause-circle-outlined' WHERE `id` = '1860000000000000126' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000127', '1860000000000000126', '新增', 2, 'mes:mes_xsl_downtime_type:add', '1', '1', 0, 'admin', NOW()),
('1860000000000000128', '1860000000000000126', '编辑', 2, 'mes:mes_xsl_downtime_type:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000000129', '1860000000000000126', '删除', 2, 'mes:mes_xsl_downtime_type:delete', '1', '1', 0, 'admin', NOW()),
('1860000000000000130', '1860000000000000126', '批量删除', 2, 'mes:mes_xsl_downtime_type:deleteBatch', '1', '1', 0, 'admin', NOW()),
('1860000000000000131', '1860000000000000126', '导出', 2, 'mes:mes_xsl_downtime_type:exportXls', '1', '1', 0, 'admin', NOW()),
('1860000000000000132', '1860000000000000126', '导入', 2, 'mes:mes_xsl_downtime_type:importExcel', '1', '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000126',
'1860000000000000127', '1860000000000000128', '1860000000000000129', '1860000000000000130',
'1860000000000000131', '1860000000000000132'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,11 @@
-- 删除停机类型模块中已废弃的字典责任区分故障等级已改为手填不再使用下拉字典
-- 保留xslmes_downtime_type_status是否启用xslmes_downtime_main_type_status停机主类型是否启用
-- 执行后请在系统管理刷新字典缓存或重新登录
SET NAMES utf8mb4;
DELETE i FROM `sys_dict_item` i
INNER JOIN `sys_dict` d ON i.`dict_id` = d.`id`
WHERE d.`dict_code` IN ('xslmes_downtime_responsibility', 'xslmes_downtime_fault_level');
DELETE FROM `sys_dict`
WHERE `dict_code` IN ('xslmes_downtime_responsibility', 'xslmes_downtime_fault_level');

View File

@@ -0,0 +1,28 @@
-- 仅建表 mes_xsl_downtime_type完整初始化请执行 mes-xsl-downtime-type-menu-permission.sql
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `mes_xsl_downtime_type` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id',
`process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
`downtime_main_type_id` varchar(32) NOT NULL COMMENT '所属主类型 mes_xsl_downtime_main_type.id',
`downtime_main_type_name` varchar(500) DEFAULT NULL COMMENT '主类型名称冗余停机主类型.downtime_type',
`downtime_type` varchar(500) NOT NULL COMMENT '停机类型同租户未删除数据中唯一',
`display_order` int NOT NULL DEFAULT '0' COMMENT '显示顺序升序必填',
`distinguish_color` varchar(500) DEFAULT NULL COMMENT '区分颜色十六进制色值',
`responsibility_distinct` varchar(500) DEFAULT NULL COMMENT '责任区分手填',
`fault_level` varchar(500) DEFAULT NULL COMMENT '故障等级手填',
`downtime_maintenance` varchar(1) DEFAULT '0' COMMENT '是否停机维修字典yn1是0否',
`status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用字典xslmes_downtime_type_status0启用1停用',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mdt_tenant_type` (`tenant_id`, `downtime_type`),
KEY `idx_mdt_process` (`process_operation_id`),
KEY `idx_mdt_main_type` (`downtime_main_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES停机类型';

View File

@@ -56,30 +56,31 @@ WHERE d.`dict_code` = 'xslmes_equipment_maintain_distinct'
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000070', @mes_base_pid, '设备类别', '/xslmes/mesXslEquipmentCategory', 'xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList', NULL, 1, NULL, '1', 10, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
VALUES ('1860000000000000070', @mes_equip_pid, '设备类别', '/xslmes/mesXslEquipmentCategory', 'xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList', NULL, 1, NULL, '1', 2, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0,
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000071', '1860000000000000070', '新增', 2, 'mes:mes_xsl_equipment_category:add', '1', '1', 0, 'admin', NOW()),
('1860000000000000072', '1860000000000000070', '编辑', 2, 'mes:mes_xsl_equipment_category:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000000073', '1860000000000000070', '删除', 2, 'mes:mes_xsl_equipment_category:delete', '1', '1', 0, 'admin', NOW()),
('1860000000000000074', '1860000000000000070', '批量删除', 2, 'mes:mes_xsl_equipment_category:deleteBatch', '1', '1', 0, 'admin', NOW()),
('1860000000000000075', '1860000000000000070', '导出', 2, 'mes:mes_xsl_equipment_category:exportXls', '1', '1', 0, 'admin', NOW()),
('1860000000000000076', '1860000000000000070', '导入', 2, 'mes:mes_xsl_equipment_category:importExcel', '1', '1', 0, 'admin', NOW())
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000071', '1860000000000000070', '新增', 2, 'mes:mes_xsl_equipment_category:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000072', '1860000000000000070', '编辑', 2, 'mes:mes_xsl_equipment_category:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000073', '1860000000000000070', '删除', 2, 'mes:mes_xsl_equipment_category:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000074', '1860000000000000070', '批量删除', 2, 'mes:mes_xsl_equipment_category:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000075', '1860000000000000070', '导出', 2, 'mes:mes_xsl_equipment_category:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000076', '1860000000000000070', '导入', 2, 'mes:mes_xsl_equipment_category:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
`is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'

View File

@@ -0,0 +1,31 @@
-- 设备管理目录 MES管理 下迁出 MES基础资料 同级已执行旧版 mes-xsl-equipment-ledger-menu-permission 时用
SET NAMES utf8mb4;
SET @mes_equip_root_parent = (
SELECT `parent_id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES基础资料'
LIMIT 1
);
SET @mes_equip_root_parent = IFNULL(@mes_equip_root_parent, (
SELECT `parent_id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES资料'
LIMIT 1
));
SET @mes_equip_root_sort = IFNULL((
SELECT `sort_no` + 1 FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
ORDER BY `sort_no` DESC
LIMIT 1
), 51);
UPDATE `sys_permission`
SET
`parent_id` = @mes_equip_root_parent,
`sort_no` = @mes_equip_root_sort,
`menu_type` = 0,
`is_leaf` = 0,
`hidden` = 0,
`status` = '1',
`del_flag` = 0
WHERE `id` = '1860000000000000133';

View File

@@ -0,0 +1,131 @@
-- MES 设备台账字典 + 建表 + 设备管理目录菜单 + 设备台账菜单 + 按钮 + 租户 admin 授权可整文件一次执行
-- 权限前缀mes:mes_xsl_equipment_ledger:*
-- 父菜单设备管理目录 MES基础资料 同级 MES管理 子级子菜单设备台账
-- 修改租户 SET @mes_tenant_id新环境也可依赖 Flyway V3.9.2_72__mes_xsl_equipment_ledger.sql
SET NAMES utf8mb4;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES设备台账状态', 'xslmes_equipment_ledger_status', '在用/停用/报废', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_equipment_ledger_status' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '在用', '0', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_equipment_ledger_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '0');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '停用', '1', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_equipment_ledger_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '报废', '2', 3, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_equipment_ledger_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '2');
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_ledger` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id',
`process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
`equipment_name` varchar(500) NOT NULL COMMENT '设备名称同租户未删除唯一',
`equipment_code` varchar(128) NOT NULL COMMENT '设备编号同租户未删除唯一',
`manufacturer_id` varchar(32) DEFAULT NULL COMMENT '所属设备厂家 mes_xsl_manufacturer.id',
`manufacturer_name` varchar(500) DEFAULT NULL COMMENT '设备厂家名称冗余',
`equipment_category_id` varchar(32) DEFAULT NULL COMMENT '设备类别 mes_xsl_equipment_category.id',
`equipment_category_name` varchar(500) DEFAULT NULL COMMENT '设备类别名称冗余',
`equipment_type_id` varchar(32) DEFAULT NULL COMMENT '设备类型 mes_xsl_equipment_type.id',
`equipment_type_name` varchar(500) DEFAULT NULL COMMENT '设备类型名称冗余',
`factory_id` varchar(32) DEFAULT NULL COMMENT '所属工厂厂家信息',
`factory_name` varchar(500) DEFAULT NULL COMMENT '所属工厂名称冗余',
`equipment_model` varchar(500) DEFAULT NULL COMMENT '设备型号',
`equipment_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '设备状态 字典xslmes_equipment_ledger_status0在用1停用2报废',
`serial_no` varchar(500) DEFAULT NULL COMMENT '序列号',
`nameplate` varchar(500) DEFAULT NULL COMMENT '铭牌',
`maintain_dept_id` varchar(32) DEFAULT NULL COMMENT '维修部门 sys_depart.id',
`maintain_person` varchar(500) DEFAULT NULL COMMENT '维修人员',
`manage_dept_id` varchar(32) DEFAULT NULL COMMENT '主管部门 sys_depart.id',
`doc_file_no` varchar(500) DEFAULT NULL COMMENT '资料文件编号',
`production_date` date DEFAULT NULL COMMENT '生产日期',
`purchase_date` date DEFAULT NULL COMMENT '购买日期',
`use_date` date DEFAULT NULL COMMENT '使用日期',
`vendor_contact` varchar(500) DEFAULT NULL COMMENT '厂商联系人',
`asset_value` varchar(128) DEFAULT NULL COMMENT '价值',
`controlled_pda` varchar(500) DEFAULT NULL COMMENT '受控PDA',
`overproduction_ratio` varchar(128) DEFAULT NULL COMMENT '超产比率',
`effective_volume` varchar(128) DEFAULT NULL COMMENT '有效体积',
`enabled_flag` varchar(1) NOT NULL DEFAULT '1' COMMENT '是否启用 字典yn1是0否',
`equipment_desc` varchar(1000) DEFAULT NULL COMMENT '设备描述',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mel_tenant_code` (`tenant_id`, `equipment_code`),
KEY `idx_mel_tenant_name` (`tenant_id`, `equipment_name`),
KEY `idx_mel_process` (`process_operation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备台账';
SET @mes_tenant_id = 1002;
-- MES基础资料同级取其 parent_id通常为 NULL MES管理 并列
SET @mes_equip_root_parent = (
SELECT `parent_id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES基础资料'
LIMIT 1
);
SET @mes_equip_root_parent = IFNULL(@mes_equip_root_parent, (
SELECT `parent_id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES资料'
LIMIT 1
));
SET @mes_equip_root_sort = IFNULL((
SELECT `sort_no` + 1 FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
ORDER BY `sort_no` DESC
LIMIT 1
), 51);
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `id` = '1860000000000000133' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000133', @mes_equip_root_parent, '设备管理', '/xslmes/equipment', 'layouts/RouteView', 'MesEquipmentLayout', 0, NULL, '1', @mes_equip_root_sort, 1, 0, 0, '1', 0, 0, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`menu_type` = VALUES(`menu_type`), `icon` = 'ant-design:tool-outlined', `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:tool-outlined' WHERE `id` = '1860000000000000133' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000134', '1860000000000000133', '设备台账', '/xslmes/mesXslEquipmentLedger', 'xslmes/mesXslEquipmentLedger/MesXslEquipmentLedgerList', 'MesXslEquipmentLedgerList', 1, NULL, '1', 1, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000135', '1860000000000000134', '新增', 2, 'mes:mes_xsl_equipment_ledger:add', '1', '1', 0, 'admin', NOW()),
('1860000000000000136', '1860000000000000134', '编辑', 2, 'mes:mes_xsl_equipment_ledger:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000000137', '1860000000000000134', '删除', 2, 'mes:mes_xsl_equipment_ledger:delete', '1', '1', 0, 'admin', NOW()),
('1860000000000000138', '1860000000000000134', '批量删除', 2, 'mes:mes_xsl_equipment_ledger:deleteBatch', '1', '1', 0, 'admin', NOW()),
('1860000000000000139', '1860000000000000134', '导出', 2, 'mes:mes_xsl_equipment_ledger:exportXls', '1', '1', 0, 'admin', NOW()),
('1860000000000000140', '1860000000000000134', '导入', 2, 'mes:mes_xsl_equipment_ledger:importExcel', '1', '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`),
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000133',
'1860000000000000134',
'1860000000000000135', '1860000000000000136', '1860000000000000137', '1860000000000000138',
'1860000000000000139', '1860000000000000140'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,46 @@
-- MES 设备台账仅建表完整初始化请执行 mes-xsl-equipment-ledger-menu-permission.sql
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_ledger` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序',
`process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
`equipment_name` varchar(500) NOT NULL COMMENT '设备名称',
`equipment_code` varchar(128) NOT NULL COMMENT '设备编号',
`manufacturer_id` varchar(32) DEFAULT NULL COMMENT '所属设备厂家',
`manufacturer_name` varchar(500) DEFAULT NULL COMMENT '设备厂家名称冗余',
`equipment_category_id` varchar(32) DEFAULT NULL COMMENT '设备类别',
`equipment_category_name` varchar(500) DEFAULT NULL COMMENT '设备类别名称冗余',
`equipment_type_id` varchar(32) DEFAULT NULL COMMENT '设备类型',
`equipment_type_name` varchar(500) DEFAULT NULL COMMENT '设备类型名称冗余',
`factory_id` varchar(32) DEFAULT NULL COMMENT '所属工厂',
`factory_name` varchar(500) DEFAULT NULL COMMENT '所属工厂名称冗余',
`equipment_model` varchar(500) DEFAULT NULL COMMENT '设备型号',
`equipment_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '设备状态',
`serial_no` varchar(500) DEFAULT NULL COMMENT '序列号',
`nameplate` varchar(500) DEFAULT NULL COMMENT '铭牌',
`maintain_dept_id` varchar(32) DEFAULT NULL COMMENT '维修部门',
`maintain_person` varchar(500) DEFAULT NULL COMMENT '维修人员',
`manage_dept_id` varchar(32) DEFAULT NULL COMMENT '主管部门',
`doc_file_no` varchar(500) DEFAULT NULL COMMENT '资料文件编号',
`production_date` date DEFAULT NULL COMMENT '生产日期',
`purchase_date` date DEFAULT NULL COMMENT '购买日期',
`use_date` date DEFAULT NULL COMMENT '使用日期',
`vendor_contact` varchar(500) DEFAULT NULL COMMENT '厂商联系人',
`asset_value` varchar(128) DEFAULT NULL COMMENT '价值',
`controlled_pda` varchar(500) DEFAULT NULL COMMENT '受控PDA',
`overproduction_ratio` varchar(128) DEFAULT NULL COMMENT '超产比率',
`effective_volume` varchar(128) DEFAULT NULL COMMENT '有效体积',
`enabled_flag` varchar(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
`equipment_desc` varchar(1000) DEFAULT NULL COMMENT '设备描述',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`),
KEY `idx_mel_tenant_code` (`tenant_id`, `equipment_code`),
KEY `idx_mel_tenant_name` (`tenant_id`, `equipment_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备台账';

View File

@@ -0,0 +1,10 @@
-- 设备管理目录及指定子菜单图标可重复执行
SET NAMES utf8mb4;
UPDATE `sys_permission` SET `icon` = 'ant-design:tool-outlined' WHERE `id` = '1860000000000000133' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:apartment-outlined' WHERE `id` = '1860000000000000091' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:tags-outlined' WHERE `id` = '1860000000000000098' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:shopping-outlined' WHERE `id` = '1860000000000000105' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:shop-outlined' WHERE `id` = '1860000000000000112' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:partition-outlined' WHERE `id` = '1860000000000000119' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:pause-circle-outlined' WHERE `id` = '1860000000000000126' AND `del_flag` = 0;

View File

@@ -24,14 +24,15 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_part` (
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000084', @mes_base_pid, '设备部位', '/xslmes/mesXslEquipmentPart', 'xslmes/mesXslEquipmentPart/MesXslEquipmentPartList', NULL, 1, NULL, '1', 12, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
VALUES ('1860000000000000084', @mes_equip_pid, '设备部位', '/xslmes/mesXslEquipmentPart', 'xslmes/mesXslEquipmentPart/MesXslEquipmentPartList', NULL, 1, NULL, '1', 4, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),

View File

@@ -27,19 +27,22 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_sub_part` (
SET @mes_tenant_id = 1002;
SET @xslmes_root_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES XSL', 'XSLMES管理', 'XSLMES')
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @xslmes_root_pid = IFNULL(@xslmes_root_pid, '1900000000000000300');
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000091', @xslmes_root_pid, '设备小部位', '/xslmes/mesXslEquipmentSubPart', 'xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPartList', NULL, 1, NULL, '1', 14, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
VALUES ('1860000000000000091', @mes_equip_pid, '设备小部位', '/xslmes/mesXslEquipmentSubPart', 'xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPartList', NULL, 1, NULL, '1', 5, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:apartment-outlined';
UPDATE `sys_permission` SET `icon` = 'ant-design:apartment-outlined' WHERE `id` = '1860000000000000091' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000092', '1860000000000000091', '新增', 2, 'mes:mes_xsl_equipment_sub_part:add', '1', '1', 0, 'admin', NOW()),

View File

@@ -0,0 +1,65 @@
-- 设备类型菜单/按钮补全并挂到设备管理解决仅 UPDATE id 077 不存在菜单与权限均不显示
-- 可重复执行修改租户改 SET @mes_tenant_id
SET NAMES utf8mb4;
SET @mes_tenant_id = 1002;
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `id` = @mes_equip_pid;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000077', @mes_equip_pid, '设备类型', '/xslmes/mesXslEquipmentType', 'xslmes/mesXslEquipmentType/MesXslEquipmentTypeList', NULL, 1, NULL, '1', 3, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0,
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000078', '1860000000000000077', '新增', 2, 'mes:mes_xsl_equipment_type:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000079', '1860000000000000077', '编辑', 2, 'mes:mes_xsl_equipment_type:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000080', '1860000000000000077', '删除', 2, 'mes:mes_xsl_equipment_type:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000081', '1860000000000000077', '批量删除', 2, 'mes:mes_xsl_equipment_type:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000082', '1860000000000000077', '导出', 2, 'mes:mes_xsl_equipment_type:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000083', '1860000000000000077', '导入', 2, 'mes:mes_xsl_equipment_type:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`),
`perms_type` = VALUES(`perms_type`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
UPDATE `sys_permission` p
INNER JOIN (SELECT @mes_equip_pid AS `pid`) x ON 1 = 1
SET p.`parent_id` = x.`pid`,
p.`is_leaf` = 0,
p.`url` = '/xslmes/mesXslEquipmentType',
p.`component` = 'xslmes/mesXslEquipmentType/MesXslEquipmentTypeList',
p.`hidden` = 0,
p.`del_flag` = 0,
p.`status` = '1',
p.`update_time` = NOW()
WHERE p.`menu_type` = 1
AND p.`url` = '/xslmes/mesXslEquipmentType'
AND p.`id` <> '1860000000000000077';
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000077',
'1860000000000000078', '1860000000000000079', '1860000000000000080',
'1860000000000000081', '1860000000000000082', '1860000000000000083'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -23,14 +23,15 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_type` (
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000077', @mes_base_pid, '设备类型', '/xslmes/mesXslEquipmentType', 'xslmes/mesXslEquipmentType/MesXslEquipmentTypeList', NULL, 1, NULL, '1', 11, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
VALUES ('1860000000000000077', @mes_equip_pid, '设备类型', '/xslmes/mesXslEquipmentType', 'xslmes/mesXslEquipmentType/MesXslEquipmentTypeList', NULL, 1, NULL, '1', 3, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),

View File

@@ -1,6 +1,6 @@
-- MES 厂家信息字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权可整文件一次执行
-- 权限前缀与 Controller前端 v-auth 一致mes:mes_xsl_manufacturer:*
-- 父菜单MES基础资料 / MES资料与备品件等脚本相同 @mes_base_pid修改租户改 SET @mes_tenant_id
-- 父菜单设备管理@mes_equip_pid修改租户改 SET @mes_tenant_id
-- 新环境也可依赖 FlywayV3.9.2_63__mes_xsl_manufacturer.sql与本文内容一致重复执行幂等
SET NAMES utf8mb4;
@@ -31,14 +31,14 @@ WHERE d.`dict_code` = 'xslmes_manufacturer_valid' AND NOT EXISTS (SELECT 1 FROM
CREATE TABLE IF NOT EXISTS `mes_xsl_manufacturer` (
`id` varchar(32) NOT NULL COMMENT '主键',
`manufacturer_category` varchar(32) NOT NULL COMMENT '厂家类别字典xslmes_manufacturer_categorymold模具 capsule胶囊 equipment设备',
`manufacturer_name` varchar(128) NOT NULL COMMENT '厂家名称同租户未删除数据中唯一',
`manufacturer_category` varchar(500) NOT NULL COMMENT '厂家类别字典xslmes_manufacturer_categorymold模具 capsule胶囊 equipment设备',
`manufacturer_name` varchar(500) NOT NULL COMMENT '厂家名称同租户未删除数据中唯一',
`valid_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否有效字典xslmes_manufacturer_valid0有效1无效',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
@@ -47,19 +47,22 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_manufacturer` (
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000112', @mes_base_pid, '厂家信息', '/xslmes/mesXslManufacturer', 'xslmes/mesXslManufacturer/MesXslManufacturerList', NULL, 1, NULL, '1', 17, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
VALUES ('1860000000000000112', @mes_equip_pid, '厂家信息', '/xslmes/mesXslManufacturer', 'xslmes/mesXslManufacturer/MesXslManufacturerList', NULL, 1, NULL, '1', 8, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:shop-outlined';
UPDATE `sys_permission` SET `icon` = 'ant-design:shop-outlined' WHERE `id` = '1860000000000000112' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000113', '1860000000000000112', '新增', 2, 'mes:mes_xsl_manufacturer:add', '1', '1', 0, 'admin', NOW()),

View File

@@ -3,14 +3,14 @@ SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `mes_xsl_manufacturer` (
`id` varchar(32) NOT NULL COMMENT '主键',
`manufacturer_category` varchar(32) NOT NULL COMMENT '厂家类别字典xslmes_manufacturer_categorymold模具 capsule胶囊 equipment设备',
`manufacturer_name` varchar(128) NOT NULL COMMENT '厂家名称同租户未删除数据中唯一',
`manufacturer_category` varchar(500) NOT NULL COMMENT '厂家类别字典xslmes_manufacturer_categorymold模具 capsule胶囊 equipment设备',
`manufacturer_name` varchar(500) NOT NULL COMMENT '厂家名称同租户未删除数据中唯一',
`valid_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否有效字典xslmes_manufacturer_valid0有效1无效',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),

View File

@@ -0,0 +1,62 @@
-- 将设备类别/类型/部位/小部位备品件厂家停机类菜单挂到设备管理目录下工序管理仍留 MES基础资料
-- 前置已执行 mes-xsl-equipment-ledger-menu-permission.sql Flyway V3.9.2_72 创建设备管理目录 id=1860000000000000133
-- 修改租户 SET @mes_tenant_id
SET NAMES utf8mb4;
SET @mes_tenant_id = 1002;
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
UPDATE `sys_permission`
SET `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0
WHERE `id` = @mes_equip_pid;
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 1, `is_leaf` = 0 WHERE `id` = '1860000000000000134';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 2, `is_leaf` = 0 WHERE `id` = '1860000000000000070';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 3, `is_leaf` = 0 WHERE `id` = '1860000000000000077';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 4, `is_leaf` = 0 WHERE `id` = '1860000000000000084';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 5, `is_leaf` = 0 WHERE `id` = '1860000000000000091';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 6, `is_leaf` = 0 WHERE `id` = '1860000000000000098';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 7, `is_leaf` = 0 WHERE `id` = '1860000000000000105';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 8, `is_leaf` = 0 WHERE `id` = '1860000000000000112';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 9, `is_leaf` = 0 WHERE `id` = '1860000000000000119';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 10, `is_leaf` = 0 WHERE `id` = '1860000000000000126';
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
@mes_equip_pid,
'1860000000000000134',
'1860000000000000070',
'1860000000000000071', '1860000000000000072', '1860000000000000073', '1860000000000000074', '1860000000000000075', '1860000000000000076',
'1860000000000000077',
'1860000000000000078', '1860000000000000079', '1860000000000000080', '1860000000000000081', '1860000000000000082', '1860000000000000083',
'1860000000000000084',
'1860000000000000085', '1860000000000000086', '1860000000000000087', '1860000000000000088', '1860000000000000089', '1860000000000000090',
'1860000000000000091',
'1860000000000000092', '1860000000000000093', '1860000000000000094', '1860000000000000095', '1860000000000000096', '1860000000000000097',
'1860000000000000098',
'1860000000000000099', '1860000000000000100', '1860000000000000101', '1860000000000000102', '1860000000000000103', '1860000000000000104',
'1860000000000000105',
'1860000000000000106', '1860000000000000107', '1860000000000000108', '1860000000000000109', '1860000000000000110', '1860000000000000111',
'1860000000000000112',
'1860000000000000113', '1860000000000000114', '1860000000000000115', '1860000000000000116', '1860000000000000117', '1860000000000000118',
'1860000000000000119',
'1860000000000000120', '1860000000000000121', '1860000000000000122', '1860000000000000123', '1860000000000000124', '1860000000000000125',
'1860000000000000126',
'1860000000000000127', '1860000000000000128', '1860000000000000129', '1860000000000000130', '1860000000000000131', '1860000000000000132',
'1860000000000000135', '1860000000000000136', '1860000000000000137', '1860000000000000138', '1860000000000000139', '1860000000000000140'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,104 @@
-- 工序管理挂MES基础资料设备类别设备类型挂设备管理修复权限树is_leaf与租户 admin 授权
-- 适用菜单曾在 MES XSL 根下或 is_leaf=1 导致角色授权页不显示按钮权限
-- 修改租户 SET @mes_tenant_id
SET NAMES utf8mb4;
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES基础资料'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES资料'
));
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料');
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `id` = @mes_equip_pid;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000060', @mes_base_pid, '工序管理', '/xslmes/mesXslProcessOperation', 'xslmes/mesXslProcessOperation/MesXslProcessOperationList', NULL, 1, NULL, '1', 9, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000061', '1860000000000000060', '新增', 2, 'mes:mes_process_operation:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000062', '1860000000000000060', '编辑', 2, 'mes:mes_process_operation:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000063', '1860000000000000060', '删除', 2, 'mes:mes_process_operation:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000064', '1860000000000000060', '批量删除', 2, 'mes:mes_process_operation:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000065', '1860000000000000060', '导出', 2, 'mes:mes_process_operation:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000066', '1860000000000000060', '导入', 2, 'mes:mes_process_operation:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `perms` = VALUES(`perms`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000070', @mes_equip_pid, '设备类别', '/xslmes/mesXslEquipmentCategory', 'xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList', NULL, 1, NULL, '1', 2, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000071', '1860000000000000070', '新增', 2, 'mes:mes_xsl_equipment_category:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000072', '1860000000000000070', '编辑', 2, 'mes:mes_xsl_equipment_category:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000073', '1860000000000000070', '删除', 2, 'mes:mes_xsl_equipment_category:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000074', '1860000000000000070', '批量删除', 2, 'mes:mes_xsl_equipment_category:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000075', '1860000000000000070', '导出', 2, 'mes:mes_xsl_equipment_category:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000076', '1860000000000000070', '导入', 2, 'mes:mes_xsl_equipment_category:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `perms` = VALUES(`perms`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000077', @mes_equip_pid, '设备类型', '/xslmes/mesXslEquipmentType', 'xslmes/mesXslEquipmentType/MesXslEquipmentTypeList', NULL, 1, NULL, '1', 3, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000078', '1860000000000000077', '新增', 2, 'mes:mes_xsl_equipment_type:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000079', '1860000000000000077', '编辑', 2, 'mes:mes_xsl_equipment_type:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000080', '1860000000000000077', '删除', 2, 'mes:mes_xsl_equipment_type:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000081', '1860000000000000077', '批量删除', 2, 'mes:mes_xsl_equipment_type:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000082', '1860000000000000077', '导出', 2, 'mes:mes_xsl_equipment_type:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000083', '1860000000000000077', '导入', 2, 'mes:mes_xsl_equipment_type:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `perms` = VALUES(`perms`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
UPDATE `sys_permission` SET `name` = '新增' WHERE `id` = '1860000000000000061' AND `name` = '添加';
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000060',
'1860000000000000061', '1860000000000000062', '1860000000000000063',
'1860000000000000064', '1860000000000000065', '1860000000000000066',
'1860000000000000070',
'1860000000000000071', '1860000000000000072', '1860000000000000073',
'1860000000000000074', '1860000000000000075', '1860000000000000076',
'1860000000000000077',
'1860000000000000078', '1860000000000000079', '1860000000000000080',
'1860000000000000081', '1860000000000000082', '1860000000000000083'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,90 @@
-- 工序管理(060) MES基础资料设备类别(070)挂设备管理修复 is_leaf租户 admin 授权
-- 可重复执行修改租户改 SET @mes_tenant_id
SET NAMES utf8mb4;
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES基础资料'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES资料'
));
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料');
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `id` = @mes_equip_pid;
-- 工序管理
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000060', @mes_base_pid, '工序管理', '/xslmes/mesXslProcessOperation', 'xslmes/mesXslProcessOperation/MesXslProcessOperationList', NULL, 1, NULL, '1', 9, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`menu_type` = VALUES(`menu_type`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000061', '1860000000000000060', '新增', 2, 'mes:mes_process_operation:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000062', '1860000000000000060', '编辑', 2, 'mes:mes_process_operation:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000063', '1860000000000000060', '删除', 2, 'mes:mes_process_operation:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000064', '1860000000000000060', '批量删除', 2, 'mes:mes_process_operation:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000065', '1860000000000000060', '导出', 2, 'mes:mes_process_operation:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000066', '1860000000000000060', '导入', 2, 'mes:mes_process_operation:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`),
`perms_type` = VALUES(`perms_type`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
UPDATE `sys_permission` SET `name` = '新增' WHERE `id` = '1860000000000000061' AND `name` = '添加';
-- 设备类别
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000070', @mes_equip_pid, '设备类别', '/xslmes/mesXslEquipmentCategory', 'xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList', NULL, 1, NULL, '1', 2, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`menu_type` = VALUES(`menu_type`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000071', '1860000000000000070', '新增', 2, 'mes:mes_xsl_equipment_category:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000072', '1860000000000000070', '编辑', 2, 'mes:mes_xsl_equipment_category:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000073', '1860000000000000070', '删除', 2, 'mes:mes_xsl_equipment_category:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000074', '1860000000000000070', '批量删除', 2, 'mes:mes_xsl_equipment_category:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000075', '1860000000000000070', '导出', 2, 'mes:mes_xsl_equipment_category:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000076', '1860000000000000070', '导入', 2, 'mes:mes_xsl_equipment_category:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`),
`perms_type` = VALUES(`perms_type`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000060',
'1860000000000000061', '1860000000000000062', '1860000000000000063',
'1860000000000000064', '1860000000000000065', '1860000000000000066',
'1860000000000000070',
'1860000000000000071', '1860000000000000072', '1860000000000000073',
'1860000000000000074', '1860000000000000075', '1860000000000000076'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,66 @@
-- 原材料送检记录菜单与权限挂到 MES管理
SET NAMES utf8mb4;
SET @mes_parent_id = (
SELECT id
FROM sys_permission
WHERE url = '/mes' AND menu_type = 0
ORDER BY create_time ASC
LIMIT 1
);
SET @mes_parent_id = IFNULL(@mes_parent_id, '1860000000000000001');
-- 二级菜单原材料送检记录
INSERT INTO sys_permission(
id, parent_id, name, url, component, component_name, menu_type, perms, perms_type, sort_no,
is_route, is_leaf, hidden, status, del_flag, keep_alive, internal_or_external, create_by, create_time
)
VALUES (
'1860000000000099111', @mes_parent_id, '原材料送检记录',
'/xslmes/mesXslRawMaterialInspectRecordList',
'xslmes/mesXslRawMaterialInspectRecord/MesXslRawMaterialInspectRecordList',
'MesXslRawMaterialInspectRecordList', 1, NULL, '1', 22,
1, 1, 0, '1', 0, 1, 0, 'admin', NOW()
)
ON DUPLICATE KEY UPDATE
parent_id = VALUES(parent_id),
name = VALUES(name),
url = VALUES(url),
component = VALUES(component),
component_name = VALUES(component_name),
menu_type = VALUES(menu_type),
perms = VALUES(perms),
perms_type = VALUES(perms_type),
sort_no = VALUES(sort_no),
is_route = VALUES(is_route),
is_leaf = VALUES(is_leaf),
hidden = VALUES(hidden),
status = VALUES(status),
del_flag = VALUES(del_flag),
keep_alive = VALUES(keep_alive),
internal_or_external = VALUES(internal_or_external);
-- 按钮权限
INSERT INTO sys_permission(id, parent_id, name, menu_type, perms, perms_type, status, del_flag, create_by, create_time) VALUES
('1860000000000099112', '1860000000000099111', '编辑', 2, 'xslmes:mes_xsl_raw_material_inspect_record:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000099113', '1860000000000099111', '导出', 2, 'xslmes:mes_xsl_raw_material_inspect_record:exportXls', '1', '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
parent_id = VALUES(parent_id),
name = VALUES(name),
menu_type = VALUES(menu_type),
perms = VALUES(perms),
perms_type = VALUES(perms_type),
status = VALUES(status),
del_flag = VALUES(del_flag);
-- admin 角色授权
INSERT INTO sys_role_permission(id, role_id, permission_id, operate_date, operate_ip)
SELECT REPLACE(UUID(), '-', ''), 'f6817f48af4fb3af11b9e8bf182f618b', p.id, NOW(), '127.0.0.1'
FROM sys_permission p
WHERE p.id IN ('1860000000000099111', '1860000000000099112', '1860000000000099113')
AND NOT EXISTS (
SELECT 1
FROM sys_role_permission rp
WHERE rp.role_id = 'f6817f48af4fb3af11b9e8bf182f618b'
AND rp.permission_id = p.id
);

View File

@@ -0,0 +1,36 @@
-- 原材料送检记录测试数据重置脚本稳妥版
-- 作用
-- 1) 将存在送检记录关联的原材料卡片检测结果重置为未检(0)
-- 2) 清空原材料送检记录主表/子表数据
SET NAMES utf8mb4;
START TRANSACTION;
-- 执行前计数便于确认是否命中数据
SELECT COUNT(1) AS before_record_count FROM mes_xsl_raw_material_inspect_record;
SELECT COUNT(1) AS before_record_line_count FROM mes_xsl_raw_material_inspect_record_line;
-- 回写原材料卡片检测结果为未检0只重置存在送检记录关联的卡片
UPDATE mes_xsl_raw_material_card c
JOIN (
SELECT DISTINCT r.raw_material_card_id AS card_id
FROM mes_xsl_raw_material_inspect_record r
WHERE r.raw_material_card_id IS NOT NULL
AND r.raw_material_card_id <> ''
) t ON t.card_id = c.id
SET c.test_result = '0',
c.update_time = NOW();
-- 先删子表再删主表
DELETE FROM mes_xsl_raw_material_inspect_record_line
WHERE record_id IN (
SELECT id FROM mes_xsl_raw_material_inspect_record
);
DELETE FROM mes_xsl_raw_material_inspect_record;
COMMIT;
-- 执行后计数
SELECT COUNT(1) AS remaining_record_count FROM mes_xsl_raw_material_inspect_record;
SELECT COUNT(1) AS remaining_record_line_count FROM mes_xsl_raw_material_inspect_record_line;

View File

@@ -0,0 +1,80 @@
-- 原材料送检记录主表 + 子表
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `mes_xsl_raw_material_inspect_record` (
`id` varchar(32) NOT NULL COMMENT '主键',
`raw_material_card_id` varchar(32) DEFAULT NULL COMMENT '原材料卡片ID',
`barcode` varchar(128) DEFAULT NULL COMMENT '条码',
`batch_no` varchar(128) DEFAULT NULL COMMENT '批次号',
`material_id` varchar(32) DEFAULT NULL COMMENT '物料ID',
`material_name` varchar(200) DEFAULT NULL COMMENT '物料名称',
`inspect_status` varchar(10) DEFAULT '0' COMMENT '检验状态字典 xslmes_inspect_status0待检 1合格 2不合格',
`inspect_time` datetime DEFAULT NULL COMMENT '送检时间',
`result_time` datetime DEFAULT NULL COMMENT '判定时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`tenant_id` int DEFAULT NULL COMMENT '租户',
PRIMARY KEY (`id`),
KEY `idx_xsl_rm_ir_card` (`raw_material_card_id`),
KEY `idx_xsl_rm_ir_status` (`inspect_status`),
KEY `idx_xsl_rm_ir_time` (`inspect_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='原材料送检记录';
CREATE TABLE IF NOT EXISTS `mes_xsl_raw_material_inspect_record_line` (
`id` varchar(32) NOT NULL COMMENT '主键',
`record_id` varchar(32) NOT NULL COMMENT '送检记录主表ID',
`inspect_std_id` varchar(32) DEFAULT NULL COMMENT '检验标准ID',
`inspect_item_id` varchar(32) DEFAULT NULL COMMENT '检验项目ID',
`inspect_item_name` varchar(200) DEFAULT NULL COMMENT '检验项目名称',
`allow_min` decimal(24,6) DEFAULT NULL COMMENT '容许最小值',
`include_min_flag` int NOT NULL DEFAULT '0' COMMENT '包含最小值1是 0否',
`allow_max` decimal(24,6) DEFAULT NULL COMMENT '容许最大值',
`include_max_flag` int NOT NULL DEFAULT '0' COMMENT '包含最大值1是 0否',
`inspect_value` decimal(24,6) DEFAULT NULL COMMENT '检验值',
`pass_flag` varchar(10) DEFAULT '0' COMMENT '判定状态字典 xslmes_inspect_status0待检 1合格 2不合格',
`sort_no` int DEFAULT NULL COMMENT '排序',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_xsl_rm_irl_record` (`record_id`),
KEY `idx_xsl_rm_irl_item` (`inspect_item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='原材料送检记录-检验明细';
-- 字典送检状态
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`)
SELECT REPLACE(UUID(), '-', ''), '送检状态', 'xslmes_inspect_status', '原材料送检状态待检/合格/不合格', 0, 'admin', NOW(), 0
WHERE NOT EXISTS (
SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_inspect_status' AND `del_flag` = 0
);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '待检', '0', '待检', 1, 1, 'admin', NOW()
FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_inspect_status'
AND d.`del_flag` = 0
AND NOT EXISTS (
SELECT 1 FROM `sys_dict_item` i WHERE i.dict_id = d.id AND i.item_value = '0'
);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '合格', '1', '合格', 2, 1, 'admin', NOW()
FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_inspect_status'
AND d.`del_flag` = 0
AND NOT EXISTS (
SELECT 1 FROM `sys_dict_item` i WHERE i.dict_id = d.id AND i.item_value = '1'
);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '不合格', '2', '不合格', 3, 1, 'admin', NOW()
FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_inspect_status'
AND d.`del_flag` = 0
AND NOT EXISTS (
SELECT 1 FROM `sys_dict_item` i WHERE i.dict_id = d.id AND i.item_value = '2'
);

View File

@@ -0,0 +1,37 @@
-- 原材料汇总页面菜单参考原材料库存菜单配置
SET NAMES utf8mb4;
-- 优先复用原材料库存的父级菜单不存在时回退到原固定父级
SET @xsl_parent_id = (
SELECT parent_id
FROM sys_permission
WHERE id = '1900000000000000600'
LIMIT 1
);
SET @xsl_parent_id = IFNULL(@xsl_parent_id, '1900000000000000300');
-- 页面菜单
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000610', @xsl_parent_id, '原材料汇总', '/xslmes/mesXslRawMaterialSummary', 'xslmes/mesXslRawMaterialSummary/MesXslRawMaterialSummaryList', 1, NULL, NULL, 1, NULL, '0', 13.00, 0, 'ant-design:database-outlined', 0, 1, 0, 0, '原材料汇总', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000610');
-- 导出按钮权限
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000611', '1900000000000000610', '导出', NULL, NULL, 0, NULL, NULL, 2, 'xslmes:mes_xsl_raw_material_summary:exportXls', '1', 1.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000611');
-- 默认管理员角色授权
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000610', NULL, NOW(), '127.0.0.1'
WHERE NOT EXISTS (
SELECT 1 FROM `sys_role_permission`
WHERE `role_id` = 'f6817f48af4fb3af11b9e8bf182f618b' AND `permission_id` = '1900000000000000610'
);
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000611', NULL, NOW(), '127.0.0.1'
WHERE NOT EXISTS (
SELECT 1 FROM `sys_role_permission`
WHERE `role_id` = 'f6817f48af4fb3af11b9e8bf182f618b' AND `permission_id` = '1900000000000000611'
);

View File

@@ -26,19 +26,22 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_spare_part` (
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000105', @mes_base_pid, '备品件信息', '/xslmes/mesXslSparePart', 'xslmes/mesXslSparePart/MesXslSparePartList', NULL, 1, NULL, '1', 16, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
VALUES ('1860000000000000105', @mes_equip_pid, '备品件信息', '/xslmes/mesXslSparePart', 'xslmes/mesXslSparePart/MesXslSparePartList', NULL, 1, NULL, '1', 7, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:shopping-outlined';
UPDATE `sys_permission` SET `icon` = 'ant-design:shopping-outlined' WHERE `id` = '1860000000000000105' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000106', '1860000000000000105', '新增', 2, 'mes:mes_xsl_spare_part:add', '1', '1', 0, 'admin', NOW()),

View File

@@ -20,19 +20,22 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_spare_parts_category` (
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000098', @mes_base_pid, '备品件类别', '/xslmes/mesXslSparePartsCategory', 'xslmes/mesXslSparePartsCategory/MesXslSparePartsCategoryList', NULL, 1, NULL, '1', 15, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
VALUES ('1860000000000000098', @mes_equip_pid, '备品件类别', '/xslmes/mesXslSparePartsCategory', 'xslmes/mesXslSparePartsCategory/MesXslSparePartsCategoryList', NULL, 1, NULL, '1', 6, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:tags-outlined';
UPDATE `sys_permission` SET `icon` = 'ant-design:tags-outlined' WHERE `id` = '1860000000000000098' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000099', '1860000000000000098', '新增', 2, 'mes:mes_xsl_spare_parts_category:add', '1', '1', 0, 'admin', NOW()),

View File

@@ -43,6 +43,7 @@ import org.jeecg.modules.xslmes.service.MesXslStompNotifyService;
import org.jeecg.modules.xslmes.vo.MesXslRawMaterialCardBriefVO;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -405,12 +406,7 @@ public class MesXslDesktopAnonController {
if (oConvertUtils.isEmpty(mesXslWeightRecord.getPlateNumber())) {
return Result.error("车牌号不能为空");
}
// 净重自动计算
if (mesXslWeightRecord.getGrossWeight() != null && mesXslWeightRecord.getTareWeight() != null) {
mesXslWeightRecord.setNetWeight(
mesXslWeightRecord.getGrossWeight().subtract(mesXslWeightRecord.getTareWeight()));
}
applyWeightBillType(mesXslWeightRecord);
applyWeightNetAndBillType(mesXslWeightRecord);
applyMaterialTypeDefault(mesXslWeightRecord);
weightRecordService.save(mesXslWeightRecord);
stompNotify.publishWeightRecordChanged("add", mesXslWeightRecord.getId());
@@ -423,12 +419,7 @@ public class MesXslDesktopAnonController {
if (oConvertUtils.isEmpty(mesXslWeightRecord.getId())) {
return Result.error("主键不能为空");
}
// 净重自动计算
if (mesXslWeightRecord.getGrossWeight() != null && mesXslWeightRecord.getTareWeight() != null) {
mesXslWeightRecord.setNetWeight(
mesXslWeightRecord.getGrossWeight().subtract(mesXslWeightRecord.getTareWeight()));
}
applyWeightBillType(mesXslWeightRecord);
applyWeightNetAndBillType(mesXslWeightRecord);
applyMaterialTypeDefault(mesXslWeightRecord);
boolean ok = weightRecordService.updateById(mesXslWeightRecord);
if (!ok) {
@@ -670,7 +661,7 @@ public class MesXslDesktopAnonController {
if (tpl == null) return Result.error("绑定的打印模板不存在");
ArrayNode mapping = PrintBizDataMappingUtil.parseMappingArray(bind.getFieldMappingJson());
JsonNode bizRoot = objectMapper.valueToTree(card);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping, tpl.getTemplateJson());
PrintBizDataMappingUtil.fillMissingDataBindingParamKeys(printData, tpl.getTemplateJson());
Map<String, Object> out = new HashMap<>(8);
out.put("cardId", card.getId());
@@ -697,7 +688,7 @@ public class MesXslDesktopAnonController {
if (tpl == null) return Result.error("绑定的打印模板不存在");
ArrayNode mapping = PrintBizDataMappingUtil.parseMappingArray(bind.getFieldMappingJson());
JsonNode bizRoot = objectMapper.valueToTree(entry);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping, tpl.getTemplateJson());
PrintBizDataMappingUtil.fillMissingDataBindingParamKeys(printData, tpl.getTemplateJson());
Map<String, Object> out = new HashMap<>(8);
out.put("entryId", entry.getId());
@@ -839,18 +830,47 @@ public class MesXslDesktopAnonController {
// ─────────────────────────── 车辆私有辅助 ────────────────────────────
private void applyWeightNetAndBillType(MesXslWeightRecord record) {
sanitizeNonPositiveWeightsToNull(record);
if (isEffectiveWeight(record.getGrossWeight()) && isEffectiveWeight(record.getTareWeight())) {
BigDecimal net = record.getGrossWeight().subtract(record.getTareWeight());
record.setNetWeight(net.compareTo(BigDecimal.ZERO) >= 0 ? net : BigDecimal.ZERO);
} else {
record.setNetWeight(null);
}
applyWeightBillType(record);
}
/** 将 ≤0 的重量视为未录入,避免 JSON/Numeric 占位 0 被当成已称皮重、误判称重完成 */
private static void sanitizeNonPositiveWeightsToNull(MesXslWeightRecord record) {
if (record.getGrossWeight() != null && record.getGrossWeight().compareTo(BigDecimal.ZERO) <= 0) {
record.setGrossWeight(null);
}
if (record.getTareWeight() != null && record.getTareWeight().compareTo(BigDecimal.ZERO) <= 0) {
record.setTareWeight(null);
}
}
private static boolean isEffectiveWeight(BigDecimal w) {
return w != null && w.compareTo(BigDecimal.ZERO) > 0;
}
private void applyWeightBillType(MesXslWeightRecord record) {
if (record.getGrossWeight() != null && record.getTareWeight() != null) {
boolean g = isEffectiveWeight(record.getGrossWeight());
boolean t = isEffectiveWeight(record.getTareWeight());
if (g && t) {
record.setBillType("2");
return;
}
if (record.getGrossWeight() != null) {
if (g) {
record.setBillType("1");
return;
}
if (record.getTareWeight() != null) {
if (t) {
record.setBillType("3");
return;
}
record.setBillType(null);
}
private void applyMaterialTypeDefault(MesXslWeightRecord record) {

View File

@@ -0,0 +1,324 @@
package org.jeecg.modules.xslmes.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType;
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
import org.jeecg.modules.xslmes.service.IMesXslDowntimeMainTypeService;
import org.jeecg.modules.xslmes.service.IMesXslProcessOperationService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
/**
* MES 停机主类型
*/
@Tag(name = "MES停机主类型")
@RestController
@RequestMapping("/xslmes/mesXslDowntimeMainType")
@Slf4j
public class MesXslDowntimeMainTypeController extends JeecgController<MesXslDowntimeMainType, IMesXslDowntimeMainTypeService> {
private static final Set<String> STATUS_VALUES = Set.of("0", "1");
private static final Pattern COLOR_HEX = Pattern.compile("^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$");
@Autowired
private IMesXslDowntimeMainTypeService mesXslDowntimeMainTypeService;
@Autowired
private IMesXslProcessOperationService mesXslProcessOperationService;
@Operation(summary = "MES停机主类型-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslDowntimeMainType>> queryPageList(
MesXslDowntimeMainType model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslDowntimeMainType> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
//update-begin---author:jiangxh ---date:20260518 for【MES】停机主类型列表默认按显示顺序升序-----------
queryWrapper.orderByAsc("display_order").orderByDesc("create_time");
//update-end---author:jiangxh ---date:20260518 for【MES】停机主类型列表默认按显示顺序升序-----------
Page<MesXslDowntimeMainType> page = new Page<>(pageNo, pageSize);
IPage<MesXslDowntimeMainType> pageList = mesXslDowntimeMainTypeService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES停机主类型-添加")
@Operation(summary = "MES停机主类型-添加")
@RequiresPermissions("mes:mes_xsl_downtime_main_type:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslDowntimeMainType model) {
//update-begin---author:jiangxh ---date:20260518 for【MES】停机主类型保存前校验-----------
String err = validateForSave(model, null);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机主类型保存前校验-----------
mesXslDowntimeMainTypeService.save(model);
return Result.OK("添加成功!");
}
@AutoLog(value = "MES停机主类型-编辑")
@Operation(summary = "MES停机主类型-编辑")
@RequiresPermissions("mes:mes_xsl_downtime_main_type:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslDowntimeMainType model) {
//update-begin---author:jiangxh ---date:20260518 for【MES】停机主类型保存前校验-----------
String err = validateForSave(model, model.getId());
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机主类型保存前校验-----------
mesXslDowntimeMainTypeService.updateById(model);
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES停机主类型-删除")
@Operation(summary = "MES停机主类型-通过id删除")
@RequiresPermissions("mes:mes_xsl_downtime_main_type:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslDowntimeMainTypeService.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES停机主类型-批量删除")
@Operation(summary = "MES停机主类型-批量删除")
@RequiresPermissions("mes:mes_xsl_downtime_main_type:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
mesXslDowntimeMainTypeService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "MES停机主类型-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslDowntimeMainType> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslDowntimeMainType entity = mesXslDowntimeMainTypeService.getById(id);
if (entity == null) {
return Result.error("未找到对应数据");
}
return Result.OK(entity);
}
@Operation(summary = "校验停机类型是否重复同租户未删除数据dataId 为编辑时当前主键)")
@GetMapping(value = "/checkDowntimeType")
public Result<String> checkDowntimeType(
@RequestParam(name = "downtimeType", required = true) String downtimeType,
@RequestParam(name = "dataId", required = false) String dataId) {
if (oConvertUtils.isEmpty(downtimeType) || downtimeType.trim().isEmpty()) {
return Result.OK("该值可用!");
}
MesXslDowntimeMainType ctx = new MesXslDowntimeMainType();
if (mesXslDowntimeMainTypeService.isDowntimeTypeDuplicated(downtimeType.trim(), dataId, ctx)) {
return Result.error("停机类型不能重复");
}
return Result.OK("该值可用!");
}
@RequiresPermissions("mes:mes_xsl_downtime_main_type:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslDowntimeMainType model) {
return super.exportXls(request, model, MesXslDowntimeMainType.class, "MES停机主类型");
}
@RequiresPermissions("mes:mes_xsl_downtime_main_type:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
//update-begin---author:jiangxh ---date:20260518 for【MES】停机主类型导入类型唯一、工序编码解析、颜色与启用状态校验-----------
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> ent : fileMap.entrySet()) {
MultipartFile file = ent.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<MesXslDowntimeMainType> list =
ExcelImportUtil.importExcel(file.getInputStream(), MesXslDowntimeMainType.class, params);
if (list == null) {
list = List.of();
}
Set<String> typesInFile = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
MesXslDowntimeMainType row = list.get(i);
int rowNo = i + 1;
if (row == null) {
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
}
String dt = row.getDowntimeType();
if (dt != null) {
dt = dt.trim();
}
if (oConvertUtils.isEmpty(dt)) {
return Result.error("文件导入失败:第 " + rowNo + " 条停机类型不能为空");
}
row.setDowntimeType(dt);
if (!typesInFile.add(dt)) {
return Result.error("文件导入失败:停机类型【" + dt + "】在导入文件中重复");
}
if (mesXslDowntimeMainTypeService.isDowntimeTypeDuplicated(dt, null, row)) {
return Result.error("文件导入失败:第 " + rowNo + " 条停机类型【" + dt + "】不能重复(同租户未删除数据中已存在)");
}
String opCode = row.getImportOperationCode();
if (opCode != null) {
opCode = opCode.trim();
}
if (oConvertUtils.isEmpty(opCode)) {
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码不能为空");
}
MesXslProcessOperation op = findProcessByOperationCode(opCode, row);
if (op == null) {
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码【" + opCode + "】不存在");
}
row.setProcessOperationId(op.getId());
row.setProcessOperationName(op.getOperationName());
if (row.getDisplayOrder() == null) {
row.setDisplayOrder(0);
}
String colorErr = normalizeColor(row);
if (colorErr != null) {
return Result.error("文件导入失败:第 " + rowNo + "" + colorErr);
}
String st = row.getStatus();
if (oConvertUtils.isEmpty(st)) {
row.setStatus("0");
} else {
st = st.trim();
if (!STATUS_VALUES.contains(st)) {
return Result.error("文件导入失败:第 " + rowNo + " 条是否启用无效(须为 0 启用或 1 停用)");
}
row.setStatus(st);
}
row.setImportOperationCode(null);
}
long start = System.currentTimeMillis();
mesXslDowntimeMainTypeService.saveBatch(list);
log.info("停机主类型Excel导入完成耗时{}ms行数={}", System.currentTimeMillis() - start, list.size());
return Result.ok("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
String msg = e.getMessage();
log.error(msg, e);
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
return Result.error("文件导入失败: 存在重复数据(停机类型不能重复)");
}
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机主类型导入类型唯一、工序编码解析、颜色与启用状态校验-----------
return Result.error("文件导入失败!");
}
//update-begin---author:jiangxh ---date:20260518 for【MES】停机主类型保存前校验与工序名称回填-----------
private String validateForSave(MesXslDowntimeMainType model, String excludeId) {
if (oConvertUtils.isEmpty(model.getDowntimeType()) || model.getDowntimeType().trim().isEmpty()) {
return "停机类型不能为空";
}
String dt = model.getDowntimeType().trim();
model.setDowntimeType(dt);
if (mesXslDowntimeMainTypeService.isDowntimeTypeDuplicated(dt, excludeId, model)) {
return "停机类型不能重复";
}
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
return "请选择所属工序";
}
MesXslProcessOperation op = mesXslProcessOperationService.getById(model.getProcessOperationId());
if (op == null) {
return "所属工序不存在";
}
model.setProcessOperationName(op.getOperationName());
if (model.getDisplayOrder() == null) {
model.setDisplayOrder(0);
}
String colorErr = normalizeColor(model);
if (colorErr != null) {
return colorErr;
}
String st = model.getStatus();
if (oConvertUtils.isEmpty(st)) {
model.setStatus("0");
} else {
st = st.trim();
if (!STATUS_VALUES.contains(st)) {
return "是否启用取值无效";
}
model.setStatus(st);
}
model.setImportOperationCode(null);
return null;
}
private static String normalizeColor(MesXslDowntimeMainType model) {
String color = model.getDistinguishColor();
if (oConvertUtils.isEmpty(color)) {
model.setDistinguishColor(null);
return null;
}
color = color.trim();
if (!color.startsWith("#")) {
color = "#" + color;
}
if (!COLOR_HEX.matcher(color).matches()) {
return "区分颜色格式无效(须为十六进制色值,如 #1890ff";
}
model.setDistinguishColor(color.toLowerCase());
return null;
}
private MesXslProcessOperation findProcessByOperationCode(String operationCode, MesXslDowntimeMainType context) {
LambdaQueryWrapper<MesXslProcessOperation> w = new LambdaQueryWrapper<>();
w.eq(MesXslProcessOperation::getOperationCode, operationCode.trim());
w.and(
q ->
q.eq(MesXslProcessOperation::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslProcessOperation::getDelFlag));
Integer tenantId = context != null ? context.getTenantId() : null;
if (tenantId != null) {
w.eq(MesXslProcessOperation::getTenantId, tenantId);
}
List<MesXslProcessOperation> found = mesXslProcessOperationService.list(w);
if (found == null || found.isEmpty()) {
return null;
}
return found.get(0);
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机主类型保存前校验与工序名称回填-----------
}

View File

@@ -0,0 +1,433 @@
package org.jeecg.modules.xslmes.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeType;
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
import org.jeecg.modules.xslmes.service.IMesXslDowntimeMainTypeService;
import org.jeecg.modules.xslmes.service.IMesXslDowntimeTypeService;
import org.jeecg.modules.xslmes.service.IMesXslProcessOperationService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
/**
* MES 停机类型
*/
@Tag(name = "MES停机类型")
@RestController
@RequestMapping("/xslmes/mesXslDowntimeType")
@Slf4j
public class MesXslDowntimeTypeController extends JeecgController<MesXslDowntimeType, IMesXslDowntimeTypeService> {
private static final Set<String> STATUS_VALUES = Set.of("0", "1");
private static final Set<String> YN_VALUES = Set.of("0", "1");
private static final Pattern COLOR_HEX = Pattern.compile("^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$");
@Autowired
private IMesXslDowntimeTypeService mesXslDowntimeTypeService;
@Autowired
private IMesXslProcessOperationService mesXslProcessOperationService;
@Autowired
private IMesXslDowntimeMainTypeService mesXslDowntimeMainTypeService;
@Operation(summary = "MES停机类型-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslDowntimeType>> queryPageList(
MesXslDowntimeType model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslDowntimeType> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
//update-begin---author:jiangxh ---date:20260518 for【MES】停机类型列表默认按显示顺序升序-----------
queryWrapper.orderByAsc("display_order").orderByDesc("create_time");
//update-end---author:jiangxh ---date:20260518 for【MES】停机类型列表默认按显示顺序升序-----------
Page<MesXslDowntimeType> page = new Page<>(pageNo, pageSize);
IPage<MesXslDowntimeType> pageList = mesXslDowntimeTypeService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES停机类型-添加")
@Operation(summary = "MES停机类型-添加")
@RequiresPermissions("mes:mes_xsl_downtime_type:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslDowntimeType model) {
//update-begin---author:jiangxh ---date:20260518 for【MES】停机类型保存前校验-----------
String err = validateForSave(model, null);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机类型保存前校验-----------
mesXslDowntimeTypeService.save(model);
return Result.OK("添加成功!");
}
@AutoLog(value = "MES停机类型-编辑")
@Operation(summary = "MES停机类型-编辑")
@RequiresPermissions("mes:mes_xsl_downtime_type:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslDowntimeType model) {
//update-begin---author:jiangxh ---date:20260518 for【MES】停机类型保存前校验-----------
String err = validateForSave(model, model.getId());
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机类型保存前校验-----------
mesXslDowntimeTypeService.updateById(model);
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES停机类型-删除")
@Operation(summary = "MES停机类型-通过id删除")
@RequiresPermissions("mes:mes_xsl_downtime_type:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslDowntimeTypeService.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES停机类型-批量删除")
@Operation(summary = "MES停机类型-批量删除")
@RequiresPermissions("mes:mes_xsl_downtime_type:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
mesXslDowntimeTypeService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "MES停机类型-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslDowntimeType> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslDowntimeType entity = mesXslDowntimeTypeService.getById(id);
if (entity == null) {
return Result.error("未找到对应数据");
}
return Result.OK(entity);
}
@Operation(summary = "校验停机类型是否重复同租户未删除数据dataId 为编辑时当前主键)")
@GetMapping(value = "/checkDowntimeType")
public Result<String> checkDowntimeType(
@RequestParam(name = "downtimeType", required = true) String downtimeType,
@RequestParam(name = "dataId", required = false) String dataId) {
if (oConvertUtils.isEmpty(downtimeType) || downtimeType.trim().isEmpty()) {
return Result.OK("该值可用!");
}
MesXslDowntimeType ctx = new MesXslDowntimeType();
if (mesXslDowntimeTypeService.isDowntimeTypeDuplicated(downtimeType.trim(), dataId, ctx)) {
return Result.error("停机类型不能重复");
}
return Result.OK("该值可用!");
}
@RequiresPermissions("mes:mes_xsl_downtime_type:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslDowntimeType model) {
return super.exportXls(request, model, MesXslDowntimeType.class, "MES停机类型");
}
@RequiresPermissions("mes:mes_xsl_downtime_type:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
//update-begin---author:jiangxh ---date:20260518 for【MES】停机类型导入必填校验、类型唯一、工序与主类型解析-----------
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> ent : fileMap.entrySet()) {
MultipartFile file = ent.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<MesXslDowntimeType> list =
ExcelImportUtil.importExcel(file.getInputStream(), MesXslDowntimeType.class, params);
if (list == null) {
list = List.of();
}
Set<String> typesInFile = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
MesXslDowntimeType row = list.get(i);
int rowNo = i + 1;
if (row == null) {
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
}
String err = validateImportRow(row, rowNo, typesInFile);
if (err != null) {
return Result.error(err);
}
}
long start = System.currentTimeMillis();
mesXslDowntimeTypeService.saveBatch(list);
log.info("停机类型Excel导入完成耗时{}ms行数={}", System.currentTimeMillis() - start, list.size());
return Result.ok("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
String msg = e.getMessage();
log.error(msg, e);
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
return Result.error("文件导入失败: 存在重复数据(停机类型不能重复)");
}
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机类型导入必填校验、类型唯一、工序与主类型解析-----------
return Result.error("文件导入失败!");
}
//update-begin---author:jiangxh ---date:20260518 for【MES】停机类型保存前校验、关联工序与主类型回填-----------
private String validateForSave(MesXslDowntimeType model, String excludeId) {
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
return "请选择所属工序";
}
MesXslProcessOperation op = mesXslProcessOperationService.getById(model.getProcessOperationId());
if (op == null) {
return "所属工序不存在";
}
model.setProcessOperationName(op.getOperationName());
if (oConvertUtils.isEmpty(model.getDowntimeMainTypeId())) {
return "请选择所属主类型";
}
String mainErr = fillAndValidateMainType(model);
if (mainErr != null) {
return mainErr;
}
if (oConvertUtils.isEmpty(model.getDowntimeType()) || model.getDowntimeType().trim().isEmpty()) {
return "停机类型不能为空";
}
String dt = model.getDowntimeType().trim();
model.setDowntimeType(dt);
if (mesXslDowntimeTypeService.isDowntimeTypeDuplicated(dt, excludeId, model)) {
return "停机类型不能重复";
}
if (model.getDisplayOrder() == null) {
return "显示顺序不能为空";
}
String colorErr = normalizeColor(model);
if (colorErr != null) {
return colorErr;
}
//update-begin---author:jiangxh ---date:20260518 for【MES】责任区分、故障等级改为手填文本仅 trim-----------
model.setResponsibilityDistinct(trimToNull(model.getResponsibilityDistinct()));
model.setFaultLevel(trimToNull(model.getFaultLevel()));
//update-end---author:jiangxh ---date:20260518 for【MES】责任区分、故障等级改为手填文本仅 trim-----------
String dm = model.getDowntimeMaintenance();
if (oConvertUtils.isEmpty(dm)) {
model.setDowntimeMaintenance("0");
} else {
dm = dm.trim();
if (!YN_VALUES.contains(dm)) {
return "是否停机维修取值无效";
}
model.setDowntimeMaintenance(dm);
}
String st = model.getStatus();
if (oConvertUtils.isEmpty(st)) {
model.setStatus("0");
} else {
st = st.trim();
if (!STATUS_VALUES.contains(st)) {
return "是否启用取值无效";
}
model.setStatus(st);
}
model.setImportOperationCode(null);
model.setImportMainTypeName(null);
return null;
}
private String fillAndValidateMainType(MesXslDowntimeType model) {
MesXslDowntimeMainType main = mesXslDowntimeMainTypeService.getById(model.getDowntimeMainTypeId());
if (main == null) {
return "所属主类型不存在";
}
if (!model.getProcessOperationId().equals(main.getProcessOperationId())) {
return "所属主类型与所选工序不匹配";
}
model.setDowntimeMainTypeName(main.getDowntimeType());
return null;
}
private String validateImportRow(MesXslDowntimeType row, int rowNo, Set<String> typesInFile) {
String opCode = row.getImportOperationCode();
if (opCode != null) {
opCode = opCode.trim();
}
if (oConvertUtils.isEmpty(opCode)) {
return "文件导入失败:第 " + rowNo + " 条工序编码不能为空";
}
MesXslProcessOperation op = findProcessByOperationCode(opCode, row);
if (op == null) {
return "文件导入失败:第 " + rowNo + " 条工序编码【" + opCode + "】不存在";
}
row.setProcessOperationId(op.getId());
row.setProcessOperationName(op.getOperationName());
String mainName = row.getImportMainTypeName();
if (mainName != null) {
mainName = mainName.trim();
}
if (oConvertUtils.isEmpty(mainName)) {
return "文件导入失败:第 " + rowNo + " 条主类型名称不能为空";
}
MesXslDowntimeMainType main = findMainTypeByNameAndProcess(mainName, op.getId(), row);
if (main == null) {
return "文件导入失败:第 " + rowNo + " 条主类型【" + mainName + "】在所选工序下不存在";
}
row.setDowntimeMainTypeId(main.getId());
row.setDowntimeMainTypeName(main.getDowntimeType());
String dt = row.getDowntimeType();
if (dt != null) {
dt = dt.trim();
}
if (oConvertUtils.isEmpty(dt)) {
return "文件导入失败:第 " + rowNo + " 条停机类型不能为空";
}
row.setDowntimeType(dt);
if (!typesInFile.add(dt)) {
return "文件导入失败:停机类型【" + dt + "】在导入文件中重复";
}
if (mesXslDowntimeTypeService.isDowntimeTypeDuplicated(dt, null, row)) {
return "文件导入失败:第 " + rowNo + " 条停机类型【" + dt + "】不能重复(同租户未删除数据中已存在)";
}
if (row.getDisplayOrder() == null) {
return "文件导入失败:第 " + rowNo + " 条显示顺序不能为空";
}
String colorErr = normalizeColor(row);
if (colorErr != null) {
return "文件导入失败:第 " + rowNo + "" + colorErr;
}
row.setResponsibilityDistinct(trimToNull(row.getResponsibilityDistinct()));
row.setFaultLevel(trimToNull(row.getFaultLevel()));
String dm = row.getDowntimeMaintenance();
if (oConvertUtils.isEmpty(dm)) {
row.setDowntimeMaintenance("0");
} else {
dm = dm.trim();
if (!YN_VALUES.contains(dm)) {
return "文件导入失败:第 " + rowNo + " 条是否停机维修无效";
}
row.setDowntimeMaintenance(dm);
}
String st = row.getStatus();
if (oConvertUtils.isEmpty(st)) {
row.setStatus("0");
} else {
st = st.trim();
if (!STATUS_VALUES.contains(st)) {
return "文件导入失败:第 " + rowNo + " 条是否启用无效";
}
row.setStatus(st);
}
row.setImportOperationCode(null);
row.setImportMainTypeName(null);
return null;
}
private MesXslDowntimeMainType findMainTypeByNameAndProcess(
String mainTypeName, String processOperationId, MesXslDowntimeType context) {
LambdaQueryWrapper<MesXslDowntimeMainType> w = new LambdaQueryWrapper<>();
w.eq(MesXslDowntimeMainType::getDowntimeType, mainTypeName.trim());
w.eq(MesXslDowntimeMainType::getProcessOperationId, processOperationId);
w.and(
q ->
q.eq(MesXslDowntimeMainType::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslDowntimeMainType::getDelFlag));
Integer tenantId = context != null ? context.getTenantId() : null;
if (tenantId != null) {
w.eq(MesXslDowntimeMainType::getTenantId, tenantId);
}
w.last("LIMIT 1");
return mesXslDowntimeMainTypeService.getOne(w, false);
}
private MesXslProcessOperation findProcessByOperationCode(String operationCode, MesXslDowntimeType context) {
LambdaQueryWrapper<MesXslProcessOperation> w = new LambdaQueryWrapper<>();
w.eq(MesXslProcessOperation::getOperationCode, operationCode.trim());
w.and(
q ->
q.eq(MesXslProcessOperation::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslProcessOperation::getDelFlag));
Integer tenantId = context != null ? context.getTenantId() : null;
if (tenantId != null) {
w.eq(MesXslProcessOperation::getTenantId, tenantId);
}
List<MesXslProcessOperation> found = mesXslProcessOperationService.list(w);
if (found == null || found.isEmpty()) {
return null;
}
return found.get(0);
}
private static String trimToNull(String value) {
if (value == null) {
return null;
}
String v = value.trim();
return v.isEmpty() ? null : v;
}
private static String normalizeColor(MesXslDowntimeType model) {
String color = model.getDistinguishColor();
if (oConvertUtils.isEmpty(color)) {
model.setDistinguishColor(null);
return null;
}
color = color.trim();
if (!color.startsWith("#")) {
color = "#" + color;
}
if (!COLOR_HEX.matcher(color).matches()) {
return "区分颜色格式无效(须为十六进制色值,如 #1890ff";
}
model.setDistinguishColor(color.toLowerCase());
return null;
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机类型保存前校验、关联工序与主类型回填-----------
}

View File

@@ -0,0 +1,319 @@
package org.jeecg.modules.xslmes.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
import org.jeecg.modules.xslmes.service.IMesXslEquipmentLedgerService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
/**
* MES 设备台账
*/
@Tag(name = "MES设备台账")
@RestController
@RequestMapping("/xslmes/mesXslEquipmentLedger")
@Slf4j
public class MesXslEquipmentLedgerController extends JeecgController<MesXslEquipmentLedger, IMesXslEquipmentLedgerService> {
private static final Set<String> EQUIPMENT_STATUS = Set.of("0", "1", "2");
private static final Set<String> ENABLED_FLAGS = Set.of("0", "1");
@Autowired
private IMesXslEquipmentLedgerService mesXslEquipmentLedgerService;
@Operation(summary = "MES设备台账-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslEquipmentLedger>> queryPageList(
MesXslEquipmentLedger model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslEquipmentLedger> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
Page<MesXslEquipmentLedger> page = new Page<>(pageNo, pageSize);
IPage<MesXslEquipmentLedger> pageList = mesXslEquipmentLedgerService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES设备台账-添加")
@Operation(summary = "MES设备台账-添加")
@RequiresPermissions("mes:mes_xsl_equipment_ledger:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslEquipmentLedger model) {
//update-begin---author:jiangxh ---date:20260518 for【MES】设备台账保存前校验-----------
String err = validateForSave(model, null);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260518 for【MES】设备台账保存前校验-----------
mesXslEquipmentLedgerService.save(model);
return Result.OK("添加成功!");
}
@AutoLog(value = "MES设备台账-编辑")
@Operation(summary = "MES设备台账-编辑")
@RequiresPermissions("mes:mes_xsl_equipment_ledger:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslEquipmentLedger model) {
//update-begin---author:jiangxh ---date:20260518 for【MES】设备台账保存前校验-----------
String err = validateForSave(model, model.getId());
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260518 for【MES】设备台账保存前校验-----------
mesXslEquipmentLedgerService.updateById(model);
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES设备台账-删除")
@Operation(summary = "MES设备台账-通过id删除")
@RequiresPermissions("mes:mes_xsl_equipment_ledger:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslEquipmentLedgerService.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES设备台账-批量删除")
@Operation(summary = "MES设备台账-批量删除")
@RequiresPermissions("mes:mes_xsl_equipment_ledger:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
mesXslEquipmentLedgerService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "MES设备台账-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslEquipmentLedger> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslEquipmentLedger entity = mesXslEquipmentLedgerService.getById(id);
if (entity == null) {
return Result.error("未找到对应数据");
}
return Result.OK(entity);
}
@Operation(summary = "校验设备编号是否重复")
@GetMapping(value = "/checkEquipmentCode")
public Result<String> checkEquipmentCode(
@RequestParam(name = "equipmentCode", required = true) String equipmentCode,
@RequestParam(name = "dataId", required = false) String dataId) {
if (oConvertUtils.isEmpty(equipmentCode) || equipmentCode.trim().isEmpty()) {
return Result.OK("该值可用!");
}
MesXslEquipmentLedger ctx = new MesXslEquipmentLedger();
if (mesXslEquipmentLedgerService.isEquipmentCodeDuplicated(equipmentCode.trim(), dataId, ctx)) {
return Result.error("设备编号不能重复");
}
return Result.OK("该值可用!");
}
@Operation(summary = "校验设备名称是否重复")
@GetMapping(value = "/checkEquipmentName")
public Result<String> checkEquipmentName(
@RequestParam(name = "equipmentName", required = true) String equipmentName,
@RequestParam(name = "dataId", required = false) String dataId) {
if (oConvertUtils.isEmpty(equipmentName) || equipmentName.trim().isEmpty()) {
return Result.OK("该值可用!");
}
MesXslEquipmentLedger ctx = new MesXslEquipmentLedger();
if (mesXslEquipmentLedgerService.isEquipmentNameDuplicated(equipmentName.trim(), dataId, ctx)) {
return Result.error("设备名称不能重复");
}
return Result.OK("该值可用!");
}
@RequiresPermissions("mes:mes_xsl_equipment_ledger:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentLedger model) {
return super.exportXls(request, model, MesXslEquipmentLedger.class, "MES设备台账");
}
@RequiresPermissions("mes:mes_xsl_equipment_ledger:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> ent : fileMap.entrySet()) {
MultipartFile file = ent.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<MesXslEquipmentLedger> list =
ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentLedger.class, params);
if (list == null) {
list = List.of();
}
Set<String> codesInFile = new HashSet<>();
Set<String> namesInFile = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
MesXslEquipmentLedger row = list.get(i);
int rowNo = i + 1;
if (row == null) {
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
}
String err = validateImportRow(row, rowNo, codesInFile, namesInFile);
if (err != null) {
return Result.error(err);
}
}
long start = System.currentTimeMillis();
mesXslEquipmentLedgerService.saveBatch(list);
log.info("设备台账Excel导入完成耗时{}ms行数={}", System.currentTimeMillis() - start, list.size());
return Result.ok("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
String msg = e.getMessage();
log.error(msg, e);
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
return Result.error("文件导入失败: 存在重复数据(设备编号或设备名称不能重复)");
}
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
return Result.error("文件导入失败!");
}
//update-begin---author:jiangxh ---date:20260518 for【MES】设备台账保存与导入校验-----------
private String validateForSave(MesXslEquipmentLedger model, String excludeId) {
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
return "请选择所属工序";
}
if (oConvertUtils.isEmpty(model.getEquipmentName()) || model.getEquipmentName().trim().isEmpty()) {
return "设备名称不能为空";
}
String name = model.getEquipmentName().trim();
model.setEquipmentName(name);
if (mesXslEquipmentLedgerService.isEquipmentNameDuplicated(name, excludeId, model)) {
return "设备名称不能重复";
}
if (oConvertUtils.isEmpty(model.getEquipmentCode()) || model.getEquipmentCode().trim().isEmpty()) {
return "设备编号不能为空";
}
String code = model.getEquipmentCode().trim();
model.setEquipmentCode(code);
if (mesXslEquipmentLedgerService.isEquipmentCodeDuplicated(code, excludeId, model)) {
return "设备编号不能重复";
}
trimRelationNames(model);
String status = model.getEquipmentStatus();
if (oConvertUtils.isEmpty(status)) {
model.setEquipmentStatus("0");
} else {
status = status.trim();
if (!EQUIPMENT_STATUS.contains(status)) {
return "设备状态无效(须为在用/停用/报废)";
}
model.setEquipmentStatus(status);
}
String enabled = model.getEnabledFlag();
if (oConvertUtils.isEmpty(enabled)) {
model.setEnabledFlag("1");
} else {
enabled = enabled.trim();
if (!ENABLED_FLAGS.contains(enabled)) {
return "是否启用无效(须为是/否)";
}
model.setEnabledFlag(enabled);
}
return null;
}
private String validateImportRow(MesXslEquipmentLedger row, int rowNo, Set<String> codesInFile, Set<String> namesInFile) {
String code = row.getEquipmentCode();
if (code != null) {
code = code.trim();
}
if (oConvertUtils.isEmpty(code)) {
return "文件导入失败:第 " + rowNo + " 条设备编号不能为空";
}
row.setEquipmentCode(code);
if (!codesInFile.add(code)) {
return "文件导入失败:设备编号【" + code + "】在导入文件中重复";
}
if (mesXslEquipmentLedgerService.isEquipmentCodeDuplicated(code, null, row)) {
return "文件导入失败:第 " + rowNo + " 条设备编号【" + code + "】不能重复";
}
String name = row.getEquipmentName();
if (name != null) {
name = name.trim();
}
if (oConvertUtils.isEmpty(name)) {
return "文件导入失败:第 " + rowNo + " 条设备名称不能为空";
}
row.setEquipmentName(name);
if (!namesInFile.add(name)) {
return "文件导入失败:设备名称【" + name + "】在导入文件中重复";
}
if (mesXslEquipmentLedgerService.isEquipmentNameDuplicated(name, null, row)) {
return "文件导入失败:第 " + rowNo + " 条设备名称【" + name + "】不能重复";
}
trimRelationNames(row);
String status = row.getEquipmentStatus();
if (oConvertUtils.isEmpty(status)) {
row.setEquipmentStatus("0");
} else if (!EQUIPMENT_STATUS.contains(status.trim())) {
return "文件导入失败:第 " + rowNo + " 条设备状态无效";
} else {
row.setEquipmentStatus(status.trim());
}
String enabled = row.getEnabledFlag();
if (oConvertUtils.isEmpty(enabled)) {
row.setEnabledFlag("1");
} else if (!ENABLED_FLAGS.contains(enabled.trim())) {
return "文件导入失败:第 " + rowNo + " 条是否启用无效";
} else {
row.setEnabledFlag(enabled.trim());
}
return null;
}
private static void trimRelationNames(MesXslEquipmentLedger model) {
if (model.getProcessOperationName() != null) {
model.setProcessOperationName(model.getProcessOperationName().trim());
}
if (model.getManufacturerName() != null) {
model.setManufacturerName(model.getManufacturerName().trim());
}
if (model.getEquipmentCategoryName() != null) {
model.setEquipmentCategoryName(model.getEquipmentCategoryName().trim());
}
if (model.getEquipmentTypeName() != null) {
model.setEquipmentTypeName(model.getEquipmentTypeName().trim());
}
if (model.getFactoryName() != null) {
model.setFactoryName(model.getFactoryName().trim());
}
}
//update-end---author:jiangxh ---date:20260518 for【MES】设备台账保存与导入校验-----------
}

View File

@@ -12,8 +12,12 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.util.oConvertUtils;
@@ -32,6 +36,8 @@ import org.jeecg.modules.print.support.PrintServerPdfJobService;
import org.jeecg.modules.print.util.PrintBizDataMappingUtil;
import org.jeecg.modules.xslmes.constant.MesXslPrintConstants;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialCard;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecord;
import org.jeecg.modules.xslmes.mapper.MesXslRawMaterialInspectRecordMapper;
import org.jeecg.modules.xslmes.service.IMesXslRawMaterialCardService;
import org.jeecg.modules.xslmes.service.MesXslStompNotifyService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -72,6 +78,8 @@ public class MesXslRawMaterialCardController extends JeecgController<MesXslRawMa
private IPrintTemplateService printTemplateService;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private MesXslRawMaterialInspectRecordMapper inspectRecordMapper;
/**
* 分页列表查询
@@ -82,8 +90,11 @@ public class MesXslRawMaterialCardController extends JeecgController<MesXslRawMa
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
if (mesXslRawMaterialCard == null) {
mesXslRawMaterialCard = new MesXslRawMaterialCard();
}
// 库区条件:去掉实体上的值避免 QueryGenerator 再拼一班;用 TRIM 与看板聚合一致(避免首尾空格导致「有汇总无明细」)
String rawWarehouseArea = mesXslRawMaterialCard != null ? mesXslRawMaterialCard.getWarehouseArea() : null;
String rawWarehouseArea = mesXslRawMaterialCard.getWarehouseArea();
String areaEq = oConvertUtils.isNotEmpty(rawWarehouseArea) ? rawWarehouseArea.trim() : "";
boolean filterByWarehouseArea = !areaEq.isEmpty();
if (filterByWarehouseArea) {
@@ -114,9 +125,34 @@ public class MesXslRawMaterialCardController extends JeecgController<MesXslRawMa
}
Page<MesXslRawMaterialCard> page = new Page<>(pageNo, pageSize);
IPage<MesXslRawMaterialCard> pageList = mesXslRawMaterialCardService.page(page, queryWrapper);
fillPendingInspectFlag(pageList.getRecords());
return Result.OK(pageList);
}
private void fillPendingInspectFlag(List<MesXslRawMaterialCard> cards) {
if (cards == null || cards.isEmpty()) {
return;
}
Set<String> cardIds = cards.stream()
.map(MesXslRawMaterialCard::getId)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
if (cardIds.isEmpty()) {
return;
}
List<MesXslRawMaterialInspectRecord> pendingList = inspectRecordMapper.selectList(
new QueryWrapper<MesXslRawMaterialInspectRecord>()
.select("raw_material_card_id")
.in("raw_material_card_id", cardIds)
.eq("inspect_status", "0")
.groupBy("raw_material_card_id"));
Set<String> pendingCardIds = pendingList == null ? Collections.emptySet() : pendingList.stream()
.map(MesXslRawMaterialInspectRecord::getRawMaterialCardId)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
cards.forEach(card -> card.setHasPendingInspect(pendingCardIds.contains(card.getId())));
}
/**
* 添加
*/
@@ -228,7 +264,7 @@ public class MesXslRawMaterialCardController extends JeecgController<MesXslRawMa
ArrayNode mapping =
PrintBizDataMappingUtil.parseMappingArray(bind.getFieldMappingJson());
JsonNode bizRoot = objectMapper.valueToTree(card);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping, tpl.getTemplateJson());
PrintBizDataMappingUtil.fillMissingDataBindingParamKeys(printData, tpl.getTemplateJson());
Map<String, Object> out = new HashMap<>(8);
out.put("cardId", card.getId());

View File

@@ -218,7 +218,7 @@ public class MesXslRawMaterialEntryController extends JeecgController<MesXslRawM
}
ArrayNode mapping = PrintBizDataMappingUtil.parseMappingArray(bind.getFieldMappingJson());
JsonNode bizRoot = objectMapper.valueToTree(entry);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping, tpl.getTemplateJson());
PrintBizDataMappingUtil.fillMissingDataBindingParamKeys(printData, tpl.getTemplateJson());
Map<String, Object> out = new HashMap<>(8);
out.put("entryId", entry.getId());

View File

@@ -0,0 +1,115 @@
package org.jeecg.modules.xslmes.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecord;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecordLine;
import org.jeecg.modules.xslmes.service.IMesXslRawMaterialInspectRecordService;
import org.jeecg.modules.xslmes.vo.MesXslRawMaterialInspectRecordPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
@Tag(name = "原材料送检记录")
@RestController
@RequestMapping("/xslmes/mesXslRawMaterialInspectRecord")
public class MesXslRawMaterialInspectRecordController
extends JeecgController<MesXslRawMaterialInspectRecord, IMesXslRawMaterialInspectRecordService> {
@Autowired private IMesXslRawMaterialInspectRecordService inspectRecordService;
@Operation(summary = "原材料送检记录-分页列表查询")
@GetMapping("/list")
public Result<IPage<MesXslRawMaterialInspectRecord>> queryPageList(
MesXslRawMaterialInspectRecord query,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslRawMaterialInspectRecord> queryWrapper =
QueryGenerator.initQueryWrapper(query, req.getParameterMap());
queryWrapper.orderByDesc("inspect_time");
IPage<MesXslRawMaterialInspectRecord> pageList =
inspectRecordService.page(new Page<>(pageNo, pageSize), queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "原材料送检记录-送检")
@Operation(summary = "原材料送检记录-送检(由原材料卡片生成)")
@RequiresPermissions("xslmes:mes_xsl_raw_material_card:edit")
@PostMapping("/createByCard")
public Result<MesXslRawMaterialInspectRecord> createByCard(@RequestBody Map<String, Object> body) {
String rawMaterialCardId =
body.get("rawMaterialCardId") == null ? "" : body.get("rawMaterialCardId").toString();
if (StringUtils.isBlank(rawMaterialCardId)) {
return Result.error("rawMaterialCardId不能为空");
}
MesXslRawMaterialInspectRecord record =
inspectRecordService.createByRawMaterialCardId(rawMaterialCardId.trim());
return Result.OK("送检成功", record);
}
@Operation(summary = "原材料送检记录-通过id查询")
@GetMapping("/queryById")
public Result<MesXslRawMaterialInspectRecord> queryById(@RequestParam(name = "id") String id) {
MesXslRawMaterialInspectRecord db = inspectRecordService.getById(id);
if (db == null) {
return Result.error("未找到对应数据");
}
return Result.OK(db);
}
@Operation(summary = "原材料送检记录-按主表查询子表")
@GetMapping("/queryLineListByRecordId")
public Result<List<MesXslRawMaterialInspectRecordLine>> queryLineListByRecordId(
@RequestParam(name = "id") String id) {
return Result.OK(inspectRecordService.selectLinesByRecordId(id));
}
@AutoLog(value = "原材料送检记录-录入检验结果前加载明细")
@Operation(summary = "原材料送检记录-录入检验结果前加载明细")
@RequiresPermissions("xslmes:mes_xsl_raw_material_inspect_record:edit")
@PostMapping("/prepareResultEntry")
public Result<List<MesXslRawMaterialInspectRecordLine>> prepareResultEntry(
@RequestBody Map<String, Object> body) {
String id = body.get("id") == null ? "" : body.get("id").toString();
if (StringUtils.isBlank(id)) {
return Result.error("id不能为空");
}
return Result.OK(inspectRecordService.prepareResultEntryLines(id.trim()));
}
@AutoLog(value = "原材料送检记录-保存检验结果")
@Operation(summary = "原材料送检记录-保存检验结果")
@RequiresPermissions("xslmes:mes_xsl_raw_material_inspect_record:edit")
@PostMapping("/saveInspectResult")
public Result<String> saveInspectResult(@RequestBody MesXslRawMaterialInspectRecordPage page) {
if (StringUtils.isBlank(page.getId())) {
return Result.error("id不能为空");
}
inspectRecordService.saveInspectResult(page.getId(), page.getLineList());
return Result.OK("保存成功");
}
@RequiresPermissions("xslmes:mes_xsl_raw_material_inspect_record:exportXls")
@RequestMapping("/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslRawMaterialInspectRecord query) {
return super.exportXls(request, query, MesXslRawMaterialInspectRecord.class, "原材料送检记录");
}
}

View File

@@ -0,0 +1,151 @@
package org.jeecg.modules.xslmes.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialSummary;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
/**
* 原材料汇总
*/
@Tag(name = "原材料汇总")
@RestController
@RequestMapping("/xslmes/mesXslRawMaterialSummary")
@Slf4j
public class MesXslRawMaterialSummaryController {
@Autowired
private JdbcTemplate jdbcTemplate;
@Operation(summary = "原材料汇总-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslRawMaterialSummary>> queryPageList(
MesXslRawMaterialSummary query,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
List<Object> params = new ArrayList<>();
String groupedSql = buildGroupedSql(query, params);
String countSql = "SELECT COUNT(1) FROM (" + groupedSql + ") t";
Long total = jdbcTemplate.queryForObject(countSql, Long.class, params.toArray());
long totalCount = total == null ? 0L : total;
int offset = Math.max((pageNo - 1) * pageSize, 0);
String pageSql = groupedSql + " ORDER BY warehouseName, materialName LIMIT ? OFFSET ?";
List<Object> pageParams = new ArrayList<>(params);
pageParams.add(pageSize);
pageParams.add(offset);
List<MesXslRawMaterialSummary> rows = queryRows(pageSql, pageParams);
Page<MesXslRawMaterialSummary> page = new Page<>(pageNo, pageSize, totalCount);
page.setRecords(rows);
return Result.OK(page);
}
@RequiresPermissions("xslmes:mes_xsl_raw_material_summary:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslRawMaterialSummary query) {
List<Object> params = new ArrayList<>();
String groupedSql = buildGroupedSql(query, params) + " ORDER BY warehouseName, materialName";
List<MesXslRawMaterialSummary> exportList = queryRows(groupedSql, params);
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "原材料汇总");
mv.addObject(NormalExcelConstants.CLASS, MesXslRawMaterialSummary.class);
mv.addObject(
NormalExcelConstants.PARAMS,
new ExportParams("原材料汇总报表", "导出人:" + (sysUser == null ? "admin" : sysUser.getRealname()), "原材料汇总", ExcelType.XSSF));
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
String exportFields = request.getParameter(NormalExcelConstants.EXPORT_FIELDS);
if (oConvertUtils.isNotEmpty(exportFields)) {
mv.addObject(NormalExcelConstants.EXPORT_FIELDS, exportFields);
}
return mv;
}
private String buildGroupedSql(MesXslRawMaterialSummary query, List<Object> params) {
String warehouseExpr = "COALESCE(NULLIF(TRIM(i.warehouse_name),''), TRIM(w.warehouse_name))";
String materialNameExpr = "COALESCE(NULLIF(TRIM(i.material_name),''), TRIM(m.material_name))";
String materialCodeExpr = "COALESCE(NULLIF(TRIM(i.material_code),''), TRIM(m.material_code))";
StringBuilder sql = new StringBuilder();
sql.append("SELECT ")
.append(warehouseExpr).append(" AS warehouseName, ")
.append(materialNameExpr).append(" AS materialName, ")
.append(materialCodeExpr).append(" AS materialCode, ")
.append("SUM(COALESCE(i.total_packages,0)) AS totalPackages, ")
.append("SUM(COALESCE(i.total_weight,0)) AS totalWeight ")
.append("FROM mes_xsl_raw_material_inventory i ")
.append("LEFT JOIN mes_xsl_warehouse w ON w.id = i.warehouse_id ")
.append("AND (w.del_flag = 0 OR w.del_flag IS NULL) ")
.append("LEFT JOIN mes_mixer_material m ON m.id = i.material_id ")
.append("AND (m.del_flag = 0 OR m.del_flag IS NULL) ")
// mes_xsl_raw_material_inventory 表当前无 del_flag 字段,这里使用恒真条件避免 SQL 报错
.append("WHERE 1=1 ");
if (query != null && StringUtils.isNotBlank(query.getWarehouseName())) {
sql.append("AND ").append(warehouseExpr).append(" LIKE ? ");
params.add("%" + query.getWarehouseName().trim() + "%");
}
if (query != null && StringUtils.isNotBlank(query.getMaterialName())) {
sql.append("AND ").append(materialNameExpr).append(" LIKE ? ");
params.add("%" + query.getMaterialName().trim() + "%");
}
if (query != null && StringUtils.isNotBlank(query.getMaterialCode())) {
sql.append("AND ").append(materialCodeExpr).append(" LIKE ? ");
params.add("%" + query.getMaterialCode().trim() + "%");
}
sql.append("GROUP BY ")
.append(warehouseExpr).append(", ")
.append(materialNameExpr).append(", ")
.append(materialCodeExpr);
return sql.toString();
}
private List<MesXslRawMaterialSummary> queryRows(String sql, List<Object> params) {
return jdbcTemplate.query(
sql,
rs -> {
List<MesXslRawMaterialSummary> list = new ArrayList<>();
int seq = 1;
while (rs.next()) {
MesXslRawMaterialSummary row = new MesXslRawMaterialSummary();
row.setWarehouseName(trim(rs.getString("warehouseName")));
row.setMaterialName(trim(rs.getString("materialName")));
row.setMaterialCode(trim(rs.getString("materialCode")));
row.setTotalPackages(rs.getBigDecimal("totalPackages"));
row.setTotalWeight(rs.getBigDecimal("totalWeight"));
row.setId(row.getWarehouseName() + "_" + row.getMaterialCode() + "_" + seq++);
list.add(row);
}
return list;
},
params.toArray());
}
private String trim(String v) {
return v == null ? "" : v.trim();
}
}

View File

@@ -72,9 +72,9 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
String seq = String.format("%03d", new Random().nextInt(1000));
mesXslWeightRecord.setBillNo("BDH-" + dateStr + seq);
}
computeBillType(mesXslWeightRecord);
applyMaterialTypeDefault(mesXslWeightRecord);
computeNetWeight(mesXslWeightRecord);
computeBillType(mesXslWeightRecord);
mesXslWeightRecordService.save(mesXslWeightRecord);
stompNotifyService.publishWeightRecordChanged("add", mesXslWeightRecord.getId());
return Result.OK("添加成功!");
@@ -85,9 +85,9 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
@RequiresPermissions("xslmes:mes_xsl_weight_record:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslWeightRecord mesXslWeightRecord) {
computeBillType(mesXslWeightRecord);
applyMaterialTypeDefault(mesXslWeightRecord);
computeNetWeight(mesXslWeightRecord);
computeBillType(mesXslWeightRecord);
mesXslWeightRecordService.updateById(mesXslWeightRecord);
stompNotifyService.publishWeightRecordChanged("edit", mesXslWeightRecord.getId());
return Result.OK("编辑成功!");
@@ -137,26 +137,47 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
}
private void computeNetWeight(MesXslWeightRecord record) {
sanitizeNonPositiveWeightsToNull(record);
BigDecimal gross = record.getGrossWeight();
BigDecimal tare = record.getTareWeight();
if (gross != null && tare != null) {
if (isEffectiveWeight(gross) && isEffectiveWeight(tare)) {
BigDecimal net = gross.subtract(tare);
record.setNetWeight(net.compareTo(BigDecimal.ZERO) >= 0 ? net : BigDecimal.ZERO);
} else {
record.setNetWeight(null);
}
}
private void computeBillType(MesXslWeightRecord record) {
if (record.getGrossWeight() != null && record.getTareWeight() != null) {
boolean g = isEffectiveWeight(record.getGrossWeight());
boolean t = isEffectiveWeight(record.getTareWeight());
if (g && t) {
record.setBillType("2");
return;
}
if (record.getGrossWeight() != null) {
if (g) {
record.setBillType("1");
return;
}
if (record.getTareWeight() != null) {
if (t) {
record.setBillType("3");
return;
}
record.setBillType(null);
}
/** 将 ≤0 的重量视为未录入,避免占位 0 误判称重完成 */
private static void sanitizeNonPositiveWeightsToNull(MesXslWeightRecord record) {
if (record.getGrossWeight() != null && record.getGrossWeight().compareTo(BigDecimal.ZERO) <= 0) {
record.setGrossWeight(null);
}
if (record.getTareWeight() != null && record.getTareWeight().compareTo(BigDecimal.ZERO) <= 0) {
record.setTareWeight(null);
}
}
private static boolean isEffectiveWeight(BigDecimal w) {
return w != null && w.compareTo(BigDecimal.ZERO) > 0;
}
private void applyMaterialTypeDefault(MesXslWeightRecord record) {

View File

@@ -0,0 +1,74 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 停机主类型(表 mes_xsl_downtime_main_type
*/
@Data
@TableName("mes_xsl_downtime_main_type")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES停机主类型")
public class MesXslDowntimeMainType implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Schema(description = "所属工序主键")
private String processOperationId;
@Excel(name = "工序名称", width = 24)
@Schema(description = "工序名称冗余")
private String processOperationName;
@Excel(name = "停机类型", width = 24)
@Schema(description = "停机类型(同租户未删除数据中唯一)")
private String downtimeType;
@Excel(name = "显示顺序", width = 12)
@Schema(description = "显示顺序(升序)")
private Integer displayOrder;
@Excel(name = "区分颜色", width = 16)
@Schema(description = "区分颜色(十六进制色值)")
private String distinguishColor;
@Excel(name = "是否启用", width = 12, dicCode = "xslmes_downtime_main_type_status")
@Dict(dicCode = "xslmes_downtime_main_type_status")
@Schema(description = "是否启用(字典 xslmes_downtime_main_type_status0启用1停用")
private String status;
/** Excel 导入用:工序编码,不落库 */
@TableField(exist = false)
@Excel(name = "工序编码", width = 18)
@Schema(description = "导入用工序编码")
private String importOperationCode;
private Integer tenantId;
private String sysOrgCode;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private Integer delFlag;
}

View File

@@ -0,0 +1,98 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 停机类型(表 mes_xsl_downtime_type
*/
@Data
@TableName("mes_xsl_downtime_type")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES停机类型")
public class MesXslDowntimeType implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Schema(description = "所属工序主键")
private String processOperationId;
@Excel(name = "工序名称", width = 24)
@Schema(description = "工序名称冗余")
private String processOperationName;
@Schema(description = "所属停机主类型主键")
private String downtimeMainTypeId;
@Excel(name = "所属主类型", width = 24)
@Schema(description = "主类型名称冗余")
private String downtimeMainTypeName;
@Excel(name = "停机类型", width = 24)
@Schema(description = "停机类型(同租户未删除数据中唯一)")
private String downtimeType;
@Excel(name = "显示顺序", width = 12)
@Schema(description = "显示顺序(升序,必填)")
private Integer displayOrder;
@Excel(name = "区分颜色", width = 16)
@Schema(description = "区分颜色(十六进制色值)")
private String distinguishColor;
@Excel(name = "责任区分", width = 20)
@Schema(description = "责任区分(手填)")
private String responsibilityDistinct;
@Excel(name = "故障等级", width = 16)
@Schema(description = "故障等级(手填)")
private String faultLevel;
@Excel(name = "是否停机维修", width = 14, dicCode = "yn")
@Dict(dicCode = "yn")
@Schema(description = "是否停机维修(字典 yn1是0否")
private String downtimeMaintenance;
@Excel(name = "是否启用", width = 12, dicCode = "xslmes_downtime_type_status")
@Dict(dicCode = "xslmes_downtime_type_status")
@Schema(description = "是否启用(字典 xslmes_downtime_type_status0启用1停用")
private String status;
@TableField(exist = false)
@Excel(name = "工序编码", width = 18)
@Schema(description = "导入用工序编码")
private String importOperationCode;
@TableField(exist = false)
@Excel(name = "主类型名称", width = 24)
@Schema(description = "导入用停机主类型名称")
private String importMainTypeName;
private Integer tenantId;
private String sysOrgCode;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private Integer delFlag;
}

View File

@@ -0,0 +1,168 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 设备台账(表 mes_xsl_equipment_ledger
*/
@Data
@TableName("mes_xsl_equipment_ledger")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES设备台账")
public class MesXslEquipmentLedger implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Schema(description = "所属工序主键")
private String processOperationId;
@Excel(name = "工序名称", width = 20)
@Schema(description = "工序名称冗余")
private String processOperationName;
@Excel(name = "设备名称", width = 22)
@Schema(description = "设备名称(同租户未删除数据中唯一)")
private String equipmentName;
@Excel(name = "设备编号", width = 18)
@Schema(description = "设备编号(同租户未删除数据中唯一)")
private String equipmentCode;
@Schema(description = "所属设备厂家主键")
private String manufacturerId;
@Excel(name = "设备厂家", width = 20)
@Schema(description = "设备厂家名称冗余")
private String manufacturerName;
@Schema(description = "设备类别主键")
private String equipmentCategoryId;
@Excel(name = "设备类别", width = 16)
@Schema(description = "设备类别名称冗余")
private String equipmentCategoryName;
@Schema(description = "设备类型主键")
private String equipmentTypeId;
@Excel(name = "设备类型", width = 16)
@Schema(description = "设备类型名称冗余")
private String equipmentTypeName;
@Schema(description = "所属工厂主键(厂家信息)")
private String factoryId;
@Excel(name = "所属工厂", width = 20)
@Schema(description = "所属工厂名称冗余")
private String factoryName;
@Excel(name = "设备型号", width = 16)
@Schema(description = "设备型号")
private String equipmentModel;
@Excel(name = "设备状态", width = 12, dicCode = "xslmes_equipment_ledger_status")
@Dict(dicCode = "xslmes_equipment_ledger_status")
@Schema(description = "设备状态(字典:在用/停用/报废)")
private String equipmentStatus;
@Excel(name = "序列号", width = 18)
@Schema(description = "序列号")
private String serialNo;
@Excel(name = "铭牌", width = 18)
@Schema(description = "铭牌")
private String nameplate;
@Excel(name = "维修部门", width = 16, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Schema(description = "维修部门主键")
private String maintainDeptId;
@Excel(name = "维修人员", width = 12)
@Schema(description = "维修人员")
private String maintainPerson;
@Excel(name = "主管部门", width = 16, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Schema(description = "主管部门主键")
private String manageDeptId;
@Excel(name = "资料文件编号", width = 18)
@Schema(description = "资料文件编号")
private String docFileNo;
@Excel(name = "生产日期", width = 14, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Schema(description = "生产日期")
private Date productionDate;
@Excel(name = "购买日期", width = 14, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Schema(description = "购买日期")
private Date purchaseDate;
@Excel(name = "使用日期", width = 14, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Schema(description = "使用日期")
private Date useDate;
@Excel(name = "厂商联系人", width = 14)
@Schema(description = "厂商联系人")
private String vendorContact;
@Excel(name = "价值", width = 14)
@Schema(description = "价值")
private String assetValue;
@Excel(name = "受控PDA", width = 14)
@Schema(description = "受控PDA")
private String controlledPda;
@Excel(name = "超产比率", width = 12)
@Schema(description = "超产比率")
private String overproductionRatio;
@Excel(name = "有效体积", width = 12)
@Schema(description = "有效体积")
private String effectiveVolume;
@Excel(name = "是否启用", width = 10, dicCode = "yn")
@Dict(dicCode = "yn")
@Schema(description = "是否启用字典yn1是0否")
private String enabledFlag;
@Excel(name = "设备描述", width = 30)
@Schema(description = "设备描述")
private String equipmentDesc;
private Integer tenantId;
private String sysOrgCode;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private Integer delFlag;
}

View File

@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@@ -138,4 +139,8 @@ public class MesXslRawMaterialCard implements Serializable {
@Schema(description = "租户ID")
private Integer tenantId;
@TableField(exist = false)
@Schema(description = "是否存在待检送检记录(前端控制送检按钮显隐)")
private Boolean hasPendingInspect;
}

View File

@@ -0,0 +1,91 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
@Data
@TableName("mes_xsl_raw_material_inspect_record")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "原材料送检记录")
public class MesXslRawMaterialInspectRecord implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
@Schema(description = "原材料卡片ID")
private String rawMaterialCardId;
@Excel(name = "条码", width = 20)
@Schema(description = "条码")
private String barcode;
@Excel(name = "批次号", width = 20)
@Schema(description = "批次号")
private String batchNo;
@Schema(description = "物料ID")
private String materialId;
@Excel(name = "物料名称", width = 20)
@Schema(description = "物料名称")
private String materialName;
@Excel(name = "检验状态", width = 12, dicCode = "xslmes_inspect_status")
@Dict(dicCode = "xslmes_inspect_status")
@Schema(description = "检验状态xslmes_inspect_status0待检 1合格 2不合格")
private String inspectStatus;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "送检时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "送检时间")
private Date inspectTime;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "判定时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "判定时间")
private Date resultTime;
@Schema(description = "备注")
private String remark;
@Schema(description = "创建人")
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间")
private Date createTime;
@Schema(description = "更新人")
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新时间")
private Date updateTime;
@Schema(description = "租户ID")
private Integer tenantId;
@TableField(exist = false)
@Schema(description = "送检明细")
private List<MesXslRawMaterialInspectRecordLine> lineList;
}

View File

@@ -0,0 +1,73 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.springframework.format.annotation.DateTimeFormat;
@Data
@TableName("mes_xsl_raw_material_inspect_record_line")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "原材料送检记录-检验明细")
public class MesXslRawMaterialInspectRecordLine implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Schema(description = "送检记录主表ID")
private String recordId;
@Schema(description = "检验标准ID")
private String inspectStdId;
@Schema(description = "检验项目ID")
private String inspectItemId;
@Schema(description = "检验项目名称")
private String inspectItemName;
@Schema(description = "容许最小值")
private BigDecimal allowMin;
@Schema(description = "包含最小值 1是 0否")
private Integer includeMinFlag;
@Schema(description = "容许最大值")
private BigDecimal allowMax;
@Schema(description = "包含最大值 1是 0否")
private Integer includeMaxFlag;
@Schema(description = "检验值")
private BigDecimal inspectValue;
@Dict(dicCode = "xslmes_inspect_status")
@Schema(description = "明细判定状态xslmes_inspect_status0待检 1合格 2不合格")
private String passFlag;
@Schema(description = "排序")
private Integer sortNo;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}

View File

@@ -0,0 +1,40 @@
package org.jeecg.modules.xslmes.entity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* 原材料汇总(按仓库+物料)
*/
@Data
@Schema(description = "原材料汇总")
public class MesXslRawMaterialSummary implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "主键")
private String id;
@Excel(name = "所在仓库", width = 20)
@Schema(description = "所在仓库")
private String warehouseName;
@Excel(name = "物料名称", width = 20)
@Schema(description = "物料名称")
private String materialName;
@Excel(name = "物料编码", width = 20)
@Schema(description = "物料编码")
private String materialCode;
@Excel(name = "总包数", width = 15)
@Schema(description = "总包数")
private BigDecimal totalPackages;
@Excel(name = "总重量", width = 15)
@Schema(description = "总重量")
private BigDecimal totalWeight;
}

View File

@@ -0,0 +1,9 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType;
/**
* MES 停机主类型
*/
public interface MesXslDowntimeMainTypeMapper extends BaseMapper<MesXslDowntimeMainType> {}

View File

@@ -0,0 +1,9 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeType;
/**
* MES 停机类型
*/
public interface MesXslDowntimeTypeMapper extends BaseMapper<MesXslDowntimeType> {}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
public interface MesXslEquipmentLedgerMapper extends BaseMapper<MesXslEquipmentLedger> {}

View File

@@ -0,0 +1,7 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecordLine;
public interface MesXslRawMaterialInspectRecordLineMapper
extends BaseMapper<MesXslRawMaterialInspectRecordLine> {}

View File

@@ -0,0 +1,7 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecord;
public interface MesXslRawMaterialInspectRecordMapper
extends BaseMapper<MesXslRawMaterialInspectRecord> {}

View File

@@ -1,5 +1,5 @@
/**
* MES XSL 业务模块Maven 工程名jeecg-module-xslmes
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})等。
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备台账({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer}、停机主类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType})、停机类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeType}等。
*/
package org.jeecg.modules.xslmes;

View File

@@ -0,0 +1,16 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType;
public interface IMesXslDowntimeMainTypeService extends IService<MesXslDowntimeMainType> {
/**
* 停机类型是否已被占用仅统计未删除del_flag 为 0 或 null。租户与拦截器注入逻辑一致。
*
* @param downtimeType 停机类型(已 trim 后传入)
* @param excludeId 编辑时排除自身主键,新增传 null
* @param context 当前提交的实体(可取 tenantId可为 null
*/
boolean isDowntimeTypeDuplicated(String downtimeType, String excludeId, MesXslDowntimeMainType context);
}

View File

@@ -0,0 +1,12 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeType;
public interface IMesXslDowntimeTypeService extends IService<MesXslDowntimeType> {
/**
* 停机类型名称是否已被占用仅统计未删除del_flag 为 0 或 null。租户与拦截器注入逻辑一致。
*/
boolean isDowntimeTypeDuplicated(String downtimeType, String excludeId, MesXslDowntimeType context);
}

View File

@@ -0,0 +1,11 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
public interface IMesXslEquipmentLedgerService extends IService<MesXslEquipmentLedger> {
boolean isEquipmentCodeDuplicated(String equipmentCode, String excludeId, MesXslEquipmentLedger context);
boolean isEquipmentNameDuplicated(String equipmentName, String excludeId, MesXslEquipmentLedger context);
}

View File

@@ -0,0 +1,26 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.math.BigDecimal;
import java.util.List;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecord;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecordLine;
public interface IMesXslRawMaterialInspectRecordService
extends IService<MesXslRawMaterialInspectRecord> {
MesXslRawMaterialInspectRecord createByRawMaterialCardId(String rawMaterialCardId);
List<MesXslRawMaterialInspectRecordLine> selectLinesByRecordId(String recordId);
List<MesXslRawMaterialInspectRecordLine> prepareResultEntryLines(String recordId);
void saveInspectResult(String recordId, List<MesXslRawMaterialInspectRecordLine> lineList);
String evaluatePassFlag(
BigDecimal inspectValue,
BigDecimal allowMin,
Integer includeMinFlag,
BigDecimal allowMax,
Integer includeMaxFlag);
}

View File

@@ -0,0 +1,63 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType;
import org.jeecg.modules.xslmes.mapper.MesXslDowntimeMainTypeMapper;
import org.jeecg.modules.xslmes.service.IMesXslDowntimeMainTypeService;
import org.springframework.stereotype.Service;
@Service
public class MesXslDowntimeMainTypeServiceImpl extends ServiceImpl<MesXslDowntimeMainTypeMapper, MesXslDowntimeMainType>
implements IMesXslDowntimeMainTypeService {
//update-begin---author:jiangxh ---date:20260518 for【MES】停机类型同租户不可重复仅统计未删除del_flag=0 或 null-----------
@Override
public boolean isDowntimeTypeDuplicated(String downtimeType, String excludeId, MesXslDowntimeMainType context) {
if (oConvertUtils.isEmpty(downtimeType)) {
return false;
}
Integer tenantId = resolveTenantId(context);
LambdaQueryWrapper<MesXslDowntimeMainType> w = new LambdaQueryWrapper<>();
w.eq(MesXslDowntimeMainType::getDowntimeType, downtimeType.trim());
w.and(
q ->
q.eq(MesXslDowntimeMainType::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslDowntimeMainType::getDelFlag));
if (oConvertUtils.isNotEmpty(excludeId)) {
w.ne(MesXslDowntimeMainType::getId, excludeId);
}
if (tenantId != null) {
w.eq(MesXslDowntimeMainType::getTenantId, tenantId);
}
return this.count(w) > 0;
}
private static Integer resolveTenantId(MesXslDowntimeMainType context) {
if (context != null && context.getTenantId() != null) {
return context.getTenantId();
}
String ts = TenantContext.getTenant();
if (oConvertUtils.isEmpty(ts)) {
try {
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
} catch (Exception ignored) {
}
}
if (oConvertUtils.isEmpty(ts)) {
return null;
}
try {
return Integer.parseInt(ts.trim());
} catch (NumberFormatException e) {
return null;
}
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机类型同租户不可重复仅统计未删除del_flag=0 或 null-----------
}

View File

@@ -0,0 +1,63 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslDowntimeType;
import org.jeecg.modules.xslmes.mapper.MesXslDowntimeTypeMapper;
import org.jeecg.modules.xslmes.service.IMesXslDowntimeTypeService;
import org.springframework.stereotype.Service;
@Service
public class MesXslDowntimeTypeServiceImpl extends ServiceImpl<MesXslDowntimeTypeMapper, MesXslDowntimeType>
implements IMesXslDowntimeTypeService {
//update-begin---author:jiangxh ---date:20260518 for【MES】停机类型名称同租户不可重复仅统计未删除del_flag=0 或 null-----------
@Override
public boolean isDowntimeTypeDuplicated(String downtimeType, String excludeId, MesXslDowntimeType context) {
if (oConvertUtils.isEmpty(downtimeType)) {
return false;
}
Integer tenantId = resolveTenantId(context);
LambdaQueryWrapper<MesXslDowntimeType> w = new LambdaQueryWrapper<>();
w.eq(MesXslDowntimeType::getDowntimeType, downtimeType.trim());
w.and(
q ->
q.eq(MesXslDowntimeType::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslDowntimeType::getDelFlag));
if (oConvertUtils.isNotEmpty(excludeId)) {
w.ne(MesXslDowntimeType::getId, excludeId);
}
if (tenantId != null) {
w.eq(MesXslDowntimeType::getTenantId, tenantId);
}
return this.count(w) > 0;
}
private static Integer resolveTenantId(MesXslDowntimeType context) {
if (context != null && context.getTenantId() != null) {
return context.getTenantId();
}
String ts = TenantContext.getTenant();
if (oConvertUtils.isEmpty(ts)) {
try {
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
} catch (Exception ignored) {
}
}
if (oConvertUtils.isEmpty(ts)) {
return null;
}
try {
return Integer.parseInt(ts.trim());
} catch (NumberFormatException e) {
return null;
}
}
//update-end---author:jiangxh ---date:20260518 for【MES】停机类型名称同租户不可重复仅统计未删除del_flag=0 或 null-----------
}

View File

@@ -0,0 +1,72 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentLedgerMapper;
import org.jeecg.modules.xslmes.service.IMesXslEquipmentLedgerService;
import org.springframework.stereotype.Service;
@Service
public class MesXslEquipmentLedgerServiceImpl extends ServiceImpl<MesXslEquipmentLedgerMapper, MesXslEquipmentLedger>
implements IMesXslEquipmentLedgerService {
//update-begin---author:jiangxh ---date:20260518 for【MES】设备台账编号、名称同租户不可重复-----------
@Override
public boolean isEquipmentCodeDuplicated(String equipmentCode, String excludeId, MesXslEquipmentLedger context) {
return isFieldDuplicated(MesXslEquipmentLedger::getEquipmentCode, equipmentCode, excludeId, context);
}
@Override
public boolean isEquipmentNameDuplicated(String equipmentName, String excludeId, MesXslEquipmentLedger context) {
return isFieldDuplicated(MesXslEquipmentLedger::getEquipmentName, equipmentName, excludeId, context);
}
private boolean isFieldDuplicated(
com.baomidou.mybatisplus.core.toolkit.support.SFunction<MesXslEquipmentLedger, String> column,
String value,
String excludeId,
MesXslEquipmentLedger context) {
if (oConvertUtils.isEmpty(value)) {
return false;
}
Integer tenantId = resolveTenantId(context);
LambdaQueryWrapper<MesXslEquipmentLedger> w = new LambdaQueryWrapper<>();
w.eq(column, value.trim());
w.and(q -> q.eq(MesXslEquipmentLedger::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesXslEquipmentLedger::getDelFlag));
if (oConvertUtils.isNotEmpty(excludeId)) {
w.ne(MesXslEquipmentLedger::getId, excludeId);
}
if (tenantId != null) {
w.eq(MesXslEquipmentLedger::getTenantId, tenantId);
}
return this.count(w) > 0;
}
private static Integer resolveTenantId(MesXslEquipmentLedger context) {
if (context != null && context.getTenantId() != null) {
return context.getTenantId();
}
String ts = TenantContext.getTenant();
if (oConvertUtils.isEmpty(ts)) {
try {
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
} catch (Exception ignored) {
}
}
if (oConvertUtils.isEmpty(ts)) {
return null;
}
try {
return Integer.parseInt(ts.trim());
} catch (NumberFormatException e) {
return null;
}
}
//update-end---author:jiangxh ---date:20260518 for【MES】设备台账编号、名称同租户不可重复-----------
}

View File

@@ -0,0 +1,302 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.mes.material.entity.MesMaterial;
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStdLine;
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
import org.jeecg.modules.mes.material.mapper.MesMixerMaterialMapper;
import org.jeecg.modules.mes.material.mapper.MesRawMaterialInspectStdLineMapper;
import org.jeecg.modules.mes.material.mapper.MesRawMaterialInspectStdMapper;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialCard;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecord;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecordLine;
import org.jeecg.modules.xslmes.mapper.MesXslRawMaterialInspectRecordLineMapper;
import org.jeecg.modules.xslmes.mapper.MesXslRawMaterialInspectRecordMapper;
import org.jeecg.modules.xslmes.service.IMesXslRawMaterialCardService;
import org.jeecg.modules.xslmes.service.IMesXslRawMaterialInspectRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Slf4j
public class MesXslRawMaterialInspectRecordServiceImpl
extends ServiceImpl<MesXslRawMaterialInspectRecordMapper, MesXslRawMaterialInspectRecord>
implements IMesXslRawMaterialInspectRecordService {
private static final String CARD_TEST_RESULT_UNTESTED = "0";
private static final String CARD_TEST_RESULT_PASS = "1";
private static final String CARD_TEST_RESULT_FAIL = "2";
private static final String STATUS_PENDING = "0";
private static final String STATUS_PASS = "1";
private static final String STATUS_FAIL = "2";
@Autowired private IMesXslRawMaterialCardService rawMaterialCardService;
@Autowired private MesXslRawMaterialInspectRecordLineMapper recordLineMapper;
@Autowired private MesMaterialMapper mesMaterialMapper;
@Autowired private MesMixerMaterialMapper mesMixerMaterialMapper;
@Autowired private MesRawMaterialInspectStdMapper inspectStdMapper;
@Autowired private MesRawMaterialInspectStdLineMapper inspectStdLineMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public MesXslRawMaterialInspectRecord createByRawMaterialCardId(String rawMaterialCardId) {
MesXslRawMaterialCard card = rawMaterialCardService.getById(rawMaterialCardId);
if (card == null) {
throw new JeecgBootException("未找到原材料卡片");
}
long pendingCount =
this.lambdaQuery()
.eq(MesXslRawMaterialInspectRecord::getRawMaterialCardId, rawMaterialCardId)
.eq(MesXslRawMaterialInspectRecord::getInspectStatus, STATUS_PENDING)
.count();
if (pendingCount > 0) {
throw new JeecgBootException("该原材料卡片已存在待检送检记录,不能重复送检");
}
String cardTestResult = normalize(card.getTestResult());
if (StringUtils.isNotBlank(cardTestResult) && !CARD_TEST_RESULT_UNTESTED.equals(cardTestResult)) {
throw new JeecgBootException("仅未检状态的原材料卡片允许送检");
}
MesXslRawMaterialInspectRecord entity = new MesXslRawMaterialInspectRecord();
entity.setRawMaterialCardId(card.getId());
entity.setBarcode(card.getBarcode());
entity.setBatchNo(card.getBatchNo());
entity.setMaterialId(card.getMaterialId());
entity.setMaterialName(card.getMaterialName());
entity.setInspectStatus(STATUS_PENDING);
entity.setInspectTime(new Date());
this.save(entity);
// 送检后将卡片检测结果置为待检
MesXslRawMaterialCard updateCard = new MesXslRawMaterialCard();
updateCard.setId(card.getId());
updateCard.setTestResult(CARD_TEST_RESULT_UNTESTED);
rawMaterialCardService.updateById(updateCard);
return entity;
}
@Override
public List<MesXslRawMaterialInspectRecordLine> selectLinesByRecordId(String recordId) {
return recordLineMapper.selectList(
new LambdaQueryWrapper<MesXslRawMaterialInspectRecordLine>()
.eq(MesXslRawMaterialInspectRecordLine::getRecordId, recordId)
.orderByAsc(MesXslRawMaterialInspectRecordLine::getSortNo));
}
@Override
@Transactional(rollbackFor = Exception.class)
public List<MesXslRawMaterialInspectRecordLine> prepareResultEntryLines(String recordId) {
MesXslRawMaterialInspectRecord record = this.getById(recordId);
if (record == null) {
throw new JeecgBootException("送检记录不存在");
}
List<MesXslRawMaterialInspectRecordLine> current = selectLinesByRecordId(recordId);
if (!current.isEmpty()) {
return current;
}
MesRawMaterialInspectStd std = resolveEnableInspectStd(record.getMaterialId(), record.getMaterialName());
if (std == null) {
throw new JeecgBootException("未找到已启用的原材料检验标准,请先维护并启用检验标准");
}
List<MesRawMaterialInspectStdLine> stdLines =
inspectStdLineMapper.selectList(
new LambdaQueryWrapper<MesRawMaterialInspectStdLine>()
.eq(MesRawMaterialInspectStdLine::getStdId, std.getId())
.orderByAsc(MesRawMaterialInspectStdLine::getSortNo));
if (stdLines.isEmpty()) {
throw new JeecgBootException("当前检验标准未配置明细检验项目");
}
int sortNo = 0;
List<MesXslRawMaterialInspectRecordLine> out = new ArrayList<>(stdLines.size());
for (MesRawMaterialInspectStdLine stdLine : stdLines) {
MesXslRawMaterialInspectRecordLine line = new MesXslRawMaterialInspectRecordLine();
line.setRecordId(recordId);
line.setInspectStdId(std.getId());
line.setInspectItemId(stdLine.getInspectItemId());
line.setInspectItemName(stdLine.getInspectItemName());
line.setAllowMin(stdLine.getAllowMin());
line.setIncludeMinFlag(stdLine.getIncludeMinFlag() == null ? 0 : stdLine.getIncludeMinFlag());
line.setAllowMax(stdLine.getAllowMax());
line.setIncludeMaxFlag(stdLine.getIncludeMaxFlag() == null ? 0 : stdLine.getIncludeMaxFlag());
line.setPassFlag(STATUS_PENDING);
line.setSortNo(sortNo++);
recordLineMapper.insert(line);
out.add(line);
}
return out;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveInspectResult(String recordId, List<MesXslRawMaterialInspectRecordLine> lineList) {
MesXslRawMaterialInspectRecord record = this.getById(recordId);
if (record == null) {
throw new JeecgBootException("送检记录不存在");
}
if (lineList == null || lineList.isEmpty()) {
throw new JeecgBootException("请至少录入一条检验结果");
}
boolean allPass = true;
for (MesXslRawMaterialInspectRecordLine line : lineList) {
if (StringUtils.isBlank(line.getId())) {
throw new JeecgBootException("明细ID不能为空请刷新后重试");
}
MesXslRawMaterialInspectRecordLine dbLine = recordLineMapper.selectById(line.getId());
if (dbLine == null || !recordId.equals(dbLine.getRecordId())) {
throw new JeecgBootException("明细不存在或不属于当前送检记录");
}
String passFlag =
evaluatePassFlag(
line.getInspectValue(),
dbLine.getAllowMin(),
dbLine.getIncludeMinFlag(),
dbLine.getAllowMax(),
dbLine.getIncludeMaxFlag());
dbLine.setInspectValue(line.getInspectValue());
dbLine.setPassFlag(passFlag);
recordLineMapper.updateById(dbLine);
if (!STATUS_PASS.equals(passFlag)) {
allPass = false;
}
}
record.setInspectStatus(allPass ? STATUS_PASS : STATUS_FAIL);
record.setResultTime(new Date());
this.updateById(record);
// 判定完成后回写原材料卡片检测结果
if (StringUtils.isNotBlank(record.getRawMaterialCardId())) {
MesXslRawMaterialCard card = new MesXslRawMaterialCard();
card.setId(record.getRawMaterialCardId());
card.setTestResult(allPass ? CARD_TEST_RESULT_PASS : CARD_TEST_RESULT_FAIL);
rawMaterialCardService.updateById(card);
}
}
@Override
public String evaluatePassFlag(
BigDecimal inspectValue,
BigDecimal allowMin,
Integer includeMinFlag,
BigDecimal allowMax,
Integer includeMaxFlag) {
if (inspectValue == null) {
return STATUS_FAIL;
}
if (allowMin != null) {
int cmpMin = inspectValue.compareTo(allowMin);
boolean includeMin = includeMinFlag != null && includeMinFlag == 1;
if (includeMin ? cmpMin < 0 : cmpMin <= 0) {
return STATUS_FAIL;
}
}
if (allowMax != null) {
int cmpMax = inspectValue.compareTo(allowMax);
boolean includeMax = includeMaxFlag != null && includeMaxFlag == 1;
if (includeMax ? cmpMax > 0 : cmpMax >= 0) {
return STATUS_FAIL;
}
}
return STATUS_PASS;
}
private MesRawMaterialInspectStd resolveEnableInspectStd(String materialId, String materialName) {
String normalizedMaterialId = normalize(materialId);
if (StringUtils.isBlank(normalizedMaterialId)) {
log.warn("送检标准匹配失败送检记录物料ID为空materialName={}", materialName);
return null;
}
List<MesRawMaterialInspectStd> allStds =
inspectStdMapper.selectList(
new LambdaQueryWrapper<MesRawMaterialInspectStd>()
.and(
w ->
w.eq(MesRawMaterialInspectStd::getDelFlag, 0)
.or()
.isNull(MesRawMaterialInspectStd::getDelFlag))
.orderByDesc(MesRawMaterialInspectStd::getEnableFlag)
.orderByDesc(MesRawMaterialInspectStd::getEffectiveDate)
.orderByDesc(MesRawMaterialInspectStd::getCreateTime));
if (allStds.isEmpty()) {
log.warn("送检标准匹配失败没有可用检验标准materialId={}", materialId);
return null;
}
String mappedMixerMaterialId = mapMaterialIdToMixerMaterialId(normalizedMaterialId);
// 第一优先级:仅在启用标准中匹配
MesRawMaterialInspectStd matchedEnabled = matchByMaterialId(allStds, normalizedMaterialId, mappedMixerMaterialId, true);
if (matchedEnabled != null) {
return matchedEnabled;
}
// 第二优先级:若未启用标准,则回退到同物料最新标准(避免业务无法录入)
MesRawMaterialInspectStd matchedAny = matchByMaterialId(allStds, normalizedMaterialId, mappedMixerMaterialId, false);
if (matchedAny != null) {
log.warn(
"送检标准未找到启用版本,已回退到未启用标准 stdId={}, materialId={}, mappedMixerMaterialId={}, enableFlag={}",
matchedAny.getId(),
materialId,
mappedMixerMaterialId,
matchedAny.getEnableFlag());
return matchedAny;
}
log.warn(
"送检标准匹配失败仅物料ID匹配materialId={}, mappedMixerMaterialId={}, materialName={}, stdCount={}",
materialId,
mappedMixerMaterialId,
materialName,
allStds.size());
return null;
}
private MesRawMaterialInspectStd matchByMaterialId(
List<MesRawMaterialInspectStd> standards,
String normalizedMaterialId,
String mappedMixerMaterialId,
boolean onlyEnabled) {
for (MesRawMaterialInspectStd std : standards) {
if (onlyEnabled && !Objects.equals(std.getEnableFlag(), 1)) {
continue;
}
String stdMaterialId = normalize(std.getMixerMaterialId());
if (Objects.equals(normalizedMaterialId, stdMaterialId)) {
return std;
}
if (StringUtils.isNotBlank(mappedMixerMaterialId) && Objects.equals(mappedMixerMaterialId, stdMaterialId)) {
return std;
}
}
return null;
}
private String mapMaterialIdToMixerMaterialId(String materialId) {
MesMaterial material = mesMaterialMapper.selectById(materialId);
if (material == null || StringUtils.isBlank(material.getMaterialCode())) {
return null;
}
MesMixerMaterial mixerMaterial =
mesMixerMaterialMapper.selectOne(
new LambdaQueryWrapper<MesMixerMaterial>()
.eq(MesMixerMaterial::getMaterialCode, StringUtils.trimToEmpty(material.getMaterialCode()))
.last("LIMIT 1"));
return mixerMaterial == null ? null : normalize(mixerMaterial.getId());
}
private String normalize(String value) {
return StringUtils.trimToEmpty(value);
}
}

View File

@@ -0,0 +1,10 @@
package org.jeecg.modules.xslmes.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialInspectRecord;
/** 原材料送检记录主子表保存页。 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MesXslRawMaterialInspectRecordPage extends MesXslRawMaterialInspectRecord {}

View File

@@ -195,3 +195,117 @@ jeecgboot-vue3/src/views/xslmes/mesXslManufacturer/MesXslManufacturerList.vue
jeecgboot-vue3/src/views/xslmes/mesXslManufacturer/MesXslManufacturer.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslManufacturer/MesXslManufacturer.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslManufacturer/components/MesXslManufacturerModal.vue
-- author:jiangxh---date:20260518--for: 【MES】停机主类型所属工序、停机类型唯一、显示顺序、区分颜色、是否启用 ---
jeecg-boot/db/mes-xsl-downtime-main-type-menu-permission.sql
jeecg-boot/db/mes-xsl-downtime-main-type.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_64__mes_xsl_downtime_main_type.sql
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslDowntimeMainType.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslDowntimeMainTypeMapper.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslDowntimeMainTypeService.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslDowntimeMainTypeServiceImpl.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDowntimeMainTypeController.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeMainType/MesXslDowntimeMainTypeList.vue
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeMainType/MesXslDowntimeMainType.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeMainType/MesXslDowntimeMainType.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeMainType/components/MesXslDowntimeMainTypeModal.vue
-- author:jiangxh---date:20260518--for: 【MES】停机类型工序+主类型+停机类型、责任区分、故障等级、停机维修、色卡) ---
jeecg-boot/db/mes-xsl-downtime-type-menu-permission.sql
jeecg-boot/db/mes-xsl-downtime-type.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_65__mes_xsl_downtime_type.sql
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslDowntimeType.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslDowntimeTypeMapper.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslDowntimeTypeService.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslDowntimeTypeServiceImpl.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDowntimeTypeController.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeType/MesXslDowntimeTypeList.vue
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeType/MesXslDowntimeType.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeType/MesXslDowntimeType.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeType/components/MesXslDowntimeTypeModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeType/components/MesXslDowntimeMainTypeSelectModal.vue
-- author:jiangxh---date:20260518--for: 【MES】停机类型责任区分、故障等级改为手填非字典 ---
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_66__mes_xsl_downtime_type_text_fields.sql
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslDowntimeType.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDowntimeTypeController.java
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeType/MesXslDowntimeType.data.ts
jeecg-boot/db/mes-xsl-downtime-type.sql
jeecg-boot/db/mes-xsl-downtime-type-menu-permission.sql
-- author:jiangxh---date:20260518--for: 【MES】停机主类型/停机类型/厂家信息业务字符字段统一 varchar(500) ---
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_67__mes_xsl_varchar500_biz_fields.sql
jeecg-boot/db/mes-xsl-downtime-main-type.sql
jeecg-boot/db/mes-xsl-downtime-main-type-menu-permission.sql
jeecg-boot/db/mes-xsl-manufacturer.sql
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
-- author:jiangxh---date:20260518--for: 【MES】删除停机类型废弃字典责任区分、故障等级改手填后 ---
jeecg-boot/db/mes-xsl-downtime-type-remove-unused-dict.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_68__mes_xsl_downtime_remove_unused_dict.sql
jeecg-boot/db/mes-xsl-downtime-type-menu-permission.sql
-- author:jiangxh---date:20260518--for: 【MES】工序管理/设备类别/设备类型菜单挂 MES基础资料并修复权限树与租户授权 ---
jeecg-boot/db/mes-xsl-move-process-equipment-menus-to-mes-base.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_69__mes_xsl_move_process_equipment_menus_to_mes_base.sql
-- author:jiangxh---date:20260518--for: 【MES】设备类型菜单补全 INSERT077 未建时仅 UPDATE 无效)---
jeecg-boot/db/mes-xsl-equipment-type-menu-fix.sql
-- author:jiangxh---date:20260518--for: 【MES】设备管理及子菜单图标 ---
jeecg-boot/db/mes-xsl-equipment-menus-icon.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_75__mes_xsl_equipment_menus_icon.sql
jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
jeecg-boot/db/mes-xsl-spare-parts-category-menu-permission.sql
jeecg-boot/db/mes-xsl-spare-part-menu-permission.sql
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
jeecg-boot/db/mes-xsl-downtime-main-type-menu-permission.sql
jeecg-boot/db/mes-xsl-downtime-type-menu-permission.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_70__mes_xsl_equipment_type_menu_ensure.sql
-- author:jiangxh---date:20260518--for: 【MES】工序管理/设备类别菜单与按钮权限补全及租户授权 ---
jeecg-boot/db/mes-xsl-process-and-category-menu-fix.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_71__mes_xsl_process_and_category_menu_ensure.sql
jeecg-boot/db/mes-process-operation-menu-permission.sql
jeecg-boot/db/mes-xsl-equipment-category-menu-permission.sql
jeecg-boot/db/mes-xsl-move-process-equipment-menus-to-mes-base.sql
-- author:jiangxh---date:20260518--for: 【MES】设备台账管理建表、设备管理菜单、CRUD、编号名称唯一校验 ---
jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql
jeecg-boot/db/mes-xsl-equipment-ledger.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_72__mes_xsl_equipment_ledger.sql
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentLedger.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentLedgerMapper.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentLedgerService.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentLedgerServiceImpl.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedgerList.vue
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/components/MesXslEquipmentLedgerModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/components/MesXslManufacturerSelectModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/components/MesXslEquipmentTypeSelectModal.vue
-- author:jiangxh---date:20260518--for: 【MES】设备管理目录与 MES基础资料 同级(非 MES管理 子菜单) ---
jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql
jeecg-boot/db/mes-xsl-equipment-ledger-menu-parent-fix.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_72__mes_xsl_equipment_ledger.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_73__mes_xsl_equipment_mgmt_menu_parent_fix.sql
-- author:jiangxh---date:20260518--for: 【MES】设备类别/类型/部位/小部位、备品件、厂家、停机类菜单挂「设备管理」目录 ---
jeecg-boot/db/mes-xsl-move-menus-to-equipment-mgmt.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_74__mes_xsl_move_menus_to_equipment_mgmt.sql
jeecg-boot/db/mes-xsl-equipment-category-menu-permission.sql
jeecg-boot/db/mes-xsl-equipment-type-menu-permission.sql
jeecg-boot/db/mes-xsl-equipment-part-menu-permission.sql
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
jeecg-boot/db/mes-xsl-spare-parts-category-menu-permission.sql
jeecg-boot/db/mes-xsl-spare-part-menu-permission.sql
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
jeecg-boot/db/mes-xsl-downtime-main-type-menu-permission.sql
jeecg-boot/db/mes-xsl-downtime-type-menu-permission.sql
jeecg-boot/db/mes-xsl-move-process-equipment-menus-to-mes-base.sql
jeecg-boot/db/mes-xsl-process-and-category-menu-fix.sql
jeecg-boot/db/mes-xsl-equipment-type-menu-fix.sql
-- author:jiangxh---date:20260518--for: 【MES】设备管理及子菜单图标 ---
jeecg-boot/db/mes-xsl-equipment-menus-icon.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_75__mes_xsl_equipment_menus_icon.sql
jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
jeecg-boot/db/mes-xsl-spare-parts-category-menu-permission.sql
jeecg-boot/db/mes-xsl-spare-part-menu-permission.sql
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
jeecg-boot/db/mes-xsl-downtime-main-type-menu-permission.sql
jeecg-boot/db/mes-xsl-downtime-type-menu-permission.sql

View File

@@ -0,0 +1,15 @@
package org.jeecg.modules.mes.material.constant;
/**
* 原材料检验标准等 MES 物料模块的打印业务编码:与「业务打印绑定」中 biz_code、print_biz_perm_entity.perm_id 一致。
*/
public final class MesMaterialPrintConstants {
/** 原材料检验标准列表页菜单sys_permission.id见 Flyway V3.9.2_62 */
public static final String RAW_MATERIAL_INSPECT_STD_MENU_PERM_ID = "1900000000000000730";
/** 历史或手工绑定时可能使用的语义型 biz_code服务端 prepareNativePrint 会作为次选查询) */
public static final String RAW_MATERIAL_INSPECT_STD_SEMANTIC_BIZ_CODE = "MES_RAW_MATERIAL_INSPECT_STD";
private MesMaterialPrintConstants() {}
}

View File

@@ -3,22 +3,40 @@ package org.jeecg.modules.mes.material.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.mes.material.constant.MesMaterialPrintConstants;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStdLine;
import org.jeecg.modules.mes.material.service.IMesRawMaterialInspectStdService;
import org.jeecg.modules.mes.material.vo.MesRawMaterialInspectStdPage;
import org.jeecg.modules.print.entity.PrintBizPermEntity;
import org.jeecg.modules.print.entity.PrintBizTemplateBind;
import org.jeecg.modules.print.entity.PrintTemplate;
import org.jeecg.modules.print.service.IPrintBizPermEntityService;
import org.jeecg.modules.print.service.IPrintBizTemplateBindService;
import org.jeecg.modules.print.service.IPrintTemplateService;
import org.jeecg.modules.print.support.PrintServerEnvironmentService;
import org.jeecg.modules.print.support.PrintServerPdfJobService;
import org.jeecg.modules.print.util.PrintBizDataMappingUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -31,6 +49,12 @@ import org.springframework.web.servlet.ModelAndView;
public class MesRawMaterialInspectStdController extends JeecgController<MesRawMaterialInspectStd, IMesRawMaterialInspectStdService> {
@Autowired private IMesRawMaterialInspectStdService mesRawMaterialInspectStdService;
@Autowired private PrintServerEnvironmentService printServerEnvironmentService;
@Autowired private PrintServerPdfJobService printServerPdfJobService;
@Autowired private IPrintBizTemplateBindService printBizTemplateBindService;
@Autowired private IPrintBizPermEntityService printBizPermEntityService;
@Autowired private IPrintTemplateService printTemplateService;
@Autowired private ObjectMapper objectMapper;
@GetMapping("/list")
public Result<IPage<MesRawMaterialInspectStd>> queryPageList(
@@ -114,6 +138,136 @@ public class MesRawMaterialInspectStdController extends JeecgController<MesRawMa
return Result.OK(flag == 1 ? "已启用" : "已停用");
}
/**
* 查询可用打印机(与原材料卡片 {@code MesXslRawMaterialCardController#queryPrinters} 一致)。
*/
@Operation(summary = "MES-原材料检验标准-查询可用打印机")
@GetMapping("/queryPrinters")
@RequiresPermissions(
value = {"mes:mes_raw_material_inspect_std:edit", "mes:mes_raw_material_inspect_std:exportXls"},
logical = Logical.OR)
public Result<Map<String, Object>> queryPrinters() {
return Result.OK(printServerEnvironmentService.buildPrinterQueryResult());
}
/**
* 根据业务打印绑定生成模板 JSON + 映射后的 printData供前端生成 PDF 后调用 printPdf与原材料卡片 prepareNativePrint 一致)。
*/
@Operation(summary = "MES-原材料检验标准-准备原生打印数据")
@GetMapping("/prepareNativePrint")
@RequiresPermissions("mes:mes_raw_material_inspect_std:edit")
public Result<Map<String, Object>> prepareNativePrint(@RequestParam(name = "id") String id) {
try {
MesRawMaterialInspectStd main = mesRawMaterialInspectStdService.getById(id);
if (main == null) {
return Result.error("未找到原材料检验标准");
}
PrintBizTemplateBind bind = resolveInspectStdPrintBind();
if (bind == null) {
return Result.error(
"请先在「业务打印绑定」中配置原材料检验标准与打印模板;业务编码需为当前列表菜单的权限 id或与 print_biz_perm_entity 中该业务实体一致");
}
PrintTemplate tpl = printTemplateService.getById(bind.getTemplateId());
if (tpl == null) {
return Result.error("绑定的打印模板不存在");
}
List<MesRawMaterialInspectStdLine> lines = mesRawMaterialInspectStdService.selectLinesByStdId(id);
MesRawMaterialInspectStdPage pageVo = new MesRawMaterialInspectStdPage();
BeanUtils.copyProperties(main, pageVo);
pageVo.setLineList(lines);
ArrayNode mapping = PrintBizDataMappingUtil.parseMappingArray(bind.getFieldMappingJson());
JsonNode bizRoot = objectMapper.valueToTree(pageVo);
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping, tpl.getTemplateJson());
PrintBizDataMappingUtil.fillMissingDataBindingParamKeys(printData, tpl.getTemplateJson());
Map<String, Object> out = new HashMap<>(8);
out.put("stdId", main.getId());
out.put("templateCode", bind.getTemplateCode());
out.put("templateJson", tpl.getTemplateJson());
out.put("paperWidthMm", tpl.getPaperWidthMm());
out.put("paperHeightMm", tpl.getPaperHeightMm());
out.put("paperOrientation", tpl.getPaperOrientation());
out.put("printData", objectMapper.convertValue(printData, Map.class));
return Result.OK(out);
} catch (Exception e) {
log.error("原材料检验标准准备打印数据失败 id={}", id, e);
return Result.error("准备打印数据失败: " + e.getMessage());
}
}
/**
* 将前端生成的 PDF Base64 提交到服务器打印机(与原材料卡片 printPdf 一致)。
*/
@AutoLog(value = "MES-原材料检验标准-PDF后端打印")
@Operation(summary = "MES-原材料检验标准-PDF后端打印")
@PostMapping("/printPdf")
@RequiresPermissions("mes:mes_raw_material_inspect_std:edit")
public Result<String> printPdf(@RequestBody Map<String, Object> body) {
String sid = String.valueOf(body.getOrDefault("id", "")).trim();
String printerName = String.valueOf(body.getOrDefault("printerName", "")).trim();
String pdfBase64 = String.valueOf(body.getOrDefault("pdfBase64", "")).trim();
String fileName = String.valueOf(body.getOrDefault("fileName", "")).trim();
if (StringUtils.isBlank(sid)) {
return Result.error("id 不能为空");
}
MesRawMaterialInspectStd std = mesRawMaterialInspectStdService.getById(sid);
if (std == null) {
return Result.error("未找到原材料检验标准");
}
String prefix =
StringUtils.isNotBlank(std.getStandardNo()) ? std.getStandardNo() : std.getId();
String fn =
StringUtils.isNotBlank(fileName) ? fileName : ("原材料检验标准-" + prefix + ".pdf");
return printServerPdfJobService.submitPdfBase64(
printerName, pdfBase64, fn, "RAW_INSPECT_STD_" + prefix);
}
private PrintBizTemplateBind resolveInspectStdPrintBind() {
PrintBizTemplateBind bind =
printBizTemplateBindService.getByBizCode(MesMaterialPrintConstants.RAW_MATERIAL_INSPECT_STD_MENU_PERM_ID);
if (bind != null) {
return bind;
}
bind =
printBizTemplateBindService.getByBizCode(MesMaterialPrintConstants.RAW_MATERIAL_INSPECT_STD_SEMANTIC_BIZ_CODE);
if (bind != null) {
return bind;
}
// 不同环境菜单 id 不一致:按 print_biz_perm_entity 中指向本实体的任意 perm_id 解析绑定
String entityFqn = MesRawMaterialInspectStd.class.getName();
List<PrintBizPermEntity> permRows =
printBizPermEntityService.lambdaQuery().eq(PrintBizPermEntity::getEntityClass, entityFqn).list();
for (PrintBizPermEntity row : permRows) {
if (StringUtils.isBlank(row.getPermId())) {
continue;
}
bind = printBizTemplateBindService.getByBizCode(row.getPermId());
if (bind != null) {
return bind;
}
}
// 最后兜底:业务名称与绑定页一致(避免 perm 映射表未同步时仍找不到)
List<PrintBizTemplateBind> byName =
printBizTemplateBindService
.lambdaQuery()
.eq(PrintBizTemplateBind::getBizName, "原材料检验标准")
.orderByDesc(PrintBizTemplateBind::getCreateTime)
.last("LIMIT 8")
.list();
if (byName.isEmpty()) {
return null;
}
if (byName.size() == 1) {
return byName.get(0);
}
for (PrintBizTemplateBind b : byName) {
PrintBizPermEntity pe = printBizPermEntityService.getByPermId(b.getBizCode());
if (pe != null && entityFqn.equals(StringUtils.trimToEmpty(pe.getEntityClass()))) {
return b;
}
}
return byName.get(0);
}
@RequiresPermissions("mes:mes_raw_material_inspect_std:exportXls")
@RequestMapping("/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesRawMaterialInspectStd model) {

View File

@@ -1,12 +1,14 @@
package org.jeecg.modules.mes.material.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@@ -71,4 +73,9 @@ public class MesRawMaterialInspectStd implements Serializable {
private Date updateTime;
private Integer delFlag;
/** 检验标准明细(子表 mes_raw_material_inspect_std_line通过 stdId 关联本表 id不参与主表入库映射 */
@TableField(exist = false)
@Schema(description = "MES原材料检验标准-检验项明细列表")
private List<MesRawMaterialInspectStdLine> lineList;
}

View File

@@ -1,14 +1,10 @@
package org.jeecg.modules.mes.material.vo;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStdLine;
/** 主子保存/编辑页 VO继承主表实体含 {@link MesRawMaterialInspectStd#lineList} 明细)。 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MesRawMaterialInspectStdPage extends MesRawMaterialInspectStd {
private List<MesRawMaterialInspectStdLine> lineList;
}
public class MesRawMaterialInspectStdPage extends MesRawMaterialInspectStd {}

View File

@@ -38,6 +38,7 @@ import org.jeecg.modules.print.vo.PrintBizDetailSlotVO;
import org.jeecg.modules.print.vo.PrintBizFieldItemVO;
import org.jeecg.modules.print.vo.PrintBizTypeVO;
import org.jeecg.modules.print.vo.PrintTemplateFieldItemVO;
import org.jeecg.modules.print.vo.PrintTemplateStructureVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.*;
@@ -182,6 +183,23 @@ public class PrintBizTemplateBindController extends JeecgController<PrintBizTemp
return Result.OK(fields);
}
@Operation(summary = "解析原生模板占位结构:主表参数 + 按明细表分组(供多标签映射)")
@GetMapping("/parseTemplateStructure")
@RequiresPermissions("print:bizBind:list")
public Result<PrintTemplateStructureVO> parseTemplateStructure(
@RequestParam(name = "templateId") String templateId) {
if (StringUtils.isBlank(templateId)) {
return Result.error("templateId 不能为空");
}
PrintTemplate tpl = printTemplateService.getById(templateId);
if (tpl == null) {
return Result.error("模板不存在");
}
PrintTemplateStructureVO structure =
PrintNativeTemplateFieldExtractor.extractStructure(tpl.getTemplateJson());
return Result.OK(structure);
}
@Operation(summary = "主实体上的明细槽位List&lt;明细实体&gt; / 明细数组 / 嵌套对象),用于先选明细再反射明细字段")
@GetMapping("/detailSlots")
@RequiresPermissions("print:bizBind:list")
@@ -258,12 +276,15 @@ public class PrintBizTemplateBindController extends JeecgController<PrintBizTemp
return Result.error("未配置该业务的打印绑定");
}
try {
PrintTemplate tpl = printTemplateService.getById(bind.getTemplateId());
ArrayNode mapping = PrintBizDataMappingUtil.parseMappingArray(bind.getFieldMappingJson());
JsonNode bizRoot = PrintBizDataMappingUtil.parseBizJson(body.getBizDataJson());
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping);
PrintTemplate tpl = printTemplateService.getById(bind.getTemplateId());
String tplJson = tpl != null ? tpl.getTemplateJson() : null;
ObjectNode printData = PrintBizDataMappingUtil.mapBizToPrintData(bizRoot, mapping, tplJson);
if (tpl != null && StringUtils.isNotBlank(tpl.getTemplateJson())) {
PrintBizDataMappingUtil.fillMissingDataBindingParamKeys(printData, tpl.getTemplateJson());
PrintBizDataMappingUtil.fillMissingDataBindingParamKeys(printData, tpl.getTemplateJson(), true);
PrintBizDataMappingUtil.fillPreviewDetailPlaceholderRowValues(
printData, bizRoot, mapping, tpl.getTemplateJson());
}
Map<String, Object> res = new HashMap<>(4);
res.put("templateCode", bind.getTemplateCode());

View File

@@ -3,19 +3,35 @@ package org.jeecg.modules.print.util;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.print.vo.PrintTemplateFieldItemVO;
/** 按映射规则把业务 JSON 转为模板打印数据(键为模板 bindField */
/**
* 按映射规则把业务 JSON 转为模板打印数据(键为模板 bindField。支持业务数组字段映射到模板明细表如 List2.Field1
*
* <p>模板 {@code dataBinding.detailTables} 中明细列统一为 {@code tableKey.fieldKey}(如 List1.Field1无双缀旧映射仍可借助
* {@link #resolveSyntheticDetailTemplateField} 参与列表展开。
*/
public final class PrintBizDataMappingUtil {
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final JsonNodeFactory NF = MAPPER.getNodeFactory();
private PrintBizDataMappingUtil() {}
public static ObjectNode mapBizToPrintData(JsonNode bizRoot, ArrayNode mappingRules) {
return mapBizToPrintData(bizRoot, mappingRules, null);
}
/**
* @param templateJson 原生模板 JSON非空时可为无双缀明细列绑定补齐 tableKey生成正确的明细数组结构
*/
public static ObjectNode mapBizToPrintData(JsonNode bizRoot, ArrayNode mappingRules, String templateJson) {
ObjectNode printData = MAPPER.createObjectNode();
if (bizRoot == null || mappingRules == null) {
return printData;
@@ -26,21 +42,109 @@ public final class PrintBizDataMappingUtil {
}
String templateField = text(rule, "templateField");
String bizField = text(rule, "bizField");
// 仅要求模板字段名;业务字段为空表示「不参与取数」,仍向 printData 写入空字符串,避免模板占位符缺键
if (StringUtils.isBlank(templateField)) {
continue;
}
// 模板明细列多为「tableKey.columnKey」如 List2.Field1业务字段为「数组字段.列」(如 lineList.inspectItemId
if (qualifiesForListExpansion(bizRoot, templateField, bizField)) {
continue;
}
// 无双缀占位Field1+ 业务侧为明细数组:交由列表展开写入 printData.List1[],避免落在根上导致表格 source 读不到
if (shouldDeferShortDetailFieldForListExpansion(bizRoot, templateField, bizField, templateJson)) {
continue;
}
JsonNode val;
if (StringUtils.isBlank(bizField)) {
val = MAPPER.getNodeFactory().textNode("");
val = NF.textNode("");
} else {
val = resolvePath(bizRoot, bizField);
}
setPath(printData, templateField, val);
}
applyListExpandedMappings(bizRoot, mappingRules, printData, templateJson);
return printData;
}
/**
* 在 {@code dataBinding.detailTables} 中按声明顺序查找首个包含 {@code fieldKey} 的明细表,返回 {@code tableKey.fieldKey}。
*
* <p>与同模块抽取器中「明细列统一为 tableKey.fieldKey」一致仍兼容历史绑定里保存的短键。
*/
private static String resolveSyntheticDetailTemplateField(String templateJson, String shortFieldKey) {
if (StringUtils.isAnyBlank(templateJson, shortFieldKey)) {
return null;
}
try {
JsonNode root = MAPPER.readTree(templateJson);
JsonNode db = root.get("dataBinding");
if (db == null || !db.isObject()) {
return null;
}
JsonNode tables = db.get("detailTables");
if (tables == null || !tables.isArray()) {
return null;
}
for (JsonNode t : tables) {
if (t == null || !t.isObject()) {
continue;
}
String tableKey = text(t, "tableKey").trim();
if (StringUtils.isBlank(tableKey)) {
continue;
}
JsonNode fields = t.get("fields");
if (fields == null || !fields.isArray()) {
continue;
}
for (JsonNode f : fields) {
if (f != null && f.isObject() && shortFieldKey.equals(text(f, "key").trim())) {
return tableKey + "." + shortFieldKey;
}
}
}
return null;
} catch (Exception ignored) {
return null;
}
}
private static String resolveEffectiveTemplateFieldForListExpansion(
String templateJson, String templateFieldRaw, String bizField, JsonNode bizRoot) {
if (StringUtils.isBlank(templateFieldRaw)) {
return templateFieldRaw;
}
String tf = templateFieldRaw.trim();
if (splitFirstDotPair(tf) != null) {
return tf;
}
if (StringUtils.isBlank(templateJson) || StringUtils.isBlank(bizField)) {
return tf;
}
HeadTail biz = splitFirstDotPair(bizField.trim());
if (biz == null) {
return tf;
}
JsonNode arr = bizRoot != null ? bizRoot.get(biz.head()) : null;
if (arr == null || !arr.isArray()) {
return tf;
}
String synthetic = resolveSyntheticDetailTemplateField(templateJson, tf);
return StringUtils.isNotBlank(synthetic) ? synthetic : tf;
}
private static boolean shouldDeferShortDetailFieldForListExpansion(
JsonNode bizRoot, String templateField, String bizField, String templateJson) {
if (StringUtils.isBlank(templateJson) || StringUtils.isAnyBlank(templateField, bizField)) {
return false;
}
if (splitFirstDotPair(templateField) != null) {
return false;
}
String eff =
resolveEffectiveTemplateFieldForListExpansion(templateJson, templateField, bizField, bizRoot);
return qualifiesForListExpansion(bizRoot, eff, bizField);
}
/**
* 按模板中已声明的绑定路径({@code dataBinding.params}、画布/表格等元素的 {@code bindField},与
* {@link PrintNativeTemplateFieldExtractor} 一致),向 printData 补齐缺失路径(空字符串)。
@@ -48,6 +152,15 @@ public final class PrintBizDataMappingUtil {
* <p>避免字段映射未包含某键时 API 缺键,桌面端渲染把「设计稿占位 text」当成数据显示。
*/
public static ObjectNode fillMissingDataBindingParamKeys(ObjectNode printData, String templateJson) {
return fillMissingDataBindingParamKeys(printData, templateJson, false);
}
/**
* @param detailPreviewPlaceholderRow 为 true 时(如绑定预览):明细数据源无行数据时用模板列生成一行 {@code null} 占位,便于 JSON 里看出字段;
* 为 false 时(真实打印):保持 {@code []},避免出现空白假行。
*/
public static ObjectNode fillMissingDataBindingParamKeys(
ObjectNode printData, String templateJson, boolean detailPreviewPlaceholderRow) {
if (printData == null) {
printData = MAPPER.createObjectNode();
}
@@ -60,18 +173,260 @@ public final class PrintBizDataMappingUtil {
if (item == null || StringUtils.isBlank(item.getBindField())) {
continue;
}
// 明细表列占位:必须由「明细数组映射」展开;不可用空串占位,否则会生成 List2 对象为 {Field1:""}
// 前端 resolveTableRows 要求 List2 为数组(见原生 TableElement
String et = StringUtils.defaultString(item.getElementType()).toLowerCase();
if ("detailfield".equals(et) || "column".equals(et)) {
continue;
}
String bf = item.getBindField().trim();
if (!hasPath(printData, bf)) {
setPath(printData, bf, MAPPER.getNodeFactory().textNode(""));
setPath(printData, bf, NF.textNode(""));
}
}
} catch (Exception ignored) {
// 模板解析异常时不阻断打印
}
try {
normalizeNativeDetailTableShapes(printData, templateJson, detailPreviewPlaceholderRow);
} catch (Exception ignored) {
// 明细形态规整失败不阻断
}
return printData;
}
/** 判断 printData 上是否存在该点分路径(含嵌套对象) */
/**
* 按模板 {@code dataBinding.detailTables} 将各明细数据源键规范为<strong>数组</strong>,并去掉首张明细表误落在根上的短列键。
*
* <p>无业务数据时:真实打印侧保留空数组 {@code []};预览侧可选注入一行列占位(见 {@code detailPreviewPlaceholderRow})。
*/
private static void normalizeNativeDetailTableShapes(
ObjectNode printData, String templateJson, boolean detailPreviewPlaceholderRow) {
if (printData == null || StringUtils.isBlank(templateJson)) {
return;
}
try {
JsonNode root = MAPPER.readTree(templateJson);
JsonNode db = root.get("dataBinding");
if (db == null || !db.isObject()) {
return;
}
JsonNode tables = db.get("detailTables");
if (tables == null || !tables.isArray()) {
return;
}
boolean firstTable = true;
LinkedHashSet<String> firstTableColumnKeys = new LinkedHashSet<>();
for (JsonNode t : tables) {
if (t == null || !t.isObject()) {
continue;
}
String tk = text(t, "tableKey").trim();
if (StringUtils.isBlank(tk)) {
continue;
}
JsonNode fields = t.get("fields");
LinkedHashSet<String> columnKeys = new LinkedHashSet<>();
if (fields != null && fields.isArray()) {
for (JsonNode f : fields) {
if (f != null && f.isObject()) {
String k = text(f, "key").trim();
if (StringUtils.isNotBlank(k)) {
columnKeys.add(k);
}
}
}
}
if (firstTable) {
firstTableColumnKeys.addAll(columnKeys);
firstTable = false;
}
JsonNode cur = printData.get(tk);
if (cur == null || cur.isNull()) {
printData.set(tk, emptyDetailTableArray(columnKeys, detailPreviewPlaceholderRow));
} else if (cur.isObject()) {
ObjectNode obj = (ObjectNode) cur;
if (obj.isEmpty() || objectLeavesOnlyEmptyPlaceholders(obj)) {
printData.set(tk, emptyDetailTableArray(columnKeys, detailPreviewPlaceholderRow));
} else {
ArrayNode arr = MAPPER.createArrayNode();
arr.add(obj.deepCopy());
printData.set(tk, arr);
}
} else if (cur.isArray()) {
ArrayNode arr = (ArrayNode) cur;
if (arr.size() == 0) {
printData.set(tk, emptyDetailTableArray(columnKeys, detailPreviewPlaceholderRow));
}
} else {
printData.set(tk, emptyDetailTableArray(columnKeys, detailPreviewPlaceholderRow));
}
}
for (String fk : firstTableColumnKeys) {
printData.remove(fk);
}
} catch (Exception ignored) {
// 忽略
}
}
/**
* 无明细行时的数组形态:预览用模板声明的列键生成一行 {@code null},便于看清字段;真实打印返回 {@code []}。
*/
private static ArrayNode emptyDetailTableArray(
LinkedHashSet<String> columnKeys, boolean detailPreviewPlaceholderRow) {
ArrayNode arr = MAPPER.createArrayNode();
if (!detailPreviewPlaceholderRow || columnKeys == null || columnKeys.isEmpty()) {
return arr;
}
ObjectNode row = MAPPER.createObjectNode();
for (String k : columnKeys) {
row.putNull(k);
}
arr.add(row);
return arr;
}
/**
* 预览专用:占位明细行单元格为 {@code null}/空串时,按映射从业务 JSON 取数写入(明细数组取<strong>第一行</strong>)。
*/
public static void fillPreviewDetailPlaceholderRowValues(
ObjectNode printData, JsonNode bizRoot, ArrayNode mappingRules, String templateJson) {
if (printData == null || bizRoot == null || mappingRules == null || StringUtils.isBlank(templateJson)) {
return;
}
LinkedHashSet<String> declaredTables = loadDeclaredDetailTableKeys(templateJson);
if (declaredTables.isEmpty()) {
return;
}
try {
for (JsonNode rule : mappingRules) {
if (rule == null || !rule.isObject()) {
continue;
}
String tfRaw = text(rule, "templateField").trim();
String bfRaw = text(rule, "bizField").trim();
if (StringUtils.isBlank(tfRaw)) {
continue;
}
String tfEff = tfRaw;
if (splitFirstDotPair(tfEff) == null) {
String syn = resolveSyntheticDetailTemplateField(templateJson, tfEff);
if (StringUtils.isNotBlank(syn)) {
tfEff = syn;
}
}
HeadTail tpl = splitFirstDotPair(tfEff);
if (tpl == null || StringUtils.isAnyBlank(tpl.head(), tpl.tail())) {
continue;
}
if (!declaredTables.contains(tpl.head())) {
continue;
}
JsonNode arrNode = printData.get(tpl.head());
if (!(arrNode instanceof ArrayNode arr) || arr.size() != 1) {
continue;
}
JsonNode rowNode = arr.get(0);
if (!(rowNode instanceof ObjectNode row)) {
continue;
}
String col = tpl.tail();
if (!row.has(col)) {
continue;
}
if (!cellNeedsPreviewFill(row.get(col))) {
continue;
}
JsonNode val = resolveBizFieldPreviewCell(bizRoot, bfRaw);
putLeaf(row, col, val);
}
} catch (Exception ignored) {
// 预览填充失败不阻断
}
}
private static LinkedHashSet<String> loadDeclaredDetailTableKeys(String templateJson) {
LinkedHashSet<String> out = new LinkedHashSet<>();
try {
JsonNode root = MAPPER.readTree(templateJson);
JsonNode db = root.get("dataBinding");
if (db == null || !db.isObject()) {
return out;
}
JsonNode tables = db.get("detailTables");
if (tables == null || !tables.isArray()) {
return out;
}
for (JsonNode t : tables) {
if (t != null && t.isObject()) {
String tk = text(t, "tableKey").trim();
if (StringUtils.isNotBlank(tk)) {
out.add(tk);
}
}
}
} catch (Exception ignored) {
// 忽略
}
return out;
}
private static boolean cellNeedsPreviewFill(JsonNode cur) {
if (cur == null || cur.isNull()) {
return true;
}
return cur.isTextual() && cur.asText("").isEmpty();
}
private static JsonNode resolveBizFieldPreviewCell(JsonNode bizRoot, String bizField) {
if (bizRoot == null || StringUtils.isBlank(bizField)) {
return mappingValueOrEmptyText(null);
}
String bf = bizField.trim();
HeadTail biz = splitFirstDotPair(bf);
if (biz != null) {
JsonNode arr = bizRoot.get(biz.head());
if (arr != null && arr.isArray() && arr.size() > 0) {
JsonNode row = arr.get(0);
if (row != null && row.isObject()) {
JsonNode v = resolvePath(row, biz.tail());
return mappingValueOrEmptyText(v);
}
}
}
JsonNode v = resolvePath(bizRoot, bf);
return mappingValueOrEmptyText(v);
}
/** 对象仅含空占位null / 空串),视为无明细行 */
private static boolean objectLeavesOnlyEmptyPlaceholders(ObjectNode obj) {
if (obj == null || obj.isEmpty()) {
return true;
}
Iterator<JsonNode> it = obj.elements();
while (it.hasNext()) {
JsonNode v = it.next();
if (v == null || v.isNull()) {
continue;
}
if (v.isTextual() && v.asText("").isEmpty()) {
continue;
}
if (v.isObject()) {
if (!objectLeavesOnlyEmptyPlaceholders((ObjectNode) v)) {
return false;
}
continue;
}
return false;
}
return true;
}
private static boolean hasPath(ObjectNode root, String path) {
if (StringUtils.isBlank(path)) {
return false;
@@ -173,6 +528,105 @@ public final class PrintBizDataMappingUtil {
}
}
/** 第一段为 JSON 对象的键路径;余下段落(可含多级)相对该对象的 field 路径。 */
private record HeadTail(String head, String tail) {}
private static HeadTail splitFirstDotPair(String path) {
if (StringUtils.isBlank(path)) {
return null;
}
int dot = path.indexOf('.');
if (dot <= 0 || dot >= path.length() - 1) {
return null;
}
String h = path.substring(0, dot).trim();
String t = path.substring(dot + 1).trim();
if (h.isEmpty() || t.isEmpty()) {
return null;
}
return new HeadTail(h, t);
}
/**
* 业务字段首段指向 JSON 数组,且模板字段为「明细表绑定键.列」(如 {@code List2.Field1})时,
* 需要将每行业务对象展开为模板 {@code previewData[listKey][i].列},供原生表格 {@code source=listKey}。
*/
private static boolean qualifiesForListExpansion(JsonNode bizRoot, String templateField, String bizField) {
if (bizRoot == null || StringUtils.isBlank(templateField) || StringUtils.isBlank(bizField)) {
return false;
}
HeadTail tpl = splitFirstDotPair(templateField);
HeadTail biz = splitFirstDotPair(bizField);
if (tpl == null || biz == null) {
return false;
}
JsonNode arr = bizRoot.get(biz.head());
return arr != null && arr.isArray();
}
/** 将「业务明细数组 → 模板明细键」的规则写入 {@code printData}。 */
private static void applyListExpandedMappings(
JsonNode bizRoot, ArrayNode mappingRules, ObjectNode printData, String templateJson) {
if (bizRoot == null || mappingRules == null || printData == null) {
return;
}
for (JsonNode rule : mappingRules) {
if (rule == null || !rule.isObject()) {
continue;
}
String tfRaw = text(rule, "templateField").trim();
String bf = text(rule, "bizField").trim();
String tfEff = resolveEffectiveTemplateFieldForListExpansion(templateJson, tfRaw, bf, bizRoot);
if (!qualifiesForListExpansion(bizRoot, tfEff, bf)) {
continue;
}
HeadTail tpl = splitFirstDotPair(tfEff);
HeadTail biz = splitFirstDotPair(bf);
if (tpl == null || biz == null) {
continue;
}
JsonNode srcArrNode = bizRoot.get(biz.head());
if (srcArrNode == null || !srcArrNode.isArray()) {
continue;
}
ArrayNode tgtArr = ensureRowObjectArray(printData, tpl.head(), srcArrNode.size());
for (int i = 0; i < srcArrNode.size(); i++) {
JsonNode srcRow = srcArrNode.get(i);
JsonNode val =
srcRow != null && srcRow.isObject() ? resolvePath(srcRow, biz.tail()) : null;
ObjectNode tgtRow = (ObjectNode) tgtArr.get(i);
setPath(tgtRow, tpl.tail(), mappingValueOrEmptyText(val));
}
}
}
/** 缺省占位与主映射一致:空则用空字符串。 */
private static JsonNode mappingValueOrEmptyText(JsonNode val) {
if (val == null || val.isNull()) {
return NF.textNode("");
}
return val;
}
/** 保证 printData.{tableKey} 为数组,且长度为 rowCount元素为展开行 Json 对象)。 */
private static ArrayNode ensureRowObjectArray(ObjectNode printData, String tableKey, int rowCount) {
JsonNode existed = printData.get(tableKey);
ArrayNode arr;
if (existed instanceof ArrayNode a) {
arr = a;
} else {
if (existed != null) {
printData.remove(tableKey);
}
arr = MAPPER.createArrayNode();
printData.set(tableKey, arr);
}
while (arr.size() < rowCount) {
arr.add(MAPPER.createObjectNode());
}
return arr;
}
private static String text(JsonNode n, String key) {
if (n == null || !n.isObject()) {
return "";

View File

@@ -3,11 +3,16 @@ package org.jeecg.modules.print.util;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.print.vo.PrintTemplateDetailTableVO;
import org.jeecg.modules.print.vo.PrintTemplateFieldItemVO;
import org.jeecg.modules.print.vo.PrintTemplateStructureVO;
/**
* 从原生打印模板 JSON 中收集所有 bindField / 表格列 field供业务字段映射使用。
@@ -40,9 +45,206 @@ public final class PrintNativeTemplateFieldExtractor {
} catch (Exception ignored) {
return list;
}
dedupeShortDetailFieldsWhenPrefixedExists(list);
return list;
}
/**
* dataBinding 已产出 {@code List1.Field1} 时,去掉画布扫描残留的同名短键 {@code Field1},避免映射表里重复一行。
*/
private static void dedupeShortDetailFieldsWhenPrefixedExists(List<PrintTemplateFieldItemVO> list) {
HashSet<String> columnSuffixes = new HashSet<>();
for (PrintTemplateFieldItemVO vo : list) {
String bf = vo.getBindField();
if (StringUtils.isBlank(bf)) {
continue;
}
int d = bf.indexOf('.');
if (d > 0 && d < bf.length() - 1) {
columnSuffixes.add(bf.substring(d + 1).trim());
}
}
list.removeIf(
vo -> {
String bf = vo.getBindField();
if (StringUtils.isBlank(bf) || bf.indexOf('.') >= 0) {
return false;
}
String et = StringUtils.defaultString(vo.getElementType()).toLowerCase();
if (!"detailfield".equals(et) && !"column".equals(et)) {
return false;
}
return columnSuffixes.contains(bf.trim());
});
}
/**
* 将 {@link #extract(String)} 的扁平结果拆成「主表参数 + 按明细表分组」,供前端多标签映射。
*
* <p>分组规则:带 {@code tableKey.} 前缀的占位归入对应明细表;无双缀短键按 dataBinding.detailTables 中字段声明归属;
* 若模板仅声明单个明细表则将短键归入该表;否则归入 {@code __general__}(其它画布/未归类占位)。
*/
public static PrintTemplateStructureVO extractStructure(String templateJson) {
PrintTemplateStructureVO vo = new PrintTemplateStructureVO();
if (StringUtils.isBlank(templateJson)) {
return vo;
}
JsonNode root;
try {
root = MAPPER.readTree(templateJson);
} catch (Exception e) {
return vo;
}
List<DetailTableMeta> metaTables = readDetailTableMeta(root);
LinkedHashSet<String> metaKeysOrdered = new LinkedHashSet<>();
Map<String, String> tableLabels = new LinkedHashMap<>();
Map<String, String> shortFieldOwner = new LinkedHashMap<>();
for (DetailTableMeta m : metaTables) {
if (StringUtils.isNotBlank(m.tableKey)) {
metaKeysOrdered.add(m.tableKey.trim());
if (StringUtils.isNotBlank(m.label)) {
tableLabels.put(m.tableKey.trim(), m.label.trim());
}
for (String fk : m.fieldKeys) {
if (StringUtils.isNotBlank(fk)) {
shortFieldOwner.putIfAbsent(fk.trim(), m.tableKey.trim());
}
}
}
}
List<PrintTemplateFieldItemVO> flat = extract(templateJson);
List<PrintTemplateFieldItemVO> params = new ArrayList<>();
List<PrintTemplateFieldItemVO> nonParams = new ArrayList<>();
for (PrintTemplateFieldItemVO f : flat) {
if (f == null) {
continue;
}
if ("param".equalsIgnoreCase(StringUtils.defaultString(f.getElementType()))) {
params.add(f);
} else {
nonParams.add(f);
}
}
vo.setParams(params);
LinkedHashSet<String> dottedPrefixes = new LinkedHashSet<>();
for (PrintTemplateFieldItemVO f : nonParams) {
String bf = StringUtils.trimToEmpty(f.getBindField());
int dot = bf.indexOf('.');
if (dot > 0) {
String prefix = bf.substring(0, dot).trim();
if (StringUtils.isNotBlank(prefix)) {
dottedPrefixes.add(prefix);
}
}
}
String soleMetaKey = metaKeysOrdered.size() == 1 ? metaKeysOrdered.iterator().next() : null;
Map<String, List<PrintTemplateFieldItemVO>> groups = new LinkedHashMap<>();
for (String k : metaKeysOrdered) {
groups.put(k, new ArrayList<>());
}
for (String p : dottedPrefixes) {
groups.computeIfAbsent(p, key -> new ArrayList<>());
}
final String generalKey = "__general__";
for (PrintTemplateFieldItemVO f : nonParams) {
String bf = StringUtils.trimToEmpty(f.getBindField());
String groupKey;
int dot = bf.indexOf('.');
if (dot > 0) {
groupKey = bf.substring(0, dot).trim();
} else if (soleMetaKey != null) {
groupKey = soleMetaKey;
} else if (StringUtils.isNotBlank(bf) && shortFieldOwner.containsKey(bf)) {
groupKey = shortFieldOwner.get(bf);
} else if (metaKeysOrdered.isEmpty() && dottedPrefixes.size() == 1) {
groupKey = dottedPrefixes.iterator().next();
} else {
groupKey = generalKey;
}
groups.computeIfAbsent(groupKey, key -> new ArrayList<>());
groups.get(groupKey).add(f);
}
List<PrintTemplateDetailTableVO> tables = new ArrayList<>();
Set<String> emitted = new LinkedHashSet<>();
for (DetailTableMeta m : metaTables) {
String tk = StringUtils.trimToEmpty(m.tableKey);
if (StringUtils.isBlank(tk)) {
continue;
}
emitted.add(tk);
List<PrintTemplateFieldItemVO> fields = groups.getOrDefault(tk, List.of());
tables.add(new PrintTemplateDetailTableVO(tk, tableLabels.get(tk), new ArrayList<>(fields)));
}
List<String> extras = new ArrayList<>();
for (String g : groups.keySet()) {
if (!emitted.contains(g) && !groups.get(g).isEmpty()) {
extras.add(g);
}
}
extras.sort(String::compareTo);
for (String g : extras) {
String lbl =
generalKey.equals(g) ? "其它(未归类画布/明细占位)" : null;
tables.add(new PrintTemplateDetailTableVO(g, lbl, new ArrayList<>(groups.get(g))));
}
vo.setDetailTables(tables);
return vo;
}
private static final class DetailTableMeta {
String tableKey = "";
String label = "";
List<String> fieldKeys = new ArrayList<>();
}
private static List<DetailTableMeta> readDetailTableMeta(JsonNode root) {
List<DetailTableMeta> out = new ArrayList<>();
if (root == null || !root.isObject()) {
return out;
}
JsonNode db = root.get("dataBinding");
if (db == null || !db.isObject()) {
return out;
}
JsonNode detailTables = db.get("detailTables");
if (detailTables == null || !detailTables.isArray()) {
return out;
}
for (JsonNode t : detailTables) {
if (t == null || !t.isObject()) {
continue;
}
DetailTableMeta m = new DetailTableMeta();
m.tableKey = text(t, "tableKey").trim();
m.label = firstNonBlank(text(t, "label"), text(t, "title")).trim();
JsonNode fields = t.get("fields");
if (fields != null && fields.isArray()) {
for (JsonNode f : fields) {
if (f != null && f.isObject()) {
String k = text(f, "key").trim();
if (StringUtils.isNotBlank(k)) {
m.fieldKeys.add(k);
}
}
}
}
if (StringUtils.isNotBlank(m.tableKey)) {
out.add(m);
}
}
return out;
}
/** 解析 schema.dataBindingparams参数键、detailTables明细字段 */
private static void collectDataBinding(JsonNode root, Set<String> seen, List<PrintTemplateFieldItemVO> list) {
JsonNode db = root.get("dataBinding");
@@ -81,11 +283,8 @@ public final class PrintNativeTemplateFieldExtractor {
if (StringUtils.isBlank(fk)) {
continue;
}
// 与画布列 bindField 一致时多为短 key多表明细同字段再加 tableKey 前缀消歧
String bindKey = fk;
if (seen.contains(bindKey) && StringUtils.isNotBlank(tableKey)) {
bindKey = tableKey + "." + fk;
}
// 统一使用 tableKey.fieldKey与多表明细、列表展开、预览占位一致避免首张表仍用短键 Field1
String bindKey = StringUtils.isNotBlank(tableKey) ? tableKey + "." + fk : fk;
if (seen.contains(bindKey) || !seen.add(bindKey)) {
continue;
}

View File

@@ -0,0 +1,26 @@
package org.jeecg.modules.print.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/** 原生模板中单个明细表(对应 dataBinding.detailTables[].tableKey及其占位字段 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "打印模板明细表分组")
public class PrintTemplateDetailTableVO implements Serializable {
@Schema(description = "明细表绑定键,与画布表格 source、占位前缀一致如 List1、List2")
private String tableKey;
@Schema(description = "设计器中配置的明细表显示名(可选)")
private String label;
@Schema(description = "该明细表下的模板占位字段bindField 已与全局解析逻辑一致)")
private List<PrintTemplateFieldItemVO> fields = new ArrayList<>();
}

View File

@@ -0,0 +1,21 @@
package org.jeecg.modules.print.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
/**
* 原生打印模板占位结构的结构化视图:主表参数 + 按明细表分组,供「业务打印绑定」弹窗标签页展示。
*/
@Data
@Schema(description = "打印模板占位结构(参数 + 多明细表)")
public class PrintTemplateStructureVO implements Serializable {
@Schema(description = "主表参数dataBinding.params")
private List<PrintTemplateFieldItemVO> params = new ArrayList<>();
@Schema(description = "明细表分组(顺序与模板 dataBinding.detailTables 一致,含画布推断的补充分组)")
private List<PrintTemplateDetailTableVO> detailTables = new ArrayList<>();
}

View File

@@ -1,5 +1,5 @@
server:
port: 8080
port: 8888
tomcat:
max-swallow-size: -1
error:

View File

@@ -0,0 +1,88 @@
-- 原材料检验标准菜单与前端 mes/rawmaterialinspectstd/index 一致+ 打印实体映射 + 可选纳入打印白名单
-- 若环境已存在同名菜单不同 id不会覆盖打印绑定时请使用本脚本中的列表页 id 作为 biz_code或沿用语义码 MES_RAW_MATERIAL_INSPECT_STD后端支持双查询
-- ===================== 1. 菜单权限父菜单MES XSL 1900000000000000300=====================
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000730', '1900000000000000300', '原材料检验标准', '/mes/rawMaterialInspectStd', 'mes/rawmaterialinspectstd/index', 1, NULL, NULL, 1, NULL, '0', 11.30, 0, 'ant-design:safety-outlined', 0, 1, 0, 0, 'MES原材料检验标准', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000730');
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000731', '1900000000000000730', '添加', NULL, NULL, 0, NULL, NULL, 2, 'mes:mes_raw_material_inspect_std:add', '1', 1.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000731');
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000732', '1900000000000000730', '编辑', NULL, NULL, 0, NULL, NULL, 2, 'mes:mes_raw_material_inspect_std:edit', '1', 2.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000732');
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000733', '1900000000000000730', '删除', NULL, NULL, 0, NULL, NULL, 2, 'mes:mes_raw_material_inspect_std:delete', '1', 3.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000733');
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000734', '1900000000000000730', '批量删除', NULL, NULL, 0, NULL, NULL, 2, 'mes:mes_raw_material_inspect_std:deleteBatch', '1', 4.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000734');
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000735', '1900000000000000730', '启用停用', NULL, NULL, 0, NULL, NULL, 2, 'mes:mes_raw_material_inspect_std:enable', '1', 5.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000735');
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000736', '1900000000000000730', '导出', NULL, NULL, 0, NULL, NULL, 2, 'mes:mes_raw_material_inspect_std:exportXls', '1', 6.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000736');
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000737', '1900000000000000730', '导入', NULL, NULL, 0, NULL, NULL, 2, 'mes:mes_raw_material_inspect_std:importExcel', '1', 7.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000737');
-- ===================== 2. 角色菜单授权admin=====================
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, '1900000000000000730', NULL, NOW(), '127.0.0.1'
FROM `sys_role` r WHERE r.`role_code` = 'admin'
AND NOT EXISTS (SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.id AND rp.`permission_id` = '1900000000000000730');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, '1900000000000000731', NULL, NOW(), '127.0.0.1'
FROM `sys_role` r WHERE r.`role_code` = 'admin'
AND NOT EXISTS (SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.id AND rp.`permission_id` = '1900000000000000731');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, '1900000000000000732', NULL, NOW(), '127.0.0.1'
FROM `sys_role` r WHERE r.`role_code` = 'admin'
AND NOT EXISTS (SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.id AND rp.`permission_id` = '1900000000000000732');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, '1900000000000000733', NULL, NOW(), '127.0.0.1'
FROM `sys_role` r WHERE r.`role_code` = 'admin'
AND NOT EXISTS (SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.id AND rp.`permission_id` = '1900000000000000733');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, '1900000000000000734', NULL, NOW(), '127.0.0.1'
FROM `sys_role` r WHERE r.`role_code` = 'admin'
AND NOT EXISTS (SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.id AND rp.`permission_id` = '1900000000000000734');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, '1900000000000000735', NULL, NOW(), '127.0.0.1'
FROM `sys_role` r WHERE r.`role_code` = 'admin'
AND NOT EXISTS (SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.id AND rp.`permission_id` = '1900000000000000735');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, '1900000000000000736', NULL, NOW(), '127.0.0.1'
FROM `sys_role` r WHERE r.`role_code` = 'admin'
AND NOT EXISTS (SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.id AND rp.`permission_id` = '1900000000000000736');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, '1900000000000000737', NULL, NOW(), '127.0.0.1'
FROM `sys_role` r WHERE r.`role_code` = 'admin'
AND NOT EXISTS (SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.id AND rp.`permission_id` = '1900000000000000737');
-- ===================== 3. 打印业务菜单关联实体含主子 lineList=====================
INSERT INTO `print_biz_perm_entity` (`perm_id`, `entity_class`)
SELECT '1900000000000000730', 'org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM `print_biz_perm_entity` WHERE `perm_id` = '1900000000000000730');
-- ===================== 4. 纳入业务打印绑定可选范围若表存在且尚未包含=====================
INSERT INTO `print_biz_bind_perm_whitelist` (`perm_id`)
SELECT '1900000000000000730'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM `print_biz_bind_perm_whitelist` WHERE `perm_id` = '1900000000000000730');

View File

@@ -0,0 +1,77 @@
-- MES 停机主类型字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权 jeecg-boot/db/mes-xsl-downtime-main-type-menu-permission.sql 一致
-- 权限前缀mes:mes_xsl_downtime_main_type:*父菜单 MES基础资料 / MES资料
SET NAMES utf8mb4;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES停机主类型是否启用', 'xslmes_downtime_main_type_status', '0启用1停用', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_downtime_main_type_status' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '启用', '0', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_main_type_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '0');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '停用', '1', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_main_type_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
CREATE TABLE IF NOT EXISTS `mes_xsl_downtime_main_type` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id',
`process_operation_name` varchar(128) DEFAULT NULL COMMENT '工序名称冗余',
`downtime_type` varchar(128) NOT NULL COMMENT '停机类型同租户未删除数据中唯一',
`display_order` int NOT NULL DEFAULT '0' COMMENT '显示顺序升序',
`distinguish_color` varchar(32) DEFAULT NULL COMMENT '区分颜色十六进制色值#1890ff',
`status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用字典xslmes_downtime_main_type_status0启用1停用',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mdmt_tenant_type` (`tenant_id`, `downtime_type`),
KEY `idx_mdmt_process` (`process_operation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES停机主类型';
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000119', @mes_base_pid, '停机主类型', '/xslmes/mesXslDowntimeMainType', 'xslmes/mesXslDowntimeMainType/MesXslDowntimeMainTypeList', NULL, 1, NULL, '1', 18, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000120', '1860000000000000119', '新增', 2, 'mes:mes_xsl_downtime_main_type:add', '1', '1', 0, 'admin', NOW()),
('1860000000000000121', '1860000000000000119', '编辑', 2, 'mes:mes_xsl_downtime_main_type:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000000122', '1860000000000000119', '删除', 2, 'mes:mes_xsl_downtime_main_type:delete', '1', '1', 0, 'admin', NOW()),
('1860000000000000123', '1860000000000000119', '批量删除', 2, 'mes:mes_xsl_downtime_main_type:deleteBatch', '1', '1', 0, 'admin', NOW()),
('1860000000000000124', '1860000000000000119', '导出', 2, 'mes:mes_xsl_downtime_main_type:exportXls', '1', '1', 0, 'admin', NOW()),
('1860000000000000125', '1860000000000000119', '导入', 2, 'mes:mes_xsl_downtime_main_type:importExcel', '1', '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000119',
'1860000000000000120', '1860000000000000121', '1860000000000000122', '1860000000000000123',
'1860000000000000124', '1860000000000000125'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,114 @@
-- MES 停机类型字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权
-- 权限前缀mes:mes_xsl_downtime_type:*父菜单 MES基础资料 / MES资料
SET NAMES utf8mb4;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES停机责任区分', 'xslmes_downtime_responsibility', '生产设备质量其他', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_downtime_responsibility' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '生产', 'production', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_responsibility' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'production');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '设备', 'equipment', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_responsibility' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'equipment');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '质量', 'quality', 3, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_responsibility' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'quality');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '其他', 'other', 4, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_responsibility' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'other');
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES停机故障等级', 'xslmes_downtime_fault_level', '一级二级三级', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_downtime_fault_level' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '一级', '1', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_fault_level' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '二级', '2', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_fault_level' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '2');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '三级', '3', 3, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_fault_level' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '3');
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES停机类型是否启用', 'xslmes_downtime_type_status', '0启用1停用', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_downtime_type_status' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '启用', '0', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_type_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '0');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '停用', '1', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_downtime_type_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
CREATE TABLE IF NOT EXISTS `mes_xsl_downtime_type` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id',
`process_operation_name` varchar(128) DEFAULT NULL COMMENT '工序名称冗余',
`downtime_main_type_id` varchar(32) NOT NULL COMMENT '所属主类型 mes_xsl_downtime_main_type.id',
`downtime_main_type_name` varchar(128) DEFAULT NULL COMMENT '主类型名称冗余停机主类型.downtime_type',
`downtime_type` varchar(128) NOT NULL COMMENT '停机类型同租户未删除数据中唯一',
`display_order` int NOT NULL DEFAULT '0' COMMENT '显示顺序升序必填',
`distinguish_color` varchar(32) DEFAULT NULL COMMENT '区分颜色十六进制色值',
`responsibility_distinct` varchar(32) DEFAULT NULL COMMENT '责任区分字典xslmes_downtime_responsibility',
`fault_level` varchar(10) DEFAULT NULL COMMENT '故障等级字典xslmes_downtime_fault_level1一级2二级3三级',
`downtime_maintenance` varchar(1) DEFAULT '0' COMMENT '是否停机维修字典yn1是0否',
`status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用字典xslmes_downtime_type_status0启用1停用',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mdt_tenant_type` (`tenant_id`, `downtime_type`),
KEY `idx_mdt_process` (`process_operation_id`),
KEY `idx_mdt_main_type` (`downtime_main_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES停机类型';
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000126', @mes_base_pid, '停机类型', '/xslmes/mesXslDowntimeType', 'xslmes/mesXslDowntimeType/MesXslDowntimeTypeList', NULL, 1, NULL, '1', 19, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000127', '1860000000000000126', '新增', 2, 'mes:mes_xsl_downtime_type:add', '1', '1', 0, 'admin', NOW()),
('1860000000000000128', '1860000000000000126', '编辑', 2, 'mes:mes_xsl_downtime_type:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000000129', '1860000000000000126', '删除', 2, 'mes:mes_xsl_downtime_type:delete', '1', '1', 0, 'admin', NOW()),
('1860000000000000130', '1860000000000000126', '批量删除', 2, 'mes:mes_xsl_downtime_type:deleteBatch', '1', '1', 0, 'admin', NOW()),
('1860000000000000131', '1860000000000000126', '导出', 2, 'mes:mes_xsl_downtime_type:exportXls', '1', '1', 0, 'admin', NOW()),
('1860000000000000132', '1860000000000000126', '导入', 2, 'mes:mes_xsl_downtime_type:importExcel', '1', '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000126',
'1860000000000000127', '1860000000000000128', '1860000000000000129', '1860000000000000130',
'1860000000000000131', '1860000000000000132'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,4 @@
-- 停机类型责任区分故障等级改为手填放宽字段长度
ALTER TABLE `mes_xsl_downtime_type`
MODIFY COLUMN `responsibility_distinct` varchar(128) DEFAULT NULL COMMENT '责任区分手填',
MODIFY COLUMN `fault_level` varchar(64) DEFAULT NULL COMMENT '故障等级手填';

View File

@@ -0,0 +1,26 @@
-- MES业务字符字段统一 varchar(500)MySQL状态/字典码仍 varchar(1)主键及外键仍 varchar(32)
ALTER TABLE `mes_xsl_downtime_main_type`
MODIFY COLUMN `process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
MODIFY COLUMN `downtime_type` varchar(500) NOT NULL COMMENT '停机类型同租户未删除数据中唯一',
MODIFY COLUMN `distinguish_color` varchar(500) DEFAULT NULL COMMENT '区分颜色十六进制色值',
MODIFY COLUMN `sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
MODIFY COLUMN `create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
MODIFY COLUMN `update_by` varchar(500) DEFAULT NULL COMMENT '更新人';
ALTER TABLE `mes_xsl_downtime_type`
MODIFY COLUMN `process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
MODIFY COLUMN `downtime_main_type_name` varchar(500) DEFAULT NULL COMMENT '主类型名称冗余',
MODIFY COLUMN `downtime_type` varchar(500) NOT NULL COMMENT '停机类型同租户未删除数据中唯一',
MODIFY COLUMN `distinguish_color` varchar(500) DEFAULT NULL COMMENT '区分颜色十六进制色值',
MODIFY COLUMN `responsibility_distinct` varchar(500) DEFAULT NULL COMMENT '责任区分手填',
MODIFY COLUMN `fault_level` varchar(500) DEFAULT NULL COMMENT '故障等级手填',
MODIFY COLUMN `sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
MODIFY COLUMN `create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
MODIFY COLUMN `update_by` varchar(500) DEFAULT NULL COMMENT '更新人';
ALTER TABLE `mes_xsl_manufacturer`
MODIFY COLUMN `manufacturer_category` varchar(500) NOT NULL COMMENT '厂家类别字典xslmes_manufacturer_category',
MODIFY COLUMN `manufacturer_name` varchar(500) NOT NULL COMMENT '厂家名称同租户未删除数据中唯一',
MODIFY COLUMN `sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
MODIFY COLUMN `create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
MODIFY COLUMN `update_by` varchar(500) DEFAULT NULL COMMENT '更新人';

View File

@@ -0,0 +1,9 @@
-- 停机类型删除未使用的字典责任区分故障等级已改为手填
SET NAMES utf8mb4;
DELETE i FROM `sys_dict_item` i
INNER JOIN `sys_dict` d ON i.`dict_id` = d.`id`
WHERE d.`dict_code` IN ('xslmes_downtime_responsibility', 'xslmes_downtime_fault_level');
DELETE FROM `sys_dict`
WHERE `dict_code` IN ('xslmes_downtime_responsibility', 'xslmes_downtime_fault_level');

View File

@@ -0,0 +1,74 @@
-- 工序管理设备类别设备类型 MES基础资料 + 权限树 is_leaf + 租户 admin 授权 db/mes-xsl-move-process-equipment-menus-to-mes-base.sql 一致
SET NAMES utf8mb4;
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
);
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料');
UPDATE `sys_permission` p
INNER JOIN (SELECT @mes_base_pid AS `pid`) x ON 1 = 1
SET p.`parent_id` = x.`pid`,
p.`is_leaf` = 0,
p.`url` = '/xslmes/mesXslProcessOperation',
p.`component` = 'xslmes/mesXslProcessOperation/MesXslProcessOperationList',
p.`component_name` = NULL,
p.`perms_type` = '1',
p.`update_by` = 'admin',
p.`update_time` = NOW()
WHERE p.`id` = '1860000000000000060';
UPDATE `sys_permission` p
INNER JOIN (SELECT @mes_base_pid AS `pid`) x ON 1 = 1
SET p.`parent_id` = x.`pid`,
p.`is_leaf` = 0,
p.`url` = '/xslmes/mesXslEquipmentCategory',
p.`component` = 'xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList',
p.`component_name` = NULL,
p.`perms_type` = '1',
p.`update_by` = 'admin',
p.`update_time` = NOW()
WHERE p.`id` = '1860000000000000070';
UPDATE `sys_permission` p
INNER JOIN (SELECT @mes_base_pid AS `pid`) x ON 1 = 1
SET p.`parent_id` = x.`pid`,
p.`is_leaf` = 0,
p.`url` = '/xslmes/mesXslEquipmentType',
p.`component` = 'xslmes/mesXslEquipmentType/MesXslEquipmentTypeList',
p.`component_name` = NULL,
p.`perms_type` = '1',
p.`update_by` = 'admin',
p.`update_time` = NOW()
WHERE p.`id` = '1860000000000000077';
UPDATE `sys_permission` SET `name` = '新增' WHERE `id` = '1860000000000000061' AND `name` = '添加';
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000060',
'1860000000000000061', '1860000000000000062', '1860000000000000063',
'1860000000000000064', '1860000000000000065', '1860000000000000066',
'1860000000000000070',
'1860000000000000071', '1860000000000000072', '1860000000000000073',
'1860000000000000074', '1860000000000000075', '1860000000000000076',
'1860000000000000077',
'1860000000000000078', '1860000000000000079', '1860000000000000080',
'1860000000000000081', '1860000000000000082', '1860000000000000083'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,54 @@
-- 设备类型补全菜单与按钮id 077 可能从未插入 MES基础资料修复权限树 is_leaf
SET NAMES utf8mb4;
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES基础资料'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES资料'
));
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000077', @mes_base_pid, '设备类型', '/xslmes/mesXslEquipmentType', 'xslmes/mesXslEquipmentType/MesXslEquipmentTypeList', NULL, 1, NULL, '1', 11, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0,
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000078', '1860000000000000077', '新增', 2, 'mes:mes_xsl_equipment_type:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000079', '1860000000000000077', '编辑', 2, 'mes:mes_xsl_equipment_type:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000080', '1860000000000000077', '删除', 2, 'mes:mes_xsl_equipment_type:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000081', '1860000000000000077', '批量删除', 2, 'mes:mes_xsl_equipment_type:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000082', '1860000000000000077', '导出', 2, 'mes:mes_xsl_equipment_type:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000083', '1860000000000000077', '导入', 2, 'mes:mes_xsl_equipment_type:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`),
`perms_type` = VALUES(`perms_type`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000077',
'1860000000000000078', '1860000000000000079', '1860000000000000080',
'1860000000000000081', '1860000000000000082', '1860000000000000083'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,72 @@
-- 工序管理设备类别补全菜单/按钮与租户 admin 授权 db/mes-xsl-process-and-category-menu-fix.sql 一致
SET NAMES utf8mb4;
SET @mes_tenant_id = 1002;
SET @mes_base_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES基础资料'
LIMIT 1
);
SET @mes_base_pid = IFNULL(@mes_base_pid, (
SELECT MIN(`id`) FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES资料'
));
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
UPDATE `sys_permission`
SET `is_leaf` = 0
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料');
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000060', @mes_base_pid, '工序管理', '/xslmes/mesXslProcessOperation', 'xslmes/mesXslProcessOperation/MesXslProcessOperationList', NULL, 1, NULL, '1', 9, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000061', '1860000000000000060', '新增', 2, 'mes:mes_process_operation:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000062', '1860000000000000060', '编辑', 2, 'mes:mes_process_operation:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000063', '1860000000000000060', '删除', 2, 'mes:mes_process_operation:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000064', '1860000000000000060', '批量删除', 2, 'mes:mes_process_operation:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000065', '1860000000000000060', '导出', 2, 'mes:mes_process_operation:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000066', '1860000000000000060', '导入', 2, 'mes:mes_process_operation:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `perms` = VALUES(`perms`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
UPDATE `sys_permission` SET `name` = '新增' WHERE `id` = '1860000000000000061' AND `name` = '添加';
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000070', @mes_base_pid, '设备类别', '/xslmes/mesXslEquipmentCategory', 'xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList', NULL, 1, NULL, '1', 10, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000071', '1860000000000000070', '新增', 2, 'mes:mes_xsl_equipment_category:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000072', '1860000000000000070', '编辑', 2, 'mes:mes_xsl_equipment_category:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000073', '1860000000000000070', '删除', 2, 'mes:mes_xsl_equipment_category:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000074', '1860000000000000070', '批量删除', 2, 'mes:mes_xsl_equipment_category:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000075', '1860000000000000070', '导出', 2, 'mes:mes_xsl_equipment_category:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000076', '1860000000000000070', '导入', 2, 'mes:mes_xsl_equipment_category:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `perms` = VALUES(`perms`), `is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000060',
'1860000000000000061', '1860000000000000062', '1860000000000000063',
'1860000000000000064', '1860000000000000065', '1860000000000000066',
'1860000000000000070',
'1860000000000000071', '1860000000000000072', '1860000000000000073',
'1860000000000000074', '1860000000000000075', '1860000000000000076'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,121 @@
-- MES 设备台账字典 + 建表 + 设备管理目录 + 设备台账菜单 + 按钮 + 租户 admin 授权
SET NAMES utf8mb4;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES设备台账状态', 'xslmes_equipment_ledger_status', '在用/停用/报废', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_equipment_ledger_status' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '在用', '0', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_equipment_ledger_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '0');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '停用', '1', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_equipment_ledger_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '报废', '2', 3, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_equipment_ledger_status' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '2');
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_ledger` (
`id` varchar(32) NOT NULL COMMENT '主键',
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id',
`process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余',
`equipment_name` varchar(500) NOT NULL COMMENT '设备名称同租户未删除唯一',
`equipment_code` varchar(128) NOT NULL COMMENT '设备编号同租户未删除唯一',
`manufacturer_id` varchar(32) DEFAULT NULL COMMENT '所属设备厂家 mes_xsl_manufacturer.id',
`manufacturer_name` varchar(500) DEFAULT NULL COMMENT '设备厂家名称冗余',
`equipment_category_id` varchar(32) DEFAULT NULL COMMENT '设备类别 mes_xsl_equipment_category.id',
`equipment_category_name` varchar(500) DEFAULT NULL COMMENT '设备类别名称冗余',
`equipment_type_id` varchar(32) DEFAULT NULL COMMENT '设备类型 mes_xsl_equipment_type.id',
`equipment_type_name` varchar(500) DEFAULT NULL COMMENT '设备类型名称冗余',
`factory_id` varchar(32) DEFAULT NULL COMMENT '所属工厂厂家信息',
`factory_name` varchar(500) DEFAULT NULL COMMENT '所属工厂名称冗余',
`equipment_model` varchar(500) DEFAULT NULL COMMENT '设备型号',
`equipment_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '设备状态 字典xslmes_equipment_ledger_status0在用1停用2报废',
`serial_no` varchar(500) DEFAULT NULL COMMENT '序列号',
`nameplate` varchar(500) DEFAULT NULL COMMENT '铭牌',
`maintain_dept_id` varchar(32) DEFAULT NULL COMMENT '维修部门 sys_depart.id',
`maintain_person` varchar(500) DEFAULT NULL COMMENT '维修人员',
`manage_dept_id` varchar(32) DEFAULT NULL COMMENT '主管部门 sys_depart.id',
`doc_file_no` varchar(500) DEFAULT NULL COMMENT '资料文件编号',
`production_date` date DEFAULT NULL COMMENT '生产日期',
`purchase_date` date DEFAULT NULL COMMENT '购买日期',
`use_date` date DEFAULT NULL COMMENT '使用日期',
`vendor_contact` varchar(500) DEFAULT NULL COMMENT '厂商联系人',
`asset_value` varchar(128) DEFAULT NULL COMMENT '价值',
`controlled_pda` varchar(500) DEFAULT NULL COMMENT '受控PDA',
`overproduction_ratio` varchar(128) DEFAULT NULL COMMENT '超产比率',
`effective_volume` varchar(128) DEFAULT NULL COMMENT '有效体积',
`enabled_flag` varchar(1) NOT NULL DEFAULT '1' COMMENT '是否启用 字典yn1是0否',
`equipment_desc` varchar(1000) DEFAULT NULL COMMENT '设备描述',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mel_tenant_code` (`tenant_id`, `equipment_code`),
KEY `idx_mel_tenant_name` (`tenant_id`, `equipment_name`),
KEY `idx_mel_process` (`process_operation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备台账';
SET @mes_tenant_id = 1002;
SET @mes_equip_root_parent = (
SELECT `parent_id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES基础资料'
LIMIT 1
);
SET @mes_equip_root_parent = IFNULL(@mes_equip_root_parent, (
SELECT `parent_id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES资料'
LIMIT 1
));
SET @mes_equip_root_sort = IFNULL((
SELECT `sort_no` + 1 FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
ORDER BY `sort_no` DESC
LIMIT 1
), 51);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000133', @mes_equip_root_parent, '设备管理', '/xslmes/equipment', 'layouts/RouteView', 'MesEquipmentLayout', 0, NULL, '1', @mes_equip_root_sort, 1, 0, 0, '1', 0, 0, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`),
`menu_type` = VALUES(`menu_type`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000134', '1860000000000000133', '设备台账', '/xslmes/mesXslEquipmentLedger', 'xslmes/mesXslEquipmentLedger/MesXslEquipmentLedgerList', 'MesXslEquipmentLedgerList', 1, NULL, '1', 1, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000135', '1860000000000000134', '新增', 2, 'mes:mes_xsl_equipment_ledger:add', '1', '1', 0, 'admin', NOW()),
('1860000000000000136', '1860000000000000134', '编辑', 2, 'mes:mes_xsl_equipment_ledger:edit', '1', '1', 0, 'admin', NOW()),
('1860000000000000137', '1860000000000000134', '删除', 2, 'mes:mes_xsl_equipment_ledger:delete', '1', '1', 0, 'admin', NOW()),
('1860000000000000138', '1860000000000000134', '批量删除', 2, 'mes:mes_xsl_equipment_ledger:deleteBatch', '1', '1', 0, 'admin', NOW()),
('1860000000000000139', '1860000000000000134', '导出', 2, 'mes:mes_xsl_equipment_ledger:exportXls', '1', '1', 0, 'admin', NOW()),
('1860000000000000140', '1860000000000000134', '导入', 2, 'mes:mes_xsl_equipment_ledger:importExcel', '1', '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`),
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000133',
'1860000000000000134',
'1860000000000000135', '1860000000000000136', '1860000000000000137', '1860000000000000138',
'1860000000000000139', '1860000000000000140'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,31 @@
-- 设备管理目录与 MES基础资料 同级修正 V3.9.2_72 曾挂在 MES管理
SET NAMES utf8mb4;
SET @mes_equip_root_parent = (
SELECT `parent_id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES基础资料'
LIMIT 1
);
SET @mes_equip_root_parent = IFNULL(@mes_equip_root_parent, (
SELECT `parent_id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES资料'
LIMIT 1
));
SET @mes_equip_root_sort = IFNULL((
SELECT `sort_no` + 1 FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
ORDER BY `sort_no` DESC
LIMIT 1
), 51);
UPDATE `sys_permission`
SET
`parent_id` = @mes_equip_root_parent,
`sort_no` = @mes_equip_root_sort,
`menu_type` = 0,
`is_leaf` = 0,
`hidden` = 0,
`status` = '1',
`del_flag` = 0
WHERE `id` = '1860000000000000133';

View File

@@ -0,0 +1,60 @@
-- 设备相关子菜单挂到设备管理目录 db/mes-xsl-move-menus-to-equipment-mgmt.sql 一致
SET NAMES utf8mb4;
SET @mes_tenant_id = 1002;
SET @mes_equip_pid = (
SELECT `id` FROM `sys_permission`
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
LIMIT 1
);
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
UPDATE `sys_permission`
SET `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0
WHERE `id` = @mes_equip_pid;
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 1, `is_leaf` = 0 WHERE `id` = '1860000000000000134';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 2, `is_leaf` = 0 WHERE `id` = '1860000000000000070';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 3, `is_leaf` = 0 WHERE `id` = '1860000000000000077';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 4, `is_leaf` = 0 WHERE `id` = '1860000000000000084';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 5, `is_leaf` = 0 WHERE `id` = '1860000000000000091';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 6, `is_leaf` = 0 WHERE `id` = '1860000000000000098';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 7, `is_leaf` = 0 WHERE `id` = '1860000000000000105';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 8, `is_leaf` = 0 WHERE `id` = '1860000000000000112';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 9, `is_leaf` = 0 WHERE `id` = '1860000000000000119';
UPDATE `sys_permission` SET `parent_id` = @mes_equip_pid, `sort_no` = 10, `is_leaf` = 0 WHERE `id` = '1860000000000000126';
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
@mes_equip_pid,
'1860000000000000134',
'1860000000000000070',
'1860000000000000071', '1860000000000000072', '1860000000000000073', '1860000000000000074', '1860000000000000075', '1860000000000000076',
'1860000000000000077',
'1860000000000000078', '1860000000000000079', '1860000000000000080', '1860000000000000081', '1860000000000000082', '1860000000000000083',
'1860000000000000084',
'1860000000000000085', '1860000000000000086', '1860000000000000087', '1860000000000000088', '1860000000000000089', '1860000000000000090',
'1860000000000000091',
'1860000000000000092', '1860000000000000093', '1860000000000000094', '1860000000000000095', '1860000000000000096', '1860000000000000097',
'1860000000000000098',
'1860000000000000099', '1860000000000000100', '1860000000000000101', '1860000000000000102', '1860000000000000103', '1860000000000000104',
'1860000000000000105',
'1860000000000000106', '1860000000000000107', '1860000000000000108', '1860000000000000109', '1860000000000000110', '1860000000000000111',
'1860000000000000112',
'1860000000000000113', '1860000000000000114', '1860000000000000115', '1860000000000000116', '1860000000000000117', '1860000000000000118',
'1860000000000000119',
'1860000000000000120', '1860000000000000121', '1860000000000000122', '1860000000000000123', '1860000000000000124', '1860000000000000125',
'1860000000000000126',
'1860000000000000127', '1860000000000000128', '1860000000000000129', '1860000000000000130', '1860000000000000131', '1860000000000000132',
'1860000000000000135', '1860000000000000136', '1860000000000000137', '1860000000000000138', '1860000000000000139', '1860000000000000140'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -0,0 +1,10 @@
-- 设备管理目录及指定子菜单图标 db/mes-xsl-equipment-menus-icon.sql 一致
SET NAMES utf8mb4;
UPDATE `sys_permission` SET `icon` = 'ant-design:tool-outlined' WHERE `id` = '1860000000000000133' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:apartment-outlined' WHERE `id` = '1860000000000000091' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:tags-outlined' WHERE `id` = '1860000000000000098' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:shopping-outlined' WHERE `id` = '1860000000000000105' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:shop-outlined' WHERE `id` = '1860000000000000112' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:partition-outlined' WHERE `id` = '1860000000000000119' AND `del_flag` = 0;
UPDATE `sys_permission` SET `icon` = 'ant-design:pause-circle-outlined' WHERE `id` = '1860000000000000126' AND `del_flag` = 0;

View File

@@ -7,10 +7,10 @@ VITE_PUBLIC_PATH = /
# 跨域代理:前缀须与 VITE_GLOB_API_URL 一致,且 rewrite 后路径需包含后端 context-path/jeecg-boot
# 详见 build/vite/proxy.ts
VITE_PROXY = [["/jeecg-boot","http://localhost:8080/jeecg-boot"],["/upload","http://localhost:3300/upload"]]
VITE_PROXY = [["/jeecg-boot","http://localhost:8888/jeecg-boot"],["/upload","http://localhost:3300/upload"]]
#后台接口全路径地址(必填)
VITE_GLOB_DOMAIN_URL=http://localhost:8080/jeecg-boot
VITE_GLOB_DOMAIN_URL=http://localhost:8888/jeecg-boot
#后台接口父地址(必填),与 server.servlet.context-path 一致,避免仅去掉别名前缀后缺少 /jeecg-boot
VITE_GLOB_API_URL=/jeecg-boot

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -30,7 +30,12 @@
}
.aui-image {
padding: 180px 80px;
/* 左侧蓝色区flex 垂直水平居中展示宣传图(替代大块 padding 顶在上方) */
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
padding: 32px 40px;
flex-basis: 60%;
-webkit-flex-basis: 60%;
background-color: #0198cd;
@@ -39,9 +44,21 @@
}
.aui-image-text {
top: 50%;
left: 50%;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
max-width: 100%;
padding: 0;
box-sizing: border-box;
}
/* 相对原图约 331×118 放大 30% → 430×153资源为 2× 导出,浏览器缩放回该尺寸更清晰 */
.aui-image-text img {
width: 430px;
max-width: min(430px, 100%);
height: auto;
display: block;
}
.aui-formBox {

View File

@@ -12,6 +12,9 @@ enum Api {
queryById = '/mes/material/rawMaterialInspectStd/queryById',
queryLineList = '/mes/material/rawMaterialInspectStd/queryLineListByStdId',
setEnable = '/mes/material/rawMaterialInspectStd/setEnable',
queryPrinters = '/mes/material/rawMaterialInspectStd/queryPrinters',
prepareNativePrint = '/mes/material/rawMaterialInspectStd/prepareNativePrint',
printPdf = '/mes/material/rawMaterialInspectStd/printPdf',
}
export const getExportUrl = Api.exportXls;
@@ -37,3 +40,15 @@ export const batchDelete = (params, handleSuccess) => {
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
export const setEnable = (params) => defHttp.post({ url: Api.setEnable, params });
export const queryPrinters = () => defHttp.get({ url: Api.queryPrinters });
export const prepareNativePrint = (id: string) =>
defHttp.get({
url: Api.prepareNativePrint,
params: { id, _t: Date.now() },
});
/** id + 前端生成的 pdfBase64printerName 空则用默认队列(与原材料卡片一致) */
export const printPdf = (data: { id: string; printerName?: string; pdfBase64: string; fileName?: string }) =>
defHttp.post({ url: Api.printPdf, data, timeout: 3 * 60 * 1000 });

View File

@@ -2,32 +2,107 @@
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_raw_material_inspect_std:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"
>新增</a-button
<a-button type="primary" v-auth="'mes:mes_raw_material_inspect_std:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<JDictSelectTag
v-model:value="printDotWsUrl"
dictCode="xslmes_print_dot_ws"
:showChooseOption="false"
style="width: 280px; margin-left: 8px"
placeholder="选择 PrintDot 地址"
@change="onPrintDotWsUrlChange"
/>
<a-button v-if="!printDotConnected" style="margin-left: 8px" @click="downloadPrintPlugin">下载打印插件</a-button>
<a-select
v-model:value="selectedPrinterName"
:options="printerOptions"
style="width: 220px; margin-left: 8px"
allow-clear
show-search
option-filter-prop="label"
:placeholder="printerSelectPlaceholder"
/>
<a-button style="margin-left: 8px" @click="() => refreshPrinterOptions(true)">刷新打印机</a-button>
<a-button
type="primary"
ghost
v-auth="'mes:mes_raw_material_inspect_std:edit'"
:loading="printLoading"
:disabled="selectedRowKeys.length === 0"
@click="handlePrintSelected"
>
<Icon icon="ant-design:printer-outlined" />
打印选中
</a-button>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_raw_material_inspect_std:edit' },
]"
:actions="getTableAction(record)"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesRawMaterialInspectStdModal @register="registerModal" @success="reload" />
<MesRawMaterialInspectStdPrintPreviewModal
v-model:open="printPreviewOpen"
:std-id="printPreviewStdId"
:standard-no="printPreviewStandardNo"
/>
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref, watch } from 'vue';
import { Icon } from '/@/components/Icon';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import { initDictOptions } from '/@/utils/dict';
import { JDictSelectTag } from '/@/components/Form';
import MesRawMaterialInspectStdModal from './modules/MesRawMaterialInspectStdModal.vue';
import MesRawMaterialInspectStdPrintPreviewModal from './modules/MesRawMaterialInspectStdPrintPreviewModal.vue';
import { columns, searchFormSchema } from './MesRawMaterialInspectStd.data';
import { list, deleteOne, setEnable } from './MesRawMaterialInspectStd.api';
import { list, deleteOne, setEnable, prepareNativePrint } from './MesRawMaterialInspectStd.api';
import { useMessage } from '/@/hooks/web/useMessage';
import {
PRINT_TEMPLATE_SELECTED_PRINTER_KEY,
printNativeSchemaViaPrintDot,
} from '/@/views/print/template/utils/printNativeViaPrintDot';
import { normalizeImportedNativeSchema } from '/@/views/print/template/native/core/nativeSchemaNormalize';
import {
fetchPrintDotPrinters,
getPrintDotBridgeConfig,
setPrintDotBridgeConfig,
} from '/@/views/print/template/utils/printDotBridge';
const { createMessage } = useMessage();
const PRINT_DOT_WS_DICT = 'xslmes_print_dot_ws';
const printDotWsUrl = ref('');
const printDotConnected = ref(false);
function persistPrintDotConfig() {
setPrintDotBridgeConfig(String(printDotWsUrl.value || '').trim(), '');
void refreshPrinterOptions(false);
}
function onPrintDotWsUrlChange() {
printDotConnected.value = false;
persistPrintDotConfig();
}
function downloadPrintPlugin() {
const base = import.meta.env.BASE_URL || '/';
const normalizedBase = base.endsWith('/') ? base : `${base}/`;
const url = `${normalizedBase}print-plugin/XSL-PrintDot.exe`;
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'XSL-PrintDot.exe');
link.rel = 'noopener';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
const [registerModal, { openModal }] = useModal();
const { tableContext } = useListPage({
tableProps: {
@@ -36,10 +111,208 @@
columns,
canResize: true,
formConfig: { labelWidth: 100, schemas: searchFormSchema, autoSubmitOnEnter: true },
actionColumn: { width: 200 },
actionColumn: { width: 280, fixed: 'right' },
},
});
const [registerTable, { reload }, { rowSelection }] = tableContext;
const [registerTable, { reload }, { rowSelection, selectedRowKeys, selectedRows }] = tableContext;
const printPreviewOpen = ref(false);
const printPreviewStdId = ref<string | null>(null);
const printPreviewStandardNo = ref<string | undefined>(undefined);
function handlePrintPreview(record: Recordable) {
printPreviewStdId.value = record.id as string;
printPreviewStandardNo.value = record.standardNo as string | undefined;
printPreviewOpen.value = true;
}
const printerOptions = ref<Array<{ label: string; value: string }>>([]);
const selectedPrinterName = ref<string>('__system_default__');
const printLoading = ref(false);
const PRINT_ROW_LOADING_KEY = 'mesRawMaterialInspectStd-print-row';
const PRINT_BATCH_LOADING_KEY = 'mesRawMaterialInspectStd-print-batch';
const printerSelectPlaceholder = '选择打印机PrintDot 桥接)';
watch(selectedPrinterName, (v) => {
if (v) {
localStorage.setItem(PRINT_TEMPLATE_SELECTED_PRINTER_KEY, v);
}
});
async function refreshPrinterOptions(showMessage = true) {
const optionMap = new Map<string, { label: string; value: string }>();
optionMap.set('__system_default__', { label: '系统默认打印机', value: '__system_default__' });
try {
const dotList = await fetchPrintDotPrinters();
printDotConnected.value = true;
dotList.forEach((p) => {
const name = String(p.name || '').trim();
if (!name) return;
const defMark = p.isDefault ? '(默认)' : '';
optionMap.set(name, { label: `${name}${defMark}`, value: name });
});
printerOptions.value = Array.from(optionMap.values());
if (showMessage) {
if (dotList.length) {
createMessage.success(`已从 PrintDot 桥接识别 ${dotList.length} 台打印机`);
} else {
createMessage.warning('PrintDot 已连接但未返回打印机列表');
}
}
} catch (e: unknown) {
printDotConnected.value = false;
printerOptions.value = Array.from(optionMap.values());
if (showMessage) {
createMessage.warning(`PrintDot${e instanceof Error ? e.message : String(e)}`);
}
}
}
async function executePrint(record: Recordable, options?: { silentSuccess?: boolean }) {
try {
const prep = (await prepareNativePrint(record.id as string)) as Record<string, unknown>;
const templateJsonRaw = prep.templateJson as string;
const printData = prep.printData as Record<string, unknown>;
const paperWidthMm = Number((prep as any).paperWidthMm ?? 0);
const paperHeightMm = Number((prep as any).paperHeightMm ?? 0);
const paperOrientation = String((prep as any).paperOrientation || '').toLowerCase();
if (!templateJsonRaw) {
throw new Error('模板 JSON 为空');
}
let raw: unknown;
try {
raw = typeof templateJsonRaw === 'string' ? JSON.parse(templateJsonRaw) : templateJsonRaw;
} catch {
throw new Error('模板 JSON 格式错误');
}
const schema = normalizeImportedNativeSchema(raw);
if (paperWidthMm > 0 && paperHeightMm > 0) {
const orient = paperOrientation === 'landscape' ? 'landscape' : paperOrientation === 'portrait' ? 'portrait' : '';
const normalized =
orient === 'landscape'
? {
width: Math.max(paperWidthMm, paperHeightMm),
height: Math.min(paperWidthMm, paperHeightMm),
}
: orient === 'portrait'
? {
width: Math.min(paperWidthMm, paperHeightMm),
height: Math.max(paperWidthMm, paperHeightMm),
}
: {
width: paperWidthMm,
height: paperHeightMm,
};
schema.page.width = normalized.width;
schema.page.height = normalized.height;
}
const no = String(record.standardNo || '').trim();
await printNativeSchemaViaPrintDot({
schema,
data: printData as Record<string, unknown>,
jobName: `原材料检验标准-${no || record.id}.pdf`,
printerSelection:
selectedPrinterName.value ||
localStorage.getItem(PRINT_TEMPLATE_SELECTED_PRINTER_KEY) ||
'__system_default__',
});
if (!options?.silentSuccess) {
createMessage.success('已通过 PrintDot 提交打印');
}
} catch (e: unknown) {
throw new Error(e instanceof Error ? e.message : String(e));
}
}
function handlePrintSelected() {
const rows = selectedRows.value || [];
if (!rows.length) {
createMessage.warning('请至少勾选一条记录后再点击「打印选中」');
return;
}
printLoading.value = true;
createMessage.destroy(PRINT_BATCH_LOADING_KEY);
createMessage.loading({
content: `正在打印 ${rows.length} 条记录,请稍候…`,
key: PRINT_BATCH_LOADING_KEY,
duration: 0,
});
(async () => {
try {
let ok = 0;
let firstError = '';
for (const row of rows) {
try {
await executePrint(row, { silentSuccess: true });
ok += 1;
} catch (e: unknown) {
if (!firstError) {
firstError = e instanceof Error ? e.message : String(e);
}
}
}
if (ok === rows.length) {
createMessage.success(`已通过 PrintDot 提交 ${ok} 条打印任务`);
} else {
createMessage.warning(
`打印完成:成功 ${ok},失败 ${rows.length - ok}${firstError ? `。首条错误:${firstError}` : ''}`,
);
}
} finally {
createMessage.destroy(PRINT_BATCH_LOADING_KEY);
printLoading.value = false;
}
})();
}
async function handlePrintRow(record: Recordable) {
printLoading.value = true;
createMessage.destroy(PRINT_ROW_LOADING_KEY);
createMessage.loading({
content: '正在生成 PDF 并提交打印,版面复杂时可能需数十秒,请稍候…',
key: PRINT_ROW_LOADING_KEY,
duration: 0,
});
try {
await executePrint(record, { silentSuccess: true });
createMessage.success('已通过 PrintDot 提交打印');
} catch (e: unknown) {
createMessage.error(e instanceof Error ? e.message : String(e));
} finally {
createMessage.destroy(PRINT_ROW_LOADING_KEY);
printLoading.value = false;
}
}
onMounted(async () => {
const cfg = getPrintDotBridgeConfig();
setPrintDotBridgeConfig(cfg.wsUrl, '');
printDotWsUrl.value = cfg.wsUrl || '';
try {
const raw = await initDictOptions(PRINT_DOT_WS_DICT);
const items = Array.isArray(raw) ? raw : [];
const values = items
.map((it: Recordable) => String(it.value ?? it.itemValue ?? '').trim())
.filter(Boolean);
const valueSet = new Set(values);
if (valueSet.size && printDotWsUrl.value && !valueSet.has(String(printDotWsUrl.value).trim())) {
printDotWsUrl.value = values[0];
setPrintDotBridgeConfig(printDotWsUrl.value, '');
} else if (valueSet.size && !printDotWsUrl.value.trim()) {
printDotWsUrl.value = values[0];
setPrintDotBridgeConfig(printDotWsUrl.value, '');
}
} catch {
/* 字典未配置时沿用 localStorage */
}
const savedPrinter = localStorage.getItem(PRINT_TEMPLATE_SELECTED_PRINTER_KEY);
if (savedPrinter) {
selectedPrinterName.value = savedPrinter;
}
await refreshPrinterOptions(false);
});
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true });
@@ -63,7 +336,28 @@
createMessage.success('已停用');
reload();
}
function getDropDownAction(record) {
function getTableAction(record: Recordable) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'mes:mes_raw_material_inspect_std:edit',
},
{
label: '打印预览',
onClick: handlePrintPreview.bind(null, record),
auth: 'mes:mes_raw_material_inspect_std:edit',
},
{
label: '打印',
onClick: handlePrintRow.bind(null, record),
auth: 'mes:mes_raw_material_inspect_std:edit',
},
];
}
function getDropDownAction(record: Recordable) {
const actions: any[] = [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{

View File

@@ -0,0 +1,203 @@
<template>
<a-modal
v-model:open="innerOpen"
:title="modalTitle"
width="960px"
:footer="null"
destroy-on-close
wrap-class-name="mes-raw-material-inspect-std-print-preview-modal"
@cancel="onClose"
>
<a-spin :spinning="loading">
<div v-if="errorText" class="preview-error">{{ errorText }}</div>
<div v-else class="preview-body">
<iframe
v-if="previewHtml"
class="preview-iframe"
title="原材料检验标准打印预览"
:srcdoc="previewHtml"
/>
<a-empty v-else-if="!loading" description="暂无预览内容" />
</div>
</a-spin>
<div class="preview-footer">
<a-space>
<a-button @click="innerOpen = false">关闭</a-button>
<a-button type="primary" :disabled="!previewHtml || !!errorText" @click="handleBrowserPrint">
<Icon icon="ant-design:printer-outlined" />
浏览器打印
</a-button>
</a-space>
</div>
</a-modal>
</template>
<script lang="ts" setup>
import { computed, ref, watch } from 'vue';
import { Icon } from '/@/components/Icon';
import { useMessage } from '/@/hooks/web/useMessage';
import { prepareNativePrint } from '../MesRawMaterialInspectStd.api';
import { renderNativePrintHtml } from '/@/views/print/template/native/core/printRenderer';
import { normalizeImportedNativeSchema } from '/@/views/print/template/native/core/nativeSchemaNormalize';
const props = defineProps<{
open: boolean;
/** 检验标准主键 */
stdId: string | null;
/** 展示在标题(如标准编号) */
standardNo?: string;
}>();
const emit = defineEmits<{
(e: 'update:open', v: boolean): void;
}>();
const { createMessage } = useMessage();
const innerOpen = computed({
get: () => props.open,
set: (v: boolean) => emit('update:open', v),
});
const modalTitle = computed(() => {
const b = String(props.standardNo || '').trim();
return b ? `原材料检验标准打印预览(标准编号:${b}` : '原材料检验标准打印预览';
});
const loading = ref(false);
const errorText = ref('');
const previewHtml = ref('');
async function loadPreview(id: string) {
loading.value = true;
errorText.value = '';
previewHtml.value = '';
try {
const prep = (await prepareNativePrint(id)) as Record<string, unknown>;
const templateJsonRaw = prep.templateJson as string;
const printData = prep.printData as Record<string, unknown>;
if (!templateJsonRaw) {
throw new Error('模板 JSON 为空,请检查「业务打印绑定」是否已配置');
}
let raw: unknown;
try {
raw = typeof templateJsonRaw === 'string' ? JSON.parse(templateJsonRaw) : templateJsonRaw;
} catch {
throw new Error('模板 JSON 格式错误');
}
const schema = normalizeImportedNativeSchema(raw);
previewHtml.value = await renderNativePrintHtml(schema, printData as Record<string, unknown>);
} catch (e: unknown) {
errorText.value = e instanceof Error ? e.message : String(e);
} finally {
loading.value = false;
}
}
function handleBrowserPrint() {
const html = previewHtml.value;
if (!html?.trim()) {
createMessage.warning('预览未就绪,请稍后再试');
return;
}
const iframe = document.createElement('iframe');
iframe.setAttribute(
'style',
'position:fixed;left:0;top:0;width:0;height:0;border:0;opacity:0;pointer-events:none;',
);
document.body.appendChild(iframe);
const doc = iframe.contentDocument;
if (!doc) {
document.body.removeChild(iframe);
createMessage.error('无法创建打印文档');
return;
}
try {
doc.open();
doc.write(html);
doc.close();
} catch {
document.body.removeChild(iframe);
createMessage.error('写入打印内容失败');
return;
}
const cleanup = () => {
try {
if (iframe.parentNode) {
document.body.removeChild(iframe);
}
} catch {
// ignore
}
};
const runPrint = () => {
try {
const w = iframe.contentWindow;
if (!w) {
createMessage.error('无法唤起打印窗口');
cleanup();
return;
}
w.focus();
w.print();
w.addEventListener('afterprint', cleanup, { once: true });
window.setTimeout(cleanup, 120000);
} catch {
createMessage.error('无法唤起打印,请检查浏览器弹窗/打印权限');
cleanup();
}
};
window.setTimeout(runPrint, 100);
}
function onClose() {
errorText.value = '';
previewHtml.value = '';
}
watch(
() => [props.open, props.stdId] as const,
([isOpen, id]) => {
if (isOpen && id) {
void loadPreview(id);
}
if (!isOpen) {
onClose();
}
},
);
</script>
<style lang="less" scoped>
.preview-error {
color: #cf1322;
padding: 8px 0;
}
.preview-body {
min-height: 420px;
max-height: 72vh;
overflow: auto;
border: 1px solid #f0f0f0;
border-radius: 4px;
background: #fafafa;
}
.preview-iframe {
display: block;
width: 100%;
min-height: 400px;
border: 0;
background: #fff;
}
.preview-footer {
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid #f0f0f0;
text-align: right;
}
</style>

View File

@@ -9,6 +9,7 @@ enum Api {
bizTypesForBinding = '/print/bizTemplateBind/bizTypesForBinding',
permWhitelist = '/print/bizTemplateBind/permWhitelist',
parseTemplateFields = '/print/bizTemplateBind/parseTemplateFields',
parseTemplateStructure = '/print/bizTemplateBind/parseTemplateStructure',
previewMappedData = '/print/bizTemplateBind/previewMappedData',
detailSlots = '/print/bizTemplateBind/detailSlots',
bizFieldsForDetailSlot = '/print/bizTemplateBind/bizFieldsForDetailSlot',
@@ -36,6 +37,16 @@ export const parseTemplateFields = (templateId: string) =>
params: { templateId, _t: Date.now() },
});
/** 主表参数 + 按模板明细表分组(多标签映射) */
export const parseTemplateStructure = (templateId: string) =>
defHttp.get<{
params: { bindField: string; elementType?: string; titleHint?: string }[];
detailTables: { tableKey: string; label?: string; fields: { bindField: string; elementType?: string; titleHint?: string }[] }[];
}>({
url: Api.parseTemplateStructure,
params: { templateId, _t: Date.now() },
});
/** 预览映射后的打印数据 */
export const previewMappedData = (data: { bizCode: string; bizDataJson: Record<string, unknown> }) =>
defHttp.post({ url: Api.previewMappedData, data });

View File

@@ -47,7 +47,7 @@
show-icon
class="bind-alert"
message="配置说明"
description="按卡片顺序操作:先选业务与模板 → 若模板含明细占位,在「明细数据来源」中选择主实体上的集合/嵌套对象 → 点击「解析模板占位字段」→ 在下方「主表参数」「明细与表格」中分别为每个占位选择业务字段业务字段下拉第一项为「空占位符」,表示不参与业务 JSON 取值(等同输出空)。主表参数一般映射主实体字段;明细占位可选带「明细前缀」的路径(如 lines.qty。支持 lines.qty首行或 lines.0.qty。"
description="按卡片顺序操作:先选业务与模板 → 点击「解析模板占位字段」→ 主表参数映射主实体字段 → 若模板含多个明细表,在「明细与表格」标签页中逐表选择与模板明细键对应的业务明细集合,再映射列字段业务字段下拉第一项为「空占位符」,表示不参与业务 JSON明细占位多为「模板明细键.列」(如 List2.Field1业务侧选「明细属性.列」(如 lineList.qty打印时会按数组展开。"
/>
<a-card title="基础信息" size="small" :bordered="true" class="bind-card">
@@ -89,30 +89,6 @@
</a-form>
</a-card>
<a-card size="small" :bordered="true" class="bind-card">
<template #title>
<span class="bind-card-head">明细数据来源</span>
<span class="bind-card-head-extra">可选</span>
</template>
<template #extra>
<span class="bind-card-sub">有明细/表格占位时需配置</span>
</template>
<p class="bind-card-desc">
选择主实体类上的明细集合属性 List&lt;明细实体&gt;或嵌套对象系统将明细类字段并入下方明细与表格中的业务字段下拉
</p>
<a-select
v-model:value="selectedDetailProperty"
allow-clear
show-search
option-filter-prop="label"
placeholder="无需明细请留空"
:options="detailSlotSelectOptions"
:loading="detailFieldsLoading"
style="width: 100%"
@change="onDetailSlotChange"
/>
</a-card>
<a-card size="small" :bordered="true" class="bind-card bind-card--mapping">
<template #title>
<span class="bind-card-head">字段映射</span>
@@ -125,7 +101,7 @@
<a-button
size="small"
@click="autoMatchFields"
:disabled="(!bizFields.length && !detailBizFields.length) || !tplFields.length"
:disabled="(!bizFields.length && !hasAnyDetailBizFields()) || !tplFields.length"
>
同名自动匹配
</a-button>
@@ -170,35 +146,59 @@
<div class="bind-map-section bind-map-section--detail">
<div class="bind-section-bar">
<span class="bind-section-title"> 明细与表格列</span>
<span class="bind-section-hint">对应明细字段表格列等可选主表字段或上方明细来源生成的前缀字段</span>
<span class="bind-section-hint">
按模板明细表tableKey分页配置每个标签页先选业务明细集合再映射列多表明细互不影响
</span>
</div>
<a-table
v-if="mappingRowsDetail.length"
size="small"
row-key="templateField"
:pagination="false"
:columns="mapTableColumnsDetail"
:data-source="mappingRowsDetail"
bordered
class="bind-map-table"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'tplKind'">
{{ templateFieldKindLabel(record.elementType) }}
</template>
<template v-if="column.key === 'bizField'">
<template v-if="detailTablesStructure.length">
<a-tabs v-model:activeKey="detailTabKey" type="card" size="small" class="bind-detail-tabs">
<a-tab-pane v-for="dt in detailTablesStructure" :key="dt.tableKey" :tab="detailTabTitle(dt)">
<p class="bind-card-desc">
模板明细键 <code>{{ dt.tableKey }}</code>
对应画布表格等组件的数据源请选择主实体上要绑定到该明细表的业务集合或嵌套对象
</p>
<a-select
v-model:value="record.bizField"
:options="bizFieldOptions"
v-model:value="detailSlotByTable[dt.tableKey]"
allow-clear
show-search
option-filter-prop="label"
style="width: 100%"
placeholder="选择业务字段"
placeholder="选择业务明细属性(如 lineList"
:options="detailSlotSelectOptions"
:loading="!!detailFieldsLoadingMap[dt.tableKey]"
style="width: 100%; margin-bottom: 12px"
@change="(v) => onDetailSlotChangeForTable(dt.tableKey, v as string | undefined)"
/>
</template>
</template>
</a-table>
<a-table
v-if="mappingRowsForDetailTable(dt).length"
size="small"
row-key="templateField"
:pagination="false"
:columns="mapTableColumnsDetail"
:data-source="mappingRowsForDetailTable(dt)"
bordered
class="bind-map-table"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'tplKind'">
{{ templateFieldKindLabel(record.elementType) }}
</template>
<template v-if="column.key === 'bizField'">
<a-select
v-model:value="record.bizField"
:options="bizFieldOptionsForTable(dt.tableKey)"
allow-clear
show-search
option-filter-prop="label"
style="width: 100%"
placeholder="选择业务字段"
/>
</template>
</template>
</a-table>
<a-empty v-else class="bind-empty" description="该模板明细表下暂无占位字段(可在设计器中维护 dataBinding.detailTables" />
</a-tab-pane>
</a-tabs>
</template>
<a-empty v-else class="bind-empty" description="本模板未解析到明细/表格列占位" />
</div>
</template>
@@ -269,7 +269,7 @@
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { computed, reactive, ref, unref } from 'vue';
import { BasicTable, TableAction, useTable } from '/@/components/Table';
import { BasicModal, useModal } from '/@/components/Modal';
import { BasicTree, TreeItem } from '/@/components/Tree';
@@ -313,6 +313,12 @@
label: string;
}
interface TemplateDetailTableItem {
tableKey: string;
label?: string;
fields: TplFieldItem[];
}
const bizTypesRef = ref<BizTypeItem[]>([]);
const tplListRef = ref<{ id: string; templateCode: string; templateName: string }[]>([]);
/** 弹窗内:业务列表 + 模板下拉并行加载中(不再阻塞 openModal避免点按钮好几秒才出框 */
@@ -335,9 +341,12 @@
const bizFields = ref<BizTypeItem['fields']>([]);
const mappingRows = ref<MappingRow[]>([]);
const detailSlots = ref<DetailSlotItem[]>([]);
const selectedDetailProperty = ref<string | undefined>(undefined);
const detailBizFields = ref<BizTypeItem['fields']>([]);
const detailFieldsLoading = ref(false);
const detailTablesStructure = ref<TemplateDetailTableItem[]>([]);
const detailTabKey = ref('');
/** 每个模板明细表键对应选中的业务明细属性名 */
const detailSlotByTable = reactive<Record<string, string | undefined>>({});
const detailBizFieldsMap = reactive<Record<string, BizTypeItem['fields']>>({});
const detailFieldsLoadingMap = reactive<Record<string, boolean>>({});
const isEditMode = ref(false);
const modalTitle = computed(() => (unref(isEditMode) ? '编辑业务打印绑定' : '新增业务打印绑定'));
@@ -372,19 +381,125 @@
return [...head, ...rest];
});
/** 主表 + 明细前缀字段(用于明细/表格占位) */
const bizFieldOptions = computed(() => {
/** 某一模板明细表标签页:主表字段 + 该表选中的业务明细前缀字段 */
function bizFieldOptionsForTable(tableKey: string) {
const head = [{ label: '— 空占位符(不参与业务 JSON—', value: EMPTY_BIZ_FIELD_SENTINEL }];
const main = unref(bizFields).map((f) => ({
label: f.label ? `${f.label}${f.fieldKey}` : f.fieldKey,
value: f.fieldKey,
}));
const detail = unref(detailBizFields).map((f) => ({
const detail = (detailBizFieldsMap[tableKey] || []).map((f) => ({
label: f.label ? `${f.label}${f.fieldKey}` : f.fieldKey,
value: f.fieldKey,
}));
return [...head, ...main, ...detail];
});
}
function hasAnyDetailBizFields(): boolean {
for (const k in detailBizFieldsMap) {
if ((detailBizFieldsMap[k] || []).length) {
return true;
}
}
return false;
}
function detailTabTitle(dt: TemplateDetailTableItem) {
const hint = dt.label || '';
return hint ? `${hint}${dt.tableKey}` : dt.tableKey;
}
/** 属于某一模板明细表的映射行(与后端分组一致) */
function mappingRowsForDetailTable(dt: TemplateDetailTableItem): MappingRow[] {
const keys = new Set((dt.fields || []).map((f) => (f.bindField || '').trim()).filter(Boolean));
return unref(mappingRows).filter((r) => keys.has((r.templateField || '').trim()));
}
/** 根据已保存映射推断业务明细属性(编辑时用) */
function inferDetailSlotForTable(tableKey: string): string | undefined {
const dt = unref(detailTablesStructure).find((d) => d.tableKey === tableKey);
if (!dt?.fields?.length) {
return undefined;
}
const keySet = new Set(dt.fields.map((f) => (f.bindField || '').trim()).filter(Boolean));
const counts = new Map<string, number>();
for (const r of unref(mappingRows)) {
if (!keySet.has((r.templateField || '').trim())) {
continue;
}
const bf = r.bizField;
if (!bf || bf === EMPTY_BIZ_FIELD_SENTINEL) {
continue;
}
const s = String(bf);
const dot = s.indexOf('.');
if (dot <= 0) {
continue;
}
const head = s.slice(0, dot);
counts.set(head, (counts.get(head) || 0) + 1);
}
let best: string | undefined;
let bestN = 0;
counts.forEach((n, h) => {
if (n > bestN) {
bestN = n;
best = h;
}
});
return best;
}
async function loadBizFieldsForTableSlot(tableKey: string, propertyName: string | undefined) {
if (!propertyName || !form.value.bizCode) {
detailBizFieldsMap[tableKey] = [];
return;
}
const slot = unref(detailSlots).find((s) => s.propertyName === propertyName);
const kind = slot?.slotKind || 'LIST';
detailFieldsLoadingMap[tableKey] = true;
try {
const list = await Api.bizFieldsForDetailSlot({
bizCode: form.value.bizCode,
detailProperty: propertyName,
slotKind: kind,
});
detailBizFieldsMap[tableKey] = (list || []) as BizTypeItem['fields'];
} catch {
detailBizFieldsMap[tableKey] = [];
} finally {
detailFieldsLoadingMap[tableKey] = false;
}
}
async function onDetailSlotChangeForTable(tableKey: string, propertyName: string | undefined) {
detailSlotByTable[tableKey] = propertyName;
await loadBizFieldsForTableSlot(tableKey, propertyName);
}
async function restoreDetailSlotsFromMapping() {
for (const dt of unref(detailTablesStructure)) {
const tk = dt.tableKey;
const existing = detailSlotByTable[tk];
if (existing) {
await loadBizFieldsForTableSlot(tk, existing);
continue;
}
const inferred = inferDetailSlotForTable(tk);
if (inferred && unref(detailSlots).some((s) => s.propertyName === inferred)) {
detailSlotByTable[tk] = inferred;
await loadBizFieldsForTableSlot(tk, inferred);
}
}
}
function resetDetailTableUiState() {
detailTablesStructure.value = [];
detailTabKey.value = '';
Object.keys(detailSlotByTable).forEach((k) => delete detailSlotByTable[k]);
Object.keys(detailBizFieldsMap).forEach((k) => delete detailBizFieldsMap[k]);
Object.keys(detailFieldsLoadingMap).forEach((k) => delete detailFieldsLoadingMap[k]);
}
/** 已保存的空字符串映射为下拉哨兵,便于展示「空占位符」项 */
function normalizeBizFieldForUi(raw?: string) {
@@ -407,11 +522,6 @@
unref(mappingRows).filter((r) => (r.elementType || '') === 'param'),
);
/** 非参数占位(明细字段、表格列、其它画布元素) */
const mappingRowsDetail = computed(() =>
unref(mappingRows).filter((r) => (r.elementType || '') !== 'param'),
);
function templateFieldKindLabel(t?: string) {
const m: Record<string, string> = {
param: '主表·参数',
@@ -545,8 +655,6 @@
async function refreshDetailSlots(code: string | undefined) {
detailSlots.value = [];
selectedDetailProperty.value = undefined;
detailBizFields.value = [];
if (!code) {
return;
}
@@ -557,37 +665,20 @@
}
}
async function onDetailSlotChange(propertyName: string | undefined) {
selectedDetailProperty.value = propertyName;
if (!propertyName || !form.value.bizCode) {
detailBizFields.value = [];
return;
}
const slot = unref(detailSlots).find((s) => s.propertyName === propertyName);
const kind = slot?.slotKind || 'LIST';
detailFieldsLoading.value = true;
try {
const list = await Api.bizFieldsForDetailSlot({
bizCode: form.value.bizCode,
detailProperty: propertyName,
slotKind: kind,
});
detailBizFields.value = (list || []) as BizTypeItem['fields'];
} catch {
detailBizFields.value = [];
} finally {
detailFieldsLoading.value = false;
}
}
async function onBizCodeChange(code: string) {
const hit = unref(bizTypesRef).find((b) => b.bizCode === code);
bizFields.value = hit?.fields ?? [];
form.value.bizName = hit?.bizName;
Object.keys(detailSlotByTable).forEach((k) => delete detailSlotByTable[k]);
Object.keys(detailBizFieldsMap).forEach((k) => delete detailBizFieldsMap[k]);
await refreshDetailSlots(code);
if (form.value.templateId && unref(detailTablesStructure).length) {
await restoreDetailSlotsFromMapping();
}
}
async function onTemplateChange() {
resetDetailTableUiState();
tplFields.value = [];
mappingRows.value = [];
await reloadTemplateFields();
@@ -598,13 +689,20 @@
if (!tid) {
tplFields.value = [];
mappingRows.value = [];
detailTablesStructure.value = [];
detailTabKey.value = '';
return;
}
parseLoading.value = true;
try {
const list = (await Api.parseTemplateFields(tid)) as TplFieldItem[];
tplFields.value = list || [];
const structure = await Api.parseTemplateStructure(tid);
detailTablesStructure.value = structure?.detailTables ?? [];
const params = structure?.params ?? [];
const flatDetail = (structure?.detailTables ?? []).flatMap((d) => d.fields ?? []);
tplFields.value = [...params, ...flatDetail];
detailTabKey.value = detailTablesStructure.value[0]?.tableKey ?? '';
rebuildMappingRows();
await restoreDetailSlotsFromMapping();
} finally {
parseLoading.value = false;
}
@@ -648,7 +746,10 @@
const savedMappingRef = ref<{ templateField: string; bizField?: string }[]>([]);
function autoMatchFields() {
const merged = [...unref(bizFields), ...unref(detailBizFields)];
const merged = [...unref(bizFields)];
for (const k in detailBizFieldsMap) {
merged.push(...(detailBizFieldsMap[k] || []));
}
const set = new Map(merged.map((f) => [f.fieldKey, f.fieldKey]));
for (const row of unref(mappingRows)) {
if (set.has(row.templateField)) {
@@ -676,8 +777,7 @@
bizFields.value = [];
mappingRows.value = [];
detailSlots.value = [];
selectedDetailProperty.value = undefined;
detailBizFields.value = [];
resetDetailTableUiState();
previewBizJson.value = '';
previewResult.value = '';
openModal(true);
@@ -709,8 +809,7 @@
mappingRows.value = [];
bizFields.value = [];
detailSlots.value = [];
selectedDetailProperty.value = undefined;
detailBizFields.value = [];
resetDetailTableUiState();
openModal(true);
modalDataLoading.value = true;
try {
@@ -853,6 +952,14 @@
border-top: 1px dashed #f0f0f0;
}
.bind-detail-tabs {
margin-top: 4px;
}
.bind-detail-tabs :deep(.ant-tabs-nav) {
margin-bottom: 10px;
}
.bind-section-bar {
display: flex;
flex-wrap: wrap;

View File

@@ -0,0 +1,58 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslDowntimeMainType/list',
checkDowntimeType = '/xslmes/mesXslDowntimeMainType/checkDowntimeType',
save = '/xslmes/mesXslDowntimeMainType/add',
edit = '/xslmes/mesXslDowntimeMainType/edit',
deleteOne = '/xslmes/mesXslDowntimeMainType/delete',
deleteBatch = '/xslmes/mesXslDowntimeMainType/deleteBatch',
importExcel = '/xslmes/mesXslDowntimeMainType/importExcel',
exportXls = '/xslmes/mesXslDowntimeMainType/exportXls',
queryById = '/xslmes/mesXslDowntimeMainType/queryById',
}
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkDowntimeType = (params: { downtimeType: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkDowntimeType, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
export const deleteOne = (params, handleSuccess) => {
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
},
});
};
export const saveOrUpdate = (params, isUpdate) => {
const url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url, params });
};

View File

@@ -0,0 +1,113 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { checkDowntimeType } from './MesXslDowntimeMainType.api';
export const columns: BasicColumn[] = [
{ title: '工序名称', align: 'center', dataIndex: 'processOperationName', width: 160 },
{ title: '停机类型', align: 'center', dataIndex: 'downtimeType', width: 160 },
{ title: '显示顺序', align: 'center', dataIndex: 'displayOrder', width: 90 },
{
title: '区分颜色',
align: 'center',
dataIndex: 'distinguishColor',
width: 120,
customRender: ({ text }) => {
const c = text ? String(text) : '';
if (!c) {
return '';
}
return h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: '6px' } }, [
h('span', {
style: {
display: 'inline-block',
width: '20px',
height: '20px',
borderRadius: '2px',
backgroundColor: c,
border: '1px solid #d9d9d9',
},
}),
h('span', c),
]);
},
},
{ title: '是否启用', align: 'center', dataIndex: 'status_dictText', width: 100 },
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
{
title: '创建时间',
align: 'center',
dataIndex: 'createTime',
width: 165,
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
},
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
];
export const searchFormSchema: FormSchema[] = [
{ label: '工序名称', field: 'processOperationName', component: 'Input', colProps: { span: 6 } },
{ label: '停机类型', field: 'downtimeType', component: 'Input', colProps: { span: 6 } },
{
label: '是否启用',
field: 'status',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_downtime_main_type_status' },
colProps: { span: 6 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{ label: '', field: 'processOperationId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择所属工序' }] },
{
label: '所属工序',
field: 'processOperationName',
component: 'Input',
slot: 'processOperationPicker',
},
{
label: '停机类型',
field: 'downtimeType',
component: 'Input',
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入停机类型' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkDowntimeType({ downtimeType: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '停机类型不能重复';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{
label: '显示顺序',
field: 'displayOrder',
component: 'InputNumber',
defaultValue: 0,
componentProps: { min: 0, precision: 0, style: { width: '100%' } },
},
{
label: '区分颜色',
field: 'distinguishColor',
component: 'Input',
slot: 'distinguishColorPicker',
},
{
label: '是否启用',
field: 'status',
required: true,
defaultValue: '0',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_downtime_main_type_status', placeholder: '请选择' },
},
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_xsl_downtime_main_type:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_downtime_main_type:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_downtime_main_type:importExcel'"
preIcon="ant-design:import-outlined"
@click="onImportXls"
>
导入
</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'mes:mes_xsl_downtime_main_type:deleteBatch'">
批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_xsl_downtime_main_type:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslDowntimeMainTypeModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslDowntimeMainType" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslDowntimeMainTypeModal from './components/MesXslDowntimeMainTypeModal.vue';
import { columns, searchFormSchema } from './MesXslDowntimeMainType.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslDowntimeMainType.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '停机主类型',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 100,
autoSubmitOnEnter: true,
showAdvancedButton: true,
},
actionColumn: {
width: 200,
fixed: 'right',
},
},
exportConfig: {
name: '停机主类型',
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true });
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: true });
}
function handleDetail(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: false });
}
async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess);
}
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
}
function handleSuccess() {
selectedRowKeys.value = [];
reload();
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'mes:mes_xsl_downtime_main_type:delete',
},
];
}
</script>

Some files were not shown because too many files have changed in this diff Show More