diff --git a/.gitignore b/.gitignore index 4022f85..319a19b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,11 @@ **/.settings/ *.iml rebel.xml +.project +.classpath +.settings/ +.factorypath +**/.settings/ ## backend **/target diff --git a/jeecg-boot/.gitignore b/jeecg-boot/.gitignore index b7838ca..ddfb170 100644 --- a/jeecg-boot/.gitignore +++ b/jeecg-boot/.gitignore @@ -2,6 +2,12 @@ **/.idea *.iml rebel.xml +# VS Code/Cursor Java 扩展(Eclipse JDT)导入 Maven 时自动生成,勿提交 +.project +.classpath +.settings/ +.factorypath +**/.settings/ ## backend **/target diff --git a/jeecg-boot/db/mes-xsl-inspect-maintain-item-menu-permission.sql b/jeecg-boot/db/mes-xsl-inspect-maintain-item-menu-permission.sql new file mode 100644 index 0000000..6e88570 --- /dev/null +++ b/jeecg-boot/db/mes-xsl-inspect-maintain-item-menu-permission.sql @@ -0,0 +1,118 @@ +-- MES 点检及保养项目:字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权(可整文件一次执行) +-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_inspect_maintain_item:* +-- 父菜单:设备管理;修改租户改 SET @mes_tenant_id +-- 新环境也可依赖 Flyway:V3.9.2_77__mes_xsl_inspect_maintain_item.sql +SET NAMES utf8mb4; + +INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`) +SELECT REPLACE(UUID(), '-', ''), 'MES点检保养项目类别', 'xslmes_im_item_category', 'inspect点检/maintain保养', 0, 'admin', NOW(), 0, 0 +WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_im_item_category' AND `del_flag` = 0); + +INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`) +SELECT REPLACE(UUID(), '-', ''), d.id, '点检', 'inspect', 1, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_item_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'inspect'); +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', 2, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_item_category' 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` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`) +SELECT REPLACE(UUID(), '-', ''), 'MES点检保养项目类型', 'xslmes_im_item_type', 'mechanical机械类/electrical电气类', 0, 'admin', NOW(), 0, 0 +WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_im_item_type' 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, '机械类', 'mechanical', 1, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_item_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'mechanical'); +INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`) +SELECT REPLACE(UUID(), '-', ''), d.id, '电气类', 'electrical', 2, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_item_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'electrical'); + +INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`) +SELECT REPLACE(UUID(), '-', ''), 'MES点检方式', 'xslmes_im_inspect_method', 'visual视觉/sight目测/hearing听觉', 0, 'admin', NOW(), 0, 0 +WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_im_inspect_method' 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, '视觉', 'visual', 1, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_inspect_method' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'visual'); +INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`) +SELECT REPLACE(UUID(), '-', ''), d.id, '目测', 'sight', 2, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_inspect_method' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'sight'); +INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`) +SELECT REPLACE(UUID(), '-', ''), d.id, '听觉', 'hearing', 3, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_inspect_method' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'hearing'); + +CREATE TABLE IF NOT EXISTS `mes_xsl_inspect_maintain_item` ( + `id` varchar(32) NOT NULL COMMENT '主键', + `item_name` varchar(500) NOT NULL COMMENT '项目名称(同租户未删除数据中唯一)', + `item_code` varchar(500) NOT NULL COMMENT '项目编号(同租户未删除数据中唯一)', + `equipment_category_id` varchar(32) NOT NULL COMMENT '设备类别主键 mes_xsl_equipment_category.id', + `equipment_category_name` varchar(500) DEFAULT NULL COMMENT '设备类别名称冗余', + `equipment_type_id` varchar(32) NOT NULL COMMENT '设备类型主键 mes_xsl_equipment_type.id', + `equipment_type_name` 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 '设备部位名称冗余', + `equipment_sub_part_id` varchar(32) NOT NULL COMMENT '设备小部位主键 mes_xsl_equipment_sub_part.id', + `equipment_sub_part_name` varchar(500) DEFAULT NULL COMMENT '设备小部位名称冗余', + `item_category` varchar(500) NOT NULL COMMENT '项目类别(字典xslmes_im_item_category:inspect点检/maintain保养)', + `item_type` varchar(500) NOT NULL COMMENT '项目类型(字典xslmes_im_item_type:mechanical机械类/electrical电气类)', + `inspect_method` varchar(500) NOT NULL COMMENT '点检方式(字典xslmes_im_inspect_method:visual视觉/sight目测/hearing听觉)', + `judgment_criteria` varchar(500) NOT NULL COMMENT '判断基准', + `maintain_cycle_days` int DEFAULT NULL COMMENT '保养周期(天)', + `tenant_id` int DEFAULT NULL COMMENT '租户', + `sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门', + `create_by` varchar(500) DEFAULT NULL COMMENT '创建人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(500) DEFAULT NULL COMMENT '更新人', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)', + PRIMARY KEY (`id`), + KEY `idx_mimi_tenant_name` (`tenant_id`, `item_name`), + KEY `idx_mimi_tenant_code` (`tenant_id`, `item_code`), + KEY `idx_mimi_category` (`equipment_category_id`), + KEY `idx_mimi_type` (`equipment_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES点检及保养项目'; + +SET @mes_tenant_id = 1002; + +SET @mes_equip_pid = ( + SELECT `id` FROM `sys_permission` + WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理' + LIMIT 1 +); +SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133'); + +INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`) +VALUES ('1860000000000000141', @mes_equip_pid, '点检及保养项目', '/xslmes/mesXslInspectMaintainItem', 'xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItemList', NULL, 1, NULL, '1', 11, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW()) +ON DUPLICATE KEY UPDATE +`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`), +`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`), +`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`), +`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:audit-outlined'; + +UPDATE `sys_permission` SET `icon` = 'ant-design:audit-outlined' WHERE `id` = '1860000000000000141' 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 +('1860000000000000142', '1860000000000000141', '新增', 2, 'mes:mes_xsl_inspect_maintain_item:add', '1', '1', 0, 'admin', NOW()), +('1860000000000000143', '1860000000000000141', '编辑', 2, 'mes:mes_xsl_inspect_maintain_item:edit', '1', '1', 0, 'admin', NOW()), +('1860000000000000144', '1860000000000000141', '删除', 2, 'mes:mes_xsl_inspect_maintain_item:delete', '1', '1', 0, 'admin', NOW()), +('1860000000000000145', '1860000000000000141', '批量删除', 2, 'mes:mes_xsl_inspect_maintain_item:deleteBatch', '1', '1', 0, 'admin', NOW()), +('1860000000000000146', '1860000000000000141', '导出', 2, 'mes:mes_xsl_inspect_maintain_item:exportXls', '1', '1', 0, 'admin', NOW()), +('1860000000000000147', '1860000000000000141', '导入', 2, 'mes:mes_xsl_inspect_maintain_item:importExcel', '1', '1', 0, 'admin', NOW()) +ON DUPLICATE KEY UPDATE +`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), +`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`); + +INSERT INTO `sys_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 ( + '1860000000000000141', + '1860000000000000142', '1860000000000000143', '1860000000000000144', '1860000000000000145', + '1860000000000000146', '1860000000000000147' + ) + 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/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslInspectMaintainItemController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslInspectMaintainItemController.java new file mode 100644 index 0000000..adec380 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslInspectMaintainItemController.java @@ -0,0 +1,301 @@ +package org.jeecg.modules.xslmes.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.util.Arrays; +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.MesXslEquipmentPart; +import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart; +import org.jeecg.modules.xslmes.entity.MesXslEquipmentType; +import org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem; +import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService; +import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService; +import org.jeecg.modules.xslmes.service.IMesXslEquipmentSubPartService; +import org.jeecg.modules.xslmes.service.IMesXslEquipmentTypeService; +import org.jeecg.modules.xslmes.service.IMesXslInspectMaintainItemService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; + +/** + * MES 点检及保养项目 + */ +@Tag(name = "MES点检及保养项目") +@RestController +@RequestMapping("/xslmes/mesXslInspectMaintainItem") +@Slf4j +public class MesXslInspectMaintainItemController + extends JeecgController { + + private static final Set ITEM_CATEGORY = Set.of("inspect", "maintain"); + private static final Set ITEM_TYPE = Set.of("mechanical", "electrical"); + private static final Set INSPECT_METHOD = Set.of("visual", "sight", "hearing"); + + @Autowired + private IMesXslInspectMaintainItemService mesXslInspectMaintainItemService; + + @Autowired + private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService; + + @Autowired + private IMesXslEquipmentTypeService mesXslEquipmentTypeService; + + @Autowired + private IMesXslEquipmentPartService mesXslEquipmentPartService; + + @Autowired + private IMesXslEquipmentSubPartService mesXslEquipmentSubPartService; + + @Operation(summary = "MES点检及保养项目-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList( + MesXslInspectMaintainItem model, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap()); + queryWrapper.orderByDesc("create_time"); + Page page = new Page<>(pageNo, pageSize); + IPage pageList = mesXslInspectMaintainItemService.page(page, queryWrapper); + return Result.OK(pageList); + } + + @AutoLog(value = "MES点检及保养项目-添加") + @Operation(summary = "MES点检及保养项目-添加") + @RequiresPermissions("mes:mes_xsl_inspect_maintain_item:add") + @PostMapping(value = "/add") + public Result add(@RequestBody MesXslInspectMaintainItem model) { + //update-begin---author:jiangxh ---date:20260519 for:【MES】点检及保养项目保存前校验----------- + String err = validateForSave(model, null); + if (err != null) { + return Result.error(err); + } + //update-end---author:jiangxh ---date:20260519 for:【MES】点检及保养项目保存前校验----------- + mesXslInspectMaintainItemService.save(model); + return Result.OK("添加成功!"); + } + + @AutoLog(value = "MES点检及保养项目-编辑") + @Operation(summary = "MES点检及保养项目-编辑") + @RequiresPermissions("mes:mes_xsl_inspect_maintain_item:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) + public Result edit(@RequestBody MesXslInspectMaintainItem model) { + //update-begin---author:jiangxh ---date:20260519 for:【MES】点检及保养项目保存前校验----------- + String err = validateForSave(model, model.getId()); + if (err != null) { + return Result.error(err); + } + //update-end---author:jiangxh ---date:20260519 for:【MES】点检及保养项目保存前校验----------- + mesXslInspectMaintainItemService.updateById(model); + return Result.OK("编辑成功!"); + } + + @AutoLog(value = "MES点检及保养项目-删除") + @Operation(summary = "MES点检及保养项目-通过id删除") + @RequiresPermissions("mes:mes_xsl_inspect_maintain_item:delete") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name = "id", required = true) String id) { + mesXslInspectMaintainItemService.removeById(id); + return Result.OK("删除成功!"); + } + + @AutoLog(value = "MES点检及保养项目-批量删除") + @Operation(summary = "MES点检及保养项目-批量删除") + @RequiresPermissions("mes:mes_xsl_inspect_maintain_item:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + mesXslInspectMaintainItemService.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) { + MesXslInspectMaintainItem entity = mesXslInspectMaintainItemService.getById(id); + if (entity == null) { + return Result.error("未找到对应数据"); + } + return Result.OK(entity); + } + + @Operation(summary = "校验项目名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)") + @GetMapping(value = "/checkItemName") + public Result checkItemName( + @RequestParam(name = "itemName", required = true) String itemName, + @RequestParam(name = "dataId", required = false) String dataId) { + if (oConvertUtils.isEmpty(itemName) || itemName.trim().isEmpty()) { + return Result.OK("该值可用!"); + } + MesXslInspectMaintainItem ctx = new MesXslInspectMaintainItem(); + if (mesXslInspectMaintainItemService.isItemNameDuplicated(itemName.trim(), dataId, ctx)) { + return Result.error("项目名称不能重复"); + } + return Result.OK("该值可用!"); + } + + @Operation(summary = "校验项目编号是否重复(同租户未删除数据;dataId 为编辑时当前主键)") + @GetMapping(value = "/checkItemCode") + public Result checkItemCode( + @RequestParam(name = "itemCode", required = true) String itemCode, + @RequestParam(name = "dataId", required = false) String dataId) { + if (oConvertUtils.isEmpty(itemCode) || itemCode.trim().isEmpty()) { + return Result.OK("该值可用!"); + } + MesXslInspectMaintainItem ctx = new MesXslInspectMaintainItem(); + if (mesXslInspectMaintainItemService.isItemCodeDuplicated(itemCode.trim(), dataId, ctx)) { + return Result.error("项目编号不能重复"); + } + return Result.OK("该值可用!"); + } + + @RequiresPermissions("mes:mes_xsl_inspect_maintain_item:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, MesXslInspectMaintainItem model) { + return super.exportXls(request, model, MesXslInspectMaintainItem.class, "MES点检及保养项目"); + } + + @RequiresPermissions("mes:mes_xsl_inspect_maintain_item:importExcel") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, MesXslInspectMaintainItem.class); + } + + //update-begin---author:jiangxh ---date:20260519 for:【MES】点检及保养项目保存校验:唯一性、设备关联、字典----------- + private String validateForSave(MesXslInspectMaintainItem model, String excludeId) { + if (model == null) { + return "参数不能为空"; + } + String itemName = model.getItemName(); + if (itemName != null) { + itemName = itemName.trim(); + } + if (oConvertUtils.isEmpty(itemName)) { + return "项目名称不能为空"; + } + model.setItemName(itemName); + + String itemCode = model.getItemCode(); + if (itemCode != null) { + itemCode = itemCode.trim(); + } + if (oConvertUtils.isEmpty(itemCode)) { + return "项目编号不能为空"; + } + model.setItemCode(itemCode); + + if (mesXslInspectMaintainItemService.isItemNameDuplicated(itemName, excludeId, model)) { + return "项目名称不能重复"; + } + if (mesXslInspectMaintainItemService.isItemCodeDuplicated(itemCode, excludeId, model)) { + return "项目编号不能重复"; + } + + if (oConvertUtils.isEmpty(model.getEquipmentCategoryId())) { + return "请选择设备类别"; + } + if (oConvertUtils.isEmpty(model.getEquipmentTypeId())) { + return "请选择设备类型"; + } + if (oConvertUtils.isEmpty(model.getEquipmentPartId())) { + return "请选择设备部位"; + } + if (oConvertUtils.isEmpty(model.getEquipmentSubPartId())) { + return "请选择设备小部位"; + } + + MesXslEquipmentCategory cat = mesXslEquipmentCategoryService.getById(model.getEquipmentCategoryId()); + if (cat == null || isDeleted(cat.getDelFlag())) { + return "设备类别不存在或已删除"; + } + model.setEquipmentCategoryName(cat.getCategoryName()); + + MesXslEquipmentType type = mesXslEquipmentTypeService.getById(model.getEquipmentTypeId()); + if (type == null || isDeleted(type.getDelFlag())) { + return "设备类型不存在或已删除"; + } + if (!model.getEquipmentCategoryId().equals(type.getEquipmentCategoryId())) { + return "设备类型与所选设备类别不匹配"; + } + model.setEquipmentTypeName(type.getTypeName()); + + MesXslEquipmentPart part = mesXslEquipmentPartService.getById(model.getEquipmentPartId()); + if (part == null || isDeleted(part.getDelFlag())) { + return "设备部位不存在或已删除"; + } + if (!model.getEquipmentCategoryId().equals(part.getEquipmentCategoryId())) { + return "设备部位与所选设备类别不匹配"; + } + model.setEquipmentPartName(part.getPartName()); + + MesXslEquipmentSubPart sub = mesXslEquipmentSubPartService.getById(model.getEquipmentSubPartId()); + if (sub == null || isDeleted(sub.getDelFlag())) { + return "设备小部位不存在或已删除"; + } + if (!model.getEquipmentCategoryId().equals(sub.getEquipmentCategoryId())) { + return "设备小部位与所选设备类别不匹配"; + } + if (!model.getEquipmentPartId().equals(sub.getEquipmentPartId())) { + return "设备小部位与所选设备部位不匹配"; + } + model.setEquipmentSubPartName(sub.getSubPartName()); + + String itemCategory = model.getItemCategory(); + if (itemCategory != null) { + itemCategory = itemCategory.trim(); + } + if (oConvertUtils.isEmpty(itemCategory) || !ITEM_CATEGORY.contains(itemCategory)) { + return "项目类别无效,请选择点检或保养"; + } + model.setItemCategory(itemCategory); + + String itemType = model.getItemType(); + if (itemType != null) { + itemType = itemType.trim(); + } + if (oConvertUtils.isEmpty(itemType) || !ITEM_TYPE.contains(itemType)) { + return "项目类型无效,请选择机械类或电气类"; + } + model.setItemType(itemType); + + String inspectMethod = model.getInspectMethod(); + if (inspectMethod != null) { + inspectMethod = inspectMethod.trim(); + } + if (oConvertUtils.isEmpty(inspectMethod) || !INSPECT_METHOD.contains(inspectMethod)) { + return "点检方式无效,请选择视觉、目测或听觉"; + } + model.setInspectMethod(inspectMethod); + + if (model.getJudgmentCriteria() != null) { + model.setJudgmentCriteria(model.getJudgmentCriteria().trim()); + } + if (oConvertUtils.isEmpty(model.getJudgmentCriteria())) { + return "判断基准不能为空"; + } + + if (model.getMaintainCycleDays() != null && model.getMaintainCycleDays() < 0) { + return "保养周期(天)不能为负数"; + } + + return null; + } + + private static boolean isDeleted(Integer delFlag) { + return delFlag != null && delFlag.equals(CommonConstant.DEL_FLAG_1); + } + //update-end---author:jiangxh ---date:20260519 for:【MES】点检及保养项目保存校验:唯一性、设备关联、字典----------- +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslInspectMaintainItem.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslInspectMaintainItem.java new file mode 100644 index 0000000..b105097 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslInspectMaintainItem.java @@ -0,0 +1,102 @@ +package org.jeecg.modules.xslmes.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.jeecg.common.aspect.annotation.Dict; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * MES 点检及保养项目(表 mes_xsl_inspect_maintain_item) + */ +@Data +@TableName("mes_xsl_inspect_maintain_item") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@Schema(description = "MES点检及保养项目") +public class MesXslInspectMaintainItem implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + @Excel(name = "项目名称", width = 22) + @Schema(description = "项目名称(同租户未删除数据中唯一)") + private String itemName; + + @Excel(name = "项目编号", width = 18) + @Schema(description = "项目编号(同租户未删除数据中唯一)") + private String itemCode; + + @Schema(description = "设备类别主键 mes_xsl_equipment_category.id") + private String equipmentCategoryId; + + @Excel(name = "设备类别", width = 20) + @Schema(description = "设备类别名称冗余") + private String equipmentCategoryName; + + @Schema(description = "设备类型主键 mes_xsl_equipment_type.id") + private String equipmentTypeId; + + @Excel(name = "设备类型", width = 20) + @Schema(description = "设备类型名称冗余") + private String equipmentTypeName; + + @Schema(description = "设备部位主键 mes_xsl_equipment_part.id") + private String equipmentPartId; + + @Excel(name = "设备部位", width = 20) + @Schema(description = "设备部位名称冗余") + private String equipmentPartName; + + @Schema(description = "设备小部位主键 mes_xsl_equipment_sub_part.id") + private String equipmentSubPartId; + + @Excel(name = "设备小部位", width = 20) + @Schema(description = "设备小部位名称冗余") + private String equipmentSubPartName; + + @Excel(name = "项目类别", width = 12, dicCode = "xslmes_im_item_category") + @Dict(dicCode = "xslmes_im_item_category") + @Schema(description = "项目类别(字典xslmes_im_item_category:inspect点检/maintain保养)") + private String itemCategory; + + @Excel(name = "项目类型", width = 12, dicCode = "xslmes_im_item_type") + @Dict(dicCode = "xslmes_im_item_type") + @Schema(description = "项目类型(字典xslmes_im_item_type:mechanical机械类/electrical电气类)") + private String itemType; + + @Excel(name = "点检方式", width = 12, dicCode = "xslmes_im_inspect_method") + @Dict(dicCode = "xslmes_im_inspect_method") + @Schema(description = "点检方式(字典xslmes_im_inspect_method:visual视觉/sight目测/hearing听觉)") + private String inspectMethod; + + @Excel(name = "判断基准", width = 28) + @Schema(description = "判断基准") + private String judgmentCriteria; + + @Excel(name = "保养周期(天)", width = 14) + @Schema(description = "保养周期(天)") + private Integer maintainCycleDays; + + 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/MesXslInspectMaintainItemMapper.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslInspectMaintainItemMapper.java new file mode 100644 index 0000000..91911f6 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslInspectMaintainItemMapper.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.xslmes.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem; + +/** + * MES 点检及保养项目 + */ +public interface MesXslInspectMaintainItemMapper 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 49c8480..aac6a87 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.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.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/IMesXslInspectMaintainItemService.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslInspectMaintainItemService.java new file mode 100644 index 0000000..e43e71e --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslInspectMaintainItemService.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.xslmes.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem; + +/** + * MES 点检及保养项目 + */ +public interface IMesXslInspectMaintainItemService extends IService { + + boolean isItemNameDuplicated(String itemName, String excludeId, MesXslInspectMaintainItem context); + + boolean isItemCodeDuplicated(String itemCode, String excludeId, MesXslInspectMaintainItem context); +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslInspectMaintainItemServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslInspectMaintainItemServiceImpl.java new file mode 100644 index 0000000..7e5c80c --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslInspectMaintainItemServiceImpl.java @@ -0,0 +1,78 @@ +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.MesXslInspectMaintainItem; +import org.jeecg.modules.xslmes.mapper.MesXslInspectMaintainItemMapper; +import org.jeecg.modules.xslmes.service.IMesXslInspectMaintainItemService; +import org.springframework.stereotype.Service; + +@Service +public class MesXslInspectMaintainItemServiceImpl + extends ServiceImpl + implements IMesXslInspectMaintainItemService { + + //update-begin---author:jiangxh ---date:20260519 for:【MES】点检及保养项目:项目名称/编号同租户不可重复----------- + @Override + public boolean isItemNameDuplicated(String itemName, String excludeId, MesXslInspectMaintainItem context) { + return isFieldDuplicated(MesXslInspectMaintainItem::getItemName, itemName, excludeId, context); + } + + @Override + public boolean isItemCodeDuplicated(String itemCode, String excludeId, MesXslInspectMaintainItem context) { + return isFieldDuplicated(MesXslInspectMaintainItem::getItemCode, itemCode, excludeId, context); + } + + private boolean isFieldDuplicated( + com.baomidou.mybatisplus.core.toolkit.support.SFunction column, + String value, + String excludeId, + MesXslInspectMaintainItem context) { + if (oConvertUtils.isEmpty(value)) { + return false; + } + Integer tenantId = resolveTenantId(context); + LambdaQueryWrapper w = new LambdaQueryWrapper<>(); + w.eq(column, value.trim()); + w.and( + q -> + q.eq(MesXslInspectMaintainItem::getDelFlag, CommonConstant.DEL_FLAG_0) + .or() + .isNull(MesXslInspectMaintainItem::getDelFlag)); + if (oConvertUtils.isNotEmpty(excludeId)) { + w.ne(MesXslInspectMaintainItem::getId, excludeId); + } + if (tenantId != null) { + w.eq(MesXslInspectMaintainItem::getTenantId, tenantId); + } + return this.count(w) > 0; + } + + private static Integer resolveTenantId(MesXslInspectMaintainItem 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) { + // ignore + } + } + if (oConvertUtils.isEmpty(ts)) { + return null; + } + try { + return Integer.parseInt(ts); + } catch (NumberFormatException e) { + return null; + } + } + //update-end---author:jiangxh ---date:20260519 for:【MES】点检及保养项目:项目名称/编号同租户不可重复----------- +} diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志 b/jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志 index be00707..4fe8ec4 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志 +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志 @@ -256,6 +256,21 @@ jeecg-boot/db/mes-xsl-spare-part-menu-permission.sql jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql jeecg-boot/db/mes-xsl-downtime-main-type-menu-permission.sql jeecg-boot/db/mes-xsl-downtime-type-menu-permission.sql +-- author:jiangxh---date:20260519--for: 【MES】点检及保养项目(建表、字典、菜单、CRUD、设备关联选择)--- +jeecg-boot/db/mes-xsl-inspect-maintain-item-menu-permission.sql +jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_77__mes_xsl_inspect_maintain_item.sql +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslInspectMaintainItem.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslInspectMaintainItemMapper.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslInspectMaintainItemService.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslInspectMaintainItemServiceImpl.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslInspectMaintainItemController.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItemList.vue +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.data.ts +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.api.ts +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslInspectMaintainItemModal.vue +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentTypeFilterSelectModal.vue +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentSubPartFilterSelectModal.vue jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_70__mes_xsl_equipment_type_menu_ensure.sql -- author:jiangxh---date:20260518--for: 【MES】工序管理/设备类别菜单与按钮权限补全及租户授权 --- jeecg-boot/db/mes-xsl-process-and-category-menu-fix.sql @@ -309,3 +324,18 @@ jeecg-boot/db/mes-xsl-spare-part-menu-permission.sql jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql jeecg-boot/db/mes-xsl-downtime-main-type-menu-permission.sql jeecg-boot/db/mes-xsl-downtime-type-menu-permission.sql +-- author:jiangxh---date:20260519--for: 【MES】点检及保养项目(建表、字典、菜单、CRUD、设备关联选择)--- +jeecg-boot/db/mes-xsl-inspect-maintain-item-menu-permission.sql +jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_77__mes_xsl_inspect_maintain_item.sql +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslInspectMaintainItem.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslInspectMaintainItemMapper.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslInspectMaintainItemService.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslInspectMaintainItemServiceImpl.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslInspectMaintainItemController.java +jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItemList.vue +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.data.ts +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.api.ts +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslInspectMaintainItemModal.vue +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentTypeFilterSelectModal.vue +jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentSubPartFilterSelectModal.vue diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_77__mes_xsl_inspect_maintain_item.sql b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_77__mes_xsl_inspect_maintain_item.sql new file mode 100644 index 0000000..225a658 --- /dev/null +++ b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_77__mes_xsl_inspect_maintain_item.sql @@ -0,0 +1,116 @@ +-- MES 点检及保养项目:字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权(与 jeecg-boot/db/mes-xsl-inspect-maintain-item-menu-permission.sql 一致) +-- 权限前缀:mes:mes_xsl_inspect_maintain_item:*;父菜单:设备管理 +SET NAMES utf8mb4; + +INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`) +SELECT REPLACE(UUID(), '-', ''), 'MES点检保养项目类别', 'xslmes_im_item_category', 'inspect点检/maintain保养', 0, 'admin', NOW(), 0, 0 +WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_im_item_category' AND `del_flag` = 0); + +INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`) +SELECT REPLACE(UUID(), '-', ''), d.id, '点检', 'inspect', 1, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_item_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'inspect'); +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', 2, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_item_category' 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` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`) +SELECT REPLACE(UUID(), '-', ''), 'MES点检保养项目类型', 'xslmes_im_item_type', 'mechanical机械类/electrical电气类', 0, 'admin', NOW(), 0, 0 +WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_im_item_type' 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, '机械类', 'mechanical', 1, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_item_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'mechanical'); +INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`) +SELECT REPLACE(UUID(), '-', ''), d.id, '电气类', 'electrical', 2, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_item_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'electrical'); + +INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`) +SELECT REPLACE(UUID(), '-', ''), 'MES点检方式', 'xslmes_im_inspect_method', 'visual视觉/sight目测/hearing听觉', 0, 'admin', NOW(), 0, 0 +WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_im_inspect_method' 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, '视觉', 'visual', 1, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_inspect_method' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'visual'); +INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`) +SELECT REPLACE(UUID(), '-', ''), d.id, '目测', 'sight', 2, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_inspect_method' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'sight'); +INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`) +SELECT REPLACE(UUID(), '-', ''), d.id, '听觉', 'hearing', 3, 1, 'admin', NOW() FROM `sys_dict` d +WHERE d.`dict_code` = 'xslmes_im_inspect_method' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'hearing'); + +CREATE TABLE IF NOT EXISTS `mes_xsl_inspect_maintain_item` ( + `id` varchar(32) NOT NULL COMMENT '主键', + `item_name` varchar(500) NOT NULL COMMENT '项目名称(同租户未删除数据中唯一)', + `item_code` varchar(500) NOT NULL COMMENT '项目编号(同租户未删除数据中唯一)', + `equipment_category_id` varchar(32) NOT NULL COMMENT '设备类别主键 mes_xsl_equipment_category.id', + `equipment_category_name` varchar(500) DEFAULT NULL COMMENT '设备类别名称冗余', + `equipment_type_id` varchar(32) NOT NULL COMMENT '设备类型主键 mes_xsl_equipment_type.id', + `equipment_type_name` 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 '设备部位名称冗余', + `equipment_sub_part_id` varchar(32) NOT NULL COMMENT '设备小部位主键 mes_xsl_equipment_sub_part.id', + `equipment_sub_part_name` varchar(500) DEFAULT NULL COMMENT '设备小部位名称冗余', + `item_category` varchar(500) NOT NULL COMMENT '项目类别(字典xslmes_im_item_category:inspect点检/maintain保养)', + `item_type` varchar(500) NOT NULL COMMENT '项目类型(字典xslmes_im_item_type:mechanical机械类/electrical电气类)', + `inspect_method` varchar(500) NOT NULL COMMENT '点检方式(字典xslmes_im_inspect_method:visual视觉/sight目测/hearing听觉)', + `judgment_criteria` varchar(500) NOT NULL COMMENT '判断基准', + `maintain_cycle_days` int DEFAULT NULL COMMENT '保养周期(天)', + `tenant_id` int DEFAULT NULL COMMENT '租户', + `sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门', + `create_by` varchar(500) DEFAULT NULL COMMENT '创建人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(500) DEFAULT NULL COMMENT '更新人', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)', + PRIMARY KEY (`id`), + KEY `idx_mimi_tenant_name` (`tenant_id`, `item_name`), + KEY `idx_mimi_tenant_code` (`tenant_id`, `item_code`), + KEY `idx_mimi_category` (`equipment_category_id`), + KEY `idx_mimi_type` (`equipment_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES点检及保养项目'; + +SET @mes_tenant_id = 1002; + +SET @mes_equip_pid = ( + SELECT `id` FROM `sys_permission` + WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理' + LIMIT 1 +); +SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133'); + +INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`) +VALUES ('1860000000000000141', @mes_equip_pid, '点检及保养项目', '/xslmes/mesXslInspectMaintainItem', 'xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItemList', NULL, 1, NULL, '1', 11, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW()) +ON DUPLICATE KEY UPDATE +`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`), +`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`), +`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`), +`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:audit-outlined'; + +UPDATE `sys_permission` SET `icon` = 'ant-design:audit-outlined' WHERE `id` = '1860000000000000141' 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 +('1860000000000000142', '1860000000000000141', '新增', 2, 'mes:mes_xsl_inspect_maintain_item:add', '1', '1', 0, 'admin', NOW()), +('1860000000000000143', '1860000000000000141', '编辑', 2, 'mes:mes_xsl_inspect_maintain_item:edit', '1', '1', 0, 'admin', NOW()), +('1860000000000000144', '1860000000000000141', '删除', 2, 'mes:mes_xsl_inspect_maintain_item:delete', '1', '1', 0, 'admin', NOW()), +('1860000000000000145', '1860000000000000141', '批量删除', 2, 'mes:mes_xsl_inspect_maintain_item:deleteBatch', '1', '1', 0, 'admin', NOW()), +('1860000000000000146', '1860000000000000141', '导出', 2, 'mes:mes_xsl_inspect_maintain_item:exportXls', '1', '1', 0, 'admin', NOW()), +('1860000000000000147', '1860000000000000141', '导入', 2, 'mes:mes_xsl_inspect_maintain_item:importExcel', '1', '1', 0, 'admin', NOW()) +ON DUPLICATE KEY UPDATE +`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), +`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`); + +INSERT INTO `sys_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 ( + '1860000000000000141', + '1860000000000000142', '1860000000000000143', '1860000000000000144', '1860000000000000145', + '1860000000000000146', '1860000000000000147' + ) + 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/mesXslInspectMaintainItem/MesXslInspectMaintainItem.api.ts b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.api.ts new file mode 100644 index 0000000..3cd8806 --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.api.ts @@ -0,0 +1,68 @@ +import { defHttp } from '/@/utils/http/axios'; +import { useMessage } from '/@/hooks/web/useMessage'; + +const { createConfirm } = useMessage(); + +enum Api { + list = '/xslmes/mesXslInspectMaintainItem/list', + checkItemName = '/xslmes/mesXslInspectMaintainItem/checkItemName', + checkItemCode = '/xslmes/mesXslInspectMaintainItem/checkItemCode', + save = '/xslmes/mesXslInspectMaintainItem/add', + edit = '/xslmes/mesXslInspectMaintainItem/edit', + deleteOne = '/xslmes/mesXslInspectMaintainItem/delete', + deleteBatch = '/xslmes/mesXslInspectMaintainItem/deleteBatch', + importExcel = '/xslmes/mesXslInspectMaintainItem/importExcel', + exportXls = '/xslmes/mesXslInspectMaintainItem/exportXls', + queryById = '/xslmes/mesXslInspectMaintainItem/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 checkItemName = (params: { itemName: string; dataId?: string }) => + defHttp.get( + { url: Api.checkItemName, params }, + { + successMessageMode: 'none', + errorMessageMode: 'none', + }, + ); + +export const checkItemCode = (params: { itemCode: string; dataId?: string }) => + defHttp.get( + { url: Api.checkItemCode, 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/mesXslInspectMaintainItem/MesXslInspectMaintainItem.data.ts b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.data.ts new file mode 100644 index 0000000..a7f2482 --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.data.ts @@ -0,0 +1,153 @@ +import { BasicColumn, FormSchema } from '/@/components/Table'; +import { checkItemCode, checkItemName } from './MesXslInspectMaintainItem.api'; + +export const columns: BasicColumn[] = [ + { title: '项目名称', align: 'center', dataIndex: 'itemName', width: 140 }, + { title: '项目编号', align: 'center', dataIndex: 'itemCode', width: 120 }, + { title: '设备类别', align: 'center', dataIndex: 'equipmentCategoryName', width: 120 }, + { title: '设备类型', align: 'center', dataIndex: 'equipmentTypeName', width: 120 }, + { title: '设备部位', align: 'center', dataIndex: 'equipmentPartName', width: 120 }, + { title: '设备小部位', align: 'center', dataIndex: 'equipmentSubPartName', width: 120 }, + { title: '项目类别', align: 'center', dataIndex: 'itemCategory_dictText', width: 90 }, + { title: '项目类型', align: 'center', dataIndex: 'itemType_dictText', width: 90 }, + { title: '点检方式', align: 'center', dataIndex: 'inspectMethod_dictText', width: 90 }, + { title: '判断基准', align: 'center', dataIndex: 'judgmentCriteria', width: 160, ellipsis: true }, + { title: '保养周期(天)', align: 'center', dataIndex: 'maintainCycleDays', width: 110 }, + { 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), + }, +]; + +export const searchFormSchema: FormSchema[] = [ + { label: '项目名称', field: 'itemName', component: 'Input', colProps: { span: 6 } }, + { label: '项目编号', field: 'itemCode', component: 'Input', colProps: { span: 6 } }, + { label: '设备类别', field: 'equipmentCategoryName', component: 'Input', colProps: { span: 6 } }, + { + label: '项目类别', + field: 'itemCategory', + component: 'JDictSelectTag', + componentProps: { dictCode: 'xslmes_im_item_category' }, + colProps: { span: 6 }, + }, +]; + +export const formSchema: FormSchema[] = [ + { label: '', field: 'id', component: 'Input', show: false }, + { + label: '项目名称', + field: 'itemName', + 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 checkItemName({ itemName: 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: 'itemCode', + 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 checkItemCode({ itemCode: 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: 'equipmentCategoryId', component: 'Input', show: false }, + { + label: '设备类别', + field: 'equipmentCategoryName', + component: 'Input', + slot: 'equipmentCategoryPicker', + }, + { label: '', field: 'equipmentTypeId', component: 'Input', show: false }, + { + label: '设备类型', + field: 'equipmentTypeName', + component: 'Input', + slot: 'equipmentTypePicker', + }, + { label: '', field: 'equipmentPartId', component: 'Input', show: false }, + { + label: '设备部位', + field: 'equipmentPartName', + component: 'Input', + slot: 'equipmentPartPicker', + }, + { label: '', field: 'equipmentSubPartId', component: 'Input', show: false }, + { + label: '设备小部位', + field: 'equipmentSubPartName', + component: 'Input', + slot: 'equipmentSubPartPicker', + }, + { + label: '项目类别', + field: 'itemCategory', + component: 'JDictSelectTag', + required: true, + componentProps: { dictCode: 'xslmes_im_item_category', placeholder: '点检/保养' }, + }, + { + label: '项目类型', + field: 'itemType', + component: 'JDictSelectTag', + required: true, + componentProps: { dictCode: 'xslmes_im_item_type', placeholder: '机械类/电气类' }, + }, + { + label: '点检方式', + field: 'inspectMethod', + component: 'JDictSelectTag', + required: true, + componentProps: { dictCode: 'xslmes_im_inspect_method', placeholder: '视觉/目测/听觉' }, + }, + { + label: '判断基准', + field: 'judgmentCriteria', + component: 'InputTextArea', + required: true, + componentProps: { rows: 3, maxlength: 500, showCount: true }, + }, + { + label: '保养周期(天)', + field: 'maintainCycleDays', + component: 'InputNumber', + componentProps: { min: 0, precision: 0, style: { width: '100%' } }, + }, +]; diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItemList.vue b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItemList.vue new file mode 100644 index 0000000..07d662c --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItemList.vue @@ -0,0 +1,132 @@ + + + diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentSubPartFilterSelectModal.vue b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentSubPartFilterSelectModal.vue new file mode 100644 index 0000000..1f4a17f --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentSubPartFilterSelectModal.vue @@ -0,0 +1,116 @@ + + + diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentTypeFilterSelectModal.vue b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentTypeFilterSelectModal.vue new file mode 100644 index 0000000..de348c2 --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentTypeFilterSelectModal.vue @@ -0,0 +1,110 @@ + + + diff --git a/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslInspectMaintainItemModal.vue b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslInspectMaintainItemModal.vue new file mode 100644 index 0000000..9551a0f --- /dev/null +++ b/jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslInspectMaintainItemModal.vue @@ -0,0 +1,218 @@ + + +