| | |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | | import me.zhengjie.modules.task.repository.TaskUserRepository; |
| | | import me.zhengjie.modules.task.service.TaskUserService; |
| | | import me.zhengjie.modules.task.service.dto.TaskMongoDto; |
| | | import me.zhengjie.modules.task.service.dto.TaskQueryCriteria; |
| | | import me.zhengjie.modules.task.service.impl.TaskServiceImpl; |
| | | import me.zhengjie.modules.task.service.impl.TaskUserServiceImpl; |
| | | import me.zhengjie.modules.treatment.domain.CmnLevel; |
| | | import me.zhengjie.modules.treatment.domain.CmnLevelRank; |
| | | import me.zhengjie.modules.treatment.domain.UserLevelWage; |
| | |
| | | import me.zhengjie.modules.treatment.repository.CmnLevelRepository; |
| | | import me.zhengjie.modules.treatment.repository.UserLevelWageRepository; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | import me.zhengjie.utils.SecurityUtils; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.sql.Timestamp; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.Map.Entry; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | |
| | | List<Task> taskListSub = getSubList(task); |
| | | changeToMongo(taskMongo, taskListSub); |
| | | |
| | | // // 查询任务分配 |
| | | // List<TaskUser> taskUserList = taskUserRepository.findByTaskId(task.getId()); |
| | | // // 查询是拥有否有子级 |
| | | // List<Task> taskListFP = taskRepository.findByPid(task.getId()); |
| | | // if (taskUserList.size() <= 0 && taskListFP.size() <= 0 && task.getPid() == null) { |
| | | // // 一级(无父无子没有分配的任务) |
| | | // TaskUserMongo taskUserMongo1 = new TaskUserMongo(); |
| | | // taskUserMongo1.setTask(taskMongo); |
| | | // taskUserMongo1.setName(task.getName()); |
| | | // taskUserMongo1.setPerformanceType(task.getPerformanceType()); |
| | | // taskUserMongo1.setPriority(task.getPriority()); |
| | | // taskUserMongo1.setTaskStatus("task_status_in_hand"); |
| | | // taskUserMongo1.setOld_id(null); |
| | | // mongoTemplate.save(taskUserMongo1); |
| | | // } else { |
| | | List<TaskUser> taskUserList = taskUserRepository.findByTaskId(task.getId()); |
| | | for (TaskUser taskUser : taskUserList) { |
| | | //有效 |
| | |
| | | taskUserMongo.setName(task.getName()); |
| | | taskUserMongo.setPerformanceType(task.getPerformanceType()); |
| | | taskUserMongo.setPriority(task.getPriority()); |
| | | // taskUserMongo.setPerformanceHours(null); // TODO |
| | | // Double num = 0.0; |
| | | // List<UserLevelWage> userLevelWageList = userLevelWageRepository.findUserLevelWageByUserId(taskUser.getUserId()); |
| | | // if (userLevelWageList.size() > 0) { |
| | | // UserLevelWage userLevelWage = userLevelWageList.get(0); |
| | | // BigDecimal bigDecimalValue = new BigDecimal(String.valueOf(userLevelWage.getPerformanceCoefficient())); |
| | | // double doubleValue = bigDecimalValue.doubleValue(); |
| | | // DecimalFormat decimalFormat = new DecimalFormat("#"); |
| | | // decimalFormat.setRoundingMode(RoundingMode.HALF_UP); |
| | | // //绩效工时 = 任务工时/绩效系数 |
| | | // num = Double.valueOf(decimalFormat.format(Double.valueOf(taskUser.getTaskHours()) / doubleValue)); |
| | | // } |
| | | |
| | | taskUserMongo.setPerformanceHours(taskUser.getTaskHours()); |
| | | taskUserMongo.setTaskHours(taskUser.getTaskHours()); |
| | | taskUserMongo.setTaskStartDate(taskUser.getTaskStartDate()); |
| | |
| | | taskUserMongo.setTaskStatus(taskUser.getTaskStatus()); |
| | | taskUserMongo.setRemarks(taskUser.getRemarks()); |
| | | //查询当前用户的这个任务填写的所有日报 |
| | | List<TaskDaliy> taskUserLists = taskDaliyRepository.findByTaskIdAndUserId(task.getId(), taskUser.getUserId()); |
| | | if (taskUserLists.size() == 0) { |
| | | List<TaskDaliy> taskDaliyList = taskDaliyRepository.findByTaskIdAndUserId(task.getId(), taskUser.getUserId()); |
| | | if (taskDaliyList.size() == 0) { |
| | | taskUserMongo.setCostHours(0.0); |
| | | } else { |
| | | Double coustHorseCount = 0.0; |
| | | for (TaskDaliy taskDaliy : taskUserLists) { |
| | | coustHorseCount = coustHorseCount + taskDaliy.getConsumedHours(); |
| | | taskUserMongo.setCostHours(taskDaliyList.stream().mapToDouble(TaskDaliy::getConsumedHours).sum()); |
| | | } |
| | | taskUserMongo.setCostHours(coustHorseCount); |
| | | } |
| | | |
| | | mongoTemplate.save(taskUserMongo); |
| | | List<TaskDaliy> taskDaliyList = taskDaliyRepository.findByTaskIdAndUserId(task.getId(), taskUser.getUserId()); |
| | | for (TaskDaliy taskDaliy : taskDaliyList) { |
| | | //查重 |
| | | Query queryDaily = new Query(); |
| | |
| | | taskDaliyMongo.setUserId(taskUserMongo.getUserId()); |
| | | taskDaliyMongo.setFillDate(taskDaliy.getFillDate()); |
| | | taskDaliyMongo.setConsumedHours(taskDaliy.getConsumedHours()); |
| | | TaskUser byTaskIdAndTaskInnerIdAndUserId = taskUserRepository.findByTaskIdAndTaskInnerIdAndUserId(taskDaliy.getTaskId(), taskDaliy.getTaskInnerId(), taskDaliy.getUserId()); |
| | | taskDaliyMongo.setPerformanceHours(byTaskIdAndTaskInnerIdAndUserId.getTaskHours()); |
| | | taskDaliyMongo.setTaskProgress(taskDaliy.getTaskProgress()); |
| | | taskDaliyMongo.setSettlementStatus(taskDaliy.getSettlementStatus()); |
| | | taskDaliyMongo.setRemarks(taskDaliy.getRemarks()); |
| | | //taskDaliyMongo.setCreateTime(taskDaliy.getCreateTime()); |
| | | //taskDaliyMongo.setUpdateTime(taskDaliy.getUpdateTime()); |
| | | mongoTemplate.save(taskDaliyMongo); |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | } |
| | | // return resultList; |
| | | } |
| | | |
| | | public List<Task> getSubList(Task task) { |