yaozc2021
2025-04-27 c0e59387fb4c9ffeb6ce268345dddf91aa55127e
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskDaliyServiceImpl.java
@@ -15,6 +15,7 @@
 */
package me.zhengjie.modules.task.service.impl;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
@@ -24,8 +25,13 @@
import java.util.stream.Collectors;
import cn.hutool.core.date.DateTime;
import me.zhengjie.modules.project.domain.Project;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.DictDetailRepository;
import me.zhengjie.modules.task.domain.*;
import me.zhengjie.modules.task.repository.TaskRepository;
import me.zhengjie.modules.task.service.dto.TaskDaliyMongoDto;
import me.zhengjie.utils.*;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
@@ -47,12 +53,9 @@
import me.zhengjie.modules.task.service.dto.TaskDaliyDto;
import me.zhengjie.modules.task.service.dto.TaskDaliyQueryCriteria;
import me.zhengjie.modules.task.service.mapstruct.TaskDaliyMapper;
import me.zhengjie.utils.DateUtil;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.SecurityUtils;
import me.zhengjie.utils.ValidationUtil;
import org.springframework.data.domain.Sort;
import javax.servlet.http.HttpServletResponse;
/**
 * @author 赵士淞
@@ -69,6 +72,8 @@
    private final ProjectRepository projectRepository;
    private final UserRepository userRepository;
    private final TaskUserRepository taskUserRepository;
    private final TaskRepository taskRepository;
    private final DictDetailRepository dictDetailRepository;
    private final RoleService roleService;
    private final MongoTemplate mongoTemplate;
@@ -522,32 +527,32 @@
        }
    }
//    @Override
//    public void download(List<TaskDaliyDto> all, HttpServletResponse response) throws IOException {
//        List<Map<String, Object>> list = new ArrayList<>();
//        for (TaskDaliyDto taskDaliy : all) {
//            String projectName = taskDaliy.getProjectId() != null ? projectRepository.findById(taskDaliy.getProjectId()).orElseGet(Project::new).getName() : "";
//            String taskName = taskDaliy.getTaskId() != null ? taskRepository.findById(taskDaliy.getTaskId()).orElseGet(Task::new).getName() : "";
//            String userNickName = taskDaliy.getUserId() != null ? userRepository.findById(taskDaliy.getUserId()).orElseGet(User::new).getNickName() : "";
//            String settlementStatus = taskDaliy.getSettlementStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.SETTLEMENT_STATUS, taskDaliy.getSettlementStatus()).getLabel() : "";
//            Map<String, Object> map = new LinkedHashMap<>();
//            map.put("填写日期", taskDaliy.getFillDate());
//            map.put("项目名称", projectName);
//            map.put("任务名称", taskName);
//            map.put("员工姓名", userNickName);
//            map.put("消耗工时", taskDaliy.getConsumedHours());
//            map.put("消耗工作量", taskDaliy.getConsumedWorkload());
//            map.put("任务进度", taskDaliy.getTaskProgress());
//            map.put("结算状态", settlementStatus);
//            map.put("备注", taskDaliy.getRemarks());
//            map.put("创建者", taskDaliy.getCreateBy());
//            map.put("创建时间", taskDaliy.getCreateTime());
//            map.put("更新者", taskDaliy.getUpdateBy());
//            map.put("更新时间", taskDaliy.getUpdateTime());
//            list.add(map);
//        }
//        FileUtil.downloadExcel(list, response);
//    }
    @Override
    public void download(List<TaskDaliyDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (TaskDaliyDto taskDaliy : all) {
            String projectName = taskDaliy.getProjectId() != null ? projectRepository.findById(taskDaliy.getProjectId()).orElseGet(Project::new).getName() : "";
            String taskName = taskDaliy.getTaskId() != null ? taskRepository.findById(taskDaliy.getTaskId()).orElseGet(Task::new).getName() : "";
            String userNickName = taskDaliy.getUserId() != null ? userRepository.findById(taskDaliy.getUserId()).orElseGet(User::new).getNickName() : "";
            String settlementStatus = taskDaliy.getSettlementStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.SETTLEMENT_STATUS, taskDaliy.getSettlementStatus()).getLabel() : "";
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("填写日期", taskDaliy.getFillDate());
            map.put("项目名称", projectName);
            map.put("任务名称", taskName);
            map.put("员工姓名", userNickName);
            map.put("消耗工时", taskDaliy.getConsumedHours());
            map.put("消耗工作量", taskDaliy.getConsumedWorkload());
            map.put("任务进度", taskDaliy.getTaskProgress());
            map.put("结算状态", settlementStatus);
            map.put("备注", taskDaliy.getRemarks());
            map.put("创建者", taskDaliy.getCreateBy());
            map.put("创建时间", taskDaliy.getCreateTime());
            map.put("更新者", taskDaliy.getUpdateBy());
            map.put("更新时间", taskDaliy.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
    @Override
    public Double queryOtherWage(TaskDaliyQueryCriteria criteria) {