Compare commits
24 Commits
b496a03190
...
cxversion
| Author | SHA1 | Date | |
|---|---|---|---|
| f2bfb001f2 | |||
|
|
2ffb3b4ebe | ||
|
|
21ffca5ded | ||
|
|
4571208ad9 | ||
|
|
5b3c59b632 | ||
|
|
890f7ea666 | ||
|
|
2e034eb6f2 | ||
|
|
8032f4c39c | ||
| e3b6915fbe | |||
| 530a0f13e7 | |||
|
|
3bfaec8cbc | ||
|
|
1b280af9e2 | ||
| 576bbfabdf | |||
| f2ca204147 | |||
| cfd7ca0a7e | |||
|
|
cea4781397 | ||
|
|
9201c7ca15 | ||
| f4d2ef21c8 | |||
| 44c6527a84 | |||
| 504dced34b | |||
| e7654ef0f6 | |||
| 31de1a0968 | |||
| 965bdf44db | |||
| 7b573cebdd |
@@ -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
|
||||
);
|
||||
|
||||
63
jeecg-boot/db/mes-process-operation-menu-permission.sql
Normal file
@@ -0,0 +1,63 @@
|
||||
-- MES 工序管理:建表 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_process_operation:*
|
||||
-- 修改租户:改 SET @mes_tenant_id;仅建表可只执行下面 CREATE 段或单独文件 mes-process-operation.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_process_operation` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`operation_code` varchar(64) NOT NULL COMMENT '工序编码',
|
||||
`operation_name` varchar(128) NOT NULL COMMENT '工序名称',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
`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_mpo_operation_code` (`operation_code`)
|
||||
) 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 ('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`), `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
|
||||
('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())
|
||||
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 (
|
||||
'1860000000000000060',
|
||||
'1860000000000000061', '1860000000000000062', '1860000000000000063', '1860000000000000064',
|
||||
'1860000000000000065', '1860000000000000066'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
18
jeecg-boot/db/mes-process-operation.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- 仅建表(与 Flyway V3.9.2_53 表结构一致)。建表+菜单+授权请执行 mes-process-operation-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_process_operation` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`operation_code` varchar(64) NOT NULL COMMENT '工序编码',
|
||||
`operation_name` varchar(128) NOT NULL COMMENT '工序名称',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
`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_mpo_operation_code` (`operation_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES工序管理';
|
||||
98
jeecg-boot/db/mes-xsl-equipment-category-menu-permission.sql
Normal file
@@ -0,0 +1,98 @@
|
||||
-- MES 设备类别:建表 + 字典 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_equipment_category:*
|
||||
-- 修改租户:改 SET @mes_tenant_id;Flyway 已含同内容时可只执行本脚本做手工补数
|
||||
-- 仅建表见 mes-xsl-equipment-category.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_category` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`category_name` varchar(128) NOT NULL COMMENT '设备类别名称',
|
||||
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序主键 mes_process_operation.id',
|
||||
`process_operation_name` varchar(128) DEFAULT NULL COMMENT '工序名称冗余展示',
|
||||
`inspect_distinct` varchar(32) NOT NULL COMMENT '点检区分 字典xslmes_equipment_inspect_distinct:generic通用 distinct区分',
|
||||
`maintain_distinct` varchar(32) NOT NULL COMMENT '保养区分 字典xslmes_equipment_maintain_distinct:maintain保养 distinct区分',
|
||||
`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_mec_tenant_name` (`tenant_id`, `category_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备类别';
|
||||
|
||||
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_inspect_distinct', '设备类别点检区分:通用/区分', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_equipment_inspect_distinct' 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, '通用', 'generic', 1, 1, 'admin', NOW()
|
||||
FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_equipment_inspect_distinct'
|
||||
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.`id` AND i.`item_value` = 'generic');
|
||||
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '区分', 'distinct', 2, 1, 'admin', NOW()
|
||||
FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_equipment_inspect_distinct'
|
||||
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.`id` AND i.`item_value` = 'distinct');
|
||||
|
||||
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_maintain_distinct', '设备类别保养区分:保养/区分', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_equipment_maintain_distinct' 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, '保养', 'maintain', 1, 1, 'admin', NOW()
|
||||
FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_equipment_maintain_distinct'
|
||||
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.`id` AND i.`item_value` = 'maintain');
|
||||
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '区分', 'distinct', 2, 1, 'admin', NOW()
|
||||
FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_equipment_maintain_distinct'
|
||||
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.`id` AND i.`item_value` = '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_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 ('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`), `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
|
||||
('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())
|
||||
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 (
|
||||
'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`
|
||||
);
|
||||
21
jeecg-boot/db/mes-xsl-equipment-category.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- 仅建表:MES 设备类别 mes_xsl_equipment_category
|
||||
-- 完整初始化(字典、菜单、租户授权)请执行 mes-xsl-equipment-category-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_category` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`category_name` varchar(128) NOT NULL COMMENT '设备类别名称',
|
||||
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序主键 mes_process_operation.id',
|
||||
`process_operation_name` varchar(128) DEFAULT NULL COMMENT '工序名称冗余展示',
|
||||
`inspect_distinct` varchar(32) NOT NULL COMMENT '点检区分 字典xslmes_equipment_inspect_distinct:generic通用 distinct区分',
|
||||
`maintain_distinct` varchar(32) NOT NULL COMMENT '保养区分 字典xslmes_equipment_maintain_distinct:maintain保养 distinct区分',
|
||||
`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_mec_tenant_name` (`tenant_id`, `category_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备类别';
|
||||
66
jeecg-boot/db/mes-xsl-equipment-part-menu-permission.sql
Normal file
@@ -0,0 +1,66 @@
|
||||
-- MES 设备部位:建表 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_equipment_part:*
|
||||
-- 依赖:mes_xsl_equipment_category;修改租户改 SET @mes_tenant_id
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`part_name` varchar(128) NOT NULL COMMENT '部位名称',
|
||||
`part_code` varchar(64) NOT NULL COMMENT '部位代码(同租户未删除数据中唯一)',
|
||||
`part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用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_mep_tenant_partcode` (`tenant_id`, `part_code`)
|
||||
) 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 ('1860000000000000084', @mes_base_pid, '设备部位', '/xslmes/mesXslEquipmentPart', 'xslmes/mesXslEquipmentPart/MesXslEquipmentPartList', NULL, 1, NULL, '1', 12, 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
|
||||
('1860000000000000085', '1860000000000000084', '新增', 2, 'mes:mes_xsl_equipment_part:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000086', '1860000000000000084', '编辑', 2, 'mes:mes_xsl_equipment_part:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000087', '1860000000000000084', '删除', 2, 'mes:mes_xsl_equipment_part:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000088', '1860000000000000084', '批量删除', 2, 'mes:mes_xsl_equipment_part:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000089', '1860000000000000084', '导出', 2, 'mes:mes_xsl_equipment_part:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000090', '1860000000000000084', '导入', 2, 'mes:mes_xsl_equipment_part: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 (
|
||||
'1860000000000000084',
|
||||
'1860000000000000085', '1860000000000000086', '1860000000000000087', '1860000000000000088',
|
||||
'1860000000000000089', '1860000000000000090'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
22
jeecg-boot/db/mes-xsl-equipment-part.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- 仅建表:MES 设备部位 mes_xsl_equipment_part
|
||||
-- 完整初始化(菜单、租户授权)请执行 mes-xsl-equipment-part-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`part_name` varchar(128) NOT NULL COMMENT '部位名称',
|
||||
`part_code` varchar(64) NOT NULL COMMENT '部位代码(同租户未删除数据中唯一)',
|
||||
`part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用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_mep_tenant_partcode` (`tenant_id`, `part_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备部位';
|
||||
69
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
Normal file
@@ -0,0 +1,69 @@
|
||||
-- MES 设备小部位:建表 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_equipment_sub_part:*
|
||||
-- 依赖:mes_xsl_equipment_category、mes_xsl_equipment_part;二级菜单父级为「MES XSL / XSLMES管理」(sys_permission.id 1900000000000000300 或按名称解析)
|
||||
-- 修改租户改 SET @mes_tenant_id;已跑过 Flyway 的旧库可另执行 V3.9.2_60 仅改 parent_id
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_sub_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`equipment_part_id` varchar(32) NOT NULL COMMENT '所属设备大部位主键 mes_xsl_equipment_part.id',
|
||||
`equipment_part_name` varchar(128) DEFAULT NULL COMMENT '设备大部位名称冗余(mes_xsl_equipment_part.part_name)',
|
||||
`sub_part_name` varchar(128) NOT NULL COMMENT '小部位名称',
|
||||
`sub_part_code` varchar(64) NOT NULL COMMENT '小部位代码(同租户未删除数据中唯一)',
|
||||
`sub_part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用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_mesp_tenant_subcode` (`tenant_id`, `sub_part_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备小部位';
|
||||
|
||||
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 @xslmes_root_pid = IFNULL(@xslmes_root_pid, '1900000000000000300');
|
||||
|
||||
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())
|
||||
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
|
||||
('1860000000000000092', '1860000000000000091', '新增', 2, 'mes:mes_xsl_equipment_sub_part:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000093', '1860000000000000091', '编辑', 2, 'mes:mes_xsl_equipment_sub_part:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000094', '1860000000000000091', '删除', 2, 'mes:mes_xsl_equipment_sub_part:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000095', '1860000000000000091', '批量删除', 2, 'mes:mes_xsl_equipment_sub_part:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000096', '1860000000000000091', '导出', 2, 'mes:mes_xsl_equipment_sub_part:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000097', '1860000000000000091', '导入', 2, 'mes:mes_xsl_equipment_sub_part: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 (
|
||||
'1860000000000000091',
|
||||
'1860000000000000092', '1860000000000000093', '1860000000000000094', '1860000000000000095',
|
||||
'1860000000000000096', '1860000000000000097'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
24
jeecg-boot/db/mes-xsl-equipment-sub-part.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- 仅建表:MES 设备小部位 mes_xsl_equipment_sub_part
|
||||
-- 完整初始化(建表 + 菜单 + 租户授权)请执行 mes-xsl-equipment-sub-part-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_sub_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`equipment_part_id` varchar(32) NOT NULL COMMENT '所属设备大部位主键 mes_xsl_equipment_part.id',
|
||||
`equipment_part_name` varchar(128) DEFAULT NULL COMMENT '设备大部位名称冗余(mes_xsl_equipment_part.part_name)',
|
||||
`sub_part_name` varchar(128) NOT NULL COMMENT '小部位名称',
|
||||
`sub_part_code` varchar(64) NOT NULL COMMENT '小部位代码(同租户未删除数据中唯一)',
|
||||
`sub_part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用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_mesp_tenant_subcode` (`tenant_id`, `sub_part_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备小部位';
|
||||
65
jeecg-boot/db/mes-xsl-equipment-type-menu-permission.sql
Normal file
@@ -0,0 +1,65 @@
|
||||
-- MES 设备类型:建表 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_equipment_type:*
|
||||
-- 依赖:mes_process_operation、mes_xsl_equipment_category;修改租户改 SET @mes_tenant_id
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_type` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`type_name` varchar(128) NOT NULL COMMENT '设备类型名称',
|
||||
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序主键 mes_process_operation.id',
|
||||
`process_operation_name` varchar(128) DEFAULT NULL COMMENT '工序名称冗余展示',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`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_met_tenant_typename` (`tenant_id`, `type_name`)
|
||||
) 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 ('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`), `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
|
||||
('1860000000000000078', '1860000000000000077', '新增', 2, 'mes:mes_xsl_equipment_type:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000079', '1860000000000000077', '编辑', 2, 'mes:mes_xsl_equipment_type:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000080', '1860000000000000077', '删除', 2, 'mes:mes_xsl_equipment_type:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000081', '1860000000000000077', '批量删除', 2, 'mes:mes_xsl_equipment_type:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000082', '1860000000000000077', '导出', 2, 'mes:mes_xsl_equipment_type:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000083', '1860000000000000077', '导入', 2, 'mes:mes_xsl_equipment_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 (
|
||||
'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`
|
||||
);
|
||||
21
jeecg-boot/db/mes-xsl-equipment-type.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- 仅建表:MES 设备类型 mes_xsl_equipment_type
|
||||
-- 完整初始化(菜单、租户授权)请执行 mes-xsl-equipment-type-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_type` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`type_name` varchar(128) NOT NULL COMMENT '设备类型名称',
|
||||
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序主键 mes_process_operation.id',
|
||||
`process_operation_name` varchar(128) DEFAULT NULL COMMENT '工序名称冗余展示',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`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_met_tenant_typename` (`tenant_id`, `type_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备类型';
|
||||
89
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
Normal file
@@ -0,0 +1,89 @@
|
||||
-- MES 厂家信息:字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_manufacturer:*
|
||||
-- 父菜单:MES基础资料 / MES资料(与备品件等脚本相同 @mes_base_pid);修改租户改 SET @mes_tenant_id
|
||||
-- 新环境也可依赖 Flyway:V3.9.2_63__mes_xsl_manufacturer.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_manufacturer_category', '模具厂家、胶囊厂家、设备厂家', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_manufacturer_category' 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, '模具厂家', 'mold', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'mold');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '胶囊厂家', 'capsule', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'capsule');
|
||||
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', 3, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_manufacturer_category' 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` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
|
||||
SELECT REPLACE(UUID(), '-', ''), 'MES厂家是否有效', 'xslmes_manufacturer_valid', '0有效1无效', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_manufacturer_valid' 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_manufacturer_valid' 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_manufacturer_valid' 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_manufacturer` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`manufacturer_category` varchar(32) NOT NULL COMMENT '厂家类别(字典xslmes_manufacturer_category:mold模具 capsule胶囊 equipment设备)',
|
||||
`manufacturer_name` varchar(128) NOT NULL COMMENT '厂家名称(同租户未删除数据中唯一)',
|
||||
`valid_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否有效(字典xslmes_manufacturer_valid:0有效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_mxm_tenant_name` (`tenant_id`, `manufacturer_name`)
|
||||
) 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 ('1860000000000000112', @mes_base_pid, '厂家信息', '/xslmes/mesXslManufacturer', 'xslmes/mesXslManufacturer/MesXslManufacturerList', NULL, 1, NULL, '1', 17, 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
|
||||
('1860000000000000113', '1860000000000000112', '新增', 2, 'mes:mes_xsl_manufacturer:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000114', '1860000000000000112', '编辑', 2, 'mes:mes_xsl_manufacturer:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000115', '1860000000000000112', '删除', 2, 'mes:mes_xsl_manufacturer:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000116', '1860000000000000112', '批量删除', 2, 'mes:mes_xsl_manufacturer:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000117', '1860000000000000112', '导出', 2, 'mes:mes_xsl_manufacturer:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000118', '1860000000000000112', '导入', 2, 'mes:mes_xsl_manufacturer: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 (
|
||||
'1860000000000000112',
|
||||
'1860000000000000113', '1860000000000000114', '1860000000000000115', '1860000000000000116',
|
||||
'1860000000000000117', '1860000000000000118'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
18
jeecg-boot/db/mes-xsl-manufacturer.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- 仅建表 mes_xsl_manufacturer。完整初始化(厂家类别/是否有效字典、菜单、租户授权)请执行 mes-xsl-manufacturer-menu-permission.sql
|
||||
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_category:mold模具 capsule胶囊 equipment设备)',
|
||||
`manufacturer_name` varchar(128) NOT NULL COMMENT '厂家名称(同租户未删除数据中唯一)',
|
||||
`valid_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否有效(字典xslmes_manufacturer_valid:0有效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_mxm_tenant_name` (`tenant_id`, `manufacturer_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES厂家信息';
|
||||
37
jeecg-boot/db/mes-xsl-raw-material-summary-menu.sql
Normal 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'
|
||||
);
|
||||
|
||||
68
jeecg-boot/db/mes-xsl-spare-part-menu-permission.sql
Normal file
@@ -0,0 +1,68 @@
|
||||
-- MES 备品件信息:建表 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_spare_part:*
|
||||
-- 依赖:mes_xsl_spare_parts_category、mes_xsl_unit;父菜单 MES基础资料 / MES资料;修改租户改 SET @mes_tenant_id
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_spare_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`spare_part_name` varchar(128) NOT NULL COMMENT '备品件名称(同租户未删除数据中唯一)',
|
||||
`spare_parts_category_id` varchar(32) NOT NULL COMMENT '所属备品件类别 mes_xsl_spare_parts_category.id',
|
||||
`spare_parts_category_name` varchar(128) DEFAULT NULL COMMENT '备品件类别名称冗余',
|
||||
`spec_model` varchar(200) DEFAULT NULL COMMENT '规格型号',
|
||||
`max_stock` decimal(18,4) NOT NULL DEFAULT '0.0000' COMMENT '最大库存',
|
||||
`min_stock` decimal(18,4) NOT NULL DEFAULT '0.0000' COMMENT '最小库存',
|
||||
`unit_id` varchar(36) NOT NULL COMMENT '单位 mes_xsl_unit.id',
|
||||
`unit_name` varchar(100) DEFAULT NULL COMMENT '单位名称冗余',
|
||||
`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_msp_tenant_name` (`tenant_id`, `spare_part_name`)
|
||||
) 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 ('1860000000000000105', @mes_base_pid, '备品件信息', '/xslmes/mesXslSparePart', 'xslmes/mesXslSparePart/MesXslSparePartList', NULL, 1, NULL, '1', 16, 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
|
||||
('1860000000000000106', '1860000000000000105', '新增', 2, 'mes:mes_xsl_spare_part:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000107', '1860000000000000105', '编辑', 2, 'mes:mes_xsl_spare_part:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000108', '1860000000000000105', '删除', 2, 'mes:mes_xsl_spare_part:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000109', '1860000000000000105', '批量删除', 2, 'mes:mes_xsl_spare_part:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000110', '1860000000000000105', '导出', 2, 'mes:mes_xsl_spare_part:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000111', '1860000000000000105', '导入', 2, 'mes:mes_xsl_spare_part: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 (
|
||||
'1860000000000000105',
|
||||
'1860000000000000106', '1860000000000000107', '1860000000000000108', '1860000000000000109',
|
||||
'1860000000000000110', '1860000000000000111'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
24
jeecg-boot/db/mes-xsl-spare-part.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- 仅建表:MES 备品件信息 mes_xsl_spare_part
|
||||
-- 完整初始化请执行 mes-xsl-spare-part-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_spare_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`spare_part_name` varchar(128) NOT NULL COMMENT '备品件名称(同租户未删除数据中唯一)',
|
||||
`spare_parts_category_id` varchar(32) NOT NULL COMMENT '所属备品件类别 mes_xsl_spare_parts_category.id',
|
||||
`spare_parts_category_name` varchar(128) DEFAULT NULL COMMENT '备品件类别名称冗余',
|
||||
`spec_model` varchar(200) DEFAULT NULL COMMENT '规格型号',
|
||||
`max_stock` decimal(18,4) NOT NULL DEFAULT '0.0000' COMMENT '最大库存',
|
||||
`min_stock` decimal(18,4) NOT NULL DEFAULT '0.0000' COMMENT '最小库存',
|
||||
`unit_id` varchar(36) NOT NULL COMMENT '单位 mes_xsl_unit.id',
|
||||
`unit_name` varchar(100) DEFAULT NULL COMMENT '单位名称冗余',
|
||||
`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_msp_tenant_name` (`tenant_id`, `spare_part_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES备品件信息';
|
||||
@@ -0,0 +1,62 @@
|
||||
-- MES 备品件类别:建表 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_spare_parts_category:*
|
||||
-- 父菜单:MES基础资料 / MES资料;修改租户改 SET @mes_tenant_id
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_spare_parts_category` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`category_name` varchar(128) NOT NULL COMMENT '类别名称(同租户未删除数据中唯一)',
|
||||
`category_description` varchar(500) DEFAULT NULL COMMENT '描述',
|
||||
`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_mspc_tenant_catname` (`tenant_id`, `category_name`)
|
||||
) 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 ('1860000000000000098', @mes_base_pid, '备品件类别', '/xslmes/mesXslSparePartsCategory', 'xslmes/mesXslSparePartsCategory/MesXslSparePartsCategoryList', NULL, 1, NULL, '1', 15, 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
|
||||
('1860000000000000099', '1860000000000000098', '新增', 2, 'mes:mes_xsl_spare_parts_category:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000100', '1860000000000000098', '编辑', 2, 'mes:mes_xsl_spare_parts_category:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000101', '1860000000000000098', '删除', 2, 'mes:mes_xsl_spare_parts_category:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000102', '1860000000000000098', '批量删除', 2, 'mes:mes_xsl_spare_parts_category:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000103', '1860000000000000098', '导出', 2, 'mes:mes_xsl_spare_parts_category:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000104', '1860000000000000098', '导入', 2, 'mes:mes_xsl_spare_parts_category: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 (
|
||||
'1860000000000000098',
|
||||
'1860000000000000099', '1860000000000000100', '1860000000000000101', '1860000000000000102',
|
||||
'1860000000000000103', '1860000000000000104'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
18
jeecg-boot/db/mes-xsl-spare-parts-category.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- 仅建表:MES 备品件类别 mes_xsl_spare_parts_category
|
||||
-- 完整初始化(建表 + 菜单 + 租户授权)请执行 mes-xsl-spare-parts-category-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_spare_parts_category` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`category_name` varchar(128) NOT NULL COMMENT '类别名称(同租户未删除数据中唯一)',
|
||||
`category_description` varchar(500) DEFAULT NULL COMMENT '描述',
|
||||
`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_mspc_tenant_catname` (`tenant_id`, `category_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES备品件类别';
|
||||
@@ -670,7 +670,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 +697,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());
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
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 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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
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/mesXslEquipmentCategory")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentCategoryController extends JeecgController<MesXslEquipmentCategory, IMesXslEquipmentCategoryService> {
|
||||
|
||||
private static final Set<String> INSPECT_DISTINCT = Set.of("generic", "distinct");
|
||||
private static final Set<String> MAINTAIN_DISTINCT = Set.of("maintain", "distinct");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Operation(summary = "MES设备类别-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentCategory>> queryPageList(
|
||||
MesXslEquipmentCategory model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentCategory> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentCategory> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentCategory> pageList = mesXslEquipmentCategoryService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类别-添加")
|
||||
@Operation(summary = "MES设备类别-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentCategory model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类别:名称唯一、工序与字典校验、冗余工序名称-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类别:名称唯一、工序与字典校验、冗余工序名称-----------
|
||||
mesXslEquipmentCategoryService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类别-编辑")
|
||||
@Operation(summary = "MES设备类别-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentCategory model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类别:名称唯一、工序与字典校验、冗余工序名称-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类别:名称唯一、工序与字典校验、冗余工序名称-----------
|
||||
mesXslEquipmentCategoryService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类别-删除")
|
||||
@Operation(summary = "MES设备类别-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentCategoryService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类别-批量删除")
|
||||
@Operation(summary = "MES设备类别-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentCategoryService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备类别-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentCategory> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentCategory entity = mesXslEquipmentCategoryService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验设备类别名称是否重复(仅未删除数据;同租户,dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkCategoryName")
|
||||
public Result<String> checkCategoryName(
|
||||
@RequestParam(name = "categoryName", required = true) String categoryName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(categoryName) || categoryName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentCategory ctx = new MesXslEquipmentCategory();
|
||||
if (mesXslEquipmentCategoryService.isCategoryNameDuplicated(categoryName.trim(), dataId, ctx)) {
|
||||
return Result.error("该类别名称已存在");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentCategory model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentCategory.class, "MES设备类别");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260514 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<MesXslEquipmentCategory> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentCategory.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentCategory row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String name = row.getCategoryName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(name)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类别名称不能为空");
|
||||
}
|
||||
row.setCategoryName(name);
|
||||
if (!namesInFile.add(name)) {
|
||||
return Result.error("文件导入失败:类别名称【" + name + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslEquipmentCategoryService.isCategoryNameDuplicated(name, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类别名称【" + name + "】已存在(未删除数据中不允许重复)");
|
||||
}
|
||||
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());
|
||||
row.setImportOperationCode(null);
|
||||
|
||||
String ins = row.getInspectDistinct();
|
||||
if (ins != null) {
|
||||
ins = ins.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ins) || !INSPECT_DISTINCT.contains(ins)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条点检区分须为字典项值 generic 或 distinct");
|
||||
}
|
||||
row.setInspectDistinct(ins);
|
||||
|
||||
String mtn = row.getMaintainDistinct();
|
||||
if (mtn != null) {
|
||||
mtn = mtn.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(mtn) || !MAINTAIN_DISTINCT.contains(mtn)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条保养区分须为字典项值 maintain 或 distinct");
|
||||
}
|
||||
row.setMaintainDistinct(mtn);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentCategoryService.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:20260514 for:【MES】设备类别导入:名称唯一、工序编码解析、字典取值校验-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类别保存前校验与工序名称回填-----------
|
||||
private String validateForSave(MesXslEquipmentCategory model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getCategoryName()) || model.getCategoryName().trim().isEmpty()) {
|
||||
return "类别名称不能为空";
|
||||
}
|
||||
String cn = model.getCategoryName().trim();
|
||||
model.setCategoryName(cn);
|
||||
if (mesXslEquipmentCategoryService.isCategoryNameDuplicated(cn, excludeId, model)) {
|
||||
return "类别名称已存在";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
|
||||
return "请选择所属工序";
|
||||
}
|
||||
MesXslProcessOperation op = mesXslProcessOperationService.getById(model.getProcessOperationId());
|
||||
if (op == null) {
|
||||
return "所属工序不存在";
|
||||
}
|
||||
model.setProcessOperationName(op.getOperationName());
|
||||
|
||||
String ins = model.getInspectDistinct();
|
||||
if (ins != null) {
|
||||
ins = ins.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ins) || !INSPECT_DISTINCT.contains(ins)) {
|
||||
return "点检区分不合法(须为字典项值 generic 或 distinct)";
|
||||
}
|
||||
model.setInspectDistinct(ins);
|
||||
|
||||
String mtn = model.getMaintainDistinct();
|
||||
if (mtn != null) {
|
||||
mtn = mtn.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(mtn) || !MAINTAIN_DISTINCT.contains(mtn)) {
|
||||
return "保养区分不合法(须为字典项值 maintain 或 distinct)";
|
||||
}
|
||||
model.setMaintainDistinct(mtn);
|
||||
model.setImportOperationCode(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private MesXslProcessOperation findProcessByOperationCode(String operationCode, MesXslEquipmentCategory 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:20260514 for:【MES】设备类别保存前校验与工序名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService;
|
||||
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/mesXslEquipmentPart")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentPartController extends JeecgController<MesXslEquipmentPart, IMesXslEquipmentPartService> {
|
||||
|
||||
private static final Set<String> ENABLE_STATUS = Set.of("0", "1");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentPartService mesXslEquipmentPartService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Operation(summary = "MES设备部位-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentPart>> queryPageList(
|
||||
MesXslEquipmentPart model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentPart> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentPart> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentPart> pageList = mesXslEquipmentPartService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备部位-添加")
|
||||
@Operation(summary = "MES设备部位-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentPart model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备部位:部位代码唯一、设备类别与启用状态校验、冗余类别名称-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备部位:部位代码唯一、设备类别与启用状态校验、冗余类别名称-----------
|
||||
mesXslEquipmentPartService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备部位-编辑")
|
||||
@Operation(summary = "MES设备部位-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentPart model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备部位:部位代码唯一、设备类别与启用状态校验、冗余类别名称-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备部位:部位代码唯一、设备类别与启用状态校验、冗余类别名称-----------
|
||||
mesXslEquipmentPartService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备部位-删除")
|
||||
@Operation(summary = "MES设备部位-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentPartService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备部位-批量删除")
|
||||
@Operation(summary = "MES设备部位-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentPartService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备部位-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentPart> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentPart entity = mesXslEquipmentPartService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验部位代码是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkPartCode")
|
||||
public Result<String> checkPartCode(
|
||||
@RequestParam(name = "partCode", required = true) String partCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(partCode) || partCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentPart ctx = new MesXslEquipmentPart();
|
||||
if (mesXslEquipmentPartService.isPartCodeDuplicated(partCode.trim(), dataId, ctx)) {
|
||||
return Result.error("部位代码不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentPart model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentPart.class, "MES设备部位");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260515 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<MesXslEquipmentPart> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentPart.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentPart row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String pc = row.getPartCode();
|
||||
if (pc != null) {
|
||||
pc = pc.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(pc)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条部位代码不能为空");
|
||||
}
|
||||
row.setPartCode(pc);
|
||||
String catName = row.getImportCategoryName();
|
||||
if (catName != null) {
|
||||
catName = catName.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(catName)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称不能为空");
|
||||
}
|
||||
MesXslEquipmentCategory cat =
|
||||
mesXslEquipmentCategoryService.findOneActiveByNameAndTenant(catName, row.getTenantId());
|
||||
if (cat == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称【" + catName + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
row.setEquipmentCategoryId(cat.getId());
|
||||
row.setEquipmentCategoryName(cat.getCategoryName());
|
||||
row.setImportCategoryName(null);
|
||||
if (!codesInFile.add(pc)) {
|
||||
return Result.error("文件导入失败:部位代码【" + pc + "】在导入文件中重复(部位代码不能重复)");
|
||||
}
|
||||
if (mesXslEquipmentPartService.isPartCodeDuplicated(pc, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条部位代码【" + pc + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
|
||||
if (row.getPartName() != null) {
|
||||
row.setPartName(row.getPartName().trim());
|
||||
}
|
||||
if (row.getPartDescription() != null) {
|
||||
row.setPartDescription(row.getPartDescription().trim());
|
||||
}
|
||||
|
||||
String en = row.getEnableStatus();
|
||||
if (en != null) {
|
||||
en = en.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(en)) {
|
||||
en = "0";
|
||||
}
|
||||
if (!ENABLE_STATUS.contains(en)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条是否启用须为字典项值 0 或 1(xslmes_unit_status)");
|
||||
}
|
||||
row.setEnableStatus(en);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentPartService.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:20260515 for:【MES】设备部位导入:部位代码唯一、设备类别名称解析、启用状态校验-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备部位保存前校验与类别名称回填-----------
|
||||
private String validateForSave(MesXslEquipmentPart model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentCategoryId())) {
|
||||
return "请选择所属设备类别";
|
||||
}
|
||||
MesXslEquipmentCategory cat = mesXslEquipmentCategoryService.getById(model.getEquipmentCategoryId());
|
||||
if (cat == null) {
|
||||
return "所属设备类别不存在";
|
||||
}
|
||||
model.setEquipmentCategoryName(cat.getCategoryName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getPartCode()) || model.getPartCode().trim().isEmpty()) {
|
||||
return "部位代码不能为空";
|
||||
}
|
||||
String pc = model.getPartCode().trim();
|
||||
model.setPartCode(pc);
|
||||
if (mesXslEquipmentPartService.isPartCodeDuplicated(pc, excludeId, model)) {
|
||||
return "部位代码不能重复";
|
||||
}
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getPartName()) || model.getPartName().trim().isEmpty()) {
|
||||
return "部位名称不能为空";
|
||||
}
|
||||
model.setPartName(model.getPartName().trim());
|
||||
|
||||
String en = model.getEnableStatus();
|
||||
if (en != null) {
|
||||
en = en.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(en)) {
|
||||
en = "0";
|
||||
}
|
||||
if (!ENABLE_STATUS.contains(en)) {
|
||||
return "是否启用不合法(须为字典项值 0 或 1,xslmes_unit_status)";
|
||||
}
|
||||
model.setEnableStatus(en);
|
||||
|
||||
if (model.getPartDescription() != null) {
|
||||
model.setPartDescription(model.getPartDescription().trim());
|
||||
}
|
||||
model.setImportCategoryName(null);
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备部位保存前校验与类别名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentSubPartService;
|
||||
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/mesXslEquipmentSubPart")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentSubPartController extends JeecgController<MesXslEquipmentSubPart, IMesXslEquipmentSubPartService> {
|
||||
|
||||
private static final Set<String> ENABLE_STATUS = Set.of("0", "1");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentSubPartService mesXslEquipmentSubPartService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentPartService mesXslEquipmentPartService;
|
||||
|
||||
@Operation(summary = "MES设备小部位-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentSubPart>> queryPageList(
|
||||
MesXslEquipmentSubPart model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentSubPart> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentSubPart> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentSubPart> pageList = mesXslEquipmentSubPartService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-添加")
|
||||
@Operation(summary = "MES设备小部位-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentSubPart model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
mesXslEquipmentSubPartService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-编辑")
|
||||
@Operation(summary = "MES设备小部位-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentSubPart model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
mesXslEquipmentSubPartService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-删除")
|
||||
@Operation(summary = "MES设备小部位-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentSubPartService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-批量删除")
|
||||
@Operation(summary = "MES设备小部位-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentSubPartService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备小部位-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentSubPart> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentSubPart entity = mesXslEquipmentSubPartService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验小部位代码是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkSubPartCode")
|
||||
public Result<String> checkSubPartCode(
|
||||
@RequestParam(name = "subPartCode", required = true) String subPartCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(subPartCode) || subPartCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentSubPart ctx = new MesXslEquipmentSubPart();
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(subPartCode.trim(), dataId, ctx)) {
|
||||
return Result.error("小部位代码不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentSubPart model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentSubPart.class, "MES设备小部位");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260515 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<MesXslEquipmentSubPart> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentSubPart.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentSubPart row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String sc = row.getSubPartCode();
|
||||
if (sc != null) {
|
||||
sc = sc.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(sc)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位代码不能为空");
|
||||
}
|
||||
row.setSubPartCode(sc);
|
||||
String catName = row.getImportCategoryName();
|
||||
if (catName != null) {
|
||||
catName = catName.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(catName)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称不能为空");
|
||||
}
|
||||
MesXslEquipmentCategory cat =
|
||||
mesXslEquipmentCategoryService.findOneActiveByNameAndTenant(catName, row.getTenantId());
|
||||
if (cat == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称【" + catName + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
row.setEquipmentCategoryId(cat.getId());
|
||||
row.setEquipmentCategoryName(cat.getCategoryName());
|
||||
|
||||
String ipc = row.getImportEquipmentPartCode();
|
||||
if (ipc != null) {
|
||||
ipc = ipc.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ipc)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条大部位代码不能为空");
|
||||
}
|
||||
MesXslEquipmentPart part =
|
||||
mesXslEquipmentPartService.findOneActiveByPartCodeAndTenant(ipc, row.getTenantId());
|
||||
if (part == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条大部位代码【" + ipc + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
if (!cat.getId().equals(part.getEquipmentCategoryId())) {
|
||||
return Result.error(
|
||||
"文件导入失败:第 " + rowNo + " 条设备类别名称与所选大部位不匹配(大部位所属类别须与类别名称一致)");
|
||||
}
|
||||
row.setEquipmentPartId(part.getId());
|
||||
row.setEquipmentPartName(part.getPartName());
|
||||
row.setImportCategoryName(null);
|
||||
row.setImportEquipmentPartCode(null);
|
||||
|
||||
if (oConvertUtils.isEmpty(row.getSubPartName()) || row.getSubPartName().trim().isEmpty()) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位名称不能为空");
|
||||
}
|
||||
row.setSubPartName(row.getSubPartName().trim());
|
||||
|
||||
if (!codesInFile.add(sc)) {
|
||||
return Result.error("文件导入失败:小部位代码【" + sc + "】在导入文件中重复(小部位代码不能重复)");
|
||||
}
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(sc, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位代码【" + sc + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
|
||||
if (row.getSubPartDescription() != null) {
|
||||
row.setSubPartDescription(row.getSubPartDescription().trim());
|
||||
}
|
||||
|
||||
String en = row.getEnableStatus();
|
||||
if (en != null) {
|
||||
en = en.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(en)) {
|
||||
en = "0";
|
||||
}
|
||||
if (!ENABLE_STATUS.contains(en)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条是否启用须为字典项值 0 或 1(xslmes_unit_status)");
|
||||
}
|
||||
row.setEnableStatus(en);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentSubPartService.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:20260515 for:【MES】设备小部位导入:小部位代码唯一、类别名称与大部位代码解析、与大部位类别一致性-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验与冗余名称回填-----------
|
||||
private String validateForSave(MesXslEquipmentSubPart model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentCategoryId())) {
|
||||
return "请选择所属设备类别";
|
||||
}
|
||||
MesXslEquipmentCategory cat = mesXslEquipmentCategoryService.getById(model.getEquipmentCategoryId());
|
||||
if (cat == null) {
|
||||
return "所属设备类别不存在";
|
||||
}
|
||||
model.setEquipmentCategoryName(cat.getCategoryName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentPartId())) {
|
||||
return "请选择所属设备大部位";
|
||||
}
|
||||
MesXslEquipmentPart part = mesXslEquipmentPartService.getById(model.getEquipmentPartId());
|
||||
if (part == null) {
|
||||
return "所属设备大部位不存在";
|
||||
}
|
||||
if (!model.getEquipmentCategoryId().equals(part.getEquipmentCategoryId())) {
|
||||
return "所属设备类别与所选设备大部位不匹配";
|
||||
}
|
||||
model.setEquipmentPartName(part.getPartName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getSubPartCode()) || model.getSubPartCode().trim().isEmpty()) {
|
||||
return "小部位代码不能为空";
|
||||
}
|
||||
String sc = model.getSubPartCode().trim();
|
||||
model.setSubPartCode(sc);
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(sc, excludeId, model)) {
|
||||
return "小部位代码不能重复";
|
||||
}
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getSubPartName()) || model.getSubPartName().trim().isEmpty()) {
|
||||
return "小部位名称不能为空";
|
||||
}
|
||||
model.setSubPartName(model.getSubPartName().trim());
|
||||
|
||||
String en = model.getEnableStatus();
|
||||
if (en != null) {
|
||||
en = en.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(en)) {
|
||||
en = "0";
|
||||
}
|
||||
if (!ENABLE_STATUS.contains(en)) {
|
||||
return "是否启用不合法(须为字典项值 0 或 1,xslmes_unit_status)";
|
||||
}
|
||||
model.setEnableStatus(en);
|
||||
|
||||
if (model.getSubPartDescription() != null) {
|
||||
model.setSubPartDescription(model.getSubPartDescription().trim());
|
||||
}
|
||||
model.setImportCategoryName(null);
|
||||
model.setImportEquipmentPartCode(null);
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验与冗余名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
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 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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentType;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentTypeService;
|
||||
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/mesXslEquipmentType")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentTypeController extends JeecgController<MesXslEquipmentType, IMesXslEquipmentTypeService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentTypeService mesXslEquipmentTypeService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Operation(summary = "MES设备类型-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentType>> queryPageList(
|
||||
MesXslEquipmentType model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentType> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentType> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentType> pageList = mesXslEquipmentTypeService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类型-添加")
|
||||
@Operation(summary = "MES设备类型-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentType model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型:名称唯一、工序与设备类别校验、冗余名称-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类型:名称唯一、工序与设备类别校验、冗余名称-----------
|
||||
mesXslEquipmentTypeService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类型-编辑")
|
||||
@Operation(summary = "MES设备类型-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentType model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型:名称唯一、工序与设备类别校验、冗余名称-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类型:名称唯一、工序与设备类别校验、冗余名称-----------
|
||||
mesXslEquipmentTypeService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类型-删除")
|
||||
@Operation(summary = "MES设备类型-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentTypeService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类型-批量删除")
|
||||
@Operation(summary = "MES设备类型-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentTypeService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备类型-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentType> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentType entity = mesXslEquipmentTypeService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验设备类型名称是否重复(仅未删除数据;同租户,dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkTypeName")
|
||||
public Result<String> checkTypeName(
|
||||
@RequestParam(name = "typeName", required = true) String typeName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(typeName) || typeName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentType ctx = new MesXslEquipmentType();
|
||||
if (mesXslEquipmentTypeService.isTypeNameDuplicated(typeName.trim(), dataId, ctx)) {
|
||||
return Result.error("该类型名称已存在");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentType model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentType.class, "MES设备类型");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260514 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<MesXslEquipmentType> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentType.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentType row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String tn = row.getTypeName();
|
||||
if (tn != null) {
|
||||
tn = tn.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(tn)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类型名称不能为空");
|
||||
}
|
||||
row.setTypeName(tn);
|
||||
if (!namesInFile.add(tn)) {
|
||||
return Result.error("文件导入失败:类型名称【" + tn + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslEquipmentTypeService.isTypeNameDuplicated(tn, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类型名称【" + tn + "】已存在(未删除数据中不允许重复)");
|
||||
}
|
||||
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());
|
||||
row.setImportOperationCode(null);
|
||||
|
||||
String catName = row.getImportCategoryName();
|
||||
if (catName != null) {
|
||||
catName = catName.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(catName)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称不能为空");
|
||||
}
|
||||
MesXslEquipmentCategory cat =
|
||||
mesXslEquipmentCategoryService.findOneActiveByNameAndTenant(catName, row.getTenantId());
|
||||
if (cat == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称【" + catName + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
row.setEquipmentCategoryId(cat.getId());
|
||||
row.setEquipmentCategoryName(cat.getCategoryName());
|
||||
row.setImportCategoryName(null);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentTypeService.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:20260514 for:【MES】设备类型导入:名称唯一、工序编码与设备类别名称解析-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型保存前校验与工序、类别名称回填-----------
|
||||
private String validateForSave(MesXslEquipmentType model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getTypeName()) || model.getTypeName().trim().isEmpty()) {
|
||||
return "类型名称不能为空";
|
||||
}
|
||||
String tn = model.getTypeName().trim();
|
||||
model.setTypeName(tn);
|
||||
if (mesXslEquipmentTypeService.isTypeNameDuplicated(tn, excludeId, model)) {
|
||||
return "类型名称已存在";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
|
||||
return "请选择所属工序";
|
||||
}
|
||||
MesXslProcessOperation op = mesXslProcessOperationService.getById(model.getProcessOperationId());
|
||||
if (op == null) {
|
||||
return "所属工序不存在";
|
||||
}
|
||||
model.setProcessOperationName(op.getOperationName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentCategoryId())) {
|
||||
return "请选择所属设备类别";
|
||||
}
|
||||
MesXslEquipmentCategory cat = mesXslEquipmentCategoryService.getById(model.getEquipmentCategoryId());
|
||||
if (cat == null) {
|
||||
return "所属设备类别不存在";
|
||||
}
|
||||
model.setEquipmentCategoryName(cat.getCategoryName());
|
||||
|
||||
model.setImportOperationCode(null);
|
||||
model.setImportCategoryName(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private MesXslProcessOperation findProcessByOperationCode(String operationCode, MesXslEquipmentType 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:20260514 for:【MES】设备类型保存前校验与工序、类别名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
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.MesXslManufacturer;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslManufacturerService;
|
||||
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/mesXslManufacturer")
|
||||
@Slf4j
|
||||
public class MesXslManufacturerController extends JeecgController<MesXslManufacturer, IMesXslManufacturerService> {
|
||||
|
||||
private static final Set<String> MANUFACTURER_CATEGORIES = Set.of("mold", "capsule", "equipment");
|
||||
private static final Set<String> VALID_STATUS = Set.of("0", "1");
|
||||
|
||||
@Autowired
|
||||
private IMesXslManufacturerService mesXslManufacturerService;
|
||||
|
||||
@Operation(summary = "MES厂家信息-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslManufacturer>> queryPageList(
|
||||
MesXslManufacturer model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslManufacturer> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslManufacturer> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslManufacturer> pageList = mesXslManufacturerService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES厂家信息-添加")
|
||||
@Operation(summary = "MES厂家信息-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslManufacturer model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||
mesXslManufacturerService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES厂家信息-编辑")
|
||||
@Operation(summary = "MES厂家信息-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslManufacturer model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||
mesXslManufacturerService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES厂家信息-删除")
|
||||
@Operation(summary = "MES厂家信息-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslManufacturerService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES厂家信息-批量删除")
|
||||
@Operation(summary = "MES厂家信息-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslManufacturerService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES厂家信息-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslManufacturer> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslManufacturer entity = mesXslManufacturerService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验厂家名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkManufacturerName")
|
||||
public Result<String> checkManufacturerName(
|
||||
@RequestParam(name = "manufacturerName", required = true) String manufacturerName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(manufacturerName) || manufacturerName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslManufacturer ctx = new MesXslManufacturer();
|
||||
if (mesXslManufacturerService.isManufacturerNameDuplicated(manufacturerName.trim(), dataId, ctx)) {
|
||||
return Result.error("厂家名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslManufacturer model) {
|
||||
return super.exportXls(request, model, MesXslManufacturer.class, "MES厂家信息");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260515 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<MesXslManufacturer> list =
|
||||
ExcelImportUtil.importExcel(file.getInputStream(), MesXslManufacturer.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslManufacturer row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String name = row.getManufacturerName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(name)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条厂家名称不能为空");
|
||||
}
|
||||
row.setManufacturerName(name);
|
||||
if (!namesInFile.add(name)) {
|
||||
return Result.error("文件导入失败:厂家名称【" + name + "】在导入文件中重复");
|
||||
}
|
||||
String cat = row.getManufacturerCategory();
|
||||
if (oConvertUtils.isEmpty(cat) || !MANUFACTURER_CATEGORIES.contains(cat.trim())) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条厂家类别无效(须为模具厂家/胶囊厂家/设备厂家对应字典值)");
|
||||
}
|
||||
row.setManufacturerCategory(cat.trim());
|
||||
String vs = row.getValidStatus();
|
||||
if (oConvertUtils.isEmpty(vs)) {
|
||||
row.setValidStatus("0");
|
||||
} else {
|
||||
vs = vs.trim();
|
||||
if (!VALID_STATUS.contains(vs)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条是否有效无效(须为有效或无效对应字典值)");
|
||||
}
|
||||
row.setValidStatus(vs);
|
||||
}
|
||||
if (mesXslManufacturerService.isManufacturerNameDuplicated(name, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条厂家名称【" + name + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslManufacturerService.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:20260515 for:【MES】厂家信息导入:名称唯一、文件内去重、类别与有效状态校验-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验-----------
|
||||
private String validateForSave(MesXslManufacturer model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getManufacturerCategory()) || model.getManufacturerCategory().trim().isEmpty()) {
|
||||
return "厂家类别不能为空";
|
||||
}
|
||||
String cat = model.getManufacturerCategory().trim();
|
||||
if (!MANUFACTURER_CATEGORIES.contains(cat)) {
|
||||
return "厂家类别无效";
|
||||
}
|
||||
model.setManufacturerCategory(cat);
|
||||
if (oConvertUtils.isEmpty(model.getManufacturerName()) || model.getManufacturerName().trim().isEmpty()) {
|
||||
return "厂家名称不能为空";
|
||||
}
|
||||
String name = model.getManufacturerName().trim();
|
||||
model.setManufacturerName(name);
|
||||
if (mesXslManufacturerService.isManufacturerNameDuplicated(name, excludeId, model)) {
|
||||
return "厂家名称不能重复";
|
||||
}
|
||||
String vs = model.getValidStatus();
|
||||
if (oConvertUtils.isEmpty(vs)) {
|
||||
model.setValidStatus("0");
|
||||
} else {
|
||||
vs = vs.trim();
|
||||
if (!VALID_STATUS.contains(vs)) {
|
||||
return "是否有效取值无效";
|
||||
}
|
||||
model.setValidStatus(vs);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验-----------
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
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.MesXslProcessOperation;
|
||||
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/mesXslProcessOperation")
|
||||
@Slf4j
|
||||
public class MesXslProcessOperationController extends JeecgController<MesXslProcessOperation, IMesXslProcessOperationService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Operation(summary = "MES工序管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslProcessOperation>> queryPageList(
|
||||
MesXslProcessOperation model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslProcessOperation> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslProcessOperation> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslProcessOperation> pageList = mesXslProcessOperationService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-添加")
|
||||
@Operation(summary = "MES工序管理-添加")
|
||||
@RequiresPermissions("mes:mes_process_operation:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslProcessOperation model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
if (oConvertUtils.isEmpty(model.getOperationCode()) || oConvertUtils.isEmpty(model.getOperationName())) {
|
||||
return Result.error("工序编码、工序名称不能为空");
|
||||
}
|
||||
String code = model.getOperationCode().trim();
|
||||
model.setOperationCode(code);
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, null, model)) {
|
||||
return Result.error("工序编码已存在");
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
mesXslProcessOperationService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-编辑")
|
||||
@Operation(summary = "MES工序管理-编辑")
|
||||
@RequiresPermissions("mes:mes_process_operation:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslProcessOperation model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
if (oConvertUtils.isEmpty(model.getOperationCode()) || oConvertUtils.isEmpty(model.getOperationName())) {
|
||||
return Result.error("工序编码、工序名称不能为空");
|
||||
}
|
||||
String code = model.getOperationCode().trim();
|
||||
model.setOperationCode(code);
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, model.getId(), model)) {
|
||||
return Result.error("工序编码已存在");
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
mesXslProcessOperationService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-删除")
|
||||
@Operation(summary = "MES工序管理-通过id删除")
|
||||
@RequiresPermissions("mes:mes_process_operation:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslProcessOperationService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-批量删除")
|
||||
@Operation(summary = "MES工序管理-批量删除")
|
||||
@RequiresPermissions("mes:mes_process_operation:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslProcessOperationService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES工序管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslProcessOperation> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslProcessOperation entity = mesXslProcessOperationService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验工序编码是否重复(仅未删除数据;同租户,dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkOperationCode")
|
||||
public Result<String> checkOperationCode(
|
||||
@RequestParam(name = "operationCode", required = true) String operationCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(operationCode) || operationCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslProcessOperation ctx = new MesXslProcessOperation();
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(operationCode.trim(), dataId, ctx)) {
|
||||
return Result.error("该工序编码已存在");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_process_operation:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslProcessOperation model) {
|
||||
return super.exportXls(request, model, MesXslProcessOperation.class, "MES工序管理");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_process_operation:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260514 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<MesXslProcessOperation> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslProcessOperation.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslProcessOperation row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String code = row.getOperationCode();
|
||||
if (code != null) {
|
||||
code = code.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(code)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码不能为空");
|
||||
}
|
||||
row.setOperationCode(code);
|
||||
if (oConvertUtils.isEmpty(row.getOperationName()) || row.getOperationName().trim().isEmpty()) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序名称不能为空");
|
||||
}
|
||||
row.setOperationName(row.getOperationName().trim());
|
||||
if (!codesInFile.add(code)) {
|
||||
return Result.error("文件导入失败:工序编码【" + code + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码【" + code + "】已存在(未删除数据中不允许重复)");
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslProcessOperationService.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:20260514 for:【MES】工序导入:文件内编码不重复,且与库中未删除数据不重复-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
}
|
||||
@@ -228,7 +228,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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
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) ")
|
||||
.append("WHERE (i.del_flag = 0 OR i.del_flag IS NULL) ");
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
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.math.BigDecimal;
|
||||
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.MesXslSparePart;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslUnit;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartsCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslUnitService;
|
||||
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/mesXslSparePart")
|
||||
@Slf4j
|
||||
public class MesXslSparePartController extends JeecgController<MesXslSparePart, IMesXslSparePartService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslSparePartService mesXslSparePartService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslSparePartsCategoryService mesXslSparePartsCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslUnitService mesXslUnitService;
|
||||
|
||||
@Operation(summary = "MES备品件信息-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslSparePart>> queryPageList(
|
||||
MesXslSparePart model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslSparePart> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslSparePart> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslSparePart> pageList = mesXslSparePartService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件信息-添加")
|
||||
@Operation(summary = "MES备品件信息-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslSparePart model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件信息保存前校验:名称唯一、类别与单位回填、库存上下限-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件信息保存前校验:名称唯一、类别与单位回填、库存上下限-----------
|
||||
mesXslSparePartService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件信息-编辑")
|
||||
@Operation(summary = "MES备品件信息-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslSparePart model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件信息保存前校验:名称唯一、类别与单位回填、库存上下限-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件信息保存前校验:名称唯一、类别与单位回填、库存上下限-----------
|
||||
mesXslSparePartService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件信息-删除")
|
||||
@Operation(summary = "MES备品件信息-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslSparePartService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件信息-批量删除")
|
||||
@Operation(summary = "MES备品件信息-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslSparePartService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES备品件信息-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslSparePart> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslSparePart entity = mesXslSparePartService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验备品件名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkSparePartName")
|
||||
public Result<String> checkSparePartName(
|
||||
@RequestParam(name = "sparePartName", required = true) String sparePartName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(sparePartName) || sparePartName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslSparePart ctx = new MesXslSparePart();
|
||||
if (mesXslSparePartService.isSparePartNameDuplicated(sparePartName.trim(), dataId, ctx)) {
|
||||
return Result.error("备品件名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslSparePart model) {
|
||||
return super.exportXls(request, model, MesXslSparePart.class, "MES备品件信息");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260515 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<MesXslSparePart> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslSparePart.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslSparePart row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String pn = row.getSparePartName();
|
||||
if (pn != null) {
|
||||
pn = pn.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(pn)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条备品件名称不能为空");
|
||||
}
|
||||
row.setSparePartName(pn);
|
||||
if (!namesInFile.add(pn)) {
|
||||
return Result.error("文件导入失败:备品件名称【" + pn + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslSparePartService.isSparePartNameDuplicated(pn, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条备品件名称【" + pn + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
|
||||
String catName = row.getImportCategoryName();
|
||||
if (catName != null) {
|
||||
catName = catName.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(catName)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条备品件类别名称不能为空");
|
||||
}
|
||||
MesXslSparePartsCategory cat =
|
||||
mesXslSparePartsCategoryService.findOneActiveByCategoryNameAndTenant(catName, row.getTenantId());
|
||||
if (cat == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条备品件类别名称【" + catName + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
row.setSparePartsCategoryId(cat.getId());
|
||||
row.setSparePartsCategoryName(cat.getCategoryName());
|
||||
row.setImportCategoryName(null);
|
||||
|
||||
String ucode = row.getImportUnitCode();
|
||||
if (ucode != null) {
|
||||
ucode = ucode.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ucode)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条单位编码不能为空");
|
||||
}
|
||||
MesXslUnit unit = mesXslUnitService.findOneActiveByUnitCodeAndTenant(ucode, row.getTenantId());
|
||||
if (unit == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条单位编码【" + ucode + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
String st = unit.getStatus();
|
||||
if (st != null && "1".equals(st.trim())) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条单位编码【" + ucode + "】对应单位已停用");
|
||||
}
|
||||
row.setUnitId(unit.getId());
|
||||
row.setUnitName(unit.getUnitName());
|
||||
row.setImportUnitCode(null);
|
||||
|
||||
String errStock = normalizeAndValidateStocks(row, rowNo);
|
||||
if (errStock != null) {
|
||||
return Result.error(errStock);
|
||||
}
|
||||
|
||||
if (row.getSpecModel() != null) {
|
||||
row.setSpecModel(row.getSpecModel().trim());
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslSparePartService.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:20260515 for:【MES】备品件信息导入:名称唯一、类别名称与单位编码解析、库存校验-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件信息保存前校验与冗余名称回填-----------
|
||||
private String validateForSave(MesXslSparePart model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getSparePartName()) || model.getSparePartName().trim().isEmpty()) {
|
||||
return "备品件名称不能为空";
|
||||
}
|
||||
String pn = model.getSparePartName().trim();
|
||||
model.setSparePartName(pn);
|
||||
if (mesXslSparePartService.isSparePartNameDuplicated(pn, excludeId, model)) {
|
||||
return "备品件名称不能重复";
|
||||
}
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getSparePartsCategoryId())) {
|
||||
return "请选择所属备品件类别";
|
||||
}
|
||||
MesXslSparePartsCategory cat = mesXslSparePartsCategoryService.getById(model.getSparePartsCategoryId());
|
||||
if (cat == null) {
|
||||
return "所属备品件类别不存在";
|
||||
}
|
||||
model.setSparePartsCategoryName(cat.getCategoryName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getUnitId())) {
|
||||
return "请选择单位";
|
||||
}
|
||||
MesXslUnit unit = mesXslUnitService.getById(model.getUnitId());
|
||||
if (unit == null) {
|
||||
return "所选单位不存在";
|
||||
}
|
||||
String ust = unit.getStatus();
|
||||
if (ust != null && "1".equals(ust.trim())) {
|
||||
return "所选单位已停用,请重新选择";
|
||||
}
|
||||
model.setUnitName(unit.getUnitName());
|
||||
|
||||
String errStock = normalizeAndValidateStocks(model, null);
|
||||
if (errStock != null) {
|
||||
return errStock;
|
||||
}
|
||||
|
||||
if (model.getSpecModel() != null) {
|
||||
model.setSpecModel(model.getSpecModel().trim());
|
||||
}
|
||||
model.setImportCategoryName(null);
|
||||
model.setImportUnitCode(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 规范化 max/min 库存并校验;rowNo 非空时错误信息带行号(导入用) */
|
||||
private String normalizeAndValidateStocks(MesXslSparePart model, Integer rowNo) {
|
||||
BigDecimal max = model.getMaxStock();
|
||||
BigDecimal min = model.getMinStock();
|
||||
if (max == null || min == null) {
|
||||
return rowNo == null ? "最大库存、最小库存不能为空" : "文件导入失败:第 " + rowNo + " 条最大库存、最小库存不能为空";
|
||||
}
|
||||
max = max.stripTrailingZeros();
|
||||
min = min.stripTrailingZeros();
|
||||
model.setMaxStock(max);
|
||||
model.setMinStock(min);
|
||||
if (max.compareTo(BigDecimal.ZERO) < 0 || min.compareTo(BigDecimal.ZERO) < 0) {
|
||||
return rowNo == null ? "最大库存、最小库存不能为负数" : "文件导入失败:第 " + rowNo + " 条最大库存、最小库存不能为负数";
|
||||
}
|
||||
if (max.compareTo(min) < 0) {
|
||||
return rowNo == null ? "最大库存不能小于最小库存" : "文件导入失败:第 " + rowNo + " 条最大库存不能小于最小库存";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件信息保存前校验与冗余名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
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.MesXslSparePartsCategory;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartsCategoryService;
|
||||
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/mesXslSparePartsCategory")
|
||||
@Slf4j
|
||||
public class MesXslSparePartsCategoryController extends JeecgController<MesXslSparePartsCategory, IMesXslSparePartsCategoryService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslSparePartsCategoryService mesXslSparePartsCategoryService;
|
||||
|
||||
@Operation(summary = "MES备品件类别-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslSparePartsCategory>> queryPageList(
|
||||
MesXslSparePartsCategory model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslSparePartsCategory> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslSparePartsCategory> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslSparePartsCategory> pageList = mesXslSparePartsCategoryService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件类别-添加")
|
||||
@Operation(summary = "MES备品件类别-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslSparePartsCategory model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验:类别名称唯一、描述 trim-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验:类别名称唯一、描述 trim-----------
|
||||
mesXslSparePartsCategoryService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件类别-编辑")
|
||||
@Operation(summary = "MES备品件类别-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslSparePartsCategory model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验:类别名称唯一、描述 trim-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验:类别名称唯一、描述 trim-----------
|
||||
mesXslSparePartsCategoryService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件类别-删除")
|
||||
@Operation(summary = "MES备品件类别-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslSparePartsCategoryService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件类别-批量删除")
|
||||
@Operation(summary = "MES备品件类别-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslSparePartsCategoryService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES备品件类别-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslSparePartsCategory> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslSparePartsCategory entity = mesXslSparePartsCategoryService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验备品件类别名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkCategoryName")
|
||||
public Result<String> checkCategoryName(
|
||||
@RequestParam(name = "categoryName", required = true) String categoryName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(categoryName) || categoryName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslSparePartsCategory ctx = new MesXslSparePartsCategory();
|
||||
if (mesXslSparePartsCategoryService.isCategoryNameDuplicated(categoryName.trim(), dataId, ctx)) {
|
||||
return Result.error("类别名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslSparePartsCategory model) {
|
||||
return super.exportXls(request, model, MesXslSparePartsCategory.class, "MES备品件类别");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260515 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<MesXslSparePartsCategory> list =
|
||||
ExcelImportUtil.importExcel(file.getInputStream(), MesXslSparePartsCategory.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslSparePartsCategory row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String name = row.getCategoryName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(name)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类别名称不能为空");
|
||||
}
|
||||
row.setCategoryName(name);
|
||||
if (!namesInFile.add(name)) {
|
||||
return Result.error("文件导入失败:类别名称【" + name + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslSparePartsCategoryService.isCategoryNameDuplicated(name, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类别名称【" + name + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
if (row.getCategoryDescription() != null) {
|
||||
row.setCategoryDescription(row.getCategoryDescription().trim());
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslSparePartsCategoryService.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:20260515 for:【MES】备品件类别导入:类别名称唯一、文件内去重-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验-----------
|
||||
private String validateForSave(MesXslSparePartsCategory model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getCategoryName()) || model.getCategoryName().trim().isEmpty()) {
|
||||
return "类别名称不能为空";
|
||||
}
|
||||
String name = model.getCategoryName().trim();
|
||||
model.setCategoryName(name);
|
||||
if (mesXslSparePartsCategoryService.isCategoryNameDuplicated(name, excludeId, model)) {
|
||||
return "类别名称不能重复";
|
||||
}
|
||||
if (model.getCategoryDescription() != null) {
|
||||
model.setCategoryDescription(model.getCategoryDescription().trim());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验-----------
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
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_equipment_category)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_category")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备类别")
|
||||
public class MesXslEquipmentCategory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "类别名称", width = 22)
|
||||
@Schema(description = "设备类别名称(同租户未删除数据中唯一)")
|
||||
private String categoryName;
|
||||
|
||||
@Schema(description = "所属工序主键")
|
||||
private String processOperationId;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称冗余,用于列表与导出展示")
|
||||
private String processOperationName;
|
||||
|
||||
@Excel(name = "点检区分", width = 14, dicCode = "xslmes_equipment_inspect_distinct")
|
||||
@Dict(dicCode = "xslmes_equipment_inspect_distinct")
|
||||
@Schema(description = "点检区分(字典 xslmes_equipment_inspect_distinct)")
|
||||
private String inspectDistinct;
|
||||
|
||||
@Excel(name = "保养区分", width = 14, dicCode = "xslmes_equipment_maintain_distinct")
|
||||
@Dict(dicCode = "xslmes_equipment_maintain_distinct")
|
||||
@Schema(description = "保养区分(字典 xslmes_equipment_maintain_distinct)")
|
||||
private String maintainDistinct;
|
||||
|
||||
/** 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;
|
||||
}
|
||||
@@ -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_equipment_part)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_part")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备部位")
|
||||
public class MesXslEquipmentPart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "所属设备类别主键")
|
||||
private String equipmentCategoryId;
|
||||
|
||||
@Excel(name = "类别名称", width = 22)
|
||||
@Schema(description = "设备类别名称冗余展示")
|
||||
private String equipmentCategoryName;
|
||||
|
||||
@Excel(name = "部位名称", width = 20)
|
||||
@Schema(description = "部位名称")
|
||||
private String partName;
|
||||
|
||||
@Excel(name = "部位代码", width = 16)
|
||||
@Schema(description = "部位代码(同租户未删除数据中唯一)")
|
||||
private String partCode;
|
||||
|
||||
@Excel(name = "部位描述", width = 28)
|
||||
@Schema(description = "部位描述")
|
||||
private String partDescription;
|
||||
|
||||
@Excel(name = "是否启用", width = 12, dicCode = "xslmes_unit_status")
|
||||
@Dict(dicCode = "xslmes_unit_status")
|
||||
@Schema(description = "是否启用(字典xslmes_unit_status:0启用1停用)")
|
||||
private String enableStatus;
|
||||
|
||||
/** Excel 导入用:设备类别名称,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "设备类别名称", width = 22)
|
||||
@Schema(description = "导入用设备类别名称")
|
||||
private String importCategoryName;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
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_equipment_sub_part)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_sub_part")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备小部位")
|
||||
public class MesXslEquipmentSubPart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "所属设备类别主键")
|
||||
private String equipmentCategoryId;
|
||||
|
||||
@Excel(name = "类别名称", width = 22)
|
||||
@Schema(description = "设备类别名称冗余展示")
|
||||
private String equipmentCategoryName;
|
||||
|
||||
@Schema(description = "所属设备大部位主键 mes_xsl_equipment_part.id")
|
||||
private String equipmentPartId;
|
||||
|
||||
@Excel(name = "大部位名称", width = 20)
|
||||
@Schema(description = "设备大部位名称冗余")
|
||||
private String equipmentPartName;
|
||||
|
||||
@Excel(name = "小部位名称", width = 20)
|
||||
@Schema(description = "小部位名称")
|
||||
private String subPartName;
|
||||
|
||||
@Excel(name = "小部位代码", width = 16)
|
||||
@Schema(description = "小部位代码(同租户未删除数据中唯一)")
|
||||
private String subPartCode;
|
||||
|
||||
@Excel(name = "部位描述", width = 28)
|
||||
@Schema(description = "部位描述")
|
||||
private String subPartDescription;
|
||||
|
||||
@Excel(name = "是否启用", width = 12, dicCode = "xslmes_unit_status")
|
||||
@Dict(dicCode = "xslmes_unit_status")
|
||||
@Schema(description = "是否启用(字典xslmes_unit_status:0启用1停用)")
|
||||
private String enableStatus;
|
||||
|
||||
/** Excel 导入用:设备类别名称,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "设备类别名称", width = 22)
|
||||
@Schema(description = "导入用设备类别名称")
|
||||
private String importCategoryName;
|
||||
|
||||
/** Excel 导入用:大部位代码 mes_xsl_equipment_part.part_code,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "大部位代码", width = 16)
|
||||
@Schema(description = "导入用设备大部位代码")
|
||||
private String importEquipmentPartCode;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 设备类型(表 mes_xsl_equipment_type)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_type")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备类型")
|
||||
public class MesXslEquipmentType implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "类型名称", width = 22)
|
||||
@Schema(description = "设备类型名称(同租户未删除数据中唯一)")
|
||||
private String typeName;
|
||||
|
||||
@Schema(description = "所属工序主键")
|
||||
private String processOperationId;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称冗余展示")
|
||||
private String processOperationName;
|
||||
|
||||
@Schema(description = "所属设备类别主键")
|
||||
private String equipmentCategoryId;
|
||||
|
||||
@Excel(name = "类别名称", width = 22)
|
||||
@Schema(description = "设备类别名称冗余展示")
|
||||
private String equipmentCategoryName;
|
||||
|
||||
/** Excel 导入用:工序编码,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "工序编码", width = 18)
|
||||
@Schema(description = "导入用工序编码")
|
||||
private String importOperationCode;
|
||||
|
||||
/** Excel 导入用:设备类别名称(与设备类别维护中名称一致),不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "设备类别名称", width = 22)
|
||||
@Schema(description = "导入用设备类别名称")
|
||||
private String importCategoryName;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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_manufacturer)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_manufacturer")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES厂家信息")
|
||||
public class MesXslManufacturer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "厂家类别", width = 16, dicCode = "xslmes_manufacturer_category")
|
||||
@Dict(dicCode = "xslmes_manufacturer_category")
|
||||
@Schema(description = "厂家类别(字典 xslmes_manufacturer_category)")
|
||||
private String manufacturerCategory;
|
||||
|
||||
@Excel(name = "厂家名称", width = 28)
|
||||
@Schema(description = "厂家名称(同租户未删除数据中唯一)")
|
||||
private String manufacturerName;
|
||||
|
||||
@Excel(name = "是否有效", width = 12, dicCode = "xslmes_manufacturer_valid")
|
||||
@Dict(dicCode = "xslmes_manufacturer_valid")
|
||||
@Schema(description = "是否有效(字典 xslmes_manufacturer_valid:0有效1无效)")
|
||||
private String validStatus;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 工序管理(表 mes_process_operation)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_process_operation")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES工序管理")
|
||||
public class MesXslProcessOperation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "工序编码", width = 20)
|
||||
@Schema(description = "工序编码(同租户内唯一)")
|
||||
private String operationCode;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称")
|
||||
private String operationName;
|
||||
|
||||
@Excel(name = "备注", width = 28)
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
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.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 备品件信息(表 mes_xsl_spare_part)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_spare_part")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES备品件信息")
|
||||
public class MesXslSparePart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "备品件名称", width = 22)
|
||||
@Schema(description = "备品件名称(同租户未删除数据中唯一)")
|
||||
private String sparePartName;
|
||||
|
||||
@Schema(description = "所属备品件类别主键")
|
||||
private String sparePartsCategoryId;
|
||||
|
||||
@Excel(name = "类别名称", width = 20)
|
||||
@Schema(description = "备品件类别名称冗余")
|
||||
private String sparePartsCategoryName;
|
||||
|
||||
@Excel(name = "规格型号", width = 20)
|
||||
@Schema(description = "规格型号")
|
||||
private String specModel;
|
||||
|
||||
@Excel(name = "最大库存", width = 14)
|
||||
@Schema(description = "最大库存")
|
||||
private BigDecimal maxStock;
|
||||
|
||||
@Excel(name = "最小库存", width = 14)
|
||||
@Schema(description = "最小库存")
|
||||
private BigDecimal minStock;
|
||||
|
||||
@Schema(description = "单位 mes_xsl_unit.id")
|
||||
private String unitId;
|
||||
|
||||
@Excel(name = "单位名称", width = 14)
|
||||
@Schema(description = "单位名称冗余")
|
||||
private String unitName;
|
||||
|
||||
/** Excel 导入用:备品件类别名称,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "备品件类别名称", width = 22)
|
||||
@Schema(description = "导入用备品件类别名称")
|
||||
private String importCategoryName;
|
||||
|
||||
/** Excel 导入用:单位编码 mes_xsl_unit.unit_code,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "单位编码", width = 16)
|
||||
@Schema(description = "导入用单位编码")
|
||||
private String importUnitCode;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 备品件类别(表 mes_xsl_spare_parts_category)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_spare_parts_category")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES备品件类别")
|
||||
public class MesXslSparePartsCategory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "类别名称", width = 24)
|
||||
@Schema(description = "类别名称(同租户未删除数据中唯一)")
|
||||
private String categoryName;
|
||||
|
||||
@Excel(name = "描述", width = 36)
|
||||
@Schema(description = "描述")
|
||||
private String categoryDescription;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory;
|
||||
|
||||
/**
|
||||
* MES 设备类别 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslEquipmentCategoryMapper extends BaseMapper<MesXslEquipmentCategory> {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart;
|
||||
|
||||
/**
|
||||
* MES 设备部位 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslEquipmentPartMapper extends BaseMapper<MesXslEquipmentPart> {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart;
|
||||
|
||||
public interface MesXslEquipmentSubPartMapper extends BaseMapper<MesXslEquipmentSubPart> {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentType;
|
||||
|
||||
/**
|
||||
* MES 设备类型 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslEquipmentTypeMapper extends BaseMapper<MesXslEquipmentType> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||
|
||||
/**
|
||||
* MES 厂家信息
|
||||
*/
|
||||
public interface MesXslManufacturerMapper extends BaseMapper<MesXslManufacturer> {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
|
||||
/**
|
||||
* MES 工序管理 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslProcessOperationMapper extends BaseMapper<MesXslProcessOperation> {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePart;
|
||||
|
||||
public interface MesXslSparePartMapper extends BaseMapper<MesXslSparePart> {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory;
|
||||
|
||||
public interface MesXslSparePartsCategoryMapper extends BaseMapper<MesXslSparePartsCategory> {}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* MES XSL 业务模块(Maven 工程名:jeecg-module-xslmes)。
|
||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})等。
|
||||
* 包含:客户管理({@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})等。
|
||||
*/
|
||||
package org.jeecg.modules.xslmes;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory;
|
||||
|
||||
public interface IMesXslEquipmentCategoryService extends IService<MesXslEquipmentCategory> {
|
||||
|
||||
/**
|
||||
* 类别名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param categoryName 类别名称(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslEquipmentCategory context);
|
||||
|
||||
/**
|
||||
* 按类别名称在未删除数据中查询一条(同租户;名称需 trim 后传入)。用于设备类型关联类别解析等。
|
||||
*
|
||||
* @param categoryName 类别名称
|
||||
* @param tenantId 租户 ID,可为 null(不按租户过滤)
|
||||
*/
|
||||
MesXslEquipmentCategory findOneActiveByNameAndTenant(String categoryName, Integer tenantId);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart;
|
||||
|
||||
public interface IMesXslEquipmentPartService extends IService<MesXslEquipmentPart> {
|
||||
|
||||
/**
|
||||
* 按部位代码在指定租户下查找一条未删除记录(用于设备小部位导入解析等)。
|
||||
*
|
||||
* @param partCode 部位代码(已 trim)
|
||||
* @param tenantId 租户 ID,可为 null(不按租户过滤)
|
||||
*/
|
||||
MesXslEquipmentPart findOneActiveByPartCodeAndTenant(String partCode, Integer tenantId);
|
||||
|
||||
/**
|
||||
* 部位代码是否已被占用:同租户下未删除数据中部位代码不可重复。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param partCode 部位代码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isPartCodeDuplicated(String partCode, String excludeId, MesXslEquipmentPart context);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart;
|
||||
|
||||
public interface IMesXslEquipmentSubPartService extends IService<MesXslEquipmentSubPart> {
|
||||
|
||||
/**
|
||||
* 小部位代码是否已被占用:同租户下未删除数据中小部位代码不可重复。
|
||||
*
|
||||
* @param subPartCode 小部位代码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isSubPartCodeDuplicated(String subPartCode, String excludeId, MesXslEquipmentSubPart context);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentType;
|
||||
|
||||
public interface IMesXslEquipmentTypeService extends IService<MesXslEquipmentType> {
|
||||
|
||||
/**
|
||||
* 类型名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param typeName 类型名称(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isTypeNameDuplicated(String typeName, String excludeId, MesXslEquipmentType context);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||
|
||||
public interface IMesXslManufacturerService extends IService<MesXslManufacturer> {
|
||||
|
||||
/**
|
||||
* 厂家名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与拦截器注入逻辑一致。
|
||||
*
|
||||
* @param manufacturerName 厂家名称(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isManufacturerNameDuplicated(String manufacturerName, String excludeId, MesXslManufacturer context);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
|
||||
public interface IMesXslProcessOperationService extends IService<MesXslProcessOperation> {
|
||||
|
||||
/**
|
||||
* 工序编码是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param operationCode 工序编码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isOperationCodeDuplicated(String operationCode, String excludeId, MesXslProcessOperation context);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePart;
|
||||
|
||||
public interface IMesXslSparePartService extends IService<MesXslSparePart> {
|
||||
|
||||
/**
|
||||
* 备品件名称是否已被占用(同租户未删除数据中唯一)。
|
||||
*/
|
||||
boolean isSparePartNameDuplicated(String sparePartName, String excludeId, MesXslSparePart context);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory;
|
||||
|
||||
public interface IMesXslSparePartsCategoryService extends IService<MesXslSparePartsCategory> {
|
||||
|
||||
/**
|
||||
* 备品件类别名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param categoryName 类别名称(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslSparePartsCategory context);
|
||||
|
||||
/**
|
||||
* 按类别名称在未删除数据中查询一条(同租户),用于备品件信息导入解析等。
|
||||
*/
|
||||
MesXslSparePartsCategory findOneActiveByCategoryNameAndTenant(String categoryName, Integer tenantId);
|
||||
}
|
||||
@@ -12,4 +12,9 @@ public interface IMesXslUnitService extends IService<MesXslUnit> {
|
||||
|
||||
/** 单位分类(sys_category)选中节点及其所有下级 id,用于列表筛选 */
|
||||
List<String> listDescendantCategoryIds(String rootId);
|
||||
|
||||
/**
|
||||
* 按单位编码在未删除数据中查询一条(同租户),用于备品件信息导入解析等。
|
||||
*/
|
||||
MesXslUnit findOneActiveByUnitCodeAndTenant(String unitCode, Integer tenantId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentCategoryMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentCategoryServiceImpl extends ServiceImpl<MesXslEquipmentCategoryMapper, MesXslEquipmentCategory>
|
||||
implements IMesXslEquipmentCategoryService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类别名称同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslEquipmentCategory context) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentCategory::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentCategory::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentCategory::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型按类别名称解析关联,提供未删除单条查询-----------
|
||||
@Override
|
||||
public MesXslEquipmentCategory findOneActiveByNameAndTenant(String categoryName, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MesXslEquipmentCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentCategory::getDelFlag));
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentCategory::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类型按类别名称解析关联,提供未删除单条查询-----------
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentCategory 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:20260514 for:【MES】设备类别名称同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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.MesXslEquipmentPart;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentPartMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentPartServiceImpl extends ServiceImpl<MesXslEquipmentPartMapper, MesXslEquipmentPart>
|
||||
implements IMesXslEquipmentPartService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isPartCodeDuplicated(String partCode, String excludeId, MesXslEquipmentPart context) {
|
||||
if (oConvertUtils.isEmpty(partCode)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentPart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentPart::getPartCode, partCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentPart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentPart::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentPart::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentPart::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentPart 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:20260515 for:【MES】设备部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备部位按代码+租户查询单条,供设备小部位导入解析大部位-----------
|
||||
@Override
|
||||
public MesXslEquipmentPart findOneActiveByPartCodeAndTenant(String partCode, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(partCode)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MesXslEquipmentPart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentPart::getPartCode, partCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentPart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentPart::getDelFlag));
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentPart::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备部位按代码+租户查询单条,供设备小部位导入解析大部位-----------
|
||||
}
|
||||
@@ -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.MesXslEquipmentSubPart;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentSubPartMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentSubPartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentSubPartServiceImpl extends ServiceImpl<MesXslEquipmentSubPartMapper, MesXslEquipmentSubPart>
|
||||
implements IMesXslEquipmentSubPartService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isSubPartCodeDuplicated(String subPartCode, String excludeId, MesXslEquipmentSubPart context) {
|
||||
if (oConvertUtils.isEmpty(subPartCode)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentSubPart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentSubPart::getSubPartCode, subPartCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentSubPart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentSubPart::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentSubPart::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentSubPart::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentSubPart 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:20260515 for:【MES】设备小部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -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.MesXslEquipmentType;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentTypeMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentTypeServiceImpl extends ServiceImpl<MesXslEquipmentTypeMapper, MesXslEquipmentType>
|
||||
implements IMesXslEquipmentTypeService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型名称同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isTypeNameDuplicated(String typeName, String excludeId, MesXslEquipmentType context) {
|
||||
if (oConvertUtils.isEmpty(typeName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentType> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentType::getTypeName, typeName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentType::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentType::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentType::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentType::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentType 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:20260514 for:【MES】设备类型名称同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -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.MesXslManufacturer;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslManufacturerMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslManufacturerService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslManufacturerServiceImpl extends ServiceImpl<MesXslManufacturerMapper, MesXslManufacturer>
|
||||
implements IMesXslManufacturerService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isManufacturerNameDuplicated(String manufacturerName, String excludeId, MesXslManufacturer context) {
|
||||
if (oConvertUtils.isEmpty(manufacturerName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslManufacturer> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslManufacturer::getManufacturerName, manufacturerName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslManufacturer::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslManufacturer::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslManufacturer::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslManufacturer::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslManufacturer 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:20260515 for:【MES】厂家名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
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.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslProcessOperationMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslProcessOperationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslProcessOperationServiceImpl extends ServiceImpl<MesXslProcessOperationMapper, MesXslProcessOperation>
|
||||
implements IMesXslProcessOperationService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isOperationCodeDuplicated(String operationCode, String excludeId, MesXslProcessOperation context) {
|
||||
if (oConvertUtils.isEmpty(operationCode)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslProcessOperation> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslProcessOperation::getOperationCode, operationCode.trim());
|
||||
// 仅与「未删除」数据判重:del_flag=0 或历史空值视为正常行,排除已删除(del_flag=1)
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslProcessOperation::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslProcessOperation::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslProcessOperation::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslProcessOperation::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
/** 与 MybatisInterceptor 注入 tenant_id 的取值顺序尽量一致,避免前端未传 tenantId 时查不到已存在数据 */
|
||||
private static Integer resolveTenantId(MesXslProcessOperation 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:20260514 for:【MES】工序编码同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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.MesXslSparePart;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslSparePartMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslSparePartServiceImpl extends ServiceImpl<MesXslSparePartMapper, MesXslSparePart> implements IMesXslSparePartService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isSparePartNameDuplicated(String sparePartName, String excludeId, MesXslSparePart context) {
|
||||
if (oConvertUtils.isEmpty(sparePartName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslSparePart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslSparePart::getSparePartName, sparePartName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslSparePart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslSparePart::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslSparePart::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslSparePart::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslSparePart 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:20260515 for:【MES】备品件名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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.MesXslSparePartsCategory;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslSparePartsCategoryMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartsCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslSparePartsCategoryServiceImpl extends ServiceImpl<MesXslSparePartsCategoryMapper, MesXslSparePartsCategory>
|
||||
implements IMesXslSparePartsCategoryService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslSparePartsCategory context) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslSparePartsCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslSparePartsCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslSparePartsCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslSparePartsCategory::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslSparePartsCategory::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslSparePartsCategory::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别按名称+租户查询单条,供备品件信息导入解析-----------
|
||||
@Override
|
||||
public MesXslSparePartsCategory findOneActiveByCategoryNameAndTenant(String categoryName, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MesXslSparePartsCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslSparePartsCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslSparePartsCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslSparePartsCategory::getDelFlag));
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslSparePartsCategory::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件类别按名称+租户查询单条,供备品件信息导入解析-----------
|
||||
|
||||
private static Integer resolveTenantId(MesXslSparePartsCategory 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:20260515 for:【MES】备品件类别名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
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.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslUnit;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslUnitMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslUnitService;
|
||||
@@ -18,4 +20,20 @@ public class MesXslUnitServiceImpl extends ServiceImpl<MesXslUnitMapper, MesXslU
|
||||
public List<String> listDescendantCategoryIds(String rootId) {
|
||||
return baseMapper.listDescendantCategoryIds(rootId);
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】单位按编码+租户查询单条,供备品件信息导入解析-----------
|
||||
@Override
|
||||
public MesXslUnit findOneActiveByUnitCodeAndTenant(String unitCode, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(unitCode)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MesXslUnit> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslUnit::getUnitCode, unitCode.trim());
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslUnit::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】单位按编码+租户查询单条,供备品件信息导入解析-----------
|
||||
}
|
||||
|
||||
197
jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志
Normal file
@@ -0,0 +1,197 @@
|
||||
-- author:jiangxh---date:20260513--for: 【MES】MES基础资料下新增工序管理(mes_process_operation,与原材料检验项目同级菜单) ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_53__mes_process_operation.sql
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/entity/MesProcessOperation.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/mapper/MesProcessOperationMapper.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/IMesProcessOperationService.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/impl/MesProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/controller/MesProcessOperationController.java
|
||||
jeecg-boot/db/mes-process-operation.sql
|
||||
jeecgboot-vue3/src/views/mes/processoperation/index.vue
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperationList.vue
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperation.data.ts
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperation.api.ts
|
||||
jeecgboot-vue3/src/views/mes/material/modules/MesProcessOperationModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260513--for: 【MES】补全工序管理后端/前端/Flyway 源码文件 ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_53__mes_process_operation.sql
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/entity/MesProcessOperation.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/mapper/MesProcessOperationMapper.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/IMesProcessOperationService.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/impl/MesProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/controller/MesProcessOperationController.java
|
||||
jeecg-boot/db/mes-process-operation.sql
|
||||
jeecgboot-vue3/src/views/mes/processoperation/index.vue
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperationList.vue
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperation.data.ts
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperation.api.ts
|
||||
jeecgboot-vue3/src/views/mes/material/modules/MesProcessOperationModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260513--for: 【MES】工序管理-工序编码同租户下不可重复 ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/IMesProcessOperationService.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/impl/MesProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/controller/MesProcessOperationController.java
|
||||
|
||||
-- author:jiangxh---date:20260514--for: 【MES】工序管理迁至 jeecg-module-xslmes,前端 xslmes/mesXslProcessOperation,菜单挂 MES基础资料、租户1002 授权脚本,Flyway V3.9.2_54 同步路由组件 ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslProcessOperation.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslProcessOperationMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslProcessOperationService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslProcessOperationController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_54__mes_process_operation_menu_xslmes_mes_base.sql
|
||||
jeecg-boot/db/mes-process-operation-menu-permission.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperationList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/components/MesXslProcessOperationModal.vue
|
||||
jeecgboot-vue3/src/views/mes/processoperation/index.vue
|
||||
|
||||
-- author:jiangxh---date:20260514--for: 【MES】mes-process-operation-menu-permission.sql 增补建表段,避免只执行菜单脚本未建表 ---
|
||||
jeecg-boot/db/mes-process-operation-menu-permission.sql
|
||||
jeecg-boot/db/mes-process-operation.sql
|
||||
|
||||
-- author:jiangxh---date:20260514--for: 【MES】工序编码唯一:排除已删除、表单异步校验接口、Excel 导入校验 ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslProcessOperationService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslProcessOperationController.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.data.ts
|
||||
|
||||
-- author:jiangxh---date:20260514--for: 【MES】MES基础资料下新增设备类别(mes_xsl_equipment_category,关联工序、点检/保养字典、类别名称同租户唯一) ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentCategory.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentCategoryMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentCategoryService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentCategoryServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentCategoryController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_55__mes_xsl_equipment_category.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-category-menu-permission.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-category.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslEquipmentCategoryModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260514--for: 【MES】MES基础资料下新增设备类型(mes_xsl_equipment_type,关联工序与设备类别、类型名称同租户唯一) ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentType.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentTypeMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentTypeService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentTypeServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentTypeController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentCategoryService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentCategoryServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_56__mes_xsl_equipment_type.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-type-menu-permission.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-type.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentType/MesXslEquipmentTypeList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentType/MesXslEquipmentType.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentType/MesXslEquipmentType.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentTypeModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentCategorySelectModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】MES基础资料下新增设备部位(mes_xsl_equipment_part,关联设备类别、部位代码同租户唯一、是否启用xslmes_unit_status) ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentPart.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentPartMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentPartService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentPartServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentPartController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_57__mes_xsl_equipment_part.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-part-menu-permission.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-part.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPartList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/components/MesXslEquipmentPartModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】设备部位:部位代码不能重复(文案与保存/导入顺序、选类别后重验代码) ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentPartController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentPartService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentPartServiceImpl.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/components/MesXslEquipmentPartModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】设备部位:明确部位代码仅同租户全局唯一(不按设备类别);去掉选类别后重验部位代码 ---
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/components/MesXslEquipmentPartModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】设备部位:部门名称字段改为部位名称(dept_name->part_name,实体partName) ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentPart.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentPartController.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_58__mes_xsl_equipment_part_dept_name_to_part_name.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-part.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-part-menu-permission.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.data.ts
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】新增设备小部位(mes_xsl_equipment_sub_part,挂 MES 基础资料,类别/大部位冗余、小部位代码同租户唯一) ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_59__mes_xsl_equipment_sub_part.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-sub-part.sql
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentSubPart.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentSubPartMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentSubPartService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentSubPartServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentSubPartController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentPartService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentPartServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPartList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPart.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPart.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/components/MesXslEquipmentSubPartModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/components/MesXslEquipmentPartSelectModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】设备小部位菜单挂到 MES XSL(XSLMES管理)父级下 ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_60__mes_xsl_equipment_sub_part_menu_xslmes_root.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】新增备品件类别(mes_xsl_spare_parts_category,挂 MES 基础资料,类别名称同租户唯一) ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_61__mes_xsl_spare_parts_category.sql
|
||||
jeecg-boot/db/mes-xsl-spare-parts-category-menu-permission.sql
|
||||
jeecg-boot/db/mes-xsl-spare-parts-category.sql
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslSparePartsCategory.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslSparePartsCategoryMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslSparePartsCategoryService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslSparePartsCategoryServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslSparePartsCategoryController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePartsCategory/MesXslSparePartsCategoryList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePartsCategory/MesXslSparePartsCategory.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePartsCategory/MesXslSparePartsCategory.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePartsCategory/components/MesXslSparePartsCategoryModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】新增备品件信息(mes_xsl_spare_part,挂 MES 基础资料,名称同租户唯一、类别与单位冗余、库存上下限) ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_62__mes_xsl_spare_part.sql
|
||||
jeecg-boot/db/mes-xsl-spare-part-menu-permission.sql
|
||||
jeecg-boot/db/mes-xsl-spare-part.sql
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslSparePart.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslSparePartMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslSparePartService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslSparePartServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslSparePartController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslSparePartsCategoryService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslSparePartsCategoryServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslUnitService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslUnitServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePartsCategory/components/MesXslSparePartsCategorySelectModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/MesXslSparePartList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/MesXslSparePart.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/MesXslSparePart.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/components/MesXslSparePartModal.vue
|
||||
-- author:jiangxh---date:20260515--for: 【MES】厂家信息(厂家类别字典、名称同租户唯一、是否有效) ---
|
||||
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
|
||||
jeecg-boot/db/mes-xsl-manufacturer.sql
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_63__mes_xsl_manufacturer.sql
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslManufacturer.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslManufacturerMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslManufacturerService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslManufacturerServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslManufacturerController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
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
|
||||
@@ -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() {}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
@@ -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<明细实体> / 明细数组 / 嵌套对象),用于先选明细再反射明细字段")
|
||||
@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());
|
||||
|
||||
@@ -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 "";
|
||||
|
||||
@@ -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.dataBinding:params(参数键)、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;
|
||||
}
|
||||
|
||||
@@ -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<>();
|
||||
}
|
||||
@@ -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<>();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
-- MES 工序管理:将菜单挂到「MES基础资料」下,url/component 对齐 xslmes 前端(与客户管理同目录风格)
|
||||
-- 依赖:V3.9.2_53 已创建 mes_process_operation 表及 sys_permission id 1860000000000000060~066
|
||||
|
||||
UPDATE `sys_permission` p
|
||||
INNER JOIN (
|
||||
SELECT COALESCE(
|
||||
(SELECT MIN(s2.`id`) FROM `sys_permission` s2
|
||||
WHERE s2.`del_flag` = 0 AND s2.`menu_type` = 0
|
||||
AND s2.`name` IN ('MES基础资料', 'MES资料')),
|
||||
'1860000000000000001'
|
||||
) AS `pid`
|
||||
FROM DUAL
|
||||
) x ON 1 = 1
|
||||
SET p.`parent_id` = x.`pid`,
|
||||
p.`url` = '/xslmes/mesXslProcessOperation',
|
||||
p.`component` = 'xslmes/mesXslProcessOperation/MesXslProcessOperationList',
|
||||
p.`component_name` = NULL,
|
||||
p.`is_leaf` = 0,
|
||||
p.`update_by` = 'admin',
|
||||
p.`update_time` = NOW()
|
||||
WHERE p.`id` = '1860000000000000060';
|
||||
|
||||
UPDATE `sys_permission` SET `name` = '新增' WHERE `id` = '1860000000000000061' AND `name` = '添加';
|
||||
@@ -0,0 +1,98 @@
|
||||
-- MES 设备类别:建表 + 字典 + 菜单 + 按钮 + 租户 admin 授权(幂等片段可重复执行)
|
||||
-- 权限前缀:mes:mes_xsl_equipment_category:*(与 Controller、前端 v-auth 一致)
|
||||
-- 依赖:mes_process_operation 表已存在;父菜单「MES基础资料」或「MES资料」
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_category` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`category_name` varchar(128) NOT NULL COMMENT '设备类别名称',
|
||||
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序主键 mes_process_operation.id',
|
||||
`process_operation_name` varchar(128) DEFAULT NULL COMMENT '工序名称冗余展示',
|
||||
`inspect_distinct` varchar(32) NOT NULL COMMENT '点检区分 字典xslmes_equipment_inspect_distinct:generic通用 distinct区分',
|
||||
`maintain_distinct` varchar(32) NOT NULL COMMENT '保养区分 字典xslmes_equipment_maintain_distinct:maintain保养 distinct区分',
|
||||
`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_mec_tenant_name` (`tenant_id`, `category_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备类别';
|
||||
|
||||
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_inspect_distinct', '设备类别点检区分:通用/区分', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_equipment_inspect_distinct' 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, '通用', 'generic', 1, 1, 'admin', NOW()
|
||||
FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_equipment_inspect_distinct'
|
||||
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.`id` AND i.`item_value` = 'generic');
|
||||
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '区分', 'distinct', 2, 1, 'admin', NOW()
|
||||
FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_equipment_inspect_distinct'
|
||||
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.`id` AND i.`item_value` = 'distinct');
|
||||
|
||||
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_maintain_distinct', '设备类别保养区分:保养/区分', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_equipment_maintain_distinct' 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, '保养', 'maintain', 1, 1, 'admin', NOW()
|
||||
FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_equipment_maintain_distinct'
|
||||
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.`id` AND i.`item_value` = 'maintain');
|
||||
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '区分', 'distinct', 2, 1, 'admin', NOW()
|
||||
FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_equipment_maintain_distinct'
|
||||
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.`id` AND i.`item_value` = '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_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 ('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`), `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
|
||||
('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())
|
||||
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 (
|
||||
'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`
|
||||
);
|
||||
@@ -0,0 +1,65 @@
|
||||
-- MES 设备类型:建表 + 菜单 + 按钮 + 租户 admin 授权(与 Flyway V3.9.2_56 内容一致,可手工执行)
|
||||
-- 权限前缀:mes:mes_xsl_equipment_type:*(与 Controller、前端 v-auth 一致)
|
||||
-- 依赖:mes_process_operation、mes_xsl_equipment_category 已存在;父菜单「MES基础资料」或「MES资料」
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_type` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`type_name` varchar(128) NOT NULL COMMENT '设备类型名称',
|
||||
`process_operation_id` varchar(32) NOT NULL COMMENT '所属工序主键 mes_process_operation.id',
|
||||
`process_operation_name` varchar(128) DEFAULT NULL COMMENT '工序名称冗余展示',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`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_met_tenant_typename` (`tenant_id`, `type_name`)
|
||||
) 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 ('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`), `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
|
||||
('1860000000000000078', '1860000000000000077', '新增', 2, 'mes:mes_xsl_equipment_type:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000079', '1860000000000000077', '编辑', 2, 'mes:mes_xsl_equipment_type:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000080', '1860000000000000077', '删除', 2, 'mes:mes_xsl_equipment_type:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000081', '1860000000000000077', '批量删除', 2, 'mes:mes_xsl_equipment_type:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000082', '1860000000000000077', '导出', 2, 'mes:mes_xsl_equipment_type:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000083', '1860000000000000077', '导入', 2, 'mes:mes_xsl_equipment_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 (
|
||||
'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`
|
||||
);
|
||||
@@ -0,0 +1,66 @@
|
||||
-- MES 设备部位:建表 + 菜单 + 按钮 + 租户 admin 授权(与 Flyway V3.9.2_57 内容一致,可手工执行)
|
||||
-- 权限前缀:mes:mes_xsl_equipment_part:*(与 Controller、前端 v-auth 一致)
|
||||
-- 依赖:mes_xsl_equipment_category;父菜单「MES基础资料」或「MES资料」
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`dept_name` varchar(128) NOT NULL COMMENT '部门名称',
|
||||
`part_code` varchar(64) NOT NULL COMMENT '部位代码(同租户未删除数据中唯一)',
|
||||
`part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用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_mep_tenant_partcode` (`tenant_id`, `part_code`)
|
||||
) 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 ('1860000000000000084', @mes_base_pid, '设备部位', '/xslmes/mesXslEquipmentPart', 'xslmes/mesXslEquipmentPart/MesXslEquipmentPartList', NULL, 1, NULL, '1', 12, 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
|
||||
('1860000000000000085', '1860000000000000084', '新增', 2, 'mes:mes_xsl_equipment_part:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000086', '1860000000000000084', '编辑', 2, 'mes:mes_xsl_equipment_part:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000087', '1860000000000000084', '删除', 2, 'mes:mes_xsl_equipment_part:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000088', '1860000000000000084', '批量删除', 2, 'mes:mes_xsl_equipment_part:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000089', '1860000000000000084', '导出', 2, 'mes:mes_xsl_equipment_part:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000090', '1860000000000000084', '导入', 2, 'mes:mes_xsl_equipment_part: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 (
|
||||
'1860000000000000084',
|
||||
'1860000000000000085', '1860000000000000086', '1860000000000000087', '1860000000000000088',
|
||||
'1860000000000000089', '1860000000000000090'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
-- 设备部位:部门名称字段更名为部位名称(dept_name -> part_name)
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(1)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'mes_xsl_equipment_part'
|
||||
AND COLUMN_NAME = 'dept_name'
|
||||
);
|
||||
SET @ddl_sql := IF(
|
||||
@col_exists > 0,
|
||||
'ALTER TABLE `mes_xsl_equipment_part` CHANGE COLUMN `dept_name` `part_name` varchar(128) NOT NULL COMMENT ''部位名称''',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE stmt_mep_part_name FROM @ddl_sql;
|
||||
EXECUTE stmt_mep_part_name;
|
||||
DEALLOCATE PREPARE stmt_mep_part_name;
|
||||
@@ -0,0 +1,68 @@
|
||||
-- MES 设备小部位:建表 + 菜单 + 按钮 + 租户 admin 授权(与 jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql 建表与菜单段一致)
|
||||
-- 权限前缀:mes:mes_xsl_equipment_sub_part:*(与 Controller、前端 v-auth 一致)
|
||||
-- 依赖:mes_xsl_equipment_category、mes_xsl_equipment_part;父菜单「MES基础资料」或「MES资料」
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_sub_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`equipment_part_id` varchar(32) NOT NULL COMMENT '所属设备大部位主键 mes_xsl_equipment_part.id',
|
||||
`equipment_part_name` varchar(128) DEFAULT NULL COMMENT '设备大部位名称冗余(mes_xsl_equipment_part.part_name)',
|
||||
`sub_part_name` varchar(128) NOT NULL COMMENT '小部位名称',
|
||||
`sub_part_code` varchar(64) NOT NULL COMMENT '小部位代码(同租户未删除数据中唯一)',
|
||||
`sub_part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用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_mesp_tenant_subcode` (`tenant_id`, `sub_part_code`)
|
||||
) 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 ('1860000000000000091', @mes_base_pid, '设备小部位', '/xslmes/mesXslEquipmentSubPart', 'xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPartList', NULL, 1, NULL, '1', 13, 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
|
||||
('1860000000000000092', '1860000000000000091', '新增', 2, 'mes:mes_xsl_equipment_sub_part:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000093', '1860000000000000091', '编辑', 2, 'mes:mes_xsl_equipment_sub_part:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000094', '1860000000000000091', '删除', 2, 'mes:mes_xsl_equipment_sub_part:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000095', '1860000000000000091', '批量删除', 2, 'mes:mes_xsl_equipment_sub_part:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000096', '1860000000000000091', '导出', 2, 'mes:mes_xsl_equipment_sub_part:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000097', '1860000000000000091', '导入', 2, 'mes:mes_xsl_equipment_sub_part: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 (
|
||||
'1860000000000000091',
|
||||
'1860000000000000092', '1860000000000000093', '1860000000000000094', '1860000000000000095',
|
||||
'1860000000000000096', '1860000000000000097'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
-- MES 设备小部位:将二级菜单从「MES基础资料」挪到「MES XSL / XSLMES管理」根菜单下
|
||||
-- 依赖:V3.9.2_59 已写入 sys_permission id 1860000000000000091
|
||||
|
||||
UPDATE `sys_permission` p
|
||||
INNER JOIN (
|
||||
SELECT COALESCE(
|
||||
(SELECT MIN(s2.`id`) FROM `sys_permission` s2
|
||||
WHERE s2.`del_flag` = 0 AND s2.`menu_type` = 0
|
||||
AND s2.`name` IN ('MES XSL', 'XSLMES管理', 'XSLMES')),
|
||||
'1900000000000000300'
|
||||
) AS `pid`
|
||||
FROM DUAL
|
||||
) x ON 1 = 1
|
||||
SET p.`parent_id` = x.`pid`,
|
||||
p.`sort_no` = 14.00,
|
||||
p.`update_by` = 'admin',
|
||||
p.`update_time` = NOW()
|
||||
WHERE p.`id` = '1860000000000000091';
|
||||
@@ -0,0 +1,62 @@
|
||||
-- MES 备品件类别:建表 + 菜单 + 按钮 + 租户 admin 授权(与 jeecg-boot/db/mes-xsl-spare-parts-category-menu-permission.sql 建表与菜单段一致)
|
||||
-- 权限前缀:mes:mes_xsl_spare_parts_category:*(与 Controller、前端 v-auth 一致)
|
||||
-- 父菜单:MES基础资料 / MES资料
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_spare_parts_category` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`category_name` varchar(128) NOT NULL COMMENT '类别名称(同租户未删除数据中唯一)',
|
||||
`category_description` varchar(500) DEFAULT NULL COMMENT '描述',
|
||||
`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_mspc_tenant_catname` (`tenant_id`, `category_name`)
|
||||
) 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 ('1860000000000000098', @mes_base_pid, '备品件类别', '/xslmes/mesXslSparePartsCategory', 'xslmes/mesXslSparePartsCategory/MesXslSparePartsCategoryList', NULL, 1, NULL, '1', 15, 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
|
||||
('1860000000000000099', '1860000000000000098', '新增', 2, 'mes:mes_xsl_spare_parts_category:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000100', '1860000000000000098', '编辑', 2, 'mes:mes_xsl_spare_parts_category:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000101', '1860000000000000098', '删除', 2, 'mes:mes_xsl_spare_parts_category:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000102', '1860000000000000098', '批量删除', 2, 'mes:mes_xsl_spare_parts_category:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000103', '1860000000000000098', '导出', 2, 'mes:mes_xsl_spare_parts_category:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000104', '1860000000000000098', '导入', 2, 'mes:mes_xsl_spare_parts_category: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 (
|
||||
'1860000000000000098',
|
||||
'1860000000000000099', '1860000000000000100', '1860000000000000101', '1860000000000000102',
|
||||
'1860000000000000103', '1860000000000000104'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -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');
|
||||
@@ -0,0 +1,68 @@
|
||||
-- MES 备品件信息:建表 + 菜单 + 按钮 + 租户 admin 授权(与 jeecg-boot/db/mes-xsl-spare-part-menu-permission.sql 建表与菜单段一致)
|
||||
-- 权限前缀:mes:mes_xsl_spare_part:*(与 Controller、前端 v-auth 一致)
|
||||
-- 依赖:mes_xsl_spare_parts_category、mes_xsl_unit;父菜单 MES基础资料 / MES资料
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_spare_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`spare_part_name` varchar(128) NOT NULL COMMENT '备品件名称(同租户未删除数据中唯一)',
|
||||
`spare_parts_category_id` varchar(32) NOT NULL COMMENT '所属备品件类别 mes_xsl_spare_parts_category.id',
|
||||
`spare_parts_category_name` varchar(128) DEFAULT NULL COMMENT '备品件类别名称冗余',
|
||||
`spec_model` varchar(200) DEFAULT NULL COMMENT '规格型号',
|
||||
`max_stock` decimal(18,4) NOT NULL DEFAULT '0.0000' COMMENT '最大库存',
|
||||
`min_stock` decimal(18,4) NOT NULL DEFAULT '0.0000' COMMENT '最小库存',
|
||||
`unit_id` varchar(36) NOT NULL COMMENT '单位 mes_xsl_unit.id',
|
||||
`unit_name` varchar(100) DEFAULT NULL COMMENT '单位名称冗余',
|
||||
`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_msp_tenant_name` (`tenant_id`, `spare_part_name`)
|
||||
) 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 ('1860000000000000105', @mes_base_pid, '备品件信息', '/xslmes/mesXslSparePart', 'xslmes/mesXslSparePart/MesXslSparePartList', NULL, 1, NULL, '1', 16, 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
|
||||
('1860000000000000106', '1860000000000000105', '新增', 2, 'mes:mes_xsl_spare_part:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000107', '1860000000000000105', '编辑', 2, 'mes:mes_xsl_spare_part:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000108', '1860000000000000105', '删除', 2, 'mes:mes_xsl_spare_part:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000109', '1860000000000000105', '批量删除', 2, 'mes:mes_xsl_spare_part:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000110', '1860000000000000105', '导出', 2, 'mes:mes_xsl_spare_part:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000111', '1860000000000000105', '导入', 2, 'mes:mes_xsl_spare_part: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 (
|
||||
'1860000000000000105',
|
||||
'1860000000000000106', '1860000000000000107', '1860000000000000108', '1860000000000000109',
|
||||
'1860000000000000110', '1860000000000000111'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -0,0 +1,87 @@
|
||||
-- MES 厂家信息:字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权(与 jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql 一致)
|
||||
-- 权限前缀:mes:mes_xsl_manufacturer:*;父菜单 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_manufacturer_category', '模具厂家、胶囊厂家、设备厂家', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_manufacturer_category' 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, '模具厂家', 'mold', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'mold');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '胶囊厂家', 'capsule', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'capsule');
|
||||
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', 3, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_manufacturer_category' 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` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
|
||||
SELECT REPLACE(UUID(), '-', ''), 'MES厂家是否有效', 'xslmes_manufacturer_valid', '0有效1无效', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_manufacturer_valid' 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_manufacturer_valid' 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_manufacturer_valid' 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_manufacturer` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`manufacturer_category` varchar(32) NOT NULL COMMENT '厂家类别(字典xslmes_manufacturer_category:mold模具 capsule胶囊 equipment设备)',
|
||||
`manufacturer_name` varchar(128) NOT NULL COMMENT '厂家名称(同租户未删除数据中唯一)',
|
||||
`valid_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否有效(字典xslmes_manufacturer_valid:0有效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_mxm_tenant_name` (`tenant_id`, `manufacturer_name`)
|
||||
) 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 ('1860000000000000112', @mes_base_pid, '厂家信息', '/xslmes/mesXslManufacturer', 'xslmes/mesXslManufacturer/MesXslManufacturerList', NULL, 1, NULL, '1', 17, 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
|
||||
('1860000000000000113', '1860000000000000112', '新增', 2, 'mes:mes_xsl_manufacturer:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000114', '1860000000000000112', '编辑', 2, 'mes:mes_xsl_manufacturer:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000115', '1860000000000000112', '删除', 2, 'mes:mes_xsl_manufacturer:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000116', '1860000000000000112', '批量删除', 2, 'mes:mes_xsl_manufacturer:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000117', '1860000000000000112', '导出', 2, 'mes:mes_xsl_manufacturer:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000118', '1860000000000000112', '导入', 2, 'mes:mes_xsl_manufacturer: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 (
|
||||
'1860000000000000112',
|
||||
'1860000000000000113', '1860000000000000114', '1860000000000000115', '1860000000000000116',
|
||||
'1860000000000000117', '1860000000000000118'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
1340
jeecgboot-vue3/pnpm-lock.yaml
generated
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 20 KiB |
@@ -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 + 前端生成的 pdfBase64;printerName 空则用默认队列(与原材料卡片一致) */
|
||||
export const printPdf = (data: { id: string; printerName?: string; pdfBase64: string; fileName?: string }) =>
|
||||
defHttp.post({ url: Api.printPdf, data, timeout: 3 * 60 * 1000 });
|
||||
|
||||
@@ -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) },
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
10
jeecgboot-vue3/src/views/mes/processoperation/index.vue
Normal file
@@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<MesXslProcessOperationList />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 兼容旧菜单 component:mes/processoperation/index(V3.9.2_53 历史配置),实际页面在 xslmes。
|
||||
*/
|
||||
import MesXslProcessOperationList from '/@/views/xslmes/mesXslProcessOperation/MesXslProcessOperationList.vue';
|
||||
</script>
|
||||
@@ -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 });
|
||||
|
||||