562 changed files with 86122 additions and 365 deletions
-
BIN.DS_Store
-
BINbin/.DS_Store
-
BINbin/target/.DS_Store
-
BINgccoffice_uploads/.DS_Store
-
BINgccoffice_uploads/app_uploads/.DS_Store
-
BINgccoffice_uploads/com_petition/.DS_Store
-
BINgccoffice_uploads/com_petition/com_action_file/.DS_Store
-
BINgccoffice_uploads/m_petition/.DS_Store
-
BINgccoffice_uploads/m_petition/m_action_file/.DS_Store
-
BINgccoffice_uploads/zh_petition/.DS_Store
-
BINgccoffice_uploads/zh_petition/zh_action_file/.DS_Store
-
25pom.xml
-
BINsrc/.DS_Store
-
BINsrc/main/.DS_Store
-
BINsrc/main/java/.DS_Store
-
BINsrc/main/java/in/.DS_Store
-
BINsrc/main/java/in/gov/.DS_Store
-
BINsrc/main/java/in/gov/chennaicorporation/.DS_Store
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/.DS_Store
-
33src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/service/Petition.java
-
107src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/AgentAssignAPIController.java
-
181src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/AgentsAPIController.java
-
36src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/AttendanceAPIController.java
-
247src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/CampaignAPIController.java
-
128src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/CategoryAPIController.java
-
204src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/MainController.java
-
26src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/WhatsappController.java
-
99src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/AddcategoryServices.java
-
97src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/AgentAssignService.java
-
349src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/AgentsService.java
-
116src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/AttendanceService.java
-
272src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/CampaignService.java
-
40src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/WhatsappMsgService.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/.DS_Store
-
242src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/ComplaintController.java
-
77src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/FollowUpController.java
-
90src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/InprogresscallController.java
-
474src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/MainController.java
-
82src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/PublicFollowUpController.java
-
291src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAPIController.java
-
160src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAdminSettingsController.java
-
235src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAgentAssignAPIController.java
-
161src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAgentsAPIController.java
-
408src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcCallsController.java
-
68src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcTaskListAPIController.java
-
346src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/SocialMediaController.java
-
80src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/StatusCountController.java
-
27src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/WhatsappController.java
-
67src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/ComplaintService.java
-
172src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/FollowUpService.java
-
102src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/InprogresscallService.java
-
52src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/PublicFollowUpService.java
-
105src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAdminSettingService.java
-
590src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAgentAssignService.java
-
563src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAgentsService.java
-
391src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcCallsService.java
-
126src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcService.java
-
292src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcTaskListService.java
-
103src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/SocialMediaService.java
-
239src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/StatusCountService.java
-
48src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/WhatsappqaqcMsgService.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/.DS_Store
-
111src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/controller/ApiController.java
-
142src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/controller/MainController.java
-
29src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/controller/WhatsappControllerCD.java
-
33src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/service/RegistrationService.java
-
41src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/service/WhatsappMsgService.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/com_petition/.DS_Store
-
160src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/controller/APIController.java
-
130src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/controller/MainController.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/controller/package-info.java
-
21src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/data/ComplaintType.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/data/package-info.java
-
7src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/package-info.java
-
719src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/service/Petition.java
-
58src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/service/PetitionMaster.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/service/package-info.java
-
10src/main/java/in/gov/chennaicorporation/gccoffice/configuration/AppConfig.java
-
101src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java
-
50src/main/java/in/gov/chennaicorporation/gccoffice/controller/APIController.java
-
34src/main/java/in/gov/chennaicorporation/gccoffice/controller/DateTimeUtil.java
-
2src/main/java/in/gov/chennaicorporation/gccoffice/controller/MenuController.java
-
17src/main/java/in/gov/chennaicorporation/gccoffice/m_petition/controller/APIController.java
-
378src/main/java/in/gov/chennaicorporation/gccoffice/m_petition/service/Petition.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/nulm/.DS_Store
-
722src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmAPIController.java
-
207src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmController.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/package-info.java
-
279src/main/java/in/gov/chennaicorporation/gccoffice/nulm/repository/NulmRepository.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/nulm/repository/package-info.java
-
1771src/main/java/in/gov/chennaicorporation/gccoffice/nulm/service/NulmService.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/nulm/service/package-info.java
-
17src/main/java/in/gov/chennaicorporation/gccoffice/pgr/service/DataSyncService.java
-
5src/main/java/in/gov/chennaicorporation/gccoffice/service/Base64Util.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/service/CustomUserDetailsService.java
-
79src/main/java/in/gov/chennaicorporation/gccoffice/service/GetMappingUserDetails.java
-
131src/main/java/in/gov/chennaicorporation/gccoffice/service/LoginUserInfo.java
-
64src/main/java/in/gov/chennaicorporation/gccoffice/sos/controller/APIController.java
-
44src/main/java/in/gov/chennaicorporation/gccoffice/sos/controller/SOSController.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/sos/controller/package-info.java
@ -0,0 +1,107 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentAssignService; |
|||
|
|||
|
|||
@RequestMapping("/gcc/api/callcenter/admin") |
|||
@RestController("callcentercontroller") |
|||
public class AgentAssignAPIController |
|||
{ |
|||
private AgentAssignService campaignmaster; |
|||
|
|||
@Autowired |
|||
public AgentAssignAPIController(AgentAssignService campaignmaster) { |
|||
this.campaignmaster = campaignmaster; |
|||
} |
|||
|
|||
@GetMapping("/getcategory") |
|||
public List<Map<String, Object>> getcategory() |
|||
{ |
|||
return campaignmaster.getcategory(); |
|||
} |
|||
|
|||
@GetMapping("/getcampaignbycategory") |
|||
public List<Map<String, Object>> getcampaignbycategory(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.getcampaignbycategory(id); |
|||
} |
|||
|
|||
@GetMapping("/getcampaignbyid") |
|||
public List<Map<String, Object>> getcampaignbyid(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.getcampaignbyid(id); |
|||
} |
|||
|
|||
@GetMapping("/getagentsfortask") |
|||
public List<Map<String, Object>> getagentsfortask(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.getagentsfortask(id); |
|||
} |
|||
|
|||
@PostMapping("/addagentsfortask") |
|||
public ResponseEntity<List<Map<String, Object>>> addagentsfortask(@RequestBody List<Map<String, Object>> requestList) { |
|||
System.out.println("Received POST request with data: " + requestList); |
|||
|
|||
List<Map<String, Object>> insertedAgents = new ArrayList<>(); // To store successfully inserted agents |
|||
|
|||
try { |
|||
for (Map<String, Object> request : requestList) { |
|||
int agentId = (int) request.get("agentId"); |
|||
int categoryId = (int) request.get("categoryId"); |
|||
int campaignId = (int) request.get("campaignId"); |
|||
|
|||
// Call the service method to insert the agent details |
|||
int rowsAffected = campaignmaster.addagentsfortask(agentId, categoryId, campaignId); |
|||
|
|||
if (rowsAffected > 0) { |
|||
// If the insert was successful, add the agent data to the response list |
|||
Map<String, Object> insertedAgent = new HashMap<>(); |
|||
insertedAgent.put("categoryId", categoryId); |
|||
insertedAgent.put("campaignId", campaignId); |
|||
insertedAgent.put("agentId", agentId); |
|||
|
|||
insertedAgents.add(insertedAgent); // Add the successfully inserted agent to the list |
|||
} else { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.singletonList(Collections.singletonMap("error", "Failed to add agent for campaignId: " + campaignId))); |
|||
} |
|||
} |
|||
|
|||
// Return the list of successfully inserted agents |
|||
return ResponseEntity.status(HttpStatus.CREATED).body(insertedAgents); |
|||
|
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) |
|||
.body(Collections.singletonList(Collections.singletonMap("error", "Invalid request data: " + e.getMessage()))); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getassignedcampaign") |
|||
public List<Map<String, Object>> checkcampaigninassignedtable(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.checkcampaigninassignedtable(id); |
|||
} |
|||
|
|||
@GetMapping("/deleteassignedbyid") |
|||
public int editagentsfortask(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.editagentsfortask(id); |
|||
} |
|||
} |
|||
@ -0,0 +1,181 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.servlet.http.HttpSession; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentsService; |
|||
|
|||
@RequestMapping("/gcc/api/agents") |
|||
@RestController |
|||
public class AgentsAPIController { |
|||
|
|||
@Autowired |
|||
private AgentsService agentsService; |
|||
|
|||
@GetMapping("/excel") |
|||
public List<Map<String, Object>> fetchDataFromExcel(@RequestParam int categoryId,@RequestParam Long campaignId) { |
|||
try { |
|||
return agentsService.fetchDataFromExcel(categoryId,campaignId); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return null; // Handle the exception as needed |
|||
} |
|||
} |
|||
|
|||
|
|||
@PostMapping("/saveExcelData") |
|||
public String saveExcelData( @RequestParam int categoryId,@RequestParam Long campaignId,@RequestParam String filePath) { |
|||
|
|||
try { |
|||
// Fetch data from Excel |
|||
List<Map<String, Object>> excelData = agentsService.getExcelData(categoryId,campaignId, filePath); |
|||
// Save data into the database |
|||
agentsService.saveExcelData(excelData); |
|||
return "Data saved successfully"; |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save data"; |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getdataByIds") |
|||
public List<Map<String, Object>> getdataByIds(@RequestParam List<Integer> ids) { |
|||
return agentsService.getdataByIds(ids); |
|||
} |
|||
|
|||
@GetMapping("/getPendingDataByIds") |
|||
public List<Map<String, Object>> getPendingDataByIds(@RequestParam List<Integer> ids) { |
|||
return agentsService.getPendingDataByIds(ids); |
|||
} |
|||
|
|||
@PostMapping("/savecall") |
|||
public ResponseEntity<String> savecall(@RequestBody Map<String, Object> callData) { |
|||
String call_status = (String) callData.get("call_status"); |
|||
String remarks = (String) callData.get("remarks"); |
|||
int data_id = (int) callData.get("data_id"); |
|||
int agent_id=(int) callData.get("agent_id"); |
|||
int campaign_id=(int) callData.get("campaign_id"); |
|||
|
|||
// Add a debug statement to check the received values |
|||
System.out.println("Received call_status: " + call_status); |
|||
|
|||
if (call_status == null || call_status.isEmpty()) { |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Call status is required."); |
|||
} |
|||
|
|||
agentsService.saveCallLogs(call_status, remarks,data_id); |
|||
|
|||
agentsService.saveInLogsTable(campaign_id, agent_id, data_id,call_status,remarks); |
|||
|
|||
return ResponseEntity.ok("Data Inserted successfully."); |
|||
} |
|||
|
|||
// @PostMapping("/updatecall") |
|||
// public ResponseEntity<String> updatecall(@RequestBody Map<String, Object> callData) |
|||
// { |
|||
// String call_status = (String) callData.get("call_status"); |
|||
// int data_id = (int) callData.get("data_id"); |
|||
// int agent_id=(int) callData.get("agent_id"); |
|||
// int campaign_id=(int) callData.get("campaign_id"); |
|||
// |
|||
// if (call_status == null || call_status.isEmpty()) { |
|||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Call status is required."); |
|||
// } |
|||
// |
|||
// agentsService.saveInLogsTable(campaign_id, agent_id, data_id,call_status); |
|||
// |
|||
// return ResponseEntity.ok("Data Inserted successfully."); |
|||
// } |
|||
|
|||
@GetMapping("/getAgentNames") |
|||
public List<Map<String, Object>> getAgentsNameById(@RequestParam List<Integer> agentIds){ |
|||
return agentsService.getAgentsNameById(agentIds); |
|||
} |
|||
|
|||
@GetMapping("/getDataFields") |
|||
public List<Map<String, Object>> getDataDetailsById( |
|||
@RequestParam String originalDataIds) throws JsonProcessingException { |
|||
|
|||
// Parse originalDataIds from JSON string |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
List<List<Integer>> originalDataIdsList = objectMapper.readValue(originalDataIds, new TypeReference<List<List<Integer>>>() {}); |
|||
|
|||
// Prepare a list to hold the results for each sub-array |
|||
List<Map<String, Object>> groupedResults = new ArrayList<>(); |
|||
|
|||
// Iterate through each sub-array of originalDataIds |
|||
for (List<Integer> dataIds : originalDataIdsList) { |
|||
List<Map<String, Object>> results = agentsService.getDataDetailsById(dataIds); |
|||
// Group results according to your business logic |
|||
Map<String, Object> combinedResult = new HashMap<>(); |
|||
for (Map<String, Object> result : results) { |
|||
combinedResult.putAll(result); |
|||
} |
|||
groupedResults.add(combinedResult); |
|||
} |
|||
|
|||
return groupedResults; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getCompletedDataFields") |
|||
public Map<String, Object> getCompletedDataDetailsById( |
|||
@RequestParam String originalCDataIds) throws JsonProcessingException { |
|||
|
|||
// Parse originalDataIds from JSON string |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
List<Integer> originalCDataIdsList = objectMapper.readValue(originalCDataIds, new TypeReference<List<Integer>>() {}); |
|||
|
|||
// Prepare a list to hold the results for each sub-array |
|||
//List<Map<String, Object>> groupedCompletedResults = new ArrayList<>(); |
|||
List<Integer> completedDataIds = new ArrayList<>(); // List to hold data_ids with Complete_count > 0 |
|||
|
|||
// Iterate through each sub-array of originalDataIds |
|||
|
|||
List<Map<String, Object>> results = agentsService.getCompletedDataDetailsById(originalCDataIdsList); |
|||
// Group results according to your business logic |
|||
//Map<String, Object> CompletedcombinedResult = new HashMap<>(); |
|||
for (Map<String, Object> result : results) { |
|||
|
|||
if (result.get("Complete_count") != null && ((Number) result.get("Complete_count")).intValue() > 0) { |
|||
completedDataIds.add((Integer) result.get("data_id")); |
|||
} |
|||
//groupedCompletedResults.add(result); |
|||
} |
|||
|
|||
|
|||
|
|||
// Prepare the final response containing grouped results and completed dataIds |
|||
Map<String, Object> response = new HashMap<>(); |
|||
//response.put("groupedCompletedResults", groupedCompletedResults); |
|||
response.put("completedDataIds", completedDataIds); |
|||
return response; |
|||
} |
|||
|
|||
@GetMapping("/getCompletedDataById") |
|||
public List<Map<String, Object>> getCompletedDataById(@RequestParam List<Integer> completedDataIds){ |
|||
return agentsService.getCompletedDataById(completedDataIds); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
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 org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("/gcc/api/attendance") |
|||
@RestController |
|||
public class AttendanceAPIController { |
|||
|
|||
private AppConfig appConfig; |
|||
private final RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
public AttendanceAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getAttendancedetails") |
|||
public String getAttendancedetails(@RequestParam String fromDate,@RequestParam String toDate){ |
|||
String apiUrl = appConfig.attendanceReport + "/callcenter/api/attendance/getattendancereport"+"?fromDate="+ fromDate + "&toDate="+ toDate; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,247 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import org.apache.poi.ss.usermodel.*; |
|||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|||
|
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.*; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.*; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.CampaignService; |
|||
|
|||
@RestController("callcenterapicontroller") |
|||
@RequestMapping("gcc/api/campaign") |
|||
public class CampaignAPIController { |
|||
|
|||
@Autowired |
|||
private CampaignService campaignService; |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
@GetMapping("/getCampaignDetails") |
|||
public ResponseEntity<Map<String, Object>> getCampaignDetails() { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
List<Map<String, Object>> data = campaignService.getCampaignDetails(); |
|||
|
|||
response.put("data", data); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
|
|||
// Endpoint to get campaign details by ID |
|||
@GetMapping("/getCampaignDetailsbyId") |
|||
public Map<String, Object> getCampaignDetailsById(@RequestParam("campaign_id") Long campaignId) { |
|||
return campaignService.getCampaignDetailsById(campaignId); |
|||
} |
|||
|
|||
@PostMapping("/updateCampaign") |
|||
public ResponseEntity<String> updateCampaign(@RequestParam Long campaign_id, |
|||
@RequestParam String campaign_name, |
|||
@RequestParam String start_date, |
|||
@RequestParam String end_date, |
|||
@RequestParam Integer no_of_agents, |
|||
@RequestParam Integer calls_per_agent, |
|||
@RequestParam String description) { |
|||
if (campaign_id == null) { |
|||
return ResponseEntity.badRequest().body("Campaign ID is required."); |
|||
} |
|||
|
|||
try { |
|||
campaignService.updateCampaign(campaign_id, campaign_name, start_date, end_date, no_of_agents, calls_per_agent, description); |
|||
return ResponseEntity.ok("Campaign updated successfully."); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error updating campaign."); |
|||
} |
|||
} |
|||
|
|||
|
|||
@PostMapping("/save") |
|||
public Map<String, String> saveCampaignDetails( |
|||
@RequestParam("name") String campaignName, |
|||
@RequestParam("category") String categoryId, |
|||
@RequestParam("eventstartdate") String startDate, |
|||
@RequestParam("eventenddate") String endDate, |
|||
@RequestParam("no_of_agent") int noOfAgents, |
|||
@RequestParam("no_of_calls") int callsPerAgent, |
|||
@RequestParam("description") String description, |
|||
@RequestParam("file") MultipartFile file) { |
|||
|
|||
// Creating a Map to store the form data with DB field names |
|||
Map<String, Object> campaignDetails = new HashMap<>(); |
|||
campaignDetails.put("campaign_name", campaignName); |
|||
campaignDetails.put("category_id", categoryId); |
|||
campaignDetails.put("start_date", startDate); |
|||
campaignDetails.put("end_date", endDate); |
|||
campaignDetails.put("no_of_agents", noOfAgents); |
|||
campaignDetails.put("calls_per_agent", callsPerAgent); |
|||
campaignDetails.put("description", description); |
|||
|
|||
try { |
|||
// Handle file upload |
|||
String fileUrl = saveFile(file); |
|||
campaignDetails.put("excel_url", fileUrl); |
|||
|
|||
// Read data from the uploaded Excel file |
|||
List<Map<String, Object>> excelData = readExcelData(file.getInputStream()); |
|||
|
|||
// Log the campaign details and Excel data to the console |
|||
System.out.println("Campaign Details: " + campaignDetails); // Print campaign details |
|||
System.out.println("Excel Data: " + excelData); // Print Excel data |
|||
|
|||
// Optionally, you can process the excelData here or save it to the database |
|||
|
|||
// Save campaign details |
|||
campaignService.saveCampaignDetails(campaignDetails); |
|||
|
|||
// Returning success response |
|||
Map<String, String> response = new HashMap<>(); |
|||
response.put("status", "success"); |
|||
response.put("message", "Campaign details saved successfully"); |
|||
response.put("category_id", categoryId); // Include the category_id in the response |
|||
return response; |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
Map<String, String> response = new HashMap<>(); |
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to save campaign details"); |
|||
|
|||
return response; |
|||
} |
|||
} |
|||
//save file and get path |
|||
private String saveFile(MultipartFile file) throws IOException { |
|||
|
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
|
|||
String folderName = environment.getProperty("campaign.foldername"); |
|||
|
|||
String fileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) + "_" + file.getOriginalFilename(); |
|||
|
|||
String folderPath = uploadDirectory + "/" + folderName + "/excel/"; |
|||
|
|||
|
|||
Path dirPath = Paths.get(folderPath); |
|||
if (!Files.exists(dirPath)) { |
|||
Files.createDirectories(dirPath); |
|||
} |
|||
|
|||
Path filePath = dirPath.resolve(fileName); |
|||
|
|||
Files.write(filePath, file.getBytes()); |
|||
|
|||
return filePath.toAbsolutePath().toString(); |
|||
} |
|||
|
|||
|
|||
|
|||
//Read excel data method |
|||
private List<Map<String, Object>> readExcelData(InputStream inputStream) throws IOException { |
|||
List<Map<String, Object>> dataList = new ArrayList<>(); |
|||
|
|||
try (Workbook workbook = new XSSFWorkbook(inputStream)) { |
|||
Sheet sheet = workbook.getSheetAt(0); // Get the first sheet |
|||
FormulaEvaluator formulaEvaluator = workbook.getCreationHelper().createFormulaEvaluator(); |
|||
|
|||
for (Row row : sheet) { |
|||
Map<String, Object> dataMap = new HashMap<>(); |
|||
for (Cell cell : row) { |
|||
String cellValue = ""; |
|||
switch (formulaEvaluator.evaluateInCell(cell).getCellType()) { |
|||
case STRING: |
|||
cellValue = cell.getStringCellValue(); |
|||
break; |
|||
case NUMERIC: |
|||
if (DateUtil.isCellDateFormatted(cell)) { |
|||
cellValue = new SimpleDateFormat("yyyy-MM-dd").format(cell.getDateCellValue()); |
|||
} else { |
|||
cellValue = String.valueOf(cell.getNumericCellValue()); |
|||
} |
|||
break; |
|||
case BOOLEAN: |
|||
cellValue = String.valueOf(cell.getBooleanCellValue()); |
|||
break; |
|||
default: |
|||
cellValue = "Unknown"; |
|||
break; |
|||
} |
|||
dataMap.put("column" + cell.getColumnIndex(), cellValue); |
|||
} |
|||
if (!dataMap.isEmpty()) { |
|||
dataList.add(dataMap); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return dataList; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getExcelData") |
|||
public ResponseEntity<List<Map<String, Object>>> getExcelData(@RequestParam("filePath") String filePath) { |
|||
try { |
|||
// Read data from the uploaded Excel file |
|||
List<Map<String, Object>> excelData = readExcelData(new FileInputStream(filePath)); |
|||
|
|||
// Return data as JSON |
|||
return ResponseEntity.ok(excelData); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); |
|||
} |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getlastCampaignid") |
|||
public List<Map<String, Object>> getLastRow() |
|||
{ |
|||
return campaignService.getLastRow(); |
|||
} |
|||
|
|||
@GetMapping("/startcampaign") |
|||
public List<Map<String, Object>> getDataforAgents(@RequestParam int campaign_id,@RequestParam int calls_per_agent) |
|||
{ |
|||
return campaignService.getDataforAgents(campaign_id, calls_per_agent); |
|||
} |
|||
|
|||
@GetMapping("/viewcampaignstatus") |
|||
public List<Map<String, Object>> viewcampaignstatus(@RequestParam int campaign_id) |
|||
{ |
|||
return campaignService.viewcampaignstatus(campaign_id); |
|||
} |
|||
|
|||
@GetMapping("/viewcompletedby") |
|||
public List<Map<String, Object>> viewcompletedby(@RequestParam int campaign_id,@RequestParam int agent_id) |
|||
{ |
|||
return campaignService.viewcompletedby(campaign_id,agent_id); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,128 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AddcategoryServices; |
|||
|
|||
|
|||
@RequestMapping("/gcc/api/category") |
|||
@RestController |
|||
public class CategoryAPIController { |
|||
|
|||
@Autowired |
|||
private AddcategoryServices addCategoryServices; // Injecting the service |
|||
|
|||
|
|||
// Endpoint to save category details |
|||
@PostMapping("/save") |
|||
public ResponseEntity<String> saveCategoryDetails(@RequestBody Map<String, Object> payload) { |
|||
try { |
|||
addCategoryServices.saveCategoryDetails(payload); // Call the service method to save category details |
|||
return ResponseEntity.ok("Category details saved successfully."); |
|||
} catch (IllegalArgumentException e) { |
|||
return ResponseEntity.badRequest().body("Error: " + e.getMessage()); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body("Error saving category details: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
// Endpoint to get all categories |
|||
@GetMapping("/list") |
|||
public List<Map<String, Object>> getAllCategories() { |
|||
return addCategoryServices.getAllCategories(); |
|||
} |
|||
|
|||
// Endpoint to get a category by its ID |
|||
@GetMapping("/showcategoryId") |
|||
public ResponseEntity<?> showCategoryId(@RequestParam("category_id") int categoryId) { |
|||
try { |
|||
Map<String, Object> category = addCategoryServices.showCategory(categoryId); |
|||
if (category != null && !category.isEmpty()) { |
|||
return ResponseEntity.ok(category); |
|||
} else { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Category not found"); |
|||
} |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Error retrieving category: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
@PutMapping("/update/{categoryId}") |
|||
public ResponseEntity<String> updateCategory( |
|||
@PathVariable("categoryId") int categoryId, |
|||
@RequestParam String categoryName) { |
|||
|
|||
// Validate input |
|||
if (categoryName == null || categoryName.trim().isEmpty()) { |
|||
return ResponseEntity.badRequest().body("Category name cannot be empty"); |
|||
} |
|||
|
|||
try { |
|||
// Call the service method to update the category |
|||
int rowsAffected = addCategoryServices.updateCategory(categoryId, categoryName); |
|||
if (rowsAffected > 0) { |
|||
return ResponseEntity.ok("Category updated successfully"); |
|||
} else { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Category not found or update failed"); |
|||
} |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Error updating category: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
// Endpoint to delete a category by its ID |
|||
@DeleteMapping("/delete/{categoryId}") |
|||
public ResponseEntity<String> deleteCategory( |
|||
@PathVariable("categoryId") int categoryId) { |
|||
|
|||
try { |
|||
// Call the service method to delete the category |
|||
addCategoryServices.deleteCategory(categoryId); |
|||
return ResponseEntity.ok("Category deleted successfully"); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Error deleting category: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
//hari category api populate |
|||
|
|||
@GetMapping("/getcategory") |
|||
public List<Map<String, Object>> getcategory() |
|||
{ |
|||
return addCategoryServices.getcategory(); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getcampaignbycategory") |
|||
public List<Map<String, Object>> getcampaignbycategory(@RequestParam int id) |
|||
{ |
|||
return addCategoryServices.getcampaignbycategory(id); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,204 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.servlet.http.HttpSession; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AddcategoryServices; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AttendanceService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentAssignService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.CampaignService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
|
|||
@RequestMapping("/gcc/callcenter") |
|||
@Controller("callCenterCampaignMainController") |
|||
public class MainController { |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
private AgentAssignService campaignmaster; |
|||
|
|||
@Autowired |
|||
private CampaignService campaignService; |
|||
|
|||
@Autowired |
|||
private AddcategoryServices addCategoryServices; |
|||
|
|||
@Autowired |
|||
private AgentsService agentsService; |
|||
|
|||
@Autowired |
|||
private AttendanceService attendanceSerivce; |
|||
|
|||
private AppConfig appConfig; |
|||
private RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
public MainController(AgentAssignService campaignmaster,AgentsService agentsService,CampaignService campaignService,AddcategoryServices addCategoryServices,RestTemplate restTemplate, AppConfig appConfig) |
|||
{ |
|||
this.campaignmaster=campaignmaster; |
|||
this.campaignService=campaignService; |
|||
this.addCategoryServices=addCategoryServices; |
|||
this.agentsService=agentsService; |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
|
|||
} |
|||
|
|||
|
|||
@GetMapping("/admin/addcategory") |
|||
|
|||
public String addcategory(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> categories = addCategoryServices.getAllCategories(); |
|||
|
|||
System.out.println(categories); |
|||
|
|||
model.addAttribute("categories", categories); |
|||
|
|||
return "modules/callcenter/addcategory"; |
|||
|
|||
} |
|||
|
|||
@GetMapping("/admin/createcampaign") |
|||
|
|||
public String createcampaign(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> campaigns = campaignService.getCampaignDetails(); |
|||
|
|||
|
|||
System.out.println("campaignlist:"+campaigns); |
|||
|
|||
model.addAttribute("campaigns", campaigns); |
|||
|
|||
return "modules/callcenter/createcampaign"; // Name of the Thymeleaf template (e.g., campaignList.html) |
|||
|
|||
} |
|||
|
|||
@GetMapping("/admin/campaignlist") |
|||
public String viewCampaignList(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> campaigns = campaignService.getDetailsForStart(); |
|||
|
|||
model.addAttribute("campaigns", campaigns); |
|||
|
|||
List<Map<String, Object>> activeCampaigns =campaignService.getActiveCampaigns(); |
|||
model.addAttribute("activeCampaigns", activeCampaigns); |
|||
|
|||
return "modules/callcenter/campaignlist"; |
|||
} |
|||
|
|||
@GetMapping("/admin/assignagents") |
|||
public String viewAssignAgents(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/callcenter/assignagents"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/agentscampaign") |
|||
public String targetPage(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> agentsCampaigns=agentsService.getAgentsALLCampaigns(userId); |
|||
model.addAttribute("agentsCampaigns", agentsCampaigns); |
|||
|
|||
return "modules/callcenter/agentscampaign"; |
|||
} |
|||
|
|||
@GetMapping("/attendancereport") |
|||
public String AttendanceList( |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate, |
|||
Model model) { |
|||
List<Map<String, Object>> attendanceData = Collections.emptyList(); |
|||
|
|||
if (fromDate != null && !fromDate.isEmpty() && toDate != null && !toDate.isEmpty()) { |
|||
String apiUrl = appConfig.attendanceReport + "/callcenter/api/attendance/getattendancereport?fromDate=" + fromDate + "&toDate=" + toDate; |
|||
|
|||
try { |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
if (responseBody.trim().startsWith("{")) { |
|||
// Single object response |
|||
Map<String, Object> singleData = objectMapper.readValue(responseBody, new TypeReference<>() {}); |
|||
attendanceData = List.of(singleData); |
|||
} else { |
|||
// Array response |
|||
attendanceData = objectMapper.readValue(responseBody, new TypeReference<>() {}); |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching attendance data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
model.addAttribute("attendanceData", attendanceData); |
|||
model.addAttribute("fromDate", fromDate); |
|||
model.addAttribute("toDate", toDate); |
|||
model.addAttribute("LoginUserId", LoginUserInfo.getLoginUserId()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenter/attendancereport"; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.WhatsappMsgService; |
|||
|
|||
@RestController |
|||
@RequestMapping("/gcc/api/whatsapp") |
|||
public class WhatsappController { |
|||
|
|||
@Autowired |
|||
private WhatsappMsgService whatsappMsgService; |
|||
|
|||
@PostMapping("/send-whatsapp-message") |
|||
public ResponseEntity<String> sendWhatsAppMessage(@RequestParam String msgUrl) { |
|||
String response = whatsappMsgService.sendMsg(msgUrl); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,99 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.sql.ResultSet; |
|||
import java.sql.SQLException; |
|||
import java.util.List; |
|||
import java.util.Locale.Category; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class AddcategoryServices { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
public void saveCategoryDetails(Map<String, Object> categoryData) { |
|||
String sql = "INSERT INTO category (category_name, isactive, isdelete, created_date) VALUES (?, 1, 0, CURRENT_TIMESTAMP)"; |
|||
|
|||
// Ensure that the key "categoryname" matches exactly what is being sent from the frontend |
|||
String categoryName = (String) categoryData.get("categoryname"); |
|||
|
|||
// Check if categoryName is null or empty and handle it properly |
|||
if (categoryName == null || categoryName.trim().isEmpty()) { |
|||
throw new IllegalArgumentException("Category name cannot be null or empty"); |
|||
} |
|||
|
|||
jdbcTemplate.update(sql, categoryName); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAllCategories() { |
|||
|
|||
String SqlQuery = "SELECT category_id,category_name FROM category;"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
return result; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
// Method to show a category by its ID |
|||
public Map<String, Object> showCategory(int categoryId) { |
|||
String sql = "SELECT category_id, category_name FROM category WHERE category_id = ?"; |
|||
return jdbcTemplate.queryForMap(sql, categoryId); |
|||
} |
|||
|
|||
|
|||
// Method to update a category's name by its ID |
|||
public int updateCategory(int categoryId, String categoryName) { |
|||
String sql = "UPDATE category SET category_name = ? WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
return jdbcTemplate.update(sql, categoryName, categoryId); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
// Method to delete a category by its name |
|||
public void deleteCategory(int categoryId) { |
|||
String sql = "DELETE FROM category WHERE category_id = ?"; |
|||
jdbcTemplate.update(sql, categoryId); |
|||
} |
|||
|
|||
|
|||
//hari populate category services |
|||
@Transactional |
|||
|
|||
public List<Map<String, Object>> getcategory() { |
|||
|
|||
String sqlQuery = "SELECT category_id,category_name FROM category where isactive='1' and isdelete='0'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
|
|||
public List<Map<String, Object>> getcampaignbycategory(int id) { |
|||
|
|||
String sqlQuery = "SELECT cr.campaign_id,cr.campaign_name FROM campaign_request cr JOIN category c ON cr.category_id=c.category_id where cr.category_id=? and cr.isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,97 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
|
|||
@Service |
|||
public class AgentAssignService |
|||
{ |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource2(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate2; |
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getcategory() { |
|||
String sqlQuery = "SELECT category_id,category_name FROM gcc_1913_campaign.category where isactive='1' and isdelete='0'"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getcampaignbycategory(int id) { |
|||
String sqlQuery = "SELECT cr.campaign_id, cr.campaign_name " + |
|||
"FROM gcc_1913_campaign.campaign_request cr " + |
|||
"JOIN gcc_1913_campaign.category c ON cr.category_id = c.category_id " + |
|||
"WHERE cr.category_id = ? " + |
|||
"AND cr.isactive = '1' "; |
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getcampaignbyid(int id) { |
|||
String sqlQuery = "SELECT * FROM gcc_1913_campaign.campaign_request where isactive='1' and campaign_id=?"; |
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getagentsfortask(int id) { |
|||
String sqlQuery = "SELECT al.agent_id,al.agent_name\r\n" |
|||
+ "FROM gcc_1913_qaqc.agents_list al\r\n" |
|||
+ "LEFT JOIN gcc_1913_campaign.agent_assign aa ON al.agent_id = aa.agent_id AND aa.isactive = '1' AND aa.campaign_id = ?\r\n" |
|||
+ "WHERE aa.agent_id IS NULL AND al.calling_type='OUTBOUND'AND al.isactive='1' AND al.isdelete='0'"; |
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int addagentsfortask(int agent_id, int category_id, int campaign_id) { |
|||
String insertSql = "INSERT INTO gcc_1913_campaign.agent_assign (agent_id, category_id, campaign_id) VALUES (?, ?, ?)"; |
|||
int rowsInserted = jdbcTemplate.update(insertSql, agent_id, category_id, campaign_id); |
|||
|
|||
return rowsInserted; |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> checkcampaigninassignedtable(int id) |
|||
{ |
|||
String sqlQuery = "SELECT al.agent_id,al.agent_name,aa.assigned_id\r\n" |
|||
+ "FROM gcc_1913_qaqc.agents_list al\r\n" |
|||
+ "JOIN gcc_1913_campaign.agent_assign aa ON al.agent_id = aa.agent_id\r\n" |
|||
+ "JOIN gcc_1913_campaign.campaign_request c ON aa.campaign_id=c.campaign_id\r\n" |
|||
+ "WHERE aa.campaign_id = ? AND aa.isactive = '1' AND al.calling_type='OUTBOUND'AND al.isactive='1' AND al.isdelete='0'"; |
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
} |
|||
|
|||
@Transactional |
|||
public int editagentsfortask(int assigned_id) { |
|||
String updateSql = "UPDATE gcc_1913_campaign.agent_assign SET isactive='0', isdelete='1',status='NOT_ASSIGNED' WHERE assigned_id=?"; |
|||
int rowsInserted = jdbcTemplate.update(updateSql,assigned_id); |
|||
|
|||
return rowsInserted; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,349 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.apache.poi.ss.usermodel.Cell; |
|||
import org.apache.poi.ss.usermodel.DateUtil; |
|||
import org.apache.poi.ss.usermodel.Row; |
|||
import org.apache.poi.ss.usermodel.Sheet; |
|||
import org.apache.poi.ss.usermodel.Workbook; |
|||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class AgentsService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource2(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate2; |
|||
|
|||
|
|||
// Utility method to get cell value based on type |
|||
private String getCellValue(Cell cell) { |
|||
if (cell == null) { |
|||
return ""; |
|||
} |
|||
switch (cell.getCellType()) { |
|||
case STRING: |
|||
return cell.getStringCellValue(); |
|||
case NUMERIC: |
|||
// Check if the numeric cell contains a date |
|||
if (DateUtil.isCellDateFormatted(cell)) { |
|||
return new SimpleDateFormat("yyyy-MM-dd").format(cell.getDateCellValue()); |
|||
} |
|||
return String.valueOf((long) cell.getNumericCellValue()); // Cast to long to avoid scientific notation |
|||
case BOOLEAN: |
|||
return String.valueOf(cell.getBooleanCellValue()); |
|||
case FORMULA: |
|||
return cell.getCellFormula(); |
|||
default: |
|||
return ""; |
|||
} |
|||
} |
|||
|
|||
// Parse integer values (for ID) |
|||
private Integer parseInteger(String value) { |
|||
try { |
|||
return Integer.parseInt(value); |
|||
} catch (NumberFormatException e) { |
|||
return null; // return null if parsing fails |
|||
} |
|||
} |
|||
|
|||
// Parse long values (for Mobile number) |
|||
private Long parseLong(String value) { |
|||
try { |
|||
return Long.parseLong(value); |
|||
} catch (NumberFormatException e) { |
|||
return null; // return null if parsing fails |
|||
} |
|||
} |
|||
|
|||
// Example fetch method |
|||
public List<Map<String, Object>> fetchDataFromExcel(int categoryId,Long campaignId) throws IOException { |
|||
String excelUrl = getExcelUrlByCampaignId(campaignId); |
|||
List<Map<String, Object>>data=getExcelData(categoryId,campaignId, excelUrl); |
|||
return saveExcelData(data); |
|||
} |
|||
|
|||
public String getExcelUrlByCampaignId(Long campaignId) { |
|||
String sql = "SELECT excel_url\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request\r\n" |
|||
+ "WHERE campaign_id = ?"; |
|||
return jdbcTemplate.queryForObject(sql, String.class, campaignId); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getExcelData(int categoryId,Long campaignId,String filePath) throws IOException { |
|||
List<Map<String, Object>> data = new ArrayList<>(); |
|||
File file = new File(filePath); |
|||
|
|||
try (FileInputStream fis = new FileInputStream(file); |
|||
Workbook workbook = new XSSFWorkbook(fis)) { |
|||
|
|||
Sheet sheet = workbook.getSheetAt(0); |
|||
for (Row row : sheet) { |
|||
if (row.getRowNum() == 0) continue; // skip header row |
|||
|
|||
Map<String, Object> rowData = new HashMap<>(); |
|||
|
|||
// Add the campaign_id and category_id to each row |
|||
|
|||
rowData.put("category_id", categoryId); |
|||
|
|||
rowData.put("campaign_id", campaignId); |
|||
|
|||
// Convert ID to Integer |
|||
rowData.put("ID", getCellValue(row.getCell(0))); |
|||
|
|||
// Name remains String |
|||
rowData.put("Name", getCellValue(row.getCell(1))); |
|||
|
|||
// Address remains String |
|||
rowData.put("Address", getCellValue(row.getCell(2))); |
|||
|
|||
// Dues remains String (you can convert if necessary) |
|||
rowData.put("Balance amount", parseLong(getCellValue(row.getCell(3)))); |
|||
|
|||
// Convert Mobile number to Long |
|||
rowData.put("Mobile number", parseLong(getCellValue(row.getCell(4)))); |
|||
|
|||
rowData.put("Tiny url", getCellValue(row.getCell(5))); |
|||
|
|||
data.add(rowData); |
|||
} |
|||
} |
|||
return data; |
|||
} |
|||
|
|||
public List<Map<String, Object>> saveExcelData(List<Map<String, Object>> data) { |
|||
|
|||
// Prepare SQL query for inserting the specified columns |
|||
String sql = "INSERT INTO gcc_1913_campaign.upload_data (category_id, campaign_id, field_1, field_2, field_3, field_4, field_5,field_6) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?,?)"; |
|||
|
|||
// Loop through the data list and insert each row into the database |
|||
for (Map<String, Object> row : data) { |
|||
jdbcTemplate.update(sql, |
|||
row.get("category_id"), // Category ID |
|||
row.get("campaign_id"), // Campaign ID |
|||
row.get("ID"), // ID (String) |
|||
row.get("Name"), // Name (String) |
|||
row.get("Address"), // Address (String) |
|||
row.get("Balance amount"), // Dues if any (String) |
|||
row.get("Mobile number"), // Mobile number (Long) |
|||
row.get("Tiny url") |
|||
); |
|||
} |
|||
|
|||
// Return the inserted data (if needed) |
|||
return data; // Optionally return the inserted data or change the return type as per your use case |
|||
} |
|||
|
|||
|
|||
|
|||
//For Assigned tasks |
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsALLCampaigns(int agent_id) { |
|||
String SqlQuery = "SELECT \r\n" |
|||
+ " c.category_name,\r\n" |
|||
+ " cr.campaign_name,\r\n" |
|||
+ " cr.calls_per_agent,\r\n" |
|||
+ " aa.campaign_id,\r\n" |
|||
+ " aa.agent_id,\r\n" |
|||
+ " (SELECT COUNT(data_id) \r\n" |
|||
+ " FROM gcc_1913_campaign.upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.campaign_id = cr.campaign_id\r\n" |
|||
+ " ) AS calls_assigned,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.field_14 IS NULL THEN 1 END) \r\n" |
|||
+ " FROM gcc_1913_campaign.upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.campaign_id = cr.campaign_id\r\n" |
|||
+ " ) AS pending_count,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.field_14 IS NOT NULL THEN 1 END) \r\n" |
|||
+ " FROM gcc_1913_campaign.upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.campaign_id = cr.campaign_id\r\n" |
|||
+ " ) AS complete_count,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.field_14 ='CALL_BACK_LATER' OR up.field_14 = 'UNATTENDED' THEN 1 END) \r\n" |
|||
+ " FROM gcc_1913_campaign.upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.campaign_id = cr.campaign_id\r\n" |
|||
+ " ) AS followup_count\r\n" |
|||
+ " \r\n" |
|||
+ "FROM \r\n" |
|||
+ " gcc_1913_campaign.agent_assign aa\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " gcc_1913_qaqc.agents_list al ON aa.agent_id = al.agent_id\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " gcc_1913_campaign.campaign_request cr ON cr.campaign_id = aa.campaign_id\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " gcc_1913_campaign.category c ON cr.category_id = c.category_id\r\n" |
|||
+ "WHERE \r\n" |
|||
+ " aa.agent_id = ? \r\n" |
|||
+ " AND aa.isactive = '1'\r\n" |
|||
+ " AND cr.isactive = '0'"; |
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery,agent_id); |
|||
} |
|||
|
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getdataByIds(List<Integer> ids) { |
|||
// Construct the SQL query with placeholders for the number of IDs |
|||
String inSql = String.join(",", Collections.nCopies(ids.size(), "?")); |
|||
String SqlQuery = "SELECT data_id, field_1 as id, field_2 as name, field_3 as address, field_4 as dues, field_5 as cellnumber,field_6 as viewdetails,field_14 as call_status,field_15 as remarks " + |
|||
"FROM gcc_1913_campaign.upload_data " + |
|||
"WHERE data_id IN (" + inSql + ")"; |
|||
|
|||
// Convert the list of ids to an Object array |
|||
return jdbcTemplate.queryForList(SqlQuery, ids.toArray()); |
|||
} |
|||
|
|||
@Transactional |
|||
public void saveCallLogs(String call_status,String remarks ,int data_id) |
|||
{ |
|||
String SqlQuery = "UPDATE gcc_1913_campaign.upload_data SET field_14 = ?,field_15=?, updated_date = NOW() WHERE (data_id = ? )"; |
|||
|
|||
jdbcTemplate.update(SqlQuery,call_status, remarks,data_id); |
|||
} |
|||
|
|||
@Transactional |
|||
public int saveInLogsTable(int campaignId, int agentId, int dataId, String call_status,String remarks) { |
|||
String sqlQuery = "INSERT INTO gcc_1913_campaign.call_logs (campaign_id,agent_id,data_id,call_status,remarks) VALUES (?, ?, ?,?,?)"; |
|||
int rowsAffected = 0; |
|||
try { |
|||
rowsAffected = jdbcTemplate.update(sqlQuery, campaignId, agentId, dataId,call_status,remarks); |
|||
System.out.println("Inserted into call_logs successfully. Rows affected: " + rowsAffected); |
|||
} catch (Exception e) { |
|||
System.err.println("Error inserting into call_logs: " + e.getMessage()); |
|||
// Log the exception or rethrow it based on your error-handling strategy |
|||
} |
|||
return rowsAffected; |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getPendingDataByIds(List<Integer> ids) { |
|||
// Construct the SQL query with placeholders for the number of IDs |
|||
String inSql = String.join(",", Collections.nCopies(ids.size(), "?")); |
|||
String SqlQuery = "SELECT data_id, field_1 as id, field_2 as name, field_3 as address, field_4 as dues, field_5 as cellnumber,field_6 as viewdetails,field_14 as call_status,field_15 as remarks " + |
|||
"FROM gcc_1913_campaign.upload_data " + |
|||
"WHERE data_id IN (" + inSql + ") " + |
|||
"AND field_14 IN ('UNATTENDED', 'CALL_BACK_LATER')"; |
|||
|
|||
// Convert the list of ids to an Object array |
|||
return jdbcTemplate.queryForList(SqlQuery, ids.toArray()); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsNameById(List<Integer> agentIds) |
|||
{ |
|||
String inSql = String.join(",", Collections.nCopies(agentIds.size(), "?")); |
|||
String SqlQuery ="select agent_name,agent_id from gcc_1913_qaqc.agents_list where agent_id IN (" + inSql + ")"; |
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery, agentIds.toArray()); |
|||
|
|||
} |
|||
//agents performance |
|||
@Transactional |
|||
public List<Map<String, Object>> getDataDetailsById(List<Integer> dataIds) |
|||
{ |
|||
if (dataIds.isEmpty()) { |
|||
// Handle the case where dataIds is empty to avoid SQL syntax error. |
|||
throw new IllegalArgumentException("The dataIds list is empty, cannot execute query."); |
|||
} |
|||
|
|||
String inSql = String.join(",", Collections.nCopies(dataIds.size(), "?")); |
|||
String SqlQuery ="SELECT\r\n" |
|||
+ " COUNT(*) AS Assigned_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 IS NOT NULL THEN 1 END) AS Complete_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 IS NULL THEN 1 END) AS Pending_count ,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'INFORMATION_GIVEN' THEN 1 END) AS Information_Given_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'UNATTENDED' THEN 1 END) AS Unattended_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'CALL_BACK_LATER' THEN 1 END) AS Call_back_later_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'SWITCH_OFF' THEN 1 END) AS Switch_off_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'WRONG_NUMBER' THEN 1 END) AS Wrong_number_count,\r\n" |
|||
+ " CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN field_14 IS NOT NULL THEN 1 END) * 100.0 / COUNT(*)), 0)END AS Percentage\r\n" |
|||
+ "FROM gcc_1913_campaign.upload_data\r\n" |
|||
+ "WHERE data_id IN (" + inSql + ")"; |
|||
|
|||
|
|||
|
|||
List<Map<String, Object>> results = jdbcTemplate.queryForList(SqlQuery, dataIds.toArray()); |
|||
return results; |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getCompletedDataDetailsById(List<Integer> CdataIds) |
|||
{ |
|||
if (CdataIds.isEmpty()) { |
|||
// Handle the case where dataIds is empty to avoid SQL syntax error. |
|||
throw new IllegalArgumentException("The CdataIds list is empty, cannot execute query."); |
|||
} |
|||
|
|||
String inSql = String.join(",", Collections.nCopies(CdataIds.size(), "?")); |
|||
String SqlQuery ="SELECT\r\n" |
|||
+ " data_id,\r\n" // Add data_id to the result |
|||
+ " COUNT(*) AS Assigned_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 IS NOT NULL THEN 1 END) AS Complete_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 IS NULL THEN 1 END) AS Pending_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'INFORMATION_GIVEN' THEN 1 END) AS Information_Given_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'UNATTENDED' THEN 1 END) AS Unattended_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'CALL_BACK_LATER' THEN 1 END) AS Call_back_later_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'SWITCH_OFF' THEN 1 END) AS Switch_off_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'WRONG_NUMBER' THEN 1 END) AS Wrong_number_count,\r\n" |
|||
+ " CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN field_14 IS NOT NULL THEN 1 END) * 100.0 / COUNT(*)), 0) END AS Percentage\r\n" |
|||
+ "FROM gcc_1913_campaign.upload_data\r\n" |
|||
+ "WHERE data_id IN (" + inSql + ")\r\n" |
|||
+ "GROUP BY data_id"; // Group by data_id |
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery, CdataIds.toArray()); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String,Object>> getCompletedDataById(List<Integer> completedDataIds) |
|||
{ |
|||
if (completedDataIds.isEmpty()) { |
|||
// Handle the case where dataIds is empty to avoid SQL syntax error. |
|||
throw new IllegalArgumentException("The completedDataIds list is empty, cannot execute query."); |
|||
} |
|||
|
|||
String inSql = String.join(",", Collections.nCopies(completedDataIds.size(), "?")); |
|||
String SqlQuery = "SELECT field_1 as id, field_2 as name, field_3 as address, " + |
|||
"field_5 as cellnumber, field_14 as call_status, updated_date as updated_date,field_15 as remarks, " + |
|||
"(SELECT COUNT(data_id) FROM call_logs WHERE data_id = upload_data.data_id) as call_count " + |
|||
"FROM gcc_1913_campaign.upload_data " + |
|||
"WHERE data_id IN (" + inSql + ")"; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery, completedDataIds.toArray()); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,116 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class AttendanceService { |
|||
|
|||
|
|||
// private JdbcTemplate jdbcTemplate; |
|||
// |
|||
// |
|||
// @Autowired |
|||
// public void setDataSource(@Qualifier("BiometricDataSource") DataSource dataSource) { |
|||
// this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
// } |
|||
// |
|||
// |
|||
// public List<Map<String, Object>> getAttendanceReport(String fromDate, String toDate) { |
|||
// String reportQuery; |
|||
// |
|||
// if (fromDate != null && toDate != null) { |
|||
// // Query with date filter if dates are provided |
|||
// reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " + |
|||
// "c.device_name, CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " + |
|||
// "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " + |
|||
// "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " + |
|||
// "tblemployee e, tbldepartment f " + |
|||
// "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " + |
|||
// "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode " + |
|||
// "AND CAST(a.officepunch AS DATE) BETWEEN ? AND ? " + |
|||
// "AND a.paycode LIKE '%19130%' " + |
|||
// "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " + |
|||
// "c.device_name, CAST(a.officepunch AS DATE) " + |
|||
// "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)"; |
|||
// |
|||
// // Execute query with date parameters |
|||
// return jdbcTemplate.queryForList(reportQuery, fromDate, toDate); |
|||
// |
|||
// } else { |
|||
// // Query without date filter |
|||
// reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " + |
|||
// "c.device_name, CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " + |
|||
// "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " + |
|||
// "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " + |
|||
// "tblemployee e, tbldepartment f " + |
|||
// "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " + |
|||
// "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode " + |
|||
// "AND a.paycode LIKE '%19130%' " + |
|||
// "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " + |
|||
// "c.device_name, CAST(a.officepunch AS DATE) " + |
|||
// "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)"; |
|||
// |
|||
// // Execute query without date parameters |
|||
// return jdbcTemplate.queryForList(reportQuery); |
|||
// } |
|||
// } |
|||
// |
|||
// |
|||
// |
|||
//// public List<Map<String, Object>> getAttendanceReport(String fromDate, String toDate) { |
|||
//// System.out.println("Service Layer: Generating attendance report"); |
|||
//// |
|||
//// String reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, c.device_name, " + |
|||
//// "CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " + |
|||
//// "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " + |
|||
//// "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " + |
|||
//// "tblemployee e, tbldepartment f " + |
|||
//// "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " + |
|||
//// "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode "; |
|||
//// |
|||
//// // Dynamic date filter |
|||
//// if (fromDate != null && toDate != null) { |
|||
//// reportQuery += "AND CAST(a.officepunch AS DATE) BETWEEN ? AND ? "; |
|||
//// } else if (fromDate != null) { |
|||
//// reportQuery += "AND CAST(a.officepunch AS DATE) = ? "; |
|||
//// } else { |
|||
//// throw new IllegalArgumentException("fromDate or toDate must be provided"); |
|||
//// } |
|||
//// |
|||
//// reportQuery += "AND a.paycode LIKE '%19130%' " + |
|||
//// "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, c.device_name, " + |
|||
//// "CAST(a.officepunch AS DATE) " + |
|||
//// "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)"; |
|||
//// |
|||
//// // Execute query based on dates |
|||
//// if (fromDate != null && toDate != null) { |
|||
//// return jdbcTemplate.queryForList(reportQuery, fromDate, toDate); |
|||
//// } else { |
|||
//// return jdbcTemplate.queryForList(reportQuery, fromDate); |
|||
//// } |
|||
//// } |
|||
// |
|||
//// public List<Map<String, Object>> getAttendanceReport() { |
|||
//// System.out.println("check 2"); |
|||
//// String reportQuery ="SELECT d.zone,d.division,b.user_id,b.user_name,f.departmentname,e.designation,c.device_name,CAST(a.officepunch AS DATE) as punch_date,MIN(a.OFFICEPUNCH) AS PUNCHIN,\r\n" |
|||
//// + "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT FROM machinerawpunch a,tbl_realtime_userinfo b,tbl_fkdevice_status c,\r\n" |
|||
//// + "zone_div_mast d,tblemployee e,tbldepartment f WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname AND a.paycode = e.paycode AND \r\n" |
|||
//// + "e.departmentcode = f.departmentcode AND CAST(officepunch AS DATE) BETWEEN '2024-10-01' AND '2024-10-10'\r\n" |
|||
//// + "AND a.paycode LIKE '%19130%' \r\n" |
|||
//// + "GROUP BY d.zone,d.division,b.user_id,b.user_name,f.departmentname,e.designation,c.device_name,CAST(a.officepunch AS DATE)\r\n" |
|||
//// + "ORDER BY d.zone,d.division,b.user_id,CAST(a.officepunch AS DATE)"; |
|||
//// System.out.println("check 3"); |
|||
//// List<Map<String,Object>> reports = jdbcTemplate.queryForList(reportQuery); |
|||
//// System.out.println("check 4"); |
|||
//// return reports; |
|||
//// } |
|||
|
|||
} |
|||
@ -0,0 +1,272 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.sql.Date; |
|||
import java.sql.PreparedStatement; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
@Service |
|||
public class CampaignService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSourcemysql(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource2(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate2; |
|||
|
|||
|
|||
//Method to save file and return its URL |
|||
public String saveFile(MultipartFile file) { |
|||
String fileName = file.getOriginalFilename(); |
|||
String filePath = "/uploads/" + fileName; // Path to save the file |
|||
try { |
|||
File destinationFile = new File(filePath); |
|||
file.transferTo(destinationFile); // Save the file locally |
|||
} catch (IOException e) { |
|||
throw new RuntimeException("Failed to store file " + fileName, e); |
|||
} |
|||
return filePath; // Return the file path (URL) for saving to the database |
|||
} |
|||
|
|||
// Method to save campaign details into the database |
|||
public void saveCampaignDetails(Map<String, Object> campaignDetails) { |
|||
String sql = "INSERT INTO gcc_1913_campaign.campaign_request (campaign_name, category_id, start_date, end_date, no_of_agents, calls_per_agent, description, excel_url) " + |
|||
"VALUES (:campaign_name, :category_id, :start_date, :end_date, :no_of_agents, :calls_per_agent, :description, :excel_url)"; |
|||
|
|||
// Using NamedParameterJdbcTemplate for mapping campaignDetails into query |
|||
NamedParameterJdbcTemplate namedJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate); |
|||
namedJdbcTemplate.update(sql, campaignDetails); |
|||
} |
|||
|
|||
|
|||
|
|||
public Map<String, Object> getCampaignDetailsById(Long campaign_id) { |
|||
String sql = "SELECT * FROM gcc_1913_campaign.campaign_request WHERE campaign_id = ?"; |
|||
return jdbcTemplate.queryForMap(sql, campaign_id); |
|||
} |
|||
|
|||
public void updateCampaign(Long campaign_id, String campaign_name, String start_date, String end_date, Integer no_of_agents, Integer calls_per_agent, String description) { |
|||
String sql = "UPDATE gcc_1913_campaign.campaign_request SET campaign_name = ?, start_date = ?, end_date = ?, no_of_agents = ?, calls_per_agent = ?, description = ? WHERE campaign_id = ?"; |
|||
jdbcTemplate.update(sql, campaign_name, start_date, end_date, no_of_agents, calls_per_agent, description, campaign_id); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getCampaignDetails() { |
|||
String sql = "SELECT campaign_id, " + |
|||
" campaign_name, " + |
|||
" CONCAT(" + |
|||
" DATE_FORMAT(start_date, '%d/%m/%Y'), " + |
|||
" ' to ', " + |
|||
" DATE_FORMAT(end_date, '%d/%m/%Y')" + |
|||
" ) AS event_dates, " + |
|||
" no_of_agents, " + |
|||
" calls_per_agent, " + |
|||
" (no_of_agents)*(calls_per_agent) as total_calls, " + |
|||
" description " + |
|||
"FROM gcc_1913_campaign.campaign_request;"; |
|||
|
|||
List<Map<String, Object>> campaigns = jdbcTemplate.queryForList(sql); |
|||
|
|||
|
|||
return campaigns; |
|||
} |
|||
|
|||
public List<Map<String, Object>> getLastRow() |
|||
{ |
|||
String sqlQuery ="SELECT campaign_id\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request\r\n" |
|||
+ "ORDER BY campaign_id DESC\r\n" |
|||
+ "LIMIT 1"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getDetailsForStart() |
|||
{ |
|||
String sqlQuery ="SELECT cr.campaign_id,c.category_name,cr.campaign_name,cr.no_of_agents,cr.calls_per_agent,(cr.no_of_agents)*(cr.calls_per_agent) as total_calls\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request cr\r\n" |
|||
+ "JOIN gcc_1913_campaign.category c ON cr.category_id=c.category_id\r\n" |
|||
+ "where cr.isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getDataforAgents(int campaign_id, int calls_per_agent) |
|||
{ |
|||
List<Map<String, Object>> assignedAgent_list =getAssignedAgentId(campaign_id); |
|||
List<Map<String, Object>> data_list =getDataId(campaign_id); |
|||
|
|||
List<Map<String, Object>> task = getTask(assignedAgent_list,data_list,calls_per_agent,campaign_id); |
|||
|
|||
// Perform the update query here |
|||
if (task != null && !task.isEmpty()) { |
|||
assignAgentIds(task); |
|||
updateAgentStatus(campaign_id); |
|||
} |
|||
|
|||
|
|||
return task; |
|||
} |
|||
|
|||
//Method to update agent_id for each data_id in upload_data table |
|||
public void assignAgentIds(List<Map<String, Object>> taskList) { |
|||
String updateQuery = "UPDATE gcc_1913_campaign.upload_data SET agent_id = ? WHERE data_id = ? AND campaign_id = ?"; |
|||
|
|||
// Loop through each agent's task list |
|||
for (Map<String, Object> task : taskList) { |
|||
Integer agentId = (Integer) task.get("agent_id"); |
|||
Integer campaignId = (Integer) task.get("campaign_id"); |
|||
List<Integer> dataIds = (List<Integer>) task.get("data_ids"); |
|||
|
|||
// Update each data_id with the respective agent_id |
|||
for (Integer dataId : dataIds) { |
|||
jdbcTemplate.update(updateQuery, agentId, dataId, campaignId); |
|||
} |
|||
} |
|||
} |
|||
|
|||
//Example update method |
|||
private void updateAgentStatus(int campaign_id) { |
|||
String updateQuery = "UPDATE gcc_1913_campaign.campaign_request SET isactive = '0', isdelete='1' WHERE campaign_id = ?"; |
|||
jdbcTemplate.update(updateQuery, campaign_id); |
|||
} |
|||
|
|||
|
|||
private List<Map<String, Object>> getTask(List<Map<String, Object>> assignedAgent_list, List<Map<String, Object>> data_list, |
|||
int calls_per_agent,int campaign_id) { |
|||
|
|||
List<Map<String, Object>> result = new ArrayList<>(); |
|||
int dataIndex = 0; |
|||
|
|||
// Loop through each assigned ID |
|||
for (Map<String, Object> assigned : assignedAgent_list) { |
|||
// Create a map to store the assigned_id and corresponding data_ids |
|||
Map<String, Object> assignedTaskMap = new HashMap<>(); |
|||
List<Integer> assignedDataIds = new ArrayList<>(); |
|||
|
|||
// Get assigned_id |
|||
Integer agent_id = (Integer) assigned.get("agent_id"); |
|||
|
|||
// Loop to assign the appropriate number of data IDs (calls_per_agent) |
|||
for (int i = 0; i < calls_per_agent; i++) { |
|||
if (dataIndex >= data_list.size()) { |
|||
// Exit if we run out of data IDs |
|||
break; |
|||
} |
|||
Map<String, Object> data = data_list.get(dataIndex); |
|||
Integer data_id = (Integer) data.get("data_id"); |
|||
assignedDataIds.add(data_id); |
|||
dataIndex++; |
|||
} |
|||
|
|||
// Put the agent_id and the corresponding data_ids in the map |
|||
assignedTaskMap.put("agent_id", agent_id); |
|||
assignedTaskMap.put("data_ids", assignedDataIds); |
|||
assignedTaskMap.put("campaign_id", campaign_id); |
|||
|
|||
// Add the map to the result list |
|||
result.add(assignedTaskMap); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
private List<Map<String, Object>> getDataId(int campaign_id) { |
|||
|
|||
String sqlQuery ="SELECT data_id\r\n" |
|||
+ "from gcc_1913_campaign.upload_data\r\n" |
|||
+ "where campaign_id=?"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, new Object[]{campaign_id}); |
|||
} |
|||
|
|||
|
|||
private List<Map<String, Object>> getAssignedAgentId(int campaign_id) { |
|||
|
|||
String sqlQuery ="SELECT agent_id\r\n" |
|||
+ "FROM gcc_1913_campaign.agent_assign \r\n" |
|||
+ "where campaign_id=? and isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, new Object[]{campaign_id}); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getActiveCampaigns() |
|||
{ |
|||
String sqlQuery ="SELECT cr.campaign_id,cr.calls_per_agent,cr.category_id,cr.campaign_name,c.category_name,cr.start_date,cr.end_date,cr.description\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request cr\r\n" |
|||
+ "JOIN gcc_1913_campaign.category c ON cr.category_id=c.category_id\r\n" |
|||
+ "where cr.isactive='0'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> viewcampaignstatus(int campaign_id) { |
|||
|
|||
String sqlQuery ="SELECT \r\n" |
|||
+ "aa.campaign_id as campaign_id,\r\n" |
|||
+ " al.agent_id as agent_id,\r\n" |
|||
+ " al.agent_name as agent_name,\r\n" |
|||
+ " COUNT(up.agent_id) AS Assigned_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 IS NOT NULL THEN 1 END) AS Complete_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 IS NULL THEN 1 END) AS Pending_count,\r\n" |
|||
+ " ROUND(\r\n" |
|||
+ " (COUNT(CASE WHEN up.field_14 IS NOT NULL THEN 1 END) * 100) / \r\n" |
|||
+ " COUNT(up.agent_id)\r\n" |
|||
+ " ) as Percentage,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'INFORMATION_GIVEN' THEN 1 END) AS Information_Given_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'UNATTENDED' THEN 1 END) AS Unattended_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'CALL_BACK_LATER' THEN 1 END) AS Call_back_later_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'SWITCH_OFF' THEN 1 END) AS Switch_off_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'WRONG_NUMBER' THEN 1 END) AS Wrong_number_count\r\n" |
|||
+ "FROM gcc_1913_campaign.agent_assign aa\r\n" |
|||
+ "JOIN gcc_1913_qaqc.agents_list al ON al.agent_id = aa.agent_id\r\n" |
|||
+ "JOIN gcc_1913_campaign.upload_data up ON up.agent_id = al.agent_id AND up.campaign_id = ?\r\n" |
|||
+ "WHERE aa.campaign_id = ? AND aa.isactive = '1'\r\n" |
|||
+ "GROUP BY aa.campaign_id,al.agent_id, al.agent_name"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery,campaign_id,campaign_id); |
|||
} |
|||
|
|||
public List<Map<String, Object>> viewcompletedby(int campaign_id, int agent_id) { |
|||
|
|||
String sqlQuery ="SELECT \r\n" |
|||
+ "up.data_id as data_id,up.field_1 as id, up.field_2 as name, up.field_3 as address,field_5 as cellnumber, field_14 as call_status, \r\n" |
|||
+ "count(cl.data_id) as call_count,updated_date as updated_date,field_15 as remarks\r\n" |
|||
+ "FROM gcc_1913_campaign.agent_assign aa\r\n" |
|||
+ "JOIN gcc_1913_campaign.upload_data up ON up.agent_id = aa.agent_id AND up.campaign_id = ?\r\n" |
|||
+ "JOIN gcc_1913_campaign.call_logs cl ON cl.data_id=up.data_id\r\n" |
|||
+ "WHERE aa.campaign_id = ? AND aa.isactive = '1' AND aa.agent_id=? AND up.field_14 IS NOT NULL\r\n" |
|||
+ "group by up.data_id,up.field_1, up.field_2"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery,campaign_id,campaign_id,agent_id); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service |
|||
public class WhatsappMsgService { |
|||
|
|||
|
|||
public String sendMsg(String msgUrl) { |
|||
|
|||
String response =""; |
|||
try{ |
|||
HttpURLConnection connection =null; |
|||
|
|||
URL url = new URL(msgUrl); |
|||
connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response=responseCode+""; |
|||
System.out.println("Response Code: " + responseCode); |
|||
|
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
public String sendSMS(String SMS_Url) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response =restTemplate.getForObject(SMS_Url,String.class); |
|||
return response; |
|||
} |
|||
} |
|||
@ -0,0 +1,242 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
|
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
|
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.ComplaintService; |
|||
|
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.util.LinkedMultiValueMap; |
|||
import org.springframework.util.MultiValueMap; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLEncoder; |
|||
import org.springframework.http.*; |
|||
|
|||
import java.util.Base64; |
|||
import java.util.HashMap; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import java.awt.Graphics2D; |
|||
import java.awt.image.BufferedImage; |
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.IOException; |
|||
import javax.imageio.ImageIO; |
|||
import java.util.Base64; |
|||
|
|||
@CrossOrigin |
|||
@RestController |
|||
@RequestMapping("gcc/api/callcenterqaqc/pgrcomplaint") |
|||
public class ComplaintController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
|
|||
public ComplaintController(RestTemplate restTemplate) { |
|||
this.restTemplate = restTemplate; |
|||
} |
|||
|
|||
@Autowired |
|||
private ComplaintService complaintService; |
|||
|
|||
@GetMapping("/getComplaintCategories") |
|||
public @ResponseBody String getComplaintCategories() { |
|||
return complaintService.fetchComplaintCategories(); |
|||
} |
|||
|
|||
@GetMapping("/getComplaintSubTypes") |
|||
public @ResponseBody String getComplaintSubTypes(@RequestParam String groupId) { |
|||
return complaintService.fetchComplaintSubTypes(groupId); |
|||
} |
|||
|
|||
@GetMapping("/getComplaintDetailsbyId") |
|||
public List<Map<String, Object>> getComplaintDetailsById(@RequestParam String complaintid) { |
|||
return complaintService.fetchComplaintDetailsById(complaintid); |
|||
} |
|||
|
|||
@GetMapping("/getComplaintDetailsByMobile") |
|||
public List<Map<String, Object>> getComplaintDetailsByMobile(@RequestParam String mobileNo) { |
|||
return complaintService.fetchComplaintDetailsByMobile(mobileNo); |
|||
} |
|||
|
|||
@PostMapping("/register") |
|||
public ResponseEntity<String> registerComplaint( |
|||
@RequestParam(value = "ComplainantName", required = false) String complainantName, |
|||
@RequestParam(value = "ComplainantAddr", required = false) String complainantAddr, |
|||
@RequestParam(value = "MobileNo", required = false) String mobileNo, |
|||
@RequestParam(value = "Email", required = false) String email, |
|||
@RequestParam(value = "ComplaintType", required = false) String complaintType, |
|||
@RequestParam(value = "ComplaintTitle", required = false) String complaintTitle, |
|||
@RequestParam(value = "ComplaintDetails", required = false) String complaintDetails, |
|||
@RequestParam(value = "StreetId", required = false) String streetId, |
|||
@RequestParam(value = "Comp_Image", required = false) String compImage, |
|||
@RequestParam(value = "latitude", required = false) String latitude, |
|||
@RequestParam(value = "longtitude", required = false) String longtitude, |
|||
@RequestParam(value = "Landmark", required = false) String landmark, |
|||
@RequestParam(value = "gender", required = false) String gender) { |
|||
|
|||
String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; |
|||
|
|||
try { |
|||
// Create the URL object |
|||
URL url = new URL(externalUrl); |
|||
|
|||
// Create the HttpURLConnection object |
|||
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
|||
conn.setRequestMethod("POST"); |
|||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
|||
conn.setDoOutput(true); |
|||
|
|||
// Create the parameters string, handling null values |
|||
String params = "serviceId=RegComplaint" + "&ComplainantName=" |
|||
+ URLEncoder.encode(complainantName != null ? complainantName : "", "UTF-8") + "&ComplainantAddr=" |
|||
+ URLEncoder.encode(complainantAddr != null ? complainantAddr : "", "UTF-8") + "&MobileNo=" |
|||
+ URLEncoder.encode(mobileNo != null ? mobileNo : "", "UTF-8") + "&Email=" |
|||
+ URLEncoder.encode(email != null ? email : "", "UTF-8") + "&ComplaintType=" |
|||
+ URLEncoder.encode(complaintType != null ? complaintType : "", "UTF-8") + "&ComplaintTitle=" |
|||
+ URLEncoder.encode(complaintTitle != null ? complaintTitle : "", "UTF-8") + "&ComplaintDetails=" |
|||
+ URLEncoder.encode(complaintDetails != null ? complaintDetails : "", "UTF-8") + "&StreetId=" |
|||
+ URLEncoder.encode(streetId != null ? streetId : "", "UTF-8") + "&Comp_Image=" |
|||
+ URLEncoder.encode(compImage != null ? compImage : "", "UTF-8") + "&latitude=" |
|||
+ URLEncoder.encode(latitude != null ? latitude : "", "UTF-8") + "&longtitude=" |
|||
+ URLEncoder.encode(longtitude != null ? longtitude : "", "UTF-8") + "&Landmark=" |
|||
+ URLEncoder.encode(landmark != null ? landmark : "", "UTF-8") + "&gender=" |
|||
+ URLEncoder.encode(gender != null ? gender : "", "UTF-8") + "&compmode=2"; |
|||
// Write parameters to request body |
|||
try (OutputStream os = conn.getOutputStream()) { |
|||
byte[] input = params.getBytes("UTF-8"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
// Read the response |
|||
int responseCode = conn.getResponseCode(); |
|||
BufferedReader reader; |
|||
if (responseCode == HttpURLConnection.HTTP_OK) { |
|||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
|||
} else { |
|||
reader = new BufferedReader(new InputStreamReader(conn.getErrorStream())); |
|||
} |
|||
|
|||
StringBuilder response = new StringBuilder(); |
|||
String line; |
|||
while ((line = reader.readLine()) != null) { |
|||
response.append(line); |
|||
} |
|||
reader.close(); |
|||
|
|||
// Return the response from the external API |
|||
return ResponseEntity.status(responseCode).body(response.toString()); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("An error occurred while processing the request."); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/updateComplaint") |
|||
public ResponseEntity<String> updateComplaint(@RequestParam("ComplaintId") String complaintId, |
|||
@RequestParam(value = "Message", required = false) String message, |
|||
@RequestParam(value = "Status") String status, |
|||
@RequestPart(value = "Comp_Image", required = false) MultipartFile compImage) { |
|||
|
|||
String userType = "Public"; |
|||
|
|||
System.out.println("message:-" + message + "\n UserType:-" + userType + "\n Status:-" + status); |
|||
System.out.println(compImage == null); |
|||
String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; |
|||
|
|||
try { |
|||
// Convert and compress the image to base64 if provided |
|||
String base64Image = null; |
|||
if (compImage != null && !compImage.isEmpty()) { |
|||
base64Image = compressAndEncodeToBase64(compImage); |
|||
System.out.println("imageee" + base64Image); |
|||
} |
|||
|
|||
// Construct the POST body with parameters |
|||
String params = "serviceId=UpdateComplaint" + "&ComplaintId=" |
|||
+ URLEncoder.encode(complaintId != null ? complaintId : "", "UTF-8") + "&Message=" |
|||
+ URLEncoder.encode(message != null ? message : "", "UTF-8") + "&UserType=" |
|||
+ URLEncoder.encode(userType, "UTF-8") + "&Status=" |
|||
+ URLEncoder.encode(status != null ? status : "", "UTF-8") + "&Comp_Image=" |
|||
+ URLEncoder.encode(compImage != null ? base64Image : "", "UTF-8") |
|||
+ "&Token=718333469976265947044293"; |
|||
// Open connection and send POST request |
|||
URL url = new URL(externalUrl); |
|||
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
|||
conn.setRequestMethod("POST"); |
|||
conn.setDoOutput(true); |
|||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
|||
|
|||
// Send parameters |
|||
OutputStream os = conn.getOutputStream(); |
|||
os.write(params.getBytes()); |
|||
os.flush(); |
|||
os.close(); |
|||
|
|||
// Handle the response |
|||
int responseCode = conn.getResponseCode(); |
|||
BufferedReader reader; |
|||
if (responseCode == HttpURLConnection.HTTP_OK) { |
|||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
|||
} else { |
|||
reader = new BufferedReader(new InputStreamReader(conn.getErrorStream())); |
|||
} |
|||
|
|||
StringBuilder response = new StringBuilder(); |
|||
String line; |
|||
while ((line = reader.readLine()) != null) { |
|||
response.append(line); |
|||
} |
|||
reader.close(); |
|||
|
|||
return ResponseEntity.status(responseCode).body(response.toString()); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("An error occurred while processing the request."); |
|||
} |
|||
} |
|||
|
|||
private String compressAndEncodeToBase64(MultipartFile file) throws IOException { |
|||
// Convert MultipartFile to BufferedImage |
|||
BufferedImage originalImage = ImageIO.read(file.getInputStream()); |
|||
|
|||
// Resize/Compress the image |
|||
int targetWidth = 800; // You can adjust the width as needed |
|||
int targetHeight = (int) (originalImage.getHeight() * (800.0 / originalImage.getWidth())); // Preserve aspect |
|||
// ratio |
|||
|
|||
BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB); |
|||
Graphics2D g = resizedImage.createGraphics(); |
|||
g.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null); |
|||
g.dispose(); |
|||
|
|||
// Compress the image by writing it to a ByteArrayOutputStream in JPEG format |
|||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|||
ImageIO.write(resizedImage, "jpg", baos); // You can change the format to "png" or "jpg" |
|||
byte[] compressedBytes = baos.toByteArray(); |
|||
|
|||
// Convert the compressed image to base64 |
|||
return Base64.getEncoder().encodeToString(compressedBytes); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.FollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent/followupcalls") |
|||
@RestController |
|||
public class FollowUpController { |
|||
|
|||
@Autowired |
|||
RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@Autowired |
|||
private FollowUpService followService; |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("dataId") int dataId, |
|||
@RequestParam("userId") String userId, |
|||
@RequestParam("action") String action, |
|||
@RequestParam(value = "remainderDate", required = false,defaultValue = "-") String remainderDate, |
|||
@RequestParam("remarks") String remarks) { |
|||
try { |
|||
System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
System.out.println("Updating Data ID: " + dataId); |
|||
System.out.println("Action: " + action); |
|||
System.out.println("Remarks: " + remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
System.out.println("updated_agent: " + updated_agent); |
|||
|
|||
Map<String, Object> complaintDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
|
|||
Integer agentId = (Integer) complaintDetails.get("agent_id"); |
|||
Map<String, Object> erp_username=qaqcCallsService.getErpnameById(agentId); |
|||
String Erpname=(String) erp_username.get("erp_username"); |
|||
|
|||
if ("WRONG_ASSIGN".equals(action)) { |
|||
|
|||
boolean statusUpdated = qaqcCallsService.ChangeStatusInErp(complaintNumber, remarks, action, Erpname); |
|||
|
|||
if (!statusUpdated) { |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
// Update complaint details |
|||
followService.updateFollowupComplaintDetails(complaintNumber, dataId, action, remarks,updated_agent); |
|||
followService.updateComplaintHistoryDetails(complaintNumber, dataId, action, remarks,updated_agent, remainderDate); |
|||
|
|||
Map<String, Object> logDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
// Upload to logs |
|||
followService.uploadComplaintDetailsInLogs(logDetails, action, complaintNumber,remainderDate); |
|||
|
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,90 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.InprogresscallService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent/inprogresscalls") |
|||
@RestController |
|||
|
|||
public class InprogresscallController { |
|||
|
|||
@Autowired |
|||
InprogresscallService inprogresscallService; |
|||
|
|||
@Autowired |
|||
RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("dataId") int dataId, |
|||
@RequestParam("userId") String userId, |
|||
@RequestParam("action") String action, |
|||
@RequestParam(value = "remainderDate", required = false,defaultValue = "-") String remainderDate, |
|||
@RequestParam("remarks") String remarks) { |
|||
try { |
|||
System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
System.out.println("Updating Data ID: " + dataId); |
|||
System.out.println("Action: " + action); |
|||
System.out.println("Remarks: " + remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
System.out.println("updated_agent: " + updated_agent); |
|||
|
|||
//to insert incorrect office mobile number details in table |
|||
if (action.equals("MOBILE_NUM")) { |
|||
inprogresscallService.saveMobileNumDetails(complaintNumber, remarks); |
|||
} |
|||
|
|||
Map<String, Object> complaintDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
|
|||
Integer agentId = (Integer) complaintDetails.get("agent_id"); |
|||
Map<String, Object> erp_username=qaqcCallsService.getErpnameById(agentId); |
|||
String Erpname=(String) erp_username.get("erp_username"); |
|||
|
|||
if ("WRONG_ASSIGN".equals(action)) { |
|||
|
|||
boolean statusUpdated = qaqcCallsService.ChangeStatusInErp(complaintNumber, remarks, action, Erpname); |
|||
|
|||
if (!statusUpdated) { |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
// Update complaint details |
|||
inprogresscallService.updateInprogressComplaintDetails(complaintNumber, dataId, action, remarks,updated_agent); |
|||
inprogresscallService.updateComplaintHistoryDetails(complaintNumber, dataId, action, remarks,updated_agent, remainderDate); |
|||
Map<String, Object> logDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
// Upload to logs |
|||
qaqcCallsService.uploadComplaintDetailsInLogs(logDetails, action, complaintNumber,remainderDate); |
|||
|
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,474 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.FollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.InprogresscallService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.PublicFollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcService; |
|||
import in.gov.chennaicorporation.gccoffice.entity.AppUserEntity; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
|
|||
@RequestMapping("/gcc/callcenterqaqc") |
|||
@Controller("callCenterQaQcMainController") |
|||
public class MainController { |
|||
|
|||
@Autowired |
|||
private QaqcService qaqcService; |
|||
|
|||
@Autowired |
|||
private QaqcAgentsService agentsService; |
|||
|
|||
@Autowired |
|||
private QaqcAdminSettingService adminService; |
|||
|
|||
@Autowired |
|||
private InprogresscallService inprogresscallService; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@Autowired |
|||
private FollowUpService followUpService; |
|||
|
|||
@Autowired |
|||
private PublicFollowUpService publicService; |
|||
|
|||
|
|||
@GetMapping("/admin/qaqcgrievancedashboard") |
|||
public String viewqaqcdashboard(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String,Object>> previousday=agentsService.getPreviousDayDashboardCounts(); |
|||
model.addAttribute("previousday", previousday); |
|||
System.out.println(previousday); |
|||
|
|||
List<Map<String,Object>> agentcount=agentsService.getAgentPreviousDayCount(); |
|||
model.addAttribute("agentcount", agentcount); |
|||
|
|||
return "modules/callcenterqaqc/qaqcgrievancedashboard"; |
|||
} |
|||
|
|||
@GetMapping("/admin/qaqcassigntaskagents") |
|||
public String viewAgentAssign(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/callcenterqaqc/qaqctaskagentassign"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/admin/qaqcfollowuplist") |
|||
public String viewAdminFollowuplist(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/callcenterqaqc/qaqcfollowuplist"; |
|||
} |
|||
|
|||
@GetMapping("/qaqctasklist") |
|||
public String viewqaqctasklist(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
|
|||
return "modules/callcenterqaqc/qaqctasklist"; |
|||
} |
|||
|
|||
@GetMapping("/qaqcagentperformance") |
|||
public String viewAgentPerformance(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/callcenterqaqc/qaqcagentperformance"; |
|||
} |
|||
|
|||
@GetMapping("/adminsettings") |
|||
public String viewAdminSettings(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
|
|||
|
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> Counts=adminService.getAdminSettingCounts(); |
|||
model.addAttribute("Counts", Counts); |
|||
|
|||
List<Map<String, Object>> agents=adminService.getAgentsForCallingtype(); |
|||
model.addAttribute("Agents", agents); |
|||
|
|||
|
|||
return "modules/callcenterqaqc/qaqcadminsettings"; |
|||
} |
|||
|
|||
@GetMapping("/agent/agentgrievancedashboard") |
|||
public String viewAgentGrievenceDashboardpage( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
Model model |
|||
) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
|
|||
|
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> details2 = agentsService.getAgentPerformanceData(userId, startDate, endDate); |
|||
model.addAttribute("details2", details2); |
|||
|
|||
List<Map<String, Object>> tasks = agentsService.getAgentTaskDetails(userId, startDate, endDate); |
|||
model.addAttribute("tasks", tasks); |
|||
System.out.println("tasks: "+tasks); |
|||
return "modules/callcenterqaqc/agentgrievancedashboard"; |
|||
} |
|||
|
|||
|
|||
|
|||
@PostMapping("/agent/agentgrievancedashboard") |
|||
public String viewAgentGrievenceDashboard( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
Model model |
|||
) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
// System.out.println("startdate: "+startDate ); |
|||
// System.out.println("enddate:" + endDate); |
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> details2 = agentsService.getAgentPerformanceData(userId, startDate, endDate); |
|||
model.addAttribute("details2", details2); |
|||
|
|||
List<Map<String, Object>> tasks = agentsService.getAgentTaskDetails(userId, startDate, endDate); |
|||
model.addAttribute("tasks", tasks); |
|||
|
|||
return "modules/callcenterqaqc/agentgrievancedashboard"; |
|||
|
|||
} |
|||
|
|||
@GetMapping("/agent/qaqccalls") |
|||
public String viewAgentQaqcCalls( @RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate,Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> qaqcCallslists=qaqcCallsService.getClosedComplaints(userId); |
|||
model.addAttribute("qaqcCallsLists",qaqcCallslists); |
|||
|
|||
List<Map<String, Object>> qaqcCallsAction=qaqcCallsService.getCallCategories(); |
|||
model.addAttribute("qaqcCallsActioin",qaqcCallsAction); |
|||
|
|||
List<Map<String, Object>> qaqcSubmitDetails=qaqcCallsService.getSubmitDetails(userId); |
|||
model.addAttribute("qaqcSubmitDetails",qaqcSubmitDetails); |
|||
|
|||
return "modules/callcenterqaqc/agentqaqccalls"; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("agent/qaqcinprogresscall") |
|||
public String viewqaqcin_progress_call( @RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate,Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> inprogresslists=inprogresscallService.getInProgressCalls(userId); |
|||
model.addAttribute("inprogresslists", inprogresslists); |
|||
|
|||
List<Map<String, Object>> qaqcactionlists=inprogresscallService.getActionsCatergory(); |
|||
model.addAttribute("qaqcactionlists", qaqcactionlists); |
|||
|
|||
List<Map<String, Object>> inSubmitDetails=inprogresscallService.getInprogressSubmitDetails(userId); |
|||
model.addAttribute("inSubmitDetails",inSubmitDetails); |
|||
|
|||
return "modules/callcenterqaqc/agentqaqcinprogresscalls"; |
|||
} |
|||
|
|||
@GetMapping("/agent/qaqcfollowupcalls") |
|||
public String viewAgentQaqcFollowupCalls(@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate,Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> qaqcfollowuplists=followUpService.getFollowUpCalls(userId); |
|||
model.addAttribute("qaqcfollowuplists",qaqcfollowuplists); |
|||
|
|||
List<Map<String, Object>> qaqccategorylists=followUpService.getFollowUpCatergory(); |
|||
|
|||
model.addAttribute("qaqccategorylists",qaqccategorylists); |
|||
|
|||
List<Map<String, Object>> fcSubmitDetails=followUpService.getFollowupSubmitDetails(userId); |
|||
model.addAttribute("fcSubmitDetails",fcSubmitDetails); |
|||
|
|||
return "modules/callcenterqaqc/agentqaqcfollowupcalls"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/agent/qaqcpublicfollowupcalls") |
|||
public String viewAgentQaqcPublicFollowupCalls(@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate,Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> qaqcfollowuplists=publicService.getFollowUpCalls(userId); |
|||
model.addAttribute("qaqcfollowuplists",qaqcfollowuplists); |
|||
|
|||
List<Map<String, Object>> qaqccategorylists=publicService.getFollowUpCatergory(); |
|||
|
|||
model.addAttribute("qaqccategorylists",qaqccategorylists); |
|||
|
|||
List<Map<String, Object>> fcSubmitDetails=publicService.getFollowupSubmitDetails(userId); |
|||
model.addAttribute("fcSubmitDetails",fcSubmitDetails); |
|||
|
|||
return "modules/callcenterqaqc/agentqaqcpublicfollowupcalls"; |
|||
} |
|||
|
|||
@GetMapping("/complaintstatus") |
|||
public String viewstatuscheck(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
|
|||
return "modules/callcenterqaqc/complaintstatus"; |
|||
} |
|||
|
|||
@GetMapping("/pgrcomplaint") |
|||
public String viewPGRpage(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenterqaqc/pgrcomplaints"; |
|||
} |
|||
|
|||
@GetMapping("/overallreport") |
|||
public String viewOverallReports(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenterqaqc/overallreport"; |
|||
} |
|||
|
|||
//callcenterqaqc/socialmediacomplaints |
|||
|
|||
@GetMapping("/socialmediacomplaints") |
|||
public String viewSocialMediaComplaints(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId", userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenterqaqc/socialmediacomplaints"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/smfinishedcomplaints") |
|||
public String viewSocialMediaCompletedComplaints(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId", userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenterqaqc/socialmediacompletedlist"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.FollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.PublicFollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent/publicfollowupcalls") |
|||
@RestController |
|||
public class PublicFollowUpController { |
|||
|
|||
@Autowired |
|||
RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@Autowired |
|||
private FollowUpService followService; |
|||
|
|||
@Autowired |
|||
private PublicFollowUpService publicService; |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("dataId") int dataId, |
|||
@RequestParam("userId") String userId, |
|||
@RequestParam("action") String action, |
|||
@RequestParam(value = "remainderDate", required = false,defaultValue = "-") String remainderDate, |
|||
@RequestParam("remarks") String remarks) { |
|||
try { |
|||
System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
System.out.println("Updating Data ID: " + dataId); |
|||
System.out.println("Action: " + action); |
|||
System.out.println("Remarks: " + remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
System.out.println("updated_agent: " + updated_agent); |
|||
|
|||
Map<String, Object> complaintDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
|
|||
Integer agentId = (Integer) complaintDetails.get("agent_id"); |
|||
Map<String, Object> erp_username=qaqcCallsService.getErpnameById(agentId); |
|||
String Erpname=(String) erp_username.get("erp_username"); |
|||
|
|||
if ("COMPLETED".equals(action) || "REOPEN".equals(action) ||"WRONG_ASSIGN".equals(action)) |
|||
{ |
|||
boolean statusUpdated =qaqcCallsService.ChangeStatusInErp(complaintNumber, remarks, action,Erpname); |
|||
System.out.println("statusUpdated="+statusUpdated); |
|||
if (!statusUpdated) |
|||
{ |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
// Update complaint details |
|||
followService.updateFollowupComplaintDetails(complaintNumber, dataId, action, remarks,updated_agent); |
|||
followService.updateComplaintHistoryDetails(complaintNumber, dataId, action, remarks,updated_agent, remainderDate); |
|||
|
|||
Map<String, Object> logDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
// Upload to logs |
|||
followService.uploadComplaintDetailsInLogs(logDetails, action, complaintNumber,remainderDate); |
|||
|
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,291 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.security.SecureRandom; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.logging.Level; |
|||
import java.util.logging.Logger; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.JsonMappingException; |
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.FollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
|
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc") |
|||
@RestController("GrivanceQCapiController") |
|||
|
|||
public class QaqcAPIController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
|
|||
@Autowired |
|||
public QaqcAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcService qaqcService; |
|||
|
|||
@Autowired |
|||
private FollowUpService followUpService; |
|||
|
|||
|
|||
|
|||
@GetMapping("/getComplaintDetails/{complaintNumber}") |
|||
public Map<String, Object> getComplaintDetails( |
|||
@PathVariable String complaintNumber, |
|||
@RequestParam(required = false) String gender, |
|||
@RequestParam(required = false) String compmode, |
|||
@RequestParam(required = false) String deptname) { |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
|
|||
try { |
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getComplaintByID&ComplaintId=" |
|||
+ complaintNumber + "&imgUrlonly=yes"; |
|||
System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintDetails = rootNode.path(0).path("ComplaintListHistory").path(0); |
|||
|
|||
String registerDate=complaintDetails.path("complaintopendate").asText("N/A"); |
|||
System.out.println("registerdate====="+registerDate); |
|||
|
|||
String formattedDate = "N/A"; // Default value if parsing fails |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty()) { |
|||
try { |
|||
// Parse the input date string |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
Date date = inputFormat.parse(registerDate); |
|||
|
|||
// Format the date to dd-MM-yyyy |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy"); |
|||
formattedDate = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log exception for debugging |
|||
} |
|||
} |
|||
|
|||
if (!complaintDetails.isMissingNode()) { |
|||
// Existing fields |
|||
resultMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
resultMap.put("complaintdate", formattedDate); |
|||
resultMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
resultMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
resultMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
resultMap.put("description", complaintDetails.path("complaintdetails").asText("N/A")); |
|||
resultMap.put("currentStatus", complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
resultMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
resultMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
resultMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
resultMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
resultMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
resultMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
resultMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
resultMap.put("gender", gender != null ? gender : complaintDetails.path("GENDER").asText("N/A")); |
|||
resultMap.put("deptname", deptname != null ? deptname : complaintDetails.path("DEPT_NAME").asText("N/A")); |
|||
resultMap.put("compmode", compmode != null ? compmode : complaintDetails.path("COMP_MODE").asText("N/A")); |
|||
|
|||
// Comments section |
|||
JsonNode comments = complaintDetails.path("Comments"); |
|||
if (!comments.isMissingNode()) { |
|||
List<Map<String, Object>> commentList = new ArrayList<>(); |
|||
for (JsonNode commentNode : comments) { |
|||
Map<String, Object> commentData = new HashMap<>(); |
|||
|
|||
// Extracting comment details |
|||
commentData.put("user", commentNode.path("user").asText("N/A")); |
|||
commentData.put("message", commentNode.path("message").asText("N/A")); |
|||
commentData.put("comment_date", commentNode.path("comment_date").asText("N/A")); |
|||
|
|||
// Handling media link (Image) as part of userimages array for each comment |
|||
JsonNode userImages = commentNode.path("userimages"); |
|||
if (!userImages.isMissingNode() && userImages.isArray() && userImages.size() > 0) { |
|||
String mediaLink = userImages.get(0).path("Comp_Image").asText(null); |
|||
// If media link is valid, add it to the comment data |
|||
if (mediaLink != null && !mediaLink.equals("null") && !mediaLink.isEmpty()) { |
|||
commentData.put("Comp_Image", mediaLink); |
|||
} else { |
|||
commentData.put("Comp_Image", "No image available"); |
|||
} |
|||
} else { |
|||
commentData.put("Comp_Image", "No image available"); |
|||
} |
|||
|
|||
// Add the comment data to the list |
|||
commentList.add(commentData); |
|||
} |
|||
resultMap.put("comments", commentList); |
|||
} |
|||
|
|||
|
|||
// Handling media link (Image) as part of userimages array |
|||
String mediaLink = complaintDetails.path("mediaLink").asText(null); |
|||
List<Map<String, String>> userImagesList = new ArrayList<>(); |
|||
Map<String, String> imageMap = new HashMap<>(); |
|||
imageMap.put("Comp_Image", mediaLink != null && !mediaLink.equals("null") ? mediaLink : null); |
|||
userImagesList.add(imageMap); |
|||
resultMap.put("userimages", userImagesList); |
|||
|
|||
|
|||
System.out.println("Image URL from API: " + mediaLink); |
|||
} |
|||
} else { |
|||
resultMap.put("error", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("error", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/followuplist") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getFollowUpList( |
|||
@RequestParam(value = "callStatus", required = false) String callStatus, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate) { |
|||
|
|||
// Set default 'toDate' to a future date (1 year ahead) if not provided |
|||
if (toDate == null) { |
|||
toDate = LocalDate.now().plusMonths(1); // Set to one year ahead or any other future date |
|||
//toDate= qaqcService.getMaxRemainderdate(); |
|||
} |
|||
|
|||
// Set default 'fromDate' to the start of the current month if not provided |
|||
if (fromDate == null) { |
|||
fromDate = LocalDate.now().withDayOfMonth(1); // Start from the first day of the current month |
|||
} |
|||
|
|||
// Print debug info |
|||
System.out.println("Received callStatus: " + callStatus); |
|||
System.out.println("From Date: " + fromDate); |
|||
System.out.println("To Date: " + toDate); |
|||
|
|||
// Call the service to fetch the filtered data based on the status and date range |
|||
return qaqcService.getFollowUpDetailsByStatus(callStatus, fromDate, toDate); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/followup/todayCount") |
|||
public ResponseEntity<Map<String, Long>> getTodayFollowUpCount(@RequestParam String followupStatus) { |
|||
LocalDate today = LocalDate.now(); // Get the current date |
|||
Map<String, Long> counts = qaqcService.countFollowUpsByDateAndStatus(today, followupStatus); |
|||
|
|||
return ResponseEntity.ok(counts); // Return the count in the response |
|||
} |
|||
|
|||
@GetMapping("/callhistory") |
|||
public ResponseEntity<List<Map<String, Object>>> getCallHistory(@RequestParam String complaintNumber) { |
|||
List<Map<String, Object>> callHistory = followUpService.getCallHistory(complaintNumber); |
|||
if (callHistory.isEmpty()) { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
|||
.body(Collections.emptyList()); |
|||
} |
|||
return ResponseEntity.ok(callHistory); |
|||
} |
|||
|
|||
@GetMapping("/getfilterreport") |
|||
public Map<String, Object> getFilterReports( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, |
|||
@RequestParam String status, |
|||
@RequestParam String group, |
|||
@RequestParam String type, |
|||
@RequestParam String mode, |
|||
@RequestParam String zone) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
LocalDate fromLocalDate = LocalDate.parse(startDate, DateTimeFormatter.ISO_DATE); |
|||
LocalDate toLocalDate = LocalDate.parse(endDate, DateTimeFormatter.ISO_DATE); |
|||
String formattedFromDate = fromLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
String formattedToDate = toLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
|
|||
String url="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+mode+"&Zoneid="+zone; |
|||
System.out.println(url); |
|||
|
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
|
|||
// Fetch response as String |
|||
ResponseEntity<String> responses = restTemplate.getForEntity(url, String.class); |
|||
String rawResponse = responses.getBody(); |
|||
|
|||
// Preprocess response to remove invalid characters if needed |
|||
if (rawResponse != null) { |
|||
//rawResponse = rawResponse.replaceAll("\"\"", "\""); // Replace double-double quotes |
|||
//rawResponse = rawResponse.replaceAll("(?<![,{])\"R", "\"R"); // Example: Fix missing commas |
|||
} |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> responseMap = objectMapper.readValue(rawResponse, Map.class); |
|||
List<Map<String, Object>> details = (List<Map<String, Object>>) responseMap.get("Details"); |
|||
//System.out.println(details); |
|||
if (details == null) { |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No Data, please change criteria"); |
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("details", details); |
|||
} |
|||
|
|||
} |
|||
catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred while fetching data."); |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,160 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.logging.Level; |
|||
import java.util.logging.Logger; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/adminsettings") |
|||
@RestController |
|||
public class QaqcAdminSettingsController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
|
|||
@Autowired |
|||
public QaqcAdminSettingsController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcAdminSettingService adminService; |
|||
|
|||
@PostMapping("/saveproductivity") |
|||
public ResponseEntity<Map<String, String>> saveproductivity(@RequestParam int productivity_count) |
|||
{ |
|||
Map<String, String> response = new HashMap<>(); |
|||
try { |
|||
|
|||
// Save task ID |
|||
int rowsInserted = adminService.saveProductivity(productivity_count); |
|||
|
|||
if (rowsInserted > 0) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Productivity inserted successfully"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
response.put("status", "fail"); |
|||
response.put("message", "Productivity not saved"); |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); // Change to BAD_REQUEST for failure |
|||
|
|||
} catch (Exception e) { |
|||
// Logging the error |
|||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Error saving task", e); |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to save productivity"); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
|
|||
@PostMapping("/updateproductivity") |
|||
public ResponseEntity<Map<String, String>> updateProductivityById(@RequestBody Map<String, Integer> requestData) |
|||
{ Map<String, String> response = new HashMap<>(); |
|||
try { |
|||
|
|||
// Save task ID |
|||
int productivityCount = requestData.getOrDefault("productivity_count", 0); // Default to 0 if not provided |
|||
int rowsUpdated = adminService.updateProductivity(productivityCount); |
|||
|
|||
|
|||
if (rowsUpdated > 0) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Productivity saved successfully"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
response.put("status", "fail"); |
|||
response.put("message", "Productivity not saved"); |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); // Change to BAD_REQUEST for failure |
|||
|
|||
} catch (Exception e) { |
|||
// Logging the error |
|||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Error saving task", e); |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to save productivity"); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getproductivity") |
|||
public Integer getProductivity() |
|||
{ |
|||
return adminService.getProductivity(); |
|||
} |
|||
|
|||
@GetMapping("/getadminsettingcounts") |
|||
public List<Map<String, Object>> getadminsettingcounts() |
|||
{ |
|||
return adminService.getAdminSettingCounts(); |
|||
|
|||
} |
|||
|
|||
@GetMapping("/assigncallingtype") |
|||
public List<Map<String, Object>> assigncallingtype() |
|||
{ |
|||
return adminService.getAgentsForCallingtype(); |
|||
|
|||
} |
|||
|
|||
@PostMapping("/updateCallType") // Bulk update endpoint |
|||
public ResponseEntity<Map<String, String>> updateCallType(@RequestBody List<Map<String, Object>> selectedAgents) { |
|||
|
|||
Map<String, String> response = new HashMap<>(); |
|||
|
|||
try { |
|||
int rowsUpdated = 0; |
|||
|
|||
// Loop through each selected agent and update their calling_type |
|||
for (Map<String, Object> agent : selectedAgents) { |
|||
String callingType = (String) agent.get("calling_type"); |
|||
|
|||
// Parse agent_id to Integer if it's passed as a String |
|||
int agentId = Integer.parseInt(agent.get("agent_id").toString()); // Ensure it's parsed as Integer |
|||
|
|||
// Update calling type for the agent |
|||
rowsUpdated += adminService.updateCallType(callingType, agentId); |
|||
|
|||
|
|||
} |
|||
adminService.saveCallingTypeInSettings(); |
|||
|
|||
if (rowsUpdated > 0) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Agents Assigned successfully"); |
|||
return ResponseEntity.ok(response); |
|||
} else { |
|||
response.put("status", "error"); |
|||
response.put("message", "No agents updated"); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "Error occurred while updating calling types: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,235 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.security.SecureRandom; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.Comparator; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.logging.Level; |
|||
import java.util.logging.Logger; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentAssignService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
|
|||
@RestController |
|||
@RequestMapping("gcc/api/callcenterqaqc/agentassign") |
|||
public class QaqcAgentAssignAPIController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
public QaqcAgentAssignAPIController(RestTemplate restTemplate) { |
|||
this.restTemplate = restTemplate; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcAgentAssignService agentAssignService; |
|||
|
|||
@Autowired |
|||
private QaqcAdminSettingService adminService; |
|||
|
|||
|
|||
|
|||
@GetMapping("/getavailableagents") |
|||
public ResponseEntity<Map<String, Object>> getAvailableAgents(@RequestParam int totalDataCount) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
try { |
|||
// Fetch available agents |
|||
List<Map<String, Object>> availableAgents = agentAssignService.getAvailableOutboundAgents(); |
|||
Integer productivity_count = adminService.getProductivity(); |
|||
|
|||
if (availableAgents.isEmpty() || totalDataCount == 0) { |
|||
response.put("status", "error"); |
|||
response.put("message", "No available agents or totalDataCount must be greater than 0."); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
|
|||
// Process and filter agents based on productivity_count |
|||
List<Map<String, Object>> filteredAgents = new ArrayList<>(); |
|||
for (Map<String, Object> agent : availableAgents) { |
|||
Integer agentId = (Integer) agent.get("agent_id"); |
|||
String agentName = (String) agent.get("agent_name"); |
|||
Integer todayCount=agentAssignService.getTodayCountForAgent(agentId); |
|||
Integer campaignPendingCount = agentAssignService.getCampaignPendingCountForAgent(agentId); |
|||
Integer pendingCounts=todayCount+campaignPendingCount; |
|||
// Log the details of each agent |
|||
System.out.println("Agent ID: " + agentId + ", Today Count: " + todayCount + |
|||
", Campaign Pending Count: " + campaignPendingCount + ", Pending Counts: " + pendingCounts); |
|||
|
|||
if(pendingCounts<productivity_count) { |
|||
filteredAgents.add(Map.of( |
|||
"agent_id", agentId, |
|||
"agent_name", agentName, |
|||
"campaignPendingCount", campaignPendingCount, |
|||
"todayCount",todayCount |
|||
)); |
|||
System.out.println("Agent added to filteredAgents: " + agentName); |
|||
|
|||
} |
|||
|
|||
} |
|||
System.out.println("Filtered Agents Size: " + filteredAgents.size()); |
|||
|
|||
|
|||
if (filteredAgents.isEmpty()) { |
|||
response.put("status", "error"); |
|||
response.put("message", "No Available Agents,To continue Increase the Productivity"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
// Calculate agent_available_count based on filtered agents |
|||
int agent_available_count = filteredAgents.size(); |
|||
|
|||
// Calculate calls per agent using filtered agent count |
|||
int calls_per_agent = totalDataCount / agent_available_count; |
|||
int remainder = totalDataCount % agent_available_count; |
|||
|
|||
// Distribute calls_per_agent and remainder |
|||
List<Map<String, Object>> finalFilteredAgents = new ArrayList<>(); |
|||
filteredAgents.sort(Comparator.comparingInt(agent -> (Integer) agent.get("campaignPendingCount"))); |
|||
|
|||
for (int i = 0; i < filteredAgents.size(); i++) { |
|||
Map<String, Object> agent = filteredAgents.get(i); |
|||
Integer agentId = (Integer) agent.get("agent_id"); |
|||
String agentName = (String) agent.get("agent_name"); |
|||
Integer todayCount = (Integer) agent.get("todayCount"); |
|||
Integer campaignPendingCount = (Integer) agent.get("campaignPendingCount"); |
|||
// Add 1 extra call for agents handling the remainder, starting from the first agent |
|||
int additionalCalls = (i < remainder) ? 1 : 0; |
|||
int totalCallsCount = todayCount+campaignPendingCount + calls_per_agent + additionalCalls; |
|||
|
|||
if (totalCallsCount < productivity_count) { |
|||
finalFilteredAgents.add(Map.of( |
|||
"agent_id", agentId, |
|||
"agent_name", agentName, |
|||
"totalCallsCount", totalCallsCount, |
|||
"todayCount",todayCount, |
|||
"campaignPendingCount", campaignPendingCount, |
|||
"calls_per_agent", calls_per_agent + additionalCalls |
|||
)); |
|||
System.out.println("Agent added to final======filteredAgents: " + agentName); |
|||
} |
|||
} |
|||
System.out.println("Final Filtered Agents Size: " + finalFilteredAgents.size()); |
|||
|
|||
if (finalFilteredAgents.isEmpty()) { |
|||
response.put("status", "error"); |
|||
response.put("message", "No Available Agents,To continue Increase the Productivity"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
|
|||
int agent_available_count2 = finalFilteredAgents.size(); |
|||
|
|||
// Calculate calls per agent using filtered agent count |
|||
int calls_per_agent2 = totalDataCount / agent_available_count2; |
|||
int remainder2 = totalDataCount % agent_available_count2; |
|||
|
|||
// Distribute calls_per_agent and remainder |
|||
List<Map<String, Object>> LastfinalFilteredAgents = new ArrayList<>(); |
|||
finalFilteredAgents.sort(Comparator.comparingInt(agent -> (Integer) agent.get("campaignPendingCount"))); |
|||
|
|||
for (int i = 0; i < finalFilteredAgents.size(); i++) { |
|||
Map<String, Object> agent = finalFilteredAgents.get(i); |
|||
Integer agentId = (Integer) agent.get("agent_id"); |
|||
String agentName = (String) agent.get("agent_name"); |
|||
Integer todayCount1 = (Integer) agent.get("todayCount"); |
|||
Integer campaignPendingCount = (Integer) agent.get("campaignPendingCount"); |
|||
// Add 1 extra call for agents handling the remainder, starting from the first agent |
|||
int additionalCalls1 = (i < remainder2) ? 1 : 0; |
|||
int totalCallsCount1 = todayCount1+campaignPendingCount + calls_per_agent2 + additionalCalls1; |
|||
|
|||
if (totalCallsCount1 < productivity_count) { |
|||
LastfinalFilteredAgents.add(Map.of( |
|||
"agent_id", agentId, |
|||
"agent_name", agentName, |
|||
"totalCallsCount", totalCallsCount1, |
|||
"todayCount1",todayCount1, |
|||
"campaignPendingCount", campaignPendingCount, |
|||
"calls_per_agent", calls_per_agent2 + additionalCalls1 |
|||
)); |
|||
System.out.println("Agent added to Lastfinal======LastfinalFilteredAgents: " + agentName); |
|||
} |
|||
} |
|||
System.out.println("Filtered Agents Size: " + LastfinalFilteredAgents.size()); |
|||
|
|||
if (LastfinalFilteredAgents.isEmpty()) { |
|||
response.put("status", "error"); |
|||
response.put("message", "No Available Agents,To continue Increase the Productivity"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
// Build response |
|||
response.put("status", "success"); |
|||
response.put("message", "Available agents fetched successfully"); |
|||
response.put("available_agents", LastfinalFilteredAgents); |
|||
response.put("productivity_count", productivity_count); |
|||
response.put("agent_available_count", LastfinalFilteredAgents.size()); |
|||
|
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
|
|||
// Return error response in case of failure |
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to fetch available agents"); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
|
|||
@PostMapping("/taskassign") |
|||
public ResponseEntity<Map<String, Object>> assignTasks(@RequestBody Map<String, Object> requestData) { |
|||
Map<String, Object> response; |
|||
try { |
|||
// Delegate transactional work to the service |
|||
response = agentAssignService.assignTasksTransactionally(requestData); |
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response = new HashMap<>(); |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/deleteRecords") |
|||
public ResponseEntity<String> deleteRecordsInUploadData() { |
|||
try { |
|||
int rowsAffected = agentAssignService.deleteUploadDataTable(); |
|||
if (rowsAffected > 0) { |
|||
return ResponseEntity.ok("success"); |
|||
} else { |
|||
return ResponseEntity.ok("No records to delete"); |
|||
} |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error deleting records"); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,161 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.io.InputStream; |
|||
import java.net.URL; |
|||
import java.net.URLConnection; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.time.LocalDate; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Required; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent") |
|||
@RestController |
|||
public class QaqcAgentsAPIController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
|
|||
@Autowired |
|||
public QaqcAgentsAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcAgentsService agentsService; |
|||
|
|||
|
|||
@GetMapping("/getdataforagents") |
|||
public ResponseEntity<Map<String, Object>> getdataforagents(@RequestParam int agent_id,@RequestParam int qaqc_id) |
|||
{ |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
List<Map<String, Object>> tasks = agentsService.getdataforagents(agent_id,qaqc_id); |
|||
|
|||
if (tasks.isEmpty()) { |
|||
|
|||
response.put("status", "no_data"); |
|||
response.put("message", "No data found for the given agent_id and qaqc_id."); |
|||
} else { |
|||
// Success case |
|||
response.put("status", "success"); |
|||
response.put("message", "Data retrieved successfully."); |
|||
response.put("tasks", tasks); |
|||
} |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
|
|||
} |
|||
|
|||
@PostMapping("/savecallstatus") |
|||
public ResponseEntity<String> savecallstatus(@RequestParam String call_status,@RequestParam String remarks,@RequestParam String complaintNumber)//get full body data |
|||
{ |
|||
|
|||
agentsService.savecallstatus(call_status, remarks,complaintNumber);//get all dbdata and save here and service also |
|||
agentsService.savecallstatusinlogs(call_status, remarks,complaintNumber);//get all dbdata and save here and service also |
|||
|
|||
return ResponseEntity.ok("Data Inserted successfully."); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getagentperformancecount") |
|||
public List<Map<String, Object>> getAgentPerformanceCount( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
List<Map<String, Object>> counts = agentsService.getAgentPerformanceCount(startDate, endDate); |
|||
System.out.println("fromdates: " + startDate); |
|||
System.out.println("todate: " + endDate); |
|||
System.out.println("overallcounts: " + counts ); |
|||
return counts; |
|||
} |
|||
|
|||
@GetMapping("/getagentperformancelist") |
|||
public List<Map<String, Object>> getAgentPerformanceList( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
// Fetch agent performance data from service |
|||
List<Map<String, Object>> agentPerformanceData = agentsService.getAgentPerformanceList(startDate, endDate); |
|||
|
|||
// Log or return the data |
|||
System.out.println("Agent Performance Data: " + agentPerformanceData); |
|||
return agentPerformanceData; |
|||
} |
|||
|
|||
@GetMapping("/agenttaskwise") |
|||
public List<Map<String, Object>> getAgentTaskwiseData(@RequestParam String agentId) { |
|||
// Call the service to fetch agent task-wise data |
|||
List<Map<String, Object>> agentTaskwiseData = agentsService.getAgentTaskwiseData(agentId); |
|||
System.out.println("Agent Task Wise Data: " + agentTaskwiseData); |
|||
return agentTaskwiseData; |
|||
} |
|||
|
|||
@GetMapping("/agentattendedcomplaints") |
|||
public List<Map<String,Object>> getAttendedComplaintStatus( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
@RequestParam(required = false) String complaintNumber, |
|||
@RequestParam(required = false) String complaintMobileNumber){ |
|||
|
|||
List<Map<String, Object>> agentAttendedData = agentsService.getAttendedComplaintStatus(startDate, endDate, complaintNumber, complaintMobileNumber); |
|||
System.out.println("Agent attended Data: " + agentAttendedData); |
|||
return agentAttendedData; |
|||
} |
|||
|
|||
@GetMapping("/attendedcomplaintshistory") |
|||
public List<Map<String,Object>> getAttendedComplainthistory( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
@RequestParam(required = false) String complaintNumber, |
|||
@RequestParam(required = false) String complaintMobileNumber){ |
|||
|
|||
List<Map<String, Object>> agentAttendedData = agentsService.getAttendedComplainthistory(startDate, endDate, complaintNumber, complaintMobileNumber); |
|||
System.out.println("Agent attended Data: " + agentAttendedData); |
|||
return agentAttendedData; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/agenttaskassign") |
|||
public List<Map<String, Object>> getAgentTaskwiseAssign(@RequestParam String agentId) { |
|||
// Call the service to fetch agent task-wise data |
|||
List<Map<String, Object>> agentTaskwiseAssign = agentsService.getAgentTaskwiseAssign(agentId); |
|||
//System.out.println("Agent Task Wise Assign: " + agentTaskwiseAssign); |
|||
return agentTaskwiseAssign; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,408 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Objects; |
|||
import java.util.stream.Stream; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent/qaqccalls") |
|||
@RestController |
|||
public class QaqcCallsController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public QaqcCallsController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("dataId") int dataId, @RequestParam("action") String action, |
|||
@RequestParam("userId") String userId, |
|||
@RequestParam(value = "remainderDate", required = false, defaultValue = "-") String remainderDate, |
|||
@RequestParam("remarks") String remarks) { |
|||
try { |
|||
System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
System.out.println("Updating Data ID: " + dataId); |
|||
System.out.println("Action: " + action); |
|||
System.out.println("Remarks: " + remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
System.out.println("updated_agent: " + updated_agent); |
|||
|
|||
|
|||
// Map<String,Object> followUpComplaint = |
|||
// qaqcCallsService.checkComplaintDetail(complaintNumber); |
|||
// |
|||
// try { |
|||
// int followupid = (int) followUpComplaint.get("id"); |
|||
// // update complaintstaus if exist in followup call logs table |
|||
// if (followUpComplaint != null &&!followUpComplaint.isEmpty()) |
|||
// { |
|||
// qaqcCallsService.updateFollowupCallLogs(complaintNumber, action, remarks,followupid); |
|||
// } |
|||
// |
|||
// } |
|||
// catch(Exception e) |
|||
// { |
|||
// System.out.println("Exception:"+e); |
|||
// } |
|||
|
|||
//to insert incorrect office mobile number details in table |
|||
if(action.equals("MOBILE_NUM")) { |
|||
qaqcCallsService.saveMobileNumDetails(complaintNumber, remarks); } |
|||
|
|||
// Get complaint details |
|||
Map<String, Object> complaintDetails =qaqcCallsService.getComplaintDetails(dataId); |
|||
|
|||
Integer agentId = (Integer) complaintDetails.get("agent_id"); |
|||
Map<String,Object> erp_username=qaqcCallsService.getErpnameById(agentId); |
|||
String Erpname=(String) erp_username.get("erp_username"); |
|||
|
|||
// Handle COMPLETED and REOPEN actions |
|||
|
|||
if ("COMPLETED".equals(action) || "REOPEN".equals(action) ||"WRONG_ASSIGN".equals(action)) |
|||
{ |
|||
boolean statusUpdated =qaqcCallsService.ChangeStatusInErp(complaintNumber, remarks, action,Erpname); |
|||
System.out.println("statusUpdated="+statusUpdated); |
|||
if (!statusUpdated) |
|||
{ |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
|
|||
// Execute common update methods |
|||
qaqcCallsService.updateComplaintDetails(complaintNumber, dataId, action,remarks,updated_agent); |
|||
qaqcCallsService.updateComplaintHistoryDetails(complaintNumber,dataId, action, remarks,updated_agent, remainderDate); |
|||
Map<String, Object> logDetails =qaqcCallsService.getComplaintDetails(dataId); |
|||
qaqcCallsService.uploadComplaintDetailsInLogs(logDetails, action,complaintNumber, remainderDate); |
|||
|
|||
|
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getComplaintDetails") |
|||
public Map<String, Object> getComplaintDetails(@RequestParam String complaintNumber) { |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
|
|||
try { |
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getComplaintByID&ComplaintId=" |
|||
+ complaintNumber + "&imgUrlonly=yes&isQcuser=Yes&jsonResp=Yes"; |
|||
System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintDetails = rootNode.path(0).path("ComplaintListHistory").path(0); |
|||
|
|||
String registerDate = complaintDetails.path("complaintopendate").asText("N/A"); |
|||
String ClosedDate = complaintDetails.path("complaintcloseddate").asText("N/A"); |
|||
String ReopenDate = complaintDetails.path("REOPENDDATE").asText("N/A"); |
|||
String FinalcloseDate = complaintDetails.path("FINALCLOSEDDATE").asText("N/A"); |
|||
|
|||
System.out.println("registerdate=====" + registerDate); |
|||
|
|||
String formattedDate = "N/A"; // Default value if parsing fails |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty()) { |
|||
try { |
|||
// Parse the input date string |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
Date date = inputFormat.parse(registerDate); |
|||
|
|||
// Format the date to dd-MM-yyyy |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy"); |
|||
formattedDate = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log exception for debugging |
|||
} |
|||
} |
|||
|
|||
|
|||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); |
|||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
|||
|
|||
LocalDateTime maxDate = Stream.of(registerDate, ClosedDate, ReopenDate, FinalcloseDate) |
|||
.filter(date -> date != null && !date.equalsIgnoreCase("null")) |
|||
.map(date -> { |
|||
try { |
|||
return LocalDateTime.parse(date, inputFormatter); |
|||
} catch (DateTimeParseException e) { |
|||
return null; // Skip invalid date formats |
|||
} |
|||
}) |
|||
.filter(Objects::nonNull) |
|||
.max(LocalDateTime::compareTo) // Find the greatest date |
|||
.orElse(null); // Default to null if no valid dates are found |
|||
|
|||
String greatestDateFormatted = (maxDate != null) ? maxDate.format(outputFormatter) : "N/A"; |
|||
|
|||
if (!complaintDetails.isMissingNode()) { |
|||
// Existing fields |
|||
resultMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
resultMap.put("complaintdate", formattedDate); |
|||
resultMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
resultMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
resultMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
resultMap.put("description", complaintDetails.path("complaintdetails").asText("N/A")); |
|||
resultMap.put("currentStatus", complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
resultMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
resultMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
resultMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
resultMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
resultMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
resultMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
resultMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
resultMap.put("gender", complaintDetails.path("GENDER").asText("N/A")); |
|||
resultMap.put("deptname", complaintDetails.path("DEPT_NAME").asText("N/A")); |
|||
resultMap.put("compmode", complaintDetails.path("COMP_MODE").asText("N/A")); |
|||
resultMap.put("greatestDate", greatestDateFormatted); |
|||
|
|||
// Comments section |
|||
JsonNode comments = complaintDetails.path("Comments"); |
|||
if (!comments.isMissingNode()) { |
|||
List<Map<String, Object>> commentList = new ArrayList<>(); |
|||
for (JsonNode commentNode : comments) { |
|||
Map<String, Object> commentData = new HashMap<>(); |
|||
|
|||
// Extracting comment details |
|||
commentData.put("user", commentNode.path("user").asText("N/A")); |
|||
commentData.put("message", commentNode.path("message").asText("N/A")); |
|||
commentData.put("comment_date", commentNode.path("comment_date").asText("N/A")); |
|||
|
|||
// Handling media link (Image) as part of userimages array for each comment |
|||
JsonNode userImages = commentNode.path("userimages"); |
|||
if (!userImages.isMissingNode() && userImages.isArray() && userImages.size() > 0) { |
|||
String mediaLink = userImages.get(0).path("Comp_Image").asText(null); |
|||
// If media link is valid, add it to the comment data |
|||
if (mediaLink != null && !mediaLink.equals("null") && !mediaLink.isEmpty()) { |
|||
commentData.put("Comp_Image", mediaLink); |
|||
} else { |
|||
commentData.put("Comp_Image", "No image available"); |
|||
} |
|||
} else { |
|||
commentData.put("Comp_Image", "No image available"); |
|||
} |
|||
|
|||
// Add the comment data to the list |
|||
commentList.add(commentData); |
|||
} |
|||
resultMap.put("comments", commentList); |
|||
} |
|||
|
|||
// Handling media link (Image) as part of userimages array |
|||
String mediaLink = complaintDetails.path("mediaLink").asText(null); |
|||
List<Map<String, String>> userImagesList = new ArrayList<>(); |
|||
Map<String, String> imageMap = new HashMap<>(); |
|||
imageMap.put("Comp_Image", mediaLink != null && !mediaLink.equals("null") ? mediaLink : null); |
|||
userImagesList.add(imageMap); |
|||
resultMap.put("userimages", userImagesList); |
|||
|
|||
System.out.println("Image URL from API: " + mediaLink); |
|||
} |
|||
} else { |
|||
resultMap.put("error", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("error", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
@GetMapping("/getComplaintDetailsByMobileNumber") |
|||
public Map<String, Object> getComplaintDetailsByMobileNumber(@RequestParam String complaintMobileNumber, |
|||
@RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate, |
|||
@RequestParam String complaintYear) { |
|||
|
|||
System.out.println("Computed Start Date: " + startDate); |
|||
System.out.println("Computed End Date: " + endDate); |
|||
System.out.println("Computed Year: " + complaintYear); |
|||
System.out.println("Computed MobileNumber: " + complaintMobileNumber); |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
List<Map<String, Object>> complaintsList = new ArrayList<>(); |
|||
|
|||
try { |
|||
// Determine current year's starting date and today's date |
|||
LocalDate currentDate = LocalDate.now(); |
|||
LocalDate yearStartDate = currentDate.withDayOfYear(1); |
|||
|
|||
// Set default dates if startDate or endDate are empty |
|||
if (startDate == null || startDate.isEmpty()) { |
|||
startDate = yearStartDate.toString(); // Set to current year's start date |
|||
} |
|||
if (endDate == null || endDate.isEmpty()) { |
|||
endDate = currentDate.toString(); // Set to today's date |
|||
} |
|||
|
|||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); |
|||
|
|||
startDate = LocalDate.parse(startDate, inputFormatter).format(outputFormatter); |
|||
endDate = LocalDate.parse(endDate, inputFormatter).format(outputFormatter); |
|||
|
|||
// Debug logs (optional) |
|||
System.out.println("Formatted Start Date: " + startDate); |
|||
System.out.println("Formatted End Date: " + endDate); |
|||
|
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getComplaintListWithImg&From_date=" |
|||
+ startDate + "&To_date=" + endDate |
|||
+ "&jsonResp=Yes&UserType=Public&Token=&PageIndex=null&Status=null&repYear=" + complaintYear |
|||
+ "&MobileNo=" + complaintMobileNumber; |
|||
|
|||
System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
// System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintListHistory = rootNode.path(0).path("ComplaintListHistory"); |
|||
|
|||
if (complaintListHistory.isArray()) { |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy"); |
|||
for (JsonNode complaintDetails : complaintListHistory) { |
|||
Map<String, Object> complaintMap = new HashMap<>(); |
|||
|
|||
String registerDate = complaintDetails.path("complaintopendate").asText("N/A"); |
|||
Date parsedDate = null; |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty() && !"null".equalsIgnoreCase(registerDate)) { |
|||
try { |
|||
parsedDate = inputFormat.parse(registerDate); |
|||
String formattedDate = outputFormat.format(parsedDate); |
|||
complaintMap.put("complaintdate", formattedDate); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
complaintMap.put("complaintdate", "N/A"); |
|||
} |
|||
} else { |
|||
complaintMap.put("complaintdate", "N/A"); |
|||
} |
|||
|
|||
// Add complaint details to the map |
|||
complaintMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
complaintMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
complaintMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
complaintMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
complaintMap.put("currentStatus",complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
complaintMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
complaintMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
complaintMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
complaintMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
complaintMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
complaintMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
complaintMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
String closedDate = complaintDetails.path("complaintcloseddate").asText("N/A"); |
|||
|
|||
// Check if the value is explicitly "null" (as a string) |
|||
if ("null".equalsIgnoreCase(closedDate)) { |
|||
closedDate = "N/A"; |
|||
} |
|||
|
|||
complaintMap.put("complaintcloseddate", closedDate); |
|||
complaintMap.put("parsedComplaintDate", parsedDate); |
|||
|
|||
// Add the complaint to the list |
|||
complaintsList.add(complaintMap); |
|||
} |
|||
|
|||
// Sort complaintsList by parsedComplaintDate in descending order |
|||
complaintsList.sort((a, b) -> { |
|||
Date dateA = (Date) a.get("parsedComplaintDate"); |
|||
Date dateB = (Date) b.get("parsedComplaintDate"); |
|||
if (dateA == null && dateB == null) return 0; |
|||
if (dateA == null) return 1; |
|||
if (dateB == null) return -1; |
|||
return dateB.compareTo(dateA); |
|||
}); |
|||
|
|||
for (Map<String, Object> complaint : complaintsList) { |
|||
complaint.remove("parsedComplaintDate"); |
|||
} |
|||
} |
|||
resultMap.put("status", "success"); |
|||
resultMap.put("complaints", complaintsList); |
|||
} else { |
|||
resultMap.put("status", "error"); |
|||
resultMap.put("message", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("status", "error"); |
|||
resultMap.put("message", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
/* |
|||
* System.out.println("Computed Start Date: " + startDate); |
|||
* System.out.println("Computed End Date: " + endDate); |
|||
* System.out.println("Computed Year: " + complaintYear); |
|||
* System.out.println("Computed MobileNumber: " + complaintMobileNumber); |
|||
* |
|||
* String url |
|||
* ="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getComplaintListWithImg&From_date=" |
|||
* +startDate+"&To_date="+endDate+ |
|||
* "&jsonResp=Yes&UserType=Public&Token=&PageIndex=null&Status=null&repYear="+ |
|||
* complaintYear+"&MobileNo="+complaintMobileNumber; |
|||
* |
|||
* System.out.println("Request URL: " + url); |
|||
* |
|||
*/ |
|||
|
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
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 org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcTaskListService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/qaqctasklist") |
|||
@RestController |
|||
public class QaqcTaskListAPIController { |
|||
|
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
|
|||
@Autowired |
|||
public QaqcTaskListAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcTaskListService tasklist; |
|||
|
|||
@GetMapping("/overalltaskcount") |
|||
public List<Map<String, Object>> getComplaintAndCallStatusCounts( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
List<Map<String, Object>> counts = tasklist.getComplaintAndCallStatusCounts(startDate, endDate); |
|||
System.out.println("overallcounts:" + counts); |
|||
return counts; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/taskdatacount") |
|||
public List<Map<String, Object>> getTaskwiseData( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
List<Map<String, Object>> taskdata = tasklist.getTaskwiseData(startDate, endDate); |
|||
System.out.println("taskdata "+ taskdata); |
|||
return taskdata; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/agentdatacount") |
|||
public List<Map<String, Object>> getAgentwiseData(@RequestParam String qaqc_id) |
|||
{ |
|||
List<Map<String, Object>> agentwisedata = tasklist.getAgentwiseData(qaqc_id); |
|||
System.out.println("agentdata "+agentwisedata); |
|||
return agentwisedata; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,346 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.io.InputStream; |
|||
import java.net.URL; |
|||
import java.net.URLConnection; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.SocialMediaService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/socialmedia") |
|||
@RestController |
|||
public class SocialMediaController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public SocialMediaService socialservice; |
|||
|
|||
@Autowired |
|||
public SocialMediaController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("userId") String userId,@RequestParam("action") String action,@RequestParam("remarks") String remarks |
|||
) { |
|||
try { |
|||
System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
System.out.println("userId= " + userId); |
|||
System.out.println("action= " + action); |
|||
System.out.println("remarks="+remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
System.out.println("updated_agent: " + updated_agent); |
|||
if(remarks.isEmpty()) |
|||
{ |
|||
remarks="N/A"; |
|||
} |
|||
|
|||
String erp_name=socialservice.getErpusernamebyId(userId); |
|||
if (erp_name.isEmpty()) { |
|||
return ResponseEntity.ok("erpname"); |
|||
} |
|||
|
|||
if ("COMPLETED".equals(action) || "REOPEN".equals(action)) |
|||
{ |
|||
boolean statusUpdated =ChangeStatusInErp(complaintNumber,action,remarks,erp_name); |
|||
System.out.println("statusUpdated="+statusUpdated); |
|||
|
|||
if (!statusUpdated) |
|||
{ |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
Map<String, Object> details =getDetailsByComplaintNumber(complaintNumber); |
|||
int rowInserted=socialservice.uploadComplaintDetailsInLogs(details,action,remarks,updated_agent); |
|||
if(rowInserted!=1) |
|||
{ |
|||
return ResponseEntity.ok("save"); |
|||
} |
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
public Map<String, Object> getDetailsByComplaintNumber(String complaintNumber) { |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
|
|||
try { |
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getComplaintByID&ComplaintId=" |
|||
+ complaintNumber + "&imgUrlonly=yes"; |
|||
System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintDetails = rootNode.path(0).path("ComplaintListHistory").path(0); |
|||
|
|||
String registerDate=complaintDetails.path("complaintopendate").asText("N/A"); |
|||
System.out.println("registerdate====="+registerDate); |
|||
|
|||
String formattedDate = "N/A"; // Default value if parsing fails |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty()) { |
|||
try { |
|||
// Parse the input date string |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
Date date = inputFormat.parse(registerDate); |
|||
|
|||
// Format the date to dd-MM-yyyy |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy"); |
|||
formattedDate = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log exception for debugging |
|||
} |
|||
} |
|||
|
|||
if (!complaintDetails.isMissingNode()) { |
|||
// Existing fields |
|||
resultMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
resultMap.put("complaintdate", formattedDate); |
|||
resultMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
resultMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
resultMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
resultMap.put("description", complaintDetails.path("complaintdetails").asText("N/A")); |
|||
resultMap.put("currentStatus", complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
resultMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
resultMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
resultMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
resultMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
resultMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
resultMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
resultMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
resultMap.put("gender", complaintDetails.path("GENDER").asText("N/A")); |
|||
resultMap.put("deptname",complaintDetails.path("DEPT_NAME").asText("N/A")); |
|||
resultMap.put("compmode", complaintDetails.path("COMP_MODE").asText("N/A")); |
|||
resultMap.put("Officialname", complaintDetails.path("Officialname").asText("N/A")); |
|||
|
|||
|
|||
} |
|||
} else { |
|||
resultMap.put("error", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("error", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
|
|||
public boolean ChangeStatusInErp(String complaintNumber,String action ,String remarks,String erp_name) { |
|||
String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?"; |
|||
String status = ""; |
|||
|
|||
|
|||
//String Erpname ="QAops1"; |
|||
|
|||
try { |
|||
// Encode parameters |
|||
String encodedComplaintNumber = URLEncoder.encode(complaintNumber, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedRemarks = URLEncoder.encode(remarks, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedErpname = URLEncoder.encode(erp_name, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
|
|||
// Determine status based on action |
|||
if ("COMPLETED".equals(action)) { |
|||
status = "11"; |
|||
} else if ("REOPEN".equals(action)) { |
|||
status = "9"; |
|||
} else { |
|||
return false; // Invalid action, return false |
|||
} |
|||
|
|||
// Construct the URL |
|||
String urlString = baseUrl |
|||
+ "serviceId=UpdateComplaint" |
|||
+ "&ComplaintId=" + encodedComplaintNumber |
|||
+ "&Message=" + encodedRemarks |
|||
+ "&UserType=Official" |
|||
+ "&Status=" + status |
|||
+ "&Comp_Image=" |
|||
+ "&erp_username=" + encodedErpname; |
|||
|
|||
System.out.println("ERP Hitting URL="+urlString); |
|||
|
|||
// Send the request |
|||
return sendRequest(urlString); |
|||
// return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
private boolean sendRequest(String urlString) { |
|||
try { |
|||
URL url = new URL(urlString); |
|||
URLConnection urlcon = url.openConnection(); |
|||
InputStream stream = urlcon.getInputStream(); |
|||
StringBuilder responseBuilder = new StringBuilder(); |
|||
int i; |
|||
while ((i = stream.read()) != -1) { |
|||
responseBuilder.append((char) i); |
|||
} |
|||
stream.close(); |
|||
|
|||
// Parse the response |
|||
String response = responseBuilder.toString(); |
|||
System.out.println("Raw Response: " + response); |
|||
|
|||
// Check ResultStatus in the response |
|||
if (response.contains("\"ResultStatus\": true")) { |
|||
System.out.println("ResultStatus is true in the response."); |
|||
return true; |
|||
} else { |
|||
System.out.println("ResultStatus is false or not present in the response."); |
|||
return false; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getsocialmediacomps") |
|||
public Map<String, Object> viewSocialMediaData( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, |
|||
@RequestParam String status, |
|||
@RequestParam String group, |
|||
@RequestParam String type, |
|||
@RequestParam String zone) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
LocalDate fromLocalDate = LocalDate.parse(startDate, DateTimeFormatter.ISO_DATE); |
|||
LocalDate toLocalDate = LocalDate.parse(endDate, DateTimeFormatter.ISO_DATE); |
|||
String formattedFromDate = fromLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
String formattedToDate = toLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
|
|||
String mode="SOCIAL MEDIA"; |
|||
|
|||
String encoded_mode=URLEncoder.encode(mode, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
|
|||
//String url="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+encoded_mode+"&Zoneid="+zone; |
|||
|
|||
String url="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+mode+"&Zoneid="+zone; |
|||
|
|||
System.out.println(url); |
|||
|
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
|
|||
// Fetch response as String |
|||
ResponseEntity<String> responses = restTemplate.getForEntity(url, String.class); |
|||
String rawResponse = responses.getBody(); |
|||
|
|||
// Preprocess response to remove invalid characters if needed |
|||
if (rawResponse != null) { |
|||
//rawResponse = rawResponse.replaceAll("\"\"", "\""); // Replace double-double quotes |
|||
//rawResponse = rawResponse.replaceAll("(?<![,{])\"R", "\"R"); // Example: Fix missing commas |
|||
} |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> responseMap = objectMapper.readValue(rawResponse, Map.class); |
|||
List<Map<String, Object>> details = (List<Map<String, Object>>) responseMap.get("Details"); |
|||
//System.out.println(details); |
|||
if (details == null) { |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No Data, please change criteria"); |
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("details", details); |
|||
} |
|||
|
|||
} |
|||
catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred while fetching data."); |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
@GetMapping("/socialmediacompletedlist") |
|||
public Map<String, Object> viewSocialMediaCompletedData( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, @RequestParam String status, |
|||
@RequestParam String zone) { |
|||
|
|||
System.out.printf("==================="+startDate,endDate,zone); |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
LocalDate fromLocalDate = LocalDate.parse(startDate, DateTimeFormatter.ISO_DATE); |
|||
LocalDate toLocalDate = LocalDate.parse(endDate, DateTimeFormatter.ISO_DATE); |
|||
String formattedFromDate = fromLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
|||
String formattedToDate = toLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
|||
|
|||
List<Map<String, Object>> details= socialservice.getdetails(formattedFromDate,formattedToDate,status,zone); |
|||
if(details==null) |
|||
{ |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No data for Selected filter"); |
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("details", details); |
|||
} |
|||
} |
|||
catch (DateTimeParseException e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "Invalid date format. Please use 'yyyy-MM-dd'."); |
|||
e.printStackTrace(); |
|||
} |
|||
catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred while fetching data."); |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import java.util.Map; |
|||
|
|||
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 in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.StatusCountService; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc") |
|||
@RestController |
|||
public class StatusCountController { |
|||
|
|||
@Autowired |
|||
private StatusCountService statusCountService; |
|||
|
|||
|
|||
@Autowired |
|||
public StatusCountController(StatusCountService statusCountService) { |
|||
this.statusCountService = statusCountService; |
|||
} |
|||
|
|||
@GetMapping("/dashboard") |
|||
public ResponseEntity<Map<String, String>> getDashboardData( |
|||
@RequestParam(value = "startDate", required = false, defaultValue = "") String fromDate, |
|||
@RequestParam(value = "endDate", required = false, defaultValue = "") String toDate, |
|||
@RequestParam(value = "dropdown1", required = false, defaultValue = "") String compType, |
|||
@RequestParam(value = "dropdown2", required = false, defaultValue = "") String zoneName, |
|||
@RequestParam(value = "dropdown3", required = false,defaultValue = "") String compMode, |
|||
@RequestParam(value = "dropdown4", required = false, defaultValue = "") String compGroup) { |
|||
|
|||
Map<String, String> counts = statusCountService.fetchComplaintCounts(fromDate, toDate, compType, zoneName, compMode, compGroup); |
|||
System.out.println("counts:" + counts); |
|||
//System.out.println("group:" + compGroup); |
|||
return ResponseEntity.ok(counts); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getComplaintTypesByGroup") |
|||
public ResponseEntity<List<String>> getComplaintTypesByGroup(@RequestParam String group) { |
|||
List<String> complaintTypes = statusCountService.fetchComplaintTypes(group); |
|||
return ResponseEntity.ok(complaintTypes); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getComplaintGroup") |
|||
public ResponseEntity<List<String>> getComplaintGroup() { |
|||
List<String> complaintGroup= statusCountService.fetchComplaintGroup(); |
|||
//System.out.println("types:"+complaintTypes); |
|||
return ResponseEntity.ok(complaintGroup); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getModes") |
|||
public ResponseEntity<List<String>> getModes() { |
|||
List<String> modes= statusCountService.fetchModes(); |
|||
//System.out.println("types:"+modes); |
|||
return ResponseEntity.ok(modes); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getZones") |
|||
public ResponseEntity<List<String>> getZones() { |
|||
List<String> zones= statusCountService.fetchZones(); |
|||
//System.out.println("types:"+zones); |
|||
return ResponseEntity.ok(zones); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
|
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.WhatsappqaqcMsgService; |
|||
|
|||
@RestController("callcenterqaqcwhatsapp") |
|||
@RequestMapping("/gcc/qaqc/api/whatsapp") |
|||
public class WhatsappController { |
|||
|
|||
@Autowired |
|||
private WhatsappqaqcMsgService whatsappqaqcMsgService; |
|||
|
|||
@PostMapping("/send-whatsapp-message") |
|||
public ResponseEntity<String> sendWhatsAppMessage(@RequestParam String msgUrl,@RequestParam String tamilmsgUrl) { |
|||
String response = whatsappqaqcMsgService.sendMsg(msgUrl,tamilmsgUrl); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,67 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Random; |
|||
|
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service |
|||
public class ComplaintService { |
|||
|
|||
private final String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; |
|||
|
|||
public String fetchComplaintCategories() { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String url = baseUrl + "?serviceId=getComplCategory&ComplaintGroupId=null"; |
|||
return restTemplate.getForObject(url, String.class); |
|||
} |
|||
|
|||
public String fetchComplaintSubTypes(String groupId) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String url = baseUrl + "?serviceId=getComplCategory&ComplaintGroupId=" + groupId; |
|||
return restTemplate.getForObject(url, String.class); |
|||
} |
|||
|
|||
public List<Map<String, Object>> fetchComplaintDetailsById(String complaintId) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String url = baseUrl + "?serviceId=getComplaintByID&ComplaintId=" + complaintId; |
|||
String response = restTemplate.getForObject(url, String.class); |
|||
|
|||
try { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
return objectMapper.readValue(response, new TypeReference<List<Map<String, Object>>>() { |
|||
}); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public List<Map<String, Object>> fetchComplaintDetailsByMobile(String mobileNo) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String url = baseUrl |
|||
+ "?serviceId=getComplaintListWithImg&From_date=01/01/2024&To_date=20/08/2024&jsonResp=Yes&UserType=Public&MobileNo=" |
|||
+ mobileNo + "&PageIndex=null&Status=null&repYear=2024"; |
|||
String response = restTemplate.getForObject(url, String.class); |
|||
|
|||
try { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
return objectMapper.readValue(response, new TypeReference<List<Map<String, Object>>>() { |
|||
}); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,172 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
@Service |
|||
public class FollowUpService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowUpCalls(int agent_id) { |
|||
String query = "SELECT data_id, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, " + |
|||
"complaint_type, official_name, official_mobilenum, call_category, complaint_mode, department " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'OFFICIALFOLLOWUP' AND agent_id = ? AND is_processed = FALSE"; |
|||
|
|||
return jdbcTemplate.queryForList(query, agent_id); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowUpCatergory() |
|||
{ |
|||
String query = "SELECT call_status " + |
|||
"FROM gcc_1913_qaqc.call_status WHERE call_category_id = 2 and isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
//public List<Map<String, Object>> getAgentCallStatus(int agentId) { |
|||
// |
|||
// String query = "SELECT " + |
|||
// " (SELECT SUM(aa.data_count) " + |
|||
// " FROM agent_assigned aa " + |
|||
// " WHERE aa.agent_id = ?) AS total_data_count, " + |
|||
// " COUNT(CASE WHEN cl.call_status = 'COMPLETED' THEN 1 END) AS completed_count, " + |
|||
// " COUNT(CASE WHEN cl.call_status != 'COMPLETED' THEN 1 END) AS pending_count " + |
|||
// "FROM " + |
|||
// " qaqc_call_logs cl " + |
|||
// "WHERE " + |
|||
// " cl.agent_id = ?"; |
|||
// return jdbcTemplate.queryForList(query,agentId); |
|||
// |
|||
// } |
|||
|
|||
public void updateFollowupComplaintDetails(String complaintNumber,int dataId, String action, String remarks,int updated_agent) |
|||
{ |
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data " + |
|||
"SET call_status = ?, " + " remarks = ?, updated_agent=?," + |
|||
" updated_date = CURRENT_TIMESTAMP, " + " is_processed = TRUE " + |
|||
"WHERE data_id = ? " +" AND complaint_number = ? "; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks,updated_agent, dataId,complaintNumber); |
|||
|
|||
System.out.println("Rows Updated in upload data: " + rowsUpdated); |
|||
} |
|||
|
|||
@Transactional |
|||
public int uploadComplaintDetailsInLogs(Map<String, Object> logDetails, String action, String complaintNumber, String remainderDate) { |
|||
System.out.println("Complaint Details: " + logDetails); |
|||
// Extract other field values from complaintDetails |
|||
int qaqcid = (int) logDetails.get("qaqc_id"); |
|||
String ccategory = logDetails.get("call_category").toString(); |
|||
String personName = logDetails.get("complaint_person_name").toString(); |
|||
String personMobNo = logDetails.get("complaint_mobilenumber").toString(); |
|||
String complaintDate = logDetails.get("complaint_date").toString(); |
|||
String cType = logDetails.get("complaint_type").toString(); |
|||
String cMode = logDetails.get("complaint_mode").toString(); |
|||
String department = logDetails.get("department").toString(); |
|||
String cGroup = logDetails.get("complaint_group").toString(); |
|||
String officialName = logDetails.get("official_name").toString(); |
|||
String officialMobileNum = logDetails.get("official_mobilenum").toString(); |
|||
String callStatus = logDetails.get("call_status").toString(); |
|||
String remarks = logDetails.get("remarks").toString(); |
|||
int agentId = (int) logDetails.get("agent_id"); |
|||
int updated_agent=(int)logDetails.get("updated_agent"); |
|||
boolean isProcessed = (boolean)logDetails.get("is_processed"); |
|||
LocalDateTime currentDate = LocalDateTime.now(); |
|||
|
|||
// Determine which table to insert into based on the action |
|||
if (action.equals("FOLLOWUP")) { |
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_followup_call_logs " |
|||
+ "SET qaqc_id = ?, call_category = ?, agent_id = ?, remainder_date = ?, call_status = ?, remarks = ?, updated_agent = ?, updated_date = CURRENT_TIMESTAMP " |
|||
+ "WHERE complaint_number = ? " |
|||
+ "AND id = (SELECT max_id FROM (SELECT MAX(id) AS max_id FROM gcc_1913_qaqc.qaqc_followup_call_logs WHERE complaint_number = ?) AS temp)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query,qaqcid, ccategory,agentId,remainderDate, callStatus, remarks,updated_agent,complaintNumber,complaintNumber); |
|||
System.out.println("Rows Updated in qaqc_followup_call_logs : " + rowsAffected); |
|||
|
|||
|
|||
String query1 = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number, complaint_date,complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name,remainder_date, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"; |
|||
|
|||
int rowsAffected1 = jdbcTemplate.update(query1, qaqcid, ccategory, agentId, complaintNumber, complaintDate,personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName,remainderDate, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
System.out.println("Rows Updated in qaqc_call_logs : " + rowsAffected1); |
|||
|
|||
return rowsAffected + rowsAffected1; |
|||
|
|||
} else { |
|||
|
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_followup_call_logs " |
|||
+ "SET qaqc_id = ?, call_category = ?, agent_id = ?, call_status = ?, remarks = ?, updated_agent = ?, updated_date = CURRENT_TIMESTAMP " |
|||
+ "WHERE complaint_number = ? " |
|||
+ "AND id = (SELECT max_id FROM (SELECT MAX(id) AS max_id FROM gcc_1913_qaqc.qaqc_followup_call_logs WHERE complaint_number = ?) AS temp)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query,qaqcid, ccategory,agentId, callStatus, remarks,updated_agent,complaintNumber,complaintNumber); |
|||
System.out.println("Rows Updated in qaqc_followup_call_logs : " + rowsAffected); |
|||
|
|||
String query1 = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number,complaint_date, complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
int rowsAffected1 = jdbcTemplate.update(query1, qaqcid, ccategory, agentId, complaintNumber,complaintDate, personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
|
|||
System.out.println("Rows Updated in qaqc_call_logs: " + rowsAffected1); |
|||
|
|||
return rowsAffected + rowsAffected1; |
|||
} |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getCallHistory(String complaintNumber) |
|||
{ |
|||
String query = "SELECT complaint_number, agent_id, remainder_date, remarks, created_date " + |
|||
"FROM gcc_1913_qaqc.qaqc_call_logs " + |
|||
"WHERE complaint_number = ? and call_status='FOLLOWUP'"; |
|||
return jdbcTemplate.queryForList(query, complaintNumber); |
|||
|
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowupSubmitDetails(int userId) { |
|||
|
|||
String query = "SELECT complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber,official_name,official_mobilenum, " + |
|||
"complaint_type, call_status, remarks " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'OFFICIALFOLLOWUP' AND agent_id = ? AND is_processed = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query,userId); |
|||
|
|||
} |
|||
|
|||
public void updateComplaintHistoryDetails(String complaintNumber, int dataId, String action, String remarks,int updated_agent, |
|||
String remainderDate) { |
|||
|
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data_history \r\n" |
|||
+ "SET call_status = ?, remarks = ?, updated_date = CURRENT_TIMESTAMP, remainder_date = ?,updated_agent=?\r\n" |
|||
+ "WHERE data_id = ? AND complaint_number = ?"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks, remainderDate, updated_agent,dataId, complaintNumber); |
|||
|
|||
System.out.println("Rows Updated in upload history: " + rowsUpdated); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,102 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@Service |
|||
public class InprogresscallService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getActionsCatergory() |
|||
{ |
|||
String query = "SELECT call_status " + |
|||
"FROM gcc_1913_qaqc.call_status WHERE call_category_id = 3 and isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
// public List<Map<String, Object>> getInProgressCalls(int agent_id) { |
|||
// String sql = "SELECT complaint_number, " + |
|||
// " official_name , " + |
|||
// " official_mobilenum , " + |
|||
// " complaint_type, " + |
|||
// " call_category, " + |
|||
// " complaint_mode, " + |
|||
// " department " + |
|||
// |
|||
// "FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
// "WHERE call_category ='inprogress' and agent_id= ?"; |
|||
// |
|||
// |
|||
// return jdbcTemplate.queryForList(sql, agent_id); |
|||
// } |
|||
|
|||
public List<Map<String, Object>> getInProgressCalls(int agent_id) { |
|||
String query = "SELECT data_id, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, " + |
|||
"complaint_type, official_name, official_mobilenum, call_category, complaint_mode, department " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE (call_category = 'PROCESSING' OR call_category = 'REOPENED' OR call_category = 'REDRESSED' OR call_category = 'INPROGRESS') " + |
|||
" AND is_processed = FALSE " + |
|||
" AND agent_id = ?"; |
|||
return jdbcTemplate.queryForList(query, agent_id); |
|||
} |
|||
|
|||
public void updateInprogressComplaintDetails(String complaintNumber,int dataId, String action, String remarks,int updated_agent) |
|||
{ |
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data " + |
|||
"SET call_status = ?, " + " remarks = ?,updated_agent=?, " + |
|||
" updated_date = CURRENT_TIMESTAMP, " + " is_processed = TRUE " + |
|||
"WHERE data_id = ? " +" AND complaint_number = ?"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks,updated_agent, dataId,complaintNumber); |
|||
|
|||
System.out.println("Rows Updated in upload data: " + rowsUpdated); |
|||
} |
|||
|
|||
public void saveMobileNumDetails(String complaintNumber, String remarks) { |
|||
String query = "insert into officer_mobileno (complaint_number,remarks) values(?,?)"; |
|||
int rowsUpdated = jdbcTemplate.update(query, complaintNumber, remarks); |
|||
System.out.println("Rows Updated: " + rowsUpdated); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getInprogressSubmitDetails(int userId) { |
|||
|
|||
String query = "SELECT complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber,official_name,official_mobilenum, " + |
|||
"complaint_type, call_status, remarks " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE (call_category = 'PROCESSING' OR call_category = 'REOPENED' OR call_category = 'REDRESSED' OR call_category = 'INPROGRESS') AND agent_id = ? AND is_processed = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query,userId); |
|||
|
|||
} |
|||
|
|||
|
|||
public void updateComplaintHistoryDetails(String complaintNumber, int dataId, String action, String remarks,int updated_agent, |
|||
String remainderDate) { |
|||
|
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data_history \r\n" |
|||
+ "SET call_status = ?, remarks = ?, updated_date = CURRENT_TIMESTAMP, remainder_date = ?,updated_agent=?\r\n" |
|||
+ "WHERE data_id = ? AND complaint_number = ?"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks, remainderDate,updated_agent, dataId, complaintNumber); |
|||
|
|||
System.out.println("Rows Updated in upload data history: " + rowsUpdated); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class PublicFollowUpService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowUpCalls(int agent_id) { |
|||
String query = "SELECT data_id, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, " + |
|||
"complaint_type, official_name, official_mobilenum, call_category, complaint_mode, department " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'PUBLICFOLLOWUP' AND agent_id = ? AND is_processed = FALSE"; |
|||
|
|||
return jdbcTemplate.queryForList(query, agent_id); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowUpCatergory() |
|||
{ |
|||
String query = "SELECT call_status " + |
|||
"FROM gcc_1913_qaqc.call_status WHERE call_category_id = 4 and isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowupSubmitDetails(int userId) { |
|||
|
|||
String query = "SELECT complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber,official_name,official_mobilenum, " + |
|||
"complaint_type, call_status, remarks " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'PUBLICFOLLOWUP' AND agent_id = ? AND is_processed = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query,userId); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class QaqcAdminSettingService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional |
|||
public int updateProductivity(int productivity_count) { |
|||
String updateSql = "UPDATE productivity SET productivity_count=? where isactive='1' and isdelete='0'"; |
|||
return jdbcTemplate.update(updateSql,productivity_count); |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public int saveProductivity(int productivity_count) { |
|||
String insertSql = "INSERT INTO productivity (productivity_count) VALUES (?)"; |
|||
return jdbcTemplate.update(insertSql, productivity_count); |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public Integer getProductivity() { |
|||
String insertSql = "select productivity_count\r\n" |
|||
+ "from productivity\r\n" |
|||
+ "where isactive='1' and isdelete='0'" |
|||
+ "LIMIT 1"; |
|||
return jdbcTemplate.queryForObject(insertSql, Integer.class); |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAdminSettingCounts() { |
|||
|
|||
String sqlQuery = "SELECT " + |
|||
"COALESCE(p.productivity_count, 0) AS productivity_count, " + |
|||
"COUNT(al.agent_id) AS total_count, " + |
|||
"COALESCE(p.inbound_count, 0) AS inbound_count, " + |
|||
"COALESCE(p.outbound_count, 0) AS outbound_count, " + |
|||
"COALESCE(p.inbound_count, 0) + COALESCE(p.outbound_count, 0) As assigned, " + |
|||
"(COUNT(al.agent_id) - (COALESCE(p.inbound_count, 0) + COALESCE(p.outbound_count, 0))) AS notassigned " + |
|||
"FROM productivity p " + |
|||
"JOIN agents_list al " + |
|||
"WHERE p.isactive = '1' AND p.isdelete = '0' AND al.isactive = '1' AND al.isdelete = '0' " + |
|||
"GROUP BY p.productivity_count, p.inbound_count, p.outbound_count"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int saveCallingTypeInSettings() { |
|||
// Query to get inbound and outbound counts |
|||
String selectSql = "SELECT\r\n" |
|||
+ "SUM(CASE WHEN calling_type = 'INBOUND' THEN 1 ELSE 0 END) AS inbound, \r\n" |
|||
+ "SUM(CASE WHEN calling_type = 'OUTBOUND' THEN 1 ELSE 0 END) AS outbound \r\n" |
|||
+ "FROM agents_list \r\n" |
|||
+ "WHERE isactive = '1' AND isdelete = '0'"; |
|||
|
|||
// Fetch the counts |
|||
Map<String, Object> result = jdbcTemplate.queryForMap(selectSql); |
|||
int inbound = ((Number) result.get("inbound")).intValue(); // Convert to int |
|||
int outbound = ((Number) result.get("outbound")).intValue(); // Convert to int |
|||
|
|||
//Corrected SQL syntax for updating multiple columns |
|||
String updateSql = "UPDATE productivity SET inbound_count = ?, outbound_count = ? WHERE isactive = '1' AND isdelete = '0'"; |
|||
return jdbcTemplate.update(updateSql, inbound, outbound); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int updateCallType(String calling_type,int agent_id) { |
|||
String updateSql = "UPDATE agents_list SET calling_type=? WHERE agent_id=? AND isactive='1'"; |
|||
|
|||
return jdbcTemplate.update(updateSql,calling_type,agent_id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsForCallingtype() |
|||
{ |
|||
String sqlQuery = "select agent_id,agent_name,mobile_number,calling_type\r\n" |
|||
+ "from agents_list\r\n" |
|||
+ "where isactive='1' and isdelete='0';"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,590 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.ZoneId; |
|||
import java.time.ZonedDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.Collections; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.Statement; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; |
|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
@Service |
|||
public class QaqcAgentAssignService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate2; |
|||
|
|||
@Autowired |
|||
public void setDataSource2(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate2 = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional |
|||
public Integer getCampaignPendingCountForAgent(int agentId) { |
|||
String countQuery = "SELECT COUNT(data_id) FROM gcc_1913_campaign.upload_data WHERE agent_id = ? AND field_14 IS NULL"; |
|||
return jdbcTemplate2.queryForObject(countQuery, Integer.class, agentId); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAvailableOutboundAgents() |
|||
{ |
|||
String sqlQuery = "select agent_id,agent_name\r\n" |
|||
+ "from gcc_1913_qaqc.agents_list\r\n" |
|||
+ "where calling_type='OUTBOUND' and isactive='1' and isdelete='0'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional |
|||
public Integer getTodayCountForAgent(int agentId) { |
|||
String countQuery = "SELECT coalesce(sum(aa.data_count),0) as todaycounts \r\n" |
|||
+ "from gcc_1913_qaqc.agent_assigned aa \r\n" |
|||
+ "join gcc_1913_qaqc.agents_list al on al.agent_id=aa.agent_id \r\n" |
|||
+ "where date(aa.created_date)=curdate() and al.agent_id=?"; |
|||
return jdbcTemplate.queryForObject(countQuery, Integer.class, agentId); |
|||
} |
|||
|
|||
|
|||
|
|||
// @Transactional |
|||
// public List<Map<String, Object>> getAvailableOutboundAgents() |
|||
// { |
|||
// String sqlQuery = "SELECT al.agent_id as agent_id,al.agent_name as agent_name,coalesce(sum(aa.data_count),0) as todaycounts\r\n" |
|||
// + "from agent_assigned aa\r\n" |
|||
// + "join agents_list al on al.agent_id=aa.agent_id\r\n" |
|||
// + "where date(aa.created_date)=curdate() and al.calling_type='OUTBOUND' and al.isactive='1' and al.isdelete='0'\r\n" |
|||
// + "group by al.agent_id,al.agent_name"; |
|||
// |
|||
// return jdbcTemplate.queryForList(sqlQuery); |
|||
// } |
|||
|
|||
|
|||
@Transactional // Ensures atomicity of operations |
|||
public Map<String, Object> assignTasksTransactionally(Map<String, Object> requestData) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
// Extract input data |
|||
String description = (String) requestData.get("description"); |
|||
String fromDate = (String) requestData.get("startDate"); |
|||
String toDate = (String) requestData.get("endDate"); |
|||
String status = (String) requestData.get("closeName"); |
|||
|
|||
String group = (String) requestData.get("group"); |
|||
String type = (String) requestData.get("type"); |
|||
String mode = (String) requestData.get("mode"); |
|||
String zone= (String) requestData.get("zone"); |
|||
|
|||
int closedCount = Integer.parseInt(requestData.get("closedCount").toString()); |
|||
System.out.println("closedCount====="+closedCount); |
|||
List<Map<String, Object>> agents = (List<Map<String, Object>>) requestData.get("agents"); |
|||
System.out.println("agents====="+agents); |
|||
// Step 1: Save task details |
|||
LocalDate fromLocalDate = LocalDate.parse(fromDate, DateTimeFormatter.ISO_DATE); |
|||
LocalDate toLocalDate = LocalDate.parse(toDate, DateTimeFormatter.ISO_DATE); |
|||
String formattedFromDate = fromLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
String formattedToDate = toLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
|
|||
LocalDateTime now = LocalDateTime.now(); |
|||
ZonedDateTime indiaTime = now.atZone(ZoneId.systemDefault()).withZoneSameInstant(ZoneId.of("Asia/Kolkata")); |
|||
String taskId = "#" + indiaTime.format(DateTimeFormatter.ofPattern("yyMMddHHmmss")); |
|||
System.out.println("taskId==="+taskId); |
|||
// if ("closed".equalsIgnoreCase(status)) { |
|||
// status = "Action Taken Level 2"; |
|||
// } |
|||
|
|||
int rowsInserted = savetaskid(taskId, formattedFromDate, formattedToDate, description, status, closedCount,group,type,mode,zone); |
|||
|
|||
if (rowsInserted <= 0) { |
|||
throw new RuntimeException("Failed to create task"); |
|||
} |
|||
|
|||
// Step 2: Get the last task |
|||
List<Map<String, Object>> lastTask = getLastTask(); |
|||
if (lastTask.isEmpty()) { |
|||
throw new RuntimeException("Failed to fetch last task"); |
|||
} |
|||
int qaqcId = (int) lastTask.get(0).get("qaqc_id"); |
|||
|
|||
|
|||
List<Map<String, Object>> assignedIDList = new ArrayList<>(); |
|||
|
|||
System.out.println("Before shuffle: " + agents); |
|||
|
|||
// Shuffle the agents list |
|||
Collections.shuffle(agents); |
|||
|
|||
System.out.println("After shuffle: " + agents); |
|||
// Step 3: Save agents' task counts |
|||
for (Map<String, Object> agent : agents) { |
|||
Integer agentId = Integer.valueOf(agent.get("agentId").toString()); |
|||
Integer dataCounts = Integer.valueOf(agent.get("callsPerAgent").toString()); |
|||
assignedIDList.add( saveInAgentAssigned(agentId, qaqcId, dataCounts)); |
|||
} |
|||
System.out.println("outside assignedIDList===="+assignedIDList); |
|||
|
|||
|
|||
// Step 4: Save upload data |
|||
if (!"officialfollowup".equalsIgnoreCase(status) && !"publicfollowup".equalsIgnoreCase(status)) |
|||
{ |
|||
String url="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+mode+"&Zoneid="+zone; |
|||
System.out.println(url); |
|||
boolean isSaved = processAndSaveDetails(url, qaqcId, agents, status,assignedIDList, mode); |
|||
if (!isSaved) { |
|||
throw new RuntimeException("Failed to process upload data"); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
boolean isSaved=processAndSaveFollowupDetails(qaqcId, agents, status,formattedFromDate); |
|||
if (!isSaved) { |
|||
throw new RuntimeException("Failed to process upload data"); |
|||
} |
|||
} |
|||
|
|||
|
|||
response.put("status", "success"); |
|||
response.put("message", "Data Transferred Successfully"); |
|||
return response; |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getfollowupdata(String fromdate, String status) { |
|||
try { |
|||
// Parse input date from dd/MM/yyyy to yyyy-MM-dd |
|||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); |
|||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|||
LocalDate formattedDate = LocalDate.parse(fromdate, inputFormatter); |
|||
|
|||
// Format the date into yyyy-MM-dd |
|||
String formattedFromDate = formattedDate.format(outputFormatter); |
|||
if (!"officialfollowup".equalsIgnoreCase(status)) |
|||
{ |
|||
String sqlQuery = "SELECT * FROM gcc_1913_qaqc.qaqc_followup_call_logs WHERE remainder_date = ? AND call_status='FOLLOWUP' AND call_category IN ('CLOSED','PUBLICFOLLOWUP')"; |
|||
return jdbcTemplate.queryForList(sqlQuery, formattedFromDate); |
|||
} |
|||
else |
|||
{ |
|||
String sqlQuery = "SELECT * FROM gcc_1913_qaqc.qaqc_followup_call_logs WHERE remainder_date = ? AND call_status='FOLLOWUP' AND call_category NOT IN ('CLOSED','PUBLICFOLLOWUP')"; |
|||
return jdbcTemplate.queryForList(sqlQuery, formattedFromDate); |
|||
} |
|||
|
|||
} catch (DateTimeParseException e) { |
|||
throw new IllegalArgumentException("Invalid date format. Expected dd/MM/yyyy.", e); |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean processAndSaveFollowupDetails(int qaqc_id, List<Map<String, Object>> agents,String status,String fromdate) { |
|||
try { |
|||
|
|||
List<Map<String,Object>> detail=getfollowupdata(fromdate, status); |
|||
|
|||
int index = 0; |
|||
|
|||
for(Map<String, Object> agent: agents) { |
|||
int remainingDataCountForAgent = Integer.parseInt(agent.get("callsPerAgent").toString()); |
|||
//System.out.println(remainingDataCountForAgent); |
|||
int currentAgentId = Integer.parseInt(agent.get("agentId").toString()); |
|||
//System.out.println(agent.get("agentName").toString()); |
|||
|
|||
for (int i = 0; i < remainingDataCountForAgent && index < detail.size(); i++, index++) { |
|||
//System.out.println(i +" "+index); |
|||
// Save the current complaint details with the current agent_id |
|||
String complaintNumber = (String) detail.get(index).get("complaint_number"); |
|||
String complaintDate = (String) detail.get(index).get("complaint_date"); |
|||
String complanitPersonName = (String) detail.get(index).get("complaint_person_name"); |
|||
String complaintPersonMobileNum = (String) detail.get(index).get("complaint_mobilenumber"); |
|||
String complaintType = (String) detail.get(index).get("complaint_type"); |
|||
String complaintMode = (String) detail.get(index).get("complaint_mode"); |
|||
String department = (String) detail.get(index).get("department"); |
|||
String complaintGroup = (String) detail.get(index).get("complaint_group"); |
|||
String officerName = (String) detail.get(index).get("official_name"); |
|||
String officerMobileNumber = (String) detail.get(index).get("official_mobilenum"); |
|||
|
|||
|
|||
String status3=status.toUpperCase(); |
|||
|
|||
// Insert into the database |
|||
String insertQuery = "INSERT INTO gcc_1913_qaqc.qaqc_upload_data (qaqc_id, call_category, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, agent_id) VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
//jdbcTemplate.update(insertQuery, qaqc_id,status3 ,complaintNumber,complaintDate, complanitPersonName, complaintPersonMobileNum, complaintType, complaintMode, department, complaintGroup, officerName, officerMobileNumber, currentAgentId); |
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setInt(1, qaqc_id); |
|||
ps.setString(2, status3); |
|||
ps.setString(3, complaintNumber); |
|||
ps.setString(4, complaintDate); |
|||
ps.setString(5, complanitPersonName); |
|||
ps.setString(6, complaintPersonMobileNum); |
|||
ps.setString(7, complaintType); |
|||
ps.setString(8, complaintMode); |
|||
ps.setString(9, department); |
|||
ps.setString(10, complaintGroup); |
|||
ps.setString(11, officerName); |
|||
ps.setString(12, officerMobileNumber); |
|||
ps.setInt(13, currentAgentId); |
|||
return ps; |
|||
}, keyHolder); |
|||
Number generatedDataId = keyHolder.getKey(); |
|||
|
|||
if (generatedDataId != null) { |
|||
long dataId = generatedDataId.longValue(); |
|||
System.out.println("followdataId=="+dataId); |
|||
// Use the dataId in the next insert for qaqc_upload_data_history |
|||
String sql = "INSERT INTO gcc_1913_qaqc.qaqc_upload_data_history " + |
|||
"(qaqc_id, call_category, complaint_number, complaint_date, complaint_person_name, complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, agent_id, data_id) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
|
|||
jdbcTemplate.update(sql, qaqc_id, status3, complaintNumber, complaintDate, complanitPersonName, |
|||
complaintPersonMobileNum, complaintType, complaintMode, department, |
|||
complaintGroup, officerName, officerMobileNumber, currentAgentId, dataId); |
|||
} |
|||
|
|||
} |
|||
} |
|||
return true; |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean processAndSaveDetails(String url, int qaqc_id, List<Map<String, Object>> agents,String status,List<Map<String, Object>> assignedIDList, String mode) { |
|||
try { |
|||
|
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
|
|||
// Fetch response as String |
|||
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class); |
|||
String rawResponse = response.getBody(); |
|||
|
|||
// Preprocess response to remove invalid characters if needed |
|||
if (rawResponse != null) { |
|||
// rawResponse = rawResponse.replaceAll("\"\"", "\""); // Replace double-double quotes |
|||
// rawResponse = rawResponse.replaceAll("(?<![,{])\"R", "\"R"); // Example: Fix missing commas |
|||
|
|||
} |
|||
|
|||
// Log raw response |
|||
//System.out.println("Raw Response: " + rawResponse); |
|||
|
|||
// Parse JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> responseMap = objectMapper.readValue(rawResponse, Map.class); |
|||
|
|||
// Target the specific field where double-double quotes might appear |
|||
String targetField = "Address"; // Replace with the actual field name |
|||
if (responseMap.containsKey(targetField)) { |
|||
String fieldValue = (String) responseMap.get(targetField); |
|||
if (fieldValue != null && fieldValue.contains("\"\"")) { |
|||
// Clean double-double quotes in the field value |
|||
fieldValue = fieldValue.replaceAll("\"\"", "\""); |
|||
responseMap.put(targetField, fieldValue); // Update the field with cleaned value |
|||
} |
|||
} |
|||
|
|||
// Extract "Details" array from the response |
|||
List<Map<String, Object>> details = (List<Map<String, Object>>) responseMap.get("Details"); |
|||
//System.out.println(details); |
|||
if (details == null) { |
|||
System.err.println("No 'Details' found in the response."); |
|||
return false; // Or handle as per your requirement |
|||
} |
|||
if(mode.isEmpty() || mode.isBlank() || mode==null ) { |
|||
details=details.stream().filter(map-> !map.get("Complaint Mode").equals("SOCIAL MEDIA")).collect(Collectors.toList()); |
|||
} |
|||
|
|||
int index = 0; |
|||
|
|||
List<Map<String, Object>> followupData= getFollowupData(); |
|||
|
|||
List<Map<String, Object>> countDetails = new ArrayList<>(); |
|||
|
|||
for(Map<String, Object> agent: agents) { |
|||
int remainingDataCountForAgent = Integer.parseInt(agent.get("callsPerAgent").toString()); |
|||
//System.out.println(remainingDataCountForAgent); |
|||
int currentAgentId = Integer.parseInt(agent.get("agentId").toString()); |
|||
//System.out.println(agent.get("agentName").toString()); |
|||
|
|||
Map<String, Object> countResult = new HashMap<>(); |
|||
int assignedCount = 0; |
|||
|
|||
for (int i = 0; i < remainingDataCountForAgent && index < details.size(); i++, index++) { |
|||
|
|||
System.out.println("CHECK = "+index+" "+details.get(index).get("Complaint Mode")); |
|||
//System.out.println(i +" "+index); |
|||
|
|||
String complaintNumber1 = (String) details.get(index).get("Complaint Number"); |
|||
System.out.println("complaintNumber = "+complaintNumber1); |
|||
|
|||
Map<String, Object> result = followupData.stream() |
|||
.filter(map -> complaintNumber1.equals(map.get("complaint_number"))) |
|||
.findFirst().orElse(null); |
|||
|
|||
String compnum = ""; |
|||
String callstatus =""; |
|||
Date calldate = null ; |
|||
if(result!= null) { |
|||
compnum = (String) result.get("complaint_number"); |
|||
callstatus = (String) result.get("call_status"); |
|||
calldate = (Date) result.get("remainder_date"); |
|||
} |
|||
|
|||
|
|||
if(!compnum.equals("") && compnum.equals(complaintNumber1)) { |
|||
//System.out.println("1 if complaintNumber = "+complaintNumber); |
|||
Date currentDate = new Date(); |
|||
if(!callstatus.equalsIgnoreCase("followup") && calldate.before(currentDate)) { |
|||
//System.out.println("2 if complaintNumber = "+complaintNumber1); |
|||
String complaintDate = (String) details.get(index).get("Complaint Opened Date"); |
|||
String complanitPersonName = (String) details.get(index).get("Complaint Person Name"); |
|||
String complaintPersonMobileNum = (String) details.get(index).get("Complaint Person Number"); |
|||
String complaintType = (String) details.get(index).get("Complaint Type"); |
|||
String complaintMode = (String) details.get(index).get("Complaint Mode"); |
|||
String department = (String) details.get(index).get("Department"); |
|||
String complaintGroup = (String) details.get(index).get("Complaint Group"); |
|||
String officerName = (String) details.get(index).get("Assign To"); |
|||
String officerMobileNumber = (String) details.get(index).get("Official Contact Number"); |
|||
String status1 = status.toUpperCase(); |
|||
|
|||
|
|||
|
|||
// Insert into the database |
|||
String insertQuery = "INSERT INTO gcc_1913_qaqc.qaqc_upload_data (qaqc_id, call_category, complaint_number,complaint_date, complaint_person_name, complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, agent_id) VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
//jdbcTemplate.update(insertQuery, qaqc_id, status1, complaintNumber1,complaintDate, complanitPersonName, complaintPersonMobileNum, complaintType, complaintMode, department, complaintGroup, officerName, officerMobileNumber, currentAgentId); |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setInt(1, qaqc_id); |
|||
ps.setString(2, status); |
|||
ps.setString(3, complaintNumber1); |
|||
ps.setString(4, complaintDate); |
|||
ps.setString(5, complanitPersonName); |
|||
ps.setString(6, complaintPersonMobileNum); |
|||
ps.setString(7, complaintType); |
|||
ps.setString(8, complaintMode); |
|||
ps.setString(9, department); |
|||
ps.setString(10, complaintGroup); |
|||
ps.setString(11, officerName); |
|||
ps.setString(12, officerMobileNumber); |
|||
ps.setInt(13, currentAgentId); |
|||
return ps; |
|||
}, keyHolder); |
|||
// Retrieve the generated data_id |
|||
Number generatedDataId = keyHolder.getKey(); |
|||
if (generatedDataId != null) { |
|||
long dataId = generatedDataId.longValue(); |
|||
System.out.println("dataId if=="+dataId); |
|||
// Use the dataId in the next insert for qaqc_upload_data_history |
|||
String sql = "INSERT INTO gcc_1913_qaqc.qaqc_upload_data_history " + |
|||
"(qaqc_id, call_category, complaint_number, complaint_date, complaint_person_name, complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, agent_id, data_id) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
|
|||
jdbcTemplate.update(sql, qaqc_id, status1, complaintNumber1, complaintDate, complanitPersonName, |
|||
complaintPersonMobileNum, complaintType, complaintMode, department, |
|||
complaintGroup, officerName, officerMobileNumber, currentAgentId, dataId); |
|||
|
|||
} |
|||
|
|||
|
|||
assignedCount++; |
|||
|
|||
} |
|||
|
|||
} else { |
|||
System.out.println("else complaintNumber = "+complaintNumber1); |
|||
String complaintDate2 = (String) details.get(index).get("Complaint Opened Date"); |
|||
String complanitPersonName2 = (String) details.get(index).get("Complaint Person Name"); |
|||
String complaintPersonMobileNum2 = (String) details.get(index).get("Complaint Person Number"); |
|||
String complaintType2 = (String) details.get(index).get("Complaint Type"); |
|||
String complaintMode2 = (String) details.get(index).get("Complaint Mode"); |
|||
String department2 = (String) details.get(index).get("Department"); |
|||
String complaintGroup2 = (String) details.get(index).get("Complaint Group"); |
|||
String officerName2 = (String) details.get(index).get("Assign To"); |
|||
String officerMobileNumber2 = (String) details.get(index).get("Official Contact Number"); |
|||
String status2 = status.toUpperCase(); |
|||
|
|||
// Insert into the database |
|||
String insertQuery = "INSERT INTO gcc_1913_qaqc.qaqc_upload_data (qaqc_id, call_category, complaint_number,complaint_date, complaint_person_name, complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, agent_id) VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
//jdbcTemplate.update(insertQuery, qaqc_id, status2, complaintNumber1,complaintDate2, complanitPersonName2, complaintPersonMobileNum2, complaintType2, complaintMode2, department2, complaintGroup2, officerName2, officerMobileNumber2, currentAgentId); |
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setInt(1, qaqc_id); |
|||
ps.setString(2, status2); |
|||
ps.setString(3, complaintNumber1); |
|||
ps.setString(4, complaintDate2); |
|||
ps.setString(5, complanitPersonName2); |
|||
ps.setString(6, complaintPersonMobileNum2); |
|||
ps.setString(7, complaintType2); |
|||
ps.setString(8, complaintMode2); |
|||
ps.setString(9, department2); |
|||
ps.setString(10, complaintGroup2); |
|||
ps.setString(11, officerName2); |
|||
ps.setString(12, officerMobileNumber2); |
|||
ps.setInt(13, currentAgentId); |
|||
return ps; |
|||
}, keyHolder); |
|||
Number generatedDataId = keyHolder.getKey(); |
|||
|
|||
if (generatedDataId != null) { |
|||
long dataId2 = generatedDataId.longValue(); |
|||
System.out.println("dataId2 else=="+dataId2); |
|||
// Use the dataId in the next insert for qaqc_upload_data_history |
|||
String sql = "INSERT INTO gcc_1913_qaqc.qaqc_upload_data_history " + |
|||
"(qaqc_id, call_category, complaint_number, complaint_date, complaint_person_name, complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, agent_id, data_id) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
|
|||
jdbcTemplate.update(sql, qaqc_id, status2, complaintNumber1, complaintDate2, complanitPersonName2, |
|||
complaintPersonMobileNum2, complaintType2, complaintMode2, department2, |
|||
complaintGroup2, officerName2, officerMobileNumber2, currentAgentId, dataId2); |
|||
} |
|||
|
|||
|
|||
assignedCount++; |
|||
} |
|||
} |
|||
|
|||
countResult.put("assignedCount", assignedCount); |
|||
countResult.put("qaqc_id", qaqc_id); |
|||
countResult.put("agent_id", currentAgentId); |
|||
countDetails.add(countResult); |
|||
} |
|||
for(Map<String, Object> assgn : assignedIDList) { |
|||
|
|||
for(Map<String, Object> count : countDetails) { |
|||
|
|||
if(((int)assgn.get("agent_id"))==((int)count.get("agent_id"))) { |
|||
int assignedid = (int)assgn.get("assigned_id"); |
|||
int agentid = (int)assgn.get("agent_id"); |
|||
int assignedCount = (int)count.get("assignedCount"); |
|||
String sql = "UPDATE agent_assigned SET data_count = ? WHERE assigned_id = ? and agent_id = ?"; |
|||
jdbcTemplate.update(sql, assignedCount, assignedid, agentid); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return true; |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
private List<Map<String, Object>> getFollowupData() { |
|||
|
|||
String sqlQuery ="select complaint_number, remainder_date, call_status from qaqc_followup_call_logs"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
// @Transactional |
|||
// public int saveInAgentAssigned(int agent_id, int qaqc_id,int data_counts) { |
|||
// String insertSql = "INSERT INTO gcc_1913_qaqc.agent_assigned (agent_id, qaqc_id,data_count) VALUES (?, ?,?)"; |
|||
// int rowsInserted = jdbcTemplate.update(insertSql, agent_id, qaqc_id,data_counts); |
|||
// |
|||
// return rowsInserted; |
|||
// } |
|||
|
|||
@Transactional |
|||
public Map<String, Object> saveInAgentAssigned(int agent_id, int qaqc_id, int data_counts) { |
|||
String insertSql = "INSERT INTO gcc_1913_qaqc.agent_assigned (agent_id, qaqc_id, data_count) VALUES (?, ?, ?)"; |
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
int rowsInserted = jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(insertSql, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setInt(1, agent_id); |
|||
ps.setInt(2, qaqc_id); |
|||
ps.setInt(3, data_counts); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
if (rowsInserted > 0 && keyHolder.getKey() != null) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
result.put("assigned_id", keyHolder.getKey().intValue()); |
|||
result.put("agent_id", agent_id); |
|||
return result; |
|||
} else { |
|||
throw new RuntimeException("Failed to insert data into agent_assigned table."); |
|||
} |
|||
} |
|||
@Transactional |
|||
public int savetaskid(String taskid,String fromdate,String todate,String description,String status, int closedCount,String group, String type, String mode, String zone) { |
|||
|
|||
// Ensure default values for nullable parameters |
|||
if (group == null || group.isEmpty()) { |
|||
group = "ALL"; |
|||
} |
|||
if (type == null || type.isEmpty()) { |
|||
type = "ALL"; |
|||
} |
|||
if (mode == null || mode.isEmpty()) { |
|||
mode = "ALL"; |
|||
} |
|||
if (zone == null || zone.isEmpty()) { |
|||
zone = "ALL"; |
|||
} |
|||
|
|||
String sql = "INSERT INTO gcc_1913_qaqc.qaqc_request (taskid,fromdate,todate,description,call_category,total_data,complaint_group,complaint_type,complaint_mode,complaint_zone) " + |
|||
"VALUES (?,?,?,?,?,?,?,?,?,?)"; |
|||
int rowsInserted = jdbcTemplate.update(sql,taskid,fromdate,todate,description,status,closedCount,group,type,mode,zone); |
|||
return rowsInserted; |
|||
} |
|||
@Transactional |
|||
public List<Map<String, Object>> getLastTask() |
|||
{ |
|||
String sqlQuery ="SELECT qaqc_id\r\n" |
|||
+ "FROM gcc_1913_qaqc.qaqc_request\r\n" |
|||
+ "ORDER BY qaqc_id DESC\r\n" |
|||
+ "LIMIT 1"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
public int deleteUploadDataTable() { |
|||
String sql = "DELETE FROM gcc_1913_qaqc.qaqc_upload_data WHERE 1=1"; |
|||
int rowsAffected= jdbcTemplate.update(sql); |
|||
return rowsAffected; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,563 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class QaqcAgentsService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsAllTasksCounts(int agent_id) { |
|||
String SqlQuery = "SELECT \r\n" |
|||
+ " cr.taskid,\r\n" |
|||
+ " cr.call_category,\r\n" |
|||
+ " cr.description,\r\n" |
|||
+ " aa.qaqc_id,\r\n" |
|||
+ " aa.agent_id,\r\n" |
|||
+ " aa.created_date,\r\n" |
|||
+ " (SELECT COUNT(data_id) \r\n" |
|||
+ " FROM qaqc_upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.qaqc_id = cr.qaqc_id\r\n" |
|||
+ " ) AS calls_assigned,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.call_status IS NULL THEN 1 END) \r\n" |
|||
+ " FROM qaqc_upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.qaqc_id = cr.qaqc_id\r\n" |
|||
+ " ) AS pending_count,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.call_status IS NOT NULL THEN 1 END) \r\n" |
|||
+ " FROM qaqc_upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.qaqc_id = cr.qaqc_id\r\n" |
|||
+ " ) AS complete_count,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.call_status ='CALL_BACK_LATER' OR up.field_9 = 'UNATTENDED' THEN 1 END) \r\n" |
|||
+ " FROM qaqc_upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.qaqc_id = cr.qaqc_id\r\n" |
|||
+ " ) AS followup_count\r\n" |
|||
+ " \r\n" |
|||
+ "FROM \r\n" |
|||
+ " agent_assigned aa\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " agents_list al ON aa.agent_id = al.agent_id\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " qaqc_request cr ON cr.qaqc_id = aa.qaqc_id\r\n" |
|||
+ "WHERE \r\n" |
|||
+ " aa.agent_id = ? \r\n" |
|||
+ " AND aa.isactive = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery,agent_id); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getdataforagents(int agent_id,int qaqc_id) { |
|||
String sqlQuery = "select *\r\n" |
|||
+ "from qaqc_upload_data\r\n" |
|||
+ "where agent_id=? and qaqc_id=?"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery,agent_id,qaqc_id); |
|||
} |
|||
|
|||
@Transactional |
|||
public void savecallstatus(String call_status, String remarks,String complaintNumber) |
|||
{ |
|||
|
|||
|
|||
String SqlQuery = "UPDATE qaqc_upload_data SET call_status = ?,remarks=?, updated_date = NOW() WHERE (complaint_number = ? )"; |
|||
|
|||
jdbcTemplate.update(SqlQuery,call_status, remarks,complaintNumber); |
|||
} |
|||
|
|||
@Transactional |
|||
public void savecallstatusinlogs(String call_status, String remarks,String complaintNumber) { |
|||
|
|||
// Step 1: Fetch details from the source table using the complaintNumber |
|||
String selectQuery = "SELECT * FROM qaqc_upload_data WHERE complaint_number = ?"; |
|||
Map<String, Object> details = jdbcTemplate.queryForMap(selectQuery, complaintNumber); |
|||
|
|||
// Extract the required fields from the result (modify based on your table structure) |
|||
String detailField1 = (String) details.get("qaqc_id"); |
|||
String detailField2 = (String) details.get("agent_id"); |
|||
String detailField3 = (String) details.get("complaint_number"); |
|||
String detailField4 = (String) details.get("complaint_person_name"); |
|||
String detailField5 = (String) details.get("complaint_mobilenumber"); |
|||
String detailField6 = (String) details.get("complaint_type"); |
|||
String detailField7 = (String) details.get("complaint_mode"); |
|||
String detailField8 = (String) details.get("department"); |
|||
String detailField9 = (String) details.get("complaint_group"); |
|||
String detailField10 = (String) details.get("official_name"); |
|||
String detailField11 = (String) details.get("official_mobilenum"); |
|||
|
|||
// Step 2: Insert the fetched details along with call_status and remarks into qaqc_call_logs |
|||
String insertQuery = "INSERT INTO qaqc_call_logs (qaqc_id, agent_id, complaint_number, complaint_person_name, complaint_mobilenumber,complaint_type,complaint_mode,department,complaint_group,official_name,official_mobilenum) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
|||
jdbcTemplate.update(insertQuery,detailField1, detailField2,detailField3,detailField4,detailField5,detailField6,detailField7,detailField8,detailField9,detailField10,detailField11,call_status,remarks); |
|||
|
|||
} |
|||
|
|||
|
|||
public List<Map<String,Object>> getPreviousDayDashboardCounts() |
|||
{ |
|||
String sqlQuery = "SELECT \r\n" |
|||
+ " COUNT(DISTINCT assigned_stats.agent_id) AS TotalAgents, \r\n" |
|||
+ " SUM(COALESCE(assigned_stats.Assigned, 0)) AS TotalAssigned, \r\n" |
|||
+ " SUM(COALESCE(completed_stats.TotalCompleted, 0)) AS TotalCompleted, \r\n" |
|||
+ " SUM(COALESCE(assigned_stats.Assigned, 0) - COALESCE(completed_stats.TotalCompleted, 0)) AS TotalPending \r\n" |
|||
+ "FROM \r\n" |
|||
+ " (SELECT al.agent_id AS agent_id, SUM(aa.data_count) AS Assigned \r\n" |
|||
+ " FROM agent_assigned aa \r\n" |
|||
+ " JOIN agents_list al ON aa.agent_id = al.agent_id \r\n" |
|||
+ " WHERE DATE(aa.created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY al.agent_id) AS assigned_stats \r\n" |
|||
+ "LEFT JOIN \r\n" |
|||
+ " (SELECT agent_id, COUNT(DISTINCT (complaint_number)) AS TotalCompleted \r\n" |
|||
+ " FROM qaqc_call_logs \r\n" |
|||
+ " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY agent_id) AS completed_stats \r\n" |
|||
+ "ON assigned_stats.agent_id = completed_stats.agent_id;"; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
// public List<Map<String,Object>> getAgentPreviousDayCount() |
|||
// { |
|||
// String sqlQuery = "SELECT DISTINCT \r\n" |
|||
// + " assigned_stats.agent_id, \r\n" |
|||
// + " assigned_stats.agent_name as agent_name, -- Use the alias assigned_stats here instead of aa\r\n" |
|||
// + " COALESCE(assigned_stats.Assigned, 0) AS Assigned, \r\n" |
|||
// + " COALESCE(completed_stats.TotalCompleted, 0) AS TotalCompleted, \r\n" |
|||
// + " COALESCE(assigned_stats.Assigned, 0) - COALESCE(completed_stats.TotalCompleted, 0) AS Pending, \r\n" |
|||
// + " CASE \r\n" |
|||
// + " WHEN COALESCE(assigned_stats.Assigned, 0) = 0 THEN 0 \r\n" |
|||
// + " ELSE ROUND(COALESCE(completed_stats.TotalCompleted, 0) * 100.0 / COALESCE(assigned_stats.Assigned, 1)) \r\n" |
|||
// + " END AS CompletionPercentage, \r\n" |
|||
// + " COALESCE(call_stats.Completed_count, 0) AS Completed_count, \r\n" |
|||
// + " COALESCE(call_stats.Reopened_count, 0) AS Reopened_count, \r\n" |
|||
// + " COALESCE(call_stats.Followup_count, 0) AS Followup_count, \r\n" |
|||
// + " COALESCE(call_stats.Other_count, 0) AS Other_count \r\n" |
|||
// + "FROM \r\n" |
|||
// + " (SELECT al.agent_id AS agent_id, al.agent_name AS agent_name, SUM(aa.data_count) AS Assigned \r\n" |
|||
// + " FROM agent_assigned aa \r\n" |
|||
// + " JOIN agents_list al ON aa.agent_id = al.agent_id \r\n" |
|||
// + " WHERE DATE(aa.created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
// + " GROUP BY al.agent_id,al.agent_name) AS assigned_stats -- The alias 'assigned_stats' is used here\r\n" |
|||
// + "LEFT JOIN \r\n" |
|||
// + " (SELECT agent_id, COUNT(qaqc_id) AS TotalCompleted \r\n" |
|||
// + " FROM qaqc_call_logs \r\n" |
|||
// + " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
// + " GROUP BY agent_id) AS completed_stats ON assigned_stats.agent_id = completed_stats.agent_id \r\n" |
|||
// + "LEFT JOIN \r\n" |
|||
// + " (SELECT agent_id, \r\n" |
|||
// + " SUM(CASE WHEN call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 ELSE 0 END) AS Completed_count, \r\n" |
|||
// + " SUM(CASE WHEN call_status = 'REOPEN' THEN 1 ELSE 0 END) AS Reopened_count, \r\n" |
|||
// + " SUM(CASE WHEN call_status = 'FOLLOWUP' THEN 1 ELSE 0 END) AS Followup_count, \r\n" |
|||
// + " SUM(CASE WHEN call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 ELSE 0 END) AS Other_count \r\n" |
|||
// + " FROM qaqc_call_logs \r\n" |
|||
// + " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
// + " GROUP BY agent_id) AS call_stats ON assigned_stats.agent_id = call_stats.agent_id;\r\n"; |
|||
// |
|||
// return jdbcTemplate.queryForList(sqlQuery); |
|||
// } |
|||
|
|||
|
|||
public List<Map<String,Object>> getAgentPreviousDayCount() |
|||
{ |
|||
String sqlQuery = "SELECT DISTINCT \r\n" |
|||
+ " assigned_stats.agent_id, \r\n" |
|||
+ " assigned_stats.agent_name as agent_name, -- Use the alias assigned_stats here instead of aa\r\n" |
|||
+ " COALESCE(assigned_stats.Assigned, 0) AS Assigned, \r\n" |
|||
+ " COALESCE(completed_stats.TotalCompleted, 0) AS TotalCompleted, \r\n" |
|||
+ " COALESCE(assigned_stats.Assigned, 0) - COALESCE(completed_stats.TotalCompleted, 0) AS Pending, \r\n" |
|||
+ " CASE \r\n" |
|||
+ " WHEN COALESCE(assigned_stats.Assigned, 0) = 0 THEN 0 \r\n" |
|||
+ " ELSE ROUND(COALESCE(completed_stats.TotalCompleted, 0) * 100.0 / COALESCE(assigned_stats.Assigned, 1)) \r\n" |
|||
+ " END AS CompletionPercentage, \r\n" |
|||
+ " COALESCE(call_stats.Completed_count, 0) AS Completed_count, \r\n" |
|||
+ " COALESCE(call_stats.Reopened_count, 0) AS Reopened_count, \r\n" |
|||
+ " COALESCE(call_stats.Followup_count, 0) AS Followup_count, \r\n" |
|||
+ " COALESCE(call_stats.Other_count, 0) AS Other_count \r\n" |
|||
+ "FROM \r\n" |
|||
+ " (SELECT al.agent_id AS agent_id, al.agent_name AS agent_name, SUM(aa.data_count) AS Assigned \r\n" |
|||
+ " FROM agent_assigned aa \r\n" |
|||
+ " JOIN agents_list al ON aa.agent_id = al.agent_id \r\n" |
|||
+ " WHERE DATE(aa.created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY al.agent_id,al.agent_name) AS assigned_stats -- The alias 'assigned_stats' is used here\r\n" |
|||
+ "LEFT JOIN \r\n" |
|||
+ " (SELECT agent_id, count(DISTINCT (complaint_number)) AS TotalCompleted \r\n" |
|||
+ " FROM qaqc_call_logs \r\n" |
|||
+ " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY agent_id) AS completed_stats ON assigned_stats.agent_id = completed_stats.agent_id \r\n" |
|||
+ "LEFT JOIN \r\n" |
|||
+ " (SELECT agent_id, \r\n" |
|||
+ " SUM(CASE WHEN call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 ELSE 0 END) AS Completed_count, \r\n" |
|||
+ " SUM(CASE WHEN call_status = 'REOPEN' THEN 1 ELSE 0 END) AS Reopened_count, \r\n" |
|||
+ " SUM(CASE WHEN call_status = 'FOLLOWUP' THEN 1 ELSE 0 END) AS Followup_count, \r\n" |
|||
+ " SUM(CASE WHEN call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 ELSE 0 END) AS Other_count \r\n" |
|||
+ " FROM qaqc_call_logs \r\n" |
|||
+ " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY agent_id) AS call_stats ON assigned_stats.agent_id = call_stats.agent_id \r\n" |
|||
+ " ORDER BY agent_name \r\n;"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentDashboard(int userId, String startDate, String endDate) { |
|||
String sql = "SELECT " + |
|||
" COALESCE(SUM(aa.data_count), 0) AS Total_Calls_assigned, " + |
|||
" COALESCE(SUM(CASE WHEN qr.call_category = 'closed' THEN aa.data_count ELSE 0 END), 0) AS Closed_Call_count, " + |
|||
" COALESCE(SUM(CASE WHEN qr.call_category IN ('inprogress', 'redressed', 'reopened','processing') THEN aa.data_count ELSE 0 END), 0) AS Inprogress_Call_count, " + |
|||
" COALESCE(SUM(CASE WHEN qr.call_category = 'officialfollowup' THEN aa.data_count ELSE 0 END), 0) AS Followup_Call_count, " + |
|||
" COALESCE(SUM(CASE WHEN qr.call_category = 'publicfollowup' THEN aa.data_count ELSE 0 END), 0) AS PublicFollowup_Call_count " + |
|||
"FROM agent_assigned aa " + |
|||
"LEFT JOIN qaqc_request qr ON aa.qaqc_id = qr.qaqc_id " + |
|||
"WHERE aa.agent_id = ? " + |
|||
"AND DATE(qr.created_date) BETWEEN ? AND ?"; |
|||
|
|||
return jdbcTemplate.queryForList(sql, userId, startDate, endDate); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentPerformanceData(int agentId, String startDate, String endDate) { |
|||
String sql = "SELECT \n" |
|||
+ " COALESCE(total_data_count, 0) AS total_data_count,\n" // Ensure total_data_count is 0 if null |
|||
+ " COALESCE(completed_count, 0) AS completed_count,\n" // Ensure completed_count is 0 if null |
|||
+ " COALESCE((total_data_count - completed_count), 0) AS pending_count,\n" // Ensure pending_count is 0 |
|||
+ " CASE \n" |
|||
+ " WHEN COALESCE(total_data_count, 0) > 0 THEN ROUND((COALESCE(completed_count, 0) / total_data_count) * 100, 1)\n" |
|||
+ " ELSE 0\n" |
|||
+ " END AS completed_percentage\n" |
|||
+ "FROM \n" |
|||
+ " (\n" |
|||
+ " SELECT \n" |
|||
+ " (SELECT COALESCE(SUM(aa.data_count), 0) \n" |
|||
+ " FROM agent_assigned aa \n" |
|||
+ " WHERE aa.agent_id = ? AND DATE(aa.created_date) BETWEEN ? AND ?) AS total_data_count,\n" |
|||
+ " \n" |
|||
+ " (SELECT COALESCE(COUNT(*), 0) \n" |
|||
+ " FROM qaqc_call_logs cl \n" |
|||
+ " WHERE cl.agent_id = ?\n" |
|||
+ " AND DATE(cl.created_date) BETWEEN ? AND ? \n" |
|||
+ " AND cl.call_status IS NOT NULL) AS completed_count\n" |
|||
+ " ) AS combined"; |
|||
|
|||
return jdbcTemplate.queryForList(sql, agentId, startDate, endDate, agentId, startDate, endDate); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentTaskDetails(int userId, String startDate, String endDate) { |
|||
String sql = "WITH LatestCallLogs AS ( " + |
|||
" SELECT " + |
|||
" cl.qaqc_id, " + |
|||
" cl.agent_id, " + |
|||
" cl.complaint_number, " + |
|||
" cl.call_status, " + |
|||
" cl.created_date, " + |
|||
" ROW_NUMBER() OVER (PARTITION BY cl.qaqc_id, cl.agent_id, cl.complaint_number ORDER BY cl.created_date DESC) AS row_num " + |
|||
" FROM " + |
|||
" qaqc_call_logs cl " + |
|||
") " + |
|||
"SELECT DISTINCT " + |
|||
" qr.taskid AS taskid, " + |
|||
" qr.call_category AS call_category, " + |
|||
" DATE(aa.created_date) AS cdate, " + |
|||
" aa.data_count AS assigned, " + |
|||
" COUNT(lcl.agent_id) AS callstaken, " + |
|||
" (aa.data_count - COUNT(lcl.agent_id)) AS pending, " + |
|||
" ROUND((CASE WHEN aa.data_count > 0 THEN (COUNT(lcl.agent_id) / aa.data_count) * 100 ELSE 0 END), 2) AS percentage, " + |
|||
" COUNT(CASE WHEN lcl.call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 END) AS Completed, " + |
|||
" COUNT(CASE WHEN lcl.call_status = 'REOPEN' THEN 1 END) AS Reopened, " + |
|||
" COUNT(CASE WHEN lcl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup, " + |
|||
" COUNT(CASE WHEN lcl.call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 END) AS Others " + |
|||
"FROM " + |
|||
" qaqc_request qr " + |
|||
"JOIN " + |
|||
" agent_assigned aa ON aa.qaqc_id = qr.qaqc_id " + |
|||
"JOIN " + |
|||
" agents_list al ON al.agent_id = aa.agent_id " + |
|||
"LEFT JOIN " + |
|||
" LatestCallLogs lcl ON qr.qaqc_id = lcl.qaqc_id AND al.agent_id = lcl.agent_id AND lcl.row_num = 1 " + |
|||
"WHERE " + |
|||
" al.agent_id = ? AND aa.data_count != 0 " + |
|||
" AND DATE(aa.created_date) BETWEEN ? AND ? " + |
|||
"GROUP BY " + |
|||
" taskid, cdate, assigned, call_category"; |
|||
|
|||
return jdbcTemplate.queryForList(sql, userId, startDate, endDate); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentPerformanceCount(String startDate, String endDate) { |
|||
String sql = "SELECT " + |
|||
"t2.total_calls, " + |
|||
"t3.completed_calls, " + |
|||
"t2.total_calls - t3.completed_calls AS pending_calls, " + |
|||
"t4.no_of_agents " + |
|||
"FROM " + |
|||
"( " + |
|||
" SELECT " + |
|||
" SUM(aa.data_count) AS total_calls " + |
|||
" FROM " + |
|||
" agent_assigned aa " + |
|||
" INNER JOIN " + |
|||
" qaqc_request qr " + |
|||
" ON " + |
|||
" aa.qaqc_id = qr.qaqc_id " + |
|||
" WHERE " + |
|||
" (? IS NULL OR date(qr.created_date) BETWEEN ? AND ?) " + |
|||
") AS t2, " + |
|||
"( " + |
|||
" SELECT " + |
|||
" SUM(qr.total_data) AS total_data, " + |
|||
" COUNT(DISTINCT CONCAT(qcl.qaqc_id, '_', qcl.complaint_number)) AS completed_calls " + |
|||
" FROM " + |
|||
" qaqc_request qr " + |
|||
" LEFT JOIN " + |
|||
" qaqc_call_logs qcl " + |
|||
" ON " + |
|||
" qr.qaqc_id = qcl.qaqc_id " + |
|||
" WHERE " + |
|||
" (? IS NULL OR date(qr.created_date) BETWEEN ? AND ?) " + |
|||
") AS t3, " + |
|||
"( " + |
|||
" SELECT " + |
|||
" COUNT(DISTINCT aa.agent_id) AS no_of_agents " + |
|||
" FROM " + |
|||
" agent_assigned aa " + |
|||
" WHERE " + |
|||
" (? IS NULL OR date(aa.created_date) BETWEEN ? AND ?) " + |
|||
") AS t4"; |
|||
|
|||
// Prepare the parameters for the query |
|||
Object[] params = new Object[] { |
|||
startDate, startDate, endDate, // For t2 |
|||
startDate, startDate, endDate, // For t3 |
|||
startDate, startDate, endDate // For t4 |
|||
}; |
|||
|
|||
// Execute the query and return the results as a List of Maps |
|||
return jdbcTemplate.queryForList(sql, params); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentPerformanceList(String startDate, String endDate) { |
|||
// Base query with subqueries for Assigned, Completed, and Pending |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT DISTINCT " + |
|||
" assigned_stats.agent_id, " + |
|||
" assigned_stats.agent_name, " + |
|||
" COALESCE(assigned_stats.Assigned, 0) AS Assigned, " + |
|||
" COALESCE(completed_stats.TotalCompleted, 0) AS TotalCompleted, " + |
|||
" COALESCE(assigned_stats.Assigned, 0) - COALESCE(completed_stats.TotalCompleted, 0) AS Pending, " + |
|||
" CASE WHEN COALESCE(assigned_stats.Assigned, 0) = 0 THEN 0 ELSE " + |
|||
" ROUND(COALESCE(completed_stats.TotalCompleted, 0) * 100.0 / COALESCE(assigned_stats.Assigned, 1), 2) " + |
|||
" END AS CompletionPercentage, " + |
|||
" COALESCE(call_stats.Completed_count, 0) AS Completed_count, " + |
|||
" COALESCE(call_stats.Reopened_count, 0) AS Reopened_count, " + |
|||
" COALESCE(call_stats.Followup_count, 0) AS Followup_count, " + |
|||
" COALESCE(call_stats.Other_count, 0) AS Other_count " + |
|||
"FROM " + |
|||
" (SELECT al.agent_id as agent_id, al.agent_name as agent_name,SUM(aa.data_count) AS Assigned " + |
|||
" FROM agent_assigned aa JOIN agents_list al ON aa.agent_id=al.agent_id " + |
|||
" WHERE (? IS NULL OR DATE(aa.created_date) >= STR_TO_DATE(?, '%Y-%m-%d')) " + // Conditional date filtering |
|||
" AND (? IS NULL OR DATE(aa.created_date) <= STR_TO_DATE(?, '%Y-%m-%d')) " + |
|||
" GROUP BY al.agent_id,al.agent_name) AS assigned_stats " + // The alias 'assigned_stats' is used here |
|||
"LEFT JOIN " + |
|||
" (SELECT agent_id, COUNT(qaqc_id) AS TotalCompleted " + |
|||
" FROM qaqc_call_logs " + |
|||
" WHERE (? IS NULL OR DATE(created_date) >= STR_TO_DATE(?, '%Y-%m-%d')) " + // Conditional date filtering |
|||
" AND (? IS NULL OR DATE(created_date) <= STR_TO_DATE(?, '%Y-%m-%d')) " + |
|||
" GROUP BY agent_id) AS completed_stats ON assigned_stats.agent_id = completed_stats.agent_id " + |
|||
"LEFT JOIN " + |
|||
" (SELECT agent_id, " + |
|||
" SUM(CASE WHEN call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 ELSE 0 END) AS Completed_count, " + |
|||
" SUM(CASE WHEN call_status = 'REOPEN' THEN 1 ELSE 0 END) AS Reopened_count, " + |
|||
" SUM(CASE WHEN call_status = 'FOLLOWUP' THEN 1 ELSE 0 END) AS Followup_count, " + |
|||
" SUM(CASE WHEN call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 ELSE 0 END) AS Other_count " + |
|||
" FROM qaqc_call_logs " + |
|||
" WHERE (? IS NULL OR DATE(created_date) >= STR_TO_DATE(?, '%Y-%m-%d')) " + // Conditional date filtering |
|||
" AND (? IS NULL OR DATE(created_date) <= STR_TO_DATE(?, '%Y-%m-%d')) " + |
|||
" GROUP BY agent_id) AS call_stats ON assigned_stats.agent_id = call_stats.agent_id" |
|||
); |
|||
|
|||
// Execute query with date range parameters |
|||
return jdbcTemplate.queryForList( |
|||
query.toString(), |
|||
startDate, startDate, endDate, endDate, // Parameters for assigned_stats |
|||
startDate, startDate, endDate, endDate, // Parameters for completed_stats |
|||
startDate, startDate, endDate, endDate // Parameters for call_stats |
|||
); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentTaskwiseData(String agentId) { |
|||
|
|||
String query="WITH LatestCallLogs AS (\r\n" |
|||
+ " SELECT \r\n" |
|||
+ " cl.qaqc_id,\r\n" |
|||
+ " cl.agent_id,\r\n" |
|||
+ " cl.complaint_number,\r\n" |
|||
+ " cl.call_status,\r\n" |
|||
+ " cl.created_date,\r\n" |
|||
+ " ROW_NUMBER() OVER (PARTITION BY cl.qaqc_id, cl.agent_id, cl.complaint_number ORDER BY cl.created_date DESC) AS row_num\r\n" |
|||
+ " FROM \r\n" |
|||
+ " qaqc_call_logs cl\r\n" |
|||
+ ")\r\n" |
|||
+ "SELECT DISTINCT \r\n" |
|||
+ " qr.taskid as taskid,\r\n" |
|||
+ " date(aa.created_date) as cdate,\r\n" |
|||
+ " aa.data_count AS assigned,\r\n" |
|||
+ " COUNT(lcl.agent_id) AS callstaken,\r\n" |
|||
+ " (aa.data_count - COUNT(lcl.agent_id)) AS pending,\r\n" |
|||
+ " ROUND((COUNT(lcl.agent_id) / aa.data_count) * 100, 2) AS percentage,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 END) AS Completed,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status = 'REOPEN' THEN 1 END) AS Reopened,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 END) AS Others\r\n" |
|||
+ "FROM \r\n" |
|||
+ " qaqc_request qr\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " agent_assigned aa ON aa.qaqc_id = qr.qaqc_id\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " agents_list al ON al.agent_id = aa.agent_id\r\n" |
|||
+ "LEFT JOIN \r\n" |
|||
+ " LatestCallLogs lcl ON qr.qaqc_id = lcl.qaqc_id AND al.agent_id = lcl.agent_id AND lcl.row_num = 1\r\n" |
|||
+ "WHERE \r\n" |
|||
+ " al.agent_id = ?\r\n" |
|||
+ "GROUP BY \r\n" |
|||
+ " taskid, cdate, assigned"; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(query, agentId); |
|||
|
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAttendedComplaintStatus( |
|||
String startDate, String endDate, String complaintNumber, String complaintMobileNumber) { |
|||
|
|||
// Base query with JOIN to include agent_name |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT qcl.*,date(qcl.created_date) as updated_date, al.agent_name " + |
|||
"FROM qaqc_call_logs qcl " + |
|||
"LEFT JOIN agents_list al ON qcl.agent_id = al.agent_id " + |
|||
"WHERE 1=1 "); |
|||
|
|||
// List to store query parameters |
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
// Add date range condition if provided |
|||
if (startDate != null && !startDate.isEmpty()) { |
|||
query.append("AND DATE(qcl.created_date) >= ? "); |
|||
params.add(startDate); |
|||
} |
|||
if (endDate != null && !endDate.isEmpty()) { |
|||
query.append("AND DATE(qcl.created_date) <= ? "); |
|||
params.add(endDate); |
|||
} |
|||
|
|||
// Add complaint number condition if provided |
|||
if (complaintNumber != null && !complaintNumber.isEmpty()) { |
|||
query.append("AND qcl.complaint_number = ? "); |
|||
params.add(complaintNumber); |
|||
} |
|||
|
|||
// Add complaint mobile number condition if provided |
|||
if (complaintMobileNumber != null && !complaintMobileNumber.isEmpty()) { |
|||
query.append("AND qcl.complaint_mobilenumber = ? "); |
|||
params.add(complaintMobileNumber); |
|||
} |
|||
|
|||
// Add ORDER BY clause |
|||
query.append("ORDER BY qcl.created_date DESC "); |
|||
|
|||
// Add LIMIT clause only if complaintNumber is provided |
|||
if (complaintNumber != null && !complaintNumber.isEmpty()) { |
|||
query.append("LIMIT 1 "); |
|||
} |
|||
|
|||
// Execute the query with dynamic parameters |
|||
return jdbcTemplate.queryForList(query.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAttendedComplainthistory( |
|||
String startDate, String endDate, String complaintNumber, String complaintMobileNumber) { |
|||
|
|||
// Base query with JOIN to include agent_name |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT qcl.*, al.agent_name " + |
|||
"FROM qaqc_call_logs qcl " + |
|||
"LEFT JOIN agents_list al ON qcl.agent_id = al.agent_id " + |
|||
"WHERE 1=1 "); |
|||
|
|||
// List to store query parameters |
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
// Add date range condition if provided |
|||
if (startDate != null && !startDate.isEmpty()) { |
|||
query.append("AND DATE(qcl.created_date) >= ? "); |
|||
params.add(startDate); |
|||
} |
|||
if (endDate != null && !endDate.isEmpty()) { |
|||
query.append("AND DATE(qcl.created_date) <= ? "); |
|||
params.add(endDate); |
|||
} |
|||
|
|||
// Add complaint number condition if provided |
|||
if (complaintNumber != null && !complaintNumber.isEmpty()) { |
|||
query.append("AND qcl.complaint_number = ? "); |
|||
params.add(complaintNumber); |
|||
} |
|||
|
|||
// Add complaint mobile number condition if provided |
|||
if (complaintMobileNumber != null && !complaintMobileNumber.isEmpty()) { |
|||
query.append("AND qcl.complaint_mobilenumber = ? "); |
|||
params.add(complaintMobileNumber); |
|||
} |
|||
|
|||
// Group by qcl.id and agent_name to avoid SQL error |
|||
query.append("GROUP BY qcl.id, al.agent_name "); |
|||
|
|||
// Add ordering clause |
|||
query.append("ORDER BY qcl.created_date DESC"); |
|||
|
|||
// Execute the query with dynamic parameters |
|||
return jdbcTemplate.queryForList(query.toString(), params.toArray()); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentTaskwiseAssign(String agentId) { |
|||
String query="SELECT * FROM qaqc_upload_data_history where agent_id=? "; |
|||
return jdbcTemplate.queryForList(query, agentId); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentName(int userId) { |
|||
String query="SELECT agent_name \r\n" |
|||
+ "FROM agents_list\r\n" |
|||
+ "where agent_id=?"; |
|||
return jdbcTemplate.queryForList(query, userId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,391 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import java.io.InputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLConnection; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
|
|||
@Service |
|||
@Transactional |
|||
public class QaqcCallsService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getClosedComplaints(int agent_id) { |
|||
String query = "SELECT data_id, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, complaint_type,official_name, official_mobilenum,complaint_mode, department,call_category " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'CLOSED' " + |
|||
" AND is_processed = FALSE " + // Fetch only unprocessed entries |
|||
" AND agent_id = ?"; |
|||
return jdbcTemplate.queryForList(query, agent_id); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getCallCategories() |
|||
{ |
|||
String query = "SELECT call_status " + |
|||
"FROM gcc_1913_qaqc.call_status WHERE call_category_id ='1' and isactive='1'"; |
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int uploadComplaintDetailsInLogs(Map<String, Object> logDetails, String action, String complaintNumber, String remainderDate) { |
|||
System.out.println("Complaint Details: " + logDetails); |
|||
// Extract other field values from complaintDetails |
|||
int qaqcid = (int) logDetails.get("qaqc_id"); |
|||
String ccategory = logDetails.get("call_category").toString(); |
|||
String complaintDate = logDetails.get("complaint_date").toString(); |
|||
String personName = logDetails.get("complaint_person_name").toString(); |
|||
String personMobNo = logDetails.get("complaint_mobilenumber").toString(); |
|||
String cType = logDetails.get("complaint_type").toString(); |
|||
String cMode = logDetails.get("complaint_mode").toString(); |
|||
String department = logDetails.get("department").toString(); |
|||
String cGroup = logDetails.get("complaint_group").toString(); |
|||
String officialName = logDetails.get("official_name").toString(); |
|||
String officialMobileNum = logDetails.get("official_mobilenum").toString(); |
|||
String callStatus = logDetails.get("call_status").toString(); |
|||
String remarks = logDetails.get("remarks").toString(); |
|||
int agentId = (int) logDetails.get("agent_id"); |
|||
int updated_agent=(int)logDetails.get("updated_agent"); |
|||
boolean isProcessed = (boolean)logDetails.get("is_processed"); |
|||
LocalDateTime currentDate = LocalDateTime.now(); |
|||
|
|||
// Determine which table to insert into based on the action |
|||
if (action.equals("FOLLOWUP")) { |
|||
String query = "INSERT INTO gcc_1913_qaqc.qaqc_followup_call_logs (qaqc_id, call_category, agent_id, complaint_number,complaint_date, complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, remainder_date,official_mobilenum, call_status, remarks,created_date,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query, qaqcid, ccategory, agentId, complaintNumber, complaintDate,personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName,remainderDate, officialMobileNum,callStatus, |
|||
remarks,currentDate,updated_agent); |
|||
System.out.println("Rows Inserted in qaqc_followup_call_logs : " + rowsAffected); |
|||
|
|||
String query1 = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number,complaint_date, complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name,remainder_date, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"; |
|||
|
|||
int rowsAffected1 = jdbcTemplate.update(query1, qaqcid, ccategory, agentId, complaintNumber, complaintDate,personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName,remainderDate, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
System.out.println("Rows Inserted in qaqc_call_logs : " + rowsAffected1); |
|||
|
|||
|
|||
return rowsAffected + rowsAffected1; |
|||
|
|||
} else { |
|||
String query = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number, complaint_date,complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query, qaqcid, ccategory, agentId, complaintNumber,complaintDate, personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
|
|||
System.out.println("Rows Inserted in qaqc_call_logs: " + rowsAffected); |
|||
|
|||
return rowsAffected; |
|||
} |
|||
} |
|||
|
|||
public void updateComplaintDetails(String complaintNumber,int dataId, String action, String remarks,int updated_agent) |
|||
{ |
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data " + |
|||
"SET call_status = ?, " + " remarks = ?,updated_agent=?, " + |
|||
" updated_date = CURRENT_TIMESTAMP, " + " is_processed = TRUE " + |
|||
"WHERE data_id = ? " +" AND complaint_number = ? " +" AND call_category = 'CLOSED'"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks,updated_agent, dataId,complaintNumber); |
|||
|
|||
System.out.println("Rows Updated in upload data: " + rowsUpdated); |
|||
} |
|||
|
|||
public Map<String, Object> getComplaintDetails(int dataId) { |
|||
String query = "Select * from gcc_1913_qaqc.qaqc_upload_data where data_id = ?"; |
|||
return jdbcTemplate.queryForMap(query, dataId); |
|||
} |
|||
|
|||
public Map<String, Object> getErpnameById(Integer agentId) { |
|||
String query = "Select erp_username from agents_list where agent_id = ?"; |
|||
return jdbcTemplate.queryForMap(query, agentId); |
|||
} |
|||
|
|||
// public boolean ChangeStatusInErp(String complaintNumber, String remarks, String action,String Erpname) { |
|||
// String urlString = ""; |
|||
// |
|||
// if(remarks.isEmpty()) { |
|||
// remarks="N/A"; |
|||
// } |
|||
// |
|||
// if("COMPLETED".equals(action) || "WRONG_ASSIGN".equals(action)) { |
|||
// |
|||
// urlString="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=UpdateComplaint&ComplaintId="+complaintNumber+"&Message="+remarks+"&UserType=Official&Status=11&erp_username="+Erpname; |
|||
// System.out.println(urlString); |
|||
// //urlencode |
|||
// try { |
|||
// |
|||
// URL url = new URL(urlString); |
|||
// URLConnection urlcon=url.openConnection(); |
|||
// InputStream stream=urlcon.getInputStream(); |
|||
// StringBuilder responseBuilder = new StringBuilder(); |
|||
// int i; |
|||
// while((i=stream.read())!=-1){ |
|||
// responseBuilder.append((char) i); |
|||
// } |
|||
// stream.close(); |
|||
// |
|||
// // Parse the response |
|||
// String response = responseBuilder.toString(); |
|||
// System.out.println("Raw Response from ERP if Completed: " + response); // Debug: Print the raw response |
|||
// |
|||
// // Check ResultStatus in the response |
|||
// if (response.contains("\"ResultStatus\": true")) { |
|||
// System.out.println("ResultStatus is true in the response."); // Debug: Positive ResultStatus |
|||
// return true; |
|||
// } |
|||
// else { |
|||
// System.out.println("ResultStatus is false or not present in the response."); // Debug: Negative or missing ResultStatus |
|||
// return false; |
|||
// } |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return false; |
|||
// } |
|||
// } |
|||
// |
|||
// if("REOPEN".equals(action)) { |
|||
// urlString="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=UpdateComplaint&ComplaintId="+complaintNumber+"&Message="+remarks+"&UserType=Official&Status=9&Comp_Image=64baseString&erp_username="+Erpname; |
|||
// System.out.println(urlString); |
|||
// try { |
|||
// URL url = new URL(urlString); |
|||
// URLConnection urlcon=url.openConnection(); |
|||
// InputStream stream=urlcon.getInputStream(); |
|||
// StringBuilder responseBuilder = new StringBuilder(); |
|||
// int i; |
|||
// while((i=stream.read())!=-1){ |
|||
// responseBuilder.append((char) i); |
|||
// } |
|||
// stream.close(); |
|||
// |
|||
// // Parse the response |
|||
// String response = responseBuilder.toString(); |
|||
// System.out.println("Raw Response from ERP if Reopen: " + response); |
|||
// |
|||
// // Check ResultStatus in the response |
|||
// if (response.contains("\"ResultStatus\": true")) { |
|||
// System.out.println("ResultStatus is true in the response."); // Debug: Positive ResultStatus |
|||
// return true; |
|||
// } |
|||
// else { |
|||
// System.out.println("ResultStatus is false or not present in the response."); // Debug: Negative or missing ResultStatus |
|||
// return false; |
|||
// } |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return false; |
|||
// } |
|||
// } |
|||
// return false; |
|||
// |
|||
// } |
|||
|
|||
// public boolean ChangeStatusInErp(String complaintNumber, String remarks, String action, String Erpname) { |
|||
// String urlString = ""; |
|||
// |
|||
// if (remarks.isEmpty()) { |
|||
// remarks = "N/A"; |
|||
// } |
|||
// |
|||
// try { |
|||
// // Encode parameters |
|||
// String encodedComplaintNumber = URLEncoder.encode(complaintNumber, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
// String encodedRemarks = URLEncoder.encode(remarks, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
// String encodedErpname = URLEncoder.encode(Erpname, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
// |
|||
// if ("COMPLETED".equals(action) || "WRONG_ASSIGN".equals(action)) { |
|||
// urlString = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?" |
|||
// + "serviceId=UpdateComplaint" |
|||
// + "&ComplaintId=" + encodedComplaintNumber |
|||
// + "&Message=" + encodedRemarks |
|||
// + "&UserType=Official" |
|||
// + "&Status=11" |
|||
// + "&erp_username=" + encodedErpname; |
|||
// |
|||
// System.out.println(urlString); |
|||
// |
|||
// return sendRequest(urlString); |
|||
// } |
|||
// |
|||
// if ("REOPEN".equals(action)) { |
|||
// urlString = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?" |
|||
// + "serviceId=UpdateComplaint" |
|||
// + "&ComplaintId=" + encodedComplaintNumber |
|||
// + "&Message=" + encodedRemarks |
|||
// + "&UserType=Official" |
|||
// + "&Status=9" |
|||
// + "&Comp_Image=64baseString" |
|||
// + "&erp_username=" + encodedErpname; |
|||
// |
|||
// System.out.println(urlString); |
|||
// |
|||
// return sendRequest(urlString); |
|||
// } |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return false; |
|||
// } |
|||
// |
|||
// return false; |
|||
// } |
|||
|
|||
public boolean ChangeStatusInErp(String complaintNumber, String remarks, String action, String Erpname) { |
|||
String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?"; |
|||
String status = ""; |
|||
|
|||
if (remarks.isEmpty()) { |
|||
remarks = "N/A"; |
|||
} |
|||
|
|||
try { |
|||
// Encode parameters |
|||
String encodedComplaintNumber = URLEncoder.encode(complaintNumber, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedRemarks = URLEncoder.encode(remarks, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedErpname = URLEncoder.encode(Erpname, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
|
|||
// Determine status based on action |
|||
if ("COMPLETED".equals(action) || "WRONG_ASSIGN".equals(action)) { |
|||
status = "11"; |
|||
} else if ("REOPEN".equals(action)) { |
|||
status = "9"; |
|||
} else { |
|||
return false; // Invalid action, return false |
|||
} |
|||
|
|||
// Construct the URL |
|||
String urlString = baseUrl |
|||
+ "serviceId=UpdateComplaint" |
|||
+ "&ComplaintId=" + encodedComplaintNumber |
|||
+ "&Message=" + encodedRemarks |
|||
+ "&UserType=Official" |
|||
+ "&Status=" + status |
|||
+ "&Comp_Image=" |
|||
+ "&erp_username=" + encodedErpname; |
|||
|
|||
System.out.println(urlString); |
|||
|
|||
// Send the request |
|||
return sendRequest(urlString); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
private boolean sendRequest(String urlString) { |
|||
try { |
|||
URL url = new URL(urlString); |
|||
URLConnection urlcon = url.openConnection(); |
|||
InputStream stream = urlcon.getInputStream(); |
|||
StringBuilder responseBuilder = new StringBuilder(); |
|||
int i; |
|||
while ((i = stream.read()) != -1) { |
|||
responseBuilder.append((char) i); |
|||
} |
|||
stream.close(); |
|||
|
|||
// Parse the response |
|||
String response = responseBuilder.toString(); |
|||
System.out.println("Raw Response: " + response); |
|||
|
|||
// Check ResultStatus in the response |
|||
if (response.contains("\"ResultStatus\": true")) { |
|||
System.out.println("ResultStatus is true in the response."); |
|||
return true; |
|||
} else { |
|||
System.out.println("ResultStatus is false or not present in the response."); |
|||
return false; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
public void saveMobileNumDetails(String complaintNumber, String remarks) { |
|||
String query = "insert into officer_mobileno (complaint_number,remarks) values(?,?)"; |
|||
int rowsUpdated = jdbcTemplate.update(query, complaintNumber, remarks); |
|||
System.out.println("Rows Updated: " + rowsUpdated); |
|||
} |
|||
|
|||
public Map<String,Object> checkComplaintDetail(String complaintNumber) { |
|||
String query = "select id,complaint_number from qaqc_followup_call_logs where complaint_number = ?"; |
|||
try { |
|||
return jdbcTemplate.queryForMap(query, complaintNumber); |
|||
} catch (Exception e) { |
|||
System.out.println("Complaint number not found"); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public void updateFollowupCallLogs(String complaintNumber, String action, String remarks, int followupid) { |
|||
System.out.println(complaintNumber+action+remarks); |
|||
|
|||
String query = "update gcc_1913_qaqc.qaqc_followup_call_logs set call_status = ?,remarks = ? where complaint_number= ? and id =?"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks, complaintNumber, followupid); |
|||
System.out.println("Rows Updated in followup: " + rowsUpdated); |
|||
|
|||
} |
|||
|
|||
public List<Map<String, Object>> getSubmitDetails(int userId) { |
|||
|
|||
String query = "SELECT complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, " + |
|||
"complaint_type, call_status, remarks " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE agent_id = ? AND call_category = 'CLOSED' AND is_processed = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query,userId); |
|||
|
|||
} |
|||
|
|||
public void updateComplaintHistoryDetails(String complaintNumber, int dataId, String action, String remarks,int updated_agent, |
|||
String remainderDate) { |
|||
|
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data_history \r\n" |
|||
+ "SET call_status = ?, remarks = ?, updated_date = CURRENT_TIMESTAMP, remainder_date = ?,updated_agent=?\r\n" |
|||
+ "WHERE data_id = ? AND complaint_number = ? AND call_category = 'CLOSED'"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks, remainderDate,updated_agent, dataId, complaintNumber); |
|||
|
|||
System.out.println("Rows Updated in upload history: " + rowsUpdated); |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,126 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class QaqcService { |
|||
|
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getFollowUpDetailsByStatus(String callStatus, LocalDate fromDate, LocalDate toDate) { |
|||
// Start the SQL query |
|||
String sql = "SELECT " + |
|||
"f.id, " + |
|||
"f.qaqc_id, " + |
|||
"f.call_category, " + |
|||
"f.complaint_number, " + |
|||
"f.agent_id, " + |
|||
"f.complaint_person_name, " + |
|||
"f.complaint_mobilenumber, " + |
|||
"f.complaint_type, " + |
|||
"f.complaint_mode, " + |
|||
"f.department, " + |
|||
"f.complaint_group, " + |
|||
"f.official_name, " + |
|||
"f.official_mobilenum, " + |
|||
"f.call_status, " + |
|||
"f.remainder_date, " + |
|||
"f.remarks, " + |
|||
"f.created_date, " + |
|||
"r.taskid " + |
|||
"FROM qaqc_followup_call_logs f " + |
|||
"LEFT JOIN qaqc_request r ON f.qaqc_id = r.qaqc_id "; |
|||
|
|||
// List to hold the query parameters |
|||
List<Object> params = new ArrayList<>(); |
|||
boolean hasCondition = false; |
|||
|
|||
// Filter by callStatus if provided |
|||
if (callStatus != null && !callStatus.isEmpty()) { |
|||
sql += " WHERE f.call_status = ?"; |
|||
params.add(callStatus); |
|||
hasCondition = true; |
|||
} |
|||
|
|||
// Filter by date range (fromDate to toDate) if both are provided |
|||
if (fromDate != null && toDate != null) { |
|||
if (hasCondition) { |
|||
sql += " AND f.remainder_date BETWEEN ? AND ?"; |
|||
} else { |
|||
sql += " WHERE f.remainder_date BETWEEN ? AND ?"; |
|||
hasCondition = true; |
|||
} |
|||
params.add(fromDate); |
|||
params.add(toDate); |
|||
} |
|||
// If only fromDate is provided |
|||
else if (fromDate != null) { |
|||
if (hasCondition) { |
|||
sql += " AND f.remainder_date >= ?"; |
|||
} else { |
|||
sql += " WHERE f.remainder_date >= ?"; |
|||
hasCondition = true; |
|||
} |
|||
params.add(fromDate); |
|||
} |
|||
// If only toDate is provided (include records with remainder_date greater than toDate) |
|||
else if (toDate != null) { |
|||
if (hasCondition) { |
|||
sql += " AND (f.remainder_date <= ? OR f.remainder_date > ?)"; |
|||
} else { |
|||
sql += " WHERE (f.remainder_date <= ? OR f.remainder_date > ?)"; |
|||
hasCondition = true; |
|||
} |
|||
params.add(toDate); // <= toDate condition |
|||
params.add(toDate); // > toDate condition |
|||
} |
|||
|
|||
// Final debugging: print the query and parameters |
|||
System.out.println("Final SQL Query: " + sql); |
|||
System.out.println("Query Parameters: " + params); |
|||
|
|||
// Execute the query with the dynamically added parameters |
|||
return jdbcTemplate.queryForList(sql, params.toArray()); |
|||
} |
|||
|
|||
|
|||
|
|||
public Map<String, Long> countFollowUpsByDateAndStatus(LocalDate today, String followupStatus) { |
|||
String sqlNotClosed = "SELECT COUNT(*) FROM qaqc_followup_call_logs " + |
|||
"WHERE call_status = ? AND DATE(remainder_date) = ? AND call_category NOT IN ('CLOSED')"; |
|||
|
|||
String sqlClosed = "SELECT COUNT(*) FROM qaqc_followup_call_logs " + |
|||
"WHERE call_status = ? AND DATE(remainder_date) = ? AND call_category IN ('CLOSED')"; |
|||
|
|||
long countNotClosed = jdbcTemplate.queryForObject(sqlNotClosed, new Object[]{followupStatus, today}, Long.class); |
|||
long countClosed = jdbcTemplate.queryForObject(sqlClosed, new Object[]{followupStatus, today}, Long.class); |
|||
|
|||
Map<String, Long> result = new HashMap<>(); |
|||
result.put("officialfollowup", countNotClosed); |
|||
result.put("publicfollowup", countClosed); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,292 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.ArrayList; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class QaqcTaskListService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
// old overalltaskcount wise method |
|||
|
|||
// public List<Map<String, Object>> getComplaintAndCallStatusCounts(String startDate, String endDate) { |
|||
// String sql = "SELECT " + |
|||
// "t1.total_tasks, " + |
|||
// "t2.total_calls, " + |
|||
// "t3.completed_calls, " + |
|||
// "t2.total_calls - t3.completed_calls AS pending_calls " + |
|||
// "FROM " + |
|||
// "( " + |
|||
// " SELECT " + |
|||
// " COUNT(qaqc_id) AS total_tasks " + |
|||
// " FROM " + |
|||
// " qaqc_request " + |
|||
// " WHERE " + |
|||
// " (? IS NULL OR created_date BETWEEN ? AND ?) " + |
|||
// ") AS t1, " + |
|||
// "( " + |
|||
// " SELECT " + |
|||
// " SUM(total_data) AS total_calls " + |
|||
// " FROM " + |
|||
// " qaqc_request " + |
|||
// " WHERE " + |
|||
// " (? IS NULL OR created_date BETWEEN ? AND ?) " + |
|||
// ") AS t2, " + |
|||
// "( " + |
|||
// " SELECT " + |
|||
// " SUM(qr.total_data) AS total_data, " + |
|||
// " COUNT(CASE WHEN qcl.qaqc_id IS NOT NULL THEN qcl.qaqc_id END) AS completed_calls " + |
|||
// " FROM " + |
|||
// " qaqc_request qr " + |
|||
// " LEFT JOIN " + |
|||
// " qaqc_call_logs qcl " + |
|||
// " ON " + |
|||
// " qr.qaqc_id = qcl.qaqc_id " + |
|||
// " WHERE " + |
|||
// " (? IS NULL OR qcl.created_date BETWEEN ? AND ?) " + |
|||
// ") AS t3;"; |
|||
// |
|||
// // Prepare the parameters for the query |
|||
// Object[] params = new Object[] { |
|||
// startDate, startDate, endDate, |
|||
// startDate, startDate, endDate, |
|||
// startDate, startDate, endDate |
|||
// }; |
|||
// |
|||
// // Execute the query and return the results as a List of Maps |
|||
// return jdbcTemplate.queryForList(sql, params); |
|||
// } |
|||
|
|||
|
|||
|
|||
//updated overalltaskcount method |
|||
public List<Map<String, Object>> getComplaintAndCallStatusCounts(String startDate, String endDate) { |
|||
// Start constructing the SQL query dynamically |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("SELECT ") |
|||
.append("t1.total_tasks, ") |
|||
.append("t2.total_calls, ") |
|||
.append("t3.completed_calls, ") |
|||
.append("t2.total_calls - t3.completed_calls AS pending_calls, ") |
|||
.append("t4.no_of_agents ") |
|||
.append("FROM ") |
|||
.append("( ") |
|||
.append(" SELECT ") |
|||
.append(" COUNT(qaqc_id) AS total_tasks ") |
|||
.append(" FROM ") |
|||
.append(" qaqc_request qr "); |
|||
|
|||
// Adding dynamic WHERE conditions for date range if provided |
|||
if (startDate != null && endDate != null) { |
|||
sql.append("WHERE DATE(qr.created_date) >= ? AND DATE(qr.created_date) <= ? "); |
|||
} |
|||
|
|||
sql.append(") AS t1, ") |
|||
.append("( ") |
|||
.append(" SELECT ") |
|||
.append(" SUM(aa.data_count) AS total_calls ") |
|||
.append(" FROM ") |
|||
.append(" agent_assigned aa ") |
|||
.append(" INNER JOIN ") |
|||
.append(" qaqc_request qr ") |
|||
.append(" ON ") |
|||
.append(" aa.qaqc_id = qr.qaqc_id "); |
|||
|
|||
if (startDate != null && endDate != null) { |
|||
sql.append("WHERE DATE(qr.created_date) >= ? AND DATE(qr.created_date) <= ? "); |
|||
} |
|||
|
|||
sql.append(") AS t2, ") |
|||
.append("( ") |
|||
.append(" SELECT ") |
|||
.append(" SUM(qr.total_data) AS total_data, ") |
|||
.append(" COUNT(CASE WHEN qcl.qaqc_id IS NOT NULL THEN qcl.qaqc_id END) AS completed_calls ") |
|||
.append(" FROM ") |
|||
.append(" qaqc_request qr ") |
|||
.append(" LEFT JOIN ") |
|||
.append(" qaqc_call_logs qcl ") |
|||
.append(" ON ") |
|||
.append(" qr.qaqc_id = qcl.qaqc_id "); |
|||
|
|||
if (startDate != null && endDate != null) { |
|||
sql.append("WHERE DATE(qcl.created_date) >= ? AND DATE(qcl.created_date) <= ? "); |
|||
} |
|||
|
|||
sql.append(") AS t3, ") |
|||
.append("( ") |
|||
.append(" SELECT ") |
|||
.append(" COUNT(DISTINCT aa.agent_id) AS no_of_agents ") |
|||
.append(" FROM ") |
|||
.append(" agent_assigned aa "); |
|||
|
|||
if (startDate != null && endDate != null) { |
|||
sql.append("WHERE DATE(aa.created_date) >= ? AND DATE(aa.created_date) <= ? "); |
|||
} |
|||
|
|||
sql.append(") AS t4;"); |
|||
|
|||
// Prepare the parameters dynamically based on the presence of the date range |
|||
List<Object> params = new ArrayList<>(); |
|||
if (startDate != null && endDate != null) { |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
} |
|||
|
|||
// Execute the query and return the results as a List of Maps |
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
//old taskwise querymethod |
|||
|
|||
// public List<Map<String, Object>> getTaskwiseData(String startDate, String endDate) { |
|||
// // Base query |
|||
// StringBuilder query = new StringBuilder( |
|||
// "SELECT " + |
|||
// " qr.taskid, " + |
|||
// " MAX(qr.total_data) AS Assigned, " + |
|||
// " MAX(qr.created_date) AS TaskCreatedDate, " + |
|||
// " COUNT(CASE WHEN acl.qaqc_id IS NOT NULL THEN qr.qaqc_id END) AS TotalCompleted, " + |
|||
// " MAX(qr.total_data) - COUNT(CASE WHEN acl.qaqc_id IS NOT NULL THEN qr.qaqc_id END) AS Pending, " + // Pending calculated as Assigned - TotalCompleted |
|||
// " COUNT(CASE WHEN acl.call_status = 'COMPLETED' THEN 1 END) AS Completed, " + |
|||
// " COUNT(CASE WHEN acl.call_status = 'REOPENED' THEN 1 END) AS Reopened, " + |
|||
// " COUNT(CASE WHEN acl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup " + |
|||
// "FROM qaqc_request qr " + |
|||
// "LEFT JOIN qaqc_call_logs acl " + |
|||
// "ON qr.qaqc_id = acl.qaqc_id " |
|||
// ); |
|||
// |
|||
// // Adding dynamic WHERE conditions for date range |
|||
// if (startDate != null && endDate != null) { |
|||
// query.append("WHERE qr.created_date BETWEEN ? AND ? "); |
|||
// } |
|||
// |
|||
// // Grouping by taskid |
|||
// query.append("GROUP BY qr.taskid"); |
|||
// |
|||
// // Query Execution |
|||
// if (startDate != null && endDate != null) { |
|||
// return jdbcTemplate.queryForList(query.toString(), startDate, endDate); |
|||
// } else { |
|||
// return jdbcTemplate.queryForList(query.toString()); |
|||
// } |
|||
// } |
|||
|
|||
|
|||
//updated taskwisedata query method |
|||
|
|||
public List<Map<String, Object>> getTaskwiseData(String startDate, String endDate) { |
|||
// Base query with subqueries for Assigned and Pending calculations |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT " + |
|||
" qr.qaqc_id, " + |
|||
" qr.taskid, " + |
|||
" qr.call_category, " + |
|||
" qr.description, " + |
|||
" (" + |
|||
" SELECT SUM(aa.data_count) " + |
|||
" FROM agent_assigned aa " + |
|||
" WHERE aa.qaqc_id = qr.qaqc_id" + |
|||
" ) AS Assigned, " + |
|||
" MAX(DATE(qr.created_date)) AS TaskCreatedDate, " + |
|||
" COUNT(CASE WHEN acl.qaqc_id IS NOT NULL THEN qr.qaqc_id END) AS TotalCompleted, " + |
|||
" (" + |
|||
" SELECT SUM(aa.data_count) " + |
|||
" FROM agent_assigned aa " + |
|||
" WHERE aa.qaqc_id = qr.qaqc_id" + |
|||
" ) - COUNT(CASE WHEN acl.qaqc_id IS NOT NULL THEN qr.qaqc_id END) AS Pending, " + |
|||
" COUNT(CASE WHEN acl.call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 END) AS Completed, " + |
|||
" COUNT(CASE WHEN acl.call_status = 'REOPEN' THEN 1 END) AS Reopened, " + |
|||
" COUNT(CASE WHEN acl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup, " + |
|||
" COUNT(CASE WHEN acl.call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 ELSE NULL END) AS Others " + |
|||
"FROM qaqc_request qr " + |
|||
"LEFT JOIN qaqc_call_logs acl " + |
|||
"ON qr.qaqc_id = acl.qaqc_id " |
|||
); |
|||
|
|||
// Adding dynamic WHERE conditions for date range if provided |
|||
if (startDate != null && endDate != null) { |
|||
query.append("WHERE DATE(qr.created_date) >= ? AND DATE(qr.created_date) <= ? "); |
|||
} |
|||
|
|||
// Grouping by taskid and qaqc_id to calculate Assigned and Pending |
|||
query.append("GROUP BY qr.taskid, qr.qaqc_id "); |
|||
|
|||
// Adding ORDER BY clause for descending order of created_date |
|||
query.append("ORDER BY TaskCreatedDate DESC, qr.qaqc_id DESC"); |
|||
|
|||
// Query execution with parameters for start and end dates if available |
|||
if (startDate != null && endDate != null) { |
|||
return jdbcTemplate.queryForList(query.toString(), startDate, endDate); |
|||
} else { |
|||
return jdbcTemplate.queryForList(query.toString()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentwiseData(String qaqc_id) { |
|||
|
|||
String query= "WITH LatestCallLogs AS (\r\n" |
|||
+ " SELECT cl.qaqc_id,\r\n" |
|||
+ " cl.agent_id,\r\n" |
|||
+ " cl.complaint_number,\r\n" |
|||
+ " cl.call_status,\r\n" |
|||
+ " cl.created_date,\r\n" |
|||
+ " ROW_NUMBER() OVER (PARTITION BY cl.qaqc_id, cl.agent_id, cl.complaint_number ORDER BY cl.created_date DESC) AS row_num\r\n" |
|||
+ " FROM qaqc_call_logs cl\r\n" |
|||
+ ")\r\n" |
|||
+ "SELECT DISTINCT al.agent_id,\r\n" |
|||
+ " al.agent_name AS agentName,\r\n" |
|||
+ " qr.taskid as taskId,\r\n" |
|||
+ " qr.fromdate as fromdate,qr.todate as todate,qr.description as description,qr.call_category as call_category,\r\n" |
|||
+ " qr.complaint_group as complaint_group,qr.complaint_type as complaint_type,qr.complaint_mode as complaint_mode,qr.complaint_zone as complaint_zone,\r\n" |
|||
+ " DATE(qr.created_date) AS TaskCreatedDate,\r\n" |
|||
+ " aa.data_count AS assigned,\r\n" |
|||
+ " COUNT(lcl.qaqc_id) AS callstaken,\r\n" |
|||
+ " (aa.data_count - COUNT(lcl.qaqc_id)) AS pending,\r\n" |
|||
+ " ROUND((COUNT(lcl.qaqc_id) / aa.data_count) * 100, 2) AS percentage,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 END) AS Completed,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status = 'REOPEN' THEN 1 END) AS Reopened,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 END) AS Others\r\n" |
|||
+ "FROM qaqc_request qr\r\n" |
|||
+ "JOIN agent_assigned aa ON aa.qaqc_id = qr.qaqc_id\r\n" |
|||
+ "JOIN agents_list al ON al.agent_id = aa.agent_id\r\n" |
|||
+ "LEFT JOIN LatestCallLogs lcl ON qr.qaqc_id = lcl.qaqc_id AND al.agent_id = lcl.agent_id AND lcl.row_num = 1\r\n" |
|||
+ "WHERE qr.qaqc_id = ?\r\n" |
|||
+ "GROUP BY al.agent_id, al.agent_name, aa.data_count"; |
|||
|
|||
return jdbcTemplate.queryForList(query, qaqc_id); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,103 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
@Service |
|||
@Transactional |
|||
public class SocialMediaService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional |
|||
public int uploadComplaintDetailsInLogs(Map<String, Object> details,String action,String remarks,int updated_agent) { |
|||
System.out.println("Complaint Details: " + details); |
|||
// Extract other field values from complaintDetails |
|||
String complaintNumber = details.get("complaintid").toString(); |
|||
String complaintDate = details.get("complaintdate").toString(); |
|||
String personName = details.get("complainantName").toString(); |
|||
String personMobNo = details.get("mobileNumber").toString(); |
|||
String cType = details.get("complaintType").toString(); |
|||
String cMode = details.get("compmode").toString(); |
|||
String department = details.get("deptname").toString(); |
|||
String officialName = details.get("Officialname").toString(); |
|||
String officialMobileNum = details.get("OfficialMobile").toString(); |
|||
String callStatus = action; |
|||
String remarksfield = remarks; |
|||
String zone = details.get("Zone").toString(); |
|||
int updated_by=updated_agent; |
|||
|
|||
LocalDateTime currentDate = LocalDateTime.now(); |
|||
|
|||
String query = "INSERT INTO gcc_1913_qaqc.social_media_completed (complaint_number,zone,complaint_date, complaint_person_name,remarks, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, official_name,official_mobilenum, call_status,created_date,updated_by) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query, complaintNumber,zone, complaintDate,personName,remarksfield, |
|||
personMobNo, cType, cMode, department, officialName, officialMobileNum,callStatus, |
|||
currentDate,updated_by); |
|||
System.out.println("Rows Inserted in table : " + rowsAffected); |
|||
|
|||
return rowsAffected; |
|||
|
|||
} |
|||
|
|||
public List<Map<String, Object>> getdetails(String formattedFromDate, String formattedToDate, String status, String zone) { |
|||
StringBuilder query = new StringBuilder("SELECT * FROM gcc_1913_qaqc.social_media_completed WHERE DATE(created_date) BETWEEN ? AND ? "); |
|||
List<Object> params = new ArrayList<>(); |
|||
params.add(formattedFromDate); |
|||
params.add(formattedToDate); |
|||
|
|||
if (zone != null && !zone.isEmpty()) { |
|||
query.append(" AND zone = ?"); |
|||
params.add(zone); |
|||
} |
|||
|
|||
if (status != null && !status.equals("ALL")) { |
|||
query.append(" AND call_status = ?"); |
|||
params.add(status); |
|||
} |
|||
|
|||
// Log the query and parameters for debugging |
|||
System.out.println("Executing query: " + query.toString()); |
|||
System.out.println("With parameters: " + params); |
|||
|
|||
// Execute the query |
|||
List<Map<String, Object>> results = jdbcTemplate.queryForList(query.toString(), params.toArray()); |
|||
|
|||
// Log the results for debugging |
|||
System.out.println("Query results: " + results); |
|||
|
|||
return results.isEmpty() ? null : results; |
|||
} |
|||
|
|||
public String getErpusernamebyId(String userId) { |
|||
|
|||
String query="SELECT erp_username FROM gcc_1913_qaqc.agents_list\r\n" |
|||
+ "where calling_type='SOCIALMEDIA' and agent_id=?"; |
|||
|
|||
System.out.println("query====="+query); |
|||
String erpUsername = jdbcTemplate.queryForObject(query,new Object[]{userId},String.class); |
|||
|
|||
return erpUsername; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,239 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@Service |
|||
public class StatusCountService { |
|||
|
|||
private RestTemplate restTemplate; |
|||
private ObjectMapper objectMapper; |
|||
@Autowired |
|||
private AppConfig appconfig; |
|||
|
|||
public StatusCountService(RestTemplate restTemplate, ObjectMapper objectMapper) { |
|||
this.restTemplate = restTemplate; |
|||
this.objectMapper = objectMapper; |
|||
} |
|||
|
|||
public Map<String, String> fetchComplaintCounts(String fromDate, String toDate, String compType, String zoneName, String compMode, String compGroup) { |
|||
//https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=common_api&jsonResp=Yes&subService=dashboardAbs&fromDate=&toDate=&compType=&zoneName=&compMode=&compGroup= |
|||
String apiUrl; |
|||
if ("SOCIAL MEDIA".equalsIgnoreCase(compMode)) { |
|||
|
|||
apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes" |
|||
+ "&subService=dashboardAbs" |
|||
+ "&fromDate=" + fromDate |
|||
+ "&toDate=" + toDate; |
|||
} |
|||
|
|||
else { |
|||
apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes" |
|||
+ "&subService=dashboardAbs" |
|||
+ "&fromDate=" + fromDate |
|||
+ "&toDate=" + toDate |
|||
+"&excludeMode=7"; |
|||
|
|||
} |
|||
|
|||
// Append parameters based on their availability |
|||
if (!compType.isEmpty()) { |
|||
apiUrl += "&compType=" + compType; |
|||
} |
|||
|
|||
if (!zoneName.isEmpty()) { |
|||
apiUrl += "&zoneName=" + zoneName; |
|||
} |
|||
|
|||
if (!compMode.isEmpty()) { |
|||
apiUrl += "&compMode=" + compMode; |
|||
} |
|||
|
|||
if (!compGroup.isEmpty()) { |
|||
apiUrl += "&compGroup=" + compGroup; |
|||
} |
|||
|
|||
Map<String, String> counts = new HashMap<>(); |
|||
System.out.println("url: " + apiUrl); |
|||
|
|||
try { |
|||
// Get the raw response |
|||
String response = restTemplate.getForObject(apiUrl, String.class); |
|||
System.out.println("API Response: " + response); // Log the response for debugging |
|||
|
|||
JsonNode jsonResponse = objectMapper.readTree(response); |
|||
|
|||
// Check if "ListResult" exists and is an array |
|||
JsonNode listResult = jsonResponse.path("ListResult"); |
|||
if (!listResult.isArray() || listResult.isEmpty()) { |
|||
System.out.println("ListResult is null or empty"); |
|||
return counts; // Return empty map or default values |
|||
} |
|||
|
|||
JsonNode resultNode = listResult.get(0); |
|||
if (resultNode != null && !resultNode.isNull()) { |
|||
counts.put("Total Complaints", resultNode.path("RECEIVED").asText("")); |
|||
counts.put("In Progress", resultNode.path("PENDING").asText("")); |
|||
counts.put("Redressed", resultNode.path("REDRESSED").asText("")); |
|||
counts.put("Reopened", resultNode.path("REOPEN").asText("")); |
|||
counts.put("Closed", resultNode.path("CLOSED").asText("")); |
|||
} else { |
|||
System.out.println("ResultNode is null"); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return counts; |
|||
|
|||
} |
|||
|
|||
|
|||
public List<String> fetchComplaintTypes(String compGroup) { |
|||
// Construct the API URL with the compGroup parameter |
|||
String apiUrl = appconfig.qaqcurl + |
|||
"serviceId=common_api&jsonResp=Yes&subService=compTypelist&compGroup=" + compGroup; |
|||
List<String> complaintTypes = new ArrayList<>(); |
|||
|
|||
try { |
|||
// Call the external API |
|||
ResponseEntity<String> response = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
if (response.getStatusCode() == HttpStatus.OK) { |
|||
// Parse the response JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootNode = objectMapper.readTree(response.getBody()); |
|||
|
|||
// Navigate to "ListResult" and extract "COMPLAINTTYPENAME" |
|||
JsonNode listResultNode = rootNode.path("ListResult"); |
|||
if (listResultNode.isArray()) { |
|||
for (JsonNode item : listResultNode) { |
|||
String complaintTypeName = item.path("COMPLAINTTYPENAME").asText().trim(); |
|||
complaintTypes.add(complaintTypeName); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching complaint types for compGroup " + compGroup + ": " + e.getMessage()); |
|||
} |
|||
|
|||
return complaintTypes; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
//for complaintgroup api |
|||
public List<String> fetchComplaintGroup() { |
|||
String apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes&subService=compGrouplist"; |
|||
List<String> complaintGroup = new ArrayList(); |
|||
|
|||
try { |
|||
// Call the external API |
|||
ResponseEntity<String> response = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
if (response.getStatusCode() == HttpStatus.OK) { |
|||
// Parse the response JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootNode = objectMapper.readTree(response.getBody()); |
|||
|
|||
// Navigate to "ListResult" and extract "COMPLAINTTYPENAME" |
|||
JsonNode listResultNode = rootNode.path("ListResult"); |
|||
if (listResultNode.isArray()) { |
|||
for (JsonNode item : listResultNode) { |
|||
String complaintTypeName = item.path("COMPLAINTGROUPNAME").asText().trim(); |
|||
complaintGroup.add(complaintTypeName); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching complaint types: " + e.getMessage()); |
|||
} |
|||
|
|||
return complaintGroup; |
|||
} |
|||
|
|||
|
|||
|
|||
//for modes api |
|||
public List<String> fetchModes() { |
|||
String apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes&subService=compModelist"; |
|||
List<String> modes = new ArrayList(); |
|||
|
|||
try { |
|||
// Call the external API |
|||
ResponseEntity<String> response = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
if (response.getStatusCode() == HttpStatus.OK) { |
|||
// Parse the response JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootNode = objectMapper.readTree(response.getBody()); |
|||
|
|||
// Navigate to "ListResult" and extract "COMPLAINTTYPENAME" |
|||
JsonNode listResultNode = rootNode.path("ListResult"); |
|||
if (listResultNode.isArray()) { |
|||
for (JsonNode item : listResultNode) { |
|||
String complaintModeName = item.path("COMP_MODE").asText().trim(); |
|||
modes.add(complaintModeName); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching complaint types: " + e.getMessage()); |
|||
} |
|||
|
|||
return modes; |
|||
} |
|||
|
|||
|
|||
// for zones api |
|||
public List<String> fetchZones() { |
|||
String apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes&subService=zoneNamelist"; |
|||
List<String> zones = new ArrayList(); |
|||
|
|||
try { |
|||
// Call the external API |
|||
ResponseEntity<String> response = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
if (response.getStatusCode() == HttpStatus.OK) { |
|||
// Parse the response JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootNode = objectMapper.readTree(response.getBody()); |
|||
|
|||
// Navigate to "ListResult" and extract "COMPLAINTTYPENAME" |
|||
JsonNode listResultNode = rootNode.path("ListResult"); |
|||
if (listResultNode.isArray()) { |
|||
for (JsonNode item : listResultNode) { |
|||
String complaintzone = item.path("NAME").asText().trim(); |
|||
zones.add(complaintzone); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching complaint types: " + e.getMessage()); |
|||
} |
|||
|
|||
return zones; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,48 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service |
|||
public class WhatsappqaqcMsgService { |
|||
|
|||
public String sendMsg(String msgUrl, String tamilmsgUrl) { |
|||
StringBuilder response = new StringBuilder(); |
|||
|
|||
|
|||
response.append("English Message Response: ").append(sendWhatsAppMessage(msgUrl)).append("\n"); |
|||
|
|||
|
|||
response.append("Tamil Message Response: ").append(sendWhatsAppMessage(tamilmsgUrl)); |
|||
|
|||
return response.toString(); |
|||
} |
|||
|
|||
private String sendWhatsAppMessage(String urlString) { |
|||
String response = ""; |
|||
try { |
|||
URL url = new URL(urlString); |
|||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response = String.valueOf(responseCode); |
|||
System.out.println("Response Code for URL: " + urlString + " is " + responseCode); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return response; |
|||
} |
|||
|
|||
|
|||
|
|||
public String sendSMS(String SMS_Url) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response =restTemplate.getForObject(SMS_Url,String.class); |
|||
return response; |
|||
} |
|||
} |
|||
@ -0,0 +1,111 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.controller; |
|||
|
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.core.env.Environment; |
|||
|
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service.RegistrationService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@RestController("cdapiController") |
|||
@RequestMapping("/gcc/api/registration") |
|||
public class ApiController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public ApiController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
@GetMapping("/pending") |
|||
public String getUserDetails(){ |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/getuserdetails"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
@GetMapping("/pendingbyid") |
|||
public String getUserDetailsById(@RequestParam("registerId") Long registerId){ |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/getuserbyid"+"?registerId="+ registerId; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
|
|||
// @PostMapping("/acceptbyid") |
|||
// public String acceptRegistration(@RequestParam("registerId") Long registerId) { |
|||
// // Your logic to accept the registration |
|||
// String apiUrl = appConfig.cdwastecollectors +"/volunteer/wastecollector/api/accept"+"?registerId="+ registerId; |
|||
// ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
// return responseEntity.getBody(); |
|||
// } |
|||
|
|||
@PostMapping("/acceptbyid") |
|||
public ResponseEntity<String> acceptRegistration(@RequestParam("registerId") Long registerId) { |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/accept?registerId=" + registerId; |
|||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(apiUrl, null, String.class); |
|||
return ResponseEntity.ok("Registration Accepted for ID: " + registerId); |
|||
} |
|||
|
|||
|
|||
|
|||
@PostMapping("/rejectbyid") |
|||
public ResponseEntity<String> rejectRegistration( |
|||
@RequestParam("registerId") Long registerId, |
|||
@RequestParam("reason") String reason) { |
|||
|
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/reject?registerId=" + registerId + "&reason=" + reason; |
|||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(apiUrl, null, String.class); |
|||
return ResponseEntity.ok("Registration Rejected for ID: " + registerId); |
|||
} |
|||
|
|||
@GetMapping("/approvallist") |
|||
public String getApprovalDetails(){ |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/approvedlist"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
@GetMapping("/rejectedlist") |
|||
public String getRejectedDetails(){ |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/rejectedlist"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,142 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.controller; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.ParameterizedTypeReference; |
|||
import org.springframework.http.HttpEntity; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.HttpMethod; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonMappingException; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service.RegistrationService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
import org.springframework.http.MediaType; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
|
|||
|
|||
@RequestMapping("/gcc/cdwaste") |
|||
@Controller("cdcontroller") |
|||
public class MainController { |
|||
|
|||
private final LoginUserInfo loginUserInfo; |
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public MainController(RestTemplate restTemplate,LoginUserInfo loginUserInfo, |
|||
AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
this.loginUserInfo = loginUserInfo; |
|||
} |
|||
|
|||
@Autowired |
|||
private RegistrationService registrationservice; |
|||
|
|||
@GetMapping("/registration") |
|||
public String SavecdRegistraion(Model model){ |
|||
return "modules/cdwaste/registration"; |
|||
} |
|||
|
|||
@GetMapping("/pending") |
|||
public String Pendinglist(Model model) throws JsonMappingException, JsonProcessingException { |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/getuserdetails"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
// Get the response body |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
// Check if the response is an object or an array |
|||
if (responseBody.trim().startsWith("{")) { // Single object case |
|||
Map<String, Object> userDetails = objectMapper.readValue(responseBody, new TypeReference<Map<String, Object>>() {}); |
|||
model.addAttribute("userDetails", List.of(userDetails)); // Convert to a list for consistency |
|||
} else { // It's expected to be an array |
|||
List<Map<String, Object>> userDetails = objectMapper.readValue(responseBody, new TypeReference<List<Map<String, Object>>>() {}); |
|||
model.addAttribute("userDetails", userDetails); // Add the list directly |
|||
} |
|||
} else { |
|||
// If response is null or empty, pass an empty list to the model |
|||
model.addAttribute("userDetails", Collections.emptyList()); |
|||
} |
|||
|
|||
return "modules/cdwaste/pending"; // Return the view |
|||
} |
|||
|
|||
|
|||
@GetMapping("/approval") |
|||
public String approvalList(Model model) throws JsonMappingException, JsonProcessingException { |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/approvedlist"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
// Get the response body |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
// Check if the response is an object or an array |
|||
if (responseBody.trim().startsWith("{")) { // Single object case |
|||
Map<String, Object> approvalDetails = objectMapper.readValue(responseBody, new TypeReference<Map<String, Object>>() {}); |
|||
model.addAttribute("approvalDetails", List.of(approvalDetails)); // Convert to list |
|||
} else { // It's an array |
|||
List<Map<String, Object>> approvalDetails = objectMapper.readValue(responseBody, new TypeReference<List<Map<String, Object>>>() {}); |
|||
model.addAttribute("approvalDetails", approvalDetails); |
|||
} |
|||
} else { |
|||
model.addAttribute("approvalDetails", Collections.emptyList()); |
|||
} |
|||
|
|||
return "modules/cdwaste/approval"; // Return the appropriate view |
|||
} |
|||
|
|||
@GetMapping("/rejected") |
|||
public String rejectedList(Model model) throws JsonMappingException, JsonProcessingException { |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/rejectedlist"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
// Get the response body |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
// Check if the response is an object or an array |
|||
if (responseBody.trim().startsWith("{")) { // Single object case |
|||
Map<String, Object> rejectedDetails = objectMapper.readValue(responseBody, new TypeReference<Map<String, Object>>() {}); |
|||
model.addAttribute("rejectedDetails", List.of(rejectedDetails)); // Convert to list |
|||
} else { // It's an array |
|||
List<Map<String, Object>> rejectedDetails = objectMapper.readValue(responseBody, new TypeReference<List<Map<String, Object>>>() {}); |
|||
model.addAttribute("rejectedDetails", rejectedDetails); |
|||
} |
|||
} else { |
|||
model.addAttribute("rejectedDetails", Collections.emptyList()); |
|||
} |
|||
|
|||
return "modules/cdwaste/rejected"; // Return the appropriate view |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.controller; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
|
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service.WhatsappMsgService; |
|||
|
|||
|
|||
|
|||
@RestController("whatsappconCD") |
|||
@RequestMapping("/gcc/api/cd/whatsapp") |
|||
public class WhatsappControllerCD { |
|||
|
|||
@Autowired |
|||
private WhatsappMsgService whatsappMsgService; |
|||
|
|||
@PostMapping("/send-whatsapp-message") |
|||
public ResponseEntity<String> sendWhatsAppMessage(@RequestParam String msgUrl) { |
|||
String response = whatsappMsgService.sendMsg(msgUrl); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,33 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service; |
|||
|
|||
import java.io.File; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.UUID; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
@Service |
|||
public class RegistrationService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,41 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
|
|||
import java.net.URL; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service("whatsappServiceCD") |
|||
public class WhatsappMsgService { |
|||
|
|||
|
|||
public String sendMsg(String msgUrl) { |
|||
|
|||
String response =""; |
|||
try{ |
|||
HttpURLConnection connection =null; |
|||
|
|||
URL url = new URL(msgUrl); |
|||
connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response=responseCode+""; |
|||
System.out.println("Response Code: " + responseCode); |
|||
|
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
public String sendSMS(String SMS_Url) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response =restTemplate.getForObject(SMS_Url,String.class); |
|||
return response; |
|||
} |
|||
} |
|||
@ -0,0 +1,160 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.controller; |
|||
|
|||
import java.util.List; |
|||
import org.springframework.security.core.Authentication; |
|||
|
|||
import org.springframework.security.core.context.SecurityContextHolder; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.com_petition.service.Petition; |
|||
import in.gov.chennaicorporation.gccoffice.com_petition.service.PetitionMaster; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("gcc/api/com_petition") |
|||
@RestController("commpRest") // Mayor Petition Rest |
|||
public class APIController { |
|||
private PetitionMaster petitionMaster; |
|||
private Petition petition; |
|||
|
|||
@Autowired |
|||
public APIController(PetitionMaster petitionMaster,Petition petition) { |
|||
this.petitionMaster = petitionMaster; |
|||
this.petition = petition; |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintTypes") |
|||
public List getComplaintTypeList() { |
|||
return petitionMaster.getComplaintType(); |
|||
} |
|||
|
|||
@GetMapping(value="/getOfficerList") |
|||
public List getOfficerList() { |
|||
return petitionMaster.getOfficerList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getPetitionTypes") |
|||
public List getPetitionTypes() { |
|||
return petitionMaster.getPetitionTypes(); |
|||
} |
|||
|
|||
@GetMapping(value="/getPetitionList") |
|||
public List getPetitionList() { |
|||
return petition.getPetitionList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getUnmapPetitionList") |
|||
public List getUnmapPetitionList() { |
|||
return petition.getUnmapPetitionList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getPetitionDetails") |
|||
public List getPetitionDetails(@RequestParam("petitionNo") String petitionNo) { |
|||
return petition.getPetitionDetails(petitionNo); |
|||
} |
|||
|
|||
@PostMapping(value="/savePetition") |
|||
public String savePetition( |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("petitionType") String petitionType, |
|||
@RequestParam("petitionerName") String petitionerName, |
|||
@RequestParam("petitionerMobile") String petitionerMobile, |
|||
@RequestParam("complaintType") String petitionerComplaint, |
|||
@RequestParam("san_page1") MultipartFile page1, |
|||
@RequestParam("san_page2") MultipartFile page2, |
|||
@RequestParam("san_page3") MultipartFile page3, |
|||
@RequestParam("san_page4") MultipartFile page4) { |
|||
|
|||
return petition.savePetition(petitionType, createdBy, petitionerName, petitionerMobile, petitionerComplaint, page1, page2, page3, page4); |
|||
} |
|||
|
|||
@PostMapping(value="/updatePetition") |
|||
public Boolean updatePetition( |
|||
@RequestParam("petitionType") String petitionType, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("petitionerName") String petitionerName, |
|||
@RequestParam("petitionerMobile") String petitionerMobile, |
|||
@RequestParam("petitionerAddress") String petitionerAddress, |
|||
@RequestParam("petitionerPincode") String petitionerPincode, |
|||
@RequestParam("complaintType") String petitionerComplaint, |
|||
@RequestParam("complaintNature") String complaintNature, |
|||
@RequestParam("remarks") String remarks) { |
|||
|
|||
return petition.updatePetition(petitionNo, petitionType, createdBy, petitionerName, petitionerMobile, petitionerAddress, petitionerPincode, petitionerComplaint, complaintNature, remarks); |
|||
} |
|||
|
|||
@PostMapping(value="/mapComplientToOfficer") |
|||
public Boolean updatePetition( |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam(value = "", required = false) String mapOfficers) { |
|||
|
|||
String com_mapping = mapOfficers; |
|||
|
|||
// First before Mapping need to unmaps old list |
|||
petition.unmapComplient(petitionId, petitionNo); |
|||
|
|||
if(com_mapping!=null) { |
|||
String[] com_mapping_parts = com_mapping.split(","); |
|||
for (String values : com_mapping_parts) { |
|||
String[] com_mapping_val = values.split("_"); |
|||
if (com_mapping_val.length > 0) { |
|||
String complientId = com_mapping_val[0]; |
|||
String offcierId = com_mapping_val[1]; |
|||
petition.mapComplientToOfficer(createdBy, petitionId, petitionNo, complientId, offcierId); |
|||
} |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
|
|||
@GetMapping(value="/getComplaintMappingDetails") |
|||
public List getComplaintMappingDetails( |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("complaintTypeId") String complaintTypeId) { |
|||
return petition.getComplaintMappingDetails(petitionNo,petitionId,complaintTypeId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintList") |
|||
public List getComplaintList(@RequestParam("loginId") String loginId) { |
|||
return petition.getComplaintList(loginId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintListByPetitionId") |
|||
public List getComplaintListByPetitionId(@RequestParam("petitionId") String petitionId) { |
|||
return petition.getComplaintListByPetitionId(petitionId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintDetails") |
|||
public List<?> getComplaintDetails(@RequestParam("mapId") String mapId) { |
|||
return petition.getComplaintDetails(mapId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintActionDetails") |
|||
public List<?> getComplaintActionDetails(@RequestParam("mapId") String mapId) { |
|||
return petition.getComplaintActionDetails(mapId); |
|||
} |
|||
|
|||
@PostMapping(value="/saveComplanitStatus") |
|||
public String saveComplanitStatus( |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("mapId") String mapId, |
|||
@RequestParam("complaintStatus") String complaintStatus, |
|||
@RequestParam("complaintActionText") String complaintActionText, |
|||
@RequestParam("action_san_page1") MultipartFile actionPage1, |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo) { |
|||
|
|||
return petition.saveComplanitStatus(createdBy, mapId, complaintStatus, complaintActionText, actionPage1, petitionId, petitionNo); |
|||
} |
|||
} |
|||
@ -0,0 +1,130 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.controller; |
|||
|
|||
import org.hibernate.hql.internal.ast.tree.RestrictableStatement; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.service.Base64Util; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/com_petition") |
|||
@Controller("ComPetitionController") |
|||
public class MainController { |
|||
private final RestTemplate restTemplate; |
|||
private String BasePath = "modules/com_petition/"; |
|||
@Autowired |
|||
public MainController(RestTemplate restTemplate) { |
|||
this.restTemplate = restTemplate; |
|||
} |
|||
|
|||
@GetMapping({"", "/", "/index", "/dashboard"}) |
|||
public String dashboard(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"index"; |
|||
} |
|||
|
|||
@GetMapping({"/new_petition"}) |
|||
public String newPetition(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"new_petition"; |
|||
} |
|||
|
|||
@GetMapping("/petition-ack/{petitionNo}") |
|||
public String petitionAck(Model model,@PathVariable("petitionNo") String petitionNo) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_ack"; |
|||
} |
|||
|
|||
@GetMapping("/petition-list") |
|||
public String petitionList(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"petition_list"; |
|||
} |
|||
|
|||
@GetMapping("/unmapped-petition-list") |
|||
public String unMappedPetitionList(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"petition_not_mapped_list"; |
|||
} |
|||
|
|||
@GetMapping("/update-petition") |
|||
public String petitionUpadte(Model model,@RequestParam(value="petitionNo", required = false) String petitionNo) { |
|||
|
|||
if (petitionNo != null && !petitionNo.isEmpty()) { |
|||
// Decrypt the encrypted value |
|||
petitionNo = Base64Util.decodeBase64(petitionNo); |
|||
} |
|||
else { |
|||
petitionNo = null; |
|||
} |
|||
|
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_update"; |
|||
} |
|||
|
|||
@GetMapping("/view-petition") |
|||
public String petitionView(Model model,@RequestParam(value="petitionNo", required = false) String petitionNo) { |
|||
|
|||
if (petitionNo != null && !petitionNo.isEmpty()) { |
|||
// Decrypt the encrypted value |
|||
petitionNo = Base64Util.decodeBase64(petitionNo); |
|||
} |
|||
else { |
|||
petitionNo = null; |
|||
} |
|||
|
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_view"; |
|||
} |
|||
|
|||
@GetMapping("/view-petition-modal") |
|||
public String petitionViewModal(Model model,@RequestParam(value="petitionNo", required = false) String petitionNo) { |
|||
|
|||
if (petitionNo != null && !petitionNo.isEmpty()) { |
|||
// Decrypt the encrypted value |
|||
petitionNo = Base64Util.decodeBase64(petitionNo); |
|||
} |
|||
else { |
|||
petitionNo = null; |
|||
} |
|||
|
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_view_modal_page"; |
|||
} |
|||
|
|||
@GetMapping("/search-petition") |
|||
public String petitionSearch(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
//model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_update"; |
|||
} |
|||
|
|||
@GetMapping("/complaint-list") |
|||
public String complaintList(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"complaint_list"; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.controller; |
|||
@ -0,0 +1,21 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.data; |
|||
|
|||
import java.util.Map; |
|||
|
|||
public class ComplaintType { |
|||
private int complaintTypeId; |
|||
private String complaintType; |
|||
|
|||
public ComplaintType(Map<String, Object> map) { |
|||
this.complaintTypeId = (int) map.get("complaint_typeid"); |
|||
this.complaintType = (String) map.get("complaint_type"); |
|||
} |
|||
|
|||
public int getComplaintTypeId() { |
|||
return complaintTypeId; |
|||
} |
|||
|
|||
public String getComplaintType() { |
|||
return complaintType; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.data; |
|||
@ -0,0 +1,7 @@ |
|||
/** |
|||
* |
|||
*/ |
|||
/** |
|||
* |
|||
*/ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition; |
|||
@ -0,0 +1,719 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.service; |
|||
|
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.SQLException; |
|||
import java.sql.Statement; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.com_petition.data.ComplaintType; |
|||
import in.gov.chennaicorporation.gccoffice.service.Base64Util; |
|||
import in.gov.chennaicorporation.gccoffice.service.GetMappingUserDetails; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
import org.springframework.jdbc.core.PreparedStatementCreator; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
|
|||
@Service("commissionerPetition") |
|||
public class Petition { |
|||
private JdbcTemplate jdbcTemplate; |
|||
private final Environment environment; |
|||
private PetitionMaster petitionMaster; |
|||
private GetMappingUserDetails getMappingUserDetails; |
|||
|
|||
@Autowired |
|||
public Petition(Environment environment,PetitionMaster petitionMaster,GetMappingUserDetails getMappingUserDetails) { |
|||
this.environment = environment; |
|||
this.petitionMaster = petitionMaster; |
|||
this.getMappingUserDetails = getMappingUserDetails; |
|||
} |
|||
|
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlCommissionerPetitionDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List getComplaintTypeList() { |
|||
return petitionMaster.getComplaintType(); |
|||
} |
|||
/* |
|||
@Transactional(readOnly = true) |
|||
public static List<ComplaintType> convertToComplaintTypes(List<Map<String, Object>> complaintTypeMaps) { |
|||
return complaintTypeMaps.stream() |
|||
.map(ComplaintType::new) |
|||
.collect(Collectors.toList()); |
|||
} |
|||
*/ |
|||
|
|||
@Transactional(readOnly = true) |
|||
public static List<ComplaintType> convertToComplaintTypes(List<Map<String, Object>> complaintTypeMaps) { |
|||
List<ComplaintType> complaintTypes = new ArrayList<>(); |
|||
for (Map<String, Object> complaintTypeMap : complaintTypeMaps) { |
|||
complaintTypes.add(new ComplaintType(complaintTypeMap)); |
|||
} |
|||
return complaintTypes; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
// Method to map complaint type IDs to their respective complaint types |
|||
public static String mapComplaintTypes(List<ComplaintType> complaintTypes, String complaint) { |
|||
String[] complaintIds = complaint.split(","); |
|||
StringBuilder complaintTxtBuilder = new StringBuilder(); |
|||
|
|||
for (String complaintId : complaintIds) { |
|||
int id = Integer.parseInt(complaintId); |
|||
for (ComplaintType type : complaintTypes) { |
|||
if (type.getComplaintTypeId() == id) { |
|||
if (complaintTxtBuilder.length() > 0) { |
|||
complaintTxtBuilder.append(","); |
|||
} |
|||
complaintTxtBuilder.append(type.getComplaintType()); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return complaintTxtBuilder.toString(); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getPetitionList() { |
|||
try { |
|||
//String sqlQuery = "SELECT * FROM petition WHERE (`isactive`=1 AND `isdelete`=0)"; |
|||
String sqlQuery = "SELECT p.* , pt.name petition_type_name FROM petition p, petition_master.petition_types pt " |
|||
+ "WHERE (p.`isactive`=1 AND p.`isdelete`=0) AND p.petition_type = pt.petition_type_id"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
Base64Util.encodeBase64(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getUnmapPetitionList() { |
|||
try { |
|||
String sqlQuery = "SELECT " |
|||
+ " p.* , pt.name petition_type_name " |
|||
+ "FROM " |
|||
+ " `petition` p, petition_master.petition_types pt " |
|||
+ "WHERE " |
|||
+ " (p.`isactive` = 1 AND p.`isdelete` = 0) AND (p.petition_type = pt.petition_type_id)" |
|||
+ " AND NOT EXISTS (" |
|||
+ " SELECT 1 " |
|||
+ " FROM `petition_mapping` pm " |
|||
+ " WHERE (p.`petition_id` = pm.`petition_id`) AND (pm.`isactive` = 1 AND pm.`isdelete` = 0 ) " |
|||
+ " )"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getPetitionDetails(String petitionNo) { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM petition WHERE petition_no = ? AND (`isactive`=1 AND `isdelete`=0) LIMIT 1"; |
|||
//System.out.println("SELECT * FROM petition WHERE petition_no = '"+petitionNo+"' AND (`isactive`=1 AND `isdelete`=0) LIMIT 1"); |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery, petitionNo); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public String savePetition( |
|||
String petitionType, |
|||
String createdBy, |
|||
String petitionerName, |
|||
String petitionerMobile, |
|||
String petitionerComplaint, |
|||
MultipartFile page1, |
|||
MultipartFile page2, |
|||
MultipartFile page3, |
|||
MultipartFile page4) { |
|||
|
|||
//System.out.println("I am from Service Page "+petitionerName); |
|||
|
|||
//String complaintNature = ""; |
|||
int lastInsertId = 0; |
|||
String sqlQuery = "INSERT INTO `petition` " |
|||
+ "(`petition_type`,`created_by`, `petitioner_name`, `petitioner_mobile`, " |
|||
+ "`petitioner_complaint`, `petitioner_complaint_txt`) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?)"; |
|||
|
|||
try { |
|||
// Complaint Type List |
|||
List complaintTypelist = getComplaintTypeList(); |
|||
// Convert the list of maps to a list of ComplaintType objects |
|||
List<ComplaintType> complaintTypes = convertToComplaintTypes(complaintTypelist); |
|||
|
|||
// Map complaint types |
|||
String petitionerComplaint_txt = mapComplaintTypes(complaintTypes, petitionerComplaint); |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
// Use JdbcTemplate's update method to execute the query with parameters |
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setString(1, petitionType); |
|||
ps.setString(2, createdBy); |
|||
ps.setString(3, petitionerName); |
|||
ps.setString(4, petitionerMobile); |
|||
ps.setString(5, petitionerComplaint); |
|||
ps.setString(6, petitionerComplaint_txt); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
// Get the last insert ID |
|||
lastInsertId = (int) keyHolder.getKey().longValue(); |
|||
|
|||
// Get the value of mp_ackno from application.properties |
|||
String ackno = environment.getProperty("com_ackno"); |
|||
String ackno_prefix = environment.getProperty("com_ackno_prefix"); |
|||
|
|||
// Convert ackno to int if needed |
|||
int acknoInt = Integer.parseInt(ackno); |
|||
|
|||
// Calculate the petition number |
|||
int petitionNo = (int) (lastInsertId + acknoInt); |
|||
|
|||
// Construct the petition number string |
|||
String petitionNoString = ackno_prefix + petitionNo; |
|||
|
|||
// Update the petition number in the database |
|||
updatePetitionNumber(lastInsertId, petitionNoString); |
|||
|
|||
// Add Petition Scan File in the database |
|||
addPetitionFile(createdBy,lastInsertId, petitionNoString, page1, page2, page3, page4); |
|||
|
|||
return petitionNoString; // If no exception, query executed successfully |
|||
} catch (DataAccessException e) { |
|||
// Handle exception (e.g., log error) |
|||
e.printStackTrace(); |
|||
return "error"; // Query execution failed |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean updatePetitionNumber(int petitionId,String petitionNoString) { |
|||
String sqlQuery = "UPDATE `petition` SET `petition_no`='"+petitionNoString+"' WHERE `petition_id`='"+petitionId+"'"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional |
|||
public String addPetitionFile(String createdBy, |
|||
int petitionId, |
|||
String petitionNoString, |
|||
MultipartFile page1, |
|||
MultipartFile page2, |
|||
MultipartFile page3, |
|||
MultipartFile page4) { |
|||
|
|||
String fileName=""; |
|||
for (int i = 1; i <= 4; i++) { |
|||
MultipartFile file = null; |
|||
switch (i) { |
|||
case 1: |
|||
file = page1; |
|||
fileName = "Scan1"; |
|||
break; |
|||
case 2: |
|||
file = page2; |
|||
fileName = "Scan2"; |
|||
break; |
|||
case 3: |
|||
file = page3; |
|||
fileName = "Scan3"; |
|||
break; |
|||
case 4: |
|||
file = page4; |
|||
fileName = "Scan4"; |
|||
break; |
|||
} |
|||
if (file != null && !file.isEmpty()) { |
|||
try { |
|||
// Get the bytes of the file |
|||
byte[] bytes = file.getBytes(); |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("com_foldername"); |
|||
uploadDirectory = uploadDirectory + serviceFolderName; |
|||
|
|||
// File name |
|||
fileName = petitionId + "_" + fileName + "_" + petitionNoString + "_" + file.getOriginalFilename(); |
|||
|
|||
//File Size |
|||
Long fileSize = file.getSize(); |
|||
|
|||
// File Type |
|||
String fileType = file.getContentType(); |
|||
|
|||
// Create directory if it doesn't exist |
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
String filePath = uploadDirectory + "/" + fileName; |
|||
|
|||
// Create a new Path object |
|||
Path path = Paths.get(filePath); |
|||
|
|||
// Write the bytes to the file |
|||
Files.write(path, bytes); |
|||
|
|||
// Save the file path to a database |
|||
String sqlQuery = "INSERT INTO `pentition_files`(`created_by`, `file_name`, `file_size`, `file_type`, `petition_no`, `petition_id`) " |
|||
+ "VALUES ('"+createdBy+"','"+fileName+"','"+fileSize+"','"+fileType+"','"+petitionNoString+"','"+petitionId+"')"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save file " + file.getOriginalFilename(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
return "success"; |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean updatePetition( |
|||
String petitionNo, |
|||
String petitionType, |
|||
String createdBy, |
|||
String petitionerName, |
|||
String petitionerMobile, |
|||
String petitionerAddress, |
|||
String petitionerPincode, |
|||
String petitionerComplaint, |
|||
String complaintNature, |
|||
String remarks) { |
|||
|
|||
try { |
|||
// Complaint Type List |
|||
List complaintTypelist = getComplaintTypeList(); |
|||
// Convert the list of maps to a list of ComplaintType objects |
|||
List<ComplaintType> complaintTypes = convertToComplaintTypes(complaintTypelist); |
|||
|
|||
// Map complaint types |
|||
String petitionerComplaint_txt = mapComplaintTypes(complaintTypes, petitionerComplaint); |
|||
/* |
|||
String sqlQuery = "UPDATE `petition` SET " |
|||
+ "`petition_type`='"+petitionType+"', `created_by`='"+createdBy+"', `petitioner_name`='"+petitionerName+"', `petitioner_mobile`='"+petitionerMobile+"', " |
|||
+ "`petitioner_address`='"+petitionerAddress+"', `petitioner_pincode`='"+petitionerPincode+"'," |
|||
+ "`petitioner_complaint`='"+petitionerComplaint+"', `petitioner_complaint_txt`='"+petitionerComplaint_txt+"', `complaint_nature`='"+complaintNature+"', `remarks`='"+remarks+"' " |
|||
+ "WHERE (`petition_no`='"+petitionNo+"') LIMIT 1"; |
|||
System.out.println(sqlQuery); |
|||
// Use JdbcTemplate's update method to execute the query with parameters |
|||
jdbcTemplate.update(sqlQuery);*/ |
|||
String sqlQuery = "UPDATE `petition` SET " |
|||
+ "`petition_type` = ?, `created_by` = ?, `petitioner_name` = ?, `petitioner_mobile` = ?, " |
|||
+ "`petitioner_address` = ?, `petitioner_pincode` = ?, `petitioner_complaint` = ?, " |
|||
+ "`petitioner_complaint_txt` = ?, `complaint_nature` = ?, `remarks` = ? " |
|||
+ "WHERE `petition_no` = ? LIMIT 1"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(sqlQuery, |
|||
petitionType, |
|||
createdBy, |
|||
petitionerName, |
|||
petitionerMobile, |
|||
petitionerAddress, |
|||
petitionerPincode, |
|||
petitionerComplaint, |
|||
petitionerComplaint_txt, // Safely includes single quotes |
|||
complaintNature, |
|||
remarks, |
|||
petitionNo |
|||
); |
|||
|
|||
// Add Petition Scan File in the database |
|||
//addPetitionFile(createdBy,lastInsertId, petitionNoString, page1, page2, page3, page4); |
|||
|
|||
return true; // If no exception, query executed successfully |
|||
} catch (DataAccessException e) { |
|||
// Handle exception (e.g., log error) |
|||
e.printStackTrace(); |
|||
return false; // Query execution failed |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean updatePetitionStatus(String petitionId,String petitionNo) { |
|||
String status_value = "close"; |
|||
List<Map<String, Object>> petitionMappingDetails = getPetitionMappingDetails(petitionNo, petitionId); |
|||
|
|||
for (Map<String, Object> mapping : petitionMappingDetails) { |
|||
// Access values from the map using keys |
|||
Object status = mapping.get("status"); |
|||
// Check if status is "close" |
|||
if (!"close".equals(status)) { |
|||
status_value = "partial"; |
|||
} |
|||
|
|||
} |
|||
|
|||
String sqlQuery = "UPDATE `petition` SET `status`='"+status_value+"' WHERE `petition_no`='"+petitionNo+"' AND `petition_id`='"+petitionId+"' LIMIT 1"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
System.out.println(sqlQuery); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getPetitionMappingDetails(String petitionNo, String petitionId) { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM petition_mapping WHERE (`petition_id`= ? AND petition_no = ?) AND (`isactive`=1 AND `isdelete`=0)"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery, petitionId, petitionNo); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean unmapComplient(String petitionId, String petitionNo) { |
|||
String sqlQuery = "UPDATE `petition_mapping` SET `isactive`='0',`isdelete`='1' WHERE `petition_id`='"+petitionId+"' AND `petition_no`='"+petitionNo+"'"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean mapComplientToOfficer( |
|||
String createdBy, String petitionId, String petitionNo, String complaintId, String officerId) { |
|||
String sqlQuery = "INSERT INTO `petition_mapping`" |
|||
+ "(`created_by`, `off_id`, `petition_no`, `complaint_typeid`, `petition_id`) " |
|||
+ "VALUES (?, ?, ?, ?, ?)"; |
|||
jdbcTemplate.update(sqlQuery, createdBy, officerId, petitionNo, complaintId, petitionId); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean updateMapComplientStatus(String mapId,String status) { |
|||
String sqlQuery = "UPDATE `petition_mapping` SET `status`=? WHERE `mapid`=? LIMIT 1"; |
|||
jdbcTemplate.update(sqlQuery, status, mapId); |
|||
System.out.println(sqlQuery); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintMappingDetails(String petitionNo, String petitionId, String complaintTypeId) { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM petition_mapping WHERE (`petition_id`= ? AND petition_no = ?) AND `complaint_typeid`= ? AND (`isactive`=1 AND `isdelete`=0) LIMIT 1"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery, petitionId, petitionNo,complaintTypeId); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintList(String loginId) { |
|||
String sqlQuery = ""; |
|||
try { |
|||
sqlQuery = "SELECT " |
|||
+ " p.`petition_id`, p.`cdate`, p.`created_by`, p.`isactive`, p.`isdelete`, p.`petition_no`, " |
|||
+ " p.`petitioner_address`, p.`petitioner_complaint`, p.`petitioner_complaint_txt`, " |
|||
+ " p.`petitioner_mobile`, p.`petitioner_name`, p.`complaint_nature`, p.`petitioner_pincode`, " |
|||
+ " pm.`mapid`, pm.`complaint_typeid`, pm.`off_id`, pm.`status`, om.`off_nm`, ctype.`complaint_type` " |
|||
+ " FROM " |
|||
+ " `petition` p, `petition_mapping` pm, `petition_master`.`officer_master` om, `petition_master`.`complaint_types` ctype " |
|||
+ " WHERE " |
|||
+ " (p.`isactive` = 1 AND p.`isdelete` = 0) " |
|||
+ " AND (pm.`isactive` = 1 AND pm.`isdelete` = 0) " |
|||
+ " AND (om.`isactive` = 1 AND om.`isdelete` = 0) " |
|||
+ " AND (om.`off_id` = pm.`off_id`) " |
|||
+ " AND (ctype.`complaint_typeid` = pm.`complaint_typeid`) " |
|||
+ " AND (p.`petition_id` = pm.`petition_id`)" |
|||
+ " "; |
|||
|
|||
String officerMaster = getMappingUserDetails.getOfficerMaster(loginId); |
|||
|
|||
if (officerMaster != null && !officerMaster.isEmpty()) { |
|||
sqlQuery = sqlQuery + "AND (pm.off_id IN("+officerMaster+"))"; |
|||
} |
|||
|
|||
System.out.println(sqlQuery); |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintListByPetitionId(String petitionId) { |
|||
try { |
|||
String sqlQuery = "SELECT " |
|||
+ " p.`petition_id`, p.`cdate`, p.`created_by`, p.`isactive`, p.`isdelete`, p.`petition_no`, " |
|||
+ " p.`petitioner_address`, p.`petitioner_complaint`, p.`petitioner_complaint_txt`, " |
|||
+ " p.`petitioner_mobile`, p.`petitioner_name`, p.`complaint_nature`, p.`petitioner_pincode`, p.`status` petition_status, " |
|||
+ " pm.`mapid`, pm.`complaint_typeid`, pm.`off_id`, pm.`status` complaint_status, pm.`cdate` mappedOn, om.`off_nm`, ctype.`complaint_type` " |
|||
+ " FROM " |
|||
+ " `commissioner_petition`.`petition` p,`commissioner_petition`.`petition_mapping` pm, `petition_master`.`officer_master` om, `petition_master`.`complaint_types` ctype " |
|||
+ " WHERE " |
|||
+ " (p.`petition_id` = '"+petitionId+"' AND p.`isactive` = 1 AND p.`isdelete` = 0) " |
|||
+ " AND (pm.`isactive` = 1 AND pm.`isdelete` = 0) " |
|||
+ " AND (om.`isactive` = 1 AND om.`isdelete` = 0) " |
|||
+ " AND (om.`off_id` = pm.`off_id`) " |
|||
+ " AND (ctype.`complaint_typeid` = pm.`complaint_typeid`) " |
|||
+ " AND (p.`petition_id` = pm.`petition_id`)" |
|||
+ " "; |
|||
System.out.println(sqlQuery); |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintDetails(String mapid) { |
|||
try { |
|||
String sqlQuery = "SELECT " |
|||
+ " p.`petition_id`, p.`cdate`, p.`created_by`, p.`isactive`, p.`isdelete`, p.`petition_no`, " |
|||
+ " p.`petitioner_address`, p.`petitioner_complaint`, p.`petitioner_complaint_txt`, " |
|||
+ " p.`petitioner_mobile`, p.`petitioner_name`, p.`complaint_nature`, p.`petitioner_pincode`, " |
|||
+ " pm.`mapid`, pm.`complaint_typeid`, pm.`off_id`, pm.`status`, om.`off_nm`, ctype.`complaint_type` " |
|||
+ " FROM " |
|||
+ " `petition` p,`petition_mapping` pm, `petition_master`.`officer_master` om, `petition_master`.`complaint_types` ctype " |
|||
+ " WHERE " |
|||
+ " pm.`mapid`='"+mapid+"' " |
|||
+ " AND (p.`isactive` = 1 AND p.`isdelete` = 0) " |
|||
+ " AND (pm.`isactive` = 1 AND pm.`isdelete` = 0) " |
|||
+ " AND (om.`isactive` = 1 AND om.`isdelete` = 0) " |
|||
+ " AND (om.`off_id` = pm.`off_id`) " |
|||
+ " AND (ctype.`complaint_typeid` = pm.`complaint_typeid`) " |
|||
+ " AND (p.`petition_id` = pm.`petition_id`)" |
|||
+ " "; |
|||
//System.out.println(sqlQuery); |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintActionDetails(String mapId) { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM `petition_action_taken` WHERE (`mapid`= ? AND `isactive`=1 AND `isdelete`=0) LIMIT 1"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery, mapId); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public String saveComplanitStatus( |
|||
String createdBy, |
|||
String mapId, |
|||
String complaintStatus, |
|||
String complaintActionText, |
|||
MultipartFile actionPage1, |
|||
String petitionId, |
|||
String petitionNo) { |
|||
|
|||
//System.out.println("I am from Service Page "+petitionerName); |
|||
|
|||
//String complaintNature = ""; |
|||
int lastInsertId = 0; |
|||
String sqlQuery = "INSERT INTO `petition_action_taken` " |
|||
+ "(`created_by`, `off_id`, `mapid`, `status`, " |
|||
+ "`comments`) " |
|||
+ "VALUES (?, ?, ?, ?, ?)"; |
|||
|
|||
try { |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
// Use JdbcTemplate's update method to execute the query with parameters |
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setString(1, createdBy); |
|||
ps.setString(2, createdBy); |
|||
ps.setString(3, mapId); |
|||
ps.setString(4, complaintStatus); |
|||
ps.setString(5, complaintActionText); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
// Get the last insert ID |
|||
lastInsertId = (int)keyHolder.getKey().longValue(); |
|||
String actionID = "error"; |
|||
if(lastInsertId>0) { |
|||
// Update Complaint Status |
|||
updateMapComplientStatus(mapId,"close"); |
|||
// Update Petition Status |
|||
updatePetitionStatus(petitionId,petitionNo); |
|||
// Add Action Scan File in the database |
|||
addActionFile(mapId,lastInsertId, actionPage1); |
|||
actionID = ""+lastInsertId; |
|||
} |
|||
|
|||
return actionID; // If no exception, query executed successfully |
|||
} catch (DataAccessException e) { |
|||
// Handle exception (e.g., log error) |
|||
e.printStackTrace(); |
|||
return "error"; // Query execution failed |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public String addActionFile( String mapId, int solmapid, |
|||
MultipartFile page1) { |
|||
|
|||
MultipartFile file = page1; |
|||
String fileName = "Scan1_"+solmapid; |
|||
|
|||
if (file != null && !file.isEmpty()) { |
|||
try { |
|||
// Get the bytes of the file |
|||
byte[] bytes = file.getBytes(); |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("com_foldername"); |
|||
String serviceActionFolderName = environment.getProperty("com_action_Foldername"); |
|||
|
|||
uploadDirectory = uploadDirectory + serviceFolderName +"/"+ serviceActionFolderName; |
|||
|
|||
// File name |
|||
fileName = mapId + "_" + fileName + "_" + file.getOriginalFilename(); |
|||
|
|||
//File Size |
|||
Long fileSize = file.getSize(); |
|||
|
|||
// File Type |
|||
String fileType = file.getContentType(); |
|||
|
|||
// Create directory if it doesn't exist |
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
String filePath = uploadDirectory + "/" + fileName; |
|||
|
|||
// Create a new Path object |
|||
Path path = Paths.get(filePath); |
|||
|
|||
// Write the bytes to the file |
|||
Files.write(path, bytes); |
|||
|
|||
// Save the file path to a database |
|||
String sqlQuery = "UPDATE `petition_action_taken` SET " |
|||
+ "`file_name`='"+fileName+"', " |
|||
+ "`file_size`='"+fileSize+"', " |
|||
+ "`file_type`='"+fileType+"' " |
|||
+ "WHERE `solmapid`='"+solmapid+"' LIMIT 1"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save file " + file.getOriginalFilename(); |
|||
} |
|||
} |
|||
return "success"; |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
@Service("ComPetitionMaster") |
|||
public class PetitionMaster { |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlPetitionMasterDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintType(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT * FROM `complaint_types` WHERE `isactive`=1 AND `isdelete`=0"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
|
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getOfficerList(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT * FROM `officer_master` WHERE `isactive`=1 AND `isdelete`=0"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
|
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getPetitionTypes(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT * FROM `petition_types` WHERE `isactive`=1 AND `isdelete`=0 ORDER BY `orderby` ASC"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.service; |
|||
@ -0,0 +1,34 @@ |
|||
package in.gov.chennaicorporation.gccoffice.controller; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
|
|||
@Service |
|||
public class DateTimeUtil { |
|||
public static String getCurrentDateTime() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ddMMyyyyHHmmss"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
public static String getCurrentYear() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
public static String getCurrentMonth() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
public static String getCurrentDay() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
public static String getCurrentDateTimeMysql() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
} |
|||
@ -0,0 +1,722 @@ |
|||
package in.gov.chennaicorporation.gccoffice.nulm.controller; |
|||
|
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.time.LocalDate; |
|||
import java.time.Month; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.dao.EmptyResultDataAccessException; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.nulm.service.NulmService; |
|||
|
|||
@RequestMapping("/gcc/api/nulm") |
|||
@RestController("nulmAPI") |
|||
public class NulmAPIController { |
|||
|
|||
private final Environment environment; |
|||
|
|||
@Autowired |
|||
private NulmService nulmService; |
|||
|
|||
@Autowired |
|||
private JdbcTemplate nulmJdbcTemplate; |
|||
|
|||
@Autowired |
|||
public NulmAPIController(NulmService nulmService,JdbcTemplate nulmJdbcTemplate,Environment environment) { |
|||
this.nulmService = nulmService; |
|||
this.nulmJdbcTemplate = nulmJdbcTemplate; |
|||
this.environment = environment; |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlNulmDataSource") DataSource dataSource) { |
|||
this.nulmJdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getYear") |
|||
public ResponseEntity<List<Map<String, Object>>> getYear() { |
|||
List<Map<String, Object>> yearList = nulmService.getYearList(); |
|||
return ResponseEntity.ok(yearList); |
|||
} |
|||
|
|||
@GetMapping("/getMonth") |
|||
public ResponseEntity<List<Map<String, Object>>> getMonth(int year) { |
|||
//System.out.println("year: "+year); |
|||
List<Map<String, Object>> monthList = nulmService.getMonthList(year); |
|||
return ResponseEntity.ok(monthList); |
|||
} |
|||
|
|||
@GetMapping("/getGender") |
|||
public ResponseEntity<List<Map<String, Object>>> getGender() { |
|||
|
|||
List<Map<String, Object>> genderList = nulmService.getGenderList(); |
|||
return ResponseEntity.ok(genderList); |
|||
} |
|||
|
|||
@GetMapping("/getDivisionList") |
|||
public ResponseEntity<List<Map<String, Object>>> getDivisionList(@RequestParam(required = false) String zone) { |
|||
List<Map<String, Object>> divisionList = nulmService.getDivisionList(zone); |
|||
return ResponseEntity.ok(divisionList); |
|||
} |
|||
|
|||
|
|||
@PostMapping("/saveGroup") |
|||
public ResponseEntity<String> saveSchemeGroup(@RequestBody Map<String, Object> payload) { |
|||
try { |
|||
Map<String, Object> groupData = new HashMap<>(payload); |
|||
nulmService.saveSchemeGroup(groupData); |
|||
return ResponseEntity.ok("Self Help Group Saved Successfully"); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body("Error saving Scheme Group: " + e.getMessage()); |
|||
} |
|||
} |
|||
/* |
|||
@PostMapping("/saveOrder") |
|||
public ResponseEntity<String> saveOrderDetails(@RequestBody Map<String, Object> payload) { |
|||
try { |
|||
Map<String, Object> orderData = new HashMap<>(payload); |
|||
nulmService.saveOrderDetails(orderData); |
|||
return ResponseEntity.ok("Order saved successfully."); |
|||
} catch (IllegalArgumentException e) { |
|||
return ResponseEntity.badRequest().body("Invalid data: " + e.getMessage()); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body("Error saving order: " + e.getMessage()); |
|||
} |
|||
} |
|||
*/ |
|||
@PostMapping("/saveStaff") |
|||
public ResponseEntity<String> saveStaffDetails(@RequestBody Map<String, Object> payload) { |
|||
try { |
|||
nulmService.saveStaffDetails(payload); |
|||
return ResponseEntity.ok("Staff details saved successfully."); |
|||
} catch (IllegalArgumentException e) { |
|||
return ResponseEntity.badRequest().body("Error: " + e.getMessage()); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body("Error saving staff details: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/assignAppointment") |
|||
public ResponseEntity<String> assignOrderToEnrollments(@RequestBody Map<String, Object> requestBody) { |
|||
int orderId = (int) requestBody.get("orderId"); |
|||
String inchargePhoneno = ((String) requestBody.get("incharge_phoneno")); |
|||
String designation = (String) requestBody.get("designation"); |
|||
List<Integer> enrollmentIds = (List<Integer>) requestBody.get("enrollmentIds"); |
|||
|
|||
// Step 1: Retrieve the selected order |
|||
String getOrderSql = "SELECT * FROM order_details WHERE order_id = ?"; |
|||
Map<String, Object> orderDetails; |
|||
|
|||
try { |
|||
orderDetails = nulmJdbcTemplate.queryForMap(getOrderSql, orderId); |
|||
} catch (EmptyResultDataAccessException e) { |
|||
// Handle the case where no order is found |
|||
return new ResponseEntity<>("No order found with order_id: " + orderId, HttpStatus.NOT_FOUND); |
|||
} |
|||
|
|||
if (orderDetails != null) { |
|||
// Step 2: Build the SQL for updating enrollments with dynamic IN clause |
|||
StringBuilder updateSql = new StringBuilder("UPDATE enrollment_table SET order_id = ?, appointed = 'Yes', facial_attendance = 'No', incharge_phoneno = ?, designation = ?, appointed_date = CURRENT_DATE WHERE enrollment_id IN ("); |
|||
|
|||
// Add placeholders for the IN clause based on the size of the enrollmentIds list |
|||
for (int i = 0; i < enrollmentIds.size(); i++) { |
|||
updateSql.append("?"); |
|||
if (i < enrollmentIds.size() - 1) { |
|||
updateSql.append(", "); |
|||
} |
|||
} |
|||
updateSql.append(")"); |
|||
|
|||
// Combine the orderId, inchargePhoneno, designation, and the list of enrollmentIds |
|||
List<Object> parameters = new ArrayList<>(); |
|||
parameters.add(orderId); |
|||
parameters.add(inchargePhoneno); |
|||
parameters.add(designation); |
|||
parameters.addAll(enrollmentIds); |
|||
|
|||
// Execute the update query |
|||
try { |
|||
nulmJdbcTemplate.update(updateSql.toString(), parameters.toArray()); |
|||
return new ResponseEntity<>("Order assigned to enrollments and appointed successfully.", HttpStatus.OK); |
|||
} catch (DataAccessException e) { |
|||
// Handle any data access exceptions |
|||
return new ResponseEntity<>("Error updating enrollments: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
|||
} |
|||
} |
|||
|
|||
return new ResponseEntity<>("Unexpected error occurred.", HttpStatus.INTERNAL_SERVER_ERROR); |
|||
} |
|||
|
|||
@PostMapping("/assignDropout") |
|||
public ResponseEntity<String> assignDropout(@RequestBody Map<String, Object> requestBody) { |
|||
int orderId = (int) requestBody.get("orderId"); |
|||
List<Integer> enrollmentIds = (List<Integer>) requestBody.get("enrollmentIds"); |
|||
|
|||
// Step 1: Retrieve the selected order |
|||
String getOrderSql = "SELECT * FROM order_details WHERE order_id = ?"; |
|||
Map<String, Object> orderDetails; |
|||
|
|||
try { |
|||
orderDetails = nulmJdbcTemplate.queryForMap(getOrderSql, orderId); |
|||
} catch (EmptyResultDataAccessException e) { |
|||
// Handle the case where no order is found |
|||
return new ResponseEntity<>("No order found with order_id: " + orderId, HttpStatus.NOT_FOUND); |
|||
} |
|||
|
|||
if (orderDetails != null) { |
|||
// Step 2: Build the SQL for updating enrollments with dynamic IN clause |
|||
StringBuilder updateSql = new StringBuilder("UPDATE enrollment_table SET appointed = 'Drop', dropout = 'Yes', dropout_date = CURRENT_DATE WHERE enrollment_id IN ("); |
|||
|
|||
// Add placeholders for the IN clause based on the size of the enrollmentIds list |
|||
for (int i = 0; i < enrollmentIds.size(); i++) { |
|||
updateSql.append("?"); |
|||
if (i < enrollmentIds.size() - 1) { |
|||
updateSql.append(", "); |
|||
} |
|||
} |
|||
updateSql.append(") AND order_id = ?"); // Match the order_id in the WHERE clause |
|||
|
|||
// Combine the list of enrollmentIds and the orderId |
|||
List<Object> parameters = new ArrayList<>(enrollmentIds); |
|||
parameters.add(orderId); // Add orderId at the end of the parameters list |
|||
|
|||
// Execute the update query |
|||
try { |
|||
int rowsAffected = nulmJdbcTemplate.update(updateSql.toString(), parameters.toArray()); |
|||
if (rowsAffected > 0) { |
|||
return new ResponseEntity<>("Order assigned to enrollments has been Dropout successfully.", HttpStatus.OK); |
|||
} else { |
|||
return new ResponseEntity<>("No matching records found to update.", HttpStatus.NOT_FOUND); |
|||
} |
|||
} catch (DataAccessException e) { |
|||
// Handle any data access exceptions |
|||
return new ResponseEntity<>("Error updating enrollments: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
|||
} |
|||
} |
|||
|
|||
return new ResponseEntity<>("Unexpected error occurred.", HttpStatus.INTERNAL_SERVER_ERROR); |
|||
} |
|||
|
|||
@GetMapping("/getAllSchemeGroupNames") |
|||
public ResponseEntity<List<Map<String, Object>>> getAllSchemeGroupNames() { |
|||
try { |
|||
List<Map<String,Object>> schemeGroupNames = nulmService.getAllSchemeGroupNames(); |
|||
return ResponseEntity.ok(schemeGroupNames); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.emptyList()); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getAllOrderNumber") |
|||
public ResponseEntity<List<String>> getAllOrderNumber() { |
|||
try { |
|||
List<String> schemeGroupNames = nulmService.getAllOrderNumber(); |
|||
return ResponseEntity.ok(schemeGroupNames); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.emptyList()); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getAllSchemeGroups") |
|||
public ResponseEntity<List<Map<String, Object>>> getAllSchemeGroups() { |
|||
try { |
|||
List<Map<String, Object>> groups = nulmService.getAllSchemeGroups(); |
|||
return ResponseEntity.ok(groups); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body(null); |
|||
} |
|||
} |
|||
|
|||
///////get all list of orders//////////////////////////// |
|||
@GetMapping("/getAllOrders") |
|||
public ResponseEntity<List<Map<String, Object>>> getAllOrders() { |
|||
try { |
|||
List<Map<String, Object>> groups = nulmService.getAllOrders(); |
|||
return ResponseEntity.ok(groups); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body(null); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getAllStaffNames") |
|||
public ResponseEntity<List<String>> getAllStaffNames() { |
|||
try { |
|||
List<String> schemeGroupNames = nulmService.getStaffName(); |
|||
return ResponseEntity.ok(schemeGroupNames); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.emptyList()); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/appointedCounts") |
|||
public ResponseEntity<Map<String, Integer>> getAppointedCounts( |
|||
@RequestParam(required = false) Integer groupId) { |
|||
|
|||
try { |
|||
// Validate that groupId is provided |
|||
if (groupId == null) { |
|||
return ResponseEntity.badRequest().body(null); // You can also return a specific error message |
|||
} |
|||
|
|||
// Call the service method to get the counts |
|||
Map<String, Integer> counts = nulmService.getAppointedCounts(groupId); |
|||
|
|||
return ResponseEntity.ok(counts); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null); // You can also return the error message |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/markAbsent") |
|||
public ResponseEntity<String> markAbsent(@RequestParam int employeeId) { |
|||
int result = nulmService.markAbsentEntry(employeeId); |
|||
|
|||
if (result > 0) { |
|||
return ResponseEntity.ok("Employee marked as absent successfully."); |
|||
} else { |
|||
return ResponseEntity.status(304).body("No update made. Employee may already be marked as absent or has attended."); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/markOverDuty") |
|||
public ResponseEntity<String> markOverDuty(@RequestParam int employeeId) { |
|||
int result = nulmService.markOverDuty(employeeId); |
|||
|
|||
if (result > 0) { |
|||
return ResponseEntity.ok("Over Duty marked successfully."); |
|||
} else { |
|||
return ResponseEntity.status(304).body("No update made. Employee ID may not exist."); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/markAttendance") |
|||
public ResponseEntity<String> markAttendance( |
|||
@RequestParam int employeeId, |
|||
@RequestParam String markAttendance) { |
|||
try { |
|||
String result = nulmService.markAttendance(employeeId, markAttendance); |
|||
if ("Checked in successfully".equals(result) || "Checked out successfully".equals(result)) { |
|||
return ResponseEntity.ok(result); |
|||
} else { |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result); |
|||
} |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to mark attendance"); |
|||
} |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getAllOrderDetails") |
|||
public ResponseEntity<List<Map<String, Object>>> getAllOrderDetails() { |
|||
try { |
|||
List<Map<String, Object>> orderDetails = nulmService.getAllOrderDetails(); |
|||
return ResponseEntity.ok(orderDetails); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Collections.emptyList()); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/enrollmentCountsbyorderId") |
|||
public ResponseEntity<Map<String, Integer>> getEnrollmentCounts(@RequestParam int orderId) { |
|||
Map<String, Integer> counts = nulmService.getAppointedCounts(orderId); |
|||
return ResponseEntity.ok(counts); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/dropOutCounts") |
|||
public ResponseEntity<Map<String, Integer>> getDropCounts(@RequestParam int orderId) { |
|||
Map<String, Integer> counts = nulmService.getDropCounts(orderId); |
|||
return ResponseEntity.ok(counts); |
|||
} |
|||
|
|||
@GetMapping("/enrollmentCountsbygroupId") |
|||
public ResponseEntity<List<Map<String, Object>>> getEnrollmentbygroupId(@RequestParam int groupId) { |
|||
List<Map<String, Object>> enrollmentDetails = nulmService.getEnrollmentDetails(groupId); |
|||
return ResponseEntity.ok(enrollmentDetails); |
|||
} |
|||
|
|||
@GetMapping("/appointmentCountsbygroupId") |
|||
public ResponseEntity<List<Map<String, Object>>> getAppointedDetails(@RequestParam int groupId) { |
|||
List<Map<String, Object>> enrollmentDetails = nulmService.getAppointedDetails(groupId); |
|||
return ResponseEntity.ok(enrollmentDetails); |
|||
} |
|||
|
|||
@GetMapping("/getDepartment") |
|||
public ResponseEntity<List<Map<String, Object>>> getDepartment() { |
|||
List<Map<String, Object>> orderNumbers = nulmService.getDepartment(); |
|||
return ResponseEntity.ok(orderNumbers); |
|||
} |
|||
|
|||
@GetMapping("/getEnrollmentdeatilsByID/{enrollmentId}") |
|||
public ResponseEntity<List<Map<String, Object>>> getEnrollmentsById(@PathVariable("enrollmentId") int enrollmentId) { |
|||
List<Map<String, Object>> enrollments = nulmService.getEnrollmentsById(enrollmentId); |
|||
|
|||
if (enrollments.isEmpty()) { |
|||
return ResponseEntity.noContent().build(); // Return 204 No Content if no enrollments are found |
|||
} |
|||
|
|||
return ResponseEntity.ok(enrollments); // Return 200 OK with the list of enrollments |
|||
} |
|||
|
|||
@GetMapping("/selfHelpGroups") |
|||
public ResponseEntity<List<Map<String, Object>>> getSelfHelpGroups() { |
|||
List<Map<String, Object>> selfHelpGroups = nulmService.getSelfHelpGroups(); |
|||
return ResponseEntity.ok(selfHelpGroups); |
|||
} |
|||
|
|||
@GetMapping("/orderNumbers") |
|||
public ResponseEntity<List<Map<String, Object>>> getOrderNumbers() { |
|||
List<Map<String, Object>> orderNumbers = nulmService.getOrderNumbers(); |
|||
return ResponseEntity.ok(orderNumbers); |
|||
} |
|||
|
|||
@PostMapping("/updateEnrollment/{id}") |
|||
public ResponseEntity<String> updateEnrollment( |
|||
@PathVariable("id") int id, |
|||
@RequestParam String dateOfBirth, |
|||
@RequestParam String gender, |
|||
@RequestParam int groupId, // New parameter |
|||
@RequestParam int orderId // New parameter |
|||
) { |
|||
int rowsAffected = nulmService.updateEnrollment(id, dateOfBirth, gender, groupId, orderId); |
|||
|
|||
if (rowsAffected > 0) { |
|||
return new ResponseEntity<>("Enrollment updated successfully", HttpStatus.OK); |
|||
} else { |
|||
return new ResponseEntity<>("Enrollment update failed", HttpStatus.NOT_FOUND); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/saveOrder") |
|||
public ResponseEntity<String> saveOrderDetails(@RequestParam String order_number, |
|||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date order_date, |
|||
@RequestParam int no_of_staffs, |
|||
@RequestParam String order_description, |
|||
@RequestParam MultipartFile ordercopyurl, |
|||
@RequestParam String order_generated_by, |
|||
@RequestParam String category, |
|||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date validity_date) { |
|||
String order_copy_url = ""; |
|||
try { |
|||
// Fetch the upload directory and folder name from environment |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String folderName = environment.getProperty("nulm_foldername"); |
|||
String fileName = "OrderCopy_" + ordercopyurl.getOriginalFilename(); |
|||
|
|||
// Construct the file path |
|||
String filepath = uploadDirectory + folderName + "/" + fileName; |
|||
Path path = Paths.get(filepath); |
|||
|
|||
// Ensure the directory exists |
|||
Files.createDirectories(path.getParent()); |
|||
|
|||
// Write the file to the specified path |
|||
Files.write(path, ordercopyurl.getBytes()); |
|||
|
|||
// Set the order_copy_url to the relative file path for storing in DB |
|||
order_copy_url = folderName + "/" + fileName; |
|||
|
|||
// Save the order details using the service method |
|||
String savedOrderNumber = nulmService.saveOrderDetails( |
|||
order_number, |
|||
order_date, |
|||
no_of_staffs, |
|||
order_description, |
|||
order_copy_url, |
|||
order_generated_by, |
|||
category, |
|||
validity_date |
|||
); |
|||
|
|||
return ResponseEntity.ok("Order saved successfully with order number: " + savedOrderNumber); |
|||
|
|||
} catch (Exception e) { |
|||
// Handle error scenarios |
|||
return ResponseEntity.status(500).body("Error saving order: " + e.getMessage()); |
|||
} |
|||
} |
|||
/* |
|||
@GetMapping("/staffInititeadList") |
|||
public ResponseEntity<List<Map<String, Object>>> getAttendanceWithInitiatedSalaryByGroupId(@RequestParam("inchargeName") String inchargeName, |
|||
@RequestParam("month") String month) { |
|||
List<Map<String, Object>> staffList = nulmService.getAttendanceWithInitiatedSalary(inchargeName, month); |
|||
return ResponseEntity.ok(staffList); |
|||
} |
|||
|
|||
@GetMapping("/staffInititeadList") |
|||
public ResponseEntity<List<Map<String, Object>>> getAttendanceWithInitiatedSalaryByGroupId( |
|||
@RequestParam(value = "inchargeId", required = false) String inchargeId, |
|||
@RequestParam(value = "month", required = false) String month, |
|||
@RequestParam(value = "inchargeName", required = false) String inchargeName, |
|||
@RequestParam(value = "zone", required = false) Integer zone) { |
|||
|
|||
List<Map<String, Object>> staffList = nulmService.getAttendanceWithInitiatedSalary(inchargeId, month, inchargeName, zone); |
|||
return ResponseEntity.ok(staffList); |
|||
} |
|||
*/ |
|||
|
|||
@GetMapping("/staffInititeadList") |
|||
public ResponseEntity<List<Map<String, Object>>> getAttendanceWithInitiatedSalaryByGroupId( |
|||
@RequestParam(value = "inchargeId", required = false) Integer inchargeId, |
|||
@RequestParam(value = "month", required = false) String month, |
|||
@RequestParam(value = "incharge_name", required = false) String inchargeName, |
|||
@RequestParam (value = "enrollmentIds", required = false) List<Integer> enrollmentIds) { |
|||
|
|||
List<Map<String, Object>> staffList = nulmService.getAttendanceWithInitiatedSalary(inchargeId, month, inchargeName, enrollmentIds); |
|||
return ResponseEntity.ok(staffList); |
|||
} |
|||
|
|||
@PostMapping("/salaryDetailUpdate") |
|||
public ResponseEntity<String> addSalaryDetails(@RequestBody List<Map<String, Object>> requestList) { |
|||
System.out.println("Received POST request with data: " + requestList); |
|||
try { |
|||
for (Map<String, Object> request : requestList) { |
|||
int totalDaysPresent = Integer.parseInt(request.get("total_days_present").toString()); |
|||
int totalDaysOd = Integer.parseInt(request.get("total_days_od").toString()); |
|||
int totalDaysSalary = Integer.parseInt(request.get("total_days_salary").toString()); |
|||
int totalDaysAbsent = Integer.parseInt(request.get("total_days_absent").toString()); |
|||
String month = request.get("month").toString(); |
|||
int year = Integer.parseInt(request.get("year").toString()); |
|||
int salaryAmount = Integer.parseInt(request.get("salary_amount").toString()); |
|||
int enrollmentId = Integer.parseInt(request.get("enrollment_id").toString()); |
|||
int groupId = Integer.parseInt(request.get("group_id").toString()); |
|||
int wageId = Integer.parseInt(request.get("wage_id").toString()); |
|||
|
|||
// Check if the month and year are valid for salary initiation (past month) |
|||
if (isFutureOrCurrentMonth(month, year)) { |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) |
|||
.body("Salary cannot be initiated for the current or future months. Please select a past month."); |
|||
} |
|||
|
|||
String salaryStatus = "Initiated"; |
|||
|
|||
// Call the service method to insert the salary details |
|||
int rowsAffected = nulmService.addSalaryDetails(totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year, salaryAmount, salaryStatus, enrollmentId, groupId, wageId); |
|||
|
|||
if (rowsAffected <= 0) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Failed to add salary details for enrollment ID: " + enrollmentId); |
|||
} |
|||
} |
|||
return ResponseEntity.status(HttpStatus.CREATED) |
|||
.body("Salary details added successfully for all selected entries."); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log the exception for debugging |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) |
|||
.body("Invalid request data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
// Helper method to check if the month is future or current |
|||
private boolean isFutureOrCurrentMonth(String month, int year) { |
|||
// Get the current month and year |
|||
LocalDate currentDate = LocalDate.now(); |
|||
Month currentMonth = currentDate.getMonth(); |
|||
int currentYear = currentDate.getYear(); |
|||
|
|||
// Convert the string month from the request to Month enum |
|||
Month requestMonth = Month.valueOf(month.toUpperCase()); // Ensure that month is passed in capitalized format like "JANUARY", "FEBRUARY", etc. |
|||
|
|||
// Compare the request month and year with the current date |
|||
if (year > currentYear) { |
|||
return true; // Future year |
|||
} else if (year == currentYear && requestMonth.compareTo(currentMonth) >= 0) { |
|||
return true; // Current or future month in the current year |
|||
} |
|||
return false; // Past month |
|||
} |
|||
|
|||
// @PostMapping("/salaryDetailUpdate") |
|||
// public ResponseEntity<String> addSalaryDetails(@RequestBody List<Map<String, Object>> requestList) { |
|||
// System.out.println("Received POST request with data: " + requestList); |
|||
// try { |
|||
// for (Map<String, Object> request : requestList) { |
|||
// int totalDaysPresent = Integer.parseInt(request.get("total_days_present").toString()); |
|||
// int totalDaysOd = Integer.parseInt(request.get("total_days_od").toString()); |
|||
// int totalDaysSalary = Integer.parseInt(request.get("total_days_salary").toString()); |
|||
// int totalDaysAbsent = Integer.parseInt(request.get("total_days_absent").toString()); |
|||
// String month = request.get("month").toString(); |
|||
// int year = Integer.parseInt(request.get("year").toString()); |
|||
// int salaryAmount = Integer.parseInt(request.get("salary_amount").toString()); |
|||
// int enrollmentId = Integer.parseInt(request.get("enrollment_id").toString()); |
|||
// int groupId = Integer.parseInt(request.get("group_id").toString()); |
|||
// int wageId = Integer.parseInt(request.get("wage_id").toString()); |
|||
// |
|||
// String salaryStatus = "Initiated"; |
|||
// |
|||
// // Call the service method to insert the salary details |
|||
// int rowsAffected = nulmService.addSalaryDetails(totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year, salaryAmount, salaryStatus, enrollmentId, groupId, wageId); |
|||
// |
|||
// if (rowsAffected <= 0) { |
|||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to add salary details for enrollment ID: " + enrollmentId); |
|||
// } |
|||
// } |
|||
// return ResponseEntity.status(HttpStatus.CREATED).body("Salary details added successfully for all selected entries."); |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); // Log the exception for debugging |
|||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid request data: " + e.getMessage()); |
|||
// } |
|||
// } |
|||
|
|||
@PostMapping("/update-salary-status") |
|||
public ResponseEntity<String> updateSalaryStatus( |
|||
@RequestParam List<Integer> enrollmentIds, |
|||
@RequestParam String month, |
|||
@RequestParam int year) { |
|||
System.out.println("Enrollment IDs: " + enrollmentIds); |
|||
System.out.println("Month: " + month); |
|||
System.out.println("Year: " + year); |
|||
nulmService.updateSalaryStatusToApproved(enrollmentIds, month, year); |
|||
return ResponseEntity.ok("Salary status updated to 'Approved' for the provided enrollments."); |
|||
} |
|||
|
|||
/***************API For Mobile Application*********************************/ |
|||
/* |
|||
@GetMapping("/attendanceWithSalary") |
|||
public ResponseEntity<List<Map<String, Object>>> getAttendanceWithSalaryByInchargeId( |
|||
@RequestParam(value = "month", required = false) String month, |
|||
@RequestParam(value = "year", required = false) Integer year, |
|||
@RequestParam(value = "incharge_id", required = false) Integer inchargeId) { |
|||
|
|||
try { |
|||
// Call the service method to fetch the data |
|||
List<Map<String, Object>> attendanceWithSalary = nulmService.getAttendanceWithSalaryByInchargeId(month, year, inchargeId); |
|||
|
|||
// If no data is found, return a NOT FOUND response |
|||
if (attendanceWithSalary.isEmpty()) { |
|||
return ResponseEntity.status(404).body(List.of(Map.of("error", "No attendance records found for the specified parameters."))); |
|||
} |
|||
|
|||
// Return the data in the response |
|||
return ResponseEntity.ok(attendanceWithSalary); |
|||
} catch (Exception ex) { |
|||
// Return a 500 Internal Server Error with the error message |
|||
return ResponseEntity.status(500).body(List.of(Map.of("error", "An error occurred while fetching attendance data: " + ex.getMessage()))); |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
@GetMapping("/attendanceWithSalary") |
|||
public ResponseEntity<List<Map<String, Object>>> getAttendanceWithSalaryByInchargeId( |
|||
@RequestParam(value = "month", required = false) String month, |
|||
@RequestParam(value = "year", required = false) Integer year, |
|||
@RequestParam(value = "incharge_id", required = false) Integer inchargeId) { |
|||
|
|||
try { |
|||
// Call the service method to fetch the data |
|||
List<Map<String, Object>> attendanceWithSalary = nulmService.getAttendanceWithSalaryByInchargeId(month, year, inchargeId); |
|||
// If no data is found, return a NOT FOUND response total_days_salary, total_salary and total_days_absent |
|||
if (attendanceWithSalary.isEmpty()) { |
|||
return ResponseEntity.status(404).body(List.of(Map.of("error", "No attendance records found for the specified parameters."))); |
|||
} |
|||
|
|||
|
|||
for (Map<String, Object> aa : attendanceWithSalary) { |
|||
long days = ((Number) aa.get("total_days")).longValue(); |
|||
long present = ((Number) aa.get("total_days_present")).longValue(); |
|||
long od = ((Number) aa.get("total_days_od")).longValue(); |
|||
long salaryPerDay = ((Number) aa.get("salary_per_day")).longValue(); |
|||
|
|||
long totalPresent = present + od; |
|||
long totalAbsent = days - totalPresent; |
|||
long totalSalary = totalPresent * salaryPerDay; |
|||
|
|||
aa.put("total_salary", totalSalary); |
|||
aa.put("total_days_absent", totalAbsent); |
|||
aa.put("total_days_salary", totalPresent); |
|||
} |
|||
|
|||
|
|||
// Return the data in the response |
|||
return ResponseEntity.ok(attendanceWithSalary); |
|||
} catch (Exception ex) { |
|||
// Return a 500 Internal Server Error with the error message |
|||
return ResponseEntity.status(500).body(List.of(Map.of("error", "An error occurred while fetching attendance data: " + ex.getMessage()))); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/salaryDetailInitiate") |
|||
public ResponseEntity<String> addInitiatedSalaryDetails( |
|||
@RequestParam("total_days_present") List<Integer> totalDaysPresentList, |
|||
@RequestParam("total_days_od") List<Integer> totalDaysOdList, |
|||
@RequestParam("total_days_salary") List<Integer> totalDaysSalaryList, |
|||
@RequestParam("total_days_absent") List<Integer> totalDaysAbsentList, |
|||
@RequestParam("month") List<String> monthList, |
|||
@RequestParam("year") List<Integer> yearList, |
|||
@RequestParam("salary_amount") List<Integer> salaryAmountList, |
|||
@RequestParam("enrollment_id") List<Integer> enrollmentIdList, |
|||
@RequestParam("group_id") List<Integer> groupIdList, |
|||
@RequestParam("wage_id") List<Integer> wageIdList |
|||
) { |
|||
//System.out.println("Received POST request with form-data"); |
|||
|
|||
try { |
|||
// Iterate through each list to process the form data |
|||
for (int i = 0; i < totalDaysPresentList.size(); i++) { |
|||
int totalDaysPresent = totalDaysPresentList.get(i); |
|||
int totalDaysOd = totalDaysOdList.get(i); |
|||
int total_days_salary = totalDaysSalaryList.get(i); |
|||
int totalDaysAbsent= totalDaysAbsentList.get(i); |
|||
String month = monthList.get(i); |
|||
int year = yearList.get(i); |
|||
int salaryAmount = salaryAmountList.get(i); |
|||
int enrollmentId = enrollmentIdList.get(i); |
|||
int groupId = groupIdList.get(i); |
|||
int wageId = wageIdList.get(i); |
|||
|
|||
String salaryStatus = "Initiated"; |
|||
|
|||
// Call the service method to insert the salary details |
|||
int rowsAffected = nulmService.addSalaryDetails(totalDaysPresent, totalDaysOd, total_days_salary, totalDaysAbsent, month, year, salaryAmount, salaryStatus, enrollmentId, groupId, wageId); |
|||
|
|||
if (rowsAffected <= 0) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to add salary details for enrollment ID: " + enrollmentId); |
|||
} |
|||
} |
|||
return ResponseEntity.status(HttpStatus.CREATED).body("Salary details added successfully for all selected entries."); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log the exception for debugging |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid request data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
// @GetMapping("/filtered-details") |
|||
// public List<Map<String, Object>> getFilteredSalaryDetails( |
|||
// @RequestParam(required = false) String month, |
|||
// @RequestParam(required = false) Integer year, |
|||
// @RequestParam(required = false) String salaryStatus) { |
|||
// |
|||
// // Call the service method to get the filtered salary details |
|||
// return nulmService.getFilteredSalaryDetails(month, year, salaryStatus); |
|||
// } |
|||
} |
|||
@ -0,0 +1,207 @@ |
|||
package in.gov.chennaicorporation.gccoffice.nulm.controller; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.nulm.service.NulmService; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@Controller |
|||
@RequestMapping("/gcc/nulm") |
|||
public class NulmController { |
|||
|
|||
@Autowired |
|||
private NulmService nulmService; |
|||
|
|||
@GetMapping("/appointment") |
|||
public String viewappoinmentMaster(Model model) { |
|||
System.out.println("appointment"); |
|||
return "modules/nulm/appointment"; |
|||
} |
|||
|
|||
@GetMapping("/self-enrollment") |
|||
public String viewselfenrollment(Model model) { |
|||
System.out.println("self-enrollment"); |
|||
return "modules/nulm/staff-enrollment"; |
|||
} |
|||
|
|||
@GetMapping("/create-order") |
|||
public String viewcreateorder(Model model) { |
|||
System.out.println("create-order"); |
|||
return "modules/nulm/create-order"; |
|||
} |
|||
|
|||
@GetMapping("/scheme-group") |
|||
public String viewschemegroup(Model model) { |
|||
System.out.println("scheme-group"); |
|||
return "modules/nulm/scheme-group"; |
|||
} |
|||
|
|||
@GetMapping("/dropout") |
|||
public String viewappointmentscreengroup(Model model) { |
|||
System.out.println("dropout"); |
|||
return "modules/nulm/dropout"; |
|||
} |
|||
|
|||
@GetMapping("/updateStaff") |
|||
public String viewUpdateScreen( |
|||
@RequestParam(value = "department", required = false) String department, |
|||
@RequestParam(value = "division", required = false) String division, |
|||
Model model) { |
|||
|
|||
// Fetch the full list or filtered list based on parameters |
|||
List<Map<String, Object>> enrollments = nulmService.getEnrollments(department, null); |
|||
|
|||
// Add the list to the model to be accessed in the view |
|||
model.addAttribute("enrollments", enrollments); |
|||
model.addAttribute("selectedDepartment", department); // Pass the selected department |
|||
|
|||
// Return the view name |
|||
return "modules/nulm/updated-staff"; |
|||
} |
|||
|
|||
@GetMapping("/salaryDetails") |
|||
public String getSalaryDetails( |
|||
@RequestParam(value = "month", required = false) String month, |
|||
@RequestParam(value = "year", required = false) Integer year, // Use Integer instead of int |
|||
Model model) { |
|||
|
|||
List<Map<String, Object>> salaryDetails = new ArrayList<>(); |
|||
|
|||
// Check if month and year are provided |
|||
if (month != null && year != null) { |
|||
salaryDetails = nulmService.getAttendanceWithSalary(month, year); |
|||
} else { |
|||
// Handle case when no month or year is provided |
|||
model.addAttribute("message", "Please select a month and year."); |
|||
} |
|||
|
|||
model.addAttribute("salaryCounts", salaryDetails); |
|||
System.out.println("salarydetails for month: " + month + ", year: " + year); |
|||
return "modules/nulm/salary-details"; |
|||
} |
|||
/* |
|||
@GetMapping("/salary-approve") |
|||
public String viewSalaryApproveScreen(@RequestParam(required = false) String month, |
|||
@RequestParam(required = false) Integer year, |
|||
@RequestParam(required = false) String salaryStatus, |
|||
Model model) { |
|||
List<Map<String, Object>> salaryInitiatedCounts; |
|||
|
|||
// If both month and year are provided, fetch the data; otherwise, return an empty list |
|||
if (month != null && year != null) { |
|||
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails(month, year, salaryStatus); |
|||
} else { |
|||
salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided |
|||
} |
|||
|
|||
model.addAttribute("salaryInitiatedCounts", salaryInitiatedCounts); |
|||
return "modules/nulm/salary-approve"; |
|||
} |
|||
*/ |
|||
@GetMapping("/salary-approve") |
|||
public String viewSalaryApproveScreen(@RequestParam(required = false) String month, |
|||
@RequestParam(required = false) Integer year, |
|||
@RequestParam(required = false) String salaryStatus, // Added department parameter |
|||
Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
List<Map<String, Object>> salaryInitiatedCounts; |
|||
|
|||
// Fetch data if both month and year are provided, otherwise return an empty list |
|||
if (month != null && year != null) { |
|||
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails(month, year, salaryStatus,LoginUserId); // Pass department to the service method |
|||
} else { |
|||
salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided |
|||
} |
|||
|
|||
model.addAttribute("salaryInitiatedCounts", salaryInitiatedCounts); |
|||
|
|||
return "modules/nulm/salary-approve"; |
|||
} |
|||
|
|||
@GetMapping("/salary-report") |
|||
public String viewSalaryReport( |
|||
@RequestParam(required = false) String month, |
|||
@RequestParam(required = false) Integer year, |
|||
@RequestParam(required = false) String salaryStatus, |
|||
@RequestParam(required = false) String groupName, |
|||
Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
// Initialize an empty salaryReport list |
|||
List<Map<String, Object>> salaryReport = new ArrayList<>(); |
|||
|
|||
// Only fetch the report if month and year are provided |
|||
if (month != null && year != null) { |
|||
salaryReport = nulmService.getSalaryReport(month, year, salaryStatus, groupName, LoginUserId); |
|||
} |
|||
|
|||
// Add the fetched data to the model |
|||
model.addAttribute("salaryReport", salaryReport); |
|||
|
|||
return "modules/nulm/salary-report"; // Returns the view 'salary-report' |
|||
} |
|||
|
|||
|
|||
@GetMapping("/salary-zonereport") |
|||
public String viewZoneWiseReport( |
|||
@RequestParam(required = false) String month, |
|||
@RequestParam(required = false) Integer year, |
|||
@RequestParam(required = false) String salaryStatus, |
|||
@RequestParam(required = false) String groupName, |
|||
@RequestParam(required = false) String zone, |
|||
@RequestParam(required = false) String division, |
|||
Model model) { |
|||
//System.out.println("Zone: "+zone); |
|||
|
|||
// Initialize an empty salaryReport list |
|||
List<Map<String, Object>> zoneWiseReport = new ArrayList<>(); |
|||
|
|||
// Only fetch the report if month, year and zone are provided |
|||
if (month != null && year != null && zone!= null) { |
|||
zoneWiseReport = nulmService.getZoneWiseReport(month, year, salaryStatus ,groupName, zone, division); |
|||
} |
|||
|
|||
// Add the fetched data to the model |
|||
model.addAttribute("zonewiseReport", zoneWiseReport); |
|||
|
|||
return "modules/nulm/zone-wise-report"; // Returns the view 'salary-zonereport' |
|||
} |
|||
|
|||
@GetMapping("/attendance-report") |
|||
public String viewAttendanceReport( |
|||
@RequestParam(required = false) String fromdate, |
|||
@RequestParam(required = false) String todate, |
|||
@RequestParam(required = false) String groupName, |
|||
@RequestParam(required = false) String zone, |
|||
@RequestParam(required = false) String division, |
|||
Model model) { |
|||
|
|||
// Initialize an empty salaryReport list |
|||
List<Map<String, Object>> attendanceReport = new ArrayList<>(); |
|||
|
|||
// Only fetch the report if month, year and zone are provided |
|||
if (division != null && zone!= null) { |
|||
attendanceReport = nulmService.getAttendanceReport(fromdate ,todate ,groupName, zone, division); |
|||
} |
|||
|
|||
// Add the fetched data to the model |
|||
model.addAttribute("attendanceReport", attendanceReport); |
|||
|
|||
return "modules/nulm/attendance-report"; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.nulm.controller; |
|||
@ -0,0 +1,279 @@ |
|||
package in.gov.chennaicorporation.gccoffice.nulm.repository; |
|||
|
|||
import java.sql.ResultSet; |
|||
import java.sql.SQLException; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.RowMapper; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
public class NulmRepository { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate nulmJdbcTemplate; |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public NulmRepository(JdbcTemplate nulmJdbcTemplate,JdbcTemplate jdbcTemplate) { |
|||
this.nulmJdbcTemplate = nulmJdbcTemplate; |
|||
this.jdbcTemplate = jdbcTemplate; |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlNulmDataSource") DataSource dataSource) { |
|||
this.nulmJdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
/////////////////////////// Order Repository /////////////////////////////// |
|||
public void saveOrderDetails(Map<String, Object> orderData) { |
|||
String sql = "INSERT INTO order_details (order_number, order_date, no_of_staffs, order_description, order_copy_url, order_generated_by, created_date, validity_date, order_status, isactive, isdelete) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?, " + |
|||
"CASE WHEN ? >= ? THEN 'Active' ELSE 'Expired' END, 1, 0)"; |
|||
nulmJdbcTemplate.update(sql, |
|||
orderData.get("orderNumber"), |
|||
orderData.get("orderDate"), |
|||
orderData.get("noOfStaffs"), |
|||
orderData.get("orderDescription"), |
|||
orderData.get("orderCopyUrl"), |
|||
orderData.get("orderGeneratedBy"), |
|||
orderData.get("validityDate"), |
|||
orderData.get("validityDate"), |
|||
orderData.get("orderDate")); |
|||
} |
|||
|
|||
/////To get all the list of orders///////////////////////////////// |
|||
public List<Map<String, Object>> getAllOrders() { |
|||
String sql = "SELECT od.*, " + |
|||
"SUM(CASE WHEN ed.appointed = '1' THEN 1 ELSE 0 END) AS appointed_yes_count " + |
|||
"FROM order_details od " + |
|||
"LEFT JOIN enrollment_table ed ON od.order_id = ed.order_id " + |
|||
"GROUP BY od.order_id, od.order_number, od.order_date, od.order_generated_by, od.order_description, od.no_of_staffs, od.category, od.validity_date, od.order_copy_url"; |
|||
|
|||
// Fetch the list of orders with the appointed counts |
|||
List<Map<String, Object>> orderLists = nulmJdbcTemplate.queryForList(sql); |
|||
|
|||
// Add the calculated value (appointed_yes_count - no_of_staffs) to each order map |
|||
for (Map<String, Object> order : orderLists) { |
|||
int appointedYesCount = ((Number) order.get("appointed_yes_count")).intValue(); |
|||
int noOfStaffs = ((Number) order.get("no_of_staffs")).intValue(); |
|||
|
|||
// Calculate the output value |
|||
int outputValue = noOfStaffs-appointedYesCount; |
|||
|
|||
// Add the output value to the order map |
|||
order.put("output_value", outputValue); |
|||
} |
|||
|
|||
return orderLists; |
|||
} |
|||
//public List<Map<String, Object>> getAllOrders() { |
|||
// String sql = "SELECT od.*, " + |
|||
// "SUM(CASE WHEN ed.appointed = 'Yes' THEN 1 ELSE 0 END) AS appointed_yes_count, " + |
|||
// "SUM(CASE WHEN ed.appointed = 'No' THEN 1 ELSE 0 END) AS appointed_no_count " + |
|||
// "FROM order_details od " + |
|||
// "LEFT JOIN enrollment_table ed ON od.order_id = ed.order_id " + |
|||
// "GROUP BY od.order_id, od.order_number, od.order_date, od.order_generated_by, od.order_description, od.no_of_staffs, od.validity_date"; |
|||
// |
|||
// List<Map<String, Object>> orderLists = nulmJdbcTemplate.queryForList(sql); |
|||
// return orderLists; |
|||
//} |
|||
|
|||
public List<Map<String, Object>> getAllOrderDetails() { |
|||
String sql = "SELECT order_id, order_number FROM order_details"; |
|||
|
|||
// Use queryForList to fetch the data |
|||
return nulmJdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
public List<String> getAllOrderNumber() { |
|||
String sql = "SELECT order_number FROM order_details"; |
|||
|
|||
// Use query with a RowMapper to map each row to a String |
|||
return nulmJdbcTemplate.query(sql, new RowMapper<String>() { |
|||
@Override |
|||
public String mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
return rs.getString("order_number"); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
/////////////////////////// Scheme Group Repository /////////////////////////////// |
|||
public void saveSchemeGroup(Map<String, Object> groupData) { |
|||
String sql = "INSERT INTO suyaudavi_kuzhu (group_name, incharge_name, incharge_phoneno, bank_name, bank_branch, ifsc_code, bank_accountno, created_date, isactive, isdelete) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, 1, 0)"; |
|||
nulmJdbcTemplate.update(sql, |
|||
groupData.get("groupName"), |
|||
groupData.get("inchargeName"), |
|||
groupData.get("inchargePhoneNo"), |
|||
groupData.get("bankName"), |
|||
groupData.get("bankBranch"), |
|||
groupData.get("ifscCode"), |
|||
groupData.get("bankAccountno")); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAllSchemeGroupNames() { |
|||
String sql = "SELECT group_id,group_name FROM suyaudavi_kuzhu"; |
|||
|
|||
// Use query with a RowMapper to map each row to a String |
|||
return nulmJdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAllSchemeGroups() { |
|||
String sql = "SELECT k.group_name, k.incharge_name, k.incharge_phoneno, k.created_date, " + |
|||
"SUM(CASE WHEN e.appointed = '1' THEN 1 ELSE 0 END) AS appointed_count, " + |
|||
"SUM(CASE WHEN e.appointed = '0' AND e.isactive = 1 THEN 1 ELSE 0 END) AS available_count, " + |
|||
"SUM(CASE WHEN e.isactive = 1 AND e.dropout = '1' THEN 1 ELSE 0 END) AS dropout_count " + |
|||
"FROM suyaudavi_kuzhu k " + |
|||
"LEFT JOIN enrollment_table e ON k.group_id = e.group_id " + |
|||
"GROUP BY k.group_name, k.incharge_name, k.incharge_phoneno, k.created_date"; |
|||
|
|||
return nulmJdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
//public List<String> getAllSchemeGroupNames() { |
|||
// String sql = "SELECT group_name FROM suyaudavi_kuzhu"; |
|||
// |
|||
// // Use query with a RowMapper to map each row to a String |
|||
// return nulmJdbcTemplate.query(sql, new RowMapper<String>() { |
|||
// @Override |
|||
// public String mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
// return rs.getString("group_name"); |
|||
// } |
|||
// }); |
|||
//} |
|||
|
|||
|
|||
|
|||
/////////////////////////// Staff Detail Repository /////////////////////////////// |
|||
private RowMapper<Integer> groupIdRowMapper = new RowMapper<Integer>() { |
|||
@Override |
|||
public Integer mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
return rs.getInt("group_id"); |
|||
} |
|||
}; |
|||
|
|||
// Method to retrieve group_id based on scheme_group_name |
|||
public Integer getGroupIdBySchemeGroupName(String groupName) { |
|||
String sql = "SELECT group_id FROM suyaudavi_kuzhu WHERE group_name = ?"; |
|||
|
|||
// Correct use of queryForObject with RowMapper and parameter |
|||
return jdbcTemplate.queryForObject(sql, groupIdRowMapper, groupName); |
|||
} |
|||
|
|||
|
|||
public void saveStaffDetails(Map<String, Object> staffData) { |
|||
String sql = "INSERT INTO enrollment_table (name, employee_id, phone_number, gender, date_of_birth, education_qualification, address, additional_skills, aadhar_card_url, ration_card_url, bank_passbook_url, staff_photo_url, created_date, group_id, appointed, facial_attendance, isactive, isdelete) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?, 'No', 'No', 1, 0)"; |
|||
|
|||
nulmJdbcTemplate.update(sql, |
|||
staffData.get("name"), |
|||
staffData.get("employeeId"), |
|||
staffData.get("phoneNumber"), |
|||
staffData.get("gender"), |
|||
staffData.get("dateOfBirth"), |
|||
staffData.get("educationQualification"), |
|||
staffData.get("address"), // Ensure address is included |
|||
staffData.get("additionalSkills"), |
|||
staffData.get("aadharCardUrl"), |
|||
staffData.get("rationCardUrl"), |
|||
staffData.get("bankPassbookUrl"), |
|||
staffData.get("staffPhotoUrl"), |
|||
staffData.get("groupId")); |
|||
} |
|||
|
|||
|
|||
public List<String> getStaffName() { |
|||
String sql = "SELECT name FROM enrollment_table "; |
|||
|
|||
// Use query with a RowMapper to map each row to a String |
|||
return nulmJdbcTemplate.query(sql, new RowMapper<String>() { |
|||
@Override |
|||
public String mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
return rs.getString("name"); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
//////////////////Attendance Repository///////////////////////////////////////////////////////////////////////////// |
|||
|
|||
|
|||
|
|||
|
|||
////////////////Appointment Repository///////////////////////////////////////////////////////////////// |
|||
//Existing RowMappers |
|||
//private RowMapper<Integer> groupIdsRowMapper = new RowMapper<Integer>() { |
|||
// @Override |
|||
// public Integer mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
// return rs.getInt("group_id"); |
|||
// } |
|||
//}; |
|||
// |
|||
//private RowMapper<Integer> enrollmentIdRowMapper = new RowMapper<Integer>() { |
|||
// @Override |
|||
// public Integer mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
// return rs.getInt("enrollment_id"); |
|||
// } |
|||
//}; |
|||
// |
|||
//private RowMapper<Integer> orderIdRowMapper = new RowMapper<Integer>() { |
|||
// @Override |
|||
// public Integer mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
// return rs.getInt("order_id"); |
|||
// } |
|||
//}; |
|||
// |
|||
////Method to retrieve group_id based on scheme_group_name |
|||
//public Integer getGroupIdsBySchemeGroupName(String schemeGroupName) { |
|||
// String sql = "SELECT group_id FROM scheme_group WHERE scheme_group_name = ?"; |
|||
// return jdbcTemplate.queryForObject(sql, groupIdsRowMapper, schemeGroupName); |
|||
//} |
|||
// |
|||
////Method to retrieve staff_id based on staff_name |
|||
//public Integer getEnrollmentIdByStaffName(String name) { |
|||
// String sql = "SELECT enrollment_id FROM enrollment_table WHERE name = ?"; |
|||
// return jdbcTemplate.queryForObject(sql, enrollmentIdRowMapper, name); |
|||
//} |
|||
// |
|||
////Method to retrieve order_id based on both order_number and order_title |
|||
//public Integer getOrderIdByOrderNumberAndTitle(int orderNumber, String orderTitle) { |
|||
// String sql = "SELECT order_id FROM order_details WHERE order_number = ? AND order_title = ?"; |
|||
// return jdbcTemplate.queryForObject(sql, orderIdRowMapper, orderNumber, orderTitle); |
|||
//} |
|||
// |
|||
////Method to save appointment |
|||
//public void saveAppointment(Map<String, Object> appointmentData) { |
|||
// String schemeGroupName = (String) appointmentData.get("schemeGroupName"); |
|||
// Integer groupId = getGroupIdsBySchemeGroupName(schemeGroupName); |
|||
// |
|||
// String name = (String) appointmentData.get("name"); |
|||
// Integer staffId = getEnrollmentIdByStaffName(name); |
|||
// |
|||
// int orderNumber = (int) appointmentData.get("orderNumber"); |
|||
// String orderTitle = (String) appointmentData.get("orderTitle"); |
|||
// Integer orderId = getOrderIdByOrderNumberAndTitle(orderNumber, orderTitle); |
|||
// |
|||
// String sql = "INSERT INTO appointment (zone, ward, supervisor_name, department, date_of_appointment, created_at, group_id, staff_id, order_id, is_active, is_delete) " + |
|||
// "VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?, ?, 1, 0)"; |
|||
// nulmJdbcTemplate.update(sql, |
|||
// appointmentData.get("zone"), |
|||
// appointmentData.get("ward"), |
|||
// appointmentData.get("supervisorName"), |
|||
// appointmentData.get("department"), |
|||
// appointmentData.get("dateOfAppointment"), |
|||
// groupId, |
|||
// staffId, |
|||
// orderId); |
|||
//} |
|||
|
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.nulm.repository; |
|||
1771
src/main/java/in/gov/chennaicorporation/gccoffice/nulm/service/NulmService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.nulm.service; |
|||
@ -0,0 +1,79 @@ |
|||
package in.gov.chennaicorporation.gccoffice.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
|
|||
@Service |
|||
public class GetMappingUserDetails { |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlAppDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getMappingList(String loginId) { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM `login_mapping_user` WHERE appuser_id=? LIMIT 1"; |
|||
//System.out.println(sqlQuery+loginId); |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery,loginId); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public String getOfficerMaster(String loginId) { |
|||
try { |
|||
String sqlQuery = "SELECT `officer_master_id` FROM `login_mapping_user` WHERE appuser_id = ? LIMIT 1"; |
|||
List<Map<String, Object>> results = jdbcTemplate.queryForList(sqlQuery, loginId); |
|||
|
|||
if (results.isEmpty()) { |
|||
return null; // No record found |
|||
} else { |
|||
// Assuming there is only one result because of LIMIT 1 |
|||
Map<String, Object> row = results.get(0); |
|||
Object officerMasterId = row.get("officer_master_id"); |
|||
|
|||
return officerMasterId != null ? officerMasterId.toString() : null; |
|||
} |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public String getERPUserId(String loginId) { |
|||
try { |
|||
String sqlQuery = "SELECT `erpuser_id` FROM `login_mapping_user` WHERE appuser_id = ? LIMIT 1"; |
|||
List<Map<String, Object>> results = jdbcTemplate.queryForList(sqlQuery, loginId); |
|||
|
|||
if (results.isEmpty()) { |
|||
return null; // No record found |
|||
} else { |
|||
// Assuming there is only one result because of LIMIT 1 |
|||
Map<String, Object> row = results.get(0); |
|||
Object erpUserId = row.get("erpuser_id"); |
|||
|
|||
return erpUserId != null ? erpUserId.toString() : null; |
|||
} |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Handle error appropriately |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
package in.gov.chennaicorporation.gccoffice.sos.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.sos.service.SOSService; |
|||
|
|||
@RequestMapping("gcc/api/sos") |
|||
@RestController("sosRest") |
|||
public class APIController { |
|||
private SOSService sosService; |
|||
|
|||
@Autowired |
|||
public APIController(SOSService sosService) { |
|||
this.sosService = sosService; |
|||
} |
|||
|
|||
@GetMapping(value="/getZoneAndWard") |
|||
public List getZoneAndWard() { |
|||
return sosService.getZoneAndWard(); |
|||
} |
|||
|
|||
@GetMapping(value="/getRescueList") |
|||
public List getRescueList(@RequestParam(value = "", required = false) String status) { |
|||
return sosService.getRescueList(status); |
|||
} |
|||
|
|||
@GetMapping(value="/getRescueUpdateData") |
|||
public List getRequestDataById(@RequestParam(value = "", required = false) String rescueid) { |
|||
return sosService.getRequestDataById(rescueid); |
|||
} |
|||
|
|||
@PostMapping(value="/saveRequest") |
|||
public List<?> saveRequest( |
|||
@RequestParam(value="contact_name", required = false) String contact_name, |
|||
@RequestParam(value="contact_number", required = false) String contact_number, |
|||
@RequestParam(value="latitude", required = false) String latitude, |
|||
@RequestParam(value="longitude", required = false) String longitude, |
|||
@RequestParam(value="zone", required = false) String zone, |
|||
@RequestParam(value="ward", required = false) String ward, |
|||
@RequestParam(value="streetid", required = false) String streetid, |
|||
@RequestParam(value="streetname", required = false) String streetname, |
|||
@RequestParam(value="location_details", required = false) String location_details, |
|||
@RequestParam(value="request_type", required = false) String request_type, |
|||
@RequestParam(value="no_of_count", required = false) String no_of_count, |
|||
@RequestParam(value="if_any", required = false) String if_any, |
|||
@RequestParam(value="land_mark", required = false) String land_mark, |
|||
@RequestParam(value="remarks", required = false) String remarks, |
|||
@RequestParam(value="loginId", required = false) String loginId, |
|||
@RequestParam(value="mode", required = false) String mode |
|||
){ |
|||
return sosService.saveRequest(contact_name, contact_number, |
|||
latitude, longitude, zone, ward, streetid, streetname, |
|||
location_details, request_type, no_of_count, if_any, |
|||
land_mark, remarks, loginId,mode); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package in.gov.chennaicorporation.gccoffice.sos.controller; |
|||
|
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/sos") |
|||
@Controller("SOSRestController") |
|||
public class SOSController { |
|||
|
|||
private String BasePath = "modules/sos/"; |
|||
|
|||
@GetMapping({"", "/", "/index"}) |
|||
public String dashboard(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"inbox"; |
|||
} |
|||
|
|||
@GetMapping({"/new"}) |
|||
public String sosNew(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"new_sos"; |
|||
} |
|||
|
|||
@GetMapping({"/pending"}) |
|||
public String sosPending(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"pending_inbox"; |
|||
} |
|||
|
|||
@GetMapping({"/closed"}) |
|||
public String sosClosed(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"closed_inbox"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.sos.controller; |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue