Browse Source

Update project_quota添加字段quota_adjustment

yue 2 months ago
parent
commit
30660a2cbe

+ 2 - 2
SourceCode/IntelligentRailwayCosting/.script/cmd/Mysql_BuildRcApp_1.0.1.run.xml → SourceCode/IntelligentRailwayCosting/.script/cmd/Mysql_BuildRcApp_1.0.2.run.xml

@@ -1,8 +1,8 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="Mysql_BuildRcApp_1.0.1" type="docker-deploy" factoryName="dockerfile" server-name="104">
+  <configuration default="false" name="Mysql_BuildRcApp_1.0.2" type="docker-deploy" factoryName="dockerfile" server-name="104">
     <deployment type="dockerfile">
       <settings>
-        <option name="imageTag" value="railway_costing-app_mysql:1.0.1" />
+        <option name="imageTag" value="railway_costing-app_mysql:1.0.2" />
         <option name="buildOnly" value="true" />
         <option name="contextFolderPath" value="." />
         <option name="sourceFilePath" value="docker/Dockerfile" />

+ 1 - 0
SourceCode/IntelligentRailwayCosting/.script/init_mysql.sql

@@ -44,6 +44,7 @@ CREATE TABLE IF NOT EXISTS project_quota (
     item_code VARCHAR(255) NOT NULL COMMENT '条目编号',
     quota_id INT NULL DEFAULT 0 COMMENT '定额序号',
     quota_code VARCHAR(50) COMMENT '定额编号',
+    quota_adjustment TEXT COMMENT '定额调整',
     entry_name VARCHAR(255) COMMENT '工程或费用项目名称',
     units VARCHAR(20) COMMENT '单位',
     amount FLOAT COMMENT '数量',

+ 1 - 0
SourceCode/IntelligentRailwayCosting/.script/init_sqlserver.sql

@@ -76,6 +76,7 @@ CREATE TABLE [dbo].[project_quota] (
     [item_code] NVARCHAR(255) NOT NULL,
     [quota_id] INT NULL DEFAULT 0,
     [quota_code] NVARCHAR(50) NULL,
+    [quota_adjustment] TEXT NULL,
     [entry_name] NVARCHAR(255) NULL,
     [units] NVARCHAR(20) NULL,
     [amount] FLOAT NULL,

+ 5 - 3
SourceCode/IntelligentRailwayCosting/app/core/dtos/excel_parse.py

@@ -119,6 +119,7 @@ class ExcelParseResultDataDto:
             item_code: str,  # 条⽬编码
             entry_name: str,  # ⼯程或费⽤项⽬名称,来⾃于定额表,
             dinge_code: str,  # 定额编号,
+            dinge_adjust: str,  # 定额调整,
             units: str,  # 单位,
             amount: float,  # 数量,
             target_id: int,  # ⽤户数据库中条⽬的id,-1表示没有,
@@ -134,6 +135,7 @@ class ExcelParseResultDataDto:
         self.item_code = item_code
         self.entry_name = entry_name
         self.dinge_code = dinge_code
+        self.dinge_adjust = dinge_adjust
         self.units = units
         self.amount = amount
         self.target_id = target_id
@@ -153,13 +155,12 @@ class ExcelParseResultDataDto:
             item_code=data.get("item_code", ""),
             entry_name=data.get("entry_name", ""),
             dinge_code=data.get("dinge_code", ""),
+            dinge_adjust=data.get("dinge_adjust", ""),
             units=data.get("units", ""),
             amount=data.get("amount", 0.0),
             target_id=data.get("target_id", -1),
             ex_file_id=(
-                base64.b64decode(data.get("ex_file_id", "").encode("utf-8")).decode(
-                    "utf-8"
-                )
+                base64.b64decode(data.get("ex_file_id", "").encode()).decode()
                 if data.get("ex_file_id", "")
                 else ""
             ),
@@ -177,6 +178,7 @@ class ExcelParseResultDataDto:
             "item_code": self.item_code,
             "entry_name": self.entry_name,
             "dinge_code": self.dinge_code,
+            "dinge_adjust": self.dinge_adjust,
             "target_id": self.target_id,
             "units": self.units,
             "amount": self.amount,

+ 13 - 12
SourceCode/IntelligentRailwayCosting/app/core/dtos/project_quota.py

@@ -4,17 +4,20 @@ from datetime import datetime
 
 from core.models import ProjectQuotaModel
 
+
 class ProjectQuotaDto(BaseModel):
     """项目定额DTO"""
+
     id: Optional[int] = None
-    task_id:Optional[int] = None
+    task_id: Optional[int] = None
     project_id: str
     budget_id: int
-    budget_code: Optional[str] =None
+    budget_code: Optional[str] = None
     item_id: int
     item_code: str
     quota_id: Optional[int] = 0
     quota_code: Optional[str] = None
+    quota_adjustment: Optional[str] = None
     entry_name: Optional[str] = None
     units: Optional[str] = None
     amount: Optional[float] = None
@@ -31,9 +34,8 @@ class ProjectQuotaDto(BaseModel):
     updated_at: Optional[datetime] = None
     updated_by: Optional[str] = None
 
-
     @classmethod
-    def from_model(cls, model: ProjectQuotaModel) -> 'ProjectQuotaDto':
+    def from_model(cls, model: ProjectQuotaModel) -> "ProjectQuotaDto":
         """从数据库模型创建DTO对象"""
         return cls(
             id=model.id,
@@ -45,8 +47,9 @@ class ProjectQuotaDto(BaseModel):
             item_code=model.item_code,
             quota_id=model.quota_id,
             quota_code=model.quota_code,
+            quota_adjustment=model.quota_adjustment,
             entry_name=model.entry_name,
-            units = model.units,
+            units=model.units,
             amount=model.amount,
             ex_file=model.ex_file,
             ex_cell=model.ex_cell,
@@ -68,7 +71,6 @@ class ProjectQuotaDto(BaseModel):
 
     @classmethod
     def ai_prompt_struct(cls):
-
         return """```typescript
         export interface input_struct {  //输入数据结构体
             i: // ID
@@ -87,15 +89,15 @@ class ProjectQuotaDto(BaseModel):
         """
 
     @classmethod
-    def from_ai_dict(cls,data: dict):
+    def from_ai_dict(cls, data: dict):
         return cls(
             project_id="",
             budget_id=0,
             item_id=0,
             item_code="",
-            id=data.get("i",0),
-            quota_code=data.get("q",""),
-            units=data.get("u",""),
+            id=data.get("i", 0),
+            quota_code=data.get("q", ""),
+            units=data.get("u", ""),
         )
 
     def to_ai_dict(self):
@@ -106,6 +108,5 @@ class ProjectQuotaDto(BaseModel):
             "q": self.project_quantity,
         }
 
-
     class Config:
-        from_attributes = True
+        from_attributes = True

+ 7 - 4
SourceCode/IntelligentRailwayCosting/app/core/dtos/quota_input.py

@@ -3,8 +3,10 @@ from typing import Optional
 from core.models.quota_input import QuotaInputModel
 from core.dtos.project_quota import ProjectQuotaDto
 
+
 class QuotaInputDto(BaseModel):
     """定额输入DTO"""
+
     quota_id: Optional[int] = None
     budget_id: int
     item_id: int
@@ -14,7 +16,7 @@ class QuotaInputDto(BaseModel):
     unit: Optional[str] = None
     project_quantity: Optional[float] = None
     # project_quantity_input: Optional[str] = None
-    # quota_adjustment: Optional[str] = None
+    quota_adjustment: Optional[str] = None
     # unit_price: Optional[float] = None
     # compilation_unit_price: Optional[float] = None
     # total_price: Optional[float] = None
@@ -43,13 +45,14 @@ class QuotaInputDto(BaseModel):
     # compilation_mechanical_workday_salary: Optional[float] = None
     compiler: Optional[str] = None
     modify_date: Optional[str] = None
+
     # quota_consumption: Optional[str] = None
     # basic_quota: Optional[str] = None
     # quota_comprehensive_unit_price: Optional[float] = None
     # quota_comprehensive_total_price: Optional[float] = None
 
     @classmethod
-    def from_model(cls, model: QuotaInputModel) -> 'QuotaInputDto':
+    def from_model(cls, model: QuotaInputModel) -> "QuotaInputDto":
         """从数据库模型创建DTO对象"""
         return cls(
             quota_id=model.quota_id,
@@ -108,7 +111,7 @@ class QuotaInputDto(BaseModel):
             unit=quota_dto.units,
             project_quantity=quota_dto.amount,
             # project_quantity_input=quota_dto.project_quantity_input,
-            # quota_adjustment=quota_dto.quota_adjustment,
+            quota_adjustment=quota_dto.quota_adjustment,
             # unit_price=quota_dto.unit_price,
             # compilation_unit_price=quota_dto.compilation_unit_price,
             # total_price=quota_dto.total_price,
@@ -147,4 +150,4 @@ class QuotaInputDto(BaseModel):
         return self.model_dump()
 
     class Config:
-        from_attributes = True
+        from_attributes = True

+ 45 - 27
SourceCode/IntelligentRailwayCosting/app/core/models/project_quota.py

@@ -4,35 +4,53 @@ from sqlalchemy.ext.declarative import declarative_base
 
 Base = declarative_base()
 
+
 class ProjectQuotaModel(Base):
-    __tablename__ = 'project_quota'
+    __tablename__ = "project_quota"
     id = Column(Integer, primary_key=True, autoincrement=True)
-    task_id = Column(Integer, nullable=False, comment='任务编号')
-    project_id = Column(String(50), nullable=False, comment='项目编号')
-    budget_id = Column(Integer, nullable=False, comment='概算序号')
-    budget_code = Column(String(50), comment='概算编号')
-    item_id = Column(Integer, nullable=False, comment='条目序号')
-    item_code = Column(String(255), nullable=False, comment='条目编号')
-    quota_id = Column(Integer, nullable=False, default=0, comment='定额序号')
-    quota_code = Column(String(50), comment='定额编号')
-    entry_name = Column(String(255), comment='工程或费用项目名称')
-    units = Column(String(20), comment='单位')
-    amount = Column(Float, comment='数量')
-    ex_file = Column(String(5000), comment='excel⽂件')
+    task_id = Column(Integer, nullable=False, comment="任务编号")
+    project_id = Column(String(50), nullable=False, comment="项目编号")
+    budget_id = Column(Integer, nullable=False, comment="概算序号")
+    budget_code = Column(String(50), comment="概算编号")
+    item_id = Column(Integer, nullable=False, comment="条目序号")
+    item_code = Column(String(255), nullable=False, comment="条目编号")
+    quota_id = Column(Integer, nullable=False, default=0, comment="定额序号")
+    quota_code = Column(String(50), comment="定额编号")
+    quota_adjustment = Column(String(50), comment="定额调整")
+    entry_name = Column(String(255), comment="工程或费用项目名称")
+    units = Column(String(20), comment="单位")
+    amount = Column(Float, comment="数量")
+    ex_file = Column(String(5000), comment="excel⽂件")
     ex_cell = Column(String(50), comment='数量单元格位置,例如"C17"')
-    ex_row = Column(String(5000), comment='该⾏内容,由逗号连接多个单元格得到')
-    ex_unit = Column(String(50), comment='excel中给出的单位')
-    ex_amount = Column(Float, comment='excel中给出的数量')
-    send_status = Column(Integer, nullable=False, default=0, comment='发送状态(0:未发送,1:发送中 ,2:已发送, 3:发送失败)')
-    send_time = Column(DateTime, comment='发送时间')
-    send_error = Column(String(5000), comment='发送错误信息')
-    is_del = Column(Integer, nullable=False, default=0, comment='是否删除(0:否, 1:是)')
-    deleted_by = Column(String(50), comment='删除人')
-    deleted_at = Column(DateTime, comment='删除时间')
-    created_by = Column(String(50), comment='创建人')
-    created_at = Column(DateTime, nullable=False, server_default=func.current_timestamp(), comment='创建时间')
-    updated_by = Column(String(50), comment='更新人')
-    updated_at = Column(DateTime, nullable=False, server_default=func.current_timestamp(), server_onupdate=func.current_timestamp(), comment='更新时间')
+    ex_row = Column(String(5000), comment="该⾏内容,由逗号连接多个单元格得到")
+    ex_unit = Column(String(50), comment="excel中给出的单位")
+    ex_amount = Column(Float, comment="excel中给出的数量")
+    send_status = Column(
+        Integer,
+        nullable=False,
+        default=0,
+        comment="发送状态(0:未发送,1:发送中 ,2:已发送, 3:发送失败)",
+    )
+    send_time = Column(DateTime, comment="发送时间")
+    send_error = Column(String(5000), comment="发送错误信息")
+    is_del = Column(Integer, nullable=False, default=0, comment="是否删除(0:否, 1:是)")
+    deleted_by = Column(String(50), comment="删除人")
+    deleted_at = Column(DateTime, comment="删除时间")
+    created_by = Column(String(50), comment="创建人")
+    created_at = Column(
+        DateTime,
+        nullable=False,
+        server_default=func.current_timestamp(),
+        comment="创建时间",
+    )
+    updated_by = Column(String(50), comment="更新人")
+    updated_at = Column(
+        DateTime,
+        nullable=False,
+        server_default=func.current_timestamp(),
+        server_onupdate=func.current_timestamp(),
+        comment="更新时间",
+    )
 
     def __repr__(self):
-        return f"<ProjectQuota(id='{self.id}', project_id='{self.project_id}')>"
+        return f"<ProjectQuota(id='{self.id}', project_id='{self.project_id}')>"

+ 2 - 0
SourceCode/IntelligentRailwayCosting/app/executor/task_processor.py

@@ -257,6 +257,7 @@ class TaskProcessor:
                     quota_dto.item_id = item.item_id
                     quota_dto.quota_id = item.target_id if item.target_id > 0 else 0
                     quota_dto.quota_code = item.dinge_code
+                    quota_dto.quota_adjustment = item.dinge_adjust
                     quota_dto.entry_name = item.entry_name
                     quota_dto.units = item.units
                     quota_dto.amount = item.amount
@@ -280,6 +281,7 @@ class TaskProcessor:
                         item_id=item.item_id,
                         quota_id=item.target_id if item.target_id > 0 else 0,
                         quota_code=item.dinge_code,
+                        quota_adjustment=item.dinge_adjust,
                         entry_name=item.entry_name,
                         units=item.units,
                         amount=item.amount,

+ 4 - 0
SourceCode/IntelligentRailwayCosting/app/routes/excel_test.py

@@ -83,6 +83,7 @@ def build_test_data(task_data):
         item_code = item.item_code
         entry_name = item.project_name
     dinge_code = f"TY-{''.join(random.choices(string.digits, k=3))}"
+    # dinge_code = ""
     # 随机选择单位和数量
     units_list = ["个", "米", "千米", "平方米", "立方米", "吨", "件"]
     units = random.choice(units_list)
@@ -97,8 +98,10 @@ def build_test_data(task_data):
     remarks = ["按图施工", "特殊工艺", "现场测量", "质量要求高", "工期紧张"]
     ex_row = f"{entry_name},{amount},{units},{random.choice(remarks)}"
     target_id = -1
+    dinge_adjust = ""
     if task_data.get("task_id") == 1:
         target_id = random.randint(-1, 15)
+        dinge_adjust = "1"
     return ExcelParseResultDataDto(
         zgs_id=selected_zgs_id if selected_zgs_id else 1,
         zgs_code=zgs_code,
@@ -107,6 +110,7 @@ def build_test_data(task_data):
         entry_name=entry_name,
         target_id=target_id,
         dinge_code=dinge_code,
+        dinge_adjust=dinge_adjust,
         units=units,
         amount=amount,
         ex_file_id=ex_file_id,

+ 10 - 10
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,
     ):
         """分页查询定额输入列表
 
@@ -108,7 +108,7 @@ class QuotaInputStore:
                 unit=dto.unit,
                 project_quantity=dto.project_quantity,
                 # project_quantity_input=dto.project_quantity_input,
-                # quota_adjustment=dto.quota_adjustment,
+                quota_adjustment=dto.quota_adjustment,
                 # compilation_unit_price=dto.compilation_unit_price,
                 # compilation_total_price=dto.compilation_total_price,
                 # unit_weight=dto.unit_weight,
@@ -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]:
         """更新定额输入
 
@@ -176,7 +176,7 @@ class QuotaInputStore:
             model.unit = dto.unit
             model.project_quantity = dto.project_quantity
             # model.project_quantity_input = dto.project_quantity_input
-            # model.quota_adjustment = dto.quota_adjustment
+            model.quota_adjustment = dto.quota_adjustment
             # model.unit_price = dto.unit_price
             # model.compilation_unit_price = dto.compilation_unit_price
             # model.total_price = dto.total_price

+ 21 - 19
SourceCode/IntelligentRailwayCosting/app/stores/railway_costing_mysql/project_quota.py

@@ -22,14 +22,14 @@ class ProjectQuotaStore:
         return self._current_user
 
     def get_quotas_paginated(
-        self,
-        budget_id: int,
-        project_id: str,
-        item_code: str,
-        page: int = 1,
-        page_size: int = 10,
-        keyword: Optional[str] = None,
-        send_status: Optional[int] = None,
+            self,
+            budget_id: int,
+            project_id: str,
+            item_code: str,
+            page: int = 1,
+            page_size: int = 10,
+            keyword: Optional[str] = None,
+            send_status: Optional[int] = None,
     ):
         """分页查询定额列表
 
@@ -81,15 +81,15 @@ class ProjectQuotaStore:
             return {"total": total_count, "data": quotas}
 
     def get_quotas_by_task_paginated(
-        self,
-        task_id: int,
-        budget_id,
-        project_id,
-        item_code,
-        page: int = 1,
-        page_size: int = 10,
-        keyword: Optional[str] = None,
-        send_status: Optional[int] = None,
+            self,
+            task_id: int,
+            budget_id,
+            project_id,
+            item_code,
+            page: int = 1,
+            page_size: int = 10,
+            keyword: Optional[str] = None,
+            send_status: Optional[int] = None,
     ):
         with db_helper.mysql_query_session(self._database) as db_session:
             query = db_session.query(ProjectQuotaModel).filter(
@@ -176,7 +176,7 @@ class ProjectQuotaStore:
         return ProjectQuotaDto.from_model(quota) if quota else None
 
     def get_quota_by_quota_input(
-        self, project_id: str, budget_id: int, quota_input_id: int
+            self, project_id: str, budget_id: int, quota_input_id: int
     ):
         with db_helper.mysql_query_session(self._database) as db_session:
             quota = (
@@ -211,6 +211,7 @@ class ProjectQuotaStore:
                 item_code=quota_dto.item_code,
                 quota_id=quota_dto.quota_id,
                 quota_code=quota_dto.quota_code,
+                quota_adjustment=quota_dto.quota_adjustment,
                 entry_name=quota_dto.entry_name,
                 units=quota_dto.units,
                 amount=quota_dto.amount,
@@ -246,6 +247,7 @@ class ProjectQuotaStore:
         with db_helper.mysql_session(self._database) as db_session:
             quota.quota_id = quota_dto.quota_id
             quota.quota_code = quota_dto.quota_code
+            quota.quota_adjustment = quota_dto.quota_adjustment
             quota.entry_name = quota_dto.entry_name
             quota.units = quota_dto.units
             quota.amount = quota_dto.amount
@@ -263,7 +265,7 @@ class ProjectQuotaStore:
             return ProjectQuotaDto.from_model(quota)
 
     def update_quota_chapter(
-        self, quota_id: int, item_id: int, item_code: str
+            self, quota_id: int, item_id: int, item_code: str
     ) -> Optional[ProjectQuotaDto]:
         quota = self.get_quota(quota_id)
         if not quota: