|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.mixsmart.utils.FormulaUtils;
|
|
|
import com.mixsmart.utils.ListUtils;
|
|
|
import com.mixsmart.utils.RegexUtils;
|
|
@@ -73,6 +74,7 @@ import org.springblade.manager.mapper.ExcelTabMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
|
import org.springblade.manager.utils.*;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
+import org.springblade.manager.wrapper.ExcelTabWrapper;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -143,7 +145,79 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
@Override
|
|
|
public IPage<ExcelTabVO> selectExcelTabPage(IPage<ExcelTabVO> page, ExcelTabVO excelTab) {
|
|
|
- return page.setRecords(baseMapper.selectExcelTabPage(page, excelTab));
|
|
|
+ if (excelTab.getProjectId() != null && excelTab.getProjectId() > 0 && (excelTab.getParentId() == null || excelTab.getParentId() == 0)) {
|
|
|
+ List<ExcelTabVO> records = baseMapper.selectRootExcelTab(page, excelTab.getProjectId(), null);
|
|
|
+ if (!records.isEmpty()) {
|
|
|
+ List<Long> ids = records.stream().map(ExcelTabVO::getId).collect(Collectors.toList());
|
|
|
+ List<ExcelTab> excelTabs = this.listByIds(ids);
|
|
|
+ Map<Long, ExcelTab> map = excelTabs.stream().collect(toMap(ExcelTab::getId, v -> v));
|
|
|
+ records.forEach(v -> {
|
|
|
+ ProjectInfoVO1 projectInfoVO1 = new ProjectInfoVO1();
|
|
|
+ projectInfoVO1.setProjectId(v.getProjectId());
|
|
|
+ projectInfoVO1.setProjectName(v.getProjectName());
|
|
|
+ if (map.get(v.getId()) != null) {
|
|
|
+ BeanUtil.copyProperties(map.get(v.getId()), v);
|
|
|
+ }
|
|
|
+ v.setProjectInfoList(Collections.singletonList(projectInfoVO1));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return page.setRecords(records);
|
|
|
+ }
|
|
|
+ List<ExcelTabVO> records = baseMapper.selectExcelTabPage(page, excelTab);
|
|
|
+ if (!records.isEmpty() && (excelTab.getParentId() == null || excelTab.getParentId() == 0)) {
|
|
|
+ Set<Long> set = records.stream().map(ExcelTabVO::getId).collect(Collectors.toSet());
|
|
|
+ List<ExcelTabVO> projectInfoList = baseMapper.selectRootExcelTab(page, null, set);
|
|
|
+ Map<Long, List<ExcelTabVO>> collect = projectInfoList.stream().collect(Collectors.groupingBy(ExcelTabVO::getId));
|
|
|
+ records.forEach(v -> {
|
|
|
+ List<ExcelTabVO> excelTabVOS = collect.get(v.getId());
|
|
|
+ if (excelTabVOS != null) {
|
|
|
+ List<ProjectInfoVO1> list = excelTabVOS.stream().map(vo -> {
|
|
|
+ ProjectInfoVO1 projectInfoVO1 = new ProjectInfoVO1();
|
|
|
+ projectInfoVO1.setProjectId(vo.getProjectId());
|
|
|
+ projectInfoVO1.setProjectName(vo.getProjectName());
|
|
|
+ return projectInfoVO1;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ v.setProjectInfoList(list);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return page.setRecords(records);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExcelTabVO templateDetail(Long id) {
|
|
|
+ ExcelTab detail = this.getById(id);
|
|
|
+ if (detail == null) {
|
|
|
+ return new ExcelTabVO();
|
|
|
+ }
|
|
|
+ ExcelTabVO excelTabVO = ExcelTabWrapper.build().entityVO(detail);
|
|
|
+ if (detail.getParentId() != null && detail.getParentId() > 0) {
|
|
|
+ return excelTabVO;
|
|
|
+ }
|
|
|
+ Map<String, Object> map = jdbcTemplate.queryForMap("SELECT count(a.id) as total,count(t.id) as useNum from m_excel_tab a LEFT JOIN ( select excel_id as id from m_wbs_tree_private where type = 2 and is_deleted = 0 and excel_id is not null GROUP BY excel_id ) as t " +
|
|
|
+ "on a.id = t.id where a.is_deleted = 0 and file_type = 3 and alias like '" + id + "%'");
|
|
|
+ if (map.get("total") == null) {
|
|
|
+ excelTabVO.setTabCout(0);
|
|
|
+ } else {
|
|
|
+ excelTabVO.setTabCout(Integer.parseInt(map.get("total").toString()));
|
|
|
+ }
|
|
|
+ if (map.get("useNum") == null) {
|
|
|
+ excelTabVO.setExcelUseNumber(0);
|
|
|
+ } else {
|
|
|
+ excelTabVO.setExcelUseNumber(Integer.parseInt(map.get("useNum").toString()));
|
|
|
+ }
|
|
|
+ List<ExcelTabVO> projectInfoList = baseMapper.selectRootExcelTab(new Page<>(), null, Collections.singleton(id));
|
|
|
+ if (projectInfoList != null && !projectInfoList.isEmpty()) {
|
|
|
+ List<ProjectInfoVO1> list = projectInfoList.stream().map(vo -> {
|
|
|
+ ProjectInfoVO1 projectInfoVO1 = new ProjectInfoVO1();
|
|
|
+ projectInfoVO1.setProjectId(vo.getProjectId());
|
|
|
+ projectInfoVO1.setProjectName(vo.getProjectName());
|
|
|
+ return projectInfoVO1;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ excelTabVO.setProjectInfoList(list);
|
|
|
+ excelTabVO.setProjectUseNumber(list.size());
|
|
|
+ }
|
|
|
+ return excelTabVO;
|
|
|
}
|
|
|
|
|
|
@Override
|