xlink遍历两个list插入到一个list中

接口名称:空笼车批量出库

参数:bertchNos 泊位编号列表

功能流程:泊位编号list,获取位置编号list,从数据库查询笼车获得list,遍历这两个list,将每一对数据绑定插入新的列表List<map>中。脚本如下bertchNoAndLocationNoList:

package com.zjft.bpe.dispatch.delivery.shelf;

import com.zjft.bpe.stdlib.exception.ParamNotExistException;
import com.zjft.bpe.stdlib.exception.UnrecognizedScopeException;
import com.zjft.bpe.stdlib.util.ModuleUtil;
import com.zjft.log.ZjLogger;
import com.zjft.zjfz.datamodule.BizDataModule;
import com.zjft.zjfz.db.DbOperate;
import com.zjft.zjfz.engine.IWFEngine;
import com.zjft.zjfz.util.LoggerUtil;
import com.zjft.zjfz.wfactivety.WFActivity;
import com.zjft.zjfz.wfdata.WFData;

import javax.sql.RowSet;
import javax.sql.rowset.CachedRowSet;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class bertchNoAndLocationNoList {
    private final static String DB_ALIAS = "ALIAS";
    private final static String BRETCH_NO = "bertchNoList";
    private final static String HANDCARTANDLOCATIONLIST = "handcartAndLocationList";

    public String process(IWFEngine engine, WFActivity activity, WFData wfd, String wfName) throws ParamNotExistException, UnrecognizedScopeException {
        BizDataModule dm = wfd.getDataModule();
        ZjLogger log = LoggerUtil.getLog(dm.getChannelId(), dm.getTxCode());
        ModuleUtil moduleUtil = new ModuleUtil(wfd, wfd.getDataModule(), activity, log);

        String alias = moduleUtil.getParamValue(DB_ALIAS);
        List<Integer> bertchNoList = (List<Integer>) moduleUtil.getParamObjValue(BRETCH_NO);
        List<String> locationList = new ArrayList<String>();
        List<String> handCartList = new ArrayList<String>();

        try {
            //查询泊位位置插入到位置列表
            Connection conn = wfd.getTxConnection(alias);
            for (int i=0;i<bertchNoList.size();i++){
                int bertchNo = bertchNoList.get(i);
                String qryLocation = "select location_no from delivery_cache_location where type = 9 and sort_no ="+bertchNo;
                RowSet locationRowSet = DbOperate.executeQuery(qryLocation, conn, log);
                locationRowSet.next();
                String location = locationRowSet.getString("location_no");
                locationList.add(location);
            }
            String qryHandCart = "select handcart_no from(\n" +
                    "select handcart_no from base_handcart_info a inner join BASE_STORAGE_LOCATION b \n" +
                    "on a.location_no = b.location_no where a.status = 1 and b.area_no = '03'\n" +
                    ") where rownum <="+bertchNoList.size();
            //查询笼车集合
            RowSet handCartRowSet = DbOperate.executeQuery(qryHandCart, conn, log);
            for (int j = 0; j<((CachedRowSet) handCartRowSet).size(); j++){
                //遍历笼车集合,插入笼车列表
                if (handCartRowSet.next()){
                    String handCart = handCartRowSet.getString("handcart_no");
                    handCartList.add(handCart);
                }
            }
        }catch (Exception e){
            log.error("异常:" + e.getMessage());
        }

        List<Map> handcartAndLocationList = new ArrayList<Map>();
        for (int i=0;i<locationList.size();i++){
            Map<String, String> map = new HashMap<String, String>();
            String handCartNo = handCartList.get(i);
            String locationNo = locationList.get(i);
            map.put("handCartNo",handCartNo);
            map.put("locationNo",locationNo);
            handcartAndLocationList.add(map);
        }
        moduleUtil.setParamObjValue(HANDCARTANDLOCATIONLIST,handcartAndLocationList);
        if (handcartAndLocationList.size()==0){
            return "fail";
        }else {
            return "ok";
        }
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_43163261/article/details/89011527