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())
|
.setPowerType(info.getPowerType())
|
.setPowerModel(info.getPowerModel())
|
.setProtocol(info.getProtocol())
|
.setPowerIp(info.getPowerIp())
|
.setModelCfg(info.getModelCfg())
|
.setPowerInuseTime(info.getPowerInuseTime());
|
if(info.getPowerId()!=null){
|
pinf.setPowerId(info.getPowerId());
|
}
|
if(info.getPowerName()!=null){
|
pinf.setPowerName(info.getPowerName());
|
}
|
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());
|
if(info.getProvice()!=null){
|
sinf.setProvice(info.getProvice());
|
}
|
if(info.getCity()!=null){
|
sinf.setCity(info.getCity());
|
}
|
if(info.getCountry()!=null){
|
sinf.setCountry(info.getCountry());
|
}
|
if(info.getStationName()!=null){
|
sinf.setStationName(info.getStationName());
|
}
|
if(info.getStationId()!=null){
|
sinf.setStationId(info.getStationId());
|
}
|
pinf.setSinf(sinf);
|
return pinf;
|
}
|
//将info对象转为电池组对象
|
public static BattInf infoToBatt(InfoDto info) {
|
BattInf binf = new BattInf();
|
if(info.getDevType()!=null){
|
binf.setDevType(info.getDevType());
|
}
|
if(info.getMoncapstd()!=null){
|
binf.setMoncapstd(info.getMoncapstd());
|
}
|
if(info.getMoncount()!=null){
|
binf.setMoncount(info.getMoncount());
|
}
|
if(info.getMonresstd()!=null){
|
binf.setMonresstd(info.getMonresstd());
|
}
|
if(info.getMonvolstd()!=null){
|
binf.setMonvolstd(info.getMonvolstd());
|
}
|
if(info.getProduct()!=null){
|
binf.setProduct(info.getProduct());
|
}
|
if(info.getBattModel()!=null){
|
binf.setBattModel(info.getBattModel());
|
}
|
if(info.getDevIp()!=null){
|
binf.setDevIp(info.getDevIp());
|
}
|
if(info.getBattgroupId()!=null){
|
binf.setBattgroupId(info.getBattgroupId());
|
}
|
if(info.getBattgroupName()!=null){
|
binf.setBattgroupName(info.getBattgroupName());
|
}
|
if(info.getDevId()!=null){
|
binf.setDevId(info.getDevId());
|
}
|
if(info.getDevName()!=null){
|
binf.setDevName(info.getDevName());
|
}
|
if(info.getInuseTime()!=null){
|
binf.setInuseTime(info.getInuseTime());
|
}
|
return binf;
|
}
|
}
|