feat: 新增改性剂计算
This commit is contained in:
@@ -13,6 +13,8 @@ class Collector:
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
# todo-2 材料id映射
|
||||
|
||||
def get_avg(self):
|
||||
query = PricePublish.get_query(name_in=(
|
||||
'杉原木',
|
||||
@@ -102,9 +104,11 @@ class Collector:
|
||||
func.avg(PricePublish.price_longyan),
|
||||
func.avg(PricePublish.price_ningde),
|
||||
func.avg(PricePublish.price_pintan),
|
||||
func.avg(PricePublish.price_zhangzhoukfq),
|
||||
PricePublish.tax,
|
||||
PricePublish.unit,
|
||||
)
|
||||
query = query.filter(PricePublish.price != 0)
|
||||
query = query.group_by(
|
||||
PricePublish.material_id,
|
||||
PricePublish.name,
|
||||
@@ -115,24 +119,25 @@ class Collector:
|
||||
data = query.all()
|
||||
for item in data:
|
||||
material_id, name, spec, price, price_fuzhou, price_xiamen, price_putian, price_sanming, price_quanzhou, \
|
||||
price_zhangzhou, price_nanpin, price_longyan, price_ningde, price_pintan, tax, unit = item
|
||||
price_zhangzhou, price_nanpin, price_longyan, price_ningde, price_pintan, price_zhangzhoukfq, tax, unit = item
|
||||
PricePublish(
|
||||
year=self.year,
|
||||
month=self.month,
|
||||
material_id=material_id,
|
||||
name=name,
|
||||
spec=spec,
|
||||
price=price,
|
||||
price_fuzhou=price_fuzhou,
|
||||
price_xiamen=price_xiamen,
|
||||
price_putian=price_putian,
|
||||
price_sanming=price_sanming,
|
||||
price_quanzhou=price_quanzhou,
|
||||
price_zhangzhou=price_zhangzhou,
|
||||
price_nanpin=price_nanpin,
|
||||
price_longyan=price_longyan,
|
||||
price_ningde=price_ningde,
|
||||
price_pintan=price_pintan,
|
||||
price=round(price, 2),
|
||||
price_fuzhou=round(price_fuzhou, 2),
|
||||
price_xiamen=round(price_xiamen, 2),
|
||||
price_putian=round(price_putian, 2),
|
||||
price_sanming=round(price_sanming, 2),
|
||||
price_quanzhou=round(price_quanzhou, 2),
|
||||
price_zhangzhou=round(price_zhangzhou, 2),
|
||||
price_nanpin=round(price_nanpin, 2),
|
||||
price_longyan=round(price_longyan, 2),
|
||||
price_ningde=round(price_ningde, 2),
|
||||
price_pintan=round(price_pintan, 2),
|
||||
price_zhangzhoukfq=round(price_zhangzhoukfq, 2),
|
||||
tax=tax,
|
||||
type=2,
|
||||
unit=unit,
|
||||
@@ -216,6 +221,7 @@ class Collector:
|
||||
price_longyan=item.price,
|
||||
price_ningde=item.price,
|
||||
price_pintan=item.price,
|
||||
price_zhangzhoukfq=item.price,
|
||||
tax=item.tax,
|
||||
type=1,
|
||||
unit=item.unit
|
||||
@@ -244,7 +250,7 @@ class Collector:
|
||||
month=self.month,
|
||||
material_id=item.material_id,
|
||||
name=item.name,
|
||||
spec='',
|
||||
spec=item.spec,
|
||||
price=item.price_recommend,
|
||||
price_fuzhou=item.price_recommend,
|
||||
price_xiamen=item.price_recommend,
|
||||
@@ -256,13 +262,17 @@ class Collector:
|
||||
price_longyan=item.price_recommend,
|
||||
price_ningde=item.price_recommend,
|
||||
price_pintan=item.price_recommend,
|
||||
price_zhangzhoukfq=item.price_recommend,
|
||||
tax=9.00,
|
||||
type=1,
|
||||
unit=item.unit,
|
||||
).upsert()
|
||||
|
||||
def run(self):
|
||||
# 当月价
|
||||
self.get_from_survey()
|
||||
self.get_from_result()
|
||||
# 近半年平均价
|
||||
self.get_avg()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user