HlDayController.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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.biz.vo.ScoreVO;
  9. import com.jjt.common.core.controller.BaseController;
  10. import com.jjt.common.core.domain.AjaxResult;
  11. import com.jjt.common.core.page.TableDataInfo;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import org.springframework.security.access.prepost.PreAuthorize;
  15. import org.springframework.web.bind.annotation.GetMapping;
  16. import org.springframework.web.bind.annotation.PathVariable;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import javax.annotation.Resource;
  20. import java.math.BigDecimal;
  21. import java.time.LocalDate;
  22. import java.util.ArrayList;
  23. import java.util.List;
  24. import java.util.Map;
  25. import java.util.Random;
  26. import java.util.stream.Collectors;
  27. /**
  28. * 日健康度记录Controller
  29. *
  30. * @author jjt
  31. * @date 2024-08-29
  32. */
  33. @Api(tags = "日健康度记录")
  34. @RestController
  35. @RequestMapping("/hl/hlDay")
  36. public class HlDayController extends BaseController {
  37. @Resource
  38. private IHlDayService hlDayService;
  39. @Resource
  40. private IHlDayDetailService dayDetailService;
  41. @Resource
  42. private IHlBaseService baseService;
  43. @ApiOperation("历史健康度得分情况")
  44. @GetMapping("/history")
  45. public List<ScoreVO> history() {
  46. List<ScoreVO> result = new ArrayList<>();
  47. String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"};
  48. for (int i = 0; i < names.length; i++) {
  49. ScoreVO vo = new ScoreVO();
  50. List<String> xData = new ArrayList<>();
  51. List<Float> scores = new ArrayList<>();
  52. LocalDate time = LocalDate.now().minusDays(8);
  53. for (int j = 0; j < 7; j++) {
  54. time = time.plusDays(1);
  55. xData.add(time.getMonthValue() + "-" + time.getDayOfMonth());
  56. Float score = Float.valueOf(new Random().nextInt(50) + 50);
  57. scores.add(score);
  58. }
  59. vo.setModelId((long) (i + 1));
  60. vo.setModelName(names[i]);
  61. vo.setScores(scores);
  62. vo.setXData(xData);
  63. result.add(vo);
  64. }
  65. return result;
  66. }
  67. @ApiOperation("根据模型ID查询健康度得分")
  68. @GetMapping("/list/{modelId}")
  69. public TableDataInfo list(@PathVariable("modelId") Long modelId) {
  70. startPage();
  71. HlDay day = new HlDay();
  72. day.setModelId(modelId);
  73. List<HlDay> list = hlDayService.selectHlDayList(day);
  74. return getDataTable(list);
  75. }
  76. @ApiOperation("健康度得分明细")
  77. @GetMapping(value = "/{dayId}")
  78. public AjaxResult getInfo(@PathVariable("dayId") Long dayId) {
  79. HlDay day = hlDayService.selectHlDayByDayId(dayId);
  80. HlBase base = baseService.selectHlBaseByModelId(day.getModelId());
  81. HlDayDetail query = new HlDayDetail();
  82. query.setDayId(dayId);
  83. List<HlDayDetail> detailList = dayDetailService.selectHlDayDetailList(query);
  84. Map<String, BigDecimal> map = detailList.stream().collect(Collectors.toMap(HlDayDetail::getHlCode, HlDayDetail::getHlScore));
  85. base.getHlClassList().forEach(hlClass -> {
  86. if (map.containsKey(hlClass.getClassCode())) {
  87. hlClass.setCurrScore(map.get(hlClass.getClassCode()).floatValue());
  88. }
  89. hlClass.getHlObjList().forEach(hlObj -> {
  90. if (map.containsKey(hlObj.getHlObjCode())) {
  91. hlObj.setCurrScore(map.get(hlObj.getHlObjCode()).floatValue());
  92. }
  93. hlObj.getHlDetailList().forEach(hlDetail -> {
  94. if (map.containsKey(hlDetail.getHlDetailCode())) {
  95. hlDetail.setCurrScore(map.get(hlDetail.getHlDetailCode()).floatValue());
  96. }
  97. });
  98. });
  99. });
  100. return success(base);
  101. }
  102. /**
  103. * 查询日健康度记录列表
  104. */
  105. @ApiOperation("查询日健康度记录列表")
  106. @PreAuthorize("@ss.hasPermi('hl:hlDay:list')")
  107. @GetMapping("/list")
  108. public TableDataInfo list(HlDay hlDay) {
  109. startPage();
  110. List<HlDay> list = hlDayService.selectHlDayList(hlDay);
  111. return getDataTable(list);
  112. }
  113. //
  114. // /**
  115. // * 导出日健康度记录列表
  116. // */
  117. // @ApiOperation("导出日健康度记录列表")
  118. // @PreAuthorize("@ss.hasPermi('hl:hlDay:export')")
  119. // @Log(title = "日健康度记录", businessType = BusinessType.EXPORT)
  120. // @PostMapping("/export")
  121. // public void export(HttpServletResponse response, HlDay hlDay) {
  122. // List<HlDay> list = hlDayService.selectHlDayList(hlDay);
  123. // ExcelUtil<HlDay> util = new ExcelUtil<HlDay>(HlDay.class);
  124. // util.exportExcel(response, list, "日健康度记录数据");
  125. // }
  126. //
  127. // /**
  128. // * 获取日健康度记录详细信息
  129. // */
  130. // @ApiOperation("获取日健康度记录详细信息")
  131. // @PreAuthorize("@ss.hasPermi('hl:hlDay:query')")
  132. // @GetMapping(value = "/{dayId}")
  133. // public AjaxResult getInfo(@PathVariable("dayId") Long dayId) {
  134. // return success(hlDayService.selectHlDayByDayId(dayId));
  135. // }
  136. //
  137. // /**
  138. // * 新增日健康度记录
  139. // */
  140. // @ApiOperation("新增日健康度记录")
  141. // @PreAuthorize("@ss.hasPermi('hl:hlDay:add')")
  142. // @Log(title = "日健康度记录", businessType = BusinessType.INSERT)
  143. // @PostMapping
  144. // public AjaxResult add(@RequestBody HlDay hlDay) {
  145. // return toAjax(hlDayService.insertHlDay(hlDay));
  146. // }
  147. //
  148. // /**
  149. // * 修改日健康度记录
  150. // */
  151. // @ApiOperation("修改日健康度记录")
  152. // @PreAuthorize("@ss.hasPermi('hl:hlDay:edit')")
  153. // @Log(title = "日健康度记录", businessType = BusinessType.UPDATE)
  154. // @PutMapping
  155. // public AjaxResult edit(@RequestBody HlDay hlDay) {
  156. // return toAjax(hlDayService.updateHlDay(hlDay));
  157. // }
  158. //
  159. // /**
  160. // * 删除日健康度记录
  161. // */
  162. // @ApiOperation("删除日健康度记录")
  163. // @PreAuthorize("@ss.hasPermi('hl:hlDay:remove')")
  164. // @Log(title = "日健康度记录", businessType = BusinessType.DELETE)
  165. // @DeleteMapping("/{dayIds}")
  166. // public AjaxResult remove(@PathVariable Long[] dayIds) {
  167. // return toAjax(hlDayService.deleteHlDayByDayIds(dayIds));
  168. // }
  169. }