longz
2026-07-17 da9b7a52dbc6fcd2173efef90528d8fccc322554
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
package com.ruoyi.chargingPile.export;
 
import com.ruoyi.chargingPile.api.dto.PageChargingPileListDTO;
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.chargingPile.api.vo.TChargingGunVO;
import com.ruoyi.common.core.annotation.Excel;
import org.junit.jupiter.api.Test;
 
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
 
class ChargingPileExportTest {
 
    @Test
    void shouldMatchPrototypeColumnOrder() {
        List<String> actual = Arrays.stream(ChargingPileExport.class.getDeclaredFields())
                .map(field -> field.getAnnotation(Excel.class))
                .filter(annotation -> annotation != null)
                .map(Excel::name)
                .collect(Collectors.toList());
 
        assertEquals(Arrays.asList(
                "*设备编码", "*设备名称", "*桩号", "设备类型", "归属电站", "设备合作商",
                "生产机构代码", "生产商名称", "设备型号", "设备生产日期", "*额定功率",
                "设备充电站编号", "设备唯一编码", "*设备分类", "设备经度", "设备纬度",
                "*接口编码", "*接口名称", "*设备接口分类", "*接口类型", "*接口状态", "*充电方式",
                "计费策略", "*额定电压上限", "*额定电压下限", "恒功率电压上限", "恒功率电压下限",
                "*额定电流", "恒功率电流上限", "恒功率电流下限", "*额定功率", "车位号",
                "车位状态", "地锁状态", "*国家标准", "接口说明", "辅助电源", "*运营状态", "运营时间"
        ), actual);
    }
 
    @Test
    void shouldCombinePileAndGunIntoOneExportRow() {
        PageChargingPileListDTO record = new PageChargingPileListDTO();
        record.setSiteName("测试电站");
        record.setPartnerName("测试合作商");
        TChargingPile pile = new TChargingPile();
        pile.setCode("PILE001");
        pile.setName("1号桩");
        pile.setNumber(1);
        pile.setManufacturerCode("ORG001");
        pile.setProductionDate(LocalDate.of(2026, 7, 16));
        TChargingGunVO gun = new TChargingGunVO();
        gun.setCode("01");
        gun.setName("1号枪");
        gun.setStrategyName("标准计费");
        gun.setRatedPower(new BigDecimal("120"));
        gun.setOpreateStatus(50);
 
        ChargingPileExport actual = ChargingPileExport.from(record, pile, gun);
 
        assertEquals("PILE001", actual.getCode());
        assertEquals("测试电站", actual.getSiteName());
        assertEquals("测试合作商", actual.getPartnerName());
        assertEquals("ORG001", actual.getManufacturerCode());
        assertEquals("2026-07-16", actual.getProductionDate());
        assertEquals("01", actual.getInterfaceCode());
        assertEquals("1号枪", actual.getInterfaceName());
        assertEquals("标准计费", actual.getStrategyName());
        assertEquals(new BigDecimal("120"), actual.getInterfaceRatedPower());
        assertEquals(50, actual.getOperateStatus());
    }
}