123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498 |
- package com.ozs.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.baomidou.mybatisplus.generator.config.IFileCreate;
- import com.github.pagehelper.PageHelper;
- import com.ozs.common.core.domain.AjaxResult;
- import com.ozs.common.core.domain.entity.SysDictData;
- import com.ozs.common.exception.ServiceException;
- import com.ozs.common.utils.AppendUtils;
- import com.ozs.common.utils.StringUtils;
- import com.ozs.common.utils.bean.BeanUtils;
- import com.ozs.common.utils.bean.BeanValidators;
- import com.ozs.entity.*;
- import com.ozs.entity.vo.BaseCameraManagementHomeVo;
- import com.ozs.entity.vo.BaseCameraManagementVo;
- import com.ozs.entity.vo.BaseCameraManagementVos;
- import com.ozs.entity.vo.BaseVehicleTerminalDto;
- import com.ozs.mapper.*;
- import com.ozs.service.BaseCameraManagementService;
- import com.ozs.service.BaseRailwayManagementService;
- import com.ozs.service.BaseUserService;
- import com.ozs.system.service.ISysDictTypeService;
- import com.ozs.utils.CameraUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.util.ObjectUtils;
- import javax.annotation.Resource;
- import javax.validation.Validator;
- import java.math.BigDecimal;
- import java.math.RoundingMode;
- import java.util.*;
- /**
- * <p>
- * 相机台账管理表 服务实现类
- * </p>
- *
- * @author ozs
- * @since 2023-02-17
- */
- @Service
- public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManagementMapper, BaseCameraManagement> implements BaseCameraManagementService {
- public static final String PATTERN = "^(\\d+.\\d{1,3}|\\d+)$";
- @Autowired
- protected Validator validator;
- @Autowired
- BaseDeviceDynamicManagementMapper baseDeviceDynamicManagementMapper;
- @Resource
- private BaseCameraManagementMapper baseCameraManagementMapper;
- @Resource
- private BaseUserService baseUserService;
- @Resource
- private BaseUserMapper baseUserMapper;
- @Resource
- private MsgAlarmMapper msgAlarmMapper;
- @Autowired
- private BaseDeptMapper baseDeptMapper;
- @Autowired
- private BaseRailwayManagementService baseRailwayManagementService;
- @Autowired
- private SkynetHeartbeatLogMapper skynetHeartbeatLogMapper;
- @Autowired
- private BaseRailwayManagementMapper baseRailwayManagementMapper;
- @Autowired
- private ISysDictTypeService dictTypeService;
- /**
- * 相机台账管理表导入
- *
- * @param accountManageList 相机台账列表
- * @param updateSupport 是否更新支持,如果已存在,则进行更新数据
- * @return
- */
- @Override
- public String importBaseAccountManagement(List<BaseCameraManagementVos> accountManageList, boolean updateSupport, String userId) {
- if (StringUtils.isEmptySunhh(accountManageList) || accountManageList.size() == 0) {
- throw new ServiceException("导入相机台账列表信息不能为空!");
- }
- int successNum = 0;
- int failureNum = 0;
- StringBuilder successMsg = new StringBuilder();
- StringBuilder failureMsg = new StringBuilder();
- for (BaseCameraManagementVos cameraManagementVos : accountManageList) {
- try {
- BaseCameraManagement accountManagement = new BaseCameraManagement();
- BeanUtils.copyProperties(cameraManagementVos, accountManagement);
- accountManagement.setBeginMile(AppendUtils.stringSplit(accountManagement.getBeginMiles()));
- accountManagement.setEndMile(AppendUtils.stringSplit(accountManagement.getEndMiles()));
- accountManagement.setInstallMile(AppendUtils.stringSplit(accountManagement.getInstallMiles()));
- // 判断相机编码是否存在
- LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
- if (!StringUtils.isEmptySunhh(accountManagement.getCameraCode())) {
- lw.eq(BaseCameraManagement::getCameraCode, accountManagement.getCameraCode());
- }
- BaseCameraManagement baseAccountManagement = baseCameraManagementMapper.selectOne(lw);
- if (StringUtils.isEmptySunhh(baseAccountManagement)) {
- BeanValidators.validateWithException(validator, accountManagement);
- accountManagement.setUpdateBy(userId);
- accountManagement.setCreateBy(userId);
- // Long deptId = baseDeptMapper.selectDeptByDeptName(accountManagement.getDeptName());
- // log.debug(accountManagement.getDeptName() + "主键id:" + deptId);
- // if (!ObjectUtils.isEmpty(deptId)) {
- // accountManagement.setDeptId(deptId);
- LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
- if (!StringUtils.isEmptySunhh(accountManagement.getRailwayName())) {
- queryWrapper.eq(BaseRailwayManagement::getRailwayName, accountManagement.getRailwayName());
- }
- // List<BaseRailwayManagement> list = baseRailwayManagementService.list(queryWrapper);
- BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
- if (!StringUtils.isEmptySunhh(baseRailwayManagement)) {
- if (!accountManagement.getBeginMile().toString().matches(PATTERN) || !accountManagement.getInstallMile().toString().matches(PATTERN) || !accountManagement.getEndMile().toString().matches(PATTERN)) {
- failureNum++;
- failureMsg.append(failureNum + "、相机编码为: " + accountManagement.getCameraCode() + "的数据,里程位置填写格式不正确,请填写数字");
- } else {
- accountManagement.setRailwayCode(baseRailwayManagement.getRailwayCode());
- if (!StringUtils.isEmptySunhh(accountManagement.getBeginMileBD())) {
- if (!accountManagement.getBeginMileBD().toString().matches(PATTERN)) {
- failureNum++;
- String msg = failureNum + "、监控范围开始里程位置填写格式不正确";
- failureMsg.append(msg);
- log.error(msg);
- // return error("监控范围开始里程位置填写格式不正确");
- } else {
- BigDecimal begin = accountManagement.getBeginMileBD().setScale(3, RoundingMode.HALF_UP);
- // BigDecimal begin = BigDecimal.parseDouble(baseCameraManagement.getBeginMile().toString());
- accountManagement.setBeginMile(begin.multiply(new BigDecimal("1000")).intValue());
- }
- }
- if (!StringUtils.isEmptySunhh(accountManagement.getInstallMileBD())) {
- if (!accountManagement.getInstallMileBD().toString().matches(PATTERN)) {
- failureNum++;
- String msg = failureNum + "、监控相机安装里程位置填写格式不正确";
- failureMsg.append(msg);
- log.error(msg);
- // return error("监控相机安装里程位置填写格式不正确");
- } else {
- BigDecimal install = accountManagement.getInstallMileBD().setScale(3, RoundingMode.HALF_UP);
- // double install = Double.parseDouble(baseCameraManagement.getInstallMile().toString());
- accountManagement.setInstallMile(install.multiply(new BigDecimal("1000")).intValue());
- }
- }
- if (!StringUtils.isEmptySunhh(accountManagement.getInstallMileBD())) {
- if (!accountManagement.getInstallMileBD().toString().matches(PATTERN)) {
- failureNum++;
- String msg = failureNum + "、监控范围结束里程位置填写格式不正确";
- failureMsg.append(msg);
- log.error(msg);
- // return error("监控范围结束里程位置填写格式不正确");
- } else {
- BigDecimal end = accountManagement.getInstallMileBD().setScale(3, RoundingMode.HALF_UP);
- // double end = Double.parseDouble(baseCameraManagement.getEndMile().toString());
- accountManagement.setEndMile(end.multiply(new BigDecimal("1000")).intValue());
- }
- }
- // accountManagement.setInstallMile(accountManagement.getInstallMileBD() * 1000);
- // accountManagement.setEndMile(accountManagement.getEndMile() * 1000);
- // accountManagement.setBeginMile(accountManagement.getBeginMile() * 1000);
- if (!StringUtils.isEmpty(cameraManagementVos.getMonitoringDirectionName())) {
- List<SysDictData> data = dictTypeService.selectDictDataByType("monitoring_direction");
- for (SysDictData datum : data) {
- if (datum.getDictLabel().equals(cameraManagementVos.getMonitoringDirectionName())) {
- accountManagement.setMonitoringDirection(Integer.valueOf(datum.getDictValue()));
- }
- }
- }
- if (!StringUtils.isEmpty(cameraManagementVos.getEnableOrNotName())) {
- accountManagement.setEnableOrNot(cameraManagementVos.getEnableOrNotName().equals("启用") ? 1 : 2);
- }
- baseCameraManagementMapper.insert(accountManagement);
- BaseDeviceDynamicManagement baseDeviceDynamicManagement = new BaseDeviceDynamicManagement();
- baseDeviceDynamicManagement.setCameraCode(accountManagement.getCameraCode());
- baseDeviceDynamicManagement.setUpdateBy(userId);
- baseDeviceDynamicManagement.setCreateBy(userId);
- baseDeviceDynamicManagementMapper.insert(baseDeviceDynamicManagement);
- successNum++;
- successMsg.append(successNum + "、相机编码 " + accountManagement.getCameraCode() + " 导入成功");
- }
- } else {
- failureNum++;
- String msg = failureNum + "、相机所属线路名称 " + accountManagement.getRailwayName() + "不存在, 导入失败:";
- failureMsg.append(msg);
- log.error(msg);
- }
- // } else {
- // failureNum++;
- // String msg = failureNum + "、相机所属工务段 " + accountManagement.getDeptName() + "不存在, 导入失败:";
- // failureMsg.append(msg);
- // log.error(msg);
- // }
- } else if (updateSupport) {
- BeanValidators.validateWithException(validator, accountManagement);
- accountManagement.setUpdateBy(userId);
- Long deptId = baseDeptMapper.selectDeptByDeptName(accountManagement.getDeptName());
- log.debug(accountManagement.getDeptName() + "主键id:" + deptId);
- // if (!ObjectUtils.isEmpty(deptId)) {
- accountManagement.setDeptId(deptId);
- if (!StringUtils.isEmpty(cameraManagementVos.getMonitoringDirectionName())) {
- List<SysDictData> data = dictTypeService.selectDictDataByType("monitoring_direction");
- for (SysDictData datum : data) {
- if (datum.getDictLabel().equals(cameraManagementVos.getMonitoringDirectionName())) {
- accountManagement.setMonitoringDirection(Integer.valueOf(datum.getDictValue()));
- }
- }
- }
- if (!StringUtils.isEmpty(cameraManagementVos.getEnableOrNotName())) {
- accountManagement.setEnableOrNot(cameraManagementVos.getEnableOrNotName().equals("启用") ? 1 : 2);
- }
- baseCameraManagementMapper.update(accountManagement, lw);
- LambdaQueryWrapper<BaseDeviceDynamicManagement> wrapper = new LambdaQueryWrapper<BaseDeviceDynamicManagement>();
- if (!StringUtils.isEmptySunhh(baseAccountManagement.getCameraCode())) {
- wrapper.eq(BaseDeviceDynamicManagement::getCameraCode, baseAccountManagement.getCameraCode());
- }
- BaseDeviceDynamicManagement baseDeviceDynamicManagement = baseDeviceDynamicManagementMapper.selectOne(wrapper);
- baseDeviceDynamicManagement.setCameraCode(accountManagement.getCameraCode());
- baseDeviceDynamicManagement.setUpdateBy(userId);
- baseDeviceDynamicManagementMapper.updateById(baseDeviceDynamicManagement);
- successNum++;
- successMsg.append(successNum + "、相机编码 " + accountManagement.getCameraCode() + " 更新成功");
- // } else {
- // failureNum++;
- // String msg = failureNum + "、相机所属工务段 " + accountManagement.getDeptName() + "不存在, 导入失败:";
- // failureMsg.append(msg);
- // log.error(msg);
- // }
- } else {
- failureNum++;
- failureMsg.append(failureNum + "、相机编码 " + accountManagement.getCameraCode() + " 已存在");
- }
- } catch (Exception e) {
- String msg = null;
- failureNum++;
- if (ObjectUtils.isEmpty(cameraManagementVos)) {
- msg = "导入的文档格式不正确";
- } else {
- msg = failureNum + "、相机编码 " + cameraManagementVos.getCameraCode() + " 导入失败:";
- }
- failureMsg.append(msg);
- log.error(msg, e);
- }
- }
- if (failureNum > 0) {
- failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
- throw new ServiceException(failureMsg.toString());
- } else {
- successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条。");
- }
- return successMsg.toString();
- }
- /**
- * 获取相机列表+数据权限
- *
- * @return
- */
- @Override
- public List<BaseCameraManagementHomeVo> selectCameraAll(BaseCameraManagementVo baseCameraManagementVo) {
- // List<String> userIdList = getUserIds(userId);
- // LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
- // if (!StringUtils.isEmpty(userIdList)) {
- // lw.in(BaseCameraManagement::getCreateBy, userIdList);
- // }
- // List<BaseCameraManagement> baseCameraManagementList = baseCameraManagementMapper.selectList(lw);
- List<BaseCameraManagement> baseCameraManagementList = baseCameraManagementMapper.selectCameraManagementList(baseCameraManagementVo);
- List<BaseCameraManagementHomeVo> allListVo = BeanUtils.entityListToVOList(baseCameraManagementList, BaseCameraManagementHomeVo.class);
- for (BaseCameraManagementHomeVo baseCameraManagementHomeVo : allListVo) {
- Integer isRelease = msgAlarmMapper.selectCameraCode(baseCameraManagementHomeVo.getCameraCode());
- baseCameraManagementHomeVo.setIsRelease(isRelease != null ? isRelease : 1);
- }
- return allListVo;
- }
- /**
- * 根据当前登陆用户ID 查询当前用户数据权限
- *
- * @param userId
- * @return
- */
- /* public List<String> getUserIds(String userId) {
- BaseUser baseUser = baseUserService.getUser(userId);
- if (StringUtils.isNull(baseUser) || StringUtils.isNull(baseUser.getDataPermission())
- || StringUtils.isNull(baseUser.getDeptId())) {
- return null;
- }
- // 数据权限 1:本人;2:本部门;3:本部门及下级部门;4:本人及本级部门;5:本人及本部门及下级部门;6:全部
- Integer dataPermission = baseUser.getDataPermission();
- Long deptId = baseUser.getDeptId();
- Set<String> set = new HashSet<>();
- if (1 == dataPermission) {
- set = baseUserMapper.getUserIdList(userId);
- } else if (2 == dataPermission) {
- set = baseUserMapper.getUserIdByDeptId(deptId);
- } else if (3 == dataPermission) {
- // 获取部门数据
- List<Long> deptList = baseUserMapper.getDeptId(deptId);
- // 获取用户列表
- set = baseUserMapper.getUserIdByDeptIds(deptList);
- } else if (4 == dataPermission) {
- set = baseUserMapper.getUserIdByDeptIdAndUserId(userId, deptId);
- } else if (5 == dataPermission) {
- // 获取本人
- Set<String> setUser = baseUserMapper.getUserIdListBy5(userId);
- // 获取部门数据
- List<Long> deptList5 = baseUserMapper.getDeptId(deptId);
- // 获取用户列表
- Set<String> setUsers = baseUserMapper.getUserIdByDeptIdsBy5(deptList5);
- set.addAll(setUser);
- set.addAll(setUsers);
- } else if (6 == dataPermission) {
- set = baseUserMapper.getUserIdList6();
- }
- List<String> list = new ArrayList<>(set);
- return list;
- }*/
- /**
- * 根据当前登陆用户ID 查询当前用户数据权限
- *
- * @param userId
- * @return
- */
- @Override
- public List<String> getUserIdList(String userId) {
- BaseUser baseUser = baseUserService.getUser(userId);
- if (StringUtils.isNull(baseUser) || StringUtils.isNull(baseUser.getDataPermission())
- || StringUtils.isNull(baseUser.getDeptId())) {
- return null;
- }
- // 数据权限 1:本人;2:本部门;3:本部门及下级部门;4:本人及本级部门;5:本人及本部门及下级部门;6:全部
- Integer dataPermission = baseUser.getDataPermission();
- Long deptId = baseUser.getDeptId();
- Set<String> set = new HashSet<>();
- if (1 == dataPermission) {
- set = baseUserMapper.getUserIdList(userId);
- } else if (2 == dataPermission) {
- set = baseUserMapper.getUserIdByDeptId(deptId);
- } else if (3 == dataPermission) {
- // 获取部门数据
- List<Long> deptList = baseUserMapper.getDeptId(deptId);
- // 获取用户列表
- set = baseUserMapper.getUserIdByDeptIds(deptList);
- } else if (4 == dataPermission) {
- set = baseUserMapper.getUserIdByDeptIdAndUserId(userId, deptId);
- } else if (5 == dataPermission) {
- // 获取本人
- Set<String> setUser = baseUserMapper.getUserIdListBy5(userId);
- // 获取部门数据
- List<Long> deptList5 = baseUserMapper.getDeptId(deptId);
- // 获取用户列表
- Set<String> setUsers = baseUserMapper.getUserIdByDeptIdsBy5(deptList5);
- set.addAll(setUser);
- set.addAll(setUsers);
- } else if (6 == dataPermission) {
- set = baseUserMapper.getUserIdsList();
- }
- List<String> list = new ArrayList<>(set);
- return list;
- }
- @Override
- public IPage<BaseCameraManagement> queryPage(BaseCameraManagementVo baseCameraManagementVo) {
- int pageNum = Integer.parseInt(baseCameraManagementVo.getPageNum().toString());
- int pageSize = Integer.parseInt(baseCameraManagementVo.getPageSize().toString());
- com.github.pagehelper.Page<BaseCameraManagement> page = PageHelper.startPage(pageNum, pageSize)
- .doSelectPage(() -> baseCameraManagementMapper.selectCameraManagementList(baseCameraManagementVo));
- com.baomidou.mybatisplus.extension.plugins.pagination.Page<BaseCameraManagement> pageR =
- new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum, pageSize);
- pageR.setRecords(page.getResult());
- pageR.setTotal(page.getTotal());
- return pageR;
- }
- @Override
- public List<BaseCameraManagement> baseCameraManagementList(BaseCameraManagementVo baseCameraManagementVo) {
- return baseCameraManagementMapper.selectCameraManagementList(baseCameraManagementVo);
- }
- @Override
- public Map<String, Integer> getMessageStatisticsCamera() {
- LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<>();
- List<BaseCameraManagement> baseCameraManagements = baseCameraManagementMapper.selectList(lw);
- int online = 0;
- int offline = 0;
- for (BaseCameraManagement baseCameraManagement : baseCameraManagements) {
- if (!StringUtils.isEmptySunhh(baseCameraManagement) && !StringUtils.isEmptySunhh(baseCameraManagement.getCameraCode())) {
- SkynetHeartbeatLog skynetHeartbeatLog = baseCameraManagementMapper.selectSkynetHeartbeatLogByCameraCode(baseCameraManagement.getCameraCode());
- if (StringUtils.isEmptySunhh(skynetHeartbeatLog)) {
- offline++;
- // baseCameraManagement.setOnline(1);
- } else {
- long timeNow = System.currentTimeMillis();
- long createTime = skynetHeartbeatLog.getCreateTime().getTime();
- long thereHourMillis = 60 * 60 * 1000 * 3;
- long timeNew = timeNow - thereHourMillis;
- if (timeNew <= createTime) {
- baseCameraManagement.setOnline(2);
- online++;
- } else {
- // baseCameraManagement.setOnline(1);
- offline++;
- }
- }
- baseCameraManagementMapper.updateById(baseCameraManagement);
- }
- }
- Map<String, Integer> map = new HashMap<>();
- map.put("countAllCamera", baseCameraManagements.size());
- map.put("online", online);
- map.put("offline", offline);
- return map;
- }
- @Override
- public AjaxResult nonContactAlarmCamera(String cameraCode) {
- List<BaseCameraManagement> list = new ArrayList<>();
- QueryWrapper<MsgAlarm> wrapper = new QueryWrapper<>();
- wrapper.eq("is_release", 2);
- List<MsgAlarm> msgAlarms = msgAlarmMapper.selectList(wrapper);
- if (!ObjectUtils.isEmpty(msgAlarms)) {
- for (MsgAlarm msgAlarm : msgAlarms) {
- LambdaQueryWrapper<BaseCameraManagement> camera = new LambdaQueryWrapper<BaseCameraManagement>();
- camera.ge(BaseCameraManagement::getEndMile, msgAlarm.getAlarmMile());
- camera.le(BaseCameraManagement::getBeginMile, msgAlarm.getAlarmMile());
- camera.eq(BaseCameraManagement::getLineDir, msgAlarm.getLineDir());
- camera.eq(BaseCameraManagement::getRailwayCode, msgAlarm.getRailwayCode());
- camera.eq(BaseCameraManagement::getOnline, 2);
- camera.eq(BaseCameraManagement::getEnableOrNot, 1);
- if (StringUtils.isNotEmpty(cameraCode)) {
- wrapper.eq("camera_code", cameraCode);
- }
- List<BaseCameraManagement> baseCameraManagementList = this.list(camera);
- for (BaseCameraManagement baseCameraManagement : baseCameraManagementList) {
- String end = "";
- if (!StringUtils.isEmptySunhh(baseCameraManagement.getEndMile())) {
- end = AppendUtils.stringAppend(baseCameraManagement.getEndMile());
- baseCameraManagement.setEndMiles(end);
- baseCameraManagement.setEndMileBD(new BigDecimal(baseCameraManagement.getEndMile()).divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP));
- }
- String begin = "";
- if (!StringUtils.isEmptySunhh(baseCameraManagement.getBeginMile())) {
- begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
- baseCameraManagement.setBeginMiles(begin);
- baseCameraManagement.setBeginMileBD(new BigDecimal(baseCameraManagement.getBeginMile()).divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP));
- }
- baseCameraManagement.setMilesRange(begin + "~" + end);
- String mils = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
- baseCameraManagement.setInstallMiles(mils);
- LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
- if (!ObjectUtils.isEmpty(baseCameraManagement.getRailwayCode())) {
- queryWrapper.eq(BaseRailwayManagement::getRailwayCode, baseCameraManagement.getRailwayCode());
- }
- BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
- baseCameraManagement.setRailwayName(baseRailwayManagement.getRailwayName());
- }
- if (!ObjectUtils.isEmpty(baseCameraManagementList)) {
- list.addAll(baseCameraManagementList);
- }
- }
- }
- return AjaxResult.success(list);
- }
- @Override
- public List<BaseVehicleTerminalDto> videoCaptureUrl(BaseVehicleTerminalDto baseVehicleTerminalDto) {
- List<BaseVehicleTerminalDto> urlList = new ArrayList<>();
- LambdaQueryWrapper<BaseCameraManagement> camera = new LambdaQueryWrapper<BaseCameraManagement>();
- camera.ge(BaseCameraManagement::getBeginMile, baseVehicleTerminalDto.getTravelMile());
- camera.eq(BaseCameraManagement::getLineDir, baseVehicleTerminalDto.getLineDir());
- camera.eq(BaseCameraManagement::getRailwayCode, baseVehicleTerminalDto.getRailwayCode());
- camera.eq(BaseCameraManagement::getOnline, 2);
- camera.eq(BaseCameraManagement::getEnableOrNot, 1);
- camera.orderByDesc(BaseCameraManagement::getCreateTime);
- camera.last("limit 4");
- List<BaseCameraManagement> baseCameraManagementList = this.list(camera);
- if (!ObjectUtils.isEmpty(baseCameraManagementList)) {
- List<BaseCameraManagement> list = new ArrayList<>(baseCameraManagementList);
- for (BaseCameraManagement baseCameraManagement : list) {
- String flv = CameraUtil.getPlayFlv(baseCameraManagement.getCameraCode(), baseCameraManagement.getChannel());
- BaseVehicleTerminalDto dto = new BaseVehicleTerminalDto();
- dto.setUrl(flv);
- dto.setCameraCode(baseCameraManagement.getCameraCode());
- dto.setTime(new Date());
- BaseRailwayManagement baseRailwayManagement = baseRailwayManagementMapper.selectOne(new QueryWrapper<BaseRailwayManagement>().eq("railway_code", baseVehicleTerminalDto.getRailwayCode()));
- dto.setRailwayName(baseRailwayManagement.getRailwayName());
- String mils = AppendUtils.stringAppend(baseVehicleTerminalDto.getTravelMile());
- dto.setTravelMileName(mils);
- dto.setLineDirStr(baseVehicleTerminalDto.getLineDir() == 1 ? "上行" : "下行");
- urlList.add(dto);
- }
- }
- return urlList;
- }
- }
|