Browse Source

update 优化代码

yue 1 week ago
parent
commit
e03675d12f

+ 1 - 1
SourceCode/IntelligentRailwayCosting/Docker/Dockerfile

@@ -28,7 +28,7 @@ COPY app/ /app
 
 
 # 暴露端口
-EXPOSE 5123
+EXPOSE 8080
 
 
 # 启动命令

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

@@ -51,7 +51,7 @@ services:
     networks:
       - railway_costing_v1
     ports:
-      - "7010:5123"
+      - "7010:8080"
     restart: always
 
 networks:

+ 1 - 1
SourceCode/IntelligentRailwayCosting/Docker/docker-compose_mysql.yml

@@ -33,7 +33,7 @@ services:
     networks:
       - railway_costing_mysql_v1
     ports:
-      - "7012:5123"
+      - "7011:8080"
     restart: always
 
 networks:

+ 1 - 1
SourceCode/IntelligentRailwayCosting/Docker/docker-compose_sqlserver.yml

@@ -15,5 +15,5 @@ services:
       - /home/docker/iwb_railway_costing_v1/app/logs:/app/logs
       - /home/docker/iwb_railway_costing_v1/app/temp_files:/app/temp_files
     ports:
-      - "7010:5123"
+      - "7010:8080"
     restart: always

+ 6 - 0
SourceCode/IntelligentRailwayCosting/app/core/configs/app_config.py

@@ -8,6 +8,7 @@ class AppConfig:
     _task_api_url = ""
     _task_max_projects_count = 10
     _task_interval = 300  # 任务执行间隔时间,单位秒
+    _ai_flag = "_AI"
 
     @property
     def name(self):
@@ -37,6 +38,10 @@ class AppConfig:
     def task_interval(self) -> int:
         return self._task_interval
 
