package com.hw.qms.controller;

import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.web.page.TableDataInfo;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.qms.domain.MesBaseBarcodeInfo;
import com.hw.qms.domain.QmsCheckRule;
import com.hw.qms.domain.QmsCheckRuleProject;
import com.hw.qms.domain.vo.QmsMaterialCheckVo;
import com.hw.qms.service.IMesBaseBarcodeInfoService;
import com.hw.qms.service.IQmsCheckRuleProjectService;
import com.hw.qms.service.IQmsCheckRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description:PDA接口
 * @ProjectName:HwMes
 * @Author:xins
 * @Date:2024-01-26 10:18
 * @Version:1.0
 */
@RestController
@RequestMapping("/qms/mobile")
public class QmsMobileController {

    @Autowired
    private IQmsCheckRuleProjectService qmsCheckRuleProjectService;
    @Autowired
    private IMesBaseBarcodeInfoService mesBaseBarcodeInfoService;

    /**
     * 获取质检结果
     */
//    @RequiresPermissions("qms:checkrule:list")
    @GetMapping("/getCheckResult")
    public AjaxResult getCheckResult(QmsMaterialCheckVo qmsMaterialCheckVo) {
        String materialBarcode = qmsMaterialCheckVo.getMaterialBarcode();
        MesBaseBarcodeInfo baseBarcodeInfo = mesBaseBarcodeInfoService.selectMesBaseBarcodeInfoByBarcodeInfo(materialBarcode);
        if (baseBarcodeInfo == null) {
            throw new ServiceException("此物料条码系统中不存在");
        }


        Long materialId = baseBarcodeInfo.getMaterialId();

        List<QmsCheckRuleProject> checkRuleProjects = qmsCheckRuleProjectService.getCheckRuleProjects(materialId);
        return null;

    }
}
