YueYunyun il y a 1 mois
Parent
commit
c4e36b1549

+ 1 - 1
SourceCode/IntelligentRailwayCosting/.script/cmd/Run_App.run.xml

@@ -2,7 +2,7 @@
   <configuration default="false" name="Run_App" type="docker-deploy" factoryName="docker-compose.yml" server-name="104">
     <deployment type="docker-compose.yml">
       <settings>
-        <option name="composeProjectName" value="tielu_dm" />
+        <option name="composeProjectName" value="railway_costing" />
         <option name="envFilePath" value="" />
         <option name="sourceFilePath" value="docker/docker-compose.yml" />
       </settings>

+ 5 - 5
SourceCode/IntelligentRailwayCosting/Docker/docker-compose.yml

@@ -37,11 +37,11 @@ services:
 #      - rc-mysql
     environment:
       - TZ=Asia/Shanghai
-      - APP_MYSQL__HOST=railway_costing-mysql
-      - APP_MYSQL__PORT=3306
-      - APP_MYSQL__DB=${MYSQL_DATABASE}
-      - APP_MYSQL__USER=${MYSQL_USER}
-      - APP_MYSQL__PASSWORD=${MYSQL_PASSWORD}
+#      - APP_MYSQL__HOST=railway_costing-mysql
+#      - APP_MYSQL__PORT=3306
+#      - APP_MYSQL__DB=${MYSQL_DATABASE}
+#      - APP_MYSQL__USER=${MYSQL_USER}
+#      - APP_MYSQL__PASSWORD=${MYSQL_PASSWORD}
     volumes:
       - /home/docker/iwb_railway_costing_v1/app/config.yml:/app/config.yml
       - /home/docker/iwb_railway_costing_v1/app/logs:/app/logs

+ 0 - 43
SourceCode/IntelligentRailwayCosting/app/__init__.py

@@ -1,43 +0,0 @@
-from flask import Flask
-from flask.json.provider import JSONProvider
-from routes.auth import login_manager
-from routes import register_api
-from views import register_views
-
-
-class CustomJSONProvider(JSONProvider):
-    def default(self, obj):
-        try:
-            return super().default(obj)
-        except TypeError:
-            return str(obj)
-            
-    def encode(self, obj):
-        return super().encode(obj).encode('utf-8').decode('unicode_escape')
-
-def create_app():
-    app = Flask(__name__, static_folder='views/static')
-    app.secret_key = "1qwe2iwb3vber"
-    app.config['JSON_AS_ASCII'] = False
-    app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024  # 限制上传文件大小为16MB
-    app.config['UPLOAD_EXTENSIONS'] = ['.jpg', '.png', '.pdf', '.doc', '.docx', '.xls', '.xlsx']  # 允许的文件类型
-    app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
-    app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
-    app.config['REQUEST_BODY_LIMIT'] = '16MB'
-    app.json_provider_class = CustomJSONProvider
-
-    login_manager.init_app(app)
-
-    # 注册所有蓝图
-    register_api(app)
-    register_views(app)
-
-    # 注册自定义过滤器
-    for rule in app.url_map.iter_rules():
-        route = {
-            'endpoint': rule.endpoint,
-            'methods': sorted(rule.methods),
-            'path': str(rule)
-        }
-        print(f"URL [{str(rule)}] ==> endpoint: {rule.endpoint}, methods: {sorted(rule.methods)}")
-    return app

+ 2 - 3
SourceCode/IntelligentRailwayCosting/app/config.yml

@@ -68,7 +68,7 @@ db:
 ai:
   api_key: sk-febca8fea4a247f096cedeea9f185520
   api_url: https://dashscope.aliyuncs.com/compatible-mode/v1
-  model: qwen-plus
+  model: qwen-max
   max_tokens: 1024
 fastgpt_ai:
   api_url: http://192.168.0.104:8020/api
@@ -86,5 +86,4 @@ fastgpt_ai:
     app_02_2024:
       api_url: http://192.168.0.104:8020/api
       api_key: fastgpt-o4CF7Pu1FRTvHjWFqeNcClBS6ApyflNfkBGXo9p51fuBMAX1L0erU8yz8
-file:
-  source_path: './temp_files'
+

+ 1 - 1
SourceCode/IntelligentRailwayCosting/app/core/configs/__init__.py

@@ -4,7 +4,7 @@ from .config import config
 # 导出配置实例和配置对象
 __all__ = ['config', 'app', 'database', 'ai', 'fastgpt_ai']
 
