TCameraServiceImpl.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. //package com.sckj.device.service.impl;
  2. //
  3. //import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. //import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  5. //import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6. //import com.baomidou.mybatisplus.core.metadata.IPage;
  7. //import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  8. //import com.sckj.camera.manager.CameraProperties;
  9. //import com.sckj.common.TapholeAdminThreadLocal;
  10. //import com.sckj.common.core.AjaxResult;
  11. //import com.sckj.common.exception.OperateException;
  12. //import com.sckj.common.validate.commons.PageValidate;
  13. //import com.sckj.device.dto.CameraInfo;
  14. //import com.sckj.device.dto.CameraParamInfo;
  15. //import com.sckj.device.validate.TCameraCreateValidate;
  16. //import com.sckj.device.validate.TCameraUpdateDTO;
  17. //import com.sckj.device.validate.TCameraUpdateValidate;
  18. //import com.sckj.device.validate.TCameraSearchValidate;
  19. //import com.sckj.device.vo.CameraDTO;
  20. //import com.sckj.device.vo.TCameraListedVo;
  21. //import com.sckj.device.vo.TCameraDetailVo;
  22. //import com.sckj.common.core.PageResult;
  23. //import com.sckj.device.entity.TCamera;
  24. //import com.sckj.device.mapper.TCameraMapper;
  25. //import org.apache.commons.lang3.ObjectUtils;
  26. //import org.springframework.beans.BeanUtils;
  27. //import org.springframework.stereotype.Service;
  28. //import org.springframework.transaction.annotation.Transactional;
  29. //import org.springframework.util.Assert;
  30. //import org.springframework.util.CollectionUtils;
  31. //
  32. //import javax.annotation.Resource;
  33. //import java.util.*;
  34. //import java.util.regex.Matcher;
  35. //import java.util.regex.Pattern;
  36. //import java.util.stream.Collectors;
  37. //import java.util.stream.Stream;
  38. //
  39. ///**
  40. // * 摄像头实现类
  41. // *
  42. // * @author zhanghao
  43. // */
  44. //@Service
  45. //public class TCameraServiceImpl extends ServiceImpl<TCameraMapper, TCamera> {
  46. //
  47. // @Resource
  48. // TCameraMapper tCameraMapper;
  49. //
  50. // /**
  51. // * 摄像头列表
  52. // *
  53. // * @param pageValidate 分页参数
  54. // * @param searchValidate 搜索参数
  55. // * @return PageResult<TCameraListedVo>
  56. // * @author zhanghao
  57. // */
  58. // public PageResult<TCameraListedVo> list(PageValidate pageValidate, TCameraSearchValidate searchValidate) {
  59. // Integer page = pageValidate.getPageNo();
  60. // Integer limit = pageValidate.getPageSize();
  61. //
  62. // QueryWrapper<TCamera> queryWrapper = new QueryWrapper<>();
  63. // queryWrapper.eq("del_flag", "1");
  64. // queryWrapper.orderByDesc("id");
  65. //
  66. // tCameraMapper.setSearch(queryWrapper, searchValidate, new String[]{
  67. // "=:no:str",
  68. // "like:name:str",
  69. // "=:model:str",
  70. // });
  71. //
  72. // IPage<TCamera> iPage = tCameraMapper.selectPage(new Page<>(page, limit), queryWrapper.eq("type", "1"));
  73. //
  74. // List<TCameraListedVo> list = new LinkedList<>();
  75. // for (TCamera item : iPage.getRecords()) {
  76. // TCameraListedVo vo = new TCameraListedVo();
  77. // BeanUtils.copyProperties(item, vo);
  78. // vo.setAddress("rtsp://" + item.getAccount() + ":" + item.getPassword() + "@" + item.getIp() + ":" + item.getPort() + "/102");
  79. // list.add(vo);
  80. // }
  81. //
  82. // return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
  83. // }
  84. //
  85. // /**
  86. // * 摄像头详情
  87. // *
  88. // * @param id 主键参数
  89. // * @return TCamera
  90. // * @author zhanghao
  91. // */
  92. // public TCameraDetailVo detail(Integer id) {
  93. // TCamera model = tCameraMapper.selectOne(
  94. // new QueryWrapper<TCamera>()
  95. // .eq("id", id).eq("del_flag", "1")
  96. // .last("limit 1"));
  97. //
  98. // Assert.notNull(model, "数据不存在");
  99. //
  100. // TCameraDetailVo vo = new TCameraDetailVo();
  101. // BeanUtils.copyProperties(model, vo);
  102. // return vo;
  103. // }
  104. //
  105. // /**
  106. // * 摄像头新增
  107. // *
  108. // * @param createValidate 参数
  109. // * @author zhanghao
  110. // */
  111. // public int add(TCameraCreateValidate createValidate) {
  112. // TCamera model = new TCamera();
  113. // if (!checkPortAndIp(createValidate.getPort(), createValidate.getIp())) {
  114. // return 0;
  115. // }
  116. // model.setCreateTime(new Date(System.currentTimeMillis()));
  117. // model.setCreateBy(String.valueOf(TapholeAdminThreadLocal.getAdminUsername()));
  118. // model.setUpdateTime(new Date(System.currentTimeMillis()));
  119. // model.setNo(createValidate.getNo());
  120. // model.setName(createValidate.getName());
  121. // model.setModel(createValidate.getModel());
  122. // model.setLocation(createValidate.getLocation());
  123. // model.setIp(createValidate.getIp());
  124. // model.setPort(createValidate.getPort());
  125. // model.setStatus(createValidate.getStatus());
  126. // model.setVcrId(createValidate.getVcrId());
  127. // model.setType(createValidate.getType());
  128. // return tCameraMapper.insert(model);
  129. // }
  130. //
  131. // /**
  132. // * 摄像头编辑
  133. // *
  134. // * @param updateValidate 参数
  135. // * @author zhanghao
  136. // */
  137. // public int edit(TCameraUpdateValidate updateValidate) {
  138. // TCamera model = tCameraMapper.selectOne(
  139. // new QueryWrapper<TCamera>()
  140. // .eq("id", updateValidate.getId())
  141. // .last("limit 1"));
  142. //
  143. // Assert.notNull(model, "数据不存在!");
  144. //
  145. // if (!checkPortAndIp(updateValidate.getPort(), updateValidate.getIp())) {
  146. // return 0;
  147. // }
  148. //
  149. // model.setUpdateTime(new Date(System.currentTimeMillis()));
  150. // model.setUpdateBy(String.valueOf(TapholeAdminThreadLocal.getAdminUsername()));
  151. // model.setNo(updateValidate.getNo());
  152. // model.setName(updateValidate.getName());
  153. // model.setModel(updateValidate.getModel());
  154. // model.setLocation(updateValidate.getLocation());
  155. // model.setIp(updateValidate.getIp());
  156. // model.setPort(updateValidate.getPort());
  157. // model.setStatus(updateValidate.getStatus());
  158. // model.setVcrId(updateValidate.getVcrId());
  159. // return tCameraMapper.updateById(model);
  160. // }
  161. //
  162. // public boolean checkPortAndIp(String port, String ip) {
  163. // if (Integer.parseInt(port) > 65535 && Integer.parseInt(port) < 0) {
  164. // return false;
  165. // }
  166. // String IP_PATTERN = "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
  167. // Pattern pattern = Pattern.compile(IP_PATTERN);
  168. // Matcher matcher = pattern.matcher(ip);
  169. // if (!matcher.matches()) {
  170. // return false;
  171. // }
  172. // return true;
  173. // }
  174. //
  175. // /**
  176. // * 摄像头删除
  177. // *
  178. // * @param id 主键ID
  179. // * @author zhanghao
  180. // */
  181. // public void del(Integer id) {
  182. // TCamera model = tCameraMapper.selectOne(
  183. // new QueryWrapper<TCamera>()
  184. // .eq("id", id)
  185. // .last("limit 1"));
  186. //
  187. // Assert.notNull(model, "数据不存在!");
  188. //
  189. // model.setDelFlag("0");
  190. //
  191. // tCameraMapper.updateById(model);
  192. // }
  193. //
  194. // /**
  195. // * 摄像头批量删除
  196. // *
  197. // * @param ids 主键数组
  198. // * @author zhanghao
  199. // */
  200. // public AjaxResult<Object> del_ex(List<Long> ids) {
  201. // List<TCamera> models = tCameraMapper.selectList(
  202. // new QueryWrapper<TCamera>()
  203. // .in("id", ids));
  204. //
  205. // if (CollectionUtils.isEmpty(models)) {
  206. // return AjaxResult.failed("数据不存在");
  207. // }
  208. // TCamera model = new TCamera();
  209. // model.setDelFlag("0");
  210. // tCameraMapper.update(model, new QueryWrapper<TCamera>().in("id", ids));
  211. // return AjaxResult.success();
  212. // }
  213. //
  214. // @Resource
  215. // private CameraProperties cameraProperties;
  216. //
  217. //
  218. // public CameraInfo getCameraInfo() {
  219. // List<TCamera> cameraList = lambdaQuery().eq(TCamera::getType, "1").in(TCamera::getStatus, "1", "2").orderByAsc(TCamera::getSort).list();
  220. // CameraInfo cameraParamInfo = new CameraInfo();
  221. // List<CameraDTO> collect = cameraList.stream().flatMap((item) -> {
  222. // CameraDTO dto = new CameraDTO();
  223. // BeanUtils.copyProperties(item, dto);
  224. // String channelNumberStr = 1 + "02"; //新通道(2012年之后设备,02代表子码流)
  225. // String rtspUrl = "rtsp://" + item.getAccount() + ":" + item.getPassword() + "@" + item.getIp() + ":" + item.getPortRtsp() + "/" + channelNumberStr + "?transportmode=unicast"; //新码流
  226. // dto.setRtspUrl(rtspUrl);
  227. // return Stream.of(dto);
  228. // }).collect(Collectors.toList());
  229. // cameraParamInfo.setCameraList(collect);
  230. //
  231. // List<CameraDTO> bannerList = new ArrayList<>();
  232. // for (CameraDTO cameraDTO : collect) {
  233. // if ("2".equals(cameraDTO.getStatus())) {
  234. // bannerList.add(cameraDTO);
  235. // }
  236. // }
  237. // cameraParamInfo.setBannerList(collect);
  238. // cameraParamInfo.setRtmpUrl("http://" + cameraProperties.getRtmp().getWebrtchost());
  239. //// map.put("rtmpUrl", "http://" + cameraProperties.getRtmp().getWebrtchost());
  240. // return cameraParamInfo;
  241. // }
  242. //
  243. // public CameraParamInfo getCameraParamInfo() {
  244. // List<TCamera> cameraList = lambdaQuery().eq(TCamera::getType, "1").in(TCamera::getStatus, "1", "2").orderByAsc(TCamera::getSort).list();
  245. // CameraParamInfo map = new CameraParamInfo();
  246. // List<CameraDTO> collect = cameraList.stream().flatMap((item) -> {
  247. // CameraDTO dto = new CameraDTO();
  248. // BeanUtils.copyProperties(item, dto);
  249. // return Stream.of(dto);
  250. // }).collect(Collectors.toList());
  251. //
  252. // List<CameraDTO> normalList = new ArrayList<>();
  253. // List<CameraDTO> bannerList = new ArrayList<>();
  254. //
  255. // for (CameraDTO cameraDTO : collect) {
  256. // if ("1".equals(cameraDTO.getStatus())) {
  257. // normalList.add(cameraDTO);
  258. // }
  259. // if ("2".equals(cameraDTO.getStatus())) {
  260. // bannerList.add(cameraDTO);
  261. // }
  262. // }
  263. // map.setNormalList(normalList);
  264. // map.setBannerList(bannerList);
  265. // return map;
  266. // }
  267. //
  268. //
  269. // @Transactional
  270. // public void updateBatchs(List<TCameraUpdateDTO> cameraList) {
  271. // for (TCameraUpdateDTO camera : cameraList) {
  272. // TCamera queryData = getById(camera.getId());
  273. // if (ObjectUtils.isEmpty(queryData)) {
  274. // throw new OperateException(String.format("传入的ID不存在:%s", camera.getId()));
  275. // }
  276. //
  277. // LambdaUpdateWrapper<TCamera> wrapper = new LambdaUpdateWrapper<>();
  278. // wrapper.eq(TCamera::getId, camera.getId());
  279. // if (ObjectUtils.isNotEmpty(camera.getStatus())) {
  280. // wrapper.set(TCamera::getStatus, camera.getStatus());
  281. // }
  282. // if (camera.getSort() != null) {
  283. // wrapper.set(TCamera::getSort, camera.getSort());
  284. // }
  285. // update(wrapper);
  286. // }
  287. // }
  288. //
  289. //}