fix: 修复发布价材料计算来源
This commit is contained in:
@@ -5,10 +5,7 @@ from sqlalchemy import func
|
|||||||
from commons.models.fujian_survey import FujianSurvey
|
from commons.models.fujian_survey import FujianSurvey
|
||||||
from commons.models.price_publish import PricePublish
|
from commons.models.price_publish import PricePublish
|
||||||
from commons.models.price_result import PriceResult
|
from commons.models.price_result import PriceResult
|
||||||
|
from commons.models.material import Material
|
||||||
|
|
||||||
MATERIAL_ID_TYPE_1 = []
|
|
||||||
MATERIAL_ID_TYPE_2 = []
|
|
||||||
|
|
||||||
|
|
||||||
class Collector:
|
class Collector:
|
||||||
@@ -18,80 +15,12 @@ class Collector:
|
|||||||
self.month = month
|
self.month = month
|
||||||
self.force = True # todo-2 已发布的价格不在覆盖计算
|
self.force = True # todo-2 已发布的价格不在覆盖计算
|
||||||
self.digit_map = {}
|
self.digit_map = {}
|
||||||
|
# 获取所有材料信息
|
||||||
|
self.materials = Material.query.all()
|
||||||
|
self.material_codes = [m.code for m in self.materials if m.code]
|
||||||
|
|
||||||
def get_avg(self):
|
def get_avg(self):
|
||||||
query = PricePublish.get_query(name_in=(
|
query = PricePublish.get_query(material_id_in=self.material_codes)
|
||||||
'杉原木',
|
|
||||||
'松原木',
|
|
||||||
'锯材',
|
|
||||||
'锯材',
|
|
||||||
'毛竹',
|
|
||||||
'冷轧带肋钢筋网',
|
|
||||||
'预应力粗钢筋',
|
|
||||||
'高强钢丝',
|
|
||||||
'钢板',
|
|
||||||
'钢板',
|
|
||||||
'圆钢',
|
|
||||||
'钢轨',
|
|
||||||
'钢管',
|
|
||||||
'镀锌钢管',
|
|
||||||
'镀锌无缝钢管',
|
|
||||||
'镀锌钢板',
|
|
||||||
'钢丝绳',
|
|
||||||
'波形钢板(双波)',
|
|
||||||
'波形钢板(三波)',
|
|
||||||
'四氟板式橡胶组合支座',
|
|
||||||
'板式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'模数式伸缩装置',
|
|
||||||
'模数式伸缩装置',
|
|
||||||
'钢绞线群锚(3孔)',
|
|
||||||
'钢绞线群锚(7孔)',
|
|
||||||
'钢绞线群锚(15孔)',
|
|
||||||
'不锈钢板',
|
|
||||||
'铁件',
|
|
||||||
'铝合金标志',
|
|
||||||
'铸铁管',
|
|
||||||
'钢板网',
|
|
||||||
'铁丝编织网',
|
|
||||||
'橡胶护舷',
|
|
||||||
'橡胶护舷',
|
|
||||||
'橡胶护舷',
|
|
||||||
'鼓型橡胶护舷',
|
|
||||||
'鼓型橡胶护舷',
|
|
||||||
'鼓型橡胶护舷',
|
|
||||||
'油漆',
|
|
||||||
'塑料排水板',
|
|
||||||
'路缘石',
|
|
||||||
'乳化炸药',
|
|
||||||
'硝铵炸药',
|
|
||||||
'导火线',
|
|
||||||
'普通雷管',
|
|
||||||
'电雷管',
|
|
||||||
'工业数码电子雷管',
|
|
||||||
'导爆索',
|
|
||||||
'引爆母线',
|
|
||||||
'重油',
|
|
||||||
|
|
||||||
'光圆钢筋',
|
|
||||||
'带肋钢筋',
|
|
||||||
'型钢',
|
|
||||||
'钢绞线',
|
|
||||||
'32.5级水泥',
|
|
||||||
'42.5级水泥',
|
|
||||||
'进口沥青',
|
|
||||||
'国产沥青',
|
|
||||||
'进口改性沥青',
|
|
||||||
'国产改性沥青',
|
|
||||||
'汽油(89)',
|
|
||||||
'汽油(92)',
|
|
||||||
'柴油(0)',
|
|
||||||
))
|
|
||||||
query = PricePublish.query_previous_month(query, start_date=datetime.date(self.year, self.month, 1), count=6)
|
query = PricePublish.query_previous_month(query, start_date=datetime.date(self.year, self.month, 1), count=6)
|
||||||
query = query.with_entities(
|
query = query.with_entities(
|
||||||
PricePublish.material_id,
|
PricePublish.material_id,
|
||||||
@@ -150,64 +79,7 @@ class Collector:
|
|||||||
).upsert()
|
).upsert()
|
||||||
|
|
||||||
def get_from_survey(self):
|
def get_from_survey(self):
|
||||||
query = FujianSurvey.get_query(self.year, self.month, name_in=(
|
query = FujianSurvey.get_query(self.year, self.month, material_id_in=self.material_codes)
|
||||||
'杉原木',
|
|
||||||
'松原木',
|
|
||||||
'锯材',
|
|
||||||
'锯材',
|
|
||||||
'毛竹',
|
|
||||||
'冷轧带肋钢筋网',
|
|
||||||
'预应力粗钢筋',
|
|
||||||
'高强钢丝',
|
|
||||||
'钢板',
|
|
||||||
'钢板',
|
|
||||||
'圆钢',
|
|
||||||
'钢轨',
|
|
||||||
'钢管',
|
|
||||||
'镀锌钢管',
|
|
||||||
'镀锌无缝钢管',
|
|
||||||
'镀锌钢板',
|
|
||||||
'钢丝绳',
|
|
||||||
'波形钢板(双波)',
|
|
||||||
'波形钢板(三波)',
|
|
||||||
'四氟板式橡胶组合支座',
|
|
||||||
'板式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'盆式橡胶支座',
|
|
||||||
'模数式伸缩装置',
|
|
||||||
'模数式伸缩装置',
|
|
||||||
'钢绞线群锚(3孔)',
|
|
||||||
'钢绞线群锚(7孔)',
|
|
||||||
'钢绞线群锚(15孔)',
|
|
||||||
'不锈钢板',
|
|
||||||
'铁件',
|
|
||||||
'铝合金标志',
|
|
||||||
'铸铁管',
|
|
||||||
'钢板网',
|
|
||||||
'铁丝编织网',
|
|
||||||
'橡胶护舷',
|
|
||||||
'橡胶护舷',
|
|
||||||
'橡胶护舷',
|
|
||||||
'鼓型橡胶护舷',
|
|
||||||
'鼓型橡胶护舷',
|
|
||||||
'鼓型橡胶护舷',
|
|
||||||
'油漆',
|
|
||||||
'塑料排水板',
|
|
||||||
'路缘石',
|
|
||||||
'乳化炸药',
|
|
||||||
'硝铵炸药',
|
|
||||||
'导火线',
|
|
||||||
'普通雷管',
|
|
||||||
'电雷管',
|
|
||||||
'工业数码电子雷管',
|
|
||||||
'导爆索',
|
|
||||||
'引爆母线',
|
|
||||||
'重油',
|
|
||||||
))
|
|
||||||
data = query.all()
|
data = query.all()
|
||||||
for item in data:
|
for item in data:
|
||||||
PricePublish(
|
PricePublish(
|
||||||
@@ -234,82 +106,7 @@ class Collector:
|
|||||||
).upsert()
|
).upsert()
|
||||||
|
|
||||||
def get_from_result(self):
|
def get_from_result(self):
|
||||||
query = PriceResult.get_query(self.year, self.month, material_id_in=(
|
query = PriceResult.get_query(self.year, self.month, material_id_in=self.material_codes)
|
||||||
'2001001',
|
|
||||||
'2001002',
|
|
||||||
'2001008',
|
|
||||||
'2003004',
|
|
||||||
'2003005',
|
|
||||||
'2003005001',
|
|
||||||
'5509001',
|
|
||||||
'5509002',
|
|
||||||
'5509003',
|
|
||||||
'3001001002',
|
|
||||||
'3001001001',
|
|
||||||
'3001002002',
|
|
||||||
'3001002001',
|
|
||||||
'3003002001',
|
|
||||||
'3003002002',
|
|
||||||
'3003003',
|
|
||||||
'4003001001',
|
|
||||||
'4003001002',
|
|
||||||
'4003002002',
|
|
||||||
'4003002001',
|
|
||||||
'4005001',
|
|
||||||
'2001003',
|
|
||||||
'2001006',
|
|
||||||
'2001013',
|
|
||||||
'2003006',
|
|
||||||
'2003007',
|
|
||||||
'2003008',
|
|
||||||
'2003009',
|
|
||||||
'2004004',
|
|
||||||
'2003012',
|
|
||||||
'2001019',
|
|
||||||
'2003015',
|
|
||||||
'2003016',
|
|
||||||
'2003017001',
|
|
||||||
'2003017002',
|
|
||||||
'2003021',
|
|
||||||
'2003022',
|
|
||||||
'6001002',
|
|
||||||
'6001003',
|
|
||||||
'6001059',
|
|
||||||
'6001071',
|
|
||||||
'6001080',
|
|
||||||
'6001086',
|
|
||||||
'6001089',
|
|
||||||
'6001092',
|
|
||||||
'6003001',
|
|
||||||
'6003003',
|
|
||||||
'6005005',
|
|
||||||
'6005009',
|
|
||||||
'6005015',
|
|
||||||
'2005002',
|
|
||||||
'2009028',
|
|
||||||
'6007002',
|
|
||||||
'2009033',
|
|
||||||
'2001025',
|
|
||||||
'2001026',
|
|
||||||
'6002001',
|
|
||||||
'6002002',
|
|
||||||
'6002003',
|
|
||||||
'6002004',
|
|
||||||
'6002005',
|
|
||||||
'6002006',
|
|
||||||
'5009002',
|
|
||||||
'5506001',
|
|
||||||
'5005001',
|
|
||||||
'5005002',
|
|
||||||
'5005003',
|
|
||||||
'5005006',
|
|
||||||
'5005007',
|
|
||||||
'5006001',
|
|
||||||
'5005009',
|
|
||||||
'5006002',
|
|
||||||
'5007003001',
|
|
||||||
'3003001',
|
|
||||||
))
|
|
||||||
data = query.all()
|
data = query.all()
|
||||||
self.digit_map = {i.material_id:i.display_digit for i in data}
|
self.digit_map = {i.material_id:i.display_digit for i in data}
|
||||||
for item in data:
|
for item in data:
|
||||||
@@ -338,7 +135,6 @@ class Collector:
|
|||||||
).upsert()
|
).upsert()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# 当月价
|
# 当月价
|
||||||
# self.get_from_survey()
|
# self.get_from_survey()
|
||||||
self.get_from_result()
|
self.get_from_result()
|
||||||
|
@@ -74,7 +74,7 @@ class PricePublish(db.Model, Model, OperationTrackMixin, BaseModelMixin):
|
|||||||
return query
|
return query
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_query(cls, year=None, month=None, name_in=None):
|
def get_query(cls, year=None, month=None, name_in=None, material_id_in=None):
|
||||||
query = cls.query
|
query = cls.query
|
||||||
if year:
|
if year:
|
||||||
query = query.filter(cls.year == year)
|
query = query.filter(cls.year == year)
|
||||||
@@ -82,4 +82,6 @@ class PricePublish(db.Model, Model, OperationTrackMixin, BaseModelMixin):
|
|||||||
query = query.filter(cls.month == month)
|
query = query.filter(cls.month == month)
|
||||||
if name_in:
|
if name_in:
|
||||||
query = query.filter(cls.name.in_(name_in))
|
query = query.filter(cls.name.in_(name_in))
|
||||||
|
if material_id_in:
|
||||||
|
query = query.filter(cls.material_id.in_(material_id_in))
|
||||||
return query
|
return query
|
||||||
|
@@ -13,9 +13,11 @@ if __name__ == '__main__':
|
|||||||
from core.factory import ClientApp
|
from core.factory import ClientApp
|
||||||
|
|
||||||
with ClientApp().app_context():
|
with ClientApp().app_context():
|
||||||
|
collect(2024, 8)
|
||||||
|
|
||||||
# for i in range(2, 12):
|
# for i in range(2, 12):
|
||||||
# collect(2022, i + 1)
|
# collect(2022, i + 1)
|
||||||
# for i in range(0, 12):
|
# for i in range(0, 12):
|
||||||
# collect(2023, i + 1)
|
# collect(2023, i + 1)
|
||||||
for i in range(5, 10):
|
# for i in range(5, 10):
|
||||||
collect(2024, i + 1)
|
# collect(2024, i + 1)
|
||||||
|
Reference in New Issue
Block a user