whyclxw
7 天以前 cfdb274a6e9303f78315b21c2dc66c2a2839fb39
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.constant.DevStateEnum;
import com.whyc.dto.Response;
import com.whyc.dto.Statistic.DeviceStateStic;
import com.whyc.mapper.DeviceStateMapper;
import com.whyc.pojo.db_ram_db.DeviceState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Map;
 
@Service
public class DeviceStateService {
    @Autowired(required = false)
    private DeviceStateMapper mapper;
    //实时获取设备信息
    public DeviceState getDevRealInfo(Integer devId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("dev_id",devId);
        wrapper.last("limit 1");
        DeviceState dev=mapper.selectOne(wrapper);
        return dev;
    }
    //设备工作状态统计
    public Response getDeviceStateStatistic(DeviceStateStic stic) {
        PageHelper.startPage(stic.getPageNum(),stic.getPageSize());
        List<DeviceState> list=mapper.getDeviceStateStatistic(stic);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list.size()>0,pageInfo,"设备工作状态统计");
    }
    //获取设备工作类型(下拉)
    public Response getDevState() {
        Map<Integer,String> map= DevStateEnum.getOpInfo();
        return new Response().setII(1,true,map,"获取设备工作类型(下拉)");
    }
 
    public List<DeviceState> getListByUserId(Integer userId) {
        return mapper.getListByUserId(userId);
    }
}