whyclxw
2025-05-17 441f4fd8652a5d51c386d19eb27a7dbb2140b10b
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
package com.whyc.factory;
 
import com.whyc.dto.InfoDto;
import com.whyc.pojo.db_station.BattInf;
import com.whyc.pojo.db_station.PowerInf;
import com.whyc.pojo.db_station.StationInf;
 
public class InfoFactory {
    //将info对象转为电源对象
    public static PowerInf infoToPower(InfoDto info) {
        PowerInf pinf = new PowerInf();
        pinf.setCompany(info.getCompany())
                .setPowerModel(info.getPowerModel())
                .setProtocol(info.getProtocol())
                .setPowerIp(info.getPowerIp());
        StationInf sinf=new StationInf();
        sinf.setProvice(info.getProvice())
                .setCity(info.getCity())
                .setCountry(info.getCountry())
                .setStationName(info.getStationName())
                .setStationType(info.getStationType())
                .setLatitude(info.getLatitude())
                .setLongitude(info.getLongitude());
        pinf.setSinf(sinf);
        return pinf;
    }
    //将info对象转为电池组对象
    public static BattInf infoToBatt(InfoDto info) {
        BattInf binf = new BattInf();
        binf.setDevIp(info.getDevIp())
                .setDevType(info.getDevType())
                .setMoncapstd(info.getMoncapstd())
                .setMoncount(info.getMoncount())
                .setMonresstd(info.getMonresstd())
                .setMonvolstd(info.getMonvolstd())
                .setProduct(info.getProduct())
                .setBattModel(info.getBattModel());
        return binf;
    }
}