feat: 新增计算保留上月小数位数

This commit is contained in:
han0
2025-01-21 16:04:21 +08:00
parent 3f431faef4
commit f5065d1ee7
4 changed files with 11 additions and 1 deletions

View File

@@ -78,6 +78,7 @@ class Calculator:
unit = "" # 单位
spec = '' # 规格
display_digit = ''
round_bit = 1 # 结果保留位数
round_method = RoundMethod.normal # 舍入方法
@@ -126,6 +127,7 @@ class Calculator:
'weight_survey': self.weight_survey,
'unit': self.unit,
'spec': self.spec,
'display_digit': self.display_digit,
}
def run(self):
@@ -228,12 +230,14 @@ class Calculator:
self.weight_fhb = self._previous_prices.weight_fhb
self.weight_network = self._previous_prices.weight_network
self.weight_survey = self._previous_prices.weight_survey
self.display_digit = self._previous_prices.display_digit
else:
self.weight_ftb = 1
self.weight_ss = 1
self.weight_fhb = 1
self.weight_network = 1
self.weight_survey = 1
self.display_digit = 1
def save(self):
result = self.result()

View File

@@ -110,6 +110,7 @@ class Collector:
func.avg(PricePublish.price_zhangzhoukfq),
PricePublish.tax,
PricePublish.unit,
PricePublish.display_digit
)
query = query.filter(PricePublish.price != 0)
query = query.group_by(
@@ -118,11 +119,12 @@ class Collector:
PricePublish.spec,
PricePublish.tax,
PricePublish.unit,
PricePublish.display_digit,
)
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, price_zhangzhoukfq, tax, unit = item
price_zhangzhou, price_nanpin, price_longyan, price_ningde, price_pintan, price_zhangzhoukfq, tax, unit, display_digit = item
PricePublish(
year=self.year,
month=self.month,
@@ -144,6 +146,7 @@ class Collector:
tax=tax,
type=2,
unit=unit,
display_digit=display_digit,
).upsert()
def get_from_survey(self):
@@ -330,6 +333,7 @@ class Collector:
tax=9.00,
type=1,
unit=item.unit,
display_digit=item.display_digit,
).upsert()
def run(self):

View File

@@ -32,6 +32,7 @@ class PricePublish(db.Model, Model, OperationTrackMixin, BaseModelMixin):
status = Column('STATUS', Integer, default=0, comment='状态')
type = Column('TYPE', Integer, default=0, comment='类型')
unit = Column('UNIT', String(128), default='', comment='单位')
display_digit = Column('DISPLAY_DIGIT', Integer, default='', comment='显示小数位数')
__tablename__ = 'PRICE_PUBLISH'
__table_args__ = (

View File

@@ -36,6 +36,7 @@ class PriceResult(db.Model, Model, OperationTrackMixin, BaseModelMixin):
weight_survey = Column('WEIGHT_SURVEY', Numeric(16, 4), default=0, comment='')
spec = Column('SPEC', String(128), default='', comment='规格')
unit = Column('UNIT', String(128), default='', comment='单位')
display_digit = Column('DISPLAY_DIGIT', Integer, default='', comment='显示小数位数')
__tablename__ = 'PRICE_RESULT'
__table_args__ = (