Changeset 16f38d4
- Timestamp:
- 01/08/23 17:17:48 (23 months ago)
- Branches:
- main
- Children:
- 0afa35a
- Parents:
- 7e10599
- Location:
- FullyStocked/src/main
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
FullyStocked/src/main/java/com/bazi/fullystocked/Models/SqlViews/OrderedArticlesReport.java
r7e10599 r16f38d4 27 27 private ArticleStatus articlestatus; 28 28 private int orderid; 29 private int storedquantity; 29 30 } -
FullyStocked/src/main/java/com/bazi/fullystocked/Repositories/OrdersReportRepository.java
r7e10599 r16f38d4 1 1 package com.bazi.fullystocked.Repositories; 2 2 3 import com.bazi.fullystocked.Models.Enumerations.OrderStatus; 3 4 import com.bazi.fullystocked.Models.SqlViews.OrdersReport; 5 import org.hibernate.criterion.Order; 4 6 import org.springframework.data.jpa.repository.JpaRepository; 5 7 import java.util.*; … … 8 10 List<OrdersReport> findAllBySupplieruserid(Integer id); 9 11 List<OrdersReport> findAllByManageruserid(Integer id); 12 List<OrdersReport> findAllByStatus(OrderStatus status); 10 13 } -
FullyStocked/src/main/java/com/bazi/fullystocked/Services/Implementations/OrdersServiceImpl.java
r7e10599 r16f38d4 192 192 } 193 193 194 @Override 195 public List<OrdersReport> findByStatus(OrderStatus status) { 196 return ordersReportRepository.findAllByStatus(status); 197 } 198 194 199 } -
FullyStocked/src/main/java/com/bazi/fullystocked/Services/OrdersService.java
r7e10599 r16f38d4 23 23 Optional<OrdersReport> findByIdReport(Integer orderId); 24 24 Optional<Orders> updateStatus(Integer orderId, OrderStatus status); 25 List<OrdersReport> findByStatus(OrderStatus status); 25 26 26 27 } -
FullyStocked/src/main/java/com/bazi/fullystocked/Web/Controller/OrderController.java
r7e10599 r16f38d4 291 291 return "redirect:/orders/manager/details/"+orderId; 292 292 } 293 @GetMapping("/worker/list") 294 public String listOrdersWorker(Model model) 295 { 296 model.addAttribute("orders", ordersService.findByStatus(OrderStatus.IN_PROGRESS)); 297 return "workerOrders"; 298 } 293 299 @PostMapping("/worker/accept") 294 300 public String acceptOrder(@RequestParam Integer orderId) 295 301 { 296 ordersService.updateStatus(orderId, OrderStatus.DELIVERED); 297 return "redirect:/worker"; 302 try { 303 ordersService.updateStatus(orderId, OrderStatus.DELIVERED); 304 } 305 catch (Exception e) 306 { 307 return "redirect:/orders/worker/list"+e.getMessage(); 308 } 309 return "redirect:/orders/worker/list"; 298 310 } 299 311 } -
FullyStocked/src/main/java/com/bazi/fullystocked/Web/Controller/WorkerController.java
r7e10599 r16f38d4 1 1 package com.bazi.fullystocked.Web.Controller; 2 2 3 import com.bazi.fullystocked.Models.Enumerations.ArticleStatus; 3 4 import com.bazi.fullystocked.Models.SqlViews.ArticlesReport; 4 5 import com.bazi.fullystocked.Models.Workers; 5 6 import com.bazi.fullystocked.Services.ArticlesService; 7 import com.bazi.fullystocked.Services.OrderedArticlesService; 6 8 import com.bazi.fullystocked.Services.StoredArticlesService; 7 9 import org.springframework.stereotype.Controller; 8 10 import org.springframework.ui.Model; 9 import org.springframework.web.bind.annotation.GetMapping; 10 import org.springframework.web.bind.annotation.PathVariable; 11 import org.springframework.web.bind.annotation.RequestMapping; 11 import org.springframework.web.bind.annotation.*; 12 12 13 13 import javax.servlet.http.HttpServletRequest; … … 19 19 private final StoredArticlesService storedArticlesService; 20 20 private final ArticlesService articlesService; 21 private final OrderedArticlesService orderedArticlesService; 21 22 22 public WorkerController(StoredArticlesService storedArticlesService, ArticlesService articlesService ) {23 public WorkerController(StoredArticlesService storedArticlesService, ArticlesService articlesService, OrderedArticlesService orderedArticlesService) { 23 24 this.storedArticlesService = storedArticlesService; 24 25 this.articlesService = articlesService; 26 this.orderedArticlesService = orderedArticlesService; 25 27 } 26 28 … … 51 53 return "redirect:/worker/articles?error=ArticleNotFound"; 52 54 } 55 @GetMapping("/deliveredArticles") 56 public String listDeliveredArticles(Model model, HttpServletRequest request) 57 { 58 Workers u= (Workers) request.getSession().getAttribute("user"); 59 model.addAttribute("articles", orderedArticlesService.findByStatusAtLocation(ArticleStatus.DELIVERED, u.getLocation().getLocationid())); 60 return "deliveredArticles"; 61 } 62 63 @PostMapping("/deliveredArticles/process") 64 public String processOrderedArticle(@RequestParam Integer articleId, HttpServletRequest request) 65 { 66 try 67 { 68 Workers u= (Workers) request.getSession().getAttribute("user"); 69 if(storedArticlesService.findById(articleId).isEmpty()) 70 { 71 return "redirect:/worker/deliveredArticles"; 72 } 73 if(!storedArticlesService.findById(articleId).get().getLocationid().equals(u.getLocation().getLocationid())) 74 { 75 return "redirect:/login"; 76 } 77 storedArticlesService.updateFromOrder(articleId); 78 return "redirect:/worker/deliveredArticles"; 79 } 80 catch (Exception e) 81 { 82 return "redirect:/worker/deliveredArticles?error="+e.getMessage(); 83 } 84 } 85 53 86 } -
FullyStocked/src/main/resources/templates/supplierOrders.html
r7e10599 r16f38d4 49 49 </th> 50 50 <th> 51 Добавувач 51 Забелешка на менаџер 52 </th> 53 <th> 54 Забелешка на добавувач 52 55 </th> 53 56 <th> … … 56 59 <th> 57 60 Приоритет 58 </th>59 <th>60 Забелешка61 61 </th> 62 62 <th>
Note:
See TracChangeset
for help on using the changeset viewer.