def update_task(self, msg_id, time, action): if not msg_id or not time or not action: return {'result': error_code.ERROR_PARAMS_ERROR} logger.info("RpcHandler::delete_task, msg_id:%s time:%s action:%s" % (msg_id, time, action)) value =[{"msg_id": msg_id,"time":time,"action":action}] DBDeviceTaskInst.update_ls(value) return {'result': error_code.ERROR_SUCCESS}
def delete_task(self, msg_id): if not msg_id: return {'result': error_code.ERROR_PARAMS_ERROR} logger.info("RpcHandler::delete_task, msg_id:%s" % msg_id) value =[{"msg_id": msg_id}] DBDeviceTaskInst.delete_ls(value) return {'result': error_code.ERROR_SUCCESS}
def create_task(self, device_id, time, action): # 这里有坑,action 如果就是False的话,将没有任何警告的直接返回,应该加LOG if not device_id\ or not time\ or not action: return {'result': error_code.ERROR_PARAMS_ERROR} value = {"device_id": device_id, "time": time, "action": action} DBDeviceTaskInst.insert_ls([value]) logger.info("RpcHandler::create_task, device_id:%s, time:%s, action:%s" % (device_id, time, action)) return {'result': error_code.ERROR_SUCCESS}
def query_task(self, device_id, msg_id): if not device_id and not msg_id: return {'result': error_code.ERROR_PARAMS_ERROR} data_ls = DBDeviceTaskInst.query_conditions(device_id, msg_id) for data in data_ls: data["time"] = datetime_to_string(data['time']) logger.info("RpcHandler::query_task, data_ls:%s" % str(data_ls)) return data_ls