DistillationController.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package com.ips.system.controller;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.fasterxml.jackson.core.JsonProcessingException;
  5. import com.ips.common.utils.StringUtils;
  6. import org.springframework.security.access.prepost.PreAuthorize;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.PutMapping;
  11. import org.springframework.web.bind.annotation.DeleteMapping;
  12. import org.springframework.web.bind.annotation.PathVariable;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import com.ips.common.annotation.Log;
  17. import com.ips.common.core.controller.BaseController;
  18. import com.ips.common.core.domain.AjaxResult;
  19. import com.ips.common.enums.BusinessType;
  20. import com.ips.system.domain.Distillation;
  21. import com.ips.system.service.IDistillationService;
  22. import com.ips.common.utils.poi.ExcelUtil;
  23. import com.ips.common.core.page.TableDataInfo;
  24. /**
  25. * 知识蒸馏Controller
  26. *
  27. * @author Allen
  28. * @date 2025-05-21
  29. */
  30. @RestController
  31. @RequestMapping("/biz/distillation")
  32. public class DistillationController extends BaseController
  33. {
  34. @Autowired
  35. private IDistillationService distillationService;
  36. /**
  37. * 查询知识蒸馏列表
  38. */
  39. @PreAuthorize("@ss.hasPermi('biz:distillation:list')")
  40. @GetMapping("/list")
  41. public TableDataInfo list(Distillation distillation)
  42. {
  43. startPage();
  44. List<Distillation> list = distillationService.selectDistillationList(distillation);
  45. return getDataTable(list);
  46. }
  47. /**
  48. * 导出知识蒸馏列表
  49. */
  50. @PreAuthorize("@ss.hasPermi('biz:distillation:export')")
  51. @Log(title = "知识蒸馏", businessType = BusinessType.EXPORT)
  52. @PostMapping("/export")
  53. public void export(HttpServletResponse response, Distillation distillation)
  54. {
  55. List<Distillation> list = distillationService.selectDistillationList(distillation);
  56. ExcelUtil<Distillation> util = new ExcelUtil<Distillation>(Distillation.class);
  57. util.exportExcel(response, list, "知识蒸馏数据");
  58. }
  59. /**
  60. * 获取知识蒸馏详细信息
  61. */
  62. @PreAuthorize("@ss.hasPermi('biz:distillation:query')")
  63. @GetMapping(value = "/{id}")
  64. public AjaxResult getInfo(@PathVariable("id") Long id)
  65. {
  66. return success(distillationService.selectDistillationById(id));
  67. }
  68. /**
  69. * 新增知识蒸馏
  70. */
  71. @PreAuthorize("@ss.hasPermi('biz:distillation:add')")
  72. @Log(title = "知识蒸馏", businessType = BusinessType.INSERT)
  73. @PostMapping
  74. public AjaxResult add(@RequestBody Distillation distillation)
  75. {
  76. return toAjax(distillationService.insertDistillation(distillation));
  77. }
  78. /**
  79. * 修改知识蒸馏
  80. */
  81. @PreAuthorize("@ss.hasPermi('biz:distillation:edit')")
  82. @Log(title = "知识蒸馏", businessType = BusinessType.UPDATE)
  83. @PutMapping
  84. public AjaxResult edit(@RequestBody Distillation distillation)
  85. {
  86. return toAjax(distillationService.updateDistillation(distillation));
  87. }
  88. /**
  89. * 删除知识蒸馏
  90. */
  91. @PreAuthorize("@ss.hasPermi('biz:distillation:remove')")
  92. @Log(title = "知识蒸馏", businessType = BusinessType.DELETE)
  93. @DeleteMapping("/{ids}")
  94. public AjaxResult remove(@PathVariable Long[] ids)
  95. {
  96. return toAjax(distillationService.deleteDistillationByIds(ids));
  97. }
  98. /**
  99. * 运行算法模型
  100. * @param id
  101. * @return
  102. * @throws JsonProcessingException
  103. */
  104. @PreAuthorize("@ss.hasPermi('biz:distillation:add')")
  105. @GetMapping(value = "/run/{id}")
  106. public AjaxResult run(@PathVariable("id") Long id) throws JsonProcessingException {
  107. String errorMsg = distillationService.run(id);
  108. if(StringUtils.isEmpty(errorMsg)){
  109. return success(errorMsg);
  110. } else {
  111. return error(errorMsg);
  112. }
  113. }
  114. /**
  115. * 获取结果详情
  116. * @param id
  117. * @return
  118. * @throws JsonProcessingException
  119. */
  120. @PreAuthorize("@ss.hasPermi('biz:distillation:add')")
  121. @GetMapping(value = "/getResultDetails/{id}")
  122. public AjaxResult getResultDetails(@PathVariable("id") Long id) throws JsonProcessingException {
  123. Distillation obj = distillationService.getResultDetails(id);
  124. if(obj != null){
  125. return success(obj);
  126. } else {
  127. return error("获取详情失败");
  128. }
  129. }
  130. @PreAuthorize("@ss.hasPermi('biz:distillation:add')")
  131. @GetMapping(value = "/getTaskStatusIsChanged/{id}")
  132. public AjaxResult getTaskStatusIsChanged(@PathVariable("id") Long id){
  133. return success(distillationService.getTaskStatusIsChanged(id));
  134. }
  135. }