本文整理汇总了Python中base.utils.MethodUtil.convertToStr方法的典型用法代码示例。如果您正苦于以下问题:Python MethodUtil.convertToStr方法的具体用法?Python MethodUtil.convertToStr怎么用?Python MethodUtil.convertToStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base.utils.MethodUtil
的用法示例。
在下文中一共展示了MethodUtil.convertToStr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: countSumZb
# 需要导入模块: from base.utils import MethodUtil [as 别名]
# 或者: from base.utils.MethodUtil import convertToStr [as 别名]
def countSumZb(rlist):
if len(rlist) > 1:
sumdict = {}
yitem = rlist[0]
sitem = rlist[1]
for key in yitem:
est = yitem[key]
if key in sitem:
sale = sitem[key]
if decimal.Decimal(est) > 0:
zb = mtu.convertToStr(decimal.Decimal(sale) * decimal.Decimal("100.0") / decimal.Decimal(est),
"0.00", 1) + "%"
else:
zb = ""
else:
zb = ""
sumdict.setdefault(key, zb)
yitem.setdefault("idname", "合计")
sitem.setdefault("idname", "合计")
sumdict.setdefault("idname", "合计")
yitem.setdefault("codelable", "计划")
sitem.setdefault("codelable", "实际达成")
sumdict.setdefault("codelable", "达成率")
rlist.append(sumdict)
示例2: countSale
# 需要导入模块: from base.utils import MethodUtil [as 别名]
# 或者: from base.utils.MethodUtil import convertToStr [as 别名]
def countSale(ydict, sdict1, sdict2, lastDay):
rsdict = {}
zbdict = {}
sumlist = []
ssumdict, ysumdict = {}, {}
sumlist.append(ysumdict) # 计划
sumlist.append(ssumdict) # 实际
for key in sdict1.keys():
sitem = sdict1[key]
if key in ydict:
yitem = ydict[key]
else:
yitem = initItem(lastDay)
ydict.setdefault(key, yitem)
newitem, zbitem = {}, {}
newitem = dict(newitem, **sitem)
for k in sitem:
# 实际销售
val1 = sitem[k]
# 批发销售单
if key in sdict2:
sitem2 = sdict2[key]
if sitem2 and k in sitem2:
val2 = sitem2[k]
else:
val2 = decimal.Decimal("0.00")
else:
val2 = decimal.Decimal("0.00")
# 真实销售 = 实际销售 + 批发销售
totalval = val1 + val2
newitem[k] = totalval
# 计划
if k in yitem:
yobj = yitem[k]
# 占比
if yobj > 0:
zb = mtu.convertToStr(totalval * decimal.Decimal("100.0") / yobj, "0.00", 1) + "%"
zbitem.setdefault(k, zb)
else:
zbitem.setdefault(k, "")
else:
zbitem.setdefault(k, "")
# 销售合计
if k in ssumdict:
ssumdict[k] += totalval
else:
ssumdict.setdefault(k, totalval)
newitem.setdefault("codelable", "实际达成")
zbitem.setdefault("codelable", "达成率")
rsdict.setdefault(key, newitem)
zbdict.setdefault(key, zbitem)
# 计划合计
for ykey in ydict.keys():
yitem = ydict[ykey]
for k in yitem.keys():
yobj = yitem[k]
if k in ysumdict:
ysumdict[k] += yobj
else:
ysumdict.setdefault(k, yobj)
yitem.setdefault("codelable", "计划")
return rsdict, zbdict, sumlist