|
@@ -15,6 +15,7 @@ import com.management.platform.service.*;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import org.assertj.core.util.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -98,6 +99,10 @@ public class TaskController {
|
|
|
private TaskPersonLiableMapper taskPersonLiableMapper;
|
|
|
@Resource
|
|
|
private SapProjectServiceService sapProjectServiceService;
|
|
|
+ @Resource
|
|
|
+ private ExcelExportService excelExportService;
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
+ private String path;
|
|
|
|
|
|
@RequestMapping("/save")
|
|
|
@Transactional
|
|
@@ -1045,7 +1050,11 @@ public class TaskController {
|
|
|
List<Department> departmentList=departmentService.list(new QueryWrapper<Department>().eq("company_id",companyId));
|
|
|
branchDepartment= getBranchDepartment(deptId, departmentList);
|
|
|
}
|
|
|
- List<Task> list = taskMapper.getTaskWithProjectName(queryWrapper, (pageIndex-1)*pageSize, pageSize,companyId,branchDepartment);
|
|
|
+ Integer pageStart=null;
|
|
|
+ if(pageIndex!=null&&pageSize!=null){
|
|
|
+ pageStart = (pageIndex - 1) * pageSize;
|
|
|
+ }
|
|
|
+ List<Task> list = taskMapper.getTaskWithProjectName(queryWrapper,pageStart, pageSize,companyId,branchDepartment);
|
|
|
List<Integer> collect = list.stream().map(l -> l.getId()).distinct().collect(Collectors.toList());
|
|
|
collect.add(-1);
|
|
|
List<TaskExecutor> taskExecutorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().in("task_id", collect));
|
|
@@ -1162,5 +1171,94 @@ public class TaskController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @RequestMapping("exportTaskList")
|
|
|
+ public HttpRespMsg exportTaskList(Integer status, Integer viewId,Integer type,Integer dateType,String startDate,String endDate,Integer deptId,Integer projectId,Integer groupId,String targetUserId){
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ List<Department> departmentList = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, companyId));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
|
|
|
+ HttpRespMsg respMsg = listByPage(status, viewId, null, null, type, dateType, startDate, endDate, deptId, projectId, groupId, targetUserId);
|
|
|
+ Map<String, Object> msgData = (Map<String, Object>) respMsg.getData();
|
|
|
+ List<Task> taskList = (List<Task>) msgData.get("records");
|
|
|
+ List<Integer> projectIds = taskList.stream().map(Task::getProjectId).distinct().collect(Collectors.toList());
|
|
|
+ projectIds.add(-1);
|
|
|
+ List<Project> projectList = projectService.list(new LambdaQueryWrapper<Project>().in(Project::getId, projectIds));
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
+ titleList.add("序号");
|
|
|
+ titleList.add("项目名称");
|
|
|
+ titleList.add("任务阶段");
|
|
|
+ titleList.add("优先级");
|
|
|
+ titleList.add("任务名称");
|
|
|
+ titleList.add("执行人");
|
|
|
+ titleList.add("开始时间");
|
|
|
+ titleList.add("截止时间");
|
|
|
+ boolean anyMatch = projectList.stream().anyMatch(p -> p.getDeptId() != null && !StringUtils.isEmpty(p.getDeptId()));
|
|
|
+ if(anyMatch){
|
|
|
+ titleList.add("所属部门");
|
|
|
+ }
|
|
|
+ dataList.add(titleList);
|
|
|
+ int no=0;
|
|
|
+ for (Task task : taskList) {
|
|
|
+ no++;
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ item.add(no+"");
|
|
|
+ Optional<Project> first = projectList.stream().filter(p -> p.getId().equals(task.getProjectId())).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ item.add(first.get().getProjectName());
|
|
|
+ }else {
|
|
|
+ item.add("");
|
|
|
+ }
|
|
|
+ item.add(task.getStagesName());
|
|
|
+ switch (task.getTaskLevel()){
|
|
|
+ case 0:item.add("一般");
|
|
|
+ break;
|
|
|
+ case 1:item.add("重要");
|
|
|
+ break;
|
|
|
+ case 2:item.add("紧急");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ item.add(task.getName());
|
|
|
+ List<TaskExecutor> executorList = task.getExecutorList();
|
|
|
+ String executorString = executorList.stream().map(t->{
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ return "$userName="+t.getExecutorName()+"$";
|
|
|
+ }else {
|
|
|
+ return t.getExecutorName();
|
|
|
+ }
|
|
|
+ }).collect(Collectors.joining(","));
|
|
|
+ item.add(executorString);
|
|
|
+ item.add(task.getStartDate()==null?"":df.format(task.getStartDate()));
|
|
|
+ item.add(task.getEndDate()==null?"":df.format(task.getEndDate()));
|
|
|
+ if(anyMatch){
|
|
|
+ if(first.isPresent()){
|
|
|
+ Project project = first.get();
|
|
|
+ Optional<Department> department = departmentList.stream().filter(d -> d.getDepartmentId().equals(project.getDeptId())).findFirst();
|
|
|
+ if(department.isPresent()){
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ item.add("$departmentName="+department.get().getCorpwxDeptid()+"$");
|
|
|
+ }else {
|
|
|
+ item.add(department.get().getDepartmentName());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ item.add("");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ item.add("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ String fileName = "待办任务导出_"+System.currentTimeMillis();
|
|
|
+ try {
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName , dataList, path);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|