Bladeren bron

健康度得分使用真实数据

wukai 10 maanden geleden
bovenliggende
commit
f709fc6912

+ 90 - 29
jjt-biz/src/main/java/com/jjt/biz/controller/BizModelController.java

@@ -10,9 +10,11 @@ import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.AjaxResult;
 import com.jjt.common.core.page.TableDataInfo;
 import com.jjt.common.enums.BusinessType;
+import com.jjt.common.utils.DateUtils;
 import com.jjt.common.utils.poi.ExcelUtil;
 import com.jjt.hl.domain.HlClass;
-import com.jjt.hl.service.IHlClassService;
+import com.jjt.hl.domain.HlScore;
+import com.jjt.hl.service.IHlScoreService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -23,7 +25,9 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 业务模型Controller
@@ -38,7 +42,7 @@ public class BizModelController extends BaseController {
     @Resource
     private IBizModelService bizModelService;
     @Resource
-    private IHlClassService classService;
+    private IHlScoreService hlScoreService;
 
     @ApiOperation("选择对象")
     @GetMapping("/obj/select/{modelId}")
@@ -65,28 +69,57 @@ public class BizModelController extends BaseController {
     @GetMapping("/time/history")
     public List<ScoreVO> timeHistory() {
         List<ScoreVO> result = new ArrayList<>();
-        String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"};
-        for (int i = 0; i < names.length; i++) {
+        LocalDateTime endTime = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
+        LocalDateTime beginTime = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0).minusHours(24);
+        HlScore search = new HlScore();
+        search.setHlType("1");
+        Map<String, Object> params = new HashMap<>(16);
+        params.put("beginTime", beginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+        params.put("endTime", endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+        search.setParams(params);
+
+        List<HlScore> list = hlScoreService.selectHlScoreList(search);
+        Map<Long, List<HlScore>> resultMap = list.stream().collect(Collectors.groupingBy(HlScore::getModelId));
+        for (Long modelId : resultMap.keySet()) {
             ScoreVO vo = new ScoreVO();
-            List<LocalDateTime> times = new ArrayList<>();
+            BizModel model = bizModelService.selectBizModelByModelId(modelId);
+            vo.setModelId(modelId);
+            vo.setModelName(model.getModelName());
             List<String> xData = new ArrayList<>();
             List<Float> scores = new ArrayList<>();
-            LocalDateTime time = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0).minusHours(23);
-            for (int j = 0; j < 24; j++) {
-                time = time.plusHours(1);
-                times.add(time);
-                xData.add(time.getHour() + "");
-                Float score = Float.valueOf(new Random().nextInt(50) + 50);
-                scores.add(score);
-            }
-
-            vo.setModelId((long) (i + 1));
-            vo.setModelName(names[i]);
-            vo.setTimes(times);
+            List<HlScore> scoreList = resultMap.get(modelId);
+            scoreList = scoreList.stream().sorted(Comparator.comparing(HlScore::getHlDate)).collect(Collectors.toList());
+            scoreList.forEach(hs -> {
+                xData.add(DateUtils.parseDateToStr("HH:mm", hs.getHlDate()));
+                scores.add(hs.getHlScore().floatValue());
+            });
             vo.setScores(scores);
             vo.setXData(xData);
             result.add(vo);
         }
+
+//        String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"};
+//        for (int i = 0; i < names.length; i++) {
+//            ScoreVO vo = new ScoreVO();
+//            List<LocalDateTime> times = new ArrayList<>();
+//            List<String> xData = new ArrayList<>();
+//            List<Float> scores = new ArrayList<>();
+//            LocalDateTime time = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0).minusHours(23);
+//            for (int j = 0; j < 24; j++) {
+//                time = time.plusHours(1);
+//                times.add(time);
+//                xData.add(time.getHour() + "");
+//                Float score = Float.valueOf(new Random().nextInt(50) + 50);
+//                scores.add(score);
+//            }
+//
+//            vo.setModelId((long) (i + 1));
+//            vo.setModelName(names[i]);
+//            vo.setTimes(times);
+//            vo.setScores(scores);
+//            vo.setXData(xData);
+//            result.add(vo);
+//        }
         return result;
     }
 
@@ -94,25 +127,53 @@ public class BizModelController extends BaseController {
     @GetMapping("/day/history")
     public List<ScoreVO> dayHistory() {
         List<ScoreVO> result = new ArrayList<>();
-        String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"};
-        for (int i = 0; i < names.length; i++) {
+        LocalDate endTime = LocalDate.now();
+        LocalDate beginTime = endTime.minusDays(8);
+        HlScore search = new HlScore();
+        search.setHlType("2");
+        Map<String, Object> params = new HashMap<>(16);
+        params.put("beginTime", beginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+        params.put("endTime", endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+        search.setParams(params);
+
+        List<HlScore> list = hlScoreService.selectHlScoreList(search);
+        Map<Long, List<HlScore>> resultMap = list.stream().collect(Collectors.groupingBy(HlScore::getModelId));
+        for (Long modelId : resultMap.keySet()) {
             ScoreVO vo = new ScoreVO();
+            BizModel model = bizModelService.selectBizModelByModelId(modelId);
+            vo.setModelId(modelId);
+            vo.setModelName(model.getModelName());
             List<String> xData = new ArrayList<>();
             List<Float> 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]);
+            List<HlScore> scoreList = resultMap.get(modelId);
+            scoreList = scoreList.stream().sorted(Comparator.comparing(HlScore::getHlDate)).collect(Collectors.toList());
+            scoreList.forEach(hs -> {
+                xData.add(DateUtils.parseDateToStr("MM-dd", hs.getHlDate()));
+                scores.add(hs.getHlScore().floatValue());
+            });
             vo.setScores(scores);
             vo.setXData(xData);
             result.add(vo);
         }
+//        String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"};
+//        for (int i = 0; i < names.length; i++) {
+//            ScoreVO vo = new ScoreVO();
+//            List<String> xData = new ArrayList<>();
+//            List<Float> 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;
     }
 //

+ 3 - 0
jjt-biz/src/main/resources/mapper/hl/HlScoreMapper.xml

@@ -61,6 +61,9 @@
             <if test="remark != null  and remark != ''">
                 and REMARK = #{remark}
             </if>
+            <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
+                and hl_date between #{params.beginTime} and #{params.endTime}
+            </if>
         </where>
         order by hl_date desc
     </select>