def put(self, model_id=None): args = user_parser.parse_args() if not model_id: model_id = args['id'] if model_id: model = User.query.get(model_id) if not model: return err_not_found() if args['username']: model.username = args['username'] if args['email']: model.email = args['email'] if args['role']: role_models = Role.query.filter(Role.name.in_( args['role'])).all() model.roles += role_models db.session.add(model) db.session.commit() return rp_modify()
def put(self, model_id=None): args = alarm_info_put_parser.parse_args() if not model_id: model_id = args['id'] if model_id: model = VarAlarmInfo.query.get(model_id) if not model: return err_not_found() if args['variable_id']: model.variable_id = args['variable_id'] if args['alarm_type']: model.alarm_type = args['alarm_type'] if args['note']: model.note = args['note'] db.session.add(model) db.session.commit() return rp_modify() else: model = VarAlarmInfo(variable_id=args['variable_id'], alarm_type=args['alarm_type'], note=args['note']) db.session.add(model) db.session.commit() return rp_create()
def put(self): args = alarm_put_parser.parse_args() model_id = args['id'] if model_id: model = VarAlarmLog.query.get(model_id) if not model: return err_not_found() if args['alarm_id']: model.alarm_id = args['alarm_id'] if args['status']: model.status = args['status'] if args['time']: model.time = args['time'] db.session.add(model) db.session.commit() return rp_modify() else: model = VarAlarmLog( alarm_id=args['alarm_id'], status=args['status'], time=args['time'], ) db.session.add(model) db.session.commit() return rp_create()
def put(self): args = value_put_parser.parse_args() value_id = args['id'] if value_id: value = Value.query.get(value_id) if not value: return err_not_found() if args['variable_id']: value.variable_id = args['variable_id'] if args['value']: value.value = args['value'] if args['time']: value.time = args['time'] db.session.add(value) db.session.commit() return rp_modify() else: value = Value(variable_id=args['variable_id'], value=args['value'], time=args['time']) db.session.add(value) db.session.commit() return rp_create()
def put(self): if self.model_id: model = Parameter.query.get(self.model_id) if not model: return err_not_found() if self.param_name: model.param_name = self.param_name if self.variable_id: model.variable_id = self.variable_id if self.unit: model.unit = self.unit db.session.add(model) db.session.commit() return rp_modify() else: model = Parameter(variable_id=self.variable_id, param_name=self.param_name, unit=self.unit) db.session.add(model) db.session.commit() return rp_create()
def put(self): args = station_put_parser.parse_args() station_id = args['id'] if station_id: station = YjStationInfo.query.get(station_id) if not station: return err_not_found() if args['station_name']: station.station_name = args['station_name'] if args['mac']: station.mac = args['mac'] if args['ip']: station.ip = args['ip'] if args['note']: station.note = args['note'] if args['id_num']: station.id_num = args['id_num'] if args['plc_count']: station.plc_count = args['plc_count'] if args['ten_id']: station.ten_id = args['ten_id'] if args['item_id']: station.item_id = args['item_id'] if args['modification']: station.modification = args['modification'] db.session.add(station) db.session.commit() return rp_modify() else: station = YjStationInfo(station_name=args['station_name'], mac=args['mac'], ip=args['ip'], note=args['note'], id_num=args['id_num'], plc_count=args['plc_count'], ten_id=args['ten_id'], item_id=args['item_id'], modification=args['modification']) db.session.add(station) db.session.commit() return rp_create()
def put(self): args = group_put_parser.parse_args() group_id = args['id'] if group_id: group = YjGroupInfo.query.get(group_id) if not group: return err_not_found() if args['group_name']: group.group_name = args['group_name'] if args['plc_id']: group.plc_id = args['plc_id'] if args['note']: group.note = args['note'] if args['upload_cycle']: group.upload_cycle = args['upload_cycle'] if args['ten_id']: group.ten_id = args['ten_id'] if args['item_id']: group.item_id = args['item_id'] if args['upload']: group.item_id = args['upload'] db.session.add(group) db.session.commit() return rp_modify() else: group = YjGroupInfo(group_name=args['group_name'], plc_id=args['plc_id'], note=args['note'], upload_cycle=args['upload_cycle'], ten_id=args['ten_id'], item_id=args['item_id'], upload=args['upload']) db.session.add(group) db.session.commit() return rp_create()
def put(self): if self.model_id: model = InterfaceLog.query.get(self.model_id) if not model: return err_not_found() if self.username: model.username = self.username if self.host_url: model.host_url = self.host_url if self.method: model.method = self.method db.session.add(model) db.session.commit() return rp_modify()
def put(self, model_id=None): args = query_put_parser.parse_args() if not model_id: model_id = args['id'] if model_id: model = QueryGroup.query.get(model_id) if not model: return err_not_found() if args['name']: model.name = args['name'] if args['variable_id']: var_models = YjVariableInfo.query.filter( YjVariableInfo.id.in_(args['variable_id'])).all() model.vars += var_models db.session.add(model) db.session.commit() return rp_modify() else: if args['variable_id']: var_models = YjVariableInfo.query.filter( YjVariableInfo.id.in_(args['variable_id'])).all() else: var_models = [] model = QueryGroup(name=args['name'], vars=var_models) db.session.add(model) db.session.commit() return rp_create()
def put(self, model_id=None): args = status_put_parser.parse_args() if not model_id: model_id = args['id'] if model_id: model = TransferLog.query.get(model_id) if not model: return err_not_found() if args['station_id']: model.station_name = args['station_id'] if args['level']: model.level = args['level'] if args['time']: model.time = args['time'] if args['note']: model.note = args['note'] db.session.add(model) db.session.commit() return rp_modify() else: model = TransferLog( station_id=args['station_id'], level=args['level'], time=args['time'], note=args['note'], ) db.session.add(model) db.session.commit() return rp_create()
def put(self): args = plc_put_parser.parse_args() plc_id = args['id'] if plc_id: plc = YjPLCInfo.query.get(plc_id) self.query = [].append(plc) print self.query if not plc: return err_not_found() if args['plc_name']: plc.plc_name = args['plc_name'] if args['station_id']: plc.station_id = args['station_id'] if args['note']: plc.note = args['note'] if args['ip']: plc.ip = args['ip'] if args['mpi']: plc.mpi = args['mpi'] if args['type']: plc.type = args['type'] if args['plc_type']: plc.plc_type = args['plc_type'] if args['ten_id']: plc.ten_id = args['ten_id'] if args['item_id']: plc.item_id = args['item_id'] if args['rack']: plc.rack = args['rack'] if args['slot']: plc.slot = args['slot'] if args['tcp_port']: plc.tcp_port = args['tcp_port'] db.session.add(plc) db.session.commit() return rp_modify() else: self.query = [] plc = YjPLCInfo(plc_name=args['plc_name'], station_id=args['station_id'], note=args['note'], ip=args['ip'], mpi=args['mpi'], type=args['type'], plc_type=args['plc_type'], ten_id=args['ten_id'], item_id=args['item_id'], rack=args['rack'], slot=args['slot'], tcp_port=args['tcp_port']) db.session.add(plc) db.session.commit() self.new_id = plc.id return rp_create()
def put(self, variable_id=None): args = variable_put_parser.parse_args() if not variable_id: variable_id = args['id'] if variable_id: variable = YjVariableInfo.query.get(variable_id) if not variable: return err_not_found() if args['variable_name'] is not None: variable.variable_name = args['variable_name'] if args['group_id'] is not None: variable.group_id = args['group_id'] if args['db_num'] is not None: variable.db_num = args['db_num'] if args['address'] is not None: variable.address = args['address'] if args['data_type'] is not None: variable.data_type = args['data_type'] if args['rw_type'] is not None: variable.rw_type = args['rw_type'] if args['upload'] is not None: variable.upload = args['upload'] if args['acquisition_cycle'] is not None: variable.acquisition_cycle = args['acquisition_cycle'] if args['server_record_cycle'] is not None: variable.server_record_cycle = args['server_record_cycle'] if args['note'] is not None: variable.note = args['note'] if args['ten_id'] is not None: variable.ten_id = args['ten_id'] if args['item_id'] is not None: variable.item_id = args['item_id'] if args['write_value'] is not None: variable.write_value = args['write_value'] if args['area'] is not None: variable.area = args['area'] db.session.add(variable) db.session.commit() return rp_modify() else: variable = YjVariableInfo( variable_name=args['variable_name'], group_id=args['group_id'], db_num=args['db_num'], address=args['address'], area=args['area'], data_type=args['data_type'], rw_type=args['rw_type'], upload=args['upload'], acquisition_cycle=args['acquisition_cycle'], server_record_cycle=args['server_record_cycle'], note=args['note'], ten_id=args['ten_id'], item_id=args['item_id'], write_value=args['write_value']) db.session.add(variable) db.session.commit() return rp_create()