@RequestMapping(value = {"/whm/report/used/material.html"}) public ModelAndView list( SearchUsedMaterialBean bean, HttpServletRequest request, HttpServletResponse response) { ModelAndView mav = new ModelAndView("/whm/used/material"); bean.setLoginWarehouseID(SecurityUtils.getPrincipal().getWarehouseID()); if (bean.getToExportedDate() != null) { bean.setToExportedDate( DateUtils.move2TheEndOfDay(new Timestamp(bean.getToExportedDate().getTime()))); } String crudaction = bean.getCrudaction(); if (crudaction != null && StringUtils.isNotBlank(crudaction)) { try { if (bean.getCrudaction() != null && "report".equals(bean.getCrudaction())) { SummaryUsedMaterialDTO result = this.exportmaterialService.reportUsedMaterial(bean); mav.addObject("result", result); } if (bean.getCrudaction() != null && "export".equals(bean.getCrudaction())) { SummaryUsedMaterialDTO result = this.exportmaterialService.reportUsedMaterial(bean); mav.addObject("result", result); exportUsedMaterial2Excel(bean, result, request, response); } } catch (Exception e) { log.error(e.getMessage(), e); } } addData2ModelMaterial(mav); mav.addObject(Constants.LIST_MODEL_KEY, bean); return mav; }
private void addData2ModelMaterial(ModelAndView mav) { List<Warehouse> warehouses = new ArrayList<Warehouse>(); if (SecurityUtils.getPrincipal().getWarehouseID() != null) { Warehouse warehouse = this.warehouseService.findByIdNoCommit(SecurityUtils.getPrincipal().getWarehouseID()); warehouses.add(warehouse); } else { warehouses = this.warehouseService.findByStatus(Constants.TPK_USER_ACTIVE); } mav.addObject("warehouses", warehouses); mav.addObject("materials", this.materialService.findAll()); mav.addObject("origins", this.originService.findAll()); mav.addObject("markets", this.marketService.findAll()); mav.addObject("productionPlans", this.productionPlanService.findAll()); mav.addObject("exportTypes", this.exporttypeService.findAll()); }
private void addData2ModelMaterial(ModelAndView mav, ExportMaterialReportBean bean) { if (bean.getFromDate() == null) { bean.setFromDate(new Date(System.currentTimeMillis())); } if (bean.getToDate() == null) { bean.setToDate(new Date(System.currentTimeMillis())); } mav.addObject("origins", this.originService.findAll()); List<Warehouse> warehouseList = new ArrayList<Warehouse>(); if (SecurityUtils.getPrincipal().getWarehouseID() != null) { Warehouse warehouse = this.warehouseService.findByIdNoCommit(SecurityUtils.getPrincipal().getWarehouseID()); warehouseList.add(warehouse); } else { warehouseList = this.warehouseService.findAll(); } mav.addObject("warehouses", warehouseList); mav.addObject("materials", this.materialService.findAll()); mav.addObject("materialCategories", this.materialcategoryService.findAll()); }