|
|
|
@ -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<BaseMaterialInfo> 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<BaseMaterialInfo> lqw = buildQueryWrapper(query);
|
|
|
|
|
BaseMaterialInfo baseMaterialInfo = baseMapper.selectOne(lqw);
|
|
|
|
|
if (baseMaterialInfo != null
|
|
|
|
|
&& !baseMaterialInfo.getMaterialId().equals(entity.getMaterialId())) {
|
|
|
|
|
throw new ServiceException("编码已存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|