浏览代码

用户登录提交

wanger 8 月之前
父节点
当前提交
f016599947

+ 0 - 0
__init__.py


+ 4 - 5
processing/algs/gdal/ExportVectorByMask.py

@@ -53,12 +53,12 @@ class ExportVectorByMask(GdalAlgorithm):
     def initAlgorithm(self, config=None):
     def initAlgorithm(self, config=None):
         self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
         self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
                                                               self.tr('数据源')))
                                                               self.tr('数据源')))
-        self.addParameter(QgsProcessingParameterCrs(self.S_SRS,self.tr('数据源坐标系')))
+        self.addParameter(QgsProcessingParameterCrs(self.S_SRS, self.tr('数据源坐标系'), optional=True))
         self.addParameter(QgsProcessingParameterFeatureSource(self.MASK,
         self.addParameter(QgsProcessingParameterFeatureSource(self.MASK,
                                                               self.tr('导出的数据范围'),
                                                               self.tr('导出的数据范围'),
                                                               [QgsProcessing.TypeVectorPolygon]))
                                                               [QgsProcessing.TypeVectorPolygon]))
 
 
-        self.addParameter(QgsProcessingParameterCrs(self.T_SRS,self.tr('数据范围坐标系')))
+        self.addParameter(QgsProcessingParameterCrs(self.T_SRS, self.tr('数据范围坐标系'), optional=True))
 
 
         options_param = QgsProcessingParameterString(self.OPTIONS,
         options_param = QgsProcessingParameterString(self.OPTIONS,
                                                      self.tr('Additional creation options'),
                                                      self.tr('Additional creation options'),
@@ -99,15 +99,14 @@ class ExportVectorByMask(GdalAlgorithm):
         tsrs = self.parameterAsCrs(parameters, self.T_SRS, context)
         tsrs = self.parameterAsCrs(parameters, self.T_SRS, context)
         ssrs = self.parameterAsCrs(parameters, self.S_SRS, context)
         ssrs = self.parameterAsCrs(parameters, self.S_SRS, context)
 
 
-
         arguments = [
         arguments = [
             # '--config',
             # '--config',
             # 'SHAPE_ENCODING',
             # 'SHAPE_ENCODING',
             # 'ISO-8859-1',
             # 'ISO-8859-1',
             '-lco',
             '-lco',
             'ENCODING=UTF-8',
             'ENCODING=UTF-8',
-            #'LCID=CHINESE_SIMPLIFIED',
-            #'CP=936',
+            # 'LCID=CHINESE_SIMPLIFIED',
+            # 'CP=936',
             '-clipsrc',
             '-clipsrc',
             maskLayer,
             maskLayer,
             '-clipsrclayer',
             '-clipsrclayer',

+ 1 - 0
processing/algs/gdal/GdalAlgorithm.py

@@ -46,6 +46,7 @@ from processing.tools.PrintUtils import getLastPrint
 from processing.tools.requestUtils import (spotfileUpload, downloadspotfile, deletespotfile)
 from processing.tools.requestUtils import (spotfileUpload, downloadspotfile, deletespotfile)
 from processing.tools.FileListPrintUtils import getFileListPrint
 from processing.tools.FileListPrintUtils import getFileListPrint
 from processing.tools.SubprocessUtils import RunSubprocess
 from processing.tools.SubprocessUtils import RunSubprocess
+import processing.tools.QGS.load
 from qgis.PyQt.QtCore import NULL
 from qgis.PyQt.QtCore import NULL
 
 
 pluginPath = os.path.normpath(os.path.join(
 pluginPath = os.path.normpath(os.path.join(

+ 1 - 1
processing/tools/CustomWebView/Manager.py

@@ -18,7 +18,7 @@ from PyQt5.QtCore import QObject
 
 
 # 创建一个QWebEnginePage实例
 # 创建一个QWebEnginePage实例
 # page = QWebEnginePage(QWebEngineProfile())
 # page = QWebEnginePage(QWebEngineProfile())
-pageURI = 'http://192.168.100.30:8082/index'
+pageURI = 'http://192.168.60.2:8082/index'
 
 
 
 
 def main():
 def main():

+ 1 - 1
processing/tools/GeoServer/Geoserver.py

@@ -65,7 +65,7 @@ class FileReader:
 class Geoserver:
 class Geoserver:
     def __init__(
     def __init__(
             self,
             self,
-            service_url: str = "http://localhost:8080/geoserver",  # default deployment url during installation
+            service_url: str = "http://localhost:28085/geoserver",  # default deployment url during installation
             username: str = "admin",  # default username during geoserver installation
             username: str = "admin",  # default username during geoserver installation
             password: str = "geoserver",  # default password during geoserver installation
             password: str = "geoserver",  # default password during geoserver installation
             request_options: Dict[str, Any] = None  # additional parameters to be sent with each request
             request_options: Dict[str, Any] = None  # additional parameters to be sent with each request

+ 90 - 0
processing/tools/Login/Login.py

@@ -0,0 +1,90 @@
+import inspect
+import shutil
+import os
+import time
+from typing import Optional
+import bcrypt
+
+from PyQt5.QtCore import Qt, QUrl, QSize
+from PyQt5.QtGui import QIcon
+from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QTreeWidget, QTreeWidgetItem, QMenu, QFileDialog, \
+    QMessageBox, QInputDialog, QLineEdit, QPushButton, QHBoxLayout, QFormLayout, QToolBar
+from PyQt5.QtWebEngineWidgets import *
+import ftplib
+import sys
+from PostgreSQL import PostgreSQL
+from Redis import Redis
+import socket
+from qgis.utils import iface
+
+
+class Login(QWidget):
+
+    def __init__(self, parent=None):
+        super().__init__(parent)
+        self.setupUi()
+
+    def setupUi(self):
+        self.setWindowTitle("用户登录")
+        self.resize(250, 100)
+        self.username_edit = QLineEdit()
+        self.password_edit = QLineEdit()
+        self.password_edit.setEchoMode(QLineEdit.Password)
+        current_directory = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
+        self.setWindowIcon(QIcon(os.path.join(current_directory, "login.png")))
+        login_button = QPushButton("登录")
+        login_button.clicked.connect(self.login)
+        layout = QFormLayout()
+        layout.addRow("用户名", self.username_edit)
+        layout.addRow("密码", self.password_edit)
+        layout.addRow(login_button)
+        self.setLayout(layout)
+
+    def checklogin(self):
+        redis = Redis()
+        s = redis.getUsername()
+        redis.close()
+        if s is not None:
+            app.quit()
+
+    def login(self):
+        username = self.username_edit.text()
+        password = self.password_edit.text()
+        if username is not None and password is not None:
+            pgconn = PostgreSQL(schema='base')
+            rows = pgconn.getPasswordByUsername(username)
+            pgconn.close()
+            if len(rows) == 0:
+                QMessageBox.critical(self, "提示信息", "用户名错误!")
+            else:
+                userpass = rows[0][0]
+                checked = bcrypt.checkpw(password.encode('utf-8'), userpass.encode('utf-8'))
+                print(checked)
+                if checked:
+                    QMessageBox.information(self, "提示信息", "登录成功")
+                    # 存储用户名到Redis
+                    redis = Redis()
+                    redis.setUsername(username)
+                    s = redis.getUsername()
+                    print(s)
+                    redis.close()
+                    app.quit()
+                else:
+                    QMessageBox.critical(self, "提示信息", "密码错误!")
+        else:
+            QMessageBox.critical(self, "提示信息", "请输入用户名、密码!")
+
+
+if __name__ == '__main__':
+    app = QApplication(sys.argv)
+    login = Login()
+    login.show()
+    # login.checklogin()
+    sys.exit(app.exec_())
+    # time.sleep(0.5)
+    # redis = Redis()
+    # s = redis.getUsername()
+    # redis.close()
+    # if s is not None:
+    #     app.quit()
+

+ 61 - 0
processing/tools/Login/PostgreSQL.py

@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+
+__author__ = 'wanger'
+__date__ = '2024-08-20'
+__copyright__ = '(C) 2024 by siwei'
+__revision__ = '1.0'
+
+import time
+from typing import Optional
+import os
+import psycopg2
+import uuid
+
+
+class PostgreSQL:
+    # 用户表
+    Sys_user = "sys_user"
+
+    def __init__(
+            self,
+            host: Optional[str] = "127.0.0.1",  # default host during installation
+            port: Optional[str] = "5432",  # default port during pg installation
+            user: Optional[str] = "postgres",  # default user during pg installation
+            password: Optional[str] = "postgres",  # default password during pg installation
+            dbname: Optional[str] = "real3d",  # default dbname during pg installation
+            schema: Optional[str] = None
+    ):
+        # 配置数据库连接参数并指定schema
+        self.connparams = {
+            "dbname": dbname,
+            "user": user,
+            "password": password,
+            "host": host,
+            "port": port,
+            "options": "-c search_path=otherSchema," + schema if schema is not None else None
+        }
+        self.conn = psycopg2.connect(**self.connparams)
+        # 创建一个游标对象
+        self.cur = self.conn.cursor()
+
+    def execute(self, sql):
+        # 执行一个查询
+        self.cur.execute(sql)
+        # 获取查询结果
+        return self.cur.fetchall()
+
+    def close(self):
+        # 关闭游标和连接
+        self.cur.close()
+        self.conn.close()
+
+    # 根据用户名查询密码
+    def getPasswordByUsername(self, username):
+        sql = "SELECT password FROM {}  t where t.user_name = '{}'".format(self.Sys_user, username)
+        self.cur.execute(sql)
+        rows = self.cur.fetchall()
+        return rows
+
+    # 判断数据是否为字符串
+    def is_string(self, var):
+        return isinstance(var, str)

+ 53 - 0
processing/tools/Login/Redis.py

@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+
+__author__ = 'wanger'
+__date__ = '2024-08-20'
+__copyright__ = '(C) 2024 by siwei'
+__revision__ = '1.0'
+
+import time
+from typing import Optional
+import os
+import uuid
+import redis
+import socket
+
+
+class Redis:
+    redis_client = None
+    expire = 60 * 30  # 默认时长   单位s
+    hostname = socket.gethostname()
+    ipaddress = socket.gethostbyname(hostname)
+
+    def __init__(
+            self,
+            host: Optional[str] = "127.0.0.1",
+            port: Optional[int] = 6379,
+            db: Optional[int] = 0,
+    ):
+        self.redis_client = redis.Redis(host=host, port=port, db=db)
+
+    def set(self, key, value, expire=60 * 30):
+        self.redis_client.set(key, value, expire)
+
+    def get(self, key):
+        return self.redis_client.get(key)
+
+    def close(self):
+        self.redis_client.close()
+
+    def setUsername(self, value, expire=60 * 30):
+        self.redis_client.set(self.ipaddress, value, expire)
+
+    def getUsername(self):
+        self.redis_client.get(self.ipaddress)
+
+    def get_ip_address(self):
+        try:
+            # 获取本地主机名
+            hostname = socket.gethostname()
+            # 获取本地IP
+            ip_address = socket.gethostbyname(hostname)
+            return ip_address
+        except socket.error as e:
+            print(f"Unable to get IP Address: {e}")

+ 0 - 0
processing/tools/Login/__init__.py


二进制
processing/tools/Login/login.png


+ 44 - 0
processing/tools/QGS/load.py

@@ -0,0 +1,44 @@
+from PyQt5.QtCore import QObject, QEvent, Qt
+from PyQt5.QtWidgets import QToolBar
+from qgis.utils import iface
+
+
+def on_initialization_completed():
+    print("QGIS 初始化完成!")
+    iface.mainWindow().setWindowTitle("无标题工程 - 四维数码")
+    main_window = iface.mainWindow()
+    main_window.findChild(QToolBar, 'ProcessingAlgorithms').setVisible(0)
+    # 获取所有动作
+    # all_actions = iface.allActions()
+    #
+    # # 遍历所有动作并连接触发信号
+    # for action in all_actions:
+    #     action.triggered.connect(on_action_triggered)
+    print("注册事件")
+
+    # 创建事件过滤器实例
+    event_filter = ClickEventFilter(main_window)
+
+    # 安装事件过滤器到地图画布
+    main_window.installEventFilter(event_filter)
+
+
+class ClickEventFilter(QObject):
+    def __init__(self, parent=None):
+        super().__init__(parent)
+
+    def eventFilter(self, obj, event):
+        print("event")
+        if event.type() == QEvent.MouseButtonPress:
+            if event.button() == Qt.LeftButton:
+                print("左键点击事件")
+            elif event.button() == Qt.RightButton:
+                print("右键点击事件")
+            elif event.button() == Qt.MiddleButton:
+                print("中键点击事件")
+            return True  # 如果你返回True,则事件被过滤掉,不再传递给其他组件
+        return super().eventFilter(obj, event)
+
+
+# 连接信号到槽函数
+iface.initializationCompleted.connect(on_initialization_completed)