Merge branch 'repair'
This commit is contained in:
commit
b0bb97d65f
@ -221,7 +221,7 @@ public class InspectionMallPartnersController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
rows.add(CollUtil.newArrayList(Optional.ofNullable(item.getCarNum()).orElse(item.getCertificateNum()), Optional.ofNullable(item.getGoodsTitle()).orElse(""), Optional.ofNullable(item.getSkuName()).orElse(""), Optional.ofNullable(item.getBusinessChannel()).orElse(""), Optional.ofNullable(item.getCustomerSource()).orElse(""), Optional.ofNullable(item.getOtherName()).orElse(""), Optional.ofNullable(item.getInsuranceCompanyName()).orElse(""), ObjectUtil.isNotEmpty(item.getInsuranceExpiryDate()) ? DateUtil.format(item.getInsuranceExpiryDate(), "yyyy-MM-dd") : "", ObjectUtil.isNotEmpty(item.getVehicleInsuranceExpiryDate()) ? DateUtil.format(item.getVehicleInsuranceExpiryDate(), "yyyy-MM-dd") : "", ObjectUtil.isEmpty(item.getGoodsPrice()) ? "" : BigDecimal.valueOf(item.getGoodsPrice())
|
||||
rows.add(CollUtil.newArrayList(ObjectUtil.isNotEmpty(item.getCarNum()) ? item.getCarNum() : item.getCertificateNum(), Optional.ofNullable(item.getGoodsTitle()).orElse(""), Optional.ofNullable(item.getSkuName()).orElse(""), Optional.ofNullable(item.getBusinessChannel()).orElse(""), Optional.ofNullable(item.getCustomerSource()).orElse(""), Optional.ofNullable(item.getOtherName()).orElse(""), Optional.ofNullable(item.getInsuranceCompanyName()).orElse(""), ObjectUtil.isNotEmpty(item.getInsuranceExpiryDate()) ? DateUtil.format(item.getInsuranceExpiryDate(), "yyyy-MM-dd") : "", ObjectUtil.isNotEmpty(item.getVehicleInsuranceExpiryDate()) ? DateUtil.format(item.getVehicleInsuranceExpiryDate(), "yyyy-MM-dd") : "", ObjectUtil.isEmpty(item.getGoodsPrice()) ? "" : BigDecimal.valueOf(item.getGoodsPrice())
|
||||
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)
|
||||
.toString(), ObjectUtil.isEmpty(item.getRealPayMoney()) ? "暂未支付" : BigDecimal.valueOf(item.getRealPayMoney())
|
||||
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)
|
||||
@ -239,17 +239,18 @@ public class InspectionMallPartnersController extends BaseController {
|
||||
|
||||
//时间类型
|
||||
if (StringUtils.isNotEmpty(query.getDateType())) {
|
||||
filterBuilder.append("时间类型:");
|
||||
if (query.getDateType().equals("nextInspectionTime")) {
|
||||
filterBuilder.append("下次年检时间:")
|
||||
filterBuilder.append("下次年检时间")
|
||||
.append(",");
|
||||
} else if (query.getDateType().equals("jcTime")) {
|
||||
filterBuilder.append("检测时间:")
|
||||
filterBuilder.append("检测时间")
|
||||
.append(",");
|
||||
} else if (query.getDateType().equals("bxTime")) {
|
||||
filterBuilder.append("保险到期时间(交强):")
|
||||
filterBuilder.append("保险到期时间(交强)")
|
||||
.append(",");
|
||||
} else if (query.getDateType().equals("bxVehicleTime")) {
|
||||
filterBuilder.append("保险到期时间(商业):")
|
||||
filterBuilder.append("保险到期时间(商业)")
|
||||
.append(",");
|
||||
}
|
||||
}
|
||||
|
@ -930,6 +930,17 @@ public class PartnerOwnController extends BaseController {
|
||||
return success(partnerList.getStaffCount(dlInspectionProject));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取员工统计
|
||||
*
|
||||
* @param dlInspectionProject 项目
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/getStaffCountByUserId")
|
||||
public CommonResult<?> getStaffCountByUserId(@RequestBody DlInspectionProject dlInspectionProject) {
|
||||
return success(partnerList.getStaffCountByUserId(dlInspectionProject));
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件统计
|
||||
*
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
@ -51,4 +51,10 @@ public class DlInspectionProject extends TenantBaseDO {
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> datetimeRange;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Long userId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String goodsTitle ;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public interface InspectionInfoMapper extends BaseMapper<InspectionInfo>
|
||||
|
||||
IPage<InspectionInfo> geStelectInspectionByBusiness(@Param("page") Page<InspectionInfo> page,@Param("info") InspectionInfo inspectionInfo);
|
||||
|
||||
List<InspectionInfo> selectMeetCarList(@Param("datetimeRange") List<String> datetimeRange);
|
||||
List<InspectionInfo> selectMeetCarList(@Param("datetimeRange") List<String> datetimeRange,@Param("goodsTitle") String goodsTitle);
|
||||
|
||||
Map<String, Object> workOrderDataNew(@Param("query") OrderTableQuery query);
|
||||
|
||||
|
@ -44,6 +44,8 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode>
|
||||
|
||||
List<StaffProjectCountVO> getStaffCount(DlInspectionProject dlInspectionProject);
|
||||
|
||||
List<StaffProjectCountVO> getStaffCountByUserId(DlInspectionProject dlInspectionProject);
|
||||
|
||||
/**
|
||||
* 根据检测id获取异常节点
|
||||
* @param idList
|
||||
@ -52,4 +54,22 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode>
|
||||
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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
@ -249,6 +249,14 @@ public interface AppInspectionPartnerService extends IService<ShopMallPartners>
|
||||
*/
|
||||
List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject);
|
||||
|
||||
/**
|
||||
* 查询员工统计
|
||||
*
|
||||
* @param dlInspectionProject 项目信息
|
||||
* @return 结果
|
||||
*/
|
||||
Map<String, Object> getStaffCountByUserId(DlInspectionProject dlInspectionProject);
|
||||
|
||||
/**
|
||||
* 文件统计
|
||||
*
|
||||
|
@ -181,7 +181,7 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
|
||||
|
||||
Map<String, Long> getBusinessCountByType(Integer partnerId, List<String> datetimeRange);
|
||||
|
||||
List<InspectionInfo> selectMeetCarList(List<String> datetimeRange);
|
||||
List<InspectionInfo> selectMeetCarList(List<String> datetimeRange, String goodsTitle);
|
||||
|
||||
List<InspectionInfo> selectLatestByCarNums(Collection<String> carNos);
|
||||
|
||||
|
@ -76,6 +76,14 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode>
|
||||
*/
|
||||
List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject);
|
||||
|
||||
/**
|
||||
* 获取员工统计排序
|
||||
*
|
||||
* @param dlInspectionProject
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getStaffCountByUserId(DlInspectionProject dlInspectionProject);
|
||||
|
||||
/**
|
||||
* 根据检测id获取异常节点
|
||||
*
|
||||
@ -89,4 +97,22 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode>
|
||||
* @param 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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -2517,7 +2517,7 @@ 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.selectMeetCarList(dlInspectionProject.getDatetimeRange());
|
||||
List<InspectionInfo> list = inspectionInfoService.selectMeetCarList(dlInspectionProject.getDatetimeRange(),null);
|
||||
// 统计每个 meetManId 的数量,避免 null key 异常
|
||||
Map<Long, List<InspectionInfo>> meetManIdCountMap = list.stream()
|
||||
.filter(info -> info.getMeetManId() != null) // 过滤 null 值
|
||||
@ -2602,17 +2602,119 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
|
||||
).reversed());
|
||||
|
||||
// 对每个员工的 children 按 count 降序排序
|
||||
// 对每个员工的 children:先移除 count == 0 的项,再按 count 降序排序
|
||||
staffCount.forEach(staff -> {
|
||||
List<Map<String, Object>> children = (List<Map<String, Object>>) staff.get("children");
|
||||
if (children != null) {
|
||||
children.removeIf(child -> ((Long) child.getOrDefault("count", 0L)) == 0L);
|
||||
children.sort(Comparator.comparingLong(
|
||||
(Map<String, Object> child) -> (Long) child.getOrDefault("count", 0L)
|
||||
).reversed());
|
||||
}
|
||||
});
|
||||
|
||||
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(), dlInspectionProject.getGoodsTitle());
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文件统计
|
||||
*
|
||||
|
@ -200,27 +200,7 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
||||
List<UserDTO> tenantAdmin = roleApi.selectUserListByRoleCode(SecurityFrameworkUtils.getLoginUser().getTenantId(), "tenant_admin");
|
||||
String content = String.join(",", keys);
|
||||
if (CollUtil.isNotEmpty(tenantAdmin)) {
|
||||
// 判断是服务套餐是检测还是驾校
|
||||
switch (inspectionFile.getServicePackageId()) {
|
||||
case "jiance":
|
||||
for (UserDTO userDTO : tenantAdmin) {
|
||||
noticeService.sentMessage(userDTO.getId(), content);
|
||||
}
|
||||
break;
|
||||
case "jiaxiao":
|
||||
for (UserDTO userDTO : tenantAdmin) {
|
||||
// 准备发送参数
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
// 发送模版内容
|
||||
templateParams.put("text", content);
|
||||
commonNotifyMessageSendService.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
|
||||
.setUserId(userDTO.getId())
|
||||
.setTemplateCode(TICKET_EMPLOY)
|
||||
.setSystemCode(SystemEnum.SCHOOL.getCode())
|
||||
.setTemplateParams(templateParams));
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.sendMessage(tenantAdmin.stream().map(UserDTO::getId).collect(Collectors.toList()), content, inspectionFile.getServicePackageId());
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -819,4 +799,26 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
||||
return parentFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @param userIdS 接收人id集合
|
||||
* @param text 消息内容
|
||||
* @param code 服务套餐id
|
||||
*/
|
||||
public void sendMessage(List<Long> userIdS, String text, String code) {
|
||||
// 准备发送参数
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
// 发送模版内容
|
||||
templateParams.put("text", text);
|
||||
// 发送站内信
|
||||
userIdS.forEach(userId -> {
|
||||
commonNotifyMessageSendService.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
|
||||
.setUserId(userId)
|
||||
.setTemplateCode(TICKET_EMPLOY)
|
||||
.setSystemCode(code)
|
||||
.setTemplateParams(templateParams));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1092,8 +1092,8 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<InspectionInfo> selectMeetCarList(List<String> datetimeRange) {
|
||||
return baseMapper.selectMeetCarList(datetimeRange);
|
||||
public List<InspectionInfo> selectMeetCarList(List<String> datetimeRange, String goodsTitle) {
|
||||
return baseMapper.selectMeetCarList(datetimeRange,goodsTitle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -495,6 +495,61 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
.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获取异常节点
|
||||
*
|
||||
@ -535,6 +590,30 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
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 对象是否在集合中有后续项目
|
||||
*
|
||||
|
@ -0,0 +1,160 @@
|
||||
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 cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
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;
|
||||
|
||||
private final AdminUserApi adminUserApi;
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/*获取员工信息*/
|
||||
AdminUserRespDTO user = adminUserApi.getUser(dlInspectionProject.getUserId());
|
||||
result.put("staffInfo", user);
|
||||
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(), dlInspectionProject.getGoodsTitle());
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
//package cn.iocoder.yudao.module.job.logger;
|
||||
//
|
||||
//import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
//import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
//import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//
|
||||
///**
|
||||
// * 物理删除 N 天前的访问日志的 Job
|
||||
// *
|
||||
// * @author j-sentinel
|
||||
// */
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class AccessLogCleanJob implements JobHandler {
|
||||
//
|
||||
// @Resource
|
||||
// private ApiAccessLogService apiAccessLogService;
|
||||
//
|
||||
// /**
|
||||
// * 清理超过(14)天的日志
|
||||
// */
|
||||
// private static final Integer JOB_CLEAN_RETAIN_DAY = 14;
|
||||
//
|
||||
// /**
|
||||
// * 每次删除间隔的条数,如果值太高可能会造成数据库的压力过大
|
||||
// */
|
||||
// private static final Integer DELETE_LIMIT = 100;
|
||||
//
|
||||
// @Override
|
||||
// @TenantIgnore
|
||||
// public String execute(String param) {
|
||||
// Integer count = apiAccessLogService.cleanAccessLog(JOB_CLEAN_RETAIN_DAY, DELETE_LIMIT);
|
||||
// log.info("[execute][定时执行清理访问日志数量 ({}) 个]", count);
|
||||
// return String.format("定时执行清理访问日志数量 %s 个", count);
|
||||
// }
|
||||
//
|
||||
//}
|
@ -267,6 +267,9 @@
|
||||
<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>
|
||||
|
||||
</where>
|
||||
GROUP BY staff.user_id ,ip.id
|
||||
@ -376,4 +379,83 @@
|
||||
GROUP BY ii.id
|
||||
ORDER BY ii.start_time DESC;
|
||||
</select>
|
||||
<select id="queryStaffCountGroupByGoods" resultType="java.util.Map">
|
||||
SELECT
|
||||
oi.goods_title AS goodsTitle,
|
||||
COUNT(DISTINCT ii.id) 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>
|
||||
|
@ -707,6 +707,7 @@ FROM
|
||||
ON ii.id = iwn_agg.inspection_info_id
|
||||
LEFT JOIN shop_user_car car on car.car_no = ii.car_num
|
||||
<where>
|
||||
ii.deleted = 0 AND oi.deleted = 0
|
||||
<if test="query.payType!=null and query.payType!=''">
|
||||
AND oi.pay_type = #{query.payType}
|
||||
</if>
|
||||
|
@ -700,11 +700,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
SELECT ii.*, imco.meet_type
|
||||
FROM inspection_info ii
|
||||
LEFT JOIN inspection_meet_car_order imco ON ii.id = imco.inspection_info_id
|
||||
JOIN order_info oi ON oi.id = ii.inspection_order_id
|
||||
<where>
|
||||
ii.deleted = 0 AND imco.deleted = 0 AND imco.is_meet = '1'
|
||||
<if test="datetimeRange != null">
|
||||
AND imco.create_time BETWEEN #{datetimeRange[0]} AND #{datetimeRange[1]}
|
||||
</if>
|
||||
<if test="goodsTitle != null and goodsTitle != ''">
|
||||
AND oi.goods_title = #{goodsTitle}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="pageWorkOrderNew" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||||
|
@ -2,22 +2,42 @@ package cn.iocoder.yudao.module.base.controller.admin;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
|
||||
import cn.iocoder.yudao.common.SystemEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.base.entity.RepairStaff;
|
||||
import cn.iocoder.yudao.module.base.entity.RepairStaffSaveVo;
|
||||
import cn.iocoder.yudao.module.base.service.RepairStaffService;
|
||||
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
|
||||
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
|
||||
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/base/repair-staff")
|
||||
@RequiredArgsConstructor
|
||||
@ -25,6 +45,8 @@ public class RepairStaffController {
|
||||
private final AdminUserService userService;
|
||||
private final RoleService roleService;
|
||||
|
||||
private final RepairStaffService repairStaffService;
|
||||
|
||||
/**
|
||||
* 获取维修员工信息
|
||||
*
|
||||
@ -36,7 +58,7 @@ public class RepairStaffController {
|
||||
// 查询信息
|
||||
AdminUserDO user = userService.getUser(id);
|
||||
if (user == null) {
|
||||
return CommonResult.error(400,"用户不存在");
|
||||
return CommonResult.error(400, "用户不存在");
|
||||
}
|
||||
|
||||
// 查询对应角色
|
||||
@ -53,7 +75,40 @@ public class RepairStaffController {
|
||||
.collect(Collectors.toList());
|
||||
repairStaff.setRoles(weixiuRoleDOS);
|
||||
|
||||
return CommonResult.success(repairStaff);
|
||||
return success(repairStaff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增员工
|
||||
*
|
||||
* @param repairStaff 员工信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
public CommonResult<?> addStaff(@RequestBody RepairStaffSaveVo repairStaff) {
|
||||
repairStaffService.addStaff(repairStaff);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/listSelectUser")
|
||||
public CommonResult<?> listSelectUser(@Valid UserPageReqVO pageReqVO){
|
||||
// 查询目前所有的userId
|
||||
RolePageReqVO role = new RolePageReqVO();
|
||||
role.setPageNo(1);
|
||||
role.setPageSize(1000000);
|
||||
IPage<UserDTO> userDTOIPage = roleService.selectListByRoleIdRepair(role);
|
||||
// 获取所有的userId
|
||||
List<Long> ids = userDTOIPage.getRecords().stream().map(UserDTO::getId).collect(Collectors.toList());
|
||||
pageReqVO.setUserIds(ids);
|
||||
// 获得用户分页列表
|
||||
PageResult<AdminUserDO> pageResult = userService.getUserPage(pageReqVO);
|
||||
return success(new PageResult<>(pageResult.getList(), pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@DeleteMapping("/deleteStaff")
|
||||
public CommonResult<?> deleteStaff(Long id) {
|
||||
repairStaffService.deleteStaff(id);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.base.entity;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
public class RepairStaffSaveVo {
|
||||
/**
|
||||
* 选择的员工
|
||||
*/
|
||||
public List<UserDTO> repairStaffs;
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private Set<Long> roleIds = Collections.emptySet();
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.base.service;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.base.entity.RepairStaffSaveVo;
|
||||
|
||||
public interface RepairStaffService {
|
||||
/**
|
||||
* 新增员工
|
||||
*
|
||||
* @param repairStaff
|
||||
*/
|
||||
public void addStaff(RepairStaffSaveVo repairStaff);
|
||||
|
||||
/**
|
||||
* 删除员工
|
||||
* @param id
|
||||
*/
|
||||
void deleteStaff(Long id);
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package cn.iocoder.yudao.module.base.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
|
||||
import cn.iocoder.yudao.common.SystemEnum;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.base.entity.RepairStaffSaveVo;
|
||||
import cn.iocoder.yudao.module.base.service.RepairStaffService;
|
||||
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
|
||||
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
|
||||
import cn.iocoder.yudao.module.staff.service.UniqueCodeService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RepairStaffServiceImpl implements RepairStaffService {
|
||||
|
||||
private final AdminUserService userService;
|
||||
|
||||
private final RoleService roleService;
|
||||
|
||||
private final PermissionService permissionService;
|
||||
|
||||
private final CompanyStaffService companyStaffService;
|
||||
|
||||
private final DeptApi deptApi;
|
||||
|
||||
private final AdminUserApi adminUserApi;
|
||||
|
||||
private final UniqueCodeService uniqueCodeService;
|
||||
|
||||
public void addStaff(RepairStaffSaveVo repairStaff) {
|
||||
// 获取当前登录用户的详细信息
|
||||
AdminUserRespDTO loginUser = getLoginUser();
|
||||
// 1. 分配角色
|
||||
repairStaff.getRepairStaffs().forEach(item -> {
|
||||
permissionService.assignUserRoleByServicePackageId(item.getId(), repairStaff.getRoleIds(), SystemEnum.REPAIR.getCode());
|
||||
});
|
||||
// 2. 查看员工表中是否存在
|
||||
List<Long> oldIds = repairStaff.getRepairStaffs().stream().map(UserDTO::getId).collect(Collectors.toList());
|
||||
List<CompanyStaff> staffList = companyStaffService.list(Wrappers.<CompanyStaff>lambdaQuery()
|
||||
.in(CompanyStaff::getUserId, oldIds));
|
||||
|
||||
// 获取员工表中已有的用户ID集合
|
||||
Set<Long> existUserIds = staffList.stream()
|
||||
.map(CompanyStaff::getUserId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 找出不存在于员工表中的用户ID
|
||||
List<UserDTO> notExistUsers = repairStaff.getRepairStaffs().stream()
|
||||
.filter(user -> !existUserIds.contains(user.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
/* 插入员工库 */
|
||||
DeptRespDTO loginDept = getLoginDept(loginUser.getDeptId());
|
||||
|
||||
// 添加员工
|
||||
if (CollectionUtil.isNotEmpty(notExistUsers)) {
|
||||
List<CompanyStaff> companyStaffs = new ArrayList<>();
|
||||
for (UserDTO notExistUser : notExistUsers) {
|
||||
CompanyStaff companyStaff = new CompanyStaff();
|
||||
|
||||
// 1 获取当前登录用户的企业信息给添加的员工
|
||||
// 2 生成唯一推广码
|
||||
String uniqueCode = uniqueCodeService.createUniqueCode();
|
||||
if (!ObjectUtil.isNotEmpty(uniqueCode)) {
|
||||
throw exception(CommonErrorCodeConstants.UNIQUE_CODE_CREATE_REPEAT);
|
||||
}
|
||||
companyStaff.setCorpId(loginDept.getCorpId());
|
||||
companyStaff.setUserId(notExistUser.getId());
|
||||
companyStaff.setName(notExistUser.getNickname());
|
||||
companyStaff.setTel(notExistUser.getUsername());
|
||||
companyStaff.setUniqueCode(uniqueCode);
|
||||
|
||||
companyStaffs.add(companyStaff);
|
||||
}
|
||||
companyStaffService.saveBatch(companyStaffs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除员工
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void deleteStaff(Long id) {
|
||||
boolean remove = companyStaffService.remove(Wrappers.<CompanyStaff>lambdaQuery()
|
||||
.eq(CompanyStaff::getUserId, id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的部门详细信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @author 小李
|
||||
* @date 17:28 2024/8/9
|
||||
**/
|
||||
private DeptRespDTO getLoginDept(Long deptId) {
|
||||
return deptApi.getDept(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的详细信息
|
||||
*
|
||||
* @author 小李
|
||||
* @date 17:27 2024/8/9
|
||||
**/
|
||||
private AdminUserRespDTO getLoginUser() {
|
||||
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
||||
return adminUserApi.getUser(userId);
|
||||
}
|
||||
}
|
@ -138,7 +138,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from system_users su
|
||||
left join system_user_role sr on su.id = sr.user_id and sr.deleted = 0
|
||||
left join system_role sr2 on sr.role_id = sr2.id
|
||||
-- INNER JOIN dl_repair_worker dsc ON dsc.user_id = su.id
|
||||
INNER JOIN company_staff dsc ON dsc.user_id = su.id
|
||||
<where>
|
||||
su.deleted = 0 and sr2.service_package_id = 'weixiu'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user