1.dao層接口
public interface projectDao {
List<CountResultPO> getIndexProjectList(CountPO countPO);
}
2.封裝實體
public class CountPO {
private static final long serialVersionUID = 1L;
private List<BusProject> cityList = Lists.newArrayList();
//getter /setter
}
3.xml配置文件
<select id="getIndexProjectList" resultType="com.entity.CountResultPO">
SELECT
b.amount,are.name as category,b.FD_CITY as cityId
from (
SELECT a.FD_CITY as FD_CITY,count(1) as amount from BUS_PROJECT a
where a.del_flag = 0
<if test="null != cityList and cityList.size > 0">
AND a.fd_city in
<foreach item="item" index="index" collection="cityList" open="(" separator="," close=")">
#{item.fdCity} //在BusProject實體中
</foreach>
</if>
GROUP BY a.FD_CITY) b
LEFT JOIN SYS_AREA are
on b.FD_CITY = are.id
</select>