mitao
2024-08-23 3a6f2b349aaac3fd9f895c16f7d833252a2158ab
finance-admin/src/main/java/com/finance/web/controller/api/CurrentQuarterController.java
@@ -13,23 +13,28 @@
import com.finance.system.query.QuestionQuery;
import com.finance.system.query.ScoreCalculateDetailQuery;
import com.finance.system.query.ScoreCalculateQuery;
import com.finance.system.service.ISysUserService;
import com.finance.system.service.TbBasicDataService;
import com.finance.system.service.TbQuestionService;
import com.finance.system.service.TbScoreService;
import com.finance.system.vo.CurrentFieldsAllVO;
import com.finance.system.vo.CurrentFieldsDetailVO;
import com.finance.system.vo.CurrentFieldsVO;
import com.finance.system.vo.DeptVO;
import com.finance.system.vo.QuestionVO;
import com.finance.system.vo.ScoreCalculateDetailVO;
import com.finance.system.vo.ScoreCalculateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -50,21 +55,24 @@
    private final TbBasicDataService tbBasicDataService;
    private final TbQuestionService tbQuestionService;
    private final TbScoreService tbScoreService;
    private final ISysUserService sysUserService;
    /**
     * 字段统计
     *
     * @return R<PageDTO < CurrentFieldsVO>>
     */
    @ApiOperation(value = "字段统计" , notes = "字段统计")
    @ApiOperation(value = "字段统计", notes = "字段统计")
    @PostMapping("/fields-statics")
    public R<PageDTO<CurrentFieldsVO>> fieldsStatics(
            @Validated @RequestBody CurrentFieldsQuery dto) {
        try {
            dto.setQuarter(DateUtils.getNowQuarter());
            String previousQuarter = DateUtils.getPreviousQuarter();
            previousQuarter = "2024年一季度";
            dto.setQuarter(previousQuarter);
            return tbBasicDataService.fieldsStatics(dto);
        } catch (Exception e) {
            log.error("获取字段统计相关信息异常" , e);
            log.error("获取字段统计相关信息异常", e);
            return R.fail();
        }
    }
@@ -76,8 +84,8 @@
     * @return R<CurrentFieldsDetailVO>
     */
    @GetMapping("/fields-details")
    @ApiOperation(value = "字段统计-查看详情" , notes = "字段统计")
    @ApiImplicitParam(name = "id" , value = "基础数据id" , required = true, dataType = "int" , paramType = "query" , dataTypeClass = Long.class)
    @ApiOperation(value = "字段统计-查看详情", notes = "字段统计")
    @ApiImplicitParam(name = "id", value = "基础数据id", required = true, dataType = "int", paramType = "query", dataTypeClass = Long.class)
    public R<CurrentFieldsDetailVO> fieldsDetails(@RequestParam("id") Long id) {
        try {
            return tbBasicDataService.fieldsDetails(id);
@@ -85,7 +93,7 @@
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            log.error("保存当前季度数据异常" , e);
            log.error("保存当前季度数据异常", e);
            return R.fail();
        }
    }
@@ -105,7 +113,7 @@
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            log.error("保存数据异常" , e);
            log.error("保存数据异常", e);
            return R.fail();
        }
        return R.ok();
@@ -117,7 +125,7 @@
     * @return R<CurrentFieldsAllVO>
     */
    @GetMapping("/fields-statics-all")
    @ApiOperation(value = "字段统计-查看全部" , notes = "字段统计")
    @ApiOperation(value = "字段统计-查看全部", notes = "字段统计")
    public R<CurrentFieldsAllVO> fieldsStaticsAll() {
        try {
            return R.ok(tbBasicDataService.fieldsStaticsAll());
@@ -125,7 +133,7 @@
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            log.error("查看全部异常" , e);
            log.error("查看全部异常", e);
            return R.fail();
        }
    }
