|
@@ -28,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
@@ -72,7 +73,8 @@ public class ProjectRequirementController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/listByPage")
|
|
|
- public HttpRespMsg listByPage(Integer pageIndex, Integer pageSize, Integer projectId, String groupName) {
|
|
|
+ public HttpRespMsg listByPage(Integer pageIndex, Integer pageSize, Integer projectId, String groupName,String reStartDate,String reEndDate ) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("TOKEN")).getCompanyId();
|
|
|
int startIndex = (pageIndex-1)*pageSize;
|
|
@@ -80,17 +82,14 @@ public class ProjectRequirementController {
|
|
|
now = now.minusDays(7);
|
|
|
String startDate = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
|
|
|
List<Integer> projectIds = new ArrayList<>();
|
|
|
- long total;
|
|
|
if (!StringUtils.isEmpty(groupName)) {
|
|
|
List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
List<Integer> collect = projectList.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().eq("name", groupName).in("project_id", collect));
|
|
|
projectIds = taskGroups.stream().map(TaskGroup::getProjectId).collect(Collectors.toList());
|
|
|
- total=projectIds.size();
|
|
|
- }else{
|
|
|
- total = projectMapper.selectCount(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
}
|
|
|
- List<ProjectRequirement> projectRequirements = projectRequirementMapper.customSelect(companyId, startDate, projectId, projectIds.size()==0?null:projectIds, startIndex, pageSize);
|
|
|
+ List<ProjectRequirement> projectRequirements = projectRequirementMapper.customSelect(companyId, startDate, projectId, projectIds.size()==0?null:projectIds, startIndex, pageSize,reStartDate,reEndDate);
|
|
|
+ long total=projectRequirementMapper.selectCountByDate(companyId, startDate, projectId, projectIds.size()==0?null:projectIds, startIndex, pageSize,reStartDate,reEndDate);
|
|
|
HashMap map = new HashMap();
|
|
|
map.put("total", total);
|
|
|
map.put("records", projectRequirements);
|
|
@@ -100,14 +99,15 @@ public class ProjectRequirementController {
|
|
|
}
|
|
|
@RequestMapping("/exportData")
|
|
|
public HttpRespMsg exportData(){
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("TOKEN")).getCompanyId();
|
|
|
LocalDate now = LocalDate.now();
|
|
|
now = now.minusDays(7);
|
|
|
String startDate = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
|
|
|
- List<ProjectRequirement> projectRequirementList = projectRequirementMapper.customSelect(companyId,startDate, null, null, null, null);
|
|
|
+ List<ProjectRequirement> projectRequirementList = projectRequirementMapper.customSelect(companyId,startDate, null, null, null, null,null,null);
|
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
|
- String[] titleString={"项目编号","项目名称","近七日活跃人员","人员需求","任务需求"};
|
|
|
+ String[] titleString={"项目编号","项目名称","近七日活跃人员","人员需求","任务需求","开始时间","结束时间"};
|
|
|
List<String> nameList = Arrays.asList(titleString);
|
|
|
dataList.add(nameList);
|
|
|
projectRequirementList.forEach(pr->{
|
|
@@ -117,6 +117,14 @@ public class ProjectRequirementController {
|
|
|
resultData.add(pr.getActiveUsers());
|
|
|
resultData.add(pr.getMembReq());
|
|
|
resultData.add(pr.getTaskReq());
|
|
|
+ if(pr.getStartDate()!=null){
|
|
|
+ String s=df.format(pr.getStartDate());
|
|
|
+ resultData.add(s);
|
|
|
+ }
|
|
|
+ if(pr.getEndDate()!=null){
|
|
|
+ String s1=df.format(pr.getEndDate());
|
|
|
+ resultData.add(s1);
|
|
|
+ }
|
|
|
dataList.add(resultData);
|
|
|
});
|
|
|
//生成excel文件导出
|
|
@@ -153,6 +161,8 @@ public class ProjectRequirementController {
|
|
|
List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
List<ProjectRequirement> projectRequirementList = projectRequirementMapper.selectList(null);
|
|
|
List<ProjectRequirement> projectRequirements=new ArrayList<>();
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ LocalDate date=LocalDate.now();
|
|
|
for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
|
XSSFRow row = sheet.getRow(rowIndex+1);
|
|
|
if (row == null) {
|
|
@@ -166,15 +176,18 @@ public class ProjectRequirementController {
|
|
|
XSSFCell codeCell = row.getCell(0);
|
|
|
XSSFCell taskReqCell = row.getCell(1);
|
|
|
XSSFCell membReqCell = row.getCell(2);
|
|
|
+ XSSFCell startDateCell = row.getCell(3);
|
|
|
+ XSSFCell endDateCell = row.getCell(4);
|
|
|
|
|
|
if (codeCell != null)codeCell.setCellType(CellType.STRING);
|
|
|
if (taskReqCell != null)taskReqCell.setCellType(CellType.STRING);
|
|
|
if (membReqCell != null)membReqCell.setCellType(CellType.STRING);
|
|
|
+ if (startDateCell != null)startDateCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (endDateCell != null)endDateCell.setCellType(CellType.NUMERIC);
|
|
|
ProjectRequirement projectRequirement=new ProjectRequirement();
|
|
|
if(codeCell==null){
|
|
|
throw new Exception("项目编号/名称不能为空");
|
|
|
}
|
|
|
- System.out.println(codeCell.getStringCellValue());
|
|
|
List<Project> list = projectList.stream().filter(project ->
|
|
|
(StringUtils.isEmpty(project.getProjectCode())?"":project.getProjectCode()).equals(codeCell.getStringCellValue())
|
|
|
|| (StringUtils.isEmpty(project.getProjectName())?"":project.getProjectName()).equals(codeCell.getStringCellValue())
|
|
@@ -187,6 +200,16 @@ public class ProjectRequirementController {
|
|
|
projectRequirement.setProjectId(li.getId());
|
|
|
projectRequirement.setTaskReq(StringUtils.isEmpty(taskReqCell.getStringCellValue())?"":taskReqCell.getStringCellValue());
|
|
|
projectRequirement.setMembReq(StringUtils.isEmpty(membReqCell.getStringCellValue())?"":membReqCell.getStringCellValue());
|
|
|
+ if(startDateCell!=null){
|
|
|
+ projectRequirement.setStartDate(startDateCell.getDateCellValue());
|
|
|
+ }else {
|
|
|
+ projectRequirement.setStartDate(null);
|
|
|
+ }
|
|
|
+ if(endDateCell!=null){
|
|
|
+ projectRequirement.setEndDate(endDateCell.getDateCellValue());
|
|
|
+ }else {
|
|
|
+ projectRequirement.setEndDate(null);
|
|
|
+ }
|
|
|
boolean flag = projectRequirementList.stream().anyMatch(pr -> pr.getProjectId().equals(li.getId()));
|
|
|
if(flag){
|
|
|
Optional<ProjectRequirement> first = projectRequirementList.stream().filter(pr -> pr.getProjectId().equals(li.getId())).findFirst();
|