PatentController.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. package cn.cslg.pas.controller;
  2. import cn.cslg.pas.common.core.annotation.Permission;
  3. import cn.cslg.pas.common.core.base.Constants;
  4. import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
  5. import cn.cslg.pas.domain.Patent;
  6. import cn.cslg.pas.common.model.vo.*;
  7. import cn.cslg.pas.common.utils.JsonUtils;
  8. import cn.cslg.pas.common.utils.Response;
  9. import cn.cslg.pas.common.utils.ResponseEnum;
  10. import cn.cslg.pas.common.utils.StringUtils;
  11. import cn.cslg.pas.service.*;
  12. import cn.cslg.pas.common.utils.CacheUtils;
  13. import cn.dev33.satoken.stp.StpUtil;
  14. import io.swagger.v3.oas.annotations.Operation;
  15. import io.swagger.v3.oas.annotations.tags.Tag;
  16. import lombok.RequiredArgsConstructor;
  17. import org.springframework.context.annotation.Lazy;
  18. import org.springframework.web.bind.annotation.*;
  19. import java.util.Collections;
  20. import java.util.List;
  21. /**
  22. * <p>
  23. * 专利 前端控制器
  24. * </p>
  25. *
  26. * @author 王岩
  27. * @since 2021-12-24
  28. */
  29. @Tag(name = "专利")
  30. @RestController
  31. @RequestMapping(Constants.API_VERSION_V2 + "/patent")
  32. @RequiredArgsConstructor(onConstructor_ = {@Lazy})
  33. public class PatentController {
  34. private final PatentService patentService;
  35. private final PatentFieldService patentFieldService;
  36. private final ProjectPatentLinkService projectPatentLinkService;
  37. private final ProjectFieldService projectFieldService;
  38. private final TaskService taskService;
  39. private final CacheUtils cacheUtils;
  40. private final ProjectFieldPatentLinkService projectFieldPatentLinkService;
  41. private final LoginUtils loginUtils;
  42. @GetMapping("/read/total")
  43. @Operation(summary = "专利阅读状态统计")
  44. public String getPatentReadTotal(PatentReadVO params) {
  45. return Response.success(projectPatentLinkService.getPatentReadTotal(params));
  46. }
  47. @Permission(roles = {1, 2})
  48. @PostMapping("/read/update")
  49. @Operation(summary = "修改专利阅读状态")
  50. public String updatePatentReadStatus(@RequestBody PatentReadVO params) {
  51. return Response.success(projectPatentLinkService.updatePatentReadStatus(params));
  52. }
  53. @PostMapping("list")
  54. @Operation(summary = "专利列表")
  55. public String getList(@RequestBody PatentVO params) {
  56. return Response.success(patentService.getPageList(params));
  57. }
  58. @GetMapping("{id}")
  59. @Operation(summary = "根据ID获取专利")
  60. public String getPatentById(@PathVariable Integer id, Integer projectId) {
  61. return Response.success(patentService.getPatentDTOById(id, projectId));
  62. }
  63. @GetMapping("id")
  64. @Operation(summary = "根据专利号获取专利ID")
  65. public String getPatentIdByPatentNo(String patentNo) {
  66. Patent patent = patentService.getByPatentNo(patentNo);
  67. return Response.success(patent == null ? 0 : patent.getId());
  68. }
  69. @PostMapping("ids")
  70. @Operation(summary = "根据范围获取专利ID")
  71. public String getPatentListIds(@RequestBody PatentVO params) {
  72. return Response.success(patentService.getPatentListIds(params));
  73. }
  74. @PostMapping("export")
  75. @Operation(summary = "导出专利")
  76. public String export(@RequestBody PatentExportParams params) {
  77. String id = cacheUtils.getSelectPatentIds(params.getKey());
  78. List<Integer> ids;
  79. if (StringUtils.isEmpty(id) && params.getPatentId() == null) {
  80. return Response.error(ResponseEnum.QUERY_CACHE_ERROR);
  81. }
  82. if (StringUtils.isNotEmpty(params.getKey())) {
  83. ids = StringUtils.changeStringToInteger(id, ",");
  84. } else {
  85. ids = Collections.singletonList(params.getPatentId());
  86. }
  87. Integer taskId = taskService.add2(params.getProjectId(), params.getSelected().stream().filter(PatentExportVO::getSelected).distinct().count(), ids.size());
  88. TaskParams taskParams = new TaskParams();
  89. taskParams.setTaskId(taskId);
  90. taskParams.setTaskType(2);
  91. taskParams.setIds(StringUtils.join(ids, ","));
  92. taskParams.setProjectId(params.getProjectId());
  93. taskParams.setSelected(JsonUtils.objectToJson(params.getSelected()));
  94. taskParams.setUserId(String.valueOf(loginUtils.getId()));
  95. patentService.exportPatent(taskParams);
  96. return Response.success(true);
  97. }
  98. @PostMapping("/query/source")
  99. @Operation(summary = "查看字段的统计数据")
  100. public String getPatentQuerySourcePageList(@RequestBody PatentQueryFieldSourceVO params) {
  101. return Response.success(patentService.getPatentQuerySourcePageList(params));
  102. }
  103. @PostMapping("/save/select")
  104. @Operation(summary = "保存选择的专利")
  105. public String saveSelectPatentIds(@RequestBody PatentVO params) {
  106. List<Integer> ids = patentService.getQueryPatentIds(params);
  107. return Response.success(cacheUtils.setSelectPatentIds(ids));
  108. }
  109. @Permission(roles = {1, 2})
  110. @PostMapping("/batch/index")
  111. @Operation(summary = "批量批量专利标引")
  112. public String patentBatchIndex(@RequestBody PatentBatchIndexVO params) {
  113. projectFieldPatentLinkService.patentBatchIndex(params);
  114. return Response.success(true);
  115. }
  116. @GetMapping("/index/setting")
  117. @Operation(summary = "获取专利标引情况")
  118. public String getPatentIndexSetting(PatentIndexSettingVO params) {
  119. return Response.success(projectFieldPatentLinkService.getPatentIndexSetting(params));
  120. }
  121. @GetMapping("/index/setting/all")
  122. @Operation(summary = "获取当前专利所有标引情况")
  123. public String getPatentIndexSetting2(Integer patentId, Integer projectId) {
  124. return Response.success(projectFieldPatentLinkService.getPatentIndexSetting2(patentId, projectId));
  125. }
  126. @Permission(roles = {1, 2})
  127. @PostMapping("/index/setting")
  128. @Operation(summary = "修改专利标引")
  129. public String updatePatentIndexSetting(@RequestBody PatentIndexSettingVO params) {
  130. projectFieldPatentLinkService.updatePatentIndexSetting(params);
  131. return Response.success(true);
  132. }
  133. @PostMapping("between")
  134. @Operation(summary = "获取当前专利相邻的两篇专利和统计信息")
  135. public String getBetweenPatentList(@RequestBody PatentVO params) {
  136. return Response.success(patentService.getBetweenPatentList(params));
  137. }
  138. }