From a5698d144990e7d4689b482909c901eb52205d26 Mon Sep 17 00:00:00 2001 From: HuangHuiKang Date: Mon, 25 May 2026 17:19:33 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=B7=BB=E5=8A=A0=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=8F=B0=E8=B4=A6=E4=BA=A7=E7=BA=BF=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=8A=E6=89=AB=E7=A0=81=E5=99=A8=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/enums/QrcodeBizTypeEnum.java | 4 +- .../qrcordrecord/QrcodeRecordService.java | 5 +- .../qrcordrecord/QrcodeRecordServiceImpl.java | 24 +- .../module/mes/enums/ErrorCodeConstants.java | 8 + .../vo/DeviceLedgerPageReqVO.java | 9 +- .../deviceledger/vo/DeviceLedgerRespVO.java | 5 +- .../vo/DeviceLedgerSaveReqVO.java | 5 +- .../deviceline/DeviceLineController.java | 210 +++++++++++ .../deviceline/vo/DeviceLineListReqVO.java | 32 ++ .../deviceline/vo/DeviceLinePageReqVO.java | 40 ++ .../admin/deviceline/vo/DeviceLineRespVO.java | 58 +++ .../deviceline/vo/DeviceLineSaveReqVO.java | 45 +++ .../deviceline/vo/DeviceLineTreeRespVO.java | 19 + .../deviceledger/DeviceLedgerDO.java | 6 +- .../dataobject/deviceline/DeviceLineDO.java | 61 ++++ .../deviceledger/DeviceLedgerMapper.java | 8 +- .../mysql/deviceline/DeviceLineMapper.java | 45 +++ .../deviceledger/DeviceLedgerServiceImpl.java | 33 ++ .../service/deviceline/DeviceLineService.java | 41 +++ .../deviceline/DeviceLineServiceImpl.java | 341 ++++++++++++++++++ .../mapper/deviceline/DeviceLineMapper.xml | 20 + .../auth/vo/AuthPermissionInfoRespVO.java | 3 + .../admin/permission/vo/menu/MenuRespVO.java | 2 + .../admin/permission/vo/menu/MenuSaveVO.java | 3 + .../permission/vo/menu/MenuSimpleRespVO.java | 2 + .../system/convert/auth/AuthConvert.java | 1 + .../dal/dataobject/permission/MenuDO.java | 5 + .../dal/mysql/permission/MenuMapper.java | 5 +- .../service/permission/MenuServiceImpl.java | 8 +- .../permission/MenuServiceImplTest.java | 12 +- 30 files changed, 1039 insertions(+), 21 deletions(-) create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/DeviceLineController.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineListReqVO.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLinePageReqVO.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineRespVO.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineSaveReqVO.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineTreeRespVO.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/deviceline/DeviceLineDO.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceline/DeviceLineMapper.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceline/DeviceLineService.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceline/DeviceLineServiceImpl.java create mode 100644 yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/deviceline/DeviceLineMapper.xml diff --git a/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/enums/QrcodeBizTypeEnum.java b/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/enums/QrcodeBizTypeEnum.java index c4981aced..51aff4a27 100644 --- a/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/enums/QrcodeBizTypeEnum.java +++ b/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/enums/QrcodeBizTypeEnum.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.module.common.enums; import lombok.AllArgsConstructor; -import lombok.Data; import lombok.Getter; @Getter @@ -10,6 +9,7 @@ public enum QrcodeBizTypeEnum { PRODUCT("PRODUCTMATERIAL", "产品物料"), EQUIPMENT("EQUIPMENT", "设备"), + DEVICE_LINE("DEVICE_LINE", "设备产线"), KEY_PART("KEY_PART", "关键件"), MOLD("MOLD", "模具"), SPARE("SPARE", "备件"); @@ -25,4 +25,4 @@ public enum QrcodeBizTypeEnum { } return null; } -} \ No newline at end of file +} diff --git a/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/service/qrcordrecord/QrcodeRecordService.java b/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/service/qrcordrecord/QrcodeRecordService.java index 8673b4913..ddf5a0ef2 100644 --- a/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/service/qrcordrecord/QrcodeRecordService.java +++ b/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/service/qrcordrecord/QrcodeRecordService.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum; import org.springframework.transaction.annotation.Transactional; import javax.validation.Valid; +import java.util.Collection; import java.io.UnsupportedEncodingException; import java.util.Map; @@ -66,6 +67,8 @@ public interface QrcodeRecordService { String selectQrcodeUrlByIdAndCode(String code, Long id, String code1); + Map selectQrcodeUrlMapByBizTypeAndIds(String bizType, Collection bizIds); + Map resolveScanBizId(String type, Long id, String code); void deleteByBiz(QrcodeBizTypeEnum bizType, Long bizId); @@ -80,4 +83,4 @@ public interface QrcodeRecordService { String scene, CodeTypeEnum codeType ) throws UnsupportedEncodingException; -} \ No newline at end of file +} diff --git a/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/service/qrcordrecord/QrcodeRecordServiceImpl.java b/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/service/qrcordrecord/QrcodeRecordServiceImpl.java index 5faf7bb29..2a6e193ab 100644 --- a/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/service/qrcordrecord/QrcodeRecordServiceImpl.java +++ b/yudao-module-common/yudao-module-common-biz/src/main/java/cn/iocoder/yudao/module/common/service/qrcordrecord/QrcodeRecordServiceImpl.java @@ -35,6 +35,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.time.LocalDate; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -335,6 +336,27 @@ public class QrcodeRecordServiceImpl implements QrcodeRecordService { } + @Override + public Map selectQrcodeUrlMapByBizTypeAndIds(String bizType, Collection bizIds) { + if (StrUtil.isBlank(bizType) || bizIds == null || bizIds.isEmpty()) { + return new HashMap<>(); + } + + List records = qrcodeRecordMapper.selectList(Wrappers.lambdaQuery() + .eq(QrcodeRecordDO::getBizType, bizType) + .in(QrcodeRecordDO::getBizId, bizIds) + .eq(QrcodeRecordDO::getStatus, 1) + .orderByDesc(QrcodeRecordDO::getId)); + + return records.stream() + .filter(record -> StrUtil.isNotBlank(record.getQrcodeFileUrl())) + .collect(Collectors.toMap( + QrcodeRecordDO::getBizId, + QrcodeRecordDO::getQrcodeFileUrl, + (first, second) -> first + )); + } + @Override public Map resolveScanBizId(String type, Long id, String code) { Map result = new HashMap<>(); @@ -602,4 +624,4 @@ public class QrcodeRecordServiceImpl implements QrcodeRecordService { } -} \ No newline at end of file +} diff --git a/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java b/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java index 2a20f5860..2e6f7a761 100644 --- a/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java +++ b/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java @@ -205,4 +205,12 @@ public interface ErrorCodeConstants { ErrorCode PRINT_TEMPLATE_CODE_EXISTS = new ErrorCode(100_401_0001, "模板编码已存在,请重新提交"); ErrorCode PRINT_TEMPLATE_TYPE_EXISTS = new ErrorCode(100_401_0002, "该模板类型已存在模板,请勿重复新增"); + // ========== 设备产线 相关 100_501_0000 ========== + ErrorCode DEVICE_LINE_NOT_EXISTS = new ErrorCode(100_501_0001, "设备产线不存在"); + ErrorCode DEVICE_LINE_PARENT_NOT_EXISTS = new ErrorCode(100_501_0002, "父级设备产线不存在"); + ErrorCode DEVICE_LINE_PARENT_IS_SELF = new ErrorCode(100_501_0003, "不能设置自己为父级"); + ErrorCode DEVICE_LINE_PARENT_IS_CHILD = new ErrorCode(100_501_0004, "不能设置子节点为父级"); + ErrorCode DEVICE_LINE_EXITS_CHILDREN = new ErrorCode(100_501_0005, "存在子设备产线,无法删除"); + ErrorCode DEVICE_LINE_CODE_EXISTS = new ErrorCode(100_501_0006, "设备产线编码已存在,请重新提交"); + ErrorCode DEVICE_LINE_CODE_NOT_EXISTS = new ErrorCode(100_501_0007, "设备产线编码不能为空"); } diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerPageReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerPageReqVO.java index 3a856b28b..4d7073201 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerPageReqVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerPageReqVO.java @@ -7,6 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -41,6 +42,12 @@ public class DeviceLedgerPageReqVO extends PageParam { @Schema(description = "设备类型", example = "1") private Long deviceType; + @Schema(description = "设备产线", example = "1") + private Integer deviceLine; + + @Schema(description = "设备产线集合") + private List deviceLineIds; + @Schema(description = "供应商") private String supplier; @@ -92,4 +99,4 @@ public class DeviceLedgerPageReqVO extends PageParam { @Schema(description = "产品Id") private Long productId; -} \ No newline at end of file +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerRespVO.java index d97992e55..d3af35ea0 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerRespVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerRespVO.java @@ -44,6 +44,9 @@ public class DeviceLedgerRespVO extends BaseDO { @Schema(description = "设备类型") private String deviceType; + @Schema(description = "设备产线") + private Integer deviceLine; + @Schema(description = "设备类型名称", example = "1") @ExcelProperty("类型") private String typeName; @@ -172,4 +175,4 @@ public class DeviceLedgerRespVO extends BaseDO { @Schema(description = "打印模板") private String templateJson; -} \ No newline at end of file +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerSaveReqVO.java index b19be7192..64ab9ef0a 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerSaveReqVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceledger/vo/DeviceLedgerSaveReqVO.java @@ -37,6 +37,9 @@ public class DeviceLedgerSaveReqVO { @Schema(description = "设备类型", example = "1") private String deviceType; + @Schema(description = "设备产线", example = "1") + private Integer deviceLine; + @Schema(description = "供应商") private String supplier; @@ -93,4 +96,4 @@ public class DeviceLedgerSaveReqVO { @Schema(description = "数据采集产能") private Integer dataCollectionCapacity; -} \ No newline at end of file +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/DeviceLineController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/DeviceLineController.java new file mode 100644 index 000000000..8a9483b5e --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/DeviceLineController.java @@ -0,0 +1,210 @@ +package cn.iocoder.yudao.module.mes.controller.admin.deviceline; + +import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum; +import cn.iocoder.yudao.module.common.service.qrcordrecord.QrcodeRecordService; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.io.IOException; +import java.util.stream.Collectors; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.deviceline.DeviceLineDO; +import cn.iocoder.yudao.module.mes.service.deviceline.DeviceLineService; + +@Tag(name = "管理后台 - 设备产线") +@RestController +@RequestMapping("/mes/device-line") +@Validated +public class DeviceLineController { + + @Resource + private DeviceLineService deviceLineService; + @Resource + private QrcodeRecordService qrcodeService; + + @PostMapping("/create") + @Operation(summary = "创建设备产线") + @PreAuthorize("@ss.hasPermission('mes:device-line:create')") + public CommonResult createDeviceLine(@Valid @RequestBody DeviceLineSaveReqVO createReqVO) throws UnsupportedEncodingException { + return success(deviceLineService.createDeviceLine(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新设备产线") + @PreAuthorize("@ss.hasPermission('mes:device-line:update')") + public CommonResult updateDeviceLine(@Valid @RequestBody DeviceLineSaveReqVO updateReqVO) { + deviceLineService.updateDeviceLine(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除设备产线") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:device-line:delete')") + public CommonResult deleteDeviceLine(@RequestParam("id") Long id) { + deviceLineService.deleteDeviceLine(id); + return success(true); + } + + @DeleteMapping("/delete-batch") + @Operation(summary = "批量删除设备产线") + @PreAuthorize("@ss.hasPermission('mes:device-line:delete')") + public CommonResult deleteDeviceLineBatch(@RequestParam("ids") List ids) { + deviceLineService.deleteDeviceLineBatch(ids); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得设备产线") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('mes:device-line:query')") + public CommonResult getDeviceLine(@RequestParam("id") Long id) { + DeviceLineDO deviceLine = deviceLineService.getDeviceLine(id); + DeviceLineRespVO deviceLineRespVO = BeanUtils.toBean(deviceLine, DeviceLineRespVO.class); + String qrcodeUrl = qrcodeService.selectQrcodeUrlByIdAndCode(QrcodeBizTypeEnum.DEVICE_LINE.getCode(),id,deviceLine.getCode()); + deviceLineRespVO.setQrcodeUrl(qrcodeUrl); + return success(deviceLineRespVO); + } + + @GetMapping("/page") + @Operation(summary = "获得设备产线分页") + @PreAuthorize("@ss.hasPermission('mes:device-line:query')") + public CommonResult> getDeviceLinePage(@Valid DeviceLinePageReqVO pageReqVO) { + PageResult pageResult = deviceLineService.getDeviceLinePage(pageReqVO); + PageResult respVOPageResult = BeanUtils.toBean(pageResult, DeviceLineRespVO.class); +//添加二维码和打印模板 +// if (respVOPageResult.getList() != null && !respVOPageResult.getList().isEmpty()) { +// String template = deviceLineService.selectPrintTemplate(); +// Map qrcodeUrlMap = qrcodeService.selectQrcodeUrlMapByBizTypeAndIds( +// QrcodeBizTypeEnum.DEVICE_LINE.getCode(), +// respVOPageResult.getList().stream().map(DeviceLineRespVO::getId).collect(Collectors.toList())); +// for (DeviceLineRespVO deviceLineRespVO : respVOPageResult.getList()) { +// deviceLineRespVO.setQrcodeUrl(qrcodeUrlMap.get(deviceLineRespVO.getId())); +// deviceLineRespVO.setTemplateJson(template); +// } +// } + return success(respVOPageResult); + } + + @GetMapping("/list") + @Operation(summary = "获得设备产线列表") + @PreAuthorize("@ss.hasPermission('mes:device-line:query')") + public CommonResult> getDeviceLineList(@Valid DeviceLineListReqVO listReqVO) { + List list = deviceLineService.getDeviceLineList(listReqVO); + return success(BeanUtils.toBean(list, DeviceLineRespVO.class)); + } + + @GetMapping("/tree") + @Operation(summary = "获得设备产线树") + @PreAuthorize("@ss.hasPermission('mes:device-line:query')") + public CommonResult> getDeviceLineTree(@Valid DeviceLineListReqVO pageReqVO) { + List tree = deviceLineService.getDeviceLineTree(pageReqVO); + + if (tree != null && !tree.isEmpty()) { + String template = deviceLineService.selectPrintTemplate(); + List allNodes = new ArrayList<>(tree); + for (int i = 0; i < allNodes.size(); i++) { + List children = allNodes.get(i).getChildren(); + if (children != null && !children.isEmpty()) { + allNodes.addAll(children); + } + } + + List ids = allNodes.stream().map(DeviceLineRespVO::getId).collect(Collectors.toList()); + Map qrcodeUrlMap = qrcodeService.selectQrcodeUrlMapByBizTypeAndIds( + QrcodeBizTypeEnum.DEVICE_LINE.getCode(), + ids); + for (DeviceLineTreeRespVO deviceLineRespVO : allNodes) { + deviceLineRespVO.setQrcodeUrl(qrcodeUrlMap.get(deviceLineRespVO.getId())); + deviceLineRespVO.setTemplateJson(template); + } + } + + return success(tree); + } + + @GetMapping("/children") + @Operation(summary = "获得子设备产线列表") + @Parameter(name = "parentId", description = "父级ID", required = true, example = "0") + @PreAuthorize("@ss.hasPermission('mes:device-line:query')") + public CommonResult> getChildrenDeviceLines(@RequestParam("parentId") Long parentId) { + List list = deviceLineService.getChildrenDeviceLines(parentId); + return success(BeanUtils.toBean(list, DeviceLineRespVO.class)); + } + + @GetMapping("/ancestors") + @Operation(summary = "获得祖先设备产线列表") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('mes:device-line:query')") + public CommonResult> getAncestorDeviceLines(@RequestParam("id") Long id) { + List list = deviceLineService.getAncestorDeviceLines(id); + return success(BeanUtils.toBean(list, DeviceLineRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出设备产线 Excel") + @PreAuthorize("@ss.hasPermission('mes:device-line:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDeviceLineExcel(@Valid DeviceLineListReqVO pageReqVO, + HttpServletResponse response) throws IOException { + + List deviceLineList = deviceLineService.getDeviceLineList(pageReqVO); + List deviceLineRespVOList = BeanUtils.toBean(deviceLineList, DeviceLineRespVO.class); + Map idToNameMap = deviceLineList.stream() + .collect(Collectors.toMap( + DeviceLineDO::getId, + DeviceLineDO::getName, + (v1, v2) -> v1 + )); + + for (DeviceLineRespVO deviceLineRespVO : deviceLineRespVOList) { + if (deviceLineRespVO.getParentId() != null && deviceLineRespVO.getParentId() > 0) { + deviceLineRespVO.setParentName(idToNameMap.getOrDefault(deviceLineRespVO.getParentId(), "")); + } else { + deviceLineRespVO.setParentName("顶级分类"); + } + } + + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + response.setHeader("Content-Disposition", + "attachment;filename=" + URLEncoder.encode("设备产线.xls", "UTF-8")); + response.setHeader("Content-Encoding", "identity"); + String fileName = String.format("设备产线_%s.xls", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); + ExcelUtils.write(response, fileName, "数据", DeviceLineRespVO.class, deviceLineRespVOList); + } + + + @PostMapping("/regenerate-code") + public CommonResult regenerateCode(@RequestParam("id") Long id, + @RequestParam("code") String code) throws UnsupportedEncodingException { + deviceLineService.regenerateCode(id, code); + return success(true); + + } + + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineListReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineListReqVO.java new file mode 100644 index 000000000..043281b10 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineListReqVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Schema(description = "管理后台 - 设备产线列表 Request VO") +public class DeviceLineListReqVO extends PageParam { + + @Schema(description = "父级ID") + private Long parentId; + + @Schema(description = "父级链") + private String parentChain; + + @Schema(description = "编码") + private String code; + + @Schema(description = "名称") + private String name; + + @Schema(description = "开始创建时间") + private String createStartTime; + + @Schema(description = "结束创建时间") + private String createEndTime; +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLinePageReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLinePageReqVO.java new file mode 100644 index 000000000..148c211bc --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLinePageReqVO.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 设备产线分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DeviceLinePageReqVO extends PageParam { + + @Schema(description = "编码") + private String code; + + @Schema(description = "名称", example = "李四") + private String name; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "排序") + private Integer sort; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "父id", example = "22428") + private Long parentId; + + @Schema(description = "父级路径") + private String parentChain; + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineRespVO.java new file mode 100644 index 000000000..44e5fe52b --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineRespVO.java @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 设备产线 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DeviceLineRespVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "13899") + @ExcelProperty("id") + private Long id; + + @Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("编码") + private String code; + + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @ExcelProperty("名称") + private String name; + + @Schema(description = "备注", example = "你猜") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "排序") + @ExcelProperty("排序") + private Integer sort; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "父id", requiredMode = Schema.RequiredMode.REQUIRED, example = "22428") + @ExcelProperty("父id") + private Long parentId; + + @Schema(description = "父级名称", example = "顶级分类") + @ExcelProperty("父级名称") + private String parentName; + + @Schema(description = "父级路径", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("父级路径") + private String parentChain; + + @Schema(description = "二维码") + private String qrcodeUrl; + + @Schema(description = "打印模板") + private String templateJson; + + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineSaveReqVO.java new file mode 100644 index 000000000..3c07f5af9 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineSaveReqVO.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.*; + +@Schema(description = "管理后台 - 设备产线新增/修改 Request VO") +@Data +public class DeviceLineSaveReqVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "13899") + private Long id; + + @Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED) +// @NotEmpty(message = "编码不能为空") + private String code; + + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @NotEmpty(message = "名称不能为空") + private String name; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "排序") + private Integer sort; + + @Schema(description = "父id", requiredMode = Schema.RequiredMode.REQUIRED, example = "22428") + @NotNull(message = "父id不能为空") + private Long parentId; + + @Schema(description = "父级路径", requiredMode = Schema.RequiredMode.REQUIRED) +// @NotEmpty(message = "父级路径不能为空") + private String parentChain; + + @Schema(description = "二维码") + private String qrcodeUrl; + + @Schema(description = "条形码") + private String barcodeUrl; + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineTreeRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineTreeRespVO.java new file mode 100644 index 000000000..181ca344f --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/deviceline/vo/DeviceLineTreeRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +@Schema(description = "管理后台 - 设备产线树形结构 Response VO") +public class DeviceLineTreeRespVO extends DeviceLineRespVO { + + @Schema(description = "子设备产线列表") + private List children; + + @Schema(description = "是否叶子节点", example = "true") + private Boolean leaf = true; +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/deviceledger/DeviceLedgerDO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/deviceledger/DeviceLedgerDO.java index 4b22a0a6a..3c49a3105 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/deviceledger/DeviceLedgerDO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/deviceledger/DeviceLedgerDO.java @@ -66,6 +66,10 @@ public class DeviceLedgerDO extends BaseDO { * 设备类型 */ private Long deviceType; + /** + * 设备产线 + */ + private Integer deviceLine; /** * 供应商 */ @@ -207,4 +211,4 @@ public class DeviceLedgerDO extends BaseDO { -} \ No newline at end of file +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/deviceline/DeviceLineDO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/deviceline/DeviceLineDO.java new file mode 100644 index 000000000..d60420c43 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/deviceline/DeviceLineDO.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.deviceline; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 设备产线 DO + * + * @author 必硕智能 + */ +@TableName("mes_device_line") +@KeySequence("mes_device_line_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeviceLineDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 编码 + */ + private String code; + /** + * 名称 + */ + private String name; + /** + * 备注 + */ + private String remark; + /** + * 排序 + */ + private Integer sort; + /** + * 父id + */ + private Long parentId; + /** + * 父级路径 + */ + private String parentChain; + + @TableField(exist = false) + private String qrcodeUrl; + + @TableField(exist = false) + private String barcodeUrl; + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceledger/DeviceLedgerMapper.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceledger/DeviceLedgerMapper.java index bf4057277..18a359a77 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceledger/DeviceLedgerMapper.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceledger/DeviceLedgerMapper.java @@ -43,6 +43,12 @@ public interface DeviceLedgerMapper extends BaseMapperX { .betweenIfPresent(DeviceLedgerDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(DeviceLedgerDO::getCreateTime); + if (reqVO.getDeviceLineIds() != null && !reqVO.getDeviceLineIds().isEmpty()) { + deviceLedgerDOLambdaQueryWrapperX.in(DeviceLedgerDO::getDeviceLine, reqVO.getDeviceLineIds()); + } else { + deviceLedgerDOLambdaQueryWrapperX.eqIfPresent(DeviceLedgerDO::getDeviceLine, reqVO.getDeviceLine()); + } + // 单独处理 ids 条件 if (StringUtils.isNotBlank(reqVO.getIds())) { List idList = Arrays.stream(reqVO.getIds().split(",")) @@ -60,4 +66,4 @@ public interface DeviceLedgerMapper extends BaseMapperX { DeviceLedgerDO selectByIdWithDeleted(@Param("id") Long id); String selectPrintTemplate(); -} \ No newline at end of file +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceline/DeviceLineMapper.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceline/DeviceLineMapper.java new file mode 100644 index 000000000..8ed908c18 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceline/DeviceLineMapper.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.deviceline; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.mes.dal.dataobject.deviceline.DeviceLineDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo.*; + +/** + * 设备产线 Mapper + * + * @author 必硕智能 + */ +@Mapper +public interface DeviceLineMapper extends BaseMapperX { + + default PageResult selectPage(DeviceLinePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DeviceLineDO::getParentId, reqVO.getParentId()) + .likeIfPresent(DeviceLineDO::getParentChain, reqVO.getParentChain()) + .eqIfPresent(DeviceLineDO::getCode, reqVO.getCode()) + .likeIfPresent(DeviceLineDO::getName, reqVO.getName()) + .eqIfPresent(DeviceLineDO::getRemark, reqVO.getRemark()) + .eqIfPresent(DeviceLineDO::getSort, reqVO.getSort()) + .betweenIfPresent(DeviceLineDO::getCreateTime, reqVO.getCreateTime()) + .orderByAsc(DeviceLineDO::getSort) + .orderByDesc(DeviceLineDO::getId)); + } + + default List selectList(DeviceLineListReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(DeviceLineDO::getParentId, reqVO.getParentId()) + .likeIfPresent(DeviceLineDO::getParentChain, reqVO.getParentChain()) + .likeIfPresent(DeviceLineDO::getCode, reqVO.getCode()) + .likeIfPresent(DeviceLineDO::getName, reqVO.getName()) + .betweenIfPresent(DeviceLineDO::getCreateTime, reqVO.getCreateStartTime(), reqVO.getCreateEndTime()) + .orderByAsc(DeviceLineDO::getSort) + .orderByDesc(DeviceLineDO::getId)); + } + + String selectPrintTemplate(); +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceledger/DeviceLedgerServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceledger/DeviceLedgerServiceImpl.java index fddd7fd52..9bb127304 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceledger/DeviceLedgerServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceledger/DeviceLedgerServiceImpl.java @@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceDO; import cn.iocoder.yudao.module.iot.service.device.DeviceService; import cn.iocoder.yudao.module.iot.service.device.TDengineService; import cn.iocoder.yudao.module.mes.dal.dataobject.devicetype.DeviceTypeDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.deviceline.DeviceLineDO; import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO; import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; @@ -33,6 +34,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.dvrepair.DvRepairMapper; import cn.iocoder.yudao.module.mes.dal.mysql.ticketresults.TicketResultsMapper; import cn.iocoder.yudao.module.mes.dal.mysql.workreportplan.ReportPlanSummaryMapper; import cn.iocoder.yudao.module.mes.service.organization.OrganizationService; +import cn.iocoder.yudao.module.mes.service.deviceline.DeviceLineService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -121,6 +123,10 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService { @Lazy private OrganizationMapper organizationMapper; + @Resource + @Lazy + private DeviceLineService deviceLineService; + @Resource private ErpProductUnitService productUnitService; @@ -346,6 +352,15 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService { @Override public PageResult getDeviceLedgerPage(DeviceLedgerPageReqVO pageReqVO) { + if (pageReqVO.getDeviceLine() != null) { + Set deviceLineIds = new LinkedHashSet<>(); + collectDeviceLineIds(Long.valueOf(pageReqVO.getDeviceLine()), deviceLineIds); + if (deviceLineIds.isEmpty()) { + return new PageResult<>(Collections.emptyList(), 0L); + } + pageReqVO.setDeviceLineIds(new ArrayList<>(deviceLineIds)); + } + if(pageReqVO.getProductId() != null ){ List relList = productDeviceRelMapper.selectList( Wrappers.lambdaQuery() @@ -372,6 +387,24 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService { return deviceLedgerDOPageResult; } + private void collectDeviceLineIds(Long deviceLineId, Set results) { + if (deviceLineId == null) { + return; + } + DeviceLineDO deviceLine = deviceLineService.getDeviceLine(deviceLineId); + if (deviceLine == null) { + return; + } + results.add(deviceLineId.intValue()); + List children = deviceLineService.getChildrenDeviceLines(deviceLineId); + if (CollUtil.isEmpty(children)) { + return; + } + for (DeviceLineDO child : children) { + collectDeviceLineIds(child.getId(), results); + } + } + @Override public PageResult getDeviceCapacityReportPage(DeviceCapacityReportPageReqVO pageReqVO) { DeviceLedgerPageReqVO queryReqVO = buildDeviceCapacityQuery(pageReqVO); diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceline/DeviceLineService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceline/DeviceLineService.java new file mode 100644 index 000000000..99dd74c28 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceline/DeviceLineService.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.mes.service.deviceline; + +import java.io.UnsupportedEncodingException; +import java.util.*; +import cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.deviceline.DeviceLineDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.validation.Valid; + +/** + * 设备产线 Service 接口 + * + * @author 必硕智能 + */ +public interface DeviceLineService { + + Long createDeviceLine(@Valid DeviceLineSaveReqVO createReqVO) throws UnsupportedEncodingException; + + void updateDeviceLine(@Valid DeviceLineSaveReqVO updateReqVO); + + void deleteDeviceLine(Long id); + + void deleteDeviceLineBatch(List ids); + + DeviceLineDO getDeviceLine(Long id); + + PageResult getDeviceLinePage(DeviceLinePageReqVO pageReqVO); + + List getDeviceLineList(DeviceLineListReqVO listReqVO); + + List getDeviceLineTree(DeviceLineListReqVO listReqVO); + + List getChildrenDeviceLines(Long parentId); + + List getAncestorDeviceLines(Long id); + + void regenerateCode(Long id, String code) throws UnsupportedEncodingException; + + String selectPrintTemplate(); +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceline/DeviceLineServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceline/DeviceLineServiceImpl.java new file mode 100644 index 000000000..b09df71b4 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/deviceline/DeviceLineServiceImpl.java @@ -0,0 +1,341 @@ +package cn.iocoder.yudao.module.mes.service.deviceline; + +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.module.common.enums.CodeTypeEnum; +import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum; +import cn.iocoder.yudao.module.common.service.qrcordrecord.QrcodeRecordService; +import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil; +import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.io.UnsupportedEncodingException; +import java.util.*; +import java.util.stream.Collectors; +import cn.iocoder.yudao.module.mes.controller.admin.deviceline.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.deviceline.DeviceLineDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.mes.dal.mysql.deviceline.DeviceLineMapper; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; + +/** + * 设备产线 Service 实现类 + * + * @author 必硕智能 + */ +@Service +@Validated +@Slf4j +public class DeviceLineServiceImpl implements DeviceLineService { + + @Resource + private DeviceLineMapper deviceLineMapper; + + @Autowired + private AutoCodeUtil autoCodeUtil; + + @Resource + private QrcodeRecordService qrcodeService; + + @Override + public Long createDeviceLine(DeviceLineSaveReqVO createReqVO) throws UnsupportedEncodingException { + validateParentDeviceLine(createReqVO.getParentId()); + if (StringUtils.isBlank(createReqVO.getCode())) { + createReqVO.setCode(autoCodeUtil.genSerialCode("DEVICE_LINE_GENERATE", null)); + } + validateCodeOnly(createReqVO.getCode()); + DeviceLineDO deviceLine = BeanUtils.toBean(createReqVO, DeviceLineDO.class); + + if (createReqVO.getParentId() != null && createReqVO.getParentId() > 0) { + DeviceLineDO parent = getDeviceLine(createReqVO.getParentId()); + deviceLine.setParentChain(buildParentChain(parent)); + } else { + deviceLine.setParentChain(""); + } + + deviceLineMapper.insert(deviceLine); + updateChildrenParentChain(deviceLine); + + // 生成二维码 + CodeTypeEnum codeType = autoCodeUtil.queryCodeType("DEVICE_LINE_GENERATE"); + if (codeType==null){ + log.warn("[创建设备台账]未配置码类型,跳过生产,ruleCode={}","DEVICE_LINE_GENERATE"); + return deviceLine.getId(); + } + + qrcodeService.generateOrRefresh( + QrcodeBizTypeEnum.DEVICE_LINE, + deviceLine.getId(), + deviceLine.getCode(), + "DETAIL", + codeType + ); + + + + return deviceLine.getId(); + } + + private void validateCodeOnly(String code) { + if (StringUtils.isBlank(code)) { + return; + } + if (deviceLineMapper.exists(Wrappers.lambdaQuery() + .eq(DeviceLineDO::getCode, code))) { + throw exception(DEVICE_LINE_CODE_EXISTS); + } + } + + @Override + public void updateDeviceLine(DeviceLineSaveReqVO updateReqVO) { + DeviceLineDO deviceLineDO = deviceLineMapper.selectById(updateReqVO.getId()); + validateDeviceLineExists(deviceLineDO); + + Long count = deviceLineMapper.selectCount(new LambdaQueryWrapper() + .eq(DeviceLineDO::getCode, updateReqVO.getCode()) + .ne(DeviceLineDO::getId, updateReqVO.getId())); + if (count > 0) { + throw exception(DEVICE_LINE_CODE_EXISTS); + } + + validateParentDeviceLine(updateReqVO.getParentId()); + if (updateReqVO.getParentId() != null) { + validateNotChildOfSelf(updateReqVO.getId(), updateReqVO.getParentId()); + } + + DeviceLineDO oldDeviceLine = getDeviceLine(updateReqVO.getId()); + DeviceLineDO updateObj = BeanUtils.toBean(updateReqVO, DeviceLineDO.class); + + if (!Objects.equals(oldDeviceLine.getParentId(), updateReqVO.getParentId())) { + if (updateReqVO.getParentId() != null && updateReqVO.getParentId() > 0) { + DeviceLineDO parent = getDeviceLine(updateReqVO.getParentId()); + updateObj.setParentChain(buildParentChain(parent)); + } else { + updateObj.setParentChain(""); + } + + updateChildrenParentChain(updateObj); + } + + deviceLineMapper.updateById(updateObj); + } + + @Override + public void deleteDeviceLine(Long id) { + DeviceLineDO deviceLine = deviceLineMapper.selectById(id); + validateDeviceLineExists(deviceLine); + + if (hasChildren(id)) { + throw exception(DEVICE_LINE_EXITS_CHILDREN); + } + + deviceLineMapper.deleteById(id); + } + + @Override + public void deleteDeviceLineBatch(List ids) { + if (ids == null || ids.isEmpty()) { + return; + } + deviceLineMapper.deleteByIds(ids); + } + + private void validateDeviceLineExists(DeviceLineDO deviceLine) { + if (deviceLine == null) { + throw exception(DEVICE_LINE_NOT_EXISTS); + } + } + + @Override + public DeviceLineDO getDeviceLine(Long id) { + return deviceLineMapper.selectById(id); + } + + @Override + public PageResult getDeviceLinePage(DeviceLinePageReqVO pageReqVO) { + return deviceLineMapper.selectPage(pageReqVO); + } + + @Override + public List getDeviceLineList(DeviceLineListReqVO listReqVO) { + return deviceLineMapper.selectList(listReqVO); + } + + @Override + public List getDeviceLineTree(DeviceLineListReqVO listReqVO) { + List allDeviceLines = deviceLineMapper.selectList(listReqVO); + return buildDeviceLineTree(allDeviceLines); + } + + @Override + public List getChildrenDeviceLines(Long parentId) { + List allDeviceLines = deviceLineMapper.selectList(Wrappers.lambdaQuery() + .eq(DeviceLineDO::getParentId, parentId)); + if (allDeviceLines == null || allDeviceLines.isEmpty()) { + return Collections.emptyList(); + } + return allDeviceLines.stream() + .sorted(Comparator.comparing(DeviceLineDO::getSort, + Comparator.nullsLast(Integer::compareTo)).thenComparing(DeviceLineDO::getId)) + .collect(Collectors.toList()); + } + + @Override + public List getAncestorDeviceLines(Long id) { + DeviceLineDO current = deviceLineMapper.selectById(id); + if (current == null) { + return Collections.emptyList(); + } + + List ancestors = new ArrayList<>(); + Long parentId = current.getParentId(); + while (parentId != null && parentId > 0) { + DeviceLineDO parent = deviceLineMapper.selectById(parentId); + if (parent == null) { + break; + } + ancestors.add(parent); + parentId = parent.getParentId(); + } + Collections.reverse(ancestors); + return ancestors; + } + + private List buildDeviceLineTree(List allDeviceLines) { + Map> childrenMap = CollectionUtils.convertMultiMap( + allDeviceLines, DeviceLineDO::getParentId); + + Map parentNameMap = allDeviceLines.stream() + .collect(Collectors.toMap( + DeviceLineDO::getId, + DeviceLineDO::getName, + (v1, v2) -> v1 + )); + + List rootDeviceLines = new ArrayList<>(childrenMap.getOrDefault(0L, Collections.emptyList())); + rootDeviceLines.addAll(childrenMap.getOrDefault(null, Collections.emptyList())); + + rootDeviceLines.sort(Comparator.comparing(DeviceLineDO::getSort, + Comparator.nullsLast(Integer::compareTo)).thenComparing(DeviceLineDO::getId)); + + return rootDeviceLines.stream() + .map(deviceLine -> convertToTree(deviceLine, childrenMap, parentNameMap)) + .collect(Collectors.toList()); + } + + private DeviceLineTreeRespVO convertToTree(DeviceLineDO deviceLine, + Map> childrenMap, + Map parentNameMap) { + DeviceLineTreeRespVO treeNode = BeanUtils.toBean(deviceLine, DeviceLineTreeRespVO.class); + + if (deviceLine.getParentId() != null && deviceLine.getParentId() > 0) { + treeNode.setParentName(parentNameMap.getOrDefault(deviceLine.getParentId(), "")); + } else { + treeNode.setParentName("顶级分类"); + } + + List children = childrenMap.getOrDefault(deviceLine.getId(), Collections.emptyList()); + if (!children.isEmpty()) { + children.sort(Comparator.comparing(DeviceLineDO::getSort, + Comparator.nullsLast(Integer::compareTo)).thenComparing(DeviceLineDO::getId)); + List childNodes = children.stream() + .map(child -> convertToTree(child, childrenMap, parentNameMap)) + .collect(Collectors.toList()); + treeNode.setChildren(childNodes); + treeNode.setLeaf(false); + } + return treeNode; + } + + private void validateParentDeviceLine(Long parentId) { + if (parentId != null && parentId > 0) { + if (deviceLineMapper.selectById(parentId) == null) { + throw exception(DEVICE_LINE_PARENT_NOT_EXISTS); + } + } + } + + private void validateNotChildOfSelf(Long id, Long parentId) { + if (id.equals(parentId)) { + throw exception(DEVICE_LINE_PARENT_IS_SELF); + } + + DeviceLineDO parent = getDeviceLine(parentId); + if (parent != null && parent.getParentChain() != null) { + String parentChain = parent.getParentChain(); + if (parentChain.contains("," + id + ",") + || parentChain.startsWith(id + ",") + || parentChain.endsWith("," + id)) { + throw exception(DEVICE_LINE_PARENT_IS_CHILD); + } + } + } + + private boolean hasChildren(Long id) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(DeviceLineDO::getParentId, id); + return deviceLineMapper.selectCount(queryWrapper) > 0; + } + + private String buildParentChain(DeviceLineDO parent) { + if (parent == null) { + return ""; + } + + StringBuilder chain = new StringBuilder(); + if (parent.getParentChain() != null && !parent.getParentChain().isEmpty()) { + chain.append(parent.getParentChain()).append(","); + } + chain.append(parent.getId()); + return chain.toString(); + } + + private void updateChildrenParentChain(DeviceLineDO deviceLine) { + List children = getChildrenDeviceLines(deviceLine.getId()); + for (DeviceLineDO child : children) { + String newParentChain = buildParentChain(deviceLine); + child.setParentChain(newParentChain); + deviceLineMapper.updateById(child); + updateChildrenParentChain(child); + } + } + + + + @Override + public void regenerateCode(Long id, String code) throws UnsupportedEncodingException { + if(deviceLineMapper.selectById(id)==null){ + throw exception(DEVICE_LINE_NOT_EXISTS); + } + if(StringUtils.isBlank(code)){ + throw exception(DEVICE_LINE_CODE_NOT_EXISTS); + } + + CodeTypeEnum codeGenerate = autoCodeUtil.queryCodeType("DEVICE_LINE_GENERATE"); + qrcodeService.regenerateByCodeType( + QrcodeBizTypeEnum.DEVICE_LINE, + id, + code, + "DETAIL", + codeGenerate.getCode() + ); + + } + + @Override + public String selectPrintTemplate() { + return deviceLineMapper.selectPrintTemplate(); + } + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/deviceline/DeviceLineMapper.xml b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/deviceline/DeviceLineMapper.xml new file mode 100644 index 000000000..4926c395c --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/deviceline/DeviceLineMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthPermissionInfoRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthPermissionInfoRespVO.java index 2ce6df79c..46c9adbca 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthPermissionInfoRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthPermissionInfoRespVO.java @@ -96,6 +96,9 @@ public class AuthPermissionInfoRespVO { */ private List children; + @Schema(description = "终端类型(菜单设置为app时) 1-移动端 2-扫码器") + private Integer terminalType; + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuRespVO.java index e212f0112..037707cbf 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuRespVO.java @@ -76,4 +76,6 @@ public class MenuRespVO { @Schema(description = "菜单端类型,参见 MenuClientTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private Integer clientType; + @Schema(description = "终端类型(菜单设置为app时) 1-移动端 2-扫码器", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer terminalType; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java index 77132712e..a558ae841 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java @@ -71,4 +71,7 @@ public class MenuSaveVO { @NotNull(message = "菜单端类型不能为空") private Integer clientType = MenuClientTypeEnum.WEB.getType(); + @Schema(description = "终端类型(菜单设置为app时) 1-移动端 2-扫码器", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer terminalType; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSimpleRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSimpleRespVO.java index ad1c141cb..36be19c0a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSimpleRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSimpleRespVO.java @@ -29,4 +29,6 @@ public class MenuSimpleRespVO { @Schema(description = "菜单端类型,参见 MenuClientTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private Integer clientType; + @Schema(description = "终端类型(菜单设置为app时) 1-移动端 2-扫码器", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer terminalType; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java index 5d2a157b7..bd7a624fc 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java @@ -53,6 +53,7 @@ public interface AuthConvert { .alwaysShow(menu.getAlwaysShow()) .enName(menu.getEnName()) .type(menu.getType()) + .terminalType(menu.getTerminalType()) .build(); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/MenuDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/MenuDO.java index a884085e4..831c1efd5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/MenuDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/MenuDO.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.system.enums.permission.MenuTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -116,5 +117,9 @@ public class MenuDO extends BaseDO { */ private Integer clientType; + /** + * 终端类型(菜单设置为app时)1-移动端 2-扫码器 + */ + private Integer terminalType; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java index 07e8a485c..fc2003e83 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java @@ -15,11 +15,12 @@ public interface MenuMapper extends BaseMapperX { return selectOne(MenuDO::getParentId, parentId, MenuDO::getName, name); } - default MenuDO selectByParentIdAndNameAndClientType(Long parentId, String name, Integer clientType) { + default MenuDO selectByParentIdAndNameAndClientType(Long parentId, String name, Integer clientType, Integer terminalType) { return selectOne(new LambdaQueryWrapperX() .eq(MenuDO::getParentId, parentId) .eq(MenuDO::getName, name) - .eq(MenuDO::getClientType, clientType)); + .eq(MenuDO::getClientType, clientType) + .eq(MenuDO::getTerminalType,terminalType)); } default Long selectCountByParentId(Long parentId) { diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java index f9df41b8d..7cea4d8f6 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java @@ -55,7 +55,7 @@ public class MenuServiceImpl implements MenuService { // 校验父菜单存在 validateParentMenu(createReqVO.getParentId(), createReqVO.getClientType(), null); // 校验菜单(自己) - validateMenu(createReqVO.getParentId(), createReqVO.getName(), createReqVO.getClientType(), null); + validateMenu(createReqVO.getParentId(), createReqVO.getName(), createReqVO.getClientType(), null,createReqVO.getTerminalType()); // 插入数据库 MenuDO menu = BeanUtils.toBean(createReqVO, MenuDO.class); @@ -77,7 +77,7 @@ public class MenuServiceImpl implements MenuService { // 校验父菜单存在 validateParentMenu(updateReqVO.getParentId(), updateReqVO.getClientType(), updateReqVO.getId()); // 校验菜单(自己) - validateMenu(updateReqVO.getParentId(), updateReqVO.getName(), updateReqVO.getClientType(), updateReqVO.getId()); + validateMenu(updateReqVO.getParentId(), updateReqVO.getName(), updateReqVO.getClientType(), updateReqVO.getId(),updateReqVO.getTerminalType()); // 更新到数据库 MenuDO updateObj = BeanUtils.toBean(updateReqVO, MenuDO.class); @@ -238,8 +238,8 @@ public class MenuServiceImpl implements MenuService { * @param id 菜单编号 */ @VisibleForTesting - void validateMenu(Long parentId, String name, Integer clientType, Long id) { - MenuDO menu = menuMapper.selectByParentIdAndNameAndClientType(parentId, name, clientType); + void validateMenu(Long parentId, String name, Integer clientType, Long id,Integer terminalType) { + MenuDO menu = menuMapper.selectByParentIdAndNameAndClientType(parentId, name, clientType,terminalType); if (menu == null) { return; } diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java index 4a1c87386..c21e97c18 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java @@ -244,20 +244,20 @@ public class MenuServiceImplTest extends BaseDbUnitTest { Long parentId = menuDO.getId(); // 调用,无需断言 - menuService.validateParentMenu(parentId, null); + menuService.validateParentMenu(parentId, null,null); } @Test public void testValidateParentMenu_canNotSetSelfToBeParent() { // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(1L, 1L), + assertServiceException(() -> menuService.validateParentMenu(1L, null,1L), MENU_PARENT_ERROR); } @Test public void testValidateParentMenu_parentNotExist() { // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(randomLongId(), null), + assertServiceException(() -> menuService.validateParentMenu(randomLongId(), null,null), MENU_PARENT_NOT_EXISTS); } @@ -270,7 +270,7 @@ public class MenuServiceImplTest extends BaseDbUnitTest { Long parentId = menuDO.getId(); // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(parentId, null), + assertServiceException(() -> menuService.validateParentMenu(parentId, null,null), MENU_PARENT_NOT_DIR_OR_MENU); } @@ -284,7 +284,7 @@ public class MenuServiceImplTest extends BaseDbUnitTest { String otherSonMenuName = randomString(); // 调用,无需断言 - menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId); + menuService.validateMenu(parentId, otherSonMenuName, null,otherSonMenuId,null); } @Test @@ -297,7 +297,7 @@ public class MenuServiceImplTest extends BaseDbUnitTest { String otherSonMenuName = sonMenu.getName(); //相同名称 // 调用,并断言异常 - assertServiceException(() -> menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId), + assertServiceException(() -> menuService.validateMenu(parentId, otherSonMenuName,null, otherSonMenuId,null), MENU_NAME_DUPLICATE); }