mybatis一对多查询之collection的用法

首先看一下返回的数据的格式:

 

//获取端子信息
List<Map<String, Object>> portList = doneTaskDao.queryTroubleTaskPort(map);

<resultMap id="troubleTaskPortMap" type="Map" >
  <result column="PORT_ID" property="PORT_ID"/>
  <result column="PORT_NO" property="PORT_NO"/>
  <result column="EQP_NO" property="EQP_NO"/>
  <result column="EQP_NAME" property="EQP_NAME"/>
  <result column="GLBM" property="GLBM"/>
  <result column="GLMC" property="GLMC"/>
  <result column="TASK_ID" property="TASK_ID"/>
  <collection property="portCheckedList" column="{TASK_ID=TASK_ID,PORT_ID=PORT_ID}" select="getPortCheckedList"></collection>
</resultMap>

 

<select id="queryTroubleTaskPort" parameterType="map" resultMap="troubleTaskPortMap">
select distinct r.port_id,
                r.port_no,
                r.eqp_no,
                r.eqp_name,
                td.glbm,
                td.glmc,
                r.task_id
  from tb_cablecheck_record r, tb_cablecheck_taskdetail td
 where r.detail_id = td.detail_id
   and td.inspect_object_type = 1
   and r.task_id = #{TASK_ID}
 order by to_number(regexp_substr(r.port_no, '[0-9]*[0-9]', 1)),
          to_number(regexp_substr(r.port_no, '[0-9]*[0-9]', 3))
</select>

 

<select id="getPortCheckedList" parameterType="map" resultType="map">
select r.record_id,
       r.record_type,
       r.descript,
       (select bs.staff_name from TB_BASE_STAFF bs where bs.staff_id=r.create_staff) create_staff,
       r.create_time,
       decode(r.ischeckok, 0, '合格', '不合格') ischeckok,
       p.photo_path,
       p.micro_photo_path
  from TB_CABLECHECK_RECORD r left join TB_CABLECHECK_PHOTO_REL pr on r.record_id=pr.object_id
  left join tb_cablecheck_photo p on p.photo_id=pr.photo_id
 where r.port_id = #{PORT_ID}
   and r.task_id = #{TASK_ID}
</select>

 

转载于:https://www.cnblogs.com/xyhero/p/9706332.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值