| Line 21... |
Line 21... |
| 21 |
import javax.servlet.http.HttpServletResponse;
|
21 |
import javax.servlet.http.HttpServletResponse;
|
| 22 |
|
22 |
|
| 23 |
import org.apache.commons.csv.CSVFormat;
|
23 |
import org.apache.commons.csv.CSVFormat;
|
| 24 |
import org.apache.commons.csv.CSVParser;
|
24 |
import org.apache.commons.csv.CSVParser;
|
| 25 |
import org.apache.commons.csv.CSVRecord;
|
25 |
import org.apache.commons.csv.CSVRecord;
|
| - |
|
26 |
import org.apache.commons.lang3.StringUtils;
|
| 26 |
import org.apache.logging.log4j.LogManager;
|
27 |
import org.apache.logging.log4j.LogManager;
|
| 27 |
import org.apache.logging.log4j.Logger;
|
28 |
import org.apache.logging.log4j.Logger;
|
| 28 |
import org.apache.thrift.TException;
|
29 |
import org.apache.thrift.TException;
|
| 29 |
import org.json.JSONObject;
|
30 |
import org.json.JSONObject;
|
| 30 |
import org.springframework.beans.factory.annotation.Autowired;
|
31 |
import org.springframework.beans.factory.annotation.Autowired;
|
| Line 485... |
Line 486... |
| 485 |
List<CSVRecord> masterDataList = readFile(file);
|
486 |
List<CSVRecord> masterDataList = readFile(file);
|
| 486 |
|
487 |
|
| 487 |
|
488 |
|
| 488 |
Map<String, LocalDateTime> imeisActivationMap = masterDataList.stream().collect(Collectors.toMap(
|
489 |
Map<String, LocalDateTime> imeisActivationMap = masterDataList.stream().collect(Collectors.toMap(
|
| 489 |
x->x.get(0).trim(),
|
490 |
x->x.get(0).trim(),
|
| - |
|
491 |
x-> {
|
| 490 |
x-> LocalDateTime.parse((String)(x.get(1).trim()), formatter)));
|
492 |
if(!StringUtils.isEmpty(x.get(1).trim())) {
|
| 491 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectBySerialNumbers(imeisActivationMap.keySet());
|
493 |
return LocalDateTime.parse((String)(x.get(1).trim()), formatter);
|
| 492 |
inventoryItems.stream().forEach(inventoryItem -> {
|
494 |
} else {
|
| 493 |
if (inventoryItem.getActivationTimestamp() == null) {
|
495 |
return null;
|
| 494 |
if (inventoryItem.getLastScanType().equals(com.spice.profitmandi.dao.enumuration.fofo.ScanType.SALE)
|
- |
|
| 495 |
|| inventoryItem.getGoodQuantity() + inventoryItem.getBadQuantity() == 1) {
|
- |
|
| 496 |
inventoryItem.setActivationTimestamp(imeisActivationMap.get(inventoryItem.getSerialNumber()));
|
- |
|
| 497 |
}
|
496 |
}
|
| 498 |
}
|
497 |
}));
|
| - |
|
498 |
inventoryService.addActivatedImeis(imeisActivationMap);
|
| 499 |
model.addAttribute("response", true);
|
499 |
model.addAttribute("response", true);
|
| 500 |
});
|
- |
|
| 501 |
return "response";
|
500 |
return "response";
|
| 502 |
}
|
501 |
}
|
| 503 |
|
502 |
|
| 504 |
private List<CSVRecord> readFile(MultipartFile file) throws Exception {
|
503 |
private List<CSVRecord> readFile(MultipartFile file) throws Exception {
|
| 505 |
List<CSVRecord> records = null;
|
504 |
List<CSVRecord> records = null;
|