Commit aa96451e59da0785b13c050ba510e1cc27519710

Authored by “wangming”
1 parent d56bd957

整理项目文件夹

.cursor/rules/project_rules.mdc
... ... @@ -169,6 +169,21 @@ Id = Guid.NewGuid().ToString()
169 169 9. **数据库文档**: 所有数据库表结构、字段说明、关联关系必须记录到数据库说明文档中
170 170 10. **ID生成规范**: 所有实体ID的生成都必须使用 `YitIdHelper.NextId().ToString()`,禁止使用 `Guid.NewGuid().ToString()` 或其他ID生成方式
171 171 11.**说明文档规范**:没有要求生成新的md文件的时候,严禁生成新md文件。
  172 +12. **文档与产出物规范**:项目相关形成的 md、sql、excel、word、py 等文件,必须放在 `docs/` 下对应子目录(md、sql、excel、word、py),排除 .cursor、readme、第三方包内的文件。
  173 +
  174 +## 📁 文档与产出物目录
  175 +
  176 +项目产出物统一存放于 `docs/`,按类型分子目录:
  177 +
  178 +| 子目录 | 用途 |
  179 +|--------|------|
  180 +| `docs/md/` | 接口测试说明、功能总结、修复说明等 |
  181 +| `docs/sql/` | 迁移脚本、修复脚本等 |
  182 +| `docs/excel/` | xlsx/xls 导入模板、导出示例等 |
  183 +| `docs/word/` | doc/docx 文档等 |
  184 +| `docs/py/` | Python 脚本等 |
  185 +
  186 +位置:`HongHua-JJ/docs/{md|sql|excel|word|py}/`
172 187  
173 188 ## 📋 重要变更记录
174 189  
... ...
doc/故障查询导入模板.xlsx renamed to docs/excel/故障查询导入模板.xlsx
No preview for this file type
docs/md/接口测试-zlgl-SimpleSearch-修复说明.md 0 → 100644
  1 +# zlgl SimpleSearch 无数据问题修复说明
  2 +
  3 +## 问题现象
  4 +
  5 +请求 `/api/Extend/zlgl/SimpleSearch?currentPage=1&pageSize=10&fl=786180219823195397&sskhbh=781034840806917381` 返回空列表,但该用户认为应有对应数据。
  6 +
  7 +## 根因
  8 +
  9 +1. **数据库情况**:
  10 + - `zlgl` 表存在 `fl=786180219823195397` 的资料(如:卧式五缸泵产品技术介绍)
  11 + - `khsb` 表中关联该产品(fl=786180219823195397)的设备,其 `sskhbh` 为 `781034555321615621`、`785683205549196549` 等组织 ID
  12 + - 传入的 `sskhbh=781034840806917381` 为用户 ID,与设备上的组织 ID 不一致
  13 +
  14 +2. **原逻辑缺陷**:
  15 + - 仅用 `k.Sskhbh.Contains(sskhbh)` 做客户过滤
  16 + - 未按用户所属组织扩展,导致用户所属组织下的设备被排除
  17 + - 仅通过 `Khsb.Fl` 获取产品,未考虑 `Khsb.Dysbbh = cpgl.Cpid` 的关联方式(旧数据可能只有 dysbbh 无 fl)
  18 +
  19 +## 修复内容
  20 +
  21 +调整 `ZlglService.GetSimpleSearchList` 的客户权限逻辑,与 `KhsbPermissionHelper` 保持一致:
  22 +
  23 +1. **sskhbh 扩展**:调用 `KhsbPermissionHelper.GetUserAllowedSskhbhIdsAsync`,得到当前用户可查看的 sskhbh 集合(userId、所属组织、上级组织等)。
  24 +2. **产品来源**:
  25 + - 来源 1:`Khsb.Fl`(已填关联产品 ID 的设备)
  26 + - 来源 2:`Khsb.Dysbbh = cpgl.Cpid`(通过产品编号关联的旧设备)
  27 +3. **权限过滤**:仅返回该用户可查看设备关联产品下的 `zlgl` 资料。
  28 +
  29 +## 验证建议
  30 +
  31 +1. 使用同一 token 再次请求:
  32 + ```
  33 + GET /api/Extend/zlgl/SimpleSearch?currentPage=1&pageSize=10&fl=786180219823195397&sskhbh=781034840806917381
  34 + ```
  35 +2. 预期:用户 781034840806917381 若属于组织 781034555321615621(或其它已关联产品的组织),应能查到 `fl=786180219823195397` 的资料。
