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,336 @@
|
||||
package com.kaidi.oa.web;
|
||||
|
||||
import com.kaidi.oa.common.ApiResp;
|
||||
import com.kaidi.oa.domain.QualCert;
|
||||
import com.kaidi.oa.domain.QualDeclFee;
|
||||
import com.kaidi.oa.domain.QualDeclaration;
|
||||
import com.kaidi.oa.domain.StaffCredential;
|
||||
import com.kaidi.oa.repository.QualCertRepository;
|
||||
import com.kaidi.oa.repository.QualDeclFeeRepository;
|
||||
import com.kaidi.oa.repository.QualDeclarationRepository;
|
||||
import com.kaidi.oa.repository.StaffCredentialRepository;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 行政·综合部——资质报表与决策分析(Module 8 缺口)。
|
||||
*
|
||||
* 补完缺口(4 个独立聚合端点):
|
||||
* GET /qual-analytics/panorama — 资质全景图:所有资质按等级/有效期/业务板块可视化数据
|
||||
* GET /qual-analytics/calendar — 资质到期日历:未来 12 个月到期资质分月汇总
|
||||
* GET /qual-analytics/cert-gap — 人员证书统计与资质标准差距仪表板
|
||||
* GET /qual-analytics/roi — 申报成本 ROI 分析(费用台账 + 关联中标额)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/qual-analytics")
|
||||
public class QualAnalyticsController {
|
||||
|
||||
private final QualCertRepository certRepo;
|
||||
private final StaffCredentialRepository credRepo;
|
||||
private final QualDeclarationRepository declRepo;
|
||||
private final QualDeclFeeRepository feeRepo;
|
||||
|
||||
public QualAnalyticsController(QualCertRepository certRepo,
|
||||
StaffCredentialRepository credRepo,
|
||||
QualDeclarationRepository declRepo,
|
||||
QualDeclFeeRepository feeRepo) {
|
||||
this.certRepo = certRepo;
|
||||
this.credRepo = credRepo;
|
||||
this.declRepo = declRepo;
|
||||
this.feeRepo = feeRepo;
|
||||
}
|
||||
|
||||
// ---------- 资质全景图 ----------
|
||||
|
||||
/**
|
||||
* 资质全景图:图形化展示所有资质的等级/有效期/业务板块/状态分布。
|
||||
* 前端可用饼图/条形图渲染。
|
||||
*
|
||||
* 满足需求:"图形化展示公司拥有的所有资质、等级、有效期,按业务板块分类"。
|
||||
*/
|
||||
@GetMapping("/panorama")
|
||||
public ApiResp<Map<String, Object>> panorama() {
|
||||
List<QualCert> all = certRepo.findAll();
|
||||
|
||||
// 按状态分组计数
|
||||
Map<String, Integer> byStatus = new LinkedHashMap<>();
|
||||
for (QualCert c : all) {
|
||||
String s = c.getStatus() != null ? c.getStatus() : "未知";
|
||||
byStatus.merge(s, 1, Integer::sum);
|
||||
}
|
||||
|
||||
// 按等级分组
|
||||
Map<String, Integer> byLevel = new LinkedHashMap<>();
|
||||
for (QualCert c : all) {
|
||||
String lv = c.getLevel() != null && !c.getLevel().isBlank() ? c.getLevel() : "不分级";
|
||||
byLevel.merge(lv, 1, Integer::sum);
|
||||
}
|
||||
|
||||
// 按类别分组(企业资质 / 人员资质 / 荣誉资质)
|
||||
Map<String, Integer> byCategory = new LinkedHashMap<>();
|
||||
for (QualCert c : all) {
|
||||
String cat = c.getCategory() != null ? c.getCategory() : "其他";
|
||||
byCategory.merge(cat, 1, Integer::sum);
|
||||
}
|
||||
|
||||
// 按资质细类(certType)分组
|
||||
Map<String, Integer> byCertType = new LinkedHashMap<>();
|
||||
for (QualCert c : all) {
|
||||
String ct = c.getCertType() != null && !c.getCertType().isBlank() ? c.getCertType() : "其他";
|
||||
byCertType.merge(ct, 1, Integer::sum);
|
||||
}
|
||||
|
||||
// 明细列表(含剩余天数)
|
||||
LocalDate today = LocalDate.now();
|
||||
List<Map<String, Object>> detail = new ArrayList<>();
|
||||
for (QualCert c : all) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("id", c.getId());
|
||||
item.put("name", c.getName() != null ? c.getName() : "");
|
||||
item.put("category", c.getCategory() != null ? c.getCategory() : "");
|
||||
item.put("certType", c.getCertType() != null ? c.getCertType() : "");
|
||||
item.put("level", c.getLevel() != null ? c.getLevel() : "");
|
||||
item.put("status", c.getStatus() != null ? c.getStatus() : "");
|
||||
item.put("expireDate", c.getExpireDate() != null ? c.getExpireDate() : "");
|
||||
LocalDate exp = parse(c.getExpireDate());
|
||||
item.put("daysToExpire", exp != null ? ChronoUnit.DAYS.between(today, exp) : null);
|
||||
detail.add(item);
|
||||
}
|
||||
|
||||
return ApiResp.ok(Map.of(
|
||||
"total", all.size(),
|
||||
"byStatus", byStatus,
|
||||
"byLevel", byLevel,
|
||||
"byCategory", byCategory,
|
||||
"byCertType", byCertType,
|
||||
"detail", detail,
|
||||
"generatedAt", today.toString()
|
||||
));
|
||||
}
|
||||
|
||||
// ---------- 资质到期日历 ----------
|
||||
|
||||
/**
|
||||
* 到期日历:按月聚合未来 12 个月内所有即将到期的资质,
|
||||
* 前端可渲染日历视图(每月 badge 数量 + 明细列表)。
|
||||
*
|
||||
* 满足需求:"日历形式展示未来12个月所有即将到期的资质证书,便于提前规划"。
|
||||
*/
|
||||
@GetMapping("/calendar")
|
||||
public ApiResp<Map<String, Object>> calendar(
|
||||
@RequestParam(required = false, defaultValue = "12") int months) {
|
||||
LocalDate today = LocalDate.now();
|
||||
LocalDate end = today.plusMonths(months);
|
||||
|
||||
List<QualCert> all = certRepo.findAll();
|
||||
|
||||
// 按 YYYY-MM 分组
|
||||
Map<String, List<Map<String, Object>>> monthly = new LinkedHashMap<>();
|
||||
// 初始化 12 个月 key(保证顺序)
|
||||
for (int i = 0; i < months; i++) {
|
||||
String key = today.plusMonths(i).toString().substring(0, 7);
|
||||
monthly.put(key, new ArrayList<>());
|
||||
}
|
||||
|
||||
for (QualCert c : all) {
|
||||
LocalDate exp = parse(c.getExpireDate());
|
||||
if (exp == null) continue;
|
||||
if (exp.isBefore(today) || exp.isAfter(end)) continue;
|
||||
String monthKey = exp.toString().substring(0, 7);
|
||||
if (!monthly.containsKey(monthKey)) continue;
|
||||
long daysLeft = ChronoUnit.DAYS.between(today, exp);
|
||||
monthly.get(monthKey).add(Map.of(
|
||||
"id", c.getId(),
|
||||
"name", c.getName() != null ? c.getName() : "",
|
||||
"category", c.getCategory() != null ? c.getCategory() : "",
|
||||
"level", c.getLevel() != null ? c.getLevel() : "",
|
||||
"expireDate", c.getExpireDate(),
|
||||
"status", c.getStatus() != null ? c.getStatus() : "",
|
||||
"daysLeft", daysLeft,
|
||||
"urgency", daysLeft <= 30 ? "紧急" : daysLeft <= 90 ? "提醒" : "提前规划"
|
||||
));
|
||||
}
|
||||
|
||||
// 月度摘要
|
||||
List<Map<String, Object>> summary = new ArrayList<>();
|
||||
for (Map.Entry<String, List<Map<String, Object>>> e : monthly.entrySet()) {
|
||||
summary.add(Map.of(
|
||||
"month", e.getKey(),
|
||||
"count", e.getValue().size(),
|
||||
"items", e.getValue()
|
||||
));
|
||||
}
|
||||
|
||||
return ApiResp.ok(Map.of(
|
||||
"windowMonths", months,
|
||||
"startDate", today.toString(),
|
||||
"endDate", end.toString(),
|
||||
"monthly", summary,
|
||||
"totalExpiring", all.stream().filter(c -> {
|
||||
LocalDate e = parse(c.getExpireDate());
|
||||
return e != null && !e.isBefore(today) && !e.isAfter(end);
|
||||
}).count()
|
||||
));
|
||||
}
|
||||
|
||||
// ---------- 人员证书统计与资质标准差距 ----------
|
||||
|
||||
/**
|
||||
* 人员证书统计仪表板:按证书类型/专业/等级统计数量,
|
||||
* 并与资质标准要求的典型配置对比,显示差距。
|
||||
*
|
||||
* 满足需求:"按证书类型、专业、等级统计人员证书数量,显示与资质标准要求的差距"。
|
||||
*/
|
||||
@GetMapping("/cert-gap")
|
||||
public ApiResp<Map<String, Object>> certGap() {
|
||||
List<StaffCredential> creds = credRepo.findAll();
|
||||
|
||||
// 按证书类型分组统计(在职有效,借出/占用也算)
|
||||
Map<String, Long> byCredType = new LinkedHashMap<>();
|
||||
Map<String, Long> availableByType = new LinkedHashMap<>();
|
||||
for (StaffCredential c : creds) {
|
||||
String t = c.getCredType() != null ? c.getCredType() : "其他";
|
||||
byCredType.merge(t, 1L, Long::sum);
|
||||
if (!"已占用".equals(c.getLockState())) {
|
||||
availableByType.merge(t, 1L, Long::sum);
|
||||
}
|
||||
}
|
||||
|
||||
// 参考行业典型资质标准配置要求(建筑业企业,供差距对比参考)
|
||||
Map<String, Integer> standardReq = Map.of(
|
||||
"一级建造师", 12,
|
||||
"二级建造师", 6,
|
||||
"注册造价工程师", 3,
|
||||
"注册安全工程师", 2,
|
||||
"高级工程师职称", 5,
|
||||
"安全员证", 4
|
||||
);
|
||||
|
||||
List<Map<String, Object>> gapList = new ArrayList<>();
|
||||
for (Map.Entry<String, Integer> req : standardReq.entrySet()) {
|
||||
long have = byCredType.getOrDefault(req.getKey(), 0L);
|
||||
long avail = availableByType.getOrDefault(req.getKey(), 0L);
|
||||
long gap = Math.max(0, req.getValue() - have);
|
||||
gapList.add(Map.of(
|
||||
"credType", req.getKey(),
|
||||
"required", req.getValue(),
|
||||
"current", have,
|
||||
"available", avail,
|
||||
"gap", gap,
|
||||
"status", gap == 0 ? "达标" : "缺口"
|
||||
));
|
||||
}
|
||||
|
||||
// 其他证书也列出(标准无要求的)
|
||||
List<Map<String, Object>> extra = new ArrayList<>();
|
||||
for (Map.Entry<String, Long> e : byCredType.entrySet()) {
|
||||
if (!standardReq.containsKey(e.getKey())) {
|
||||
extra.add(Map.of(
|
||||
"credType", e.getKey(),
|
||||
"current", e.getValue(),
|
||||
"available", availableByType.getOrDefault(e.getKey(), 0L)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return ApiResp.ok(Map.of(
|
||||
"totalCerts", creds.size(),
|
||||
"gapAnalysis", gapList,
|
||||
"extraCerts", extra,
|
||||
"byCredType", byCredType,
|
||||
"note", "差距分析参考建筑业企业资质通用配置标准,实际以目标资质最新申报要求为准"
|
||||
));
|
||||
}
|
||||
|
||||
// ---------- 申报成本 ROI 分析 ----------
|
||||
|
||||
/**
|
||||
* 申报成本 ROI 分析:统计各资质申报费用 + 关联中标额,计算综合 ROI。
|
||||
*
|
||||
* 满足需求:"统计各资质的申报费用、维护成本、带来的中标额,计算ROI"。
|
||||
*/
|
||||
@GetMapping("/roi")
|
||||
public ApiResp<Map<String, Object>> roi() {
|
||||
List<QualDeclaration> decls = declRepo.findAll();
|
||||
List<QualDeclFee> fees = feeRepo.findAll();
|
||||
List<QualCert> certs = certRepo.findAll();
|
||||
|
||||
// 按 declarationId 汇总费用
|
||||
Map<Long, BigDecimal> feeByDecl = new HashMap<>();
|
||||
for (QualDeclFee f : fees) {
|
||||
if (f.getDeclarationId() != null) {
|
||||
feeByDecl.merge(f.getDeclarationId(),
|
||||
f.getAmount() != null ? f.getAmount() : BigDecimal.ZERO,
|
||||
BigDecimal::add);
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal totalCost = BigDecimal.ZERO;
|
||||
BigDecimal totalBudget = BigDecimal.ZERO;
|
||||
List<Map<String, Object>> items = new ArrayList<>();
|
||||
|
||||
for (QualDeclaration d : decls) {
|
||||
BigDecimal spent = feeByDecl.getOrDefault(d.getId(), BigDecimal.ZERO);
|
||||
BigDecimal budget = d.getBudget() != null ? d.getBudget() : BigDecimal.ZERO;
|
||||
totalCost = totalCost.add(spent);
|
||||
totalBudget = totalBudget.add(budget);
|
||||
|
||||
// 估算资质带来的中标额(此处仅做占位逻辑,实际应关联投标/合同模块)
|
||||
BigDecimal estBidAmount = BigDecimal.ZERO;
|
||||
|
||||
// ROI = (中标额 - 申报成本) / 申报成本 * 100%
|
||||
// 因无真实合同联动,此处给出成本利用效率(已领证/已提交视为有效)
|
||||
boolean effective = "已领证".equals(d.getStatus()) || "已提交".equals(d.getStatus());
|
||||
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("declId", d.getId());
|
||||
item.put("qualName", d.getQualName() != null ? d.getQualName() : "");
|
||||
item.put("declType", d.getDeclType() != null ? d.getDeclType() : "");
|
||||
item.put("status", d.getStatus() != null ? d.getStatus() : "");
|
||||
item.put("budget", budget);
|
||||
item.put("spent", spent);
|
||||
item.put("budgetUtil", budget.compareTo(BigDecimal.ZERO) > 0
|
||||
? spent.multiply(new BigDecimal("100")).divide(budget, 1, java.math.RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO);
|
||||
item.put("effective", effective);
|
||||
item.put("estBidAmount", estBidAmount);
|
||||
item.put("note", effective ? "已产生资质效益" : "申报中/未完成");
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
// 资质有效数量
|
||||
long validCerts = certs.stream().filter(c -> "有效".equals(c.getStatus()) || "即将到期".equals(c.getStatus())).count();
|
||||
|
||||
return ApiResp.ok(Map.of(
|
||||
"totalDeclCost", totalCost,
|
||||
"totalBudget", totalBudget,
|
||||
"validCertCount", validCerts,
|
||||
"declCount", decls.size(),
|
||||
"items", items,
|
||||
"note", "ROI 中标额关联需对接投标/合同模块获取实际中标数据,当前为成本利用分析"
|
||||
));
|
||||
}
|
||||
|
||||
// ---------- helper ----------
|
||||
|
||||
private static LocalDate parse(String s) {
|
||||
if (s == null || s.isBlank()) return null;
|
||||
try {
|
||||
return LocalDate.parse(s.trim().substring(0, Math.min(10, s.trim().length())));
|
||||
} catch (DateTimeParseException | IndexOutOfBoundsException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user