| | |
| | | import com.sandu.ximon.dao.enums.PoleBindingEnums; |
| | | import com.sandu.ximon.dao.mapper.MonitorMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | @Slf4j |
| | | public class MonitorService extends BaseServiceImpl<MonitorMapper, Monitor> { |
| | | private final MonitorMapper monitorMapper; |
| | | //萤石云AppKey |
| | |
| | | /** |
| | | * 删除摄像头 |
| | | * |
| | | * @param Id |
| | | * @param |
| | | * @return |
| | | */ |
| | | public boolean deleteMonitor(Long Id) { |
| | | Monitor monitor = getById(Id); |
| | | if (monitor == null) { |
| | | throw new BusinessException("找不到摄像头"); |
| | | public boolean deleteMonitor(List<Long> ids) { |
| | | List<Long> idList = new ArrayList<Long>(); |
| | | List<Monitor> monitors = listByIds(ids); |
| | | if (!monitors.isEmpty()) { |
| | | monitors.forEach( |
| | | monitor -> { |
| | | if (monitor == null) { |
| | | throw new BusinessException("找不到摄像头"); |
| | | } |
| | | PoleBinding one = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, monitor.getDeviceSerial())); |
| | | if (one != null) { |
| | | //删除摄像头设备前需要先解绑 |
| | | poleBindingService.unBindPole(null, monitor.getDeviceSerial()); |
| | | } |
| | | /** |
| | | * 删除摄像头日志记录开始 |
| | | */ |
| | | String content = "{摄像头Code:" + monitor.getDeviceSerial() + ", 摄像头名称:" + monitor.getDeviceName() + " }"; |
| | | List<String> listCode = new ArrayList<>(); |
| | | listCode.add(monitor.getDeviceSerial()); |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "删除摄像头", content); |
| | | /** |
| | | * 删除摄像头日志记录结束 |
| | | */ |
| | | idList.add(monitor.getId()); |
| | | } |
| | | ); |
| | | } |
| | | PoleBinding one = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, monitor.getDeviceSerial())); |
| | | if (one != null) { |
| | | //删除摄像头设备前需要先解绑 |
| | | poleBindingService.unBindPole(null, monitor.getDeviceSerial()); |
| | | } |
| | | /** |
| | | * 删除摄像头日志记录开始 |
| | | */ |
| | | String content = "{摄像头Code:" + monitor.getDeviceSerial() + ", 摄像头名称:" + monitor.getDeviceName() + " }"; |
| | | List<String> listCode = new ArrayList<>(); |
| | | listCode.add(monitor.getDeviceSerial()); |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "删除摄像头", content); |
| | | /** |
| | | * 删除摄像头日志记录结束 |
| | | */ |
| | | return removeById(Id); |
| | | //全部删除成功 |
| | | return removeByIds(idList); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | paramMap.put("appKey", AppKey); |
| | | paramMap.put("appSecret", Secret); |
| | | String s = HttpUtil.post(YSY_URL + ACCESSTOKEN_URL, paramMap); |
| | | if (!s.startsWith("{") || !s.endsWith("}")) { |
| | | log.error("获取摄像头token失败,格式有误!"); |
| | | } |
| | | YSY_AccessTokenDto accessTokenDto = JSON.parseObject(s, YSY_AccessTokenDto.class); |
| | | |
| | | //二次获取 |
| | | if (accessTokenDto == null) { |
| | | log.error("获取摄像头token失败,格式有误!"); |
| | | s = HttpUtil.post(YSY_URL + ACCESSTOKEN_URL, paramMap); |
| | | accessTokenDto = JSON.parseObject(s, YSY_AccessTokenDto.class); |
| | | } |
| | | return accessTokenDto.getData().getAccessToken(); |
| | | } |
| | | |