whyclxw
2025-05-17 c7e058bb6dc997bde478c488ddc98561c61085dc
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
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());
        if(info.getProvice()!=null){
            pinf.setProvice(info.getProvice());
        }
        if(info.getCity()!=null){
            pinf.setCity(info.getCity());
        }
        if(info.getCountry()!=null){
            pinf.setCountry(info.getCountry());
        }
        if(info.getStationName()!=null){
            pinf.setStationName(info.getStationName());
        }
        if(info.getStationId()!=null){
            pinf.setStationId(info.getStationId());
        }
        if(info.getPowerId()!=null){
            pinf.setPowerId(info.getPowerId());
        }
        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());
        if(info.getBattgroupId()!=null){
            binf.setBattgroupId(info.getBattgroupId());
        }
        if(info.getDevId()!=null){
            binf.setDevId(info.getDevId());
        }
        return binf;
    }
}