Commit cb06d496 by 李小惠

Merge branch 'develop' of http://gitlab.sothing.top/843502640/jyzb_platformV2 into develop-lxh

parents 03be860b 58b8c586
...@@ -15,7 +15,6 @@ public interface EquipmentTypeMapper extends BaseMapper<EquipmentType> { ...@@ -15,7 +15,6 @@ public interface EquipmentTypeMapper extends BaseMapper<EquipmentType> {
void wipeParentIdsData();
void setTypeParentIds(); void setTypeParentIds();
......
...@@ -273,8 +273,6 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E ...@@ -273,8 +273,6 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
@Override @Override
public ResponseResult setTypeParentIds() { public ResponseResult setTypeParentIds() {
//清空parent_ids字段
equipmentTypeMapper.wipeParentIdsData();
//更新parent_ids字段 //更新parent_ids字段
equipmentTypeMapper.setTypeParentIds(); equipmentTypeMapper.setTypeParentIds();
return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS); return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS);
......
...@@ -19,30 +19,27 @@ ...@@ -19,30 +19,27 @@
</sql> </sql>
<update id="wipeParentIdsData">
UPDATE base_equipment_type t
SET t.parent_ids = "";
</update>
<update id="setTypeParentIds" parameterType="java.util.Map"> <update id="setTypeParentIds" parameterType="java.util.Map">
WITH RECURSIVE cte AS ( UPDATE base_equipment_type t1
SELECT id, parent_id, CAST(id AS CHAR(200)) AS parent_ids SET t1.parent_ids = (
WITH RECURSIVE ParentHierarchy AS (
SELECT id, parent_id
FROM base_equipment_type FROM base_equipment_type
WHERE parent_id = "-1" WHERE id = t1.id
UNION ALL UNION
SELECT o.id, o.parent_id, SELECT t2.id, t2.parent_id
CASE FROM ParentHierarchy ph
WHEN FIND_IN_SET(o.parent_id, cte.parent_ids) > 0 THEN cte.parent_ids JOIN base_equipment_type t2 ON ph.parent_id = t2.id
ELSE CONCAT(cte.parent_ids, ',', o.parent_id) )
END AS parent_ids SELECT IFNULL(GROUP_CONCAT(
FROM base_equipment_type o CASE WHEN parent_id != '00000000-0000-0000-0000-000000000000' THEN parent_id END
INNER JOIN cte ON o.parent_id = cte.id ORDER BY parent_id SEPARATOR ','), '')
) FROM ParentHierarchy
UPDATE base_equipment_type p )
JOIN cte ON p.id = cte.id WHERE t1.parent_id IS NOT NULL;
SET p.parent_ids = cte.parent_ids;
</update> </update>
<select id="selectByItems" resultType="java.lang.String"> <select id="selectByItems" resultType="java.lang.String">
SELECT DISTINCT t4.id, t4.parent_id SELECT DISTINCT t4.id, t4.parent_id
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论