云
2 天以前 657698fd2fb32794932474648dbaee9e284e38c8
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
package cn.iocoder.yudao.module.mes.dal.mysql.qc.iqc;
 
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.mes.controller.admin.qc.iqc.vo.MesQcIqcPageReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.qc.iqc.MesQcIqcDO;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
 
import java.time.LocalDateTime;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
 
class MesQcIqcMapperTest extends BaseDbUnitTest {
 
    @Resource
    private MesQcIqcMapper mapper;
 
    private final LocalDateTime receiveDate = LocalDateTime.of(2026, 10, 12, 0, 0);
 
    private MesQcIqcDO insert(String vendorName) {
        MesQcIqcDO record = new MesQcIqcDO().setCode("IQC-" + vendorName)
                .setItemId(10L).setVendorName(vendorName)
                .setVendorBatch("B001").setReceiveDate(receiveDate);
        mapper.insert(record);
        return record;
    }
 
    @Test
    void freeTextSupplierPersistsAndSeparatesImportDuplicates() {
        MesQcIqcDO first = insert("手填供应商A");
        insert("手填供应商B");
        assertEquals("手填供应商A", mapper.selectById(first.getId()).getVendorName());
        assertEquals(1, mapper.selectListByImportKey(10L, "手填供应商A", "B001", receiveDate).size());
        assertEquals(0, mapper.selectListByImportKey(10L, "手填供应商C", "B001", receiveDate).size());
        MesQcIqcPageReqVO query = new MesQcIqcPageReqVO();
        query.setVendorName("供应商A");
        assertEquals(1L, mapper.selectPage(query).getTotal());
    }
 
    @Test
    void blankSupplierMatchesBothEmptyAndLegacyNull() {
        insert(null);
        insert("");
        insert("手填供应商");
        assertEquals(2, mapper.selectListByImportKey(10L, "", "B001", receiveDate).size());
    }
 
    @Test
    void supplierCanBeClearedWhenEditing() {
        MesQcIqcDO record = insert("手填供应商");
        mapper.updateById(new MesQcIqcDO().setId(record.getId()).setVendorName(""));
        assertEquals("", mapper.selectById(record.getId()).getVendorName());
    }
}