fix: 修复计算后未移除多余材料的问题
This commit is contained in:
@@ -39,6 +39,10 @@ class PricePublish(db.Model, Model, OperationTrackMixin, BaseModelMixin):
|
||||
{'comment': '发布价格'},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def clean(cls, year, month):
|
||||
cls.query.filter(cls.year == year, cls.month == month).delete()
|
||||
|
||||
@classmethod
|
||||
def get_by_key(cls, name, year, month, type):
|
||||
query = cls.query
|
||||
|
@@ -43,6 +43,10 @@ class PriceResult(db.Model, Model, OperationTrackMixin, BaseModelMixin):
|
||||
{'comment': '计算结果'},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def clean(cls, year, month):
|
||||
cls.query.filter(cls.year == year, cls.month == month).delete()
|
||||
|
||||
@classmethod
|
||||
def get_by_key(cls, material_id, year, month):
|
||||
query = cls.query
|
||||
|
@@ -1,5 +1,6 @@
|
||||
from calculators import RoundMethod
|
||||
from commons.models.material import Material
|
||||
from commons.models.price_result import PriceResult
|
||||
|
||||
|
||||
def calculate(year=2023, month=8):
|
||||
@@ -8,6 +9,8 @@ def calculate(year=2023, month=8):
|
||||
"""
|
||||
from calculators import Calculator
|
||||
|
||||
# 清空当月数据
|
||||
PriceResult.clean(year, month)
|
||||
# 从材料表获取趋势表所需的材料信息
|
||||
for material in Material.query.all():
|
||||
calculator = Calculator(year=year, month=month)
|
||||
@@ -36,7 +39,7 @@ if __name__ == '__main__':
|
||||
from core.factory import ClientApp
|
||||
|
||||
with ClientApp().app_context():
|
||||
calculate(2024, 8)
|
||||
calculate(2024, 7)
|
||||
|
||||
# for i in range(2, 12):
|
||||
# calculate(2022, i+1)
|
||||
|
@@ -1,10 +1,12 @@
|
||||
from collectors import Collector
|
||||
from commons.models.price_publish import PricePublish
|
||||
|
||||
|
||||
def collect(year=2023, month=11):
|
||||
"""
|
||||
整理发布价格
|
||||
"""
|
||||
PricePublish.clean(year, month) # 清空当月数据
|
||||
collector = Collector(year, month)
|
||||
collector.run()
|
||||
|
||||
|
Reference in New Issue
Block a user