|
@@ -0,0 +1,236 @@
|
|
|
+package com.wtkj.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.wtkj.entity.IndexMessage;
|
|
|
+import com.wtkj.entity.Task;
|
|
|
+import com.wtkj.service.IIndexMessageService;
|
|
|
+import com.wtkj.service.IIndexService;
|
|
|
+import com.wtkj.service.IProjectService;
|
|
|
+import com.wtkj.service.ITaskService;
|
|
|
+import com.wtkj.vo.IndexProjectAndTaskSummaryVO;
|
|
|
+import com.wtkj.vo.MyIndexTaskStatistics;
|
|
|
+import com.wtkj.vo.ScheduleUserVO;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import static com.wtkj.config.MagicValue.*;
|
|
|
+
|
|
|
+
|
|
|
+ * @author Blizzard
|
|
|
+ * @create at 2023-09-20 14:51
|
|
|
+ * @describe
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class IndexServiceImpl implements IIndexService {
|
|
|
+
|
|
|
+ private final ITaskService taskService;
|
|
|
+ private final IProjectService projectService;
|
|
|
+ private final IIndexMessageService indexMessageService;
|
|
|
+ private final IUserClient userClient;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IndexProjectAndTaskSummaryVO projectAndTaskSummary(Long topDept) {
|
|
|
+ IndexProjectAndTaskSummaryVO vo = new IndexProjectAndTaskSummaryVO();
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+
|
|
|
+ Set<Long> allIds = new HashSet<>();
|
|
|
+ Set<Long> createIds = projectService.getByCreate(topDept, null);
|
|
|
+ if (!CollectionUtils.isEmpty(createIds)) {
|
|
|
+ allIds.addAll(createIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Long> executeIds = taskService.getByExecute(topDept, null);
|
|
|
+ if (!CollectionUtils.isEmpty(executeIds)) {
|
|
|
+ allIds.addAll(executeIds);
|
|
|
+
|
|
|
+ vo.setTaskCount(executeIds.size());
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(allIds)) {
|
|
|
+ vo.setProjectCount(allIds.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Long> myIds = new HashSet<>();
|
|
|
+ Set<Long> myCreate = projectService.getByCreate(null, userId);
|
|
|
+ if (!CollectionUtils.isEmpty(myCreate)) {
|
|
|
+ myIds.addAll(myCreate);
|
|
|
+ }
|
|
|
+ Set<Long> myExecute = taskService.getByUser(String.valueOf(userId));
|
|
|
+ if (!CollectionUtils.isEmpty(myExecute)) {
|
|
|
+ myIds.addAll(myExecute);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(myIds)) {
|
|
|
+ vo.setMyProjectCount(myIds.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Long> myTask = taskService.getByExecute(null, String.valueOf(userId));
|
|
|
+ if (!CollectionUtils.isEmpty(myTask)) {
|
|
|
+ vo.setMyTaskCount(myTask.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Long> todayTask = taskService.todayTask(userId);
|
|
|
+ if (!CollectionUtils.isEmpty(todayTask)) {
|
|
|
+ vo.setTodayTask(todayTask.size());
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<IndexMessage> todoList(Integer isRead, IPage<IndexMessage> page) {
|
|
|
+ LambdaQueryWrapper<IndexMessage> lqw = new LambdaQueryWrapper<>();
|
|
|
+ lqw.eq(IndexMessage::getCategory, 1);
|
|
|
+ lqw.eq(IndexMessage::getToUser, AuthUtil.getUserId());
|
|
|
+ if (isRead == 1) {
|
|
|
+ lqw.eq(IndexMessage::getIsRead, 1);
|
|
|
+ lqw.orderByDesc(IndexMessage::getCreateTime);
|
|
|
+ } else if (isRead == 2) {
|
|
|
+ lqw.eq(IndexMessage::getIsRead, 0);
|
|
|
+ lqw.orderByDesc(IndexMessage::getCreateTime);
|
|
|
+ } else if (isRead == 0) {
|
|
|
+ lqw.orderByAsc(IndexMessage::getIsRead);
|
|
|
+ lqw.orderByDesc(IndexMessage::getCreateTime);
|
|
|
+ }
|
|
|
+ return indexMessageService.page(page, lqw);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object studyList(IPage<Object> page) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IndexMessage messageDetail(Long id) {
|
|
|
+ IndexMessage byId = indexMessageService.getById(id);
|
|
|
+ if (byId != null) {
|
|
|
+ byId.setIsRead(1);
|
|
|
+ indexMessageService.updateById(byId);
|
|
|
+ }
|
|
|
+ return byId;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ScheduleUserVO> schedule(Long topDept, String date) {
|
|
|
+ List<ScheduleUserVO> result = new ArrayList<>();
|
|
|
+ Set<Long> res = new HashSet<>();
|
|
|
+ String roleName = AuthUtil.getUserRole();
|
|
|
+ String deptId = AuthUtil.getDeptId();
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+ if (roleName != null) {
|
|
|
+ if (roleName.contains(STAFF_ADMIN)) {
|
|
|
+
|
|
|
+ List<Task> list = taskService.getByOrgDeptId(topDept, date);
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ for (Task task : list) {
|
|
|
+ String executeUser = task.getExecuteUser();
|
|
|
+ if (StringUtil.isNotBlank(executeUser)) {
|
|
|
+ List<Long> userIds = Func.toLongList(executeUser);
|
|
|
+ res.addAll(userIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (roleName.contains(STAFF_SECOND_ADMIN)) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(list)){
|
|
|
+ for (Task task : list){
|
|
|
+ String executeUser = task.getExecuteUser();
|
|
|
+ if (StringUtil.isNotBlank(executeUser)){
|
|
|
+ List<Long> userIds = Func.toLongList(executeUser);
|
|
|
+ res.addAll(userIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ } else if (roleName.contains(STAFF_USER)) {
|
|
|
+ res.add(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(res)) {
|
|
|
+ for (Long id : res) {
|
|
|
+ R<User> rpc = userClient.userInfoById(id);
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
+ ScheduleUserVO vo = new ScheduleUserVO();
|
|
|
+ vo.setUser(rpc.getData());
|
|
|
+ List<Task> tasks = taskService.todayTodo(userId, date);
|
|
|
+ if (!CollectionUtils.isEmpty(tasks)) {
|
|
|
+ vo.setTodayTodo(tasks.size());
|
|
|
+ }
|
|
|
+ List<Task> tasks1 = taskService.todayExpire(userId, date);
|
|
|
+ if (!CollectionUtils.isEmpty(tasks1)) {
|
|
|
+ vo.setTodayExpire(tasks1.size());
|
|
|
+ }
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Task> scheduleExpand(Long userId, String date) {
|
|
|
+ return taskService.getTodoAndExpireByUserId(userId, date);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Integer>> mapStatistics(Long topDept, String date) {
|
|
|
+ List<Map<String, Integer>> res = new ArrayList<>();
|
|
|
+
|
|
|
+ List<Task> tasks = taskService.getTodayTodoByOrgDeptId(topDept, date);
|
|
|
+ Set<Long> userIds = new HashSet<>();
|
|
|
+ if (!CollectionUtils.isEmpty(tasks)) {
|
|
|
+ for (Task task : tasks) {
|
|
|
+ String executeUser = task.getExecuteUser();
|
|
|
+ if (StringUtil.isNotBlank(executeUser)) {
|
|
|
+ List<Long> ids = Func.toLongList(executeUser);
|
|
|
+ userIds.addAll(ids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(userIds)) {
|
|
|
+ userIds.forEach(userId -> {
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ R<User> userR = userClient.userInfoById(userId);
|
|
|
+ if (userR.isSuccess()) {
|
|
|
+ List<Task> tasks1 = taskService.todayTodo(userId, date);
|
|
|
+ if (!CollectionUtils.isEmpty(tasks1)) {
|
|
|
+ map.put(userR.getData().getName(), tasks1.size());
|
|
|
+ res.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public MyIndexTaskStatistics myStatistics(String date) {
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+ MyIndexTaskStatistics statistics = new MyIndexTaskStatistics();
|
|
|
+
|
|
|
+ List<Task> tasks = taskService.listByUser(userId, null, null);
|
|
|
+ if (!CollectionUtils.isEmpty(tasks)) {
|
|
|
+ statistics.setAll(tasks.size());
|
|
|
+
|
|
|
+ List<Task> todo = taskService.todayTodo(userId, date);
|
|
|
+ if (!CollectionUtils.isEmpty(todo)) {
|
|
|
+ statistics.setTodayTodo(todo.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Task> expires = taskService.todayExpire(userId, date);
|
|
|
+ if (!CollectionUtils.isEmpty(expires)) {
|
|
|
+ statistics.setExpire(expires.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return statistics;
|
|
|
+ }
|
|
|
+}
|