package com.nantian.cloud.jly.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nantian.cloud.jly.entity.CheckBasis;
import com.nantian.cloud.jly.entity.CheckVerdict;
import com.nantian.cloud.jly.entity.EnterpriseSituation;
import com.nantian.cloud.jly.service.CheckBasisService;
import com.nantian.cloud.jly.service.CheckVerdictService;
import com.nantian.sc.cloud.common.core.util.R;
import com.nantian.sc.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.math.BigInteger;
import java.util.List;


/**
 * 审批意见表
 */
@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/checkBasis")
@Api(value = "checkBasis", tags = "审批意见表")
public class CheckBasisController {
    private final CheckBasisService checkBasisService;
    /**
     * 根据审查计划id查询
     * @param checkPlanId
     * @return
     */
    @SysLog("查找审查报告D3")
    @GetMapping("/getBycheckPlanId")
    public R getBycheckPlanId(BigInteger checkPlanId,String epc) {
        QueryWrapper<CheckBasis> queryWrapper = new QueryWrapper<CheckBasis>();
        queryWrapper.eq("check_plan_id",checkPlanId);
        queryWrapper.eq("epc",epc);
        List<CheckBasis> list = checkBasisService.list(queryWrapper);
        return R.ok(list);
    }

    /**
     * 保存
     *
     * @param checkBasis
     * @return R
     */
    @SysLog("保存审查报告D3")
    @ApiOperation(value = "用能单位概况", notes = "用能单位概况")
    @ApiImplicitParam(name = "checkBasis", value = "用能单位概况", required = true, dataType = "json", paramType = "path")
    @PostMapping("/save")
    public R save(@RequestBody CheckBasis checkBasis) {
        checkBasisService.deleteByPlanId(checkBasis.getCheckPlanId(),checkBasis.getEpc());
        return R.ok(checkBasisService.save(checkBasis));
    }

    /**
     * 查询D3要用的标准
     */
    @SysLog("查询D3要用的标准")
    @GetMapping("/getGBList")
    public R getGBList() {
        return R.ok(checkBasisService.getGBList());
    }
}
