Bläddra i källkod

健康度模拟分数

wukai 9 månader sedan
förälder
incheckning
a5f073e601

+ 28 - 33
jjt-biz/src/main/java/com/jjt/hl/controller/HlClassScoreController.java

@@ -1,28 +1,21 @@
 package com.jjt.hl.controller;
 
-import java.util.List;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-
-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.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.jjt.common.annotation.Log;
 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.poi.ExcelUtil;
 import com.jjt.hl.domain.HlClassScore;
 import com.jjt.hl.service.IHlClassScoreService;
-import com.jjt.common.utils.poi.ExcelUtil;
-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.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 模型健康度分类得分Controller
@@ -30,22 +23,29 @@ import com.jjt.common.core.page.TableDataInfo;
  * @author jjt
  * @date 2024-09-05
  */
-@Api(tags="模型健康度分类得分")
+@Api(tags = "模型健康度分类得分")
 @RestController
 @RequestMapping("/hl/hcs")
-public class HlClassScoreController extends BaseController
-{
+public class HlClassScoreController extends BaseController {
     @Resource
     private IHlClassScoreService hlClassScoreService;
 
     /**
      * 查询模型健康度分类得分列表
      */
+    @ApiOperation("根据分数ID查询详细")
+    @GetMapping("/list/{hlScoreId}")
+    public AjaxResult list4score(@PathVariable("hlScoreId") Long hlScoreId) {
+        HlClassScore hlClassScore = new HlClassScore();
+        hlClassScore.setHlScoreId(hlScoreId);
+        List<HlClassScore> list = hlClassScoreService.selectHlClassScoreList(hlClassScore);
+        return AjaxResult.success(list);
+    }
+
     @ApiOperation("查询模型健康度分类得分列表")
     @PreAuthorize("@ss.hasPermi('hl:hcs:list')")
     @GetMapping("/list")
-    public TableDataInfo list(HlClassScore hlClassScore)
-    {
+    public TableDataInfo list(HlClassScore hlClassScore) {
         startPage();
         List<HlClassScore> list = hlClassScoreService.selectHlClassScoreList(hlClassScore);
         return getDataTable(list);
@@ -58,8 +58,7 @@ public class HlClassScoreController extends BaseController
     @PreAuthorize("@ss.hasPermi('hl:hcs:export')")
     @Log(title = "模型健康度分类得分", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, HlClassScore hlClassScore)
-    {
+    public void export(HttpServletResponse response, HlClassScore hlClassScore) {
         List<HlClassScore> list = hlClassScoreService.selectHlClassScoreList(hlClassScore);
         ExcelUtil<HlClassScore> util = new ExcelUtil<HlClassScore>(HlClassScore.class);
         util.exportExcel(response, list, "模型健康度分类得分数据");
@@ -71,8 +70,7 @@ public class HlClassScoreController extends BaseController
     @ApiOperation("获取模型健康度分类得分详细信息")
     @PreAuthorize("@ss.hasPermi('hl:hcs:query')")
     @GetMapping(value = "/{scoreClassId}")
-    public AjaxResult getInfo(@PathVariable("scoreClassId") Long scoreClassId)
-    {
+    public AjaxResult getInfo(@PathVariable("scoreClassId") Long scoreClassId) {
         return success(hlClassScoreService.selectHlClassScoreByScoreClassId(scoreClassId));
     }
 
@@ -83,8 +81,7 @@ public class HlClassScoreController extends BaseController
     @PreAuthorize("@ss.hasPermi('hl:hcs:add')")
     @Log(title = "模型健康度分类得分", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody HlClassScore hlClassScore)
-    {
+    public AjaxResult add(@RequestBody HlClassScore hlClassScore) {
         return toAjax(hlClassScoreService.insertHlClassScore(hlClassScore));
     }
 
@@ -95,8 +92,7 @@ public class HlClassScoreController extends BaseController
     @PreAuthorize("@ss.hasPermi('hl:hcs:edit')")
     @Log(title = "模型健康度分类得分", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody HlClassScore hlClassScore)
-    {
+    public AjaxResult edit(@RequestBody HlClassScore hlClassScore) {
         return toAjax(hlClassScoreService.updateHlClassScore(hlClassScore));
     }
 
@@ -106,9 +102,8 @@ public class HlClassScoreController extends BaseController
     @ApiOperation("删除模型健康度分类得分")
     @PreAuthorize("@ss.hasPermi('hl:hcs:remove')")
     @Log(title = "模型健康度分类得分", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{scoreClassIds}")
-    public AjaxResult remove(@PathVariable Long[] scoreClassIds)
-    {
+    @DeleteMapping("/{scoreClassIds}")
+    public AjaxResult remove(@PathVariable Long[] scoreClassIds) {
         return toAjax(hlClassScoreService.deleteHlClassScoreByScoreClassIds(scoreClassIds));
     }
 }

+ 2 - 2
jjt-biz/src/main/java/com/jjt/hl/controller/HlMetricsController.java

@@ -44,12 +44,12 @@ public class HlMetricsController extends BaseController {
         HlMetrics hlMetrics = new HlMetrics();
         hlMetrics.setHlClassId(hlClassId);
         List<HlMetrics> list = hlMetricsService.selectHlMetricsList(hlMetrics);
-        if ("1".equals(hlClass.getScoreType())) {
+        if (list.size() > 0 && "1".equals(hlClass.getScoreType())) {
             //均分
             int size = list.size();
             BigDecimal total = hlClass.getHlScore();
             int avg = total.divide(BigDecimal.valueOf(size), 0, RoundingMode.HALF_DOWN).intValue();
-            int one = avg * size == total.intValue() ? avg : total.intValue() - avg * size;
+            int one = avg * size == total.intValue() ? avg : total.intValue() - avg * (size-1);
             boolean flag = true;
             for (HlMetrics hm : list) {
                 if (flag) {

+ 31 - 33
jjt-biz/src/main/java/com/jjt/hl/controller/HlMetricsScoreController.java

@@ -1,28 +1,21 @@
 package com.jjt.hl.controller;
 
-import java.util.List;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-
-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.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.jjt.common.annotation.Log;
 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.poi.ExcelUtil;
 import com.jjt.hl.domain.HlMetricsScore;
 import com.jjt.hl.service.IHlMetricsScoreService;
-import com.jjt.common.utils.poi.ExcelUtil;
-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.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 业务模型健康度指标得分Controller
@@ -30,22 +23,32 @@ import com.jjt.common.core.page.TableDataInfo;
  * @author jjt
  * @date 2024-09-05
  */
-@Api(tags="业务模型健康度指标得分")
+@Api(tags = "业务模型健康度指标得分")
 @RestController
 @RequestMapping("/hl/hms")
-public class HlMetricsScoreController extends BaseController
-{
+public class HlMetricsScoreController extends BaseController {
     @Resource
     private IHlMetricsScoreService hlMetricsScoreService;
 
     /**
+     * 查询模型健康度分类得分列表
+     */
+    @ApiOperation("根据分类ID查询详细")
+    @GetMapping("/list/{scoreClassId}")
+    public AjaxResult list4score(@PathVariable("scoreClassId") Long scoreClassId) {
+        HlMetricsScore hlMetricsScore = new HlMetricsScore();
+        hlMetricsScore.setScoreClassId(scoreClassId);
+        List<HlMetricsScore> list = hlMetricsScoreService.selectHlMetricsScoreList(hlMetricsScore);
+        return AjaxResult.success(list);
+    }
+
+    /**
      * 查询业务模型健康度指标得分列表
      */
     @ApiOperation("查询业务模型健康度指标得分列表")
     @PreAuthorize("@ss.hasPermi('hl:hms:list')")
     @GetMapping("/list")
-    public TableDataInfo list(HlMetricsScore hlMetricsScore)
-    {
+    public TableDataInfo list(HlMetricsScore hlMetricsScore) {
         startPage();
         List<HlMetricsScore> list = hlMetricsScoreService.selectHlMetricsScoreList(hlMetricsScore);
         return getDataTable(list);
@@ -58,8 +61,7 @@ public class HlMetricsScoreController extends BaseController
     @PreAuthorize("@ss.hasPermi('hl:hms:export')")
     @Log(title = "业务模型健康度指标得分", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, HlMetricsScore hlMetricsScore)
-    {
+    public void export(HttpServletResponse response, HlMetricsScore hlMetricsScore) {
         List<HlMetricsScore> list = hlMetricsScoreService.selectHlMetricsScoreList(hlMetricsScore);
         ExcelUtil<HlMetricsScore> util = new ExcelUtil<HlMetricsScore>(HlMetricsScore.class);
         util.exportExcel(response, list, "业务模型健康度指标得分数据");
@@ -71,8 +73,7 @@ public class HlMetricsScoreController extends BaseController
     @ApiOperation("获取业务模型健康度指标得分详细信息")
     @PreAuthorize("@ss.hasPermi('hl:hms:query')")
     @GetMapping(value = "/{scoreMetricsId}")
-    public AjaxResult getInfo(@PathVariable("scoreMetricsId") Long scoreMetricsId)
-    {
+    public AjaxResult getInfo(@PathVariable("scoreMetricsId") Long scoreMetricsId) {
         return success(hlMetricsScoreService.selectHlMetricsScoreByScoreMetricsId(scoreMetricsId));
     }
 
@@ -83,8 +84,7 @@ public class HlMetricsScoreController extends BaseController
     @PreAuthorize("@ss.hasPermi('hl:hms:add')")
     @Log(title = "业务模型健康度指标得分", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody HlMetricsScore hlMetricsScore)
-    {
+    public AjaxResult add(@RequestBody HlMetricsScore hlMetricsScore) {
         return toAjax(hlMetricsScoreService.insertHlMetricsScore(hlMetricsScore));
     }
 
@@ -95,8 +95,7 @@ public class HlMetricsScoreController extends BaseController
     @PreAuthorize("@ss.hasPermi('hl:hms:edit')")
     @Log(title = "业务模型健康度指标得分", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody HlMetricsScore hlMetricsScore)
-    {
+    public AjaxResult edit(@RequestBody HlMetricsScore hlMetricsScore) {
         return toAjax(hlMetricsScoreService.updateHlMetricsScore(hlMetricsScore));
     }
 
@@ -106,9 +105,8 @@ public class HlMetricsScoreController extends BaseController
     @ApiOperation("删除业务模型健康度指标得分")
     @PreAuthorize("@ss.hasPermi('hl:hms:remove')")
     @Log(title = "业务模型健康度指标得分", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{scoreMetricsIds}")
-    public AjaxResult remove(@PathVariable Long[] scoreMetricsIds)
-    {
+    @DeleteMapping("/{scoreMetricsIds}")
+    public AjaxResult remove(@PathVariable Long[] scoreMetricsIds) {
         return toAjax(hlMetricsScoreService.deleteHlMetricsScoreByScoreMetricsIds(scoreMetricsIds));
     }
 }

+ 266 - 12
jjt-biz/src/main/java/com/jjt/hl/service/impl/HlScoreServiceImpl.java

@@ -1,5 +1,6 @@
 package com.jjt.hl.service.impl;
 
+import com.googlecode.aviator.AviatorEvaluator;
 import com.jjt.biz.domain.BizModel;
 import com.jjt.biz.service.IBizModelDetailService;
 import com.jjt.biz.service.IBizModelService;
@@ -8,13 +9,17 @@ import com.jjt.common.utils.bean.BeanUtils;
 import com.jjt.hl.domain.*;
 import com.jjt.hl.mapper.HlScoreMapper;
 import com.jjt.hl.service.*;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.Random;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * 健康度分数记录Service业务层处理
@@ -42,6 +47,8 @@ public class HlScoreServiceImpl implements IHlScoreService {
     private IHlMetricsScoreService hlMetricsScoreService;
     @Resource
     private IHlMetricsScoreDetailService hlMetricsScoreDetailService;
+    @Resource
+    private JdbcTemplate jdbcTemplate;
 
 
     /**
@@ -132,6 +139,7 @@ public class HlScoreServiceImpl implements IHlScoreService {
             score.setHlDate(curr);
             score.setHlType("1");
             insertHlScore(score);
+            BigDecimal totalLose = BigDecimal.ZERO;
             List<HlClass> classList = modelService.selectHlClassList4modelId(model.getModelId());
             for (HlClass hlClass : classList) {
                 HlClassScore hlClassScore = new HlClassScore();
@@ -139,28 +147,44 @@ public class HlScoreServiceImpl implements IHlScoreService {
                 hlClassScore.setHlScoreId(score.getHlScoreId());
                 List<HlObj> hlObjList = hlObjService.selectHlObjListByClassId(hlClass.getHlClassId());
                 hlClassScoreService.insertHlClassScore(hlClassScore);
-                List<HlMetrics> hlMetricsList = hlMetricsService.selectHlMetricsList4ModelId(hlClassScore.getModelId(), hlClass.getObjType());
+                HlMetrics hm = new HlMetrics();
+                hm.setHlClassId(hlClass.getHlClassId());
+                List<HlMetrics> hlMetricsList = hlMetricsService.selectHlMetricsList(hm);
                 BigDecimal loseScore = BigDecimal.ZERO;
                 //1.均分 2.细项分
-                hlClass.getScoreType();
+//                hlClass.getScoreType();
                 for (HlMetrics hlMetrics : hlMetricsList) {
                     //TODO ..这里需要从对象指标表里面去找。
 //                    BizObjMetrics
 //                    BizObjMetricsData
-                    BigDecimal lose = BigDecimal.ZERO;
+                    BigDecimal ss = random(hlMetrics.getHlScore().intValue());
+                    BigDecimal lose = hlMetrics.getHlScore().multiply(ss);
+                    loseScore = loseScore.add(lose);
                     HlMetricsScore metricsScore = new HlMetricsScore();
                     BeanUtils.copyBeanProp(metricsScore, hlMetrics);
-                    if (flag()) {
-                        //TODO 模拟扣分判断
-                        if ("1".equals(hlClassScore.getScoreType())) {
-                            //均分
-//                            Random
-                        } else {
-                            //细项分
-                        }
-                    }
+                    metricsScore.setLoseScore(lose);
+                    metricsScore.setScore(ss);
+                    metricsScore.setScoreClassId(hlClassScore.getScoreClassId());
+                    hlMetricsScoreService.insertHlMetricsScore(metricsScore);
+//                    if (flag()) {
+//                        //TODO 模拟扣分判断
+//                        if ("1".equals(hlClassScore.getScoreType())) {
+//                            //均分
+////                            Random
+//                        } else {
+//                            //细项分
+//                        }
+//                    }
                 }
+                hlClassScore.setLoseScore(loseScore);
+                totalLose = totalLose.add(loseScore);
+                BigDecimal df = hlClassScore.getHlScore().multiply(loseScore);
+                hlClassScore.setScore(df);
+                hlClassScoreService.updateHlClassScore(hlClassScore);
             }
+
+            score.setHlScore(BigDecimal.valueOf(100).multiply(totalLose));
+            updateHlScore(score);
         }
     }
 
@@ -182,4 +206,234 @@ public class HlScoreServiceImpl implements IHlScoreService {
         int x = r.nextInt(8889) + 1;
         return x % 2 == 1;
     }
+
+
+    /**
+     * 根据模型ID删除健康度数据
+     *
+     * @param modelId 模型ID
+     */
+//    @Override
+    public void deleteHlBase4ModelId(Long modelId) {
+        if (modelId == -1) {
+            return;
+        }
+        try {
+            // 开始事务
+            jdbcTemplate.execute("BEGIN");
+
+            // 执行删除语句
+            jdbcTemplate.update("DELETE FROM hl_detail WHERE HL_OBJ_ID IN (SELECT HL_OBJ_ID FROM hl_obj WHERE CLASS_ID IN (SELECT CLASS_ID FROM hl_class WHERE hl_base_id IN (SELECT hl_base_id FROM hl_base WHERE model_id = ?)))", modelId);
+            jdbcTemplate.update("DELETE FROM hl_obj WHERE CLASS_ID IN (SELECT CLASS_ID FROM hl_class WHERE hl_base_id IN (SELECT hl_base_id FROM hl_base WHERE model_id = ?))", modelId);
+            jdbcTemplate.update("DELETE FROM hl_class WHERE hl_base_id IN (SELECT hl_base_id FROM hl_base WHERE model_id = ?)", modelId);
+            jdbcTemplate.update("DELETE FROM hl_base WHERE model_id = ?", modelId);
+
+            // 提交事务
+            jdbcTemplate.execute("COMMIT");
+        } catch (Exception e) {
+            // 回滚事务
+            jdbcTemplate.execute("ROLLBACK");
+            throw new RuntimeException(e);
+        }
+    }
+
+//    /**
+//     * 健康度评分
+//     */
+//    @Override
+//    public void score() {
+//        Map<String, String> expMap = relaService.selectHlMetricsRelaList(new HlMetricsRela()).stream()
+//                .collect(Collectors.toMap(HlMetricsRela::getHlCode, HlMetricsRela::getExp));
+//        Map<String, Long> defMap = defService.selectMetricsDefList(new MetricsDef()).stream().collect(Collectors.toMap(MetricsDef::getMetricsCode, MetricsDef::getMetricsId));
+//
+//        List<HlBase> list = selectHlBaseList(new HlBase());
+//        list.forEach(base -> {
+//            if (base.getModelId() != -1) {
+//                Map<Long, List<BizObjMetrics>> metricsGroup = modelService.selectBizModelMetricsList(base.getModelId()).stream().collect(Collectors.groupingBy(BizObjMetrics::getMetricsId));
+//                HlScore score = new HlScore();
+//                score.setModelId(base.getModelId());
+//                scoreService.insertHlScore(score);
+//                List<HlClass> classes = base.getHlClassList();
+//                AtomicReference<BigDecimal> total = new AtomicReference<>(new BigDecimal(0));
+//                classes.forEach(cs -> {
+//                    HlScoreDetail csDetail = new HlScoreDetail();
+//                    csDetail.setHlScoreId(score.getHlScoreId());
+//                    csDetail.setHlType("CLASS");
+//                    csDetail.setHlCode(cs.getClassCode());
+//                    List<HlObj> objs = cs.getHlObjList();
+//                    AtomicReference<BigDecimal> scc = new AtomicReference<>(new BigDecimal(0));
+//                    objs.forEach(ob -> {
+//                        List<HlDetail> details = ob.getHlDetailList();
+//                        HlScoreDetail obDetail = new HlScoreDetail();
+//                        obDetail.setHlScoreId(score.getHlScoreId());
+//                        obDetail.setHlType("OBJ");
+//                        obDetail.setHlCode(ob.getHlObjCode());
+//                        AtomicReference<BigDecimal> sc = new AtomicReference<>(new BigDecimal(0));
+//                        if ("LINK".equals(ob.getHlObjCode())) {
+//                            details.forEach(d -> {
+//                                HlScoreDetail scoreDetail = new HlScoreDetail();
+//                                scoreDetail.setHlScoreId(score.getHlScoreId());
+//                                scoreDetail.setHlType("DETAIL");
+//                                scoreDetail.setHlCode(d.getHlDetailCode());
+//                                String hlCode = d.getHlDetailCode();
+//                                String exp = expMap.get(hlCode);
+//                                BigDecimal standScore = new BigDecimal(d.getHlDetailScore());
+//                                switch (hlCode) {
+//                                    case "C01":
+//                                    case "C02":
+//                                    case "C03":
+//                                        if (StringUtils.isNotEmpty(exp)) {
+//                                            Matcher matcher = match(exp);
+//                                            Map<String, List<BizObjMetrics>> originalMap = new HashMap<>();
+//                                            //先拿到一个code,好获取组件数量
+//                                            String oneCode = "";
+//                                            while (matcher.find()) {
+//                                                String code = matcher.group(1);
+//                                                String old = String.format("${%s}", code);
+//                                                String newCode = code.replace(".", "");
+//                                                oneCode = newCode;
+//                                                exp = exp.replace(old, newCode);
+//
+//                                                Long mid = defMap.get(code);
+//                                                List<BizObjMetrics> omList = metricsGroup.get(mid);
+//                                                originalMap.put(newCode, omList);
+//                                            }
+//                                            // 获取组件数量
+//                                            int size = originalMap.get(oneCode).size();
+//                                            int alarmSize = 0;
+//                                            // 遍历列表并创建新的 Map
+//                                            for (int i = 0; i < size; i++) {
+//                                                Map<String, Object> singleEntryMap = new HashMap<>();
+//                                                for (String s : originalMap.keySet()) {
+//                                                    singleEntryMap.put(s, originalMap.get(s).get(i).getDValue().floatValue());
+//                                                }
+//
+//                                                boolean flag = evaluator(exp, singleEntryMap);
+//                                                if (flag) {
+//                                                    alarmSize++;
+//                                                }
+//                                            }
+//                                            //最终得分(告警组件数量/总数量 )*细项分
+//                                            BigDecimal df = standScore.subtract(BigDecimal.valueOf(alarmSize).divide(BigDecimal.valueOf(size)).multiply(standScore));
+//                                            scoreDetail.setHlScore(df);
+//                                            scoreDetailService.insertHlScoreDetail(scoreDetail);
+//                                        }
+//                                        break;
+//                                    default:
+//                                        break;
+//                                }
+//                            });
+//                        } else {
+//                            sc.set(random(ob.getHlObjScore()));
+//                        }
+//                        obDetail.setHlScore(sc.get());
+//                        scoreDetailService.insertHlScoreDetail(obDetail);
+//                        scc.set(scc.get().add(obDetail.getHlScore()));
+//                    });
+//                    csDetail.setHlScore(scc.get());
+//                    scoreDetailService.insertHlScoreDetail(csDetail);
+//                    total.set(total.get().add(csDetail.getHlScore()));
+//                });
+//                score.setHlScore(total.get());
+//                scoreService.updateHlScore(score);
+//            }
+//        });
+//    }
+//
+//    /**
+//     * 昨日健康度评分
+//     */
+//    @Override
+//    public void yesterday() {
+//        LocalDate localDate = LocalDate.now().minusDays(1);
+//        List<HlBase> list = selectHlBaseList(new HlBase());
+//
+//        list.forEach(base -> {
+//            if (base.getModelId() != -1) {
+//                HlDay hlDay = new HlDay();
+//                hlDay.setModelId(base.getModelId());
+//                hlDay.setHlDate(Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+//                dayService.insertHlDay(hlDay);
+//                List<HlClass> classes = base.getHlClassList();
+//                AtomicReference<BigDecimal> total = new AtomicReference<>(new BigDecimal(0));
+//                classes.forEach(cs -> {
+//                    HlDayDetail csDetail = new HlDayDetail();
+//                    csDetail.setDayId(hlDay.getDayId());
+//                    csDetail.setHlType("CLASS");
+//                    csDetail.setHlCode(cs.getClassCode());
+//                    List<HlObj> objs = cs.getHlObjList();
+//                    AtomicReference<BigDecimal> scc = new AtomicReference<>(new BigDecimal(0));
+//                    objs.forEach(ob -> {
+//                        List<HlDetail> details = ob.getHlDetailList();
+//                        HlDayDetail obDetail = new HlDayDetail();
+//                        obDetail.setDayId(hlDay.getDayId());
+//                        obDetail.setHlType("OBJ");
+//                        obDetail.setHlCode(ob.getHlObjCode());
+//                        AtomicReference<BigDecimal> sc = new AtomicReference<>(new BigDecimal(0));
+//                        if ("LINK".equals(ob.getHlObjCode())) {
+//                            details.forEach(d -> {
+//                                HlDayDetail scoreDetail = new HlDayDetail();
+//                                scoreDetail.setDayId(hlDay.getDayId());
+//                                scoreDetail.setHlType("DETAIL");
+//                                scoreDetail.setHlCode(d.getHlDetailCode());
+//                                switch (d.getHlDetailCode()) {
+//                                    case "C01":
+//                                    case "C02":
+//                                    case "C03":
+//                                        BigDecimal dc = random(d.getHlDetailScore());
+//                                        scoreDetail.setHlScore(dc);
+//                                        sc.set(sc.get().add(dc));
+//                                        dayDetailService.insertHlDayDetail(scoreDetail);
+//                                        break;
+//                                    default:
+//                                        break;
+//                                }
+//                            });
+//                        } else {
+//                            sc.set(random(ob.getHlObjScore()));
+//                        }
+//                        obDetail.setHlScore(sc.get());
+//                        dayDetailService.insertHlDayDetail(obDetail);
+//                        scc.set(scc.get().add(obDetail.getHlScore()));
+//                    });
+//                    csDetail.setHlScore(scc.get());
+//                    dayDetailService.insertHlDayDetail(csDetail);
+//                    total.set(total.get().add(csDetail.getHlScore()));
+//                });
+//                hlDay.setHlScore(total.get());
+//                dayService.updateHlDay(hlDay);
+//            }
+//        });
+//    }
+
+    private BigDecimal random(int s) {
+        Random random = new Random();
+        int randomNumber = random.nextInt(s);
+//        // 生01到3的随机数
+//        int v = s.intValue() - randomNumber;
+        return BigDecimal.valueOf(randomNumber);
+    }
+
+    /**
+     * 公式计算
+     *
+     * @param exp 表达式
+     * @param env 值
+     * @return 结果
+     */
+    private boolean evaluator(String exp, Map<String, Object> env) {
+        return (boolean) AviatorEvaluator.execute(exp, env);
+    }
+
+    /**
+     * 正则匹配
+     *
+     * @param exp 表达式
+     * @return 结果
+     */
+    private Matcher match(String exp) {
+        //正则表达式匹配变量
+        Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}");
+        return pattern.matcher(exp);
+    }
 }