|
@@ -11,6 +11,7 @@ import com.usky.iot.mapper.PmProjectMapper;
|
|
|
import com.usky.iot.mapper.PmWorkContentMapper;
|
|
|
import com.usky.iot.mapper.PmWorkReportMapper;
|
|
|
import com.usky.iot.mapper.SysUserMapper;
|
|
|
+import com.usky.iot.service.PmProjectService;
|
|
|
import com.usky.iot.service.PmWorkContentService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.iot.service.vo.ProjectWorkTimeVO;
|
|
@@ -46,6 +47,9 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
@Autowired
|
|
|
private PmProjectMapper pmProjectMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PmProjectService pmProjectService;
|
|
|
+
|
|
|
@Override
|
|
|
public void deleteContent(Integer reportId) {
|
|
|
LambdaQueryWrapper<PmWorkContent> deleteWrapper = Wrappers.lambdaQuery();
|
|
@@ -54,7 +58,15 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<PmWorkContent> projectQuery(String startDate, String endDate, String projectName, Integer projectAscription) {
|
|
|
+ public List<PmWorkContent> projectQuery(String startDate, String endDate, String projectName, Integer projectAscription, Integer reportId) {
|
|
|
+ if (reportId != null && reportId != 0) {
|
|
|
+ LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
|
+ contentLambdaQuery.select(PmWorkContent::getProjectId, PmWorkContent::getProjectName)
|
|
|
+ .eq(PmWorkContent::getReportId, reportId)
|
|
|
+ .groupBy(PmWorkContent::getProjectId, PmWorkContent::getProjectName);
|
|
|
+ List<PmWorkContent> pmWorkContentList = this.list(contentLambdaQuery);
|
|
|
+ return pmWorkContentList;
|
|
|
+ }
|
|
|
LocalDate start = LocalDate.parse(startDate);
|
|
|
LocalDate end = LocalDate.parse(endDate);
|
|
|
String subQueryReports = "SELECT id FROM pm_work_report WHERE report_date BETWEEN '" + start + "' AND '" + end + "' AND tenant_id = " + SecurityUtils.getTenantId();
|
|
@@ -77,39 +89,54 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<PmWorkReport> workReportQuery(String startDate, String endDate, String projectName, Integer projectAscription) {
|
|
|
- LocalDate start = LocalDate.parse(startDate);
|
|
|
- LocalDate end = LocalDate.parse(endDate);
|
|
|
- String subQueryReports = "SELECT id FROM pm_work_report WHERE report_date BETWEEN '" + start + "' AND '" + end + "' AND tenant_id = " + SecurityUtils.getTenantId();
|
|
|
- String subQueryReport = "SELECT id FROM pm_work_report WHERE FIND_IN_SET('" + SecurityUtils.getUserId() + "', cc_to) > 0 AND tenant_id = " + SecurityUtils.getTenantId();
|
|
|
- String subQueryProjects = "SELECT id FROM pm_project WHERE project_head = '" + SecurityUtils.getUserId() + "' AND tenant_id = " + SecurityUtils.getTenantId();
|
|
|
- String reportIdList = "SELECT report_id FROM pm_work_content WHERE project_name = '" + projectName + "' AND tenant_id = " + SecurityUtils.getTenantId();
|
|
|
+ public List<PmWorkReport> workReportQuery(String startDate, String endDate, String projectName, Integer projectAscription, Integer reportId) {
|
|
|
List<PmWorkReport> reportList = new ArrayList<>();
|
|
|
- LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
|
- contentLambdaQuery.select(PmWorkContent::getReportId, PmWorkContent::getWorkContent, PmWorkContent::getWorkTime, PmWorkContent::getProjectName)
|
|
|
- .inSql(PmWorkContent::getReportId, subQueryReports);
|
|
|
- if (projectAscription == 1) {
|
|
|
- contentLambdaQuery.inSql(PmWorkContent::getProjectId, subQueryProjects);
|
|
|
- } else if (projectAscription == 2) {
|
|
|
- contentLambdaQuery.inSql(PmWorkContent::getReportId, subQueryReport);
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(projectName)) {
|
|
|
- contentLambdaQuery.inSql(PmWorkContent::getReportId, reportIdList);
|
|
|
- }
|
|
|
- List<PmWorkContent> pmWorkContentList = this.list(contentLambdaQuery);
|
|
|
- if (pmWorkContentList == null || pmWorkContentList.size() == 0) {
|
|
|
- return reportList;
|
|
|
- }
|
|
|
- List<Integer> reportIds = new ArrayList<>();
|
|
|
- for (PmWorkContent a : pmWorkContentList) {
|
|
|
- reportIds.add(a.getReportId());
|
|
|
+ List<PmWorkContent> pmWorkContentList = new ArrayList<>();
|
|
|
+ if (reportId != null && reportId != 0) {
|
|
|
+ LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
+ reportQuery.select(PmWorkReport::getId, PmWorkReport::getCoordinateWork, PmWorkReport::getTomorrowPlan, PmWorkReport::getCcTo, PmWorkReport::getSubmitterId,
|
|
|
+ PmWorkReport::getCreateTime, PmWorkReport::getReportDate)
|
|
|
+ .eq(PmWorkReport::getId, reportId);
|
|
|
+ PmWorkReport report = pmWorkReportMapper.selectOne(reportQuery);
|
|
|
+ LambdaQueryWrapper<PmWorkContent> contentQuery = Wrappers.lambdaQuery();
|
|
|
+ contentQuery.select(PmWorkContent::getWorkContent, PmWorkContent::getWorkTime, PmWorkContent::getProjectName)
|
|
|
+ .eq(PmWorkContent::getReportId, reportId);
|
|
|
+ pmWorkContentList = this.list(contentQuery);
|
|
|
+ report.setWorkContents(pmWorkContentList);
|
|
|
+ reportList.add(report);
|
|
|
+ }else{
|
|
|
+ LocalDate start = LocalDate.parse(startDate);
|
|
|
+ LocalDate end = LocalDate.parse(endDate);
|
|
|
+ String subQueryReports = "SELECT id FROM pm_work_report WHERE report_date BETWEEN '" + start + "' AND '" + end + "' AND tenant_id = " + SecurityUtils.getTenantId();
|
|
|
+ String subQueryReport = "SELECT id FROM pm_work_report WHERE FIND_IN_SET('" + SecurityUtils.getUserId() + "', cc_to) > 0 AND tenant_id = " + SecurityUtils.getTenantId();
|
|
|
+ String subQueryProjects = "SELECT id FROM pm_project WHERE project_head = '" + SecurityUtils.getUserId() + "' AND tenant_id = " + SecurityUtils.getTenantId();
|
|
|
+ String reportIdList = "SELECT report_id FROM pm_work_content WHERE project_name = '" + projectName + "' AND tenant_id = " + SecurityUtils.getTenantId();
|
|
|
+ LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
|
+ contentLambdaQuery.select(PmWorkContent::getReportId, PmWorkContent::getWorkContent, PmWorkContent::getWorkTime, PmWorkContent::getProjectName)
|
|
|
+ .inSql(PmWorkContent::getReportId, subQueryReports);
|
|
|
+ if (projectAscription == 1) {
|
|
|
+ contentLambdaQuery.inSql(PmWorkContent::getProjectId, subQueryProjects);
|
|
|
+ } else if (projectAscription == 2) {
|
|
|
+ contentLambdaQuery.inSql(PmWorkContent::getReportId, subQueryReport);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(projectName)) {
|
|
|
+ contentLambdaQuery.inSql(PmWorkContent::getReportId, reportIdList);
|
|
|
+ }
|
|
|
+ pmWorkContentList = this.list(contentLambdaQuery);
|
|
|
+ if (pmWorkContentList == null || pmWorkContentList.size() == 0) {
|
|
|
+ return reportList;
|
|
|
+ }
|
|
|
+ List<Integer> reportIds = new ArrayList<>();
|
|
|
+ for (PmWorkContent a : pmWorkContentList) {
|
|
|
+ reportIds.add(a.getReportId());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
+ reportQuery.select(PmWorkReport::getId, PmWorkReport::getCoordinateWork, PmWorkReport::getTomorrowPlan, PmWorkReport::getCcTo, PmWorkReport::getSubmitterId,
|
|
|
+ PmWorkReport::getCreateTime, PmWorkReport::getReportDate)
|
|
|
+ .in(PmWorkReport::getId, reportIds)
|
|
|
+ .orderByDesc(PmWorkReport::getCreateTime);
|
|
|
+ reportList = pmWorkReportMapper.selectList(reportQuery);
|
|
|
}
|
|
|
- LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
- reportQuery.select(PmWorkReport::getId, PmWorkReport::getCoordinateWork, PmWorkReport::getTomorrowPlan, PmWorkReport::getCcTo, PmWorkReport::getSubmitterId,
|
|
|
- PmWorkReport::getCreateTime)
|
|
|
- .in(PmWorkReport::getId, reportIds)
|
|
|
- .orderByDesc(PmWorkReport::getCreateTime);
|
|
|
- reportList = pmWorkReportMapper.selectList(reportQuery);
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
for (PmWorkReport c : reportList) {
|
|
|
List<PmWorkContent> contents = new ArrayList<>();
|
|
@@ -136,7 +163,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Object> workHourStatistic(Long userId, Integer filter, String startDate, String endDate, Integer workerOrProject) {
|
|
|
+ public List<Object> workHourStatistic(Long userId, Integer projectId, Integer filter, String startDate, String endDate, Integer workerOrProject) {
|
|
|
List<ProjectWorkTimeVO> projectWorkTime = new ArrayList<>();
|
|
|
List<UserWorkTimeVO> userWorkTimeVO = new ArrayList<>();
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
@@ -144,27 +171,27 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
LocalDate start = LocalDate.parse(startDate);
|
|
|
LocalDate end = LocalDate.parse(endDate);
|
|
|
//找出租户下所有项目
|
|
|
- LambdaQueryWrapper<PmProject> projectQuery = Wrappers.lambdaQuery();
|
|
|
- projectQuery.select(PmProject::getProjectName)
|
|
|
- .eq(PmProject::getTenantId, SecurityUtils.getTenantId())
|
|
|
- .orderByAsc(PmProject::getProjectName);
|
|
|
- List<PmProject> projects = pmProjectMapper.selectList(projectQuery);
|
|
|
- List<String> pmProjectName = projects.stream()
|
|
|
- .map(PmProject::getProjectName)
|
|
|
+ List<Map<String, Object>> projectIdName = pmProjectService.projectIdName(projectId);
|
|
|
+ List<String> pmProjectName = projectIdName.stream()
|
|
|
+ .map(map -> (String) map.get("name"))
|
|
|
.collect(Collectors.toList());
|
|
|
+ //所有人员id和nickName
|
|
|
+ List<Map<String, Object>> users = pmProjectService.projectUsers(userId);
|
|
|
+ List<String> nickName = new ArrayList<>();
|
|
|
+ for (Map<String, Object> map : users) {
|
|
|
+ Object name = map.get("name");
|
|
|
+ nickName.add((String) name);
|
|
|
+ }
|
|
|
//统计userId每个项目所需工时
|
|
|
List<WorkHoursStatisticsVO> userAndProject = baseMapper.workHoursStatistics(start, end, userId, tenantId);
|
|
|
- List<String> nickName = userAndProject.stream()
|
|
|
- .map(WorkHoursStatisticsVO::getNickName)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (workerOrProject != 2) {
|
|
|
+ Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
|
|
+ List<WorkHoursStatisticsVO> userAndProjectD = baseMapper.statisticsDept(start, end, userId, tenantId, deptId);
|
|
|
+ if (workerOrProject != 1) {
|
|
|
returnList.add(nickName);
|
|
|
//重组返回数据结构
|
|
|
- for (PmProject project : projects) {
|
|
|
- String name = project.getProjectName();
|
|
|
+ for (String name : pmProjectName) {
|
|
|
ProjectWorkTimeVO projectWorkTimeVO = new ProjectWorkTimeVO();
|
|
|
- projectWorkTimeVO.setProjectName(name);
|
|
|
+ projectWorkTimeVO.setProjectOrPerson(name);
|
|
|
List<BigDecimal> workTime = new ArrayList<>();
|
|
|
boolean hasNonZeroWorkTime = false;
|
|
|
for (String currentNickName : nickName) {
|
|
@@ -198,12 +225,12 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
for (String uName : nickName) {
|
|
|
String name = uName;
|
|
|
UserWorkTimeVO userWorkTimeVO2 = new UserWorkTimeVO();
|
|
|
- userWorkTimeVO2.setUserNickName(name);
|
|
|
+ userWorkTimeVO2.setProjectOrPerson(name);
|
|
|
List<BigDecimal> workTime = new ArrayList<>();
|
|
|
boolean hasNonZeroWorkTime = false;
|
|
|
for (String currentNickName : pmProjectName) {
|
|
|
boolean foundWorkTime = false;
|
|
|
- for (WorkHoursStatisticsVO workHoursStatisticsVO : userAndProject) {
|
|
|
+ for (WorkHoursStatisticsVO workHoursStatisticsVO : userAndProjectD) {
|
|
|
String userNickName = workHoursStatisticsVO.getNickName();
|
|
|
String projectName = workHoursStatisticsVO.getProjectName();
|
|
|
BigDecimal userProjectWorkTime = workHoursStatisticsVO.getWorkTime();
|
|
@@ -227,8 +254,6 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
}
|
|
|
returnList.add(userWorkTimeVO);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
return returnList;
|
|
|
}
|
|
|
|