@@ -141,10 +149,12 @@
    public R<PageDTO<ScoreCalculateVO>> scoreCalculate(
            @Validated @RequestBody ScoreCalculateQuery query) {
        try {
            query.setQuarter(DateUtils.getNowQuarter());
            String previousQuarter = DateUtils.getPreviousQuarter();
            previousQuarter = "2024年一季度";
            query.setQuarter(previousQuarter);
            return R.ok(tbBasicDataService.scoreCalculatePage(query));
        } catch (Exception e) {
            log.error("获取得分计算异常" , e);
            log.error("获取得分计算异常", e);
            return R.fail();
        }
    }
@@ -157,10 +167,13 @@
     */
    @PostMapping("/score-calculate-detail")
    @ApiOperation("得分计算-查看详情")
    @ApiImplicitParam(name = "areaName" , value = "部门名称" , required = false, dataType = "string" , paramType = "query" , dataTypeClass = String.class)
    public R<ScoreCalculateDetailVO> scoreCalculateDetail(
            @Validated @RequestBody ScoreCalculateDetailQuery query) {
        return R.ok(tbScoreService.scoreCalculateDetail(query));
        try {
            return R.ok(tbScoreService.scoreCalculateDetail(query));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    /**
@@ -170,7 +183,7 @@
     * @return R<Void>
     */
    @PostMapping("add-question")
    @ApiOperation(value = "发现问题-添加问题" , notes = "发现问题")
    @ApiOperation(value = "发现问题-添加问题", notes = "发现问题")
    public R<Void> addQuestion(@Validated @RequestBody QuestionDTO dto) {
        try {
            tbQuestionService.addQuestion(dto);
@@ -179,7 +192,7 @@
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            log.error("添加问题异常" , e);
            log.error("添加问题异常", e);
            return R.fail();
        }
    }
@@ -191,7 +204,7 @@
     * @return R<Void>
     */
    @PostMapping("/edit-question")
    @ApiOperation(value = "发现问题-编辑问题" , notes = "发现问题")
    @ApiOperation(value = "发现问题-编辑问题", notes = "发现问题")
    public R<Void> editQuestion(@Validated @RequestBody QuestionUpdDTO dto) {
        try {
            tbQuestionService.editQuestion(dto);
@@ -200,7 +213,7 @@
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            log.error("编辑问题异常" , e);
            log.error("编辑问题异常", e);
            return R.fail();
        }
    }
@@ -212,7 +225,7 @@
     * @return R<PageDTO < QuestionVO>>
     */
    @PostMapping("/page-question")
    @ApiOperation(value = "发现问题-分页查询问题" , notes = "发现问题")
    @ApiOperation(value = "发现问题-分页查询问题", notes = "发现问题")
    public R<PageDTO<QuestionVO>> pageQuestion(@Validated @RequestBody QuestionQuery dto) {
        return R.ok(tbQuestionService.pageQuestion(dto));
    }
@@ -224,10 +237,10 @@
     * @return R<QuestionDTO>
     */
    @GetMapping("/detail-question")
    @ApiOperation(value = "发现问题-问题详情" , notes = "发现问题")
    public R<QuestionDTO> detailQuestion(@RequestParam("id") Long id) {
    @ApiOperation(value = "发现问题-问题详情", notes = "发现问题")
    public R<QuestionVO> detailQuestion(@RequestParam("id") Long id) {
        TbQuestion question = tbQuestionService.getById(id);
        return R.ok(BeanUtils.copyBean(question, QuestionDTO.class));
        return R.ok(BeanUtils.copyBean(question, QuestionVO.class));
    }
    /**
@@ -237,9 +250,17 @@
     * @return R<Void>
     */
    @DeleteMapping("/delete")
    @ApiOperation(value = "发现问题-删除问题" , notes = "发现问题")
    @ApiOperation(value = "发现问题-删除问题", notes = "发现问题")
    public R<Void> delete(@RequestParam("id") Long id) {
        tbQuestionService.removeById(id);
        tbQuestionService.delete(id);
        return R.ok();
    }
    @GetMapping(value = {"/dept/list/{deptName}", "/dept/list"})
    @ApiOperation(value = "发现问题-获取部门列表", notes = "发现问题")
    public R<List<DeptVO>> deptList(
            @ApiParam(value = "部门名称", required = false) @PathVariable(value = "deptName", required = false) String deptName) {
        return R.ok(sysUserService.queryDeptListByName(deptName));
    }
}