def put(self): args = user_parser.parse_args() 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 patch(self): args = status_put_parser.parse_args() model_id = args['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()
def patch(self): args = station_alarm_parser.parse_args() model_id = args['id'] # 修改 model = StationAlarm.query.get(model_id) if not model: return err_not_found() if args['id_num'] is not None: model.id_num = args['id_num'] if args['code'] is not None: model.code = args['code'] if args['note'] is not None: model.note = args['note'] if args['time'] is not None: model.time = args['time'] db.session.add(model) db.session.commit() return rp_modify()
def patch(self): args = group_put_parser.parse_args() model_id = args['id'] model = YjGroupInfo.query.get(model_id) if not model: return err_not_found() if args['group_name']: model.group_name = args['group_name'] if args['plc_id']: model.plc_id = args['plc_id'] if args['note']: model.note = args['note'] if args['upload_cycle']: model.upload_cycle = args['upload_cycle'] if args['ten_id']: model.ten_id = args['ten_id'] if args['item_id']: model.item_id = args['item_id'] if args['upload']: model.upload = args['upload'] db.session.add(model) db.session.commit() return rp_modify()
def patch(self): args = alarm_info_put_parser.parse_args() model_id = args['id'] model = VarAlarmInfo.query.get(model_id) if not model: return err_not_found() if args['variable_id'] is not None: model.variable_id = args['variable_id'] if args['alarm_type'] is not None: model.alarm_type = args['alarm_type'] if args['note'] is not None: model.note = args['note'] if args['is_send_message'] is not None: model.is_send_message = args['is_send_message'] db.session.add(model) db.session.commit() return rp_modify()
def patch(self): args = plc_alarm_parser.parse_args() model_id = args['id'] # 修改 model = PLCAlarm.query.get(model_id) if model is None: return err_not_found() if args['id_num'] is not None: model.id_num = args['id_num'] if args['plc_id'] is not None: model.plc_id = args['plc_id'] if args['level'] is not None: model.level = args['level'] if args['note'] is not None: model.note = args['note'] if args['time'] is not None: model.time = args['time'] db.session.add(model) db.session.commit() return rp_modify()
def patch(self): args = variable_put_parser.parse_args() variable_id = args['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()
def patch(self): args = plc_put_parser.parse_args() plc_id = args['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'] is not None: plc.plc_name = args['plc_name'] if args['station_id'] is not None: plc.station_id = args['station_id'] if args['note'] is not None: plc.note = args['note'] if args['ip'] is not None: plc.ip = args['ip'] if args['mpi'] is not None: plc.mpi = args['mpi'] if args['type'] is not None: plc.type = args['type'] if args['plc_type'] is not None: plc.plc_type = args['plc_type'] if args['ten_id'] is not None: plc.ten_id = args['ten_id'] if args['item_id'] is not None: plc.item_id = args['item_id'] if args['rack'] is not None: plc.rack = args['rack'] if args['slot'] is not None: plc.slot = args['slot'] if args['tcp_port'] is not None: plc.tcp_port = args['tcp_port'] db.session.add(plc) db.session.commit() return rp_modify()
def patch(self): args = station_put_parser.parse_args() model_id = args['id'] model = YjStationInfo.query.get(model_id) if not model: return err_not_found() if args['station_name'] is not None: model.station_name = args['station_name'] if args['mac'] is not None: model.mac = args['mac'] if args['ip'] is not None: model.ip = args['ip'] if args['note'] is not None: model.note = args['note'] if args['id_num'] is not None: model.id_num = args['id_num'] if args['plc_count'] is not None: model.plc_count = args['plc_count'] if args['ten_id'] is not None: model.ten_id = args['ten_id'] if args['item_id'] is not None: model.item_id = args['item_id'] if args['modification'] is not None: model.modification = args['modification'] if args['phone'] is not None: model.phone = args['phone'] if args['version'] is not None: model.version = args['version'] db.session.add(model) db.session.commit() return rp_modify()
def patch(self): 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()
def patch(self): args = alarm_now_put_parser.parse_args() model_id = args['id'] model = VarAlarm.query.get(model_id) if not model: return err_not_found() if args['alarm_id']: model.alarm_id = args['alarm_id'] if args['time']: model.time = args['time'] db.session.add(model) db.session.commit() return rp_modify()
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 patch(self): args = query_put_parser.parse_args() model_id = args['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 = list(set(model.vars).union(set(var_models))) db.session.add(model) db.session.commit() return rp_modify()
def patch(self): args = value_put_parser.parse_args() model_id = args['id'] model = Value.query.get(model_id) if not model: return err_not_found() if args['variable_id']: model.variable_id = args['variable_id'] if args['value']: model.value = args['value'] if args['time']: model.time = args['time'] db.session.add(model) db.session.commit() return rp_modify()