HlDayController.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. package com.jjt.biz.controller;
  2. import com.jjt.biz.domain.HlBase;
  3. import com.jjt.biz.domain.HlDay;
  4. import com.jjt.biz.domain.HlDayDetail;
  5. import com.jjt.biz.service.IHlBaseService;
  6. import com.jjt.biz.service.IHlDayDetailService;
  7. import com.jjt.biz.service.IHlDayService;
  8. import com.jjt.common.core.controller.BaseController;
  9. import com.jjt.common.core.domain.AjaxResult;
  10. import com.jjt.common.core.page.TableDataInfo;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import org.springframework.security.access.prepost.PreAuthorize;
  14. import org.springframework.web.bind.annotation.GetMapping;
  15. import org.springframework.web.bind.annotation.PathVariable;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import javax.annotation.Resource;
  19. import java.math.BigDecimal;
  20. import java.util.List;
  21. import java.util.Map;
  22. import java.util.stream.Collectors;
  23. /**
  24. * 日健康度记录Controller
  25. *
  26. * @author jjt
  27. * @date 2024-08-29
  28. */
  29. @Api(tags = "日健康度记录")
  30. @RestController
  31. @RequestMapping("/hl/hlDay")
  32. public class HlDayController extends BaseController {
  33. @Resource
  34. private IHlDayService hlDayService;
  35. @Resource
  36. private IHlDayDetailService dayDetailService;
  37. @Resource
  38. private IHlBaseService baseService;
  39. @ApiOperation("根据模型ID查询健康度得分")
  40. @GetMapping("/list/{modelId}")
  41. public TableDataInfo list(@PathVariable("modelId") Long modelId) {
  42. startPage();
  43. HlDay day = new HlDay();
  44. day.setModelId(modelId);
  45. List<HlDay> list = hlDayService.selectHlDayList(day);
  46. return getDataTable(list);
  47. }
  48. @ApiOperation("健康度得分明细")
  49. @GetMapping(value = "/{dayId}")
  50. public AjaxResult getInfo(@PathVariable("dayId") Long dayId) {
  51. HlDay day = hlDayService.selectHlDayByDayId(dayId);
  52. HlBase base = baseService.selectHlBaseByModelId(day.getModelId());
  53. HlDayDetail query = new HlDayDetail();
  54. query.setDayId(dayId);
  55. List<HlDayDetail> detailList = dayDetailService.selectHlDayDetailList(query);
  56. Map<String, BigDecimal> map = detailList.stream().collect(Collectors.toMap(HlDayDetail::getHlCode, HlDayDetail::getHlScore));
  57. base.getHlClassList().forEach(hlClass -> {
  58. if (map.containsKey(hlClass.getClassCode())) {
  59. hlClass.setCurrScore(map.get(hlClass.getClassCode()).floatValue());
  60. }
  61. hlClass.getHlObjList().forEach(hlObj -> {
  62. if (map.containsKey(hlObj.getHlObjCode())) {
  63. hlObj.setCurrScore(map.get(hlObj.getHlObjCode()).floatValue());
  64. }
  65. hlObj.getHlDetailList().forEach(hlDetail -> {
  66. if (map.containsKey(hlDetail.getHlDetailCode())) {
  67. hlDetail.setCurrScore(map.get(hlDetail.getHlDetailCode()).floatValue());
  68. }
  69. });
  70. });
  71. });
  72. return success(base);
  73. }
  74. /**
  75. * 查询日健康度记录列表
  76. */
  77. @ApiOperation("查询日健康度记录列表")
  78. @PreAuthorize("@ss.hasPermi('hl:hlDay:list')")
  79. @GetMapping("/list")
  80. public TableDataInfo list(HlDay hlDay) {
  81. startPage();
  82. List<HlDay> list = hlDayService.selectHlDayList(hlDay);
  83. return getDataTable(list);
  84. }
  85. //
  86. // /**
  87. // * 导出日健康度记录列表
  88. // */
  89. // @ApiOperation("导出日健康度记录列表")
  90. // @PreAuthorize("@ss.hasPermi('hl:hlDay:export')")
  91. // @Log(title = "日健康度记录", businessType = BusinessType.EXPORT)
  92. // @PostMapping("/export")
  93. // public void export(HttpServletResponse response, HlDay hlDay) {
  94. // List<HlDay> list = hlDayService.selectHlDayList(hlDay);
  95. // ExcelUtil<HlDay> util = new ExcelUtil<HlDay>(HlDay.class);
  96. // util.exportExcel(response, list, "日健康度记录数据");
  97. // }
  98. //
  99. // /**
  100. // * 获取日健康度记录详细信息
  101. // */
  102. // @ApiOperation("获取日健康度记录详细信息")
  103. // @PreAuthorize("@ss.hasPermi('hl:hlDay:query')")
  104. // @GetMapping(value = "/{dayId}")
  105. // public AjaxResult getInfo(@PathVariable("dayId") Long dayId) {
  106. // return success(hlDayService.selectHlDayByDayId(dayId));
  107. // }
  108. //
  109. // /**
  110. // * 新增日健康度记录
  111. // */
  112. // @ApiOperation("新增日健康度记录")
  113. // @PreAuthorize("@ss.hasPermi('hl:hlDay:add')")
  114. // @Log(title = "日健康度记录", businessType = BusinessType.INSERT)
  115. // @PostMapping
  116. // public AjaxResult add(@RequestBody HlDay hlDay) {
  117. // return toAjax(hlDayService.insertHlDay(hlDay));
  118. // }
  119. //
  120. // /**
  121. // * 修改日健康度记录
  122. // */
  123. // @ApiOperation("修改日健康度记录")
  124. // @PreAuthorize("@ss.hasPermi('hl:hlDay:edit')")
  125. // @Log(title = "日健康度记录", businessType = BusinessType.UPDATE)
  126. // @PutMapping
  127. // public AjaxResult edit(@RequestBody HlDay hlDay) {
  128. // return toAjax(hlDayService.updateHlDay(hlDay));
  129. // }
  130. //
  131. // /**
  132. // * 删除日健康度记录
  133. // */
  134. // @ApiOperation("删除日健康度记录")
  135. // @PreAuthorize("@ss.hasPermi('hl:hlDay:remove')")
  136. // @Log(title = "日健康度记录", businessType = BusinessType.DELETE)
  137. // @DeleteMapping("/{dayIds}")
  138. // public AjaxResult remove(@PathVariable Long[] dayIds) {
  139. // return toAjax(hlDayService.deleteHlDayByDayIds(dayIds));
  140. // }
  141. }