|
|
@ -1,5 +1,6 @@
|
|
|
|
package org.dromara.mes.service.impl;
|
|
|
|
package org.dromara.mes.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
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.BaseDeviceCategory;
|
|
|
|
|
|
|
|
import org.dromara.mes.domain.vo.BaseMaterialTypeVo;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.dromara.mes.domain.bo.BaseDeviceTypeBo;
|
|
|
|
import org.dromara.mes.domain.bo.BaseDeviceTypeBo;
|
|
|
|
import org.dromara.mes.domain.vo.BaseDeviceTypeVo;
|
|
|
|
import org.dromara.mes.domain.vo.BaseDeviceTypeVo;
|
|
|
@ -73,6 +76,11 @@ public class BaseDeviceTypeServiceImpl implements IBaseDeviceTypeService {
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
MPJLambdaWrapper<BaseDeviceType> lqw = JoinWrappers.lambda(BaseDeviceType.class)
|
|
|
|
MPJLambdaWrapper<BaseDeviceType> lqw = JoinWrappers.lambda(BaseDeviceType.class)
|
|
|
|
.selectAll(BaseDeviceType.class)
|
|
|
|
.selectAll(BaseDeviceType.class)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 关联查询设备大类信息
|
|
|
|
|
|
|
|
.select(BaseDeviceCategory::getDeviceCategoryName)
|
|
|
|
|
|
|
|
.leftJoin(BaseDeviceCategory.class,BaseDeviceCategory::getDeviceCategoryId,BaseDeviceType::getDeviceCategoryId)
|
|
|
|
|
|
|
|
|
|
|
|
.eq(bo.getDeviceTypeId() != null, BaseDeviceType::getDeviceTypeId, bo.getDeviceTypeId())
|
|
|
|
.eq(bo.getDeviceTypeId() != null, BaseDeviceType::getDeviceTypeId, bo.getDeviceTypeId())
|
|
|
|
.eq(bo.getParentId() != null, BaseDeviceType::getParentId, bo.getParentId())
|
|
|
|
.eq(bo.getParentId() != null, BaseDeviceType::getParentId, bo.getParentId())
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getDeviceTypeCode()), BaseDeviceType::getDeviceTypeCode, bo.getDeviceTypeCode())
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getDeviceTypeCode()), BaseDeviceType::getDeviceTypeCode, bo.getDeviceTypeCode())
|
|
|
@ -94,6 +102,15 @@ public class BaseDeviceTypeServiceImpl implements IBaseDeviceTypeService {
|
|
|
|
public Boolean insertByBo(BaseDeviceTypeBo bo) {
|
|
|
|
public Boolean insertByBo(BaseDeviceTypeBo bo) {
|
|
|
|
BaseDeviceType add = MapstructUtils.convert(bo, BaseDeviceType.class);
|
|
|
|
BaseDeviceType add = MapstructUtils.convert(bo, BaseDeviceType.class);
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
|
|
|
//获取父节点信息
|
|
|
|
|
|
|
|
BaseDeviceTypeVo 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;
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
if (flag) {
|
|
|
|
if (flag) {
|
|
|
|
bo.setDeviceTypeId(add.getDeviceTypeId());
|
|
|
|
bo.setDeviceTypeId(add.getDeviceTypeId());
|
|
|
|