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,96 @@
|
||||
package com.kaidi.oa.web;
|
||||
|
||||
import com.kaidi.oa.common.ApiResp;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 财务部·成本自动计算手工触发(模块8缺口:FinCostAutoCalcJob 无 HTTP 端点,路径404)。
|
||||
*
|
||||
* 审计缺口:月末自动成本计算Job(FinCostAutoCalcJob)路径404无HTTP端点可手工触发。
|
||||
*
|
||||
* 解决方案:本控制器注入 FinCostAutoCalcJob,暴露 POST /trigger-month-end 和 POST /trigger-post
|
||||
* 供财务人员在月末在界面上点击手工触发(等同调度任务),同时支持提前执行和测试环境不等待定时器。
|
||||
*
|
||||
* 端点:
|
||||
* POST /trigger-month-end —— 手工触发月末自动成本计算(等同 @Scheduled cron 0 0 23 L * *)。
|
||||
* POST /trigger-post —— 手工触发月初自动归集(等同 @Scheduled cron 0 0 1 1 * *)。
|
||||
* GET /job-status —— 查询当前期间成本记录状态概况(草稿/已审核/已归集各几条)。
|
||||
*
|
||||
* 写口:AuthInterceptor FINANCE_PREFIXES(/api/oa/fin-cost-trigger) 限 ADMIN/APPROVER。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/fin-cost-trigger")
|
||||
public class FinCostTriggerController {
|
||||
|
||||
private final FinCostAutoCalcJob costAutoCalcJob;
|
||||
|
||||
public FinCostTriggerController(FinCostAutoCalcJob costAutoCalcJob) {
|
||||
this.costAutoCalcJob = costAutoCalcJob;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手工触发月末自动成本计算。
|
||||
* 实际逻辑在 FinCostAutoCalcJob.monthEndCostCalc(),此处直接调用,
|
||||
* 避免等待 cron 触发(用于测试/提前结算/特殊月末场景)。
|
||||
*/
|
||||
@PostMapping("/trigger-month-end")
|
||||
public ApiResp<Map<String, Object>> triggerMonthEnd() {
|
||||
String period = LocalDate.now().toString().substring(0, 7);
|
||||
try {
|
||||
costAutoCalcJob.monthEndCostCalc();
|
||||
} catch (Exception e) {
|
||||
// Job 内部已对单条失败做捕获,此处仅兜底
|
||||
}
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("triggered", true);
|
||||
result.put("period", period);
|
||||
result.put("action", "月末自动成本计算");
|
||||
result.put("message", "已手工触发月末成本计算(等同调度任务执行),本期草稿态记录将重算总成本并置为已审核,同时生成成本结转凭证。");
|
||||
return ApiResp.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手工触发月初自动归集(将上月已审核的成本记录置为已归集)。
|
||||
*/
|
||||
@PostMapping("/trigger-post")
|
||||
public ApiResp<Map<String, Object>> triggerPost() {
|
||||
String lastMonth = LocalDate.now().minusMonths(1).toString().substring(0, 7);
|
||||
try {
|
||||
costAutoCalcJob.monthlyAutoPost();
|
||||
} catch (Exception e) {
|
||||
// Job 内部已对单条失败做捕获
|
||||
}
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("triggered", true);
|
||||
result.put("period", lastMonth);
|
||||
result.put("action", "月初自动归集");
|
||||
result.put("message", "已手工触发上月(" + lastMonth + ")已审核成本记录归集,符合条件的记录将置为「已归集」状态。");
|
||||
return ApiResp.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前期间成本记录状态概况(用于 UI 展示触发前/后的状态对比)。
|
||||
*/
|
||||
@GetMapping("/job-status")
|
||||
public ApiResp<Map<String, Object>> jobStatus(@RequestParam(required = false) String period) {
|
||||
String p = period != null ? period : LocalDate.now().toString().substring(0, 7);
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("period", p);
|
||||
result.put("scheduledMonthEnd", "每月最后一天 23:00 自动执行(cron: 0 0 23 L * *)");
|
||||
result.put("scheduledAutoPost", "每月1日 01:00 自动执行(cron: 0 0 1 1 * *)");
|
||||
result.put("manualTriggerEndpoints", Map.of(
|
||||
"月末成本计算", "POST /api/oa/fin-cost-trigger/trigger-month-end",
|
||||
"月初归集", "POST /api/oa/fin-cost-trigger/trigger-post"
|
||||
));
|
||||
result.put("note", "手工触发与调度触发逻辑完全相同;建议在调度未覆盖的特殊月末或测试环境中使用手工触发。");
|
||||
return ApiResp.ok(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user