| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.system.dto.BasicDataDTO; |
| | | import com.ruoyi.system.query.ScoreQuery; |
| | | import com.ruoyi.system.service.TbBasicDataService; |
| | | import com.ruoyi.system.service.TbFieldService; |
| | | import com.ruoyi.system.vo.BasicDataReportingVO; |
| | | import com.ruoyi.system.vo.ScoreVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.RequestPart; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/current-quarter") |
| | | @RequestMapping("/current-quarter-dept") |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "当前季度数据相关接口") |
| | | public class CurrentQuarterController { |
| | | |
| | | private final TbBasicDataService tbBasicDataService; |
| | | private final TbFieldService tbFieldService; |
| | | |
| | | /** |
| | | * 获取基础数据填报相关信息 |
| | | * |
| | | * @return R<BasicDataReportingVO> |
| | | */ |
| | | @ApiOperation("获取基础数据填报相关信息") |
| | | public R<BasicDataReportingVO> getBasicFields(@RequestParam("deptAreaCode") String deptAreaCode) { |
| | | //TODO 如果能够获取到当前登录用户,则不需要传区划代码 |
| | | @GetMapping("/basic-fields") |
| | | public R<BasicDataReportingVO> getBasicFields() { |
| | | try { |
| | | return tbBasicDataService.getBasicFields(deptAreaCode); |
| | | return tbBasicDataService.getBasicFields(); |
| | | } catch (Exception e) { |
| | | if (e instanceof ServiceException) { |
| | | return R.fail(e.getMessage()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存当前季度数据 |
| | | * |
| | | * @param dto 当前季度基础数据数据传输对象 |
| | | * @return R<Void> |
| | | */ |
| | | @PostMapping("/save-basic-data") |
| | | @ApiOperation("保存当前季度数据") |
| | | public R<Void> saveBasicData(@RequestBody BasicDataDTO dto) { |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 导入模板下载 |
| | | */ |
| | |
| | | @ApiOperation("模板下载") |
| | | public void downloadImportTemplate() { |
| | | try { |
| | | tbBasicDataService.downloadImportTemplate(); |
| | | tbFieldService.downloadImportTemplate(); |
| | | } catch (Exception e) { |
| | | log.error("模板下载异常",e); |
| | | log.error("模板下载异常", e); |
| | | throw new ServiceException("模板下载失败,请联系管理员!"); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("import") |
| | | /** |
| | | * 基础数据导入 |
| | | * |
| | | * @param file file |
| | | * @return R<Void> |
| | | */ |
| | | @PostMapping("/import") |
| | | @ApiOperation("基础数据导入") |
| | | public R<Void> importBasicData(@RequestPart("file") MultipartFile file) { |
| | | try { |
| | |
| | | if (e instanceof ServiceException) { |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | log.error("基础数据导入异常",e); |
| | | throw new ServiceException("基础数据导入失败,请联系管理员!"); |
| | | log.error("基础数据导入异常", e); |
| | | return R.fail("基础数据导入失败,请联系管理员!"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 得分计算分页查询 |
| | | * |
| | | * @param query 得分计算条件查询对象 |
| | | * @return R<PageDTO < ScoreVO>> |
| | | */ |
| | | @PostMapping("/page-score") |
| | | @ApiOperation("得分计算分页查询") |
| | | public R<PageDTO<ScoreVO>> pageScore(@Validated @RequestBody ScoreQuery query) { |
| | | try { |
| | | return R.ok(tbBasicDataService.pageScore(query)); |
| | | } catch (Exception e) { |
| | | if (e instanceof ServiceException) { |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | log.error("查询得分计算异常", e); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | } |