import request from '@/utils/request'

// 查询配种记录列表
export function listBreeding_records(query) {
  return request({
    url: '/Breeding_records/Breeding_records/list',
    method: 'get',
    params: query
  })
}

// 查询配种记录详细
export function getBreeding_records(id) {
  return request({
    url: '/Breeding_records/Breeding_records/' + id,
    method: 'get'
  })
}

// 新增配种记录
export function addBreeding_records(data) {
  return request({
    url: '/Breeding_records/Breeding_records',
    method: 'post',
    data: data
  })
}

// 修改配种记录
export function updateBreeding_records(data) {
  return request({
    url: '/Breeding_records/Breeding_records',
    method: 'put',
    data: data
  })
}

// 删除配种记录
export function delBreeding_records(id) {
  return request({
    url: '/Breeding_records/Breeding_records/' + id,
    method: 'delete'
  })
}

// 根据耳号查询羊只信息
export function getSheepInfoByTags(manageTags) {
  return request({
    url: '/Breeding_records/Breeding_records/getSheepByTags/' + manageTags,
    method: 'get'
  })
}

// 根据母羊耳号获取配种计划信息
export function getBreedPlanByEweTags(manageTags) {
  return request({
    url: '/Breeding_records/Breeding_records/getBreedPlan/' + manageTags,
    method: 'get'
  })
}

// 根据母羊耳号获取最新配种计划信息（优先从配种计划生成表获取）
export function getLatestBreedPlanByEweTags(manageTags) {
  return request({
    url: '/Breeding_records/Breeding_records/getLatestBreedPlan/' + manageTags,
    method: 'get'
  })
}

// 同步孕检结果到配种记录
export function syncPregnancyResult(data) {
  return request({
    url: '/Breeding_records/Breeding_records/syncPregnancyResult',
    method: 'post',
    data: data
  })
}

// 根据羊只ID和时间范围查询配种记录
export function getBreedRecordsByTimeRange(sheepId, startDate, endDate) {
  return request({
    url: `/Breeding_records/Breeding_records/getByTimeRange/${sheepId}/${startDate}/${endDate}`,
    method: 'get'
  })
}