Commit 90ca6e4ae33e7214d1f6655b24ad66cb41115a18
1 parent
215f5881
feat(mes-cal): 新增班次管理和排班计划前端页面
新增班次管理(cal/shift)和排班计划(cal/plan)的前端实现, 包含 API 定义、列表页、表单弹窗、班组面板和班次面板, 以及 dict.ts 中 CAL 相关字典类型补充
Showing
21 changed files
with
1354 additions
and
0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||
| 9 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 10 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 11 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryPageReqVO; | ||
| 12 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryRespVO; | ||
| 13 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachinerySaveReqVO; | ||
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; | ||
| 15 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryTypeDO; | ||
| 16 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkshopDO; | ||
| 17 | +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; | ||
| 18 | +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryTypeService; | ||
| 19 | +import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkshopService; | ||
| 20 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 21 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 22 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 23 | +import jakarta.annotation.Resource; | ||
| 24 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 25 | +import jakarta.validation.Valid; | ||
| 26 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 27 | +import org.springframework.validation.annotation.Validated; | ||
| 28 | +import org.springframework.web.bind.annotation.*; | ||
| 29 | + | ||
| 30 | +import java.io.IOException; | ||
| 31 | +import java.util.Collections; | ||
| 32 | +import java.util.List; | ||
| 33 | +import java.util.Map; | ||
| 34 | + | ||
| 35 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | ||
| 36 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 37 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 38 | + | ||
| 39 | +@Tag(name = "管理后台 - MES 设备台账") | ||
| 40 | +@RestController | ||
| 41 | +@RequestMapping("/mes/dv/machinery") | ||
| 42 | +@Validated | ||
| 43 | +public class MesDvMachineryController { | ||
| 44 | + | ||
| 45 | + @Resource | ||
| 46 | + private MesDvMachineryService machineryService; | ||
| 47 | + | ||
| 48 | + @Resource | ||
| 49 | + private MesDvMachineryTypeService machineryTypeService; | ||
| 50 | + | ||
| 51 | + @Resource | ||
| 52 | + private MesMdWorkshopService workshopService; | ||
| 53 | + | ||
| 54 | + @PostMapping("/create") | ||
| 55 | + @Operation(summary = "创建设备") | ||
| 56 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery:create')") | ||
| 57 | + public CommonResult<Long> createMachinery(@Valid @RequestBody MesDvMachinerySaveReqVO createReqVO) { | ||
| 58 | + return success(machineryService.createMachinery(createReqVO)); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @PutMapping("/update") | ||
| 62 | + @Operation(summary = "更新设备") | ||
| 63 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery:update')") | ||
| 64 | + public CommonResult<Boolean> updateMachinery(@Valid @RequestBody MesDvMachinerySaveReqVO updateReqVO) { | ||
| 65 | + machineryService.updateMachinery(updateReqVO); | ||
| 66 | + return success(true); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @DeleteMapping("/delete") | ||
| 70 | + @Operation(summary = "删除设备") | ||
| 71 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 72 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery:delete')") | ||
| 73 | + public CommonResult<Boolean> deleteMachinery(@RequestParam("id") Long id) { | ||
| 74 | + machineryService.deleteMachinery(id); | ||
| 75 | + return success(true); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @GetMapping("/get") | ||
| 79 | + @Operation(summary = "获得设备") | ||
| 80 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 81 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery:query')") | ||
| 82 | + public CommonResult<MesDvMachineryRespVO> getMachinery(@RequestParam("id") Long id) { | ||
| 83 | + MesDvMachineryDO machinery = machineryService.getMachinery(id); | ||
| 84 | + MesDvMachineryRespVO respVO = BeanUtils.toBean(machinery, MesDvMachineryRespVO.class); | ||
| 85 | + // 拼接设备类型名称和车间名称 | ||
| 86 | + // TODO @AI:复用下 buildMachineryRespVOList 方法; | ||
| 87 | + if (respVO != null) { | ||
| 88 | + if (respVO.getMachineryTypeId() != null) { | ||
| 89 | + MesDvMachineryTypeDO machineryType = machineryTypeService.getMachineryType(respVO.getMachineryTypeId()); | ||
| 90 | + if (machineryType != null) { | ||
| 91 | + respVO.setMachineryTypeName(machineryType.getName()); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + if (respVO.getWorkshopId() != null) { | ||
| 95 | + MesMdWorkshopDO workshop = workshopService.getWorkshop(respVO.getWorkshopId()); | ||
| 96 | + if (workshop != null) { | ||
| 97 | + respVO.setWorkshopName(workshop.getName()); | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + return success(respVO); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @GetMapping("/page") | ||
| 105 | + @Operation(summary = "获得设备分页") | ||
| 106 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery:query')") | ||
| 107 | + public CommonResult<PageResult<MesDvMachineryRespVO>> getMachineryPage(@Valid MesDvMachineryPageReqVO pageReqVO) { | ||
| 108 | + PageResult<MesDvMachineryDO> pageResult = machineryService.getMachineryPage(pageReqVO); | ||
| 109 | + return success(new PageResult<>(buildMachineryRespVOList(pageResult.getList()), pageResult.getTotal())); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + @GetMapping("/export-excel") | ||
| 113 | + @Operation(summary = "导出设备 Excel") | ||
| 114 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery:export')") | ||
| 115 | + @ApiAccessLog(operateType = EXPORT) | ||
| 116 | + public void exportMachineryExcel(@Valid MesDvMachineryPageReqVO pageReqVO, | ||
| 117 | + HttpServletResponse response) throws IOException { | ||
| 118 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 119 | + List<MesDvMachineryDO> list = machineryService.getMachineryPage(pageReqVO).getList(); | ||
| 120 | + // 导出 Excel | ||
| 121 | + ExcelUtils.write(response, "设备台账.xls", "数据", MesDvMachineryRespVO.class, | ||
| 122 | + buildMachineryRespVOList(list)); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + // ==================== 拼接 VO ==================== | ||
| 126 | + | ||
| 127 | + private List<MesDvMachineryRespVO> buildMachineryRespVOList(List<MesDvMachineryDO> list) { | ||
| 128 | + if (CollUtil.isEmpty(list)) { | ||
| 129 | + return Collections.emptyList(); | ||
| 130 | + } | ||
| 131 | + // 1. 批量获取设备类型和车间信息 | ||
| 132 | + Map<Long, MesDvMachineryTypeDO> machineryTypeMap = machineryTypeService.getMachineryTypeMap( | ||
| 133 | + convertSet(list, MesDvMachineryDO::getMachineryTypeId)); | ||
| 134 | + Map<Long, MesMdWorkshopDO> workshopMap = workshopService.getWorkshopMap( | ||
| 135 | + convertSet(list, MesDvMachineryDO::getWorkshopId)); | ||
| 136 | + // 2. 拼接 VO | ||
| 137 | + return BeanUtils.toBean(list, MesDvMachineryRespVO.class, vo -> { | ||
| 138 | + MapUtils.findAndThen(machineryTypeMap, vo.getMachineryTypeId(), | ||
| 139 | + machineryType -> vo.setMachineryTypeName(machineryType.getName())); | ||
| 140 | + MapUtils.findAndThen(workshopMap, vo.getWorkshopId(), | ||
| 141 | + workshop -> vo.setWorkshopName(workshop.getName())); | ||
| 142 | + }); | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryTypeController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeListReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeSaveReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryTypeDO; | ||
| 10 | +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryTypeService; | ||
| 11 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 12 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 13 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 14 | +import jakarta.annotation.Resource; | ||
| 15 | +import jakarta.validation.Valid; | ||
| 16 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 17 | +import org.springframework.validation.annotation.Validated; | ||
| 18 | +import org.springframework.web.bind.annotation.*; | ||
| 19 | + | ||
| 20 | +import java.util.List; | ||
| 21 | + | ||
| 22 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 23 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 24 | + | ||
| 25 | +@Tag(name = "管理后台 - MES 设备类型") | ||
| 26 | +@RestController | ||
| 27 | +@RequestMapping("/mes/dv/machinery-type") | ||
| 28 | +@Validated | ||
| 29 | +public class MesDvMachineryTypeController { | ||
| 30 | + | ||
| 31 | + @Resource | ||
| 32 | + private MesDvMachineryTypeService machineryTypeService; | ||
| 33 | + | ||
| 34 | + @PostMapping("/create") | ||
| 35 | + @Operation(summary = "创建设备类型") | ||
| 36 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery-type:create')") | ||
| 37 | + public CommonResult<Long> createMachineryType(@Valid @RequestBody MesDvMachineryTypeSaveReqVO createReqVO) { | ||
| 38 | + return success(machineryTypeService.createMachineryType(createReqVO)); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @PutMapping("/update") | ||
| 42 | + @Operation(summary = "更新设备类型") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery-type:update')") | ||
| 44 | + public CommonResult<Boolean> updateMachineryType(@Valid @RequestBody MesDvMachineryTypeSaveReqVO updateReqVO) { | ||
| 45 | + machineryTypeService.updateMachineryType(updateReqVO); | ||
| 46 | + return success(true); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @DeleteMapping("/delete") | ||
| 50 | + @Operation(summary = "删除设备类型") | ||
| 51 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 52 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery-type:delete')") | ||
| 53 | + public CommonResult<Boolean> deleteMachineryType(@RequestParam("id") Long id) { | ||
| 54 | + machineryTypeService.deleteMachineryType(id); | ||
| 55 | + return success(true); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @GetMapping("/get") | ||
| 59 | + @Operation(summary = "获得设备类型") | ||
| 60 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 61 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery-type:query')") | ||
| 62 | + public CommonResult<MesDvMachineryTypeRespVO> getMachineryType(@RequestParam("id") Long id) { | ||
| 63 | + MesDvMachineryTypeDO machineryType = machineryTypeService.getMachineryType(id); | ||
| 64 | + return success(BeanUtils.toBean(machineryType, MesDvMachineryTypeRespVO.class)); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @GetMapping("/list") | ||
| 68 | + @Operation(summary = "获得设备类型列表") | ||
| 69 | + @PreAuthorize("@ss.hasPermission('mes:dv-machinery-type:query')") | ||
| 70 | + public CommonResult<List<MesDvMachineryTypeRespVO>> getMachineryTypeList(@Valid MesDvMachineryTypeListReqVO listReqVO) { | ||
| 71 | + List<MesDvMachineryTypeDO> list = machineryTypeService.getMachineryTypeList(listReqVO); | ||
| 72 | + return success(BeanUtils.toBean(list, MesDvMachineryTypeRespVO.class)); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @GetMapping("/simple-list") | ||
| 76 | + @Operation(summary = "获得设备类型精简列表", description = "只包含被开启的类型,主要用于前端的下拉选项") | ||
| 77 | + public CommonResult<List<MesDvMachineryTypeRespVO>> getMachineryTypeSimpleList() { | ||
| 78 | + List<MesDvMachineryTypeDO> list = machineryTypeService.getMachineryTypeList( | ||
| 79 | + new MesDvMachineryTypeListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus())); | ||
| 80 | + return success(convertList(list, machineryType -> new MesDvMachineryTypeRespVO() | ||
| 81 | + .setId(machineryType.getId()).setName(machineryType.getName()) | ||
| 82 | + .setParentId(machineryType.getParentId()))); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/vo/MesDvMachineryPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - MES 设备台账分页 Request VO") | ||
| 10 | +@Data | ||
| 11 | +@EqualsAndHashCode(callSuper = true) | ||
| 12 | +@ToString(callSuper = true) | ||
| 13 | +public class MesDvMachineryPageReqVO extends PageParam { | ||
| 14 | + | ||
| 15 | + @Schema(description = "设备编码", example = "EQ-001") | ||
| 16 | + private String code; | ||
| 17 | + | ||
| 18 | + @Schema(description = "设备名称", example = "CNC 加工中心") | ||
| 19 | + private String name; | ||
| 20 | + | ||
| 21 | + @Schema(description = "品牌", example = "西门子") | ||
| 22 | + private String brand; | ||
| 23 | + | ||
| 24 | + @Schema(description = "设备类型编号", example = "100") | ||
| 25 | + private Long machineryTypeId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "所属车间编号", example = "200") | ||
| 28 | + private Long workshopId; | ||
| 29 | + | ||
| 30 | + @Schema(description = "设备状态", example = "1") | ||
| 31 | + private Integer status; | ||
| 32 | + | ||
| 33 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/vo/MesDvMachineryRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | +import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; | ||
| 6 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | ||
| 7 | +import cn.idev.excel.annotation.ExcelProperty; | ||
| 8 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 9 | +import lombok.Data; | ||
| 10 | + | ||
| 11 | +import java.time.LocalDateTime; | ||
| 12 | + | ||
| 13 | +@Schema(description = "管理后台 - MES 设备台账 Response VO") | ||
| 14 | +@Data | ||
| 15 | +@ExcelIgnoreUnannotated | ||
| 16 | +public class MesDvMachineryRespVO { | ||
| 17 | + | ||
| 18 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 19 | + @ExcelProperty("编号") | ||
| 20 | + private Long id; | ||
| 21 | + | ||
| 22 | + @Schema(description = "设备编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "EQ-001") | ||
| 23 | + @ExcelProperty("设备编码") | ||
| 24 | + private String code; | ||
| 25 | + | ||
| 26 | + @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "CNC 加工中心") | ||
| 27 | + @ExcelProperty("设备名称") | ||
| 28 | + private String name; | ||
| 29 | + | ||
| 30 | + @Schema(description = "品牌", example = "西门子") | ||
| 31 | + @ExcelProperty("品牌") | ||
| 32 | + private String brand; | ||
| 33 | + | ||
| 34 | + @Schema(description = "规格型号", example = "S7-300") | ||
| 35 | + @ExcelProperty("规格型号") | ||
| 36 | + private String spec; | ||
| 37 | + | ||
| 38 | + @Schema(description = "设备类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 39 | + private Long machineryTypeId; | ||
| 40 | + | ||
| 41 | + @Schema(description = "设备类型名称", example = "数控机床") | ||
| 42 | + @ExcelProperty("设备类型") | ||
| 43 | + private String machineryTypeName; | ||
| 44 | + | ||
| 45 | + @Schema(description = "所属车间编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") | ||
| 46 | + private Long workshopId; | ||
| 47 | + | ||
| 48 | + @Schema(description = "所属车间名称", example = "一号车间") | ||
| 49 | + @ExcelProperty("所属车间") | ||
| 50 | + private String workshopName; | ||
| 51 | + | ||
| 52 | + @Schema(description = "设备状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 53 | + @ExcelProperty(value = "设备状态", converter = DictConvert.class) | ||
| 54 | + @DictFormat(DictTypeConstants.MES_DV_MACHINERY_STATUS) | ||
| 55 | + private Integer status; | ||
| 56 | + | ||
| 57 | + @Schema(description = "最近保养时间") | ||
| 58 | + @ExcelProperty("最近保养时间") | ||
| 59 | + private LocalDateTime lastMaintenTime; | ||
| 60 | + | ||
| 61 | + @Schema(description = "最近点检时间") | ||
| 62 | + @ExcelProperty("最近点检时间") | ||
| 63 | + private LocalDateTime lastCheckTime; | ||
| 64 | + | ||
| 65 | + @Schema(description = "备注", example = "备注") | ||
| 66 | + @ExcelProperty("备注") | ||
| 67 | + private String remark; | ||
| 68 | + | ||
| 69 | + @Schema(description = "预留字段1") | ||
| 70 | + private String attribute1; | ||
| 71 | + | ||
| 72 | + @Schema(description = "预留字段2") | ||
| 73 | + private String attribute2; | ||
| 74 | + | ||
| 75 | + @Schema(description = "预留字段3") | ||
| 76 | + private Integer attribute3; | ||
| 77 | + | ||
| 78 | + @Schema(description = "预留字段4") | ||
| 79 | + private Integer attribute4; | ||
| 80 | + | ||
| 81 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 82 | + @ExcelProperty("创建时间") | ||
| 83 | + private LocalDateTime createTime; | ||
| 84 | + | ||
| 85 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/vo/MesDvMachinerySaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - MES 设备台账新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class MesDvMachinerySaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "设备编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "EQ-001") | ||
| 16 | + @NotEmpty(message = "设备编码不能为空") | ||
| 17 | + private String code; | ||
| 18 | + | ||
| 19 | + @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "CNC 加工中心") | ||
| 20 | + @NotEmpty(message = "设备名称不能为空") | ||
| 21 | + private String name; | ||
| 22 | + | ||
| 23 | + @Schema(description = "品牌", example = "西门子") | ||
| 24 | + private String brand; | ||
| 25 | + | ||
| 26 | + @Schema(description = "规格型号", example = "S7-300") | ||
| 27 | + private String spec; | ||
| 28 | + | ||
| 29 | + @Schema(description = "设备类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 30 | + @NotNull(message = "设备类型不能为空") | ||
| 31 | + private Long machineryTypeId; | ||
| 32 | + | ||
| 33 | + @Schema(description = "所属车间编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") | ||
| 34 | + @NotNull(message = "所属车间不能为空") | ||
| 35 | + private Long workshopId; | ||
| 36 | + | ||
| 37 | + @Schema(description = "设备状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 38 | + @NotNull(message = "设备状态不能为空") | ||
| 39 | + private Integer status; | ||
| 40 | + | ||
| 41 | + @Schema(description = "备注", example = "备注") | ||
| 42 | + private String remark; | ||
| 43 | + | ||
| 44 | + @Schema(description = "预留字段1") | ||
| 45 | + private String attribute1; | ||
| 46 | + | ||
| 47 | + @Schema(description = "预留字段2") | ||
| 48 | + private String attribute2; | ||
| 49 | + | ||
| 50 | + @Schema(description = "预留字段3") | ||
| 51 | + private Integer attribute3; | ||
| 52 | + | ||
| 53 | + @Schema(description = "预留字段4") | ||
| 54 | + private Integer attribute4; | ||
| 55 | + | ||
| 56 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/vo/type/MesDvMachineryTypeListReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import lombok.experimental.Accessors; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - MES 设备类型列表 Request VO") | ||
| 8 | +@Data | ||
| 9 | +@Accessors(chain = true) | ||
| 10 | +public class MesDvMachineryTypeListReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "类型名称", example = "数控机床") | ||
| 13 | + private String name; | ||
| 14 | + | ||
| 15 | + @Schema(description = "状态", example = "0") | ||
| 16 | + private Integer status; | ||
| 17 | + | ||
| 18 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/vo/type/MesDvMachineryTypeRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type; | ||
| 2 | + | ||
| 3 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | +import cn.idev.excel.annotation.ExcelProperty; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - MES 设备类型 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ExcelIgnoreUnannotated | ||
| 13 | +public class MesDvMachineryTypeRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 16 | + @ExcelProperty("编号") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "类型编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "MT-001") | ||
| 20 | + @ExcelProperty("类型编码") | ||
| 21 | + private String code; | ||
| 22 | + | ||
| 23 | + @Schema(description = "类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "数控机床") | ||
| 24 | + @ExcelProperty("类型名称") | ||
| 25 | + private String name; | ||
| 26 | + | ||
| 27 | + @Schema(description = "父类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 28 | + private Long parentId; | ||
| 29 | + | ||
| 30 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 31 | + @ExcelProperty("状态") | ||
| 32 | + private Integer status; | ||
| 33 | + | ||
| 34 | + @Schema(description = "显示排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 35 | + @ExcelProperty("显示排序") | ||
| 36 | + private Integer sort; | ||
| 37 | + | ||
| 38 | + @Schema(description = "备注", example = "备注") | ||
| 39 | + @ExcelProperty("备注") | ||
| 40 | + private String remark; | ||
| 41 | + | ||
| 42 | + @Schema(description = "预留字段1") | ||
| 43 | + private String attribute1; | ||
| 44 | + | ||
| 45 | + @Schema(description = "预留字段2") | ||
| 46 | + private String attribute2; | ||
| 47 | + | ||
| 48 | + @Schema(description = "预留字段3") | ||
| 49 | + private Integer attribute3; | ||
| 50 | + | ||
| 51 | + @Schema(description = "预留字段4") | ||
| 52 | + private Integer attribute4; | ||
| 53 | + | ||
| 54 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 55 | + @ExcelProperty("创建时间") | ||
| 56 | + private LocalDateTime createTime; | ||
| 57 | + | ||
| 58 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/vo/type/MesDvMachineryTypeSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - MES 设备类型新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class MesDvMachineryTypeSaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "类型编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "MT-001") | ||
| 16 | + @NotEmpty(message = "类型编码不能为空") | ||
| 17 | + private String code; | ||
| 18 | + | ||
| 19 | + @Schema(description = "类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "数控机床") | ||
| 20 | + @NotEmpty(message = "类型名称不能为空") | ||
| 21 | + private String name; | ||
| 22 | + | ||
| 23 | + @Schema(description = "父类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 24 | + @NotNull(message = "父类型编号不能为空") | ||
| 25 | + private Long parentId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 28 | + @NotNull(message = "状态不能为空") | ||
| 29 | + private Integer status; | ||
| 30 | + | ||
| 31 | + @Schema(description = "显示排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 32 | + @NotNull(message = "显示排序不能为空") | ||
| 33 | + private Integer sort; | ||
| 34 | + | ||
| 35 | + @Schema(description = "备注", example = "备注") | ||
| 36 | + private String remark; | ||
| 37 | + | ||
| 38 | + @Schema(description = "预留字段1") | ||
| 39 | + private String attribute1; | ||
| 40 | + | ||
| 41 | + @Schema(description = "预留字段2") | ||
| 42 | + private String attribute2; | ||
| 43 | + | ||
| 44 | + @Schema(description = "预留字段3") | ||
| 45 | + private Integer attribute3; | ||
| 46 | + | ||
| 47 | + @Schema(description = "预留字段4") | ||
| 48 | + private Integer attribute4; | ||
| 49 | + | ||
| 50 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/machinery/MesDvMachineryDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import lombok.*; | ||
| 8 | + | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * MES 设备台账 DO | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@TableName("mes_dv_machinery") | ||
| 17 | +@KeySequence("mes_dv_machinery_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 18 | +@Data | ||
| 19 | +@EqualsAndHashCode(callSuper = true) | ||
| 20 | +@ToString(callSuper = true) | ||
| 21 | +@Builder | ||
| 22 | +@NoArgsConstructor | ||
| 23 | +@AllArgsConstructor | ||
| 24 | +public class MesDvMachineryDO extends BaseDO { | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 编号 | ||
| 28 | + */ | ||
| 29 | + @TableId | ||
| 30 | + private Long id; | ||
| 31 | + /** | ||
| 32 | + * 设备编码 | ||
| 33 | + */ | ||
| 34 | + private String code; | ||
| 35 | + /** | ||
| 36 | + * 设备名称 | ||
| 37 | + */ | ||
| 38 | + private String name; | ||
| 39 | + /** | ||
| 40 | + * 品牌 | ||
| 41 | + */ | ||
| 42 | + private String brand; | ||
| 43 | + /** | ||
| 44 | + * 规格型号 | ||
| 45 | + */ | ||
| 46 | + private String spec; | ||
| 47 | + /** | ||
| 48 | + * 设备类型编号 | ||
| 49 | + * | ||
| 50 | + * 关联 {@link MesDvMachineryTypeDO#getId()} | ||
| 51 | + */ | ||
| 52 | + private Long machineryTypeId; | ||
| 53 | + /** | ||
| 54 | + * 所属车间编号 | ||
| 55 | + * | ||
| 56 | + * 关联 {@link cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkshopDO#getId()} | ||
| 57 | + */ | ||
| 58 | + private Long workshopId; | ||
| 59 | + // TODO @AI:搞个枚举类,然后 @下; | ||
| 60 | + /** | ||
| 61 | + * 设备状态 | ||
| 62 | + * | ||
| 63 | + * 字典 mes_dv_machinery_status | ||
| 64 | + */ | ||
| 65 | + private Integer status; | ||
| 66 | + /** | ||
| 67 | + * 最近保养时间 | ||
| 68 | + */ | ||
| 69 | + private LocalDateTime lastMaintenTime; | ||
| 70 | + /** | ||
| 71 | + * 最近点检时间 | ||
| 72 | + */ | ||
| 73 | + private LocalDateTime lastCheckTime; | ||
| 74 | + /** | ||
| 75 | + * 备注 | ||
| 76 | + */ | ||
| 77 | + private String remark; | ||
| 78 | + /** | ||
| 79 | + * 预留字段1 | ||
| 80 | + */ | ||
| 81 | + private String attribute1; | ||
| 82 | + /** | ||
| 83 | + * 预留字段2 | ||
| 84 | + */ | ||
| 85 | + private String attribute2; | ||
| 86 | + /** | ||
| 87 | + * 预留字段3 | ||
| 88 | + */ | ||
| 89 | + private Integer attribute3; | ||
| 90 | + /** | ||
| 91 | + * 预留字段4 | ||
| 92 | + */ | ||
| 93 | + private Integer attribute4; | ||
| 94 | + | ||
| 95 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/machinery/MesDvMachineryTypeDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import lombok.*; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * MES 设备类型 DO | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +@TableName("mes_dv_machinery_type") | ||
| 15 | +@KeySequence("mes_dv_machinery_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 16 | +@Data | ||
| 17 | +@EqualsAndHashCode(callSuper = true) | ||
| 18 | +@ToString(callSuper = true) | ||
| 19 | +@Builder | ||
| 20 | +@NoArgsConstructor | ||
| 21 | +@AllArgsConstructor | ||
| 22 | +public class MesDvMachineryTypeDO extends BaseDO { | ||
| 23 | + | ||
| 24 | + public static final Long PARENT_ID_ROOT = 0L; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 编号 | ||
| 28 | + */ | ||
| 29 | + @TableId | ||
| 30 | + private Long id; | ||
| 31 | + /** | ||
| 32 | + * 类型编码 | ||
| 33 | + */ | ||
| 34 | + private String code; | ||
| 35 | + /** | ||
| 36 | + * 类型名称 | ||
| 37 | + */ | ||
| 38 | + private String name; | ||
| 39 | + /** | ||
| 40 | + * 父类型编号 | ||
| 41 | + * | ||
| 42 | + * 关联 {@link MesDvMachineryTypeDO#getId()} | ||
| 43 | + */ | ||
| 44 | + private Long parentId; | ||
| 45 | + /** | ||
| 46 | + * 状态 | ||
| 47 | + * | ||
| 48 | + * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} | ||
| 49 | + */ | ||
| 50 | + private Integer status; | ||
| 51 | + /** | ||
| 52 | + * 显示排序 | ||
| 53 | + */ | ||
| 54 | + private Integer sort; | ||
| 55 | + /** | ||
| 56 | + * 备注 | ||
| 57 | + */ | ||
| 58 | + private String remark; | ||
| 59 | + /** | ||
| 60 | + * 预留字段1 | ||
| 61 | + */ | ||
| 62 | + private String attribute1; | ||
| 63 | + /** | ||
| 64 | + * 预留字段2 | ||
| 65 | + */ | ||
| 66 | + private String attribute2; | ||
| 67 | + /** | ||
| 68 | + * 预留字段3 | ||
| 69 | + */ | ||
| 70 | + private Integer attribute3; | ||
| 71 | + /** | ||
| 72 | + * 预留字段4 | ||
| 73 | + */ | ||
| 74 | + private Integer attribute4; | ||
| 75 | + | ||
| 76 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalPlanMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.cal.plan; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.MesCalPlanPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * MES 排班计划 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface MesCalPlanMapper extends BaseMapperX<MesCalPlanDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<MesCalPlanDO> selectPage(MesCalPlanPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesCalPlanDO>() | ||
| 20 | + .likeIfPresent(MesCalPlanDO::getCode, reqVO.getCode()) | ||
| 21 | + .likeIfPresent(MesCalPlanDO::getName, reqVO.getName()) | ||
| 22 | + .eqIfPresent(MesCalPlanDO::getShiftType, reqVO.getShiftType()) | ||
| 23 | + .eqIfPresent(MesCalPlanDO::getStatus, reqVO.getStatus()) | ||
| 24 | + .orderByDesc(MesCalPlanDO::getId)); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + default MesCalPlanDO selectByCode(String code) { | ||
| 28 | + return selectOne(MesCalPlanDO::getCode, code); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalPlanTeamMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.cal.plan; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanTeamDO; | ||
| 6 | +import org.apache.ibatis.annotations.Mapper; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * MES 计划班组关联 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface MesCalPlanTeamMapper extends BaseMapperX<MesCalPlanTeamDO> { | ||
| 17 | + | ||
| 18 | + default List<MesCalPlanTeamDO> selectListByPlanId(Long planId) { | ||
| 19 | + return selectList(new LambdaQueryWrapperX<MesCalPlanTeamDO>() | ||
| 20 | + .eq(MesCalPlanTeamDO::getPlanId, planId) | ||
| 21 | + .orderByDesc(MesCalPlanTeamDO::getId)); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + default Long selectCountByPlanId(Long planId) { | ||
| 25 | + return selectCount(MesCalPlanTeamDO::getPlanId, planId); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + default MesCalPlanTeamDO selectByPlanIdAndTeamId(Long planId, Long teamId) { | ||
| 29 | + return selectOne(new LambdaQueryWrapperX<MesCalPlanTeamDO>() | ||
| 30 | + .eq(MesCalPlanTeamDO::getPlanId, planId) | ||
| 31 | + .eq(MesCalPlanTeamDO::getTeamId, teamId)); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + default void deleteByPlanId(Long planId) { | ||
| 35 | + delete(new LambdaQueryWrapperX<MesCalPlanTeamDO>() | ||
| 36 | + .eq(MesCalPlanTeamDO::getPlanId, planId)); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalShiftMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.cal.plan; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * MES 计划班次 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface MesCalShiftMapper extends BaseMapperX<MesCalShiftDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<MesCalShiftDO> selectPage(MesCalShiftPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesCalShiftDO>() | ||
| 22 | + .eqIfPresent(MesCalShiftDO::getPlanId, reqVO.getPlanId()) | ||
| 23 | + .likeIfPresent(MesCalShiftDO::getName, reqVO.getName()) | ||
| 24 | + .orderByAsc(MesCalShiftDO::getSort)); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + default List<MesCalShiftDO> selectListByPlanId(Long planId) { | ||
| 28 | + return selectList(new LambdaQueryWrapperX<MesCalShiftDO>() | ||
| 29 | + .eq(MesCalShiftDO::getPlanId, planId) | ||
| 30 | + .orderByAsc(MesCalShiftDO::getSort)); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + default Long selectCountByPlanId(Long planId) { | ||
| 34 | + return selectCount(MesCalShiftDO::getPlanId, planId); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + default void deleteByPlanId(Long planId) { | ||
| 38 | + delete(new LambdaQueryWrapperX<MesCalShiftDO>() | ||
| 39 | + .eq(MesCalShiftDO::getPlanId, planId)); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/machinery/MesDvMachineryMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * MES 设备台账 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface MesDvMachineryMapper extends BaseMapperX<MesDvMachineryDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<MesDvMachineryDO> selectPage(MesDvMachineryPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesDvMachineryDO>() | ||
| 20 | + .likeIfPresent(MesDvMachineryDO::getCode, reqVO.getCode()) | ||
| 21 | + .likeIfPresent(MesDvMachineryDO::getName, reqVO.getName()) | ||
| 22 | + .likeIfPresent(MesDvMachineryDO::getBrand, reqVO.getBrand()) | ||
| 23 | + .eqIfPresent(MesDvMachineryDO::getMachineryTypeId, reqVO.getMachineryTypeId()) | ||
| 24 | + .eqIfPresent(MesDvMachineryDO::getWorkshopId, reqVO.getWorkshopId()) | ||
| 25 | + .eqIfPresent(MesDvMachineryDO::getStatus, reqVO.getStatus()) | ||
| 26 | + .orderByDesc(MesDvMachineryDO::getId)); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + default MesDvMachineryDO selectByCode(String code) { | ||
| 30 | + return selectOne(MesDvMachineryDO::getCode, code); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + default Long selectCountByMachineryTypeId(Long machineryTypeId) { | ||
| 34 | + return selectCount(MesDvMachineryDO::getMachineryTypeId, machineryTypeId); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/machinery/MesDvMachineryTypeMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeListReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryTypeDO; | ||
| 7 | +import org.apache.ibatis.annotations.Mapper; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * MES 设备类型 Mapper | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@Mapper | ||
| 17 | +public interface MesDvMachineryTypeMapper extends BaseMapperX<MesDvMachineryTypeDO> { | ||
| 18 | + | ||
| 19 | + default List<MesDvMachineryTypeDO> selectList(MesDvMachineryTypeListReqVO reqVO) { | ||
| 20 | + return selectList(new LambdaQueryWrapperX<MesDvMachineryTypeDO>() | ||
| 21 | + .likeIfPresent(MesDvMachineryTypeDO::getName, reqVO.getName()) | ||
| 22 | + .eqIfPresent(MesDvMachineryTypeDO::getStatus, reqVO.getStatus()) | ||
| 23 | + .orderByAsc(MesDvMachineryTypeDO::getSort) | ||
| 24 | + .orderByDesc(MesDvMachineryTypeDO::getId)); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + default List<MesDvMachineryTypeDO> selectList() { | ||
| 28 | + return selectList(new LambdaQueryWrapperX<MesDvMachineryTypeDO>() | ||
| 29 | + .orderByAsc(MesDvMachineryTypeDO::getSort) | ||
| 30 | + .orderByDesc(MesDvMachineryTypeDO::getId)); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + default MesDvMachineryTypeDO selectByParentIdAndName(Long parentId, String name) { | ||
| 34 | + return selectOne(new LambdaQueryWrapperX<MesDvMachineryTypeDO>() | ||
| 35 | + .eq(MesDvMachineryTypeDO::getParentId, parentId) | ||
| 36 | + .eq(MesDvMachineryTypeDO::getName, name)); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + default MesDvMachineryTypeDO selectByParentIdAndCode(Long parentId, String code) { | ||
| 40 | + return selectOne(new LambdaQueryWrapperX<MesDvMachineryTypeDO>() | ||
| 41 | + .eq(MesDvMachineryTypeDO::getParentId, parentId) | ||
| 42 | + .eq(MesDvMachineryTypeDO::getCode, code)); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + default Long selectCountByParentId(Long parentId) { | ||
| 46 | + return selectCount(MesDvMachineryTypeDO::getParentId, parentId); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java
| @@ -16,5 +16,6 @@ public interface DictTypeConstants { | @@ -16,5 +16,6 @@ public interface DictTypeConstants { | ||
| 16 | String MES_CAL_SHIFT_METHOD = "mes_cal_shift_method"; // MES 倒班方式 | 16 | String MES_CAL_SHIFT_METHOD = "mes_cal_shift_method"; // MES 倒班方式 |
| 17 | String MES_CAL_CALENDAR_TYPE = "mes_cal_calendar_type"; // MES 班组类型 | 17 | String MES_CAL_CALENDAR_TYPE = "mes_cal_calendar_type"; // MES 班组类型 |
| 18 | String MES_CAL_PLAN_STATUS = "mes_cal_plan_status"; // MES 排班计划状态 | 18 | String MES_CAL_PLAN_STATUS = "mes_cal_plan_status"; // MES 排班计划状态 |
| 19 | + String MES_DV_MACHINERY_STATUS = "mes_dv_machinery_status"; // MES 设备状态 | ||
| 19 | 20 | ||
| 20 | } | 21 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| @@ -104,9 +104,17 @@ public interface ErrorCodeConstants { | @@ -104,9 +104,17 @@ public interface ErrorCodeConstants { | ||
| 104 | 104 | ||
| 105 | // ========== MES 设备管理-设备类型(1-040-300-000) ========== | 105 | // ========== MES 设备管理-设备类型(1-040-300-000) ========== |
| 106 | ErrorCode DV_MACHINERY_TYPE_NOT_EXISTS = new ErrorCode(1_040_300_000, "设备类型不存在"); | 106 | ErrorCode DV_MACHINERY_TYPE_NOT_EXISTS = new ErrorCode(1_040_300_000, "设备类型不存在"); |
| 107 | + ErrorCode DV_MACHINERY_TYPE_EXITS_CHILDREN = new ErrorCode(1_040_300_001, "存在子类型,无法删除"); | ||
| 108 | + ErrorCode DV_MACHINERY_TYPE_PARENT_NOT_EXITS = new ErrorCode(1_040_300_002, "父级类型不存在"); | ||
| 109 | + ErrorCode DV_MACHINERY_TYPE_PARENT_ERROR = new ErrorCode(1_040_300_003, "不能设置自己为父类型"); | ||
| 110 | + ErrorCode DV_MACHINERY_TYPE_NAME_DUPLICATE = new ErrorCode(1_040_300_004, "同一父类型下已存在该名称"); | ||
| 111 | + ErrorCode DV_MACHINERY_TYPE_CODE_DUPLICATE = new ErrorCode(1_040_300_005, "同一父类型下已存在该编码"); | ||
| 112 | + ErrorCode DV_MACHINERY_TYPE_PARENT_IS_CHILD = new ErrorCode(1_040_300_006, "不能设置自己的子类型为父类型"); | ||
| 113 | + ErrorCode DV_MACHINERY_TYPE_HAS_MACHINERY = new ErrorCode(1_040_300_007, "该类型下存在设备,无法删除"); | ||
| 107 | 114 | ||
| 108 | // ========== MES 设备管理-设备台账(1-040-301-000) ========== | 115 | // ========== MES 设备管理-设备台账(1-040-301-000) ========== |
| 109 | ErrorCode DV_MACHINERY_NOT_EXISTS = new ErrorCode(1_040_301_000, "设备不存在"); | 116 | ErrorCode DV_MACHINERY_NOT_EXISTS = new ErrorCode(1_040_301_000, "设备不存在"); |
| 117 | + ErrorCode DV_MACHINERY_CODE_DUPLICATE = new ErrorCode(1_040_301_001, "设备编码已存在"); | ||
| 110 | 118 | ||
| 111 | // ========== MES 设备管理-点检计划(1-040-302-000) ========== | 119 | // ========== MES 设备管理-点检计划(1-040-302-000) ========== |
| 112 | ErrorCode DV_CHECK_PLAN_NOT_EXISTS = new ErrorCode(1_040_302_000, "点检计划不存在"); | 120 | ErrorCode DV_CHECK_PLAN_NOT_EXISTS = new ErrorCode(1_040_302_000, "点检计划不存在"); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachinerySaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; | ||
| 7 | +import jakarta.validation.Valid; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * MES 设备台账 Service 接口 | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +public interface MesDvMachineryService { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 创建设备 | ||
| 18 | + * | ||
| 19 | + * @param createReqVO 创建信息 | ||
| 20 | + * @return 编号 | ||
| 21 | + */ | ||
| 22 | + Long createMachinery(@Valid MesDvMachinerySaveReqVO createReqVO); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 更新设备 | ||
| 26 | + * | ||
| 27 | + * @param updateReqVO 更新信息 | ||
| 28 | + */ | ||
| 29 | + void updateMachinery(@Valid MesDvMachinerySaveReqVO updateReqVO); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 删除设备 | ||
| 33 | + * | ||
| 34 | + * @param id 编号 | ||
| 35 | + */ | ||
| 36 | + void deleteMachinery(Long id); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 获得设备 | ||
| 40 | + * | ||
| 41 | + * @param id 编号 | ||
| 42 | + * @return 设备 | ||
| 43 | + */ | ||
| 44 | + MesDvMachineryDO getMachinery(Long id); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得设备分页 | ||
| 48 | + * | ||
| 49 | + * @param pageReqVO 分页查询 | ||
| 50 | + * @return 设备分页 | ||
| 51 | + */ | ||
| 52 | + PageResult<MesDvMachineryDO> getMachineryPage(MesDvMachineryPageReqVO pageReqVO); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获得指定设备类型下的设备数量 | ||
| 56 | + * | ||
| 57 | + * @param machineryTypeId 设备类型编号 | ||
| 58 | + * @return 设备数量 | ||
| 59 | + */ | ||
| 60 | + Long getMachineryCountByMachineryTypeId(Long machineryTypeId); | ||
| 61 | + | ||
| 62 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.util.ObjUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachinerySaveReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryMapper; | ||
| 10 | +import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkshopService; | ||
| 11 | +import jakarta.annotation.Resource; | ||
| 12 | +import org.springframework.context.annotation.Lazy; | ||
| 13 | +import org.springframework.stereotype.Service; | ||
| 14 | +import org.springframework.validation.annotation.Validated; | ||
| 15 | + | ||
| 16 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 17 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * MES 设备台账 Service 实现类 | ||
| 21 | + * | ||
| 22 | + * @author 芋道源码 | ||
| 23 | + */ | ||
| 24 | +@Service | ||
| 25 | +@Validated | ||
| 26 | +public class MesDvMachineryServiceImpl implements MesDvMachineryService { | ||
| 27 | + | ||
| 28 | + @Resource | ||
| 29 | + private MesDvMachineryMapper machineryMapper; | ||
| 30 | + | ||
| 31 | + @Resource | ||
| 32 | + @Lazy // 延迟加载,避免循环依赖 | ||
| 33 | + private MesDvMachineryTypeService machineryTypeService; | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + @Lazy | ||
| 37 | + private MesMdWorkshopService workshopService; | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public Long createMachinery(MesDvMachinerySaveReqVO createReqVO) { | ||
| 41 | + // 校验设备类型存在 | ||
| 42 | + machineryTypeService.getMachineryType(createReqVO.getMachineryTypeId()); | ||
| 43 | + // 校验车间存在 | ||
| 44 | + workshopService.getWorkshop(createReqVO.getWorkshopId()); | ||
| 45 | + // 校验编码唯一 | ||
| 46 | + validateMachineryCodeUnique(null, createReqVO.getCode()); | ||
| 47 | + | ||
| 48 | + // 插入 | ||
| 49 | + MesDvMachineryDO machinery = BeanUtils.toBean(createReqVO, MesDvMachineryDO.class); | ||
| 50 | + machineryMapper.insert(machinery); | ||
| 51 | + return machinery.getId(); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void updateMachinery(MesDvMachinerySaveReqVO updateReqVO) { | ||
| 56 | + // 校验存在 | ||
| 57 | + validateMachineryExists(updateReqVO.getId()); | ||
| 58 | + // 校验设备类型存在 | ||
| 59 | + machineryTypeService.getMachineryType(updateReqVO.getMachineryTypeId()); | ||
| 60 | + // 校验车间存在 | ||
| 61 | + workshopService.getWorkshop(updateReqVO.getWorkshopId()); | ||
| 62 | + // 校验编码唯一 | ||
| 63 | + validateMachineryCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | ||
| 64 | + | ||
| 65 | + // 更新 | ||
| 66 | + MesDvMachineryDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMachineryDO.class); | ||
| 67 | + machineryMapper.updateById(updateObj); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public void deleteMachinery(Long id) { | ||
| 72 | + // 校验存在 | ||
| 73 | + validateMachineryExists(id); | ||
| 74 | + // TODO @芋艿:后续补充点检计划、保养记录、维修工单等引用校验 | ||
| 75 | + | ||
| 76 | + // 删除 | ||
| 77 | + machineryMapper.deleteById(id); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + private void validateMachineryExists(Long id) { | ||
| 81 | + if (machineryMapper.selectById(id) == null) { | ||
| 82 | + throw exception(DV_MACHINERY_NOT_EXISTS); | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + private void validateMachineryCodeUnique(Long id, String code) { | ||
| 87 | + if (code == null) { | ||
| 88 | + return; | ||
| 89 | + } | ||
| 90 | + MesDvMachineryDO machinery = machineryMapper.selectByCode(code); | ||
| 91 | + if (machinery == null) { | ||
| 92 | + return; | ||
| 93 | + } | ||
| 94 | + if (ObjUtil.notEqual(machinery.getId(), id)) { | ||
| 95 | + throw exception(DV_MACHINERY_CODE_DUPLICATE); | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Override | ||
| 100 | + public MesDvMachineryDO getMachinery(Long id) { | ||
| 101 | + return machineryMapper.selectById(id); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Override | ||
| 105 | + public PageResult<MesDvMachineryDO> getMachineryPage(MesDvMachineryPageReqVO pageReqVO) { | ||
| 106 | + return machineryMapper.selectPage(pageReqVO); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + @Override | ||
| 110 | + public Long getMachineryCountByMachineryTypeId(Long machineryTypeId) { | ||
| 111 | + return machineryMapper.selectCountByMachineryTypeId(machineryTypeId); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryTypeService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeListReqVO; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeSaveReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryTypeDO; | ||
| 6 | +import jakarta.validation.Valid; | ||
| 7 | + | ||
| 8 | +import java.util.Collection; | ||
| 9 | +import java.util.List; | ||
| 10 | +import java.util.Map; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * MES 设备类型 Service 接口 | ||
| 16 | + * | ||
| 17 | + * @author 芋道源码 | ||
| 18 | + */ | ||
| 19 | +public interface MesDvMachineryTypeService { | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 创建设备类型 | ||
| 23 | + * | ||
| 24 | + * @param createReqVO 创建信息 | ||
| 25 | + * @return 编号 | ||
| 26 | + */ | ||
| 27 | + Long createMachineryType(@Valid MesDvMachineryTypeSaveReqVO createReqVO); | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 更新设备类型 | ||
| 31 | + * | ||
| 32 | + * @param updateReqVO 更新信息 | ||
| 33 | + */ | ||
| 34 | + void updateMachineryType(@Valid MesDvMachineryTypeSaveReqVO updateReqVO); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 删除设备类型 | ||
| 38 | + * | ||
| 39 | + * @param id 编号 | ||
| 40 | + */ | ||
| 41 | + void deleteMachineryType(Long id); | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 获得设备类型 | ||
| 45 | + * | ||
| 46 | + * @param id 编号 | ||
| 47 | + * @return 设备类型 | ||
| 48 | + */ | ||
| 49 | + MesDvMachineryTypeDO getMachineryType(Long id); | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 获得设备类型列表 | ||
| 53 | + * | ||
| 54 | + * @param listReqVO 列表查询 | ||
| 55 | + * @return 设备类型列表 | ||
| 56 | + */ | ||
| 57 | + List<MesDvMachineryTypeDO> getMachineryTypeList(MesDvMachineryTypeListReqVO listReqVO); | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 获得设备类型列表 | ||
| 61 | + * | ||
| 62 | + * @param ids 编号数组 | ||
| 63 | + * @return 设备类型列表 | ||
| 64 | + */ | ||
| 65 | + List<MesDvMachineryTypeDO> getMachineryTypeList(Collection<Long> ids); | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 获得设备类型 Map | ||
| 69 | + * | ||
| 70 | + * @param ids 编号数组 | ||
| 71 | + * @return 设备类型 Map | ||
| 72 | + */ | ||
| 73 | + default Map<Long, MesDvMachineryTypeDO> getMachineryTypeMap(Collection<Long> ids) { | ||
| 74 | + return convertMap(getMachineryTypeList(ids), MesDvMachineryTypeDO::getId); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 获得指定父类型下的所有子类型(递归) | ||
| 79 | + * | ||
| 80 | + * @param parentId 父类型编号 | ||
| 81 | + * @return 子类型列表 | ||
| 82 | + */ | ||
| 83 | + List<MesDvMachineryTypeDO> getMachineryTypeChildrenList(Long parentId); | ||
| 84 | + | ||
| 85 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryTypeServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.machinery; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.util.ObjUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeListReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeSaveReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryTypeDO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryMapper; | ||
| 10 | +import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryTypeMapper; | ||
| 11 | +import jakarta.annotation.Resource; | ||
| 12 | +import org.springframework.context.annotation.Lazy; | ||
| 13 | +import org.springframework.stereotype.Service; | ||
| 14 | +import org.springframework.validation.annotation.Validated; | ||
| 15 | + | ||
| 16 | +import java.util.*; | ||
| 17 | + | ||
| 18 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * MES 设备类型 Service 实现类 | ||
| 23 | + * | ||
| 24 | + * @author 芋道源码 | ||
| 25 | + */ | ||
| 26 | +@Service | ||
| 27 | +@Validated | ||
| 28 | +public class MesDvMachineryTypeServiceImpl implements MesDvMachineryTypeService { | ||
| 29 | + | ||
| 30 | + @Resource | ||
| 31 | + private MesDvMachineryTypeMapper machineryTypeMapper; | ||
| 32 | + | ||
| 33 | + @Resource | ||
| 34 | + @Lazy // 延迟加载,避免循环依赖 | ||
| 35 | + private MesDvMachineryService machineryService; | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public Long createMachineryType(MesDvMachineryTypeSaveReqVO createReqVO) { | ||
| 39 | + // 校验父类型编号的有效性 | ||
| 40 | + validateParentMachineryType(null, createReqVO.getParentId()); | ||
| 41 | + // 校验类型名称的唯一性 | ||
| 42 | + validateMachineryTypeNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); | ||
| 43 | + // 校验类型编码的唯一性 | ||
| 44 | + validateMachineryTypeCodeUnique(null, createReqVO.getParentId(), createReqVO.getCode()); | ||
| 45 | + | ||
| 46 | + // 插入 | ||
| 47 | + MesDvMachineryTypeDO machineryType = BeanUtils.toBean(createReqVO, MesDvMachineryTypeDO.class); | ||
| 48 | + machineryTypeMapper.insert(machineryType); | ||
| 49 | + return machineryType.getId(); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Override | ||
| 53 | + public void updateMachineryType(MesDvMachineryTypeSaveReqVO updateReqVO) { | ||
| 54 | + // 校验存在 | ||
| 55 | + validateMachineryTypeExists(updateReqVO.getId()); | ||
| 56 | + // 校验父类型编号的有效性 | ||
| 57 | + validateParentMachineryType(updateReqVO.getId(), updateReqVO.getParentId()); | ||
| 58 | + // 校验类型名称的唯一性 | ||
| 59 | + validateMachineryTypeNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); | ||
| 60 | + // 校验类型编码的唯一性 | ||
| 61 | + validateMachineryTypeCodeUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getCode()); | ||
| 62 | + | ||
| 63 | + // 更新 | ||
| 64 | + MesDvMachineryTypeDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMachineryTypeDO.class); | ||
| 65 | + machineryTypeMapper.updateById(updateObj); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public void deleteMachineryType(Long id) { | ||
| 70 | + // 1.1 校验存在 | ||
| 71 | + validateMachineryTypeExists(id); | ||
| 72 | + // 1.2 校验是否有子类型 | ||
| 73 | + if (machineryTypeMapper.selectCountByParentId(id) > 0) { | ||
| 74 | + throw exception(DV_MACHINERY_TYPE_EXITS_CHILDREN); | ||
| 75 | + } | ||
| 76 | + // 1.3 校验是否有设备 | ||
| 77 | + if (machineryService.getMachineryCountByMachineryTypeId(id) > 0) { | ||
| 78 | + throw exception(DV_MACHINERY_TYPE_HAS_MACHINERY); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + // 2. 删除 | ||
| 82 | + machineryTypeMapper.deleteById(id); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + private void validateMachineryTypeExists(Long id) { | ||
| 86 | + if (machineryTypeMapper.selectById(id) == null) { | ||
| 87 | + throw exception(DV_MACHINERY_TYPE_NOT_EXISTS); | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + private void validateParentMachineryType(Long id, Long parentId) { | ||
| 92 | + if (parentId == null || MesDvMachineryTypeDO.PARENT_ID_ROOT.equals(parentId)) { | ||
| 93 | + return; | ||
| 94 | + } | ||
| 95 | + // 1. 不能设置自己为父类型 | ||
| 96 | + if (Objects.equals(id, parentId)) { | ||
| 97 | + throw exception(DV_MACHINERY_TYPE_PARENT_ERROR); | ||
| 98 | + } | ||
| 99 | + // 2. 父类型不存在 | ||
| 100 | + MesDvMachineryTypeDO parentType = machineryTypeMapper.selectById(parentId); | ||
| 101 | + if (parentType == null) { | ||
| 102 | + throw exception(DV_MACHINERY_TYPE_PARENT_NOT_EXITS); | ||
| 103 | + } | ||
| 104 | + // 3. 递归校验父类型,如果父类型是自己的子类型,则报错,避免形成环路 | ||
| 105 | + if (id == null) { // id 为空,说明新增,不需要考虑环路 | ||
| 106 | + return; | ||
| 107 | + } | ||
| 108 | + for (int i = 0; i < Short.MAX_VALUE; i++) { | ||
| 109 | + // 3.1 校验环路 | ||
| 110 | + parentId = parentType.getParentId(); | ||
| 111 | + if (Objects.equals(id, parentId)) { | ||
| 112 | + throw exception(DV_MACHINERY_TYPE_PARENT_IS_CHILD); | ||
| 113 | + } | ||
| 114 | + // 3.2 继续递归下一级父类型 | ||
| 115 | + if (parentId == null || MesDvMachineryTypeDO.PARENT_ID_ROOT.equals(parentId)) { | ||
| 116 | + break; | ||
| 117 | + } | ||
| 118 | + parentType = machineryTypeMapper.selectById(parentId); | ||
| 119 | + if (parentType == null) { | ||
| 120 | + break; | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + private void validateMachineryTypeNameUnique(Long id, Long parentId, String name) { | ||
| 126 | + MesDvMachineryTypeDO machineryType = machineryTypeMapper.selectByParentIdAndName(parentId, name); | ||
| 127 | + if (machineryType == null) { | ||
| 128 | + return; | ||
| 129 | + } | ||
| 130 | + if (ObjUtil.notEqual(machineryType.getId(), id)) { | ||
| 131 | + throw exception(DV_MACHINERY_TYPE_NAME_DUPLICATE); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + private void validateMachineryTypeCodeUnique(Long id, Long parentId, String code) { | ||
| 136 | + MesDvMachineryTypeDO machineryType = machineryTypeMapper.selectByParentIdAndCode(parentId, code); | ||
| 137 | + if (machineryType == null) { | ||
| 138 | + return; | ||
| 139 | + } | ||
| 140 | + if (ObjUtil.notEqual(machineryType.getId(), id)) { | ||
| 141 | + throw exception(DV_MACHINERY_TYPE_CODE_DUPLICATE); | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + @Override | ||
| 146 | + public MesDvMachineryTypeDO getMachineryType(Long id) { | ||
| 147 | + return machineryTypeMapper.selectById(id); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + @Override | ||
| 151 | + public List<MesDvMachineryTypeDO> getMachineryTypeList(MesDvMachineryTypeListReqVO listReqVO) { | ||
| 152 | + return machineryTypeMapper.selectList(listReqVO); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + @Override | ||
| 156 | + public List<MesDvMachineryTypeDO> getMachineryTypeList(Collection<Long> ids) { | ||
| 157 | + if (CollUtil.isEmpty(ids)) { | ||
| 158 | + return Collections.emptyList(); | ||
| 159 | + } | ||
| 160 | + return machineryTypeMapper.selectByIds(ids); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + @Override | ||
| 164 | + public List<MesDvMachineryTypeDO> getMachineryTypeChildrenList(Long parentId) { | ||
| 165 | + List<MesDvMachineryTypeDO> allList = machineryTypeMapper.selectList(); // 类型总量小,全量查 | ||
| 166 | + // 递归收集所有子类型 | ||
| 167 | + List<MesDvMachineryTypeDO> result = new ArrayList<>(); | ||
| 168 | + collectMachineryTypeChildren(result, parentId, allList); | ||
| 169 | + return result; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + /** | ||
| 173 | + * 递归收集所有子类型 | ||
| 174 | + */ | ||
| 175 | + private void collectMachineryTypeChildren(List<MesDvMachineryTypeDO> result, Long parentId, | ||
| 176 | + List<MesDvMachineryTypeDO> allList) { | ||
| 177 | + for (MesDvMachineryTypeDO machineryType : allList) { | ||
| 178 | + if (Objects.equals(machineryType.getParentId(), parentId)) { | ||
| 179 | + result.add(machineryType); | ||
| 180 | + collectMachineryTypeChildren(result, machineryType.getId(), allList); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | +} |