package com.jjt.biz.controller; import com.jjt.biz.domain.HlBase; import com.jjt.biz.domain.HlDay; import com.jjt.biz.domain.HlDayDetail; import com.jjt.biz.service.IHlBaseService; import com.jjt.biz.service.IHlDayDetailService; import com.jjt.biz.service.IHlDayService; import com.jjt.biz.vo.ScoreVO; import com.jjt.common.core.controller.BaseController; import com.jjt.common.core.domain.AjaxResult; import com.jjt.common.core.page.TableDataInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Random; import java.util.stream.Collectors; /** * 日健康度记录Controller * * @author jjt * @date 2024-08-29 */ @Api(tags = "日健康度记录") @RestController @RequestMapping("/hl/hlDay") public class HlDayController extends BaseController { @Resource private IHlDayService hlDayService; @Resource private IHlDayDetailService dayDetailService; @Resource private IHlBaseService baseService; @ApiOperation("历史健康度得分情况") @GetMapping("/history") public List history() { List result = new ArrayList<>(); String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"}; for (int i = 0; i < names.length; i++) { ScoreVO vo = new ScoreVO(); List xData = new ArrayList<>(); List scores = new ArrayList<>(); LocalDate time = LocalDate.now().minusDays(8); for (int j = 0; j < 7; j++) { time = time.plusDays(1); xData.add(time.getMonthValue() + "-" + time.getDayOfMonth()); Float score = Float.valueOf(new Random().nextInt(50) + 50); scores.add(score); } vo.setModelId((long) (i + 1)); vo.setModelName(names[i]); vo.setScores(scores); vo.setXData(xData); result.add(vo); } return result; } @ApiOperation("根据模型ID查询健康度得分") @GetMapping("/list/{modelId}") public TableDataInfo list(@PathVariable("modelId") Long modelId) { startPage(); HlDay day = new HlDay(); day.setModelId(modelId); List list = hlDayService.selectHlDayList(day); return getDataTable(list); } @ApiOperation("健康度得分明细") @GetMapping(value = "/{dayId}") public AjaxResult getInfo(@PathVariable("dayId") Long dayId) { HlDay day = hlDayService.selectHlDayByDayId(dayId); HlBase base = baseService.selectHlBaseByModelId(day.getModelId()); HlDayDetail query = new HlDayDetail(); query.setDayId(dayId); List detailList = dayDetailService.selectHlDayDetailList(query); Map map = detailList.stream().collect(Collectors.toMap(HlDayDetail::getHlCode, HlDayDetail::getHlScore)); base.getHlClassList().forEach(hlClass -> { if (map.containsKey(hlClass.getClassCode())) { hlClass.setCurrScore(map.get(hlClass.getClassCode()).floatValue()); } hlClass.getHlObjList().forEach(hlObj -> { if (map.containsKey(hlObj.getHlObjCode())) { hlObj.setCurrScore(map.get(hlObj.getHlObjCode()).floatValue()); } hlObj.getHlDetailList().forEach(hlDetail -> { if (map.containsKey(hlDetail.getHlDetailCode())) { hlDetail.setCurrScore(map.get(hlDetail.getHlDetailCode()).floatValue()); } }); }); }); return success(base); } /** * 查询日健康度记录列表 */ @ApiOperation("查询日健康度记录列表") @PreAuthorize("@ss.hasPermi('hl:hlDay:list')") @GetMapping("/list") public TableDataInfo list(HlDay hlDay) { startPage(); List list = hlDayService.selectHlDayList(hlDay); return getDataTable(list); } // // /** // * 导出日健康度记录列表 // */ // @ApiOperation("导出日健康度记录列表") // @PreAuthorize("@ss.hasPermi('hl:hlDay:export')") // @Log(title = "日健康度记录", businessType = BusinessType.EXPORT) // @PostMapping("/export") // public void export(HttpServletResponse response, HlDay hlDay) { // List list = hlDayService.selectHlDayList(hlDay); // ExcelUtil util = new ExcelUtil(HlDay.class); // util.exportExcel(response, list, "日健康度记录数据"); // } // // /** // * 获取日健康度记录详细信息 // */ // @ApiOperation("获取日健康度记录详细信息") // @PreAuthorize("@ss.hasPermi('hl:hlDay:query')") // @GetMapping(value = "/{dayId}") // public AjaxResult getInfo(@PathVariable("dayId") Long dayId) { // return success(hlDayService.selectHlDayByDayId(dayId)); // } // // /** // * 新增日健康度记录 // */ // @ApiOperation("新增日健康度记录") // @PreAuthorize("@ss.hasPermi('hl:hlDay:add')") // @Log(title = "日健康度记录", businessType = BusinessType.INSERT) // @PostMapping // public AjaxResult add(@RequestBody HlDay hlDay) { // return toAjax(hlDayService.insertHlDay(hlDay)); // } // // /** // * 修改日健康度记录 // */ // @ApiOperation("修改日健康度记录") // @PreAuthorize("@ss.hasPermi('hl:hlDay:edit')") // @Log(title = "日健康度记录", businessType = BusinessType.UPDATE) // @PutMapping // public AjaxResult edit(@RequestBody HlDay hlDay) { // return toAjax(hlDayService.updateHlDay(hlDay)); // } // // /** // * 删除日健康度记录 // */ // @ApiOperation("删除日健康度记录") // @PreAuthorize("@ss.hasPermi('hl:hlDay:remove')") // @Log(title = "日健康度记录", businessType = BusinessType.DELETE) // @DeleteMapping("/{dayIds}") // public AjaxResult remove(@PathVariable Long[] dayIds) { // return toAjax(hlDayService.deleteHlDayByDayIds(dayIds)); // } }