Mybatis查询之list作为参数查询

来源:互联网 发布:怎么做淘宝客服 编辑:程序博客网 时间:2024/05/17 03:50

dao:

 Float findTotMaterial(Map<String,Object> map);

service:

//查询出list昨晚参数

List<String> youndIdLists = youComInfoMapper.findCycCount2(
                    producecode, farmIdList, dayAge);

Map<String, Object> paramMap2 = new HashMap<String, Object>();

paramMap2.put("list1", youndIdLists);


Float totMaterial = youComInfoMapper.findTotMaterial(paramMap2);


映射xm代码:

<select id="findTotMaterial" resultType="java.lang.Float" parameterType="java.util.Map">
    select round(s.totalMaterialNum*1000/(s.youngCount -s.deathCount),2) totMaterial from
        (select COALESCE(sum(ins.fMatNum),0) totalMaterialNum,
        COALESCE(sum(ys.iCount+ys.iGivCount),0)youngCount,
        COALESCE(sum(ins.iDeaCount),0)deathCount
        from inspection ins
        left JOIN young ys on ins.iYoungId=ys.ID
         where ys.ID in
         <foreach collection="list1" index="index" item="youngId" open="(" separator="," close=")">
            #{youngId}
        </foreach>
        )s
    </select>




0 0
原创粉丝点击