This commit is contained in:
xyc 2025-06-16 17:00:56 +08:00
parent c22edb5c6d
commit 15248e8680
13 changed files with 106 additions and 24 deletions

View File

@ -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;
}

View File

@ -115,4 +115,7 @@ public class InspectionWorkNode extends TenantBaseDO {
private String meetCarId;
@TableField(exist = false)
private List<String> idList;
/** 退车时传的退车类型*/
@TableField(exist = false)
private Integer returnType;
}

View File

@ -97,4 +97,6 @@ public interface InspectionInfoMapper extends BaseMapper<InspectionInfo>
IPage<InspectionInfo> geStelectInspectionByBusiness(@Param("page") Page<InspectionInfo> page,@Param("info") InspectionInfo inspectionInfo);
List<InspectionInfo> selectMeetCarList();
}

View File

@ -175,4 +175,6 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
IPage<InspectionInfo> geStelectInspectionByBusiness(Page<InspectionInfo> page, InspectionInfo inspectionInfo);
Map<String, Long> getBusinessCountByType(Integer partnerId);
List<InspectionInfo> selectMeetCarList();
}

View File

@ -2302,37 +2302,71 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
public List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject) {
List<Map<String, Object>> staffCount = inspectionWorkNodeService.getStaffCount(dlInspectionProject);
// 根据userId查询检测工单表 接车人
List<InspectionInfo> list = inspectionInfoService.list(Wrappers.<InspectionInfo>lambdaQuery()
.eq(InspectionInfo::getIsMeetCar, 1));
List<InspectionInfo> list = inspectionInfoService.selectMeetCarList();
// 统计每个 meetManId 的数量避免 null key 异常
Map<Long, Long> meetManIdCountMap = list.stream()
Map<Long, List<InspectionInfo>> meetManIdCountMap = list.stream()
.filter(info -> info.getMeetManId() != null) // 过滤 null
.collect(Collectors.groupingBy(InspectionInfo::getMeetManId, Collectors.counting()));
.collect(Collectors.groupingBy(InspectionInfo::getMeetManId));
// 根据userId查询还车人
List<InspectionInfo> returnCarList = inspectionInfoService.list(Wrappers.<InspectionInfo>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<Long, Long> returnCarUserIdCountMap = returnCarList.stream()
Map<Long, List<InspectionInfo>> returnCarUserIdCountMap = returnCarList.stream()
.filter(info -> info.getReturnCarUserId() != null) // 过滤 null
.collect(Collectors.groupingBy(InspectionInfo::getReturnCarUserId, Collectors.counting()));
.collect(Collectors.groupingBy(InspectionInfo::getReturnCarUserId));
for (Map<String, Object> stringObjectMap : staffCount) {
Long userId = (Long) stringObjectMap.get("userId");
List<Map<String, Object>> children = (List<Map<String, Object>>) 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<InspectionInfo> 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<String, Object> 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<String, Object> 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<InspectionInfo> 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<String, Object> 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<String, Object> returnCarHashMap = new HashMap<>();
returnCarHashMap.put("count", returnGoCount);
returnCarHashMap.put("projectName", "上门还车");
children.add(returnCarHashMap);
}
// meetCarCount 降序排序员工
staffCount.sort(Comparator.comparingLong(

View File

@ -113,7 +113,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
@Autowired
private InspectionStepInfoService inspectionStepInfoService;
@Autowired
private InspectionNoticeService noticeService;
private InspectionNoticeService noticeService;
@Resource
private CustomerMainService customerMainService;
@Autowired
@ -546,7 +546,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
// 查询接车订单信息
InspectionMeetCarOrder order = inspectionMeetCarOrderService.getById(inspectionInfo.getId());
info.put("meetManId", order.getMeetManId());
info.put("day",order.getAppointmentDay());
info.put("day", order.getAppointmentDay());
info.put("carNo", order.getCarNum());
} else {
@ -561,7 +561,6 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
saveLeadRecord(inspectionInfo.getId(), inspectionInfo.getMeetManId());
// // 发送站内信
// String msg = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_ASSIGN_STAFF_MEET_CAR, info.get("day"), inspectionInfo.getCarNum());
// noticeService.sentMessage(inspectionInfo.getLeadManId(), msg);
@ -950,7 +949,13 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
//存入步骤表
InspectionStepInfo stepInfo = new InspectionStepInfo();
stepInfo.setInspectionInfoId(inspectionWorkNode.getInspectionInfoId());
stepInfo.setTitle("还车拍照");
String title = "还车拍照";
if (inspectionWorkNode.getReturnType() == 0 ){
title = "还车拍照";
} else if (inspectionWorkNode.getReturnType() == 1) {
title = "上门还车";
}
stepInfo.setTitle(title);
stepInfo.setContent(remark);
stepInfo.setImages(dealImages);
stepInfo.setCreator(Math.toIntExact(SecurityFrameworkUtils.getLoginUserId()));
@ -964,7 +969,8 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
int update = baseMapper.update(Wrappers.<InspectionInfo>lambdaUpdate()
.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<InspectionInfoMapper,
}
}
/**
* @return
*/
@Override
public List<InspectionInfo> selectMeetCarList() {
return baseMapper.selectMeetCarList();
}
/**
* 保存引车员记录
*

View File

@ -121,13 +121,19 @@ public class InspectionMeetCarOrderServiceImpl extends ServiceImpl<InspectionMee
}
if (StrUtil.isNotEmpty(order.getContent()) || StrUtil.isNotEmpty(order.getImages())) {
String title = "接车拍照";
if (order.getMeetType() == 0) {
title = "接车拍照";
} else if (order.getMeetType() == 1) {
title = "上门接车";
}
// 在步骤表里添加一条记录
InspectionStepInfo inspectionStepInfo = new InspectionStepInfo();
inspectionStepInfo.setInspectionInfoId(order.getId());
//设置开始时间
inspectionStepInfo.setCreateTime(DateUtil.date());
inspectionStepInfo.setCreator(Integer.parseInt(SecurityFrameworkUtils.getLoginUserId() + ""));
inspectionStepInfo.setTitle("接车拍照");
inspectionStepInfo.setTitle(title);
inspectionStepInfo.setContent(order.getContent());
inspectionStepInfo.setImages(order.getImages());
inspectionStepInfo.setStepNum(1);

View File

@ -143,6 +143,12 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
@Override
public InspectionStaffSaveVo get(Long id) {
InspectionStaffSaveVo inspectionStaffSaveVo = baseMapper.get(id);
if (inspectionStaffSaveVo == null) {
// 创建子表
inspectionStaffSaveVo = new InspectionStaffSaveVo();
inspectionStaffSaveVo.setUserId(id);
baseMapper.insert(inspectionStaffSaveVo);
}
if (inspectionStaffSaveVo == null) {
return null;
}

View File

@ -457,6 +457,9 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
// 添加项目
List<Map<String, Object>> children = (List<Map<String, Object>>) userEntry.get("children");
if (vo.getCount() == 0) {
continue;
}
Map<String, Object> project = new HashMap<>();
project.put("projectName", vo.getProjectName());
project.put("count", vo.getCount());
@ -477,7 +480,6 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
})
.sorted((a, b) -> Long.compare((Long) b.get("totalCount"), (Long) a.get("totalCount")))
.collect(Collectors.toList());
}
/**

View File

@ -9,4 +9,5 @@ public class StaffProjectCountVO {
private Long count;
private String nickname;
private String projectName;
private Long nodeCount;
}

View File

@ -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 @@
</if>
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
</select>

View File

@ -651,4 +651,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<select id="selectMeetCarList" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
SELECT ii.*, imco.meet_type
FROM inspection_info ii
LEFT JOIN inspection_meet_car_order imco ON ii.id = imco.inspection_info_id
WHERE ii.deleted = 0 AND imco.deleted = 0 AND imco.is_meet = '1'
</select>
</mapper>

View File

@ -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
<where>
sr.service_package_id = 'jiance' and sr.code != 'jcyh'
and su.id = #{id}