|
@@ -0,0 +1,207 @@
|
|
|
|
|
+package com.aijiuyi.admin.common.config;
|
|
|
|
|
+
|
|
|
|
|
+import com.aijiuyi.admin.entity.Plan;
|
|
|
|
|
+import com.aijiuyi.admin.entity.PlanStep;
|
|
|
|
|
+import com.aijiuyi.admin.mapper.PlanMapper;
|
|
|
|
|
+import com.aijiuyi.admin.mapper.PlanStepMapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.boot.CommandLineRunner;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 启动时确保系统内置方案存在。
|
|
|
|
|
+ */
|
|
|
|
|
+@Component
|
|
|
|
|
+public class PlanDataInitializer implements CommandLineRunner {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PlanMapper planMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PlanStepMapper planStepMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run(String... args) {
|
|
|
|
|
+ List<PlanSeed> seeds = buildSeeds();
|
|
|
|
|
+ for (PlanSeed seed : seeds) {
|
|
|
|
|
+ Plan plan = planMapper.selectOne(new LambdaQueryWrapper<Plan>()
|
|
|
|
|
+ .eq(Plan::getPlanCode, seed.planCode)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (plan == null) {
|
|
|
|
|
+ plan = new Plan();
|
|
|
|
|
+ plan.setPlanCode(seed.planCode);
|
|
|
|
|
+ plan.setApplicableGender(0);
|
|
|
|
|
+ plan.setAgeMin(1);
|
|
|
|
|
+ plan.setAgeMax(120);
|
|
|
|
|
+ plan.setAuthorType(1);
|
|
|
|
|
+ plan.setAuthorName("ADMIN");
|
|
|
|
|
+ plan.setStatus(1);
|
|
|
|
|
+ plan.setUseCount(0);
|
|
|
|
|
+ fillPlan(plan, seed);
|
|
|
|
|
+ planMapper.insert(plan);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fillPlan(plan, seed);
|
|
|
|
|
+ planMapper.updateById(plan);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ planStepMapper.delete(new LambdaUpdateWrapper<PlanStep>()
|
|
|
|
|
+ .eq(PlanStep::getPlanId, plan.getId()));
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < seed.steps.size(); i++) {
|
|
|
|
|
+ StepSeed stepSeed = seed.steps.get(i);
|
|
|
|
|
+ PlanStep step = new PlanStep();
|
|
|
|
|
+ step.setPlanId(plan.getId());
|
|
|
|
|
+ step.setStepOrder(i + 1);
|
|
|
|
|
+ step.setAcupointId(stepSeed.acupointId);
|
|
|
|
|
+ step.setAcupointName(stepSeed.acupointName);
|
|
|
|
|
+ step.setSide(stepSeed.side);
|
|
|
|
|
+ step.setTemperature(stepSeed.temperature);
|
|
|
|
|
+ step.setDuration(stepSeed.duration);
|
|
|
|
|
+ step.setTechniqueId(stepSeed.techniqueId);
|
|
|
|
|
+ step.setTechniqueName(stepSeed.techniqueName);
|
|
|
|
|
+ step.setRemark(stepSeed.remark);
|
|
|
|
|
+ planStepMapper.insert(step);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void fillPlan(Plan plan, PlanSeed seed) {
|
|
|
|
|
+ plan.setName(seed.name);
|
|
|
|
|
+ plan.setModeType(seed.modeType);
|
|
|
|
|
+ plan.setEffectType(seed.effectType);
|
|
|
|
|
+ plan.setSymptoms(seed.symptoms);
|
|
|
|
|
+ plan.setDescription(seed.description);
|
|
|
|
|
+ plan.setAuthorType(1);
|
|
|
|
|
+ plan.setAuthorName("ADMIN");
|
|
|
|
|
+ plan.setStatus(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<PlanSeed> buildSeeds() {
|
|
|
|
|
+ List<PlanSeed> seeds = new ArrayList<>();
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S001", "一键艾灸(默认)", 1, null, "日常调理,疲劳,手脚冰凉", "系统默认一键艾灸方案,覆盖基础督脉与膀胱经调理。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(1L, "大椎穴", 1, 42.0, 6, 2L, "温和灸", "默认基准穴位"),
|
|
|
|
|
+ new StepSeed(2L, "风门穴", 4, 43.0, 6, 2L, "温和灸", "双侧温养"),
|
|
|
|
|
+ new StepSeed(3L, "肺俞穴", 4, 43.0, 6, 2L, "温和灸", "提升背部暖感"),
|
|
|
|
|
+ new StepSeed(8L, "肾俞穴", 4, 44.0, 6, 2L, "温和灸", "补益下焦"),
|
|
|
|
|
+ new StepSeed(9L, "命门穴", 1, 45.0, 6, 2L, "温和灸", "固本收尾")
|
|
|
|
|
+ )));
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S002", "专业驱寒方案", 2, "驱寒", "怕冷,手脚冰凉,畏寒", "针对阳虚畏寒人群的基础驱寒方案。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(1L, "大椎穴", 1, 44.0, 8, 3L, "雀啄灸", "驱寒起始"),
|
|
|
|
|
+ new StepSeed(2L, "风门穴", 4, 44.0, 8, 3L, "雀啄灸", "祛寒散表"),
|
|
|
|
|
+ new StepSeed(8L, "肾俞穴", 4, 45.0, 8, 2L, "温和灸", "温补肾阳"),
|
|
|
|
|
+ new StepSeed(9L, "命门穴", 1, 45.0, 8, 2L, "温和灸", "扶阳收尾")
|
|
|
|
|
+ )));
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S003", "专业祛湿方案", 2, "祛湿", "困倦,湿重,食欲差", "围绕脾胃与膀胱经调理的祛湿方案。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(6L, "脾俞穴", 4, 43.0, 8, 2L, "温和灸", "健脾化湿"),
|
|
|
|
|
+ new StepSeed(7L, "胃俞穴", 4, 43.0, 8, 2L, "温和灸", "和胃助运化"),
|
|
|
|
|
+ new StepSeed(10L, "中脘穴", 1, 42.0, 8, 4L, "回旋灸", "中焦祛湿"),
|
|
|
|
|
+ new StepSeed(11L, "气海穴", 1, 42.0, 6, 2L, "温和灸", "益气固本")
|
|
|
|
|
+ )));
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S004", "专业祛风方案", 2, "祛风", "感冒,怕风,鼻塞", "针对风寒风邪引发不适的基础调理方案。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(1L, "大椎穴", 1, 42.0, 7, 2L, "温和灸", "祛风首穴"),
|
|
|
|
|
+ new StepSeed(2L, "风门穴", 4, 43.0, 7, 3L, "雀啄灸", "散风解表"),
|
|
|
|
|
+ new StepSeed(3L, "肺俞穴", 4, 42.0, 7, 2L, "温和灸", "协同宣肺"),
|
|
|
|
|
+ new StepSeed(4L, "心俞穴", 4, 42.0, 6, 2L, "温和灸", "安神扶正")
|
|
|
|
|
+ )));
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S005", "专业化瘀方案", 2, "化瘀", "僵硬,酸痛,局部不适", "用于改善局部瘀滞与经络不畅。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(4L, "心俞穴", 4, 43.0, 8, 4L, "回旋灸", "活络起始"),
|
|
|
|
|
+ new StepSeed(5L, "肝俞穴", 4, 44.0, 8, 4L, "回旋灸", "疏肝化瘀"),
|
|
|
|
|
+ new StepSeed(6L, "脾俞穴", 4, 43.0, 6, 2L, "温和灸", "调和中焦"),
|
|
|
|
|
+ new StepSeed(9L, "命门穴", 1, 44.0, 6, 2L, "温和灸", "温阳通络")
|
|
|
|
|
+ )));
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S006", "专业活血方案", 2, "活血", "疲劳,循环差,肩背紧张", "帮助提升背部循环与整体活力。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(3L, "肺俞穴", 4, 42.0, 7, 4L, "回旋灸", "活血舒展"),
|
|
|
|
|
+ new StepSeed(4L, "心俞穴", 4, 43.0, 7, 4L, "回旋灸", "促进循环"),
|
|
|
|
|
+ new StepSeed(5L, "肝俞穴", 4, 43.0, 7, 4L, "回旋灸", "疏通经络"),
|
|
|
|
|
+ new StepSeed(11L, "气海穴", 1, 42.0, 6, 2L, "温和灸", "补气收束")
|
|
|
|
|
+ )));
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S007", "专业化痰方案", 2, "化痰", "咳嗽,痰多,胸闷", "偏肺俞与中焦调理的化痰方案。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(3L, "肺俞穴", 4, 42.0, 8, 2L, "温和灸", "宣肺止咳"),
|
|
|
|
|
+ new StepSeed(2L, "风门穴", 4, 42.0, 8, 2L, "温和灸", "协同宣散"),
|
|
|
|
|
+ new StepSeed(10L, "中脘穴", 1, 41.0, 7, 4L, "回旋灸", "中焦运化"),
|
|
|
|
|
+ new StepSeed(11L, "气海穴", 1, 41.0, 7, 2L, "温和灸", "益气化痰")
|
|
|
|
|
+ )));
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S008", "专业养颜方案", 2, "养颜", "气色差,疲劳,睡眠一般", "通过脾胃与气海关元综合调理气色。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(6L, "脾俞穴", 4, 42.0, 8, 2L, "温和灸", "健脾养颜"),
|
|
|
|
|
+ new StepSeed(7L, "胃俞穴", 4, 42.0, 8, 2L, "温和灸", "和胃生化"),
|
|
|
|
|
+ new StepSeed(11L, "气海穴", 1, 42.0, 7, 4L, "回旋灸", "补气养神"),
|
|
|
|
|
+ new StepSeed(12L, "关元穴", 1, 42.0, 7, 2L, "温和灸", "养元收尾")
|
|
|
|
|
+ )));
|
|
|
|
|
+ seeds.add(new PlanSeed(
|
|
|
|
|
+ "S009", "专业扶阳方案", 2, "扶阳", "乏力,腰酸,手脚冰凉", "以命门肾俞关元为主的扶阳固本方案。",
|
|
|
|
|
+ Arrays.asList(
|
|
|
|
|
+ new StepSeed(8L, "肾俞穴", 4, 44.0, 8, 2L, "温和灸", "补肾扶阳"),
|
|
|
|
|
+ new StepSeed(9L, "命门穴", 1, 45.0, 8, 2L, "温和灸", "培补命门火"),
|
|
|
|
|
+ new StepSeed(11L, "气海穴", 1, 44.0, 7, 2L, "温和灸", "益气助阳"),
|
|
|
|
|
+ new StepSeed(12L, "关元穴", 1, 44.0, 7, 2L, "温和灸", "固本培元")
|
|
|
|
|
+ )));
|
|
|
|
|
+ return seeds;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static class PlanSeed {
|
|
|
|
|
+ private final String planCode;
|
|
|
|
|
+ private final String name;
|
|
|
|
|
+ private final Integer modeType;
|
|
|
|
|
+ private final String effectType;
|
|
|
|
|
+ private final String symptoms;
|
|
|
|
|
+ private final String description;
|
|
|
|
|
+ private final List<StepSeed> steps;
|
|
|
|
|
+
|
|
|
|
|
+ private PlanSeed(String planCode, String name, Integer modeType, String effectType,
|
|
|
|
|
+ String symptoms, String description, List<StepSeed> steps) {
|
|
|
|
|
+ this.planCode = planCode;
|
|
|
|
|
+ this.name = name;
|
|
|
|
|
+ this.modeType = modeType;
|
|
|
|
|
+ this.effectType = effectType;
|
|
|
|
|
+ this.symptoms = symptoms;
|
|
|
|
|
+ this.description = description;
|
|
|
|
|
+ this.steps = steps;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static class StepSeed {
|
|
|
|
|
+ private final Long acupointId;
|
|
|
|
|
+ private final String acupointName;
|
|
|
|
|
+ private final Integer side;
|
|
|
|
|
+ private final BigDecimal temperature;
|
|
|
|
|
+ private final Integer duration;
|
|
|
|
|
+ private final Long techniqueId;
|
|
|
|
|
+ private final String techniqueName;
|
|
|
|
|
+ private final String remark;
|
|
|
|
|
+
|
|
|
|
|
+ private StepSeed(Long acupointId, String acupointName, Integer side, double temperature,
|
|
|
|
|
+ Integer duration, Long techniqueId, String techniqueName, String remark) {
|
|
|
|
|
+ this.acupointId = acupointId;
|
|
|
|
|
+ this.acupointName = acupointName;
|
|
|
|
|
+ this.side = side;
|
|
|
|
|
+ this.temperature = BigDecimal.valueOf(temperature);
|
|
|
|
|
+ this.duration = duration;
|
|
|
|
|
+ this.techniqueId = techniqueId;
|
|
|
|
|
+ this.techniqueName = techniqueName;
|
|
|
|
|
+ this.remark = remark;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|