+    @property
+    def ai_flag(self) -> str:
+        return self._ai_flag
+
     def update_config(self, config):
         """更新应用配置
 
@@ -50,3 +55,4 @@ class AppConfig:
         self._task_api_url = config.get("task_api_url", "")
         self._task_max_projects_count = int(config.get("task_max_projects", 10))
         self._task_interval = int(config.get("task_interval", 300))
+        self._ai_flag = config.get("ai_flag", "_AI")

+ 40 - 36
SourceCode/IntelligentRailwayCosting/app/core/dtos/excel_parse.py

@@ -52,17 +52,18 @@ class ExcelParseFileDto:
 
 class ExcelParseDto:
     def __init__(
-        self,
-        task_id: int,
-        version: str,
-        project_id: str,
-        project_name: str,
-        project_stage: str,
-        selected_zgs_id: int,
-        zgs_list: list[ExcelParseZgsDto],
-        hierarchy: list[ExcelParseItemDto],
-        components: list[ExcelParseItemDto],
-        files: list[ExcelParseFileDto],
+            self,
+            task_id: int,
+            version: str,
+            project_id: str,
+            project_name: str,
+            project_stage: str,
+            selected_zgs_id: int,
+            zgs_list: list[ExcelParseZgsDto],
+            selected_chapter: list[ExcelParseItemDto],
+            # hierarchy: list[ExcelParseItemDto],
+            # components: list[ExcelParseItemDto],
+            files: list[ExcelParseFileDto],
     ):
         self.task_id = task_id
         self.version = version
@@ -71,12 +72,13 @@ class ExcelParseDto:
         self.project_stage = project_stage
         self.selected_zgs_id = -1 if selected_zgs_id == 0 else selected_zgs_id
         self.zgs_list = zgs_list
-        self.hierarchy = hierarchy
-        self.components = components
+        self.selected_chapter = selected_chapter
+        # self.hierarchy = hierarchy
+        # self.components = components
         self.files = files
 
     def to_dict(self):
-        return {
+        data = {
             "task_id": self.task_id,
             "version": self.version,
             "project_id": self.project_id,
@@ -85,9 +87,11 @@ class ExcelParseDto:
             "selected_zgs_id": self.selected_zgs_id,
             "files": [file.to_dict() for file in self.files],
             "zgs_list": [zgs.to_dict() for zgs in self.zgs_list],
-            "hierarchy": [item.to_dict() for item in self.hierarchy],
-            "components": [item.to_dict() for item in self.components],
+            "selected_chapter": [item.to_dict() for item in self.selected_chapter],
+            # "hierarchy": [item.to_dict() for item in self.hierarchy],
+            # "components": [item.to_dict() for item in self.components],
         }
+        return data
 
 
 class ExcelParseResultDataDto:
@@ -108,21 +112,21 @@ class ExcelParseResultDataDto:
     #     "ex_amount": excel中给出的数量, // number
     # }
     def __init__(
-        self,
-        zgs_id: int,  # 总概算id
-        zgs_code: str,  # 总概算编号
-        item_id: int,  # 条⽬序号
-        item_code: str,  # 条⽬编码
-        entry_name: str,  # ⼯程或费⽤项⽬名称,来⾃于定额表,
-        dinge_code: str,  # 定额编号,
-        units: str,  # 单位,
-        amount: float,  # 数量,
-        target_id: int,  # ⽤户数据库中条⽬的id,-1表示没有,
-        ex_file_id: str,  # excel⽂件id,
-        ex_cell: str,  # 数量单元格位置,例如 "C17",
-        ex_row: str,  # 该⾏内容,由逗号连接多个单元格得到,
-        ex_unit: str,  # excel中给出的单位,
-        ex_amount: float,  # excel中给出的数量,
+            self,
+            zgs_id: int,  # 总概算id
+            zgs_code: str,  # 总概算编号
+            item_id: int,  # 条⽬序号
+            item_code: str,  # 条⽬编码
+            entry_name: str,  # ⼯程或费⽤项⽬名称,来⾃于定额表,
+            dinge_code: str,  # 定额编号,
+            units: str,  # 单位,
+            amount: float,  # 数量,
+            target_id: int,  # ⽤户数据库中条⽬的id,-1表示没有,
+            ex_file_id: str,  # excel⽂件id,
+            ex_cell: str,  # 数量单元格位置,例如 "C17",
+            ex_row: str,  # 该⾏内容,由逗号连接多个单元格得到,
+            ex_unit: str,  # excel中给出的单位,
+            ex_amount: float,  # excel中给出的数量,
     ):
         self.zgs_id = zgs_id
         self.zgs_code = zgs_code
@@ -188,11 +192,11 @@ class ExcelParseResultDataDto:
 
 class ExcelParseResultDto:
     def __init__(
-        self,
-        task_id: int,
-        result: int = -1,
-        reason: str = "",
-        data: list[ExcelParseResultDataDto] = None,
+            self,
+            task_id: int,
+            result: int = -1,
+            reason: str = "",
+            data: list[ExcelParseResultDataDto] = None,
     ):
         self.task_id = task_id
         self.result = result  # -1-失败;0-运行中;1-成功

+ 29 - 22
SourceCode/IntelligentRailwayCosting/app/executor/task_processor.py

@@ -54,15 +54,19 @@ class TaskProcessor:
             budgets = [
                 TotalBudgetInfoDto.from_model(budget) for budget in budget_models
             ]
-            parents = self._chapter_store.get_all_parents_chapter_items(
+            chapter = self._chapter_store.get_chapter_item_by_item_code(
                 task.project_id, task.item_code
             )
-            children = self._chapter_store.get_all_children_chapter_items(
-                task.project_id, task.item_code
-            )
-            data, msg = self._build_api_body(
-                task, project, budgets, parents, children, files
-            )
+            # parents = self._chapter_store.get_all_parents_chapter_items(
+            #     task.project_id, task.item_code
+            # )
+            # children = self._chapter_store.get_all_children_chapter_items(
+            #     task.project_id, task.item_code
+            # )
+            # data, msg = self._build_api_body(
+            #     task, project, budgets, parents, children, files
+            # )
+            data, msg = self._build_api_body(task, project, budgets, chapter, files)
             if not data:
                 raise Exception(msg)
             res = self._call_api(self._task_submit_url, data)
@@ -172,18 +176,20 @@ class TaskProcessor:
             return None, msg
 
     def _build_api_body(
-        self,
-        task: ProjectTaskDto,
-        project: ProjectDto,
-        budgets: list[TotalBudgetInfoDto],
-        parents: list[ChapterDto],
-        children: list[ChapterDto],
-        files: list[ExcelParseFileDto],
+            self,
+            task: ProjectTaskDto,
+            project: ProjectDto,
+            budgets: list[TotalBudgetInfoDto],
+            chapter: list[ChapterDto],
+            # parents: list[ChapterDto],
+            # children: list[ChapterDto],
+            files: list[ExcelParseFileDto],
     ):
         try:
             budgets_data = [ExcelParseZgsDto.from_dto(budget) for budget in budgets]
-            parents_data = [ExcelParseItemDto.from_dto(parent) for parent in parents]
-            children_data = [ExcelParseItemDto.from_dto(child) for child in children]
+            chapter_data = [ExcelParseItemDto.from_dto(chapter) for chapter in chapter]
+            # parents_data = [ExcelParseItemDto.from_dto(parent) for parent in parents]
+            # children_data = [ExcelParseItemDto.from_dto(child) for child in children]
             data = ExcelParseDto(
                 task_id=task.id or 0,
                 version=configs.app.version or "2020",
@@ -192,8 +198,9 @@ class TaskProcessor:
                 project_stage=project.design_stage,
                 selected_zgs_id=task.budget_id or 0,
                 zgs_list=budgets_data,
-                hierarchy=parents_data,
-                components=children_data,
+                selected_chapter=chapter_data,
+                # hierarchy=parents_data,
+                # components=children_data,
                 files=files,
             )
             return data, ""
@@ -226,10 +233,10 @@ class TaskProcessor:
             raise Exception(msg)
 
     def _insert_data(
-        self,
-        task: ProjectTaskDto,
-        project: ProjectDto,
-        data: list[ExcelParseResultDataDto],
+            self,
+            task: ProjectTaskDto,
+            project: ProjectDto,
+            data: list[ExcelParseResultDataDto],
     ):
         try:
             self._logger.debug(f"开始插入数据:{task.task_name}")

+ 2 - 1
SourceCode/IntelligentRailwayCosting/app/executor/task_sender.py

@@ -1,4 +1,4 @@
-import tools.utils as utils
+import tools.utils as utils, core.configs as configs
 from core.dtos import ProjectTaskDto, ProjectQuotaDto, QuotaInputDto
 from core.enum import SendStatusEnum
 from stores import ProjectQuotaStore, ProjectTaskStore, QuotaInputStore
@@ -63,6 +63,7 @@ class TaskSender:
     def _save_quota(self, quota: QuotaInputDto, project_id: str):
         try:
             # data = self._quota_input_store.get_quota(project_id, quota.budget_id,quota.item_id,quota.quota_code)
+            quota.project_name = f"{quota.project_name}{configs.app.ai_flag}"
             if quota.quota_id and quota.quota_id > 0:
                 self._logger.debug(
                     f"修改定额输入[{quota.quota_id}]:{quota.project_name} {quota.quota_code} {quota.quota_id}"

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

@@ -13,7 +13,7 @@ def main():
     thread.daemon = True
     thread.start()
 
-    app.run(host="0.0.0.0", port=5123)  # 指定HTTP端口为5123
+    app.run(host="0.0.0.0", port=8080)  # 指定HTTP端口为8080
 
 
 if __name__ == "__main__":

+ 8 - 8
SourceCode/IntelligentRailwayCosting/app/stores/quota_input.py

@@ -20,13 +20,13 @@ class QuotaInputStore:
         return self._current_user
 
     def get_quotas_paginated(
-            self,
-            project_id: str,
-            budget_id: int,
-            item_id: int,
-            page: int = 1,
-            page_size: int = 10,
-            keyword: Optional[str] = None,
+        self,
+        project_id: str,
+        budget_id: int,
+        item_id: int,
+        page: int = 1,
+        page_size: int = 10,
+        keyword: Optional[str] = None,
     ):
         """分页查询定额输入列表
 
