From 965bdf44dbcb7c5fd5f9e23d0ebfa9f685b61c72 Mon Sep 17 00:00:00 2001 From: jiangxh <1217934998@qq.com> Date: Thu, 14 May 2026 17:11:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=88=AB=E6=96=B0?= =?UTF-8?q?=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...xsl-equipment-category-menu-permission.sql | 98 ++++++ jeecg-boot/db/mes-xsl-equipment-category.sql | 21 ++ .../MesXslEquipmentCategoryController.java | 300 ++++++++++++++++++ .../entity/MesXslEquipmentCategory.java | 71 +++++ .../mapper/MesXslEquipmentCategoryMapper.java | 11 + .../jeecg/modules/xslmes/package-info.java | 2 +- .../IMesXslEquipmentCategoryService.java | 16 + .../MesXslEquipmentCategoryServiceImpl.java | 63 ++++ .../jeecg-system-biz/docs/代码修改日志 | 16 + .../V3.9.2_55__mes_xsl_equipment_category.sql | 98 ++++++ .../MesXslEquipmentCategory.api.ts | 58 ++++ .../MesXslEquipmentCategory.data.ts | 87 +++++ .../MesXslEquipmentCategoryList.vue | 127 ++++++++ .../MesXslEquipmentCategoryModal.vue | 76 +++++ .../MesXslProcessOperationSelectModal.vue | 99 ++++++ 15 files changed, 1142 insertions(+), 1 deletion(-) create mode 100644 jeecg-boot/db/mes-xsl-equipment-category-menu-permission.sql create mode 100644 jeecg-boot/db/mes-xsl-equipment-category.sql create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentCategoryController.java create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentCategory.java create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentCategoryMapper.java create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentCategoryService.java create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentCategoryServiceImpl.java create mode 100644 jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_55__mes_xsl_equipment_category.sql create mode 100644 jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.api.ts create mode 100644 jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.data.ts create mode 100644 jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList.vue create mode 100644 jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslEquipmentCategoryModal.vue create mode 100644 jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue diff --git a/jeecg-boot/db/mes-xsl-equipment-category-menu-permission.sql b/jeecg-boot/db/mes-xsl-equipment-category-menu-permission.sql new file mode 100644 index 0000000..6bed9d0 --- /dev/null +++ b/jeecg-boot/db/mes-xsl-equipment-category-menu-permission.sql @@ -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` + ); diff --git a/jeecg-boot/db/mes-xsl-equipment-category.sql b/jeecg-boot/db/mes-xsl-equipment-category.sql new file mode 100644 index 0000000..871a2df --- /dev/null +++ b/jeecg-boot/db/mes-xsl-equipment-category.sql @@ -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设备类别'; diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentCategoryController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentCategoryController.java new file mode 100644 index 0000000..ae17bed --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentCategoryController.java @@ -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 { + + private static final Set INSPECT_DISTINCT = Set.of("generic", "distinct"); + private static final Set MAINTAIN_DISTINCT = Set.of("maintain", "distinct"); + + @Autowired + private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService; + + @Autowired + private IMesXslProcessOperationService mesXslProcessOperationService; + + @Operation(summary = "MES设备类别-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList( + MesXslEquipmentCategory model, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap()); + Page page = new Page<>(pageNo, pageSize); + IPage 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 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 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 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 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 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 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 fileMap = multipartRequest.getFileMap(); + for (Map.Entry ent : fileMap.entrySet()) { + MultipartFile file = ent.getValue(); + ImportParams params = new ImportParams(); + params.setTitleRows(2); + params.setHeadRows(1); + params.setNeedSave(true); + try { + List list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentCategory.class, params); + if (list == null) { + list = List.of(); + } + Set 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 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 found = mesXslProcessOperationService.list(w); + if (found == null || found.isEmpty()) { + return null; + } + return found.get(0); + } + //update-end---author:jiangxh ---date:20260514 for:【MES】设备类别保存前校验与工序名称回填----------- +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentCategory.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentCategory.java new file mode 100644 index 0000000..b68f657 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentCategory.java @@ -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; +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentCategoryMapper.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentCategoryMapper.java new file mode 100644 index 0000000..faef1b3 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentCategoryMapper.java @@ -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 {} 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 8553fcc..1fda835 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.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})等。 */ package org.jeecg.modules.xslmes; diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentCategoryService.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentCategoryService.java new file mode 100644 index 0000000..cfef690 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentCategoryService.java @@ -0,0 +1,16 @@ +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 { + + /** + * 类别名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。 + * + * @param categoryName 类别名称(已 trim 后传入) + * @param excludeId 编辑时排除自身主键,新增传 null + * @param context 当前提交的实体(可取 tenantId;可为 null) + */ + boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslEquipmentCategory context); +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentCategoryServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentCategoryServiceImpl.java new file mode 100644 index 0000000..f6d7312 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentCategoryServiceImpl.java @@ -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.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 + 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 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; + } + + 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)----------- +} diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志 b/jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志 index db89aaa..7a9dbeb 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志 +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志 @@ -56,3 +56,19 @@ jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules 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 diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_55__mes_xsl_equipment_category.sql b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_55__mes_xsl_equipment_category.sql new file mode 100644 index 0000000..aa3c9d3 --- /dev/null +++ b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_55__mes_xsl_equipment_category.sql @@ -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` + ); diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.api.ts b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.api.ts new file mode 100644 index 0000000..f7270f3 --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.api.ts @@ -0,0 +1,58 @@ +import { defHttp } from '/@/utils/http/axios'; +import { useMessage } from '/@/hooks/web/useMessage'; + +const { createConfirm } = useMessage(); + +enum Api { + list = '/xslmes/mesXslEquipmentCategory/list', + checkCategoryName = '/xslmes/mesXslEquipmentCategory/checkCategoryName', + save = '/xslmes/mesXslEquipmentCategory/add', + edit = '/xslmes/mesXslEquipmentCategory/edit', + deleteOne = '/xslmes/mesXslEquipmentCategory/delete', + deleteBatch = '/xslmes/mesXslEquipmentCategory/deleteBatch', + importExcel = '/xslmes/mesXslEquipmentCategory/importExcel', + exportXls = '/xslmes/mesXslEquipmentCategory/exportXls', + queryById = '/xslmes/mesXslEquipmentCategory/queryById', +} + +export const getExportUrl = Api.exportXls; +export const getImportUrl = Api.importExcel; + +export const list = (params) => defHttp.get({ url: Api.list, params }); + +export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params }); + +export const checkCategoryName = (params: { categoryName: string; dataId?: string }) => + defHttp.get( + { url: Api.checkCategoryName, params }, + { + successMessageMode: 'none', + errorMessageMode: 'none', + }, + ); + +export const deleteOne = (params, handleSuccess) => { + return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); +}; + +export const batchDelete = (params, handleSuccess) => { + createConfirm({ + iconType: 'warning', + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); + }, + }); +}; + +export const saveOrUpdate = (params, isUpdate) => { + const url = isUpdate ? Api.edit : Api.save; + return defHttp.post({ url, params }); +}; diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.data.ts b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.data.ts new file mode 100644 index 0000000..40361f6 --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.data.ts @@ -0,0 +1,87 @@ +import { BasicColumn, FormSchema } from '/@/components/Table'; +import { checkCategoryName } from './MesXslEquipmentCategory.api'; + +export const columns: BasicColumn[] = [ + { title: '类别名称', align: 'center', dataIndex: 'categoryName', width: 160 }, + { title: '工序名称', align: 'center', dataIndex: 'processOperationName', width: 180 }, + { title: '点检区分', align: 'center', dataIndex: 'inspectDistinct_dictText', width: 100 }, + { title: '保养区分', align: 'center', dataIndex: 'maintainDistinct_dictText', width: 100 }, + { title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 }, + { + title: '创建时间', + align: 'center', + dataIndex: 'createTime', + width: 165, + customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text), + }, + { title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true }, +]; + +export const searchFormSchema: FormSchema[] = [ + { label: '类别名称', field: 'categoryName', component: 'Input', colProps: { span: 6 } }, + { label: '工序名称', field: 'processOperationName', component: 'Input', colProps: { span: 6 } }, + { + label: '点检区分', + field: 'inspectDistinct', + component: 'JDictSelectTag', + componentProps: { dictCode: 'xslmes_equipment_inspect_distinct' }, + colProps: { span: 6 }, + }, + { + label: '保养区分', + field: 'maintainDistinct', + component: 'JDictSelectTag', + componentProps: { dictCode: 'xslmes_equipment_maintain_distinct' }, + colProps: { span: 6 }, + }, +]; + +export const formSchema: FormSchema[] = [ + { label: '', field: 'id', component: 'Input', show: false }, + { + label: '类别名称', + field: 'categoryName', + component: 'Input', + componentProps: { placeholder: '同租户内未删除数据中不可重复' }, + dynamicRules: ({ model }) => [ + { required: true, message: '请输入类别名称' }, + { + validator: async (_rule, value) => { + const v = value == null ? '' : String(value).trim(); + if (!v) { + return Promise.resolve(); + } + try { + await checkCategoryName({ categoryName: v, dataId: model?.id }); + return Promise.resolve(); + } catch (e: any) { + const msg = e?.response?.data?.message || e?.message || '该类别名称已存在'; + return Promise.reject(msg); + } + }, + trigger: 'blur', + }, + ], + }, + { label: '', field: 'processOperationId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择所属工序' }] }, + { + label: '所属工序', + field: 'processOperationName', + component: 'Input', + slot: 'processOperationPicker', + }, + { + label: '点检区分', + field: 'inspectDistinct', + required: true, + component: 'JDictSelectTag', + componentProps: { dictCode: 'xslmes_equipment_inspect_distinct', placeholder: '请选择' }, + }, + { + label: '保养区分', + field: 'maintainDistinct', + required: true, + component: 'JDictSelectTag', + componentProps: { dictCode: 'xslmes_equipment_maintain_distinct', placeholder: '请选择' }, + }, +]; diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList.vue b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList.vue new file mode 100644 index 0000000..91d0b06 --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategoryList.vue @@ -0,0 +1,127 @@ + + + diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslEquipmentCategoryModal.vue b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslEquipmentCategoryModal.vue new file mode 100644 index 0000000..47a3c52 --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslEquipmentCategoryModal.vue @@ -0,0 +1,76 @@ + + + diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue new file mode 100644 index 0000000..ff2265f --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue @@ -0,0 +1,99 @@ + + +