|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
@ -20,9 +21,8 @@ import org.dromara.system.mapper.SysPrintTemplateNodeMapper;
|
|
|
|
|
import org.dromara.system.service.ISysPrintTemplateNodeService;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 打印节点信息Service业务层处理
|
|
|
|
|
@ -91,6 +91,7 @@ public class SysPrintTemplateNodeServiceImpl implements ISysPrintTemplateNodeSer
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getData()), SysPrintTemplateNode::getData, bo.getData())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getParentNode()), SysPrintTemplateNode::getParentNode, bo.getParentNode())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), SysPrintTemplateNode::getActiveFlag, bo.getActiveFlag())
|
|
|
|
|
.in(StringUtils.isNotNull(bo.getIds()), SysPrintTemplateNode::getId, bo.getIds())
|
|
|
|
|
.orderByAsc(SysPrintTemplateNode::getCreateTime);
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
@ -155,26 +156,51 @@ public class SysPrintTemplateNodeServiceImpl implements ISysPrintTemplateNodeSer
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public int updateNode(List<SysPrintTemplateNodeBo> bos) {
|
|
|
|
|
int i = 1;
|
|
|
|
|
for (SysPrintTemplateNodeBo bo : bos) {
|
|
|
|
|
String id = bo.getId();
|
|
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
|
|
throw new ServiceException(bo.getId() + "节点不可为空!");
|
|
|
|
|
}
|
|
|
|
|
SysPrintTemplateNodeBo selectNodeBo = new SysPrintTemplateNodeBo();
|
|
|
|
|
selectNodeBo.setId(bo.getId());
|
|
|
|
|
List<SysPrintTemplateNodeVo> nodeVos = this.queryList(selectNodeBo);
|
|
|
|
|
if (nodeVos.isEmpty()) {
|
|
|
|
|
throw new ServiceException(bo.getId() + "节点不存在!");
|
|
|
|
|
}
|
|
|
|
|
if (i == 1){
|
|
|
|
|
for (SysPrintTemplateNodeVo nodeVo : nodeVos) {
|
|
|
|
|
baseMapper.deleteById(nodeVo.getTemplateNodeId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
this.insertByBo(bo);
|
|
|
|
|
if (CollectionUtils.isEmpty(bos)) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
List<String> idList = bos.stream()
|
|
|
|
|
.map(bo -> {
|
|
|
|
|
String id = bo.getId();
|
|
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
|
|
throw new ServiceException("节点ID不可为空!");
|
|
|
|
|
}
|
|
|
|
|
return id;
|
|
|
|
|
})
|
|
|
|
|
.distinct()
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
List<SysPrintTemplateNodeVo> existingNodes = this.queryListByIds(idList);
|
|
|
|
|
Set<Long> templateNodeIds = existingNodes.stream()
|
|
|
|
|
.map(SysPrintTemplateNodeVo::getTemplateNodeId)
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
if (!templateNodeIds.isEmpty()) {
|
|
|
|
|
baseMapper.deleteByIds(templateNodeIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int insertCount = 0;
|
|
|
|
|
for (SysPrintTemplateNodeBo bo : bos) {
|
|
|
|
|
SysPrintTemplateNode add = MapstructUtils.convert(bo, SysPrintTemplateNode.class);
|
|
|
|
|
add.setTemplateNodeId(null);
|
|
|
|
|
if (baseMapper.insert(add) > 0) {
|
|
|
|
|
insertCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return insertCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量查询节点信息
|
|
|
|
|
*/
|
|
|
|
|
private List<SysPrintTemplateNodeVo> queryListByIds(List<String> ids) {
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
SysPrintTemplateNodeBo queryBo = new SysPrintTemplateNodeBo();
|
|
|
|
|
queryBo.setIds(ids);
|
|
|
|
|
return this.queryList(queryBo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|