SimpleLuckyDay.py 2.8 KB

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