From 95a8fc0fb74e2d9154c6f9dd21e396c068a71125 Mon Sep 17 00:00:00 2001 From: zch Date: Mon, 20 Jan 2025 11:28:53 +0800 Subject: [PATCH] =?UTF-8?q?change(hwmom-mes):=E4=BC=98=E5=8C=96=E7=89=A9?= =?UTF-8?q?=E6=96=99=E7=B1=BB=E5=9E=8B=E5=92=8C=E8=AE=A1=E9=87=8F=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E4=BF=A1=E6=81=AF=E7=9A=84=E6=8F=92=E5=85=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91,=E4=BD=BF=E7=94=A8=20ObjectUtils.isNotEmpty()=20?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=E7=A9=BA=E5=80=BC=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/BaseMaterialTypeServiceImpl.java | 14 +++++++++++++- .../impl/BaseMeasurementUnitInfoServiceImpl.java | 6 ++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMaterialTypeServiceImpl.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMaterialTypeServiceImpl.java index 440f790..7ac3ae5 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMaterialTypeServiceImpl.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMaterialTypeServiceImpl.java @@ -1,5 +1,6 @@ package org.dromara.mes.service.impl; +import org.apache.commons.lang3.ObjectUtils; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; @@ -87,6 +88,17 @@ public class BaseMaterialTypeServiceImpl implements IBaseMaterialTypeService { public Boolean insertByBo(BaseMaterialTypeBo bo) { BaseMaterialType add = MapstructUtils.convert(bo, BaseMaterialType.class); validEntityBeforeSave(add); + + //获取父节点信息 + BaseMaterialTypeVo query = baseMapper.selectVoById(bo.getParentId()); + if (ObjectUtils.isNotEmpty(query)) { + //若父节点不为空,则将父节点的ancestors拼接父节点id拼接成ancestors + add.setAncestors(query.getAncestors() + "," + bo.getParentId()); + }else{ + //若父节点为空,则ancestors仅有父节点id + add.setAncestors(bo.getParentId().toString()); + } + boolean flag = baseMapper.insert(add) > 0; if (flag) { bo.setMatrialTypeId(add.getMatrialTypeId()); @@ -135,7 +147,7 @@ public class BaseMaterialTypeServiceImpl implements IBaseMaterialTypeService { if(isValid){ //TODO 做一些业务上的校验,判断是否需要校验 for (Long id : ids) { - //TODO 校验是否需要删除 + //监测删除的节点是否有子节点 BaseMaterialType query = new BaseMaterialType(); query.setParentId(id); if (baseMapper.selectCount(Wrappers.lambdaQuery(query)) > 0) { diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMeasurementUnitInfoServiceImpl.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMeasurementUnitInfoServiceImpl.java index 8d62ebd..df7f9e1 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMeasurementUnitInfoServiceImpl.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMeasurementUnitInfoServiceImpl.java @@ -1,5 +1,6 @@ package org.dromara.mes.service.impl; +import org.apache.commons.lang3.ObjectUtils; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; @@ -80,16 +81,17 @@ public class BaseMeasurementUnitInfoServiceImpl implements IBaseMeasurementUnitI public Boolean insertByBo(BaseMeasurementUnitInfoBo bo) { BaseMeasurementUnitInfo add = MapstructUtils.convert(bo, BaseMeasurementUnitInfo.class); validEntityBeforeSave(add); + // 获取父节点信息 BaseMeasurementUnitInfoVo query = baseMapper.selectVoById(bo.getParentId()); - - if (query != null) { + if (ObjectUtils.isNotEmpty(query)) { //若父节点不为空,则将父节点的ancestors拼接父节点id拼接成ancestors add.setAncestors(query.getAncestors() + "," + bo.getParentId()); }else{ //若父节点为空,则ancestors仅有父节点id add.setAncestors(bo.getParentId().toString()); } + boolean flag = baseMapper.insert(add) > 0; if (flag) { bo.setUnitId(add.getUnitId());