| Line 37... |
Line 37... |
| 37 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
37 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 38 |
import com.spice.profitmandi.dao.repository.warehouse.WarehousePurchaseOrderRepository;
|
38 |
import com.spice.profitmandi.dao.repository.warehouse.WarehousePurchaseOrderRepository;
|
| 39 |
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
|
39 |
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
|
| 40 |
import com.spice.profitmandi.service.NotificationService;
|
40 |
import com.spice.profitmandi.service.NotificationService;
|
| 41 |
import com.spice.profitmandi.service.inventory.Combo;
|
41 |
import com.spice.profitmandi.service.inventory.Combo;
|
| - |
|
42 |
import com.spice.profitmandi.service.inventory.ComboOptionModel;
|
| 42 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
43 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 43 |
import com.spice.profitmandi.service.inventory.MappedComboModel;
|
44 |
import com.spice.profitmandi.service.inventory.MappedComboModel;
|
| 44 |
import com.spice.profitmandi.service.order.OrderService;
|
45 |
import com.spice.profitmandi.service.order.OrderService;
|
| 45 |
import com.spice.profitmandi.service.user.RetailerService;
|
46 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 46 |
import com.spice.profitmandi.web.model.LoginDetails;
|
47 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| Line 214... |
Line 215... |
| 214 |
|
215 |
|
| 215 |
@Autowired
|
216 |
@Autowired
|
| 216 |
ComboMappedModelRepository comboMappedModelRepository;
|
217 |
ComboMappedModelRepository comboMappedModelRepository;
|
| 217 |
|
218 |
|
| 218 |
@Autowired
|
219 |
@Autowired
|
| - |
|
220 |
private ComboOptionRepository comboOptionRepository;
|
| - |
|
221 |
|
| - |
|
222 |
@Autowired
|
| 219 |
private UserRepository userUserRepository;
|
223 |
private UserRepository userUserRepository;
|
| 220 |
|
224 |
|
| 221 |
@Autowired
|
225 |
@Autowired
|
| 222 |
private AddressRepository addressRepository;
|
226 |
private AddressRepository addressRepository;
|
| 223 |
|
227 |
|
| Line 1739... |
Line 1743... |
| 1739 |
return "create-combo";
|
1743 |
return "create-combo";
|
| 1740 |
}
|
1744 |
}
|
| 1741 |
|
1745 |
|
| 1742 |
@RequestMapping(value = "/addCombo", method = RequestMethod.POST)
|
1746 |
@RequestMapping(value = "/addCombo", method = RequestMethod.POST)
|
| 1743 |
public String addCombo(HttpServletRequest request, @RequestBody Combo combo, Model model) throws Exception {
|
1747 |
public String addCombo(HttpServletRequest request, @RequestBody Combo combo, Model model) throws Exception {
|
| - |
|
1748 |
List<Integer> warehouseIds = new ArrayList<Integer>();
|
| - |
|
1749 |
|
| - |
|
1750 |
|
| - |
|
1751 |
if (combo.getWarehouseId().isEmpty()) {
|
| - |
|
1752 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 1744 |
|
1753 |
|
| - |
|
1754 |
warehouseIds.addAll(warehouseMap.entrySet().stream().map(x -> x.getKey()).collect(Collectors.toList()));
|
| - |
|
1755 |
|
| - |
|
1756 |
} else {
|
| - |
|
1757 |
warehouseIds.addAll(combo.getWarehouseId());
|
| - |
|
1758 |
}
|
| 1745 |
for (Integer warehouseId : combo.getWarehouseId()) {
|
1759 |
for (Integer warehouseId : warehouseIds) {
|
| 1746 |
|
1760 |
|
| 1747 |
ComboModel comboModel = comboModelRepository.selectByCatalogIdWarehouseIdAndQty(combo.getCatalogId(), warehouseId, combo.getQty());
|
1761 |
ComboModel comboModel = comboModelRepository.selectByCatalogIdWarehouseIdAndQty(combo.getCatalogId(), warehouseId, combo.getQty());
|
| 1748 |
if (comboModel != null) {
|
1762 |
if (comboModel != null) {
|
| - |
|
1763 |
|
| 1749 |
List<ComboMappedModel> comboMappedModels = comboMappedModelRepository.selectByComboId(comboModel.getId());
|
1764 |
List<Integer> comboOptions = comboOptionRepository.selectByComboId(comboModel.getId()).stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 1750 |
for (ComboMappedModel comboMappedModel : comboMappedModels) {
|
1765 |
for (Integer comboOption : comboOptions) {
|
| 1751 |
comboMappedModelRepository.delete(comboMappedModel);
|
1766 |
comboMappedModelRepository.deleteByEquals(comboOption);
|
| 1752 |
}
|
1767 |
}
|
| 1753 |
|
1768 |
|
| - |
|
1769 |
comboOptionRepository.deleteByEquals(comboModel.getId());
|
| - |
|
1770 |
|
| - |
|
1771 |
|
| 1754 |
comboModelRepository.delete(comboModel);
|
1772 |
comboModelRepository.delete(comboModel);
|
| 1755 |
}
|
1773 |
}
|
| - |
|
1774 |
|
| 1756 |
ComboModel cm = new ComboModel();
|
1775 |
ComboModel cm = new ComboModel();
|
| 1757 |
cm.setCatalogId(combo.getCatalogId());
|
1776 |
cm.setCatalogId(combo.getCatalogId());
|
| 1758 |
cm.setQty(combo.getQty());
|
1777 |
cm.setQty(combo.getQty());
|
| 1759 |
cm.setWarehouseId(warehouseId);
|
1778 |
cm.setWarehouseId(warehouseId);
|
| 1760 |
comboModelRepository.persist(cm);
|
1779 |
comboModelRepository.persist(cm);
|
| 1761 |
|
1780 |
|
| 1762 |
LOGGER.info("cm" + cm);
|
1781 |
LOGGER.info("cm" + cm);
|
| - |
|
1782 |
for (ComboOptionModel comboOptionModel : combo.getComboOptionModel()) {
|
| - |
|
1783 |
ComboOption comboOption = new ComboOption();
|
| - |
|
1784 |
comboOption.setComboId(cm.getId());
|
| - |
|
1785 |
comboOptionRepository.persist(comboOption);
|
| - |
|
1786 |
for (MappedComboModel mappedComboModel : comboOptionModel.getMappedComboModel()) {
|
| - |
|
1787 |
ComboMappedModel cmm = new ComboMappedModel();
|
| - |
|
1788 |
cmm.setComboCatalogId(mappedComboModel.getCatalogId());
|
| - |
|
1789 |
cmm.setComboQty(mappedComboModel.getQty());
|
| - |
|
1790 |
cmm.setComboOptionId(comboOption.getId());
|
| - |
|
1791 |
comboMappedModelRepository.persist(cmm);
|
| 1763 |
|
1792 |
|
| 1764 |
for (MappedComboModel mcc : combo.getMappedComboModel()) {
|
- |
|
| 1765 |
ComboMappedModel cmm = new ComboMappedModel();
|
- |
|
| 1766 |
cmm.setComboCatalogId(mcc.getCatalogId());
|
- |
|
| 1767 |
cmm.setComboQty(mcc.getQty());
|
- |
|
| 1768 |
cmm.setComboId(cm.getId());
|
1793 |
}
|
| 1769 |
comboMappedModelRepository.persist(cmm);
|
- |
|
| 1770 |
|
1794 |
|
| 1771 |
}
|
1795 |
}
|
| 1772 |
|
1796 |
|
| 1773 |
}
|
1797 |
}
|
| 1774 |
|
- |
|
| 1775 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
1798 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 1776 |
|
1799 |
|
| 1777 |
return "response";
|
1800 |
return "response";
|
| 1778 |
|
1801 |
|
| 1779 |
}
|
1802 |
}
|
| 1780 |
|
1803 |
|
| 1781 |
@RequestMapping(value = "/combo/remove", method = RequestMethod.POST)
|
1804 |
@RequestMapping(value = "/combo/remove", method = RequestMethod.POST)
|
| 1782 |
public String removeCombo(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
|
1805 |
public String removeCombo(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
|
| - |
|
1806 |
|
| - |
|
1807 |
List<Integer> comboOptions = comboOptionRepository.selectByComboId(id).stream().map(x -> x.getId()).collect(Collectors.toList());
|
| - |
|
1808 |
for (Integer comboOption : comboOptions) {
|
| - |
|
1809 |
comboMappedModelRepository.deleteByEquals(comboOption);
|
| - |
|
1810 |
}
|
| - |
|
1811 |
|
| 1783 |
comboMappedModelRepository.deleteByEquals(id);
|
1812 |
comboOptionRepository.deleteByEquals(id);
|
| 1784 |
comboModelRepository.deleteById(id);
|
1813 |
comboModelRepository.deleteById(id);
|
| 1785 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
1814 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 1786 |
|
1815 |
|
| 1787 |
return "response";
|
1816 |
return "response";
|
| 1788 |
|
1817 |
|