package com.srs.web.controller.diagnostic;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.query.MPJQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.srs.comprehensive.domain.ViewStuInfo;
import com.srs.comprehensive.mapper.SrsStudentMapper;
import com.srs.comprehensive.mapper.ViewStuInfoMapper;
import com.srs.diagnostic.domain.DiaReportItems;
import com.srs.diagnostic.domain.DiaReportStudentCompletion;
import com.srs.diagnostic.mapper.DiaReportStandardsMapper;
import com.srs.diagnostic.mapper.DiaReportStudentCompletionMapper;
import com.srs.system.domain.SysDeptMap;
import com.srs.system.service.ISysDeptMapService;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.diagnostic.domain.DiaReportStandards;
import com.srs.diagnostic.service.IDiaReportStandardsService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;

/**
 * 诊断报告标准Controller
 *
 * @author LSD
 * @date 2025-06-21
 */
@RestController
@RequestMapping("/diagnostic/reportStandards")
@Api(value = "诊断报告标准管理", tags = "诊断报告标准管理")
public class DiaReportStandardsController extends BaseController {
    @Autowired
    private IDiaReportStandardsService diaReportStandardsService;

    @Autowired
    private DiaReportStandardsMapper diaReportStandardsMapper;

    @Autowired
    private DiaReportStudentCompletionMapper diaReportStudentCompletionMapper;

