1.调试ai
This commit is contained in:
@@ -56,5 +56,6 @@
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -2,11 +2,18 @@ package cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportDetailBatchSaveReqVO;
|
||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportDetailRespVO;
|
||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportDetailSaveItemVO;
|
||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.AiAssistantReportDifyParseReqVO;
|
||||
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.AiAssistantReportSaveReqVO;
|
||||
import cn.iocoder.yudao.module.ydoyun.controller.admin.aiassistantreport.vo.ReportCountByDateVO;
|
||||
import cn.iocoder.yudao.module.ydoyun.service.aiassistantreport.AiAssistantReportDetailService;
|
||||
import cn.iocoder.yudao.module.ydoyun.service.aiassistantreport.AiAssistantReportService;
|
||||
import cn.iocoder.yudao.module.ydoyun.service.aiassistantreport.DailyReportDifyParseService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -29,6 +36,8 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
public class AiAssistantReportController {
|
||||
|
||||
private final AiAssistantReportService aiAssistantReportService;
|
||||
private final AiAssistantReportDetailService aiAssistantReportDetailService;
|
||||
private final DailyReportDifyParseService dailyReportDifyParseService;
|
||||
|
||||
@PostMapping("/save")
|
||||
@Operation(summary = "保存报告单据")
|
||||
@@ -78,4 +87,35 @@ public class AiAssistantReportController {
|
||||
@Parameter(description = "结束日期", required = true) @RequestParam("endDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
|
||||
return success(aiAssistantReportService.getReportCountByDate(reporterId, moduleCode, startDate, endDate));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除本人「报告日期为当天」的一条记录(历史纠错)")
|
||||
public CommonResult<Boolean> deleteMyReportToday(@Parameter(description = "主键", required = true) @RequestParam("id") Long id) {
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
aiAssistantReportService.deleteMyReportToday(id, loginUserId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/detail/list")
|
||||
@Operation(summary = "按每日汇报主键查询详表(仅本人报告)")
|
||||
public CommonResult<List<AiAssistantReportDetailRespVO>> getDetailList(
|
||||
@Parameter(description = "每日汇报主表 ID", required = true) @RequestParam("reportId") Long reportId) {
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
return success(aiAssistantReportDetailService.listByReportId(reportId, loginUserId));
|
||||
}
|
||||
|
||||
@PostMapping("/detail/save-batch")
|
||||
@Operation(summary = "批量保存详表(全量替换:先删后插,与主表保存分步调用)")
|
||||
public CommonResult<Boolean> saveDetailBatch(@Valid @RequestBody AiAssistantReportDetailBatchSaveReqVO reqVO) {
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
aiAssistantReportDetailService.saveBatch(reqVO, loginUserId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/dify-parse-diagnosis")
|
||||
@Operation(summary = "Dify 智能解析报告正文为「AI经营诊断」详表行(不落库,仅返回列表)")
|
||||
public CommonResult<List<AiAssistantReportDetailSaveItemVO>> difyParseDiagnosis(
|
||||
@Valid @RequestBody AiAssistantReportDifyParseReqVO reqVO) {
|
||||
return success(dailyReportDifyParseService.parseReportToDiagnosisRows(reqVO.getText()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@Data
|
||||
public class AiAssistantReportSaveReqVO {
|
||||
|
||||
@Schema(description = "主键,传入则更新;不传则按报告人+模块编码+报告日期唯一,存在则更新否则新增")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模块名称(当前组件名称)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "模块名称不能为空")
|
||||
private String moduleName;
|
||||
|
||||
@@ -38,6 +38,18 @@ public interface AiAssistantReportMapper extends BaseMapperX<AiAssistantReportDO
|
||||
.orderByDesc(AiAssistantReportDO::getCreateTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一报告人、同一模块编码、同一报告日期的唯一一条(用于 upsert)
|
||||
*/
|
||||
default AiAssistantReportDO selectByReporterModuleAndDate(Long reporterId, String moduleCode, LocalDate reportTime) {
|
||||
return selectOne(new LambdaQueryWrapperX<AiAssistantReportDO>()
|
||||
.eq(AiAssistantReportDO::getReporterId, reporterId)
|
||||
.eq(AiAssistantReportDO::getModuleCode, moduleCode)
|
||||
.eq(AiAssistantReportDO::getReportTime, reportTime)
|
||||
.orderByDesc(AiAssistantReportDO::getId)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定范围内有报告的去重日期列表(用于日历展示)
|
||||
*/
|
||||
|
||||
@@ -73,4 +73,12 @@ public interface AiAssistantReportService {
|
||||
* @return 每日提交数量列表
|
||||
*/
|
||||
List<ReportCountByDateVO> getReportCountByDate(Long reporterId, String moduleCode, LocalDate startDate, LocalDate endDate);
|
||||
|
||||
/**
|
||||
* 删除本人「报告日期为当天」的一条记录(用于历史列表纠错)
|
||||
*
|
||||
* @param id 主键
|
||||
* @param reporterId 当前登录用户 ID,须与记录一致
|
||||
*/
|
||||
void deleteMyReportToday(Long id, Long reporterId);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
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.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* AI 决策助手报告单据 Service 实现类
|
||||
*
|
||||
@@ -26,9 +30,38 @@ public class AiAssistantReportServiceImpl implements AiAssistantReportService {
|
||||
|
||||
@Resource
|
||||
private AiAssistantReportMapper aiAssistantReportMapper;
|
||||
@Resource
|
||||
private AiAssistantReportDetailService aiAssistantReportDetailService;
|
||||
|
||||
@Override
|
||||
public Long saveReport(AiAssistantReportSaveReqVO saveReqVO) {
|
||||
// 显式指定 id:仅允许更新本人数据
|
||||
if (saveReqVO.getId() != null) {
|
||||
AiAssistantReportDO existing = aiAssistantReportMapper.selectById(saveReqVO.getId());
|
||||
if (existing == null) {
|
||||
throw exception(BAD_REQUEST);
|
||||
}
|
||||
if (!existing.getReporterId().equals(saveReqVO.getReporterId())) {
|
||||
throw exception(BAD_REQUEST);
|
||||
}
|
||||
AiAssistantReportDO update = BeanUtils.toBean(saveReqVO, AiAssistantReportDO.class);
|
||||
aiAssistantReportMapper.updateById(update);
|
||||
return update.getId();
|
||||
}
|
||||
// 同一报告人 + 模块编码 + 报告日:至多一条,存在则更新
|
||||
if (saveReqVO.getModuleCode() == null || saveReqVO.getModuleCode().isEmpty()) {
|
||||
throw exception(BAD_REQUEST);
|
||||
}
|
||||
AiAssistantReportDO sameDay = aiAssistantReportMapper.selectByReporterModuleAndDate(
|
||||
saveReqVO.getReporterId(), saveReqVO.getModuleCode(), saveReqVO.getReportTime());
|
||||
if (sameDay != null) {
|
||||
sameDay.setModuleName(saveReqVO.getModuleName());
|
||||
sameDay.setReporter(saveReqVO.getReporter());
|
||||
sameDay.setReportContent(saveReqVO.getReportContent());
|
||||
sameDay.setScreenshotUrl(saveReqVO.getScreenshotUrl());
|
||||
aiAssistantReportMapper.updateById(sameDay);
|
||||
return sameDay.getId();
|
||||
}
|
||||
AiAssistantReportDO entity = BeanUtils.toBean(saveReqVO, AiAssistantReportDO.class);
|
||||
aiAssistantReportMapper.insert(entity);
|
||||
return entity.getId();
|
||||
@@ -61,4 +94,24 @@ public class AiAssistantReportServiceImpl implements AiAssistantReportService {
|
||||
public List<ReportCountByDateVO> getReportCountByDate(Long reporterId, String moduleCode, LocalDate startDate, LocalDate endDate) {
|
||||
return aiAssistantReportMapper.selectReportCountByDate(reporterId, moduleCode, startDate, endDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMyReportToday(Long id, Long reporterId) {
|
||||
if (id == null || reporterId == null) {
|
||||
throw exception(BAD_REQUEST);
|
||||
}
|
||||
AiAssistantReportDO row = aiAssistantReportMapper.selectById(id);
|
||||
if (row == null) {
|
||||
throw exception(BAD_REQUEST);
|
||||
}
|
||||
if (!reporterId.equals(row.getReporterId())) {
|
||||
throw exception(FORBIDDEN);
|
||||
}
|
||||
LocalDate today = LocalDate.now();
|
||||
if (row.getReportTime() == null || !today.equals(row.getReportTime())) {
|
||||
throw exception(BAD_REQUEST);
|
||||
}
|
||||
aiAssistantReportDetailService.deleteByReportId(id);
|
||||
aiAssistantReportMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,6 @@ public class ReportPageService {
|
||||
|
||||
// ---------- admin 直接查全部 ----------
|
||||
if ("admin".equalsIgnoreCase(username)) {
|
||||
|
||||
if ("PINPAI".equals(table)) {
|
||||
sql.append("SELECT PPDM, PPMC FROM ").append(table);
|
||||
} else if ("KEHU".equals(table)) {
|
||||
|
||||
Reference in New Issue
Block a user