class PowerLineTowerIDRoute(Resource): def __init__(self): self.dao = TowerDao() self.userDao = UserDAO() def post(self): # if (request.data != ""): # data = json.loads(request.data) # token = data['token'] # user = self.userDao.verify_token(token, '') # if (not user): # return make_response(jsonify({'error': 'Unauthorized access'}), 401) args = parser.parse_args() tower_id = args.get('towerid') rs = self.dao.query_tower_id(tower_id) if rs == None: return make_response( jsonify({ 'error': '根据杆塔id查询杆塔信息失败', 'errorcode': 10000000 }), 401) else: return rs # else: # return rs # else: # return make_response(jsonify({'error': 'Unauthorized access'}), 401) def get(self): return self.post()
class PowerLineTowerRoute(Resource): def __init__(self): self.dao = TowerDao() self.userDao = UserDAO def post(self): # if (request.data != ""): # data = json.loads(request.data) # token = data['token'] # user = self.userDao.verify_token(token, '') # if (not user): # return make_response(jsonify({'error': 'Unauthorized access'}), 401) args = parser.parse_args() linename = args.get('linename') rs = self.dao.query_towers(linename) if rs == None: return make_response(jsonify({'error': 'Unauthorized access'}), 401) else: return rs # else: # return rs # else: # return make_response(jsonify({'error': 'Unauthorized access'}), 401) def get(self): return self.post()
class PowerLineTowerUpdateLocation(Resource): def __init__(self): self.dao = TowerDao() self.userDao = UserDAO() def post(self): if (request.data != ""): data = json.loads(request.data) token = data['token'] towerdict = data['tower'] user = self.userDao.verify_token(token, '') if (not user): return make_response( jsonify({ 'error': '用户不存在或登录过期', 'errorcode': 10000000 }), 400) if user == 1010301: return make_response( jsonify({ 'error': '登录过期', 'errorcode': user }), 400) if user == 1010302: return make_response( jsonify({ 'error': '用户验证错误', 'errorcode': user }), 400) tower = Towers() tower.tower_id = towerdict['tower_id'] tower.tower_lat = towerdict['tower_lat'] tower.tower_lng = towerdict['tower_lng'] rs = self.dao.update_tower(user, tower) if rs == 3020501: return make_response( jsonify({ 'error': '无权限更新杆塔坐标', 'errorcode': rs }), 401) else: return make_response(jsonify({'success': '更新杆塔坐标成功'}), 200) else: return make_response( jsonify({ 'error': '传入参数出错', 'errorcode': 10000000 }), 401) def get(self): return self.post()
class PowerLineTowerAdd(Resource): def __init__(self): self.dao = TowerDao() self.userDao = UserDAO() def post(self): if (request.data != ""): data = json.loads(request.data) token = data['token'] towerdict = data['tower'] user = self.userDao.verify_token(token, '') if (not user): return make_response( jsonify({ 'error': '用户不存在或登录过期', 'errorcode': 10000000 }), 400) if user == 1010301: return make_response( jsonify({ 'error': '登录过期', 'errorcode': user }), 400) if user == 1010302: return make_response( jsonify({ 'error': '用户验证错误', 'errorcode': user }), 400) tower = Towers() tower.tower_linename = towerdict[0]['tower_linename'] tower.tower_idx = extractTowerIdx(towerdict[0]['tower_idx']) tower.tower_type = towerdict[0]['tower_type'] tower.tower_height = towerdict[0]['tower_height'] tower.tower_lat = towerdict[0]['tower_lat'] tower.tower_lng = towerdict[0]['tower_lng'] tower.tower_elevation = towerdict[0]['tower_elevation'] rs = self.dao.add_tower(user, tower) if rs == 3020401: return make_response( jsonify({ 'error': '无权限添加杆塔', 'errorcode': rs }), 401) else: return make_response(jsonify({'success': '添加杆塔成功'}), 200) else: return make_response(jsonify({'error': '传入参数错误'}), 401) def get(self): return self.post()
class PowerLineTowerDeleteRoute(Resource): def __init__(self): self.dao = TowerDao() self.userDao = UserDAO() def post(self): if (request.data != ""): data = json.loads(request.data) token = data['token'] user = self.userDao.verify_token(token, '') if (not user): return make_response( jsonify({ 'error': '用户不存在或登录过期', 'errorcode': 10000000 }), 400) if user == 1010301: return make_response( jsonify({ 'error': '登录过期', 'errorcode': user }), 400) if user == 1010302: return make_response( jsonify({ 'error': '用户验证错误', 'errorcode': user }), 400) args = parser.parse_args() towerid = args.get('lineid') rs = self.dao.del_tower(user, towerid) if rs != 1: return make_response(jsonify({'error': 'Unauthorized access'}), 401) else: return rs else: return make_response(jsonify({'error': 'Unauthorized access'}), 401) def get(self): return self.post()
def __init__(self): self.dao = TowerDao() self.userDao = UserDAO
class PowerLineTowerUpdate(Resource): def __init__(self): self.dao = TowerDao() self.userDao = UserDAO() def post(self): if (request.data != ""): data = json.loads(request.data) token = data['token'] towerdict = data['tower'] user = self.userDao.verify_token(token, '') if (not user): return make_response( jsonify({ 'error': '用户不存在或登录过期', 'errorcode': 10000000 }), 400) if user == 1010301: return make_response( jsonify({ 'error': '登录过期', 'errorcode': user }), 400) if user == 1010302: return make_response( jsonify({ 'error': '用户验证错误', 'errorcode': user }), 400) tower = Towers() tower.tower_linename = towerdict['tower_linename'] tower.tower_id = towerdict['tower_id'] tower.tower_idx = extractTowerIdx(towerdict['tower_idx']) tower.tower_type = towerdict['tower_type'] tower.tower_lat = towerdict['tower_lat'] tower.tower_lng = towerdict['tower_lng'] tower.tower_date = datetime.strptime(towerdict['tower_date'], '%Y-%m-%d').date() tower.tower_span_small = towerdict['tower_span_small'] tower.tower_span_horizonal = towerdict['tower_span_horizonal'] tower.tower_span_vertical = towerdict['tower_span_vertical'] tower.tower_rotation_direction = towerdict[ 'tower_rotation_direction'] tower.tower_rotation_degree = towerdict['tower_rotation_degree'] tower.tower_descriptor = towerdict['tower_descriptor'] tower.tower_lightarrest_type = towerdict['tower_lightarrest_type'] tower.tower_insulator_material = towerdict[ 'tower_insulator_material'] tower.tower_insulator_type = towerdict['tower_insulator_type'] tower.tower_insulator_strand = towerdict['tower_insulator_strand'] tower.tower_insulator_double = towerdict['tower_insulator_double'] tower.tower_insulator_doublehang = towerdict[ 'tower_insulator_doublehang'] tower.tower_opgw_type = towerdict['tower_opgw_type'] rs = self.dao.update_tower(user, tower) if rs == 3020501: return make_response( jsonify({ 'error': '无权限更新杆塔信息', 'errorcode': rs }), 401) else: return make_response(jsonify({'success': '添加杆塔信息成功'}), 200) else: return make_response( jsonify({ 'error': '传入参数错误', 'errorcode': 10000000 }), 401) def get(self): return self.post()
def GetTowerPosition(self,linename): towerPosDao = TowerDao() towers=towerPosDao.query_towers(linename); return towers