fix: 修复计算机未按权重计算的问题
This commit is contained in:
@@ -133,6 +133,7 @@ class Calculator:
|
||||
}
|
||||
|
||||
def run(self):
|
||||
self._get_weight()
|
||||
self.price_ftb, self.fluctuating_ftb = self._get_ftb_price()
|
||||
self.price_ss, self.fluctuating_ss = self._get_ss_price()
|
||||
self.price_fhb, self.fluctuating_fhb = self._get_fhb_price()
|
||||
@@ -204,8 +205,6 @@ class Calculator:
|
||||
return result
|
||||
|
||||
def _get_recommend_price(self, round_by=10):
|
||||
self._get_weight()
|
||||
|
||||
if not self.previous_prices:
|
||||
return 0, 0
|
||||
|
||||
@@ -231,7 +230,7 @@ class Calculator:
|
||||
|
||||
def _get_weight(self):
|
||||
# 如果有上月数据按上月权重计算 无则平均数
|
||||
if self._previous_prices:
|
||||
if self.previous_prices:
|
||||
self.weight_ftb = self._previous_prices.weight_ftb
|
||||
self.weight_ss = self._previous_prices.weight_ss
|
||||
self.weight_fhb = self._previous_prices.weight_fhb
|
||||
|
@@ -18,7 +18,7 @@ def calculate(year=2023, month=8):
|
||||
calculator.material_id = material.id
|
||||
calculator.unit = material.unit
|
||||
calculator.spec = material.spec
|
||||
|
||||
|
||||
# 设置小数位数,如果数据库中未设置则使用默认值0
|
||||
calculator.round_bit = material.round_bit if material.round_bit is not None else 0
|
||||
|
||||
@@ -39,11 +39,11 @@ if __name__ == '__main__':
|
||||
from core.factory import ClientApp
|
||||
|
||||
with ClientApp().app_context():
|
||||
calculate(2024, 4)
|
||||
calculate(2025, 3)
|
||||
|
||||
# for i in range(2, 12):
|
||||
# calculate(2022, i+1)
|
||||
# for i in range(0, 12):
|
||||
# calculate(2023, i+1)
|
||||
# for i in range(1, 5+1):
|
||||
# calculate(2025, i)
|
||||
# for i in range(6-1, 10):
|
||||
# calculate(2024, i+1)
|
||||
|
Reference in New Issue
Block a user