-_path = os.environ.get("CONFIG_PATH", os.path.join(os.path.dirname(__file__), "../..", "config.yml"))
+_path = os.environ.get("CONFIG_PATH",  "config.yml")
 
 # 初始化配置
 config.load_config(_path)

+ 2 - 1
SourceCode/IntelligentRailwayCosting/app/core/configs/config.py

@@ -32,7 +32,8 @@ class Config:
             path: 配置文件路径,如果为None则使用默认路径
         """
         if path is None:
-            path = os.environ.get("CONFIG_PATH", os.path.join(os.path.dirname(__file__), "../..", "config.yml"))
+            # path = os.environ.get("CONFIG_PATH", os.path.join(os.path.dirname(__file__), "../..", "config.yml"))
+            path = os.environ.get("CONFIG_PATH","config.yml")
 
         with open(path, 'r', encoding='utf-8') as f:
             cls._config = yaml.safe_load(f)

+ 6 - 2
SourceCode/IntelligentRailwayCosting/app/core/dtos/log.py

@@ -9,7 +9,7 @@ class LogDto(BaseModel):
     username: str
     operation_type: str
     operation_desc: str
-    operation_result: str
+    operation_result: str | int
     operation_module: str
     operation_data: Optional[str] = None
     data_changes: Optional[str] = None
@@ -34,7 +34,11 @@ class LogDto(BaseModel):
 
     def to_dict(self) -> dict:
         """转换为字典格式"""
-        return self.model_dump()
+        data = self.model_dump()
+
+        if self.created_at:
+            data['created_at'] = self.created_at.strftime('%Y-%m-%d %H:%M:%S')
+        return data
 
     class Config:
         from_attributes = True

+ 47 - 0
SourceCode/IntelligentRailwayCosting/app/flask_app/__init__.py

@@ -0,0 +1,47 @@
+from flask import Flask
+from flask.json.provider import JSONProvider
+from routes.auth import login_manager
+from routes import register_api
+from views import register_views
+
+
+class CustomJSONProvider(JSONProvider):
+    def default(self, obj):
+        try:
+            return super().default(obj)
+        except TypeError:
+            return str(obj)
+
+    def encode(self, obj):
+        return super().encode(obj).encode('utf-8').decode('unicode_escape')
+
+
+def create_app():
+    app = Flask(__name__, static_folder='../views/static')
+    app.secret_key = "1qwe2iwb3vber"
+    app.config['JSON_AS_ASCII'] = False
+    app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024  # 限制上传文件大小为16MB
+    app.config['UPLOAD_EXTENSIONS'] = ['.jpg', '.png', '.pdf', '.doc', '.docx', '.xls', '.xlsx']  # 允许的文件类型
+    app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
+    app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
+    app.config['REQUEST_BODY_LIMIT'] = '16MB'
+    app.json_provider_class = CustomJSONProvider
+
+    login_manager.init_app(app)
+
+    # 注册所有蓝图
+    register_api(app)
+    register_views(app)
+
+    # 注册自定义过滤器
+    for rule in app.url_map.iter_rules():
+        route = {
+            'endpoint': rule.endpoint,
+            'methods': sorted(rule.methods),
+            'path': str(rule)
+        }
+        print(f"URL [{str(rule)}] ==> endpoint: {rule.endpoint}, methods: {sorted(rule.methods)}")
+    return app
+
+
+__all__ = ['create_app']

+ 1 - 1
SourceCode/IntelligentRailwayCosting/app/main.py

@@ -1,4 +1,4 @@
-from  app import create_app
+from flask_app import create_app
 import tools.utils as utils
 logger = utils.get_logger()
 

+ 1 - 1
SourceCode/IntelligentRailwayCosting/app/tools/utils/config_helper.py

@@ -4,7 +4,7 @@ class ConfigHelper:
     _instance = None
 
     # 默认配置文件路径
-    default_config_path = os.path.join(os.path.dirname(__file__), "..\..", "config.yml")
+    default_config_path = "config.yml"
 
     # 类变量存储加载的配置
     _config = None

+ 38 - 35
SourceCode/IntelligentRailwayCosting/app/views/templates/log/index.html

@@ -3,49 +3,52 @@
 {% block title %}日志查询{% endblock %}
 
 {% block page_content %}
- <div class="header my-5">
+ <div class="app-body-header h-50px">
     <h3>日志查询</h3>
     <ol class="breadcrumb breadcrumb-dot text-muted fs-6 fw-semibold ms-5">
         <li class="breadcrumb-item text-muted">日志查询</li>
     </ol>
 </div>
-<div class="table-box table-responsive">
-    <div class="d-flex justify-content-between mb-5 mx-10">
-        <div>
-        </div>
-        <form class="search-box d-flex">
-            <div class="d-flex">
-                <input type="text" class="form-control form-control-sm w-200px me-5" placeholder="请输入用户名" name="username" />
-                <select class="form-select form-select-sm w-100 me-5" name="operationType" >
-                    <option value="">全部类型</option>
-                    {% for op in operation_type_list %}
-                        <option value="{{ op }}">{{ op }}</option>
-                    {% endfor %}
-                </select>
-                <select class="form-select form-select-sm w-100 me-5" name="operationModule" >
-                    <option value="">全部模块</option>
-                   {% for op in operation_module_list %}
-                        <option value="{{ op }}">{{ op }}</option>
-                    {% endfor %}
-                </select>
-                <select class="form-select form-select-sm w-100 me-5" name="operationResult" >
-                    <option value="">全部结果</option>
-                    <option value="1">成功</option>
-                    <option value="0">失败</option>
-                </select>
-                <input type="text" class="form-control form-control-sm w-200px me-5" placeholder="请输入关键字" name="date" id="date"/>
-            </div>
-            <div class="btn-group ms-5">
-                <button type="button" class="btn btn-primary btn-sm" onclick="IwbTableSearch(this)">查询</button>
-                <button type="button" class="btn btn-danger btn-sm" onclick="IwbTableResetSearch(this)">重置</button>
+<div class="mx-10 my-5">
+    <div class="table-box table-responsive">
+        <div class="d-flex justify-content-between mb-5 mx-10">
+            <div>
             </div>
-        </form>
+            <form class="search-box d-flex">
+                <div class="d-flex">
+                    <input type="text" class="form-control form-control-sm w-200px me-5" placeholder="请输入用户名" name="username" />
+                    <select class="form-select form-select-sm w-100 me-5" name="operationType" >
+                        <option value="">全部类型</option>
+                        {% for op in operation_type_list %}
+                            <option value="{{ op }}">{{ op }}</option>
+                        {% endfor %}
+                    </select>
+                    <select class="form-select form-select-sm w-100 me-5" name="operationModule" >
+                        <option value="">全部模块</option>
+                       {% for op in operation_module_list %}
+                            <option value="{{ op }}">{{ op }}</option>
+                        {% endfor %}
+                    </select>
+                    <select class="form-select form-select-sm w-100 me-5" name="operationResult" >
+                        <option value="">全部结果</option>
+                        <option value="0">成功</option>
+                        <option value="1">失败</option>
+                    </select>
+                    <input type="text" class="form-control form-control-sm w-200px me-5" placeholder="请输入关键字" name="date" id="date"/>
+                </div>
+                <div class="btn-group ms-5">
+                    <button type="button" class="btn btn-primary btn-sm" onclick="IwbTableSearch(this)">查询</button>
+                    <button type="button" class="btn btn-danger btn-sm" onclick="IwbTableResetSearch(this)">重置</button>
+                </div>
+            </form>
+        </div>
+        <table class="table table-striped table-bordered table-hover  table-rounded" id="table">
+        </table>
+        <div class="pagination-row"></div>
     </div>
-    <table class="table table-striped table-bordered table-hover  table-rounded" id="table">
-    </table>
-    <div class="pagination-row"></div>
 </div>
 
+
 <div class="modal fade" id="modal" tabindex="-1" aria-hidden="true">
     <div class="modal-dialog modal-dialog-centered">
         <div class="modal-content rounded">
@@ -178,7 +181,7 @@
                         data: 'operation_result',
                         width: '120px',
                         render: function (row) {
-                            if (row.operation_result === 1) {
+                            if (row.operation_result === 0) {
                                 return '<span class="badge badge-success">成功</span>';
                             } else {
                                 return '<span class="badge badge-danger">失败</span>';

+ 2 - 1
SourceCode/IntelligentRailwayCosting/requirements.txt

@@ -9,4 +9,5 @@ Flask~=3.1.0
 openai~=1.66.3
 pandas~=2.2.3
 requests~=2.32.3
-PyYAML~=6.0.2
+PyYAML~=6.0.2
+pyodbc~=5.2.0