| | |
| | | import me.zhengjie.modules.task.repository.TaskDaliyRepository; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | | import me.zhengjie.modules.task.repository.TaskUserRepository; |
| | | import me.zhengjie.modules.task.service.dto.TaskMongoDto; |
| | | import me.zhengjie.modules.task.service.TaskUserService; |
| | | 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 java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | 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; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private CmnLevelRankRepository cmnLevelRankRepository; |
| | | |
| | | private TaskUserService taskUserService; |
| | | |
| | | @Test |
| | | public void deleteMongo() { |
| | |
| | | ulw.setBasicWage(cmnLevel.getBasicWage()); |
| | | ulw.setRankWage(cmnLevel.getBasicWage()); |
| | | ulw.setPerformanceWage(cmnLevel.getPerformanceWage()); |
| | | int rankLevel = 1 + r.nextInt(1); |
| | | int rankLevel = 1 + r.nextInt(1); |
| | | ulw.setRank((long) rankLevel); |
| | | List<CmnLevelRank> byLevelIdlist = cmnLevelRankRepository.findByLevelId((long) level); |
| | | ulw.setPerformanceCoefficient(BigDecimal.valueOf(byLevelIdlist.get(rankLevel).getPerformanceCoefficient())); |
| | |
| | | @Test |
| | | public void moveData() { |
| | | TaskQueryCriteria criteria = new TaskQueryCriteria(); |
| | | criteria.setPidIsNull(true); |
| | | // criteria.setPidIsNull(true); |
| | | List<Task> taskList = taskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)); |
| | | changeToMongo(null, taskList); |
| | | // List<TaskMongo> taskMongoList = |
| | |
| | | Map<String, String> dictDetailMap = dictDetailList.stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); |
| | | |
| | | for (Task task : taskList) { |
| | | //查重 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("old_id").is(task.getId())); |
| | | TaskMongo existingTaskMongo = mongoTemplate.findOne(query, TaskMongo.class); |
| | | if (existingTaskMongo != null) { |
| | | continue; |
| | | } |
| | | TaskMongo taskMongo = new TaskMongo(); |
| | | |
| | | taskMongo.setPid(task.getPid()); |
| | | taskMongo.setProjectId(task.getProjectId()); |
| | | taskMongo.setOld_id(task.getId()); |
| | | |
| | | taskMongo.setName(task.getName()); |
| | | taskMongo.setParent(parent); |
| | | // taskMongo.setParent(parent); |
| | | |
| | | taskMongo.setPlanHours(task.getPlanHours()); |
| | | taskMongo.setPlanStartTime(task.getPlanStartTime()); |
| | | taskMongo.setPlanEndTime(task.getPlanEndTime()); |
| | | if (task.getPlanWorkload() != null) { |
| | | taskMongo.setPlanWorkload(task.getPlanWorkload()); |
| | | } |
| | | |
| | | String classification = task.getTaskClassification(); |
| | | |
| | | if (task.getPlanWorkloadUnit() != null) { |
| | | taskMongo.setPlanWorkloadUnit(task.getPlanWorkloadUnit()); |
| | | } |
| | | |
| | | taskMongo.setTagList(Collections.singletonList(dictDetailMap.get(classification))); |
| | | |
| | |
| | | |
| | | List<TaskUser> taskUserList = taskUserRepository.findByTaskId(task.getId()); |
| | | for (TaskUser taskUser : taskUserList) { |
| | | //有效 |
| | | if (taskUser.getEnable()) { |
| | | TaskUserMongo taskUserMongo = new TaskUserMongo(); |
| | | taskUserMongo.setTask(taskMongo); |
| | | taskUserMongo.setOld_id(taskUser.getId()); |
| | | taskUserMongo.setUserId(taskUser.getUserId()); |
| | | taskUserMongo.setName(task.getName()); |
| | | taskUserMongo.setPerformanceType(task.getPerformanceType()); |
| | | taskUserMongo.setPriority(task.getPriority()); |
| | | taskUserMongo.setPerformanceHours(null); // TODO |
| | | |
| | | taskUserMongo.setPerformanceHours(taskUser.getTaskHours()); |
| | | taskUserMongo.setTaskHours(taskUser.getTaskHours()); |
| | | taskUserMongo.setTaskStartDate(taskUser.getTaskStartDate()); |
| | | taskUserMongo.setTaskEndDate(taskUser.getTaskEndDate()); |
| | | taskUserMongo.setTaskStatus(taskUser.getTaskStatus()); |
| | | taskUserMongo.setRemarks(taskUser.getRemarks()); |
| | | |
| | | mongoTemplate.save(taskUserMongo); |
| | | //查询当前用户的这个任务填写的所有日报 |
| | | List<TaskDaliy> taskDaliyList = taskDaliyRepository.findByTaskIdAndUserId(task.getId(), taskUser.getUserId()); |
| | | // List<TaskDaliy> taskDaliyList = taskDaliyRepository.findTaskDaliyByTaskId(taskUser.getUserId()); |
| | | |
| | | if (taskDaliyList.size() == 0) { |
| | | taskUserMongo.setCostHours(0.0); |
| | | } else { |
| | | taskUserMongo.setCostHours(taskDaliyList.stream().mapToDouble(TaskDaliy::getConsumedHours).sum()); |
| | | } |
| | | mongoTemplate.save(taskUserMongo); |
| | | for (TaskDaliy taskDaliy : taskDaliyList) { |
| | | //查重 |
| | | Query queryDaily = new Query(); |
| | | queryDaily.addCriteria(Criteria.where("userId").is(taskUserMongo.getUserId()).and("fillDate").is(taskDaliy.getFillDate()).and("old_task_id").is(taskDaliy.getTaskId())); |
| | | TaskDaliyMongo existingTaskDaliyMongo = mongoTemplate.findOne(queryDaily, TaskDaliyMongo.class); |
| | | if (existingTaskDaliyMongo != null) { |
| | | continue; |
| | | } |
| | | TaskDaliyMongo taskDaliyMongo = new TaskDaliyMongo(); |
| | | taskDaliyMongo.setOld_task_id(taskDaliy.getTaskId()); |
| | | taskDaliyMongo.setTaskUserMongo(taskUserMongo); |
| | | if (taskDaliy.getConsumedWorkload() != null) { |
| | | taskDaliyMongo.setConsumedWorkload(taskDaliy.getConsumedWorkload()); |
| | | } |
| | | 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) { |