把一张表中的数据即一个List作为查询另一张表的条件参数

XML查询语句:

<select id="getMatterFunForeach" parameterType="Map" resultType="hashmap">
  select * from(
	select m.mattertitle as mattertitle,

	<foreach collection="list" index="index" item="item" separator="," >
 		count(decode(f.funcode, '${item.funcode}', 1)) as ${item.funcode}isnot
    </foreach>
	from os_fun f
	 join os_matter_fun mf
    on f.funcode = mf.funcode
   and f.funname = mf.funname
  join os_matter m
    on m.matterid = mf.matterid
	group by m.matterid,m.mattertitle)
	<where>
		<if test="funcode!=null and funcode!=''">
			and ${funcode}ISNOT >0
		</if>
	</where>
  </select>
SpringMVC控制层:

@RequestMapping(value = "")
	public ModelAndView LoadMatteropen(
			@RequestParam(required = false,defaultValue="1") String pageNum,
			@RequestParam(required = false,defaultValue="20") String pageSize,
			@RequestParam(required = false,defaultValue="")String funcode,
			HttpServletRequest request, 
			HttpServletResponse response
			) throws Exception {
		ModelAndView result = null;
		Map<String, Object> map = new HashMap<String, Object>();
		String userid = getLoginUserId(request);
		SysUserOrg suo = sysUserOrgService.findOrgByUserId2(userid);
		WorkOrg wo = null;
		if(suo!=null){
			wo= workOrgService.getWorkOrgByOrgcode(suo.getOrgCode());
		}
		int orgtype =getLoginUserInfo(request, response).getUser().getOrgtype();//获取user对象中的orgtype
		if(orgtype==1){
			result = new ModelAndView("");
			result.addObject("funcode", funcode);
			List<OsFun> funList = osFunService.getOsFunList();
			if(funList.size()>0){
				result.addObject("funList", funList);
			}
			map.put("funcode", funcode);
			map.put("list", funList);
			Page<Map<String,Object>> mapList = osMatterService.getMatterFunForeach(map, new PageUtil(pageNum,pageSize)); 
			result.addObject("mapList", mapList);
			setPageInfo(result,mapList,"",map);
		}
		result.addObject("orgtype", orgtype);
		load(result, request, response);
		return result;
	}
freemarker页面代码:

<table class="listtable" align="center" cellpadding="0" cellspacing="1" border="0">
				<tr class="header">
					<td width="30" class="center">No</td>
					<td class="center">局委名称</td>
					<td width="60" class="center">办事项总数</td>
					<#list funList as fun>
							<td width="53" class="center">${(fun.funname)!}</td>
					</#list>
				</tr>
				<!-- loop begin -->
				<#assign i=1/>
				<#if mapList??>
				<#assign totalcount=0/>
				<#list mapList as map>
					<tr <#if map_has_next>class="trow"<#else>class="header"</#if>>
							<#if map_has_next>
							<td <#if map_has_next>class="center tno" <#else>class="right ttext" colspan="2"</#if>>${i}</td>
							<#else>
							</#if>
							<td <#if map_has_next>class="left ttext"<#else>class="right ttext" colspan="2"</#if>>${(map['ORGNAME'])!}</td> 
							<td class="center tlink">
								<#if map_has_next>
									<a href="${RootPath}x.html?orgid=${(map['ORGID'])!}">
										<#if (map['COUNT'])>0>
											${(map['COUNT'])!}个
										</#if>								
									</a>
									<#assign totalcount=totalcount+map['COUNT']/>
								<#else>
									<a href="${RootPath}x.html">
										<#if totalcount>0>
											${totalcount}个
										</#if>
									</a>
								</#if>
							</td> 
							<!-- <#list map?keys as itemKey>
								<td class="center tlink">
									<a href="${RootPath}x.html?orgid=${(map['ORGID'])!}">
										${map[itemKey]}
									</a>
								</td>
							</#list>-->
							
						 <#list funList as fun>
							<td class="center tlink">
								<a href="${RootPath}x.html?<#if map_has_next>orgid=${(map['ORGID'])!}&</#if>funcode=${fun.funcode?upper_case}">
									<#if (map['${fun.funcode?upper_case}COUNT'])>0>
										${(map['${fun.funcode?upper_case}COUNT'])!}个
									</#if>								
								</a>
							</td>
							
						</#list>
					</tr>
					<#assign i++/>
				</#list>
				</#if>
				<!-- loop end -->
			</table>




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值