// #ifdef APP-ANDROID
import { selectTableData, insertTableData, updateTableData, selectJoinTableData, selectRecordData, selectRecordInfo, selectLatestInfoData, deleteTableData, selectTaskInfo, selectLatestTaskData, selectTaskId, selectTaskDetail, selectTableDataByOrder } from '@/utils/sqlite'
// #endif

export type Download = {
	pdid : number,
	workorder : string,
	invname : string,
	productno : string,
	graphid : string,
	cardno : string,
	processno : string,
	ver : string,
	updatetime : string,
	progress : string,
	status : number
}

export type Record = {
	sxid : number,
	senum : number,
	photoitem : string,
	productno : string,
	part : string,
	descb : string,
	date : string,
	partno : string,
	num : number,
	status : number,
	urlspl : string[],
	imgname : string[],
	urlpdt : string[]
}

export type TaskProcess = {
	id : number
	name : string
	num : number
	step : number
	status : number
}

export type JoinRecord = {
	sxid : number,
	senum : number,
	photoitem : string,
	productno : string,
	part : string,
	descb : string,
	date : string,
	partno : string,
	num : number,
	status : number,
	urlspl : string
	imgname : string,
	urlpdt : string,
	pid : number,
	workorder : string,
	invname : string
}

export type RecordCalculate = {
	photoitem : string,
	pid : number,
	step : number,
	total : number,
	status : number
}

//检验任务
export type TaskInfo = {
	gxid : string,
	itemTitle : string,
	photoitemStep : number,
	photoitemTotal : number,
	photoitemStatus : string,
	recordStep : number,
	recordTotal : number,
	recordStatus : string,
	keypointStep : number,
	keypointTotal : number
	keypointStatus : string
}


export type TaskDownload = {
	pdid : number,
	gxpk : string,
	cardno : string,
	productcode : string,
	model : string,
	workorder : string,
	invname : string,
	graphid : string,
	processno : string,
	gxno : string,
	ver : string,
	lastupdatetime ?: string,
	updateuser ?: string,
	progress ?: string,
	uploadflag : number
}

export type TaskDetail = {
	pdid: string,
	gxno: string,
	photoTotal: number,
	photoCount: number,
	photoStatus: string,
	keyTotal: number,
	keyCount: number,
	keyStatus: string,
	recordTotal: number,
	recordCount: number,
	recordStatus: string,
}

export type TaskPhoto = {
	sxid : number,
	pdid : number,
	senum: number,
	photographpoint : string,
	photographdescription : string,
	photourl : string,
	photourlSpl : string[],
	imgname : string[],
	exampleurl : string,
	exampleurlSpl : string[],
	photoname : string,
	fk_qcRecord : string,
	fk_prodcode : string,
	prodno : string,
	processStep ?: string,
}

export type TaskJoinRecord = {
	sxid : number,
	pdid : number,
	photographpoint : string,
	photographdescription : string,
	photourl ?: string,
	photourlSpl ?: string[],
	imgname : string,
	exampleurl ?: string,
	exampleurlSpl ?: string[],
	photoname ?: string,
	fk_qcRecord ?: string,
	fk_prodcode ?: string,
	prodno ?: string,
	processStep ?: string,
	workorder : string,
	invname : string,
}

export type QcRecord = {
	sxid: number,
	pdid: number,
	pk: string,
	fk_invcode: string,
	no: string,
	invcode: string,
	invname: string,
	processStep: string,
	fk_processTask: string,
	checkTarget: string,
	checknum: number,
	oknum: number,
	ngnum: number,
	status: string,
	result: string,
	checkTime: string,
	fk_creator: string,
	cs: string,
	ts: string,
	psxid: number,
	fk_qcRecord: string,
	fk_prodcode: string,
	prodno: string,
	name: string,
	nature: string,
	unit: string,
	maxNum: string,
	minNum: string,
	memo: string,
	measuredvalue: string,
	measuredvaluemax: string
}

export type TaskKeyProcess = {
	sxid: number,
	pdid: number,
	senum : number,
	parameterorder: number,
	parametername: string,
	prodno: string,
	testapparatus?: string,
	testrequirelower?: string,
	testrequireupper?: string,
	memo?: string,
	measuredvaluemin?: string,
	measuredvaluemax?: string,
	result?: string,
}

export function offlineData(data : UTSJSONObject) : Promise<UTSJSONObject> {
	return new Promise((resolve, reject) => {
		let result = JSON.parseObject(JSON.stringify(data)) as UTSJSONObject
		resolve(result)
	});
}

