145 lines
6.2 KiB
Java
145 lines
6.2 KiB
Java
package com.kaidi.oa.seed;
|
|
|
|
import com.kaidi.oa.domain.TestTask;
|
|
import com.kaidi.oa.repository.TestTaskRepository;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
import java.time.Instant;
|
|
|
|
/**
|
|
* 实验室检测任务看板演示数据。
|
|
* 覆盖全部状态列(待分配 / 检测中 / 待复核 / 已复核 / 偏差处理 / 已出报告),
|
|
* 让 labkanban.vue 活体展示多状态卡片。
|
|
* Order(8) = 在所有基础 Seeder 之后、FtsIndexRunner(200) 之前。
|
|
*/
|
|
@DemoSeed
|
|
@Order(8)
|
|
public class LabTestKanbanSeeder implements CommandLineRunner {
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(LabTestKanbanSeeder.class);
|
|
|
|
private final TestTaskRepository repo;
|
|
|
|
public LabTestKanbanSeeder(TestTaskRepository repo) {
|
|
this.repo = repo;
|
|
}
|
|
|
|
@Override
|
|
public void run(String... args) {
|
|
if (repo.count() > 0) {
|
|
return; // 已有数据则跳过,幂等
|
|
}
|
|
log.info("Seeding LabTestKanban demo data...");
|
|
|
|
// 待分配
|
|
seed("JC-001", "COD 化学需氧量", "GB 11914-1989", "污水样-2026001", "城镇污水处理厂进水", "高", "2026-06-20", "待分配", null, null, null, null);
|
|
seed("JC-002", "氨氮(NH3-N)", "HJ 535-2009", "污水样-2026002", "工业废水进水", "高", "2026-06-20", "待分配", null, null, null, null);
|
|
|
|
// 检测中
|
|
seed("JC-003", "总磷(TP)", "GB 11893-1989", "污水样-2026003", "生物质肥料浸提液", "中", "2026-06-18", "检测中", "李化验", null, null, null);
|
|
seed("JC-004", "pH 值", "GB/T 6920-1986", "废水样-2026004", "工业废水排放口", "低", "2026-06-22", "检测中", "王化验", null, null, null);
|
|
seed("JC-005", "悬浮物(SS)", "GB 11901-1989", "污水样-2026005", "脱水污泥渗滤液", "中", "2026-06-19", "检测中", "李化验", null, null, null);
|
|
|
|
// 待复核
|
|
TestTask t6 = build("JC-006", "总氮(TN)", "HJ 636-2012", "废水样-2026006", "环保设备出水", "高", "2026-06-17", "待复核", "张检测");
|
|
t6.setResultValue("12.5");
|
|
t6.setResultUnit("mg/L");
|
|
t6.setStandardLimit("≤15 mg/L");
|
|
t6.setJudge("合格");
|
|
repo.save(t6);
|
|
|
|
TestTask t7 = build("JC-007", "总有机碳(TOC)", "HJ 501-2009", "污水样-2026007", "科研实验室废液", "中", "2026-06-16", "待复核", "张检测");
|
|
t7.setResultValue("38.2");
|
|
t7.setResultUnit("mg/L");
|
|
t7.setStandardLimit("≤50 mg/L");
|
|
t7.setJudge("合格");
|
|
repo.save(t7);
|
|
|
|
// 偏差处理(OOS超标)
|
|
TestTask t8 = build("JC-008", "六价铬 Cr(VI)", "GB 7467-1987", "废水样-2026008", "镀件清洗废水", "高", "2026-06-15", "偏差处理", "陈检测");
|
|
t8.setResultValue("0.85");
|
|
t8.setResultUnit("mg/L");
|
|
t8.setStandardLimit("≤0.5 mg/L");
|
|
t8.setJudge("OOS偏差");
|
|
t8.setRemark("实测值超标1.7倍,已启动偏差调查,通知车间排查污染源。");
|
|
repo.save(t8);
|
|
|
|
// 已复核
|
|
TestTask t9 = build("JC-009", "石油类", "HJ 637-2018", "废水样-2026009", "机加工切削液", "中", "2026-06-14", "已复核", "李化验");
|
|
t9.setResultValue("4.2");
|
|
t9.setResultUnit("mg/L");
|
|
t9.setStandardLimit("≤5 mg/L");
|
|
t9.setJudge("合格");
|
|
t9.setReviewer("王主任");
|
|
t9.setReviewedAt("2026-06-14");
|
|
t9.setResultLocked(true);
|
|
repo.save(t9);
|
|
|
|
TestTask t10 = build("JC-010", "氟化物", "HJ 488-2009", "废水样-2026010", "酸洗废水处理站", "中", "2026-06-13", "已复核", "陈检测");
|
|
t10.setResultValue("8.5");
|
|
t10.setResultUnit("mg/L");
|
|
t10.setStandardLimit("≤10 mg/L");
|
|
t10.setJudge("合格");
|
|
t10.setReviewer("张主任");
|
|
t10.setReviewedAt("2026-06-13");
|
|
t10.setResultLocked(true);
|
|
repo.save(t10);
|
|
|
|
// 已出报告
|
|
TestTask t11 = build("JC-011", "色度", "GB 11903-1989", "污水样-2026011", "城镇污水出水", "低", "2026-06-12", "已出报告", "王化验");
|
|
t11.setResultValue("10");
|
|
t11.setResultUnit("度");
|
|
t11.setStandardLimit("≤30 度");
|
|
t11.setJudge("合格");
|
|
t11.setReviewer("李主任");
|
|
t11.setReviewedAt("2026-06-12");
|
|
t11.setResultLocked(true);
|
|
repo.save(t11);
|
|
|
|
TestTask t12 = build("JC-012", "溶解氧(DO)", "HJ 506-2009", "污水样-2026012", "好氧池曝气段", "低", "2026-06-11", "已出报告", "李化验");
|
|
t12.setResultValue("5.8");
|
|
t12.setResultUnit("mg/L");
|
|
t12.setStandardLimit("≥2 mg/L");
|
|
t12.setJudge("合格");
|
|
t12.setReviewer("王主任");
|
|
t12.setReviewedAt("2026-06-11");
|
|
t12.setResultLocked(true);
|
|
repo.save(t12);
|
|
|
|
log.info("LabTestKanban demo data seeded: {} records.", repo.count());
|
|
}
|
|
|
|
private void seed(String taskNo, String detectItem, String methodNo,
|
|
String sampleNo, String sampleName, String priority,
|
|
String dueDate, String status, String tester,
|
|
String resultValue, String resultUnit, String judge) {
|
|
TestTask t = build(taskNo, detectItem, methodNo, sampleNo, sampleName, priority, dueDate, status, tester);
|
|
if (resultValue != null) t.setResultValue(resultValue);
|
|
if (resultUnit != null) t.setResultUnit(resultUnit);
|
|
if (judge != null) t.setJudge(judge);
|
|
repo.save(t);
|
|
}
|
|
|
|
private TestTask build(String taskNo, String detectItem, String methodNo,
|
|
String sampleNo, String sampleName, String priority,
|
|
String dueDate, String status, String tester) {
|
|
TestTask t = new TestTask();
|
|
t.setTaskNo(taskNo);
|
|
t.setDetectItem(detectItem);
|
|
t.setMethodNo(methodNo);
|
|
t.setSampleNo(sampleNo);
|
|
t.setSampleName(sampleName);
|
|
t.setPriority(priority);
|
|
t.setDueDate(dueDate);
|
|
t.setStatus(status);
|
|
t.setTester(tester);
|
|
t.setResultLocked(false);
|
|
t.setResultSource("手动录入");
|
|
t.setCreatedAt(Instant.now());
|
|
return t;
|
|
}
|
|
}
|