|
|
@@ -34,50 +34,56 @@ public class ChannelRailServiceImpl implements IChannelRailService {
|
|
|
|
|
|
@Override
|
|
|
public int save(ChannelRail channelRail) {
|
|
|
+ int result = 0;
|
|
|
+ List<ChannelRail> rails = channelRailMapper.getList(channelRail.getChannelId(), channelRail.getTaskId());
|
|
|
+ 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 = JSONObject.parseArray(channel.getString("channelPresetPointVOS"), JSONObject.class);
|
|
|
- channelPresetPointVOS = channelPresetPointVOS.stream().map(channelPresetPointVO -> {
|
|
|
- if (channelPresetPointVO.getLong("presetPointId").equals(channelRail.getPointId())) {
|
|
|
- List<Map<String, Object>> channelCutInfos = new ArrayList<>();
|
|
|
- List<JSONObject> polygons = JSONObject.parseArray(JSONObject.parseObject(channelRail.getJsonData()).getString("polygons"), JSONObject.class);
|
|
|
- polygons.forEach(item -> {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("taskId", jsonObject.getLong("id"));
|
|
|
- map.put("pointId", channelRail.getPointId());
|
|
|
- map.put("pointName", channelRail.getPointName());
|
|
|
- map.put("type", channelRail.getType());
|
|
|
- item.remove("lineColor");
|
|
|
- item.remove("fillColor");
|
|
|
- item.remove("lineWidth");
|
|
|
- map.put("areaPoints", item.toJSONString());
|
|
|
- map.put("channelCode", channel.getString("channelCode"));
|
|
|
- map.put("channelName", channel.getString("channelName"));
|
|
|
- channelCutInfos.add(map);
|
|
|
- });
|
|
|
- Collections.reverse(channelCutInfos);
|
|
|
- channelPresetPointVO.put("channelCutInfos", channelCutInfos);
|
|
|
- }
|
|
|
- return channelPresetPointVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ 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));
|
|
|
- dahuaService.updateTask(jsonObject);
|
|
|
+ result = dahuaService.updateTask(jsonObject);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ channelRail.setSyncStatus(result);
|
|
|
return channelRailMapper.save(channelRail);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int delete(String channelId, Long taskId, Long pointId, String type) {
|
|
|
- return channelRailMapper.delete(channelId, taskId, pointId, type);
|
|
|
+ public int delete(String channelId, Long taskId, Long pointId) {
|
|
|
+ return channelRailMapper.delete(channelId, taskId, pointId);
|
|
|
}
|
|
|
}
|