xjc hace 6 meses
padre
commit
8e2313298e
Se han modificado 6 ficheros con 5424 adiciones y 5363 borrados
  1. 1 0
      src/common/models.py
  2. 36 0
      src/manage/controls.py
  3. 1 0
      src/manage/urls_backstage.py
  4. 16 1
      src/manage/views.py
  5. 5360 5361
      src/tools/code.csv
  6. 10 1
      src/utils/ocrmanage.py

+ 1 - 0
src/common/models.py

@@ -204,6 +204,7 @@ class Stock(models.Model):
     user_num = models.IntegerField(u"持股人数",blank=False,null=False,default=0)
     comments_num = models.IntegerField(u"留言条数",blank=False,null=False,default=0)
     choice_num = models.IntegerField(u"自选人数",blank=False,null=False,default=0)
+    stock_date = models.CharField(u"持股日期", max_length=255,blank=True,null=True)
 
     ctime = models.DateTimeField(u"创建时间", auto_now_add=True)
 

+ 36 - 0
src/manage/controls.py

@@ -1414,3 +1414,39 @@ def download_top3_imgs(request):
     return tmpzip
     #return imgData
 
+
+def update_stock_usernum(**kwargs):
+    """
+    """
+    stock_date = kwargs.get("stock_date")
+    qset = cm.UserStock.objects.filter(stock_date=stock_date,fund__gt=0)
+    qset = qset.values("stock_id","stock_name").annotate(count=Count("stock_id"),total_fund=Sum("fund")).order_by("-count")
+    cm.Stock.objects.update(stock_date=None)
+    for q in qset:
+        stock_id = q["stock_id"]
+        count = q["count"]
+        cm.Stock.objects.filter(id=stock_id).update(user_num=count,stock_date=stock_date)
+
+
+
+def get_stock_list(**kwargs):
+    """
+    """
+    name = kwargs.get("name")
+    stock_date = kwargs.get("stock_date")
+    qset = cm.Stock.objects.all()
+    if name:
+        qset = qset.filter(name__icontains=name)
+    if stock_date:
+        qset = qset.filter(stock_date=stock_date)
+
+    data = list(qset.order_by("-user_num").values())
+    page = int(kwargs.get("page",1))
+    page_size = int(kwargs.get("page_size",20))
+    if page and page_size:
+        total,data = ccf.get_page_list(data,page,page_size)
+        return total,data
+    else:
+        return len(data),data
+
+

+ 1 - 0
src/manage/urls_backstage.py

@@ -71,6 +71,7 @@ urlpatterns = [
     url(r'^baike/detail/top$', views.BaikeDetailTopView.as_view()),
     url(r'^article/spider$', views.ArticleSpiderView.as_view()),
     url(r'^player/record/download/top3img$', views.DownloadTop3ImageView.as_view()),
+    url(r'^stock/updateUserStock$', views.UpdateUserStockView.as_view()),
 
 ]
 

+ 16 - 1
src/manage/views.py

@@ -914,7 +914,8 @@ class StockListView(cv.AdminView):
         """
         qdata = request.json
         try:
-            total,rst = ctl.get_list_info(self,**qdata)
+            #total,rst = ctl.get_list_info(self,**qdata)
+            total,rst = ctl.get_stock_list(**qdata)
             return cv.to_suc({"total":total,"list":rst})
         except Exception as e:
             cv.tracefail()
@@ -1959,3 +1960,17 @@ class DownloadTop3ImageView(cv.BaseView):
         except Exception as e:
             cv.tracefail()
             return cv.to_fail(e)
+
+
+class UpdateUserStockView(cv.AdminView):
+    def post(self, request):
+        """
+        #更新股票持仓人数(平台管理后台)
+        """
+        try:
+            qdata = request.json
+            rst = ctl.update_stock_usernum(**qdata)
+            return cv.to_suc(rst)
+        except Exception as e:
+            cv.tracefail()
+            return cv.to_fail(e)

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 5360 - 5361
src/tools/code.csv


+ 10 - 1
src/utils/ocrmanage.py

@@ -203,6 +203,15 @@ class OcrManage:
                 if len(codeName['name']) > 0:
                     break
             if len(codeName['name']) > 0:
+                bhave = 0
+                if len(flist) > 0:
+                    for adic in flist:
+                        if adic['name'] == codeName['name']:
+                            bhave = 1
+                            break
+                if bhave == 1:
+                    continue
+                    
                 fund = 0
                 market = '0'
                 money = 0
@@ -400,7 +409,7 @@ class OcrManage:
                 codeName = nstr
         
         if len(words) >= 5:
-            nstr = words[:2]
+            nstr = words[:5]
             code = stock_cache.get_code_by_name(nstr)
             if code is not None:
                 codeName = nstr