package com.hxhq.business.controller;

import java.util.Arrays;
import java.util.List;

import com.hxhq.business.domain.GspFfjlJcgj;
import com.hxhq.business.domain.MjyFfjlJcgj;
import com.hxhq.business.dto.gsp.GspFfjlListDto;
import com.hxhq.business.form.gsp.GspGdForm;
import com.hxhq.business.form.gsp.GspJyForm;
import com.hxhq.business.form.gsp.GspSearchListForm;
import com.hxhq.business.form.mjy.*;
import com.hxhq.business.service.IGspFfjlJcgjService;
import com.hxhq.business.service.IStudyService;
import com.hxhq.common.core.utils.StringUtils;
import com.hxhq.common.security.annotation.RequiresPermissions;
import com.hxhq.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.domain.GspFfjl;
import com.hxhq.business.service.IGspFfjlService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo;


/**
 * 供试品发放记录Controller
 *
 * @author hxhq
 * @date 2025-12-30
 */
@RestController
@RequestMapping("/business/gspFfjl")
public class GspFfjlController extends BaseController
{
    @Autowired
    private IGspFfjlService gspFfjlService;

    @Autowired
    private IGspFfjlJcgjService gspFfjlJcgjService;

    /**
     * 查询供试品发放记录列表
     */
    @GetMapping("/list")
    @RequiresPermissions("business:resource:gsp:ffjllist")
    public TableDataInfo list(GspSearchListForm form)
    {
        startPage();
        List<GspFfjlListDto> list = gspFfjlService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 详细信息
     */
    @GetMapping(value = "/info")
    @RequiresPermissions("business:resource:gsp:ffjllist")
    public AjaxResult getInfo(Long id)
    {
        return AjaxResult.success(gspFfjlService.getById(id));
    }

    /**
     * 稽查轨迹列表
     */
    @GetMapping("/jcgjList")
    @RequiresPermissions("business:resource:gsp:ffjllist")
    public TableDataInfo jcgjList(GspFfjlJcgj form)
    {
        startPage();
        List<GspFfjlJcgj> list = gspFfjlJcgjService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 解档
     */
    @PostMapping("/jd")
    @RequiresPermissions("business:resource:gsp:ffjljd")
    public AjaxResult jd(@RequestBody FfjlJdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspFfjlService.jd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 批量归档
     */
    @PostMapping("/plgd")
    @RequiresPermissions("business:resource:gsp:ffjlgd")
    public AjaxResult plgd(@RequestBody FfjlGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspFfjlService.plgd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 归档
     */
    @PostMapping("/gd")
    @RequiresPermissions("business:resource:gsp:ffjlgd")
    public AjaxResult gd(@RequestBody FfjlGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspFfjlService.gd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 批量锁定
     */
    @PostMapping("/plsd")
    @RequiresPermissions("business:resource:gsp:ffjlsd")
    public AjaxResult plsd(@RequestBody FfjlSdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspFfjlService.plsd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 锁定
     */
    @PostMapping("/sd")
    @RequiresPermissions("business:resource:gsp:ffjlsd")
    public AjaxResult sd(@RequestBody FfjlSdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspFfjlService.sd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 解锁
     */
    @PostMapping("/js")
    @RequiresPermissions("business:resource:gsp:ffjljs")
    public AjaxResult js(@RequestBody FfjlJsForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspFfjlService.js(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 借阅
     */
    @RequiresPermissions("business:resource:gsp:ffjljy")
    @PostMapping("/jy")
    public AjaxResult jy(@RequestBody FfjlJyForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspFfjlService.jy(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 加签
     */
    @PostMapping("/jq")
    @RequiresPermissions("business:resource:gsp:ffjljq")
    public AjaxResult jq(@RequestBody FfjlJqForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspFfjlService.jq(form);
        return AjaxResult.success("操作成功");
    }

}
