package com.prolog.cs.biz.inbound.controller.rqc;

import com.prolog.cs.biz.inbound.dto.PageParam;
import com.prolog.cs.biz.inbound.dto.rcv.RcvHDTO;
import com.prolog.cs.biz.inbound.dto.rqc.RqcReDTO;
import com.prolog.cs.biz.inbound.dto.rqc.RqcReHeadersDTO;
import com.prolog.cs.biz.inbound.dto.task.TaskQcRecheckDetailDTO;
import com.prolog.cs.biz.inbound.service.rqc.RqcReHeadersService;
import com.prolog.cs.biz.inbound.vo.RcvQueryVO;
import com.prolog.cs.biz.inbound.vo.RqcHQueryVO;
import com.prolog.cs.biz.inbound.vo.task.TaskQcDetailQueryVO;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.utils.AssertUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description
 * @Date 2021-04-02
 */

@Api(tags = "复检单")
@RestController
@RequestMapping("/rqcReHeaders")
public class RqcReHeadersController {

	@Resource
	private RqcReHeadersService rqcReHeadersService;

	/**
	 * 条件分页
	 */
	@ApiOperation("条件分页")
	@GetMapping("/page")
	public RestMessage<Page<RqcReHeadersDTO>> list(RqcHQueryVO rqcHQueryVO, PageParam pageParam) {
		return RestMessage.newInstance(true, "pageSuccess", rqcReHeadersService.findList(rqcHQueryVO, pageParam));
	}

	/**
	 * 详情
	 */
	@ApiOperation("详情(主键id)")
	@GetMapping("/findByPkId")
	public RestMessage<RqcReHeadersDTO> findByPkId(String pkId) {
		AssertUtils.isNotBlank(pkId, "主键id不可为空");
		return RestMessage.newInstance(true, "findByPkIdSuccess", rqcReHeadersService.findByPkId(pkId));
	}

	@ApiOperation("新增(级联关联表)")
	@PostMapping("/addWithRelated")
	public RestMessage<Object> addWithRelated(@RequestBody RqcReDTO rqcReDTO) {
		return RestMessage.newInstance(true, "addWithRelated", rqcReHeadersService.addWithRelated(rqcReDTO));
	}

	/**
	 * 提取复检池中的任务
	 */
	@ApiOperation("提取复检池中的任务(条件分页)")
	@GetMapping("/extractRqcReTask")
	public RestMessage<Page<TaskQcRecheckDetailDTO>> extractRqcTask(TaskQcDetailQueryVO taskQcDetailQueryVO) {
		return RestMessage.newInstance(true, "extractRqcTask",
				rqcReHeadersService.extractRqcReTask(taskQcDetailQueryVO));
	}

	/**
	 * 找寻待复质检的rcv头表
	 */
	@ApiOperation("提取待复质检的rcv头表")
	@GetMapping("/extractRcvH")
	public RestMessage<Page<RcvHDTO>> extractRcvH(RcvQueryVO rcvQueryVO, PageParam pageParam) {
		return RestMessage.newInstance(true, "extractRcvH",
				rqcReHeadersService.extractRcvHAndPro(rcvQueryVO, pageParam));
	}

}
