SimpleLuckyDay.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import datetime
  2. import GaoNengLogic
  3. import SiZhuLogic
  4. from DBTools import DBWanNianLi
  5. from DataCenter import DataCenter
  6. from LocalModel import BaZi, LuckyDayInfo, SiZhu, SiZhuWeiZhi
  7. def calc_simple_lucky_day(bazi: BaZi, dc: DataCenter):
  8. bazi.luckyDays = []
  9. dt = datetime.datetime.now()
  10. for i in range(0, 1):
  11. diff = datetime.timedelta(days=i)
  12. cur = dt + diff
  13. dts = DBWanNianLi.query_first_by(nian=cur.year, yue=cur.month, ri=cur.day)
  14. if dts is not None:
  15. # print(dts.nian_gan, dts.nian_zhi, "年 ", dts.yue_gan, dts.yue_zhi, "月 ", dts.ri_gan, dts.ri_zhi, "日")
  16. info = LuckyDayInfo()
  17. info.year = cur.year
  18. info.month = cur.month
  19. info.day = cur.day
  20. info.niangan = SiZhu(bazi.qiankun, True, dts.nian_gan, SiZhuWeiZhi.liu_niangan)
  21. info.nianzhi = SiZhu(bazi.qiankun, False, dts.nian_zhi, SiZhuWeiZhi.liu_nianzhi)
  22. info.yuegan = SiZhu(bazi.qiankun, True, dts.yue_gan, SiZhuWeiZhi.liu_yuegan)
  23. info.yuezhi = SiZhu(bazi.qiankun, False, dts.yue_zhi, SiZhuWeiZhi.liu_yuezhi)
  24. info.rigan = SiZhu(bazi.qiankun, True, dts.ri_gan, SiZhuWeiZhi.liu_rigan)
  25. info.rizhi = SiZhu(bazi.qiankun, False, dts.ri_zhi, SiZhuWeiZhi.liu_rizhi)
  26. for gan in info.all_gans():
  27. SiZhuLogic.__fill_sizhu_of_tiangan(gan)
  28. for zhi in info.all_zhis():
  29. SiZhuLogic.__fill_sizhu_of_dizhi(zhi)
  30. SiZhuLogic.__fill_sizhu_of_zhangsheng(info.nianzhi, info.niangan.text, bazi.riGan.text)
  31. SiZhuLogic.__fill_sizhu_of_zhangsheng(info.yuezhi, info.yuegan.text, bazi.riGan.text)
  32. SiZhuLogic.__fill_sizhu_of_zhangsheng(info.rizhi, info.rigan.text, bazi.riGan.text)
  33. for zhi in info.all_zhis():
  34. SiZhuLogic.__fill_cang_gan(zhi, bazi.riGan)
  35. for sz in info.all_zhus():
  36. SiZhuLogic.__fill_shishen(bazi.riGan, sz)
  37. sz.check_lushen(bazi.riGan.text)
  38. tgZhus = [info.niangan, info.yuegan, info.rigan, bazi.riGan]
  39. dzZhus = [info.nianzhi, info.yuezhi, info.rizhi, bazi.riZhi]
  40. for tg in tgZhus:
  41. GaoNengLogic.__fix_tiangan_gaoneng(tg, tgZhus, bazi, dc, False)
  42. for dz in dzZhus:
  43. GaoNengLogic.__fix_dizhi3_gaoneng(dz, dzZhus, bazi, dc, False)
  44. for dz in dzZhus:
  45. GaoNengLogic.__fix_dizhi2_gaoneng(dz, dzZhus, bazi, dc, False)
  46. for sz in info.all_zhus():
  47. sz.power = dc.get_shishen_power(sz.shiShen)
  48. per = dc.get_cangan_power_percentage_by_zhu(sz)
  49. sz.update_canggan_powers(per)
  50. sz.selfPower = sz.get_canggan_power_by_wuxing(sz.wuXing)
  51. bazi.luckyDays.append(info)