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.XRFDataService;

import cn.hutool.core.collection.CollUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;

@Tag(name = "荧光取数接口")
@RestController
@RequestMapping("/qms/thirdpartyapi/xrf-data")
@DeptDataPermissionIgnore(enable = "true")
public class XRFDataController {
	
	@Resource
	private XRFDataService xrfDataService;
	
	@GetMapping("/xrf-line-list")
	public CommonResult<?> getXrfLineList(@RequestParam("deviceNo") String deviceNo) {
		List<ConfigXRFLineCustomRespVO> list = xrfDataService.getXrfLineList(deviceNo);
		return CommonResult.success(list);
	}
	
	@PostMapping("/submit-xrf-data")
	public CommonResult<?> submitXrfData(@RequestBody List<XRFDeviceSampleReqVO> reqList) {
		if (CollUtil.isEmpty(reqList)) {
			return CommonResult.error(1_032_001_000, "请求参数不允许为空");
		}
		int count = xrfDataService.submitXrfData(reqList);
		return CommonResult.success(count);
	}

}
