addFilter
This commit is contained in:
parent
24b69c6024
commit
2f6515652e
@ -1,13 +1,38 @@
|
||||
package callcenter;
|
||||
|
||||
import jdk.jfr.Enabled;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
public class Callcenter2Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Callcenter2Application.class, args);
|
||||
}
|
||||
@Bean
|
||||
public CacheManager cacheManager() {
|
||||
return new ConcurrentMapCacheManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("http://localhost:4200") // Разрешенный источник
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE") // Разрешенные HTTP-методы
|
||||
.allowedHeaders("*"); // Разрешенные заголовки
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package callcenter.Repository;
|
||||
|
||||
|
||||
import callcenter.models.CallLogTypeResult;
|
||||
import callcenter.models.CallTypes;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@ -9,8 +10,9 @@ import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface CallTypesRepository extends JpaRepository<CallTypes,Integer> {
|
||||
|
||||
|
||||
|
||||
CallTypes findByName(String callTypeName);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,46 @@
|
||||
package callcenter.Repository;
|
||||
|
||||
|
||||
import callcenter.models.CallLog;
|
||||
import callcenter.models.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CalllogRepository extends JpaRepository<CallLog,Integer> {
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface CalllogRepository extends JpaRepository<CallLog,Integer> {
|
||||
|
||||
int countByCallLogTypeResult(CallLogTypeResult callLogTypeResult);
|
||||
int countByCallResult(CallResults callResult);
|
||||
int countByCallResultName(String callResultName);
|
||||
int countByCallType(CallTypes callType);
|
||||
|
||||
|
||||
//@Query("SELECT cl FROM CallLog cl WHERE cl.callResult = :callResult")
|
||||
//List<CallLog> findByScenarioAndCallResultAndEmployeeInAndTag( @Param("callResult") CallResults callResult);
|
||||
|
||||
@Query("SELECT cl FROM CallLog cl WHERE (:scenario is null or cl.scenario = :scenario) " +
|
||||
"AND (:callResult is null or cl.callResult = :callResult) " +
|
||||
"AND (:employee is null or cl.employee = :employee) " +
|
||||
"AND (:tag is null or cl.tag = :tag)")
|
||||
List<CallLog> findByScenarioAndCallResultAndEmployeeAndTag(
|
||||
@Param("scenario") Scenario scenario,
|
||||
@Param("callResult") CallResults callResult,
|
||||
@Param("employee") Employees employees,
|
||||
@Param("tag") Tags tag);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@Query("SELECT COUNT(cl) FROM CallLog cl WHERE (:scenario is null or cl.scenario = :scenario) " +
|
||||
"AND (:callResult is null or cl.callResult = :callResult) " +
|
||||
"AND (:employee is null or cl.employee = :employee) " +
|
||||
"AND (:tag is null or cl.tag = :tag)")
|
||||
int calculateFilteredCount(
|
||||
@Param("scenario") Scenario scenario,
|
||||
@Param("callResult") CallResults callResult,
|
||||
@Param("employee") Employees employees,
|
||||
@Param("tag") Tags tag
|
||||
);
|
||||
}
|
||||
|
@ -3,10 +3,15 @@ package callcenter.Repository;
|
||||
|
||||
import callcenter.models.Clients;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.Optional;
|
||||
@Repository
|
||||
public interface ClientsRepository extends JpaRepository<Clients , Integer> {
|
||||
|
||||
@Query("SELECT COUNT(c) FROM Clients c")
|
||||
int countAll();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,11 @@ import callcenter.models.Employees;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface EmpoyeesRepository extends JpaRepository<Employees, Integer> {
|
||||
Employees findByFamily(String family);
|
||||
List<Employees> findByFamilyIn(List<String> family);
|
||||
|
||||
}
|
@ -5,11 +5,13 @@ import callcenter.models.Tags;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface TagsRepository extends JpaRepository<Tags,Integer> {
|
||||
|
||||
Tags findByNameTag(String nameTag);
|
||||
|
||||
List<Tags> findByNameTagIn(List<String> tags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
package callcenter.Service;
|
||||
|
||||
|
||||
import callcenter.Repository.*;
|
||||
import callcenter.models.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CallServiceFilter {
|
||||
|
||||
private final CalllogRepository calllogRepository;
|
||||
private final ScenarioRepository scenarioRepository;
|
||||
private final EmpoyeesRepository empoyeesRepository;
|
||||
private final TagsRepository tagsRepository;
|
||||
private final CallResultsRepository callResultsRepository;
|
||||
|
||||
@Autowired
|
||||
public CallServiceFilter(CalllogRepository calllogRepository, ScenarioRepository scenarioRepository, EmpoyeesRepository empoyeesRepository, TagsRepository tagsRepository, CallResultsRepository callResultsRepository) {
|
||||
this.calllogRepository = calllogRepository;
|
||||
this.scenarioRepository = scenarioRepository;
|
||||
this.empoyeesRepository = empoyeesRepository;
|
||||
this.tagsRepository = tagsRepository;
|
||||
this.callResultsRepository = callResultsRepository;
|
||||
}
|
||||
|
||||
public List<CallLog> filterCall(
|
||||
String scenario,
|
||||
String callResult,
|
||||
String family,
|
||||
String tag
|
||||
) {
|
||||
Scenario scenarioEntity = scenario != null ? scenarioRepository.findByName(scenario) : null;
|
||||
CallResults callResultEntity = callResult != null ? callResultsRepository.findByName(callResult) : null;
|
||||
Employees employeeEntity = family != null ? empoyeesRepository.findByFamily(family) : null;
|
||||
Tags tagEntity = tag != null ? tagsRepository.findByNameTag(tag) : null;
|
||||
|
||||
List<CallLog> filteredCalls = calllogRepository.findByScenarioAndCallResultAndEmployeeAndTag(
|
||||
scenarioEntity,
|
||||
callResultEntity,
|
||||
employeeEntity,
|
||||
tagEntity
|
||||
);
|
||||
|
||||
return filteredCalls;
|
||||
}
|
||||
|
||||
public int countFilteredCalls(
|
||||
String scenario,
|
||||
String callResult,
|
||||
String family,
|
||||
String tag
|
||||
) {
|
||||
Scenario scenarioEntity = scenario != null ? scenarioRepository.findByName(scenario) : null;
|
||||
CallResults callResultEntity = callResult != null ? callResultsRepository.findByName(callResult) : null;
|
||||
Employees employeeEntity = family != null ? empoyeesRepository.findByFamily(family) : null;
|
||||
Tags tagEntity = tag != null ? tagsRepository.findByNameTag(tag) : null;
|
||||
|
||||
int count = calllogRepository.calculateFilteredCount(
|
||||
scenarioEntity,
|
||||
callResultEntity,
|
||||
employeeEntity,
|
||||
tagEntity
|
||||
);
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
@ -10,6 +10,9 @@ import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
@ -33,8 +36,10 @@ public class ReportService {
|
||||
private final CallLogTypeResultRepository callLogTypeResultRepository;
|
||||
private final ContactsPostRepository contactsPostRepository;
|
||||
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
@Autowired
|
||||
public ReportService(CalllogRepository callLogRepository, EmpoyeesRepository empoyeesRepository, CallTypesRepository callTypeRepository, ClientsRepository clientRepository, CallResultsRepository callResultRepository, ContactsRepository contactRepository, TagsRepository tagRepository, OrganizationRepository organizationRepository, ScenarioRepository scenarioRepository, CallLogTypeResultRepository callLogTypeResultRepository, ContactsPostRepository contactsPostRepository) {
|
||||
public ReportService(CalllogRepository callLogRepository, EmpoyeesRepository empoyeesRepository, CallTypesRepository callTypeRepository, ClientsRepository clientRepository, CallResultsRepository callResultRepository, ContactsRepository contactRepository, TagsRepository tagRepository, OrganizationRepository organizationRepository, ScenarioRepository scenarioRepository, CallLogTypeResultRepository callLogTypeResultRepository, ContactsPostRepository contactsPostRepository, CacheManager cacheManager) {
|
||||
this.callLogRepository = callLogRepository;
|
||||
this.empoyeesRepository = empoyeesRepository;
|
||||
this.callTypeRepository = callTypeRepository;
|
||||
@ -47,6 +52,7 @@ public class ReportService {
|
||||
this.callLogTypeResultRepository = callLogTypeResultRepository;
|
||||
|
||||
this.contactsPostRepository = contactsPostRepository;
|
||||
this.cacheManager = cacheManager;
|
||||
}
|
||||
|
||||
public void processReport(File reportFile) {
|
||||
@ -83,7 +89,7 @@ public class ReportService {
|
||||
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
|
||||
// Извлечение данных из каждой ячейки и создайте объекты моделей
|
||||
// Извлечение данных из каждой ячейки и омделей
|
||||
|
||||
// CallLog
|
||||
CallLog callLog = new CallLog();
|
||||
@ -107,12 +113,12 @@ public class ReportService {
|
||||
Cell callId = row.getCell(20);
|
||||
if (callId != null) {
|
||||
if (callId.getCellType() == CellType.NUMERIC) {
|
||||
callLog.setIdzapisi((int) callId.getNumericCellValue());
|
||||
callLog.setCall_record_id((int) callId.getNumericCellValue());
|
||||
} else {
|
||||
callLog.setIdzapisi(null);
|
||||
callLog.setCall_record_id(null);
|
||||
}
|
||||
} else {
|
||||
callLog.setIdzapisi(null);
|
||||
callLog.setCall_record_id(null);
|
||||
}
|
||||
|
||||
callLogRepository.save(callLog);
|
||||
@ -394,10 +400,98 @@ public class ReportService {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// @CacheEvict("reportData" )
|
||||
public void clearReportDataCache() {
|
||||
cacheManager.getCache("reportData").clear();
|
||||
}
|
||||
|
||||
// @Cacheable("reportData")
|
||||
public List<CallLog> getReportData(){
|
||||
System.out.println("Getting report data");
|
||||
return callLogRepository.findAll();
|
||||
}
|
||||
|
||||
// клиентов
|
||||
// справочники
|
||||
// статистика контактов
|
||||
|
||||
// @Cacheable("clientsData")
|
||||
public List<Clients> getClietntsData(){return clientRepository.findAll();}
|
||||
|
||||
// @Cacheable("callLogTypeResult")
|
||||
public List<CallLogTypeResult> getCallLogTypeResult(){
|
||||
return callLogTypeResultRepository.findAll();
|
||||
}
|
||||
|
||||
// @Cacheable("callResults")
|
||||
public List<CallResults> getCallResults(){
|
||||
return callResultRepository.findAll();
|
||||
}
|
||||
|
||||
// @Cacheable("callTypes")
|
||||
public List<CallTypes> getCallTypes(){
|
||||
return callTypeRepository.findAll();
|
||||
}
|
||||
|
||||
// @Cacheable("employees")
|
||||
public List<Employees> getEmployees(){
|
||||
return empoyeesRepository.findAll();
|
||||
}
|
||||
|
||||
// @Cacheable("scenario")
|
||||
public List<Scenario> getScenario(){
|
||||
return scenarioRepository.findAll();
|
||||
}
|
||||
|
||||
// @Cacheable("tags")
|
||||
public List<Tags> getTags(){
|
||||
return tagRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
// количество клиентов
|
||||
public int countTotalClients() {
|
||||
return clientRepository.countAll();
|
||||
}
|
||||
|
||||
// количество = по проекту
|
||||
public int countProject() {
|
||||
CallTypes callType = callTypeRepository.findByName("По проекту");
|
||||
return callLogRepository.countByCallType(callType);
|
||||
}
|
||||
|
||||
|
||||
// количество успешных звонков
|
||||
public int countSuccessTypeResult(){
|
||||
CallLogTypeResult successTypeResult = callLogTypeResultRepository.findByNametyperesult("Успешные");
|
||||
|
||||
if (successTypeResult != null) {
|
||||
return callLogRepository.countByCallLogTypeResult(successTypeResult);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// лид передан
|
||||
public int countLead() {
|
||||
CallResults callResult = callResultRepository.findByName("ЛИД Передан");
|
||||
return callLogRepository.countByCallResult(callResult);
|
||||
}
|
||||
|
||||
// дозвонились (не системные)
|
||||
public Map<String, Integer> countGotThrough() {
|
||||
Map<String, Integer> countMap = new HashMap<>();
|
||||
countMap.put("ЛИД Передан", callLogRepository.countByCallResultName("ЛИД Передан"));
|
||||
countMap.put("Отказ", callLogRepository.countByCallResultName("Отказ"));
|
||||
countMap.put("Перезвон", callLogRepository.countByCallResultName("Перезвон"));
|
||||
|
||||
int totalCount = countMap.values().stream().mapToInt(Integer::intValue).sum();
|
||||
countMap.put("Общее количество", totalCount);
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,48 @@
|
||||
package callcenter.controllers;
|
||||
|
||||
|
||||
import callcenter.Service.CallServiceFilter;
|
||||
import callcenter.models.CallLog;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/reports")
|
||||
public class FilterController {
|
||||
|
||||
private final CallServiceFilter callServiceFilter;
|
||||
|
||||
@Autowired
|
||||
public FilterController(CallServiceFilter callServiceFilter) {
|
||||
this.callServiceFilter = callServiceFilter;
|
||||
}
|
||||
|
||||
@GetMapping("/filter")
|
||||
public ResponseEntity<List<CallLog>> getFilteredCalls(
|
||||
@RequestParam(value = "scenario", required = false) String scenario,
|
||||
@RequestParam(value = "callResult", required = false) String callResult,
|
||||
@RequestParam(value = "family", required = false) String family,
|
||||
@RequestParam(value = "tag", required = false) String tag
|
||||
) {
|
||||
List<CallLog> filteredCalls = callServiceFilter.filterCall(scenario, callResult, family, tag);
|
||||
return ResponseEntity.ok(filteredCalls);
|
||||
}
|
||||
|
||||
@GetMapping("/count")
|
||||
public ResponseEntity<Integer> countFilteredCalls(
|
||||
@RequestParam(value = "scenario", required = false) String scenario,
|
||||
@RequestParam(value = "callResult", required = false) String callResult,
|
||||
@RequestParam(value = "family", required = false) String family,
|
||||
@RequestParam(value = "tag", required = false) String tag
|
||||
) {
|
||||
int count = callServiceFilter.countFilteredCalls(scenario, callResult, family, tag);
|
||||
return ResponseEntity.ok(count);
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package callcenter.controllers;
|
||||
|
||||
import callcenter.Service.CallServiceFilter;
|
||||
import callcenter.Service.ReportService;
|
||||
import callcenter.models.CallLog;
|
||||
import callcenter.models.*;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -12,14 +14,15 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/reports")
|
||||
public class ReportController {
|
||||
@RequestMapping("/reports")
|
||||
public class ReportController {
|
||||
|
||||
private final ReportService reportService;
|
||||
private final ReportService reportService;
|
||||
|
||||
@Autowired
|
||||
@Autowired
|
||||
public ReportController(ReportService reportService){
|
||||
this.reportService = reportService;
|
||||
}
|
||||
@ -48,9 +51,12 @@ public class ReportController {
|
||||
// Выполнение запроса к базе данных для получения данных отчета
|
||||
List<CallLog> reportData = reportService.getReportData();
|
||||
|
||||
// Создание объекта JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(reportData);
|
||||
|
||||
reportService.clearReportDataCache(); // очищяем кэш
|
||||
|
||||
// Возвращаем успешный ответ с данными отчета в виде json- файла
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type", "application/json")
|
||||
@ -64,5 +70,225 @@ public class ReportController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/clients")
|
||||
public ResponseEntity<?> getClients() {
|
||||
try {
|
||||
// Выполнение запроса к базе данных для получения данных отчета
|
||||
List<Clients> clientsData = reportService.getClietntsData();
|
||||
|
||||
// Создание объекта JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(clientsData);
|
||||
|
||||
// Возвращаем успешный ответ с данными отчета в виде json- файла
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type", "application/json")
|
||||
.body(jsonData);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("{\"error\": \"Произошла ошибка при получении данных отчета.\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/callLogTypeResult")
|
||||
public ResponseEntity<?> getCallLogTypeResult() {
|
||||
try {
|
||||
// Выполнение запроса к базе данных для получения данных отчета
|
||||
List<CallLogTypeResult> callLogTypeResultResultsData = reportService.getCallLogTypeResult();
|
||||
|
||||
// Создание объекта JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(callLogTypeResultResultsData);
|
||||
|
||||
// Возвращаем успешный ответ с данными отчета в виде json- файла
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type", "application/json")
|
||||
.body(jsonData);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("{\"error\": \"Произошла ошибка при получении данных отчета.\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/callResults")
|
||||
public ResponseEntity<?> getCallResult() {
|
||||
try {
|
||||
// Выполнение запроса к базе данных для получения данных отчета
|
||||
List<CallResults> callResultsData = reportService.getCallResults();
|
||||
|
||||
// Создание объекта JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(callResultsData);
|
||||
|
||||
// Возвращаем успешный ответ с данными отчета в виде json- файла
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type", "application/json")
|
||||
.body(jsonData);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("{\"error\": \"Произошла ошибка при получении данных отчета.\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/callTypes")
|
||||
public ResponseEntity<?> getCallTypes() {
|
||||
try {
|
||||
// Выполнение запроса к базе данных для получения данных отчета
|
||||
List<CallTypes> callTypessData = reportService.getCallTypes();
|
||||
|
||||
// Создание объекта JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(callTypessData);
|
||||
|
||||
// Возвращаем успешный ответ с данными отчета в виде json- файла
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type", "application/json")
|
||||
.body(jsonData);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("{\"error\": \"Произошла ошибка при получении данных отчета.\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/employees")
|
||||
public ResponseEntity<?> getEmployees() {
|
||||
try {
|
||||
// Выполнение запроса к базе данных для получения данных отчета
|
||||
List<Employees> employees = reportService.getEmployees();
|
||||
|
||||
// Создание объекта JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(employees);
|
||||
|
||||
// Возвращаем успешный ответ с данными отчета в виде json- файла
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type", "application/json")
|
||||
.body(jsonData);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("{\"error\": \"Произошла ошибка при получении данных отчета.\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/scenario")
|
||||
public ResponseEntity<?> getScenario() {
|
||||
try {
|
||||
// Выполнение запроса к базе данных для получения данных отчета
|
||||
List<Scenario> scenarios = reportService.getScenario();
|
||||
|
||||
// Создание объекта JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(scenarios);
|
||||
|
||||
// Возвращаем успешный ответ с данными отчета в виде json- файла
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type", "application/json")
|
||||
.body(jsonData);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("{\"error\": \"Произошла ошибка при получении данных отчета.\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/tags")
|
||||
public ResponseEntity<?> getTags() {
|
||||
try {
|
||||
// Выполнение запроса к базе данных для получения данных отчета
|
||||
List<Tags> tags = reportService.getTags();
|
||||
|
||||
// Создание объекта JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(tags);
|
||||
|
||||
// Возвращаем успешный ответ с данными отчета в виде json- файла
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type", "application/json")
|
||||
.body(jsonData);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("{\"error\": \"Произошла ошибка при получении данных отчета.\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/totalContactsCount") // количество всех клиентов
|
||||
public ResponseEntity<Integer> getTotalContactsCount() {
|
||||
try {
|
||||
int totalContactsCount = reportService.countTotalClients();
|
||||
|
||||
// Возвращаем успешный ответ
|
||||
return ResponseEntity.ok(totalContactsCount);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/successTypeResult") // успешные вызовы
|
||||
public ResponseEntity<Integer> getSuccessfulCallsCount() {
|
||||
try {
|
||||
int successCallResult = reportService.countSuccessTypeResult();
|
||||
|
||||
// Возвращаем успешный ответ
|
||||
return ResponseEntity.ok(successCallResult);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/leadPassedCount") // передано лиду
|
||||
public ResponseEntity<Integer> getLeadPassedCount() {
|
||||
try {
|
||||
int leadPassedCount = reportService.countLead();
|
||||
// Возвращаем успешный ответ
|
||||
return ResponseEntity.ok(leadPassedCount);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Возвращаем ответ с ошибкой
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getCountByCallResults") // общее количество прозвоненых клинтов (не системные)
|
||||
public ResponseEntity<Integer> getCountByCallResults() {
|
||||
Map<String, Integer> countMap = reportService.countGotThrough();
|
||||
int totalCount = countMap.get("Общее количество");
|
||||
return ResponseEntity.ok(totalCount);
|
||||
}
|
||||
|
||||
@GetMapping("/countProject") // по проекту
|
||||
public int getCountProject() {
|
||||
return reportService.countProject();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class Tags {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int tag_id;
|
||||
|
||||
// @Column(unique = true)
|
||||
@Column(unique = true)
|
||||
private String nameTag;
|
||||
|
||||
}
|
||||
|
@ -4,4 +4,6 @@ spring.datasource.username= bronnikovalexandr
|
||||
spring.datasource.password= 84937
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.cache.type=caffeine
|
||||
logging.level.org.springframework.cache=DEBUG
|
||||
server.port=8081
|
Loading…
Reference in New Issue
Block a user