package com.ruoyi.postCheck.controller;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

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.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
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.PostAssessmentRating;
import com.ruoyi.postCheck.service.IPostAssessmentRatingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiImplicitParam;

/**
 * 考核评比Controller：类型：1-职能；2-生产；
 *
 * @author csg
 * @date 2023-12-21
 */
@Api(tags = "4.1.1-考核评比接口（类型：1-职能；2-生产；）")
@RestController
@RequestMapping("/postCheck/assessmentRating")
public class PostAssessmentRatingController extends BaseController {
    @Autowired
    private IPostAssessmentRatingService postAssessmentRatingService;

    /**
     * 查询考核评比列表
     */
    @ApiOperation("查询考核评比列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "type", value = "类型：1-职能；2-生产；", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "postId", value = "岗位名称", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "headUserId", value = "负责人ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "integrityIssuesTotal", value = "完整性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "integrityIssuesResolved", value = "完整性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "effectivenessIssuesTotal", value = "有效性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "effectivenessIssuesResolved", value = "有效性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "suitabilityIssuesTotal", value = "适宜性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "suitabilityIssuesResolved", value = "适宜性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "peerEvaluationScore", value = "互评得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "dailyScore", value = "日常得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "departmentScore", value = "部门得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "positionScore", value = "岗位得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "ratingTime", value = "评分时间", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 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:assessmentRating:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostAssessmentRating postAssessmentRating) {
        startPage();
        List<PostAssessmentRating> list = postAssessmentRatingService.selectPostAssessmentRatingList(postAssessmentRating);
        return getDataTable(list);
    }

    /**
     * 导出考核评比列表
     */
    @ApiOperation("导出考核评比列表")
    @PreAuthorize("@ss.hasPermi('postCheck:assessmentRating:export')")
    @Log(title = "考核评比", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PostAssessmentRating postAssessmentRating) {
        List<PostAssessmentRating> list = postAssessmentRatingService.selectPostAssessmentRatingList(postAssessmentRating);
        ExcelUtil<PostAssessmentRating> util = new ExcelUtil<PostAssessmentRating>(PostAssessmentRating.class);
        util.exportExcel(response, list, "考核评比数据");
    }

    /**
     * 获取考核评比详细信息
     */
    @ApiOperation("获取考核评比详细信息")
    @PreAuthorize("@ss.hasPermi('postCheck:assessmentRating:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(postAssessmentRatingService.selectPostAssessmentRatingById(id));
    }

    /**
     * 新增考核评比
     */
    @ApiOperation("新增考核评比")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "type", value = "类型：1-职能；2-生产；", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "postId", value = "岗位名称", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "headUserId", value = "负责人ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "integrityIssuesTotal", value = "完整性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "integrityIssuesResolved", value = "完整性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "effectivenessIssuesTotal", value = "有效性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "effectivenessIssuesResolved", value = "有效性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "suitabilityIssuesTotal", value = "适宜性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "suitabilityIssuesResolved", value = "适宜性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "peerEvaluationScore", value = "互评得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "dailyScore", value = "日常得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "departmentScore", value = "部门得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "positionScore", value = "岗位得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "ratingTime", value = "评分时间", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
    })
    @PreAuthorize("@ss.hasPermi('postCheck:assessmentRating:add')")
    @Log(title = "考核评比", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PostAssessmentRating postAssessmentRating) {
        return toAjax(postAssessmentRatingService.insertPostAssessmentRating(postAssessmentRating));
    }

    /**
     * 修改考核评比
     */
    @ApiOperation("修改考核评比")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "type", value = "类型：1-职能；2-生产；", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "postId", value = "岗位名称", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "headUserId", value = "负责人ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "integrityIssuesTotal", value = "完整性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "integrityIssuesResolved", value = "完整性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "effectivenessIssuesTotal", value = "有效性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "effectivenessIssuesResolved", value = "有效性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "suitabilityIssuesTotal", value = "适宜性问题数量-总数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "suitabilityIssuesResolved", value = "适宜性问题数量-已整改", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "peerEvaluationScore", value = "互评得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "dailyScore", value = "日常得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "departmentScore", value = "部门得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "positionScore", value = "岗位得分", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "ratingTime", value = "评分时间", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
    })
    @PreAuthorize("@ss.hasPermi('postCheck:assessmentRating:edit')")
    @Log(title = "考核评比", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PostAssessmentRating postAssessmentRating) {
        return toAjax(postAssessmentRatingService.updatePostAssessmentRating(postAssessmentRating));
    }

    /**
     * 删除考核评比
     */
    @ApiOperation("删除考核评比")
    @ApiImplicitParam(name = "ids", value = "Long类型的主键数组", dataType = "Long[]", dataTypeClass = Long[].class)
    @PreAuthorize("@ss.hasPermi('postCheck:assessmentRating:remove')")
    @Log(title = "考核评比", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(postAssessmentRatingService.deletePostAssessmentRatingByIds(ids));
    }
}
