diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/BaseMaterialInfo.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/BaseMaterialInfo.java index 2984590b..4cbf300c 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/BaseMaterialInfo.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/BaseMaterialInfo.java @@ -270,4 +270,11 @@ public class BaseMaterialInfo extends TenantEntity { */ @TableField(exist = false) private String factoryName; //映射字段 + + /** + * 物料类型名称 + */ + @TableField(exist = false) + private String matrialTypeName;//映射字段 + } diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/vo/BaseMaterialInfoVo.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/vo/BaseMaterialInfoVo.java index 5a3ea64e..1f7aa51a 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/vo/BaseMaterialInfoVo.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/vo/BaseMaterialInfoVo.java @@ -375,4 +375,10 @@ public class BaseMaterialInfoVo implements Serializable { @ExcelProperty(value = "所属工厂") private String factoryName; + /** + * 物料类型名称 + */ + @ExcelProperty(value = "物料类型名称") + private String matrialTypeName;//映射字段 + } diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMaterialInfoServiceImpl.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMaterialInfoServiceImpl.java index 3ba89f5e..c04469f7 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMaterialInfoServiceImpl.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/BaseMaterialInfoServiceImpl.java @@ -1,5 +1,6 @@ package org.dromara.mes.service.impl; +import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.TableDataInfo; @@ -9,6 +10,8 @@ import com.github.yulichang.toolkit.JoinWrappers; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; +import org.dromara.mes.domain.BaseMaterialType; +import org.dromara.mes.domain.BaseMeasurementUnitInfo; import org.dromara.mes.domain.ProdBaseFactoryInfo; import org.springframework.stereotype.Service; import org.dromara.mes.domain.bo.BaseMaterialInfoBo; @@ -75,9 +78,21 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService { MPJLambdaWrapper lqw = JoinWrappers.lambda(BaseMaterialInfo.class) .selectAll(BaseMaterialInfo.class) + // 关联查询工厂信息 .select(ProdBaseFactoryInfo::getFactoryName) .leftJoin(ProdBaseFactoryInfo.class, ProdBaseFactoryInfo::getFactoryId, BaseMaterialInfo::getFactoryId) + //关联查询物料类型名称 + .select(BaseMaterialType::getMatrialTypeName) + //注意"e":BaseMaterialType实体类中为matrialTypeId,BaseMaterialInfo实体类中为materialTypeId + .leftJoin(BaseMaterialType.class, BaseMaterialType::getMatrialTypeId, BaseMaterialInfo::getMaterialTypeId) + +/* //关联计量单位信息 + .select(BaseMeasurementUnitInfo::getUnitName) + .leftJoin(BaseMeasurementUnitInfo.class, BaseMeasurementUnitInfo::getUnitId, BaseMaterialInfo::getMaterialUnitId)*/ + + + .eq(bo.getMaterialId() != null, BaseMaterialInfo::getMaterialId, bo.getMaterialId()) .eq(StringUtils.isNotBlank(bo.getErpId()), BaseMaterialInfo::getErpId, bo.getErpId()) @@ -166,6 +181,16 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService { */ private void validEntityBeforeSave(BaseMaterialInfo entity){ //TODO 做一些数据校验,如唯一约束 + if (StringUtils.isNotBlank(entity.getMaterialCode())) { + BaseMaterialInfoBo query = new BaseMaterialInfoBo(); + query.setMaterialCode(entity.getMaterialCode()); + MPJLambdaWrapper lqw = buildQueryWrapper(query); + BaseMaterialInfo baseMaterialInfo = baseMapper.selectOne(lqw); + if (baseMaterialInfo != null + && !baseMaterialInfo.getMaterialId().equals(entity.getMaterialId())) { + throw new ServiceException("编码已存在"); + } + } } /**