whycxzp
2021-07-26 8c189b243bfbbacb2ab1ce79f4e1ff22708f125a
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.app.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.CentralMonitorSysRTHistoryMapper;
import com.whyc.mapper.CentralMonitorSysRTMapper;
import com.whyc.mapper.CommonMapper;
import com.whyc.pojo.CentralMonitorSysRT;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service("SER-CentralMonitorSysRTService")
public class CentralMonitorSysRTService {
 
    @Resource
    private CentralMonitorSysRTMapper mapper;
 
    @Resource
    private CentralMonitorSysRTHistoryMapper historyMapper;
 
    @Resource
    private CommonMapper commonMapper;
 
    public Response getInfoByDevId(int devId) {
        QueryWrapper<CentralMonitorSysRT> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dev_id",devId);
        try{
            CentralMonitorSysRT centralMonitorSysRT = mapper.selectOne(queryWrapper);
            return new Response<>().set(1,centralMonitorSysRT);
        }catch (Exception e){
            e.printStackTrace();
            return new Response<>().setCode(0);
        }
    }
 
    public Response<PageInfo<CentralMonitorSysRT>> getHistory(int pageNum, int pageSize, int devId) {
        List<String> tableNames = commonMapper.getTableName("db_3.5mw_motor_history", "tb_central_monitor_sys_rt_" + devId);
        PageHelper.startPage(pageNum, pageSize);
        if (tableNames.size() > 0) {
            List<CentralMonitorSysRT> centralMonitorSysRTs = historyMapper.getAppHistory(tableNames);
            PageInfo<CentralMonitorSysRT> centralMonitorSysRTPageInfo = new PageInfo<>(centralMonitorSysRTs);
            return new Response<PageInfo<CentralMonitorSysRT>>().set(1, centralMonitorSysRTPageInfo);
 
        } else {
            return new Response<PageInfo<CentralMonitorSysRT>>().set(1, null);
        }
    }
}