diff --git a/.gitignore b/.gitignore
index 0255576..a5b4546 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.idea
-test.py
\ No newline at end of file
+test.py
+./groupchat/*.xlsx
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 91e3202..5127e76 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/scf-python-dev-demo.iml b/.idea/scf-python-dev-demo.iml
index 67621be..d9cd630 100644
--- a/.idea/scf-python-dev-demo.iml
+++ b/.idea/scf-python-dev-demo.iml
@@ -4,7 +4,7 @@
-
+
diff --git a/esmart.py b/esmart.py
index 37ff25c..2dedf00 100644
--- a/esmart.py
+++ b/esmart.py
@@ -97,6 +97,33 @@ class SmartSheet:
return True
return False
+ def add_fields(self, fields: list[dict]):
+ url = "https://a.cmdp.cn/umss/v1/wxw/common/submit"
+ body = {
+ "url": "https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/add_fields",
+ "method": "POST",
+ "body": {
+ "docid": self.doc_id,
+ "sheet_id": self.sheet_id,
+ "fields": fields
+ }
+ }
+ return self._post(url, body)
+
+ def delete_field(self, field_ids: list[str]):
+ url = "https://a.cmdp.cn/umss/v1/wxw/common/submit"
+ body = {
+ "url": "https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/delete_fields",
+ "method": "POST",
+ "body": {
+ "docid": self.doc_id,
+ "sheet_id": self.sheet_id,
+ "field_ids": field_ids
+
+ }
+ }
+ return self._post(url, body)
+
def transform_data(self, data: dict):
result = {}
columns = self.columns
@@ -184,13 +211,56 @@ class SmartSheet:
return {"columns": self.columns, "data": data}
+class SmartMetadata(SmartSheet):
+ def __init__(self, doc_id, sheet_id=None):
+ super().__init__(doc_id, sheet_id)
+
+ def create(self):
+ url = "https://a.cmdp.cn/umss/v1/wxw/addSheet"
+ body = {
+ "docid": self.doc_id,
+ "properties": {
+ "title": "Metadata"
+ }
+ }
+ resp = self._post(url, body)
+ if resp.get("properties"):
+ self.sheet_id = resp["properties"]["sheet_id"]
+ self.add_fields([
+ {
+ "field_type": "FIELD_TYPE_TEXT",
+ "field_title": "名称"
+ },
+ {
+ "property_single_select": {
+ "options": [{"style": 13, "text": "doc"},
+ {"style": 7, "text": "sheet"},
+ {"style": 11, "text": "metadata"}
+ ],
+ "is_multiple": False,
+ "is_quick_add": True
+ },
+ "field_type": "FIELD_TYPE_SINGLE_SELECT",
+ "field_title": "类型"
+ }, {
+ "field_type": "FIELD_TYPE_TEXT",
+ "field_title": "值"
+ }
+ ])
+ self.delete_field([self.columns[i]["field_id"] for i in self.columns if i not in ["名称", "类型", "值"]])
+ self.update(self.sheet_id, sheet_name="Metadata", sheet_type="metadata")
+
+ def update(self, sheet_id, sheet_name, sheet_type="sheet"):
+ self.add({"名称": sheet_name, "类型": sheet_type, "值": sheet_id})
+
+
class SmartTableApi:
- def __init__(self, doc_id):
+ def __init__(self, doc_id=None):
self.doc_id = doc_id
- self.metadata_id = None
self._metadata = None
self.metadata_table = None
- self._get_sheet_list()
+ if self.doc_id is not None:
+ self._get_sheet_list()
@staticmethod
def _post(url, body):
@@ -199,6 +269,18 @@ class SmartTableApi:
return resp.json()
return {}
+ def create(self, doc_name: str, admin_users: list[str]):
+ url = "https://a.cmdp.cn/umss/v1/wxw/addDocument"
+ body = {
+ "doc_type": 10,
+ "doc_name": doc_name,
+ "admin_users": admin_users
+ }
+ resp = self._post(url, body)
+ self.doc_id = resp.get("docid")
+ self._get_sheet_list()
+ self.metadata_table.update(self.doc_id, sheet_name=doc_name, sheet_type="doc")
+
def _get_sheet_list(self):
url = "https://a.cmdp.cn/umss/v1/wxw/common/submit"
body = {
@@ -212,22 +294,20 @@ class SmartTableApi:
resp = self._post(url, body)
sheet_list = resp.get("sheet_list", [])
result = {i["title"]: i["sheet_id"] for i in sheet_list}
- self.metadata_id = result.get("Metadata")
if "Metadata" in result:
+ metadata_id = result.get("Metadata")
+ self.metadata_table = SmartMetadata(self.doc_id, metadata_id)
del result["Metadata"]
+ else:
+ self.metadata_table = SmartMetadata(self.doc_id)
+ self.metadata_table.create()
self._metadata = result
@property
def metadata(self):
return self._metadata
- def _update_metadata(self, sheet_id, sheet_name):
- if not self.metadata_table:
- self.metadata_table = SmartSheet(self.doc_id, self.metadata_id)
- self.metadata_table.add({"名称": sheet_name, "类型": "sheet", "值": sheet_id})
- pass
-
- def add_sheet(self, sheet_name):
+ def _add_sheet(self, sheet_name):
url = "https://a.cmdp.cn/umss/v1/wxw/addSheet"
body = {
"docid": self.doc_id,
@@ -235,9 +315,12 @@ class SmartTableApi:
"title": sheet_name
}
}
- resp = self._post(url, body)
+ return self._post(url, body)
+
+ def add_sheet(self, sheet_name):
+ resp = self._add_sheet(sheet_name)
if resp.get("properties"):
- self._update_metadata(sheet_id=resp["properties"]["sheet_id"], sheet_name=sheet_name)
+ self.metadata_table.update(sheet_id=resp["properties"]["sheet_id"], sheet_name=sheet_name)
return resp
def get_sheet(self, sheet_id):
@@ -447,5 +530,11 @@ class ESmart:
if __name__ == '__main__':
- esmart = ESmart()
- esmart.prepared_message()
\ No newline at end of file
+ # esmart = ESmart()
+ # esmart.prepared_message()
+ sta = SmartTableApi("dcxzIyHG8nZDXswX00xaTDBGgW9NQ00Qk5WH6zLPTFONlE42y2CWZ8nCG8O-gvZSA5dRjTDASSThVAk2iWF16MAg")
+ sta.add_sheet("维护更新")
+ sta.add_sheet("VIP交付情况")
+ sta.add_sheet("备份存档")
+ # sta.create("推广-深交所用户智能跟踪",
+ # ["lychang", "rhu"])
diff --git a/groupchat/main.py b/groupchat/main.py
index 6d32be4..4814675 100644
--- a/groupchat/main.py
+++ b/groupchat/main.py
@@ -36,6 +36,8 @@ def parser_chat_text(content: str):
if __name__ == '__main__':
df = pd.read_excel("聊天记录.xlsx")
for group_name,group_messages in df.values:
+ if group_messages == " ":
+ continue
writer = pd.ExcelWriter(f"{group_name}-聊天记录分析.xlsx", engine="xlsxwriter")
chat_messages ,chat_analyzer = parser_chat_text(group_messages)
df1 = pd.DataFrame(chat_messages,columns=["user","date","time","content"])
diff --git a/groupchat/创业板群1-聊天记录分析.xlsx b/groupchat/创业板群1-聊天记录分析.xlsx
deleted file mode 100644
index 0c03416..0000000
Binary files a/groupchat/创业板群1-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/创业板群2-聊天记录分析.xlsx b/groupchat/创业板群2-聊天记录分析.xlsx
deleted file mode 100644
index 517e032..0000000
Binary files a/groupchat/创业板群2-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/创业板群3-聊天记录分析.xlsx b/groupchat/创业板群3-聊天记录分析.xlsx
deleted file mode 100644
index 6e51442..0000000
Binary files a/groupchat/创业板群3-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/创业板群4-聊天记录分析.xlsx b/groupchat/创业板群4-聊天记录分析.xlsx
deleted file mode 100644
index 72a4646..0000000
Binary files a/groupchat/创业板群4-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/创业板群5-聊天记录分析.xlsx b/groupchat/创业板群5-聊天记录分析.xlsx
deleted file mode 100644
index e804834..0000000
Binary files a/groupchat/创业板群5-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/深主板群1-聊天记录分析.xlsx b/groupchat/深主板群1-聊天记录分析.xlsx
deleted file mode 100644
index de9a628..0000000
Binary files a/groupchat/深主板群1-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/深主板群2-聊天记录分析.xlsx b/groupchat/深主板群2-聊天记录分析.xlsx
deleted file mode 100644
index 7fc2eda..0000000
Binary files a/groupchat/深主板群2-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/深主板群3-聊天记录分析.xlsx b/groupchat/深主板群3-聊天记录分析.xlsx
deleted file mode 100644
index 111d69f..0000000
Binary files a/groupchat/深主板群3-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/深主板群4-聊天记录分析.xlsx b/groupchat/深主板群4-聊天记录分析.xlsx
deleted file mode 100644
index e8ba7ac..0000000
Binary files a/groupchat/深主板群4-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/深主板群5-聊天记录分析.xlsx b/groupchat/深主板群5-聊天记录分析.xlsx
deleted file mode 100644
index 487e8d6..0000000
Binary files a/groupchat/深主板群5-聊天记录分析.xlsx and /dev/null differ
diff --git a/groupchat/聊天记录.xlsx b/groupchat/聊天记录.xlsx
index 403c8e3..7b1f417 100644
Binary files a/groupchat/聊天记录.xlsx and b/groupchat/聊天记录.xlsx differ
diff --git a/lib.py b/lib.py
index d3ae75d..1395d35 100644
--- a/lib.py
+++ b/lib.py
@@ -521,7 +521,7 @@ def parse_data(data: dict, mapping: dict) -> dict:
crop_id = "wx98dfa35ad7e4b271"
space_id = "s.wx98dfa35ad7e4b271.744621152iSk"
-doc_id = 'dc1zao6J8YnS9p86FKKvKQadukmFXlXv3dU1qVQrgcjB81zdSVI7qoi9a7K_OpN4BTyXc8EbYVXxpnQNUUTMWwIw'
+f_id = 'dc1zao6J8YnS9p86FKKvKQadukmFXlXv3dU1qVQrgcjB81zdSVI7qoi9a7K_OpN4BTyXc8EbYVXxpnQNUUTMWwIw'
wxc_app_secret = "gyN5moBa6Ev1Vd0ZLUVrsEtAO_goppWKUBdsnSng-Ks"
wapi_app_secret = "oM0hwIi8GRPw6HWk9o5__g3v5ziz5CGyBUo2FASSrVw"
wxc_auth = WXworkAuth(crop_id, wxc_app_secret)
@@ -718,7 +718,7 @@ class SalesTools:
return response.json().get("data", {})
@staticmethod
- def get_report_rule(tags: [str]):
+ def get_report_rule(tags: list[str]):
"""
四.尽调报告的规则文件地址查询
@@ -906,7 +906,6 @@ class SalesTools:
"filter": "'fileInfo.extends.resource.delStatus' eq 1 and 'fileInfo.extends.resource.label' eq '小智智填-定期报告专版'",
"tags": ["tech_sbom", f"prod_year_{year}", "type_入口", "prod_小智转写"]
}
- print(url, json.dumps(body, ensure_ascii=False))
response = requests.post(url, json=body)
if response.status_code == 200:
response_json = response.json()
@@ -1065,7 +1064,7 @@ class SalesTools:
resp = requests.get(basiceg_url + file_path)
if resp.status_code == 200:
data = resp.content
- resp = requests.put(basiceg_url + static_path, data=data)
+ requests.put(basiceg_url + static_path, data=data)
return f'
'
else:
return ""
@@ -1096,12 +1095,6 @@ class CalendarEventDB(CalendarDB):
bp_id = bp_info.get("id")
bp_mail = bp_info.get("email")
- # 获取二维码
- # product_id = st.get_current_product_id()
- # product_id ="1909049700811497474"
- # st.get_smart_genie_product(eid, product_id)
- # product_qrcode_path = st.get_product_qrcode(eid, product_id)
- # qrcode = st.get_qrcode_base64(product_qrcode_path)
# 获取报告文件
now = time.localtime(time.time())
year = now.tm_year
@@ -1126,7 +1119,7 @@ class CalendarEventDB(CalendarDB):
# content = content.replace("{{qrcode}}", qrcode)
content = content.replace("{{picture}}", st.get_information_disclosure_picture("2024", security_code))
st.send_company_mail(bp_mail, f"客户拜访准备文件-{full_name}[{security_code}]", content)
- ssp.add_row(doc_id=doc_id, sheet_id="tTMuVB", records=[
+ ssp.add_row(doc_id=f_id, sheet_id="tTMuVB", records=[
{
"values": {
"证券代码": [