From 457089e27153644db27c04d11cb2a1b79090b093 Mon Sep 17 00:00:00 2001 From: jiangxh <1217934998@qq.com> Date: Wed, 3 Jun 2026 16:28:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=AF=B9=E5=BA=94=E9=83=A8?= =?UTF-8?q?=E4=BD=8D=E5=8A=9F=E8=83=BD=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...xsl-equip-part-mapping-menu-permission.sql | 65 ++++++++ ...s-xsl-equipment-ledger-menu-permission.sql | 2 + jeecg-boot/db/mes-xsl-equipment-ledger.sql | 4 +- .../jeecg-module-xslmes/doc/代码修改日志 | 43 +++++ .../MesXslEquipPartMappingController.java | 57 +++++++ .../MesXslEquipmentLedgerController.java | 27 +++ .../xslmes/entity/MesXslEquipPartMapping.java | 75 +++++++++ .../xslmes/entity/MesXslEquipmentLedger.java | 4 + .../mapper/MesXslEquipPartMappingMapper.java | 6 + .../mapper/MesXslEquipmentLedgerMapper.java | 13 +- .../jeecg/modules/xslmes/package-info.java | 2 +- .../IMesXslEquipPartMappingService.java | 12 ++ .../IMesXslEquipmentLedgerService.java | 3 + .../MesXslEquipInspectConfigServiceImpl.java | 36 ++++ .../MesXslEquipPartMappingServiceImpl.java | 156 ++++++++++++++++++ .../MesXslEquipmentLedgerServiceImpl.java | 48 ++++++ ...22__mes_xsl_equipment_ledger_ledger_no.sql | 49 ++++++ ...V3.9.2_123__mes_xsl_equip_part_mapping.sql | 48 ++++++ .../MesXslEquipPartMapping.api.ts | 10 ++ .../MesXslEquipPartMapping.data.ts | 20 +++ .../MesXslEquipPartMappingList.vue | 45 +++++ .../MesXslEquipmentLedger.api.ts | 3 + .../MesXslEquipmentLedger.data.ts | 15 +- .../components/MesXslEquipmentLedgerModal.vue | 11 +- 24 files changed, 747 insertions(+), 7 deletions(-) create mode 100644 jeecg-boot/db/mes-xsl-equip-part-mapping-menu-permission.sql create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipPartMappingController.java create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipPartMapping.java create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipPartMappingMapper.java create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipPartMappingService.java create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipPartMappingServiceImpl.java create mode 100644 jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_122__mes_xsl_equipment_ledger_ledger_no.sql create mode 100644 jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_123__mes_xsl_equip_part_mapping.sql create mode 100644 jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.api.ts create mode 100644 jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.data.ts create mode 100644 jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMappingList.vue diff --git a/jeecg-boot/db/mes-xsl-equip-part-mapping-menu-permission.sql b/jeecg-boot/db/mes-xsl-equip-part-mapping-menu-permission.sql new file mode 100644 index 0000000..0db100b --- /dev/null +++ b/jeecg-boot/db/mes-xsl-equip-part-mapping-menu-permission.sql @@ -0,0 +1,65 @@ +-- MES 设备对应部位:建表 + 菜单 + 按钮 + 租户 admin 授权(可整文件一次执行) +-- 权限前缀:mes:mes_xsl_equip_part_mapping:* +-- 数据由设备点检配置保存后自动生成,列表无手工新增 +-- Flyway:V3.9.2_123__mes_xsl_equip_part_mapping.sql +SET NAMES utf8mb4; + +CREATE TABLE IF NOT EXISTS `mes_xsl_equip_part_mapping` ( + `id` varchar(32) NOT NULL COMMENT '主键', + `equipment_ledger_id` varchar(32) NOT NULL COMMENT '设备台账主键 mes_xsl_equipment_ledger.id', + `equipment_name` varchar(500) NOT NULL COMMENT '设备名称', + `machine_code` varchar(500) DEFAULT NULL COMMENT '机台代号(设备编号冗余)', + `equipment_part_id` varchar(32) NOT NULL COMMENT '设备大部位主键 mes_xsl_equipment_part.id', + `equipment_part_name` varchar(500) DEFAULT NULL COMMENT '设备大部位名称', + `part_code` varchar(500) DEFAULT NULL COMMENT '大部位代码', + `equipment_sub_part_id` varchar(32) NOT NULL COMMENT '设备小部位主键 mes_xsl_equipment_sub_part.id', + `equipment_sub_part_name` varchar(500) DEFAULT NULL COMMENT '设备小部位名称', + `sub_part_code` 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`), + UNIQUE KEY `uk_mepm_ledger_part_sub` (`equipment_ledger_id`, `equipment_part_id`, `equipment_sub_part_id`), + KEY `idx_mepm_tenant_equip_name` (`tenant_id`, `equipment_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备对应部位'; + +SET @mes_tenant_id = 1002; + +SET @mes_equip_pid = ( + SELECT `id` FROM `sys_permission` + WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理' + LIMIT 1 +); +SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133'); + +INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`) +VALUES ('1860000000000000215', @mes_equip_pid, '设备对应部位', '/xslmes/mesXslEquipPartMapping', 'xslmes/mesXslEquipPartMapping/MesXslEquipPartMappingList', 'MesXslEquipPartMappingList', 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`), `icon` = 'ant-design:apartment-outlined'; + +UPDATE `sys_permission` SET `icon` = 'ant-design:apartment-outlined' WHERE `id` = '1860000000000000215' AND `del_flag` = 0; + +INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES +('1860000000000000216', '1860000000000000215', '导出', 2, 'mes:mes_xsl_equip_part_mapping:exportXls', '1', '1', 0, 'admin', NOW()) +ON DUPLICATE KEY UPDATE +`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), +`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`); + +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 ('1860000000000000215', '1860000000000000216') + AND NOT EXISTS ( + SELECT 1 FROM `sys_role_permission` rp + WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id` + ); diff --git a/jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql b/jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql index 2fea0db..a16f131 100644 --- a/jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql +++ b/jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql @@ -23,6 +23,7 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_ledger` ( `process_operation_id` varchar(32) NOT NULL COMMENT '所属工序 mes_xsl_process_operation.id', `process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余', `equipment_name` varchar(500) NOT NULL COMMENT '设备名称(同租户未删除唯一)', + `ledger_no` varchar(16) DEFAULT NULL COMMENT '编号(租户内从001递增自动生成,只读)', `equipment_code` varchar(128) NOT NULL COMMENT '设备编号(同租户未删除唯一)', `manufacturer_id` varchar(32) DEFAULT NULL COMMENT '所属设备厂家 mes_xsl_manufacturer.id', `manufacturer_name` varchar(500) DEFAULT NULL COMMENT '设备厂家名称冗余', @@ -59,6 +60,7 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_ledger` ( `del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)', PRIMARY KEY (`id`), KEY `idx_mel_tenant_code` (`tenant_id`, `equipment_code`), + KEY `idx_mel_tenant_ledger_no` (`tenant_id`, `ledger_no`), KEY `idx_mel_tenant_name` (`tenant_id`, `equipment_name`), KEY `idx_mel_process` (`process_operation_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备台账'; diff --git a/jeecg-boot/db/mes-xsl-equipment-ledger.sql b/jeecg-boot/db/mes-xsl-equipment-ledger.sql index bf49bf8..f86016b 100644 --- a/jeecg-boot/db/mes-xsl-equipment-ledger.sql +++ b/jeecg-boot/db/mes-xsl-equipment-ledger.sql @@ -6,7 +6,8 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_ledger` ( `process_operation_id` varchar(32) NOT NULL COMMENT '所属工序', `process_operation_name` varchar(500) DEFAULT NULL COMMENT '工序名称冗余', `equipment_name` varchar(500) NOT NULL COMMENT '设备名称', - `equipment_code` varchar(128) NOT NULL COMMENT '设备编号', + `ledger_no` varchar(16) DEFAULT NULL COMMENT '编号(租户内从001递增自动生成,只读)', + `equipment_code` varchar(128) NOT NULL COMMENT '设备编号(同租户不可重复)', `manufacturer_id` varchar(32) DEFAULT NULL COMMENT '所属设备厂家', `manufacturer_name` varchar(500) DEFAULT NULL COMMENT '设备厂家名称冗余', `equipment_category_id` varchar(32) DEFAULT NULL COMMENT '设备类别', @@ -42,5 +43,6 @@ CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_ledger` ( `del_flag` int DEFAULT '0' COMMENT '删除标记', PRIMARY KEY (`id`), KEY `idx_mel_tenant_code` (`tenant_id`, `equipment_code`), + KEY `idx_mel_tenant_ledger_no` (`tenant_id`, `ledger_no`), KEY `idx_mel_tenant_name` (`tenant_id`, `equipment_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备台账'; diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/doc/代码修改日志 b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/doc/代码修改日志 index 576c33e..181abf3 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/doc/代码修改日志 +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/doc/代码修改日志 @@ -678,3 +678,46 @@ jeecgboot-vue3/src/views/xslmes/mesXslRubberSmallLockLog/MesXslRubberSmallLockLo jeecgboot-vue3/src/views/xslmes/mesXslRubberSmallLockLog/MesXslRubberSmallLockLog.api.ts jeecgboot-vue3/src/views/xslmes/mesXslRubberSmallLockLog/MesXslRubberSmallLockLogList.vue jeecgboot-vue3/src/views/xslmes/mesXslRubberSmallLockLog/components/MesXslRubberSmallLockLogModal.vue + +-- author:jiangxh---date:20250602--for: 【MES】设备台账原设备编号改为自定义编号、新增001自增只读系统编号 --- +jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_122__mes_xsl_equipment_ledger_ledger_no.sql +jeecg-boot/db/mes-xsl-equipment-ledger.sql +jeecg-boot/db/mes-xsl-equipment-ledger-menu-permission.sql +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentLedger.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentLedgerMapper.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentLedgerService.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentLedgerServiceImpl.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java +jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts +jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api.ts +jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/components/MesXslEquipmentLedgerModal.vue +jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/components/MesXslEquipmentLedgerSelectModal.vue +jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/components/MesXslEquipmentLedgerMultiSelectModal.vue + +-- author:jiangxh---date:20250602--for: 【MES】设备台账设备类别、设备类型必填 --- +jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java + +-- author:jiangxh---date:20250602--for: 【MES】设备台账 ledgerNo 显示名改为设备编号 --- +jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentLedger.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java + +-- author:jiangxh---date:20250602--for: 【MES】设备台账 ledgerNo 显示名改为系统编号、equipmentCode 改为设备编号 --- +jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentLedger.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java + +-- author:jiangxh---date:20250603--for: 【MES】设备对应部位:点检配置保存后按大部位+小部位去重生成,列表只读无新增 --- +jeecg-boot/db/mes-xsl-equip-part-mapping-menu-permission.sql +jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_123__mes_xsl_equip_part_mapping.sql +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipPartMapping.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipPartMappingMapper.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipPartMappingService.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipPartMappingServiceImpl.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipPartMappingController.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipInspectConfigServiceImpl.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java +jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMappingList.vue +jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.data.ts +jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.api.ts diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipPartMappingController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipPartMappingController.java new file mode 100644 index 0000000..be8d6f5 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipPartMappingController.java @@ -0,0 +1,57 @@ +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 lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.modules.xslmes.entity.MesXslEquipPartMapping; +import org.jeecg.modules.xslmes.service.IMesXslEquipPartMappingService; +import org.springframework.beans.factory.annotation.Autowired; +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; + +/** + * MES 设备对应部位(只读列表,数据由设备点检配置保存后自动生成) + */ +@Tag(name = "MES设备对应部位") +@RestController +@RequestMapping("/xslmes/mesXslEquipPartMapping") +@Slf4j +public class MesXslEquipPartMappingController + extends JeecgController { + + @Autowired + private IMesXslEquipPartMappingService mesXslEquipPartMappingService; + + @Operation(summary = "MES设备对应部位-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList( + MesXslEquipPartMapping model, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap()); + //update-begin---author:jiangxh ---date:20250603 for:【MES】设备对应部位列表按设备名称、机台代号、大部位代码排序----------- + queryWrapper.orderByAsc("equipment_name", "machine_code", "part_code", "sub_part_code"); + //update-end---author:jiangxh ---date:20250603 for:【MES】设备对应部位列表按设备名称、机台代号、大部位代码排序----------- + Page page = new Page<>(pageNo, pageSize); + IPage pageList = mesXslEquipPartMappingService.page(page, queryWrapper); + return Result.OK(pageList); + } + + @RequiresPermissions("mes:mes_xsl_equip_part_mapping:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, MesXslEquipPartMapping model) { + return super.exportXls(request, model, MesXslEquipPartMapping.class, "MES设备对应部位"); + } +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java index 3934b73..54bd337 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentLedgerController.java @@ -69,6 +69,9 @@ public class MesXslEquipmentLedgerController extends JeecgController nextLedgerNo() { + MesXslEquipmentLedger ctx = new MesXslEquipmentLedger(); + return Result.OK(mesXslEquipmentLedgerService.generateNextLedgerNo(ctx)); + } + @Operation(summary = "校验设备名称是否重复") @GetMapping(value = "/checkEquipmentName") public Result checkEquipmentName( @@ -225,6 +235,14 @@ public class MesXslEquipmentLedgerController extends JeecgController {} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentLedgerMapper.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentLedgerMapper.java index 6dbabd1..f710849 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentLedgerMapper.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentLedgerMapper.java @@ -1,6 +1,17 @@ package org.jeecg.modules.xslmes.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger; -public interface MesXslEquipmentLedgerMapper extends BaseMapper {} +public interface MesXslEquipmentLedgerMapper extends BaseMapper { + + //update-begin---author:jiangxh ---date:20250602 for:【MES】设备台账租户内最大三位系统编号----------- + @Select( + "SELECT IFNULL(MAX(CAST(ledger_no AS UNSIGNED)), 0) FROM mes_xsl_equipment_ledger " + + "WHERE del_flag = 0 AND ledger_no REGEXP '^[0-9]+$' " + + "AND (#{tenantId} IS NULL OR tenant_id = #{tenantId})") + Integer selectMaxNumericLedgerNo(@Param("tenantId") Integer tenantId); + //update-end---author:jiangxh ---date:20250602 for:【MES】设备台账租户内最大三位系统编号----------- +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java index 01d97f0..fb5a8cd 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java @@ -1,5 +1,5 @@ /** * MES XSL 业务模块(Maven 工程名:jeecg-module-xslmes)。 - * 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备台账({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、点检及保养项目({@link org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem})、设备点检配置({@link org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfig})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})、停机主类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType})、停机类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeType})等。 + * 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备台账({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、点检及保养项目({@link org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem})、设备点检配置({@link org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfig})、设备对应部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipPartMapping})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})、停机主类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType})、停机类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeType})等。 */ package org.jeecg.modules.xslmes; diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipPartMappingService.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipPartMappingService.java new file mode 100644 index 0000000..c535b09 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipPartMappingService.java @@ -0,0 +1,12 @@ +package org.jeecg.modules.xslmes.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.xslmes.entity.MesXslEquipPartMapping; + +public interface IMesXslEquipPartMappingService extends IService { + + /** + * 根据设备台账下全部点检/保养配置明细,按大部位+小部位去重后重建对应部位记录。 + */ + void syncByEquipmentLedgerId(String equipmentLedgerId); +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentLedgerService.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentLedgerService.java index 40dda4e..dac2e4f 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentLedgerService.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentLedgerService.java @@ -5,6 +5,9 @@ import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger; public interface IMesXslEquipmentLedgerService extends IService { + /** 生成下一系统编号(001 起,三位数字,租户维度) */ + String generateNextLedgerNo(MesXslEquipmentLedger context); + boolean isEquipmentCodeDuplicated(String equipmentCode, String excludeId, MesXslEquipmentLedger context); boolean isEquipmentNameDuplicated(String equipmentName, String excludeId, MesXslEquipmentLedger context); diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipInspectConfigServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipInspectConfigServiceImpl.java index 207b78c..ff6137e 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipInspectConfigServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipInspectConfigServiceImpl.java @@ -13,6 +13,7 @@ import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfigLine; import org.jeecg.modules.xslmes.mapper.MesXslEquipInspectConfigLineMapper; import org.jeecg.modules.xslmes.mapper.MesXslEquipInspectConfigMapper; import org.jeecg.modules.xslmes.service.IMesXslEquipInspectConfigService; +import org.jeecg.modules.xslmes.service.IMesXslEquipPartMappingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,21 +27,40 @@ public class MesXslEquipInspectConfigServiceImpl @Autowired private MesXslEquipInspectConfigLineMapper mesXslEquipInspectConfigLineMapper; + @Autowired + private IMesXslEquipPartMappingService mesXslEquipPartMappingService; + @Override @Transactional(rollbackFor = Exception.class) public void saveMain(MesXslEquipInspectConfig main, List lineList) { this.save(main); insertLines(main.getId(), lineList); + //update-begin---author:jiangxh ---date:20250603 for:【MES】设备点检配置保存后同步设备对应部位----------- + syncEquipPartMapping(main.getEquipmentLedgerId()); + //update-end---author:jiangxh ---date:20250603 for:【MES】设备点检配置保存后同步设备对应部位----------- } @Override @Transactional(rollbackFor = Exception.class) public void updateMain(MesXslEquipInspectConfig main, List lineList) { + //update-begin---author:jiangxh ---date:20250603 for:【MES】设备点检配置变更台账时同步原设备对应部位----------- + MesXslEquipInspectConfig old = this.getById(main.getId()); + String oldLedgerId = old != null ? old.getEquipmentLedgerId() : null; + //update-end---author:jiangxh ---date:20250603 for:【MES】设备点检配置变更台账时同步原设备对应部位----------- this.updateById(main); mesXslEquipInspectConfigLineMapper.delete( new LambdaQueryWrapper() .eq(MesXslEquipInspectConfigLine::getConfigId, main.getId())); insertLines(main.getId(), lineList); + //update-begin---author:jiangxh ---date:20250603 for:【MES】设备点检配置保存后同步设备对应部位----------- + syncEquipPartMapping(main.getEquipmentLedgerId()); + String newLedgerId = main.getEquipmentLedgerId(); + if (oConvertUtils.isNotEmpty(oldLedgerId) + && oConvertUtils.isNotEmpty(newLedgerId) + && !oldLedgerId.trim().equals(newLedgerId.trim())) { + syncEquipPartMapping(oldLedgerId); + } + //update-end---author:jiangxh ---date:20250603 for:【MES】设备点检配置保存后同步设备对应部位----------- } private void insertLines(String configId, List lineList) { @@ -59,9 +79,16 @@ public class MesXslEquipInspectConfigServiceImpl @Override @Transactional(rollbackFor = Exception.class) public void delMain(String id) { + //update-begin---author:jiangxh ---date:20250603 for:【MES】设备点检配置删除后同步设备对应部位----------- + MesXslEquipInspectConfig main = this.getById(id); + String ledgerId = main != null ? main.getEquipmentLedgerId() : null; + //update-end---author:jiangxh ---date:20250603 for:【MES】设备点检配置删除后同步设备对应部位----------- mesXslEquipInspectConfigLineMapper.delete( new LambdaQueryWrapper().eq(MesXslEquipInspectConfigLine::getConfigId, id)); this.removeById(id); + //update-begin---author:jiangxh ---date:20250603 for:【MES】设备点检配置删除后同步设备对应部位----------- + syncEquipPartMapping(ledgerId); + //update-end---author:jiangxh ---date:20250603 for:【MES】设备点检配置删除后同步设备对应部位----------- } @Override @@ -106,4 +133,13 @@ public class MesXslEquipInspectConfigServiceImpl } //update-end---author:jiangxh ---date:20260519 for:【MES】设备点检配置:同设备同类型(点检/保养)仅允许一条主数据----------- + + //update-begin---author:jiangxh ---date:20250603 for:【MES】设备点检配置保存后同步设备对应部位----------- + private void syncEquipPartMapping(String equipmentLedgerId) { + if (oConvertUtils.isEmpty(equipmentLedgerId)) { + return; + } + mesXslEquipPartMappingService.syncByEquipmentLedgerId(equipmentLedgerId); + } + //update-end---author:jiangxh ---date:20250603 for:【MES】设备点检配置保存后同步设备对应部位----------- } diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipPartMappingServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipPartMappingServiceImpl.java new file mode 100644 index 0000000..2584ac0 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipPartMappingServiceImpl.java @@ -0,0 +1,156 @@ +package org.jeecg.modules.xslmes.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfig; +import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfigLine; +import org.jeecg.modules.xslmes.entity.MesXslEquipPartMapping; +import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger; +import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart; +import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart; +import org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem; +import org.jeecg.modules.xslmes.mapper.MesXslEquipInspectConfigLineMapper; +import org.jeecg.modules.xslmes.mapper.MesXslEquipInspectConfigMapper; +import org.jeecg.modules.xslmes.mapper.MesXslEquipPartMappingMapper; +import org.jeecg.modules.xslmes.service.IMesXslEquipPartMappingService; +import org.jeecg.modules.xslmes.service.IMesXslEquipmentLedgerService; +import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService; +import org.jeecg.modules.xslmes.service.IMesXslEquipmentSubPartService; +import org.jeecg.modules.xslmes.service.IMesXslInspectMaintainItemService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +@Service +public class MesXslEquipPartMappingServiceImpl + extends ServiceImpl + implements IMesXslEquipPartMappingService { + + @Autowired + private IMesXslEquipmentLedgerService mesXslEquipmentLedgerService; + + @Autowired + private IMesXslInspectMaintainItemService mesXslInspectMaintainItemService; + + @Autowired + private IMesXslEquipmentPartService mesXslEquipmentPartService; + + @Autowired + private IMesXslEquipmentSubPartService mesXslEquipmentSubPartService; + + @Autowired + private MesXslEquipInspectConfigMapper mesXslEquipInspectConfigMapper; + + @Autowired + private MesXslEquipInspectConfigLineMapper mesXslEquipInspectConfigLineMapper; + + //update-begin---author:jiangxh ---date:20250603 for:【MES】设备点检配置保存后按大部位+小部位去重生成设备对应部位----------- + @Override + @Transactional(rollbackFor = Exception.class) + public void syncByEquipmentLedgerId(String equipmentLedgerId) { + if (oConvertUtils.isEmpty(equipmentLedgerId)) { + return; + } + String ledgerId = equipmentLedgerId.trim(); + MesXslEquipmentLedger ledger = mesXslEquipmentLedgerService.getById(ledgerId); + if (ledger == null || isDeleted(ledger.getDelFlag())) { + removeByLedgerId(ledgerId); + return; + } + + LambdaQueryWrapper configW = new LambdaQueryWrapper<>(); + configW.eq(MesXslEquipInspectConfig::getEquipmentLedgerId, ledgerId); + configW.and( + q -> + q.eq(MesXslEquipInspectConfig::getDelFlag, CommonConstant.DEL_FLAG_0) + .or() + .isNull(MesXslEquipInspectConfig::getDelFlag)); + List configs = mesXslEquipInspectConfigMapper.selectList(configW); + + Map unique = new LinkedHashMap<>(); + if (!CollectionUtils.isEmpty(configs)) { + for (MesXslEquipInspectConfig config : configs) { + List lines = + mesXslEquipInspectConfigLineMapper.selectList( + new LambdaQueryWrapper() + .eq(MesXslEquipInspectConfigLine::getConfigId, config.getId()) + .orderByAsc(MesXslEquipInspectConfigLine::getSortNo)); + if (CollectionUtils.isEmpty(lines)) { + continue; + } + for (MesXslEquipInspectConfigLine line : lines) { + if (line == null || oConvertUtils.isEmpty(line.getInspectMaintainItemId())) { + continue; + } + MesXslInspectMaintainItem item = + mesXslInspectMaintainItemService.getById(line.getInspectMaintainItemId().trim()); + if (item == null || isDeleted(item.getDelFlag())) { + continue; + } + if (oConvertUtils.isEmpty(item.getEquipmentPartId()) + || oConvertUtils.isEmpty(item.getEquipmentSubPartId())) { + continue; + } + String partKey = item.getEquipmentPartId().trim() + "|" + item.getEquipmentSubPartId().trim(); + if (unique.containsKey(partKey)) { + continue; + } + MesXslEquipPartMapping row = buildMappingRow(ledger, item); + if (row != null) { + unique.put(partKey, row); + } + } + } + } + + removeByLedgerId(ledgerId); + if (unique.isEmpty()) { + return; + } + saveBatch(new ArrayList<>(unique.values())); + } + + private MesXslEquipPartMapping buildMappingRow(MesXslEquipmentLedger ledger, MesXslInspectMaintainItem item) { + MesXslEquipmentPart part = mesXslEquipmentPartService.getById(item.getEquipmentPartId()); + MesXslEquipmentSubPart subPart = mesXslEquipmentSubPartService.getById(item.getEquipmentSubPartId()); + if (part == null || isDeleted(part.getDelFlag()) || subPart == null || isDeleted(subPart.getDelFlag())) { + return null; + } + MesXslEquipPartMapping row = new MesXslEquipPartMapping(); + row.setEquipmentLedgerId(ledger.getId()); + row.setEquipmentName(ledger.getEquipmentName()); + row.setMachineCode(ledger.getEquipmentCode()); + row.setEquipmentPartId(part.getId()); + row.setEquipmentPartName( + oConvertUtils.isNotEmpty(part.getPartName()) ? part.getPartName() : item.getEquipmentPartName()); + row.setPartCode(part.getPartCode()); + row.setEquipmentSubPartId(subPart.getId()); + row.setEquipmentSubPartName( + oConvertUtils.isNotEmpty(subPart.getSubPartName()) + ? subPart.getSubPartName() + : item.getEquipmentSubPartName()); + row.setSubPartCode(subPart.getSubPartCode()); + row.setTenantId(ledger.getTenantId()); + row.setSysOrgCode(ledger.getSysOrgCode()); + row.setDelFlag(CommonConstant.DEL_FLAG_0); + return row; + } + + private void removeByLedgerId(String equipmentLedgerId) { + this.remove( + new LambdaQueryWrapper() + .eq(MesXslEquipPartMapping::getEquipmentLedgerId, equipmentLedgerId)); + } + + private static boolean isDeleted(Integer delFlag) { + return delFlag != null && delFlag.equals(CommonConstant.DEL_FLAG_1); + } + //update-end---author:jiangxh ---date:20250603 for:【MES】设备点检配置保存后按大部位+小部位去重生成设备对应部位----------- +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentLedgerServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentLedgerServiceImpl.java index 5ff53c2..27bf75b 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentLedgerServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentLedgerServiceImpl.java @@ -9,6 +9,7 @@ import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger; import org.jeecg.modules.xslmes.mapper.MesXslEquipmentLedgerMapper; import org.jeecg.modules.xslmes.service.IMesXslEquipmentLedgerService; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class MesXslEquipmentLedgerServiceImpl extends ServiceImpl @@ -47,4 +48,51 @@ public class MesXslEquipmentLedgerServiceImpl extends ServiceImpl 999) { + throw new IllegalStateException("编号已超过999,请联系管理员"); + } + return String.format("%03d", next); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean save(MesXslEquipmentLedger entity) { + if (oConvertUtils.isEmpty(entity.getLedgerNo())) { + entity.setLedgerNo(generateNextLedgerNo(entity)); + } + return super.save(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean saveBatch(java.util.Collection entityList, int batchSize) { + if (entityList != null) { + for (MesXslEquipmentLedger entity : entityList) { + if (oConvertUtils.isEmpty(entity.getLedgerNo())) { + entity.setLedgerNo(generateNextLedgerNo(entity)); + } + } + } + return super.saveBatch(entityList, batchSize); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean updateById(MesXslEquipmentLedger entity) { + if (oConvertUtils.isNotEmpty(entity.getId())) { + MesXslEquipmentLedger old = getById(entity.getId()); + if (old != null) { + entity.setLedgerNo(old.getLedgerNo()); + } + } + return super.updateById(entity); + } + //update-end---author:jiangxh ---date:20250602 for:【MES】设备台账系统编号001递增、编辑不可改----------- } diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_122__mes_xsl_equipment_ledger_ledger_no.sql b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_122__mes_xsl_equipment_ledger_ledger_no.sql new file mode 100644 index 0000000..b98bd2d --- /dev/null +++ b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_122__mes_xsl_equipment_ledger_ledger_no.sql @@ -0,0 +1,49 @@ +-- MES 设备台账:新增系统编号 ledger_no(001自增)+ 历史数据回填;equipment_code 语义改为自定义编号 +SET NAMES utf8mb4; + +SET @ledger_no_exists := ( + SELECT COUNT(1) + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'mes_xsl_equipment_ledger' + AND COLUMN_NAME = 'ledger_no' +); +SET @ddl_ledger_no := IF( + @ledger_no_exists = 0, + 'ALTER TABLE `mes_xsl_equipment_ledger` ADD COLUMN `ledger_no` varchar(16) DEFAULT NULL COMMENT ''编号(租户内从001递增自动生成,只读)'' AFTER `equipment_name`', + 'SELECT 1' +); +PREPARE stmt_ledger_no FROM @ddl_ledger_no; +EXECUTE stmt_ledger_no; +DEALLOCATE PREPARE stmt_ledger_no; + +UPDATE `mes_xsl_equipment_ledger` t +INNER JOIN ( + SELECT + id, + LPAD( + ROW_NUMBER() OVER (PARTITION BY IFNULL(tenant_id, 0) ORDER BY IFNULL(create_time, '1970-01-01'), id), + 3, + '0' + ) AS new_no + FROM `mes_xsl_equipment_ledger` + WHERE del_flag = 0 +) s ON t.id = s.id +SET t.ledger_no = s.new_no +WHERE t.del_flag = 0 AND (t.ledger_no IS NULL OR TRIM(t.ledger_no) = ''); + +SET @idx_ledger_no_exists := ( + SELECT COUNT(1) + FROM information_schema.STATISTICS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'mes_xsl_equipment_ledger' + AND INDEX_NAME = 'idx_mel_tenant_ledger_no' +); +SET @ddl_idx_ledger_no := IF( + @idx_ledger_no_exists = 0, + 'ALTER TABLE `mes_xsl_equipment_ledger` ADD KEY `idx_mel_tenant_ledger_no` (`tenant_id`, `ledger_no`)', + 'SELECT 1' +); +PREPARE stmt_idx_ledger_no FROM @ddl_idx_ledger_no; +EXECUTE stmt_idx_ledger_no; +DEALLOCATE PREPARE stmt_idx_ledger_no; diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_123__mes_xsl_equip_part_mapping.sql b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_123__mes_xsl_equip_part_mapping.sql new file mode 100644 index 0000000..fc1f0be --- /dev/null +++ b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_123__mes_xsl_equip_part_mapping.sql @@ -0,0 +1,48 @@ +-- MES 设备对应部位(由设备点检配置保存后自动生成) +SET NAMES utf8mb4; + +CREATE TABLE IF NOT EXISTS `mes_xsl_equip_part_mapping` ( + `id` varchar(32) NOT NULL COMMENT '主键', + `equipment_ledger_id` varchar(32) NOT NULL COMMENT '设备台账主键 mes_xsl_equipment_ledger.id', + `equipment_name` varchar(500) NOT NULL COMMENT '设备名称', + `machine_code` varchar(500) DEFAULT NULL COMMENT '机台代号(设备编号冗余)', + `equipment_part_id` varchar(32) NOT NULL COMMENT '设备大部位主键 mes_xsl_equipment_part.id', + `equipment_part_name` varchar(500) DEFAULT NULL COMMENT '设备大部位名称', + `part_code` varchar(500) DEFAULT NULL COMMENT '大部位代码', + `equipment_sub_part_id` varchar(32) NOT NULL COMMENT '设备小部位主键 mes_xsl_equipment_sub_part.id', + `equipment_sub_part_name` varchar(500) DEFAULT NULL COMMENT '设备小部位名称', + `sub_part_code` 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`), + UNIQUE KEY `uk_mepm_ledger_part_sub` (`equipment_ledger_id`, `equipment_part_id`, `equipment_sub_part_id`), + KEY `idx_mepm_tenant_equip_name` (`tenant_id`, `equipment_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备对应部位'; + +SET @mes_equip_pid = ( + SELECT `id` FROM `sys_permission` + WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理' + LIMIT 1 +); +SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133'); + +INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`) +SELECT '1860000000000000215', @mes_equip_pid, '设备对应部位', '/xslmes/mesXslEquipPartMapping', 'xslmes/mesXslEquipPartMapping/MesXslEquipPartMappingList', 'MesXslEquipPartMappingList', 1, NULL, '1', 14, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW() +FROM DUAL +WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1860000000000000215'); + +UPDATE `sys_permission` SET + `parent_id` = @mes_equip_pid, `name` = '设备对应部位', `url` = '/xslmes/mesXslEquipPartMapping', + `component` = 'xslmes/mesXslEquipPartMapping/MesXslEquipPartMappingList', `component_name` = 'MesXslEquipPartMappingList', + `menu_type` = 1, `sort_no` = 14, `is_route` = 1, `is_leaf` = 0, `icon` = 'ant-design:apartment-outlined', `del_flag` = 0 +WHERE `id` = '1860000000000000215'; + +INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) +SELECT '1860000000000000216', '1860000000000000215', '导出', 2, 'mes:mes_xsl_equip_part_mapping:exportXls', '1', '1', 0, 'admin', NOW() +FROM DUAL +WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1860000000000000216'); diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.api.ts b/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.api.ts new file mode 100644 index 0000000..a1e888a --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.api.ts @@ -0,0 +1,10 @@ +import { defHttp } from '/@/utils/http/axios'; + +enum Api { + list = '/xslmes/mesXslEquipPartMapping/list', + exportXls = '/xslmes/mesXslEquipPartMapping/exportXls', +} + +export const list = (params) => defHttp.get({ url: Api.list, params }); + +export const getExportUrl = Api.exportXls; diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.data.ts b/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.data.ts new file mode 100644 index 0000000..b18404a --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMapping.data.ts @@ -0,0 +1,20 @@ +import { BasicColumn, FormSchema } from '/@/components/Table'; + +export const columns: BasicColumn[] = [ + { title: '设备名称', align: 'center', dataIndex: 'equipmentName', width: 180 }, + { title: '机台代号', align: 'center', dataIndex: 'machineCode', width: 140 }, + { title: '设备大部位', align: 'center', dataIndex: 'equipmentPartName', width: 160 }, + { title: '大部位代码', align: 'center', dataIndex: 'partCode', width: 120 }, + { title: '设备小部位', align: 'center', dataIndex: 'equipmentSubPartName', width: 160 }, + { title: '小部位代码', align: 'center', dataIndex: 'subPartCode', width: 120 }, + { title: '创建时间', align: 'center', dataIndex: 'createTime', width: 165 }, +]; + +export const searchFormSchema: FormSchema[] = [ + { label: '设备名称', field: 'equipmentName', component: 'Input', colProps: { span: 6 } }, + { label: '机台代号', field: 'machineCode', component: 'Input', colProps: { span: 6 } }, + { label: '设备大部位', field: 'equipmentPartName', component: 'Input', colProps: { span: 6 } }, + { label: '设备小部位', field: 'equipmentSubPartName', component: 'Input', colProps: { span: 6 } }, + { label: '大部位代码', field: 'partCode', component: 'Input', colProps: { span: 6 } }, + { label: '小部位代码', field: 'subPartCode', component: 'Input', colProps: { span: 6 } }, +]; diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMappingList.vue b/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMappingList.vue new file mode 100644 index 0000000..f7b37d8 --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipPartMapping/MesXslEquipPartMappingList.vue @@ -0,0 +1,45 @@ + + + diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api.ts b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api.ts index 38ab84e..5129e11 100644 --- a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api.ts +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api.ts @@ -3,6 +3,7 @@ import { defHttp } from '/@/utils/http/axios'; enum Api { list = '/xslmes/mesXslEquipmentLedger/list', checkEquipmentCode = '/xslmes/mesXslEquipmentLedger/checkEquipmentCode', + nextLedgerNo = '/xslmes/mesXslEquipmentLedger/nextLedgerNo', checkEquipmentName = '/xslmes/mesXslEquipmentLedger/checkEquipmentName', save = '/xslmes/mesXslEquipmentLedger/add', edit = '/xslmes/mesXslEquipmentLedger/edit', @@ -20,6 +21,8 @@ export const checkEquipmentCode = (params: { equipmentCode: string; dataId?: str export const checkEquipmentName = (params: { equipmentName: string; dataId?: string }) => defHttp.get({ url: Api.checkEquipmentName, params }, { successMessageMode: 'none', errorMessageMode: 'none' }); + +export const fetchNextLedgerNo = () => defHttp.get({ url: Api.nextLedgerNo }, { successMessageMode: 'none' }); export const deleteOne = (params, handleSuccess) => defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess()); export const batchDelete = (params, handleSuccess) => defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true }).then(() => handleSuccess()); export const saveOrUpdate = (params, isUpdate) => { diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts index b7df152..70318c1 100644 --- a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.data.ts @@ -4,6 +4,7 @@ import { checkEquipmentCode, checkEquipmentName } from './MesXslEquipmentLedger. const colHalf = { span: 12 }; export const columns: BasicColumn[] = [ + { title: '系统编号', align: 'center', dataIndex: 'ledgerNo', width: 100 }, { title: '设备编号', align: 'center', dataIndex: 'equipmentCode', width: 130 }, { title: '设备名称', align: 'center', dataIndex: 'equipmentName', width: 160 }, { title: '工序', align: 'center', dataIndex: 'processOperationName', width: 120 }, @@ -18,6 +19,7 @@ export const columns: BasicColumn[] = [ ]; export const searchFormSchema: FormSchema[] = [ + { label: '系统编号', field: 'ledgerNo', component: 'Input', colProps: { span: 6 } }, { label: '设备编号', field: 'equipmentCode', component: 'Input', colProps: { span: 6 } }, { label: '设备名称', field: 'equipmentName', component: 'Input', colProps: { span: 6 } }, { label: '', field: 'processOperationId', component: 'Input', show: false }, @@ -80,8 +82,8 @@ export const formSchema: FormSchema[] = [ { label: '', field: 'id', component: 'Input', show: false }, { label: '', field: 'processOperationId', component: 'Input', show: false }, { label: '', field: 'manufacturerId', component: 'Input', show: false }, - { label: '', field: 'equipmentCategoryId', component: 'Input', show: false }, - { label: '', field: 'equipmentTypeId', component: 'Input', show: false }, + { label: '', field: 'equipmentCategoryId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择设备类别' }] }, + { label: '', field: 'equipmentTypeId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择设备类型' }] }, { label: '', field: 'factoryId', component: 'Input', show: false }, { label: '所属工序', @@ -91,6 +93,13 @@ export const formSchema: FormSchema[] = [ colProps: colHalf, dynamicRules: () => [{ required: true, message: '请选择所属工序' }], }, + { + label: '系统编号', + field: 'ledgerNo', + component: 'Input', + colProps: colHalf, + componentProps: { readonly: true, placeholder: '保存时从001起自动生成' }, + }, { label: '设备编号', field: 'equipmentCode', @@ -150,6 +159,7 @@ export const formSchema: FormSchema[] = [ component: 'Input', slot: 'equipmentCategoryPicker', colProps: colHalf, + dynamicRules: () => [{ required: true, message: '请选择设备类别' }], }, { label: '设备类型', @@ -157,6 +167,7 @@ export const formSchema: FormSchema[] = [ component: 'Input', slot: 'equipmentTypePicker', colProps: colHalf, + dynamicRules: () => [{ required: true, message: '请选择设备类型' }], }, { label: '所属工厂', diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/components/MesXslEquipmentLedgerModal.vue b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/components/MesXslEquipmentLedgerModal.vue index 7aa32de..63f9dc7 100644 --- a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/components/MesXslEquipmentLedgerModal.vue +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentLedger/components/MesXslEquipmentLedgerModal.vue @@ -62,7 +62,7 @@ import { BasicModal, useModalInner, useModal } from '/@/components/Modal'; import { BasicForm, useForm } from '/@/components/Form/index'; import { formSchema } from '../MesXslEquipmentLedger.data'; - import { saveOrUpdate } from '../MesXslEquipmentLedger.api'; + import { fetchNextLedgerNo, saveOrUpdate } from '../MesXslEquipmentLedger.api'; import MesXslProcessOperationSelectModal from '/@/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue'; import MesXslManufacturerSelectModal from './MesXslManufacturerSelectModal.vue'; import MesXslEquipmentCategorySelectModal from '/@/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentCategorySelectModal.vue'; @@ -112,7 +112,14 @@ isUpdate.value = !!data?.isUpdate; isDetail.value = !data?.showFooter; if (unref(isUpdate)) await setFieldsValue({ ...data.record }); - else await setFieldsValue({ equipmentStatus: '0', enabledFlag: '1' }); + else { + try { + const nextNo = await fetchNextLedgerNo(); + await setFieldsValue({ equipmentStatus: '0', enabledFlag: '1', ledgerNo: nextNo }); + } catch { + await setFieldsValue({ equipmentStatus: '0', enabledFlag: '1', ledgerNo: '' }); + } + } setProps({ disabled: !data?.showFooter }); });