diff --git a/business-css/README.md b/business-css/README.md new file mode 100644 index 0000000..5353721 --- /dev/null +++ b/business-css/README.md @@ -0,0 +1,12 @@ +# business-css + +临界事故情景分析模拟系统(业务模块)。 + +- 引用 `framework` 公共模块:依赖坐标 `com.yfd:platform:1.0:jar:plain` +- 提供基础 REST 接口:`/api/simulation/ping` 与 `/api/simulation/run` +- 运行方式:在项目根目录执行 `mvn -DskipTests spring-boot:run -pl business-css` + +## 开发约定 +- 统一使用 JDK 17 +- 数据库连接在 `application.yml` 中配置,可根据环境覆盖 +- 与框架的通用工具、模型、常量等直接通过依赖引入使用 \ No newline at end of file diff --git a/business-css/docs/分析模拟系统方案.md b/business-css/docs/分析模拟系统方案.md new file mode 100644 index 0000000..9886ead --- /dev/null +++ b/business-css/docs/分析模拟系统方案.md @@ -0,0 +1,64 @@ +# 临界事故情景分析模拟系统方案 + +本文档定义业务模块 `business-css` 的目标、架构、数据模型、接口设计与实施计划。 + +## 目标 +- 支撑对“临界事故”相关情景的建模、参数化配置与快速模拟评估。 +- 与 `framework` 项目共享通用能力(鉴权、缓存、日志、通用工具、数据访问等)。 +- 提供 REST 接口用于前端或第三方系统的集成。 + +## 总体架构 +- 应用:Spring Boot(JDK 17),模块名 `business-css`。 +- 依赖:`com.yfd:platform:1.0:jar:plain` 引入框架公共模块。 +- 数据存储:MySQL(默认 `yfd_platform`,可按环境切换)。 +- 接口:按 `REST + JSON` 约定,OpenAPI 自动文档可选。 + +## 核心域模型(初版) +- `Scenario`:事故情景(名称、类型、参数定义、风险等级)。 +- `IncidentFactor`:影响因子(指标、阈值、权重、取值范围)。 +- `SimulationRequest`:一次模拟请求(情景名、输入参数)。 +- `SimulationResult`:模拟输出(状态、关键指标、结论摘要、时间戳)。 + +## 关键能力 +- 参数化建模:基于影响因子提出可配置的情景模板。 +- 指标计算:利用 `framework` 的通用工具库(如缓存、时间序列、统计)实现。 +- 场景评估:形成风险等级、预警阈值与应对建议。 +- 结果持久化:保存模拟结果用于追踪与复盘(后续版本)。 + +## 接口草图 +- `GET /api/simulation/ping`:服务健康检测。 +- `POST /api/simulation/run`:执行一次模拟,输入 `SimulationRequest`,输出 `SimulationResult`。 +- 后续:`/api/scenario/*` 用于情景模板的增删改查;`/api/factor/*` 用于影响因子的管理。 + +## 数据表(建议) +- `css_scenario`:情景基础信息表。 +- `css_factor`:影响因子表。 +- `css_simulation_log`:模拟记录表(包含输入与输出摘要)。 + +## 与框架的集成 +- 鉴权与用户上下文:复用 `framework` 的安全模块。 +- 通用组件:缓存(Caffeine/Redis)、日志、异常统一处理。 +- 数据访问:沿用 MyBatis/MyBatis-Plus 与统一的分页、审计字段策略。 + +## 版本与发布 +- 业务模块版本:`1.0-SNAPSHOT` 起步;与框架 `1.0` 对齐。 +- 构建:在仓库根 `pom` 中作为模块聚合;可单独使用 `-pl business-css` 构建或运行。 + +## 渐进式实施计划 +1. 基础骨架搭建(已完成:应用入口、控制器、服务接口与模型)。 +2. 定义情景与影响因子数据模型,建立数据库表结构与 Mapper。 +3. 接入框架公共工具,完善指标计算与风险评估逻辑。 +4. 增加 OpenAPI 文档与前端集成接口规范。 +5. 引入结果持久化与查询报表。 + +## 运维与配置 +- 端口默认 `8082`,环境覆盖通过 `application.yml` 与外部化配置。 +- 数据库连接按环境注入(dev/test/prod)。 +- 日志级别默认 `info`,业务包 `com.yfd` 可设为 `debug`。 + +## 安全与合规 +- 按角色访问控制(复用框架安全),仅授权用户可触发模拟。 +- 输入校验与审计日志记录,避免非法参数导致资源消耗异常。 + +--- +本文为初版方案,后续将结合具体需求与数据约束逐步细化与调整。 \ No newline at end of file diff --git a/business-css/pom.xml b/business-css/pom.xml new file mode 100644 index 0000000..ec5ccb9 --- /dev/null +++ b/business-css/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 3.3.0 + + + + com.yfd + business-css + 1.0-SNAPSHOT + jar + business-css + 临界事故情景分析模拟系统(业务模块) + + + 17 + UTF-8 + + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.5.0 + + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 3.0.3 + + + com.mysql + mysql-connector-j + runtime + + + + + com.yfd + platform + 1.0 + plain + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/business-css/src/main/java/com/yfd/business/css/CriticalScenarioApplication.java b/business-css/src/main/java/com/yfd/business/css/CriticalScenarioApplication.java new file mode 100644 index 0000000..fde89d5 --- /dev/null +++ b/business-css/src/main/java/com/yfd/business/css/CriticalScenarioApplication.java @@ -0,0 +1,11 @@ +package com.yfd.business.css; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CriticalScenarioApplication { + public static void main(String[] args) { + SpringApplication.run(CriticalScenarioApplication.class, args); + } +} \ No newline at end of file diff --git a/business-css/src/main/java/com/yfd/business/css/controller/SimulationController.java b/business-css/src/main/java/com/yfd/business/css/controller/SimulationController.java new file mode 100644 index 0000000..75f3065 --- /dev/null +++ b/business-css/src/main/java/com/yfd/business/css/controller/SimulationController.java @@ -0,0 +1,29 @@ +package com.yfd.business.css.controller; + +import com.yfd.business.css.model.SimulationRequest; +import com.yfd.business.css.model.SimulationResult; +import com.yfd.business.css.service.SimulationService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/simulation") +public class SimulationController { + + private final SimulationService simulationService; + + public SimulationController(SimulationService simulationService) { + this.simulationService = simulationService; + } + + @GetMapping("/ping") + public ResponseEntity ping() { + return ResponseEntity.ok("business-css simulation service is up"); + } + + @PostMapping("/run") + public ResponseEntity run(@RequestBody SimulationRequest request) { + SimulationResult result = simulationService.runSimulation(request); + return ResponseEntity.ok(result); + } +} \ No newline at end of file diff --git a/business-css/src/main/java/com/yfd/business/css/model/SimulationRequest.java b/business-css/src/main/java/com/yfd/business/css/model/SimulationRequest.java new file mode 100644 index 0000000..ccffa8d --- /dev/null +++ b/business-css/src/main/java/com/yfd/business/css/model/SimulationRequest.java @@ -0,0 +1,24 @@ +package com.yfd.business.css.model; + +import java.util.Map; + +public class SimulationRequest { + private String scenarioName; + private Map parameters; + + public String getScenarioName() { + return scenarioName; + } + + public void setScenarioName(String scenarioName) { + this.scenarioName = scenarioName; + } + + public Map getParameters() { + return parameters; + } + + public void setParameters(Map parameters) { + this.parameters = parameters; + } +} \ No newline at end of file diff --git a/business-css/src/main/java/com/yfd/business/css/model/SimulationResult.java b/business-css/src/main/java/com/yfd/business/css/model/SimulationResult.java new file mode 100644 index 0000000..f4beb8c --- /dev/null +++ b/business-css/src/main/java/com/yfd/business/css/model/SimulationResult.java @@ -0,0 +1,40 @@ +package com.yfd.business.css.model; + +public class SimulationResult { + private String scenarioName; + private String startTime; + private String status; + private String summary; + + public String getScenarioName() { + return scenarioName; + } + + public void setScenarioName(String scenarioName) { + this.scenarioName = scenarioName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } +} \ No newline at end of file diff --git a/business-css/src/main/java/com/yfd/business/css/service/SimulationService.java b/business-css/src/main/java/com/yfd/business/css/service/SimulationService.java new file mode 100644 index 0000000..bc06cfe --- /dev/null +++ b/business-css/src/main/java/com/yfd/business/css/service/SimulationService.java @@ -0,0 +1,8 @@ +package com.yfd.business.css.service; + +import com.yfd.business.css.model.SimulationRequest; +import com.yfd.business.css.model.SimulationResult; + +public interface SimulationService { + SimulationResult runSimulation(SimulationRequest request); +} \ No newline at end of file diff --git a/business-css/src/main/java/com/yfd/business/css/service/impl/SimulationServiceImpl.java b/business-css/src/main/java/com/yfd/business/css/service/impl/SimulationServiceImpl.java new file mode 100644 index 0000000..ae1c91a --- /dev/null +++ b/business-css/src/main/java/com/yfd/business/css/service/impl/SimulationServiceImpl.java @@ -0,0 +1,22 @@ +package com.yfd.business.css.service.impl; + +import com.yfd.business.css.model.SimulationRequest; +import com.yfd.business.css.model.SimulationResult; +import com.yfd.business.css.service.SimulationService; +import org.springframework.stereotype.Service; + +import java.time.Instant; + +@Service +public class SimulationServiceImpl implements SimulationService { + @Override + public SimulationResult runSimulation(SimulationRequest request) { + // TODO: 引入 framework 公共模块的算法与工具进行真实计算 + SimulationResult result = new SimulationResult(); + result.setScenarioName(request.getScenarioName()); + result.setStartTime(Instant.now().toString()); + result.setStatus("SUCCESS"); + result.setSummary("占位结果:根据输入参数完成快速估算"); + return result; + } +} \ No newline at end of file diff --git a/business-css/src/main/resources/application.yml b/business-css/src/main/resources/application.yml new file mode 100644 index 0000000..724707e --- /dev/null +++ b/business-css/src/main/resources/application.yml @@ -0,0 +1,21 @@ +spring: + application: + name: business-css + datasource: + url: jdbc:mysql://43.138.168.68:3306/frameworkdb2023?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true + username: root + password: ylfw20230626@ + driver-class-name: com.mysql.cj.jdbc.Driver + jackson: + time-zone: Asia/Shanghai + date-format: yyyy-MM-dd'T'HH:mm:ssXXX + +server: + port: 8082 + servlet: + context-path: / + +logging: + level: + root: info + com.yfd: debug \ No newline at end of file diff --git a/business-css/target/business-css-1.0-SNAPSHOT.jar b/business-css/target/business-css-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..ef8222b Binary files /dev/null and b/business-css/target/business-css-1.0-SNAPSHOT.jar differ diff --git a/business-css/target/business-css-1.0-SNAPSHOT.jar.original b/business-css/target/business-css-1.0-SNAPSHOT.jar.original new file mode 100644 index 0000000..bce4e6b Binary files /dev/null and b/business-css/target/business-css-1.0-SNAPSHOT.jar.original differ diff --git a/business-css/target/classes/application.yml b/business-css/target/classes/application.yml new file mode 100644 index 0000000..724707e --- /dev/null +++ b/business-css/target/classes/application.yml @@ -0,0 +1,21 @@ +spring: + application: + name: business-css + datasource: + url: jdbc:mysql://43.138.168.68:3306/frameworkdb2023?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true + username: root + password: ylfw20230626@ + driver-class-name: com.mysql.cj.jdbc.Driver + jackson: + time-zone: Asia/Shanghai + date-format: yyyy-MM-dd'T'HH:mm:ssXXX + +server: + port: 8082 + servlet: + context-path: / + +logging: + level: + root: info + com.yfd: debug \ No newline at end of file diff --git a/business-css/target/classes/com/yfd/business/css/CriticalScenarioApplication.class b/business-css/target/classes/com/yfd/business/css/CriticalScenarioApplication.class new file mode 100644 index 0000000..8923934 Binary files /dev/null and b/business-css/target/classes/com/yfd/business/css/CriticalScenarioApplication.class differ diff --git a/business-css/target/classes/com/yfd/business/css/controller/SimulationController.class b/business-css/target/classes/com/yfd/business/css/controller/SimulationController.class new file mode 100644 index 0000000..b89e7fe Binary files /dev/null and b/business-css/target/classes/com/yfd/business/css/controller/SimulationController.class differ diff --git a/business-css/target/classes/com/yfd/business/css/model/SimulationRequest.class b/business-css/target/classes/com/yfd/business/css/model/SimulationRequest.class new file mode 100644 index 0000000..6d60d1f Binary files /dev/null and b/business-css/target/classes/com/yfd/business/css/model/SimulationRequest.class differ diff --git a/business-css/target/classes/com/yfd/business/css/model/SimulationResult.class b/business-css/target/classes/com/yfd/business/css/model/SimulationResult.class new file mode 100644 index 0000000..2feb025 Binary files /dev/null and b/business-css/target/classes/com/yfd/business/css/model/SimulationResult.class differ diff --git a/business-css/target/classes/com/yfd/business/css/service/SimulationService.class b/business-css/target/classes/com/yfd/business/css/service/SimulationService.class new file mode 100644 index 0000000..5469756 Binary files /dev/null and b/business-css/target/classes/com/yfd/business/css/service/SimulationService.class differ diff --git a/business-css/target/classes/com/yfd/business/css/service/impl/SimulationServiceImpl.class b/business-css/target/classes/com/yfd/business/css/service/impl/SimulationServiceImpl.class new file mode 100644 index 0000000..d1d6957 Binary files /dev/null and b/business-css/target/classes/com/yfd/business/css/service/impl/SimulationServiceImpl.class differ diff --git a/business-css/target/maven-archiver/pom.properties b/business-css/target/maven-archiver/pom.properties new file mode 100644 index 0000000..193f74a --- /dev/null +++ b/business-css/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=business-css +groupId=com.yfd +version=1.0-SNAPSHOT diff --git a/business-css/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/business-css/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..79e58b5 --- /dev/null +++ b/business-css/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,6 @@ +com\yfd\business\css\CriticalScenarioApplication.class +com\yfd\business\css\service\impl\SimulationServiceImpl.class +com\yfd\business\css\controller\SimulationController.class +com\yfd\business\css\model\SimulationRequest.class +com\yfd\business\css\model\SimulationResult.class +com\yfd\business\css\service\SimulationService.class diff --git a/business-css/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/business-css/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..aeb255e --- /dev/null +++ b/business-css/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,6 @@ +D:\JavaProjectSpace\business-css\src\main\java\com\yfd\business\css\controller\SimulationController.java +D:\JavaProjectSpace\business-css\src\main\java\com\yfd\business\css\CriticalScenarioApplication.java +D:\JavaProjectSpace\business-css\src\main\java\com\yfd\business\css\model\SimulationRequest.java +D:\JavaProjectSpace\business-css\src\main\java\com\yfd\business\css\model\SimulationResult.java +D:\JavaProjectSpace\business-css\src\main\java\com\yfd\business\css\service\impl\SimulationServiceImpl.java +D:\JavaProjectSpace\business-css\src\main\java\com\yfd\business\css\service\SimulationService.java diff --git a/maven编译打包安装说明.md b/maven编译打包安装说明.md new file mode 100644 index 0000000..f091803 --- /dev/null +++ b/maven编译打包安装说明.md @@ -0,0 +1,72 @@ +# Maven 编译、打包、安装说明 + +本文档说明在本仓库根目录下进行项目的编译、打包与安装的常用操作命令。适用于聚合构建(包含 `framework` 与 `business-css` 两个模块)。 + +## 环境要求 +- JDK:`17` +- Maven:`3.6.3+`(推荐 `3.8+`) +- 操作系统:Windows(命令在 PowerShell 下执行) + +## 项目结构(聚合) +- 根 `pom.xml`:`packaging=pom`,聚合模块 + - 模块 `framework`(artifact:`com.yfd:platform:1.0`) + - 模块 `business-css`(artifact:`com.yfd:business-css:1.0-SNAPSHOT`) + +## 常用全局构建 +- 清理并打包所有模块(跳过测试): + - `mvn -DskipTests clean package` +- 清理并安装到本地仓库(跳过测试): + - `mvn -DskipTests clean install` + +## 仅构建某个模块 +- 仅构建 `framework`: + - `mvn -DskipTests clean package -pl framework` +- 仅安装 `framework` 到本地仓库: + - `mvn -DskipTests install -pl framework` +- 仅构建 `business-css`,并自动构建其依赖: + - `mvn -DskipTests clean package -pl business-css -am` +- 仅安装 `business-css` 到本地仓库: + - `mvn -DskipTests install -pl business-css -am` + +## 运行业务模块(开发) +- 在根目录运行 `business-css`: + - `mvn -DskipTests spring-boot:run -pl business-css` +- 运行后默认端口 `8082`:`http://localhost:8082` + +## 产物位置说明 +- `framework` 模块打包产物(位于 `d:\JavaProjectSpace\framework\target\`): + - 可执行(经 `spring-boot-maven-plugin` 重打包)Jar:`platform-1.0.jar`(名称可能包含时间戳或 SNAPSHOT) + - 附加 classes Jar(用于业务模块依赖):`platform-1.0-plain.jar` +- `business-css` 模块打包产物(位于 `d:\JavaProjectSpace\business-css\target\`): + - 可执行 Jar:`business-css-1.0-SNAPSHOT.jar` + +## 本地 Maven 仓库位置(Windows) +- `D:\maven-repository` +- 安装命令执行成功后,相关坐标将被写入该目录: + - `com\yfd\platform\1.0\platform-1.0-plain.jar` + - `com\yfd\platform\1.0\platform-1.0.jar` + - `com\yfd\business-css\1.0-SNAPSHOT\business-css-1.0-SNAPSHOT.jar` + +## 业务模块对框架的依赖 +- `business-css/pom.xml` 引用框架的公共 classes Jar: + - 坐标:`com.yfd:platform:1.0:jar:plain` +- 构建方式一:先构建 `framework` 再构建 `business-css` + - `mvn -DskipTests clean package -pl framework` + - `mvn -DskipTests clean package -pl business-css -am` +- 构建方式二:在根目录一次性构建所有模块 + - `mvn -DskipTests clean package` + +## 常见问题与提示 +- 如果出现依赖解析失败,优先执行 `install` 将产物写入本地仓库: + - `mvn -DskipTests clean install` +- 版本号与快照:业务模块当前为 `1.0-SNAPSHOT`,框架为 `1.0` +- 代理/网络:如需远程仓库依赖,确保 Maven 设置(`settings.xml`)配置正确 +- 清理构建缓存: + - `mvn clean` + +## 验证服务可用性 +- 健康检查:`GET http://localhost:8082/api/simulation/ping` +- 模拟执行:`POST http://localhost:8082/api/simulation/run` + +--- +以上命令均在仓库根目录执行。若需在 CI 中使用,请根据环境变量与缓存策略调整 `-DskipTests` 与并发参数。 \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6f54f47 --- /dev/null +++ b/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + com.yfd + java-project-repo + 1.0-SNAPSHOT + pom + JavaProjectRepo + Parent aggregator for framework and business modules + + + framework + business-css + + + + 17 + 17 + UTF-8 + + \ No newline at end of file diff --git a/业务分支Git处理方案.md b/业务分支Git处理方案.md index f399b5a..9bfd159 100644 --- a/业务分支Git处理方案.md +++ b/业务分支Git处理方案.md @@ -88,4 +88,36 @@ - 合并后启动失败:优先检查 `pom.xml`、`application-*.yml` 的配置合入及数据库变更迁移是否完整。 --- -如需自动化执行“从 main-framework 合并到当前分支”,请确保工作区干净并已配置远端,然后按上文标准步骤执行即可。 \ No newline at end of file +如需自动化执行“从 main-framework 合并到当前分支”,请确保工作区干净并已配置远端,然后按上文标准步骤执行即可。 + +## 自动化合并脚本 +- 脚本位置:`D:\JavaProjectSpace\scripts\merge-main-framework.ps1` +- 作用:自动执行从 `origin/main-framework` 合并到当前分支的流程,包含工作区检查、自动暂存(可选)、`fetch`、合并、冲突策略与推送。 + +参数说明: +- `-RepoPath`:仓库路径,默认为脚本所在目录的上一级。 +- `-AutoStash`:当工作区不干净时自动执行 `git stash push -u`,默认 `true`。 +- `-Push`:合并成功后是否推送到远端,默认 `true`。 +- `-OnConflict`:冲突策略,`abort` 立即中止并恢复现场,`leave` 保留冲突现场供手动解决,默认 `leave`。 + +使用示例: +```powershell +# 常用:自动暂存 + 推送,冲突保留现场 +& "D:\JavaProjectSpace\scripts\merge-main-framework.ps1" -AutoStash $true -Push $true -OnConflict 'leave' + +# 冲突直接中止合并(不会生成合并提交) +& "D:\JavaProjectSpace\scripts\merge-main-framework.ps1" -OnConflict 'abort' + +# 禁止自动暂存,需确保工作区干净 +& "D:\JavaProjectSpace\scripts\merge-main-framework.ps1" -AutoStash $false +``` + +退出码约定: +- `0`:合并(及推送)成功。 +- `2`:存在冲突且策略为 `leave`,保留现场供手动解决(按提示执行 `git add` / `git commit`)。 +- `1`:命令执行错误或远端分支不存在等异常。 + +注意事项: +- 需本机安装并可用 `git` 命令。 +- 远端分支固定为 `origin/main-framework`,如远端名不同请调整脚本或配置。 +- 合并完成后建议在后端与前端分别执行构建验证,确保配置与依赖同步。 \ No newline at end of file