package com.zt.plat.module.qms.thirdpartyapi.controller.admin;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore;
import com.zt.plat.module.qms.thirdpartyapi.controller.vo.*;
import com.zt.plat.module.qms.thirdpartyapi.service.AutoIngredientsService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;

/**
 * 自动配料接口
 */
@Tag(name = "自动配料(自动火试金)接口")
@RestController
@RequestMapping("/qms/thirdpartyapi/auto-ingredients")
@DeptDataPermissionIgnore(enable = "true")
public class AutoIngredientsController {
	
	@Resource
	private AutoIngredientsService autoIngredientsService;

	@GetMapping("/task-list")
    @Operation(summary = "获取检验批列表")
	public CommonResult<?> taskList(AutoIngredientsTaskQueryReqVO reqVO) {
		List<AutoIngredientsTaskRespVO> list = autoIngredientsService.taskList(reqVO);
		return CommonResult.success(list);
	}
	
	@GetMapping("/task-detail-list")
    @Operation(summary = "获取检验批中的检测任务")
	public CommonResult<?> taskDetailList(@RequestParam("id") Long id) {
		List<AutoIngredientsTaskDetailRespVO> list = autoIngredientsService.taskDetailList(id);
		return CommonResult.success(list);
	}
	
	@PostMapping("/submit-assay-result")
	@Operation(summary = "检测结果同步")
	public CommonResult<?> submitAssayResult(@RequestBody AutoIngredientsTaskAssayResultReqVO body) {
//		System.out.println(com.alibaba.fastjson2.JSON.toJSONString(body));
		autoIngredientsService.submitAssayResult(body);
		return CommonResult.success("成功");
	}
}
