|
@@ -9,6 +9,7 @@ import com.ruoyi.common.datascope.context.DataScopeContextHolder;
|
|
|
import com.usky.common.core.bean.CommonPage;
|
|
|
import com.usky.common.core.domain.R;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
+import com.usky.common.log.annotation.Log;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
|
import com.usky.iot.domain.PmProject;
|
|
@@ -20,6 +21,7 @@ import com.usky.iot.service.PmProjectService;
|
|
|
import com.usky.iot.service.PmWorkContentService;
|
|
|
import com.usky.iot.service.vo.*;
|
|
|
import com.usky.system.domain.SysUser;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -40,6 +42,7 @@ import java.util.stream.Collectors;
|
|
|
* @author fu
|
|
|
* @since 2024-05-20
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentMapper, PmWorkContent> implements PmWorkContentService {
|
|
|
|
|
@@ -427,7 +430,8 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
* @return: java.util.List<com.usky.system.domain.PmWorkContent>
|
|
|
**/
|
|
|
@Override
|
|
|
- public CommonPage<PmWorkReport> reportPage(Integer projectAscription, Integer pageNum, Integer pageSize, Integer reportId, String startDate, String endDate, Integer projectId) {
|
|
|
+ public CommonPage<PmWorkReport> reportPage(Integer projectAscription, Integer pageNum, Integer pageSize, Integer reportId,
|
|
|
+ String startDate, String endDate, Integer projectId, Long userId) {
|
|
|
// LocalDateTime startDateTime = null;
|
|
|
// LocalDateTime endDateTime = null;
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
@@ -446,6 +450,14 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
end = LocalDate.parse(endDate, formatter);
|
|
|
// startDateTime = start.atStartOfDay();
|
|
|
// endDateTime = end.atTime(23, 59, 59);
|
|
|
+
|
|
|
+ if (userId != null && userId > 0){
|
|
|
+ LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
+ reportQuery.eq(PmWorkReport::getSubmitterId, userId);
|
|
|
+ IPage<PmWorkReport> reportPage = pmWorkReportMapper.selectPage(new Page<>(pageNum, pageSize), reportQuery);
|
|
|
+ return new CommonPage<>(reportPage.getRecords(), reportPage.getTotal(), pageSize, pageNum);
|
|
|
+ }
|
|
|
+
|
|
|
LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
reportQuery.select(PmWorkReport::getId).eq(PmWorkReport::getReportStatus, 1).between(PmWorkReport::getReportDate, start, end);
|
|
|
reportIds = pmWorkReportMapper.selectList(reportQuery).stream().map(PmWorkReport::getId).collect(Collectors.toList());
|
|
@@ -466,7 +478,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
|
|
|
List<PmWorkContent> pmWorkContentList = new ArrayList<>();
|
|
|
// Integer tenantId = SecurityUtils.getTenantId();
|
|
|
- Long userId = SecurityUtils.getUserId();
|
|
|
+ Long userId2 = SecurityUtils.getUserId();
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
List<Integer> receiveList = receive();
|
|
|
if (receiveList.isEmpty() && projectAscription == 2) {
|
|
@@ -526,7 +538,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
|
|
|
// 查询已读状态
|
|
|
LambdaQueryWrapper<PmReceive> statusQuery = Wrappers.lambdaQuery();
|
|
|
- statusQuery.select(PmReceive::getReportId, PmReceive::getReadFlag).eq(PmReceive::getReceiverId, userId);
|
|
|
+ statusQuery.select(PmReceive::getReportId, PmReceive::getReadFlag).eq(PmReceive::getReceiverId, userId2);
|
|
|
if (reportId != null && reportId != 0) {
|
|
|
statusQuery.eq(PmReceive::getReportId, reportId);
|
|
|
} else if (!receiveList.isEmpty()) {
|
|
@@ -613,48 +625,9 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return new CommonPage<>(reportList, reportPage.getTotal(), pageSize, pageNum);
|
|
|
+ return new CommonPage<PmWorkReport>(reportList, reportPage.getTotal(), pageSize, pageNum);
|
|
|
}
|
|
|
|
|
|
- /*private PmReportReadersVO readCount() {
|
|
|
- List<PmReceive> receives = receives(receiveList);
|
|
|
- List<Long> uId = new ArrayList<>();
|
|
|
- for (PmReceive pmReceive : receives) {
|
|
|
- Long receiverId = pmReceive.getReceiverId();
|
|
|
- uId.add(receiverId);
|
|
|
- }
|
|
|
-
|
|
|
- Set<Long> userIdSet = new HashSet<>();
|
|
|
- for (PmWorkReport report : reportList) {
|
|
|
- Long submitterId = report.getSubmitterId();
|
|
|
- userIdSet.add(submitterId);
|
|
|
- }
|
|
|
- List<Long> userIdList = new ArrayList<>(userIdSet);
|
|
|
-
|
|
|
- List<SysUser> sysUsers = nickNames(userIdList);
|
|
|
-
|
|
|
- Map<Integer, List<PmReceive>> reportReceivesMap = receives.stream()
|
|
|
- .collect(Collectors.groupingBy(PmReceive::getReportId));
|
|
|
-
|
|
|
- if (sysUsers != null) {
|
|
|
- for (PmWorkReport report : reportList) {
|
|
|
- List<Long> readAlready = new ArrayList<>();
|
|
|
- List<Long> readNotAlready = new ArrayList<>();
|
|
|
- int readCount = 0;
|
|
|
- int unreadCount = 0;
|
|
|
- List<PmReceive> reportReceives = reportReceivesMap.getOrDefault(report.getId(), Collections.emptyList());
|
|
|
- for (PmReceive pmReceive : reportReceives) {
|
|
|
- if (pmReceive.getReadFlag() == 1) {
|
|
|
- readCount++;
|
|
|
- readAlready.add(pmReceive.getReceiverId());
|
|
|
- } else {
|
|
|
- unreadCount++;
|
|
|
- readNotAlready.add(pmReceive.getReceiverId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- PmReportReadersVO readUnreadVO = new PmReportReadersVO(readAlready, readNotAlready, readCount, unreadCount);
|
|
|
- }*/
|
|
|
|
|
|
/**
|
|
|
* @description: 获取报告接收人
|
|
@@ -703,7 +676,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
return pmProjectMapper.selectList(projectsQuery);
|
|
|
}
|
|
|
|
|
|
- @DataScope(userAlias = "d")
|
|
|
+ @DataScope
|
|
|
private List<SysUser> userNameList(Long userId) {
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
|
@@ -716,8 +689,9 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
userNameQuery.eq(SysUser::getUserId, userId);
|
|
|
return sysUserMapper.selectList(userNameQuery);
|
|
|
}
|
|
|
- // userNameQuery.apply(DataScopeContextHolder.getDataScopeSql());
|
|
|
- userNameQuery.eq(SysUser::getTenantId, tenantId).eq(SysUser::getDeptId, deptId);
|
|
|
+ userNameQuery.apply(Objects.nonNull(DataScopeContextHolder.getDataScopeSql()),DataScopeContextHolder.getDataScopeSql());
|
|
|
+ log.info("dataScopeSql: "+DataScopeContextHolder.getDataScopeSql());
|
|
|
+ //userNameQuery.eq(SysUser::getTenantId, tenantId).eq(SysUser::getDeptId, deptId);
|
|
|
return sysUserMapper.selectList(userNameQuery);
|
|
|
}
|
|
|
|
|
@@ -728,7 +702,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
* @param: [startDate, endDate, projectName, projectAscription]
|
|
|
* @return: java.util.List<com.usky.iot.domain.PmWorkReport>
|
|
|
**/
|
|
|
- //@DataScope//数据权限注解
|
|
|
+ @DataScope//数据权限注解
|
|
|
private List<PmWorkContent> workTimeCount(List<Long> users, List<Integer> project, String startDate, String endDate) {
|
|
|
List<PmWorkContent> pmWorkContentList = new ArrayList<>();
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
@@ -753,7 +727,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
return pmWorkContentList;
|
|
|
}
|
|
|
}
|
|
|
- // workTimeQuery.apply(DataScopeContextHolder.getDataScopeSql());// 数据权限设置
|
|
|
+ workTimeQuery.apply(DataScopeContextHolder.getDataScopeSql());// 数据权限设置
|
|
|
pmWorkContentList = pmWorkContentMapper.selectList(workTimeQuery);
|
|
|
|
|
|
Map<String, PmWorkContent> workTimeMap = new HashMap<>();
|