diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java index b6516a80..6c61363e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java @@ -123,6 +123,12 @@ public class RepairWorkerController { return success(workerService.listByLeads()); } + @GetMapping("/listLeadsAll") + @Operation(summary = "通过班组长的id查该班组的员工(不去掉班组长)") + public CommonResult listLeadsAll() { + return success(workerService.listLeadsAll()); + } + /** * 查当前登录用户是否维修班组长 * @author vinjor-M diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java index 72ac833c..f1edb86f 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java @@ -106,6 +106,14 @@ public interface RepairWorkerService extends IService { **/ List listByLeads(); + /** + * 通过班组长的id查该班组的员工(不去掉班组长) + * @author PQZ + * @date 15:20 2024/11/13 + * @return java.util.List + **/ + List listLeadsAll(); + /** * 查当前登录用户是否维修班组长 * @author vinjor-M diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java index 52f29168..5110d502 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java @@ -272,6 +272,21 @@ public class RepairWorkerServiceImpl extends ServiceImpl !Objects.equals(item.getUserId(), worker.getUserId())).collect(Collectors.toList()); } + /** + * 通过班组长的id查该班组的员工()不去掉班组长 + * + * @return java.util.List + * @author PQZ + * @date 15:20 2024/11/13 + **/ + @Override + public List listLeadsAll() { + // 取班组长的记录 + RepairWorker worker = baseMapper.selectOne(new LambdaQueryWrapper().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId())); + // 根据班组长的工种查所有该工程的工人 + return baseMapper.selectList(new LambdaQueryWrapper().eq(RepairWorker::getWorkType, worker.getWorkType())); + } + /** * 查当前登录用户是否维修班组长 * diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index 9f9a64a4..004c33c6 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.common.*; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.base.entity.RepairWorker; @@ -876,7 +877,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl list = repairWorkerService.list(); + //查询当前工单下所有项目 + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(DlRepairTitem::getTicketId,ticketId); + List itemList = titemService.list(lambdaQueryWrapper); + //过滤出不包括当前指派人的值 + List filterList = itemList.stream().filter(item -> !item.getRepairNames().contains(nowRepairName)).collect(Collectors.toList()); + List saveList = new ArrayList<>(); + //当前处理人工作组 + Map workerMap = list.stream().collect(Collectors.toMap(RepairWorker::getUserId,worker -> worker)); + String workType = workerMap.get(nowRepairId).getWorkType(); + filterList.forEach(item -> { + //深拷贝 + DlRepairTitem saveItem = BeanUtils.toBean(item,DlRepairTitem.class); + if (StringUtils.isNotEmpty(saveItem.getRepairIds())){ + //取出用户id + List repairIds = Arrays.stream(saveItem.getRepairIds().split(",")).map(Long::parseLong).collect(Collectors.toList()); + repairIds.forEach(idItem -> { + // 获取对应的 worker + RepairWorker worker = workerMap.get(idItem); + // 检查 worker 是否存在并比较 workType + if (worker != null && workType.equals(worker.getWorkType())) { + saveList.add(saveItem); + return; + } + }); + } + }); + saveList.forEach(item -> { + String newRepairId = item.getRepairIds()+","+nowRepairId; + String newRepairName = item.getRepairNames() + "," + nowRepairName; + item.setRepairIds(newRepairId); + item.setRepairNames(newRepairName); + }); + titemService.updateBatchById(saveList); + + } + /** * 更新工单状态(针对开始施工、施工中记录、施工完成) *