package com.ruoyi.postCheck.controller;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constant.PostPlanEnum;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.postCheck.domain.join.PostPlanJoinChecked;
import com.ruoyi.postCheck.service.IPostPlanJoinCheckedService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 岗检记录上传列表Controller
 *
 * @author csg
 * @date 2023-12-22
 */
@Api(tags = "3.1.1-岗检记录上传")
@RestController
@RequestMapping("/postCheck/postPlanJoinChecked")
public class PostPlanJoinCheckedController extends BaseController {
    @Autowired
    private IPostPlanJoinCheckedService postPlanJoinCheckedService;


    @ApiOperation("查询岗检记录上传列表列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "checkGroupId", value = "检查工作组ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedDeptId", value = "被检查部门ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedDeptName", value = "被检查部门名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "status", value = "岗检状态：1-未检；2-已检；", dataType = "Integer", dataTypeClass = Integer.class),

            @ApiImplicitParam(name = "pageNum", value = "页码从1开始", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序字段", dataType = "String", dataTypeClass = String.class)
    })
//    @PreAuthorize("@ss.hasPermi('postCheck:postPlanJoinChecked:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostPlanJoinChecked postPlanJoinChecked) {
//        pageNum: 1
//        pageSize: 10
//        checkGroupName: 工作组
//        checkedPostNames: 岗位
//        checkedDeptName: 部门
//        status: 2
        startPage();
//        startPage("desc", "t1.create_time");
//        岗检计划通过状态
        postPlanJoinChecked.setPlanStatus(PostPlanEnum.STATUS_PASS.getValue());
        List<PostPlanJoinChecked> list = postPlanJoinCheckedService.selectPostPlanJoinCheckedList(postPlanJoinChecked);
        return getDataTable(list);
    }


    @ApiOperation("岗检完成确认")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "planInfoId", value = "岗检计划明细ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedUserName", value = "检查人姓名-与系统用户不关联", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "checkedTime", value = "检查时间(yyyy-MM-dd HH:mm:ss)", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "checkedImg", value = "检查表照片(图片上传后的相对路径)", dataType = "String", dataTypeClass = String.class),

    })
    @Log(title = "岗检完成确认", businessType = BusinessType.UPDATE)
    @PutMapping("/checked")
    public AjaxResult checked(Long planInfoId, String checkedUserName, Date checkedTime, String checkedImg) {
        return toAjax(postPlanJoinCheckedService.checked(planInfoId, checkedUserName, checkedTime, checkedImg));
    }

    @ApiOperation("岗检完成确认后重新上传检查表照片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "planInfoId", value = "岗检计划明细ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedImg", value = "检查表照片(图片上传后的相对路径)", dataType = "String", dataTypeClass = String.class),
    })
    @Log(title = "岗检完成确认后重新上传检查表照片", businessType = BusinessType.UPDATE)
    @PutMapping("imgReUpload")
    public AjaxResult imgReUpload(Long planInfoId, String checkedImg) {
        return toAjax(postPlanJoinCheckedService.imgReUpload(planInfoId, checkedImg));
    }
}
