zhangbin 1 gadu atpakaļ
vecāks
revīzija
5cfd63342f

+ 12 - 3
xpgx-admin/src/main/java/com/miaxis/app/controller/gan/GanZhiController.java

@@ -74,13 +74,21 @@ public class GanZhiController extends BaseController {
         ganZhiDto.setTimeGan(lunar.getTimeGan());
         ganZhiDto.setTimeZhi(lunar.getTimeZhi());
 
-
-        //ganZhiDto = ganZhiService.getDaYun(ganZhiDto); //月柱节气矫正 取出90年大运
+        ganZhiDto = ganZhiService.getDaYun(ganZhiDto); //月柱节气矫正 取出90年大运
+        Map<String, Object> riYuanQrMap = ganZhiService.getRiYuanQr(ganZhiDto);  //查出日元强弱
         List<GanZhiRowVo> ganZhiRowVoList = ganZhiService.selectGanZhiRowVoList(ganZhiDto);
+
+
+        int maxTianGan = ganZhiService.getMaxTianGan(ganZhiDto);  //最出能量最强的天干
+        ganZhiService.getGeJu(ganZhiRowVoList,maxTianGan,riYuanQrMap.get("qr").toString()); //查出八字常见格局
+
+
+
+
+
         Map<String, Integer> fiveCountMap = ganZhiService.getGanZhiRowVoCount(ganZhiDto);
         List<GanZhiNaYinVo> ganZhiNaYinVoList = ganZhiService.selectGanZhiNaYinList(ganZhiDto);
         List<GanZhiKongWangVo> ganZhiKongWangVoList = ganZhiService.selectGanZhiKongWangList(ganZhiDto);
-        Map<String, Object> riYuanQrMap = ganZhiService.getRiYuanQr(ganZhiDto);
         Map<String, Object> numberYunMap = ganZhiService.getNumberYun(riYuanQrMap);
         Map<String, Object> zaoShiCount = ganZhiService.getZaoShiCount(ganZhiDto);
         List<DiseasePart> diseasePartList = ganZhiService.getJiBing(ganZhiDto);
@@ -99,6 +107,7 @@ public class GanZhiController extends BaseController {
         ganZhiVo.setNumberYunMap(numberYunMap);
         ganZhiVo.setZaoShiMap(zaoShiCount);
         ganZhiVo.setDiseasePartList(diseasePartList);
+        ganZhiVo.setDaYunList(ganZhiDto.getDaYunList());
 
         // 输出结果
         return Response.success(ganZhiVo);

+ 27 - 0
xpgx-common/src/main/java/com/miaxis/common/config/ShiShenConfig.java

@@ -859,4 +859,31 @@ public class ShiShenConfig {
         return result;
     }
 
+
+    // 定义一个方法,接收三个参数并返回最大值
+    public static int getMax(int num1, int num2, int num3) {
+        int max = num1;
+        // 比较 num2 和 max
+        if (num2 > max) {
+            max = num2;
+        }
+
+        // 再比较 num3 和 max
+        if (num3 > max) {
+            max = num3;
+        }
+
+        if(max==num1) {
+            return 1;
+        }
+        if(max==num2) {
+            return 2;
+        }
+        if(max==num3) {
+            return 3;
+        }
+        return 0;
+    }
+
+
 }

+ 3 - 0
xpgx-service/src/main/java/com/miaxis/gan/dto/GanZhiDto.java

@@ -56,6 +56,9 @@ public class GanZhiDto {
     @ApiModelProperty(value = "时支",hidden = true)
     private String timeZhi;
 
+    @ApiModelProperty(value = "最强能量的天干",hidden = true)
+    private int maxGan;
+
     @ApiModelProperty(value = "大运",hidden = true)
     private List<Map<String, String>> daYunList;
 

+ 2 - 0
xpgx-service/src/main/java/com/miaxis/gan/service/IGanZhiService.java

@@ -90,5 +90,7 @@ public interface IGanZhiService extends IService<GanZhi>{
     List<Map<String, String>> getLiuNian(LiuNianDto linNianDto);
 
 
+    int getMaxTianGan(GanZhiDto ganZhiDto);
 
+    Map<String,String> getGeJu(List<GanZhiRowVo> list, int maxTianGan, String qr);
 }

+ 153 - 0
xpgx-service/src/main/java/com/miaxis/gan/service/impl/GanZhiServiceImpl.java

@@ -963,4 +963,157 @@ public class GanZhiServiceImpl extends ServiceImpl<GanZhiMapper, GanZhi> impleme
     }
 
 
+    /**
+     * 返回能量最强的天干
+     *
+     * @param ganZhiDto
+     * @return 1 天干  2月干  3时干
+     */
+    @Override
+    public int getMaxTianGan(GanZhiDto ganZhiDto) {
+        /*-------------------能量最强天干---------------------*/
+        List<GanZhiRowVo> list = this.getGanZhiRowVoList(ganZhiDto);
+
+        //年干 得分
+//        int yearGanQR = ShiShenConfig.generateRelationship(list.get(0).getFive(), list.get(0).getFive());
+        int yearZhiQR1 = ShiShenConfig.generateRelationship(list.get(0).getFive(), list.get(1).getFive());
+        int monthGanQR1 = ShiShenConfig.generateRelationship(list.get(0).getFive(), list.get(2).getFive());
+        int monthZhiQR1 = ShiShenConfig.generateRelationship(list.get(0).getFive(), list.get(3).getFive());
+        int dayGanQR1 = ShiShenConfig.generateRelationship(list.get(0).getFive(), list.get(4).getFive());
+        int dayZhiQR1 = ShiShenConfig.generateRelationship(list.get(0).getFive(), list.get(5).getFive());
+        int timeGanQR1 = ShiShenConfig.generateRelationship(list.get(0).getFive(), list.get(6).getFive());
+        int timeZhiQR1 = ShiShenConfig.generateRelationship(list.get(0).getFive(), list.get(7).getFive());
+
+        int yearGanScore = 0;
+        if (yearZhiQR1 > 0) {
+            yearGanScore += 12;
+        }
+        if (monthGanQR1 > 0) {
+            yearGanScore += 12;
+        }
+        if (monthZhiQR1 > 0) {
+            yearGanScore += 40;
+        }
+        if (dayGanQR1 > 0) {
+            yearGanScore += 12;
+        }
+        if (dayZhiQR1 > 0) {
+            yearGanScore += 12;
+        }
+        if (timeGanQR1 > 0) {
+            yearGanScore += 8;
+        }
+        if (timeZhiQR1 > 0) {
+            yearGanScore += 4;
+        }
+
+        /*-------------------能量最强天干---------------------*/
+
+        //月干 得分
+        int yearGanQR2 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(0).getFive());
+        int yearZhiQR2 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(1).getFive());
+//        int monthGanQR2 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(2).getFive());
+        int monthZhiQR2 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(3).getFive());
+        int dayGanQR2 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(4).getFive());
+        int dayZhiQR2 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(5).getFive());
+        int timeGanQR2 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(6).getFive());
+        int timeZhiQR2 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(7).getFive());
+
+        int monthGanScore = 0;
+        if (yearGanQR2 > 0) {
+            monthGanScore += 12;
+        }
+        if (yearZhiQR2 > 0) {
+            monthGanScore += 12;
+        }
+        if (monthZhiQR2 > 0) {
+            monthGanScore += 40;
+        }
+        if (dayGanQR2 > 0) {
+            monthGanScore += 12;
+        }
+        if (dayZhiQR2 > 0) {
+            monthGanScore += 12;
+        }
+        if (timeGanQR2 > 0) {
+            monthGanScore += 8;
+        }
+        if (timeZhiQR2 > 0) {
+            monthGanScore += 4;
+        }
+
+
+        //时干 得分
+        int yearGanQR3 = ShiShenConfig.generateRelationship(list.get(6).getFive(), list.get(0).getFive());
+        int yearZhiQR3 = ShiShenConfig.generateRelationship(list.get(6).getFive(), list.get(1).getFive());
+        int monthGanQR3 = ShiShenConfig.generateRelationship(list.get(2).getFive(), list.get(2).getFive());
+        int monthZhiQR3 = ShiShenConfig.generateRelationship(list.get(6).getFive(), list.get(3).getFive());
+        int dayGanQR3 = ShiShenConfig.generateRelationship(list.get(6).getFive(), list.get(4).getFive());
+        int dayZhiQR3 = ShiShenConfig.generateRelationship(list.get(6).getFive(), list.get(5).getFive());
+        //int timeGanQR3 = ShiShenConfig.generateRelationship(list.get(6).getFive(), list.get(6).getFive());
+        int timeZhiQR3 = ShiShenConfig.generateRelationship(list.get(6).getFive(), list.get(7).getFive());
+
+        int timeGanScore = 0;
+        if (yearGanQR3 > 0) {
+            timeGanScore += 8;
+        }
+        if (yearZhiQR3 > 0) {
+            timeGanScore += 4;
+        }
+        if (monthGanQR3 > 0) {
+            timeGanScore += 40;
+        }
+        if (monthZhiQR3 > 0) {
+            timeGanScore += 12;
+        }
+        if (dayGanQR3 > 0) {
+            timeGanScore += 12;
+        }
+        if (dayZhiQR3 > 0) {
+            timeGanScore += 12;
+        }
+        if (timeZhiQR3 > 0) {
+            timeGanScore += 12;
+        }
+        int maxGan = ShiShenConfig.getMax(yearGanScore, monthGanScore, timeGanScore);
+        ganZhiDto.setMaxGan(maxGan);
+        return maxGan;
+    }
+
+
+    @Override
+    public Map<String,String> getGeJu(List<GanZhiRowVo> list,int maxTianGan, String qr) {
+
+        String yearGan = list.get(0).getShiShen1();
+        String monthGan = list.get(2).getShiShen1();
+        String timeGan = list.get(6).getShiShen1();
+
+
+        if (list.get(3).getShiShen1() != null && yearGan.contains(list.get(3).getShiShen1())) { //月令十神1在 年干透出
+
+        } else if (list.get(3).getShiShen1() != null && monthGan.contains(list.get(3).getShiShen1())) { //月令十神1在 月干透出
+
+        } else if (list.get(3).getShiShen1() != null && timeGan.contains(list.get(3).getShiShen1())) { //月令十神1在 时干透出
+
+        } else if (list.get(3).getShiShen2() != null && yearGan.contains(list.get(3).getShiShen2())) { //月令十神2在 年干透出
+
+        } else if (list.get(3).getShiShen2() != null && monthGan.contains(list.get(3).getShiShen2())) { //月令十神2在 月干透出
+
+        } else if (list.get(3).getShiShen2() != null && timeGan.contains(list.get(3).getShiShen2())) { //月令十神2在 时干透出
+
+        } else if (list.get(3).getShiShen3() != null && yearGan.contains(list.get(3).getShiShen3())) { //月令十神3在 年干透出
+
+        } else if (list.get(3).getShiShen3() != null && monthGan.contains(list.get(3).getShiShen3())) { //月令十神3在 月干透出
+
+        } else if (list.get(3).getShiShen3() != null && timeGan.contains(list.get(3).getShiShen3())) { //月令十神3在 时干透出
+
+        }
+
+
+
+
+        return null;
+    }
+
+
 }

+ 1 - 1
xpgx-service/src/main/java/com/miaxis/gan/vo/GanZhiVo.java

@@ -32,7 +32,7 @@ public class GanZhiVo {
     private String nongDay;
 
     @ApiModelProperty(value = "起运年龄")
-    private Integer qiYunOld;
+    private List<Map<String,String>> daYunList;
 
     @ApiModelProperty(value = "日元强弱")
     private Map<String,Object> riYuan;