package com.ruoyi.postCheck.controller;

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.PostAssessmentRatingOther;
import com.ruoyi.postCheck.service.IPostAssessmentRatingOtherService;
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
 *
 * @author csg
 * @date 2024-01-01
 */
@Api(tags = "4.2.1-打分表(职能互评生产日常)接口")
@RestController
@RequestMapping("/postCheck/postAssessmentRatingOther")
public class PostAssessmentRatingOtherController extends BaseController {
    @Autowired
    private IPostAssessmentRatingOtherService postAssessmentRatingOtherService;

    /**
     * 查询打分表(职能互评生产日常)列表
     */
    @ApiOperation("查询打分表(职能互评生产日常)列表")
    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "type", value = "类型：1-职能互评；2-生产日常；", dataType = "Integer", dataTypeClass = Integer.class),
//                    @ApiImplicitParam(name = "batchId", value = "批次号（管理员创建的）", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "startTime", value = "评分开始时间（管理员创建的）", dataType = "Date", dataTypeClass = Date.class),
//            @ApiImplicitParam(name = "status", value = "状态：1-进行中；2-已完成", dataType = "Integer", dataTypeClass = Integer.class),
//            @ApiImplicitParam(name = "deptId", value = "评分部门ID：打分部门，自己给其他12个部门打分；", dataType = "Long", dataTypeClass = Long.class),
//                    @ApiImplicitParam(name = "completeTime", value = "评分完成时间", dataType = "Date", dataTypeClass = Date.class),
//                    @ApiImplicitParam(name = "scoreUserId", value = "评分人ID", dataType = "Long", dataTypeClass = Long.class),
//                    @ApiImplicitParam(name = "scoreUserName", value = "评分人姓名", dataType = "String", dataTypeClass = String.class),
//                    @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.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:postAssessmentRatingOther:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostAssessmentRatingOther postAssessmentRatingOther) {
        startPage();
        List<PostAssessmentRatingOther> list = postAssessmentRatingOtherService.selectPostAssessmentRatingOtherList(postAssessmentRatingOther);
        return getDataTable(list);
    }

    /**
     * 导出打分表(职能互评生产日常)列表
     @ApiOperation("导出打分表(职能互评生产日常)列表")
     @PreAuthorize("@ss.hasPermi('postCheck:postAssessmentRatingOther:export')")
     @Log(title = "打分表(职能互评生产日常)", businessType = BusinessType.EXPORT)
     @PostMapping("/export") public void export(HttpServletResponse response, PostAssessmentRatingOther postAssessmentRatingOther)
     {
     List<PostAssessmentRatingOther> list = postAssessmentRatingOtherService.selectPostAssessmentRatingOtherList(postAssessmentRatingOther);
     ExcelUtil<PostAssessmentRatingOther> util = new ExcelUtil<PostAssessmentRatingOther>(PostAssessmentRatingOther.class);
     util.exportExcel(response, list, "打分表(职能互评生产日常)数据");
     }
     */

    /**
     * 获取打分表(职能互评生产日常)详细信息
     */
    @ApiOperation("获取打分表(职能互评生产日常)详细信息")
    @PreAuthorize("@ss.hasPermi('postCheck:postAssessmentRatingOther:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(postAssessmentRatingOtherService.selectPostAssessmentRatingOtherById(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 = "batchId", value = "批次号（管理员创建的）", dataType = "String", dataTypeClass = String.class),
     @ApiImplicitParam(name = "startTime", value = "评分开始时间（管理员创建的）", dataType = "Date", dataTypeClass = Date.class),
     @ApiImplicitParam(name = "status", value = "状态：1-进行中；2-已完成", dataType = "Integer", dataTypeClass = Integer.class),
     @ApiImplicitParam(name = "deptId", value = "评分部门ID：打分部门，自己给其他12个部门打分；", dataType = "Long", dataTypeClass = Long.class),
     //        @ApiImplicitParam(name = "completeTime", value = "评分完成时间", dataType = "Date", dataTypeClass = Date.class),
     //        @ApiImplicitParam(name = "scoreUserId", value = "评分人ID", dataType = "Long", dataTypeClass = Long.class),
     //        @ApiImplicitParam(name = "scoreUserName", value = "评分人姓名", dataType = "String", dataTypeClass = String.class),
     //        @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.class),
     //        @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
     })
     @PreAuthorize("@ss.hasPermi('postCheck:postAssessmentRatingOther:add')")
     @Log(title = "打分表(职能互评生产日常)", businessType = BusinessType.INSERT)
     @PostMapping public AjaxResult add(@RequestBody PostAssessmentRatingOther postAssessmentRatingOther)
     {
     return toAjax(postAssessmentRatingOtherService.insertPostAssessmentRatingOther(postAssessmentRatingOther));
     }
     */

    /**
     * 修改打分表(职能互评生产日常)
     @ApiOperation("修改打分表(职能互评生产日常)")
     @ApiImplicitParams({
     @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", dataTypeClass = Long.class),
     @ApiImplicitParam(name = "type", value = "类型：1-职能互评；2-生产日常；", dataType = "Integer", dataTypeClass = Integer.class),
     @ApiImplicitParam(name = "batchId", value = "批次号（管理员创建的）", dataType = "String", dataTypeClass = String.class),
     @ApiImplicitParam(name = "startTime", value = "评分开始时间（管理员创建的）", dataType = "Date", dataTypeClass = Date.class),
     @ApiImplicitParam(name = "status", value = "状态：1-进行中；2-已完成", dataType = "Integer", dataTypeClass = Integer.class),
     @ApiImplicitParam(name = "deptId", value = "评分部门ID：打分部门，自己给其他12个部门打分；", dataType = "Long", dataTypeClass = Long.class),
     @ApiImplicitParam(name = "completeTime", value = "评分完成时间", dataType = "Date", dataTypeClass = Date.class),
     @ApiImplicitParam(name = "scoreUserId", value = "评分人ID", dataType = "Long", dataTypeClass = Long.class),
     @ApiImplicitParam(name = "scoreUserName", value = "评分人姓名", dataType = "String", dataTypeClass = String.class),
     @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.class),
     @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
     })
     @PreAuthorize("@ss.hasPermi('postCheck:postAssessmentRatingOther:edit')")
     @Log(title = "打分表(职能互评生产日常)", businessType = BusinessType.UPDATE)
     @PutMapping public AjaxResult edit(@RequestBody PostAssessmentRatingOther postAssessmentRatingOther)
     {
     return toAjax(postAssessmentRatingOtherService.updatePostAssessmentRatingOther(postAssessmentRatingOther));
     }
     */

    /**
     * 删除打分表(职能互评生产日常)
     @ApiOperation("删除打分表(职能互评生产日常)")
     @ApiImplicitParam(name = "ids", value = "Long类型的主键数组", dataType = "Long[]", dataTypeClass = Long[].class)
     @PreAuthorize("@ss.hasPermi('postCheck:postAssessmentRatingOther:remove')")
     @Log(title = "打分表(职能互评生产日常)", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids)
     {
     return toAjax(postAssessmentRatingOtherService.deletePostAssessmentRatingOtherByIds(ids));
     }
     */

    /**
     * 管理员创建互评计划：(职能部门互评、生产部门日常)
     * 互评批次：管理员启动互评任务，初始化13个部门互相打分的记录
     */
    @ApiOperation("新增打分表(职能互评生产日常)")
    @ApiImplicitParams({
//     @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "type", value = "类型：1-职能互评；2-生产日常；", dataType = "Integer", dataTypeClass = Integer.class),
//     @ApiImplicitParam(name = "batchId", value = "批次号（管理员创建的）", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "startTime", value = "评分开始时间（管理员创建的）", dataType = "Date", dataTypeClass = Date.class),
//     @ApiImplicitParam(name = "status", value = "状态：1-进行中；2-已完成", dataType = "Integer", dataTypeClass = Integer.class),
//     @ApiImplicitParam(name = "deptId", value = "评分部门ID：打分部门，自己给其他12个部门打分；", dataType = "Long", dataTypeClass = Long.class),
            //        @ApiImplicitParam(name = "completeTime", value = "评分完成时间", dataType = "Date", dataTypeClass = Date.class),
            //        @ApiImplicitParam(name = "scoreUserId", value = "评分人ID", dataType = "Long", dataTypeClass = Long.class),
            //        @ApiImplicitParam(name = "scoreUserName", value = "评分人姓名", dataType = "String", dataTypeClass = String.class),
            //        @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.class),
            //        @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
    })
    @PreAuthorize("@ss.hasPermi('postCheck:postAssessmentRatingOther:add')")
    @Log(title = "打分表(职能互评生产日常)", businessType = BusinessType.INSERT)
    @PostMapping("/batchAddRatingOther")
    public AjaxResult batchAddRatingOther(@RequestBody PostAssessmentRatingOther postAssessmentRatingOther) {
        postAssessmentRatingOther.setDeptId(getDeptId());
        return toAjax(postAssessmentRatingOtherService.batchAddRatingOther(postAssessmentRatingOther));
    }




    @ApiOperation("职能互评表打分提交")
    @PreAuthorize("@ss.hasPermi('postCheck:postAssessmentRatingOther:update')")
    @Log(title = "职能互评表打分提交", businessType = BusinessType.UPDATE)
    @PostMapping("/functionalDepartmentSub")
    public AjaxResult functionalDepartmentSub(@RequestBody PostAssessmentRatingOther postAssessmentRatingOther) {
        return toAjax(postAssessmentRatingOtherService.batchAddRatingOtherUpdate(postAssessmentRatingOther));
    }

    @ApiOperation("生产部门日常得分")
    @PreAuthorize("@ss.hasPermi('postCheck:postAssessmentRatingOther:update')")
    @Log(title = "生产部门日常得分", businessType = BusinessType.UPDATE)
    @PostMapping("/productionDepartmentSub")
    public AjaxResult productionDepartmentSub(@RequestBody List<PostAssessmentRatingOther> postAssessmentRatingOther) {
        return toAjax(postAssessmentRatingOtherService.productionDepartmentSub(postAssessmentRatingOther));
    }
}
