From 15248e86807ec54c7578cfa2ab04a3c3e4f852b1 Mon Sep 17 00:00:00 2001 From: xyc <3422692813@qq.com> Date: Mon, 16 Jun 2025 17:00:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspection/entity/InspectionInfo.java | 3 + .../inspection/entity/InspectionWorkNode.java | 3 + .../mapper/InspectionInfoMapper.java | 2 + .../service/IInspectionInfoService.java | 2 + .../impl/AppInspectionPartnerServiceImpl.java | 62 ++++++++++++++----- .../impl/InspectionInfoServiceImpl.java | 24 +++++-- .../InspectionMeetCarOrderServiceImpl.java | 8 ++- .../impl/InspectionStaffServiceImpl.java | 6 ++ .../impl/InspectionWorkNodeServiceImpl.java | 4 +- .../inspection/vo/StaffProjectCountVO.java | 1 + .../mapper/InspectionWorkNodeMapper.xml | 7 ++- .../inspection/InspectionInfoMapper.xml | 6 ++ .../inspection/InspectionStaffMapper.xml | 2 +- 13 files changed, 106 insertions(+), 24 deletions(-) diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java index 873129e5..94841cff 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java @@ -167,6 +167,7 @@ public class InspectionInfo extends TenantBaseDO private Long returnCarUserId; /** 是否还车 */ private Integer isReturnCar; + private Integer returnType; /** 开始检测时需要 传入 选择项目的id、角色id、排序 */ @TableField(exist = false) @@ -207,4 +208,6 @@ public class InspectionInfo extends TenantBaseDO private String appointmentDay; // 经度 @TableField(exist = false) private String appointmentTime; // 经度 + @TableField(exist = false) + private Integer meetType; } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionWorkNode.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionWorkNode.java index d4ac0fe1..f457d30d 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionWorkNode.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionWorkNode.java @@ -115,4 +115,7 @@ public class InspectionWorkNode extends TenantBaseDO { private String meetCarId; @TableField(exist = false) private List idList; + /** 退车时传的退车类型*/ + @TableField(exist = false) + private Integer returnType; } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java index 1571737e..7136168e 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java @@ -97,4 +97,6 @@ public interface InspectionInfoMapper extends BaseMapper IPage geStelectInspectionByBusiness(@Param("page") Page page,@Param("info") InspectionInfo inspectionInfo); + + List selectMeetCarList(); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java index 0931b460..96a075da 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java @@ -175,4 +175,6 @@ public interface IInspectionInfoService extends IService IPage geStelectInspectionByBusiness(Page page, InspectionInfo inspectionInfo); Map getBusinessCountByType(Integer partnerId); + + List selectMeetCarList(); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionPartnerServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionPartnerServiceImpl.java index b5e7493c..af9ee3fc 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionPartnerServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionPartnerServiceImpl.java @@ -2302,37 +2302,71 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl> getStaffCount(DlInspectionProject dlInspectionProject) { List> staffCount = inspectionWorkNodeService.getStaffCount(dlInspectionProject); // 根据userId查询检测工单表 接车人 - List list = inspectionInfoService.list(Wrappers.lambdaQuery() - .eq(InspectionInfo::getIsMeetCar, 1)); + List list = inspectionInfoService.selectMeetCarList(); // 统计每个 meetManId 的数量,避免 null key 异常 - Map meetManIdCountMap = list.stream() + Map> meetManIdCountMap = list.stream() .filter(info -> info.getMeetManId() != null) // 过滤 null 值 - .collect(Collectors.groupingBy(InspectionInfo::getMeetManId, Collectors.counting())); + .collect(Collectors.groupingBy(InspectionInfo::getMeetManId)); // 根据userId查询还车人 List returnCarList = inspectionInfoService.list(Wrappers.lambdaQuery() - .eq(InspectionInfo::getIsReturnCar, 1)); + .eq(InspectionInfo::getIsReturnCar, 1) + .between(CollUtil.isNotEmpty(dlInspectionProject.getDatetimeRange()), InspectionInfo::getEndTime, dlInspectionProject.getDatetimeRange().get(0), dlInspectionProject.getDatetimeRange().get(1))); // 统计每个 returnCarUserId 的数量,避免 null key 异常 - Map returnCarUserIdCountMap = returnCarList.stream() + Map> returnCarUserIdCountMap = returnCarList.stream() .filter(info -> info.getReturnCarUserId() != null) // 过滤 null 值 - .collect(Collectors.groupingBy(InspectionInfo::getReturnCarUserId, Collectors.counting())); + .collect(Collectors.groupingBy(InspectionInfo::getReturnCarUserId)); for (Map stringObjectMap : staffCount) { Long userId = (Long) stringObjectMap.get("userId"); List> children = (List>) stringObjectMap.get("children"); // stringObjectMap.put("meetCarCount", meetManIdCountMap.get(userId)); - stringObjectMap.put("totalCount", (Long) stringObjectMap.get("totalCount") == null ? 0 : (Long) stringObjectMap.get("totalCount") + (meetManIdCountMap.get(userId) == null ? 0 : meetManIdCountMap.get(userId))); + // 获取所有接车信息 + List inspectionInfos = meetManIdCountMap.get(userId); + stringObjectMap.put("totalCount", (Long) stringObjectMap.get("totalCount") == null ? 0 : (Long) stringObjectMap.get("totalCount") + (meetManIdCountMap.get(userId) == null ? 0 : meetManIdCountMap.get(userId).size())); + long meetCount = 0; + long meetGoCount = 0; + if (CollUtil.isNotEmpty(inspectionInfos)) { + meetCount = inspectionInfos.stream().filter(inspectionInfo -> Integer.valueOf(0).equals(inspectionInfo.getMeetType())).count(); + meetGoCount = inspectionInfos.stream().filter(inspectionInfo -> Integer.valueOf(1).equals(inspectionInfo.getMeetType())).count(); + } HashMap objectObjectHashMap = new HashMap<>(); - objectObjectHashMap.put("count", meetManIdCountMap.get(userId) == null ? 0 : meetManIdCountMap.get(userId)); - objectObjectHashMap.put("projectName", "接车"); - + objectObjectHashMap.put("count", meetCount); + objectObjectHashMap.put("projectName", "接车拍照"); children.add(objectObjectHashMap); + HashMap meetCarHashMap = new HashMap<>(); + meetCarHashMap.put("count", meetGoCount); + meetCarHashMap.put("projectName", "上门接车"); + + children.add(meetCarHashMap); //还车 //设置totalCount - stringObjectMap.put("totalCount", (Long) stringObjectMap.get("totalCount") == null ? 0 : (Long) stringObjectMap.get("totalCount") + (returnCarUserIdCountMap.get(userId) == null ? 0 : returnCarUserIdCountMap.get(userId))); + List returnCarInfoList = returnCarUserIdCountMap.get(userId); + long returnCount = 0; + long returnGoCount = 0; + if (CollUtil.isNotEmpty(returnCarInfoList)) { + returnCount = Optional.ofNullable(returnCarInfoList) + .orElse(Collections.emptyList()) + .stream() + .filter(Objects::nonNull) + .filter(i -> i.getReturnType() != null && i.getReturnType() == 0) + .count(); + + returnGoCount = Optional.ofNullable(returnCarInfoList) + .orElse(Collections.emptyList()) + .stream() + .filter(Objects::nonNull) + .filter(i -> i.getReturnType() != null && i.getReturnType() == 1) + .count(); + } + stringObjectMap.put("totalCount", (Long) stringObjectMap.get("totalCount") == null ? 0 : (Long) stringObjectMap.get("totalCount") + (returnCarUserIdCountMap.get(userId) == null ? 0 : returnCarUserIdCountMap.get(userId).size())); Map objectObjectHashMap1 = new HashMap<>(); - objectObjectHashMap1.put("count", returnCarUserIdCountMap.get(userId) == null ? 0 : returnCarUserIdCountMap.get(userId)); - objectObjectHashMap1.put("projectName", "还车"); + objectObjectHashMap1.put("count", returnCount); + objectObjectHashMap1.put("projectName", "还车拍照"); children.add(objectObjectHashMap1); + Map returnCarHashMap = new HashMap<>(); + returnCarHashMap.put("count", returnGoCount); + returnCarHashMap.put("projectName", "上门还车"); + children.add(returnCarHashMap); } // 按 meetCarCount 降序排序员工 staffCount.sort(Comparator.comparingLong( diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java index 820e2af7..3ef6d261 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java @@ -113,7 +113,7 @@ public class InspectionInfoServiceImpl extends ServiceImpllambdaUpdate() .eq(InspectionInfo::getId, inspectionWorkNode.getInspectionInfoId()) .set(InspectionInfo::getIsReturnCar, InspectionConstants.INSPECTION_MEET_CAR_ORDER_IS_MEET_CAR_YES) - .set(InspectionInfo::getReturnCarUserId, SecurityFrameworkUtils.getLoginUserId())); + .set(InspectionInfo::getReturnType, inspectionWorkNode.getReturnType()) + .set(InspectionInfo::getReturnCarUserId, SecurityFrameworkUtils.getLoginUserId())); return true; } @@ -1060,6 +1066,14 @@ public class InspectionInfoServiceImpl extends ServiceImpl selectMeetCarList() { + return baseMapper.selectMeetCarList(); + } + /** * 保存引车员记录 * diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionMeetCarOrderServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionMeetCarOrderServiceImpl.java index 82a6c4a2..2dda11ab 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionMeetCarOrderServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionMeetCarOrderServiceImpl.java @@ -121,13 +121,19 @@ public class InspectionMeetCarOrderServiceImpl extends ServiceImpl> children = (List>) userEntry.get("children"); + if (vo.getCount() == 0) { + continue; + } Map project = new HashMap<>(); project.put("projectName", vo.getProjectName()); project.put("count", vo.getCount()); @@ -477,7 +480,6 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl Long.compare((Long) b.get("totalCount"), (Long) a.get("totalCount"))) .collect(Collectors.toList()); - } /** diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/StaffProjectCountVO.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/StaffProjectCountVO.java index ad97ca2c..b78b5e11 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/StaffProjectCountVO.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/StaffProjectCountVO.java @@ -9,4 +9,5 @@ public class StaffProjectCountVO { private Long count; private String nickname; private String projectName; + private Long nodeCount; } diff --git a/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml b/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml index a0e37ea9..c332215d 100644 --- a/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml @@ -246,10 +246,13 @@ ip.project_name, is2.user_id, su.nickname, - COUNT(iwn.id) AS count + COUNT(iwn.id) AS count, + SUM(iwn.node_count) AS nodeCount FROM inspection_staff is2 CROSS JOIN inspection_project ip LEFT JOIN system_users su ON su.id = is2.user_id + left join system_user_role sr on su.id = sr.user_id + left join system_role sr2 on sr.role_id = sr2.id LEFT JOIN inspection_work_node iwn ON iwn.deal_user_id = is2.user_id AND iwn.project_id = ip.id @@ -258,7 +261,7 @@ WHERE is2.deleted = 0 - AND ip.deleted = 0 + AND su.deleted = 0 and sr2.service_package_id = 'jiance' and sr2.code != 'jcyh' and sr2.code != 'jcywjl' GROUP BY is2.user_id, ip.id diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml index ade6bc61..7f10c800 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml @@ -651,4 +651,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionStaffMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionStaffMapper.xml index b082039b..0e215b33 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionStaffMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionStaffMapper.xml @@ -73,7 +73,7 @@ FROM system_users su left join system_user_role sur on su.id = sur.user_id left join system_role sr on sur.role_id = sr.id - left join inspection_staff iss on iss.user_id = su.id + inner join inspection_staff iss on iss.user_id = su.id sr.service_package_id = 'jiance' and sr.code != 'jcyh' and su.id = #{id}