returnResult.error(message="level0 data [%s]not found"%(level0_id))
sql_data=f"select * from cpic_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time >= '{level0_data.data.obs_time}' order by obs_time ASC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
sql_data=f"select * from cpic_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time <= '{level0_data.data.obs_time}' order by obs_time DESC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
returnResult.error(message="not found")
exceptExceptionase:
returnResult.error(message=str(e))
deffind(self,**kwargs):
''' retrieve calibration merge records from database
parameter kwargs:
detector_no: [str]
ref_type: [str]
obs_time: (start,end)
qc1_status : [int]
prc_status : [int]
file_name: [str]
limit: limits returns the number of records,default 0:no-limit
returnResult.error(message="level0 data [%s]not found"%(level0_id))
sql_data=f"select * from mci_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time >= '{level0_data.data.obs_time}' order by obs_time ASC limit 1"
sql_data=f"select * from t_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time >= '{level0_data.data.obs_time}' order by obs_time ASC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
sql_data=f"select * from mci_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time <= '{level0_data.data.obs_time}' order by obs_time DESC limit 1"
sql_data=f"select * from t_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time <= '{level0_data.data.obs_time}' order by obs_time DESC limit 1"
r=self.db.select_one(sql_data)
ifr:
...
...
@@ -79,8 +78,8 @@ class CalMergeApi(object):
file_name=get_parameter(kwargs,"file_name")
limit=get_parameter(kwargs,"limit",0)
sql_count="select count(*) as c from mci_cal_merge where 1=1"
sql_data=f"select * from mci_cal_merge where 1=1"
sql_count="select count(*) as c from t_cal_merge where 1=1"
sql_data=f"select * from t_cal_merge where 1=1"
sql_condition=""
ifdetector_no:
...
...
@@ -139,10 +138,10 @@ class CalMergeApi(object):
defget_by_id(self,iid:int):
try:
r=self.db.select_one(
"select * from mci_cal_merge where id=?",(iid,))
"select * from t_cal_merge where id=?",(iid,))
ifr:
sql_get_level0_id=f"select level0_id from mci_cal2level0 where merge_id={r['id']}"
sql_get_level0_id=f"select level0_id from t_cal2level0 where merge_id={r['id']}"
_,records=self.db.select_many(sql_get_level0_id)
level0_ids=[r["level0_id"]forrinrecords]
...
...
@@ -159,10 +158,10 @@ class CalMergeApi(object):
defget_by_cal_id(self,cal_id:str):
try:
r=self.db.select_one(
"select * from mci_cal_merge where cal_id=?",(cal_id,))
"select * from t_cal_merge where cal_id=?",(cal_id,))
ifr:
sql_get_level0_id=f"select level0_id from mci_cal2level0 where merge_id={r['id']}"
sql_get_level0_id=f"select level0_id from t_cal2level0 where merge_id={r['id']}"
_,records=self.db.select_many(sql_get_level0_id)
level0_ids=[r["level0_id"]forrinrecords]
...
...
@@ -198,7 +197,7 @@ class CalMergeApi(object):
try:
self.db.execute(
'update mci_cal_merge set qc1_status=?, qc1_time=? where id=?',
'update t_cal_merge set qc1_status=?, qc1_time=? where id=?',
(status,format_time_ms(time.time()),id)
)
self.db.end()
...
...
@@ -230,14 +229,14 @@ class CalMergeApi(object):
try:
existed=self.db.exists(
"select * from mci_cal_merge where id=?",
"select * from t_cal_merge where id=?",
(id,)
)
ifnotexisted:
log.warning('%s not found'%(id,))
returnResult.error(message='%s not found'%(id,))
self.db.execute(
'update mci_cal_merge set prc_status=?, prc_time=? where id=?',
'update t_cal_merge set prc_status=?, prc_time=? where id=?',
(status,format_time_ms(time.time()),id)
)
self.db.end()
...
...
@@ -279,14 +278,14 @@ class CalMergeApi(object):
)
try:
self.db.execute(
'INSERT INTO mci_cal_merge (cal_id,detector_no,ref_type,obs_time,exp_time,filename,file_path,prc_status,prc_time,create_time) \
'INSERT INTO t_cal_merge (cal_id,detector_no,ref_type,obs_time,exp_time,filename,file_path,prc_status,prc_time,create_time) \
returnResult.error(message="level0 data [%s]not found"%(level0_id))
sql_data=f"select * from ifs_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time >= '{level0_data.data.obs_time}' order by obs_time ASC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
sql_data=f"select * from ifs_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time <= '{level0_data.data.obs_time}' order by obs_time DESC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
returnResult.error(message="not found")
exceptExceptionase:
returnResult.error(message=str(e))
deffind(self,**kwargs):
''' retrieve calibration merge records from database
parameter kwargs:
detector_no: [str]
ref_type: [str]
obs_time: (start,end)
qc1_status : [int]
prc_status : [int]
file_name: [str]
limit: limits returns the number of records,default 0:no-limit
returnResult.error(message="level0 data [%s]not found"%(level0_id))
sql_data=f"select * from msc_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time >= '{level0_data.data.obs_time}' order by obs_time ASC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
sql_data=f"select * from msc_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time <= '{level0_data.data.obs_time}' order by obs_time DESC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
returnResult.error(message="not found")
exceptExceptionase:
returnResult.error(message=str(e))
deffind(self,**kwargs):
''' retrieve calibration merge records from database
parameter kwargs:
detector_no: [str]
ref_type: [str]
obs_time: (start,end)
qc1_status : [int]
prc_status : [int]
file_name: [str]
limit: limits returns the number of records,default 0:no-limit
returnResult.error(message="level0 data [%s]not found"%(level0_id))
sql_data=f"select * from sls_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time >= '{level0_data.data.obs_time}' order by obs_time ASC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
sql_data=f"select * from sls_cal_merge where detector_no='{level0_data.data.detector_no}' and ref_type='{ref_type}' and obs_time <= '{level0_data.data.obs_time}' order by obs_time DESC limit 1"
r=self.db.select_one(sql_data)
ifr:
rec=CalMergeRecord().from_dict(r)
returnResult.ok_data(data=rec)
returnResult.error(message="not found")
exceptExceptionase:
returnResult.error(message=str(e))
deffind(self,**kwargs):
''' retrieve calibration merge records from database
parameter kwargs:
detector_no: [str]
ref_type: [str]
obs_time: (start,end)
qc1_status : [int]
prc_status : [int]
file_name: [str]
limit: limits returns the number of records,default 0:no-limit