package weaver.interfaces.htsc.cwkhtzlc;

import org.apache.ibatis.jdbc.SQL;
import weaver.general.Util;
import weaver.soa.workflow.request.*;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MiniUtil {
    /**
     * 主表数据
     * */
    public static Map mainData(RequestInfo requestInfo){
        Map mainTableDataMap = new HashMap();
        Property[] property = requestInfo.getMainTableInfo().getProperty();
        for (int i = 0; i < property.length; i++) {
            mainTableDataMap.put(property[i].getName().toLowerCase(), Util.null2String(property[i].getValue()));
        }
        return mainTableDataMap;
    }

    /**
     * 获取明细表数据
     */
    public static List dtData(RequestInfo requestInfo, Integer num){
//        bb.writeLog("成功进入明细表数据获取方法,获取第"+num+1+"个明细表数据");
        DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(num);
        Row[] rows = detailTable.getRow();//dtltable数组中的行数据集合
        List sublist = new ArrayList();
        for (int i = 0; i < rows.length; i++) {
            Row row = rows[i];
            Map onerow = new HashMap();
            sublist.add(onerow);
            Cell[] cells = row.getCell();
            for (int j = 0; j < cells.length; j++) {
                Cell cell = cells[j];
                onerow.put(cell.getName(), Util.null2String(cell.getValue()));
            }
        }
        return sublist;

    }


}
