houzhongjian
2024-07-23 a6de490948278991e47952e90671ddba4555e9a2
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
package com.iailab.module.device.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.iailab.framework.common.constant.Constant;
import com.iailab.framework.common.page.PageData;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.module.device.dao.DeviceHealthAlarmDao;
import com.iailab.module.device.dto.DeviceHealthAlarmDTO;
import com.iailab.module.device.entity.DeviceHealthAlarmEntity;
import com.iailab.module.device.service.DeviceHealthAlarmService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
 
import java.util.Map;
 
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年06月28日
 */
@Slf4j
@Service
public class DeviceHealthAlarmServiceImpl extends BaseServiceImpl<DeviceHealthAlarmDao, DeviceHealthAlarmEntity>
        implements DeviceHealthAlarmService {
    @Override
    public PageData<DeviceHealthAlarmDTO> page(Map<String, Object> params) {
        IPage<DeviceHealthAlarmEntity> page = baseDao.selectPage(
                getPage(params, Constant.CREATE_DATE, false),
                getWrapper(params)
        );
        return getPageData(page, DeviceHealthAlarmDTO.class);
    }
 
    @Override
    public DeviceHealthAlarmDTO get(String id) {
        return baseDao.getInfo(id);
    }
 
    private QueryWrapper<DeviceHealthAlarmEntity> getWrapper(Map<String, Object> params) {
        String devNo = (String) params.get("devNo");
        String devName = (String) params.get("devName");
        String faultName = (String) params.get("faultName");
        String startTime = (String) params.get("startTime");
        String endTime = (String) params.get("endTime");
        QueryWrapper<DeviceHealthAlarmEntity> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(devNo), "dev_no", devNo)
                .like(StringUtils.isNotBlank(devName), "dev_name", devName)
                .eq(StringUtils.isNotBlank(faultName), "fault_name", faultName)
                .ge(StringUtils.isNotBlank(startTime), "fault_time", startTime)
                .le(StringUtils.isNotBlank(endTime), "fault_time", endTime);
        return wrapper;
    }
}