diff --git a/README.md b/README.md index e673750f..ac2b1ec3 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,358 @@ -# 场外交易管理系统 +# 场外交易管理系统 (YLErp TRS) +一个基于 ASP.NET Core 的场外衍生品交易管理系统,支持场外期权、权益互换(TRS)、利率互换等多种场外衍生品业务的全生命周期管理。 +## 项目简介 + +本项目是一个完整的金融场外交易管理系统(OTC - Over The Counter),主要用于金融机构管理场外衍生品交易,包括客户管理、交易录入、风险管理、结算对账、资金监控等核心功能。系统支持多公司配置,可适配不同券商和期货公司的业务需求。 + +### 核心功能 + +- **客户管理**:完整的客户信息管理,包括客户基本信息、适当性评估、KYC 合规、资质管理等 +- **交易管理**:支持场外期权、权益互换、利率互换等多种衍生品交易的全流程管理 +- **风险管理**:实时风险监控、保证金管理、限额控制、风险预警 +- **结算对账**:日终结算、交易确认书生成、结算报告、外部对账 +- **资金管理**:出入金管理、资金监控、预付金管理、授信管理 +- **报表分析**:多维度统计分析、监管报表、数据导出 + +### 技术栈 + +- **后端框架**:ASP.NET Core 6.0 +- **前端技术**:Razor Views + jQuery + jqGrid + SignalR +- **ORM**:Entity Framework Core 6.0 +- **数据库**:Oracle / MySQL +- **缓存**:Redis +- **消息队列**:Kafka +- **依赖注入**:Autofac +- **日志**:NLog +- **验证码**:Lazy.Captcha.Core +- **Excel/Word**:YLErp.Office, EPPlus, NPOI + +## 环境要求 + +### 开发环境 + +- **操作系统**:Windows 10/11 或 Linux (CentOS/Ubuntu) +- **.NET SDK**:.NET 6.0 SDK +- **IDE**:Visual Studio 2022 (推荐) 或 VS Code +- **数据库**: + - Oracle Database 11g 或更高版本(主数据库) + - MySQL 5.7 或更高版本(辅助数据库) +- **缓存**:Redis 5.0 或更高版本 +- **消息队列**:Kafka 2.0 或更高版本 + +### 运行时环境 + +- **操作系统**:Windows Server 2016+ 或 Linux (CentOS 7+/Ubuntu 18.04+) +- **运行时**:ASP.NET Core 6.0 Runtime +- **内存**:建议 4GB 以上 +- **磁盘**:建议 50GB 以上可用空间 + +## 安装步骤 + +### 1. 克隆代码 + +```bash +git clone http://infra.yiliantech.com/gitlab/otc-dev/otcdms.git +cd zszq-trs +``` + +### 2. 配置数据库 + +#### Oracle 数据库配置 + +1. 安装 Oracle Database +2. 创建数据库用户并授权 + +```sql +-- 示例 SQL +CREATE USER ylclient IDENTIFIED BY password; +GRANT CONNECT, RESOURCE TO ylclient; +``` + +3. 执行数据库初始化脚本 + +```bash +# 数据库脚本位于 Framework/YLErp.Core/DBScripts/ +sqlplus ylclient/password @Framework/YLErp.Core/DBScripts/init.sql +``` + +#### MySQL 数据库配置 + +1. 安装 MySQL Server +2. 创建数据库 + +```sql +CREATE DATABASE yldb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +CREATE USER 'yluser'@'%' IDENTIFIED BY 'password'; +GRANT ALL PRIVILEGES ON yldb.* TO 'yluser'@'%'; +FLUSH PRIVILEGES; +``` + +### 3. 配置应用设置 + +1. 复制并修改配置文件 + +```bash +cd YLErpWeb +cp appsettings.json appsettings.local.json +``` + +2. 编辑 `appsettings.local.json`,添加数据库连接字符串等配置 + +```json +{ + "ConnectionStrings": { + "ylclient": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));User Id=ylclient;Password=yourpassword;", + "yldb": "Server=localhost;Port=3306;Database=yldb;User=yluser;Password=yourpassword;" + }, + "RedisConfig": { + "ConnectionString": "localhost:6379,password=,defaultDatabase=0" + }, + "KafkaConfig": { + "BootstrapServers": "localhost:9092", + "GroupId": "ylerp-group" + } +} +``` + +### 4. 安装依赖 + +```bash +# 使用 dotnet restore 恢复 NuGet 包 +dotnet restore YLerpbase.sln + +# 或使用 Visual Studio 打开解决方案,IDE 会自动恢复 +``` + +### 5. 编译项目 + +#### 方式一:使用 Visual Studio + +1. 打开 `YLerpbase.sln` +2. 选择配置为 `Release` +3. 右键解决方案 → "生成解决方案" + +#### 方式二:使用命令行 + +```bash +# 编译整个解决方案 +dotnet build YLerpbase.sln --configuration Release + +# 或使用提供的编译脚本 +.\Publish.bat +``` + +### 6. 配置第三方依赖 + +1. **第三方定价库**:将 `ThirdPartyLibs/` 目录下的 DLL 文件复制到编译输出目录 +2. **Excel 模板**:确保 `YLErpWeb/App_Docs/` 目录下的导入/导出模板文件完整 + +### 7. 运行项目 + +#### 开发环境运行 + +```bash +cd YLErpWeb +dotnet run +``` + +或在 Visual Studio 中按 `F5` 启动调试 + +#### 生产环境部署 + +**Windows:** + +```bash +# 发布项目 +dotnet publish YLErpWeb/YLErpWeb.csproj --configuration Release --output ./publish + +# 运行发布的应用程序 +cd publish +dotnet YLErpWeb.dll +``` + +**Linux:** + +```bash +# 使用 MSBuild 发布(参考 Publish.bat 中的配置) +dotnet publish YLErpWeb/YLErpWeb.csproj --configuration Release --runtime linux-x64 --self-contained false + +# 使用启动脚本 +cp YLErpWeb/start.prod.sh ./publish/ +cd publish +chmod +x start.prod.sh +./start.prod.sh +``` + +## 使用示例 + +### 启动应用 + +应用启动后,默认监听端口 5000(开发环境),访问: ## Getting started To make it easy for you to get started with GitLab, here's a list of recommended next steps. -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! +不同公司的配置会影响: +- 界面显示字段 +- 业务流程 +- 报表模板 +- 接口对接 -## Add your files +### 权限配置 -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: +权限通过 `Authorization` 属性控制,主要权限标识: -``` -cd existing_repo -git remote add origin http://infra.yiliantech.com/gitlab/otc-dev/otcdms.git -git branch -M master -git push -uf origin master +```csharp +// 示例:控制器权限控制 +[Authorize(Policy = "客户管理-客户查看")] +public class ClientController : Controller +{ + // ... +} ``` -## Integrate with your tools +## 常见问题 -- [ ] [Set up project integrations](http://infra.yiliantech.com/gitlab/otc-dev/otcdms/-/settings/integrations) +### 编译错误 -## Collaborate with your team +**问题**:找不到引用的 DLL 文件 -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) +**解决**: +1. 确保 `ThirdPartyLibs/` 目录存在且包含所有必需的 DLL +2. 检查项目文件中的 `` 路径是否正确 +3. 执行 `dotnet restore` 重新恢复依赖 -## Test and Deploy +### 数据库连接失败 -Use the built-in continuous integration in GitLab. +**问题**:无法连接到 Oracle 数据库 -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) +**解决**: +1. 检查 Oracle 服务是否启动 +2. 验证连接字符串格式 +3. 确保已安装 Oracle.ManagedDataAccess.Core 包 +4. 检查防火墙设置 -*** +### NPE 空指针异常 -# Editing this README +**问题**:运行时出现 NullReferenceException -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. +**解决**: +1. 检查配置文件是否完整 +2. 确保数据库表结构正确 +3. 查看日志文件定位具体错误位置 -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. +### 缓存连接失败 -## Name -Choose a self-explaining name for your project. +**问题**:Redis 连接超时 -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. +**解决**: +1. 检查 Redis 服务是否运行 +2. 验证 Redis 连接字符串 +3. 检查 Redis 防火墙配置 +4. 确认 Redis 密码是否正确 -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. +## 开发指南 -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. +### 代码规范 -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. +- 遵循 C# 编码规范 +- 使用 XML 文档注释 +- Controller 方法添加权限注释 +- 新增功能编写单元测试 -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. +### 提交规范 -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. +提交信息格式: -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. +``` +<类型>: <简短描述> -## Contributing -State if you are open to contributions and what your requirements are for accepting them. +详细描述(可选) -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. +类型: +- feat: 新功能 +- fix: Bug 修复 +- docs: 文档更新 +- style: 代码格式 +- refactor: 重构 +- test: 测试相关 +- chore: 构建/工具相关 +``` -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. +### 分支策略 -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +- `master`:主分支,生产环境代码 +- `develop`:开发分支 +- `feature/*`:功能分支 +- `hotfix/*`:紧急修复分支 -## License -For open source projects, say how it is licensed. +### 测试 -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +运行单元测试: + +```bash +dotnet test UnitTestProject/UnitTestProject.csproj +``` + +## 贡献指南 + +欢迎提交 Issue 和 Pull Request! + +### 贡献流程 + +1. Fork 本仓库 +2. 创建特性分支 (`git checkout -b feature/AmazingFeature`) +3. 提交更改 (`git commit -m 'feat: Add some AmazingFeature'`) +4. 推送到分支 (`git push origin feature/AmazingFeature`) +5. 提交 Pull Request + +### 代码审查 + +- 确保 CI 测试通过 +- 代码符合项目规范 +- 添加必要的单元测试 +- 更新相关文档 + +### 报告 Bug + +提交 Issue 时请提供: +- 环境信息(操作系统、.NET 版本) +- 复现步骤 +- 错误日志 +- 预期行为 + +## 许可证 + +本项目为内部项目,版权归公司所有。 + +## 联系方式 + +- **项目负责人**:[请填写] +- **技术支持**:[请填写] +- **GitLab**:http://infra.yiliantech.com/gitlab/otc-dev/otcdms + +## 附录 + +### 相关文档 + +- [客户列表功能分析文档](./客户列表功能分析文档.md) +- [出入金和资金记录详细需求文档](./出入金和资金记录详细需求文档.md) +- [项目文档/](./项目文档/) - 更多技术文档 + +### 外部依赖 + +- **EF Core 文档**:https://docs.microsoft.com/ef/core/ +- **ASP.NET Core 文档**:https://docs.microsoft.com/aspnet/core/ +- **Kafka 文档**:https://kafka.apache.org/documentation/ +- **Redis 文档**:https://redis.io/documentation + +### 更新日志 + +请查看项目文档目录下的更新日志文件。 + +--- + +*最后更新:2026-03-20*