恢复点(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>
163 lines
7.5 KiB
Java
163 lines
7.5 KiB
Java
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.InternalControlMatrix;
|
|
import com.kaidi.oa.repository.InternalControlMatrixRepository;
|
|
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.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 法务合规·内控矩阵。把关键风险点映射到业务流程的控制措施,并定期测试控制有效性。
|
|
* 含控制点登记、控制有效性测试(记录最近测试日 + 有效性结论)、按控制类型/流程的有效性统计。
|
|
*
|
|
* 读口含内部控制治理信息,已登记进 SENSITIVE_READ_PREFIXES;写口受 default-deny 保护。
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/api/oa/control-matrices")
|
|
public class InternalControlMatrixController {
|
|
|
|
private final InternalControlMatrixRepository repo;
|
|
|
|
public InternalControlMatrixController(InternalControlMatrixRepository repo) {
|
|
this.repo = repo;
|
|
}
|
|
|
|
@GetMapping
|
|
public ApiResp<List<InternalControlMatrix>> list(@RequestParam(required = false) String controlType,
|
|
@RequestParam(required = false) String effectiveness) {
|
|
if (controlType != null && !controlType.isBlank()) {
|
|
return ApiResp.ok(repo.findByControlType(controlType));
|
|
}
|
|
if (effectiveness != null && !effectiveness.isBlank()) {
|
|
return ApiResp.ok(repo.findByEffectiveness(effectiveness));
|
|
}
|
|
return ApiResp.ok(repo.findAll());
|
|
}
|
|
|
|
@GetMapping("/{id}")
|
|
public ApiResp<InternalControlMatrix> get(@PathVariable Long id) {
|
|
return ApiResp.ok(repo.findById(id)
|
|
.orElseThrow(() -> new NotFoundException("control matrix not found: " + id)));
|
|
}
|
|
|
|
public record ControlRequest(
|
|
String code, String process, String riskPoint, String controlMeasure, String controlType,
|
|
String frequency, String owner, String effectiveness, String lastTestDate, String remark) {
|
|
}
|
|
|
|
@PostMapping
|
|
public ApiResp<InternalControlMatrix> create(@RequestBody ControlRequest req) {
|
|
if (req.process() == null || req.process().isBlank()) {
|
|
throw new ApiException(400, "业务流程(process) 不能为空");
|
|
}
|
|
if (req.controlMeasure() == null || req.controlMeasure().isBlank()) {
|
|
throw new ApiException(400, "控制措施(controlMeasure) 不能为空");
|
|
}
|
|
InternalControlMatrix c = new InternalControlMatrix();
|
|
c.setCode(req.code() == null || req.code().isBlank()
|
|
? "NKJZ-" + (repo.count() + 1) : req.code());
|
|
c.setProcess(req.process());
|
|
c.setRiskPoint(req.riskPoint());
|
|
c.setControlMeasure(req.controlMeasure());
|
|
c.setControlType(req.controlType() == null || req.controlType().isBlank() ? "预防" : req.controlType());
|
|
c.setFrequency(req.frequency());
|
|
c.setOwner(req.owner());
|
|
c.setEffectiveness(req.effectiveness() == null || req.effectiveness().isBlank() ? "未测试" : req.effectiveness());
|
|
c.setLastTestDate(req.lastTestDate());
|
|
c.setRemark(req.remark());
|
|
c.setCreatedAt(Instant.now());
|
|
return ApiResp.ok(repo.save(c));
|
|
}
|
|
|
|
@PatchMapping("/{id}")
|
|
public ApiResp<InternalControlMatrix> update(@PathVariable Long id, @RequestBody ControlRequest req) {
|
|
InternalControlMatrix c = repo.findById(id)
|
|
.orElseThrow(() -> new NotFoundException("control matrix not found: " + id));
|
|
if (req.process() != null && !req.process().isBlank()) c.setProcess(req.process());
|
|
if (req.riskPoint() != null) c.setRiskPoint(req.riskPoint());
|
|
if (req.controlMeasure() != null && !req.controlMeasure().isBlank()) c.setControlMeasure(req.controlMeasure());
|
|
if (req.controlType() != null && !req.controlType().isBlank()) c.setControlType(req.controlType());
|
|
if (req.frequency() != null) c.setFrequency(req.frequency());
|
|
if (req.owner() != null) c.setOwner(req.owner());
|
|
if (req.effectiveness() != null && !req.effectiveness().isBlank()) c.setEffectiveness(req.effectiveness());
|
|
if (req.lastTestDate() != null) c.setLastTestDate(req.lastTestDate());
|
|
if (req.remark() != null) c.setRemark(req.remark());
|
|
return ApiResp.ok(repo.save(c));
|
|
}
|
|
|
|
@DeleteMapping("/{id}")
|
|
public ApiResp<Void> delete(@PathVariable Long id) {
|
|
if (!repo.existsById(id)) {
|
|
throw new NotFoundException("control matrix not found: " + id);
|
|
}
|
|
repo.deleteById(id);
|
|
return ApiResp.ok(null);
|
|
}
|
|
|
|
// ---------- 控制有效性测试 ----------
|
|
|
|
public record TestRequest(String effectiveness, String testDate, String remark) {
|
|
}
|
|
|
|
/**
|
|
* 记录一次控制有效性测试:回填测试结论(有效/部分有效/失效)与测试日。未传日期默认今天。
|
|
*/
|
|
@PostMapping("/{id}/test")
|
|
public ApiResp<InternalControlMatrix> test(@PathVariable Long id, @RequestBody TestRequest req) {
|
|
InternalControlMatrix c = repo.findById(id)
|
|
.orElseThrow(() -> new NotFoundException("control matrix not found: " + id));
|
|
if (req.effectiveness() == null || req.effectiveness().isBlank()) {
|
|
throw new ApiException(400, "测试结论(effectiveness) 不能为空");
|
|
}
|
|
c.setEffectiveness(req.effectiveness());
|
|
c.setLastTestDate(req.testDate() == null || req.testDate().isBlank()
|
|
? LocalDate.now().toString() : req.testDate());
|
|
if (req.remark() != null && !req.remark().isBlank()) {
|
|
c.setRemark(req.remark());
|
|
}
|
|
return ApiResp.ok(repo.save(c));
|
|
}
|
|
|
|
// ---------- 有效性统计 ----------
|
|
|
|
public record EffectivenessSummary(int total, Map<String, Integer> byEffectiveness,
|
|
Map<String, Integer> byControlType, int untested) {
|
|
}
|
|
|
|
/**
|
|
* 内控矩阵有效性概览:按有效性结论、按控制类型分桶计数,并给未测试控制点数(用于驱动控制测试计划)。
|
|
*/
|
|
@GetMapping("/stats/effectiveness")
|
|
public ApiResp<EffectivenessSummary> effectivenessStats() {
|
|
List<InternalControlMatrix> all = repo.findAll();
|
|
Map<String, Integer> byEff = new LinkedHashMap<>();
|
|
Map<String, Integer> byType = new LinkedHashMap<>();
|
|
int untested = 0;
|
|
for (InternalControlMatrix c : all) {
|
|
String eff = c.getEffectiveness() == null || c.getEffectiveness().isBlank() ? "未测试" : c.getEffectiveness();
|
|
String type = c.getControlType() == null || c.getControlType().isBlank() ? "未分类" : c.getControlType();
|
|
byEff.merge(eff, 1, Integer::sum);
|
|
byType.merge(type, 1, Integer::sum);
|
|
if ("未测试".equals(eff)) {
|
|
untested++;
|
|
}
|
|
}
|
|
return ApiResp.ok(new EffectivenessSummary(all.size(), byEff, byType, untested));
|
|
}
|
|
}
|