@@ -147,7 +147,7 @@ class QuotaInputStore:
             return QuotaInputDto.from_model(model)
 
     def update_quota(
-            self, project_id: str, dto: QuotaInputDto
+        self, project_id: str, dto: QuotaInputDto
     ) -> Optional[QuotaInputDto]:
         """更新定额输入
 

+ 1 - 1
SourceCode/IntelligentRailwayCosting/app/views/static/project/budget_info.js

@@ -305,7 +305,7 @@ function RenderRightBox_Custom(data) {
                         }
                         str += `<!--<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="编辑" onclick="Edit(${row.id})"><i class="ki-duotone ki-message-edit fs-1"><span class="path1"></span><span class="path2"></span></i></button>-->`
                         if (row.process_status === 2 || row.process_status === 200) {
-                            str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary"  data-bs-toggle="tooltip" data-bs-placement="top" title="定额输入列表" onclick="GoTo('/quota_info/${project_id}/${row.id}')"><i class="ki-duotone ki-eye fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
+                            str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary"  data-bs-toggle="tooltip" data-bs-placement="top" title="定额输入列表" onclick="GoTo('/quota_info/${project_id}/${row.id}',0)"><i class="ki-duotone ki-eye fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
                         }
                         if (row.process_status !== 2 && row.process_status !== 1) {
                             str += `<button type="button" class="btn btn-icon btn-sm btn-light-danger"  data-bs-toggle="tooltip" data-bs-placement="top" title="删除" onclick="Delete(${row.id})"><i class="ki-duotone ki-trash-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`

+ 13 - 5
SourceCode/IntelligentRailwayCosting/app/views/static/project/quota_info.js

@@ -57,6 +57,12 @@ const quota_modal_template = `
             <div class="fv-row form-group mb-3">
               <label for="quota_code" class="form-label">定额编号</label>
               <input type="text" class="form-control" name="quota_code" id="quota_code" placeholder="请输入定额编号" />
+            </div>
+            <div class="fv-row form-group mb-3">
+              <label for="quota_code" class="form-label">章节条目</label>
+              <select type="text" class="form-select" name="chapter" id="chapter">
+                <option value="">请选择章节条目</option>
+              </select>
             </div>
 			<div class="d-flex pt-3 justify-content-center">
 			  <div class="form-check form-check-custom form-check-solid form-check-danger mb-3 is_cover_box">
@@ -100,10 +106,10 @@ table_run_select_template = `<select class="form-select form-select-sm me-5" nam
     table_send_select_template = `<select class="form-select form-select-sm me-5" name="send_status">
 												<option value="">全部推送状态</option>
 												<option value="0">未推送</option>
-												<option value="1">推送中</option>
+<!--												<option value="1">推送中</option>-->
 												<option value="200">推送成功</option>
 												<option value="2">推送失败</option>
-												<option value="3">数据变更</option>
+<!--												<option value="3">数据变更</option>-->
 											</select>`,
     table_template = `<div class="table-box table-responsive" data-id="{0}" id="table_box_{0}">
 								<div class="d-flex justify-content-between my-5">
@@ -444,14 +450,16 @@ function LoadQuotaTable(table) {
                     if (row.send_status === 0) {
                         str += `<button type="button" class="btn btn-icon btn-sm ${row.quota_id ? 'btn-primary' : 'btn-light-primary'}" data-bs-toggle="tooltip" data-bs-placement="top" title="开始推送" onclick="StartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
                     } else if (row.send_status === 200) {
-                        str += `<button type="button" class="btn btn-icon btn-sm  ${row.quota_id ? 'btn-warning' : 'btn-light-warning'}" data-bs-toggle="tooltip" data-bs-placement="top" title="重新推送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
+                        // str += `<button type="button" class="btn btn-icon btn-sm  ${row.quota_id ? 'btn-warning' : 'btn-light-warning'}" data-bs-toggle="tooltip" data-bs-placement="top" title="重新推送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
                     } else if (row.send_status === 2) {
                         str += `<button type="button" class="btn btn-icon btn-sm  ${row.quota_id ? 'btn-danger' : 'btn-light-danger'}" data-bs-toggle="tooltip" data-bs-placement="top" title="重新推送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
                     } else if (row.send_status === 3) {
                         str += `<button type="button" class="btn btn-icon btn-sm  ${row.quota_id ? 'btn-info' : 'btn-light-info'}" data-bs-toggle="tooltip" data-bs-placement="top" title="重新推送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
                     }
-                    str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="编辑" onclick="Edit_Quota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-message-edit fs-1"><span class="path1"></span><span class="path2"></span></i></button>`
-                    str += `<button type="button" class="btn btn-icon btn-sm btn-light-danger"  data-bs-toggle="tooltip" data-bs-placement="top" title="删除" onclick="Delete_Quota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-trash-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
+                    if (row.send_status !== 200) {
+                        str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="编辑" onclick="Edit_Quota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-message-edit fs-1"><span class="path1"></span><span class="path2"></span></i></button>`
+                        str += `<button type="button" class="btn btn-icon btn-sm btn-light-danger"  data-bs-toggle="tooltip" data-bs-placement="top" title="删除" onclick="Delete_Quota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-trash-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
+                    }
                     return str
                 }
             },