BaseCameraManagementServiceImpl.java 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. package com.ozs.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6. import com.baomidou.mybatisplus.generator.config.IFileCreate;
  7. import com.github.pagehelper.PageHelper;
  8. import com.ozs.common.core.domain.AjaxResult;
  9. import com.ozs.common.core.domain.entity.SysDictData;
  10. import com.ozs.common.exception.ServiceException;
  11. import com.ozs.common.utils.AppendUtils;
  12. import com.ozs.common.utils.StringUtils;
  13. import com.ozs.common.utils.bean.BeanUtils;
  14. import com.ozs.common.utils.bean.BeanValidators;
  15. import com.ozs.entity.*;
  16. import com.ozs.entity.vo.BaseCameraManagementHomeVo;
  17. import com.ozs.entity.vo.BaseCameraManagementVo;
  18. import com.ozs.entity.vo.BaseCameraManagementVos;
  19. import com.ozs.entity.vo.BaseVehicleTerminalDto;
  20. import com.ozs.mapper.*;
  21. import com.ozs.service.BaseCameraManagementService;
  22. import com.ozs.service.BaseRailwayManagementService;
  23. import com.ozs.service.BaseUserService;
  24. import com.ozs.system.service.ISysDictTypeService;
  25. import com.ozs.utils.CameraUtil;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.stereotype.Service;
  28. import org.springframework.util.ObjectUtils;
  29. import javax.annotation.Resource;
  30. import javax.validation.Validator;
  31. import java.math.BigDecimal;
  32. import java.math.RoundingMode;
  33. import java.util.*;
  34. /**
  35. * <p>
  36. * 相机台账管理表 服务实现类
  37. * </p>
  38. *
  39. * @author ozs
  40. * @since 2023-02-17
  41. */
  42. @Service
  43. public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManagementMapper, BaseCameraManagement> implements BaseCameraManagementService {
  44. public static final String PATTERN = "^(\\d+.\\d{1,3}|\\d+)$";
  45. @Autowired
  46. protected Validator validator;
  47. @Autowired
  48. BaseDeviceDynamicManagementMapper baseDeviceDynamicManagementMapper;
  49. @Resource
  50. private BaseCameraManagementMapper baseCameraManagementMapper;
  51. @Resource
  52. private BaseUserService baseUserService;
  53. @Resource
  54. private BaseUserMapper baseUserMapper;
  55. @Resource
  56. private MsgAlarmMapper msgAlarmMapper;
  57. @Autowired
  58. private BaseDeptMapper baseDeptMapper;
  59. @Autowired
  60. private BaseRailwayManagementService baseRailwayManagementService;
  61. @Autowired
  62. private SkynetHeartbeatLogMapper skynetHeartbeatLogMapper;
  63. @Autowired
  64. private BaseRailwayManagementMapper baseRailwayManagementMapper;
  65. @Autowired
  66. private ISysDictTypeService dictTypeService;
  67. /**
  68. * 相机台账管理表导入
  69. *
  70. * @param accountManageList 相机台账列表
  71. * @param updateSupport 是否更新支持,如果已存在,则进行更新数据
  72. * @return
  73. */
  74. @Override
  75. public String importBaseAccountManagement(List<BaseCameraManagementVos> accountManageList, boolean updateSupport, String userId) {
  76. if (StringUtils.isEmptySunhh(accountManageList) || accountManageList.size() == 0) {
  77. throw new ServiceException("导入相机台账列表信息不能为空!");
  78. }
  79. int successNum = 0;
  80. int failureNum = 0;
  81. StringBuilder successMsg = new StringBuilder();
  82. StringBuilder failureMsg = new StringBuilder();
  83. for (BaseCameraManagementVos cameraManagementVos : accountManageList) {
  84. try {
  85. BaseCameraManagement accountManagement = new BaseCameraManagement();
  86. BeanUtils.copyProperties(cameraManagementVos, accountManagement);
  87. accountManagement.setBeginMile(AppendUtils.stringSplit(accountManagement.getBeginMiles()));
  88. accountManagement.setEndMile(AppendUtils.stringSplit(accountManagement.getEndMiles()));
  89. accountManagement.setInstallMile(AppendUtils.stringSplit(accountManagement.getInstallMiles()));
  90. // 判断相机编码是否存在
  91. LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
  92. if (!StringUtils.isEmptySunhh(accountManagement.getCameraCode())) {
  93. lw.eq(BaseCameraManagement::getCameraCode, accountManagement.getCameraCode());
  94. }
  95. BaseCameraManagement baseAccountManagement = baseCameraManagementMapper.selectOne(lw);
  96. if (StringUtils.isEmptySunhh(baseAccountManagement)) {
  97. BeanValidators.validateWithException(validator, accountManagement);
  98. accountManagement.setUpdateBy(userId);
  99. accountManagement.setCreateBy(userId);
  100. // Long deptId = baseDeptMapper.selectDeptByDeptName(accountManagement.getDeptName());
  101. // log.debug(accountManagement.getDeptName() + "主键id:" + deptId);
  102. // if (!ObjectUtils.isEmpty(deptId)) {
  103. // accountManagement.setDeptId(deptId);
  104. LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
  105. if (!StringUtils.isEmptySunhh(accountManagement.getRailwayName())) {
  106. queryWrapper.eq(BaseRailwayManagement::getRailwayName, accountManagement.getRailwayName());
  107. }
  108. // List<BaseRailwayManagement> list = baseRailwayManagementService.list(queryWrapper);
  109. BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
  110. if (!StringUtils.isEmptySunhh(baseRailwayManagement)) {
  111. if (!accountManagement.getBeginMile().toString().matches(PATTERN) || !accountManagement.getInstallMile().toString().matches(PATTERN) || !accountManagement.getEndMile().toString().matches(PATTERN)) {
  112. failureNum++;
  113. failureMsg.append(failureNum + "、相机编码为: " + accountManagement.getCameraCode() + "的数据,里程位置填写格式不正确,请填写数字");
  114. } else {
  115. accountManagement.setRailwayCode(baseRailwayManagement.getRailwayCode());
  116. if (!StringUtils.isEmptySunhh(accountManagement.getBeginMileBD())) {
  117. if (!accountManagement.getBeginMileBD().toString().matches(PATTERN)) {
  118. failureNum++;
  119. String msg = failureNum + "、监控范围开始里程位置填写格式不正确";
  120. failureMsg.append(msg);
  121. log.error(msg);
  122. // return error("监控范围开始里程位置填写格式不正确");
  123. } else {
  124. BigDecimal begin = accountManagement.getBeginMileBD().setScale(3, RoundingMode.HALF_UP);
  125. // BigDecimal begin = BigDecimal.parseDouble(baseCameraManagement.getBeginMile().toString());
  126. accountManagement.setBeginMile(begin.multiply(new BigDecimal("1000")).intValue());
  127. }
  128. }
  129. if (!StringUtils.isEmptySunhh(accountManagement.getInstallMileBD())) {
  130. if (!accountManagement.getInstallMileBD().toString().matches(PATTERN)) {
  131. failureNum++;
  132. String msg = failureNum + "、监控相机安装里程位置填写格式不正确";
  133. failureMsg.append(msg);
  134. log.error(msg);
  135. // return error("监控相机安装里程位置填写格式不正确");
  136. } else {
  137. BigDecimal install = accountManagement.getInstallMileBD().setScale(3, RoundingMode.HALF_UP);
  138. // double install = Double.parseDouble(baseCameraManagement.getInstallMile().toString());
  139. accountManagement.setInstallMile(install.multiply(new BigDecimal("1000")).intValue());
  140. }
  141. }
  142. if (!StringUtils.isEmptySunhh(accountManagement.getInstallMileBD())) {
  143. if (!accountManagement.getInstallMileBD().toString().matches(PATTERN)) {
  144. failureNum++;
  145. String msg = failureNum + "、监控范围结束里程位置填写格式不正确";
  146. failureMsg.append(msg);
  147. log.error(msg);
  148. // return error("监控范围结束里程位置填写格式不正确");
  149. } else {
  150. BigDecimal end = accountManagement.getInstallMileBD().setScale(3, RoundingMode.HALF_UP);
  151. // double end = Double.parseDouble(baseCameraManagement.getEndMile().toString());
  152. accountManagement.setEndMile(end.multiply(new BigDecimal("1000")).intValue());
  153. }
  154. }
  155. // accountManagement.setInstallMile(accountManagement.getInstallMileBD() * 1000);
  156. // accountManagement.setEndMile(accountManagement.getEndMile() * 1000);
  157. // accountManagement.setBeginMile(accountManagement.getBeginMile() * 1000);
  158. if (!StringUtils.isEmpty(cameraManagementVos.getMonitoringDirectionName())) {
  159. List<SysDictData> data = dictTypeService.selectDictDataByType("monitoring_direction");
  160. for (SysDictData datum : data) {
  161. if (datum.getDictLabel().equals(cameraManagementVos.getMonitoringDirectionName())) {
  162. accountManagement.setMonitoringDirection(Integer.valueOf(datum.getDictValue()));
  163. }
  164. }
  165. }
  166. if (!StringUtils.isEmpty(cameraManagementVos.getEnableOrNotName())) {
  167. accountManagement.setEnableOrNot(cameraManagementVos.getEnableOrNotName().equals("启用") ? 1 : 2);
  168. }
  169. baseCameraManagementMapper.insert(accountManagement);
  170. BaseDeviceDynamicManagement baseDeviceDynamicManagement = new BaseDeviceDynamicManagement();
  171. baseDeviceDynamicManagement.setCameraCode(accountManagement.getCameraCode());
  172. baseDeviceDynamicManagement.setUpdateBy(userId);
  173. baseDeviceDynamicManagement.setCreateBy(userId);
  174. baseDeviceDynamicManagementMapper.insert(baseDeviceDynamicManagement);
  175. successNum++;
  176. successMsg.append(successNum + "、相机编码 " + accountManagement.getCameraCode() + " 导入成功");
  177. }
  178. } else {
  179. failureNum++;
  180. String msg = failureNum + "、相机所属线路名称 " + accountManagement.getRailwayName() + "不存在, 导入失败:";
  181. failureMsg.append(msg);
  182. log.error(msg);
  183. }
  184. // } else {
  185. // failureNum++;
  186. // String msg = failureNum + "、相机所属工务段 " + accountManagement.getDeptName() + "不存在, 导入失败:";
  187. // failureMsg.append(msg);
  188. // log.error(msg);
  189. // }
  190. } else if (updateSupport) {
  191. BeanValidators.validateWithException(validator, accountManagement);
  192. accountManagement.setUpdateBy(userId);
  193. Long deptId = baseDeptMapper.selectDeptByDeptName(accountManagement.getDeptName());
  194. log.debug(accountManagement.getDeptName() + "主键id:" + deptId);
  195. // if (!ObjectUtils.isEmpty(deptId)) {
  196. accountManagement.setDeptId(deptId);
  197. if (!StringUtils.isEmpty(cameraManagementVos.getMonitoringDirectionName())) {
  198. List<SysDictData> data = dictTypeService.selectDictDataByType("monitoring_direction");
  199. for (SysDictData datum : data) {
  200. if (datum.getDictLabel().equals(cameraManagementVos.getMonitoringDirectionName())) {
  201. accountManagement.setMonitoringDirection(Integer.valueOf(datum.getDictValue()));
  202. }
  203. }
  204. }
  205. if (!StringUtils.isEmpty(cameraManagementVos.getEnableOrNotName())) {
  206. accountManagement.setEnableOrNot(cameraManagementVos.getEnableOrNotName().equals("启用") ? 1 : 2);
  207. }
  208. baseCameraManagementMapper.update(accountManagement, lw);
  209. LambdaQueryWrapper<BaseDeviceDynamicManagement> wrapper = new LambdaQueryWrapper<BaseDeviceDynamicManagement>();
  210. if (!StringUtils.isEmptySunhh(baseAccountManagement.getCameraCode())) {
  211. wrapper.eq(BaseDeviceDynamicManagement::getCameraCode, baseAccountManagement.getCameraCode());
  212. }
  213. BaseDeviceDynamicManagement baseDeviceDynamicManagement = baseDeviceDynamicManagementMapper.selectOne(wrapper);
  214. baseDeviceDynamicManagement.setCameraCode(accountManagement.getCameraCode());
  215. baseDeviceDynamicManagement.setUpdateBy(userId);
  216. baseDeviceDynamicManagementMapper.updateById(baseDeviceDynamicManagement);
  217. successNum++;
  218. successMsg.append(successNum + "、相机编码 " + accountManagement.getCameraCode() + " 更新成功");
  219. // } else {
  220. // failureNum++;
  221. // String msg = failureNum + "、相机所属工务段 " + accountManagement.getDeptName() + "不存在, 导入失败:";
  222. // failureMsg.append(msg);
  223. // log.error(msg);
  224. // }
  225. } else {
  226. failureNum++;
  227. failureMsg.append(failureNum + "、相机编码 " + accountManagement.getCameraCode() + " 已存在");
  228. }
  229. } catch (Exception e) {
  230. String msg = null;
  231. failureNum++;
  232. if (ObjectUtils.isEmpty(cameraManagementVos)) {
  233. msg = "导入的文档格式不正确";
  234. } else {
  235. msg = failureNum + "、相机编码 " + cameraManagementVos.getCameraCode() + " 导入失败:";
  236. }
  237. failureMsg.append(msg);
  238. log.error(msg, e);
  239. }
  240. }
  241. if (failureNum > 0) {
  242. failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
  243. throw new ServiceException(failureMsg.toString());
  244. } else {
  245. successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条。");
  246. }
  247. return successMsg.toString();
  248. }
  249. /**
  250. * 获取相机列表+数据权限
  251. *
  252. * @return
  253. */
  254. @Override
  255. public List<BaseCameraManagementHomeVo> selectCameraAll(BaseCameraManagementVo baseCameraManagementVo) {
  256. // List<String> userIdList = getUserIds(userId);
  257. // LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
  258. // if (!StringUtils.isEmpty(userIdList)) {
  259. // lw.in(BaseCameraManagement::getCreateBy, userIdList);
  260. // }
  261. // List<BaseCameraManagement> baseCameraManagementList = baseCameraManagementMapper.selectList(lw);
  262. List<BaseCameraManagement> baseCameraManagementList = baseCameraManagementMapper.selectCameraManagementList(baseCameraManagementVo);
  263. List<BaseCameraManagementHomeVo> allListVo = BeanUtils.entityListToVOList(baseCameraManagementList, BaseCameraManagementHomeVo.class);
  264. for (BaseCameraManagementHomeVo baseCameraManagementHomeVo : allListVo) {
  265. Integer isRelease = msgAlarmMapper.selectCameraCode(baseCameraManagementHomeVo.getCameraCode());
  266. baseCameraManagementHomeVo.setIsRelease(isRelease != null ? isRelease : 1);
  267. }
  268. return allListVo;
  269. }
  270. /**
  271. * 根据当前登陆用户ID 查询当前用户数据权限
  272. *
  273. * @param userId
  274. * @return
  275. */
  276. /* public List<String> getUserIds(String userId) {
  277. BaseUser baseUser = baseUserService.getUser(userId);
  278. if (StringUtils.isNull(baseUser) || StringUtils.isNull(baseUser.getDataPermission())
  279. || StringUtils.isNull(baseUser.getDeptId())) {
  280. return null;
  281. }
  282. // 数据权限 1:本人;2:本部门;3:本部门及下级部门;4:本人及本级部门;5:本人及本部门及下级部门;6:全部
  283. Integer dataPermission = baseUser.getDataPermission();
  284. Long deptId = baseUser.getDeptId();
  285. Set<String> set = new HashSet<>();
  286. if (1 == dataPermission) {
  287. set = baseUserMapper.getUserIdList(userId);
  288. } else if (2 == dataPermission) {
  289. set = baseUserMapper.getUserIdByDeptId(deptId);
  290. } else if (3 == dataPermission) {
  291. // 获取部门数据
  292. List<Long> deptList = baseUserMapper.getDeptId(deptId);
  293. // 获取用户列表
  294. set = baseUserMapper.getUserIdByDeptIds(deptList);
  295. } else if (4 == dataPermission) {
  296. set = baseUserMapper.getUserIdByDeptIdAndUserId(userId, deptId);
  297. } else if (5 == dataPermission) {
  298. // 获取本人
  299. Set<String> setUser = baseUserMapper.getUserIdListBy5(userId);
  300. // 获取部门数据
  301. List<Long> deptList5 = baseUserMapper.getDeptId(deptId);
  302. // 获取用户列表
  303. Set<String> setUsers = baseUserMapper.getUserIdByDeptIdsBy5(deptList5);
  304. set.addAll(setUser);
  305. set.addAll(setUsers);
  306. } else if (6 == dataPermission) {
  307. set = baseUserMapper.getUserIdList6();
  308. }
  309. List<String> list = new ArrayList<>(set);
  310. return list;
  311. }*/
  312. /**
  313. * 根据当前登陆用户ID 查询当前用户数据权限
  314. *
  315. * @param userId
  316. * @return
  317. */
  318. @Override
  319. public List<String> getUserIdList(String userId) {
  320. BaseUser baseUser = baseUserService.getUser(userId);
  321. if (StringUtils.isNull(baseUser) || StringUtils.isNull(baseUser.getDataPermission())
  322. || StringUtils.isNull(baseUser.getDeptId())) {
  323. return null;
  324. }
  325. // 数据权限 1:本人;2:本部门;3:本部门及下级部门;4:本人及本级部门;5:本人及本部门及下级部门;6:全部
  326. Integer dataPermission = baseUser.getDataPermission();
  327. Long deptId = baseUser.getDeptId();
  328. Set<String> set = new HashSet<>();
  329. if (1 == dataPermission) {
  330. set = baseUserMapper.getUserIdList(userId);
  331. } else if (2 == dataPermission) {
  332. set = baseUserMapper.getUserIdByDeptId(deptId);
  333. } else if (3 == dataPermission) {
  334. // 获取部门数据
  335. List<Long> deptList = baseUserMapper.getDeptId(deptId);
  336. // 获取用户列表
  337. set = baseUserMapper.getUserIdByDeptIds(deptList);
  338. } else if (4 == dataPermission) {
  339. set = baseUserMapper.getUserIdByDeptIdAndUserId(userId, deptId);
  340. } else if (5 == dataPermission) {
  341. // 获取本人
  342. Set<String> setUser = baseUserMapper.getUserIdListBy5(userId);
  343. // 获取部门数据
  344. List<Long> deptList5 = baseUserMapper.getDeptId(deptId);
  345. // 获取用户列表
  346. Set<String> setUsers = baseUserMapper.getUserIdByDeptIdsBy5(deptList5);
  347. set.addAll(setUser);
  348. set.addAll(setUsers);
  349. } else if (6 == dataPermission) {
  350. set = baseUserMapper.getUserIdsList();
  351. }
  352. List<String> list = new ArrayList<>(set);
  353. return list;
  354. }
  355. @Override
  356. public IPage<BaseCameraManagement> queryPage(BaseCameraManagementVo baseCameraManagementVo) {
  357. int pageNum = Integer.parseInt(baseCameraManagementVo.getPageNum().toString());
  358. int pageSize = Integer.parseInt(baseCameraManagementVo.getPageSize().toString());
  359. com.github.pagehelper.Page<BaseCameraManagement> page = PageHelper.startPage(pageNum, pageSize)
  360. .doSelectPage(() -> baseCameraManagementMapper.selectCameraManagementList(baseCameraManagementVo));
  361. com.baomidou.mybatisplus.extension.plugins.pagination.Page<BaseCameraManagement> pageR =
  362. new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum, pageSize);
  363. pageR.setRecords(page.getResult());
  364. pageR.setTotal(page.getTotal());
  365. return pageR;
  366. }
  367. @Override
  368. public List<BaseCameraManagement> baseCameraManagementList(BaseCameraManagementVo baseCameraManagementVo) {
  369. return baseCameraManagementMapper.selectCameraManagementList(baseCameraManagementVo);
  370. }
  371. @Override
  372. public Map<String, Integer> getMessageStatisticsCamera() {
  373. LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<>();
  374. List<BaseCameraManagement> baseCameraManagements = baseCameraManagementMapper.selectList(lw);
  375. int online = 0;
  376. int offline = 0;
  377. for (BaseCameraManagement baseCameraManagement : baseCameraManagements) {
  378. if (!StringUtils.isEmptySunhh(baseCameraManagement) && !StringUtils.isEmptySunhh(baseCameraManagement.getCameraCode())) {
  379. SkynetHeartbeatLog skynetHeartbeatLog = baseCameraManagementMapper.selectSkynetHeartbeatLogByCameraCode(baseCameraManagement.getCameraCode());
  380. if (StringUtils.isEmptySunhh(skynetHeartbeatLog)) {
  381. offline++;
  382. // baseCameraManagement.setOnline(1);
  383. } else {
  384. long timeNow = System.currentTimeMillis();
  385. long createTime = skynetHeartbeatLog.getCreateTime().getTime();
  386. long thereHourMillis = 60 * 60 * 1000 * 3;
  387. long timeNew = timeNow - thereHourMillis;
  388. if (timeNew <= createTime) {
  389. baseCameraManagement.setOnline(2);
  390. online++;
  391. } else {
  392. // baseCameraManagement.setOnline(1);
  393. offline++;
  394. }
  395. }
  396. baseCameraManagementMapper.updateById(baseCameraManagement);
  397. }
  398. }
  399. Map<String, Integer> map = new HashMap<>();
  400. map.put("countAllCamera", baseCameraManagements.size());
  401. map.put("online", online);
  402. map.put("offline", offline);
  403. return map;
  404. }
  405. @Override
  406. public AjaxResult nonContactAlarmCamera(String cameraCode) {
  407. List<BaseCameraManagement> list = new ArrayList<>();
  408. QueryWrapper<MsgAlarm> wrapper = new QueryWrapper<>();
  409. wrapper.eq("is_release", 2);
  410. List<MsgAlarm> msgAlarms = msgAlarmMapper.selectList(wrapper);
  411. if (!ObjectUtils.isEmpty(msgAlarms)) {
  412. for (MsgAlarm msgAlarm : msgAlarms) {
  413. LambdaQueryWrapper<BaseCameraManagement> camera = new LambdaQueryWrapper<BaseCameraManagement>();
  414. camera.ge(BaseCameraManagement::getEndMile, msgAlarm.getAlarmMile());
  415. camera.le(BaseCameraManagement::getBeginMile, msgAlarm.getAlarmMile());
  416. camera.eq(BaseCameraManagement::getLineDir, msgAlarm.getLineDir());
  417. camera.eq(BaseCameraManagement::getRailwayCode, msgAlarm.getRailwayCode());
  418. camera.eq(BaseCameraManagement::getOnline, 2);
  419. camera.eq(BaseCameraManagement::getEnableOrNot, 1);
  420. if (StringUtils.isNotEmpty(cameraCode)) {
  421. wrapper.eq("camera_code", cameraCode);
  422. }
  423. List<BaseCameraManagement> baseCameraManagementList = this.list(camera);
  424. for (BaseCameraManagement baseCameraManagement : baseCameraManagementList) {
  425. String end = "";
  426. if (!StringUtils.isEmptySunhh(baseCameraManagement.getEndMile())) {
  427. end = AppendUtils.stringAppend(baseCameraManagement.getEndMile());
  428. baseCameraManagement.setEndMiles(end);
  429. baseCameraManagement.setEndMileBD(new BigDecimal(baseCameraManagement.getEndMile()).divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP));
  430. }
  431. String begin = "";
  432. if (!StringUtils.isEmptySunhh(baseCameraManagement.getBeginMile())) {
  433. begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
  434. baseCameraManagement.setBeginMiles(begin);
  435. baseCameraManagement.setBeginMileBD(new BigDecimal(baseCameraManagement.getBeginMile()).divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP));
  436. }
  437. baseCameraManagement.setMilesRange(begin + "~" + end);
  438. String mils = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
  439. baseCameraManagement.setInstallMiles(mils);
  440. LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
  441. if (!ObjectUtils.isEmpty(baseCameraManagement.getRailwayCode())) {
  442. queryWrapper.eq(BaseRailwayManagement::getRailwayCode, baseCameraManagement.getRailwayCode());
  443. }
  444. BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
  445. baseCameraManagement.setRailwayName(baseRailwayManagement.getRailwayName());
  446. }
  447. if (!ObjectUtils.isEmpty(baseCameraManagementList)) {
  448. list.addAll(baseCameraManagementList);
  449. }
  450. }
  451. }
  452. return AjaxResult.success(list);
  453. }
  454. @Override
  455. public List<BaseVehicleTerminalDto> videoCaptureUrl(BaseVehicleTerminalDto baseVehicleTerminalDto) {
  456. List<BaseVehicleTerminalDto> urlList = new ArrayList<>();
  457. LambdaQueryWrapper<BaseCameraManagement> camera = new LambdaQueryWrapper<BaseCameraManagement>();
  458. camera.ge(BaseCameraManagement::getBeginMile, baseVehicleTerminalDto.getTravelMile());
  459. camera.eq(BaseCameraManagement::getLineDir, baseVehicleTerminalDto.getLineDir());
  460. camera.eq(BaseCameraManagement::getRailwayCode, baseVehicleTerminalDto.getRailwayCode());
  461. camera.eq(BaseCameraManagement::getOnline, 2);
  462. camera.eq(BaseCameraManagement::getEnableOrNot, 1);
  463. camera.orderByDesc(BaseCameraManagement::getCreateTime);
  464. camera.last("limit 4");
  465. List<BaseCameraManagement> baseCameraManagementList = this.list(camera);
  466. if (!ObjectUtils.isEmpty(baseCameraManagementList)) {
  467. List<BaseCameraManagement> list = new ArrayList<>(baseCameraManagementList);
  468. for (BaseCameraManagement baseCameraManagement : list) {
  469. String flv = CameraUtil.getPlayFlv(baseCameraManagement.getCameraCode(), baseCameraManagement.getChannel());
  470. BaseVehicleTerminalDto dto = new BaseVehicleTerminalDto();
  471. dto.setUrl(flv);
  472. dto.setCameraCode(baseCameraManagement.getCameraCode());
  473. dto.setTime(new Date());
  474. BaseRailwayManagement baseRailwayManagement = baseRailwayManagementMapper.selectOne(new QueryWrapper<BaseRailwayManagement>().eq("railway_code", baseVehicleTerminalDto.getRailwayCode()));
  475. dto.setRailwayName(baseRailwayManagement.getRailwayName());
  476. String mils = AppendUtils.stringAppend(baseVehicleTerminalDto.getTravelMile());
  477. dto.setTravelMileName(mils);
  478. dto.setLineDirStr(baseVehicleTerminalDto.getLineDir() == 1 ? "上行" : "下行");
  479. urlList.add(dto);
  480. }
  481. }
  482. return urlList;
  483. }
  484. }