EasyUI-datagrid动态列创建


<div data-options="region:'center'" border="false" style="background:#ffffff;">
     <table id="dgMesResourceCapacityBottleneck"
       data-options="
         fit: true,
         border: false,
         rownumbers: false,
         animate: true,
         collapsible: false,
         autoRowHeight: false,
         idField :'id',
         singleSelect: true,
         checkOnSelect: true,
         selectOnCheck: false,
         pagination:true,
         pageSize:dataOptions.pageSize,
         pageList:dataOptions.pageList,
         striped:true">
     table>
div>
   /**
     * @description:数据拼装
     * @param queryReqBean
     * @return
     * @throws Exception
     */
    public Map doCreate(QueryReqBean> queryReqBean) throws Exception {
        try {
            Map map = new HashMap();
            List> listMap = new ArrayList>();
            List> listHolidayMap = this.searchSumHours(queryReqBean.getSearchParams());
            //这个统计出来的时间是资源能力工时调整表中的数据,需要加上该工作中心的当天能力工时,然后用来和实际工序工时进行比对判断
            List> adjustHoursMap = this.searchSumHoursAndHoliday(queryReqBean.getSearchParams());
            
            QueryRespBean> queryRespBean = this.searchMesResourceCapacityBottleneckByPage(queryReqBean);
            /*Page> mapPage = queryRespBean.getResult();
            for (Map mp : mapPage) {
                queryReqBean.getSearchParams().put("mdsWorkCenterId",mp.get("MDS_WORK_CENTER_ID"));
            }*/
            List> mdsFactoryCalendarDateMap = this.searchMdsFactoryCalendarDate(queryReqBean.getSearchParams());
            
            Page> dataList = queryRespBean.getResult();
            Page> pageList = new Page>();
            pageList.setPageNum(dataList.getPageNum());
            pageList.setPageSize(dataList.getPageSize());
            pageList.setTotal(dataList.getTotal());
            
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            
            List> listHeadMap = dataList.getResult();
            for (Map map2 : listHeadMap) {
                Map mapList = new HashMap();
                mapList.put("ID", map2.get("ID"));
                mapList.put("WorkLineName", map2.get("WORK_LINE_NAME"));
                mapList.put("Zycode", map2.get("ZYCODE"));
                mapList.put("FixedCapacity", map2.get("FIXED_CAPACITY"));
                mapList.put("Overdue", map2.get("OVERDUE"));
                mapList.put("Zyid", map2.get("ZYID"));
                mapList.put("BottleneckType", map2.get("BOTTLENECK_TYPE"));
                for (int i= 0;i) {
                    for (Map map4 : listHolidayMap) {
                        String s = (String)map4.get("HOLIDAY");
                        String s1 = dateFormat.format(mdsFactoryCalendarDateMap.get(i).get("CALENDAR_DATE"));
                        if(s==null||s1==null){
                            continue;
                        }
                        if(s.equals(s1)){
                            if(map2.get("ZYID").equals(map4.get("ID"))){
                                mapList.put("date"+i, map4.get("SUMHOURS"));
                            }
                        }
                    }
                    if(!mapList.containsKey("date"+i)){
                        mapList.put("date"+i, 0);
                    }
                    for (Map map5 : adjustHoursMap) {
                        String s = (String)map5.get("HOLIDAY");
                        String s1 = dateFormat.format(mdsFactoryCalendarDateMap.get(i).get("CALENDAR_DATE"));
                        if(s==null||s1==null){
                            continue;
                        }
                        if(s.equals(s1)){
                            if(map2.get("ZYID").equals(map5.get("ID"))){
                                mapList.put("dateContrast"+i, Integer.parseInt(map2.get("FIXED_CAPACITY").toString())+Integer.parseInt(map5.get("SUMADJUSTHOURS").toString()));
                            }
                        }
                    }
                    if(!mapList.containsKey("dateContrast"+i)){
                        mapList.put("dateContrast"+i, map2.get("FIXED_CAPACITY"));
                    }
                }
                listMap.add(mapList);
                pageList.add(mapList);
            }
            queryRespBean.setResult(pageList);
            map.put("title", mdsFactoryCalendarDateMap);
            map.put("data", queryRespBean);
            return map;
        } catch (Exception e) {
            LOGGER.error("doCreate出错:", e);
            e.printStackTrace();
            throw new DaoException(e.getMessage(), e);
        }
    }