|
@@ -7,9 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.google.gson.JsonArray;
|
|
|
-import com.google.gson.JsonElement;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.vo.*;
|
|
|
import com.management.platform.mapper.*;
|
|
@@ -34,13 +31,10 @@ import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
-import org.apache.tomcat.jni.Local;
|
|
|
import org.assertj.core.util.Lists;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Isolation;
|
|
|
-import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -54,6 +48,7 @@ import java.math.BigDecimal;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.NumberFormat;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
@@ -65,8 +60,6 @@ import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static java.time.format.DateTimeFormatter.ISO_DATE;
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -2350,6 +2343,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
curItem.id = "请假_"+leaveSheetList.get(i).getId();
|
|
|
curItem.userId = leaveSheetList.get(i).getOwnerId();
|
|
|
switch (leaveSheetList.get(i).getLeaveType()){
|
|
|
+ //case 0:curItem.text = "事假";
|
|
|
+ case 0:curItem.text = MessageUtils.message("leave.thing");
|
|
|
+ break;
|
|
|
//case 1:curItem.text = "病假";
|
|
|
case 1:curItem.text = MessageUtils.message("leave.illness");
|
|
|
break;
|
|
@@ -7855,6 +7851,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
break;
|
|
|
}
|
|
|
HttpRespMsg msg = getUserReportTimelinessRate(request, startDate, endDate, null, null, null, null);
|
|
|
+ try {
|
|
|
+ List<String> monthList = SplitDateUtil.doDateByStatisticsType("month", startDate, endDate);
|
|
|
+ for (int i = 0; i < monthList.size(); i++) {
|
|
|
+ String sDate = monthList.get(i);
|
|
|
+ String eDate = monthList.get(i + 1);
|
|
|
+ i++;
|
|
|
+ List<String> weekList = SplitDateUtil.doDateByStatisticsType("week", sDate, eDate);
|
|
|
+ for (int i1 = 0; i1 < weekList.size(); i1++) {
|
|
|
+ String sDate1 = weekList.get(i1);
|
|
|
+ String eDate1 = weekList.get(i1 + 1);
|
|
|
+ i1++;
|
|
|
+ System.out.println(sDate1+"-----"+eDate1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
HashMap map= (HashMap) msg.data;
|
|
|
List<TimelinessRateVO> list = (List<TimelinessRateVO>) map.get("list");
|
|
|
//String[] s={"人员","工号","部门","填报及时率"};
|
|
@@ -7885,4 +7898,433 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getGanttDataNew(Integer type, String startDate, String endDate, String targetUserId, Integer targetProjectId, String groupName,Integer taskType, HttpServletRequest request) {
|
|
|
+ //根据人员权限来获取,
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+ List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部项目");
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
|
|
|
+ List<User> AllUser = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
+ if (functionList.size() == 0) {
|
|
|
+ //看看是部门经理还是项目负责人
|
|
|
+ if (user.getManageDeptId() != null && user.getManageDeptId() != 0) {
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("department_id", user.getManageDeptId()));
|
|
|
+ userIds = userList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ //检查是否是项目负责人
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("incharger_id", user.getId()));
|
|
|
+ if (projectList.size() > 0) {
|
|
|
+ List<Integer> collect = projectList.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
+ List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().in("project_id", collect));
|
|
|
+ userIds = participationList.stream().map(Participation::getUserId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ //把自己加进去
|
|
|
+ if (!userIds.contains(user.getId())) {
|
|
|
+ userIds.add(user.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //查看全部
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
+ userIds = userList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(targetUserId)) {
|
|
|
+ userIds = userIds.stream().filter(u->u.equals(targetUserId)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ List<GanttDataItem> itemList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<Integer> projectIds = null;
|
|
|
+ if (targetProjectId != null) {
|
|
|
+ projectIds = new ArrayList<>();
|
|
|
+ projectIds.add(targetProjectId);
|
|
|
+ } else {
|
|
|
+ if (functionList.size() == 0) {
|
|
|
+ //普通员工只看自己相关的
|
|
|
+ List<Participation> participationList
|
|
|
+ = participationMapper.selectList(new QueryWrapper<Participation>().in("user_id", userIds));
|
|
|
+ projectIds = participationList.stream().map(Participation::getProjectId).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ projectIds = null;//查看全部的
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Map> ganttData = null;
|
|
|
+ if (userIds.size() > 0) {
|
|
|
+ if (type == 0) {
|
|
|
+ String lsLastItemId = null;
|
|
|
+ String btLastItemId = null;
|
|
|
+ //按人员获取
|
|
|
+ ganttData = projectMapper.getTaskPlanByMemb(userIds, startDate ,endDate, user.getCompanyId());
|
|
|
+ QueryWrapper<LeaveSheet> lsQueryWrapper=new QueryWrapper();
|
|
|
+ lsQueryWrapper.in("owner_id", userIds);
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
+ lsQueryWrapper.le("start_date", endDate).ge("end_date", startDate);
|
|
|
+ }
|
|
|
+ List<LeaveSheet> leaveSheetList = leaveSheetMapper.selectList(lsQueryWrapper);
|
|
|
+ QueryWrapper<BusinessTrip> btQueryWrapper =new QueryWrapper<>();
|
|
|
+ btQueryWrapper.in("owner_id", userIds);
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
+ btQueryWrapper.le("start_date", endDate).ge("end_date", startDate);
|
|
|
+ }
|
|
|
+ List<BusinessTrip> businessTripList = businessTripMapper.selectList(btQueryWrapper);
|
|
|
+ for(Department department:departmentList){
|
|
|
+ GanttDataItem parent = new GanttDataItem();
|
|
|
+ parent.id=department.getDepartmentId().toString();
|
|
|
+ parent.time = 0;
|
|
|
+ parent.text=department.getDepartmentName();
|
|
|
+ parent.type="department";
|
|
|
+ if(department.getSuperiorId()!=null){
|
|
|
+ parent.parent=String.valueOf(department.getSuperiorId());
|
|
|
+ parent.type="milestone";
|
|
|
+ }
|
|
|
+ parent= getGanttDataItemList(parent, department, departmentList);
|
|
|
+ Set set=new HashSet();
|
|
|
+ if(set.add(parent.id)&&department.getSuperiorId()==null){
|
|
|
+ itemList.add(parent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //加上全部的人员(不含已离职),不要和已有任务的人员重复
|
|
|
+ List<String> extraUidList = new ArrayList<>();
|
|
|
+ for (String uid : userIds) {
|
|
|
+ boolean find = false;
|
|
|
+ for (Map userMap : ganttData) {
|
|
|
+ String taskUid = (String)userMap.get("user_id");
|
|
|
+ if (taskUid.equals(uid)) {
|
|
|
+ find = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!find) {
|
|
|
+ extraUidList.add(uid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (extraUidList.size() > 0) {
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", extraUidList).eq("is_active", 1));
|
|
|
+ for (User u : userList) {
|
|
|
+ GanttDataItem userGantt = new GanttDataItem();
|
|
|
+ userGantt.id = u.getId();
|
|
|
+ userGantt.userId = u.getId();
|
|
|
+ userGantt.text = u.getName();
|
|
|
+ userGantt.render = "split";
|
|
|
+ userGantt.start_date = null;
|
|
|
+ userGantt.end_date = null;
|
|
|
+ userGantt.time = 0;
|
|
|
+ userGantt.color=u.getColor();
|
|
|
+ userGantt.parent=String.valueOf(u.getDepartmentId());
|
|
|
+ userGantt.children=new ArrayList<>();
|
|
|
+ userGantt.type="user";
|
|
|
+ itemList=getUserGanttDataItemList(userGantt,itemList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for(int i=0;i<leaveSheetList.size();i++){
|
|
|
+ GanttDataItem curItem = new GanttDataItem();;
|
|
|
+ if (!leaveSheetList.get(i).getOwnerId().equals(lsLastItemId)) {
|
|
|
+ //抽取父级对象,人员名称
|
|
|
+ int finalI = i;
|
|
|
+ Optional<User> first = AllUser.stream().filter(us -> us.getId().equals(leaveSheetList.get(finalI).getOwnerId())).findFirst();
|
|
|
+ Integer departmentId =null;
|
|
|
+ if(first.isPresent()){
|
|
|
+ departmentId=first.get().getDepartmentId();
|
|
|
+ }
|
|
|
+ System.out.println("====================="+departmentId+"======================");
|
|
|
+ GanttDataItem parent = new GanttDataItem();
|
|
|
+ parent.id = leaveSheetList.get(i).getOwnerId();
|
|
|
+ parent.userId = leaveSheetList.get(i).getOwnerId();
|
|
|
+ parent.text = leaveSheetList.get(i).getOwnerName();
|
|
|
+ parent.render = "split";
|
|
|
+ parent.start_date = leaveSheetList.get(i).getStartDate().toString();
|
|
|
+ parent.end_date = leaveSheetList.get(i).getEndDate().toString();
|
|
|
+ parent.time = 0;
|
|
|
+ parent.parent=String.valueOf(departmentId);
|
|
|
+ lsLastItemId =leaveSheetList.get(i).getOwnerId();
|
|
|
+ }
|
|
|
+ curItem.id = "请假_"+leaveSheetList.get(i).getId();
|
|
|
+ curItem.userId = leaveSheetList.get(i).getOwnerId();
|
|
|
+ switch (leaveSheetList.get(i).getLeaveType()){
|
|
|
+ //case 0:curItem.text = "事假";
|
|
|
+ case 0:curItem.text = MessageUtils.message("leave.thing");
|
|
|
+ break;
|
|
|
+ //case 1:curItem.text = "病假";
|
|
|
+ case 1:curItem.text = MessageUtils.message("leave.illness");
|
|
|
+ break;
|
|
|
+ //case 2:curItem.text = "年假";
|
|
|
+ case 2:curItem.text = MessageUtils.message("leave.year");
|
|
|
+ break;
|
|
|
+ //case 3:curItem.text = "产假";
|
|
|
+ case 3:curItem.text = MessageUtils.message("leave.maternity");
|
|
|
+ break;
|
|
|
+ //case 4:curItem.text = "婚假";
|
|
|
+ case 4:curItem.text = MessageUtils.message("leave.marry");
|
|
|
+ break;
|
|
|
+ //case 5:curItem.text = "丧假";
|
|
|
+ case 5:curItem.text = MessageUtils.message("leave.die");
|
|
|
+ break;
|
|
|
+ //case 6:curItem.text = "调休假";
|
|
|
+ case 6:curItem.text = MessageUtils.message("leave.compensatory");
|
|
|
+ break;
|
|
|
+ //case 7:curItem.text = "陪产假";
|
|
|
+ case 7:curItem.text = MessageUtils.message("leave.paternity");
|
|
|
+ break;
|
|
|
+ //case 8:curItem.text = "其他";
|
|
|
+ case 8:curItem.text = MessageUtils.message("leave.other");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ curItem.start_date = leaveSheetList.get(i).getStartDate().toString();
|
|
|
+ curItem.end_date =leaveSheetList.get(i).getEndDate().toString();
|
|
|
+ curItem.parent = lsLastItemId;
|
|
|
+ curItem.children=new ArrayList<>();
|
|
|
+ itemList=getUserGanttDataItemList(curItem,itemList);
|
|
|
+ lsLastItemId = leaveSheetList.get(i).getOwnerId();
|
|
|
+ }
|
|
|
+ for(int i=0;i<businessTripList.size();i++){
|
|
|
+ GanttDataItem curItem = new GanttDataItem();;
|
|
|
+ if (!businessTripList.get(i).getOwnerId().equals(btLastItemId)) {
|
|
|
+ //抽取父级对象,人员名称
|
|
|
+ int finalI = i;
|
|
|
+ Optional<User> first = AllUser.stream().filter(us -> us.getId().equals(businessTripList.get(finalI).getOwnerId())).findFirst();
|
|
|
+ Integer departmentId =null;
|
|
|
+ if(first.isPresent()){
|
|
|
+ departmentId=first.get().getDepartmentId();
|
|
|
+ }
|
|
|
+ GanttDataItem parent = new GanttDataItem();
|
|
|
+ parent.id = businessTripList.get(i).getOwnerId();
|
|
|
+ parent.userId = businessTripList.get(i).getOwnerId();
|
|
|
+ parent.text = businessTripList.get(i).getOwnerName();
|
|
|
+ parent.render = "split";
|
|
|
+ parent.start_date = businessTripList.get(i).getStartDate().toString();
|
|
|
+ parent.end_date = businessTripList.get(i).getEndDate().toString();
|
|
|
+ parent.time = 0;
|
|
|
+ parent.parent=String.valueOf(departmentId);
|
|
|
+ btLastItemId =businessTripList.get(i).getOwnerId();
|
|
|
+ }
|
|
|
+ //curItem.id = "出差_"+businessTripList.get(i).getId();
|
|
|
+ curItem.id = MessageUtils.message("leave.busTra") + "_" + businessTripList.get(i).getId();
|
|
|
+ curItem.userId = businessTripList.get(i).getOwnerId();
|
|
|
+ //curItem.text = "出差";
|
|
|
+ curItem.text = MessageUtils.message("leave.busTra");
|
|
|
+ curItem.start_date = businessTripList.get(i).getStartDate().toString();
|
|
|
+
|
|
|
+ curItem.end_date =businessTripList.get(i).getEndDate().toString();
|
|
|
+ curItem.parent = btLastItemId;
|
|
|
+ curItem.children=new ArrayList<>();
|
|
|
+ itemList=getUserGanttDataItemList(curItem,itemList);
|
|
|
+ btLastItemId = businessTripList.get(i).getOwnerId();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //按照项目获取
|
|
|
+ String btLastItemId = null;
|
|
|
+ GanttDataItem btLastParentItem=null;
|
|
|
+ if (!StringUtils.isEmpty(groupName)) {
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
|
|
|
+ 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));
|
|
|
+ List filterPids = taskGroups.stream().map(TaskGroup::getProjectId).collect(Collectors.toList());
|
|
|
+ if (projectIds == null) {
|
|
|
+ projectIds = filterPids;
|
|
|
+ if (projectIds.size() == 0) {
|
|
|
+ projectIds.add(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (taskType!=null) {
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
|
|
|
+ List<Integer> collect = projectList.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
+ List<Task> tasks = taskMapper.selectList(new QueryWrapper<Task>().eq("task_type", taskType).in("project_id", collect));
|
|
|
+ List filterPids = tasks.stream().map(Task::getProjectId).collect(Collectors.toList());
|
|
|
+ if (projectIds == null) {
|
|
|
+ projectIds = filterPids;
|
|
|
+ if (projectIds.size() == 0) {
|
|
|
+ projectIds.add(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ganttData = projectMapper.getTaskPlanByProject(projectIds, startDate ,endDate, user.getCompanyId());
|
|
|
+ QueryWrapper<BusinessTrip> btQueryWrapper =new QueryWrapper<>();
|
|
|
+ QueryWrapper<BustripProject> bpQueryWrapper =new QueryWrapper<>();
|
|
|
+ btQueryWrapper.in("owner_id", userIds);
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
+ bpQueryWrapper.le("start_date", endDate).ge("end_date", startDate);
|
|
|
+ }
|
|
|
+ List<Integer> btIdList=new ArrayList<>();
|
|
|
+ List<BusinessTrip> businessTripList = businessTripMapper.selectList(btQueryWrapper);
|
|
|
+ if(businessTripList.size()>0){
|
|
|
+ businessTripList.forEach(bt->{
|
|
|
+ btIdList.add(bt.getId());
|
|
|
+ });
|
|
|
+ bpQueryWrapper.in("bustrip_id", btIdList);
|
|
|
+ if(projectIds!=null){
|
|
|
+ bpQueryWrapper.in("project_id", projectIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<BustripProject> bustripProjectList = bustripProjectMapper.selectList(bpQueryWrapper);
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
|
|
|
+ for(BusinessTrip businessTrip:businessTripList){
|
|
|
+ List<BustripProject> collect = bustripProjectList.stream().filter(bp -> bp.getBustripId().equals(businessTrip.getId())).collect(Collectors.toList());
|
|
|
+ for(BustripProject bustripProject:collect){
|
|
|
+ GanttDataItem curItem = new GanttDataItem();
|
|
|
+ if(bustripProject.getProjectId()!=null) {
|
|
|
+ Project project = projectList.stream().filter(pro -> pro.getId().equals(bustripProject.getProjectId())).collect(Collectors.toList()).get(0);
|
|
|
+ if (!bustripProject.getProjectId().equals(btLastItemId)) {
|
|
|
+ //抽取父级对象,项目名称
|
|
|
+ GanttDataItem parent = new GanttDataItem();
|
|
|
+ parent.id = String.valueOf(bustripProject.getProjectId());
|
|
|
+ parent.userId = businessTrip.getOwnerId();
|
|
|
+ parent.text = project.getProjectName();
|
|
|
+ parent.render = "split";
|
|
|
+ parent.start_date = bustripProject.getStartDate().toString();
|
|
|
+ parent.end_date = bustripProject.getEndDate().toString();
|
|
|
+ parent.time = 0;
|
|
|
+ parent.children=new ArrayList<>();
|
|
|
+ itemList.add(parent);
|
|
|
+ btLastItemId = String.valueOf(bustripProject.getProjectId());
|
|
|
+ }
|
|
|
+ //curItem.id = "出差_" + businessTrip.getId();
|
|
|
+ curItem.id = MessageUtils.message("leave.busTra") + "_" + businessTrip.getId();
|
|
|
+ curItem.userId = businessTrip.getOwnerId();
|
|
|
+ //curItem.text = "出差/" + businessTrip.getOwnerName();
|
|
|
+ curItem.text = MessageUtils.message("leave.busTra")+"/" + businessTrip.getOwnerName();
|
|
|
+ curItem.start_date = bustripProject.getStartDate().toString();
|
|
|
+ curItem.end_date = bustripProject.getEndDate().toString();
|
|
|
+ curItem.type="user";
|
|
|
+ curItem.parent = btLastItemId;
|
|
|
+ itemList=getUserGanttDataItemList(curItem,itemList);
|
|
|
+ btLastItemId = String.valueOf(bustripProject.getProjectId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String lastItemId = null;
|
|
|
+ GanttDataItem lastParentItem = null;
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ for (int i=0;i<ganttData.size(); i++) {
|
|
|
+ Map map = ganttData.get(i);
|
|
|
+ String userId = (String) map.get("user_id");
|
|
|
+ List<Map> finalGanttData = ganttData;
|
|
|
+ int finalI = i;
|
|
|
+ Optional<User> first = AllUser.stream().filter(us -> us.getId().equals(finalGanttData.get(finalI).get("user_id"))).findFirst();
|
|
|
+ Integer departmentId =null;
|
|
|
+ if(first.isPresent()){
|
|
|
+ departmentId=first.get().getDepartmentId();
|
|
|
+ }
|
|
|
+ String start_date = sdf.format((Date) map.get("start_date"));
|
|
|
+ String end_date = sdf.format((Date) map.get("end_date"));
|
|
|
+ String projectId = ""+ (Integer) map.get("id");
|
|
|
+ System.out.println(map);
|
|
|
+ //String exeId = "任务_"+map.get("task_id") +"_"+ (type==0?(Integer) map.get("exe_id"):userId);
|
|
|
+ String exeId = MessageUtils.message("excel.task") + "_"+map.get("task_id") +"_"+ (type==0?(Integer) map.get("exe_id"):userId);
|
|
|
+ String taskId = ""+ (Integer) map.get("task_id");
|
|
|
+
|
|
|
+ GanttDataItem curItem = new GanttDataItem();;
|
|
|
+ if (type == 0) {
|
|
|
+ if (!userId.equals(lastItemId)) {
|
|
|
+ //抽取父级对象,人员名称
|
|
|
+ GanttDataItem parent = new GanttDataItem();
|
|
|
+ parent.id = userId;
|
|
|
+ parent.userId = (String) map.get("user_id");
|
|
|
+ parent.text = (String) map.get("name");
|
|
|
+ parent.render = "split";
|
|
|
+ parent.start_date = start_date;
|
|
|
+ parent.end_date = end_date;
|
|
|
+ parent.time = 0;
|
|
|
+ parent.type="user";
|
|
|
+ parent.parent=String.valueOf(departmentId);
|
|
|
+ parent.children=new ArrayList<>();
|
|
|
+ Optional<User> optional = AllUser.stream().filter(au -> au.getId().equals(userId)).findFirst();
|
|
|
+ if(optional.isPresent()){
|
|
|
+ parent.color=optional.get().getColor();
|
|
|
+ }
|
|
|
+ lastItemId = userId;
|
|
|
+ itemList.add(parent);
|
|
|
+ lastParentItem = parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ curItem.id = exeId;
|
|
|
+ curItem.userId = (String) map.get("user_id");
|
|
|
+ curItem.text = (String) map.get("project_name")+"/"+(String)map.get("task_name");
|
|
|
+ curItem.start_date = start_date;
|
|
|
+
|
|
|
+ curItem.end_date = end_date;
|
|
|
+ curItem.time = (Integer)map.get("duration");
|
|
|
+ curItem.parent = lastItemId;
|
|
|
+ curItem.children=new ArrayList<>();
|
|
|
+ itemList=getUserGanttDataItemList(curItem,itemList);
|
|
|
+ lastItemId = userId;
|
|
|
+ } else {
|
|
|
+ if (!projectId.equals(lastItemId)) {
|
|
|
+ //抽取父级对象,项目名称
|
|
|
+ GanttDataItem parent = new GanttDataItem();
|
|
|
+ parent.id = projectId;
|
|
|
+ parent.userId = (String) map.get("user_id");
|
|
|
+ parent.text = (String) map.get("project_name");
|
|
|
+ parent.render = "split";
|
|
|
+ parent.start_date = start_date;
|
|
|
+ parent.end_date = end_date;
|
|
|
+ parent.time = 0;
|
|
|
+ parent.children=new ArrayList<>();
|
|
|
+ lastItemId = projectId;
|
|
|
+ itemList.add(parent);
|
|
|
+ lastParentItem = parent;
|
|
|
+ }
|
|
|
+ curItem.id = projectId+"_"+exeId;
|
|
|
+ curItem.userId = (String) map.get("user_id");
|
|
|
+ curItem.text = (String) map.get("name")+"/"+(String)map.get("task_name");
|
|
|
+ curItem.start_date = start_date;
|
|
|
+ curItem.end_date = end_date;
|
|
|
+ curItem.time = (Integer)map.get("duration");
|
|
|
+ curItem.type="user";
|
|
|
+ curItem.parent = lastItemId;
|
|
|
+ itemList=getUserGanttDataItemList(curItem,itemList);
|
|
|
+ lastItemId = projectId;
|
|
|
+ }
|
|
|
+ //校正父对象
|
|
|
+ if (curItem.start_date.compareTo(lastParentItem.start_date) < 0) {
|
|
|
+ lastParentItem.start_date = curItem.start_date;
|
|
|
+ }
|
|
|
+ if (curItem.end_date.compareTo(lastParentItem.end_date) > 0) {
|
|
|
+ lastParentItem.end_date = curItem.end_date;
|
|
|
+ }
|
|
|
+ lastParentItem.time = lastParentItem.time + curItem.time;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ msg.data = itemList;
|
|
|
+
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ private List<GanttDataItem> getUserGanttDataItemList(GanttDataItem userGantt, List<GanttDataItem> itemList) {
|
|
|
+ if(itemList==null){
|
|
|
+ itemList=new ArrayList<>();
|
|
|
+ }
|
|
|
+ for (GanttDataItem ganttDataItem : itemList) {
|
|
|
+ if(ganttDataItem.getId().equals(userGantt.parent)){
|
|
|
+ ganttDataItem.children.add(userGantt);
|
|
|
+ }
|
|
|
+ getUserGanttDataItemList(userGantt,ganttDataItem.children);
|
|
|
+ }
|
|
|
+ return itemList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private GanttDataItem getGanttDataItemList(GanttDataItem parent, Department department, List<Department> departmentList) {
|
|
|
+ List<Department> collect = departmentList.stream().filter(dl ->dl.getSuperiorId()!=null&& dl.getSuperiorId().equals(department.getDepartmentId())).collect(Collectors.toList());
|
|
|
+ parent.children=new ArrayList<>();
|
|
|
+ for (Department dept : collect) {
|
|
|
+ GanttDataItem subParent = new GanttDataItem();
|
|
|
+ subParent.id=dept.getDepartmentId().toString();
|
|
|
+ subParent.time = 0;
|
|
|
+ subParent.text=dept.getDepartmentName();
|
|
|
+ subParent.type="department";
|
|
|
+ if(dept.getSuperiorId()!=null){
|
|
|
+ subParent.parent=String.valueOf(dept.getSuperiorId());
|
|
|
+ subParent.type="milestone";
|
|
|
+ }
|
|
|
+ GanttDataItem sub = getGanttDataItemList(subParent, dept, departmentList);
|
|
|
+ parent.children.add(sub);
|
|
|
+ }
|
|
|
+ return parent;
|
|
|
+ }
|
|
|
+
|
|
|
}
|