|
|
@@ -545,51 +545,54 @@ def download_records(request):
|
|
|
|
|
|
data = []
|
|
|
for item in qdata:
|
|
|
- user = cm.UserInfo.objects.filter(id=item["user_id"]).first()
|
|
|
- item["username"] = user.username
|
|
|
- item["usercode"] = user.usercode
|
|
|
- item["today_income"] = "{}%".format(item["today_income"]*100)
|
|
|
- item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
-
|
|
|
- today_stock = json.loads(item["today_stock"]) if item["today_stock"] else []
|
|
|
- today_stock = list(filter(lambda x:x["name"],today_stock if today_stock else []))
|
|
|
- today_stock = ",".join([x["name"]+str(x["fund"]) for x in today_stock]) if today_stock else ""
|
|
|
-
|
|
|
- yesterday_stock = json.loads(item["yesterday_stock"]) if item["yesterday_stock"] else []
|
|
|
- yesterday_stock = list(filter(lambda x:x["name"],yesterday_stock if yesterday_stock else []))
|
|
|
- yesterday_stock = ",".join([x["name"]+str(x["fund"]) for x in yesterday_stock]) if yesterday_stock else ""
|
|
|
-
|
|
|
- #空仓、开超市、请假判断
|
|
|
- if item["auto_complete"] > 0:
|
|
|
- today_stock = u"请假"
|
|
|
- else:
|
|
|
- if item["is_markt"] == 1:
|
|
|
- today_stock = u"开超市"
|
|
|
+ try:
|
|
|
+ user = cm.UserInfo.objects.filter(id=item["user_id"]).first()
|
|
|
+ item["username"] = user.username
|
|
|
+ item["usercode"] = user.usercode
|
|
|
+ item["today_income"] = "{}%".format(item["today_income"]*100)
|
|
|
+ item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
+
|
|
|
+ today_stock = json.loads(item["today_stock"]) if item["today_stock"] else []
|
|
|
+ today_stock = list(filter(lambda x:x["name"],today_stock if today_stock else []))
|
|
|
+ today_stock = ",".join([x["name"]+str(x["fund"]) for x in today_stock]) if today_stock else ""
|
|
|
+
|
|
|
+ yesterday_stock = json.loads(item["yesterday_stock"]) if item["yesterday_stock"] else []
|
|
|
+ yesterday_stock = list(filter(lambda x:x["name"],yesterday_stock if yesterday_stock else []))
|
|
|
+ yesterday_stock = ",".join([x["name"]+str(x["fund"]) for x in yesterday_stock]) if yesterday_stock else ""
|
|
|
+
|
|
|
+ #空仓、开超市、请假判断
|
|
|
+ if item["auto_complete"] > 0:
|
|
|
+ today_stock = u"请假"
|
|
|
else:
|
|
|
- if today_stock == "":
|
|
|
- today_stock = u"空仓"
|
|
|
- #昨日
|
|
|
- if item["yesterday_auto_complete"] > 0:
|
|
|
- yesterday_stock = u"请假"
|
|
|
- else:
|
|
|
- if item["yesterday_is_markt"] == 1:
|
|
|
- yesterday_stock = u"开超市"
|
|
|
+ if item["is_markt"] == 1:
|
|
|
+ today_stock = u"开超市"
|
|
|
+ else:
|
|
|
+ if today_stock == "":
|
|
|
+ today_stock = u"空仓"
|
|
|
+ #昨日
|
|
|
+ if item["yesterday_auto_complete"] > 0:
|
|
|
+ yesterday_stock = u"请假"
|
|
|
else:
|
|
|
- if yesterday_stock == "":
|
|
|
- yesterday_stock = u"空仓"
|
|
|
-
|
|
|
- data.append(
|
|
|
- [
|
|
|
- item["group_rank"],
|
|
|
- item["username"],
|
|
|
- item["init_fund"],
|
|
|
- item["yesterday_fund"],
|
|
|
- item["today_fund"],
|
|
|
- item["today_income"],
|
|
|
- item["total_income"],
|
|
|
- yesterday_stock,
|
|
|
- today_stock
|
|
|
- ])
|
|
|
+ if item["yesterday_is_markt"] == 1:
|
|
|
+ yesterday_stock = u"开超市"
|
|
|
+ else:
|
|
|
+ if yesterday_stock == "":
|
|
|
+ yesterday_stock = u"空仓"
|
|
|
+
|
|
|
+ data.append(
|
|
|
+ [
|
|
|
+ item["group_rank"],
|
|
|
+ item["username"],
|
|
|
+ item["init_fund"],
|
|
|
+ item["yesterday_fund"],
|
|
|
+ item["today_fund"],
|
|
|
+ item["today_income"],
|
|
|
+ item["total_income"],
|
|
|
+ yesterday_stock,
|
|
|
+ today_stock
|
|
|
+ ])
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
xlsfile = os.path.join(settings.BASE_DIR,"demo.xls")
|
|
|
exceltool = ExcelTool(xlsfile)
|
|
|
xlsdata = exceltool.save_data(u"学员报名数据表",header,data)
|