package com.tairui.app.cim.controller;
|
|
import com.tairui.app.cim.dao.model.*;
|
import com.tairui.app.cim.mapper.*;
|
import com.http.HttpResult;
|
import com.vividsolutions.jts.geom.Coordinate;
|
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.GeometryFactory;
|
import com.vividsolutions.jts.geom.Point;
|
import io.swagger.annotations.ApiOperation;
|
import org.apache.ibatis.annotations.Param;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
@RestController
|
@RequestMapping("/cim/geom")
|
public class GeomController {
|
|
@Autowired
|
AlarmPointMapper alarmPointMapper ;
|
@Autowired
|
CameraMapper cameraMapper ;
|
@Autowired
|
PersonnelPointMapper personnelPointMapper ;
|
@Autowired
|
ProductionAreaMapper productionAreaMapper ;
|
@Autowired
|
ProductionUnitAreaMapper productionUnitAreaMapper ;
|
@Autowired
|
OperationAreaMapper operationAreaMapper ;
|
@Autowired
|
InspectionMapper inspectionMapper ;
|
|
@Autowired
|
ElevationMapper elevationMapper ;
|
|
|
@Autowired
|
EmergencySuppliesPointMapper emergencySuppliesPointMapper;
|
@Autowired
|
EntranceGuardPointMapper entranceGuardPointMapper;
|
@Autowired
|
EvacuationPointMapper evacuationPointMapper ;
|
@Autowired
|
MajorHazardsPointMapper majorHazardsPointMapper ;
|
@Autowired
|
ToxicGasPointMapper toxicGasPointMapper;
|
@Autowired
|
FireEquipmentPointMapper fireEquipmentPointMapper;
|
@GetMapping("/queryByID")
|
@ApiOperation("table_name:alarm,camera,inspection,production,production_unit,operation," +
|
"toxic_gas_point,emergency_supplies_point,major_hazards_point,entrance_guard_point," +
|
"evacuation_point,fire_equipment_point")
|
public HttpResult queryByID(int gid ,String table_name ){
|
|
if( table_name.toLowerCase().equals("alarm")) return HttpResult.ok(alarmPointMapper.query(gid));
|
if( table_name.toLowerCase().equals("camera")) return HttpResult.ok(cameraMapper.query(gid));
|
if( table_name.toLowerCase().equals("personnel")) return HttpResult.ok(personnelPointMapper.query(gid));
|
if( table_name.toLowerCase().equals("inspection")) return HttpResult.ok(inspectionMapper.query(gid));
|
|
if( table_name.toLowerCase().equals("production")) return HttpResult.ok(productionAreaMapper.query(gid));
|
if( table_name.toLowerCase().equals("production_unit"))return HttpResult.ok(productionUnitAreaMapper.query(gid));
|
if( table_name.toLowerCase().equals("operation")) return HttpResult.ok(operationAreaMapper.query(gid));
|
|
if( table_name.toLowerCase().equals("toxic_gas_point")) return HttpResult.ok(toxicGasPointMapper.query(gid));
|
if( table_name.toLowerCase().equals("emergency_supplies_point")) return HttpResult.ok(emergencySuppliesPointMapper.query(gid));
|
|
if( table_name.toLowerCase().equals("major_hazards_point")) return HttpResult.ok(majorHazardsPointMapper.query(gid));
|
if( table_name.toLowerCase().equals("entrance_guard_point"))return HttpResult.ok(entranceGuardPointMapper.query(gid));
|
if( table_name.toLowerCase().equals("evacuation_point")) return HttpResult.ok(evacuationPointMapper.query(gid));
|
if( table_name.toLowerCase().equals("fire_equipment_point")) return HttpResult.ok(fireEquipmentPointMapper.query(gid));
|
|
return HttpResult.error("参数错误");
|
}
|
|
@GetMapping("/update")
|
public HttpResult update(int gid , String geom,String table_name){
|
if( table_name.toLowerCase().equals("alarm")) {
|
AlarmPoint alarmPoint = alarmPointMapper.selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = alarmPointMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("camera")) {
|
CameraPoint alarmPoint = cameraMapper.selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = cameraMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("inspection")) {
|
Inspection alarmPoint =inspectionMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = inspectionMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("production")) {
|
ProductionArea alarmPoint =productionAreaMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = productionAreaMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("production_unit")){
|
ProductionUnitArea alarmPoint =productionUnitAreaMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = productionUnitAreaMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("operation")) {
|
OperationArea alarmPoint =operationAreaMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = operationAreaMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
|
|
|
if( table_name.toLowerCase().equals("toxic_gas_point")){
|
ToxicGasPoint alarmPoint =toxicGasPointMapper.selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = toxicGasPointMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("emergency_supplies_point")) {
|
EmergencySuppliesPoint alarmPoint =emergencySuppliesPointMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = emergencySuppliesPointMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("major_hazards_point")){
|
MajorHazardsPoint alarmPoint =majorHazardsPointMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = majorHazardsPointMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("entrance_guard_point")) {
|
EntranceGuardPoint alarmPoint =entranceGuardPointMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = entranceGuardPointMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("evacuation_point")){
|
EvacuationPoint alarmPoint =evacuationPointMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = evacuationPointMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
if( table_name.toLowerCase().equals("fire_equipment_point")){
|
FireEquipmentPoint alarmPoint =fireEquipmentPointMapper .selectById(gid) ;
|
if( alarmPoint == null ) return HttpResult.error("记录不存在!");
|
alarmPoint.setGeom(geom);
|
int ret = fireEquipmentPointMapper.updateById(alarmPoint);
|
return HttpResult.ok(ret);
|
}
|
|
return HttpResult.error("参数错误");
|
}
|
|
/**
|
* 处理过程,根据楼层得到面数据,判断点是否在面上,如果在,返回 x,y ,coor_z
|
* 如果不在面上,获得最近的面,返回 cen_x cen_y coor_z
|
* @param x
|
* @param y
|
* @param
|
* @return
|
*/
|
@GetMapping("/queryElevation")
|
public HttpResult queryElevation(String floor_num,double x , double y){
|
List<Elevation> list = new ArrayList<>();
|
//一层不查询
|
if( floor_num.equals("1")){
|
Elevation e = new Elevation();
|
e.setCenx(x);
|
e.setCeny(y);
|
e.setHigh("0");
|
list.add(e);
|
return HttpResult.ok(list );
|
|
}
|
list = elevationMapper.queryFloor(x,y,floor_num) ;
|
if( list == null || list.size() == 0 ){
|
list = elevationMapper.queryMinDistance(x,y,floor_num);
|
return (HttpResult.ok(list));//.stream().filter(p->{System.out.println(p.getCentX());p.setCen_x(p.getCenx());p.setCen_y(p.getCeny());return true;}).collect(Collectors.toList())));
|
}else{
|
return HttpResult.ok( list.stream().filter(p->{p.setCenx(x);p.setCeny(y);return true;}).collect(Collectors.toList()));
|
}
|
|
|
}
|
}
|