@RequestMapping(value = "/vendorReturnAdvanceSearchOperations", method = RequestMethod.POST) public String vendorReturnAdvanceSearchOperations( @ModelAttribute("vendorReturnCommand") VendorReturn vendorReturn, HttpServletRequest request, HttpServletResponse response, Model model) { vr1 = new ArrayList<VendorReturn>(); String columns = vendorReturn.getFirstLabel(); String operations = vendorReturn.getOperations1(); String advanceSearchText = vendorReturn.getAdvanceSearchText(); if (advanceSearchText.length() != 0) { objectsArray = vrService.getVendorReturnAdvance(columns, operations, advanceSearchText); } else { objectsArray = vrService.getVendorReturn("ALL"); } iterator = objectsArray.iterator(); while (iterator.hasNext()) { VendorReturn vr = (VendorReturn) iterator.next(); vr.setVendorReturnId(vr.getVendorReturnId()); vr.setVendorReturnNo(vr.getVendorReturnNo()); vr.setVendorReturnDate(vr.getVendorReturnDate()); vr.setReference(vr.getReference()); vr.setDescription(vr.getDescription()); vr1.add(vr); } request.setAttribute("vendorReturnSearch", vr1); model.addAttribute("vendorReturn", new VendorReturn()); vendorReturn.setAdvanceSearchHidden(0); return "vendorReturnHome"; }
/* * =====================================Edit * Method============================== */ @RequestMapping(value = "/vendorReturnIdEdit1", method = RequestMethod.GET) @Scope("request") public String vendorReturnEdit( @ModelAttribute VendorReturn vendorReturnIdEdit1, BindingResult result, HttpServletRequest request, HttpServletResponse response, Model model) { response.setCharacterEncoding("UTF-8"); List<Float> qtyList = new ArrayList<Float>(); List<Object> list = null; List<VendorReturn> vrEditList = new ArrayList<VendorReturn>(); List<VendorReturnLine> vrLineEditList = new ArrayList<VendorReturnLine>(); int vrid = vendorReturnIdEdit1.getVendorReturnId(); try { list = vrService.editVendorReturnWithId(vrid); Iterator<Object> iterator = list.iterator(); if (iterator.hasNext()) { Object vrObj = iterator.next(); VendorReturn vr = (VendorReturn) vrObj; vendorReturnIdEdit1.setVendorReturnIdEditt(vr.getVendorReturnId()); vendorReturnIdEdit1.setVendorReturnNoEditt(vr.getVendorReturnNo()); vendorReturnIdEdit1.setVendorReturnDateEditt( dateService.dateFormat(dateService.dateParse(vr.getVendorReturnDate(), "se"), "se")); vendorReturnIdEdit1.setReferenceEditt(vr.getReference()); vendorReturnIdEdit1.setDescriptionEditt(vr.getDescription()); vendorReturnIdEdit1.setPurchaseOrderIdEditt(vr.getPurchaseOrderId()); vendorReturnIdEdit1.setGoodsReceiptIdEdit(vr.getGoodsReceiptId()); List<VendorReturnLine> listEdit = vr.getVendorReturnLine(); Iterator<VendorReturnLine> iterator1 = listEdit.iterator(); while (iterator1.hasNext()) { Object vrLineObj = iterator1.next(); VendorReturnLine vrLine = (VendorReturnLine) vrLineObj; VendorReturnLine vrMultiple = new VendorReturnLine(); vrMultiple.setVendorReturnLineId(vrLine.getVendorReturnLineId()); int materialId = Integer.parseInt(vrLine.getMaterial_Id()); int previousUpdatedStock; previousUpdatedStock = materialService.materialStockGet(materialId); int materialQtyInEditField = (int) (vrLine.getQuantity()); int stockEdit = previousUpdatedStock + materialQtyInEditField; vrMultiple.setStockEdit(stockEdit); Material material = vrLine.getMaterialDetails(); Uom uom = vrLine.getUomDetails(); ReasonForRejection rfr = vrLine.getRfrDetails(); StorageLocation storage = vrLine.getStorageDetails(); vrMultiple.setMaterial_IdEditt((vrLine.getMaterial_Id())); vrMultiple.setMaterialName(material.getMaterialName()); vrMultiple.setQuantityEditt((vrLine.getQuantity())); vrMultiple.setBatchNoEdit(vrLine.getBatchNo()); vrMultiple.setUom_IdEditt(vrLine.getUom_Id()); vrMultiple.setUomName(uom.getUom()); vrMultiple.setPriceEditt(vrLine.getPrice()); vrMultiple.setReasonForRejectionIdEditt(vrLine.getReasonForRejectionId()); vrMultiple.setRfrName(rfr.getReasonForRejection()); vrMultiple.setStorageLocationIdEditt(vrLine.getStorageLocationId()); vrMultiple.setStorageName(storage.getStorageLocation()); vrLineEditList.add(vrMultiple); qtyList.add((float) vrLine.getQuantity()); } vrEditList.add(vendorReturnIdEdit1); } model.addAttribute("vendorReturnCommand", vendorReturnIdEdit1); session = request.getSession(false); session.setAttribute("qtyList", qtyList); request.setAttribute("vrEditList", vrEditList); request.setAttribute("vrLineEditList", vrLineEditList); } catch (Exception e) { e.printStackTrace(); } return "vendorReturnHome"; }
@RequestMapping(value = "/vendorReturnSearch", method = RequestMethod.GET) @Scope("request") public ModelAndView searchVendorReturn( @ModelAttribute("vendorReturnCommand") VendorReturn vendorReturnSearch, BindingResult bindingResult, HttpServletRequest request, HttpServletResponse response) { response.setCharacterEncoding("UTF-8"); List<VendorReturn> vrlist = new ArrayList<VendorReturn>(); List<Object> list = null; List<Object> lob = null; try { String dbField = vendorReturnSearch.getXmlLabel(); String operation = vendorReturnSearch.getOperations(); String basicSearchId = vendorReturnSearch.getBasicSearchId(); if (operation.equals("_%")) { operation = " like "; basicSearchId = basicSearchId + "%"; } else if (operation.equals("%_")) { operation = " like "; basicSearchId = "%" + basicSearchId; } else if (operation.equals("%_%")) { operation = " like "; basicSearchId = "%" + basicSearchId + "%"; } if (basicSearchId == "") { lob = vrService.searchVendorReturn(); Iterator<Object> iterator = lob.iterator(); while (iterator.hasNext()) { VendorReturn vr = (VendorReturn) iterator.next(); vr.setVendorReturnId(vr.getVendorReturnId()); vr.setVendorReturnNo(vr.getVendorReturnNo()); vr.setVendorReturnDate( dateService.dateFormat(dateService.dateParse(vr.getVendorReturnDate(), "se"), "se")); vr.setReference(vr.getReference()); vr.setDescription(vr.getDescription()); vr.setBatchNo(vr.getBatchNo()); vrlist.add(vr); } } else { list = vrService.basicSearchVendorReturn(dbField, operation, basicSearchId); Iterator<Object> iter = list.iterator(); while (iter.hasNext()) { VendorReturn vr = (VendorReturn) iter.next(); vr.setVendorReturnId(vr.getVendorReturnId()); vr.setVendorReturnNo(vr.getVendorReturnNo()); vr.setVendorReturnDate( dateService.dateFormat(dateService.dateParse(vr.getVendorReturnDate(), "se"), "se")); vr.setReference(vr.getReference()); vr.setDescription(vr.getDescription()); vr.setBatchNo(vr.getBatchNo()); vrlist.add(vr); } } } catch (Exception e) { e.printStackTrace(); } request.setAttribute("vendorReturnSearch", vrlist); ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("vendorReturnHome"); modelAndView.addObject("vendorReturnCommand"); return modelAndView; }