Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/controller/HomeController.java
re02787e r2a552fe 1 1 package com.example.autopartz.controller; 2 2 3 import com.example.autopartz.model.*;4 3 import com.example.autopartz.model.DTO.CurrentOrderDTO; 5 4 import com.example.autopartz.model.DTO.OrderInfo; 5 import com.example.autopartz.model.*; 6 6 import com.example.autopartz.model.manytomany.OrderContainsPart; 7 7 import com.example.autopartz.model.manytomany.PartIsInStockInWarehouse; 8 import com.example.autopartz.model.manytomany.PartIsInStockInWarehouseId;9 8 import com.example.autopartz.model.views.DeliveriesInProgress; 10 9 import com.example.autopartz.model.views.PartsForCarTypeAndCategory; … … 20 19 import java.io.IOException; 21 20 import java.util.ArrayList; 22 import java.util.Comparator;23 21 import java.util.List; 24 22 import java.util.Objects; … … 103 101 int total = 0; 104 102 List<OrderContainsPart> qList = orderContainsPartRepository.findAllByOrderid(o.getOrderid()); 105 for ( int i = 0; i < qList.size(); i++) {106 int pr = qList.get(i).getQuantity_order()*107 priceService.findPriceForPart(partService.findById( qList.get(i).getPartid())).stream().findFirst().get().getAmount();103 for (OrderContainsPart orderContainsPart : qList) { 104 int pr = orderContainsPart.getQuantity_order() * 105 priceService.findPriceForPart(partService.findById(orderContainsPart.getPartid())).stream().findFirst().get().getAmount(); 108 106 CurrentOrderDTO temp = new CurrentOrderDTO( 109 partService.findById( qList.get(i).getPartid()).getName(),110 partService.findById( qList.get(i).getPartid()).getManufacturer().getName(),111 qList.get(i).getQuantity_order(),107 partService.findById(orderContainsPart.getPartid()).getName(), 108 partService.findById(orderContainsPart.getPartid()).getManufacturer().getName(), 109 orderContainsPart.getQuantity_order(), 112 110 pr); 113 111 list.add(temp); 114 total +=pr;112 total += pr; 115 113 } 116 114 model.addAttribute("total",total); … … 188 186 } 189 187 @PostMapping("/finishRegister") 190 public void handleWarehousemanRegister(@RequestParam String location, Model model,HttpServletResponse response, HttpSession session){188 public void handleWarehousemanRegister(@RequestParam String location, HttpServletResponse response, HttpSession session){ 191 189 System.out.println("here?"); 192 190 String username = (String) session.getAttribute("username"); … … 243 241 } 244 242 @PostMapping("/finishDelivery/{id}") 245 public void finishDelivery(@PathVariable Integer id, Model model,HttpServletResponse response){243 public void finishDelivery(@PathVariable Integer id, HttpServletResponse response){ 246 244 Delivery d = deliveryService.findByOrder(orderService.findById(id)); 247 245 d.setStatus("finished"); … … 257 255 List<OrderContainsPart> list = orderContainsPartRepository.findAllByOrderid(id); 258 256 List<OrderInfo> partList = new ArrayList<>(); 259 for ( int i = 0; i < list.size(); i++) {260 OrderInfo oi = new OrderInfo(partService.findById( list.get(i).getPartid()).getName(),261 list.get(i).getQuantity_order(),partService.findById(list.get(i).getPartid()).getManufacturer().getName());257 for (OrderContainsPart orderContainsPart : list) { 258 OrderInfo oi = new OrderInfo(partService.findById(orderContainsPart.getPartid()).getName(), 259 orderContainsPart.getQuantity_order(), partService.findById(orderContainsPart.getPartid()).getManufacturer().getName()); 262 260 partList.add(oi); 263 261 } … … 301 299 Warehouse wh = whm.getWarehouse(); 302 300 Integer whId = wh.getId(); 303 PartIsInStockInWarehouseId tmp = new PartIsInStockInWarehouseId(pId,whId); 304 PartIsInStockInWarehouse temp = partIsInStockInWarehouseRepository.findById(tmp).get(); 305 temp.setQuantity(temp.getQuantity()+quantity); 306 partIsInStockInWarehouseRepository.save(temp); 301 partService.addPartToWarehouse(pId,quantity,whId); 307 302 try { 308 303 response.sendRedirect("/myWarehouseReport");
Note:
See TracChangeset
for help on using the changeset viewer.