Commit 3ec149b9 authored by đinh thị đầm's avatar đinh thị đầm
parents 065c5c6a a3114bcf
......@@ -19,7 +19,9 @@ import org.hibernate.transform.Transformers;
import org.hibernate.type.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.*;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
......@@ -27,9 +29,10 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Repository
public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
......@@ -638,7 +641,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"),\n" +
"data as (\n" +
"select a.*, rownum row_ from data_temp a\n" +
"where a.totalCusList > 0" +
"where a.totalCusCampaign > 0" +
"),\n" +
"count_data as (\n" +
"select count(*) totalRow from data_temp\n" +
......
......@@ -393,17 +393,15 @@ public class ScenarioServiceImpl implements ScenarioService {
//insert data
if (isValid) {
logger.info("----- Data valid, start import scenario question -----");
List<ScenarioQuestionDTO> lstQuestion = buildQuestionsLst(rawDataList, scenarioId, campaignId, companySiteId);
lstQuestion.forEach(question -> {
// questionService.add(question);
questionService.add(question);
});
FileOutputStream fos = new FileOutputStream(file);
workbook.write(fos);
result.put("file", file);
result.put("message", BundleUtils.getLangString("customer.importSuccess", locale));
} else {
logger.info("----- Data invalid, can't import scenario question -----");
FileOutputStream fos = new FileOutputStream(file);
workbook.write(fos);
result.put("file", file);
......
......@@ -121,20 +121,18 @@ public class ScenarioController {
Map<String, Object> map = scenarioService.readAndValidateCustomer(path, scenarioId, campaignId, userSession.getCompanySiteId());
File fileExport = (File) map.get("file");
String message = (String) map.get("message");
ResultDTO resultDTO = new ResultDTO();
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
ResultDTO resultDTO= new ResultDTO();
resultDTO.setErrorCode("00");
resultDTO.setDescription(message);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=import_scenario_result.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
resultDTO.setData(fileExport);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX);
headers.add("Message", message);
return ResponseEntity.ok()
.headers(headers)
.body(Files.readAllBytes(fileExport.toPath()));
} catch (Exception e) {
logger.error(e.getMessage());
ResultDTO resultDTO = new ResultDTO();
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment