更新0805

This commit is contained in:
xyc 2025-08-05 14:40:25 +08:00
parent cf9b1f9234
commit 1ef058fb16
11 changed files with 559 additions and 0 deletions

View File

@ -930,6 +930,17 @@ public class PartnerOwnController extends BaseController {
return success(partnerList.getStaffCount(dlInspectionProject)); return success(partnerList.getStaffCount(dlInspectionProject));
} }
/**
* 获取员工统计
*
* @param dlInspectionProject 项目
* @return 结果
*/
@PostMapping("/getStaffCountByUserId")
public CommonResult<?> getStaffCountByUserId(@RequestBody DlInspectionProject dlInspectionProject) {
return success(partnerList.getStaffCountByUserId(dlInspectionProject));
}
/** /**
* 文件统计 * 文件统计
* *

View File

@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.inspection.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject;
import cn.iocoder.yudao.module.inspection.service.StatisticsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @BelongsProject: lanan-system
* @BelongsPackage: cn.iocoder.yudao.module.inspection.controller.admin
* @Author:
* @CreateTime: 2025-08-05 11:16
* @Description: 数据统计接口
* @Version: 1.0
*/
@RestController
@RequestMapping("/inspection/statistics")
@RequiredArgsConstructor
public class StatisticsController {
private final StatisticsService statisticsService;
/**
* @description: 获取员工项目统计信息
* @author:
* @date: 2025/8/5 11:21
* @param: [dlInspectionProject]
* @return: cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@PostMapping("/queryStaffStatisticsInfo")
public CommonResult<?> queryStaffStatisticsInfo(@RequestBody DlInspectionProject dlInspectionProject) {
return CommonResult.success(statisticsService.queryStaffStatisticsInfo(dlInspectionProject));
}
/**
* @description: 获取员工检测项目统计 根据车型
* @author:
* @date: 2025/8/5 14:28
* @param: [dlInspectionProject]
* @return: cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@PostMapping("/queryStaffStatisticsGroupByGoods")
public CommonResult<?> queryStaffStatisticsGroupByGoods(@RequestBody DlInspectionProject dlInspectionProject) {
return CommonResult.success(statisticsService.queryStaffCountGroupByGoods(dlInspectionProject));
}
}

View File

@ -51,4 +51,10 @@ public class DlInspectionProject extends TenantBaseDO {
@TableField(exist = false) @TableField(exist = false)
private List<String> datetimeRange; private List<String> datetimeRange;
@TableField(exist = false)
private Long userId;
@TableField(exist = false)
private String goodsTitle ;
} }

View File

@ -44,6 +44,8 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode>
List<StaffProjectCountVO> getStaffCount(DlInspectionProject dlInspectionProject); List<StaffProjectCountVO> getStaffCount(DlInspectionProject dlInspectionProject);
List<StaffProjectCountVO> getStaffCountByUserId(DlInspectionProject dlInspectionProject);
/** /**
* 根据检测id获取异常节点 * 根据检测id获取异常节点
* @param idList * @param idList
@ -52,4 +54,22 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode>
List<Map<String, Object>> selectExceptionNodesByInspectionIds(@Param("ids") List<Long> idList); List<Map<String, Object>> selectExceptionNodesByInspectionIds(@Param("ids") List<Long> idList);
IPage<Map<String, Object>> selectStaffProjectByUserId(@Param("page")Page<Map<String, Object>> page, @Param("query") InspectionListQuery query); IPage<Map<String, Object>> selectStaffProjectByUserId(@Param("page")Page<Map<String, Object>> page, @Param("query") InspectionListQuery query);
/**
* @description: 查询员工项目统计根据车型
* @author:
* @date: 2025/8/5 13:13
* @param: [dlInspectionProject]
* @return: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
**/
List<Map<String, Object>> queryStaffCountGroupByGoods(DlInspectionProject dlInspectionProject);
/**
* @description: 查询员工项目统计
* @author:
* @date: 2025/8/5 14:07
* @param: [dlInspectionProject]
* @return: java.util.Map<java.lang.String,java.lang.Object>
**/
Map<String, Object> queryStaffInspectionCount(DlInspectionProject dlInspectionProject);
} }

View File

@ -249,6 +249,14 @@ public interface AppInspectionPartnerService extends IService<ShopMallPartners>
*/ */
List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject); List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject);
/**
* 查询员工统计
*
* @param dlInspectionProject 项目信息
* @return 结果
*/
Map<String, Object> getStaffCountByUserId(DlInspectionProject dlInspectionProject);
/** /**
* 文件统计 * 文件统计
* *

View File

@ -76,6 +76,14 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode>
*/ */
List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject); List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject);
/**
* 获取员工统计排序
*
* @param dlInspectionProject
* @return
*/
Map<String, Object> getStaffCountByUserId(DlInspectionProject dlInspectionProject);
/** /**
* 根据检测id获取异常节点 * 根据检测id获取异常节点
* *
@ -89,4 +97,22 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode>
* @param idList * @param idList
*/ */
void updateException(Long inspectionInfoId,List<String> idList); void updateException(Long inspectionInfoId,List<String> idList);
/**
* @description: 员工统计根据车型
* @author:
* @date: 2025/8/5 11:41
* @param: [dlInspectionProject]
* @return: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
**/
List<Map<String, Object>> queryStaffCountGroupByGoods(DlInspectionProject dlInspectionProject);
/**
* @description: 员工统计初检数量和复检数量
* @author:
* @date: 2025/8/5 14:04
* @param: [dlInspectionProject]
* @return: java.util.Map<java.lang.String,java.lang.Object>
**/
Map<String, Object> queryStaffInspectionCount(DlInspectionProject dlInspectionProject);
} }

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.inspection.service;
import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject;
import java.util.Map;
public interface StatisticsService {
/**
* @description: 获取员工统计信息
* @author:
* @date: 2025/8/5 11:25
* @param: [dlInspectionProject]
* @return: java.util.Map<java.lang.String,java.lang.Object>
**/
Map<String, Object> queryStaffStatisticsInfo(DlInspectionProject dlInspectionProject);
/**
* @description: 获取员工统计信息
* @author:
* @date: 2025/8/5 14:30
* @param: [dlInspectionProject]
* @return: java.util.Map<java.lang.String,java.lang.Object>
**/
Map<String, Object> queryStaffCountGroupByGoods(DlInspectionProject dlInspectionProject);
}

View File

@ -2616,6 +2616,105 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
return staffCount; return staffCount;
} }
/**
* 查询员工统计
*
* @param dlInspectionProject 项目信息
* @return 结果
*/
@Override
public Map<String, Object> getStaffCountByUserId(DlInspectionProject dlInspectionProject) {
Map<String, Object> staffCount = inspectionWorkNodeService.getStaffCountByUserId(dlInspectionProject);
if (staffCount == null || staffCount.isEmpty()) {
return Collections.emptyMap();
}
Long userId = (Long) staffCount.get("userId");
Set<Long> inspectionInfoIds = new HashSet<>();
List<Map<String, Object>> children = (List<Map<String, Object>>) staffCount.get("children");
if (children == null) {
children = new ArrayList<>();
staffCount.put("children", children);
}
// 收集已有项目中的 inspectionInfoId
inspectionInfoIds.addAll(
children.stream()
.map(map -> (String) map.get("inspectionInfoId"))
.flatMap(idsStr -> Arrays.stream(idsStr.split(",")))
.map(String::trim)
.filter(idStr -> !idStr.isEmpty())
.map(Long::valueOf)
.collect(Collectors.toSet())
);
// 查询接车信息
List<InspectionInfo> meetCarList = inspectionInfoService.selectMeetCarList(dlInspectionProject.getDatetimeRange());
List<InspectionInfo> userMeetCarList = meetCarList.stream()
.filter(i -> userId.equals(i.getMeetManId()))
.collect(Collectors.toList());
long meetCount = userMeetCarList.stream().filter(i -> Integer.valueOf(0).equals(i.getMeetType())).count();
long meetGoCount = userMeetCarList.stream().filter(i -> Integer.valueOf(1).equals(i.getMeetType())).count();
inspectionInfoIds.addAll(userMeetCarList.stream().map(InspectionInfo::getId).collect(Collectors.toList()));
Map<String, Object> meetPhotoMap = new HashMap<>();
meetPhotoMap.put("projectName", "接车拍照");
meetPhotoMap.put("count", meetCount);
children.add(meetPhotoMap);
Map<String, Object> meetGoMap = new HashMap<>();
meetGoMap.put("projectName", "上门接车");
meetGoMap.put("count", meetGoCount);
children.add(meetGoMap);
// 查询还车信息
LambdaQueryWrapper<InspectionInfo> wrapper = Wrappers.lambdaQuery();
wrapper.eq(InspectionInfo::getIsReturnCar, 1);
List<String> datetimeRange = dlInspectionProject.getDatetimeRange();
if (CollUtil.isNotEmpty(datetimeRange) && datetimeRange.size() == 2) {
wrapper.between(InspectionInfo::getEndTime, datetimeRange.get(0), datetimeRange.get(1));
}
List<InspectionInfo> returnCarList = inspectionInfoService.list(wrapper);
List<InspectionInfo> userReturnCarList = returnCarList.stream()
.filter(i -> userId.equals(i.getReturnCarUserId()))
.collect(Collectors.toList());
long returnCount = userReturnCarList.stream().filter(i -> Integer.valueOf(0).equals(i.getReturnType())).count();
long returnGoCount = userReturnCarList.stream().filter(i -> Integer.valueOf(1).equals(i.getReturnType())).count();
inspectionInfoIds.addAll(userReturnCarList.stream().map(InspectionInfo::getId).collect(Collectors.toList()));
Map<String, Object> returnPhotoMap = new HashMap<>();
returnPhotoMap.put("projectName", "还车拍照");
returnPhotoMap.put("count", returnCount);
children.add(returnPhotoMap);
Map<String, Object> returnGoMap = new HashMap<>();
returnGoMap.put("projectName", "上门还车");
returnGoMap.put("count", returnGoCount);
children.add(returnGoMap);
// 重新设置总数
staffCount.put("totalCount", (long) inspectionInfoIds.size());
// 移除 count == 0 children
children.removeIf(c -> ((Long) c.getOrDefault("count", 0L)) == 0L);
// count 降序排序
children.sort(Comparator.comparingLong(c -> (Long) c.getOrDefault("count", 0L)));
Collections.reverse(children);
return staffCount;
}
/** /**
* 文件统计 * 文件统计
* *

View File

@ -495,6 +495,61 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
/**
* 获取员工统计排序
*
* @param dlInspectionProject
* @return
*/
@Override
public Map<String, Object> getStaffCountByUserId(DlInspectionProject dlInspectionProject) {
Map<Long, Map<String, Object>> tempMap = new LinkedHashMap<>();
List<StaffProjectCountVO> staffCount = baseMapper.getStaffCountByUserId(dlInspectionProject);
for (StaffProjectCountVO vo : staffCount) {
Map<String, Object> userEntry = tempMap.computeIfAbsent(vo.getUserId(), k -> {
Map<String, Object> m = new HashMap<>();
m.put("userId", vo.getUserId());
m.put("nickname", vo.getNickname());
m.put("totalCount", 0L); // 初始总数
m.put("children", new ArrayList<Map<String, Object>>());
return m;
});
// 添加项目
List<Map<String, Object>> children = (List<Map<String, Object>>) userEntry.get("children");
vo.setCount(vo.getCount() == null ? 0 : vo.getCount());
if (vo.getCount() == 0) {
continue;
}
Map<String, Object> project = new HashMap<>();
project.put("projectName", vo.getProjectName());
project.put("count", vo.getCount());
project.put("id", vo.getId());
project.put("inspectionInfoId", vo.getInspectionInfoIds());
children.add(project);
// 累加总数
Long currentTotal = (Long) userEntry.get("totalCount");
userEntry.put("totalCount", currentTotal + vo.getCount());
}
// 如果查出来的用户为空返回空对象
if (tempMap.isEmpty()) {
return Collections.emptyMap();
}
// 只取一个用户数据因为你保证只有一个用户
Map<String, Object> result = tempMap.values().iterator().next();
// 排序该用户下的项目 children
List<Map<String, Object>> children = (List<Map<String, Object>>) result.get("children");
children.sort((a, b) -> Long.compare((Long) b.get("count"), (Long) a.get("count")));
return result;
}
/** /**
* 根据检测id获取异常节点 * 根据检测id获取异常节点
* *
@ -535,6 +590,30 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
inspectionStepService.save(stepInfo); inspectionStepService.save(stepInfo);
} }
/**
* @description: 员工统计根据车型
* @author:
* @date: 2025/8/5 11:41
* @param: [dlInspectionProject]
* @return: java.util.List<java.util.Map < java.lang.String, java.lang.Object>>
*/
@Override
public List<Map<String, Object>> queryStaffCountGroupByGoods(DlInspectionProject dlInspectionProject) {
return baseMapper.queryStaffCountGroupByGoods(dlInspectionProject);
}
/**
* @description: 员工统计初检数量和复检数量
* @author:
* @date: 2025/8/5 14:04
* @param: [dlInspectionProject]
* @return: java.util.Map<java.lang.String, java.lang.Object>
*/
@Override
public Map<String, Object> queryStaffInspectionCount(DlInspectionProject dlInspectionProject) {
return baseMapper.queryStaffInspectionCount(dlInspectionProject);
}
/** /**
* 判断传入的 InspectionWorkNode 对象是否在集合中有后续项目 * 判断传入的 InspectionWorkNode 对象是否在集合中有后续项目
* *

View File

@ -0,0 +1,152 @@
package cn.iocoder.yudao.module.inspection.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject;
import cn.iocoder.yudao.module.inspection.entity.InspectionInfo;
import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService;
import cn.iocoder.yudao.module.inspection.service.IInspectionWorkNodeService;
import cn.iocoder.yudao.module.inspection.service.StatisticsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @BelongsProject: lanan-system
* @BelongsPackage: cn.iocoder.yudao.module.inspection.service.impl
* @Author:
* @CreateTime: 2025-08-05 11:24
* @Description: 数据统计实现类
* @Version: 1.0
*/
@Service
@RequiredArgsConstructor
public class StatisticsServiceImpl implements StatisticsService {
private final IInspectionWorkNodeService inspectionWorkNodeService;
private final IInspectionInfoService inspectionInfoService;
/**
* @description: 获取员工统计信息
* @author:
* @date: 2025/8/5 11:25
* @param: [dlInspectionProject]
* @return: java.util.Map<java.lang.String, java.lang.Object>
*/
@Override
public Map<String, Object> queryStaffStatisticsInfo(DlInspectionProject dlInspectionProject) {
Map<String, Object> result = new HashMap<>();
/*车型数量统计*/
//1.根据userId查询完成的车型数量
List<Map<String, Object>> goodsStatistics = inspectionWorkNodeService.queryStaffCountGroupByGoods(dlInspectionProject);
result.put("goodsStatistics", goodsStatistics);
/*初检数量统计 复检数量统计*/
//1.根据userId查询
Map<String, Object> inspectionStatistics =inspectionWorkNodeService.queryStaffInspectionCount(dlInspectionProject);
result.put("inspectionStatistics", inspectionStatistics);
return result;
}
/**
* @description: 获取员工统计信息
* @author:
* @date: 2025/8/5 14:30
* @param: [dlInspectionProject]
* @return: java.util.Map<java.lang.String, java.lang.Object>
*/
@Override
public Map<String, Object> queryStaffCountGroupByGoods(DlInspectionProject dlInspectionProject) {
Map<String, Object> staffCount = inspectionWorkNodeService.getStaffCountByUserId(dlInspectionProject);
if (staffCount == null || staffCount.isEmpty()) {
return Collections.emptyMap();
}
Long userId = (Long) staffCount.get("userId");
Set<Long> inspectionInfoIds = new HashSet<>();
List<Map<String, Object>> children = (List<Map<String, Object>>) staffCount.get("children");
if (children == null) {
children = new ArrayList<>();
staffCount.put("children", children);
}
// 收集已有项目中的 inspectionInfoId
inspectionInfoIds.addAll(
children.stream()
.map(map -> (String) map.get("inspectionInfoId"))
.flatMap(idsStr -> Arrays.stream(idsStr.split(",")))
.map(String::trim)
.filter(idStr -> !idStr.isEmpty())
.map(Long::valueOf)
.collect(Collectors.toSet())
);
// 查询接车信息
List<InspectionInfo> meetCarList = inspectionInfoService.selectMeetCarList(dlInspectionProject.getDatetimeRange());
List<InspectionInfo> userMeetCarList = meetCarList.stream()
.filter(i -> userId.equals(i.getMeetManId()))
.collect(Collectors.toList());
long meetCount = userMeetCarList.stream().filter(i -> Integer.valueOf(0).equals(i.getMeetType())).count();
long meetGoCount = userMeetCarList.stream().filter(i -> Integer.valueOf(1).equals(i.getMeetType())).count();
inspectionInfoIds.addAll(userMeetCarList.stream().map(InspectionInfo::getId).collect(Collectors.toList()));
Map<String, Object> meetPhotoMap = new HashMap<>();
meetPhotoMap.put("projectName", "接车拍照");
meetPhotoMap.put("count", meetCount);
children.add(meetPhotoMap);
Map<String, Object> meetGoMap = new HashMap<>();
meetGoMap.put("projectName", "上门接车");
meetGoMap.put("count", meetGoCount);
children.add(meetGoMap);
// 查询还车信息
LambdaQueryWrapper<InspectionInfo> wrapper = Wrappers.lambdaQuery();
wrapper.eq(InspectionInfo::getIsReturnCar, 1);
List<String> datetimeRange = dlInspectionProject.getDatetimeRange();
if (CollUtil.isNotEmpty(datetimeRange) && datetimeRange.size() == 2) {
wrapper.between(InspectionInfo::getEndTime, datetimeRange.get(0), datetimeRange.get(1));
}
List<InspectionInfo> returnCarList = inspectionInfoService.list(wrapper);
List<InspectionInfo> userReturnCarList = returnCarList.stream()
.filter(i -> userId.equals(i.getReturnCarUserId()))
.collect(Collectors.toList());
long returnCount = userReturnCarList.stream().filter(i -> Integer.valueOf(0).equals(i.getReturnType())).count();
long returnGoCount = userReturnCarList.stream().filter(i -> Integer.valueOf(1).equals(i.getReturnType())).count();
inspectionInfoIds.addAll(userReturnCarList.stream().map(InspectionInfo::getId).collect(Collectors.toList()));
Map<String, Object> returnPhotoMap = new HashMap<>();
returnPhotoMap.put("projectName", "还车拍照");
returnPhotoMap.put("count", returnCount);
children.add(returnPhotoMap);
Map<String, Object> returnGoMap = new HashMap<>();
returnGoMap.put("projectName", "上门还车");
returnGoMap.put("count", returnGoCount);
children.add(returnGoMap);
// 重新设置总数
staffCount.put("totalCount", (long) inspectionInfoIds.size());
// 移除 count == 0 children
children.removeIf(c -> ((Long) c.getOrDefault("count", 0L)) == 0L);
// count 降序排序
children.sort(Comparator.comparingLong(c -> (Long) c.getOrDefault("count", 0L)));
Collections.reverse(children);
return staffCount;
}
}