export const statusDict = { '1': '未执行', '2': '执行中', '3': '已执行', '4': '执行错误', '5': '已取消' }
export const recordStatusDict = { '1': '未拍照', '2': '拍照中', '3': '拍照完成', '4': '检验不清晰', '5': '拍照取消' }
export const taskType = { '1': '检测任务', '2': '关键工序任务' }
export const funcType = { '1': '新增', '2': '更新', '3': '删除' }
//export const moduleType = {'1': '声像记录', '2':'检验任务', '3':'关键工序','4': '系统管理','5':'其它'}

export async function getList(tableName : string, condition ?: string | null, value ?: string | null, condition2 ?: string | null, value2 ?: string | null, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {

	// #ifdef APP-ANDROID
	const result = await selectTableData(tableName, condition, value, condition2, value2);
	console.log(result);
	return result;
	// #endif

	// #ifdef H5
	return offlineData(initData)
	// #endif
}


export async function getJoinList(dbTable : string, joinTable : string, labels : string, joinCondition : string, lname ?: string, lvalue ?: string, others ?: string) : Promise<UTSJSONObject> {

	// #ifdef APP-ANDROID
	const result = await selectJoinTableData(dbTable, joinTable, labels, joinCondition, lname, lvalue, others);
	console.log(result);
	return result;
	// #endif
}



export async function updateData(tableName : string, data : string, lname ?: string, lvalue ?: string) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	const result = await updateTableData(tableName, data, lname, lvalue);
	console.log(result);
	addLog({ module: tableName, dataid: lvalue, content: '更新数据', status: result?.['errMsg'] === 'ok' ? 1 : 0, params: data })
	return result;
	// #endif
}


