weicw-dshsa 92baf41073 fix: 消除 GROUP BY 非分组列报错并修复连锁标识脏数据
MySQL ONLY_FULL_GROUP_BY 下,MyBatis-Plus 的 list(wrapper) 默认 SELECT
实体全部字段,配合 groupBy 后非分组列既不在 GROUP BY 中也不函数依赖分组键,
导致 SQLSyntaxErrorException。即便放宽模式,这些字段也只是组内随机一行的值。

根因是借用 SQL GROUP BY 实现"按某列去重",共 7 处,统一改为一次查询 +
内存分组,返回值结构与原实现一致:

- MerchantServiceImpl.groupByChain(本次线上报错点)
- YxeProductServiceImpl.listByGroup / listByChain / listByCate(2 个重载)
- YxeTaskProductServiceImpl.productGroupByTask
- YxeShareServiceImpl.listByMerchant(2 个重载)

分组父节点用独立副本(BeanUtils.copyProperties)而非复用子列表实例,
否则 parent.setChildren(children) 会造成对象自引用,JSON 序列化报
"Direct self-reference leading to cycle"。

附带消除 N+1:groupByChain 原为 1+12 次查询、重复拉取 8105 行。

同时 groupByChain 返回稳定 chainId(连锁名,与字典 sys_dict_data.dict_id=175
的 dict_data_code 一致),从源头消除前端回退到 `chain_${index}` 位置型占位符,
避免其经审核端写入 yxe_self_report.chain_id 后按连锁等值筛选永久漏查。

SQL: fix_self_report_chain_id_placeholder_2026-10-11.sql(本地已执行 5 行)
2026-10-11 16:34:21 +08:00
2023-06-03 23:56:49 +08:00
2026-10-10 21:34:36 +08:00
2023-06-03 23:56:49 +08:00
2026-10-10 21:34:36 +08:00
2026-10-10 21:34:36 +08:00
2026-10-10 21:34:36 +08:00
2026-10-10 21:34:36 +08:00
2026-10-10 21:34:36 +08:00
2026-10-10 21:34:36 +08:00
2026-10-10 21:34:36 +08:00
2026-10-10 21:34:36 +08:00
2026-10-10 21:34:36 +08:00
S
Description
No description provided
1.6 MiB
Languages
Java 100%