View File

@ -267,6 +267,9 @@
<where> <where>
staff.deleted = 0 AND su.deleted = 0 staff.deleted = 0 AND su.deleted = 0
AND (valid_roles.user_id IS NOT NULL) -- 只保留有合格角色的用户 AND (valid_roles.user_id IS NOT NULL) -- 只保留有合格角色的用户
<if test="userId != null and userId != ''">
AND staff.user_id = #{userId}
</if>
</where> </where>
GROUP BY staff.user_id ,ip.id GROUP BY staff.user_id ,ip.id
@ -376,4 +379,83 @@
GROUP BY ii.id GROUP BY ii.id
ORDER BY ii.start_time DESC; ORDER BY ii.start_time DESC;
</select> </select>
<select id="queryStaffCountGroupByGoods" resultType="java.util.Map">
SELECT
oi.goods_title AS goodsTitle,
COUNT(*) AS totalCount
FROM
inspection_work_node iwn
JOIN
inspection_info ii ON iwn.inspection_info_id = ii.id
JOIN
order_info oi ON ii.inspection_order_id = oi.id
WHERE
iwn.deal_user_id = #{userId} -- 替换为你要查询的用户ID
AND iwn.deleted = b'0'
<if test="datetimeRange != null and datetimeRange.size() == 2">
AND ii.create_time BETWEEN CONCAT(#{datetimeRange[0]}, ' 00:00:00') AND CONCAT(#{datetimeRange[1]}, ' 23:59:59')
</if>
AND iwn.status = '2'
AND ii.deleted = 0
AND oi.deleted = 0
GROUP BY
oi.goods_title;
</select>
<select id="queryStaffInspectionCount" resultType="java.util.Map">
SELECT
COUNT(*) AS initialCheckCount,
COALESCE(SUM(CASE
WHEN node_count > 1 THEN node_count - 1
ELSE 0
END), 0) AS recheckCount
FROM inspection_work_node
WHERE deleted = b'0'
AND deal_user_id = #{userId}
AND status = '2'
<if test="datetimeRange != null and datetimeRange.size() == 2">
AND create_time BETWEEN CONCAT(#{datetimeRange[0]}, ' 00:00:00') AND CONCAT(#{datetimeRange[1]}, ' 23:59:59')
</if>
</select>
<select id="getStaffCountByUserId" resultType="cn.iocoder.yudao.module.inspection.vo.StaffProjectCountVO">
SELECT
staff.user_id,
iwn.id,
ip.project_name,
ip.id AS project_id,
GROUP_CONCAT(iwn.inspection_info_id) AS inspectionInfoIds,
su.nickname,
SUM(IF(iwn.node_count = 0, 1, iwn.node_count)) AS count
FROM
inspection_staff staff
LEFT JOIN inspection_work_node iwn ON iwn.deal_user_id = staff.user_id
<if test="datetimeRange != null">
AND iwn.create_time BETWEEN concat(#{datetimeRange[0]}, ' 00:00:00') AND concat(#{datetimeRange[1]}, ' 23:59:59')
</if>
-- ✅ 新增两个表连接
LEFT JOIN inspection_info ii ON iwn.inspection_info_id = ii.id
LEFT JOIN order_info oi ON ii.inspection_order_id = oi.id
-- ✅ 项目表不变
LEFT JOIN inspection_project ip ON ip.id = iwn.project_id
LEFT JOIN (
SELECT DISTINCT sur.user_id
FROM system_user_role sur
JOIN system_role sr ON sur.role_id = sr.id
WHERE sr.service_package_id = 'jiance'
AND sr.CODE NOT IN ('jcyh', 'jcywjl')
) valid_roles ON staff.user_id = valid_roles.user_id
LEFT JOIN system_users su ON su.id = staff.user_id
<where>
staff.deleted = 0 AND su.deleted = 0
AND valid_roles.user_id IS NOT NULL -- 只保留有合格角色的用户
<if test="userId != null and userId != ''">
AND staff.user_id = #{userId}
</if>
<!-- ✅ 根据 goodsTitle 条件过滤 -->
<if test="goodsTitle != null and goodsTitle != ''">
AND oi.goods_title LIKE CONCAT('%', #{goodsTitle}, '%')
</if>
</where>
GROUP BY staff.user_id, ip.id;
</select>
</mapper> </mapper>