import { TCheckDetailModel, TCheckDto, TCheckModel, TCheckQueryParam } from '@/types'
import request from '@/until/request'

/**
 * 获取拷机业务列表
 * @param data TCheckQueryParam
 */
const QueryTCheckList = (data: TCheckQueryParam) =>
    request({
        url: '/TCheckAction/list',
        method: 'post',
        data: data
    })

/**
* 新增拷机业务
* @param data TCheckModel
*/
const AddTCheck = (data: TCheckModel) =>
    request({
        url: '/TCheckAction/saveTCheck',
        method: 'post',
        data: data
    })

/**
* 编辑拷机业务
* @param data TCheckModel
*/
const EditTCheck = (data: TCheckModel) =>
    request({
        url: '/TCheckAction/updateTCheck',
        method: 'post',
        data: data
    })

/**
* 删除拷机业务
* @param  id number
*/
const DeleteTCheck = (id: number) =>
    request({
        url: '/TCheckAction/deleteTCheck/' + id,
        method: 'get',
    })

/**
* 开始拷机业务
* @param  id number
*/
const StartTCheck = (id: number) =>
    request({
        url: '/TCheckAction/startCopy/' + id,
        method: 'get',
    })

/**
* 结束拷机业务
* @param  data TCheckModel
*/
const StopTCheck = (data: TCheckModel) =>
    request({
        url: '/TCheckAction/endCopy',
        method: 'post',
        data: data
    })

/**
* 根据checkid查找拷机明细
* @param  checkId string
*/
const QueryTCheckDetail = (checkId: string) =>
    request({
        url: '/TCheckAction/findBycheckId/' + checkId,
        method: 'get',
    })

/**
* 添加明细拷机调用方法
* @param  data TCheckDto
*/
const AddTCheckDetail = (data: TCheckDto) =>
    request({
        url: '/TCheckAction/addDetail/' + data.id + "/" + data.platId + "/" + data.deviceSns,
        method: 'get',
    })

/**
* 添加明细拷机调用方法
* @param  data TCheckDto
*/
const AddTCheckDetailPost = (data: TCheckModel) =>
request({
    url: '/TCheckAction/addDetail',
    method: 'post',
    data: data
})


/**
 * 删除拷机明细调用方法
 * @param id 明细表的id并非业务ID
 * @returns 
 */
const DeleteTCheckDetail = (id: number) =>
    request({
        url: '/TCheckAction/deleteDetail/' + id,
        method: 'get',
    })

/**
 * 删除拷机明细调用方法
 * @param id 明细表的id并非业务ID
 * @returns 
 */
const FindBycheckByIdWithMx = (checkId: string) =>
    request({
        url: '/TCheckAction/findBycheckByIdWithMx/' + checkId,
        method: 'get',
    })

/**
* 根据拷机对象获取明细中设备的最新一条数据
* @param data TCheckModel
*/
const FindCheckDetailLatestAiRead = (data: TCheckModel) =>
    request({
        url: '/TCheckAction/findCheckDetailLatestAiRead',
        method: 'post',
        data: data
    })

/**
* 校验拷机设备的采样间隔
* @param data TCheckModel
*/
const CheckSampleIntervalByCheckDetails = (data: TCheckModel) =>
    request({
        url: '/TCheckAction/checkSampleIntervalByCheckDetails',
        method: 'post',
        data: data
    })

export default {
    QueryTCheckList,
    AddTCheck,
    EditTCheck,
    DeleteTCheck,
    StartTCheck,
    StopTCheck,
    QueryTCheckDetail,
    AddTCheckDetail,
    DeleteTCheckDetail,
    FindBycheckByIdWithMx,
    FindCheckDetailLatestAiRead,
    CheckSampleIntervalByCheckDetails,
    AddTCheckDetailPost
}