//package com.zhyc.module.base.controller;
//
//import java.util.List;
//import java.util.Map;
//import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.PutMapping;
//import org.springframework.web.bind.annotation.DeleteMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import com.zhyc.common.annotation.Log;
//import com.zhyc.common.enums.BusinessType;
//import com.zhyc.module.base.domain.BreedRamFile;
//import com.zhyc.module.base.service.IBreedRamFileService;
//import com.zhyc.common.core.controller.BaseController;
//import com.zhyc.common.core.domain.AjaxResult;
//import com.zhyc.common.utils.poi.ExcelUtil;
//import com.zhyc.common.core.page.TableDataInfo;
//
///**
// * 种公羊档案Controller
// *
// * @author zhyc
// * @date 2025-07-29
// */
//@RestController
//@RequestMapping("/ram_file/bas_ram_file")
//public class BreedRamFileController extends BaseController
//{
//    @Autowired
//    private IBreedRamFileService breedRamFileService;
//
//    /**
//     * 查询种公羊档案列表
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(BreedRamFile breedRamFile)
//    {
//        startPage();
//        List<BreedRamFile> list = breedRamFileService.selectBreedRamFileList(breedRamFile);
//        return getDataTable(list);
//    }
//
//    /**
//     * 导出种公羊档案列表
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:export')")
//    @Log(title = "种公羊档案", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, BreedRamFile breedRamFile)
//    {
//        List<BreedRamFile> list = breedRamFileService.selectBreedRamFileList(breedRamFile);
//        ExcelUtil<BreedRamFile> util = new ExcelUtil<BreedRamFile>(BreedRamFile.class);
//        util.exportExcel(response, list, "种公羊档案数据");
//    }
//
//    /**
//     * 获取种公羊档案详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return success(breedRamFileService.selectBreedRamFileById(id));
//    }
//
//    /**
//     * 新增种公羊档案
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:add')")
//    @Log(title = "种公羊档案", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody BreedRamFile breedRamFile)
//    {
//        return toAjax(breedRamFileService.insertBreedRamFile(breedRamFile));
//    }
//
//    /**
//     * 修改种公羊档案
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:edit')")
//    @Log(title = "种公羊档案", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody BreedRamFile breedRamFile)
//    {
//        return toAjax(breedRamFileService.updateBreedRamFile(breedRamFile));
//    }
//
//    /**
//     * 删除种公羊档案
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:remove')")
//    @Log(title = "种公羊档案", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(breedRamFileService.deleteBreedRamFileByIds(ids));
//    }
//
//    /**
//     * 从sheep_file同步公羊数据
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:sync')")
//    @Log(title = "种公羊档案同步", businessType = BusinessType.UPDATE)
//    @PostMapping("/sync")
//    public AjaxResult syncFromSheepFile()
//    {
//        int syncCount = breedRamFileService.syncFromSheepFile();
//        return AjaxResult.success("成功同步 " + syncCount + " 条公羊数据");
//    }
//
//    /**
//     * 以下方法可以添加到 BreedRamFileController.java 中
//     * 提供更丰富的查询接口
//     */
//
//    /**
//     * 根据普通耳号查询种公羊档案
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:query')")
//    @GetMapping("/byEarNumber/{earNumber}")
//    public AjaxResult getByEarNumber(@PathVariable("earNumber") String earNumber)
//    {
//        BreedRamFile ram = breedRamFileService.selectBreedRamFileByEarNumber(earNumber);
//        return success(ram);
//    }
//
//    /**
//     * 根据牧场ID查询种公羊档案列表
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
//    @GetMapping("/byRanch/{ranchId}")
//    public AjaxResult getByRanchId(@PathVariable("ranchId") Long ranchId)
//    {
//        List<BreedRamFile> list = breedRamFileService.selectBreedRamFileListByRanchId(ranchId);
//        return success(list);
//    }
//
//    /**
//     * 查询核心羊群种公羊档案列表
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
//    @GetMapping("/coreFlock")
//    public TableDataInfo getCoreFlockList(BreedRamFile breedRamFile)
//    {
//        startPage();
//        List<BreedRamFile> list = breedRamFileService.selectCoreFlockBreedRamFileList(breedRamFile);
//        return getDataTable(list);
//    }
//
//    /**
//     * 查询种用种公羊档案列表
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
//    @GetMapping("/breedingUse")
//    public TableDataInfo getBreedingUseList(BreedRamFile breedRamFile)
//    {
//        startPage();
//        List<BreedRamFile> list = breedRamFileService.selectBreedingUseBreedRamFileList(breedRamFile);
//        return getDataTable(list);
//    }
//
//    /**
//     * 根据羊舍ID查询种公羊档案列表
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
//    @GetMapping("/bySheepfold/{sheepfoldId}")
//    public AjaxResult getBySheepfoldId(@PathVariable("sheepfoldId") Long sheepfoldId)
//    {
//        List<BreedRamFile> list = breedRamFileService.selectBreedRamFileListBySheepfoldId(sheepfoldId);
//        return success(list);
//    }
//
//    /**
//     * 批量同步指定公羊的数据
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:sync')")
//    @Log(title = "批量同步种公羊数据", businessType = BusinessType.UPDATE)
//    @PostMapping("/syncBatch")
//    public AjaxResult syncBatch(@RequestBody List<String> earNumbers)
//    {
//        int syncCount = breedRamFileService.syncSpecificRams(earNumbers);
//        return AjaxResult.success("成功同步 " + syncCount + " 条公羊数据");
//    }
//
//    /**
//     * 获取种公羊统计信息
//     */
//    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
//    @GetMapping("/statistics")
//    public AjaxResult getStatistics()
//    {
//        Map<String, Object> statistics = breedRamFileService.getBreedRamStatistics();
//        return success(statistics);
//    }
//}

