SNAPSHOT W7 已部署稳定态 — 凯迪ERP+OA一体化平台 (MET 73.3%)
恢复点(restore point)。别人改崩后可 git reset --hard 回到此提交。 == 此快照内容 == - 后端 oa-backend: 734 控制器 / 711 实体 (Spring Boot 3.2.5 + SQLite, 端口8091) - 前端 modern-ui/app: Vue3+Vite, 约700页 (构建产物已在 oa-backend/src/main/resources/static) - 数据库 oa-backend/data/oa.db: 含全部演示数据 (强制入库, 6.6MB) - 交接文档 go.md + go-code-reference/endpoints/entities/database.md - 多代理建设脚本 .claude/wf-*.js == 状态 == - 对 凯迪科技ERP_20260507.xlsx 合规 MET ~73.3% (PARTIAL 75: 34可建+6种子/bug+35外部硬天花板) - 安全: 5轮红队+5轮复检, default-deny分级鉴权, 连续零可利用 - W3~W7 累计补完436缺口; W8末轮(40缺口)为半成品(源码树可编译但未集成) - 运行: cd oa-backend; java -jar build/libs/oa-backend-0.1.0.jar --server.port=8091; admin/123456 == 排除(gitignore, 可再生) == node_modules / oa-backend/build / .jdks / *.log / Backup-ERP-* / 弃用的OFBiz核心(只保留modern-ui) 完整文件夹备份见同目录 Backup-ERP-20260615-191517/ (含上述全部, 仅缺 node_modules) 时间戳: 20260615-191517 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
package com.kaidi.oa.web;
|
||||
|
||||
import com.kaidi.oa.common.ApiException;
|
||||
import com.kaidi.oa.common.ApiResp;
|
||||
import com.kaidi.oa.common.NotFoundException;
|
||||
import com.kaidi.oa.domain.AuditNotice;
|
||||
import com.kaidi.oa.domain.AuditProject;
|
||||
import com.kaidi.oa.repository.AuditNoticeRepository;
|
||||
import com.kaidi.oa.repository.AuditProjectRepository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Year;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 审计通知书(内控部·审计监察部·审计项目实施管理)。
|
||||
*
|
||||
* 解决审计缺口:「缺审计通知签收」——在线生成审计通知书,发送至被审计单位,被审计单位在线签收确认。
|
||||
*
|
||||
* 状态机 + 跨实体级联(@Transactional):
|
||||
* - POST / 生成审计通知书(noticeNo 自动编号 AN-yyyy-序号)→ 待签收;
|
||||
* - PATCH /{id}/sign 被审计单位在线签收确认 → 已签收(回写 signedAt/signedBy);
|
||||
* - PATCH /{id}/recall 撤回通知(待签收 → 已撤回);
|
||||
* - DELETE /{id} 删除(仅待签收/已撤回可删除)。
|
||||
*
|
||||
* 联动:签收后自动将关联审计项目状态推进至「实施中」(若当前为「计划」)。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/audit-notices")
|
||||
public class AuditNoticeController {
|
||||
|
||||
private final AuditNoticeRepository noticeRepo;
|
||||
private final AuditProjectRepository projectRepo;
|
||||
|
||||
public AuditNoticeController(AuditNoticeRepository noticeRepo,
|
||||
AuditProjectRepository projectRepo) {
|
||||
this.noticeRepo = noticeRepo;
|
||||
this.projectRepo = projectRepo;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ApiResp<List<AuditNotice>> list(@RequestParam(required = false) Long projectId,
|
||||
@RequestParam(required = false) String status) {
|
||||
if (projectId != null) {
|
||||
return ApiResp.ok(noticeRepo.findByProjectId(projectId));
|
||||
}
|
||||
if (status != null && !status.isBlank()) {
|
||||
return ApiResp.ok(noticeRepo.findByStatus(status));
|
||||
}
|
||||
return ApiResp.ok(noticeRepo.findByOrderByIdDesc());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ApiResp<AuditNotice> get(@PathVariable Long id) {
|
||||
return ApiResp.ok(load(id));
|
||||
}
|
||||
|
||||
public record CreateRequest(
|
||||
Long projectId, String purpose, String plannedStartDate,
|
||||
String issuer, String issueDate) {
|
||||
}
|
||||
|
||||
/** 生成审计通知书(状态 待签收)。 */
|
||||
@PostMapping
|
||||
@Transactional
|
||||
public ApiResp<AuditNotice> create(@RequestBody CreateRequest req) {
|
||||
if (req.projectId() == null) {
|
||||
throw new ApiException(400, "请选择关联审计项目");
|
||||
}
|
||||
AuditProject project = projectRepo.findById(req.projectId())
|
||||
.orElseThrow(() -> new ApiException(400, "审计项目不存在: " + req.projectId()));
|
||||
|
||||
AuditNotice n = new AuditNotice();
|
||||
n.setNoticeNo(nextNoticeNo());
|
||||
n.setProjectId(project.getId());
|
||||
n.setProjectName(project.getName());
|
||||
n.setAuditee(project.getAuditee());
|
||||
n.setAuditPeriod(project.getPeriod());
|
||||
n.setPurpose(req.purpose());
|
||||
n.setPlannedStartDate(req.plannedStartDate());
|
||||
n.setIssuer(req.issuer());
|
||||
n.setIssueDate(req.issueDate() != null && !req.issueDate().isBlank()
|
||||
? req.issueDate() : LocalDate.now().toString());
|
||||
n.setStatus("待签收");
|
||||
n.setCreatedAt(Instant.now());
|
||||
return ApiResp.ok(noticeRepo.save(n));
|
||||
}
|
||||
|
||||
public record SignRequest(String signedBy, String signNote) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 被审计单位在线签收确认 → 已签收。
|
||||
* 联动:若关联审计项目当前为「计划」,自动推进至「实施中」。
|
||||
*/
|
||||
@PatchMapping("/{id}/sign")
|
||||
@Transactional
|
||||
public ApiResp<AuditNotice> sign(@PathVariable Long id, @RequestBody SignRequest req) {
|
||||
AuditNotice n = load(id);
|
||||
if ("已签收".equals(n.getStatus())) {
|
||||
throw new ApiException(409, "该审计通知已签收,请勿重复操作");
|
||||
}
|
||||
if ("已撤回".equals(n.getStatus())) {
|
||||
throw new ApiException(409, "该审计通知已撤回,无法签收");
|
||||
}
|
||||
if (req.signedBy() == null || req.signedBy().isBlank()) {
|
||||
throw new ApiException(400, "签收人不能为空");
|
||||
}
|
||||
n.setSignedBy(req.signedBy());
|
||||
n.setSignedAt(Instant.now());
|
||||
n.setSignNote(req.signNote());
|
||||
n.setStatus("已签收");
|
||||
|
||||
// 联动推进项目状态(计划 → 实施中)。
|
||||
if (n.getProjectId() != null) {
|
||||
projectRepo.findById(n.getProjectId()).ifPresent(p -> {
|
||||
if ("计划".equals(p.getStatus())) {
|
||||
p.setStatus("实施中");
|
||||
projectRepo.save(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
return ApiResp.ok(noticeRepo.save(n));
|
||||
}
|
||||
|
||||
public record RecallRequest(String reason) {
|
||||
}
|
||||
|
||||
/** 撤回通知(仅待签收状态可撤回)。 */
|
||||
@PatchMapping("/{id}/recall")
|
||||
public ApiResp<AuditNotice> recall(@PathVariable Long id, @RequestBody RecallRequest req) {
|
||||
AuditNotice n = load(id);
|
||||
if (!"待签收".equals(n.getStatus())) {
|
||||
throw new ApiException(409, "只有待签收状态的通知书可以撤回");
|
||||
}
|
||||
n.setStatus("已撤回");
|
||||
if (req.reason() != null) {
|
||||
n.setSignNote(req.reason());
|
||||
}
|
||||
return ApiResp.ok(noticeRepo.save(n));
|
||||
}
|
||||
|
||||
/** 删除(仅待签收/已撤回可删)。 */
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResp<Void> delete(@PathVariable Long id) {
|
||||
AuditNotice n = load(id);
|
||||
if ("已签收".equals(n.getStatus())) {
|
||||
throw new ApiException(409, "已签收的审计通知不能删除");
|
||||
}
|
||||
noticeRepo.deleteById(id);
|
||||
return ApiResp.ok(null);
|
||||
}
|
||||
|
||||
private AuditNotice load(Long id) {
|
||||
return noticeRepo.findById(id)
|
||||
.orElseThrow(() -> new NotFoundException("审计通知书不存在: " + id));
|
||||
}
|
||||
|
||||
/** 生成通知书编号 AN-yyyy-序号。 */
|
||||
private String nextNoticeNo() {
|
||||
String year = String.valueOf(Year.now().getValue());
|
||||
long seq = noticeRepo.count() + 1;
|
||||
return String.format("AN-%s-%03d", year, seq);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user