mybatis使用 Map查询
//前端传的多选参数
List<SemiSerialListVo> semiSerialRecordsList = queryDate.getSemiSerialRecords();
/**
 * 根据批次号查询备注,组装成map
 * Map 查询的参数map
 */
Map<String, Object> paramMap=new HashMap<>(1);
List<String> batchList=new ArrayList<>();
for (SemiSerialListVo serialListVo : semiSerialRecordsList) {
    batchList.add(serialListVo.getBatchNo());
}
paramMap.put("batchList",batchList);
//根据批次号查询出uuid和备注,转为map集合
List<ImageURLVo> uuidRemarkList = qualifiedIncomingListService.querySemiPhotoRemarkByBatchNo(paramMap);
Map<String, String> uuidMap = uuidRemarkList.stream().collect(Collectors.toMap(ImageURLVo::getUuid, ImageURLVo::getRemark));
Mapper方法:
List<ImageURLVo> querySemiPhotoRemarkByBatchNo(Map<String, Object> paramMap);
xml SQL:
<!--根据批次号查询图片的uuid和图片的备注,batchNo-->
<select id="querySemiPhotoRemarkByBatchNo" resultType="com.xc.mes.mesincomingmgr.putinproduct.pojo.db2.ImageURLVo" parameterType="Map">
    select UUID as uuid,case when REMARK is not null then REMARK else '' end as remark from
    ICOM_INSPECT_REPORT_REMARK where IS_DELETED = '0' and BATCH_NO in
    <foreach item="batchNo" index="index" collection="batchList" open="(" separator="," close=")">
        #{batchNo}
    </foreach>
</select>
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号