Skip to content

Commit

Permalink
1.5.4 (#32)
Browse files Browse the repository at this point in the history
修改配置信息,支持使用YAML,放弃JSON存储,并支持自足添加航线
对文件结构进行优化
合并冲突
  • Loading branch information
jerryliang122 authored Sep 12, 2023
1 parent a435c13 commit 40df588
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ github.event.pull_request.title }}
name: Release ${{ github.event.pull_request.head.ref }}
name: 瀚万客服小程序 ${{ github.event.pull_request.title }}
body: ${{ github.event.pull_request.body }}
draft: false
prerelease: false
Expand Down
18 changes: 3 additions & 15 deletions Ui_untitled.py → Ui/Ui_untitled.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Form implementation generated from reading ui file 'd:\Git\working-CIF-service\untitled.ui'
# Form implementation generated from reading ui file '.\untitled.ui'
#
# Created by: PyQt6 UI code generator 6.4.2
#
Expand Down Expand Up @@ -169,12 +169,6 @@ def setupUi(self, Form):
self.horizontalLayout_8.addItem(spacerItem7)
self.hangxian = QtWidgets.QComboBox(parent=self.horizontalLayoutWidget_8)
self.hangxian.setObjectName("hangxian")
self.hangxian.addItem("")
self.hangxian.addItem("")
self.hangxian.addItem("")
self.hangxian.addItem("")
self.hangxian.addItem("")
self.hangxian.addItem("")
self.horizontalLayout_8.addWidget(self.hangxian)
self.horizontalLayoutWidget_9 = QtWidgets.QWidget(parent=self.groupBox_2)
self.horizontalLayoutWidget_9.setGeometry(QtCore.QRect(120, 20, 131, 31))
Expand Down Expand Up @@ -298,18 +292,12 @@ def retranslateUi(self, Form):
self.groupBox_2.setTitle(_translate("Form", "选择代理"))
self.label_9.setText(_translate("Form", "港口"))
self.label_8.setText(_translate("Form", "航线"))
self.hangxian.setItemText(0, _translate("Form", "东亚"))
self.hangxian.setItemText(1, _translate("Form", "东南亚"))
self.hangxian.setItemText(2, _translate("Form", "印巴"))
self.hangxian.setItemText(3, _translate("Form", "澳大利亚"))
self.hangxian.setItemText(4, _translate("Form", "北美"))
self.hangxian.setItemText(5, _translate("Form", "南美"))
self.label_10.setText(_translate("Form", "国家"))
self.groupBox_3.setTitle(_translate("Form", "添加代理信息"))
self.add_agent_email.setText(_translate("Form", "添加"))
self.pushButton_2.setText(_translate("Form", "删除"))
self.label_11.setText(_translate("Form", "代理名称"))
self.groupBox_4.setTitle(_translate("Form", "渲染界面"))
self.groupBox_4.setTitle(_translate("Form", "自动识别以及渲染界面"))
self.groupBox_5.setTitle(_translate("Form", "发送邮件"))
self.Preview_email.setText(_translate("Form", "预览"))
self.label_12.setText(_translate("Form", "询价编号"))
Expand All @@ -318,5 +306,5 @@ def retranslateUi(self, Form):
self.groupBox_6.setTitle(_translate("Form", "编号加载"))
self.aoto.setText(_translate("Form", "生成"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("Form", "询价"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("Form", "提单"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("Form", "预付货总结"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("Form", "设置"))
33 changes: 1 addition & 32 deletions untitled.ui → Ui/untitled.ui
Original file line number Diff line number Diff line change
Expand Up @@ -466,38 +466,7 @@
</spacer>
</item>
<item>
<widget class="QComboBox" name="hangxian">
<item>
<property name="text">
<string>东亚</string>
</property>
</item>
<item>
<property name="text">
<string>东南亚</string>
</property>
</item>
<item>
<property name="text">
<string>印巴</string>
</property>
</item>
<item>
<property name="text">
<string>澳大利亚</string>
</property>
</item>
<item>
<property name="text">
<string>北美</string>
</property>
</item>
<item>
<property name="text">
<string>南美</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="hangxian"/>
</item>
</layout>
</widget>
Expand Down
2 changes: 2 additions & 0 deletions controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#询价界面
from .inquiry import work_inquiry
35 changes: 21 additions & 14 deletions work/inquiry.py → controllers/inquiry.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import sys
import json
import os
from PyQt6.QtGui import QStandardItemModel, QStandardItem
from PyQt6.QtWidgets import QListView, QAbstractItemView, QMainWindow, QMessageBox, QHeaderView
from email_api.agent_email_sql import Agent, Session
from utils import email_sql
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine, Column, Integer, String, TEXT
import logging
import email_api.inquiry.smtp as smtps

from utils import inquiry_smtp
from utils import port
logger = logging.getLogger("my_logger")

# 获取港口信息
with open(os.path.join(os.getcwd(), "conf", "port.json"), "r", encoding="utf-8") as f:
port_conf = f.read()
port_conf = json.loads(port_conf)
port_conf = port()


# 数据库操作方法
session = Session()

session = email_sql.Session()
Agent = email_sql.Agent

def insert(name, email):
agent = Agent(name=name, email=email)
Expand Down Expand Up @@ -71,6 +68,9 @@ def write_port_name(port, name, email):
class work_inquiry:
def __init__(self, main_window):
self.main_window = main_window
self.get_line()
self.get_country()
self.get_port()
self.main_window.hangxian.currentIndexChanged.connect(self.get_country)
self.main_window.guojia.currentIndexChanged.connect(self.get_port)
self.main_window.gangkou.currentIndexChanged.connect(self.get_proxy)
Expand All @@ -80,10 +80,17 @@ def __init__(self, main_window):
self.main_window.aoto.clicked.connect(self.random_number)
self.main_window.delete_data.clicked.connect(self.delete_data)

#自动生成航线菜单栏中的内容
def get_line(self):
self.main_window.hangxian.clear()
#读取航线
line = list(port_conf.get_line())
self.main_window.hangxian.addItems(line)

# 根据选择的航线,获取json中的国家
def get_country(self):
ship_route = self.main_window.hangxian.currentText()
country = list(port_conf[ship_route].keys())
country = list(port_conf.get_country(ship_route))
# 更新到ComboBox
self.main_window.guojia.clear()
self.main_window.guojia.addItems(country)
Expand All @@ -93,7 +100,7 @@ def get_country(self):
def get_port(self):
ship_route = self.main_window.hangxian.currentText()
if country := self.main_window.guojia.currentText():
port = port_conf[ship_route][country]
port = list(port_conf.get_port(ship_route,country))
# 更新到ComboBox
self.main_window.gangkou.clear()
self.main_window.gangkou.addItems(port)
Expand Down Expand Up @@ -173,7 +180,7 @@ def preview_data(self):
["hs_code", f"{hs_code}"],
["cargo_description", f"{goods_description}"],
]
return smtps.mail_template(clause, port, address, data)
return inquiry_smtp.mail_template(clause, port, address, data)

# 预览显示到界面
def preview(self):
Expand All @@ -200,7 +207,7 @@ def send_email(self):
for index in selected_indexes:
proxy_infos = read_email(index.data(), port)
# 发送邮件
report = smtps.send_mail(proxy_infos, subject, template)
report = inquiry_smtp.send_mail(proxy_infos, subject, template)
# 判断reports列表中是否含有false
if report == False:
QMessageBox.about(self.main_window, "提示", "发送失败")
Expand All @@ -212,7 +219,7 @@ def send_email(self):

# 随机生成询价编号
def random_number(self):
import work.random_number as random_number
import utils as random_number

inquiry_number = random_number.reandom()
self.main_window.random_number.clear()
Expand Down
18 changes: 0 additions & 18 deletions email_api/get/folder.py

This file was deleted.

35 changes: 35 additions & 0 deletions init_conf/国家港口信息.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
印巴:
印度:
- 那瓦西瓦
- 清奈
巴基斯坦:
- 卡拉奇
东亚:
日本:
- 东京
- 大阪
韩国:
- 首尔
- 釜山
东南亚:
泰国:
- 曼谷
越南:
- 河内
- 胡志明市
澳大利亚:
澳大利亚:
- 墨尔本
- 悉尼
北美:
美国:
- 洛杉矶
- 纽约
加拿大:
- 温哥华
- 多伦多
南美:
巴西:
- 里约热内卢
巴拿马:
- 厄瓜多尔
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
os.rename("init_conf", "conf")

from PyQt6.QtWidgets import QApplication, QMainWindow
from Ui_untitled import Ui_Form
from Ui.Ui_untitled import Ui_Form
import sys
from work.inquiry import work_inquiry
from controllers import work_inquiry
import logging

logpath = os.path.join(os.getcwd(), "log.log")
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ imbox @ git+https://github.com/martinrusev/imbox.git@616e278519a6b906d42e98a44ac
PyQt6==6.5.2
PyQt6_sip==13.5.2
SQLAlchemy==1.4.49
pyyaml==6.0.1
14 changes: 13 additions & 1 deletion init_conf/port.json → tests/test.PY
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import json

# JSON 数据
json_data = '''
{
"印巴": {
"印度": [
Expand Down Expand Up @@ -51,4 +55,12 @@
"厄瓜多尔"
]
}
}
}
'''

# 解析 JSON 数据
data = json.loads(json_data)

# 遍历 JSON 数据的键
for key in data.keys():
print(data[key].keys())
8 changes: 8 additions & 0 deletions utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#获取conf中的信息
from .comfig import port
#发送询价邮件
from .email_api import inquiry_smtp
#生成随机编号
from . import random_number
#获取数据库
from .email_api import email_sql
Empty file added utils/ai/__init__.py
Empty file.
Empty file added utils/ai/chatglm.py
Empty file.
21 changes: 21 additions & 0 deletions utils/comfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import yaml
import os

class port():
def __init__(self):
path = os.getcwd()
port_path = os.path.join(path, "conf","国家港口信息.yaml")
with open(port_path, "r",encoding='utf-8') as f:
self.config = yaml.safe_load(f)

#获取航线
def get_line(self):
return self.config.keys()

#获取国家
def get_country(self,line):
return self.config[line]

#获取港口
def get_port(self,line,country):
return self.config[line][country]
Empty file added utils/email_api/__init__.py
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from email.mime.image import MIMEImage
import os
import json
from email_api.agent_email_sql import Session, Agent
from .email_sql import Session, Agent
import logging

logger = logging.getLogger("my_logger")
Expand Down
File renamed without changes.

0 comments on commit 40df588

Please sign in to comment.