diff --git a/huzhou/pom.xml b/huzhou/pom.xml index fc29e6f..bc7b7d0 100644 --- a/huzhou/pom.xml +++ b/huzhou/pom.xml @@ -47,6 +47,12 @@ com.easy.admin easy-activiti + + + cn.afterturn + easypoi-spring-boot-starter + 4.4.0 + diff --git a/huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouProjectController.java b/huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouProjectController.java index e0ed3ba..3171fe3 100644 --- a/huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouProjectController.java +++ b/huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouProjectController.java @@ -301,23 +301,33 @@ public class HuzhouProjectController { @GetMapping("/getProjectSummaryPage") public Result getProjectSummaryPage(HuzhouProjectinfoOV projectinfo, @RequestParam(name="current", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ - IPage result = projectinfoService.getProjectSummaryPage(projectinfo,pageNo,pageSize); + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + @RequestParam(name="sortField", defaultValue="") String orderBy, + @RequestParam(name="sortOrder", defaultValue="") String orderDir){ + IPage result = projectinfoService.getProjectSummaryPage(projectinfo,pageNo,pageSize,orderBy,orderDir); return Result.ok(result); } @GetMapping("/getProjectSummaryPageByTask") public Result getProjectSummaryPageByTask(HuzhouProjectinfoOV projectinfo, @RequestParam(name="current", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ - IPage result = projectinfoService.getProjectSummaryPageByTask(projectinfo,pageNo,pageSize); + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + @RequestParam(name="sortField", defaultValue="") String orderBy, + @RequestParam(name="sortOrder", defaultValue="") String orderDir){ + IPage result = projectinfoService.getProjectSummaryPageByTask(projectinfo,pageNo,pageSize,orderBy,orderDir); return Result.ok(result); } @GetMapping("/getProjectDetailPage") public Result getProjectDetailPage(HuzhouProjectinfoOV projectinfo, @RequestParam(name="stage", defaultValue="") String stage, - @RequestParam(name="current", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ - IPage result = projectinfoService.getProjectDetailPage(projectinfo,stage, pageNo, pageSize); + @RequestParam(name="current", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + @RequestParam(name="sortField", defaultValue="") String orderBy, + @RequestParam(name="sortOrder", defaultValue="") String orderDir, + @RequestParam(name="projectStage", defaultValue="") String projectStage, + @RequestParam(name="stepName", defaultValue="") String stepName, + @RequestParam(name="isUpload", defaultValue="") String isUpload, + @RequestParam(name="isOffline", defaultValue="") String isOffline){ + IPage result = projectinfoService.getProjectDetailPage(projectinfo, pageNo, pageSize,orderBy,orderDir,projectStage,stepName,isUpload,isOffline); return Result.ok(result); } @GetMapping("/countStage") @@ -325,4 +335,9 @@ public class HuzhouProjectController { List result = projectinfoService.countStage(projectinfo); return Result.ok(result); } + @GetMapping("/import") + public Result tryImport(@RequestParam("file")MultipartFile file) throws Exception { + projectinfoService.updateTypeByImportFile(file); + return Result.ok("更新成功"); + }//测试的时候Body选择form-data,key写file,value选择需要导入的文件 } diff --git a/huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/HuzhouProjectinfoMapper.java b/huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/HuzhouProjectinfoMapper.java index 3a2190e..9b11155 100644 --- a/huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/HuzhouProjectinfoMapper.java +++ b/huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/HuzhouProjectinfoMapper.java @@ -89,4 +89,5 @@ public interface HuzhouProjectinfoMapper extends BaseMapper { Map getMoneyById(@Param("projectId") String projectId); List getIds(@Param("reformName") String reformName,@Param("superLeader") String superLeader); + } diff --git a/huzhou/src/main/java/com/easy/admin/modules/huzhou/service/IHuzhouProjectinfoService.java b/huzhou/src/main/java/com/easy/admin/modules/huzhou/service/IHuzhouProjectinfoService.java index c10f6c0..fa4a986 100644 --- a/huzhou/src/main/java/com/easy/admin/modules/huzhou/service/IHuzhouProjectinfoService.java +++ b/huzhou/src/main/java/com/easy/admin/modules/huzhou/service/IHuzhouProjectinfoService.java @@ -189,14 +189,17 @@ public interface IHuzhouProjectinfoService extends IService { FundByTypeOV countSupportingFound(); - IPage getProjectSummaryPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize); + IPage getProjectSummaryPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize,String orderBy,String orderDir); - IPage getProjectSummaryPageByTask(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize); + IPage getProjectSummaryPageByTask(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize,String orderBy,String orderDir); - IPage getProjectDetailPage(HuzhouProjectinfo projectInfo,String stage, Integer pageNo, Integer pageSize); + IPage getProjectDetailPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize,String orderBy,String orderDir, + String projectStage,String stepName,String isUpload,String isOffline); List countStage(HuzhouProjectinfo projectInfo); + void updateTypeByImportFile (MultipartFile file) throws Exception; + } diff --git a/huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java b/huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java index d50401d..7dbd181 100644 --- a/huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java +++ b/huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java @@ -1,5 +1,8 @@ package com.easy.admin.modules.huzhou.service.impl; +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -18,6 +21,7 @@ import com.easy.admin.modules.huzhou.service.*; import com.easy.admin.modules.huzhou.vo.*; import com.easy.admin.sys.model.SysDict; import com.easy.admin.sys.service.SysDictService; +import groovy.util.logging.Slf4j; import kotlin.collections.EmptyList; import org.activiti.engine.RuntimeService; import org.activiti.engine.TaskService; @@ -1401,7 +1405,8 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl getProjectSummaryPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize){ + @Override + public IPage getProjectSummaryPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize,String orderBy,String orderDir){ IPage result = new Page<>(); //只要入库项目 projectInfo.setType("1"); @@ -1416,13 +1421,25 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl currentPageData = projectSummaryPageList.subList(fromIndex, Math.min(fromIndex + pageSize, projectSummaryPageList.size())); - result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(projectSummaryPageList.size()); + //排序 + if(!orderBy.equals("")&&!orderDir.equals("")){ + List summarySortedList = this.getSummarySortedList(projectSummaryPageList, orderBy, orderDir); + //手动分页 + int fromIndex = (pageNo - 1) * pageSize; + List currentPageData = summarySortedList.subList(fromIndex, Math.min(fromIndex + pageSize, summarySortedList.size())); + result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(summarySortedList.size()); + }else { + //手动分页 + int fromIndex = (pageNo - 1) * pageSize; + List currentPageData = projectSummaryPageList.subList(fromIndex, Math.min(fromIndex + pageSize, projectSummaryPageList.size())); + result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(projectSummaryPageList.size()); + } + return result; } - public IPage getProjectSummaryPageByTask(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize){ + + @Override + public IPage getProjectSummaryPageByTask(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize,String orderBy,String orderDir){ IPage result = new Page<>(); //只要入库项目 projectInfo.setType("1"); @@ -1437,13 +1454,26 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl currentPageData = projectSummaryPageList.subList(fromIndex, Math.min(fromIndex + pageSize, projectSummaryPageList.size())); - result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(projectSummaryPageList.size()); + //排序 + if(!orderBy.equals("")&&!orderDir.equals("")){ + List summarySortedList = this.getSummarySortedList(projectSummaryPageList, orderBy, orderDir); + //手动分页 + int fromIndex = (pageNo - 1) * pageSize; + List currentPageData = summarySortedList.subList(fromIndex, Math.min(fromIndex + pageSize, summarySortedList.size())); + result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(summarySortedList.size()); + }else { + //手动分页 + int fromIndex = (pageNo - 1) * pageSize; + List currentPageData = projectSummaryPageList.subList(fromIndex, Math.min(fromIndex + pageSize, projectSummaryPageList.size())); + result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(projectSummaryPageList.size()); + + } return result; } - public IPage getProjectDetailPage(HuzhouProjectinfo projectInfo,String stage, Integer pageNo, Integer pageSize){ + + @Override + public IPage getProjectDetailPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize,String orderBy,String orderDir, + String projectStage,String stepName,String isUpload,String isOffline){ IPage result = new Page<>(); List records=new ArrayList<>(); HashMap stageMap=new HashMap<>(); @@ -1492,18 +1522,18 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl onGoingLevelList = planinfoService.list(query1).stream().map(x -> x.getTaskLevel().split("\\.")).collect(Collectors.toList()); - String stepName=""; - String isUpload=""; - String isOffline="0"; + String defaultStepName=""; + String defaultIsUpload=""; + String defaultIsOffline="0"; if(!onGoingLevelList.isEmpty()){//有1取1,多1取最大 List onGoingKeyList = onGoingLevelList.stream().filter(x -> x.length == 2).collect(Collectors.toList()); int firstMax = onGoingKeyList.stream().mapToInt(x -> Integer.parseInt(x[0])).summaryStatistics().getMax(); List onGoingKeyFilterList = onGoingKeyList.stream().filter(x -> x[0].equals(String.valueOf(firstMax))).collect(Collectors.toList()); int secondMax = onGoingKeyFilterList.stream().mapToInt(x -> Integer.parseInt(x[1])).summaryStatistics().getMax(); String level=firstMax+"."+secondMax; - stepName=planinfoMapper.getTaskName(p.getId(),level); - isOffline = planinfoMapper.getIsOffline(p.getId(), level); - isUpload="1"; + defaultStepName=planinfoMapper.getTaskName(p.getId(),level); + defaultIsUpload = planinfoMapper.getIsOffline(p.getId(), level); + defaultIsOffline="1"; } else if(onGoingLevelList.isEmpty() && !levelList.isEmpty()){//没有1,有2 List keyList = levelList.stream().filter(x -> x.length == 2).collect(Collectors.toList()); @@ -1511,13 +1541,13 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl onGoingKeyFilterList = keyList.stream().filter(x -> x[0].equals(String.valueOf(firstMax))).collect(Collectors.toList()); int secondMax = onGoingKeyFilterList.stream().mapToInt(x -> Integer.parseInt(x[1])).summaryStatistics().getMax(); String level=firstMax+"."+secondMax; - stepName=planinfoMapper.getTaskName(p.getId(),level); - isOffline = planinfoMapper.getIsOffline(p.getId(), level); - isUpload="1"; + defaultStepName=planinfoMapper.getTaskName(p.getId(),level); + defaultIsUpload = planinfoMapper.getIsOffline(p.getId(), level); + defaultIsOffline="1"; } - projectDetail.setStepName(stepName); - projectDetail.setIsUpload(isUpload); - projectDetail.setIsOffline(isOffline); + projectDetail.setStepName(defaultStepName); + projectDetail.setIsUpload(defaultIsUpload); + projectDetail.setIsOffline(defaultIsOffline); // 进度 List projectIds=new ArrayList<>(); projectIds.add(p.getId()); @@ -1527,22 +1557,182 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl filterRecords=records.stream().filter(x->x.getProjectStage().equals(queryStage)).collect(Collectors.toList()); - //手动分页 - int fromIndex = (pageNo - 1) * pageSize; - List currentPageData = filterRecords.subList(fromIndex, Math.min(fromIndex + pageSize, filterRecords.size())); - result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(filterRecords.size()); + //先筛再排 +// List filteredList=new ArrayList<>(); + List detailSortedList=new ArrayList<>(); + List conditionList=new ArrayList<>(); + //筛选条件集合 + HashMap filterMap= new HashMap<>(); + filterMap.put("projectStage",projectStage); + filterMap.put("stepName",stepName); + filterMap.put("isUpload",isUpload); + filterMap.put("isOffline",isOffline); + for (Map.Entry entry : filterMap.entrySet()){ + if (!entry.getValue().equals("")){ + conditionList.add(entry.getKey()); + } + } + //筛选 + if(!conditionList.isEmpty()){ + List tempList=new ArrayList<>(); + tempList.addAll(records); + List filteredList=new ArrayList<>(); + for(String condition:conditionList){ + if(condition.equals("projectStage")){ + filteredList = tempList.stream().filter(x -> x.getProjectStage().equals(stageMap.get(projectStage))).collect(Collectors.toList()); + }else if (condition.equals("stepName")){ + filteredList = tempList.stream().filter(x -> x.getStepName().equals(stepName)).collect(Collectors.toList()); + } else if (condition.equals("isUpload")) { + filteredList = tempList.stream().filter(x -> x.getIsUpload().equals(isUpload)).collect(Collectors.toList()); + } else if (condition.equals("isOffline")) { + filteredList = tempList.stream().filter(x -> x.getIsOffline().equals(isOffline)).collect(Collectors.toList()); + } + tempList.clear(); + tempList.addAll(filteredList); + } + records=filteredList; + } + if(!orderBy.equals("")&&!orderDir.equals("")){ + detailSortedList = this.getDetailSortedList(records, orderBy, orderDir); + }else { - //手动分页 - int fromIndex = (pageNo - 1) * pageSize; - List currentPageData = records.subList(fromIndex, Math.min(fromIndex + pageSize, records.size())); - result.setCurrent(pageNo).setSize(pageSize).setRecords(currentPageData).setTotal(records.size()); + detailSortedList=records; } + //手动分页 + int fromIndex = (pageNo - 1) * pageSize; + List currentPageData = detailSortedList.subList(fromIndex, Math.min(fromIndex + pageSize, detailSortedList.size())); + result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(detailSortedList.size()); + return result; } + public List getSummarySortedList(List originalList,String orderBy,String orderDir){ + List sortedList=new ArrayList<>(); + List projectNumList = originalList.stream().map(x -> x.getProjectNum()).collect(Collectors.toList()); + List totalMoneyList = originalList.stream().map(x -> x.getTotalMoney()).collect(Collectors.toList()); + List centralMoneyList = originalList.stream().map(x -> x.getCentralMoney()).collect(Collectors.toList()); + List estimateMoneyList = originalList.stream().map(x -> x.getEstimateMoney()).collect(Collectors.toList()); + List contractMoneyList = originalList.stream().map(x -> x.getContractMoney()).collect(Collectors.toList()); + List contractCentralMoneyList = originalList.stream().map(x -> x.getContractCentralMoney()).collect(Collectors.toList()); + List projectProgressList = originalList.stream().map(x -> x.getProjectProgress()).collect(Collectors.toList()); + List empList=new ArrayList<>(); + + if (Objects.equals(orderBy, "projectNum")&& Objects.equals(orderDir, "descend")){ + sortedList=projectNumList.isEmpty()?originalList:originalList.stream().sorted(Comparator.comparing(ProjectSummaryOV::getProjectNum).reversed()).collect(Collectors.toList()); + } else if (Objects.equals(orderBy, "projectNum") && Objects.equals(orderDir, "ascend")) { + sortedList=projectNumList.isEmpty()?originalList:originalList.stream().sorted(Comparator.comparing(ProjectSummaryOV::getProjectNum)).collect(Collectors.toList()); + }else if (Objects.equals(orderBy, "totalMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=totalMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getTotalMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getTotalMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getTotalMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + } else if (Objects.equals(orderBy, "totalMoney") && Objects.equals(orderDir, "ascend")) { + sortedList=totalMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getTotalMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getTotalMoney)).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getTotalMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "centralMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=centralMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getCentralMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "centralMoney")&& Objects.equals(orderDir, "ascend")){ + sortedList=centralMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getCentralMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "estimateMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=estimateMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getEstimateMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getEstimateMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getEstimateMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + } else if (Objects.equals(orderBy, "estimateMoney") && Objects.equals(orderDir, "ascend")) { + sortedList=estimateMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getEstimateMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getEstimateMoney)).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getEstimateMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "contractMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=contractMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getContractMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "contractMoney")&& Objects.equals(orderDir, "ascend")){ + sortedList=contractMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getContractMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "contractCentralMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=contractCentralMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractCentralMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getContractCentralMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractCentralMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "contractCentralMoney")&& Objects.equals(orderDir, "ascend")){ + sortedList=contractCentralMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractCentralMoney()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getContractCentralMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractCentralMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "projectProgress")&& Objects.equals(orderDir, "descend")){ + sortedList=projectProgressList.isEmpty()?originalList:originalList.stream().filter(x->x.getProjectProgress()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getProjectProgress).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getProjectProgress() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "projectProgress")&& Objects.equals(orderDir, "ascend")){ + sortedList=projectProgressList.isEmpty()?originalList:originalList.stream().filter(x->x.getProjectProgress()!=null).sorted(Comparator.comparing(ProjectSummaryOV::getProjectProgress).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getProjectProgress() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + } + return sortedList; + } + public List getDetailSortedList(List originalList,String orderBy,String orderDir){ + List sortedList=new ArrayList<>(); + List totalMoneyList = originalList.stream().map(x -> x.getTotalMoney()).collect(Collectors.toList()); + List centralMoneyList = originalList.stream().map(x -> x.getCentralMoney()).collect(Collectors.toList()); + List estimateMoneyList = originalList.stream().map(x -> x.getEstimateMoney()).collect(Collectors.toList()); + List contractMoneyList = originalList.stream().map(x -> x.getContractMoney()).collect(Collectors.toList()); + List contractCentralMoneyList = originalList.stream().map(x -> x.getContractCentralMoney()).collect(Collectors.toList()); + List projectProgressList = originalList.stream().map(x -> x.getProjectProgress()).collect(Collectors.toList()); + List empList=new ArrayList<>(); + if (Objects.equals(orderBy, "totalMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=totalMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getTotalMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getTotalMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getTotalMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + } else if (Objects.equals(orderBy, "totalMoney") && Objects.equals(orderDir, "ascend")) { + sortedList=totalMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getTotalMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getTotalMoney)).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getTotalMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "centralMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=centralMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getCentralMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getCentralMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getCentralMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "centralMoney")&& Objects.equals(orderDir, "ascend")){ + sortedList=centralMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getCentralMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getCentralMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getCentralMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "estimateMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=estimateMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getEstimateMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getEstimateMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getEstimateMoney()== null).collect(Collectors.toList()); + sortedList.addAll(empList); + } else if (Objects.equals(orderBy, "estimateMoney") && Objects.equals(orderDir, "ascend")) { + sortedList=estimateMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getEstimateMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getEstimateMoney)).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getEstimateMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "contractMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=contractMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getContractMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "contractMoney")&& Objects.equals(orderDir, "ascend")){ + sortedList=contractMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getContractMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "contractCentralMoney")&& Objects.equals(orderDir, "descend")){ + sortedList=contractCentralMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractCentralMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getContractCentralMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractCentralMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "contractCentralMoney")&& Objects.equals(orderDir, "ascend")){ + sortedList=contractCentralMoneyList.isEmpty()?originalList:originalList.stream().filter(x->x.getContractCentralMoney()!=null).sorted(Comparator.comparing(ProjectDetailOV::getContractCentralMoney).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getContractCentralMoney() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "projectProgress")&& Objects.equals(orderDir, "descend")){ + sortedList=projectProgressList.isEmpty()?originalList:originalList.stream().filter(x->x.getProjectProgress()!=null).sorted(Comparator.comparing(ProjectDetailOV::getProjectProgress).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getProjectProgress() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + }else if (Objects.equals(orderBy, "projectProgress")&& Objects.equals(orderDir, "ascend")){ + sortedList=projectProgressList.isEmpty()?originalList:originalList.stream().filter(x->x.getProjectProgress()!=null).sorted(Comparator.comparing(ProjectDetailOV::getProjectProgress).reversed()).collect(Collectors.toList()); + empList = originalList.stream().filter(x -> x.getProjectProgress() == null).collect(Collectors.toList()); + sortedList.addAll(empList); + } + return sortedList; + } + + @Override public List countStage(HuzhouProjectinfo projectInfo){ List result = new ArrayList<>(); HashMap stageMap=new HashMap<>(); @@ -1588,4 +1778,32 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl typeMap=new HashMap<>(); + typeMap.put("入库项目","1"); + typeMap.put("配套项目","2"); + //表格标题行数,默认0 + importParams.setTitleRows(0); + //是否需要校验上传的Excel + importParams.setNeedVerify(true); + ExcelImportResult result = ExcelImportUtil.importExcelMore(file.getInputStream(),ImportTypeOV.class,importParams); + if (!result.getList().isEmpty()) { + for (ImportTypeOV request : result.getList()) { + HuzhouProjectinfo projectInfo=new HuzhouProjectinfo(); + projectInfo.setProjectName(request.getName()); + String s = typeMap.get(request.getType()); + projectInfo.setType(s); + LambdaUpdateWrapper updateWrapper=new LambdaUpdateWrapper<>(); + updateWrapper.set(null,projectInfo); + projectinfoMapper.updateById(projectInfo); + } + for (ImportTypeOV request : result.getFailList()) { + System.out.println(request); + } + } + } + + } diff --git a/huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/ImportTypeOV.java b/huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/ImportTypeOV.java new file mode 100644 index 0000000..00b2bc3 --- /dev/null +++ b/huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/ImportTypeOV.java @@ -0,0 +1,15 @@ +package com.easy.admin.modules.huzhou.vo; + + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +@Data +public class ImportTypeOV { + + @Excel(name = "项目名称") + private String name; + + @Excel(name = "项目类型") + private String type; +}