刘光辉
15 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package jnpf.limsService.support;
 
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import jnpf.limsEntity.LimsSxtKanbanItemVo;
 
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.TimeZone;
 
public class LimsSxtKanbanApiChecks {
    public static void main(String[] args) throws Exception {
        Path root = Paths.get("").toAbsolutePath().normalize();
        String service = read(root, "jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/LimsSxtKanbanService.java");
        require(service, "listKanbanRows", "kanban rows contract missing");
        require(service, "listKanbanItems", "kanban items contract missing");
        require(service, "quxiaoWeilaiRenwu", "future Renwu cancellation contract missing");
 
        String controller = read(root, "jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/limsController/LimsSxtKanbanController.java");
        require(controller, "@GetMapping(\"/options\")", "kanban options endpoint missing");
 
        String implementation = read(root, "jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsSxtKanbanServiceImpl.java");
        require(implementation, "kanbanMapper.selectRows", "kanban rows must use point master data");
 
        String mapper = read(root, "jnpf-lims/jnpf-lims-biz/src/main/resources/mapper/LimsSxtKanbanMapper.xml");
        String sampleTypeQuery = selectBlock(mapper, "selectSampleTypes");
        require(sampleTypeQuery, "FROM yangpin_guanli y", "sample types must start from sample master data");
        require(sampleTypeQuery, "INNER JOIN qingyan_leixing ql", "sample types must resolve the inspection category");
        require(sampleTypeQuery, "y.biz_enabled = 'enabled'", "disabled samples must be excluded");
        require(sampleTypeQuery, "ql.fenlei_mingcheng = '水系统'", "sample types must be limited to water system samples");
        reject(sampleTypeQuery, "activePointJoins", "sample types must not depend on sampling point configuration");
        require(mapper, "FROM lims_sxt_quyangdian p", "kanban rows must start from sampling points");
        require(mapper, "p.biz_enabled = 'enabled'", "disabled points must be excluded");
        require(mapper, "p.f_delete_mark IS NULL OR p.f_delete_mark <> 1", "deleted points must be excluded");
        reject(mapper, "lims_sxt_quyang_jihua_renwu", "kanban master rows must not depend on Renwu");
        verifyCalendarDateSerialization();
    }
 
    private static String read(Path root, String relativePath) throws Exception {
        return new String(Files.readAllBytes(root.resolve(relativePath)));
    }
 
    private static String selectBlock(String mapper, String id) {
        int start = mapper.indexOf("<select id=\"" + id + "\"");
        int end = mapper.indexOf("</select>", start);
        requireCondition(start >= 0 && end >= 0, "mapper select block missing: " + id);
        return mapper.substring(start, end);
    }
 
    private static void verifyCalendarDateSerialization() throws Exception {
        TimeZone originalTimeZone = TimeZone.getDefault();
        try {
            TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
            LimsSxtKanbanItemVo item = new LimsSxtKanbanItemVo();
            item.setJihuaRiqi(Date.from(LocalDate.of(2026, 7, 1)
                    .atStartOfDay(ZoneId.of("GMT+8")).toInstant()));
 
            JsonNode result = new ObjectMapper().readTree(new ObjectMapper().writeValueAsString(item));
            requireCondition("2026-07-01".equals(result.path("jihua_riqi").asText()),
                    "kanban calendar date must retain the GMT+8 calendar day");
        } finally {
            TimeZone.setDefault(originalTimeZone);
        }
    }
 
    private static void require(String source, String token, String message) {
        if (!source.contains(token)) throw new AssertionError(message);
    }
 
    private static void reject(String source, String token, String message) {
        if (source.contains(token)) throw new AssertionError(message);
    }
 
    private static void requireCondition(boolean condition, String message) {
        if (!condition) throw new AssertionError(message);
    }
}