数据库生成组织架构的code作为层级标识()-其他
数据库生成组织架构的code作为层级标识()
<!-- 查询同级的如果有数据,就store_code+1返回,没有的话就找上一级的store_code拼接上1001返回-->
<select id="getStoreCode" parameterType="java.util.Map" resultType="java.lang.String">
Select Case When b.store_code Is Null Then CONCAT(a.pStore_Code,'1001')
Else CONCAT( Substr(b.store_code,1,Length(b.store_code)-4),Substr(b.store_code,LENGTH(b.store_code)-3)+1)
End As NewStoreCode FROM
(select store_code As pStore_Code from tf_store_info a Where a.qw_group_id=#{qwGroupPid} and a.status = 'E') a
Left Outer Join
(select Max(a.store_code) As store_code from tf_store_info a where a.qw_group_pid=#{qwGroupPid} and a.status = 'E') b
On 1=1
</select>在新增组织的时候生成一个code,所以 qwGroupPid 是传的上一级 组织的id进来获取。最终数据如下1001100110011001100210011003100110031001
————————
<!-- 查询同级的如果有数据,就store_code+1返回,没有的话就找上一级的store_code拼接上1001返回-->
<select id="getStoreCode" parameterType="java.util.Map" resultType="java.lang.String">
Select Case When b.store_code Is Null Then CONCAT(a.pStore_Code,'1001')
Else CONCAT( Substr(b.store_code,1,Length(b.store_code)-4),Substr(b.store_code,LENGTH(b.store_code)-3)+1)
End As NewStoreCode FROM
(select store_code As pStore_Code from tf_store_info a Where a.qw_group_id=#{qwGroupPid} and a.status = 'E') a
Left Outer Join
(select Max(a.store_code) As store_code from tf_store_info a where a.qw_group_pid=#{qwGroupPid} and a.status = 'E') b
On 1=1
</select>在新增组织的时候生成一个code,所以 qwGroupPid 是传的上一级 组织的id进来获取。最终数据如下1001100110011001100210011003100110031001