| Line 38... |
Line 38... |
| 38 |
import org.apache.commons.csv.CSVParser;
|
38 |
import org.apache.commons.csv.CSVParser;
|
| 39 |
import org.apache.commons.csv.CSVRecord;
|
39 |
import org.apache.commons.csv.CSVRecord;
|
| 40 |
import org.apache.commons.lang3.StringUtils;
|
40 |
import org.apache.commons.lang3.StringUtils;
|
| 41 |
import org.apache.logging.log4j.LogManager;
|
41 |
import org.apache.logging.log4j.LogManager;
|
| 42 |
import org.apache.logging.log4j.Logger;
|
42 |
import org.apache.logging.log4j.Logger;
|
| - |
|
43 |
import org.apache.poi.xssf.usermodel.XSSFRow;
|
| - |
|
44 |
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
| - |
|
45 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| 43 |
import org.json.JSONArray;
|
46 |
import org.json.JSONArray;
|
| 44 |
import org.json.JSONObject;
|
47 |
import org.json.JSONObject;
|
| 45 |
import org.springframework.beans.factory.annotation.Autowired;
|
48 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
49 |
import org.springframework.http.HttpHeaders;
|
| - |
|
50 |
import org.springframework.http.HttpStatus;
|
| - |
|
51 |
import org.springframework.http.MediaType;
|
| 46 |
import org.springframework.http.ResponseEntity;
|
52 |
import org.springframework.http.ResponseEntity;
|
| 47 |
import org.springframework.stereotype.Controller;
|
53 |
import org.springframework.stereotype.Controller;
|
| 48 |
import org.springframework.transaction.annotation.Transactional;
|
54 |
import org.springframework.transaction.annotation.Transactional;
|
| 49 |
import org.springframework.ui.Model;
|
55 |
import org.springframework.ui.Model;
|
| 50 |
import org.springframework.web.bind.annotation.*;
|
56 |
import org.springframework.web.bind.annotation.*;
|
| Line 162... |
Line 168... |
| 162 |
itemLoaderService.parse(file);
|
168 |
itemLoaderService.parse(file);
|
| 163 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
169 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 164 |
return "response";
|
170 |
return "response";
|
| 165 |
}
|
171 |
}
|
| 166 |
|
172 |
|
| - |
|
173 |
// column order must match ItemLoaderService.createLoaderModel
|
| - |
|
174 |
private static final List<String> CATALOG_TEMPLATE_HEADERS = Arrays.asList("Product Group",
|
| - |
|
175 |
"Category Id As per System", "Category", "HSNCode(Ensure that hsncode exists)", "Brand", "Model Number",
|
| - |
|
176 |
"Model Name", "Color", "MRP", "SP", "MOP", "DP", "TP", "NLC", "Startdate", "Preferred Vendor", "Risky",
|
| - |
|
177 |
"Weight in Kg", "Item type(1 for Serialized and 2 for non-serialized)", "TaxRate",
|
| - |
|
178 |
"Brand Identifier (OEM model/SKU code - mandatory for smartphones of flagged brands)");
|
| - |
|
179 |
|
| - |
|
180 |
@GetMapping(value = "/catalog/template.xlsx")
|
| - |
|
181 |
public ResponseEntity<byte[]> downloadCatalogTemplate() throws Exception {
|
| - |
|
182 |
try (XSSFWorkbook workbook = new XSSFWorkbook(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
| - |
|
183 |
XSSFSheet sheet = workbook.createSheet("items");
|
| - |
|
184 |
XSSFRow headerRow = sheet.createRow(0);
|
| - |
|
185 |
for (int i = 0; i < CATALOG_TEMPLATE_HEADERS.size(); i++) {
|
| - |
|
186 |
headerRow.createCell(i).setCellValue(CATALOG_TEMPLATE_HEADERS.get(i));
|
| - |
|
187 |
sheet.setColumnWidth(i, Math.min(CATALOG_TEMPLATE_HEADERS.get(i).length() + 2, 60) * 256);
|
| - |
|
188 |
}
|
| - |
|
189 |
sheet.createFreezePane(0, 1);
|
| - |
|
190 |
workbook.write(baos);
|
| - |
|
191 |
HttpHeaders headers = new HttpHeaders();
|
| - |
|
192 |
headers.setContentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
|
| - |
|
193 |
headers.setContentDispositionFormData("catalog-template.xlsx", "catalog-template.xlsx");
|
| - |
|
194 |
return new ResponseEntity<>(baos.toByteArray(), headers, HttpStatus.OK);
|
| - |
|
195 |
}
|
| - |
|
196 |
}
|
| - |
|
197 |
|
| 167 |
@Autowired
|
198 |
@Autowired
|
| 168 |
CategorySpecDerivationService categorySpecDerivationService;
|
199 |
CategorySpecDerivationService categorySpecDerivationService;
|
| 169 |
|
200 |
|
| 170 |
// one-time backfill trigger; safe to re-run (skips docs that already have specs)
|
201 |
// one-time backfill trigger; safe to re-run (skips docs that already have specs)
|
| 171 |
@PostMapping(value = "/content/specs/derive")
|
202 |
@PostMapping(value = "/content/specs/derive")
|