|
@@ -4,10 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
import com.usky.iot.domain.PmWorkContent;
|
|
import com.usky.iot.domain.PmWorkContent;
|
|
|
|
+import com.usky.iot.domain.PmWorkReport;
|
|
import com.usky.iot.mapper.PmWorkContentMapper;
|
|
import com.usky.iot.mapper.PmWorkContentMapper;
|
|
|
|
+import com.usky.iot.mapper.PmWorkReportMapper;
|
|
|
|
+import com.usky.iot.mapper.SysUserMapper;
|
|
import com.usky.iot.service.PmWorkContentService;
|
|
import com.usky.iot.service.PmWorkContentService;
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
|
+import com.usky.system.domain.SysUser;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
@@ -25,6 +30,12 @@ import java.util.List;
|
|
@Service
|
|
@Service
|
|
public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentMapper, PmWorkContent> implements PmWorkContentService {
|
|
public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentMapper, PmWorkContent> implements PmWorkContentService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private PmWorkReportMapper pmWorkReportMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void deleteContent(Integer reportId) {
|
|
public void deleteContent(Integer reportId) {
|
|
LambdaQueryWrapper<PmWorkContent> deleteWrapper = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<PmWorkContent> deleteWrapper = Wrappers.lambdaQuery();
|
|
@@ -36,9 +47,9 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
public List<PmWorkContent> projectQuery(String startDate, String endDate, String projectName, Integer projectAscription) {
|
|
public List<PmWorkContent> projectQuery(String startDate, String endDate, String projectName, Integer projectAscription) {
|
|
LocalDate start = LocalDate.parse(startDate);
|
|
LocalDate start = LocalDate.parse(startDate);
|
|
LocalDate end = LocalDate.parse(endDate);
|
|
LocalDate end = LocalDate.parse(endDate);
|
|
- String subQueryReports = "SELECT id FROM pm_work_report WHERE report_date BETWEEN '" + start + "' AND '" + end + "'";
|
|
|
|
- String subQueryReport = "SELECT id FROM pm_work_report WHERE FIND_IN_SET('" + SecurityUtils.getUserId() + "', cc_to) > 0";
|
|
|
|
- String subQueryProjects = "SELECT id FROM pm_project WHERE project_head = " + SecurityUtils.getUserId();
|
|
|
|
|
|
+ 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();
|
|
LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
contentLambdaQuery.select(PmWorkContent::getProjectId, PmWorkContent::getProjectName)
|
|
contentLambdaQuery.select(PmWorkContent::getProjectId, PmWorkContent::getProjectName)
|
|
.inSql(PmWorkContent::getReportId, subQueryReports);
|
|
.inSql(PmWorkContent::getReportId, subQueryReports);
|
|
@@ -54,4 +65,63 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
List<PmWorkContent> pmWorkContentList = this.list(contentLambdaQuery);
|
|
List<PmWorkContent> pmWorkContentList = this.list(contentLambdaQuery);
|
|
return pmWorkContentList;
|
|
return pmWorkContentList;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @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();
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ 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<>();
|
|
|
|
+ for (PmWorkContent b : pmWorkContentList) {
|
|
|
|
+ if (b.getReportId() == c.getId()) {
|
|
|
|
+ contents.add(b);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ c.setWorkContents(contents);
|
|
|
|
+ userIds.add(c.getSubmitterId());
|
|
|
|
+ }
|
|
|
|
+ LambdaQueryWrapper<SysUser> usersQuery = Wrappers.lambdaQuery();
|
|
|
|
+ usersQuery.select(SysUser::getUserId, SysUser::getNickName)
|
|
|
|
+ .in(SysUser::getUserId, userIds);
|
|
|
|
+ List<SysUser> nickNames = sysUserMapper.selectList(usersQuery);
|
|
|
|
+ for (PmWorkReport d : reportList) {
|
|
|
|
+ for (SysUser e : nickNames) {
|
|
|
|
+ if (e.getUserId().equals(d.getSubmitterId())) {
|
|
|
|
+ d.setCreateBy(e.getNickName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return reportList;
|
|
|
|
+ }
|
|
}
|
|
}
|