Commit bdcc2b8d by 高宇强

gyq

parent cc3afdef
......@@ -7,11 +7,11 @@
</head>
<body>
<div id="68b4d14e3c5c4244bfdcb44255ea8778" style="width:900px; height:500px;"></div>
<div id="3c558637439b48cd8376beb835f7d0b1" class="chart-container" style="width:900px; height:500px;"></div>
<script>
var chart_68b4d14e3c5c4244bfdcb44255ea8778 = echarts.init(
document.getElementById('68b4d14e3c5c4244bfdcb44255ea8778'), 'white', {renderer: 'canvas'});
var option_68b4d14e3c5c4244bfdcb44255ea8778 = {
var chart_3c558637439b48cd8376beb835f7d0b1 = echarts.init(
document.getElementById('3c558637439b48cd8376beb835f7d0b1'), 'white', {renderer: 'canvas'});
var option_3c558637439b48cd8376beb835f7d0b1 = {
"animation": true,
"animationThreshold": 2000,
"animationDuration": 1000,
......@@ -21,7 +21,9 @@
"animationEasingUpdate": "cubicOut",
"animationDelayUpdate": 0,
"color": [
"#1E90FF",
"#fd666d",
"#67e0e3",
"#37a2da",
"#c23531",
"#2f4554",
"#61a0a8",
......@@ -50,13 +52,33 @@
"series": [
{
"type": "bar",
"data": [
153,
119,
100,
84,
67
],
"name": "\u53d1\u660e\u4e13\u5229",
"data": [],
"stack": "stack1",
"barCategoryGap": "20%",
"label": {
"show": true,
"position": "top",
"margin": 8
}
},
{
"type": "bar",
"name": "\u65b0\u578b\u5b9e\u7528\u65b0\u578b",
"data": [],
"stack": "stack1",
"barCategoryGap": "20%",
"label": {
"show": true,
"position": "top",
"margin": 8
}
},
{
"type": "bar",
"name": "\u5916\u89c2\u8bbe\u8ba1",
"data": [],
"stack": "stack1",
"barCategoryGap": "20%",
"label": {
"show": true,
......@@ -68,10 +90,14 @@
"legend": [
{
"data": [
""
"\u53d1\u660e\u4e13\u5229",
"\u65b0\u578b\u5b9e\u7528\u65b0\u578b",
"\u5916\u89c2\u8bbe\u8ba1"
],
"selected": {
"": true
"\u53d1\u660e\u4e13\u5229": true,
"\u65b0\u578b\u5b9e\u7528\u65b0\u578b": true,
"\u5916\u89c2\u8bbe\u8ba1": true
}
}
],
......@@ -106,14 +132,7 @@
"curveness": 0,
"type": "solid"
}
},
"data": [
"9",
"42",
"35",
"38",
"36"
]
}
}
],
"yAxis": [
......@@ -135,11 +154,12 @@
"curveness": 0,
"type": "solid"
}
}
},
"data": []
}
]
};
chart_68b4d14e3c5c4244bfdcb44255ea8778.setOption(option_68b4d14e3c5c4244bfdcb44255ea8778);
chart_3c558637439b48cd8376beb835f7d0b1.setOption(option_3c558637439b48cd8376beb835f7d0b1);
</script>
</body>
</html>
#-*- encoding:utf-8 -*-
import requests
import json
url = "http://172.16.18.120:9999/patentdoc/api/createdoc"
headers = {'Content-Type':'application/json'}
data = {"mycompanyname":"华为技术有限公司"}
res = requests.post(url, data=json.dumps(data), headers=headers)#post请求
print(res.text)
\ No newline at end of file
#-*- encoding:utf-8 -*-
#!/usr/bin/python
from docx import Document
from docx.oxml import shared
from docx.opc import constants
from elasticsearch import Elasticsearch
import time, datetime
import requests
from PIL import Image
import os
import oss2
from flask import Flask , render_template,request
from docxtpl import DocxTemplate, RichText,InlineImage
import os
from docx.shared import Inches, Pt, RGBColor, Mm
from pyecharts.charts import Gauge,Pie,Line,Bar,WordCloud
from pyecharts.render import make_snapshot
from snapshot_selenium import snapshot
from pyecharts import options as opts
import json
import numpy as np
import PIL.Image as image
import flask
from flask_cors import CORS
from wordcloud import WordCloud
app = flask.Flask(__name__)
CORS(app, supports_credentials=True)
app.config['JSON_AS_ASCII'] = False
#esip = "43.247.184.94"
#esport = 9200
esip = "172.16.18.110"
esport = 9203
esuser = "admines"
espassword = "adminGSBes"
es = Elasticsearch([esip], http_auth=(esuser, espassword), port=esport)
# 阿里云接口地址
endpoint = 'http://oss-cn-beijing.aliyuncs.com'
auth = oss2.Auth('LTAI4GC5tSKvqsH2hMqj6pvd', '3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5')
bucket = oss2.Bucket(auth, endpoint, 'gsb-zc')
#生成图片
def charts(datalist,charttype,pngpath):
try:
img = None
if charttype == 1: #仪表盘
img = Gauge()
img.add("知产价值评估",[("", datalist[0]["value"])], axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(
color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30
)),label_opts=opts.LabelOpts(formatter="{value}"))
elif charttype == 2:#饼状图
img = Pie()
valuelist = []
for list in datalist:
valuelist.append((list["key"],list["value"]))
img.add("", valuelist, label_opts=opts.LabelOpts(formatter="{b}: {c}"))
elif charttype ==3:#折线图
img = Line()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("",valuelist,color= "#1E90FF")
elif charttype ==4:#柱状图
img = Bar()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("",valuelist,color= "#1E90FF")
elif charttype ==5:
img=WordCloud()
words=[]
for list in datalist:
if len(words)<10:
word=(list["key"],int(list["value"]))
words.append(word)
else:
break
img.add("",words,word_size_range=[20,100])
elif charttype == 6: # 条形图
img = Bar()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("", valuelist, color="#1E90FF")
img.reversal_axis()
if img:
make_snapshot(snapshot, img.render(), pngpath)
return True
else:
return False
except Exception as e:
print(e)
return False
def chartslines(xlist,datalist1,datalist2,datalist3,pngpath):#多折线
try:
img = Line()
img.add_xaxis(xlist)
img.add_yaxis("发明专利", datalist1,color= "#67e0e3")
img.add_yaxis("新型新型", datalist2,color= "#37a2da")
img.add_yaxis("外观设计", datalist3,color= "#fd666d")
if img:
make_snapshot(snapshot, img.render(), pngpath)
return True
else:
return False
except:
return False
def chartsbars(xlist,datalist1,datalist2,datalist3,pngpath):#多条形图
try:
img = Bar()
img.add_xaxis(xlist)
img.add_yaxis("发明专利", datalist1, stack="stack1",color= "#37a2da")
img.add_yaxis("新型实用新型", datalist2, stack="stack1",color= "#67e0e3")
img.add_yaxis("外观设计", datalist3, stack="stack1",color= "#fd666d")
img.reversal_axis()
if img:
make_snapshot(snapshot, img.render(), pngpath)
return True
else:
return False
except:
return False
def strQ2B(ustring):
"""全角转半角"""
rstring = ""
for uchar in ustring:
inside_code=ord(uchar)
if inside_code == 12288: #全角空格直接转换
inside_code = 32
elif (inside_code >= 65281 and inside_code <= 65374): #全角字符(除空格)根据关系转化
inside_code -= 65248
rstring += chr(inside_code)
return rstring
def createciyuntm(cut_text,png_path):#词云图
try:
mask = np.array(image.open("tm2.jpg"))
if not cut_text:
cut_text = "暂无数据 "
wordcloud = WordCloud(
font_path="SIMSUN.TTC",
mask=mask,
collocations=False,
background_color="white", width=100, height=80).generate(cut_text)
wordcloud.to_file(png_path)
return True
except:
return False
def create_doc(mycompanyname):
# 读取模板文件
tpl = DocxTemplate('cellbg.docx')
# 工商接口
resjq = es.search(index="bigdata_ic_gsb_company_op",
body={"query": {"term": {"company_name.raw": mycompanyname}}})
#context = {'gsblg': InlineImage(tpl, "gsb.png", width=Mm(8)), 'template': mycompanyname}
context = {'template': mycompanyname}
if resjq["hits"]["hits"]:
mycompanyinfo = resjq["hits"]["hits"][0]["_source"]
reg_number=str(mycompanyinfo["reg_number"])
context['reg_number']=reg_number
org_number = "未公开"
if mycompanyinfo["org_number"]:
org_number = str(mycompanyinfo["org_number"])
context['org_number'] = org_number
legal_person = "未公开"
if mycompanyinfo["legal_person"]:
legal_person = str(mycompanyinfo["legal_person"])
context['legal_person'] = legal_person
reg_status = "未公开"
if mycompanyinfo["reg_status"]:
reg_status = str(mycompanyinfo["reg_status"])
context['reg_status'] = reg_status
estibish_time = "未公开"
if mycompanyinfo["estiblish_time"]:
estibish_time = str(time.strftime("%Y-%m-%d", time.localtime(mycompanyinfo["estiblish_time"])))
context['estiblish_time'] = estibish_time
to_time = "未公开"
if mycompanyinfo["to_time"]:
to_time = str(time.strftime("%Y-%m-%d", time.localtime(mycompanyinfo["to_time"])))
#context['to_time'] = to_time
reg_capital = "未公开"
if mycompanyinfo["reg_capital"] and mycompanyinfo["reg_capital"]!=0 and mycompanyinfo["reg_unit"]:
reg_capital = str(mycompanyinfo["reg_capital"])+" "+str(mycompanyinfo["reg_unit"])
context['reg_capital'] = reg_capital
reg_institute = "未公开"
if mycompanyinfo["reg_institute"]:
reg_institute = str(mycompanyinfo["reg_institute"])
context['reg_institute'] = reg_institute
reg_location = "未公开"
if mycompanyinfo["reg_location"]:
reg_location = str(mycompanyinfo["reg_location"])
context['reg_location'] = reg_location
business_scope = "未公开"
if mycompanyinfo["business_scope"]:
business_scope = str(mycompanyinfo["business_scope"])
context['business_scope'] = business_scope
# 专利接口
index_name = "bigdata_patent_bib"
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"term": {
"pub_type": "发明"
}
}
]
}
}
}
searched = es.search(index=index_name,body=doc)
fm_pub_count = searched["hits"]["total"]#发明公开量
context["fm_pub_count"] = str(fm_pub_count)
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"term": {
"pub_type": "发明"
}
},
{"exists": {"field": "gr_no"}}
]
}
}
}
searched = es.search(index=index_name,body=doc)
fm_gr_count = searched["hits"]["total"]#发明公开量
context["fm_gr_count"] = str(fm_gr_count)
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"term": {
"pub_type": "实用新型"
}
}
]
}
}
}
searched = es.search(index=index_name,body=doc)
xx_pub_count = searched["hits"]["total"]#新型公开量
xx_gr_count = searched["hits"]["total"]#新型授权量
context["xx_pub_count"] = str(xx_pub_count)
context["xx_gr_count"] = str(xx_gr_count)
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"term": {
"pub_type": "外观设计"
}
}
]
}
}
}
searched = es.search(index=index_name, body=doc)
wg_pub_count = searched["hits"]["total"]#新型公开量
wg_gr_count = searched["hits"]["total"]#新型授权量
context["wg_pub_count"] = str(wg_pub_count)
context["wg_gr_count"] = str(wg_gr_count)
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"term": {
"pub_status": "有效"
}
}
]
}
},
"aggregations": {
"group_by_type": {
"terms": {
"field": "pub_type",
"size": 20,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
}
}
}
}
searched = es.search(index=index_name,body=doc)
buckets = searched["aggregations"]["group_by_type"]["buckets"]#发明公开量
fm_yx_count = buckets[0]["doc_count"]
context["fm_yx_count"] = str(fm_yx_count)
wg_yx_count = buckets[1]["doc_count"]
context["wg_yx_count"] = str(wg_yx_count)
xx_yx_count = buckets[2]["doc_count"]
context["xx_yx_count"] = str(xx_yx_count)
context["total_pub_count"] = str(fm_pub_count + xx_pub_count + wg_pub_count)
context["total_gr_count"] = str(fm_gr_count + xx_gr_count + wg_gr_count)
context["total_yx_count"] = str(fm_yx_count + xx_yx_count + wg_yx_count)
info = [{"key": "发明专利", "value": str(fm_pub_count)}, {"key": "实用新型", "value": str(xx_pub_count)},
{"key": "外观设计", "value": str(wg_pub_count)}]#公开量做饼图
if charts(info, 2, "pie01.png"):
context['pub_pie'] = InlineImage(tpl, "pie01.png", width=Mm(60))
info = [{"key": "发明专利", "value": str(fm_gr_count)}, {"key": "实用新型", "value": str(xx_gr_count)},
{"key": "外观设计", "value": str(wg_gr_count)}]#授权量做饼图
if charts(info, 2, "pie02.png"):
context['gr_pie'] = InlineImage(tpl, "pie02.png", width=Mm(60))
info = [{"key": "发明专利", "value": str(fm_yx_count)}, {"key": "实用新型", "value": str(xx_yx_count)},
{"key": "外观设计", "value": str(wg_yx_count)}]#有效量做饼图
if charts(info, 2, "pie03.png"):
context['yx_pie'] = InlineImage(tpl, "pie03.png", width=Mm(60))
#发展趋势-申请量
yearlist = ["2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018"]
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{"terms": {"filing_year": yearlist}}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_year": {
"terms": {
"field": "filing_year",
"size": 10,
"order": {
"_term": "asc"
}
},
"aggregations": {
"group_by_type": {
"terms": {
"field": "pub_type",
"size": 10,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
}
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
sources = []
fmlist = [0,0,0,0,0,0,0,0,0,0]
xxlist = [0,0,0,0,0,0,0,0,0,0]
wglist = [0,0,0,0,0,0,0,0,0,0]
for aggs in searched["aggregations"]["group_by_year"]["buckets"]:
m=0
for year in yearlist:
if aggs["key"] == year:
fmlist[m] = aggs["group_by_type"]["buckets"][0]["doc_count"]
wglist[m] = aggs["group_by_type"]["buckets"][1]["doc_count"]
xxlist[m] = aggs["group_by_type"]["buckets"][2]["doc_count"]
m += 1
m=0
totallist = []
for year in yearlist:
total = fmlist[m] + xxlist[m] + wglist[m]
totallist.append({"key":year,"value":total})
source = {"year2":year,"fm2count":fmlist[m],"xx2count":xxlist[m],"wg2count":wglist[m],"total2count":total}
sources.append(source)
m+=1
context["tms"] = sources
if chartslines(yearlist, fmlist,xxlist,wglist, "linefiling.png"):
context['filing2_line'] = InlineImage(tpl, "linefiling.png", width=Mm(120))
if charts(totallist,3,"lineftotal.png"):
context['filing2_total_line'] = InlineImage(tpl, "linefiling.png", width=Mm(120))
# 发展趋势-公开量
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{"terms": {"pub_year": yearlist}}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_year": {
"terms": {
"field": "pub_year",
"size": 10,
"order": {
"_term": "asc"
}
},
"aggregations": {
"group_by_type": {
"terms": {
"field": "pub_type",
"size": 10,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
}
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
sources = []
fmlist = [0,0,0,0,0,0,0,0,0,0]
xxlist = [0,0,0,0,0,0,0,0,0,0]
wglist = [0,0,0,0,0,0,0,0,0,0]
for aggs in searched["aggregations"]["group_by_year"]["buckets"]:
m=0
for year in yearlist:
if aggs["key"] == year:
fmlist[m] = aggs["group_by_type"]["buckets"][0]["doc_count"]
wglist[m] = aggs["group_by_type"]["buckets"][1]["doc_count"]
xxlist[m] = aggs["group_by_type"]["buckets"][2]["doc_count"]
m += 1
m=0
totallist = []
for year in yearlist:
total = fmlist[m] + xxlist[m] + wglist[m]
totallist.append({"key":year,"value":total})
source = {"year2":year,"fm2count":fmlist[m],"xx2count":xxlist[m],"wg2count":wglist[m],"total2count":total}
sources.append(source)
m+=1
context["pubtms"] = sources
if chartslines(yearlist, fmlist,xxlist,wglist, "linepub.png"):
context['filing2_pub_line'] = InlineImage(tpl, "linepub.png", width=Mm(120))
if charts(totallist,3,"lineptotal.png"):
context['filing2_pub_total_line'] = InlineImage(tpl, "lineptotal.png", width=Mm(120))
# 发展趋势-授权量
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{"terms": {"gr_year": yearlist}}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_year": {
"terms": {
"field": "gr_year",
"size": 10,
"order": {
"_term": "asc"
}
},
"aggregations": {
"group_by_type": {
"terms": {
"field": "pub_type",
"size": 10,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
}
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
sources = []
fmlist = [0,0,0,0,0,0,0,0,0,0]
xxlist = [0,0,0,0,0,0,0,0,0,0]
wglist = [0,0,0,0,0,0,0,0,0,0]
for aggs in searched["aggregations"]["group_by_year"]["buckets"]:
m=0
for year in yearlist:
if aggs["key"] == year:
fmlist[m] = aggs["group_by_type"]["buckets"][0]["doc_count"]
wglist[m] = aggs["group_by_type"]["buckets"][1]["doc_count"]
xxlist[m] = aggs["group_by_type"]["buckets"][2]["doc_count"]
m += 1
m=0
totallist = []
for year in yearlist:
total = fmlist[m] + xxlist[m] + wglist[m]
totallist.append({"key":year,"value":total})
source = {"year2":year,"fm2count":fmlist[m],"xx2count":xxlist[m],"wg2count":wglist[m],"total2count":total}
sources.append(source)
m+=1
context["grtms"] = sources
if chartslines(yearlist, fmlist,xxlist,wglist, "linegr.png"):
context['filing2_gr_line'] = InlineImage(tpl, "linegr.png", width=Mm(120))
if charts(totallist,3,"linegtotal.png"):
context['filing2_gr_total_line'] = InlineImage(tpl, "linegtotal.png", width=Mm(120))
#IPC分析-大类
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"terms": {
"pub_type": ["发明", "实用新型"]
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_ipc": {
"terms": {
"field": "large class",
"size": 10,
"order": {
"_count": "desc"
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
ipclist = []
for agg in searched["aggregations"]["group_by_ipc"]["buckets"]:
ipclist.append({"key":agg["key"],"value":agg["doc_count"]})
if charts(ipclist,6,"ipclarge.png"):
context['ipc_large'] = InlineImage(tpl, "ipclarge.png", width=Mm(120))
#IPC分析-小类
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"terms": {
"pub_type": ["发明", "实用新型"]
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_ipc": {
"terms": {
"field": "sub_class",
"size": 10,
"order": {
"_count": "desc"
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
ipclist = []
for agg in searched["aggregations"]["group_by_ipc"]["buckets"]:
ipclist.append({"key":agg["key"],"value":agg["doc_count"]})
if charts(ipclist,6,"ipcsmall.png"):
context['ipc_small'] = InlineImage(tpl, "ipcsmall.png", width=Mm(120))
#IPC分析-洛迦诺大类
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"term": {
"pub_type": "外观设计"
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_ipc": {
"terms": {
"field": "class_code",
"size": 10,
"order": {
"_count": "desc"
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
ipclist = []
for agg in searched["aggregations"]["group_by_ipc"]["buckets"]:
ipclist.append({"key":agg["key"],"value":agg["doc_count"]})
if charts(ipclist,6,"ljnlarge.png"):
context['ljn_large'] = InlineImage(tpl, "ljnlarge.png", width=Mm(120))
#IPC分析-洛迦诺小类
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"term": {
"pub_type": "外观设计"
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_ipc": {
"terms": {
"field": "main_ipc",
"size": 10,
"order": {
"_count": "desc"
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
ipclist = []
for agg in searched["aggregations"]["group_by_ipc"]["buckets"]:
ipclist.append({"key":agg["key"],"value":agg["doc_count"]})
if charts(ipclist,6,"ljnsmall.png"):
context['ljn_small'] = InlineImage(tpl, "ljnsmall.png", width=Mm(120))
#法律状态
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_type": {
"terms": {
"field": "pub_type",
"size": 20,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
},
"aggregations": {
"group_by_status": {
"terms": {
"field": "pub_status",
"size": 10,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
}
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
fminfo = []
xxinfo = []
wginfo = []
zxcount = [0,0,0]
wxcount = [0,0,0]
yxcount = [0,0,0]
for aggs in searched["aggregations"]["group_by_type"]["buckets"]:
if aggs["key"] == "发明":
for agg in aggs["group_by_status"]["buckets"]:
fminfo.append({"key":agg["key"],"value":agg["doc_count"]})
if agg["key"] == "在审":
zxcount[0] = agg["doc_count"]
elif agg["key"] == "有效":
yxcount[0] = agg["doc_count"]
elif agg["key"] == "无效":
wxcount[0] = agg["doc_count"]
elif aggs["key"] == "实用新型":
for agg in aggs["group_by_status"]["buckets"]:
xxinfo.append({"key":agg["key"],"value":agg["doc_count"]})
if agg["key"] == "在审":
zxcount[1] = agg["doc_count"]
elif agg["key"] == "有效":
yxcount[1] = agg["doc_count"]
elif agg["key"] == "无效":
wxcount[1] = agg["doc_count"]
elif aggs["key"] == "外观设计":
for agg in aggs["group_by_status"]["buckets"]:
wginfo.append({"key":agg["key"],"value":agg["doc_count"]})
if agg["key"] == "在审":
zxcount[2] = agg["doc_count"]
elif agg["key"] == "有效":
yxcount[2] = agg["doc_count"]
elif agg["key"] == "无效":
wxcount[2] = agg["doc_count"]
context["fl_fm_0"] = yxcount[0]
context["fl_xx_0"] = yxcount[1]
context["fl_wg_0"] = yxcount[2]
context["fl_fm_1"] = wxcount[0]
context["fl_xx_1"] = wxcount[1]
context["fl_wg_1"] = wxcount[2]
context["fl_fm_2"] = zxcount[0]
context["fl_xx_2"] = zxcount[1]
context["fl_wg_2"] = zxcount[2]
if charts(fminfo, 2, "piefmzs.png"):
context['fl_fm_pie'] = InlineImage(tpl, "piefmzs.png", width=Mm(60))
if charts(xxinfo, 2, "piexxzs.png"):
context['fl_xx_pie'] = InlineImage(tpl, "piexxzs.png", width=Mm(60))
if charts(wginfo, 2, "piewgzs.png"):
context['fl_wg_pie'] = InlineImage(tpl, "piewgzs.png", width=Mm(60))
#无效原因
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
},
{
"term": {
"pub_status": "无效"
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_status": {
"terms": {
"field": "pub_status_now",
"size": 20,
"order": {
"_count": "desc"
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
info = []
for agg in searched["aggregations"]["group_by_status"]["buckets"]:
info.append({"key":agg["key"],"value":agg["doc_count"]})
if charts(info, 2, "flpie.png"):
context['fl_pie'] = InlineImage(tpl, "flpie.png", width=Mm(120))
#申请人分析
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_appl": {
"terms": {
"field": "applicant_name.raw",
"size": 11,
"order": {
"_count": "desc"
}
},
"aggregations": {
"group_by_type": {
"terms": {
"field": "pub_type",
"size": 10,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
}
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
appllist = []
fmlist = []
xxlist = []
wglist = []
sources = []
if len(searched["aggregations"]["group_by_appl"]["buckets"]) > 1:
for m in range(1,len(searched["aggregations"]["group_by_appl"]["buckets"])):
key = searched["aggregations"]["group_by_appl"]["buckets"][m]["key"]
appllist.append(key)
fmcount = searched["aggregations"]["group_by_appl"]["buckets"][m]["group_by_type"]["buckets"][0]["doc_count"]
fmlist.append(fmcount)
wgcount = searched["aggregations"]["group_by_appl"]["buckets"][m]["group_by_type"]["buckets"][1]["doc_count"]
wglist.append(wgcount)
xxcount = searched["aggregations"]["group_by_appl"]["buckets"][m]["group_by_type"]["buckets"][2]["doc_count"]
xxlist.append(xxcount)
total = fmcount + xxcount + wgcount
sources.append({"name": key, "fmcount": fmcount, "xxcount": xxcount, "wgcount": wgcount,"totalcount": total})
context["appls"] = sources
if chartsbars(appllist,fmlist,xxlist,wglist,"appls.png"):
context['appl_line'] = InlineImage(tpl, "appls.png", width=Mm(120))
#发明人分析
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_appl": {
"terms": {
"field": "inventor_name.raw",
"size": 10,
"order": {
"_count": "desc"
}
},
"aggregations": {
"group_by_type": {
"terms": {
"field": "pub_type",
"size": 10,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
}
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
appllist = []
fmlist = []
xxlist = []
wglist = []
sources = []
for agg in searched["aggregations"]["group_by_appl"]["buckets"]:
key = agg["key"]
appllist.append(key)
fmcount = agg["group_by_type"]["buckets"][0]["doc_count"]
fmlist.append(fmcount)
wgcount = agg["group_by_type"]["buckets"][1]["doc_count"]
wglist.append(wgcount)
xxcount = agg["group_by_type"]["buckets"][2]["doc_count"]
xxlist.append(xxcount)
total = fmcount + xxcount + wgcount
sources.append({"name": key, "fmcount": fmcount, "xxcount": xxcount, "wgcount": wgcount, "totalcount": total})
context["invs"] = sources
if chartsbars(appllist,fmlist,xxlist,wglist,"invs.png"):
context['inv_line'] = InlineImage(tpl, "invs.png", width=Mm(120))
#代理机构分析
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_appl": {
"terms": {
"field": "agency_name.raw",
"size": 10,
"order": {
"_count": "desc"
}
},
"aggregations": {
"group_by_type": {
"terms": {
"field": "pub_type",
"size": 10,
"min_doc_count": 0,
"order": {
"_term": "asc"
}
}
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
appllist = []
fmlist = []
xxlist = []
wglist = []
sources = []
for agg in searched["aggregations"]["group_by_appl"]["buckets"]:
key = agg["key"]
appllist.append(key)
fmcount = agg["group_by_type"]["buckets"][0]["doc_count"]
fmlist.append(fmcount)
wgcount = agg["group_by_type"]["buckets"][1]["doc_count"]
wglist.append(wgcount)
xxcount = agg["group_by_type"]["buckets"][2]["doc_count"]
xxlist.append(xxcount)
total = fmcount + xxcount + wgcount
sources.append({"name": key, "fmcount": fmcount, "xxcount": xxcount, "wgcount": wgcount, "totalcount": total})
context["agns"] = sources
if chartsbars(appllist,fmlist,xxlist,wglist,"agns.png"):
context['agn_line'] = InlineImage(tpl, "agns.png", width=Mm(120))
#专利技术分析
doc = {"query": {"bool": {"must": [{"term": {"applicant_name.raw": mycompanyname}}]}},
"aggregations": {
"types": {
"terms": {
"field": "key_word",
"size": 50,
"order": {
"_count": "desc"
}
}
}
}}
searched = es.search(index=index_name, body=doc)
tmnames = ""
m=1
for buk in searched["aggregations"]["types"]["buckets"]:
if m==1:
context["keyword1"] = buk["key"]
context["key_word1"] = buk["key"]
context["key_count1"] = buk["doc_count"]
elif m==2:
context["keyword2"] = buk["key"]
context["key_word2"] = buk["key"]
context["key_count2"] = buk["doc_count"]
elif m==3:
context["keyword3"] = buk["key"]
context["key_word3"] = buk["key"]
context["key_count3"] = buk["doc_count"]
elif m==4:
context["keyword4"] = buk["key"]
context["key_word4"] = buk["key"]
context["key_count4"] = buk["doc_count"]
m+=1
for i in range(buk["doc_count"]):
tmnames = tmnames + buk["key"] + " "
if tmnames:
if createciyuntm(tmnames,"ciyun.png"):
context['key_yun'] = InlineImage(tpl, "ciyun.png", width=Mm(150))
#专利产业布局
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
}
]
}
},
"aggregations": {
"types": {
"terms": {
"field": "broad_name",
"size": 50,
"order": {
"_count": "desc"
}
}
}
}
}
searched = es.search(index=index_name, body=doc)
if len(searched["aggregations"]["types"]["buckets"]) >0:
brodinfo = []
if len(searched["aggregations"]["types"]["buckets"]) <= 10:
m = 1
for buk in searched["aggregations"]["types"]["buckets"]:
if m == 1:
context["broad1"] = buk["key"]
elif m == 2:
context["broad2"] = buk["key"]
elif m == 3:
context["broad3"] = buk["key"]
elif m == 4:
context["broad4"] = buk["key"]
m += 1
brodinfo.append({"key":buk["key"],"value":buk["doc_count"]})
else:
for i in range(10):
brodinfo.append({"key": searched["aggregations"]["types"]["buckets"][i]["key"], "value":
searched["aggregations"]["types"]["buckets"][i]["doc_count"]})
if i==0:
context["broad1"] = searched["aggregations"]["types"]["buckets"][i]["key"]
elif i==1:
context["broad2"] = searched["aggregations"]["types"]["buckets"][i]["key"]
elif i==2:
context["broad3"] = searched["aggregations"]["types"]["buckets"][i]["key"]
elif i==3:
context["broad3"] = searched["aggregations"]["types"]["buckets"][i]["key"]
other_count = 0;
for i in range(10,len(searched["aggregations"]["types"]["buckets"])):
other_count += searched["aggregations"]["types"]["buckets"][i]["doc_count"]
if other_count:
brodinfo.append({"key": "其它", "value": other_count})
if brodinfo:
if charts(brodinfo, 2, "piebrod.png"):
context['broad_pai'] = InlineImage(tpl, "piebrod.png", width=Mm(120))
#专利详情
doc = {
"query": {
"bool": {
"must": [
{
"term": {
"applicant_name.raw": mycompanyname
}
}
]
}
},
"from": 0,
"size": 100,
"sort": [
{
"pub_date": "desc"
}
],
"_source": [
"filing_no",
"pub_type",
"filing_time",
"pub_time",
"pub_no",
"gr_time",
"gr_no",
"filing_name",
"pub_status",
"abstr_text",
"main_ipc",
"broad_name"
]
}
searched = es.search(index=index_name, body=doc)
p_source = []
m=1
for hit in searched["hits"]["hits"]:
bg = "000000"
if hit["_source"]["pub_status"] == "无效":
bg = 'FF0000'
if hit["_source"]["gr_no"]:
pn = hit["_source"]["gr_no"]
pd = hit["_source"]["gr_time"]
else:
pn = hit["_source"]["pub_no"]
pd = hit["_source"]["pub_time"]
list = hit["_source"]["broad_name"]
broad_name = ""
if list:
for br in list:
broad_name += br + ";"
broad_name = broad_name.strip(";")
p_source.append({"no": m, "fn": hit["_source"]["filing_no"], "fd": hit["_source"]["filing_time"],
"pn": pn, "pd": pd,"pt":hit["_source"]["pub_type"],"ps":RichText(hit["_source"]["pub_status"],color=bg),
"title":hit["_source"]["filing_name"],"bord":broad_name})
m+=1
if p_source:
context["ps"] = p_source
nowtime = time.strftime('%Y-%m-%d', time.localtime())
context['nowtime'] = nowtime
tpl.render(context)
tpl.save('cellbg1.docx')
# 生成新的word文件
# Docx = Document("aaa.docx")
# os.remove("aaa.docx")
# 保存文件
#Docx.save(mycompanyname + "python.docx")
current_file_path = "patent.docx"
current_fold = time.strftime('%Y%m%d%H%M%S', time.localtime())
file_path = mycompanyname + "patent.docx"
p = mycompanyname + "_" + str(current_fold) + "_" + current_file_path
print(p)
# 上传阿里云
bucket.put_object_from_file(p, "cellbg1.docx")
os.remove("cellbg1.docx")
return "https://gsb-zc.oss-cn-beijing.aliyuncs.com/"+p
# 服务器接口API
@app.route('/patentdoc/api/createdoc',methods=['POST', 'GET'])
def PatentDocApi():
if request.method == "GET":
mycompanyname = request.args.get("mycompanyname") # 得到问题
if request.method == "POST":
mycompanyname = request.get_json().get("mycompanyname") # 得到问题
r_1 = create_doc(strQ2B(mycompanyname))
return r_1
if __name__ == '__main__':
#app.run(host='127.0.0.1', port=5000, debug=True)
app.run(host='172.16.18.120', port=9500, debug=True)
from pyecharts.charts import Gauge,Pie,Line,Bar
from pyecharts.render import make_snapshot
from snapshot_selenium import snapshot
from pyecharts import options as opts
def charts(datalist,charttype,pngpath):
try:
img = None
if charttype == 1: #仪表盘
img = Gauge()
img.add("知产价值评估",[("", datalist[0]["value"])], axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(
color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30
)),label_opts=opts.LabelOpts(formatter="{value}"))
elif charttype == 2:#饼状图
img = Pie()
valuelist = []
for list in datalist:
valuelist.append((list["key"],list["value"]))
img.add("", valuelist, label_opts=opts.LabelOpts(formatter="{b}: {c}"))
elif charttype ==3:#折线图
img = Line()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("",valuelist,color= "#1E90FF")
elif charttype ==4:#柱状图
img = Bar()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("",valuelist,color= "#1E90FF")
if img:
make_snapshot(snapshot, img.render(), pngpath)
return True
else:
return False
except Exception as e1:
print(e1)
return False
# 下面一句的作用1是:运行本程序文件时执行什么操作
if __name__ == "__main__":
data1 = [{"key":"价值评价","value":55.9}]
charts(data1,1,"1.png")
name = ["2014", "2015", "2016", "2017", "2018", "2019"]
value = [100, 300, 250, 90, 150, 50]
data2 = [{"key":"运行","value":100},{"key":"2015","value":300},{"key":"2016","value":250},{"key":"2017","value":150},
{"key":"2018","value":200},{"key":"2019","value":90}]
charts(data2,2,"2.png")
charts(data2,3,"3.png")
charts(data2,4,"4.png")
charts(data2,5,"5.png")
print("over")
#-*- encoding:utf-8 -*-
from elasticsearch import Elasticsearch
import time, datetime
import oss2
from flask import Flask , render_template,request
from docxtpl import DocxTemplate, RichText,InlineImage
import os
from docx.shared import Inches, Pt, RGBColor, Mm
from pyecharts.charts import Gauge,Pie,Line,Bar
from pyecharts.render import make_snapshot
from snapshot_selenium import snapshot
from pyecharts import options as opts
import json
import numpy as np
import PIL.Image as image
from wordcloud import WordCloud
file_object = open('ncltwo.json',encoding='UTF-8')
app = Flask(__name__)
# esip = "43.247.184.94"
# esport = 9200
# # esip = "172.16.18.120"
# # esport = 9201
# esuser = "admines"
# espassword = "adminGSBes"
# es = Elasticsearch([esip], http_auth=(esuser, espassword), port=esport)
#
# esip1 = "43.247.184.94"
# esport1 = 9200
# es1 = Elasticsearch([esip], http_auth=(esuser, espassword), port=7200)
# esip = "43.247.184.94"
#esport = 9200
esip = "172.16.18.110"
esport = 9201
esuser = "admines"
espassword = "adminGSBes"
es = Elasticsearch([esip], http_auth=(esuser, espassword), port=esport)
esip1 = "172.16.18.10"
esport1 = 9200
es1 = Elasticsearch([esip1], http_auth=(esuser, espassword), port=esport1)
# 阿里云接口地址
endpoint = 'http://oss-cn-beijing.aliyuncs.com'
auth = oss2.Auth('LTAI4GC5tSKvqsH2hMqj6pvd', '3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5')
bucket = oss2.Bucket(auth, endpoint, 'gsb-zc')
ncl_one=[ "化学原料","颜料油漆","日化用品","燃料油脂","医药","金属材料","机械设备","手工器械","科学仪器","医疗器械","灯具空调","运输工具","军火烟火","珠宝钟表","乐器","办公用品","橡胶制品","皮革皮具","筑材料","家具","厨房洁具","绳网袋蓬","纱线丝","布料床单","服装鞋帽","钮扣拉链","地毯席垫",
"健身器材","食品","方便食品","农林生鲜","啤酒饮料","酒","烟草烟具","广告销售","金融物管","建筑修理","通讯服务","运输贮藏","材料加工","教育娱乐","科技服务","餐饮住宿","医疗园艺","社会服务"]
file_context = json.load(file_object)
ncl_two=file_context["RECORDS"]
dict_ncl_two={}
for n in ncl_two:
dict_ncl_two[n["code"]]=n["name"]
b=dict_ncl_two
#生成图片
def charts(datalist,charttype,pngpath):
try:
img = None
if charttype == 1: #仪表盘
img = Gauge()
img.add("知产价值评估",[("", datalist[0]["value"])], axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(
color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30
)),label_opts=opts.LabelOpts(formatter="{value}"))
elif charttype == 2:#饼状图
img = Pie()
valuelist = []
for list in datalist:
valuelist.append((list["key"],list["value"]))
img.add("", valuelist, label_opts=opts.LabelOpts(formatter="{b}: {c}"))
elif charttype ==3:#折线图
img = Line()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("",valuelist,color= "#1E90FF")
elif charttype ==4:#柱状图
img = Bar()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("",valuelist,color= "#1E90FF")
elif charttype ==5:
img=WordCloud()
words=[]
for list in datalist:
if len(words)<10:
word=(list["key"],int(list["value"]))
words.append(word)
else:
break
img.add("",words,word_size_range=[20,100])
if img:
make_snapshot(snapshot, img.render(), pngpath)
return True
else:
return False
except Exception as e:
print(e)
return False
def strQ2B(ustring):
"""全角转半角"""
rstring = ""
for uchar in ustring:
inside_code=ord(uchar)
if inside_code == 12288: #全角空格直接转换
inside_code = 32
elif (inside_code >= 65281 and inside_code <= 65374): #全角字符(除空格)根据关系转化
inside_code -= 65248
rstring += chr(inside_code)
return rstring
def sortlist(lis):
#进行去重
c = []
for i in lis:
if i not in c:
c.append(i)
#进行统计,生成二维列表
b = []
for i in c:
num = 0
for j in range(len(lis)):
if lis[j] == i:
num += 1
a = []
a.append(i)
a.append(num)
b.append(a)
# 排序算法,按出现次数进行降序排列
for i in range(len(b)):
for j in range(i,len(b)):
if b[i][1] < b[j][1]:
temp = b[i]
b[i] = b[j]
b[j] = temp
print(b)
strlist=""
if len(b)>5:
for k1 in range(5):
if int(b[k1][0])<50:
strlist += str(ncl_one[int(b[k1][0])-1]) + "、"
else:
strlist+=str(b[k1][0])+"、"
else:
for k2 in b:
if int(k2[0])<50:
strlist += str(ncl_one[int(k2[0])-1]) + "、"
else:
strlist+=str(k2[0])+"、"
strlist=strlist[:-1]
return strlist
def createciyun(list):
cut_text=""
mask=np.array(image.open("tm.jpg"))
for i in list:
if i in dict_ncl_two.keys():
cut_text+=dict_ncl_two[i]+" "
if not cut_text:
cut_text="暂无数据 "
wordcloud = WordCloud(
font_path="SIMSUN.TTC",
mask=mask,
background_color="white", width=100, height=80).generate(cut_text)
wordcloud.to_file("ciyun.png")
return True
def createciyuntm(cut_text):
mask=np.array(image.open("tm2.jpg"))
if not cut_text:
cut_text="暂无数据 "
wordcloud = WordCloud(
font_path="SIMSUN.TTC",
mask=mask,
background_color="white", width=100, height=80).generate(cut_text)
wordcloud.to_file("ciyuntm.png")
return True
def categorylist(lis):
#进行去重
c = []
for i in lis:
if i not in c:
c.append(i)
#进行统计,生成二维列表
b = []
for i in c:
num = 0
for j in range(len(lis)):
if lis[j] == i:
num += 1
a = []
a.append(i)
a.append(num)
b.append(a)
# 排序算法,按出现次数进行降序排列
for i in range(len(b)):
for j in range(i,len(b)):
if b[i][1] < b[j][1]:
temp = b[i]
b[i] = b[j]
b[j] = temp
print(b)
strlist=[]
if len(b)>5:
for k1 in range(5):
source={"key":b[k1][0],"value":b[k1][1]}
strlist.append(source)
else:
for k2 in b:
source ={"key":ncl_one[int(k2[0])-1], "value": k2[1]}
strlist.append(source)
return strlist
def ncltwolist(lis):
#进行去重
c = []
for i in lis:
if i not in c:
c.append(i)
#进行统计,生成二维列表
b = []
for i in c:
num = 0
for j in range(len(lis)):
if lis[j] == i:
num += 1
a = []
a.append(i)
a.append(num)
b.append(a)
# 排序算法,按出现次数进行降序排列
for i in range(len(b)):
for j in range(i,len(b)):
if b[i][1] < b[j][1]:
temp = b[i]
b[i] = b[j]
b[j] = temp
print(b)
strlist=[]
for k2 in b:
if k2[0] in dict_ncl_two.keys():
source = {"key": dict_ncl_two[k2[0]], "value": k2[1]}
strlist.append(source)
return strlist
def yearlist(lis):
count2014 = 0
count2015 = 0
count2016 = 0
count2017 = 0
count2018 = 0
count2019 = 0
for i in lis:
if i==2014:
count2014+=1
if i==2015:
count2015+=1
if i==2016:
count2016+=1
if i==2017:
count2017+=1
if i==2018:
count2018+=1
if i==2019:
count2019+=1
count = [{"key":"2014","value":str(count2014)},{"key":"2015","value":str(count2015)},{"key":"2016","value":str(count2016)},
{"key":"2017","value":str(count2017)},{"key":"2018","value":str(count2018)},{"key":"2019","value":str(count2019)}]
return count
def create_doc(mycompanyname,rivalcompanyname):
# 读取模板文件
tpl = DocxTemplate('cellbg.docx')
# 工商接口
resjq = es.search(index="bigdata_ic_gsb_company_op",
body={"query": {"term": {"company_name.raw": mycompanyname}}})
context={'template': mycompanyname}
if resjq["hits"]["hits"]:
mycompanyinfo = resjq["hits"]["hits"][0]["_source"]
reg_number=str(mycompanyinfo["reg_number"])
context['reg_number']=reg_number
org_number = "未公开"
if mycompanyinfo["org_number"]:
org_number = str(mycompanyinfo["org_number"])
context['org_number'] = org_number
legal_person = "未公开"
if mycompanyinfo["legal_person"]:
legal_person = str(mycompanyinfo["legal_person"])
context['legal_person'] = legal_person
reg_status = "未公开"
if mycompanyinfo["reg_status"]:
reg_status = str(mycompanyinfo["reg_status"])
context['reg_status'] = reg_status
estibish_time = "未公开"
if mycompanyinfo["estiblish_time"]:
estibish_time = str(time.strftime("%Y-%m-%d", time.localtime(mycompanyinfo["estiblish_time"])))
context['estibish_time'] = estibish_time
to_time = "未公开"
if mycompanyinfo["to_time"]:
to_time = str(time.strftime("%Y-%m-%d", time.localtime(mycompanyinfo["to_time"])))
context['to_time'] = to_time
reg_capital = "未公开"
if mycompanyinfo["reg_capital"] and mycompanyinfo["reg_capital"]!=0 and mycompanyinfo["reg_unit"]:
reg_capital = str(mycompanyinfo["reg_capital"])+" "+str(mycompanyinfo["reg_unit"])
context['reg_capital'] = reg_capital
reg_institute = "未公开"
if mycompanyinfo["reg_institute"]:
reg_institute = str(mycompanyinfo["reg_institute"])
context['reg_institute'] = reg_institute
reg_location = "未公开"
if mycompanyinfo["reg_location"]:
reg_location = str(mycompanyinfo["reg_location"])
context['reg_location'] = reg_location
business_scope = "未公开"
if mycompanyinfo["business_scope"]:
business_scope = str(mycompanyinfo["business_scope"])
context['business_scope'] = business_scope
# 商标接口
resjq = es1.search(index="bigdata_middle_gsb_tm_info",
body={"size": 1000, "query": {"term": {"applicant_cn": mycompanyname}}})
mytminfo = resjq["hits"]["hits"]
yx = 0
sqz = 0
wx = 0
ot = 0
years = []
nclone = []
ncltwos=[]
tmnames=""
if mytminfo:
# 获得所需数组
for i in mytminfo:
years.append(i["_source"]["apply_year"])
nclone.append(i["_source"]["ncl_one_codes"])
if 'ncl_two_codes' in i["_source"].keys():
if i["_source"]["ncl_two_codes"]:
ncltwos+=i["_source"]["ncl_two_codes"]
if i["_source"]["tm_name"]:
if "图形" not in i["_source"]["tm_name"]:
tmnames+=i["_source"]["tm_name"]+" "
if i["_source"]["status"] == 1:
sqz += 1
elif i["_source"]["status"] == 2 or i["_source"]["status"] == 3:
yx += 1
elif i["_source"]["status"] == 4:
wx += 1
else:
ot += 1
# 计算评分
grades = 70
if len(mytminfo) > 50 and len(mytminfo) <= 100:
grades = 75
elif len(mytminfo) > 100 and len(mytminfo) <= 200:
grades = 80
elif len(mytminfo) > 200 and len(mytminfo) <= 500:
grades = 85
elif len(mytminfo) > 500:
grades = 90
pie=""
guage=""
line=""
bar=""
tciyun=""
tciyuntm=""
if charts([{"key": "", "value": grades}], 1, "yibiaopan.png"):
guage="yibiaopan.png"
info = [{"key": "有效注册", "value": str(yx)}, {"key": "申请中", "value": str(sqz)},
{"key": "无效", "value": str(wx)}, {"key": "其他", "value": str(ot)}]
if charts(info, 2, "bar01.png"):
pie = "bar01.png"
yearls=yearlist(years)
if charts(yearls, 3, "zx01.png"):
line="zx01.png"
if createciyun(ncltwos):
tciyun="ciyun.png"
if createciyuntm(tmnames):
tciyuntm="ciyuntm.png"
nclones = categorylist(nclone)
nclone1=""
countnclone1=""
nclone2 = ""
countnclone2 = ""
nclone3 = ""
countnclone3 = ""
nclone4 = ""
countnclone4 = ""
nclone5 = ""
countnclone5 = ""
if charts(nclones, 4, "zz01.png"):
bar="zz01.png"
nclone1 = nclones[0]['key']
countnclone1 = nclones[0]['value']
if len(nclones)>1:
nclone2 = nclones[1]['key']
countnclone2 = nclones[1]['value']
if len(nclones)>2:
nclone3 = nclones[2]['key']
countnclone3 = nclones[2]['value']
if len(nclones)>3:
nclone4 = nclones[3]['key']
countnclone4 = nclones[3]['value']
if len(nclones)>4:
nclone5 = nclones[4]['key']
countnclone5 = nclones[4]['value']
ncltwotables=ncltwolist(ncltwos)
ncltwo1 = ""
countncltwo1 = ""
ncltwo2 = ""
countncltwo2 = ""
ncltwo3 = ""
countncltwo3 = ""
ncltwo4 = ""
countncltwo4 = ""
ncltwo5 = ""
countncltwo5 = ""
if len(ncltwotables) > 0:
ncltwo1 = ncltwotables[0]['key']
countncltwo1 = ncltwotables[0]['value']
if len(ncltwotables)>1:
ncltwo2 = ncltwotables[1]['key']
countncltwo2 = ncltwotables[1]['value']
if len(ncltwotables)>2:
ncltwo3 = ncltwotables[2]['key']
countncltwo3 = ncltwotables[2]['value']
if len(ncltwotables)>3:
ncltwo4 = ncltwotables[3]['key']
countncltwo4 = ncltwotables[3]['value']
if len(ncltwotables)>4:
ncltwo5 = ncltwotables[4]['key']
countncltwo5 = ncltwotables[4]['value']
# 获取时间戳
beforetime = datetime.datetime.now() + datetime.timedelta(days=365)
aftertime = datetime.datetime.now() - datetime.timedelta(days=183)
nowTime = datetime.datetime.now()
nowday = datetime.date.today()
sources=[]
for m in mytminfo:
tm_regist_num=m["_source"]["tm_regist_num"]
tm_name="未公开"
if m["_source"]["tm_name"]:
tm_name=m["_source"]["tm_name"]
bg="FFFFFF"
if m["_source"]["tm_end_day"]:
if int(m["_source"]["tm_end_day"]) < int(beforetime.timestamp()) and int(
m["_source"]["tm_end_day"]) > int(nowTime.timestamp()):
bg = 'FF0000'
elif int(m["_source"]["tm_end_day"]) < int(nowTime.timestamp()) and int(
m["_source"]["tm_end_day"]) > int(aftertime.timestamp()):
bg = 'FF0000'
tm_status = "未公开"
if m["_source"]["status"] == 1:
tm_status = "申请中"
elif m["_source"]["status"] == 2:
tm_status = "初审"
elif m["_source"]["status"] == 3:
tm_status = "注册"
apply_day = "未公开"
if m["_source"]["apply_day"]:
apply_day = time.strftime("%Y-%m-%d", time.localtime(m["_source"]["apply_day"]))
regist_notice_day = "未公开"
if m["_source"]["regist_notice_day"]:
regist_notice_day = time.strftime("%Y-%m-%d", time.localtime(m["_source"]["regist_notice_day"]))
tm_end_day = "未公开"
if m["_source"]["regist_notice_day"]:
tm_end_day = time.strftime("%Y-%m-%d", time.localtime(m["_source"]["tm_end_day"]))
ncl_one_codes = m["_source"]["ncl_one_codes"]
source={"tm_regist_num":tm_regist_num,"tm_name":tm_name,"tm_status":tm_status,"apply_day":apply_day,"regist_notice_day":regist_notice_day,"tm_end_day":tm_end_day,"ncl_one_codes":ncl_one_codes,"bg":bg}
sources.append(source)
context['validate_Num'] = str(yx)
context['invalidate_Num'] = str(wx)
context['application_Num'] = str(sqz)
context['other_Num'] = str(ot)
context['tms'] = sources
context['guage'] = InlineImage(tpl, guage, width=Mm(80))
context['pie'] = InlineImage(tpl, pie, width=Mm(80))
context['line'] = InlineImage(tpl, line, width=Mm(130))
context['bar'] = InlineImage(tpl, bar, width=Mm(130))
context['tciyun'] = InlineImage(tpl, tciyun, width=Mm(130))
context['tciyuntm'] = InlineImage(tpl, tciyuntm, width=Mm(130))
context['count2014'] = yearls[0]['value']
context['count2015'] = yearls[1]['value']
context['count2016'] = yearls[2]['value']
context['count2017'] = yearls[3]['value']
context['count2018'] = yearls[4]['value']
context['count2019'] = yearls[5]['value']
context['nclone1'] = nclone1
context['countnclone1'] = countnclone1
context['nclone2'] = nclone2
context['countnclone2'] = countnclone2
context['nclone3'] = nclone3
context['countnclone3'] = countnclone3
context['nclone4'] = nclone4
context['countnclone4'] = countnclone4
context['nclone5'] = nclone5
context['countnclone5'] = countnclone5
context['ncltwo1'] = ncltwo1
context['countncltwo1'] = countncltwo1
context['ncltwo2'] = ncltwo2
context['countncltwo2'] = countncltwo2
context['ncltwo3'] = ncltwo3
context['countncltwo3'] = countncltwo3
context['ncltwo4'] = ncltwo4
context['countncltwo4'] = countncltwo4
context['ncltwo5'] = ncltwo5
context['countncltwo5'] = countncltwo5
tpl.render(context)
tpl.save('cellbg1.docx')
# 生成新的word文件
# Docx = Document("aaa.docx")
# os.remove("aaa.docx")
# 保存文件
# Docx.save(mycompanyname + "python.docx")
current_file_path = "tmreport.docx"
current_fold = time.strftime('%Y%m%d%H%M%S', time.localtime())
file_path = "cellbg1.docx"
p = mycompanyname + "_" + str(current_fold) + "_" + current_file_path
print(p)
# 上传阿里云
bucket.put_object_from_file(p, file_path)
os.remove(file_path)
return "https://gsb-zc.oss-cn-beijing.aliyuncs.com/"+p
# 服务器接口API
@app.route('/tmdoc/api/createdoc',methods=['POST', 'GET'])
def RobotApi():
rivalcompanyname=None
if request.method == "GET":
mycompanyname = request.args.get("mycompanyname") # 得到问题
if request.args.get("rivalcompanyname"):
rivalcompanyname = request.args.get("rivalcompanyname")
if request.method == "POST":
mycompanyname = request.get_json.get("mycompanyname") # 得到问题
if request.get_json.get("rivalcompanyname"):
rivalcompanyname = request.get_json.get("rivalcompanyname")
print(strQ2B(mycompanyname))
r_1 = create_doc(strQ2B(mycompanyname),rivalcompanyname)
return r_1
if __name__ == '__main__':
#server.run(host='127.0.0.1', port=8888, debug=True)
# app.run(host='192.168.18.181', port=8888, debug=True)
app.run(
host='172.16.18.2',
port=8015,
debug=True
)
{
"RECORDS":[
{
"code":"0101",
"name":"工业气体,单质"
},
{
"code":"0102",
"name":"用于工业、科学、农业、园艺、林业的工业化工原料"
},
{
"code":"0103",
"name":"放射性元素及其化学品"
},
{
"code":"0104",
"name":"用于工业、科学的化学品、化学制剂,不属于其他类别的产品用的化学制品"
},
{
"code":"0105",
"name":"用于农业、园艺、林业的化学品、化学制剂"
},
{
"code":"0106",
"name":"化学试剂"
},
{
"code":"0107",
"name":"摄影用化学用品及材料"
},
{
"code":"0108",
"name":"未加工的人造合成树脂,未加工塑料物质(不包括未加工的天然树脂)"
},
{
"code":"0109",
"name":"肥料"
},
{
"code":"0110",
"name":"灭火、防火用合成物"
},
{
"code":"0111",
"name":"淬火用化学制剂"
},
{
"code":"0112",
"name":"焊接用化学制剂"
},
{
"code":"0113",
"name":"食药用化学品(不包括食品用防腐盐)"
},
{
"code":"0114",
"name":"鞣料及皮革用化学品"
},
{
"code":"0115",
"name":"工业用黏合剂和胶(不包括纸用黏合剂)"
},
{
"code":"0116",
"name":"纸浆"
},
{
"code":"0201",
"name":"染料,媒染剂(不包括食用)"
},
{
"code":"0202",
"name":"颜料(不包括食用、绝缘用),绘画、装饰、印刷和艺术用金属箔及金属粉"
},
{
"code":"0203",
"name":"食品着色剂"
},
{
"code":"0204",
"name":"油墨"
},
{
"code":"0205",
"name":"涂料,油漆及附料(不包括绝缘漆)"
},
{
"code":"0206",
"name":"防锈剂,木材防腐剂"
},
{
"code":"0207",
"name":"未加工的天然树脂"
},
{
"code":"0301",
"name":"肥皂,香皂及其他人用洗洁物品,洗衣用漂白剂及其他物料"
},
{
"code":"0302",
"name":"清洁、去渍用制剂"
},
{
"code":"0303",
"name":"抛光、擦亮制剂"
},
{
"code":"0304",
"name":"研磨用材料及其制剂"
},
{
"code":"0305",
"name":"香料,香精油"
},
{
"code":"0306",
"name":"化妆品(不包括动物用化妆品)"
},
{
"code":"0307",
"name":"牙膏,洗牙用制剂"
},
{
"code":"0308",
"name":"熏料"
},
{
"code":"0309",
"name":"动物用化妆品"
},
{
"code":"0310",
"name":"室内芳香剂"
},
{
"code":"0401",
"name":"工业用油及油脂,润滑油,润滑剂(不包括燃料用油)"
},
{
"code":"0402",
"name":"液体、气体燃料和照明燃料"
},
{
"code":"0403",
"name":"固体燃料"
},
{
"code":"0404",
"name":"工业用蜡"
},
{
"code":"0405",
"name":"照明用蜡烛和灯芯"
},
{
"code":"0406",
"name":"吸收、润湿和黏结灰尘用合成物"
},
{
"code":"0407",
"name":"能源"
},
{
"code":"0501",
"name":"药品,消毒剂,中药药材,药酒"
},
{
"code":"0502",
"name":"医用营养品,人用膳食补充剂,婴儿食品"
},
{
"code":"0503",
"name":"净化制剂"
},
{
"code":"0504",
"name":"兽药,动物用膳食补充剂"
},
{
"code":"0505",
"name":"杀虫剂,除莠剂,农药"
},
{
"code":"0506",
"name":"卫生用品,绷敷材料,医用保健袋"
},
{
"code":"0507",
"name":"填塞牙孔用料,牙科用蜡"
},
{
"code":"0508",
"name":"单一商品"
},
{
"code":"0601",
"name":"普通金属及其合金、板、各种型材(不包括焊接及铁路用金属材料)"
},
{
"code":"0602",
"name":"普通金属管及其配件"
},
{
"code":"0603",
"name":"金属建筑材料,可移动金属建筑物(不包括建筑小五金)"
},
{
"code":"0604",
"name":"铁路用金属材料"
},
{
"code":"0605",
"name":"非电气用缆索和金属线、网、带"
},
{
"code":"0606",
"name":"缆绳用非电气金属附件"
},
{
"code":"0607",
"name":"钉及标准紧固件"
},
{
"code":"0608",
"name":"家具及门窗的金属附件"
},
{
"code":"0609",
"name":"日用五金器具"
},
{
"code":"0610",
"name":"非电子锁"
},
{
"code":"0611",
"name":"保险箱柜"
},
{
"code":"0612",
"name":"金属器具,金属硬件(非机器零件)"
},
{
"code":"0613",
"name":"金属容器"
},
{
"code":"0614",
"name":"金属标牌"
},
{
"code":"0615",
"name":"动物用金属制品"
},
{
"code":"0616",
"name":"焊接用金属材料(不包括塑料焊丝)"
},
{
"code":"0617",
"name":"锚,停船用金属浮动船坞,金属下锚桩"
},
{
"code":"0618",
"name":"手铐,金属制身份鉴别手环"
},
{
"code":"0619",
"name":"(测气象或风力的)金属风标"
},
{
"code":"0620",
"name":"金属植物保护器"
},
{
"code":"0621",
"name":"捕野兽陷阱"
},
{
"code":"0622",
"name":"普通金属艺术品,青铜(艺术品)"
},
{
"code":"0623",
"name":"矿石,矿砂"
},
{
"code":"0624",
"name":"金属棺(埋葬用),金属棺材扣件,棺材用金属器材"
},
{
"code":"0701",
"name":"农业用机械及部件(不包括小农具)"
},
{
"code":"0702",
"name":"渔牧业用机械及器具"
},
{
"code":"0703",
"name":"伐木、锯木、木材加工及火柴生产用机械及器具"
},
{
"code":"0704",
"name":"造纸及加工纸制品工业用机械及器具"
},
{
"code":"0705",
"name":"印刷工业用机械及器具"
},
{
"code":"0706",
"name":"纤维加工及纺织、针织工业用机械及部件"
},
{
"code":"0707",
"name":"印染工业用机械"
},
{
"code":"0708",
"name":"制茶工业用机械"
},
{
"code":"0709",
"name":"食品业用机械及部件"
},
{
"code":"0710",
"name":"酿造、饮料工业用机械"
},
{
"code":"0711",
"name":"烟草工业用机械"
},
{
"code":"0712",
"name":"皮革工业用机械"
},
{
"code":"0713",
"name":"缝纫、制鞋工业用机械"
},
{
"code":"0714",
"name":"自行车工业用设备"
},
{
"code":"0715",
"name":"陶瓷、砖、瓦制造机械"
},
{
"code":"0716",
"name":"工业用雕刻、打标机械"
},
{
"code":"0717",
"name":"制电池机械"
},
{
"code":"0718",
"name":"日用杂品加工机械"
},
{
"code":"0719",
"name":"制搪瓷机械"
},
{
"code":"0720",
"name":"制灯泡机械"
},
{
"code":"0721",
"name":"包装机械(不包括成套设备专用包装机械)"
},
{
"code":"0722",
"name":"民用煤加工机械"
},
{
"code":"0723",
"name":"厨房家用器具(不包括烹调、电气加热设备及厨房手工具)"
},
{
"code":"0724",
"name":"洗衣机"
},
{
"code":"0725",
"name":"制药工业用机械及部件"
},
{
"code":"0726",
"name":"橡胶、塑料工业机械"
},
{
"code":"0727",
"name":"玻璃工业用机械"
},
{
"code":"0728",
"name":"化肥设备"
},
{
"code":"0729",
"name":"其他化学工业用机械"
},
{
"code":"0730",
"name":"地质勘探、采矿、选矿用机械"
},
{
"code":"0731",
"name":"冶炼工业用设备"
},
{
"code":"0732",
"name":"石油开采、精炼工业用设备"
},
{
"code":"0733",
"name":"建筑、铁道、土木工程用机械"
},
{
"code":"0734",
"name":"起重运输机械"
},
{
"code":"0735",
"name":"锻压设备"
},
{
"code":"0736",
"name":"铸造机械"
},
{
"code":"0737",
"name":"蒸汽动力设备"
},
{
"code":"0738",
"name":"内燃动力设备"
},
{
"code":"0739",
"name":"风力、水力动力设备"
},
{
"code":"0740",
"name":"制办公用针钉机械"
},
{
"code":"0741",
"name":"制纽扣拉链机械"
},
{
"code":"0742",
"name":"金属切削机床, 切削工具和其他金属加工机械"
},
{
"code":"0743",
"name":"非手动的手持工具"
},
{
"code":"0744",
"name":"静电、电子工业用设备"
},
{
"code":"0745",
"name":"光学工业用设备"
},
{
"code":"0746",
"name":"气体分离设备"
},
{
"code":"0747",
"name":"喷漆机具"
},
{
"code":"0748",
"name":"发电机,非陆地车辆用马达和引擎,马达和引擎零部件"
},
{
"code":"0749",
"name":"泵,阀,气体压缩机,风机,液压元件,气动元件"
},
{
"code":"0750",
"name":"机器传动用联轴节,传动带及其他机器零部件"
},
{
"code":"0751",
"name":"焊接机械"
},
{
"code":"0752",
"name":"清洁、废物处理机械"
},
{
"code":"0753",
"name":"单一商品"
},
{
"code":"0754",
"name":"电镀设备"
},
{
"code":"0801",
"name":"手动研磨器具"
},
{
"code":"0802",
"name":"小农具(不包括农业、园艺用刀剪)"
},
{
"code":"0803",
"name":"林业、园艺用手工具"
},
{
"code":"0804",
"name":"畜牧业用手工具"
},
{
"code":"0805",
"name":"渔业用手工具"
},
{
"code":"0806",
"name":"理发工具,修指甲刀,文身器具"
},
{
"code":"0807",
"name":"非动力手工具(不包括刀、剪)"
},
{
"code":"0808",
"name":"非动力手工器具"
},
{
"code":"0809",
"name":"专业用手工具"
},
{
"code":"0810",
"name":"刀剪(不包括机械刀片,文具刀)"
},
{
"code":"0811",
"name":"除火器外的随身武器"
},
{
"code":"0812",
"name":"餐具刀、叉、匙"
},
{
"code":"0813",
"name":"手工具柄"
},
{
"code":"0901",
"name":"电子计算机及其外部设备"
},
{
"code":"0902",
"name":"记录、记数检测器"
},
{
"code":"0903",
"name":"其他办公用机械(不包括打字机、誊写机、油印机)"
},
{
"code":"0904",
"name":"衡器"
},
{
"code":"0905",
"name":"量具"
},
{
"code":"0906",
"name":"信号器具"
},
{
"code":"0907",
"name":"通信导航设备"
},
{
"code":"0908",
"name":"音像设备"
},
{
"code":"0909",
"name":"摄影、电影用具及仪器"
},
{
"code":"0910",
"name":"测量仪器仪表,实验室用器具,电测量仪器,科学仪器"
},
{
"code":"0911",
"name":"光学仪器"
},
{
"code":"0912",
"name":"光电传输材料"
},
{
"code":"0913",
"name":"电器用晶体及碳素材料,电子、电气通用元件"
},
{
"code":"0914",
"name":"电器成套设备及控制装置"
},
{
"code":"0915",
"name":"电解装置"
},
{
"code":"0916",
"name":"灭火器具"
},
{
"code":"0918",
"name":"工业用X光机械设备"
},
{
"code":"0919",
"name":"安全救护器具"
},
{
"code":"0920",
"name":"警报装置,电铃"
},
{
"code":"0921",
"name":"眼镜及附件"
},
{
"code":"0922",
"name":"电池,充电器"
},
{
"code":"0923",
"name":"电影片,已曝光材料"
},
{
"code":"0924",
"name":"单一商品"
},
{
"code":"1001",
"name":"外科、医疗和兽医用仪器、器械、设备,不包括电子、核子、电疗、医疗用X光设备、器械及仪器"
},
{
"code":"1002",
"name":"牙科设备及器具"
},
{
"code":"1003",
"name":"医疗用电子、核子、电疗和X光设备"
},
{
"code":"1004",
"name":"医疗用辅助器具、设备和用品"
},
{
"code":"1005",
"name":"奶嘴,奶瓶"
},
{
"code":"1006",
"name":"性用品"
},
{
"code":"1007",
"name":"假肢,假发和假器官"
},
{
"code":"1008",
"name":"矫形矫正及助行用品"
},
{
"code":"1009",
"name":"缝合用材料"
},
{
"code":"1101",
"name":"照明用设备、器具(不包括汽灯、油灯)"
},
{
"code":"1103",
"name":"汽灯,油灯"
},
{
"code":"1104",
"name":"烹调及民用电气加热设备(不包括厨房用手工用具,食品加工机器)"
},
{
"code":"1105",
"name":"制冷、冷藏设备(不包括冷藏车)"
},
{
"code":"1106",
"name":"干燥、通风、空调设备(包括冷暖房设备),气体净化设备"
},
{
"code":"1107",
"name":"加温、蒸汽设备(包括工业用炉、锅炉,不包括机车锅炉、锅驼机锅炉、蒸汽机锅炉)"
},
{
"code":"1108",
"name":"水暖管件"
},
{
"code":"1109",
"name":"卫生设备(不包括盥洗室用具)"
},
{
"code":"1110",
"name":"消毒和净化设备"
},
{
"code":"1111",
"name":"小型取暖器"
},
{
"code":"1112",
"name":"不属别类的打火器具"
},
{
"code":"1113",
"name":"核能反应设备"
},
{
"code":"1201",
"name":"火车及其零部件"
},
{
"code":"1202",
"name":"汽车、电车、摩托车及其零部件(不包括轮胎)"
},
{
"code":"1204",
"name":"自行车、三轮车及其零部件(不包括轮胎)"
},
{
"code":"1205",
"name":"缆车,架空运输设备"
},
{
"code":"1206",
"name":"轮椅,手推车,儿童推车"
},
{
"code":"1207",
"name":"畜力车辆,雪橇"
},
{
"code":"1208",
"name":"轮胎及轮胎修理工具"
},
{
"code":"1209",
"name":"空用运载工具(不包括飞机轮胎)"
},
{
"code":"1210",
"name":"水用运载工具"
},
{
"code":"1211",
"name":"运载工具零部件"
},
{
"code":"1301",
"name":"火器,军火及子弹"
},
{
"code":"1302",
"name":"爆炸物"
},
{
"code":"1303",
"name":"烟火,爆竹"
},
{
"code":"1304",
"name":"个人防护用喷雾"
},
{
"code":"1401",
"name":"贵金属及其合金"
},
{
"code":"1402",
"name":"贵金属盒"
},
{
"code":"1403",
"name":"珠宝,首饰,宝石及贵金属制纪念品"
},
{
"code":"1404",
"name":"钟,表,计时器及其零部件"
},
{
"code":"1501",
"name":"乐器"
},
{
"code":"1502",
"name":"乐器辅助用品及配件"
},
{
"code":"1601",
"name":"工业用纸"
},
{
"code":"1602",
"name":"技术用纸(不包括绝缘纸)"
},
{
"code":"1603",
"name":"生活用纸"
},
{
"code":"1604",
"name":"纸板"
},
{
"code":"1605",
"name":"办公、日用纸制品"
},
{
"code":"1606",
"name":"印刷出版物"
},
{
"code":"1607",
"name":"照片,图片,图画"
},
{
"code":"1609",
"name":"纸及不属别类的塑料包装物品"
},
{
"code":"1610",
"name":"办公装订、切削用具"
},
{
"code":"1611",
"name":"办公文具(不包括笔,墨,印,胶水)"
},
{
"code":"1612",
"name":"墨,砚"
},
{
"code":"1613",
"name":"印章,印油"
},
{
"code":"1614",
"name":"笔"
},
{
"code":"1615",
"name":"办公或家庭用胶带或黏合剂"
},
{
"code":"1616",
"name":"办公室用绘图仪器,绘画仪器"
},
{
"code":"1617",
"name":"绘画用具(不包括绘图仪器,笔)"
},
{
"code":"1618",
"name":"打字机、誊写机、油印机及其附件(包括印刷铅字、印版)"
},
{
"code":"1619",
"name":"教学用具(不包括教学实验用仪器)"
},
{
"code":"1620",
"name":"室内模型物(不包括教学用模型标本)"
},
{
"code":"1621",
"name":"单一商品"
},
{
"code":"1701",
"name":"不属别类的橡胶,古塔胶,树胶"
},
{
"code":"1702",
"name":"非金属密封减震制品"
},
{
"code":"1703",
"name":"橡胶,树脂,纤维制品"
},
{
"code":"1704",
"name":"软管"
},
{
"code":"1705",
"name":"保温、隔热、隔音材料"
},
{
"code":"1706",
"name":"绝缘用材料及其制品"
},
{
"code":"1707",
"name":"包装、填充用材料(包括橡胶、塑料制品)"
},
{
"code":"1708",
"name":"单一商品"
},
{
"code":"1801",
"name":"皮革和人造皮革,裘皮"
},
{
"code":"1802",
"name":"不属别类的皮革、人造皮革制品,箱子及旅行袋,日用革制品"
},
{
"code":"1804",
"name":"雨伞及其部件"
},
{
"code":"1805",
"name":"手杖"
},
{
"code":"1806",
"name":"动物用具"
},
{
"code":"1807",
"name":"肠衣"
},
{
"code":"1901",
"name":"半成品木材"
},
{
"code":"1902",
"name":"土,沙,石,石料,灰泥,炉渣等建筑用料"
},
{
"code":"1903",
"name":"石膏"
},
{
"code":"1904",
"name":"水泥"
},
{
"code":"1905",
"name":"水泥预制构件"
},
{
"code":"1906",
"name":"建筑砖瓦"
},
{
"code":"1907",
"name":"非金属耐火材料及制品"
},
{
"code":"1908",
"name":"柏油,沥青及制品"
},
{
"code":"1909",
"name":"非金属建筑材料及构件(不包括水泥预制构件)"
},
{
"code":"1910",
"name":"非金属建筑物"
},
{
"code":"1911",
"name":"建筑用玻璃及玻璃材料"
},
{
"code":"1912",
"name":"建筑用涂层"
},
{
"code":"1913",
"name":"建筑用黏合料"
},
{
"code":"1914",
"name":"石、混凝土、大理石雕塑品"
},
{
"code":"1915",
"name":"棺椁墓碑"
},
{
"code":"2001",
"name":"家具"
},
{
"code":"2002",
"name":"非金属容器及附件"
},
{
"code":"2003",
"name":"不属别类的工业、建筑配件"
},
{
"code":"2004",
"name":"镜子、画框及部件"
},
{
"code":"2005",
"name":"不属别类的竹、藤、棕、草制品"
},
{
"code":"2006",
"name":"未加工或半加工的骨、角、牙、介及不属别类的工艺品"
},
{
"code":"2007",
"name":"非金属牌照"
},
{
"code":"2008",
"name":"食品用塑料装饰品"
},
{
"code":"2009",
"name":"禽、畜等动物用制品"
},
{
"code":"2010",
"name":"非金属制身份鉴别手环"
},
{
"code":"2011",
"name":"非金属棺材及附件"
},
{
"code":"2012",
"name":"非金属家具附件"
},
{
"code":"2013",
"name":"垫,枕"
},
{
"code":"2014",
"name":"非金属紧固件及门窗附件"
},
{
"code":"2101",
"name":"厨房炊事用具及容器(包括不属别类的餐具)"
},
{
"code":"2102",
"name":"不属别类的玻璃器皿"
},
{
"code":"2103",
"name":"瓷器,陶器(茶具,酒具除外)"
},
{
"code":"2104",
"name":"玻璃、瓷、陶的工艺品"
},
{
"code":"2105",
"name":"茶具、酒具、咖啡具及饮水用具"
},
{
"code":"2106",
"name":"家庭日用及卫生器具"
},
{
"code":"2107",
"name":"梳子,刷子(不包括牙刷),制刷原料"
},
{
"code":"2108",
"name":"刷牙用具"
},
{
"code":"2109",
"name":"牙签"
},
{
"code":"2110",
"name":"化妆用具"
},
{
"code":"2111",
"name":"隔热用具"
},
{
"code":"2112",
"name":"家务用具"
},
{
"code":"2113",
"name":"未加工或半加工玻璃(不包括建筑用玻璃)"
},
{
"code":"2114",
"name":"不属别类的动植物器具"
},
{
"code":"2115",
"name":"家用灭虫、灭鼠用具"
},
{
"code":"2201",
"name":"缆,绳,线,带"
},
{
"code":"2202",
"name":"网,遮篷,帐篷,防水帆布,帆"
},
{
"code":"2203",
"name":"袋子,装卸、包装用物品"
},
{
"code":"2204",
"name":"衬垫,填充料,密封物品(不包括橡胶、塑料制品)"
},
{
"code":"2205",
"name":"纤维原料"
},
{
"code":"2301",
"name":"纺织用纱、丝"
},
{
"code":"2302",
"name":"线"
},
{
"code":"2303",
"name":"毛线"
},
{
"code":"2401",
"name":"纺织品,布料"
},
{
"code":"2402",
"name":"特殊用织物"
},
{
"code":"2403",
"name":"纺织品壁挂"
},
{
"code":"2404",
"name":"毡及毡制品"
},
{
"code":"2405",
"name":"毛巾,浴巾,手帕"
},
{
"code":"2406",
"name":"床上用品"
},
{
"code":"2407",
"name":"室内遮盖物"
},
{
"code":"2409",
"name":"特殊用布"
},
{
"code":"2410",
"name":"纺织品制或塑料制旗"
},
{
"code":"2411",
"name":"寿衣"
},
{
"code":"2501",
"name":"衣物"
},
{
"code":"2502",
"name":"婴儿纺织用品"
},
{
"code":"2503",
"name":"特种运动服装"
},
{
"code":"2504",
"name":"不透水服装"
},
{
"code":"2505",
"name":"戏装"
},
{
"code":"2507",
"name":"鞋"
},
{
"code":"2508",
"name":"帽"
},
{
"code":"2509",
"name":"袜"
},
{
"code":"2510",
"name":"手套(不包括特种手套)"
},
{
"code":"2511",
"name":"领带,围巾,披巾,面纱"
},
{
"code":"2512",
"name":"腰带,服装带"
},
{
"code":"2513",
"name":"单一商品"
},
{
"code":"2601",
"name":"花边,饰品及编带"
},
{
"code":"2602",
"name":"不属别类的服饰品,饰针"
},
{
"code":"2603",
"name":"纽扣,领钩扣,拉链"
},
{
"code":"2604",
"name":"假发,假胡须"
},
{
"code":"2605",
"name":"缝纫用具(线除外)"
},
{
"code":"2606",
"name":"假花"
},
{
"code":"2607",
"name":"硬托衬骨"
},
{
"code":"2608",
"name":"修补纺织品用热粘胶片"
},
{
"code":"2609",
"name":"亚麻布标记用品"
},
{
"code":"2701",
"name":"地毯"
},
{
"code":"2702",
"name":"席类"
},
{
"code":"2703",
"name":"垫及其他可移动铺地板用品"
},
{
"code":"2704",
"name":"墙纸,非纺织品墙帷及非纺织品壁挂"
},
{
"code":"2801",
"name":"娱乐器械,娱乐物品"
},
{
"code":"2802",
"name":"玩具"
},
{
"code":"2803",
"name":"棋,牌及辅助器材"
},
{
"code":"2804",
"name":"球类及器材"
},
{
"code":"2805",
"name":"健身器材"
},
{
"code":"2806",
"name":"射箭运动器材"
},
{
"code":"2807",
"name":"体操、举重、田径、冰雪及属于本类的其他运动器材"
},
{
"code":"2808",
"name":"游泳池及跑道"
},
{
"code":"2809",
"name":"运动防护器具及冰鞋"
},
{
"code":"2810",
"name":"圣诞树用的装饰品"
},
{
"code":"2811",
"name":"钓具"
},
{
"code":"2812",
"name":"单一商品"
},
{
"code":"2901",
"name":"肉,非活的家禽,野味,肉汁"
},
{
"code":"2902",
"name":"非活水产品"
},
{
"code":"2903",
"name":"罐头食品(软包装食品不包括在内,随原料制成品归组)"
},
{
"code":"2904",
"name":"腌渍、干制水果及制品"
},
{
"code":"2905",
"name":"腌制、干制蔬菜"
},
{
"code":"2906",
"name":"蛋品"
},
{
"code":"2907",
"name":"奶及乳制品"
},
{
"code":"2908",
"name":"食用油脂"
},
{
"code":"2909",
"name":"色拉"
},
{
"code":"2910",
"name":"食用果胶"
},
{
"code":"2911",
"name":"加工过的坚果"
},
{
"code":"2912",
"name":"菌类干制品"
},
{
"code":"2913",
"name":"食物蛋白,豆腐制品"
},
{
"code":"2914",
"name":"肠衣"
},
{
"code":"3001",
"name":"咖啡,咖啡代用品,可可"
},
{
"code":"3002",
"name":"茶、茶饮料"
},
{
"code":"3003",
"name":"糖"
},
{
"code":"3004",
"name":"糖果,南糖,糖"
},
{
"code":"3005",
"name":"蜂蜜,蜂王浆等营养食品"
},
{
"code":"3006",
"name":"面包,糕点"
},
{
"code":"3007",
"name":"方便食品"
},
{
"code":"3008",
"name":"米,面粉(包括五谷杂粮)"
},
{
"code":"3009",
"name":"面条及米面制品"
},
{
"code":"3010",
"name":"谷物膨化食品"
},
{
"code":"3011",
"name":"豆粉,食用预制面筋"
},
{
"code":"3012",
"name":"食用淀粉及其制品"
},
{
"code":"3013",
"name":"食用冰,冰制品"
},
{
"code":"3014",
"name":"食盐"
},
{
"code":"3015",
"name":"酱油,醋"
},
{
"code":"3016",
"name":"芥末,味精,沙司,酱等调味品"
},
{
"code":"3017",
"name":"酵母"
},
{
"code":"3018",
"name":"食用香精,香料"
},
{
"code":"3019",
"name":"单一商品"
},
{
"code":"3101",
"name":"未加工的林业产品"
},
{
"code":"3102",
"name":"未加工的谷物及农产品(不包括蔬菜,种子)"
},
{
"code":"3103",
"name":"花卉,园艺产品,草本植物"
},
{
"code":"3104",
"name":"活动物"
},
{
"code":"3105",
"name":"未加工的水果及干果"
},
{
"code":"3106",
"name":"新鲜蔬菜"
},
{
"code":"3107",
"name":"种子"
},
{
"code":"3108",
"name":"动物饲料"
},
{
"code":"3109",
"name":"麦芽"
},
{
"code":"3110",
"name":"动物栖息用干草等制品"
},
{
"code":"3201",
"name":"啤酒"
},
{
"code":"3202",
"name":"不含酒精饮料"
},
{
"code":"3203",
"name":"糖浆及其他供饮料用的制剂"
},
{
"code":"3301",
"name":"含酒精的饮料(啤酒除外)"
},
{
"code":"3401",
"name":"烟草及其制品"
},
{
"code":"3402",
"name":"烟具"
},
{
"code":"3403",
"name":"火柴"
},
{
"code":"3404",
"name":"吸烟用打火机"
},
{
"code":"3405",
"name":"烟纸,过滤嘴"
},
{
"code":"3406",
"name":"香烟用调味品"
},
{
"code":"3407",
"name":"电子香烟及其部件"
},
{
"code":"3501",
"name":"广告"
},
{
"code":"3502",
"name":"工商管理辅助业"
},
{
"code":"3503",
"name":"替他人推销"
},
{
"code":"3504",
"name":"人事管理辅助业"
},
{
"code":"3505",
"name":"商业企业迁移"
},
{
"code":"3506",
"name":"办公事务"
},
{
"code":"3507",
"name":"财会"
},
{
"code":"3508",
"name":"单一服务"
},
{
"code":"3509",
"name":"药品、医疗用品零售或批发服务"
},
{
"code":"3601",
"name":"保险"
},
{
"code":"3602",
"name":"金融事务"
},
{
"code":"3603",
"name":"珍品估价"
},
{
"code":"3604",
"name":"不动产事务"
},
{
"code":"3605",
"name":"海关经纪"
},
{
"code":"3606",
"name":"担保"
},
{
"code":"3607",
"name":"慈善募捐"
},
{
"code":"3608",
"name":"受托管理"
},
{
"code":"3609",
"name":"典当"
},
{
"code":"3701",
"name":"建设、维修信息服务"
},
{
"code":"3702",
"name":"建筑工程服务"
},
{
"code":"3703",
"name":"开采服务"
},
{
"code":"3704",
"name":"建筑物装饰修理服务"
},
{
"code":"3705",
"name":"供暖设备的安装与修理"
},
{
"code":"3706",
"name":"机械、电器设备的安装与修理"
},
{
"code":"3707",
"name":"陆地机械车辆维修"
},
{
"code":"3708",
"name":"飞机维修"
},
{
"code":"3709",
"name":"造船服务"
},
{
"code":"3710",
"name":"影视器材维修"
},
{
"code":"3711",
"name":"钟表修理"
},
{
"code":"3712",
"name":"保险装置的维修"
},
{
"code":"3713",
"name":"特殊处理服务"
},
{
"code":"3714",
"name":"轮胎维修服务"
},
{
"code":"3715",
"name":"家具的修复、保养"
},
{
"code":"3716",
"name":"衣服、皮革的修补、保护、洗涤服务"
},
{
"code":"3717",
"name":"灭虫,消毒服务"
},
{
"code":"3718",
"name":"单一服务"
},
{
"code":"3801",
"name":"进行播放无线电或电视节目的服务"
},
{
"code":"3802",
"name":"通信服务"
},
{
"code":"3901",
"name":"运输及运输前的包装服务"
},
{
"code":"3902",
"name":"水上运输及相关服务"
},
{
"code":"3903",
"name":"陆地运输"
},
{
"code":"3904",
"name":"空中运输"
},
{
"code":"3905",
"name":"其他运输及相关服务"
},
{
"code":"3906",
"name":"货物的贮藏"
},
{
"code":"3907",
"name":"潜水工具出租"
},
{
"code":"3908",
"name":"供水电气服务"
},
{
"code":"3909",
"name":"水闸管理服务"
},
{
"code":"3910",
"name":"投递服务"
},
{
"code":"3911",
"name":"旅行安排"
},
{
"code":"3912",
"name":"单一服务"
},
{
"code":"4001",
"name":"综合加工及提供信息服务"
},
{
"code":"4002",
"name":"金属材料处理或加工服务"
},
{
"code":"4003",
"name":"纺织品化学处理或加工服务"
},
{
"code":"4004",
"name":"木材加工服务"
},
{
"code":"4005",
"name":"纸张加工服务"
},
{
"code":"4006",
"name":"玻璃加工服务"
},
{
"code":"4007",
"name":"陶器加工服务"
},
{
"code":"4008",
"name":"食物、饮料加工服务"
},
{
"code":"4009",
"name":"剥制加工服务"
},
{
"code":"4010",
"name":"皮革、服装加工服务"
},
{
"code":"4011",
"name":"影像加工处理服务"
},
{
"code":"4012",
"name":"污物处理服务"
},
{
"code":"4013",
"name":"空气调节服务"
},
{
"code":"4014",
"name":"水处理服务"
},
{
"code":"4015",
"name":"单一服务"
},
{
"code":"4101",
"name":"教育"
},
{
"code":"4102",
"name":"组织和安排教育、文化、娱乐等活动"
},
{
"code":"4103",
"name":"图书馆服务"
},
{
"code":"4104",
"name":"出版服务"
},
{
"code":"4105",
"name":"文娱、体育活动的服务"
},
{
"code":"4106",
"name":"驯兽"
},
{
"code":"4107",
"name":"单一服务"
},
{
"code":"4209",
"name":"提供科学技术研究服务"
},
{
"code":"4210",
"name":"提供地质调查、研究、开发服务"
},
{
"code":"4211",
"name":"提供化学研究服务"
},
{
"code":"4212",
"name":"提供生物学、医学研究服务"
},
{
"code":"4213",
"name":"提供气象情报服务"
},
{
"code":"4214",
"name":"提供测试服务"
},
{
"code":"4216",
"name":"外观设计服务"
},
{
"code":"4217",
"name":"建筑物的设计、咨询服务"
},
{
"code":"4218",
"name":"服装设计服务"
},
{
"code":"4220",
"name":"计算机编程及相关服务"
},
{
"code":"4224",
"name":"提供艺术品鉴定服务"
},
{
"code":"4227",
"name":"单一服务"
},
{
"code":"4301",
"name":"提供餐饮,住宿服务"
},
{
"code":"4302",
"name":"提供房屋设施的服务"
},
{
"code":"4303",
"name":"养老院"
},
{
"code":"4304",
"name":"托儿服务"
},
{
"code":"4305",
"name":"为动物提供食宿"
},
{
"code":"4306",
"name":"单一服务"
},
{
"code":"4401",
"name":"医疗服务"
},
{
"code":"4402",
"name":"卫生、美容服务"
},
{
"code":"4403",
"name":"为动物提供服务"
},
{
"code":"4404",
"name":"农业、园艺服务"
},
{
"code":"4405",
"name":"单一服务"
},
{
"code":"4501",
"name":"安全服务"
},
{
"code":"4502",
"name":"提供人员服务"
},
{
"code":"4503",
"name":"提供服饰服务"
},
{
"code":"4504",
"name":"殡仪服务"
},
{
"code":"4505",
"name":"单一服务"
},
{
"code":"4506",
"name":"法律服务"
}
]
}
\ No newline at end of file
import fitz
import time
import re
import os
def pdf2pic(path, pic_path):
'''
# 从pdf中提取图片
:param path: pdf的路径
:param pic_path: 图片保存的路径
:return:
'''
t0 = time.clock()
# 使用正则表达式来查找图片
checkXO = r"/Type(?= */XObject)"
checkIM = r"/Subtype(?= */Image)"
# 打开pdf
doc = fitz.open(path)
# 图片计数
imgcount = 0
lenXREF = doc._getXrefLength()
# 打印PDF的信息
print("文件名:{}, 页数: {}, 对象: {}".format(path, len(doc), lenXREF - 1))
# 遍历每一个对象
for i in range(1, lenXREF):
# 定义对象字符串
text = doc.getObjectString(i)
isXObject = re.search(checkXO, text)
# 使用正则表达式查看是否是图片
isImage = re.search(checkIM, text)
# 如果不是对象也不是图片,则continue
if not isXObject or not isImage:
continue
imgcount += 1
# 根据索引生成图像
pix = fitz.Pixmap(doc, i)
# 根据pdf的路径生成图片的名称
new_name = path.replace('\\', '_') + "_img{}.png".format(imgcount)
new_name = new_name.replace(':', '')
# 如果pix.n<5,可以直接存为PNG
if pix.n < 5:
pix.writePNG(os.path.join(pic_path, new_name))
# 否则先转换CMYK
else:
pix0 = fitz.Pixmap(fitz.csRGB, pix)
pix0.writePNG(os.path.join(pic_path, new_name))
pix0 = None
# 释放资源
pix = None
t1 = time.clock()
print("运行时间:{}s".format(t1 - t0))
print("提取了{}张图片".format(imgcount))
if __name__=='__main__':
# pdf路径
path = 'aaa.pdf'
pic_path = '/root/business/creatdoc'
# 创建保存图片的文件夹
if os.path.exists(pic_path):
print("文件夹已存在,请重新创建新文件夹!")
raise SystemExit
else:
os.mkdir(pic_path)
m = pdf2pic(path, pic_path)
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument("--no-sandbox")
browser = webdriver.Chrome(chrome_options=chrome_options,
executable_path="/root/chromedriver")
url = "http://www.baidu.com"
browser.get(url)
print("su")
time.sleep(10)
browser.quit()
\ No newline at end of file
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