| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| - |
|
4 |
import java.util.HashMap;
|
| 4 |
import java.util.List;
|
5 |
import java.util.List;
|
| - |
|
6 |
import java.util.Map;
|
| - |
|
7 |
import java.util.stream.Collectors;
|
| 5 |
|
8 |
|
| 6 |
import javax.servlet.http.HttpServletRequest;
|
9 |
import javax.servlet.http.HttpServletRequest;
|
| 7 |
|
10 |
|
| 8 |
import org.apache.logging.log4j.LogManager;
|
11 |
import org.apache.logging.log4j.LogManager;
|
| 9 |
import org.apache.logging.log4j.Logger;
|
12 |
import org.apache.logging.log4j.Logger;
|
| 10 |
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 11 |
import org.springframework.stereotype.Controller;
|
14 |
import org.springframework.stereotype.Controller;
|
| 12 |
import org.springframework.transaction.annotation.Transactional;
|
15 |
import org.springframework.transaction.annotation.Transactional;
|
| 13 |
import org.springframework.ui.Model;
|
16 |
import org.springframework.ui.Model;
|
| - |
|
17 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 14 |
import org.springframework.web.bind.annotation.RequestMapping;
|
18 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 15 |
import org.springframework.web.bind.annotation.RequestMethod;
|
19 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 16 |
import org.springframework.web.bind.annotation.RequestParam;
|
20 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 17 |
|
21 |
|
| - |
|
22 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
| - |
|
23 |
import com.spice.profitmandi.dao.entity.inventory.Warehouse;
|
| - |
|
24 |
import com.spice.profitmandi.dao.entity.inventory.Vendor;
|
| 18 |
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
|
25 |
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
|
| - |
|
26 |
import com.spice.profitmandi.dao.enumuration.inventory.InventoryType;
|
| - |
|
27 |
import com.spice.profitmandi.dao.enumuration.inventory.WarehouseType;
|
| - |
|
28 |
import com.spice.profitmandi.dao.hrms.CreateNewSupplier;
|
| - |
|
29 |
import com.spice.profitmandi.dao.hrms.WarehouseIdPrefixModel;
|
| - |
|
30 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| - |
|
31 |
import com.spice.profitmandi.dao.repository.inventory.VendorRepository;
|
| 19 |
|
- |
|
| - |
|
32 |
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
|
| - |
|
33 |
import com.spice.profitmandi.dao.repository.transaction.WareHouseAddressMasterRepository;
|
| - |
|
34 |
import com.spice.profitmandi.dao.repository.transaction.SellerRepository;
|
| - |
|
35 |
import com.spice.profitmandi.dao.repository.transaction.SellerWarehouseRepository;
|
| - |
|
36 |
import com.spice.profitmandi.dao.repository.transaction.WareHouseAddressMappingRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.warehouse.SupplierRepository;
|
37 |
import com.spice.profitmandi.dao.repository.warehouse.SupplierRepository;
|
| - |
|
38 |
import com.spice.profitmandi.service.warehouse.WarehouseService;
|
| 21 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
39 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22 |
|
40 |
|
| - |
|
41 |
import com.spice.profitmandi.dao.entity.transaction.*;
|
| - |
|
42 |
|
| 23 |
@Controller
|
43 |
@Controller
|
| 24 |
@Transactional(rollbackFor = Throwable.class)
|
44 |
@Transactional(rollbackFor = Throwable.class)
|
| 25 |
public class SupplierController {
|
45 |
public class SupplierController {
|
| 26 |
|
46 |
|
| 27 |
@Autowired
|
47 |
@Autowired
|
| 28 |
private SupplierRepository supplierRepository;
|
48 |
private SupplierRepository supplierRepository;
|
| 29 |
|
49 |
|
| 30 |
@Autowired
|
50 |
@Autowired
|
| 31 |
private MVCResponseSender mvcResponseSender;
|
51 |
private MVCResponseSender mvcResponseSender;
|
| - |
|
52 |
@Autowired
|
| - |
|
53 |
private WarehouseRepository warehouseRepository;
|
| 32 |
|
54 |
|
| - |
|
55 |
@Autowired
|
| - |
|
56 |
private SellerRepository sellerRepository;
|
| - |
|
57 |
|
| - |
|
58 |
@Autowired
|
| - |
|
59 |
private WarehouseService warehouseService;
|
| - |
|
60 |
|
| - |
|
61 |
@Autowired
|
| - |
|
62 |
private SellerWarehouseRepository sellerWarehouseRepository;
|
| - |
|
63 |
|
| - |
|
64 |
@Autowired
|
| - |
|
65 |
private VendorRepository vendorRepository;
|
| - |
|
66 |
|
| - |
|
67 |
@Autowired
|
| - |
|
68 |
private WareHouseAddressMappingRepository wareHouseAddressMappingRepository;
|
| - |
|
69 |
|
| - |
|
70 |
@Autowired
|
| - |
|
71 |
private WareHouseAddressMasterRepository WareHouseAddressMasterRepository;
|
| - |
|
72 |
|
| - |
|
73 |
@Autowired
|
| - |
|
74 |
private StateRepository stateRepository;
|
| - |
|
75 |
|
| 33 |
private static final Logger LOGGER = LogManager.getLogger(SellerController.class);
|
76 |
private static final Logger LOGGER = LogManager.getLogger(SupplierController.class);
|
| 34 |
|
77 |
|
| 35 |
@RequestMapping(value = "/getAllSupplier", method = RequestMethod.GET)
|
78 |
@RequestMapping(value = "/getAllSupplier", method = RequestMethod.GET)
|
| 36 |
public String getShowSupplier(HttpServletRequest request,Model model)
|
79 |
public String getShowSupplier(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
80 |
|
| - |
|
81 |
List<Supplier> supplierAcvtives = supplierRepository.selectByStatus(true);
|
| - |
|
82 |
|
| - |
|
83 |
List<SellerWarehouse> sellerWarehouses = supplierRepository.selectAll();
|
| - |
|
84 |
List<Integer> sellerwarehouseIds = sellerWarehouses.stream().map(x -> x.getWarehouseId())
|
| - |
|
85 |
.collect(Collectors.toList());
|
| - |
|
86 |
LOGGER.info("sellerWarehouses" + sellerWarehouses);
|
| - |
|
87 |
Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
|
| - |
|
88 |
|
| - |
|
89 |
for (SellerWarehouse sw : sellerWarehouses) {
|
| - |
|
90 |
|
| - |
|
91 |
WarehouseAddressMapping warehouseAddressMapping = wareHouseAddressMappingRepository
|
| - |
|
92 |
.selectByWarehouseId(sw.getWarehouseId());
|
| - |
|
93 |
LOGGER.info("warehouseAddressMapping" + warehouseAddressMapping);
|
| 37 |
throws Exception {
|
94 |
if (warehouseAddressMapping != null) {
|
| - |
|
95 |
WarehouseAddressMaster WarehouseAddressMaster = WareHouseAddressMasterRepository
|
| - |
|
96 |
.selectByAddressId(warehouseAddressMapping.getAddressId());
|
| - |
|
97 |
LOGGER.info("warehouseAddressMappingAddreesId" + warehouseAddressMapping.getAddressId());
|
| - |
|
98 |
LOGGER.info("WarehouseAddressMaster" + WarehouseAddressMaster);
|
| - |
|
99 |
State state = stateRepository.selectById(WarehouseAddressMaster.getStateId());
|
| - |
|
100 |
WarehouseIdPrefixModel wp = new WarehouseIdPrefixModel();
|
| - |
|
101 |
wp.setPrefix(sw.getPrefix());
|
| - |
|
102 |
wp.setStateName(state.getName());
|
| - |
|
103 |
warehouseIdAndState.put(sw.getWarehouseId(), wp);
|
| - |
|
104 |
LOGGER.info("state" + state);
|
| - |
|
105 |
}
|
| 38 |
|
106 |
}
|
| - |
|
107 |
LOGGER.info("warehouseIdAndState" + warehouseIdAndState);
|
| - |
|
108 |
model.addAttribute("warehouseIdAndState", warehouseIdAndState);
|
| - |
|
109 |
|
| 39 |
List<Supplier> supplierAcvtives =supplierRepository.selectByStatus(true);
|
110 |
List<State> state = supplierRepository.selectByIdStateMaster();
|
| 40 |
|
111 |
|
| 41 |
model.addAttribute("suppliers", supplierAcvtives);
|
112 |
model.addAttribute("suppliers", supplierAcvtives);
|
| 42 |
|
- |
|
| 43 |
LOGGER.info("supplierAcvtives"+supplierAcvtives);
|
113 |
model.addAttribute("state", state);
|
| 44 |
|
114 |
|
| 45 |
return "supplier";
|
115 |
return "supplier";
|
| 46 |
|
116 |
|
| 47 |
}
|
117 |
}
|
| 48 |
|
- |
|
| 49 |
|
118 |
|
| 50 |
@RequestMapping(value = "/getAllInActiveSupplier", method = RequestMethod.GET)
|
119 |
@RequestMapping(value = "/getAllInActiveSupplier", method = RequestMethod.GET)
|
| 51 |
public String getShowInActiveSupplier(HttpServletRequest request,Model model)
|
120 |
public String getShowInActiveSupplier(HttpServletRequest request, Model model) throws Exception {
|
| 52 |
throws Exception {
|
- |
|
| 53 |
|
121 |
|
| 54 |
List<Supplier> supplierInactives =supplierRepository.selectByStatus(false);
|
122 |
List<Supplier> supplierInactives = supplierRepository.selectByStatus(false);
|
| 55 |
|
123 |
|
| 56 |
model.addAttribute("supplierInactives", supplierInactives);
|
124 |
model.addAttribute("supplierInactives", supplierInactives);
|
| 57 |
|
125 |
|
| 58 |
LOGGER.info("supplierInactives"+supplierInactives);
|
126 |
LOGGER.info("supplierInactives" + supplierInactives);
|
| 59 |
|
127 |
|
| 60 |
return "supplier-in-active";
|
128 |
return "supplier-in-active";
|
| 61 |
|
129 |
|
| 62 |
}
|
130 |
}
|
| 63 |
|
- |
|
| 64 |
|
- |
|
| 65 |
|
- |
|
| 66 |
|
131 |
|
| - |
|
132 |
@RequestMapping(value = "/getCreateNewSupplier", method = RequestMethod.GET)
|
| - |
|
133 |
public String getCreateNewSupplier(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
134 |
|
| - |
|
135 |
List<SellerWarehouse> sellerWarehouses = supplierRepository.selectAll();
|
| - |
|
136 |
List<Integer> sellerwarehouseIds = sellerWarehouses.stream().map(x -> x.getWarehouseId())
|
| - |
|
137 |
.collect(Collectors.toList());
|
| - |
|
138 |
LOGGER.info("sellerWarehouses" + sellerWarehouses);
|
| - |
|
139 |
Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
|
| - |
|
140 |
|
| - |
|
141 |
for (SellerWarehouse sw : sellerWarehouses) {
|
| - |
|
142 |
|
| - |
|
143 |
WarehouseAddressMapping warehouseAddressMapping = wareHouseAddressMappingRepository
|
| - |
|
144 |
.selectByWarehouseId(sw.getWarehouseId());
|
| - |
|
145 |
LOGGER.info("warehouseAddressMapping" + warehouseAddressMapping);
|
| - |
|
146 |
if (warehouseAddressMapping != null) {
|
| - |
|
147 |
WarehouseAddressMaster WarehouseAddressMaster = WareHouseAddressMasterRepository
|
| - |
|
148 |
.selectByAddressId(warehouseAddressMapping.getAddressId());
|
| - |
|
149 |
LOGGER.info("warehouseAddressMappingAddreesId" + warehouseAddressMapping.getAddressId());
|
| - |
|
150 |
LOGGER.info("WarehouseAddressMaster" + WarehouseAddressMaster);
|
| - |
|
151 |
State state = stateRepository.selectById(WarehouseAddressMaster.getStateId());
|
| - |
|
152 |
WarehouseIdPrefixModel wp = new WarehouseIdPrefixModel();
|
| - |
|
153 |
wp.setPrefix(sw.getPrefix());
|
| - |
|
154 |
wp.setStateName(state.getName());
|
| - |
|
155 |
warehouseIdAndState.put(sw.getWarehouseId(), wp);
|
| - |
|
156 |
LOGGER.info("state" + state);
|
| - |
|
157 |
}
|
| - |
|
158 |
}
|
| - |
|
159 |
LOGGER.info("warehouseIdAndState" + warehouseIdAndState);
|
| - |
|
160 |
model.addAttribute("warehouseIdAndState", warehouseIdAndState);
|
| - |
|
161 |
|
| - |
|
162 |
List<State> state = supplierRepository.selectByIdStateMaster();
|
| - |
|
163 |
|
| - |
|
164 |
model.addAttribute("state", state);
|
| - |
|
165 |
|
| - |
|
166 |
return "new-supplier";
|
| 67 |
|
167 |
}
|
| - |
|
168 |
|
| 68 |
@RequestMapping(value = "/setStatusInActive", method = RequestMethod.POST)
|
169 |
@RequestMapping(value = "/setStatusInActive", method = RequestMethod.POST)
|
| 69 |
public String setInActiveSupplier(HttpServletRequest request,
|
170 |
public String setInActiveSupplier(HttpServletRequest request,
|
| 70 |
@RequestParam(name = "id", required = true, defaultValue = "0") int id, Model model)
|
171 |
@RequestParam(name = "id", required = true, defaultValue = "0") int id, Model model) throws Exception {
|
| 71 |
throws Exception {
|
- |
|
| 72 |
|
- |
|
| 73 |
|
172 |
|
| 74 |
Supplier supplier=supplierRepository.selectById(id);
|
173 |
Supplier supplier = supplierRepository.selectById(id);
|
| 75 |
|
174 |
|
| 76 |
supplier.setStatus(false);
|
175 |
supplier.setStatus(false);
|
| 77 |
|
- |
|
| 78 |
|
176 |
|
| 79 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
177 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 80 |
|
178 |
|
| 81 |
return "response";
|
179 |
return "response";
|
| 82 |
}
|
180 |
}
|
| - |
|
181 |
|
| 83 |
@RequestMapping(value = "/setStatusActive", method = RequestMethod.POST)
|
182 |
@RequestMapping(value = "/setStatusActive", method = RequestMethod.POST)
|
| 84 |
public String setActiveSupplier(HttpServletRequest request,
|
183 |
public String setActiveSupplier(HttpServletRequest request,
|
| 85 |
@RequestParam(name = "id", required = true, defaultValue = "0") int id, Model model)
|
184 |
@RequestParam(name = "id", required = true, defaultValue = "0") int id, Model model) throws Exception {
|
| - |
|
185 |
|
| - |
|
186 |
Supplier supplier = supplierRepository.selectById(id);
|
| - |
|
187 |
|
| - |
|
188 |
supplier.setStatus(true);
|
| - |
|
189 |
|
| - |
|
190 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
191 |
|
| - |
|
192 |
return "response";
|
| - |
|
193 |
|
| - |
|
194 |
}
|
| - |
|
195 |
|
| - |
|
196 |
@RequestMapping(value = "/submitNewSupplier", method = RequestMethod.POST)
|
| - |
|
197 |
public String getCreateNewSupplier(HttpServletRequest request, @RequestBody CreateNewSupplier createNewSupplier,
|
| 86 |
throws Exception {
|
198 |
Model model) throws Exception {
|
| - |
|
199 |
|
| - |
|
200 |
Supplier supplier = new Supplier();
|
| - |
|
201 |
|
| - |
|
202 |
supplier.setName(createNewSupplier.getName());
|
| - |
|
203 |
supplier.setCommunicationAddress(createNewSupplier.getCommunicationAddress());
|
| - |
|
204 |
supplier.setContactEmail(createNewSupplier.getContactEmail());
|
| - |
|
205 |
supplier.setContactFax(createNewSupplier.getContactFax());
|
| - |
|
206 |
supplier.setContactName(createNewSupplier.getContactPerson());
|
| - |
|
207 |
supplier.setGstin(createNewSupplier.getGst());
|
| - |
|
208 |
supplier.setHeadDesignation(createNewSupplier.getHeadDesign());
|
| - |
|
209 |
supplier.setHeadEmail(createNewSupplier.getHeadEmail());
|
| - |
|
210 |
supplier.setHeadName(createNewSupplier.getHeadName());
|
| - |
|
211 |
supplier.setPan(createNewSupplier.getPan());
|
| - |
|
212 |
supplier.setPhone(createNewSupplier.getPhone());
|
| - |
|
213 |
supplier.setPoValidityLimit(createNewSupplier.getpOValidityLimit());
|
| - |
|
214 |
supplier.setRegisteredAddress(createNewSupplier.getRegisteredAddress());
|
| - |
|
215 |
supplier.setStateId(createNewSupplier.getState());
|
| - |
|
216 |
supplierRepository.persist(supplier);
|
| - |
|
217 |
|
| - |
|
218 |
Vendor vendor = new Vendor();
|
| - |
|
219 |
vendor.setName(supplier.getName());
|
| - |
|
220 |
vendor.setId(supplier.getId());
|
| - |
|
221 |
vendorRepository.persist(vendor);
|
| - |
|
222 |
LOGGER.info("supplierId" + supplier.getId());
|
| - |
|
223 |
LOGGER.info("vendorId" + vendor.getId());
|
| - |
|
224 |
|
| - |
|
225 |
List<WarehouseAddressMapping> warehouseAddressMappings = wareHouseAddressMappingRepository
|
| - |
|
226 |
.selectAllByIds(createNewSupplier.getWarehouseId());
|
| - |
|
227 |
LOGGER.info("warehouseAddressMappings" + warehouseAddressMappings);
|
| - |
|
228 |
|
| - |
|
229 |
for (WarehouseAddressMapping wamp : warehouseAddressMappings) {
|
| - |
|
230 |
List<SellerWarehouse> sellerWarehouse = sellerWarehouseRepository
|
| - |
|
231 |
.selectBywarehouseId(wamp.getWarehouseId());
|
| - |
|
232 |
for (SellerWarehouse sw : sellerWarehouse) {
|
| - |
|
233 |
Seller seller = sellerRepository.sellerSelectById(sw.getSellerId());
|
| - |
|
234 |
|
| - |
|
235 |
WarehouseAddressMaster wam = WareHouseAddressMasterRepository.selectByAddressId(wamp.getAddressId());
|
| - |
|
236 |
|
| - |
|
237 |
// GOOD - WarehouseType.OURS, InventoryType.GOOD
|
| - |
|
238 |
warehouseService.createVendorWarehouse(WarehouseType.OURS, InventoryType.GOOD, seller.getLabel(),
|
| - |
|
239 |
wamp.getWarehouseId(), wam, vendor.getId());
|
| - |
|
240 |
|
| - |
|
241 |
// BAD - WarehouseType.OURS, InventoryType.BAD
|
| - |
|
242 |
warehouseService.createVendorWarehouse(WarehouseType.OURS, InventoryType.BAD, seller.getLabel(),
|
| - |
|
243 |
wamp.getWarehouseId(), wam, vendor.getId());
|
| - |
|
244 |
|
| - |
|
245 |
// VIRTUAL - WarehouseType.THIRD_PARTY, InventoryType.GOOD
|
| - |
|
246 |
warehouseService.createVendorWarehouse(WarehouseType.THIRD_PARTY, InventoryType.GOOD, seller.getLabel(),
|
| - |
|
247 |
wamp.getWarehouseId(), wam, 0);
|
| - |
|
248 |
|
| 87 |
|
249 |
}
|
| - |
|
250 |
|
| 88 |
|
251 |
}
|
| - |
|
252 |
|
| - |
|
253 |
return "new-supplier";
|
| - |
|
254 |
|
| - |
|
255 |
}
|
| - |
|
256 |
|
| 89 |
Supplier supplier=supplierRepository.selectById(id);
|
257 |
@RequestMapping(value = "/createTaxation", method = RequestMethod.GET)
|
| - |
|
258 |
public String showUploaderTaxation(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
259 |
|
| 90 |
|
260 |
|
| 91 |
supplier.setStatus(true);
|
- |
|
| 92 |
|
- |
|
| 93 |
|
- |
|
| 94 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
- |
|
| 95 |
|
- |
|
| 96 |
return "response";
|
261 |
return "taxation";
|
| 97 |
|
262 |
|
| 98 |
}
|
263 |
}
|
| 99 |
|
264 |
|
| 100 |
}
|
265 |
}
|