... ...
接口测试-小红点未读数量分析.md renamed to docs/md/接口测试-小红点未读数量分析.md
接口测试-我的设备两个接口.md renamed to docs/md/接口测试-我的设备两个接口.md
接口测试报告-产品详情Tab接口.md renamed to docs/md/接口测试报告-产品详情Tab接口.md
接口测试报告-移动端权限接口.md renamed to docs/md/接口测试报告-移动端权限接口.md
uniapp_jiju/pages/new/gzpc/搜索功能优化总结.md renamed to docs/md/搜索功能优化总结.md
doc/故障查询-模板导出导入-任务分派.md renamed to docs/md/故障查询-模板导出导入-任务分派.md
fix-铁钻工产品缺失.sql renamed to docs/sql/fix-铁钻工产品缺失.sql
机具(服务端)/migrations_sbwhry.sql renamed to docs/sql/migrations_sbwhry.sql
机具(服务端)/migrations_xccpgl.sql renamed to docs/sql/migrations_xccpgl.sql
机具(服务端)/netcore/src/Modularity/Extend/NCC.Extend/ZlglService.cs
... ... @@ -306,18 +306,42 @@ namespace NCC.Extend.Zlgl
306 306 }
307 307  
308 308 // 客户权限:仅显示该客户在“我的设备”中已有设备关联产品的资料(传入 sskhbh 时生效;管理员不传则看全部)
  309 + // 使用与 KhsbPermissionHelper 一致的 sskhbh 扩展逻辑:当前用户可看 [userId, 所属组织, 上级组织] 下的设备
309 310 if (!string.IsNullOrEmpty(input.sskhbh))
310 311 {
311   - var allowedProductIds = await _db.Queryable<KhsbEntity>()
312   - .Where(k => k.Sskhbh != null && k.Sskhbh.Contains(input.sskhbh.Trim()))
313   - .Where(k => k.Fl != null && k.Fl != "")
314   - .Select(k => k.Fl)
315   - .Distinct()
316   - .ToListAsync();
317   - if (allowedProductIds == null || allowedProductIds.Count == 0)
318   - query = query.Where(it => false); // 无设备或无关联产品时返回空列表
  312 + var allowedSskhbhIds = await KhsbPermissionHelper.GetUserAllowedSskhbhIdsAsync(_userManager, _db);
  313 + if (allowedSskhbhIds == null)
  314 + {
  315 + // 管理员:不限制客户
  316 + }
  317 + else if (allowedSskhbhIds.Count == 0)
  318 + {
  319 + query = query.Where(it => false);
  320 + }
319 321 else
320   - query = query.Where(it => allowedProductIds.Contains(it.Fl));
  322 + {
  323 + // 获取该用户可查看的设备所关联的产品ID:优先 Khsb.Fl,其次通过 Khsb.Dysbbh=cpgl.Cpid 关联
  324 + var productIdsFromFl = await _db.Queryable<KhsbEntity>()
  325 + .Where(k => k.Sskhbh != null && allowedSskhbhIds.Contains(k.Sskhbh))
  326 + .Where(k => k.Fl != null && k.Fl != "")
  327 + .Select(k => k.Fl)
  328 + .Distinct()
  329 + .ToListAsync();
  330 + var productIdsFromDysbbh = await _db.Queryable<KhsbEntity>()
  331 + .InnerJoin<CpglEntity>((k, c) => k.Dysbbh != null && k.Dysbbh != "" && k.Dysbbh == c.Cpid)
  332 + .Where((k, c) => k.Sskhbh != null && allowedSskhbhIds.Contains(k.Sskhbh))
  333 + .Select((k, c) => c.Id)
  334 + .Distinct()
  335 + .ToListAsync();
  336 + var allowedProductIds = (productIdsFromFl ?? new List<string>())
  337 + .Union(productIdsFromDysbbh ?? new List<string>())
  338 + .Distinct()
  339 + .ToList();
  340 + if (allowedProductIds == null || allowedProductIds.Count == 0)
  341 + query = query.Where(it => false);
  342 + else
  343 + query = query.Where(it => it.Fl != null && allowedProductIds.Contains(it.Fl));
  344 + }
321 345 }
322 346  
323 347 var data = await query
... ...