|
|
|
@ -7,18 +7,18 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
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.dms.domain.DmsDeviceModeParameter;
|
|
|
|
|
import org.dromara.dms.mapper.DmsDeviceModeParameterMapper;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.dromara.dms.domain.bo.DmsDeviceModeFunctionBo;
|
|
|
|
|
import org.dromara.dms.domain.vo.DmsDeviceModeFunctionVo;
|
|
|
|
|
import org.dromara.dms.domain.DmsDeviceModeFunction;
|
|
|
|
|
import org.dromara.dms.mapper.DmsDeviceModeFunctionMapper;
|
|
|
|
|
import org.dromara.dms.service.IDmsDeviceModeFunctionService;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设备模型功能Service业务层处理
|
|
|
|
@ -32,6 +32,8 @@ public class DmsDeviceModeFunctionServiceImpl implements IDmsDeviceModeFunctionS
|
|
|
|
|
|
|
|
|
|
private final DmsDeviceModeFunctionMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
private final DmsDeviceModeParameterMapper dmsDeviceModeParameterMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询设备模型功能
|
|
|
|
|
*
|
|
|
|
@ -40,7 +42,24 @@ public class DmsDeviceModeFunctionServiceImpl implements IDmsDeviceModeFunctionS
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public DmsDeviceModeFunctionVo queryById(Long modeFunctionId) {
|
|
|
|
|
return baseMapper.selectVoById(modeFunctionId);
|
|
|
|
|
DmsDeviceModeFunctionVo modeFunctionVo = baseMapper.selectVoById(modeFunctionId);
|
|
|
|
|
MPJLambdaWrapper<DmsDeviceModeParameter> lqw = JoinWrappers.lambda(DmsDeviceModeParameter.class)
|
|
|
|
|
.selectAll(DmsDeviceModeParameter.class)
|
|
|
|
|
.eq(DmsDeviceModeParameter::getModeFunctionId, modeFunctionId);
|
|
|
|
|
List<DmsDeviceModeParameter> parameterList = dmsDeviceModeParameterMapper.selectList(lqw);
|
|
|
|
|
List<DmsDeviceModeParameter> inputParametersData = new ArrayList<>();
|
|
|
|
|
List<DmsDeviceModeParameter> outputParametersData = new ArrayList<>();
|
|
|
|
|
parameterList.forEach(e -> {
|
|
|
|
|
if (e.getParameterType().equals("1")) {
|
|
|
|
|
inputParametersData.add(e);
|
|
|
|
|
}
|
|
|
|
|
if (e.getParameterType().equals("2")) {
|
|
|
|
|
outputParametersData.add(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
modeFunctionVo.setInputParametersData(inputParametersData);
|
|
|
|
|
modeFunctionVo.setOutputParametersData(outputParametersData);
|
|
|
|
|
return modeFunctionVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -104,12 +123,27 @@ public class DmsDeviceModeFunctionServiceImpl implements IDmsDeviceModeFunctionS
|
|
|
|
|
* @return 是否新增成功
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean insertByBo(DmsDeviceModeFunctionBo bo) {
|
|
|
|
|
DmsDeviceModeFunction add = MapstructUtils.convert(bo, DmsDeviceModeFunction.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
bo.setModeFunctionId(add.getModeFunctionId());
|
|
|
|
|
List<DmsDeviceModeParameter> inputParametersDataList = bo.getInputParametersData();
|
|
|
|
|
List<DmsDeviceModeParameter> outputParametersDataList = bo.getOutputParametersData();
|
|
|
|
|
if (inputParametersDataList.size() > 0) {
|
|
|
|
|
inputParametersDataList.forEach(e -> {
|
|
|
|
|
e.setModeFunctionId(add.getModeFunctionId());
|
|
|
|
|
dmsDeviceModeParameterMapper.insert(e);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (outputParametersDataList.size() > 0) {
|
|
|
|
|
outputParametersDataList.forEach(e -> {
|
|
|
|
|
e.setModeFunctionId(add.getModeFunctionId());
|
|
|
|
|
dmsDeviceModeParameterMapper.insert(e);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
@ -121,9 +155,25 @@ public class DmsDeviceModeFunctionServiceImpl implements IDmsDeviceModeFunctionS
|
|
|
|
|
* @return 是否修改成功
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean updateByBo(DmsDeviceModeFunctionBo bo) {
|
|
|
|
|
DmsDeviceModeFunction update = MapstructUtils.convert(bo, DmsDeviceModeFunction.class);
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
assert update != null;
|
|
|
|
|
List<DmsDeviceModeParameter> inputParametersDataList = bo.getInputParametersData();
|
|
|
|
|
List<DmsDeviceModeParameter> outputParametersDataList = bo.getOutputParametersData();
|
|
|
|
|
if (inputParametersDataList.size() > 0) {
|
|
|
|
|
inputParametersDataList.forEach(e -> {
|
|
|
|
|
e.setModeFunctionId(update.getModeFunctionId());
|
|
|
|
|
dmsDeviceModeParameterMapper.insertOrUpdate(e);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (outputParametersDataList.size() > 0) {
|
|
|
|
|
outputParametersDataList.forEach(e -> {
|
|
|
|
|
e.setModeFunctionId(update.getModeFunctionId());
|
|
|
|
|
dmsDeviceModeParameterMapper.insertOrUpdate(e);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|