change(hwmom-mes):增加物料类型名称字段并实现关联查询

- 在 BaseMaterialInfo 模型中添加 matrialTypeName 字段
- 在 BaseMaterialInfoServiceImpl 服务中实现物料类型名称的关联查询
- 在 BaseMaterialInfoVo 视图中添加 matrialTypeName 属性
- 添加物料编码唯一性的校验逻辑
master
zch 5 days ago
parent ff86026d4f
commit de1391e701

@ -270,4 +270,11 @@ public class BaseMaterialInfo extends TenantEntity {
*/ */
@TableField(exist = false) @TableField(exist = false)
private String factoryName; //映射字段 private String factoryName; //映射字段
/**
*
*/
@TableField(exist = false)
private String matrialTypeName;//映射字段
} }

@ -375,4 +375,10 @@ public class BaseMaterialInfoVo implements Serializable {
@ExcelProperty(value = "所属工厂") @ExcelProperty(value = "所属工厂")
private String factoryName; private String factoryName;
/**
*
*/
@ExcelProperty(value = "物料类型名称")
private String matrialTypeName;//映射字段
} }

@ -1,5 +1,6 @@
package org.dromara.mes.service.impl; 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.MapstructUtils;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo; 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.github.yulichang.wrapper.MPJLambdaWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.mes.domain.BaseMaterialType;
import org.dromara.mes.domain.BaseMeasurementUnitInfo;
import org.dromara.mes.domain.ProdBaseFactoryInfo; import org.dromara.mes.domain.ProdBaseFactoryInfo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.dromara.mes.domain.bo.BaseMaterialInfoBo; import org.dromara.mes.domain.bo.BaseMaterialInfoBo;
@ -75,9 +78,21 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService {
MPJLambdaWrapper<BaseMaterialInfo> lqw = JoinWrappers.lambda(BaseMaterialInfo.class) MPJLambdaWrapper<BaseMaterialInfo> lqw = JoinWrappers.lambda(BaseMaterialInfo.class)
.selectAll(BaseMaterialInfo.class) .selectAll(BaseMaterialInfo.class)
// 关联查询工厂信息
.select(ProdBaseFactoryInfo::getFactoryName) .select(ProdBaseFactoryInfo::getFactoryName)
.leftJoin(ProdBaseFactoryInfo.class, ProdBaseFactoryInfo::getFactoryId, BaseMaterialInfo::getFactoryId) .leftJoin(ProdBaseFactoryInfo.class, ProdBaseFactoryInfo::getFactoryId, BaseMaterialInfo::getFactoryId)
//关联查询物料类型名称
.select(BaseMaterialType::getMatrialTypeName)
//注意"e":BaseMaterialType实体类中为matrialTypeIdBaseMaterialInfo实体类中为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(bo.getMaterialId() != null, BaseMaterialInfo::getMaterialId, bo.getMaterialId())
.eq(StringUtils.isNotBlank(bo.getErpId()), BaseMaterialInfo::getErpId, bo.getErpId()) .eq(StringUtils.isNotBlank(bo.getErpId()), BaseMaterialInfo::getErpId, bo.getErpId())
@ -166,6 +181,16 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService {
*/ */
private void validEntityBeforeSave(BaseMaterialInfo entity){ private void validEntityBeforeSave(BaseMaterialInfo entity){
//TODO 做一些数据校验,如唯一约束 //TODO 做一些数据校验,如唯一约束
if (StringUtils.isNotBlank(entity.getMaterialCode())) {
BaseMaterialInfoBo query = new BaseMaterialInfoBo();
query.setMaterialCode(entity.getMaterialCode());
MPJLambdaWrapper<BaseMaterialInfo> lqw = buildQueryWrapper(query);
BaseMaterialInfo baseMaterialInfo = baseMapper.selectOne(lqw);
if (baseMaterialInfo != null
&& !baseMaterialInfo.getMaterialId().equals(entity.getMaterialId())) {
throw new ServiceException("编码已存在");
}
}
} }
/** /**

Loading…
Cancel
Save