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,541 @@
|
||||
package com.kaidi.oa.seed;
|
||||
|
||||
import com.kaidi.oa.domain.FinAccountAux;
|
||||
import com.kaidi.oa.domain.FinBudgetExecution;
|
||||
import com.kaidi.oa.domain.FinBudgetPlan;
|
||||
import com.kaidi.oa.domain.FinCostCalc;
|
||||
import com.kaidi.oa.domain.FinEmpLoan;
|
||||
import com.kaidi.oa.domain.FinVoucherTemplate;
|
||||
import com.kaidi.oa.repository.FinAccountAuxRepository;
|
||||
import com.kaidi.oa.repository.FinBudgetExecutionRepository;
|
||||
import com.kaidi.oa.repository.FinBudgetPlanRepository;
|
||||
import com.kaidi.oa.repository.FinCostCalcRepository;
|
||||
import com.kaidi.oa.repository.FinEmpLoanRepository;
|
||||
import com.kaidi.oa.repository.FinVoucherTemplateRepository;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付中心/结算中心演示数据种子(W6 缺口补完)。
|
||||
*
|
||||
* 补全审计缺口:
|
||||
* [gap-9] 会计科目辅助核算配置活体为空(0条) → 补 FinAccountAux 演示数据(6维 × 5科目)。
|
||||
* [gap-10] 成本核算活体记录为空(0条) → 补 FinCostCalc 演示数据(多方法/多期间)。
|
||||
* [gap-11] 活体预算计划和执行记录均为0条 → 补 FinBudgetPlan + FinBudgetExecution。
|
||||
* [gap-voucher] 凭证模板活体为空(0条) → 补 FinVoucherTemplate 常用模板。
|
||||
* [gap-emp-loan] 员工借款缺演示数据 → 补 FinEmpLoan 多状态演示记录。
|
||||
*
|
||||
* 幂等:各表 count > 0 则跳过。
|
||||
*
|
||||
* @Order(20) 在 DataSeeder(@Order 1) 和 BranchFinDemoSeeder(@Order 15) 之后运行。
|
||||
*/
|
||||
@Component
|
||||
@Order(20)
|
||||
public class FinPaymentDemoSeeder implements ApplicationRunner {
|
||||
|
||||
private final FinVoucherTemplateRepository voucherTemplateRepo;
|
||||
private final FinAccountAuxRepository accountAuxRepo;
|
||||
private final FinBudgetPlanRepository budgetPlanRepo;
|
||||
private final FinBudgetExecutionRepository budgetExecRepo;
|
||||
private final FinCostCalcRepository costCalcRepo;
|
||||
private final FinEmpLoanRepository empLoanRepo;
|
||||
|
||||
public FinPaymentDemoSeeder(FinVoucherTemplateRepository voucherTemplateRepo,
|
||||
FinAccountAuxRepository accountAuxRepo,
|
||||
FinBudgetPlanRepository budgetPlanRepo,
|
||||
FinBudgetExecutionRepository budgetExecRepo,
|
||||
FinCostCalcRepository costCalcRepo,
|
||||
FinEmpLoanRepository empLoanRepo) {
|
||||
this.voucherTemplateRepo = voucherTemplateRepo;
|
||||
this.accountAuxRepo = accountAuxRepo;
|
||||
this.budgetPlanRepo = budgetPlanRepo;
|
||||
this.budgetExecRepo = budgetExecRepo;
|
||||
this.costCalcRepo = costCalcRepo;
|
||||
this.empLoanRepo = empLoanRepo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
seedVoucherTemplates();
|
||||
seedAccountAux();
|
||||
seedBudgetPlans();
|
||||
seedBudgetExecutions();
|
||||
seedCostCalcRecords();
|
||||
seedEmpLoans();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 1. 凭证模板(gap-voucher: 0条)
|
||||
// ============================================================
|
||||
|
||||
private void seedVoucherTemplates() {
|
||||
if (voucherTemplateRepo.count() > 0) return;
|
||||
|
||||
List<FinVoucherTemplate> list = new ArrayList<>();
|
||||
|
||||
list.add(template("TMPL-001", "计提折旧-设备", FinVoucherTemplate.TYPE_DEPREC,
|
||||
"5011.001 制造费用-折旧", "1602 累计折旧",
|
||||
"${period}期计提固定资产折旧", "折旧计算", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-002", "计提折旧-房屋", FinVoucherTemplate.TYPE_DEPREC,
|
||||
"6602 管理费用-折旧", "1602 累计折旧",
|
||||
"${period}期计提房屋折旧", "折旧计算", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-003", "摊销无形资产", FinVoucherTemplate.TYPE_AMORT,
|
||||
"6602 管理费用-摊销", "1702 累计摊销",
|
||||
"${period}期摊销无形资产", "摊销计算", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-004", "结转损益", FinVoucherTemplate.TYPE_TRANSFER,
|
||||
"4103 本年利润", "5001 主营业务收入",
|
||||
"${period}期结转主营业务收入", "手填", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-005", "结转研发费用", FinVoucherTemplate.TYPE_RD,
|
||||
"1503 开发支出", "5011 研发费用",
|
||||
"${period}期研发费用资本化结转", "手填", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-006", "分摊制造费用-工时", FinVoucherTemplate.TYPE_MFG,
|
||||
"1405 库存商品-半成品", "5011 制造费用",
|
||||
"${period}期按工时分摊制造费用", "手填", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-007", "期末调汇-外币账户", FinVoucherTemplate.TYPE_FX,
|
||||
"1122 应收账款-外币", "6301 汇兑损益",
|
||||
"${period}期末外币调汇(应收账款)", "手填", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-008", "付款核销手工模板", FinVoucherTemplate.TYPE_MANUAL,
|
||||
"2202 应付账款", "1002 银行存款",
|
||||
"采购款付款:${amount}", "手填", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-009", "收款核销手工模板", FinVoucherTemplate.TYPE_MANUAL,
|
||||
"1002 银行存款", "1122 应收账款",
|
||||
"销售回款:${amount}", "手填", Boolean.TRUE, "admin"));
|
||||
|
||||
list.add(template("TMPL-010", "计提工资-生产", FinVoucherTemplate.TYPE_MANUAL,
|
||||
"5011.002 制造费用-人工", "2211 应付职工薪酬",
|
||||
"${period}期计提生产人员工资", "手填", Boolean.TRUE, "admin"));
|
||||
|
||||
voucherTemplateRepo.saveAll(list);
|
||||
}
|
||||
|
||||
private FinVoucherTemplate template(String code, String name, String type,
|
||||
String debit, String credit, String summary,
|
||||
String amountSource, Boolean enabled, String createdBy) {
|
||||
FinVoucherTemplate t = new FinVoucherTemplate();
|
||||
t.setCode(code);
|
||||
t.setName(name);
|
||||
t.setTemplateType(type);
|
||||
t.setDebitAccount(debit);
|
||||
t.setCreditAccount(credit);
|
||||
t.setSummaryTemplate(summary);
|
||||
t.setAmountSource(amountSource);
|
||||
t.setEnabled(enabled);
|
||||
t.setCreatedBy(createdBy);
|
||||
t.setCreatedAt(Instant.now());
|
||||
return t;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 2. 会计科目辅助核算配置(gap-9: 0条)
|
||||
// ============================================================
|
||||
|
||||
private void seedAccountAux() {
|
||||
if (accountAuxRepo.count() > 0) return;
|
||||
|
||||
List<FinAccountAux> list = new ArrayList<>();
|
||||
|
||||
// 1122 应收账款 - 客户维度
|
||||
list.add(aux("1122", "应收账款", "客户", "岳阳城陵矶市政开发公司",
|
||||
"启用", "财务部", "admin", "按客户追踪应收账款余额"));
|
||||
list.add(aux("1122", "应收账款", "客户", "湖南省水务建设集团",
|
||||
"启用", "财务部", "admin", "按客户追踪应收账款余额"));
|
||||
list.add(aux("1122", "应收账款", "客户", "岳阳市凯利环保科技",
|
||||
"启用", "财务部", "admin", "按客户追踪应收账款余额"));
|
||||
|
||||
// 2202 应付账款 - 供应商维度
|
||||
list.add(aux("2202", "应付账款", "供应商", "长沙美迪机械有限公司",
|
||||
"启用", "财务部", "admin", "按供应商追踪应付账款余额"));
|
||||
list.add(aux("2202", "应付账款", "供应商", "岳阳德信建材供应商",
|
||||
"启用", "财务部", "admin", "按供应商追踪应付账款余额"));
|
||||
|
||||
// 5011 制造费用 - 部门维度
|
||||
list.add(aux("5011", "制造费用", "部门", "环保设备制造中心",
|
||||
"启用", "财务部", "admin", "按部门归集制造费用"));
|
||||
list.add(aux("5011", "制造费用", "部门", "生物质肥料制造中心",
|
||||
"启用", "财务部", "admin", "按部门归集制造费用"));
|
||||
|
||||
// 6601 销售费用 - 项目维度
|
||||
list.add(aux("6601", "销售费用", "项目", "P-YY-2025-001岳阳污水厂",
|
||||
"启用", "财务部", "admin", "按项目核算销售费用"));
|
||||
list.add(aux("6601", "销售费用", "项目", "P-HN-2025-003湖南改造项目",
|
||||
"启用", "财务部", "admin", "按项目核算销售费用"));
|
||||
|
||||
// 6602 管理费用 - 成本中心维度
|
||||
list.add(aux("6602", "管理费用", "成本中心", "总部行政成本中心",
|
||||
"启用", "财务部", "admin", "按成本中心分配管理费用"));
|
||||
list.add(aux("6602", "管理费用", "成本中心", "研发成本中心",
|
||||
"启用", "财务部", "admin", "研发费用归集到成本中心"));
|
||||
|
||||
// 1405 库存商品 - 产品维度
|
||||
list.add(aux("1405", "库存商品", "产品", "过滤膜组件-A型",
|
||||
"启用", "财务部", "admin", "按产品追踪库存余额"));
|
||||
list.add(aux("1405", "库存商品", "产品", "污水处理药剂-PAC",
|
||||
"启用", "财务部", "admin", "按产品追踪库存余额"));
|
||||
|
||||
accountAuxRepo.saveAll(list);
|
||||
}
|
||||
|
||||
private FinAccountAux aux(String accountCode, String accountName, String auxDimension,
|
||||
String auxVal, String enabledVal, String applicant,
|
||||
String approver, String reason) {
|
||||
FinAccountAux a = new FinAccountAux();
|
||||
a.setAccountCode(accountCode);
|
||||
a.setAccountName(accountName);
|
||||
a.setAuxDimension(auxDimension);
|
||||
a.setAuxVal(auxVal);
|
||||
a.setEnabledVal(enabledVal);
|
||||
a.setBalance(BigDecimal.ZERO);
|
||||
a.setApplicant(applicant);
|
||||
a.setApprover(approver);
|
||||
a.setReason(reason);
|
||||
a.setCreatedAt(Instant.now());
|
||||
a.setUpdatedAt(Instant.now());
|
||||
return a;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 3. 预算编制计划(gap-11: 0条)
|
||||
// ============================================================
|
||||
|
||||
private void seedBudgetPlans() {
|
||||
if (budgetPlanRepo.count() > 0) return;
|
||||
|
||||
List<FinBudgetPlan> list = new ArrayList<>();
|
||||
|
||||
// 2025年度预算 - 各部门申报
|
||||
list.add(plan("BP2025-001", "2025", 1, "环保设备制造中心", "成本预算",
|
||||
"直接材料采购成本", new BigDecimal("12000000"),
|
||||
new BigDecimal("11500000"), FinBudgetPlan.S_APPROVED,
|
||||
"材料价格上涨,申报略高", "核减至市场均价水平", "张三", "李四",
|
||||
"2025-01-10", "2025-01-25"));
|
||||
|
||||
list.add(plan("BP2025-002", "2025", 1, "环保设备制造中心", "费用预算",
|
||||
"制造费用(水电人工)", new BigDecimal("3200000"),
|
||||
new BigDecimal("3100000"), FinBudgetPlan.S_APPROVED,
|
||||
"含新增设备维护费用", "适当核减维护费", "张三", "李四",
|
||||
"2025-01-10", "2025-01-25"));
|
||||
|
||||
list.add(plan("BP2025-003", "2025", 1, "研发中心", "费用预算",
|
||||
"研发人员薪酬", new BigDecimal("5600000"),
|
||||
new BigDecimal("5600000"), FinBudgetPlan.S_APPROVED,
|
||||
"含3名新招研发人员", "按申报批准", "王五", "李四",
|
||||
"2025-01-12", "2025-01-25"));
|
||||
|
||||
list.add(plan("BP2025-004", "2025", 1, "工程管理中心", "收入预算",
|
||||
"主营业务收入-EPC工程", new BigDecimal("85000000"),
|
||||
new BigDecimal("82000000"), FinBudgetPlan.S_APPROVED,
|
||||
"基于在手合同及预期新签合同", "保守预估,略有核减", "赵六", "李四",
|
||||
"2025-01-11", "2025-01-25"));
|
||||
|
||||
list.add(plan("BP2025-005", "2025", 1, "财务部", "现金流预算",
|
||||
"年度净现金流(经营活动)", new BigDecimal("15000000"),
|
||||
new BigDecimal("14000000"), FinBudgetPlan.S_APPROVED,
|
||||
"基于合同回款预期", "适当调低", "钱七", "李四",
|
||||
"2025-01-13", "2025-01-25"));
|
||||
|
||||
list.add(plan("BP2025-006", "2025", 2, "工程管理中心", "资本预算",
|
||||
"固定资产投资(办公设备)", new BigDecimal("800000"),
|
||||
new BigDecimal("650000"), FinBudgetPlan.S_APPROVED,
|
||||
"含2台大型绘图仪采购", "核减1台", "赵六", "李四",
|
||||
"2025-01-15", "2025-01-28"));
|
||||
|
||||
// 2026年度预算(汇总中状态)
|
||||
list.add(plan("BP2026-001", "2026", 1, "环保设备制造中心", "成本预算",
|
||||
"直接材料采购成本", new BigDecimal("13500000"),
|
||||
BigDecimal.ZERO, FinBudgetPlan.S_GATHERING,
|
||||
"预计材料价格持平或略降,增量来自产能扩张", null, "张三", null,
|
||||
"2026-01-08", null));
|
||||
|
||||
list.add(plan("BP2026-002", "2026", 1, "研发中心", "费用预算",
|
||||
"研发费用总额(含人工+耗材)", new BigDecimal("7200000"),
|
||||
BigDecimal.ZERO, FinBudgetPlan.S_SUBMITTED,
|
||||
"含2项新立项研发课题预算", null, "王五", null,
|
||||
"2026-01-09", null));
|
||||
|
||||
budgetPlanRepo.saveAll(list);
|
||||
}
|
||||
|
||||
private FinBudgetPlan plan(String planCode, String year, int roundNo, String dept,
|
||||
String type, String item, BigDecimal proposed, BigDecimal approved,
|
||||
String status, String justification, String approvalComment,
|
||||
String submitter, String approver, String submitDate, String approvalDate) {
|
||||
FinBudgetPlan p = new FinBudgetPlan();
|
||||
p.setPlanCode(planCode);
|
||||
p.setBudgetYear(year);
|
||||
p.setRoundNo(roundNo);
|
||||
p.setDepartment(dept);
|
||||
p.setBudgetType(type);
|
||||
p.setBudgetItem(item);
|
||||
p.setProposedAmount(proposed);
|
||||
p.setApprovedAmount(approved);
|
||||
p.setVarianceFromTop(proposed.subtract(approved));
|
||||
p.setStatus(status);
|
||||
p.setJustification(justification);
|
||||
p.setApprovalComment(approvalComment);
|
||||
p.setSubmitter(submitter);
|
||||
p.setApprover(approver);
|
||||
p.setSubmitDate(submitDate);
|
||||
p.setApprovalDate(approvalDate);
|
||||
p.setCreatedAt(Instant.now());
|
||||
p.setUpdatedAt(Instant.now());
|
||||
return p;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 4. 预算执行记录(gap-11: 0条)
|
||||
// ============================================================
|
||||
|
||||
private void seedBudgetExecutions() {
|
||||
if (budgetExecRepo.count() > 0) return;
|
||||
|
||||
List<FinBudgetExecution> list = new ArrayList<>();
|
||||
|
||||
// 2025年各月度执行记录
|
||||
list.add(exec("直接材料采购成本", FinBudgetExecution.TYPE_COST, "2025-01",
|
||||
new BigDecimal("1000000"), new BigDecimal("980000"), "环保设备制造中心", "P-2025-MFG", "已批准", Boolean.FALSE));
|
||||
list.add(exec("直接材料采购成本", FinBudgetExecution.TYPE_COST, "2025-02",
|
||||
new BigDecimal("1000000"), new BigDecimal("1120000"), "环保设备制造中心", "P-2025-MFG", "已批准", Boolean.TRUE));
|
||||
list.add(exec("直接材料采购成本", FinBudgetExecution.TYPE_COST, "2025-03",
|
||||
new BigDecimal("1000000"), new BigDecimal("950000"), "环保设备制造中心", "P-2025-MFG", "已批准", Boolean.FALSE));
|
||||
list.add(exec("研发人员薪酬", FinBudgetExecution.TYPE_EXPENSE, "2025-01",
|
||||
new BigDecimal("466667"), new BigDecimal("466667"), "研发中心", null, "已批准", Boolean.FALSE));
|
||||
list.add(exec("研发人员薪酬", FinBudgetExecution.TYPE_EXPENSE, "2025-02",
|
||||
new BigDecimal("466667"), new BigDecimal("466667"), "研发中心", null, "已批准", Boolean.FALSE));
|
||||
list.add(exec("研发人员薪酬", FinBudgetExecution.TYPE_EXPENSE, "2025-03",
|
||||
new BigDecimal("466667"), new BigDecimal("510000"), "研发中心", null, "已批准", Boolean.TRUE));
|
||||
list.add(exec("主营业务收入-EPC工程", FinBudgetExecution.TYPE_INCOME, "2025-Q1",
|
||||
new BigDecimal("20500000"), new BigDecimal("18200000"), "工程管理中心", null, "已批准", Boolean.FALSE));
|
||||
list.add(exec("主营业务收入-EPC工程", FinBudgetExecution.TYPE_INCOME, "2025-Q2",
|
||||
new BigDecimal("20500000"), new BigDecimal("22800000"), "工程管理中心", null, "已批准", Boolean.FALSE));
|
||||
list.add(exec("年度净现金流(经营活动)", FinBudgetExecution.TYPE_CASHFLOW, "2025",
|
||||
new BigDecimal("14000000"), new BigDecimal("12300000"), "财务部", null, "初稿", Boolean.FALSE));
|
||||
list.add(exec("固定资产投资(办公设备)", FinBudgetExecution.TYPE_CAPITAL, "2025",
|
||||
new BigDecimal("650000"), new BigDecimal("580000"), "工程管理中心", null, "已批准", Boolean.FALSE));
|
||||
|
||||
budgetExecRepo.saveAll(list);
|
||||
}
|
||||
|
||||
private FinBudgetExecution exec(String budgetItem, String budgetType, String period,
|
||||
BigDecimal budgetAmount, BigDecimal actualAmount,
|
||||
String department, String projectCode, String version,
|
||||
Boolean overBudget) {
|
||||
FinBudgetExecution e = new FinBudgetExecution();
|
||||
e.setBudgetItem(budgetItem);
|
||||
e.setBudgetType(budgetType);
|
||||
e.setPeriod(period);
|
||||
e.setBudgetAmount(budgetAmount);
|
||||
e.setActualAmount(actualAmount);
|
||||
BigDecimal variance = actualAmount.subtract(budgetAmount);
|
||||
e.setVarianceAmount(variance);
|
||||
if (budgetAmount.signum() != 0) {
|
||||
e.setVarianceRate(variance.multiply(new BigDecimal("100"))
|
||||
.divide(budgetAmount, 2, java.math.RoundingMode.HALF_UP));
|
||||
}
|
||||
e.setOverBudget(overBudget);
|
||||
e.setAlerted(overBudget);
|
||||
e.setAlertThreshold(new BigDecimal("10"));
|
||||
e.setDepartment(department);
|
||||
e.setProjectCode(projectCode);
|
||||
e.setCompanySubject("湖南凯迪工程科技有限公司");
|
||||
e.setBudgetVersion(version);
|
||||
e.setOperator("admin");
|
||||
e.setCreatedAt(Instant.now());
|
||||
e.setUpdatedAt(Instant.now());
|
||||
return e;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 5. 成本核算记录(gap-10: 0条)
|
||||
// ============================================================
|
||||
|
||||
private void seedCostCalcRecords() {
|
||||
if (costCalcRepo.count() > 0) return;
|
||||
|
||||
List<FinCostCalc> list = new ArrayList<>();
|
||||
|
||||
// 品种法 - 膜组件产品月度成本核算
|
||||
list.add(costCalc("CC-2025-001", FinCostCalc.METHOD_VARIETY,
|
||||
"过滤膜组件-A型", "产品", "2025-01",
|
||||
new BigDecimal("520000"), new BigDecimal("85000"), new BigDecimal("68000"),
|
||||
"工时", 4200.0, new BigDecimal("16.19"),
|
||||
new BigDecimal("673000"), new BigDecimal("650000"), FinCostCalc.STATUS_POSTED, "admin"));
|
||||
|
||||
list.add(costCalc("CC-2025-002", FinCostCalc.METHOD_VARIETY,
|
||||
"过滤膜组件-A型", "产品", "2025-02",
|
||||
new BigDecimal("495000"), new BigDecimal("85000"), new BigDecimal("62000"),
|
||||
"工时", 4000.0, new BigDecimal("15.50"),
|
||||
new BigDecimal("642000"), new BigDecimal("650000"), FinCostCalc.STATUS_POSTED, "admin"));
|
||||
|
||||
list.add(costCalc("CC-2025-003", FinCostCalc.METHOD_VARIETY,
|
||||
"污水处理药剂-PAC", "产品", "2025-01",
|
||||
new BigDecimal("280000"), new BigDecimal("32000"), new BigDecimal("25000"),
|
||||
"产量", 5000.0, new BigDecimal("5.00"),
|
||||
new BigDecimal("337000"), new BigDecimal("330000"), FinCostCalc.STATUS_POSTED, "admin"));
|
||||
|
||||
// 分批法 - 工程项目成本归集
|
||||
list.add(costCalc("CC-2025-004", FinCostCalc.METHOD_BATCH,
|
||||
"P-YY-2025-001岳阳污水厂", "项目", "2025-Q1",
|
||||
new BigDecimal("3200000"), new BigDecimal("680000"), new BigDecimal("420000"),
|
||||
"收入", 18200000.0, new BigDecimal("0.023"),
|
||||
new BigDecimal("4300000"), new BigDecimal("4200000"), FinCostCalc.STATUS_APPROVED, "张三"));
|
||||
|
||||
list.add(costCalc("CC-2025-005", FinCostCalc.METHOD_BATCH,
|
||||
"P-HN-2025-003湖南改造项目", "项目", "2025-Q1",
|
||||
new BigDecimal("1800000"), new BigDecimal("380000"), new BigDecimal("210000"),
|
||||
"收入", 9500000.0, new BigDecimal("0.022"),
|
||||
new BigDecimal("2390000"), new BigDecimal("2350000"), FinCostCalc.STATUS_APPROVED, "赵六"));
|
||||
|
||||
// 分步法 - 生产工单成本
|
||||
list.add(costCalc("CC-2025-006", FinCostCalc.METHOD_PROCESS,
|
||||
"WO-2025-003膜组件装配", "工单", "2025-02",
|
||||
new BigDecimal("120000"), new BigDecimal("28000"), new BigDecimal("15000"),
|
||||
"工时", 850.0, new BigDecimal("17.65"),
|
||||
new BigDecimal("163000"), new BigDecimal("160000"), FinCostCalc.STATUS_POSTED, "admin"));
|
||||
|
||||
// 作业成本法 - 研发项目
|
||||
list.add(costCalc("CC-2025-007", FinCostCalc.METHOD_ABC,
|
||||
"RD-2025-002新型膜研发", "项目", "2025-Q1",
|
||||
new BigDecimal("680000"), new BigDecimal("520000"), new BigDecimal("85000"),
|
||||
"人数", 8.0, new BigDecimal("10625"),
|
||||
new BigDecimal("1285000"), new BigDecimal("1300000"), FinCostCalc.STATUS_DRAFT, "王五"));
|
||||
|
||||
costCalcRepo.saveAll(list);
|
||||
}
|
||||
|
||||
private FinCostCalc costCalc(String code, String calcMethod, String costObject, String costObjectType,
|
||||
String period, BigDecimal directMaterial, BigDecimal directLabor,
|
||||
BigDecimal manufacturingOverhead, String allocationDriver,
|
||||
Double driverQuantity, BigDecimal allocationRate,
|
||||
BigDecimal totalCost, BigDecimal standardCost,
|
||||
String status, String operator) {
|
||||
FinCostCalc c = new FinCostCalc();
|
||||
c.setCode(code);
|
||||
c.setCalcMethod(calcMethod);
|
||||
c.setCostObject(costObject);
|
||||
c.setCostObjectType(costObjectType);
|
||||
c.setPeriod(period);
|
||||
c.setDirectMaterial(directMaterial);
|
||||
c.setDirectLabor(directLabor);
|
||||
c.setManufacturingOverhead(manufacturingOverhead);
|
||||
c.setAllocationDriver(allocationDriver);
|
||||
c.setDriverQuantity(driverQuantity);
|
||||
c.setAllocationRate(allocationRate);
|
||||
c.setTotalCost(totalCost);
|
||||
c.setStandardCost(standardCost);
|
||||
c.setCostVariance(totalCost.subtract(standardCost));
|
||||
c.setStatus(status);
|
||||
c.setOperator(operator);
|
||||
c.setCreatedAt(Instant.now());
|
||||
return c;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 6. 员工借款演示数据(多状态覆盖)
|
||||
// ============================================================
|
||||
|
||||
private void seedEmpLoans() {
|
||||
if (empLoanRepo.count() > 0) return;
|
||||
|
||||
List<FinEmpLoan> list = new ArrayList<>();
|
||||
|
||||
// 已批准 - 差旅借款
|
||||
list.add(empLoan("EL-202501", "张工", "E001", "工程管理中心",
|
||||
FinEmpLoan.TYPE_TRAVEL, "岳阳项目现场调研差旅费",
|
||||
new BigDecimal("8000"), BigDecimal.ZERO, new BigDecimal("8000"),
|
||||
"2025-01-05", "2025-02-05", null,
|
||||
"2025-01-07", "张总", "同意", null, null,
|
||||
FinEmpLoan.S_APPROVED, Boolean.FALSE));
|
||||
|
||||
// 还款中 - 备用金借款
|
||||
list.add(empLoan("EL-202502", "李会计", "E002", "财务部",
|
||||
FinEmpLoan.TYPE_PETTY, "2025年Q1采购零星备用金",
|
||||
new BigDecimal("5000"), new BigDecimal("2000"), new BigDecimal("3000"),
|
||||
"2025-01-10", "2025-04-10", null,
|
||||
"2025-01-12", "财务总监", "同意", null, "EXP-2025-012",
|
||||
FinEmpLoan.S_REPAYING, Boolean.FALSE));
|
||||
|
||||
// 已结清 - 差旅借款
|
||||
list.add(empLoan("EL-202503", "王测试", "E003", "研发中心",
|
||||
FinEmpLoan.TYPE_TRAVEL, "上海环博会参展差旅",
|
||||
new BigDecimal("12000"), new BigDecimal("12000"), BigDecimal.ZERO,
|
||||
"2025-02-01", "2025-03-01", "2025-02-28",
|
||||
"2025-02-03", "研发总监", "同意", "2025-02-28", "EXP-2025-023",
|
||||
FinEmpLoan.S_SETTLED, Boolean.FALSE));
|
||||
|
||||
// 逾期 - 其他借款(已过期未还)
|
||||
list.add(empLoan("EL-202504", "赵工", "E004", "环保设备制造中心",
|
||||
FinEmpLoan.TYPE_OTHER, "设备维修紧急备用金",
|
||||
new BigDecimal("3000"), BigDecimal.ZERO, new BigDecimal("3000"),
|
||||
"2025-03-15", "2025-04-15", null,
|
||||
"2025-03-17", "生产总监", "同意", null, null,
|
||||
FinEmpLoan.S_OVERDUE, Boolean.FALSE));
|
||||
|
||||
// 待审批 - 备用金借款
|
||||
list.add(empLoan("EL-202505", "孙经理", "E005", "市场部",
|
||||
FinEmpLoan.TYPE_PETTY, "华南区市场拓展备用金",
|
||||
new BigDecimal("15000"), BigDecimal.ZERO, new BigDecimal("15000"),
|
||||
"2025-05-20", "2025-08-20", null,
|
||||
null, null, null, null, null,
|
||||
FinEmpLoan.S_PENDING, Boolean.FALSE));
|
||||
|
||||
// 草稿 - 差旅借款
|
||||
list.add(empLoan("EL-202506", "周工", "E006", "工程管理中心",
|
||||
FinEmpLoan.TYPE_TRAVEL, "武汉项目踏勘差旅",
|
||||
new BigDecimal("6500"), BigDecimal.ZERO, new BigDecimal("6500"),
|
||||
"2025-06-01", "2025-07-01", null,
|
||||
null, null, null, null, null,
|
||||
FinEmpLoan.S_DRAFT, Boolean.FALSE));
|
||||
|
||||
empLoanRepo.saveAll(list);
|
||||
}
|
||||
|
||||
private FinEmpLoan empLoan(String loanCode, String employeeName, String employeeId,
|
||||
String department, String loanType, String purpose,
|
||||
BigDecimal loanAmount, BigDecimal repaidAmount, BigDecimal remainAmount,
|
||||
String applyDate, String expectedRepayDate, String settleDate,
|
||||
String approvalDate, String approver, String approvalComment,
|
||||
String settleDate2, String relatedExpenseCode,
|
||||
String status, Boolean deductFromSalary) {
|
||||
FinEmpLoan l = new FinEmpLoan();
|
||||
l.setLoanCode(loanCode);
|
||||
l.setEmployeeName(employeeName);
|
||||
l.setEmployeeId(employeeId);
|
||||
l.setDepartment(department);
|
||||
l.setLoanType(loanType);
|
||||
l.setPurpose(purpose);
|
||||
l.setLoanAmount(loanAmount);
|
||||
l.setRepaidAmount(repaidAmount);
|
||||
l.setRemainAmount(remainAmount);
|
||||
l.setApplyDate(applyDate);
|
||||
l.setExpectedRepayDate(expectedRepayDate);
|
||||
l.setSettleDate(settleDate);
|
||||
l.setApprovalDate(approvalDate);
|
||||
l.setApprover(approver);
|
||||
l.setApprovalComment(approvalComment);
|
||||
l.setRelatedExpenseCode(relatedExpenseCode);
|
||||
l.setStatus(status);
|
||||
l.setDeductFromSalary(deductFromSalary);
|
||||
if (FinEmpLoan.S_OVERDUE.equals(status)) {
|
||||
l.setOverdueDays(61); // 逾期超过60天
|
||||
}
|
||||
l.setOperator("admin");
|
||||
l.setCreatedAt(Instant.now());
|
||||
l.setUpdatedAt(Instant.now());
|
||||
return l;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user