From 5d9c814d4fb7e80b470ec8c6208882d2f94b2f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=BE=99?= Date: Tue, 1 Apr 2025 16:00:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=86=E5=8D=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DistributionSplitOrderTaskController.java | 3 +- .../IDistributionSplitOrderTaskService.java | 3 +- ...DistributionSplitOrderTaskServiceImpl.java | 53 +++++++++++-------- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java index 92d184845..08ea01f8e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java @@ -7,6 +7,7 @@ import com.logpm.distribution.entity.DistributionSplitOrderAllTaskEntity; import com.logpm.distribution.entity.DistributionSplitOrderTaskEntity; import com.logpm.distribution.service.IDistributionSplitOrderTaskService; import com.logpm.distribution.vo.DistributionSplitOrderAllTaskVO; +import com.logpm.distribution.vo.DistributionSplitOrderTaskVO; import com.logpm.distribution.vo.SplitPackageOrderVO; import lombok.AllArgsConstructor; import org.slf4j.Logger; @@ -97,7 +98,7 @@ public class DistributionSplitOrderTaskController { } @GetMapping("/task-list") - public R> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) { + public R> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) { return distributionSplitOrderTaskService.taskList(query, distributionSplitTaskSearchDTO); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java index 07710ab16..3362b6689 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java @@ -7,6 +7,7 @@ import com.logpm.distribution.dto.splitOrder.DistributionSplitTaskSearchDTO; import com.logpm.distribution.entity.DistributionSplitOrderAllTaskEntity; import com.logpm.distribution.entity.DistributionSplitOrderTaskEntity; import com.logpm.distribution.vo.DistributionSplitOrderAllTaskVO; +import com.logpm.distribution.vo.DistributionSplitOrderTaskVO; import com.logpm.distribution.vo.SplitPackageOrderVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; @@ -25,7 +26,7 @@ public interface IDistributionSplitOrderTaskService extends BaseService> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO); + R> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO); /** * 拆单总任务 diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java index e2e5a3896..673907ea5 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java @@ -42,7 +42,9 @@ import org.springblade.core.redis.lock.LockType; import org.springblade.core.redis.lock.RedisLockClient; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.system.cache.UserCache; import org.springblade.system.entity.User; +import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -67,7 +69,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) { + public R> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); if (distributionSplitTaskSearchDTO.getSplitOrderAllTaskId() != null) { queryWrapper.eq(DistributionSplitOrderTaskEntity::getSplitOrderAllTaskId, distributionSplitTaskSearchDTO.getSplitOrderAllTaskId()); @@ -91,24 +93,28 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl page = Condition.getPage(query); IPage pageRes = Condition.getPage(query); List list = list(page, queryWrapper); + List listVo = new ArrayList<>(); + if (list != null && !list.isEmpty()) { + Map userIdNameMap = getUserIdNameMap(list.stream().map(DistributionSplitOrderTaskEntity::getCreateUser).collect(Collectors.toList())); + + listVo = list.stream().map(item -> { + DistributionSplitOrderTaskVO distributionSplitOrderTaskVO = new DistributionSplitOrderTaskVO(); + BeanUtil.copyProperties(item, distributionSplitOrderTaskVO); + distributionSplitOrderTaskVO.setCreateUserName(userIdNameMap.get(item.getCreateUser())); + return distributionSplitOrderTaskVO; + }).collect(Collectors.toList()); + } - Map userIdNameMap = getUserIdNameMap(list.stream().map(DistributionSplitOrderTaskEntity::getCreateUser).collect(Collectors.toList())); - - pageRes.setRecords(list.stream().map(item -> { - DistributionSplitOrderTaskVO distributionSplitOrderTaskVO = new DistributionSplitOrderTaskVO(); - BeanUtil.copyProperties(item, distributionSplitOrderTaskVO); - distributionSplitOrderTaskVO.setCreateUserName(userIdNameMap.get(item.getCreateUser())); - return distributionSplitOrderTaskVO; - }).collect(Collectors.toList())); + pageRes.setRecords(listVo); pageRes.setPages(page.getPages()); pageRes.setTotal(page.getTotal()); - return R.data(page); + return R.data(pageRes); } private Map getUserIdNameMap(List list) { String createUserIds = list.stream().map((d) -> d + "").collect(Collectors.joining(",")); - List users = iUserClient.userInfoByIds(AuthUtil.getTenantId(), String.join(",", createUserIds)).getData(); + List users = iUserClient.userInfoByIds(AuthUtil.getTenantId(), createUserIds).getData(); return users.stream().collect(Collectors.toMap(User::getId, User::getName)); } @@ -716,7 +722,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl cancelTask(Long taskId) { DistributionSplitOrderTaskEntity task = getById(taskId); - if (!task.getState().equals(OrderSplitStateConstant.InProgress.getValue())) { + if (!task.getState().equals(OrderSplitStateConstant.finish.getValue())) { return R.fail("任务未已完成,无法操作"); } DistributionSplitOrderAllTaskEntity allTask = distributionSplitOrderAllTaskService.getById(task.getSplitOrderAllTaskId()); @@ -903,16 +909,18 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl list = distributionSplitOrderAllTaskService.list(page, queryWrapper); - - Map userMap = getUserIdNameMap(list.stream().map(DistributionSplitOrderAllTaskEntity::getCreateUser).collect(Collectors.toList())); - Map allTaskIdPackageNumber = getAllTaskIdPackageNumber(list.stream().map(DistributionSplitOrderAllTaskEntity::getId).collect(Collectors.toList())); - List listVo = list.stream().map(d -> { - DistributionSplitOrderAllTaskVO vo = new DistributionSplitOrderAllTaskVO(); - BeanUtil.copyProperties(d, vo); - vo.setCreateUserName(userMap.get(d.getCreateUser())); - vo.setSplitPackageNumber(allTaskIdPackageNumber.get(d.getId())); - return vo; - }).collect(Collectors.toList()); + List listVo = new ArrayList<>(); + if (list != null && !list.isEmpty()) { + Map userMap = getUserIdNameMap(list.stream().map(DistributionSplitOrderAllTaskEntity::getCreateUser).collect(Collectors.toList())); + Map allTaskIdPackageNumber = getAllTaskIdPackageNumber(list.stream().map(DistributionSplitOrderAllTaskEntity::getId).collect(Collectors.toList())); + listVo = list.stream().map(d -> { + DistributionSplitOrderAllTaskVO vo = new DistributionSplitOrderAllTaskVO(); + BeanUtil.copyProperties(d, vo); + vo.setCreateUserName(userMap.get(d.getCreateUser())); + vo.setSplitPackageNumber(allTaskIdPackageNumber.get(d.getId())); + return vo; + }).collect(Collectors.toList()); + } pageResult.setRecords(listVo); pageResult.setPages(page.getPages()); @@ -949,6 +957,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl