提交 | 用户 | 时间
|
ce910c
|
1 |
package com.iailab.module.data.dev.service.impl; |
H |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
5 |
import com.iailab.framework.common.constant.Constant; |
|
6 |
import com.iailab.framework.common.page.PageData; |
|
7 |
import com.iailab.framework.common.pojo.PageResult; |
|
8 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
9 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
10 |
import com.iailab.framework.common.util.object.ConvertUtils; |
1432cd
|
11 |
import com.iailab.framework.web.core.util.WebFrameworkUtils; |
ce910c
|
12 |
import com.iailab.module.data.dev.controller.admin.nvr.vo.DevNvrPageReqVO; |
H |
13 |
import com.iailab.module.data.dev.controller.admin.nvr.vo.DevNvrSaveReqVO; |
|
14 |
import com.iailab.module.data.dev.dahua.DHCapturePictureClient; |
|
15 |
import com.iailab.module.data.dev.dahua.DHClientFactory; |
|
16 |
import com.iailab.module.data.dev.dao.DevNvrDao; |
|
17 |
import com.iailab.module.data.dev.dto.DevNvrDTO; |
|
18 |
import com.iailab.module.data.dev.entity.DevNvrEntity; |
|
19 |
import com.iailab.module.data.dev.service.DevNvrService; |
|
20 |
import org.apache.commons.lang3.StringUtils; |
|
21 |
import org.springframework.beans.factory.annotation.Autowired; |
|
22 |
import org.springframework.stereotype.Service; |
|
23 |
import org.springframework.transaction.annotation.Transactional; |
|
24 |
|
|
25 |
import javax.annotation.Resource; |
|
26 |
import java.util.Arrays; |
|
27 |
import java.util.Date; |
|
28 |
import java.util.List; |
|
29 |
import java.util.Map; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* @author PanZhibao |
|
34 |
* @Description |
|
35 |
* @createTime 2024年03月07日 |
|
36 |
*/ |
|
37 |
@Service |
|
38 |
public class DevNvrServiceImpl extends BaseServiceImpl<DevNvrDao, DevNvrEntity> implements DevNvrService { |
|
39 |
|
|
40 |
@Resource |
|
41 |
private DevNvrDao devNvrDao; |
|
42 |
|
|
43 |
@Resource |
|
44 |
private DHClientFactory dhClientFactory; |
|
45 |
|
|
46 |
@Override |
|
47 |
public PageResult<DevNvrDTO> getPage(DevNvrPageReqVO pageReqVO) { |
|
48 |
PageResult<DevNvrEntity> pageResult = devNvrDao.selectPage(pageReqVO); |
|
49 |
// List<DevNvrEntity> list = pageResult.getList(); |
|
50 |
// dhClientFactory.getNvrOnlineStatus(list); |
|
51 |
return BeanUtils.toBean(pageResult, DevNvrDTO.class); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public List<DevNvrDTO> list(Map<String, Object> params) { |
|
56 |
QueryWrapper<DevNvrEntity> queryWrapper = getWrapper(params); |
|
57 |
queryWrapper.orderByDesc(Constant.CREATE_DATE); |
|
58 |
List<DevNvrEntity> list = baseDao.selectList(queryWrapper); |
|
59 |
return ConvertUtils.sourceToTarget(list, DevNvrDTO.class); |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public DevNvrDTO get(String id) { |
|
64 |
DevNvrEntity entity = baseDao.selectById(id); |
|
65 |
|
|
66 |
return ConvertUtils.sourceToTarget(entity, DevNvrDTO.class); |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public DevNvrDTO getByIp(String ip) { |
|
71 |
QueryWrapper<DevNvrEntity> wrapper = new QueryWrapper<>(); |
|
72 |
wrapper.eq("ip", ip); |
|
73 |
DevNvrEntity entity = baseDao.selectOne(wrapper); |
|
74 |
|
|
75 |
return ConvertUtils.sourceToTarget(entity, DevNvrDTO.class); |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public DevNvrDTO getByCode(String code) { |
|
80 |
QueryWrapper<DevNvrEntity> wrapper = new QueryWrapper<>(); |
|
81 |
wrapper.eq("code", code); |
|
82 |
DevNvrEntity entity = baseDao.selectOne(wrapper); |
|
83 |
|
|
84 |
return ConvertUtils.sourceToTarget(entity, DevNvrDTO.class); |
|
85 |
} |
|
86 |
|
|
87 |
private QueryWrapper<DevNvrEntity> getWrapper(Map<String, Object> params) { |
|
88 |
String code = (String) params.get("code"); |
|
89 |
String location = (String) params.get("location"); |
|
90 |
String nvrId = (String) params.get("nvrId"); |
|
91 |
Integer status = params.get("status") == null ? null : Integer.parseInt(params.get("status").toString()); |
|
92 |
|
|
93 |
QueryWrapper<DevNvrEntity> wrapper = new QueryWrapper<>(); |
|
94 |
wrapper.like(StringUtils.isNotBlank(code), "code", code) |
|
95 |
.like(StringUtils.isNotBlank(location), "location", location) |
|
96 |
.eq(StringUtils.isNotBlank(nvrId), "nvr_id", nvrId) |
|
97 |
.eq(status != null, "status", status); |
|
98 |
|
|
99 |
return wrapper; |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public String save(DevNvrSaveReqVO saveReqVO) { |
|
104 |
DevNvrEntity entity = BeanUtils.toBean(saveReqVO, DevNvrEntity.class); |
|
105 |
entity.setCreateDate(new Date()); |
1432cd
|
106 |
entity.setUpdater(WebFrameworkUtils.getLoginUserId()); |
ce910c
|
107 |
insert(entity); |
H |
108 |
return entity.getId(); |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public String update(DevNvrSaveReqVO saveReqVO) { |
|
113 |
DevNvrEntity entity = BeanUtils.toBean(saveReqVO, DevNvrEntity.class); |
1432cd
|
114 |
entity.setUpdateDate(new Date()); |
H |
115 |
entity.setUpdater(WebFrameworkUtils.getLoginUserId()); |
ce910c
|
116 |
updateById(entity); |
H |
117 |
return entity.getId(); |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
@Transactional(rollbackFor = Exception.class) |
|
122 |
public void delete(Long id) { |
|
123 |
devNvrDao.deleteById(id); |
|
124 |
} |
|
125 |
|
|
126 |
// @Override |
|
127 |
// public Long cheack(DevNvrDTO dto) { |
|
128 |
// Long id = dto.getId(); |
|
129 |
// String code = dto.getCode(); |
|
130 |
// String name = dto.getName(); |
|
131 |
// QueryWrapper<DevNvrEntity> queryWrapper = new QueryWrapper<>(); |
|
132 |
// queryWrapper.ne(StringUtils.isNotBlank(id.toString()), "id", id); |
|
133 |
// queryWrapper.and(wrapper -> wrapper.eq("code", code).or(). |
|
134 |
// eq(StringUtils.isNotBlank(name), "name", name)); |
|
135 |
// return baseDao.selectCount(queryWrapper); |
|
136 |
// } |
|
137 |
|
|
138 |
@Override |
|
139 |
public void setStatus(String ip, Integer status) { |
|
140 |
QueryWrapper<DevNvrEntity> wrapper = new QueryWrapper<>(); |
|
141 |
wrapper.eq("ip", ip); |
|
142 |
DevNvrEntity entity = new DevNvrEntity(); |
|
143 |
entity.setIp(ip); |
|
144 |
entity.setStatus(status); |
|
145 |
baseDao.update(entity, wrapper); |
|
146 |
} |
|
147 |
} |