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;
|
}
|
}
|