package com.platform.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Maps; import com.platform.mapper.NodeMapper; import com.platform.model.dto.NodeDTO; import com.platform.model.entity.ExcelDataEntity; import com.platform.model.entity.NodeEntity; import com.platform.model.vo.ExcelDataVO; import com.platform.model.vo.NodeVO; import com.platform.service.ExcelDataService; import com.platform.service.NodeService; import com.platform.service.UserService; import com.platform.utils.DozerUtils; import org.apache.commons.compress.utils.Lists; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.*; @Service public class NodeServiceImpl extends ServiceImpl implements NodeService { @Resource private UserService userService; @Resource private ExcelDataService excelDataService; @Override public void saveData(Integer id, List nodes) { List nodeEntityList = DozerUtils.convertList(nodes, NodeEntity.class); nodeEntityList.forEach(nodeEntity -> nodeEntity.setCaseId(id)); saveBatch(nodeEntityList); } @Override public List queryByCaseId(Integer id) { return DozerUtils.convertList(baseMapper.selectList(new LambdaQueryWrapper() .eq(NodeEntity::getCaseId, id)), NodeVO.class); } @Override public List mchRelationUser(NodeDTO nodeDTO) { // 使用Set去重 Set uniqueNodes = new HashSet<>(); List excelDataEntityList = excelDataService.queryListByPayeeNameAndPayUserName(nodeDTO.getPayeeName(), nodeDTO.getCaseId()); excelDataEntityList.forEach(excelDataEntity -> { String payer = excelDataEntity.getPayUserName(); String payee = excelDataEntity.getPayeeName(); // 添加节点 uniqueNodes.add(payer); uniqueNodes.add(payee); }); //查看每个人的账号类型 List userNameList = new ArrayList<>(uniqueNodes); //查看每个人的账号标签 List excelDataEntityListNew = userService.queryUserLabel(userNameList, nodeDTO.getCaseId()); List result = Lists.newArrayList(); excelDataEntityListNew.forEach(excelDataVO -> { NodeVO person = new NodeVO(); person.setNode(excelDataVO.getPayUserName()); person.setNodeNum(excelDataVO.getNodeNum()); person.setLabel(excelDataVO.getLabel()); person.setNodeType("个人"); result.add(person); }); return result; } @Override public boolean deleteNode(String nodeName) { excelDataService.deleteByPayUserName(nodeName); excelDataService.deleteByPayeeName(nodeName); return true; } }