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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.iailab.module.data.channel.opcua.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.common.utils.PageUtils;
import com.iailab.module.data.common.utils.Query;
import com.iailab.module.data.channel.opcua.dao.ChannelOPCUADeviceDao;
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity;
import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService;
import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService;
import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Map;
 
/**
 * @author DongYukun
 * @Description
 * @createTime 2023年05月08日 15:04:00
 */
@Service
public class ChannelOPCUADeviceServiceImpl extends ServiceImpl<ChannelOPCUADeviceDao, ChannelOPCUADeviceEntity> implements ChannelOPCUADeviceService {
    @Resource
    private ChannelOPCUADeviceDao channelOPCUADeviceDao;
 
    @Resource
    private ChannelOPCUATagService channelOPCUATagService;
    /**
     * 分页查询opc ua配置
     *
     * @param params
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String serverName = (String) params.get("serverName");
 
        IPage<ChannelOPCUADeviceEntity> page = this.page(
                new Query<ChannelOPCUADeviceEntity>().getPage(params),
                new QueryWrapper<ChannelOPCUADeviceEntity>()
                        .like(StringUtils.isNotBlank(serverName), "server_name", serverName)
                        .orderByDesc("create_time")
        );
        return new PageUtils(page);
    }
 
    /**
     * 查询opc ua配置详情
     *
     * @param id
     */
    @Override
    public ChannelOPCUADeviceEntity info(String id) {
        return channelOPCUADeviceDao.selectById(id);
    }
 
    /**
     * 列表
     *
     * @param params
     * @return
     */
    @Override
    public List<ChannelOPCUADeviceEntity> list(Map<String, Object> params) {
        return channelOPCUADeviceDao.selectList(new QueryWrapper<ChannelOPCUADeviceEntity>().orderByAsc("server_name"));
    }
 
    /**
     * 添加opc ua配置
     *
     * @param channelOPCUADeviceEntity
     */
    @Override
    public void add(ChannelOPCUADeviceEntity channelOPCUADeviceEntity) {
        channelOPCUADeviceDao.insert(channelOPCUADeviceEntity);
    }
 
    /**
     * 修改opc ua配置
     *
     * @param channelOPCUADeviceEntity
     */
    @Override
    public void update(ChannelOPCUADeviceEntity channelOPCUADeviceEntity) {
        channelOPCUADeviceDao.updateById(channelOPCUADeviceEntity);
    }
 
    /**
     * 删除opc ua配置
     *
     * @param id
     */
    @Override
    public void delete(String id) {
 
        //先删除device下的tag
        channelOPCUATagService.deleteByDeviceName(info(id).getServerName());
 
        channelOPCUADeviceDao.deleteById(id);
    }
 
    @Override
    public List<ChannelOPCUADeviceDTO> selectAll() {
 
        List<ChannelOPCUADeviceEntity> entityList = baseMapper.selectList(
                null
        );
        return ConvertUtils.sourceToTarget(entityList, ChannelOPCUADeviceDTO.class);
    }
}