export async function getRecordCalculate(tableName : string, value ?: string | null, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {

	// #ifdef APP-ANDROID
	const result = await selectRecordData(tableName, value);
	console.log(result);
	return result;
	// #endif

	// #ifdef H5
	return offlineData(initData)
	// #endif
}

export async function getRecordInfoList(initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {

	// #ifdef APP-ANDROID
	const result = await selectRecordInfo();
	console.log(result);
	return result;
	// #endif

	// #ifdef H5
	return offlineData(initData)
	// #endif
}

/**
 * 保存媒体信息数据到数据库
 * @param data MediaInfoData类型的数据
 * @returns Promise<UTSJSONObject> 保存结果
 */
export async function saveMediaInfo(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	// 表名
	const tableName = 'app_media_info';

	// 构造插入的数据字符串，注意数据库字段名和类型
	const values = `'${data?.getString('workorder') ?? ''}','${data?.getString('invname') ?? ''}','${data?.getString('productcode') ?? ''}','${data?.getString('cardno') ?? ''}','${data?.getString('model') ?? ''}','${data?.getString('graphid') ?? ''}','${data?.getString('ver') ?? ''}','${data?.getString('phase') ?? ''}','${data?.getString('processno') ?? ''}','${data?.getString('progress') ?? ''}',${data?.getNumber('status') ?? 1},'${data?.getString('createtime') ?? ''}',${data?.getNumber('createuser') ?? 0},'${data?.getString('updatetime') ?? ''}',${data?.getNumber('updateuser') ?? 0}, 0`;

	// 构造字段名字符串
	const fields = 'workorder,invname,productno,cardno,model,graphid,ver,phase,processno,progress,status,createtime,createuser,updatetime,updateuser,uploadflag';

	try {
		// 调用sqlite的插入方法
		const result = await insertTableData(tableName, values, fields);
		console.log('保存app_media_info成功:', result);
		addLog({ module: tableName, dataid: 0, content: '保存媒体信息', status: 1, params: values })
		return result;
	} catch (error) {
		console.error('保存app_media_info失败:', error);
		addLog({ module: tableName, dataid: 0, content: '保存媒体信息失败', status: 0, params: values })
		return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}

/**
 * 保存媒体信息数据到数据库
 * @param data saveMediaRecord类型的数据
 * @returns Promise<UTSJSONObject> 保存结果
 */
export async function saveMediaRecord(values : string) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	// 表名
	const tableName = 'app_media_record';

	// 构造字段名字符串
	const fields = 'senum,photoitem,productno,part,partno,pk,exampleid,descb,num,status,date,urlspl,imgname,urlpdt,createtime,createuser,updatetime,updateuser,pid';

	try {
		// 调用sqlite的插入方法
		const result = await insertTableData(tableName, values, fields);
		console.log('保存app_media_record成功:', result);
		addLog({ module: tableName, dataid: 0, content: '保存媒体记录', status: 1, params: values })
		return result;
	} catch (error) {
		console.error('保存app_media_record失败:', error);
		addLog({ module: tableName, dataid: 0, content: '保存媒体记录失败', status: 0, params: values })
		return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}


export async function getLatestRecord(productNo : string, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	const result = await selectLatestInfoData(productNo);
	console.log(result);
	return result;
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject)
	// #endif
}

export async function removeTableData(tableName : string, field : string, value : string) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID

	try {
		// 调用sqlite的删除方法
		const result = await deleteTableData(tableName, field, value);
		console.log('删除数据成功:', result);
		addLog({ module: tableName, dataid: 1, content: '删除数据成功', status: 1, params: value })
		return result;
	} catch (error) {
		console.error('删除数据失败:', error);
		addLog({ module: tableName, dataid: 1, content: '删除数据失败', status: 0, params: value })
		return { errMsg: '删除失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}


export async function removeInfoAndRecord(value : string) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID

	try {
		// 调用sqlite的删除方法
		const result = await deleteTableData('app_media_record', 'pid', value);
		addLog({ module: 'app_media_record', dataid: 1, content: '删除数据成功', status: 1, params: value, updatetime: "strftime('%Y-%m-%d %H:%M:%S', 'now')" })

		const result2 = await deleteTableData('app_media_info', 'pdid', value);
		addLog({ module: 'app_media_info', dataid: 1, content: '删除数据成功', status: 1, params: value })
		return result;
	} catch (error) {
		console.error('删除数据失败:', error);
		addLog({ module: 'app_media_record', dataid: 1, content: '删除数据失败', status: 0, params: value })
		return { errMsg: '删除失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}

export async function addLog(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
	const tableName = 'app_log';
	// #ifdef APP-ANDROID
	const params = data?.getString('params')?.replace(/['"]/g, '')
	const dataid = data?.getNumber('dataid') ?? 0
	let fields = 'module,dataid,content,status,params';
	let values = `'${data?.getString('module') ?? ''}',${data?.getNumber('dataid') ?? 0},'${data?.getString('content') ?? ''}',${data?.getNumber('status') ?? 0},'${params}'`;
	if (dataid === 0) {
		fields = fields + ",createuser,createtime"
		values = values + `,'${data?.getString('createuser') ?? 0}',strftime('%Y-%m-%d %H:%M:%S', 'now')`
	} else {
		fields = fields + ",updateuser,updatetime"
		values = values + `,'${data?.getString('updateuser') ?? 0}',strftime('%Y-%m-%d %H:%M:%S', 'now')`
	}

	const result = await insertTableData(tableName, values, fields);
	console.log(result);
	return result;
	// #endif
	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}


export async function saveTaskInfo(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	// 表名
	const tableName = 'app_task_info';

	// 构造插入的数据字符串，注意数据库字段名和类型
	const values = `'${data?.getString('gxpk') ?? ''}','${data?.getString('pk_serial') ?? ''}','${data?.getString('cardno') ?? ''}','${data?.getString('productcode') ?? ''}','${data?.getString('model') ?? ''}','${data?.getString('workorder') ?? ''}','${data?.getString('invname') ?? ''}','${data?.getString('graphid') ?? ''}','${data?.getString('processno') ?? ''}','${data?.getString('gxno') ?? ''}', '${data?.getString('ver') ?? ''}','${data?.getString('lastupdatetime') ?? ''}','${data?.getString('updateuser') ?? ''}', 0`;

	// 构造字段名字符串
	const fields = 'gxpk,pk_serial,cardno,productcode,model,workorder,invname,graphid,processno,gxno,ver,lastupdatetime,updateuser,uploadflag';

	try {
		// 调用sqlite的插入方法
		const result = await insertTableData(tableName, values, fields);
		console.log('保存app_task_info成功:', result);
		addLog({ module: tableName, dataid: 0, content: '保存检验任务信息成功', status: 1, params: values })
		return result;
	} catch (error) {
		console.error('保存app_task_info失败:', error);
		addLog({ module: tableName, dataid: 0, content: '保存检验任务信息失败', status: 0, params: values })
		return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}


/**
 * 保存检验任务信息里的图片数据到数据库
 * @param data saveTaskPhoto类型的数据
 * @returns Promise<UTSJSONObject> 保存结果
 */
export async function saveTaskPhoto(values : string) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	// 表名
	const tableName = 'app_task_photo';

	// 构造字段名字符串
	const fields = 'pdid,pk,photographpoint,photographdescription,photourl,exampleurl,photoname,fk_qcRecord,fk_prodcode,prodno,fk_creator,fks_operator,operator,processStep,fk_processTask,cs,ts';

	try {
		// 调用sqlite的插入方法
		const result = await insertTableData(tableName, values, fields);
		console.log('保存app_task_photo成功:', result);
		addLog({ module: tableName, dataid: 0, content: '保存任务图像记录', status: 1, params: values })
		return result;
	} catch (error) {
		console.error('保存app_task_photo失败:', error);
		addLog({ module: tableName, dataid: 0, content: '保存任务图像记录失败', status: 0, params: values })
		return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}


export async function getTaskInfoList(initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {

	// #ifdef APP-ANDROID
	const result = await selectTaskInfo();
	console.log(result);
	return result;
	// #endif

	// #ifdef H5
	return offlineData(initData)
	// #endif
}


export async function saveTaskKeyProcess(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	// 表名
	const tableName = 'app_task_keyprocess';

	// 构造插入的数据字符串，注意数据库字段名和类型
	const values = `'${data?.getNumber('pdid') ?? 0}','${data?.getString('pk') ?? ''}','${data?.getString('testapparatus') ?? ''}','${data?.getString('tableid') ?? ''}','${data?.getString('testrequirelower') ?? ''}','${data?.getString('testrequireupper') ?? ''}','${data?.getString('parametername') ?? ''}','${data?.getString('parameterorder') ?? ''}','${data?.getString('measureunit') ?? ''}','${data?.getString('parameterinstruction') ?? ''}', '${data?.getString('parameterid') ?? ''}','${data?.getString('fk_creator') ?? ''}','${data?.getString('fk_prodcode') ?? ''}','${data?.getString('prodno') ?? ''}','${data?.getString('processstep') ?? ''}','${data?.getString('fk_processtask') ?? ''}','${data?.getString('measuredvaluemin') ?? ''}','${data?.getString('measuredvaluemax') ?? ''}','${data?.getString('result') ?? ''}','${data?.getString('memo') ?? ''}','${data?.getString('fks_operator') ?? ''}','${data?.getString('cs') ?? ''}','${data?.getString('ts') ?? ''}'`;

	// 构造字段名字符串
	const fields = 'pdid,pk,testapparatus,tableid,testrequirelower,testrequireupper,parametername,parameterorder,measureunit,parameterinstruction,parameterid,fk_creator,fk_prodcode,prodno,processstep,fk_processtask,measuredvaluemin,measuredvaluemax,result,memo,fks_operator,cs,ts';

	try {
		// 调用sqlite的插入方法
		const result = await insertTableData(tableName, values, fields);
		console.log('保存app_task_info成功:', result);
		addLog({ module: tableName, dataid: 0, content: '保存检验任务信息成功', status: 1, params: values })
		return result;
	} catch (error) {
		console.error('保存app_task_info失败:', error);
		addLog({ module: tableName, dataid: 0, content: '保存检验任务信息失败', status: 0, params: values })
		return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}


export async function saveTaskRecord(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	// 表名
	const tableName = 'app_task_record';

	// 构造插入的数据字符串，注意数据库字段名和类型
	const values = `'${data?.getNumber('pdid') ?? 0}','${data?.getString('pk') ?? ''}','${data?.getString('fk_invcode') ?? ''}','${data?.getString('no') ?? ''}','${data?.getString('invcode') ?? ''}','${data?.getString('invname') ?? ''}','${data?.getString('processStep') ?? ''}','${data?.getString('fk_processTask') ?? ''}','${data?.getString('checkTarget') ?? ''}',${data?.getNumber('checknum') ?? 0}, ${data?.getNumber('oknum') ?? 0},${data?.getNumber('ngnum') ?? 0},'${data?.getString('status') ?? ''}','${data?.getString('result') ?? ''}','${data?.getString('checkTime') ?? ''}','${data?.getString('fk_creator') ?? ''}','${data?.getString('cs') ?? ''}','${data?.getString('ts') ?? ''}'`;

	// 构造字段名字符串
	const fields = 'pdid,pk,fk_invcode,no,invcode,invname,processStep,fk_processTask,checkTarget,checknum,oknum,ngnum,status,result,checkTime,fk_creator,cs,ts';

	try {
		// 调用sqlite的插入方法
		const result = await insertTableData(tableName, values, fields);
		console.log('保存app_task_record成功:', result);
		addLog({ module: tableName, dataid: 0, content: '保存检验任务记录信息成功', status: 1, params: values })
		return result;
	} catch (error) {
		console.error('保存app_task_record失败:', error);
		addLog({ module: tableName, dataid: 0, content: '保存检验任务记录信息失败', status: 0, params: values })
		return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}



export async function saveTaskRecordItem(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	// 表名
	const tableName = 'app_task_record_item';

	// 构造插入的数据字符串，注意数据库字段名和类型
	const values = `'${data?.getNumber('psxid') ?? 0}','${data?.getString('pk') ?? ''}','${data?.getString('fk_qcRecord') ?? ''}','${data?.getString('fk_prodcode') ?? ''}','${data?.getString('prodno') ?? ''}','${data?.getString('name') ?? ''}','${data?.getString('no') ?? ''}','${data?.getString('nature') ?? ''}','${data?.getString('unit') ?? ''}',${data?.getNumber('maxNum') ?? 0}, ${data?.getNumber('maxNum') ?? 0},'${data?.getString('status') ?? ''}','${data?.getString('memo') ?? ''}','${data?.getString('measuredvalue') ?? ''}','${data?.getString('measuredvaluemax') ?? ''}','${data?.getString('result') ?? ''}','${data?.getString('cs') ?? ''}','${data?.getString('ts') ?? ''}'`;

	// 构造字段名字符串
	const fields = 'psxid,pk,fk_qcRecord,fk_prodcode,prodno,prodno,no,nature,unit,maxNum,minNum,status,memo,measuredvalue,measuredvaluemax,result,cs,ts';

	try {
		// 调用sqlite的插入方法
		const result = await insertTableData(tableName, values, fields);
		console.log('保存app_task_record_item成功:', result);
		addLog({ module: tableName, dataid: 0, content: '保存检验任务项目信息成功', status: 1, params: values })
		return result;
	} catch (error) {
		console.error('保存app_task_record_item失败:', error);
		addLog({ module: tableName, dataid: 0, content: '保存检验任务项目信息失败', status: 0, params: values })
		return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}


export async function getLatestTask(productNo : string, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID
	const result = await selectLatestTaskData(productNo);
	console.log(result);
	return result;
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject)
	// #endif
}

export async function removeTaskAndRecord(value : string) : Promise<UTSJSONObject> {
	// #ifdef APP-ANDROID

	try {
		// 调用sqlite的删除方法
		const taskId = await selectTaskId('app_task_info', 'pdid', 'gxpk', value);
		const result = await deleteTableData('app_task_info', 'pdid', taskId);
		addLog({ module: 'app_task_info', dataid: 1, content: '删除数据成功', status: 1, params: value, updatetime: "strftime('%Y-%m-%d %H:%M:%S', 'now')" })

		const result2 = await deleteTableData('app_task_photo', 'pdid', taskId);
		addLog({ module: 'app_task_photo', dataid: 1, content: '删除数据成功', status: 1, params: value })

		const recordId = await selectTaskId('app_task_record', 'sxid', 'pdid', taskId);
		const result3 = await deleteTableData('app_task_record_item', 'psxid', recordId);
		addLog({ module: 'app_task_record_item', dataid: 1, content: '删除数据成功', status: 1, params: value })

		const result4 = await deleteTableData('app_task_record', 'sxid', recordId);
		addLog({ module: 'app_task_record', dataid: 1, content: '删除数据成功', status: 1, params: value })
		return {};
	} catch (error) {
		console.error('删除数据失败:', error);
		addLog({ module: 'app_media_record', dataid: 1, content: '删除数据失败', status: 0, params: value })
		return { errMsg: '删除失败', data: [] as any[] } as UTSJSONObject;
	}
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject);
	// #endif
}

export async function getTaskDetail(field ?: string | null, value ?: string | null) : Promise<UTSJSONObject> {

	// #ifdef APP-ANDROID
	const result = await selectTaskDetail(field, value);
	console.log(result);
	return result;
	// #endif

	// #ifdef H5
	return offlineData({ success: true, data: [] } as UTSJSONObject)
	// #endif
}

export async function getListByOrder(tableName : string, condition ?: string | null, value ?: string | null, order ?:string | null, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {

	// #ifdef APP-ANDROID
	const result = await selectTableDataByOrder(tableName, condition, value, null, null, order);
	console.log(result);
	return result;
	// #endif

	// #ifdef H5
	return offlineData(initData)
	// #endif
}