package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.whyc.mapper.BattInfChangeMapper;
|
import com.whyc.mapper.PowerInfChangeMapper;
|
import com.whyc.mapper.StationInfChangeMapper;
|
import com.whyc.pojo.db_station.*;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Date;
|
import java.util.List;
|
|
@Service
|
public class InfoChangeService {
|
@Autowired(required = false)
|
private StationInfChangeMapper sinfChangeMapper;
|
|
@Autowired(required = false)
|
private PowerInfChangeMapper pinfChangeMapper;
|
|
@Autowired(required = false)
|
private BattInfChangeMapper binfChangeMapper;
|
|
//存入变更信息记录
|
public void addInfoChange(StationInf sinf, PowerInf pinf, BattInf binf,String updateReason) {
|
StationInfChange sinfChange = new StationInfChange();
|
PowerInfChange pinfChange = new PowerInfChange();
|
BattInfChange binfChange = new BattInfChange();
|
Date updateTime = new Date();
|
//将信息拷贝至对应的变更信息表
|
BeanUtils.copyProperties(sinf,sinfChange);
|
String fullName=sinf.getProvice()+"_"+sinf.getCity()+"_"+sinf.getCountry()+"_"+sinf.getStationName();
|
sinfChange.setFullName(fullName);
|
sinfChange.setUpdateTime(updateTime);
|
sinfChange.setUpdateReason(updateReason);
|
|
BeanUtils.copyProperties(pinf,pinfChange);
|
pinfChange.setUpdateTime(updateTime);
|
pinfChange.setUpdateReason(updateReason);
|
|
BeanUtils.copyProperties(binf,binfChange);
|
binfChange.setUpdateTime(updateTime);
|
binfChange.setUpdateReason(updateReason);
|
|
//将变更记录存入变更表
|
sinfChangeMapper.insert(sinfChange);
|
pinfChangeMapper.insert(pinfChange);
|
binfChangeMapper.insert(binfChange);
|
}
|
//获取机房,电源,电池组变更记录
|
public List<StationInfChange> getSinfChange(Integer stationId) {
|
QueryWrapper wrapper=new QueryWrapper();
|
wrapper.eq("station_id",stationId);
|
wrapper.orderByDesc("update_time");
|
List<StationInfChange> list=sinfChangeMapper.selectList(wrapper);
|
return list;
|
}
|
public List<PowerInfChange> getPinfChange(Integer powerId) {
|
QueryWrapper wrapper=new QueryWrapper();
|
wrapper.eq("power_id",powerId);
|
wrapper.orderByDesc("update_time");
|
List<PowerInfChange> list=pinfChangeMapper.selectList(wrapper);
|
return list;
|
}
|
|
public List<BattInfChange> getBinfChange(Integer battgroupId) {
|
QueryWrapper wrapper=new QueryWrapper();
|
wrapper.eq("battgroup_id",battgroupId);
|
wrapper.orderByDesc("update_time");
|
List<BattInfChange> list=binfChangeMapper.selectList(wrapper);
|
return list;
|
}
|
}
|