mybaits 中的foreach循环

阅读更多
[size=x-small]
一、  当集合为map对象的数据
      @service.java
                 map.put("ordDd", ordDd);
map.put("consignee", shr);
map.put("shdh", shdh);
map.put("shdz", shdz);
map.put("opType", opType);
map.put("useHosp", useHosp);
map.put("username", username);
//将要保存的表头数据放入 定义好的集合中
listMap.add(map);
         sqlId = "com.ifm.mappers.accept.accept.insertTHTemReady_insert";
if(listMap != null && listMap.size()>0){
mapcs.put("listMap", listMap);
dao.insert(sqlId, mapcs);
     @Mybatis

INSERT INTO
MF_POS_SO_TMP (
BIL_TYPE,
rem,
cus_no,
cus_name,
sal_no,
OS_NO,
OS_DD,
CON_MAN,
CON_MAN_PHONE,
addr,
op_type,
op_hos,
OPERATOR
)
VALUES

(
'${item.bilType}',
'${item.rem}',
'${item.cusNo}','${item.cusName}','${item.salNo}'
,'${item.ordNo}',#{item.ordDd},'${item.consignee}','${item.shdh}',
'${item.shdz}','${item.opType}','${item.useHosp}','${item.username}'
)


一、  当集合为list对象的集合
     @service.java
            List cusNoList = new ArrayList(wdrList.size());
//可获取单号集合
List ordNoList = new ArrayList(wdrList.size());

///  定义订单日期
ordDd = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
if (wdrList != null && wdrList.size() > 0) {
//遍历查询结果
for (getDsptWdrOrderBean ordBean : wdrList) {
ordNo = ordBean.getOrderCode();
ordNoList.add(ordNo);
cusNo = ordBean.getCusNo();
cusNoList.add(cusNo);
}
mapcs.put("ordNoList", ordNoList);
sqlId = "com.ifm.mappers.accept.accept.selectcusName_select";
mapcs.put("cusNoList", cusNoList);
   @Mybatis