    @Autowired
    private ViewStuInfoMapper viewStuInfoMapper;

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:fdydataview')")
    @ApiOperation("辅导员统计各班级指标完成率")
    @GetMapping("/countFdyClassItemFinishNumByRelId")
    public AjaxResult countFdyClassItemFinishNumByRelId(DiaReportStandards params) {
        params.fdyNo = getUsername();
        List<Map<String, Object>> list = diaReportStandardsService.countClassItemFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:fdydataview')")
    @ApiOperation("辅导员统计各年级报告完成率")
    @GetMapping("/countFdyClassFinishNumByRelId")
    public AjaxResult countFdyClassFinishNumByRelId(DiaReportStandards params) {
        params.fdyNo = getUsername();
        List<Map<String, Object>> list = diaReportStandardsService.countClassFinishNumByRelId(params);
        return AjaxResult.success(list);
    }


    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("学务统计各班级指标完成率")
    @GetMapping("/countXwClassItemFinishNumByRelId")
    public AjaxResult countXwClassItemFinishNumByRelId(DiaReportStandards params) {
        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            params.deptId = dept.getOldDeptId();
        }
        List<Map<String, Object>> list = diaReportStandardsService.countClassItemFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("学务统计各年级报告完成率")
    @GetMapping("/countXwClassFinishNumByRelId")
    public AjaxResult countXwClassFinishNumByRelId(DiaReportStandards params) {
        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            params.deptId = dept.getOldDeptId();
        }
        List<Map<String, Object>> list = diaReportStandardsService.countClassFinishNumByRelId(params);
        return AjaxResult.success(list);
    }


    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("学务统计各年级指标完成率")
    @GetMapping("/countXwGradeItemFinishNumByRelId")
    public AjaxResult countXwGradeItemFinishNumByRelId(DiaReportStandards params) {
        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            params.deptId = dept.getOldDeptId();
        }
        List<Map<String, Object>> list = diaReportStandardsService.countGradeItemFinishNumByRelId(params);
        return AjaxResult.success(list);
    }


    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计各年级指标完成率")
    @GetMapping("/countGradeItemFinishNumByRelId")
    public AjaxResult countGradeItemFinishNumByRelId(DiaReportStandards params) {
        List<Map<String, Object>> list = diaReportStandardsService.countGradeItemFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("学务统计各年级报告完成率")
    @GetMapping("/countXwGradeFinishNumByRelId")
    public AjaxResult countXwGradeFinishNumByRelId(DiaReportStandards params) {
        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            params.deptId = dept.getOldDeptId();
        }
        List<Map<String, Object>> list = diaReportStandardsService.countGradeFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计各年级报告完成率")
    @GetMapping("/countGradeFinishNumByRelId")
    public AjaxResult countGradeFinishNumByRelId(DiaReportStandards params) {
        List<Map<String, Object>> list = diaReportStandardsService.countGradeFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("学务统计各专业指标完成率")
    @GetMapping("/countXwMajorItemFinishNumByRelId")
    public AjaxResult countXwMajorItemFinishNumByRelId(DiaReportStandards params) {
        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            params.deptId = dept.getOldDeptId();
        }
        List<Map<String, Object>> list = diaReportStandardsService.countMajorItemFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计各专业指标完成率")
    @GetMapping("/countMajorItemFinishNumByRelId")
    public AjaxResult countMajorItemFinishNumByRelId(DiaReportStandards params) {
        List<Map<String, Object>> list = diaReportStandardsService.countMajorItemFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("统计各专业报告完成率")
    @GetMapping("/countXwMajorFinishNumByRelId")
    public AjaxResult countXwMajorFinishNumByRelId(DiaReportStandards params) {
        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            params.deptId = dept.getOldDeptId();
        }
        List<Map<String, Object>> list = diaReportStandardsService.countMajorFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计各专业报告完成率")
    @GetMapping("/countMajorFinishNumByRelId")
    public AjaxResult countMajorFinishNumByRelId(DiaReportStandards params) {
        List<Map<String, Object>> list = diaReportStandardsService.countMajorFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计各学院报告完成率")
    @GetMapping("/countDeptFinishNumByRelId")
    public AjaxResult countDeptFinishNumByRelId(DiaReportStandards params) {
        List<Map<String, Object>> list = diaReportStandardsService.countDeptFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计各学院指标完成率")
    @GetMapping("/countDeptItemFinishNumByRelId")
    public AjaxResult countDeptItemFinishNumByRelId(DiaReportStandards params) {
        List<Map<String, Object>> list = diaReportStandardsService.countDeptItemFinishNumByRelId(params);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:fdydataview')")
    @ApiOperation("辅导员统计指标完成率")
    @GetMapping("/countFdyItemFinishNumByRelId")
    public AjaxResult countFdyItemFinishNumByRelId(DiaReportStandards params) {
        params.fdyNo = getUsername();
        Map<String, Object> res = diaReportStandardsService.countItemFinishNumByRelId(params);
        return AjaxResult.success(res);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("学务统计指标完成率")
    @GetMapping("/countXwItemFinishNumByRelId")
    public AjaxResult countXwItemFinishNumByRelId(DiaReportStandards params) {
        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            params.deptId = dept.getOldDeptId();
        }
        Map<String, Object> res = diaReportStandardsService.countItemFinishNumByRelId(params);
        return AjaxResult.success(res);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计指标完成率")
    @GetMapping("/countItemFinishNumByRelId")
    public AjaxResult countItemFinishNumByRelId(DiaReportStandards params) {
        Map<String, Object> res = diaReportStandardsService.countItemFinishNumByRelId(params);
        return AjaxResult.success(res);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:fdydataview')")
    @ApiOperation("辅导员统计报告完成率")
    @GetMapping("/countFdyFinishNumByRelId")
    public AjaxResult countFdyFinishNumByRelId(DiaReportStandards params) {
        params.fdyNo = getUsername();
        Map<String, Object> res = diaReportStandardsService.countFinishNumByRelId(params);
        return AjaxResult.success(res);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("学务统计报告完成率")
    @GetMapping("/countXwFinishNumByRelId")
    public AjaxResult countXwFinishNumByRelId(DiaReportStandards params) {
        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            params.deptId = dept.getOldDeptId();
        }
        Map<String, Object> res = diaReportStandardsService.countFinishNumByRelId(params);
        return AjaxResult.success(res);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计报告完成率")
    @GetMapping("/countFinishNumByRelId")
    public AjaxResult countFinishNumByRelId(DiaReportStandards params) {
        Map<String, Object> res = diaReportStandardsService.countFinishNumByRelId(params);
        return AjaxResult.success(res);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:fdydataview')")
    @ApiOperation("辅导员统计完成率")
    @GetMapping("/countFdyItemFinishByRelId")
    public AjaxResult countFdyItemFinishByRelId(DiaReportStandards params) {
        Long relId = params.getRelId();
        List<DiaReportItems> list = diaReportStandardsService.countItemFinishByRelId(relId);
        QueryWrapper<ViewStuInfo> stuInfoQueryWrapper = new QueryWrapper<>();
        stuInfoQueryWrapper.notIn("status", "02", "03");
        stuInfoQueryWrapper.eq("t_no", getUsername());
        if (params.classId != null && params.classId != 0) {
            stuInfoQueryWrapper.eq("class_id", params.classId);
        }

        Long stuCount = viewStuInfoMapper.selectCount(stuInfoQueryWrapper);
        Long deptId = getDeptId();

        for (DiaReportItems item : list) {
            item.stuCount = stuCount;

            MPJLambdaWrapper<DiaReportStudentCompletion> wrapper = new MPJLambdaWrapper<>();
            wrapper
                    .leftJoin(ViewStuInfo.class, ViewStuInfo::getStuNo, DiaReportStudentCompletion::getStuNo)
                    .eq(DiaReportStudentCompletion::getItemId, item.getItemId())
                    .eq(DiaReportStudentCompletion::getRelId, relId)
                    .eq(DiaReportStudentCompletion::getCompleted, 1)
                    .notIn(ViewStuInfo::getStatus, "02", "03")
                    .eq(ViewStuInfo::getTNo, getUsername());

            DiaReportStandards searchQuery = new DiaReportStandards();
            searchQuery.setRelId(relId);
            searchQuery.setItemId(item.getItemId());
            searchQuery.setLevel(2);
            searchQuery.deptId = deptId;
            DiaReportStandards diaReportStandards1 = diaReportStandardsMapper.selectStandardDept(searchQuery);
            if (diaReportStandards1 != null) {
                item.xwStandard = diaReportStandards1.getStandardValue();
            }

            if (params.classId != null && params.classId != 0) {
                wrapper.eq(ViewStuInfo::getClassId, params.classId);
            }

            Long finishCount = diaReportStudentCompletionMapper.selectJoinCount(wrapper);
            item.finishCount = finishCount;
        }
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwdataview')")
    @ApiOperation("学务统计完成率")
    @GetMapping("/countXwItemFinishByRelId")
    public AjaxResult countXwItemFinishByRelId(DiaReportStandards params) {
        Long relId = params.getRelId();
        List<DiaReportItems> list = diaReportStandardsService.countItemFinishByRelId(relId);
        QueryWrapper<ViewStuInfo> stuInfoQueryWrapper = new QueryWrapper<>();
        stuInfoQueryWrapper.notIn("status", "02", "03");
        if (params.gradeId != null && params.gradeId != 0) {
            stuInfoQueryWrapper.eq("grade_id", params.gradeId);
        }
        Long deptId = getDeptId();

        Long oldId = getDeptId();
        SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
        if (dept != null) {
            stuInfoQueryWrapper.eq("dept_id", dept.getOldDeptId());
        }


        if (params.majorId != null && params.majorId != 0) {
            stuInfoQueryWrapper.eq("major_id", params.majorId);
        }
        if (params.classId != null && params.classId != 0) {
            stuInfoQueryWrapper.eq("class_id", params.classId);
        }

        Long stuCount = viewStuInfoMapper.selectCount(stuInfoQueryWrapper);

        for (DiaReportItems item : list) {
            item.stuCount = stuCount;

            MPJLambdaWrapper<DiaReportStudentCompletion> wrapper = new MPJLambdaWrapper<>();
            wrapper
                    .leftJoin(ViewStuInfo.class, ViewStuInfo::getStuNo, DiaReportStudentCompletion::getStuNo)
                    .eq(DiaReportStudentCompletion::getItemId, item.getItemId())
                    .eq(DiaReportStudentCompletion::getRelId, relId)
                    .eq(DiaReportStudentCompletion::getCompleted, 1)
                    .notIn(ViewStuInfo::getStatus, "02", "03");

            if (params.getGradeId() != null && params.getGradeId() != 0) {
                wrapper.eq(ViewStuInfo::getGradeId, params.getGradeId());
            }
            if (params.getDeptId() != null && params.getDeptId() != 0) {
                wrapper.eq(ViewStuInfo::getDeptId, params.getDeptId());
                DiaReportStandards searchQuery = new DiaReportStandards();
                searchQuery.setRelId(relId);
                searchQuery.setItemId(item.getItemId());
                searchQuery.setLevel(2);
                searchQuery.deptId = deptId;
                DiaReportStandards diaReportStandards1 = diaReportStandardsMapper.selectStandardDept(searchQuery);
                if (diaReportStandards1 != null) {
                    item.xwStandard = diaReportStandards1.getStandardValue();
                }
            }
            if (params.getMajorId() != null && params.getMajorId() != 0) {
                wrapper.eq(ViewStuInfo::getMajorId, params.getMajorId());
            }
            if (params.classId != null && params.classId != 0) {
                wrapper.eq(ViewStuInfo::getClassId, params.classId);
            }

            Long finishCount = diaReportStudentCompletionMapper.selectJoinCount(wrapper);
            item.finishCount = finishCount;
        }
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:dataview')")
    @ApiOperation("统计完成率")
    @GetMapping("/countItemFinishByRelId")
    public AjaxResult countItemFinishByRelId(DiaReportStandards params) {
        Long relId = params.getRelId();
        List<DiaReportItems> list = diaReportStandardsService.countItemFinishByRelId(relId);
        QueryWrapper<ViewStuInfo> stuInfoQueryWrapper = new QueryWrapper<>();
        stuInfoQueryWrapper.notIn("status", "02", "03");
        if (params.gradeId != null && params.gradeId != 0) {
            stuInfoQueryWrapper.eq("grade_id", params.gradeId);
        }
        Long deptId = 0L;
        if (params.deptId != null && params.deptId != 0) {
            stuInfoQueryWrapper.eq("dept_id", params.deptId);
            SysDeptMap dept = _deptMap.getNewDeptByOldId(params.deptId);
            if (dept != null) {
                deptId = dept.getNewDeptId();
            }
        }
        if (params.majorId != null && params.majorId != 0) {
            stuInfoQueryWrapper.eq("major_id", params.majorId);
        }
        if (params.classId != null && params.classId != 0) {
            stuInfoQueryWrapper.eq("class_id", params.classId);
        }

        Long stuCount = viewStuInfoMapper.selectCount(stuInfoQueryWrapper);

        for (DiaReportItems item : list) {
            item.stuCount = stuCount;

            MPJLambdaWrapper<DiaReportStudentCompletion> wrapper = new MPJLambdaWrapper<>();
            wrapper
                    .leftJoin(ViewStuInfo.class, ViewStuInfo::getStuNo, DiaReportStudentCompletion::getStuNo)
                    .eq(DiaReportStudentCompletion::getItemId, item.getItemId())
                    .eq(DiaReportStudentCompletion::getRelId, relId)
                    .eq(DiaReportStudentCompletion::getCompleted, 1)
                    .notIn(ViewStuInfo::getStatus, "02", "03");

            if (params.getGradeId() != null && params.getGradeId() != 0) {
                wrapper.eq(ViewStuInfo::getGradeId, params.getGradeId());
            }
            if (params.getDeptId() != null && params.getDeptId() != 0) {
                wrapper.eq(ViewStuInfo::getDeptId, params.getDeptId());
                DiaReportStandards searchQuery = new DiaReportStandards();
                searchQuery.setRelId(relId);
                searchQuery.setItemId(item.getItemId());
                searchQuery.setLevel(2);
                searchQuery.deptId = deptId;
                DiaReportStandards diaReportStandards1 = diaReportStandardsMapper.selectStandardDept(searchQuery);
                if (diaReportStandards1 != null) {
                    item.xwStandard = diaReportStandards1.getStandardValue();
                }
            }
            if (params.getMajorId() != null && params.getMajorId() != 0) {
                wrapper.eq(ViewStuInfo::getMajorId, params.getMajorId());
            }
            if (params.classId != null && params.classId != 0) {
                wrapper.eq(ViewStuInfo::getClassId, params.classId);
            }


            Long finishCount = diaReportStudentCompletionMapper.selectJoinCount(wrapper);
            item.finishCount = finishCount;
        }
        return AjaxResult.success(list);
    }


    @ApiOperation("学生填写")
    @PostMapping("/stuEditStandard")
    public AjaxResult stuEditStandard(@RequestBody List<DiaReportStandards> diaReportStandards) {
        return diaReportStandardsService.stuEditStandard(diaReportStandards);
    }


    @ApiOperation("学务填写")
    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xwEditStandard')")
    @PostMapping("/xwEditStandard")
    public AjaxResult xwEditStandard(@RequestBody List<DiaReportStandards> diaReportStandards) {
        return diaReportStandardsService.xwEditStandard(diaReportStandards);
    }

    @ApiOperation("学工填写")
    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:xgEditStandard')")
    @PostMapping("/xgEditStandard")
    public AjaxResult xgEditStandard(@RequestBody List<DiaReportStandards> diaReportStandards) {
        return diaReportStandardsService.xgEditStandard(diaReportStandards);
    }

    @GetMapping("/getXgItemByReportId/{relId}/{reportId}")
    public AjaxResult getXgItemByReportId(@PathVariable("relId") Long relId, @PathVariable("reportId") Long reportId) {
        List<DiaReportItems> list = diaReportStandardsService.getXgItemByReportId(relId, reportId);
        return AjaxResult.success(list);
    }

    @GetMapping("/getXwItemByReportId/{relId}/{reportId}")
    public AjaxResult getXwItemByReportId(@PathVariable("relId") Long relId, @PathVariable("reportId") Long reportId) {
        List<DiaReportItems> list = diaReportStandardsService.getXwItemByReportId(relId, reportId);
        return AjaxResult.success(list);
    }


    @Autowired
    ISysDeptMapService _deptMap;

    @GetMapping("/getStuItemByReportId/{relId}/{reportId}")
    public AjaxResult getStuItemByReportId(@PathVariable("relId") Long relId, @PathVariable("reportId") Long reportId) {
        QueryWrapper<ViewStuInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("stu_no", getUsername());
        ViewStuInfo viewStuInfo = viewStuInfoMapper.selectOne(queryWrapper);
        Long stuDept = viewStuInfo.getDeptId();
        SysDeptMap dept = _deptMap.getNewDeptByOldId(stuDept);
        Long deptId = 0L;
        if (dept != null) {
            deptId = dept.getNewDeptId();
        }
        List<DiaReportItems> list = diaReportStandardsService.getStuItemByReportId(deptId, relId, reportId);
        return AjaxResult.success(list);
    }


    @GetMapping("/getItemByReportId/{reportId}")
    public AjaxResult getItemByReportId(@PathVariable Long reportId) {
        List<DiaReportItems> list = diaReportStandardsService.getItemByReportId(reportId);
        return AjaxResult.success(list);
    }


    /**
     * 查询诊断报告标准列表
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:list')")
    @GetMapping("/list")
    @ApiOperation("查询诊断报告标准列表")
    public TableDataInfo list(DiaReportStandards diaReportStandards) {
        startPage();
        List<DiaReportStandards> list = diaReportStandardsService.selectDiaReportStandardsList(diaReportStandards);
        return getDataTable(list);
    }

    /**
     * 导出诊断报告标准列表
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:export')")
    @Log(title = "诊断报告标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出诊断报告标准列表")
    public void export(HttpServletResponse response, DiaReportStandards diaReportStandards) {
        List<DiaReportStandards> list = diaReportStandardsService.selectDiaReportStandardsList(diaReportStandards);
        ExcelUtil<DiaReportStandards> util = new ExcelUtil<DiaReportStandards>(DiaReportStandards.class);
        util.exportExcel(response, list, "诊断报告标准数据");
    }

    /**
     * 获取诊断报告标准详细信息
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:query')")
    @GetMapping(value = "/{standardId}")
    @ApiOperation("获取诊断报告标准详细信息")
    public AjaxResult getInfo(@PathVariable("standardId") Long standardId) {
        return success(diaReportStandardsService.selectDiaReportStandardsByStandardId(standardId));
    }

    /**
     * 新增诊断报告标准
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:add')")
    @Log(title = "诊断报告标准", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增诊断报告标准")
    public AjaxResult add(@RequestBody DiaReportStandards diaReportStandards) {
        return toAjax(diaReportStandardsService.insertDiaReportStandards(diaReportStandards));
    }

    /**
     * 修改诊断报告标准
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:edit')")
    @Log(title = "诊断报告标准", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改诊断报告标准")
    public AjaxResult edit(@RequestBody DiaReportStandards diaReportStandards) {
        return toAjax(diaReportStandardsService.updateDiaReportStandards(diaReportStandards));
    }

    /**
     * 删除诊断报告标准
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reportStandards:remove')")
    @Log(title = "诊断报告标准", businessType = BusinessType.DELETE)
    @PostMapping("/{standardIds}")
    @ApiOperation("删除诊断报告标准")
    public AjaxResult remove(@PathVariable Long[] standardIds) {
        return toAjax(diaReportStandardsService.deleteDiaReportStandardsByStandardIds(standardIds));
    }
}
