Commit 0f2086a6 by huangjing

hj

parent 18345b62
......@@ -3,11 +3,17 @@
from dao.Dataoper_dao import DataoperDao
from db.mod_db import DataBase
import time
class Datao:
def Getdata(self,cate_name):
def Getdata(self,cate_name,establishment_time):
try:
Dataoper = DataoperDao()
# 将时间戳转化为年
struct_time = time.localtime(establishment_time) # 得到结构化时间格式
establishment_time = time.strftime("%Y-%m-%d %H:%M:%S", struct_time).split('-')[0]
establishment_time = int(establishment_time)
print(establishment_time, "======establishment_time")
re1 = Dataoper.select_sql_1(cate_name)
if re1:
list = []
......@@ -15,8 +21,10 @@ class Datao:
if ree:
policy_name = ree["policy_name"]
life_cycle = ree["life_cycle"]
life_cycle = int(life_cycle)
life_year = establishment_time + life_cycle
dict = {}
dict[policy_name] = life_cycle
dict[policy_name] = life_year
list.append(dict)
return 1, list
......@@ -29,6 +37,7 @@ class Datao:
DataInfo.close()
return -1, {}
def InsertData(self,datainfo):
# 数据库连接
try:
......@@ -62,6 +71,4 @@ if __name__ == "__main__":
DataoInfo = Datao()
re1,re2 = DataoInfo.Getdata(cate_name)
print(str(re1))
print(str(re2))
print(str(re2))
\ No newline at end of file
......@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from flask import request
import json
import Dataoper
from Dataoper import Datao
from dao.trade_es import trade_Es
......@@ -18,8 +18,8 @@ def selectcyle(server):
company_cate_2 = searched["hits"]["hits"][0]['_source']["gsb_company_cate_2"] # 行业第二大类
company_cate_3 = searched["hits"]["hits"][0]['_source']["gsb_company_cate_3"] # 行业第三大类
establishment_time = searched["hits"]["hits"][0]['_source']["estibish_time"] # 成立时间
re1,re2 = Dataoper.Getdata(company_cate_1,establishment_time)
DataoperInfo = Datao()
re1,re2 = DataoperInfo.Getdata(company_cate_1,establishment_time)
if re1:
return json.dumps({"status": 0, "msg":"操作成功","data": re2}, ensure_ascii=False)
else:
......@@ -35,7 +35,8 @@ def insertcycle(server):
try:
data=request.get_json().get("data")
print(data)
re1=Dataoper.InsertData(data)
DataoperInfo = Datao()
re1=DataoperInfo.InsertData(data)
if re1 :
return json.dumps({"status": 0, "msg":"成功","data": re1}, ensure_ascii=False)
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment