whyclxw
5 天以前 4b3cef746d0752487beffb72ff340e220b0388cd
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
65
66
67
68
69
70
71
72
73
74
75
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;
    }
}