|
@@ -1,16 +1,14 @@
|
|
|
package com.sooka.sponest.monitor.channelrail.service.impl;
|
|
package com.sooka.sponest.monitor.channelrail.service.impl;
|
|
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.sooka.sponest.monitor.ai.domain.BusAiAlgorithmTask;
|
|
|
import com.sooka.sponest.monitor.channelrail.domain.ChannelRail;
|
|
import com.sooka.sponest.monitor.channelrail.domain.ChannelRail;
|
|
|
import com.sooka.sponest.monitor.channelrail.mapper.ChannelRailMapper;
|
|
import com.sooka.sponest.monitor.channelrail.mapper.ChannelRailMapper;
|
|
|
import com.sooka.sponest.monitor.channelrail.service.IChannelRailService;
|
|
import com.sooka.sponest.monitor.channelrail.service.IChannelRailService;
|
|
|
-import com.sooka.sponest.monitor.dahua.service.DahuaService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 摄像头通道Service业务层处理
|
|
* 摄像头通道Service业务层处理
|
|
@@ -24,9 +22,6 @@ public class ChannelRailServiceImpl implements IChannelRailService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ChannelRailMapper channelRailMapper;
|
|
private ChannelRailMapper channelRailMapper;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private DahuaService dahuaService;
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public ChannelRail get(String channelId, Long taskId, Long pointId, String type) {
|
|
public ChannelRail get(String channelId, Long taskId, Long pointId, String type) {
|
|
|
return channelRailMapper.get(channelId, taskId, pointId, type);
|
|
return channelRailMapper.get(channelId, taskId, pointId, type);
|
|
@@ -34,51 +29,8 @@ public class ChannelRailServiceImpl implements IChannelRailService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int save(ChannelRail channelRail) {
|
|
public int save(ChannelRail channelRail) {
|
|
|
- int result = 0;
|
|
|
|
|
List<ChannelRail> rails = channelRailMapper.getList(channelRail.getChannelId(), channelRail.getTaskId());
|
|
List<ChannelRail> rails = channelRailMapper.getList(channelRail.getChannelId(), channelRail.getTaskId());
|
|
|
rails.add(channelRail);
|
|
rails.add(channelRail);
|
|
|
- try {
|
|
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(channelRail.getInfo());
|
|
|
|
|
- List<JSONObject> channels = JSONObject.parseArray(jsonObject.getString("channelInfos"), JSONObject.class);
|
|
|
|
|
- channels = channels.stream().map(channel -> {
|
|
|
|
|
- if (channel.getString("channelCode").equals(channelRail.getChannelId())) {
|
|
|
|
|
- List<JSONObject> channelPresetPointVOS = new ArrayList<>();
|
|
|
|
|
- for (ChannelRail rail : rails) {
|
|
|
|
|
- JSONObject channelPresetPointVO = new JSONObject();
|
|
|
|
|
- channelPresetPointVO.put("presetPointId", rail.getPointId());
|
|
|
|
|
- channelPresetPointVO.put("pointName", rail.getPointName());
|
|
|
|
|
- List<Map<String, Object>> channelCutInfos = new ArrayList<>();
|
|
|
|
|
- List<JSONObject> polygons = JSONObject.parseArray(JSONObject.parseObject(rail.getJsonData()).getString("polygons"), JSONObject.class);
|
|
|
|
|
- polygons.forEach(item -> {
|
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
|
- map.put("pointId", rail.getPointId());
|
|
|
|
|
- map.put("pointName", rail.getPointName());
|
|
|
|
|
- map.put("type", rail.getType());
|
|
|
|
|
- map.put("areaPoints", item.toJSONString());
|
|
|
|
|
- map.put("taskId", jsonObject.getLong("id"));
|
|
|
|
|
- map.put("channelCode", channel.getString("channelCode"));
|
|
|
|
|
- map.put("channelName", channel.getString("channelName"));
|
|
|
|
|
- channelCutInfos.add(map);
|
|
|
|
|
- });
|
|
|
|
|
- Collections.reverse(channelCutInfos);
|
|
|
|
|
- channelPresetPointVO.put("channelCutInfos", channelCutInfos);
|
|
|
|
|
- channelPresetPointVO.put("taskId", rail.getTaskId());
|
|
|
|
|
- channelPresetPointVO.put("channelCode", channel.getString("channelCode"));
|
|
|
|
|
- channelPresetPointVO.put("channelName", channel.getString("channelName"));
|
|
|
|
|
- channelPresetPointVO.put("pointType", 1);
|
|
|
|
|
- channelPresetPointVOS.add(channelPresetPointVO);
|
|
|
|
|
- }
|
|
|
|
|
- channel.put("channelPresetPointVOS", channelPresetPointVOS);
|
|
|
|
|
- }
|
|
|
|
|
- return channel;
|
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
|
- jsonObject.put("channelInfos", channels);
|
|
|
|
|
- System.out.println(JSON.toJSONString(jsonObject));
|
|
|
|
|
- result = dahuaService.updateTask(jsonObject);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- channelRail.setSyncStatus(result);
|
|
|
|
|
return channelRailMapper.save(channelRail);
|
|
return channelRailMapper.save(channelRail);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -86,4 +38,38 @@ public class ChannelRailServiceImpl implements IChannelRailService {
|
|
|
public int delete(String channelId, Long taskId, Long pointId) {
|
|
public int delete(String channelId, Long taskId, Long pointId) {
|
|
|
return channelRailMapper.delete(channelId, taskId, pointId);
|
|
return channelRailMapper.delete(channelId, taskId, pointId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void fill(BusAiAlgorithmTask aiAlgorithmTask) {
|
|
|
|
|
+ aiAlgorithmTask.getChannelInfos().forEach(channel -> {
|
|
|
|
|
+ List<ChannelRail> rails = channelRailMapper.getList(channel.getChannelCode(), aiAlgorithmTask.getId());
|
|
|
|
|
+ List<JSONObject> channelPresetPointVOS = new ArrayList<>();
|
|
|
|
|
+ for (ChannelRail rail : rails) {
|
|
|
|
|
+ JSONObject channelPresetPointVO = new JSONObject();
|
|
|
|
|
+ channelPresetPointVO.put("presetPointId", rail.getPointId());
|
|
|
|
|
+ channelPresetPointVO.put("pointName", rail.getPointName());
|
|
|
|
|
+ List<Map<String, Object>> channelCutInfos = new ArrayList<>();
|
|
|
|
|
+ List<JSONObject> polygons = JSONObject.parseArray(JSONObject.parseObject(rail.getJsonData()).getString("polygons"), JSONObject.class);
|
|
|
|
|
+ polygons.forEach(item -> {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("pointId", rail.getPointId());
|
|
|
|
|
+ map.put("pointName", rail.getPointName());
|
|
|
|
|
+ map.put("type", rail.getType());
|
|
|
|
|
+ map.put("areaPoints", item.toJSONString());
|
|
|
|
|
+ map.put("taskId", rail.getTaskId());
|
|
|
|
|
+ map.put("channelCode", channel.getChannelCode());
|
|
|
|
|
+ map.put("channelName", channel.getChannelName());
|
|
|
|
|
+ channelCutInfos.add(map);
|
|
|
|
|
+ });
|
|
|
|
|
+ Collections.reverse(channelCutInfos);
|
|
|
|
|
+ channelPresetPointVO.put("channelCutInfos", channelCutInfos);
|
|
|
|
|
+ channelPresetPointVO.put("taskId", rail.getTaskId());
|
|
|
|
|
+ channelPresetPointVO.put("channelCode", channel.getChannelCode());
|
|
|
|
|
+ channelPresetPointVO.put("channelName", channel.getChannelName());
|
|
|
|
|
+ channelPresetPointVO.put("pointType", 1);
|
|
|
|
|
+ channelPresetPointVOS.add(channelPresetPointVO);
|
|
|
|
|
+ }
|
|
|
|
|
+ channel.setChannelPresetPointVOS(channelPresetPointVOS);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|