1. 提交代码
This commit is contained in:
@@ -25,6 +25,7 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -85,6 +86,15 @@ public class AiAssistantReportController {
|
|||||||
return success(aiAssistantReportService.getMyReportPage(reqVO));
|
return success(aiAssistantReportService.getMyReportPage(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/dept-daily-list")
|
||||||
|
@Operation(summary = "按部门+统计日查询全员汇报(单次查询,用于日志填报汇总)")
|
||||||
|
public CommonResult<List<AiAssistantReportRespVO>> listDeptDailyReports(
|
||||||
|
@Parameter(description = "部门编号", required = true) @RequestParam("deptId") Long deptId,
|
||||||
|
@Parameter(description = "统计日", required = true) @RequestParam("reportDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate reportDate,
|
||||||
|
@Parameter(description = "模块编码(可选)") @RequestParam(value = "moduleCode", required = false) String moduleCode) {
|
||||||
|
return success(aiAssistantReportService.listDeptDailyReports(deptId, reportDate, moduleCode));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/report-count-by-date")
|
@GetMapping("/report-count-by-date")
|
||||||
@Operation(summary = "按日期聚合报告提交数量(用于轨迹图)")
|
@Operation(summary = "按日期聚合报告提交数量(用于轨迹图)")
|
||||||
public CommonResult<List<ReportCountByDateVO>> getReportCountByDate(
|
public CommonResult<List<ReportCountByDateVO>> getReportCountByDate(
|
||||||
@@ -111,6 +121,13 @@ public class AiAssistantReportController {
|
|||||||
return success(aiAssistantReportDetailService.listByReportId(reportId, loginUserId));
|
return success(aiAssistantReportDetailService.listByReportId(reportId, loginUserId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/detail/list-for-manage")
|
||||||
|
@Operation(summary = "按每日汇报主键查询详表(管理端:日志填报汇总等,与 dept-daily-list 同权限)")
|
||||||
|
public CommonResult<List<AiAssistantReportDetailRespVO>> getDetailListForManage(
|
||||||
|
@Parameter(description = "每日汇报主表 ID", required = true) @RequestParam("reportId") Long reportId) {
|
||||||
|
return success(aiAssistantReportDetailService.listByReportIdForManage(reportId));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/detail/save-batch")
|
@PostMapping("/detail/save-batch")
|
||||||
@Operation(summary = "批量保存详表(全量替换:先删后插,与主表保存分步调用)")
|
@Operation(summary = "批量保存详表(全量替换:先删后插,与主表保存分步调用)")
|
||||||
public CommonResult<Boolean> saveDetailBatch(@Valid @RequestBody AiAssistantReportDetailBatchSaveReqVO reqVO) {
|
public CommonResult<Boolean> saveDetailBatch(@Valid @RequestBody AiAssistantReportDetailBatchSaveReqVO reqVO) {
|
||||||
|
|||||||
@@ -5,12 +5,15 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportPageReqVO;
|
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportPageReqVO;
|
||||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.ReportCountByDateVO;
|
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.ReportCountByDateVO;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.module.ydoyun.dal.dataobject.aiassistantreport.AiAssistantReportDO;
|
import cn.iocoder.yudao.module.ydoyun.dal.dataobject.aiassistantreport.AiAssistantReportDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,6 +41,22 @@ public interface AiAssistantReportMapper extends BaseMapperX<AiAssistantReportDO
|
|||||||
.orderByDesc(AiAssistantReportDO::getCreateTime));
|
.orderByDesc(AiAssistantReportDO::getCreateTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定统计日、多名报告人 IN 条件(用于部门汇总一次查全)
|
||||||
|
*/
|
||||||
|
default List<AiAssistantReportDO> selectListByReporterIdsAndReportDate(
|
||||||
|
Collection<Long> reporterIds, String moduleCode, LocalDate reportDate) {
|
||||||
|
if (CollUtil.isEmpty(reporterIds)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return selectList(new LambdaQueryWrapperX<AiAssistantReportDO>()
|
||||||
|
.in(AiAssistantReportDO::getReporterId, reporterIds)
|
||||||
|
.eqIfPresent(AiAssistantReportDO::getModuleCode, moduleCode)
|
||||||
|
.eq(AiAssistantReportDO::getReportTime, reportDate)
|
||||||
|
.orderByDesc(AiAssistantReportDO::getReportTime)
|
||||||
|
.orderByDesc(AiAssistantReportDO::getCreateTime));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前租户下某模块(页面)全部店长的历史汇报,用于 Dify 知识库聚合
|
* 当前租户下某模块(页面)全部店长的历史汇报,用于 Dify 知识库聚合
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ public interface AiAssistantReportDetailService {
|
|||||||
*/
|
*/
|
||||||
List<AiAssistantReportDetailRespVO> listByReportId(@NotNull Long reportId, @NotNull Long loginUserId);
|
List<AiAssistantReportDetailRespVO> listByReportId(@NotNull Long reportId, @NotNull Long loginUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按主表 ID 查询详表(管理端:仅校验主表存在;租户由框架隔离;需接口权限)
|
||||||
|
*/
|
||||||
|
List<AiAssistantReportDetailRespVO> listByReportIdForManage(@NotNull Long reportId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量保存(删除该主表下旧明细后插入新行)
|
* 批量保存(删除该主表下旧明细后插入新行)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -46,6 +46,16 @@ public class AiAssistantReportDetailServiceImpl implements AiAssistantReportDeta
|
|||||||
return BeanUtils.toBean(list, AiAssistantReportDetailRespVO.class);
|
return BeanUtils.toBean(list, AiAssistantReportDetailRespVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AiAssistantReportDetailRespVO> listByReportIdForManage(Long reportId) {
|
||||||
|
AiAssistantReportDO report = aiAssistantReportMapper.selectById(reportId);
|
||||||
|
if (report == null) {
|
||||||
|
throw exception(BAD_REQUEST);
|
||||||
|
}
|
||||||
|
List<AiAssistantReportDetailDO> list = aiAssistantReportDetailMapper.selectListByReportId(reportId);
|
||||||
|
return BeanUtils.toBean(list, AiAssistantReportDetailRespVO.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveBatch(AiAssistantReportDetailBatchSaveReqVO reqVO, Long loginUserId) {
|
public void saveBatch(AiAssistantReportDetailBatchSaveReqVO reqVO, Long loginUserId) {
|
||||||
Long reportId = reqVO.getReportId();
|
Long reportId = reqVO.getReportId();
|
||||||
|
|||||||
@@ -81,4 +81,14 @@ public interface AiAssistantReportService {
|
|||||||
* @param reporterId 当前登录用户 ID,须与记录一致
|
* @param reporterId 当前登录用户 ID,须与记录一致
|
||||||
*/
|
*/
|
||||||
void deleteMyReportToday(Long id, Long reporterId);
|
void deleteMyReportToday(Long id, Long reporterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按部门 + 统计日查询该部门下全员汇报(单次 DB 查询,避免前端按人 N 次请求)
|
||||||
|
*
|
||||||
|
* @param deptId 部门编号(与系统用户 dept_id 一致,不含子部门)
|
||||||
|
* @param reportDate 报告日期
|
||||||
|
* @param moduleCode 模块编码(可选)
|
||||||
|
* @return 汇报列表
|
||||||
|
*/
|
||||||
|
List<AiAssistantReportRespVO> listDeptDailyReports(Long deptId, LocalDate reportDate, String moduleCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.ydoyun.service.aiassistantreport;
|
package cn.iocoder.yudao.module.ydoyun.service.aiassistantreport;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||||
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportPageReqVO;
|
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportPageReqVO;
|
||||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportRespVO;
|
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportRespVO;
|
||||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportSaveReqVO;
|
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportSaveReqVO;
|
||||||
@@ -13,8 +17,12 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
|
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.FORBIDDEN;
|
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.FORBIDDEN;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@@ -32,6 +40,10 @@ public class AiAssistantReportServiceImpl implements AiAssistantReportService {
|
|||||||
private AiAssistantReportMapper aiAssistantReportMapper;
|
private AiAssistantReportMapper aiAssistantReportMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private AiAssistantReportDetailService aiAssistantReportDetailService;
|
private AiAssistantReportDetailService aiAssistantReportDetailService;
|
||||||
|
@Resource
|
||||||
|
private AdminUserService adminUserService;
|
||||||
|
@Resource
|
||||||
|
private DeptService deptService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long saveReport(AiAssistantReportSaveReqVO saveReqVO) {
|
public Long saveReport(AiAssistantReportSaveReqVO saveReqVO) {
|
||||||
@@ -95,6 +107,21 @@ public class AiAssistantReportServiceImpl implements AiAssistantReportService {
|
|||||||
return aiAssistantReportMapper.selectReportCountByDate(reporterId, moduleCode, startDate, endDate);
|
return aiAssistantReportMapper.selectReportCountByDate(reporterId, moduleCode, startDate, endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AiAssistantReportRespVO> listDeptDailyReports(Long deptId, LocalDate reportDate, String moduleCode) {
|
||||||
|
// 含本部门及所有下级部门用户(与左侧部门树父节点选中场景一致;仅 dept_id=deptId 会漏掉子部门用户)
|
||||||
|
Set<Long> deptScope = new HashSet<>(deptService.getChildDeptIdListFromCache(deptId));
|
||||||
|
deptScope.add(deptId);
|
||||||
|
List<AdminUserDO> users = adminUserService.getUserListByDeptIds(deptScope);
|
||||||
|
if (CollUtil.isEmpty(users)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<Long> reporterIds = convertList(users, AdminUserDO::getId);
|
||||||
|
List<AiAssistantReportDO> list = aiAssistantReportMapper.selectListByReporterIdsAndReportDate(
|
||||||
|
reporterIds, moduleCode, reportDate);
|
||||||
|
return BeanUtils.toBean(list, AiAssistantReportRespVO.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMyReportToday(Long id, Long reporterId) {
|
public void deleteMyReportToday(Long id, Long reporterId) {
|
||||||
if (id == null || reporterId == null) {
|
if (id == null || reporterId == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user