package com.zhyc.module.base.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhyc.common.annotation.Log;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.base.domain.BreedRamFile;
import com.zhyc.module.base.domain.ViewBreedRamFile;
import com.zhyc.module.base.service.IBreedRamFileService;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 种公羊档案Controller
 *
 * @author zhyc
 * @date 2025-07-29
 */
@RestController
@RequestMapping("/ram_file/bas_ram_file")
public class BreedRamFileController extends BaseController
{
    @Autowired
    private IBreedRamFileService breedRamFileService;

    /**
     * 查询种公羊档案列表(使用视图)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
    @GetMapping("/list")
    public TableDataInfo list(ViewBreedRamFile viewBreedRamFile)
    {
        startPage();
        List<ViewBreedRamFile> list = breedRamFileService.selectViewBreedRamFileList(viewBreedRamFile);
        return getDataTable(list);
    }

    /**
     * 导出种公羊档案列表(使用视图)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:export')")
    @Log(title = "种公羊档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ViewBreedRamFile viewBreedRamFile)
    {
        List<ViewBreedRamFile> list = breedRamFileService.selectViewBreedRamFileList(viewBreedRamFile);
        ExcelUtil<ViewBreedRamFile> util = new ExcelUtil<ViewBreedRamFile>(ViewBreedRamFile.class);
        util.exportExcel(response, list, "种公羊档案数据");
    }

    /**
     * 获取种公羊档案详细信息(使用视图)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(breedRamFileService.selectViewBreedRamFileById(id));
    }

    /**
     * 新增种公羊档案(更新表)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:add')")
    @Log(title = "种公羊档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BreedRamFile breedRamFile)
    {
        return toAjax(breedRamFileService.insertBreedRamFile(breedRamFile));
    }

    /**
     * 修改种公羊档案(更新表)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:edit')")
    @Log(title = "种公羊档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BreedRamFile breedRamFile)
    {
        return toAjax(breedRamFileService.updateBreedRamFile(breedRamFile));
    }

    /**
     * 删除种公羊档案(更新表)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:remove')")
    @Log(title = "种公羊档案", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(breedRamFileService.deleteBreedRamFileByIds(ids));
    }

    /**
     * 从sheep_file同步公羊数据
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:sync')")
    @Log(title = "种公羊档案同步", businessType = BusinessType.UPDATE)
    @PostMapping("/sync")
    public AjaxResult syncFromSheepFile()
    {
        int syncCount = breedRamFileService.syncFromSheepFile();
        return AjaxResult.success("成功同步 " + syncCount + " 条公羊数据");
    }

    /**
     * 根据普通耳号查询种公羊档案(使用视图)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:query')")
    @GetMapping("/byEarNumber/{earNumber}")
    public AjaxResult getByEarNumber(@PathVariable("earNumber") String earNumber)
    {
        ViewBreedRamFile ram = breedRamFileService.selectViewBreedRamFileByEarNumber(earNumber);
        return success(ram);
    }

    /**
     * 根据牧场ID查询种公羊档案列表(使用视图)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
    @GetMapping("/byRanch/{ranchId}")
    public AjaxResult getByRanchId(@PathVariable("ranchId") Long ranchId)
    {
        List<ViewBreedRamFile> list = breedRamFileService.selectViewBreedRamFileListByRanchId(ranchId);
        return success(list);
    }

    /**
     * 查询核心羊群种公羊档案列表(使用视图)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
    @GetMapping("/coreFlock")
    public TableDataInfo getCoreFlockList(ViewBreedRamFile viewBreedRamFile)
    {
        startPage();
        List<ViewBreedRamFile> list = breedRamFileService.selectCoreFlockViewBreedRamFileList(viewBreedRamFile);
        return getDataTable(list);
    }

    /**
     * 查询种用种公羊档案列表(使用视图)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
    @GetMapping("/breedingUse")
    public TableDataInfo getBreedingUseList(ViewBreedRamFile viewBreedRamFile)
    {
        startPage();
        List<ViewBreedRamFile> list = breedRamFileService.selectBreedingUseViewBreedRamFileList(viewBreedRamFile);
        return getDataTable(list);
    }

    /**
     * 根据羊舍ID查询种公羊档案列表(使用视图)
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
    @GetMapping("/bySheepfold/{sheepfoldId}")
    public AjaxResult getBySheepfoldId(@PathVariable("sheepfoldId") Long sheepfoldId)
    {
        List<ViewBreedRamFile> list = breedRamFileService.selectViewBreedRamFileListBySheepfoldId(sheepfoldId);
        return success(list);
    }

    /**
     * 批量同步指定公羊的数据
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:sync')")
    @Log(title = "批量同步种公羊数据", businessType = BusinessType.UPDATE)
    @PostMapping("/syncBatch")
    public AjaxResult syncBatch(@RequestBody List<String> earNumbers)
    {
        int syncCount = breedRamFileService.syncSpecificRams(earNumbers);
        return AjaxResult.success("成功同步 " + syncCount + " 条公羊数据");
    }

    /**
     * 获取种公羊统计信息
     */
    @PreAuthorize("@ss.hasPermi('breed_ram_file:breed_ram_file:list')")
    @GetMapping("/statistics")
    public AjaxResult getStatistics()
    {
        Map<String, Object> statistics = breedRamFileService.getBreedRamStatistics();
        return success(statistics);
    }
}