| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.HistoryGroup; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.ReportingStatusEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.validate.HistoryGroup; |
| | | import com.ruoyi.system.domain.TbBasicData; |
| | | import com.ruoyi.system.query.CurrentFieldsQuery; |
| | | import com.ruoyi.system.query.HistoryDataQuery; |
| | | import com.ruoyi.system.query.QuestionQuery; |
| | | import com.ruoyi.system.query.ScoreCalculateDetailQuery; |
| | | import com.ruoyi.system.query.ScoreCalculateQuery; |
| | | import com.ruoyi.system.service.TbBasicDataService; |
| | | import com.ruoyi.system.service.TbQuestionService; |
| | | import com.ruoyi.system.service.TbScoreService; |
| | | import com.ruoyi.system.vo.*; |
| | | import com.ruoyi.system.vo.BasicDataVO; |
| | | import com.ruoyi.system.vo.CurrentFieldsAllVO; |
| | | import com.ruoyi.system.vo.CurrentFieldsDetailVO; |
| | | import com.ruoyi.system.vo.CurrentFieldsVO; |
| | | import com.ruoyi.system.vo.QuestionVO; |
| | | import com.ruoyi.system.vo.ScoreCalculateDetailVO; |
| | | import com.ruoyi.system.vo.ScoreCalculateVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RequestPart; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | | * @author mitao |
| | |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "历史数据相关接口") |
| | | public class HistoryDataController { |
| | | |
| | | private final TbBasicDataService tbBasicDataService; |
| | | private final TbScoreService tbScoreService; |
| | | private final TbQuestionService tbQuestionService; |
| | | |
| | | /** |
| | | * 历史数据分页查询 |
| | |
| | | Date startTime = dto.getStartTime(); |
| | | Date endTime = dto.getEndTime(); |
| | | boolean flag = Objects.nonNull(startTime) && Objects.nonNull(endTime); |
| | | Page<TbBasicData> page = tbBasicDataService.lambdaQuery() |
| | | .eq(TbBasicData::getStatus, ReportingStatusEnum.FILLED) |
| | | .between(flag, TbBasicData::getCreateTime, startTime, endTime) |
| | | .groupBy(TbBasicData::getQuarter) |
| | | .orderByDesc(TbBasicData::getCreateTime) |
| | | .page(new Page<>(dto.getPageNum(), dto.getPageSize())); |
| | | Page<TbBasicData> page = |
| | | tbBasicDataService |
| | | .lambdaQuery() |
| | | .eq(TbBasicData::getStatus, ReportingStatusEnum.FILLED) |
| | | .between(flag, TbBasicData::getCreateTime, startTime, endTime) |
| | | .groupBy(TbBasicData::getQuarter) |
| | | .orderByDesc(TbBasicData::getCreateTime) |
| | | .page(new Page<>(dto.getPageNum(), dto.getPageSize())); |
| | | return R.ok(PageDTO.of(page, BasicDataVO.class)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation(value = "字段统计", notes = "字段统计") |
| | | @PostMapping("/fields-statics") |
| | | public R<PageDTO<CurrentFieldsVO>> historyFieldsStatics(@Validated({HistoryGroup.class}) @RequestBody CurrentFieldsQuery dto) { |
| | | public R<PageDTO<CurrentFieldsVO>> historyFieldsStatics( |
| | | @Validated({HistoryGroup.class}) @RequestBody CurrentFieldsQuery dto) { |
| | | try { |
| | | return tbBasicDataService.historyFieldsStatics(dto); |
| | | } catch (Exception e) { |
| | |
| | | */ |
| | | @GetMapping("/fields-details") |
| | | @ApiOperation(value = "查看详情", notes = "字段统计") |
| | | @ApiImplicitParam(name = "id", value = "基础数据id", required = true, dataType = "int", paramType = "query", dataTypeClass = Long.class) |
| | | @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); |
| | |
| | | */ |
| | | @GetMapping("/fields-statics-all") |
| | | @ApiOperation(value = "查看全部", notes = "字段统计") |
| | | @ApiImplicitParam(name = "quarter", value = "季度", required = true, dataType = "string", paramType = "query", dataTypeClass = String.class) |
| | | @ApiImplicitParam( |
| | | name = "quarter", |
| | | value = "季度", |
| | | required = true, |
| | | dataType = "string", |
| | | paramType = "query", |
| | | dataTypeClass = String.class) |
| | | public R<CurrentFieldsAllVO> fieldsStaticsAll(@RequestParam("quarter") String quarter) { |
| | | try { |
| | | return R.ok(tbBasicDataService.fieldsStaticsAll(quarter)); |
| | |
| | | */ |
| | | @PostMapping("/score-calculate") |
| | | @ApiOperation("得分计算") |
| | | public R<PageDTO<ScoreCalculateVO>> scoreCalculate(@Validated({HistoryGroup.class}) @RequestBody ScoreCalculateQuery query) { |
| | | public R<PageDTO<ScoreCalculateVO>> scoreCalculate( |
| | | @Validated({HistoryGroup.class}) @RequestBody ScoreCalculateQuery query) { |
| | | return R.ok(tbBasicDataService.scoreCalculatePage(query)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PostMapping("/score-calculate-detail") |
| | | @ApiOperation("得分计算-查看详情") |
| | | public R<ScoreCalculateDetailVO> scoreCalculateDetail(@Validated @RequestBody ScoreCalculateDetailQuery query) { |
| | | public R<ScoreCalculateDetailVO> scoreCalculateDetail( |
| | | @Validated @RequestBody ScoreCalculateDetailQuery query) { |
| | | return R.ok(tbScoreService.scoreCalculateDetail(query)); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询问题 |
| | | * |
| | | * @param dto 发现问题分页数据传输对象 |
| | | * @return R<PageDTO < QuestionVO>> |
| | | */ |
| | | @PostMapping("/page-question") |
| | | @ApiOperation(value = "问题查看-分页查询问题", notes = "问题查看") |
| | | public R<PageDTO<QuestionVO>> pageQuestion( |
| | | @Validated({HistoryGroup.class}) @RequestBody QuestionQuery dto) { |
| | | return R.ok(tbQuestionService.pageQuestion(dto)); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @ApiOperation("导入历史数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "file", paramType = "form"), |
| | | @ApiImplicitParam(name = "quarter", value = "季度 e.g. 2024年一季度", required = true, dataType = "string", paramType = "query", dataTypeClass = String.class) |
| | | }) |
| | | public R<Void> importData(@RequestPart("file") MultipartFile file, |
| | | @RequestParam("quarter") String quarter) { |
| | | try { |
| | | tbBasicDataService.importData(file, quarter); |
| | | } catch (Exception e) { |
| | | if (e instanceof ServiceException) { |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | log.error("导入历史数据异常", e); |
| | | return R.fail(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/export") |
| | | @ApiOperation("导出") |
| | | @ApiImplicitParam(name = "quarterList", value = "quarterList", allowMultiple = true, dataTypeClass = List.class, paramType = "query") |
| | | public void exportData(@RequestParam("quarterList") List<String> quarterList) { |
| | | try { |
| | | tbBasicDataService.exportData(quarterList); |
| | | } catch (Exception e) { |
| | | log.error("导出历史数据异常", e); |
| | | } |
| | | } |
| | | } |