whycxzp
2021-03-05 e7a7b634352f684085bb6eea34b331fc069ff44d
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.CommonMapper;
import com.whyc.mapper.RectifierPowerHistoryMapper;
import com.whyc.mapper.RectifierPowerMapper;
import com.whyc.pojo.CentralMonitorSysST;
import com.whyc.pojo.RectifierPowerRT;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.sql.Wrapper;
import java.util.List;
 
@Service
public class RectifierPowerService {
 
    @Resource
    private RectifierPowerMapper mapper;
 
    @Resource
    private RectifierPowerHistoryMapper historyMapper;
 
    @Resource
    private CommonMapper commonMapper;
 
    public Response<IPage<RectifierPowerRT>> getAll(int pageNum, int pageSize) {
        IPage<RectifierPowerRT> rectifierPowerRTIPage = mapper.selectPage(new Page<>(pageNum, pageSize), null);
        return new Response<IPage<RectifierPowerRT>>().set(1,rectifierPowerRTIPage);
    }
 
    public Response<RectifierPowerRT> getInfoByDevId(int devId) {
        QueryWrapper<RectifierPowerRT> query = Wrappers.query();
        query.eq("dev_id",devId);
        RectifierPowerRT rectifierPowerRT = mapper.selectOne(query);
        return new Response<RectifierPowerRT>().set(1,rectifierPowerRT);
    }
 
    public Response<PageInfo<RectifierPowerRT>> getHistory(int pageNum, int pageSize, int devId) {
        List<String> tableNames = commonMapper.getTableName("db_3.5mw_motor_history", "tb_rectifier_power_" + devId);
        PageHelper.startPage(pageNum,pageSize);
        List<RectifierPowerRT> rectifierPowerRTs = historyMapper.getHistory(tableNames);
        PageInfo<RectifierPowerRT> rectifierPowerRTPageInfo = new PageInfo<>(rectifierPowerRTs);
        return new Response<PageInfo<RectifierPowerRT>>().set(1,rectifierPowerRTPageInfo);
    }
}