119 changed files with 20936 additions and 6798 deletions
-
BIN.DS_Store
-
2pom.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
-
7src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/CampaignReportService.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/.DS_Store
-
3src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/ComplaintController.java
-
8src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/FollowUpController.java
-
6src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/InprogresscallController.java
-
7src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/PublicFollowUpController.java
-
4src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAPIController.java
-
160src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAdminSettingsController.java
-
13src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcCallsController.java
-
12src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcPgrComplaintsMainController.java
-
11src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/SocialMediaApiController.java
-
346src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/SocialMediaController.java
-
30src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/ComplaintService.java
-
54src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/FollowUpService.java
-
517src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAgentAssignService.java
-
19src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcService.java
-
4src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/StatusCountService.java
-
3src/main/java/in/gov/chennaicorporation/gccoffice/configuration/AppConfig.java
-
21src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java
-
5src/main/java/in/gov/chennaicorporation/gccoffice/m_petition/service/Petition.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/nulm/.DS_Store
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/pensioner/.DS_Store
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/pensioner/controller/.DS_Store
-
390src/main/java/in/gov/chennaicorporation/gccoffice/pensioner/controller/DashboardApiController.java
-
43src/main/java/in/gov/chennaicorporation/gccoffice/pensioner/service/DepartmentReceivedService.java
-
2src/main/java/in/gov/chennaicorporation/gccoffice/pensioner/service/ReturnFromAuditService.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/school/.DS_Store
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/school/Controller/.DS_Store
-
1077src/main/java/in/gov/chennaicorporation/gccoffice/school/Controller/BuildingAssetController.java
-
919src/main/java/in/gov/chennaicorporation/gccoffice/school/Controller/DropdownsController.java
-
99src/main/java/in/gov/chennaicorporation/gccoffice/school/Controller/MainController.java
-
474src/main/java/in/gov/chennaicorporation/gccoffice/school/Controller/SchoolPropertyController.java
-
20src/main/java/in/gov/chennaicorporation/gccoffice/school/Controller/SchoolReportController.java
-
127src/main/java/in/gov/chennaicorporation/gccoffice/school/Controller/StudentInfoController.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/school/Service/.DS_Store
-
260src/main/java/in/gov/chennaicorporation/gccoffice/school/Service/BuildingAssetService.java
-
6src/main/java/in/gov/chennaicorporation/gccoffice/school/Service/DropdownsService.java
-
784src/main/java/in/gov/chennaicorporation/gccoffice/school/Service/SchoolPropertyService.java
-
302src/main/java/in/gov/chennaicorporation/gccoffice/school/Service/SchoolReportService.java
-
857src/main/java/in/gov/chennaicorporation/gccoffice/school/Service/StudentInfoService.java
-
480src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/ApiController.java
-
126src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/CreateEventAPIController.java
-
147src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/MainController.java
-
37src/main/java/in/gov/chennaicorporation/gccoffice/vendor/service/DateTimeUtil.java
-
484src/main/java/in/gov/chennaicorporation/gccoffice/vendor/service/StreetVendorService.java
-
167src/main/java/in/gov/chennaicorporation/gccoffice/vendor/service/createventService.java
-
46src/main/java/in/gov/chennaicorporation/gccoffice/vtrack/service/VehicleService.java
-
9src/main/java/in/gov/chennaicorporation/gccoffice/works/service/ERPEstimateService.java
-
8src/main/java/in/gov/chennaicorporation/gccoffice/works/service/EstimateService.java
-
BINsrc/main/resources/.DS_Store
-
6src/main/resources/application.properties
-
BINsrc/main/resources/static/.DS_Store
-
BINsrc/main/resources/static/assets/node_modules/.DS_Store
-
BINsrc/main/resources/static/assets/node_modules/ammap3/.DS_Store
-
BINsrc/main/resources/static/assets/node_modules/ammap3/ammap/.DS_Store
-
BINsrc/main/resources/templates/.DS_Store
-
BINsrc/main/resources/templates/fragments/.DS_Store
-
BINsrc/main/resources/templates/fragments/modules/.DS_Store
-
1src/main/resources/templates/fragments/modules/com_petition/petition_view_script.html
-
BINsrc/main/resources/templates/modules/.DS_Store
-
692src/main/resources/templates/modules/callcenter/assignagents.html
-
73src/main/resources/templates/modules/callcenter/campaignreport.html
-
BINsrc/main/resources/templates/modules/callcenterqaqc/.DS_Store
-
156src/main/resources/templates/modules/callcenterqaqc/agentqaqccalls.html
-
148src/main/resources/templates/modules/callcenterqaqc/agentqaqcfollowupcalls.html
-
149src/main/resources/templates/modules/callcenterqaqc/agentqaqcinprogresscalls.html
-
151src/main/resources/templates/modules/callcenterqaqc/agentqaqcpublicfollowupcalls.html
-
499src/main/resources/templates/modules/callcenterqaqc/pgrcomplaints.html
-
29src/main/resources/templates/modules/callcenterqaqc/qaqcadminsettings.html
-
70src/main/resources/templates/modules/callcenterqaqc/qaqcgrievancedashboard.html
-
59src/main/resources/templates/modules/callcenterqaqc/socialmediacomplaints.html
-
298src/main/resources/templates/modules/cdwaste/approval.html
-
171src/main/resources/templates/modules/cdwaste/pending.html
-
307src/main/resources/templates/modules/cdwaste/rejected.html
-
4src/main/resources/templates/modules/com_petition/petition_list.html
-
8src/main/resources/templates/modules/com_petition/petition_view_modal_page.html
-
6src/main/resources/templates/modules/m_petition/petition_list.html
-
BINsrc/main/resources/templates/modules/pensioner/.DS_Store
-
BINsrc/main/resources/templates/modules/pensioner/department/.DS_Store
-
1954src/main/resources/templates/modules/pensioner/department/dashboard.html
-
BINsrc/main/resources/templates/modules/pensioner/department/newentry/.DS_Store
-
80src/main/resources/templates/modules/pensioner/department/newentry/gis.html
-
2src/main/resources/templates/modules/pensioner/department/received/provisionalretirement.html
-
BINsrc/main/resources/templates/modules/pensioner/pensioner/.DS_Store
-
1932src/main/resources/templates/modules/pensioner/pensioner/dashboard.html
-
BINsrc/main/resources/templates/modules/school/.DS_Store
-
42src/main/resources/templates/modules/school/addelectricalasset.html
-
30src/main/resources/templates/modules/school/addfurnitureasset.html
-
168src/main/resources/templates/modules/school/assetmanagement.html
-
68src/main/resources/templates/modules/school/building.html
-
1src/main/resources/templates/modules/school/dashboard.html
@ -1,160 +0,0 @@ |
|||
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); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,25 +1,37 @@ |
|||
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.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.callcenterqaqc.service.QaqcAgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/callcenterqaqccomplaintsregistration") |
|||
@Controller("callCenterQaQcComplaintsRegistrationController") |
|||
public class QaqcPgrComplaintsMainController { |
|||
|
|||
@Autowired |
|||
private QaqcAgentsService agentsService; |
|||
|
|||
@GetMapping("/pgrcomplaint") |
|||
public String viewPGRpage(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()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
return "modules/callcenterqaqc/pgrcomplaints"; |
|||
} |
|||
|
|||
|
|||
@ -1,346 +0,0 @@ |
|||
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; |
|||
} |
|||
|
|||
} |
|||
@ -1,241 +1,149 @@ |
|||
package in.gov.chennaicorporation.gccoffice.pensioner.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
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.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.pensioner.service.DashboardApiService; |
|||
@RestController |
|||
public class DashboardApiController { |
|||
@Autowired |
|||
private DashboardApiService dashboardApiService; |
|||
|
|||
@GetMapping("/dashboard") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getDashboardData() { |
|||
|
|||
return dashboardApiService.fetchCategoryCounts(); |
|||
} |
|||
/*@GetMapping("/dashboardsearch") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> fetchDashboardData( |
|||
@RequestParam(required = false) String startdate, |
|||
@RequestParam(required = false) String enddate) { |
|||
System.out.println("Endpoint hit with startdate: " + startdate + ", enddate: " + enddate); |
|||
try { |
|||
return dashboardApiService.fetchCategorysearchCounts(startdate, enddate); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Print fetchCategoryCounts stack trace to the logs |
|||
throw e; // Rethrow the exception to propagate the 500 error |
|||
} |
|||
} |
|||
@GetMapping("/categoryCounts") |
|||
public List<Map<String, Object>> getCategoryCounts() { |
|||
return dashboardApiService.fetchCategoryCounts(); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getEmpNoByFileName") |
|||
public List<Map<String, Object>> getEmployeeDetails(@RequestParam("file_id") String FileId) { |
|||
System.out.println("before fetch"); |
|||
return dashboardApiService.getEmployeeDetails(FileId); |
|||
} |
|||
@GetMapping("/stageWiseCounts") |
|||
public ResponseEntity<List<Map<String, Object>>> getStageWiseCounts() { |
|||
List<Map<String, Object>> stageWiseCounts = dashboardApiService.getStageWiseCounts(); |
|||
return ResponseEntity.ok(stageWiseCounts); |
|||
}*/ |
|||
|
|||
@GetMapping("/getDepartments") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getDepartment() { |
|||
return dashboardApiService.getDepartment(); |
|||
} |
|||
@GetMapping("/getEmpNoByFileName") |
|||
public List<Map<String, Object>> getEmployeeDetails(@RequestParam("file_id") String FileId) { |
|||
System.out.println("before fetch"); |
|||
return dashboardApiService.getEmployeeDetails(FileId); |
|||
} |
|||
|
|||
|
|||
//department |
|||
|
|||
@GetMapping("/deparmentdashboard") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getDepartmentDashboardData(@RequestParam(required = false) String deptId) { |
|||
System.out.println("deptid"+ deptId); |
|||
return dashboardApiService.DepartmenfetchCategoryCounts(deptId); |
|||
} |
|||
|
|||
|
|||
/* @GetMapping("/deparmentcategoryCounts") |
|||
public List<Map<String, Object>> getDepartmenCategoryCounts(@RequestParam(required = false) String deptId) { |
|||
return dashboardApiService.DepartmenfetchCategoryCounts(deptId); |
|||
} |
|||
//DepartmentstageWiseCounts |
|||
|
|||
@GetMapping("/DepartmentstageWiseCounts") |
|||
public ResponseEntity<List<Map<String, Object>>> getDepartmentStageWiseCounts(@RequestParam(required = false) String deptId) { |
|||
List<Map<String, Object>> stageWiseCounts = dashboardApiService.getDepartmentStageWiseCounts(deptId); |
|||
return ResponseEntity.ok(stageWiseCounts); |
|||
}*/ |
|||
|
|||
|
|||
@GetMapping("/stageWiseCounts") |
|||
public ResponseEntity<List<Map<String, Object>>> getDepartmentStageWiseCounts( |
|||
@RequestParam(required = false) String deptId, |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
if(startDate.isEmpty()) |
|||
{ |
|||
startDate=null; |
|||
} |
|||
if(endDate.isEmpty()) |
|||
{ |
|||
endDate=null; |
|||
} |
|||
List<Map<String, Object>> stageWiseCounts = dashboardApiService.getStageWiseCounts(deptId, startDate, endDate); |
|||
return ResponseEntity.ok(stageWiseCounts); |
|||
} |
|||
@GetMapping("/categoryCounts") |
|||
public List<Map<String, Object>> getDepartmenCategoryCounts( |
|||
@RequestParam(required = false) String deptId, |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
if(startDate.isEmpty()) |
|||
{ |
|||
startDate=null; |
|||
} |
|||
if(endDate.isEmpty()) |
|||
{ |
|||
endDate=null; |
|||
} |
|||
|
|||
return dashboardApiService.fetchchartCategoryCounts(deptId, startDate, endDate); |
|||
} |
|||
|
|||
@GetMapping("/dashboardsearch") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> fetchDeparmentDashboardData( |
|||
@RequestParam(required = false) String startdate, |
|||
@RequestParam(required = false) String enddate,@RequestParam(required = false) String deptId) { |
|||
if(deptId.isEmpty()) |
|||
{ |
|||
deptId=null; |
|||
} |
|||
|
|||
System.out.println("Endpoint hit with startdate: " + startdate + ", enddate: " + enddate); |
|||
try { |
|||
return dashboardApiService.fetchCategorysearchCounts(startdate, enddate,deptId); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Print fetchCategoryCounts stack trace to the logs |
|||
throw e; // Rethrow the exception to propagate the 500 error |
|||
} |
|||
} |
|||
|
|||
//pension |
|||
|
|||
@GetMapping("/pensiondashboard") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getPensionDashboardData(@RequestParam(required = false) String deptId) { |
|||
System.out.println("deptid"+ deptId); |
|||
return dashboardApiService.DepartmenfetchCategoryCounts(deptId); |
|||
} |
|||
/* @GetMapping("/pensiondashboardsearch") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> fetchpensionDashboardData( |
|||
@RequestParam(required = false) String startdate, |
|||
@RequestParam(required = false) String enddate,@RequestParam(required = false) String deptId) { |
|||
|
|||
if(deptId.isEmpty()) |
|||
{ |
|||
deptId=null; |
|||
} |
|||
|
|||
|
|||
System.out.println("Endpoint hit with startdate: " + startdate + ", enddate: " + enddate); |
|||
try { |
|||
return dashboardApiService.fetchDeparmentCategorysearchCounts(startdate, enddate,deptId); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Print fetchCategoryCounts stack trace to the logs |
|||
throw e; // Rethrow the exception to propagate the 500 error |
|||
} |
|||
}*/ |
|||
|
|||
|
|||
/* @GetMapping("/pensioncategoryCounts") |
|||
public List<Map<String, Object>> getpensionCategoryCounts( |
|||
@RequestParam(required = false) String deptId, |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
if(startDate.isEmpty()) |
|||
{ |
|||
startDate=null; |
|||
} |
|||
if(endDate.isEmpty()) |
|||
{ |
|||
endDate=null; |
|||
} |
|||
|
|||
return dashboardApiService.DepartmenfetchDepartmentCategoryCounts(deptId, startDate, endDate); |
|||
}*/ |
|||
|
|||
|
|||
/* @GetMapping("/pensionstageWiseCounts") |
|||
public ResponseEntity<List<Map<String, Object>>> getpensionStageWiseCounts( |
|||
@RequestParam(required = false) String deptId, |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
if(startDate.isEmpty()) |
|||
{ |
|||
startDate=null; |
|||
} |
|||
if(endDate.isEmpty()) |
|||
{ |
|||
endDate=null; |
|||
} |
|||
List<Map<String, Object>> stageWiseCounts = dashboardApiService.getDepartmentStageWiseCounts(deptId, startDate, endDate); |
|||
return ResponseEntity.ok(stageWiseCounts); |
|||
}*/ |
|||
|
|||
@GetMapping("/fetchEmpDetails") |
|||
public List<Map<String, Object>> getEmpDetails(@RequestParam(required = false) String Empcode) { |
|||
System.out.println("checking"); |
|||
System.out.println(Empcode); |
|||
|
|||
return dashboardApiService.getEmpDetails(Empcode); |
|||
} |
|||
|
|||
@GetMapping("/fetchPensionEmpDetails") |
|||
public List<Map<String, Object>> getPensionEmpDetails(@RequestParam(required = false) String Empcode) { |
|||
System.out.println("checking"); |
|||
System.out.println(Empcode); |
|||
|
|||
return dashboardApiService.getPensionEmpDetails(Empcode); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/fetchTempDetails") |
|||
public List<Map<String, Object>> getTempEmpDetails(@RequestParam(required = false) String tempId) { |
|||
System.out.println("checking"); |
|||
System.out.println(tempId); |
|||
|
|||
return dashboardApiService.getTempEmpDetails(tempId); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
package in.gov.chennaicorporation.gccoffice.pensioner.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.pensioner.service.DashboardApiService; |
|||
|
|||
@RequestMapping("/gcc/api/pensionerdashboard") |
|||
@RestController |
|||
public class DashboardApiController { |
|||
@Autowired |
|||
private DashboardApiService dashboardApiService; |
|||
|
|||
@GetMapping("/dashboard") |
|||
//@ResponseBody |
|||
public List<Map<String, Object>> getDashboardData() { |
|||
|
|||
return dashboardApiService.fetchCategoryCounts(); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getDepartments") |
|||
//@ResponseBody |
|||
public List<Map<String, Object>> getDepartment() { |
|||
return dashboardApiService.getDepartment(); |
|||
} |
|||
|
|||
@GetMapping("/getEmpNoByFileName") |
|||
public List<Map<String, Object>> getEmployeeDetails(@RequestParam("file_id") String FileId) { |
|||
//System.out.println("before fetch"); |
|||
return dashboardApiService.getEmployeeDetails(FileId); |
|||
} |
|||
|
|||
|
|||
//department |
|||
|
|||
@GetMapping("/departmentdashboard") |
|||
//@ResponseBody |
|||
public List<Map<String, Object>> getDepartmentDashboardData(@RequestParam(required = false) String deptId) { |
|||
//System.out.println("deptid"+ deptId); |
|||
return dashboardApiService.DepartmenfetchCategoryCounts(deptId); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/stageWiseCounts") |
|||
public ResponseEntity<List<Map<String, Object>>> getDepartmentStageWiseCounts( |
|||
@RequestParam(required = false) String deptId, |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
if(startDate.isEmpty()) |
|||
{ |
|||
startDate=null; |
|||
} |
|||
if(endDate.isEmpty()) |
|||
{ |
|||
endDate=null; |
|||
} |
|||
List<Map<String, Object>> stageWiseCounts = dashboardApiService.getStageWiseCounts(deptId, startDate, endDate); |
|||
|
|||
return ResponseEntity.ok(stageWiseCounts); |
|||
} |
|||
|
|||
@GetMapping("/categoryCounts") |
|||
public List<Map<String, Object>> getDepartmenCategoryCounts( |
|||
@RequestParam(required = false) String deptId, |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
if(startDate.isEmpty()) |
|||
{ |
|||
startDate=null; |
|||
} |
|||
if(endDate.isEmpty()) |
|||
{ |
|||
endDate=null; |
|||
} |
|||
|
|||
return dashboardApiService.fetchchartCategoryCounts(deptId, startDate, endDate); |
|||
} |
|||
|
|||
@GetMapping("/dashboardsearch") |
|||
//@ResponseBody |
|||
public List<Map<String, Object>> fetchDeparmentDashboardData( |
|||
@RequestParam(required = false) String startdate, |
|||
@RequestParam(required = false) String enddate,@RequestParam(required = false) String deptId) { |
|||
if(deptId.isEmpty()) |
|||
{ |
|||
deptId=null; |
|||
} |
|||
|
|||
//System.out.println("Endpoint hit with startdate: " + startdate + ", enddate: " + enddate); |
|||
try { |
|||
return dashboardApiService.fetchCategorysearchCounts(startdate, enddate,deptId); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Print fetchCategoryCounts stack trace to the logs |
|||
throw e; // Rethrow the exception to propagate the 500 error |
|||
} |
|||
} |
|||
|
|||
//pension |
|||
|
|||
@GetMapping("/pensiondashboard") |
|||
//@ResponseBody |
|||
public List<Map<String, Object>> getPensionDashboardData(@RequestParam(required = false) String deptId) { |
|||
//System.out.println("deptid"+ deptId); |
|||
return dashboardApiService.DepartmenfetchCategoryCounts(deptId); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/fetchEmpDetails") |
|||
public List<Map<String, Object>> getEmpDetails(@RequestParam(required = false) String Empcode) { |
|||
//System.out.println("checking"); |
|||
//System.out.println(Empcode); |
|||
|
|||
return dashboardApiService.getEmpDetails(Empcode); |
|||
} |
|||
|
|||
@GetMapping("/fetchPensionEmpDetails") |
|||
public List<Map<String, Object>> getPensionEmpDetails(@RequestParam(required = false) String Empcode) { |
|||
//System.out.println("checking"); |
|||
//System.out.println(Empcode); |
|||
|
|||
return dashboardApiService.getPensionEmpDetails(Empcode); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/fetchTempDetails") |
|||
public List<Map<String, Object>> getTempEmpDetails(@RequestParam(required = false) String tempId) { |
|||
// System.out.println("checking"); |
|||
// System.out.println(tempId); |
|||
|
|||
return dashboardApiService.getTempEmpDetails(tempId); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
1077
src/main/java/in/gov/chennaicorporation/gccoffice/school/Controller/BuildingAssetController.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,127 @@ |
|||
package in.gov.chennaicorporation.gccoffice.school.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.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.school.Service.StudentInfoService; |
|||
|
|||
@RestController |
|||
@RequestMapping("/gcc/api/gccschool/studentInfo") |
|||
public class StudentInfoController { |
|||
@Autowired |
|||
private StudentInfoService studentInfoService; |
|||
|
|||
@Autowired |
|||
public StudentInfoController(StudentInfoService studentInfoService) { |
|||
this.studentInfoService = studentInfoService; |
|||
} |
|||
|
|||
@GetMapping("/getStandards") |
|||
public ResponseEntity<?> getStandards(@RequestParam String udise){ |
|||
return studentInfoService.getStandards(udise); |
|||
} |
|||
|
|||
@GetMapping("/getSections") |
|||
public ResponseEntity<?> getSections(){ |
|||
return studentInfoService.getSections(); |
|||
} |
|||
|
|||
@PostMapping("/saveStudent") |
|||
public ResponseEntity<?> saveStudent(@RequestParam String udise, |
|||
@RequestParam String student_name, |
|||
@RequestParam String emis_no, |
|||
@RequestParam String gender, |
|||
@RequestParam String std, |
|||
@RequestParam String dob, |
|||
@RequestParam String age, |
|||
@RequestParam String parent_type, |
|||
@RequestParam String section, |
|||
@RequestParam String medium, |
|||
@RequestParam(value = "father_name", required = false) String father_name, |
|||
@RequestParam(value = "mother_name", required = false) String mother_name, |
|||
@RequestParam(value = "guardian_name", required = false) String guardian_name, |
|||
@RequestParam(value = "father_mobile", required = false) String father_mobile, |
|||
@RequestParam(value = "mother_mobile", required = false) String mother_mobile, |
|||
@RequestParam(value = "guardian_mobile", required = false) String guardian_mobile, |
|||
@RequestParam(value = "father_aadhar", required = false) String father_aadhar, |
|||
@RequestParam(value = "mother_aadhar", required = false) String mother_aadhar, |
|||
@RequestParam(value = "guardian_aadhar", required = false) String guardian_aadhar, |
|||
@RequestParam(value = "student_aadhar", required = false) String student_aadhar, |
|||
@RequestParam(value = "father_aadhar_file", required = false) MultipartFile father_aadhar_file, |
|||
@RequestParam(value = "mother_aadhar_file", required = false) MultipartFile mother_aadhar_file, |
|||
@RequestParam(value = "guardian_aadhar_file", required = false) MultipartFile guardian_aadhar_file, |
|||
@RequestParam(value = "student_aadhar_file", required = false) MultipartFile student_aadhar_file) { |
|||
//return studentInfoService.saveStudent(udise, student_name, emis_no, gender, std, dob, age, parent_type, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, father_aadhar_file, mother_aadhar_file, guardian_aadhar_file, student_aadhar_file); |
|||
return studentInfoService.checkStudent(udise, student_name, emis_no, gender, std, dob, age, parent_type,section,medium, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, father_aadhar_file, mother_aadhar_file, guardian_aadhar_file, student_aadhar_file); |
|||
} |
|||
|
|||
@GetMapping("/getStudentsClass") |
|||
public ResponseEntity<?> getStudentsClass(@RequestParam String std, |
|||
@RequestParam String udise){ |
|||
return studentInfoService.getStudentsClass(udise, std); |
|||
} |
|||
|
|||
@GetMapping("/getStudentsDetails") |
|||
public ResponseEntity<?> getStudentsDetails(@RequestParam String studentId){ |
|||
return studentInfoService.getStudentsDetails(studentId); |
|||
} |
|||
|
|||
@GetMapping("/getMedium") |
|||
public ResponseEntity<?> getMedium(){ |
|||
return studentInfoService.getMedium(); |
|||
} |
|||
|
|||
@PostMapping("/deleteStudent") |
|||
public ResponseEntity<?> deleteStudent(@RequestParam String student_id, |
|||
@RequestParam String user_id, |
|||
@RequestParam String action_type) { |
|||
return studentInfoService.deleteProcess(student_id, user_id, action_type); |
|||
} |
|||
|
|||
@PostMapping("/updateStudent") |
|||
public ResponseEntity<?> updateStudent(@RequestParam String student_id, |
|||
@RequestParam String user_id, |
|||
@RequestParam String action_type, |
|||
@RequestParam String udise, |
|||
@RequestParam String student_name, |
|||
@RequestParam String emis_no, |
|||
@RequestParam String gender, |
|||
@RequestParam String mediums, |
|||
@RequestParam String std, |
|||
@RequestParam String section, |
|||
@RequestParam String dob, |
|||
@RequestParam String age, |
|||
@RequestParam String parent_type, |
|||
@RequestParam(value = "father_name", required = false) String father_name, |
|||
@RequestParam(value = "mother_name", required = false) String mother_name, |
|||
@RequestParam(value = "guardian_name", required = false) String guardian_name, |
|||
@RequestParam(value = "father_mobile", required = false) String father_mobile, |
|||
@RequestParam(value = "mother_mobile", required = false) String mother_mobile, |
|||
@RequestParam(value = "guardian_mobile", required = false) String guardian_mobile, |
|||
@RequestParam(value = "father_aadhar", required = false) String father_aadhar, |
|||
@RequestParam(value = "mother_aadhar", required = false) String mother_aadhar, |
|||
@RequestParam(value = "guardian_aadhar", required = false) String guardian_aadhar, |
|||
@RequestParam(value = "student_aadhar", required = false) String student_aadhar, |
|||
@RequestParam(value = "father_aadhar_file", required = false) MultipartFile father_aadhar_file, |
|||
@RequestParam(value = "mother_aadhar_file", required = false) MultipartFile mother_aadhar_file, |
|||
@RequestParam(value = "guardian_aadhar_file", required = false) MultipartFile guardian_aadhar_file, |
|||
@RequestParam(value = "student_aadhar_file", required = false) MultipartFile student_aadhar_file, |
|||
@RequestParam (value = "raw_father_aadhar", required = false) String raw_father_aadhar, |
|||
@RequestParam (value = "raw_mother_aadhar", required = false) String raw_mother_aadhar, |
|||
@RequestParam (value = "raw_guardian_aadhar", required = false) String raw_guardian_aadhar, |
|||
@RequestParam (value = "raw_student_aadhar", required = false) String raw_student_aadhar) { |
|||
return studentInfoService.updateProcess(student_id, user_id, action_type, udise, student_name, emis_no, gender, mediums, std, section, dob, age, parent_type, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, father_aadhar_file, mother_aadhar_file, guardian_aadhar_file, student_aadhar_file, raw_father_aadhar, raw_mother_aadhar, raw_guardian_aadhar, raw_student_aadhar); |
|||
} |
|||
|
|||
@GetMapping("/checkStudent") |
|||
public ResponseEntity<?> checkStudent(@RequestParam String udise, @RequestParam String schoolId){ |
|||
return studentInfoService.checkStudent(udise, schoolId); |
|||
} |
|||
|
|||
} |
|||
784
src/main/java/in/gov/chennaicorporation/gccoffice/school/Service/SchoolPropertyService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,857 @@ |
|||
package in.gov.chennaicorporation.gccoffice.school.Service; |
|||
|
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
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.core.env.Environment; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
@Service |
|||
public class StudentInfoService { |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
private String fileBaseUrl; |
|||
|
|||
@Autowired |
|||
public void setDataSourcemysql(@Qualifier("mysqlSchoolDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
this.fileBaseUrl=environment.getProperty("fileBaseUrl"); |
|||
} |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
@Transactional |
|||
public ResponseEntity<?> getStandards(String udise) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
String standard = getStandardsCount(udise); |
|||
List<String> standards = Arrays.asList(standard.split(",")); |
|||
List<Map<String, Object>> updateSTD = new ArrayList<>(); |
|||
for (String std:standards) { |
|||
Map<String, Object> data = new HashMap<>(); |
|||
String clas = std; |
|||
String count = getStudentCount(udise, clas); |
|||
data.put("Designation", clas); |
|||
data.put("Student_Count", count); |
|||
updateSTD.add(data); |
|||
} |
|||
if(!updateSTD.isEmpty()) { |
|||
result.put("Message", "Success"); |
|||
result.put("Data", updateSTD); |
|||
return ResponseEntity.ok(result); |
|||
} else { |
|||
result.put("Message", "Error"); |
|||
result.put("Error", "Failed to fetch class List"); |
|||
return ResponseEntity.ok(result); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public ResponseEntity<?> getSections() { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
String sql = "SELECT id,section FROM class_sections_master WHERE is_active=1 AND is_delete=0 ORDER BY id"; |
|||
try { |
|||
List<Map<String, Object>> data = jdbcTemplate.queryForList(sql); |
|||
result.put("Message", "Success"); |
|||
result.put("Data", data); |
|||
return ResponseEntity.ok(result); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
result.put("Message", "Error"); |
|||
result.put("Error", "Failed to fetch medium List: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
private String getStudentCount(String udise, String clas) { |
|||
String sql = "SELECT count(student_id) FROM student_info where udise = ? AND std = ? AND is_active = 1 AND is_delete = 0 "; |
|||
try { |
|||
String data = jdbcTemplate.queryForObject(sql, new Object[]{udise, clas}, String.class); |
|||
return data; |
|||
}catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ""; |
|||
} |
|||
} |
|||
@Transactional |
|||
public String getStandardsCount(String udise) { |
|||
|
|||
String sql = "SELECT CONCAT_WS(',', " |
|||
+ " IF(prekg = 1, 'PreKg', NULL), " |
|||
+ " IF(lkg = 1, 'LKG', NULL), " |
|||
+ " IF(ukg = 1, 'UKG', NULL), " |
|||
+ " IF(class1 = 1, 'Class1', NULL), " |
|||
+ " IF(class2 = 1, 'Class2', NULL), " |
|||
+ " IF(class3 = 1, 'Class3', NULL), " |
|||
+ " IF(class4 = 1, 'Class4', NULL), " |
|||
+ " IF(class5 = 1, 'Class5', NULL), " |
|||
+ " IF(class6 = 1, 'Class6', NULL), " |
|||
+ " IF(class7 = 1, 'Class7', NULL), " |
|||
+ " IF(class8 = 1, 'Class8', NULL), " |
|||
+ " IF(class9 = 1, 'Class9', NULL), " |
|||
+ " IF(class10 = 1, 'Class10', NULL), " |
|||
+ " IF(class11 = 1, 'Class11', NULL), " |
|||
+ " IF(class12 = 1, 'Class12', NULL) " |
|||
+ " ) AS active_classes " |
|||
+ " FROM school_class_master " |
|||
+ " WHERE udise = ? "; |
|||
|
|||
try { |
|||
String data = jdbcTemplate.queryForObject(sql, String.class, udise); |
|||
return data; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
|
|||
//return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
|
|||
// @Transactional |
|||
// public ResponseEntity<?> getStandards(String udise) { |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// String sql = "SELECT Designation, Student_Count FROM ( " |
|||
// + "SELECT 'PreKG' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'PreKG' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (PreKg_Boys > 0 OR PreKg_Girls > 0 OR PreKg_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'LKG' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'LKG' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (LKG_Boys > 0 OR LKG_Girls > 0 OR LKG_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'UKG' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'UKG' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (UKG_Boys > 0 OR UKG_Girls > 0 OR UKG_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class1' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class1' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class1_Boys > 0 OR Class1_Girls > 0 OR Class1_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class2' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class2' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class2_Boys > 0 OR Class2_Girls > 0 OR Class2_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class3' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class3' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class3_Boys > 0 OR Class3_Girls > 0 OR Class3_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class4' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class4' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class4_Boys > 0 OR Class4_Girls > 0 OR Class4_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class5' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class5' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class5_Boys > 0 OR Class5_Girls > 0 OR Class5_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class6' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class6' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class6_Boys > 0 OR Class6_Girls > 0 OR Class6_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class7' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class7' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class7_Boys > 0 OR Class7_Girls > 0 OR Class7_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class8' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class8' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class8_Boys > 0 OR Class8_Girls > 0 OR Class8_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class9' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class9' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class9_Boys > 0 OR Class9_Girls > 0 OR Class9_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class10' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class10' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class10_Boys > 0 OR Class10_Girls > 0 OR Class10_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class11' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class11' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class11_Boys > 0 OR Class11_Girls > 0 OR Class11_Transgen > 0) AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " UNION ALL " |
|||
// + " SELECT 'Class12' AS Designation, " |
|||
// + " COUNT(si.student_id) AS Student_Count " |
|||
// + " FROM student_enrollment_master sem " |
|||
// + " LEFT JOIN student_info si " |
|||
// + " ON sem.UDISE = si.udise AND si.std = 'Class12' " |
|||
// + " WHERE sem.UDISE = ? " |
|||
// + " AND (Class12_Boys > 0 OR Class12_Girls > 0 OR Class12_Transgen > 0)AND si.is_active = 1 AND si.is_delete = 0 " |
|||
// + " ) AS result WHERE Student_Count > 0"; |
|||
// |
|||
// try { |
|||
// List<Map<String, Object>> data = jdbcTemplate.queryForList(sql, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise); |
|||
// result.put("Message", "Success"); |
|||
// result.put("Data", data); |
|||
// return ResponseEntity.ok(result); |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// result.put("Message", "Error"); |
|||
// result.put("Error", "Failed to fetch class List: " + e.getMessage()); |
|||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); |
|||
// } |
|||
// |
|||
// } |
|||
|
|||
// @Transactional |
|||
// public ResponseEntity<?> getStandards(String udise) { |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// String sql = "SELECT 'PreKG' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (PreKg_Boys > 0 OR PreKg_Girls > 0 OR PreKg_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'LKG' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (LKG_Boys > 0 OR LKG_Girls > 0 OR LKG_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'UKG' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (UKG_Boys > 0 OR UKG_Girls > 0 OR UKG_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class1' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class1_Boys > 0 OR Class1_Girls > 0 OR Class1_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class2' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class2_Boys > 0 OR Class2_Girls > 0 OR Class2_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class3' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class3_Boys > 0 OR Class3_Girls > 0 OR Class3_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class4' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class4_Boys > 0 OR Class4_Girls > 0 OR Class4_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class5' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class5_Boys > 0 OR Class5_Girls > 0 OR Class5_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class6' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class6_Boys > 0 OR Class6_Girls > 0 OR Class6_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class7' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class7_Boys > 0 OR Class7_Girls > 0 OR Class7_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class8' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class8_Boys > 0 OR Class8_Girls > 0 OR Class8_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class9' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class9_Boys > 0 OR Class9_Girls > 0 OR Class9_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class10' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class10_Boys > 0 OR Class10_Girls > 0 OR Class10_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class11' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class11_Boys > 0 OR Class11_Girls > 0 OR Class11_Transgen > 0) " |
|||
// + " UNION " |
|||
// + " SELECT 'Class12' AS Designation " |
|||
// + " FROM student_enrollment_master " |
|||
// + " WHERE UDISE = ? " |
|||
// + " AND (Class12_Boys > 0 OR Class12_Girls > 0 OR Class12_Transgen > 0)"; |
|||
// |
|||
// try { |
|||
// List<Map<String, Object>> data = jdbcTemplate.queryForList(sql, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise, udise); |
|||
// result.put("Message", "Success"); |
|||
// result.put("Data", data); |
|||
// return ResponseEntity.ok(result); |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// result.put("Message", "Error"); |
|||
// result.put("Error", "Failed to fetch class List: " + e.getMessage()); |
|||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); |
|||
// } |
|||
// |
|||
// } |
|||
@Transactional |
|||
public ResponseEntity<?> checkStudent(String udise, String student_name, String emis_no, String gender, String std, |
|||
String dob, String age, String parent_type,String section,String medium, String father_name, String mother_name, String guardian_name, |
|||
String father_mobile, String mother_mobile, String guardian_mobile, String father_aadhar, |
|||
String mother_aadhar, String guardian_aadhar, String student_aadhar, MultipartFile father_aadhar_file, |
|||
MultipartFile mother_aadhar_file, MultipartFile guardian_aadhar_file, MultipartFile student_aadhar_file) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
int is_avbl = checkEmis(emis_no); |
|||
if(is_avbl==0) { |
|||
String data = saveStudent(udise, student_name, emis_no, gender, std, dob, age, parent_type,section,medium, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, father_aadhar_file, mother_aadhar_file, guardian_aadhar_file, student_aadhar_file); |
|||
if (data.equalsIgnoreCase("sucess")) { |
|||
result.put("Message", "Saved Sucessfully"); |
|||
result.put("Data", "Success"); |
|||
} else { |
|||
result.put("Message", "Error"); |
|||
result.put("Error", "Failed to save"); |
|||
} |
|||
|
|||
} else if(is_avbl==1){ |
|||
result.put("Message", "Duplicate"); |
|||
result.put("Error", "EMIS No already registered"); |
|||
|
|||
}else { |
|||
result.put("Message", "Error"); |
|||
result.put("Error", "Failed to save"); |
|||
} |
|||
return ResponseEntity.ok(result); |
|||
|
|||
} |
|||
|
|||
private int checkEmis(String emis_no) { |
|||
String sql = "SELECT CASE WHEN EXISTS (SELECT 1 FROM student_info WHERE emis_no = ? and is_active=1 and is_delete=0) THEN 1 ELSE 0 END AS result"; |
|||
try { |
|||
return jdbcTemplate.queryForObject(sql, Integer.class, emis_no); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return 5; |
|||
} |
|||
} |
|||
@Transactional |
|||
public String saveStudent(String udise, String student_name, String emis_no, String gender, String std, |
|||
String dob, String age, String parent_type,String section,String medium, String father_name, String mother_name, String guardian_name, String father_mobile, String mother_mobile, String guardian_mobile, |
|||
String father_aadhar, String mother_aadhar, String guardian_aadhar, String student_aadhar, MultipartFile father_aadhar_file, |
|||
MultipartFile mother_aadhar_file, MultipartFile guardian_aadhar_file, MultipartFile student_aadhar_file) { |
|||
|
|||
String sql = "INSERT INTO student_info (udise, student_name, emis_no, gender, std, dob, age, parent_type,section,mediums, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, father_aadhar_file, mother_aadhar_file, guardian_aadhar_file, student_aadhar_file) VALUES (?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
try { |
|||
String fatherUrl = null; |
|||
String motherUrl = null; |
|||
String guardianUrl = null; |
|||
String studentUrl = null; |
|||
|
|||
if(student_aadhar.isEmpty()) { |
|||
student_aadhar=null; |
|||
} |
|||
|
|||
String sec=section.toUpperCase(); |
|||
|
|||
if(father_aadhar_file!=null && !father_aadhar_file.isEmpty()) { |
|||
fatherUrl = saveFile(father_aadhar_file); |
|||
} |
|||
if(mother_aadhar_file!=null && !mother_aadhar_file.isEmpty()) { |
|||
motherUrl = saveFile(mother_aadhar_file); |
|||
} |
|||
if(guardian_aadhar_file!=null && !guardian_aadhar_file.isEmpty()) { |
|||
guardianUrl = saveFile(guardian_aadhar_file); |
|||
} |
|||
if(student_aadhar_file!=null && !student_aadhar_file.isEmpty()) { |
|||
studentUrl = saveFile(student_aadhar_file); |
|||
} |
|||
|
|||
|
|||
|
|||
// System.out.println("----- Student Info -----"); |
|||
// System.out.println("UDISE: " + udise); |
|||
// System.out.println("Student Name: " + student_name); |
|||
// System.out.println("EMIS No: " + emis_no); |
|||
// System.out.println("Gender: " + gender); |
|||
// System.out.println("Class: " + std); |
|||
// System.out.println("DOB: " + dob); |
|||
// System.out.println("Age: " + age); |
|||
// System.out.println("Parent Type: " + parent_type); |
|||
// |
|||
// System.out.println("----- Parent Details -----"); |
|||
// System.out.println("Father Name: " + father_name); |
|||
// System.out.println("Mother Name: " + mother_name); |
|||
// System.out.println("Guardian Name: " + guardian_name); |
|||
// |
|||
// System.out.println("Father Mobile: " + father_mobile); |
|||
// System.out.println("Mother Mobile: " + mother_mobile); |
|||
// System.out.println("Guardian Mobile: " + guardian_mobile); |
|||
// |
|||
// System.out.println("Father Aadhar: " + father_aadhar); |
|||
// System.out.println("Mother Aadhar: " + mother_aadhar); |
|||
// System.out.println("Guardian Aadhar: " + guardian_aadhar); |
|||
// System.out.println("Student Aadhar: " + student_aadhar); |
|||
// |
|||
// System.out.println("----- Uploaded Files -----"); |
|||
// System.out.println("Father Aadhar File: " + (father_aadhar_file != null ? father_aadhar_file.getOriginalFilename() : "null")); |
|||
// System.out.println("Mother Aadhar File: " + (mother_aadhar_file != null ? mother_aadhar_file.getOriginalFilename() : "null")); |
|||
// System.out.println("Guardian Aadhar File: " + (guardian_aadhar_file != null ? guardian_aadhar_file.getOriginalFilename() : "null")); |
|||
// System.out.println("Student Aadhar File: " + (student_aadhar_file != null ? student_aadhar_file.getOriginalFilename() : "null")); |
|||
|
|||
|
|||
jdbcTemplate.update(sql, udise, student_name, emis_no, gender, std, dob, age, parent_type,sec,medium, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, fatherUrl, motherUrl, guardianUrl, studentUrl); |
|||
return "sucess"; |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "error"; |
|||
} |
|||
|
|||
} |
|||
|
|||
// private String saveFile(MultipartFile file) throws IOException { |
|||
// |
|||
// String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
// |
|||
// String folderName = environment.getProperty("education.foldername"); |
|||
// |
|||
// String fileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) + "_" + file.getOriginalFilename(); |
|||
// |
|||
// String folderPath = uploadDirectory + "/" + folderName; |
|||
// |
|||
// 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(); |
|||
// } |
|||
|
|||
private String saveFile(MultipartFile file) throws IOException { |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String folderName = environment.getProperty("education.foldername"); |
|||
|
|||
String fileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) + "_" + file.getOriginalFilename(); |
|||
|
|||
String FilePath = "/"+ folderName +"/"+fileName; |
|||
// Create the directory path |
|||
Path dirPath = Paths.get(uploadDirectory, folderName); |
|||
if (!Files.exists(dirPath)) { |
|||
Files.createDirectories(dirPath); |
|||
} |
|||
|
|||
// Create the full file path |
|||
Path filePath = dirPath.resolve(fileName); |
|||
|
|||
// Save the file |
|||
Files.write(filePath, file.getBytes()); |
|||
|
|||
return FilePath; |
|||
|
|||
// Return the full file path as a string |
|||
//return filePath.toString().replace("\\", "/"); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public ResponseEntity<?> getStudentsClass(String udise, String std) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
String sql = "SELECT student_id, student_name, emis_no FROM student_info WHERE udise = ? AND std = ? AND is_active=1 AND is_delete=0"; |
|||
try { |
|||
List<Map<String, Object>> data = jdbcTemplate.queryForList(sql, udise, std); |
|||
result.put("Message", "Success"); |
|||
result.put("Data", data); |
|||
return ResponseEntity.ok(result); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
result.put("Message", "Error"); |
|||
result.put("Error", "Failed to fetch students in class List: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public ResponseEntity<?> getStudentsDetails(String studentId) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
String sql = "SELECT *, " + |
|||
"CONCAT('" + fileBaseUrl + "/gcc/files', father_aadhar_file) AS view_father_aadhar_file, " + |
|||
"CONCAT('" + fileBaseUrl + "/gcc/files', mother_aadhar_file) AS view_mother_aadhar_file, " + |
|||
"CONCAT('" + fileBaseUrl + "/gcc/files', guardian_aadhar_file) AS view_guardian_aadhar_file, " + |
|||
"CONCAT('" + fileBaseUrl + "/gcc/files', student_aadhar_file) AS view_student_aadhar_file " + |
|||
" FROM student_info WHERE student_id = ?"; |
|||
try { |
|||
List<Map<String, Object>> data = jdbcTemplate.queryForList(sql, studentId); |
|||
result.put("Message", "Success"); |
|||
result.put("Data", data); |
|||
return ResponseEntity.ok(result); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
result.put("Message", "Error"); |
|||
result.put("Error", "Failed to fetch student detail: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public ResponseEntity<?> getMedium() { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
String sql = "SELECT * FROM medium_master ORDER BY execution_order ASC"; |
|||
try { |
|||
List<Map<String, Object>> data = jdbcTemplate.queryForList(sql); |
|||
result.put("Message", "Success"); |
|||
result.put("Data", data); |
|||
return ResponseEntity.ok(result); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
result.put("Message", "Error"); |
|||
result.put("Error", "Failed to fetch medium List: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); |
|||
} |
|||
} |
|||
|
|||
private String logEntry(String student_id, String user_id, String action_type) { |
|||
String sql="INSERT INTO student_info_log (student_id, udise, student_name, emis_no, gender, mediums, std, section, dob, age, parent_type, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, father_aadhar_file, mother_aadhar_file, guardian_aadhar_file, student_aadhar_file, user_id, action_type) " |
|||
+ " SELECT student_id, udise, student_name, emis_no, gender, mediums, std, section, dob, age, parent_type, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, father_aadhar_file, mother_aadhar_file, guardian_aadhar_file, student_aadhar_file, ?, ? FROM student_info WHERE student_id = ?"; |
|||
|
|||
try { |
|||
jdbcTemplate.update(sql, user_id, action_type, student_id); |
|||
return "sucess"; |
|||
|
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return "failure"; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public ResponseEntity<?> deleteProcess(String student_id, String user_id, String action_type) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
|
|||
String data = logEntry(student_id, user_id, action_type); |
|||
String data1 = ""; |
|||
if(data.equalsIgnoreCase("sucess")) { |
|||
data1 = deleteStudent(student_id); |
|||
} else { |
|||
result.put("Message", "Error"); |
|||
result.put("Data", "Failed"); |
|||
return ResponseEntity.ok(result); |
|||
} |
|||
if(data1.equalsIgnoreCase("sucess")) { |
|||
result.put("Message", "Success"); |
|||
result.put("Data", "Deleted sucessfully"); |
|||
}else { |
|||
result.put("Message", "Error"); |
|||
result.put("Data", "Failed to Delete"); |
|||
} |
|||
return ResponseEntity.ok(result); |
|||
} |
|||
|
|||
private String deleteStudent(String student_id) { |
|||
String sql="UPDATE student_info SET is_delete = 1, is_active = 0 WHERE student_id = ? "; |
|||
|
|||
|
|||
try { |
|||
jdbcTemplate.update(sql, student_id); |
|||
return "sucess"; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return "failure"; |
|||
} |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public ResponseEntity<?> updateProcess(String student_id, String user_id, String action_type, String udise, |
|||
String student_name, String emis_no, String gender, String mediums, String std, String section, String dob, |
|||
String age, String parent_type, String father_name, String mother_name, String guardian_name, |
|||
String father_mobile, String mother_mobile, String guardian_mobile, String father_aadhar, |
|||
String mother_aadhar, String guardian_aadhar, String student_aadhar, MultipartFile father_aadhar_file, |
|||
MultipartFile mother_aadhar_file, MultipartFile guardian_aadhar_file, MultipartFile student_aadhar_file, String raw_father_aadhar, String raw_mother_aadhar, String raw_guardian_aadhar, String raw_student_aadhar) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
|
|||
String data = logEntry(student_id, user_id, action_type); |
|||
String data1 = ""; |
|||
if(data.equalsIgnoreCase("sucess")) { |
|||
data1 = updateStudent(student_id, udise, student_name, emis_no, gender, mediums, std, section, dob, age, parent_type, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, father_aadhar_file, mother_aadhar_file, guardian_aadhar_file, student_aadhar_file, raw_father_aadhar, raw_mother_aadhar, raw_guardian_aadhar, raw_student_aadhar); |
|||
} |
|||
else { |
|||
result.put("Message", "Error"); |
|||
result.put("Data", "Failed"); |
|||
return ResponseEntity.ok(result); |
|||
} |
|||
|
|||
if(data1.equalsIgnoreCase("sucess")) { |
|||
result.put("Message", "Success"); |
|||
result.put("Data", "Updated successfully"); |
|||
}else { |
|||
result.put("Message", "Error"); |
|||
result.put("Data", "Failed to update"); |
|||
} |
|||
|
|||
return ResponseEntity.ok(result); |
|||
} |
|||
|
|||
private String updateStudent(String student_id, String udise, String student_name, String emis_no, String gender, |
|||
String mediums, String std, String section, String dob, String age, String parent_type, String father_name, |
|||
String mother_name, String guardian_name, String father_mobile, String mother_mobile, |
|||
String guardian_mobile, String father_aadhar, String mother_aadhar, String guardian_aadhar, |
|||
String student_aadhar, MultipartFile father_aadhar_file, MultipartFile mother_aadhar_file, |
|||
MultipartFile guardian_aadhar_file, MultipartFile student_aadhar_file, String raw_father_aadhar, String raw_mother_aadhar, String raw_guardian_aadhar, String raw_student_aadhar) { |
|||
|
|||
String sql = ""; |
|||
|
|||
String fatherUrl = null; |
|||
String motherUrl = null; |
|||
String guardianUrl = null; |
|||
String studentUrl = null; |
|||
|
|||
|
|||
try { |
|||
|
|||
//// for parent |
|||
if("Parent".equalsIgnoreCase(parent_type)) { |
|||
|
|||
if(raw_father_aadhar!=null && !raw_father_aadhar.isEmpty() ) { |
|||
fatherUrl = raw_father_aadhar; |
|||
if(father_aadhar_file!=null && !father_aadhar_file.isEmpty()) { |
|||
fatherUrl = saveFile(father_aadhar_file); |
|||
} |
|||
|
|||
} |
|||
else { |
|||
if(father_aadhar_file!=null && !father_aadhar_file.isEmpty()) { |
|||
fatherUrl = saveFile(father_aadhar_file); |
|||
} |
|||
else { |
|||
fatherUrl = null; |
|||
} |
|||
|
|||
} |
|||
|
|||
if(raw_mother_aadhar!=null && !raw_mother_aadhar.isEmpty() ) { |
|||
|
|||
motherUrl = raw_mother_aadhar; |
|||
if(mother_aadhar_file!=null && !mother_aadhar_file.isEmpty()) { |
|||
|
|||
motherUrl = saveFile(mother_aadhar_file); |
|||
} |
|||
|
|||
} |
|||
else { |
|||
|
|||
if(mother_aadhar_file!=null && !mother_aadhar_file.isEmpty()) { |
|||
motherUrl = saveFile(mother_aadhar_file); |
|||
} |
|||
else { |
|||
motherUrl =null; |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
else { |
|||
if (father_aadhar_file != null && !father_aadhar_file.isEmpty()) { |
|||
fatherUrl = saveFile(father_aadhar_file); |
|||
} else { |
|||
//fatherUrl = (raw_father_aadhar != null) ? raw_father_aadhar : null; |
|||
fatherUrl = (raw_father_aadhar != null && !raw_father_aadhar.isEmpty()) ? raw_father_aadhar : null; |
|||
} |
|||
|
|||
if (mother_aadhar_file != null && !mother_aadhar_file.isEmpty()) { |
|||
motherUrl = saveFile(mother_aadhar_file); |
|||
} else { |
|||
//motherUrl = (raw_mother_aadhar != null) ? raw_mother_aadhar : null; |
|||
motherUrl = (raw_mother_aadhar != null && !raw_mother_aadhar.isEmpty()) ? raw_mother_aadhar : null; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
//// |
|||
guardianUrl = raw_guardian_aadhar; |
|||
if(guardian_aadhar_file!=null && !guardian_aadhar_file.isEmpty()) { |
|||
guardianUrl = saveFile(guardian_aadhar_file); |
|||
} |
|||
|
|||
/// |
|||
studentUrl = raw_student_aadhar; |
|||
if(student_aadhar_file!=null && !student_aadhar_file.isEmpty()) { |
|||
studentUrl = saveFile(student_aadhar_file); |
|||
} |
|||
|
|||
//father_mobile mother_mobile |
|||
if (father_mobile != null && father_mobile.trim().isEmpty()) { |
|||
father_mobile = null; |
|||
} |
|||
if (mother_mobile != null && mother_mobile.trim().isEmpty()) { |
|||
mother_mobile = null; |
|||
} |
|||
|
|||
// father_aadhar mother_aadhar student_aadhar |
|||
if (father_aadhar != null && father_aadhar.trim().isEmpty()) { |
|||
father_aadhar = null; |
|||
} |
|||
if (mother_aadhar != null && mother_aadhar.trim().isEmpty()) { |
|||
mother_aadhar = null; |
|||
} |
|||
|
|||
if (student_aadhar != null && student_aadhar.trim().isEmpty()) { |
|||
student_aadhar = null; |
|||
} |
|||
|
|||
//////// |
|||
if(parent_type.equalsIgnoreCase("Parent")) { |
|||
sql="UPDATE student_info SET udise = ?, student_name = ?, emis_no = ?, gender = ?, mediums = ?, std = ?, section = ?, dob = ?, age = ?, parent_type = ?, father_name = ?, mother_name = ?, father_mobile = ?, mother_mobile = ?, father_aadhar = ?, mother_aadhar = ?, student_aadhar = ?, father_aadhar_file = ?, mother_aadhar_file = ?, student_aadhar_file = ? WHERE student_id = ? "; |
|||
jdbcTemplate.update(sql, udise, student_name, emis_no, gender, mediums, std, section, dob, age, parent_type, father_name, mother_name, father_mobile, mother_mobile, father_aadhar, mother_aadhar, student_aadhar, fatherUrl, motherUrl, studentUrl, student_id); |
|||
} else if(parent_type.equalsIgnoreCase("SingleParent_Father")) { |
|||
sql="UPDATE student_info SET udise = ?, student_name = ?, emis_no = ?, gender = ?, mediums = ?, std = ?, section = ?, dob = ?, age = ?, parent_type = ?, father_name = ?, father_mobile = ?, father_aadhar = ?, student_aadhar = ?, father_aadhar_file = ?, student_aadhar_file = ? WHERE student_id = ? "; |
|||
jdbcTemplate.update(sql, udise, student_name, emis_no, gender, mediums, std, section, dob, age, parent_type, father_name, father_mobile, father_aadhar, student_aadhar, fatherUrl, studentUrl, student_id); |
|||
} else if(parent_type.equalsIgnoreCase("SingleParent_Mother")) { |
|||
sql="UPDATE student_info SET udise = ?, student_name = ?, emis_no = ?, gender = ?, mediums = ?, std = ?, section = ?, dob = ?, age = ?, parent_type = ?, mother_name = ?, mother_mobile = ?, mother_aadhar = ?, student_aadhar = ?, mother_aadhar_file = ?, student_aadhar_file = ? WHERE student_id = ? "; |
|||
jdbcTemplate.update(sql, udise, student_name, emis_no, gender, mediums, std, section, dob, age, parent_type, mother_name, mother_mobile, mother_aadhar, student_aadhar, motherUrl, studentUrl, student_id); |
|||
} else if(parent_type.equalsIgnoreCase("Guardian")) { |
|||
sql="UPDATE student_info SET udise = ?, student_name = ?, emis_no = ?, gender = ?, mediums = ?, std = ?, section = ?, dob = ?, age = ?, parent_type = ?, father_name = ?, mother_name = ?, guardian_name = ?, father_mobile = ?, mother_mobile = ?, guardian_mobile = ?, father_aadhar = ?, mother_aadhar = ?, guardian_aadhar = ?, student_aadhar = ?, father_aadhar_file = ?, mother_aadhar_file = ?, guardian_aadhar_file = ?, student_aadhar_file = ? WHERE student_id = ? "; |
|||
jdbcTemplate.update(sql, udise, student_name, emis_no, gender, mediums, std, section, dob, age, parent_type, father_name, mother_name, guardian_name, father_mobile, mother_mobile, guardian_mobile, father_aadhar, mother_aadhar, guardian_aadhar, student_aadhar, fatherUrl, motherUrl, guardianUrl, studentUrl, student_id); |
|||
} |
|||
return "sucess"; |
|||
}catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return "failure"; |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public ResponseEntity<?> checkStudent(String udise, String schoolId) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
try { |
|||
String stu_strength = studentStrength(schoolId); |
|||
String aadhar_strength = aadharStrength(udise); |
|||
|
|||
if (!stu_strength.equalsIgnoreCase("error") && !aadhar_strength.equalsIgnoreCase("error")) { |
|||
int allowable_strength = Integer.parseInt(stu_strength) - Integer.parseInt(aadhar_strength); |
|||
result.put("Student_Strength", Integer.parseInt(stu_strength)); |
|||
result.put("Aadhar_strength", Integer.parseInt(aadhar_strength)); |
|||
result.put("Allowable_strength", allowable_strength); |
|||
result.put("Message", "Sucessfully student count fetched"); |
|||
result.put("Status", "Sucess"); |
|||
} else if (stu_strength.equalsIgnoreCase("error") || aadhar_strength.equalsIgnoreCase("error")) { |
|||
result.put("Status", "Error"); |
|||
result.put("Message", "Error in fetching students count"); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
result.put("Status", "Error"); |
|||
result.put("Message", "Error in fetching students count"); |
|||
} |
|||
return ResponseEntity.ok(result); |
|||
} |
|||
|
|||
|
|||
private String aadharStrength(String udise) { |
|||
String sql = "SELECT count(*) FROM student_info WHERE udise = ? AND is_active = 1 AND is_delete = 0"; |
|||
String strength = "0"; |
|||
|
|||
try { |
|||
String result = jdbcTemplate.queryForObject(sql, String.class, udise); |
|||
if (result != null && !result.isEmpty()) { |
|||
strength = result; |
|||
} |
|||
} |
|||
catch (Exception e) { |
|||
System.out.println("Error fetching student strength: " + e.getMessage()); |
|||
strength = "error"; |
|||
} |
|||
|
|||
return strength; |
|||
} |
|||
private String studentStrength(String schoolId) { |
|||
String sql = "SELECT total_students FROM student_strength WHERE school_id = ?"; |
|||
String strength = "0"; |
|||
|
|||
try { |
|||
String result = jdbcTemplate.queryForObject(sql, String.class, schoolId); |
|||
if (result != null && !result.isEmpty()) { |
|||
strength = result; |
|||
} |
|||
} |
|||
catch (Exception e) { |
|||
System.out.println("Error fetching student strength: " + e.getMessage()); |
|||
strength = "error"; |
|||
} |
|||
|
|||
return strength; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,480 @@ |
|||
package in.gov.chennaicorporation.gccoffice.vendor.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.http.HttpMethod; |
|||
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 org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.vendor.service.StreetVendorService; |
|||
import in.gov.chennaicorporation.gccoffice.vendor.service.createventService; |
|||
|
|||
@RestController("streetvendorApiController") |
|||
@RequestMapping("/gcc/api/streetvendor") |
|||
public class ApiController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
private StreetVendorService streetVendorService; |
|||
|
|||
@Autowired |
|||
public createventService createventservice; |
|||
|
|||
@Autowired |
|||
public ApiController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
@GetMapping("/vendorCommiteeList") |
|||
public String getVendorCommiteeDetails(){ |
|||
String apiUrl = appConfig.mobileservice + "/gccofficialapp/api/streetvendor/vendingCommiteeList"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
// @GetMapping("/vendorCommiteeListbyID") |
|||
// public String getVendorCommiteeDetailsByID(@RequestParam("id") Long id) { |
|||
// String apiUrl = appConfig.mobileservice + "/gccofficialapp/api/streetvendor/vendingCommiteeListbyId?id=" + id; |
|||
// ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
// return responseEntity.getBody(); |
|||
// } |
|||
|
|||
@GetMapping("/vendorCommiteeListbyID") |
|||
public ResponseEntity<List<Map<String, Object>>> getVendorCommiteeDetailsByID(@RequestParam("id") Long id) { |
|||
String apiUrl = appConfig.mobileservice + "/gccofficialapp/api/streetvendor/vendingCommiteeListbyId?id=" + id; |
|||
ResponseEntity<List> responseEntity = restTemplate.exchange(apiUrl, HttpMethod.GET, null, List.class); |
|||
//System.out.println("responseEntity...."+responseEntity); |
|||
return ResponseEntity.ok(responseEntity.getBody()); |
|||
} |
|||
|
|||
@GetMapping("/vendingCommiteeList") |
|||
public ResponseEntity<List<Map<String, Object>>> getVendingCommiteeList(@RequestParam("date") String date) { |
|||
String apiUrl = appConfig.mobileservice + "/gccofficialapp/api/streetvendor/vendingCommiteeList?date=" + date; |
|||
ResponseEntity<List> responseEntity = restTemplate.exchange(apiUrl, HttpMethod.GET, null, List.class); |
|||
|
|||
List<String> saved_request_no=createventservice.removeSavedVendorDetails(); |
|||
//System.out.println("saved_request_no="+saved_request_no); |
|||
|
|||
// Filter out matching vendor_req_id entries |
|||
List<Map<String, Object>> originalList = responseEntity.getBody(); |
|||
List<Map<String,Object>> filteredList = originalList.stream().filter(item -> !saved_request_no.contains(String.valueOf(item.get("vendor_req_id")))) |
|||
.collect(Collectors.toList()); |
|||
|
|||
return ResponseEntity.ok(filteredList); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/vendorDetailsByReqId") |
|||
public ResponseEntity<List<Map<String, Object>>> getVendorDetailsByReqId(@RequestParam("requestId") String requestId) { |
|||
String apiUrl = appConfig.mobileservice + "/gccofficialapp/api/streetvendor/vendorDetailsByReqId?requestId=" + requestId; |
|||
ResponseEntity<List> responseEntity = restTemplate.exchange(apiUrl, HttpMethod.GET, null, List.class); |
|||
return ResponseEntity.ok(responseEntity.getBody()); |
|||
} |
|||
|
|||
|
|||
@PostMapping("/savedetailsforvendor") |
|||
public ResponseEntity<Map<String, Object>> savedetailsforvendor(@RequestBody Map<String, Object> payload) |
|||
{ |
|||
return createventservice.saveVendorDetails(payload); |
|||
} |
|||
|
|||
@GetMapping("/vendingCommiteeDetails") |
|||
public List<Map<String, Object>> getvendingCommiteeDetails(@RequestParam("event_req_id") String event_req_id) { |
|||
|
|||
return createventservice.getCommiteeDetails(event_req_id); |
|||
} |
|||
|
|||
@GetMapping("/vendingDetailsWeb") |
|||
public List<Map<String, Object>> getvendingDetailsWeb(@RequestParam String cby) { |
|||
|
|||
return streetVendorService.getCommiteeDetailsWeb(cby); |
|||
} |
|||
|
|||
@GetMapping("/webVendorDetailsByReqId") |
|||
public List<Map<String, Object>> getwebVendorDetailsByReqId(@RequestParam("requestId") String requestId) { |
|||
|
|||
return streetVendorService.getwebVendorDetailsByReqId(requestId); |
|||
} |
|||
|
|||
// sanjay |
|||
|
|||
// @GetMapping("/wards-by-zone") |
|||
// |
|||
// public List<Map<String, Object>> getWardsByZone(@RequestParam("zoneId") int zoneId) { |
|||
// return streetVendorService.fetchWardsByZone(zoneId); |
|||
// } |
|||
|
|||
|
|||
|
|||
// @PostMapping("/saveDetails") |
|||
// public ResponseEntity<Map<String, Object>> saveVenderDetails( |
|||
// |
|||
// @RequestParam String latitude, |
|||
// @RequestParam String longitude, |
|||
// @RequestParam String zone, |
|||
// @RequestParam String ward, |
|||
// @RequestParam String landmark, |
|||
// @RequestParam String vending_district, |
|||
// @RequestParam int vending_pincode, |
|||
// @RequestParam int vending_category, |
|||
// @RequestParam String vending_space, |
|||
// @RequestParam boolean pm_svanidhi_loan, |
|||
// @RequestParam boolean bank_acc_status, |
|||
// @RequestParam (required = false, name = "bank_passbook" )MultipartFile bank_passbook, |
|||
// @RequestParam MultipartFile street_vendor_photo, |
|||
// @RequestParam String name, |
|||
// @RequestParam String f_h_name, |
|||
// @RequestParam String mobile_number, |
|||
// @RequestParam String dob, |
|||
// @RequestParam String gender, |
|||
// @RequestParam int social_category, |
|||
// @RequestParam boolean diff_abled, |
|||
// @RequestParam int education_status, |
|||
// @RequestParam int marital_status, |
|||
// @RequestParam int no_of_fam_mem, |
|||
// @RequestParam boolean are_any_fam_mem_invol_str, |
|||
//// @RequestParam String vending_address, |
|||
// |
|||
// @RequestParam String door_no, |
|||
// @RequestParam String streetname, |
|||
// @RequestParam String areaname, |
|||
// @RequestParam String present_district, |
|||
// @RequestParam int present_pincode, |
|||
// @RequestParam MultipartFile ration_card_photo, |
|||
// @RequestParam MultipartFile aadhar_front_photo, |
|||
// @RequestParam MultipartFile aadhar_back_photo, |
|||
// @RequestParam String aadharNo) { |
|||
// |
|||
// String presentAddress = door_no + ", " + streetname + ", " + areaname; |
|||
// |
|||
// System.out.println("bank_passbook...."+bank_passbook); |
|||
// System.out.println("ration_card_photo...."+ration_card_photo); |
|||
// System.out.println("street_vendor_photo...."+street_vendor_photo); |
|||
// System.out.println("aadhar_front_photo...."+aadhar_front_photo); |
|||
// System.out.println("aadhar_back_photo...."+aadhar_back_photo); |
|||
// |
|||
// String bankPassbookPath = ""; |
|||
// |
|||
// // Only upload passbook if status is true |
|||
// if (bank_acc_status) { |
|||
// if (bank_passbook != null && !bank_passbook.isEmpty()) { |
|||
// bankPassbookPath = streetVendorService.fileUpload (bank_passbook, "bank_passbook"); |
|||
// } else { |
|||
// return ResponseEntity.badRequest().body(Map.of( |
|||
// "status", false, |
|||
// "description", "Bank passbook is required when account status is Yes" |
|||
// )); |
|||
// } |
|||
// } |
|||
// String rationCardPath = streetVendorService.fileUpload(ration_card_photo, "ration_card"); |
|||
// String streetVendorPhotoPath = streetVendorService.fileUpload(street_vendor_photo, "vendor_photo"); |
|||
// String aadharFrontPhotoPath = streetVendorService.fileUpload(aadhar_front_photo, "aadhar_front"); |
|||
// String aadharBackPhotoPath = streetVendorService.fileUpload(aadhar_back_photo, "aadhar_back"); |
|||
// |
|||
// String saveStatus = streetVendorService.saveStreetVendorDetails( |
|||
// latitude, longitude,zone, ward, landmark, vending_district, vending_pincode, vending_category, vending_space, |
|||
// pm_svanidhi_loan, bank_acc_status, bankPassbookPath, |
|||
// streetVendorPhotoPath, name, f_h_name, mobile_number,dob, |
|||
// gender, social_category, diff_abled, education_status, marital_status, |
|||
// no_of_fam_mem, are_any_fam_mem_invol_str,presentAddress, present_district, present_pincode, |
|||
// rationCardPath,aadharFrontPhotoPath, aadharBackPhotoPath,aadharNo); |
|||
// |
|||
// if (saveStatus == null || saveStatus.equals("error")) { |
|||
// return ResponseEntity.ok(Map.of( |
|||
// "status", false, |
|||
// "message", "failed", |
|||
// "description", "Failed to save the details" |
|||
// )); |
|||
// } |
|||
// |
|||
// return ResponseEntity.ok(Map.of( |
|||
// "status", true, |
|||
// "message", "success", |
|||
// "description", "Details saved successfully", |
|||
// "vendor_req_id", saveStatus |
|||
// )); |
|||
// } |
|||
|
|||
|
|||
@PostMapping("/saveDetails") |
|||
public ResponseEntity<Map<String, Object>> saveVenderDetails( |
|||
|
|||
@RequestParam (required = false)String latitude, |
|||
@RequestParam (required = false)String longitude, |
|||
@RequestParam (required = false)String zone, |
|||
@RequestParam (required = false)String ward, |
|||
@RequestParam (required = false)String landmark, |
|||
@RequestParam (required = false)String vending_district, |
|||
@RequestParam (required = false)Integer vending_pincode, |
|||
@RequestParam Integer vending_category, |
|||
@RequestParam (required = false)String vending_space, |
|||
@RequestParam (required = false) Boolean pm_svanidhi_loan, |
|||
@RequestParam (required = false) Boolean bank_acc_status, |
|||
@RequestParam (required = false, name = "bank_passbook" )MultipartFile bank_passbook, |
|||
@RequestParam (required = false) MultipartFile street_vendor_photo, |
|||
@RequestParam String name, |
|||
@RequestParam (required = false)String f_h_name, |
|||
@RequestParam String mobile_number, |
|||
@RequestParam (required = false)String dob, |
|||
|
|||
@RequestParam (required = false)String gender, |
|||
@RequestParam (required = false)Integer social_category, |
|||
@RequestParam (required = false)Boolean diff_abled, |
|||
@RequestParam (required = false)Integer education_status, |
|||
@RequestParam (required = false)Integer marital_status, |
|||
@RequestParam (required = false)Integer no_of_fam_mem, |
|||
@RequestParam (required = false)Boolean are_any_fam_mem_invol_str, |
|||
|
|||
@RequestParam (required = false)String door_no, |
|||
@RequestParam (required = false)String streetname, |
|||
@RequestParam (required = false)String areaname, |
|||
@RequestParam (required = false)String present_district, |
|||
@RequestParam (required = false)Integer present_pincode, |
|||
@RequestParam (required = false)MultipartFile ration_card_photo, |
|||
@RequestParam (required = false)MultipartFile aadhar_front_photo, |
|||
@RequestParam (required = false)MultipartFile aadhar_back_photo, |
|||
@RequestParam (required = false)String aadharNo, |
|||
@RequestParam String userId) { |
|||
|
|||
//String presentAddress = door_no + ", " + streetname + ", " + areaname; |
|||
|
|||
|
|||
|
|||
String doorNoVal = (door_no != null && !door_no.trim().isEmpty()) ? door_no : ""; |
|||
String streetNameVal = (streetname != null && !streetname.trim().isEmpty()) ? streetname : ""; |
|||
String areaNameVal = (areaname != null && !areaname.trim().isEmpty()) ? areaname : ""; |
|||
|
|||
|
|||
|
|||
String presentAddress = String.join(", ", doorNoVal, streetNameVal, areaNameVal); |
|||
|
|||
String bankPassbookPath = null; |
|||
|
|||
// Only upload passbook if status is true |
|||
if (Boolean.TRUE.equals(bank_acc_status)) { |
|||
|
|||
if (bank_passbook != null && !bank_passbook.isEmpty()) { |
|||
|
|||
bankPassbookPath = streetVendorService.fileUpload (bank_passbook, "street_vendor_bank"); |
|||
} else { |
|||
return ResponseEntity.badRequest().body(Map.of( |
|||
"status", false, |
|||
"description", "Bank passbook is required when account status is Yes" |
|||
)); |
|||
} |
|||
} |
|||
|
|||
|
|||
String rationCardPath=null; |
|||
String streetVendorPhotoPath=null; |
|||
String aadharFrontPhotoPath=null; |
|||
String aadharBackPhotoPath=null; |
|||
|
|||
if(ration_card_photo != null && !ration_card_photo.isEmpty()) |
|||
{ |
|||
rationCardPath = streetVendorService.fileUpload(ration_card_photo, "street_vendor_ration"); |
|||
} |
|||
if (street_vendor_photo != null && !street_vendor_photo.isEmpty()) |
|||
{ |
|||
streetVendorPhotoPath = streetVendorService.fileUpload(street_vendor_photo, "street_vendor_photo"); |
|||
} |
|||
if (aadhar_front_photo != null && !aadhar_front_photo.isEmpty()) |
|||
{ |
|||
aadharFrontPhotoPath = streetVendorService.fileUpload(aadhar_front_photo, "aadhar_front"); |
|||
} |
|||
if (aadhar_back_photo != null && !aadhar_back_photo.isEmpty()) |
|||
{ |
|||
aadharBackPhotoPath = streetVendorService.fileUpload(aadhar_back_photo, "aadhar_back"); |
|||
} |
|||
|
|||
|
|||
String saveStatus = streetVendorService.saveStreetVendorDetails( |
|||
latitude, longitude,zone, ward, landmark, vending_district, vending_pincode, vending_category, vending_space, |
|||
pm_svanidhi_loan, bank_acc_status, bankPassbookPath, |
|||
streetVendorPhotoPath, name, f_h_name, mobile_number,dob, |
|||
gender, social_category, diff_abled, education_status, marital_status, |
|||
no_of_fam_mem, are_any_fam_mem_invol_str,presentAddress, present_district, present_pincode, |
|||
rationCardPath,aadharFrontPhotoPath, aadharBackPhotoPath,aadharNo,userId); |
|||
|
|||
if (saveStatus == null || saveStatus.equals("error")) { |
|||
return ResponseEntity.ok(Map.of( |
|||
"status", false, |
|||
"message", "failed", |
|||
"description", "Failed to save the details" |
|||
)); |
|||
} |
|||
|
|||
|
|||
return ResponseEntity.ok(Map.of( |
|||
"status", true, |
|||
"message", "success", |
|||
"description", "Details saved successfully", |
|||
"vendor_req_id", saveStatus |
|||
)); |
|||
} |
|||
|
|||
|
|||
|
|||
// check mobile number registered |
|||
@GetMapping("/check-mobile") |
|||
public ResponseEntity<Boolean> checkMobileNumber(@RequestParam String mobilenumber) { |
|||
boolean exists = streetVendorService.isMobileRegistered(mobilenumber); |
|||
return ResponseEntity.ok(exists); |
|||
} |
|||
|
|||
|
|||
|
|||
@PostMapping("/updateDetails") |
|||
public ResponseEntity<Map<String, Object>> updateVenderDetails( |
|||
|
|||
@RequestParam (required = false)String latitude, |
|||
@RequestParam (required = false)String longitude, |
|||
@RequestParam (required = false)String zone, |
|||
@RequestParam (required = false)String ward, |
|||
@RequestParam (required = false)String landmark, |
|||
@RequestParam (required = false)String vending_district, |
|||
@RequestParam (required = false)Integer vending_pincode, |
|||
@RequestParam Integer vending_category, |
|||
@RequestParam (required = false)String vending_space, |
|||
@RequestParam (required = false) Boolean pm_svanidhi_loan, |
|||
@RequestParam (required = false) Boolean bank_acc_status, |
|||
@RequestParam (required = false, name = "bank_passbook" )MultipartFile bank_passbook, |
|||
@RequestParam (required = false) MultipartFile street_vendor_photo, |
|||
@RequestParam String name, |
|||
@RequestParam (required = false)String f_h_name, |
|||
@RequestParam String mobile_number, |
|||
@RequestParam (required = false)String dob, |
|||
|
|||
@RequestParam (required = false)String gender, |
|||
@RequestParam (required = false)Integer social_category, |
|||
@RequestParam (required = false)Boolean diff_abled, |
|||
@RequestParam (required = false)Integer education_status, |
|||
@RequestParam (required = false)Integer marital_status, |
|||
@RequestParam (required = false)Integer no_of_fam_mem, |
|||
@RequestParam (required = false)Boolean are_any_fam_mem_invol_str, |
|||
|
|||
@RequestParam (required = false)String door_no, |
|||
@RequestParam (required = false)String streetname, |
|||
@RequestParam (required = false)String areaname, |
|||
@RequestParam (required = false)String present_district, |
|||
@RequestParam (required = false)Integer present_pincode, |
|||
@RequestParam (required = false)MultipartFile ration_card_photo, |
|||
@RequestParam (required = false)MultipartFile aadhar_front_photo, |
|||
@RequestParam (required = false)MultipartFile aadhar_back_photo, |
|||
@RequestParam (required = false)String aadharNo, |
|||
@RequestParam (required = false)String raw_bank_passbook, |
|||
@RequestParam (required = false)String raw_street_vendor_photo, |
|||
@RequestParam (required = false)String raw_aadhar_front_photo, |
|||
@RequestParam (required = false)String raw_aadhar_back_photo, |
|||
@RequestParam (required = false)String raw_ration_card_photo, |
|||
@RequestParam String userId, |
|||
@RequestParam String vendor_req_id){ |
|||
|
|||
|
|||
String data = streetVendorService.logEntry(userId, vendor_req_id); |
|||
|
|||
if(data.equalsIgnoreCase("success")) { |
|||
|
|||
String bankPassbookPath = null; |
|||
String rationCardPath=null; |
|||
String streetVendorPhotoPath=null; |
|||
String aadharFrontPhotoPath=null; |
|||
String aadharBackPhotoPath=null; |
|||
|
|||
System.out.println("raw_bank_passbook="+raw_bank_passbook); |
|||
System.out.println("raw_street_vendor_photo="+raw_street_vendor_photo); |
|||
System.out.println("raw_aadhar_front_photo="+raw_aadhar_front_photo); |
|||
System.out.println("raw_aadhar_back_photo="+raw_aadhar_back_photo); |
|||
System.out.println("raw_ration_card_photo="+raw_ration_card_photo); |
|||
|
|||
|
|||
bankPassbookPath=raw_bank_passbook; |
|||
if(bank_passbook!=null && !bank_passbook.isEmpty()) { |
|||
bankPassbookPath = streetVendorService.fileUpload (bank_passbook, "street_vendor_bank"); |
|||
} |
|||
|
|||
rationCardPath=raw_ration_card_photo; |
|||
if(ration_card_photo!=null && !ration_card_photo.isEmpty()) { |
|||
rationCardPath = streetVendorService.fileUpload (ration_card_photo, "street_vendor_ration"); |
|||
} |
|||
|
|||
streetVendorPhotoPath=raw_street_vendor_photo; |
|||
if(street_vendor_photo!=null && !street_vendor_photo.isEmpty()) { |
|||
streetVendorPhotoPath = streetVendorService.fileUpload (street_vendor_photo, "street_vendor_photo"); |
|||
} |
|||
|
|||
aadharFrontPhotoPath=raw_aadhar_front_photo; |
|||
if(aadhar_front_photo!=null && !aadhar_front_photo.isEmpty()) { |
|||
aadharFrontPhotoPath = streetVendorService.fileUpload (aadhar_front_photo, "aadhar_front"); |
|||
} |
|||
|
|||
aadharBackPhotoPath=raw_aadhar_back_photo; |
|||
if(aadhar_back_photo!=null && !aadhar_back_photo.isEmpty()) { |
|||
aadharBackPhotoPath = streetVendorService.fileUpload (aadhar_back_photo, "aadhar_back"); |
|||
} |
|||
|
|||
String doorNoVal = (door_no != null && !door_no.trim().isEmpty()) ? door_no : ""; |
|||
String streetNameVal = (streetname != null && !streetname.trim().isEmpty()) ? streetname : ""; |
|||
String areaNameVal = (areaname != null && !areaname.trim().isEmpty()) ? areaname : ""; |
|||
|
|||
|
|||
String presentAddress = String.join(", ", doorNoVal, streetNameVal, areaNameVal); |
|||
|
|||
String sts=streetVendorService.updateStreetVendorDetailsWeb( |
|||
latitude, longitude,zone, ward, landmark, vending_district, vending_pincode, vending_category, vending_space, |
|||
pm_svanidhi_loan, bank_acc_status, bankPassbookPath, |
|||
streetVendorPhotoPath, name, f_h_name, mobile_number,dob, |
|||
gender, social_category, diff_abled, education_status, marital_status, |
|||
no_of_fam_mem, are_any_fam_mem_invol_str,presentAddress, present_district, present_pincode, |
|||
rationCardPath,aadharFrontPhotoPath, aadharBackPhotoPath,aadharNo,userId,vendor_req_id); |
|||
|
|||
if(sts.equals("Error")) { |
|||
return ResponseEntity.ok(Map.of( |
|||
"status", false, |
|||
"message", "failed", |
|||
"description", "Failed to update the details" |
|||
)); |
|||
} |
|||
|
|||
return ResponseEntity.ok(Map.of( |
|||
"status", true, |
|||
"message", "success", |
|||
"description", "Details Updated successfully" |
|||
)); |
|||
|
|||
} |
|||
|
|||
else { |
|||
|
|||
return ResponseEntity.ok(Map.of( |
|||
"status", false, |
|||
"message", "failed", |
|||
"description", "Issues in log entry,So failed to update" |
|||
)); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,126 @@ |
|||
package in.gov.chennaicorporation.gccoffice.vendor.controller; |
|||
|
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
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.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.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.vendor.service.createventService; |
|||
|
|||
@RequestMapping("/gcc/api/vending") |
|||
@RestController |
|||
public class CreateEventAPIController { |
|||
|
|||
@Autowired |
|||
private createventService createventservices; |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
@PostMapping("/save") |
|||
public ResponseEntity<String> saveEventWithFile( |
|||
@RequestParam("eventName") String eventName, |
|||
@RequestParam("eventDate") String eventDateStr, |
|||
@RequestParam("file") MultipartFile file) { |
|||
|
|||
try { |
|||
if (eventName == null || eventDateStr == null || file.isEmpty()) { |
|||
throw new IllegalArgumentException("Event Name, Date, and File must not be empty."); |
|||
} |
|||
|
|||
// Debug logs |
|||
System.out.println("Event Name: " + eventName); |
|||
System.out.println("Event Date: " + eventDateStr); |
|||
System.out.println("Original File Name: " + file.getOriginalFilename()); |
|||
|
|||
String originalfilename = file.getOriginalFilename(); |
|||
boolean existfileurl = createventservices.isFileExists(originalfilename); |
|||
String fileUrl = saveFile(file); |
|||
// Save to DB |
|||
LocalDate eventDate = LocalDate.parse(eventDateStr); |
|||
createventservices.insertEvent(eventName, eventDate, fileUrl); |
|||
|
|||
return ResponseEntity.ok("Event saved successfully."); |
|||
} catch (IllegalArgumentException e) { |
|||
return ResponseEntity.badRequest().body("Validation Error: " + e.getMessage()); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body("Internal Server Error: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
//save file and get path |
|||
private String saveFile(MultipartFile file) throws IOException { |
|||
|
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
|
|||
String folderName = environment.getProperty("vending.foldername"); |
|||
|
|||
String fileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) + "_" + file.getOriginalFilename(); |
|||
|
|||
String folderPath = uploadDirectory + "/" + folderName + "/"; |
|||
|
|||
|
|||
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(); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/dropdown-Event") |
|||
public ResponseEntity<List<Map<String, Object>>> ViewDropdownEvent() { |
|||
try { |
|||
List<Map<String, Object>> result = createventservices.ViewDropdownEvent(); |
|||
return ResponseEntity.ok(result); |
|||
} catch (Exception e) { |
|||
Map<String, Object> error = new HashMap<>(); |
|||
error.put("error", "Unable to fetch event list"); |
|||
error.put("details", e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.singletonList(error)); |
|||
} |
|||
} |
|||
|
|||
|
|||
@GetMapping("/committedropdown") |
|||
public ResponseEntity<List<Map<String, Object>>> ViewCommitteeDropdownEvent() { |
|||
try { |
|||
List<Map<String, Object>> result = createventservices.ViewCommitteeDropdownEvent(); |
|||
System.out.println("result="+result); |
|||
return ResponseEntity.ok(result); |
|||
} catch (Exception e) { |
|||
Map<String, Object> error = new HashMap<>(); |
|||
error.put("error", "Unable to fetch event list"); |
|||
error.put("details", e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.singletonList(error)); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,147 @@ |
|||
package in.gov.chennaicorporation.gccoffice.vendor.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
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.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
import in.gov.chennaicorporation.gccoffice.vendor.service.StreetVendorService; |
|||
|
|||
@RequestMapping("/gcc/vendor") |
|||
@Controller("vendorMainController") |
|||
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 StreetVendorService streetVendorService; |
|||
|
|||
@GetMapping("/addevent") |
|||
public String viewAddEvent(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/vendors/addevent"; |
|||
} |
|||
|
|||
@GetMapping("/requestlist") |
|||
public String viewRequestList(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/vendors/RequestList"; |
|||
} |
|||
|
|||
@GetMapping("/eventlist") |
|||
public String viewEventList(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/vendors/EventList"; |
|||
} |
|||
|
|||
@GetMapping("/streetvendorform") |
|||
public String streetvendorform(Model model) |
|||
{ |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
|
|||
|
|||
List<Map<String, Object>>communities=streetVendorService.fetchCommunities(); |
|||
//System.out.println("communities===="+communities); |
|||
model.addAttribute("communities", communities); |
|||
|
|||
|
|||
|
|||
List<Map<String, Object>>maritalStatuses=streetVendorService.fetchMaritalStatus(); |
|||
//System.out.println("maritalStatuses===="+maritalStatuses); |
|||
model.addAttribute("maritalStatuses", maritalStatuses); |
|||
|
|||
|
|||
|
|||
List<Map<String, Object>>educationList=streetVendorService.fetchEducationStatus(); |
|||
//System.out.println("educationList===="+educationList); |
|||
model.addAttribute("educationList", educationList); |
|||
|
|||
|
|||
|
|||
List<Map<String, Object>>vendingCategories=streetVendorService.fetchvendingCategory(); |
|||
//System.out.println("vendingCategory===="+vendingCategories); |
|||
model.addAttribute("vendingCategories", vendingCategories); |
|||
|
|||
|
|||
//List<Map<String, Object>>zones=streetVendorService.fetchZones(); |
|||
//System.out.println("zones===="+zones); |
|||
//model.addAttribute("zones", zones); |
|||
|
|||
|
|||
|
|||
|
|||
return "modules/vendors/streetVendorRequestForm"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/streetvendorlist") |
|||
public String viewVendorRequestList(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
|
|||
List<Map<String, Object>>communities=streetVendorService.fetchCommunities(); |
|||
model.addAttribute("communities", communities); |
|||
|
|||
|
|||
List<Map<String, Object>>maritalStatuses=streetVendorService.fetchMaritalStatus(); |
|||
model.addAttribute("maritalStatuses", maritalStatuses); |
|||
|
|||
|
|||
List<Map<String, Object>>educationList=streetVendorService.fetchEducationStatus(); |
|||
model.addAttribute("educationList", educationList); |
|||
|
|||
|
|||
List<Map<String, Object>>vendingCategories=streetVendorService.fetchvendingCategory(); |
|||
model.addAttribute("vendingCategories", vendingCategories); |
|||
|
|||
return "modules/vendors/streetVendorRequestList"; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
package in.gov.chennaicorporation.gccoffice.vendor.service; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
|
|||
import org.springframework.stereotype.Component; |
|||
|
|||
|
|||
|
|||
@Component("vendorDateTimeUtil") // For vendo |
|||
public final 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,484 @@ |
|||
package in.gov.chennaicorporation.gccoffice.vendor.service; |
|||
|
|||
import java.awt.image.BufferedImage; |
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.security.SecureRandom; |
|||
import java.sql.PreparedStatement; |
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Random; |
|||
|
|||
import javax.imageio.ImageIO; |
|||
import javax.imageio.ImageWriteParam; |
|||
import javax.imageio.ImageWriter; |
|||
import javax.imageio.stream.ImageOutputStream; |
|||
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.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
|
|||
|
|||
@Service |
|||
public class StreetVendorService { |
|||
|
|||
|
|||
@Autowired |
|||
@Qualifier("vendorDateTimeUtil") |
|||
private DateTimeUtil dateTimeUtil; |
|||
|
|||
|
|||
private final Environment environment; |
|||
|
|||
private String fileBaseUrl; |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlGccStreetVendorDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
|||
private static final int STRING_LENGTH = 15; |
|||
private static final Random RANDOM = new SecureRandom(); |
|||
|
|||
|
|||
public StreetVendorService(Environment environment) { |
|||
this.environment = environment; |
|||
this.fileBaseUrl = environment.getProperty("fileBaseUrl"); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> fetchCommunities() { |
|||
String query = "SELECT id,category_name " + |
|||
"FROM social_category_master " + |
|||
"WHERE is_active=1 AND is_delete=0 "; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> fetchMaritalStatus() { |
|||
String query = "SELECT id,marital_status " + |
|||
"FROM marital_status_master " + |
|||
"WHERE is_active=1 AND is_delete=0 "; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> fetchEducationStatus() { |
|||
String query = "SELECT id,education " + |
|||
"FROM education_master " + |
|||
"WHERE is_active=1 AND is_delete=0 "; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
public List<Map<String, Object>> fetchvendingCategory() { |
|||
String query = "SELECT id,vending_category_name " + |
|||
"FROM vending_category_master " + |
|||
"WHERE is_active=1 AND is_delete=0 "; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
|
|||
// public List<Map<String, Object>> fetchZones() { |
|||
// String query = "SELECT id,zone_name " + |
|||
// "FROM zone_master " + |
|||
// "WHERE is_active=1 AND is_delete=0 "; |
|||
// |
|||
// |
|||
// return jdbcTemplate.queryForList(query); |
|||
// } |
|||
|
|||
// public List<Map<String, Object>> fetchWardsByZone(int zoneId) { |
|||
// String sql = "SELECT id, ward_name FROM ward_master WHERE zone_id = ? "; |
|||
// return jdbcTemplate.queryForList(sql, zoneId); |
|||
// } |
|||
|
|||
|
|||
// public String saveStreetVendorDetails(String latitude,String longitude,String zone, String ward, String landmark, String vending_district, |
|||
// int vending_pincode, int vending_category, String vending_space, boolean pm_svanidhi_loan, |
|||
// boolean bank_acc_status, String bankPassbookPath, String streetVendorPhotoPath, String name, |
|||
// String f_h_name, String mobile_number, String dob, String gender, int social_category, boolean diff_abled, |
|||
// int education_status, int marital_status, int no_of_fam_mem, boolean are_any_fam_mem_invol_str, |
|||
// String presentAddress, String present_district, int present_pincode, String rationCardPath, |
|||
// String aadharFrontPhotoPath, String aadharBackPhotoPath,String aadharNo) { |
|||
// |
|||
// |
|||
// |
|||
// String sql = "INSERT INTO vendor_details (" |
|||
// + "latitude,longitude,zone, ward, vending_address,vending_district, vending_pincode, vending_category, vending_space, pm_svanidhi_loan, " |
|||
// + "bank_acc_status, bank_passbook, street_vendor_photo, name, f_h_name, mob_no, " |
|||
// + "dob,gender,social_category, diff_abled, education_status, marital_status,no_of_fam_mem, " |
|||
// + "are_any_fam_mem_invol_str_ven,present_address, present_district, present_pincode, ration_card_photo, aadhar_front_photo, " |
|||
// + "aadhar_back_photo,aadhar_no" |
|||
// + ") VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
// |
|||
// KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
// |
|||
// try { |
|||
// int result = jdbcTemplate.update(connection -> { |
|||
// PreparedStatement ps = connection.prepareStatement(sql, new String[] { "id" }); |
|||
// ps.setString(1, latitude); |
|||
// ps.setString(2, longitude); |
|||
// ps.setString(3, zone); |
|||
// ps.setString(4, ward); |
|||
// ps.setString(5, landmark); |
|||
// ps.setString(6, vending_district); |
|||
// ps.setInt(7, vending_pincode); |
|||
// ps.setInt(8, vending_category); |
|||
// ps.setString(9, vending_space); |
|||
// ps.setBoolean(10, pm_svanidhi_loan); |
|||
// ps.setBoolean(11, bank_acc_status); |
|||
// ps.setString(12, bankPassbookPath); |
|||
// ps.setString(13, streetVendorPhotoPath); |
|||
// ps.setString(14, name); |
|||
// ps.setString(15, f_h_name); |
|||
// ps.setString(16, mobile_number); |
|||
// ps.setString(17, dob); |
|||
// ps.setString(18, gender); |
|||
// ps.setInt(19, social_category); |
|||
// ps.setBoolean(20, diff_abled); |
|||
// ps.setInt(21, education_status); |
|||
// ps.setInt(22, marital_status); |
|||
// ps.setInt(23, no_of_fam_mem); |
|||
// ps.setBoolean(24, are_any_fam_mem_invol_str); |
|||
// ps.setString(25, presentAddress); |
|||
// ps.setString(26, present_district); |
|||
// ps.setInt(27, present_pincode); |
|||
// ps.setString(28, rationCardPath); |
|||
// ps.setString(29, aadharFrontPhotoPath); |
|||
// ps.setString(30, aadharBackPhotoPath); |
|||
// ps.setString(31, aadharNo); |
|||
// return ps; |
|||
// }, keyHolder); |
|||
// //return keyHolder.getKey().intValue(); |
|||
// if (result > 0) { |
|||
// int generatedId = keyHolder.getKey().intValue(); |
|||
// String prefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
|||
// String refId = prefix + generatedId; |
|||
// |
|||
// String updateSql = " UPDATE vendor_details SET vendor_req_id = ? WHERE id = ? "; |
|||
// jdbcTemplate.update(updateSql,refId, generatedId); |
|||
// return refId; |
|||
// } |
|||
// //return "error"; |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// } |
|||
// return "error"; |
|||
// } |
|||
|
|||
|
|||
public String saveStreetVendorDetails(String latitude,String longitude,String zone, String ward, String landmark, String vending_district, |
|||
Integer vending_pincode, Integer vending_category, String vending_space, Boolean pm_svanidhi_loan, |
|||
Boolean bank_acc_status, String bankPassbookPath, String streetVendorPhotoPath, String name, |
|||
String f_h_name, String mobile_number, String dob, String gender, Integer social_category, Boolean diff_abled, |
|||
Integer education_status, Integer marital_status, Integer no_of_fam_mem, Boolean are_any_fam_mem_invol_str, |
|||
String presentAddress, String present_district, Integer present_pincode, String rationCardPath, |
|||
String aadharFrontPhotoPath, String aadharBackPhotoPath,String aadharNo,String userId) { |
|||
|
|||
int isWeb=1; |
|||
String latitudeVal = (latitude != null && !latitude.trim().isEmpty()) ? latitude : null; |
|||
String longitudeVal = (longitude != null && !longitude.trim().isEmpty()) ? longitude : null; |
|||
String zoneVal = (zone != null && !zone.trim().isEmpty()) ? zone : null; |
|||
String wardVal = (ward != null && !ward.trim().isEmpty()) ? ward : null; |
|||
String dobVal = (dob != null && !dob.trim().isEmpty()) ? dob : null; |
|||
String vendingAddressVal = (landmark != null && !landmark.trim().isEmpty()) ? landmark : null; |
|||
|
|||
|
|||
|
|||
String sql = "INSERT INTO vendor_details (" |
|||
+ "latitude,longitude,zone, ward, vending_address,vending_district, vending_pincode, vending_category, vending_space, pm_svanidhi_loan, " |
|||
+ "bank_acc_status, bank_passbook, street_vendor_photo, name, f_h_name, mob_no, " |
|||
+ "dob,gender,social_category, diff_abled, education_status, marital_status,no_of_fam_mem, " |
|||
+ "are_any_fam_mem_invol_str_ven,present_address, present_district, present_pincode, ration_card_photo, aadhar_front_photo, " |
|||
+ "aadhar_back_photo,aadhar_no,is_web,cby" |
|||
+ ") VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?)"; |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
try { |
|||
int result = jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sql, new String[] { "id" }); |
|||
ps.setString(1, latitudeVal); |
|||
ps.setString(2, longitudeVal); |
|||
ps.setString(3, zoneVal); |
|||
ps.setString(4, wardVal); |
|||
ps.setString(5, vendingAddressVal); |
|||
ps.setString(6, vending_district); |
|||
if (vending_pincode != null) ps.setInt(7, vending_pincode); |
|||
else ps.setNull(7, java.sql.Types.INTEGER); |
|||
|
|||
if (vending_category != null) ps.setInt(8, vending_category); |
|||
else ps.setNull(8, java.sql.Types.INTEGER); |
|||
ps.setString(9, vending_space); |
|||
if (pm_svanidhi_loan != null) ps.setBoolean(10, pm_svanidhi_loan); |
|||
else ps.setNull(10, java.sql.Types.BOOLEAN); |
|||
|
|||
if (bank_acc_status != null) ps.setBoolean(11, bank_acc_status); |
|||
else ps.setNull(11, java.sql.Types.BOOLEAN); |
|||
ps.setString(12, bankPassbookPath); |
|||
ps.setString(13, streetVendorPhotoPath); |
|||
ps.setString(14, name); |
|||
ps.setString(15, f_h_name); |
|||
ps.setString(16, mobile_number); |
|||
ps.setString(17, dobVal); |
|||
ps.setString(18, gender); |
|||
if (social_category != null) ps.setInt(19, social_category); |
|||
else ps.setNull(19, java.sql.Types.INTEGER); |
|||
if (diff_abled != null) ps.setBoolean(20, diff_abled); |
|||
else ps.setNull(20, java.sql.Types.BOOLEAN); |
|||
if (education_status != null) ps.setInt(21, education_status); |
|||
else ps.setNull(21, java.sql.Types.INTEGER); |
|||
|
|||
if (marital_status != null) ps.setInt(22, marital_status); |
|||
else ps.setNull(22, java.sql.Types.INTEGER); |
|||
|
|||
if (no_of_fam_mem != null) ps.setInt(23, no_of_fam_mem); |
|||
else ps.setNull(23, java.sql.Types.INTEGER); |
|||
if (are_any_fam_mem_invol_str != null) ps.setBoolean(24, are_any_fam_mem_invol_str); |
|||
else ps.setNull(24, java.sql.Types.BOOLEAN); |
|||
ps.setString(25, presentAddress); |
|||
ps.setString(26, present_district); |
|||
if (present_pincode != null) ps.setInt(27, present_pincode); |
|||
else ps.setNull(27, java.sql.Types.INTEGER); |
|||
ps.setString(28, rationCardPath); |
|||
ps.setString(29, aadharFrontPhotoPath); |
|||
ps.setString(30, aadharBackPhotoPath); |
|||
ps.setString(31, aadharNo); |
|||
ps.setInt(32, isWeb); |
|||
ps.setString(33, userId); |
|||
return ps; |
|||
}, keyHolder); |
|||
//return keyHolder.getKey().intValue(); |
|||
if (result > 0) { |
|||
int generatedId = keyHolder.getKey().intValue(); |
|||
String prefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
|||
String refId = prefix + generatedId; |
|||
|
|||
String updateSql = " UPDATE vendor_details SET vendor_req_id = ? WHERE id = ? "; |
|||
jdbcTemplate.update(updateSql,refId, generatedId); |
|||
return refId; |
|||
} |
|||
//return "error"; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return "error"; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public String fileUpload(MultipartFile file, String name) { |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory.mobile"); |
|||
String serviceFolderName = environment.getProperty("street_vendor_foldername"); |
|||
var year = DateTimeUtil.getCurrentYear(); |
|||
var month = DateTimeUtil.getCurrentMonth(); |
|||
|
|||
uploadDirectory = uploadDirectory + serviceFolderName + "/" + year + "/" + month; |
|||
|
|||
try { |
|||
// Create directory if it doesn't exist |
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
// Datetime string |
|||
String datetimetxt = DateTimeUtil.getCurrentDateTime(); |
|||
|
|||
// File name |
|||
String fileName = name + "_" + datetimetxt + "_" + file.getOriginalFilename(); |
|||
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename |
|||
|
|||
String filePath = uploadDirectory + "/" + fileName; |
|||
|
|||
String filepath_txt = "/" + serviceFolderName + "/" + year + "/" + month + "/" + fileName; |
|||
|
|||
// Create a new Path object |
|||
Path path = Paths.get(filePath); |
|||
|
|||
// Get the bytes of the file |
|||
byte[] bytes = file.getBytes(); |
|||
|
|||
/* |
|||
* // Compress the image BufferedImage image = ImageIO.read(new |
|||
* ByteArrayInputStream(bytes)); byte[] compressedBytes = compressImage(image, |
|||
* 0.5f); // Compress with 50% quality |
|||
* |
|||
* // Write the bytes to the file |
|||
* Files.write(path, compressedBytes); |
|||
*/ |
|||
|
|||
Files.write(path, bytes); |
|||
|
|||
System.out.println(filePath); |
|||
return filepath_txt; |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save file " + file.getOriginalFilename(); |
|||
} |
|||
} |
|||
|
|||
|
|||
private byte[] compressImage(BufferedImage image, float quality) throws IOException { |
|||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
|||
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream); |
|||
|
|||
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); |
|||
writer.setOutput(imageOutputStream); |
|||
|
|||
ImageWriteParam param = writer.getDefaultWriteParam(); |
|||
if (param.canWriteCompressed()) { |
|||
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
|||
param.setCompressionQuality(quality); |
|||
} |
|||
|
|||
writer.write(null, new javax.imageio.IIOImage(image, null, null), param); |
|||
|
|||
writer.dispose(); |
|||
imageOutputStream.close(); |
|||
|
|||
return byteArrayOutputStream.toByteArray(); |
|||
} |
|||
|
|||
|
|||
public static String generateRandomString() { |
|||
StringBuilder result = new StringBuilder(STRING_LENGTH); |
|||
for (int i = 0; i < STRING_LENGTH; i++) { |
|||
result.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); |
|||
} |
|||
return result.toString(); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public boolean isMobileRegistered(String mobilenumber) { |
|||
String sql = "SELECT COUNT(*) FROM vendor_details WHERE mob_no = ?"; |
|||
Integer count = jdbcTemplate.queryForObject(sql, new Object[]{mobilenumber}, Integer.class); |
|||
return count != null && count > 0; |
|||
} |
|||
|
|||
public List<Map<String, Object>> getCommiteeDetailsWeb(String cby) { |
|||
String sql = "SELECT * " |
|||
+ "FROM vendor_details " |
|||
+ "WHERE is_web=1 AND cby=?"; |
|||
return jdbcTemplate.queryForList(sql, cby); |
|||
|
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getwebVendorDetailsByReqId(String requestId) { |
|||
|
|||
String sql="SELECT vd.*,em.education as education_name,mm.marital_status as marital_name,scm.category_name as category_name,vcm.vending_category_name as vending_category_name, "+ |
|||
"CONCAT(vd.present_address,',',vd.present_district) as residental_address, CONCAT(vd.vending_address,',',vending_district) as business_address, "+ |
|||
"CONCAT('" + fileBaseUrl + "/gccofficialapp/files', vd.bank_passbook) AS view_bank_passbook, " + |
|||
"CONCAT('" + fileBaseUrl + "/gccofficialapp/files', vd.ration_card_photo) AS view_ration_card_photo, " + |
|||
"CONCAT('" + fileBaseUrl + "/gccofficialapp/files', vd.street_vendor_photo) AS view_street_vendor_photo, " + |
|||
"CONCAT('" + fileBaseUrl + "/gccofficialapp/files', vd.aadhar_front_photo) AS view_aadhar_front_photo, " + |
|||
"CONCAT('" + fileBaseUrl + "/gccofficialapp/files', vd.aadhar_back_photo) AS view_aadhar_back_photo " + |
|||
"FROM vendor_details vd " |
|||
+ "LEFT JOIN social_category_master scm on vd.social_category = scm.id " |
|||
+ "LEFT JOIN vending_category_master vcm ON vd.vending_category=vcm.id " |
|||
+ "LEFT JOIN education_master em on vd.education_status = em.id " |
|||
+ "LEFT JOIN marital_status_master mm on vd.marital_status = mm.id " |
|||
+ "WHERE vd.vendor_req_id = ?"; |
|||
|
|||
return jdbcTemplate.queryForList(sql,requestId); |
|||
} |
|||
|
|||
|
|||
public String updateStreetVendorDetailsWeb(String latitude, String longitude, String zone, String ward, |
|||
String landmark, String vending_district, Integer vending_pincode, Integer vending_category, |
|||
String vending_space, Boolean pm_svanidhi_loan, Boolean bank_acc_status, String bankPassbookPath, |
|||
String streetVendorPhotoPath, String name, String f_h_name, String mobile_number, String dob, String gender, |
|||
Integer social_category, Boolean diff_abled, Integer education_status, Integer marital_status, |
|||
Integer no_of_fam_mem, Boolean are_any_fam_mem_invol_str, String presentAddress, String present_district, |
|||
Integer present_pincode, String rationCardPath, String aadharFrontPhotoPath, String aadharBackPhotoPath, |
|||
String aadharNo, String userId, String vendor_req_id) { |
|||
|
|||
|
|||
String latitudeVal = (latitude != null && !latitude.trim().isEmpty()) ? latitude : null; |
|||
String longitudeVal = (longitude != null && !longitude.trim().isEmpty()) ? longitude : null; |
|||
String zoneVal = (zone != null && !zone.trim().isEmpty()) ? zone : null; |
|||
String wardVal = (ward != null && !ward.trim().isEmpty()) ? ward : null; |
|||
String dobVal = (dob != null && !dob.trim().isEmpty()) ? dob : null; |
|||
String vendingAddressVal = (landmark != null && !landmark.trim().isEmpty()) ? landmark : null; |
|||
|
|||
String sql="UPDATE vendor_details SET " |
|||
+ "latitude =?,longitude=?,zone=?, ward=?, vending_address=?,vending_district=?, vending_pincode=?, vending_category=?, vending_space=?, pm_svanidhi_loan=?, " |
|||
+ "bank_acc_status=?, bank_passbook=?, street_vendor_photo=?, name=?, f_h_name=?, mob_no=?, " |
|||
+ "dob=?,gender=?,social_category=?, diff_abled=?, education_status=?, marital_status=?,no_of_fam_mem=?, " |
|||
+ "are_any_fam_mem_invol_str_ven=?,present_address=?, present_district=?, present_pincode=?, ration_card_photo=?, aadhar_front_photo=?, " |
|||
+ "aadhar_back_photo=?,aadhar_no=?,updated_date=NOW() " |
|||
+ " WHERE vendor_req_id = ? AND is_web=1 AND editable=1"; |
|||
try { |
|||
int rows=jdbcTemplate.update(sql, latitudeVal, longitudeVal, zoneVal, wardVal, vendingAddressVal, vending_district, |
|||
vending_pincode, vending_category, vending_space, pm_svanidhi_loan, bank_acc_status, bankPassbookPath, |
|||
streetVendorPhotoPath, name, f_h_name, mobile_number, dobVal, gender, social_category, diff_abled, |
|||
education_status, marital_status, no_of_fam_mem, are_any_fam_mem_invol_str, presentAddress, |
|||
present_district, present_pincode, rationCardPath, aadharFrontPhotoPath, aadharBackPhotoPath, aadharNo, |
|||
vendor_req_id); |
|||
|
|||
if (rows==1) { |
|||
return "Success"; |
|||
} |
|||
else { |
|||
return "Error"; |
|||
} |
|||
} |
|||
catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return "error"; |
|||
} |
|||
|
|||
|
|||
public String logEntry(String userId, String vendor_req_id) { |
|||
String sql="INSERT INTO vendor_details_web_log (name,f_h_name,gender,dob,social_category,diff_abled,mob_no,aadhar_no,present_address,present_district,present_pincode,vending_address,vending_district,vending_pincode,vending_category,vending_space,bank_acc_status,bank_passbook,ration_card_photo,street_vendor_photo,aadhar_front_photo,aadhar_back_photo,zone,ward,pm_svanidhi_loan,vendor_req_id,education_status,marital_status,no_of_fam_mem,are_any_fam_mem_invol_str_ven,latitude,longitude,cby) " |
|||
+ " SELECT name,f_h_name,gender,dob,social_category,diff_abled,mob_no,aadhar_no,present_address,present_district,present_pincode,vending_address,vending_district,vending_pincode,vending_category,vending_space,bank_acc_status,bank_passbook,ration_card_photo,street_vendor_photo,aadhar_front_photo,aadhar_back_photo,zone,ward,pm_svanidhi_loan,vendor_req_id,education_status,marital_status,no_of_fam_mem,are_any_fam_mem_invol_str_ven,latitude,longitude,? FROM vendor_details WHERE vendor_req_id=?"; |
|||
|
|||
try { |
|||
jdbcTemplate.update(sql, userId,vendor_req_id); |
|||
return "success"; |
|||
|
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return "failure"; |
|||
|
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,167 @@ |
|||
package in.gov.chennaicorporation.gccoffice.vendor.service; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.Statement; |
|||
import java.time.LocalDate; |
|||
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.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class createventService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlVendingCommitteDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public boolean isFileExists(String originalFilename) { |
|||
String sql = "SELECT COUNT(*) FROM vendingcommitte.create_event " + |
|||
"WHERE file_url LIKE ?"; |
|||
String filenamePattern = "%" + originalFilename; // Match filename at the end of the path |
|||
Integer count = jdbcTemplate.queryForObject(sql, Integer.class, filenamePattern); |
|||
return count != null && count > 0; |
|||
} |
|||
|
|||
public void insertEvent(String eventName, LocalDate eventDate, String fileUrl) { |
|||
String sql = "INSERT INTO vendingcommitte.create_event (event_name, event_date, file_url) VALUES (?, ?, ?)"; |
|||
jdbcTemplate.update(sql, eventName, eventDate, fileUrl); |
|||
} |
|||
|
|||
//SELECT * FROM vendingcommitte.create_event |
|||
public List<Map<String, Object>> ViewDropdownEvent() { |
|||
String sql = "SELECT * FROM create_event"; |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
public List<Map<String, Object>> ViewCommitteeDropdownEvent() { |
|||
String sql = "SELECT distinct rl.event_req_id as event_req_id,ce.event_name as event_name,ce.event_date as event_date " |
|||
+ "FROM vendor_request_list rl " |
|||
+ "JOIN create_event ce ON ce.req_id=rl.event_req_id"; |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
public ResponseEntity<Map<String, Object>> saveVendorDetails(Map<String, Object> payload) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
String vendor_req_id = (String) payload.get("vendor_req_id"); |
|||
String name = (String) payload.get("name"); |
|||
String mob_no= (String) payload.get("mob_no"); |
|||
String business_address= (String) payload.get("business_address"); |
|||
String vending_pincode= (String) payload.get("vending_pincode"); |
|||
String status = (String) payload.get("status"); |
|||
final String remarks = (payload.get("remarks") == null || ((String) payload.get("remarks")).trim().isEmpty()) |
|||
? "-" |
|||
: (String) payload.get("remarks"); |
|||
int event_req_id = Integer.parseInt((String) payload.get("event_req_id")); |
|||
|
|||
//System.out.println("values="+vendor_req_id+name+mob_no+business_address+vending_pincode+status+remarks+event_req_id); |
|||
|
|||
String sql = "INSERT INTO vendor_request_list (request_no,person_name, mobile_no, address, status, remarks, pincode,event_req_id) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
try { |
|||
int rows = jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sql); |
|||
ps.setString(1, vendor_req_id); |
|||
ps.setString(2, name); |
|||
ps.setString(3, mob_no); |
|||
ps.setString(4, business_address); |
|||
ps.setString(5, status); |
|||
ps.setString(6, remarks); |
|||
ps.setString(7, vending_pincode); |
|||
ps.setInt(8, event_req_id); |
|||
return ps; |
|||
}); |
|||
|
|||
|
|||
if(rows > 0) { |
|||
String result=sendWhatsappMsg(mob_no,status,vendor_req_id); |
|||
|
|||
if("200".equalsIgnoreCase(result)) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Data submitted successfully!"); |
|||
|
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("message", "Data Submitted But Whatsapp Message not Sent"); |
|||
|
|||
} |
|||
} |
|||
else { |
|||
response.put("status", "Error"); |
|||
response.put("message", "Error in saving Vendor Details"); |
|||
} |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log the exception |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Map.of("status", "Error", "message", "Error fetching to save vendor details: " + e.getMessage())); |
|||
} |
|||
} |
|||
|
|||
private String sendWhatsappMsg(String mob_no, String status,String vendor_req_id) { |
|||
String urlString=""; |
|||
|
|||
if("Approved".equals(status)) { |
|||
urlString="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+mob_no+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=You+are+recognized+as+a+roadside+vendor.+Registration+number%3A+"+vendor_req_id+".&isTemplate=true&footer=GCC+-+IT+Cell"; |
|||
} |
|||
else { |
|||
urlString="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+mob_no+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+application+is+rejected+because+your+roadside+vendor+details+are+incorrect.+%0A%0ARegistration+Number%3A+"+vendor_req_id+"."; |
|||
} |
|||
|
|||
String res=hitURL(urlString); |
|||
return res; |
|||
} |
|||
|
|||
private String hitURL(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(); |
|||
} |
|||
System.out.println("response="+response); |
|||
return response; |
|||
} |
|||
|
|||
public List<Map<String, Object>> getCommiteeDetails(String event_req_id) { |
|||
String sql = "SELECT * " |
|||
+ "FROM vendor_request_list " |
|||
+ "WHERE event_req_id=? "; |
|||
return jdbcTemplate.queryForList(sql,event_req_id); |
|||
} |
|||
|
|||
public List<String> removeSavedVendorDetails() { |
|||
|
|||
String sql="SELECT request_no FROM vendor_request_list"; |
|||
|
|||
return jdbcTemplate.queryForList(sql,String.class); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,692 +0,0 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head th:replace="~{fragments/modules/base/head :: head}"> |
|||
<style> |
|||
|
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="wrapper"> |
|||
<!-- Header --> |
|||
<header th:replace="~{fragments/modules/base/header :: header}"></header> |
|||
|
|||
<div class="page-wrap"> |
|||
<!-- Left Menu --> |
|||
<div th:replace="~{fragments/modules/base/menu :: menu}"></div> |
|||
|
|||
<div class="main-content"> |
|||
<div class="container-fluid"> |
|||
<div class="page-header"> |
|||
<div class="row align-items-end"> |
|||
<div class="col-lg-8"> |
|||
<div class="page-header-title"> |
|||
<i class="fas fa-user-graduate bg-blue"></i> |
|||
<div class="d-inline"> |
|||
<h5>Assign Agents</h5> |
|||
<span>1913 Assign agents for Campaign</span> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="col-lg-4"> |
|||
<nav class="breadcrumb-container" aria-label="breadcrumb"> |
|||
<ol class="breadcrumb"> |
|||
<li class="breadcrumb-item"> |
|||
<a href="/index"><i class="ik ik-home"></i></a> |
|||
</li> |
|||
<li class="breadcrumb-item">1913 Campaign</li> |
|||
<li class="breadcrumb-item active" aria-current="page">Assign Agents</li> |
|||
</ol> |
|||
</nav> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<hr> |
|||
|
|||
|
|||
|
|||
<!-- Card for Agent Assignment --> |
|||
<div class="card"> |
|||
<div class="card-header"> |
|||
<h3>Agent Assign</h3> |
|||
</div> |
|||
<div class="card-body"> |
|||
|
|||
<!-- Dropdown for Category --> |
|||
<div class="row"> |
|||
<div class="form-group col-md-6 col-sm-12"> |
|||
<label for="category">Category</label> |
|||
<select id="category" class="form-control"> |
|||
|
|||
</select> |
|||
</div> |
|||
|
|||
<!-- Dropdown for Campaigns --> |
|||
<div class="form-group col-md-6 col-sm-12"> |
|||
<label for="campaign">Campaign</label> |
|||
<select id="campaign" class="form-control" disabled> |
|||
</select> |
|||
</div> |
|||
|
|||
|
|||
<div class="form-group col-12 d-flex justify-content-center align-items-center"> |
|||
<!-- Centered button between the dropdowns --> |
|||
<button id="searchBtn" class="btn btn-primary">Search</button> |
|||
<button id="resetBtn" class="btn btn-secondary ml-3">Reset</button> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
<!-- Card for Campaign Details --> |
|||
<div class="card mt-3" id="campaignDetailsCard" style="display:none;"> |
|||
<div class="card-header"> |
|||
<h3>Campaign Details</h3> |
|||
</div> |
|||
|
|||
|
|||
<div class="card-body"> |
|||
|
|||
<table class="table table-bordered"> |
|||
<tbody> |
|||
<tr> |
|||
<th >Name</th> |
|||
<td class="fw-semibold" id="campaignName" style="padding: 0.45rem 0.45rem;"></td> |
|||
</tr> |
|||
<tr> |
|||
<th>From Date</th> |
|||
<td class="fw-semibold" id="campaignStartdate" style="padding: 0.45rem 0.45rem;"></td> |
|||
</tr> |
|||
<tr> |
|||
<th>To Date</th> |
|||
<td class="fw-semibold" id="campaignEnddate" style="padding: 0.45rem 0.45rem;"></td> |
|||
</tr> |
|||
<tr> |
|||
<th>Agents Assigned</th> |
|||
<td class="fw-semibold" id="campaignAgents" style="padding: 0.45rem 0.45rem;"></td> |
|||
</tr> |
|||
<tr> |
|||
<th>Calls Assigned (per person)</th> |
|||
<td class="fw-semibold" id="campaignCalls" style="padding: 0.45rem 0.45rem;"></td> |
|||
</tr> |
|||
<tr> |
|||
<th>Description</th> |
|||
<td class="fw-semibold" id="campaignDesc" style="padding: 0.45rem 0.45rem;"></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<div class="row" id="editagentCard" style="display:none;"> |
|||
<div class="col-md-12"> |
|||
<div class="card"> |
|||
|
|||
<div class="card-block"> |
|||
<div class="page-header-title" > |
|||
<h5 style="margin: 0;font-weight: bold;">Selected Agent List</h5><hr> |
|||
</div> |
|||
<table id="editagentsDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid" > |
|||
<thead class="thead-dark"> |
|||
<tr role="row"> |
|||
<th class="text-center no-sort" width="1%">S.No</th> |
|||
<th class="text-center">Agent Id</th> |
|||
<th class="text-center">Name of Agents</th> |
|||
<th class="text-center">Select/Not Selected</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody id="editagentList" style="text-align:center;"> |
|||
<!-- Rows will be dynamically inserted here --> |
|||
</tbody> |
|||
</table> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
|
|||
<div class="row" id="agentCard" style="display:none;"> |
|||
<div class="col-md-12"> |
|||
<div class="card"> |
|||
|
|||
<div class="card-block"> |
|||
<div class="page-header-title" > |
|||
<h5 style="margin: 0;font-weight: bold;">Overall Agent List</h5><hr> |
|||
</div> |
|||
<div class=" d-flex justify-content-end mb-2"> |
|||
|
|||
<button class="btn btn-primary" id="selectedCount"><i class="ik ik-user-plus f-16 mr-2"></i>0</button> |
|||
<!-- <button class="btn btn-warning ml-2" id="editAgentsBtn"><i class="ik ik-edit f-16 mr-2"></i>Edit</button> --> |
|||
|
|||
</div> |
|||
|
|||
<table id="agentsDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid" > |
|||
<thead class="thead-dark"> |
|||
<tr role="row"> |
|||
<th class="text-center no-sort" width="1%">S.No</th> |
|||
<th class="text-center">Agent Id</th> |
|||
<th class="text-center">Name of Agents</th> |
|||
<th class="text-center"><input type="checkbox" id="selectAllAgents"> Select All</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody id="agentList" style="text-align:center;"> |
|||
<!-- Rows will be dynamically inserted here --> |
|||
</tbody> |
|||
</table> |
|||
<!-- Center the Submit button --> |
|||
<div class="text-center"> |
|||
<button type="submit" class="btn btn-primary" id="submitBtn">Submit</button> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<!-- Include jQuery and Bootstrap JavaScript --> |
|||
|
|||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> |
|||
|
|||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> |
|||
|
|||
<script th:replace="~{fragments/modules/base/script :: script}"></script> |
|||
<!-- sweet alert --> |
|||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> |
|||
<script type="text/javascript"> |
|||
|
|||
// Fetch category dropdown on page load |
|||
fetchCategoryDropdown(); |
|||
|
|||
// Handle category change event to fetch campaigns |
|||
$(document).on('change', '#category', function() { |
|||
let selectedCategoryId = $(this).val(); |
|||
if (selectedCategoryId != '0') { |
|||
fetchCampaignDropdown(selectedCategoryId); |
|||
} else { |
|||
$('#campaign').empty().prop('disabled', true); |
|||
} |
|||
}); |
|||
|
|||
|
|||
|
|||
$("#searchBtn").click(function () { |
|||
let selectedCampaignId = $('#campaign').val(); |
|||
|
|||
|
|||
if(selectedCampaignId == null || selectedCampaignId=='0'){ |
|||
Swal.fire({ |
|||
title: 'Info!', |
|||
text: 'Please Select Category and Campaign!', |
|||
icon: 'info', |
|||
timer: 2000, |
|||
//timerProgressBar: true, |
|||
showConfirmButton: false |
|||
}) |
|||
hideCampaignAndAgentDetails(); |
|||
} |
|||
else if (selectedCampaignId != '0') { |
|||
fetchCampaignDetails(selectedCampaignId); |
|||
checkCampaignInAssigned(selectedCampaignId); |
|||
|
|||
// Disable the category and campaign dropdowns after search |
|||
$('#category').prop('disabled', true); |
|||
$('#campaign').prop('disabled', true); |
|||
} |
|||
else { |
|||
|
|||
hideCampaignAndAgentDetails(); |
|||
|
|||
} |
|||
}); |
|||
|
|||
|
|||
|
|||
//Approve button click event |
|||
$("#submitBtn").click(function () { |
|||
handleSubmit(); |
|||
}); |
|||
|
|||
$("#resetBtn").click(function () { |
|||
location.reload(); // Reloads the current page |
|||
}); |
|||
|
|||
|
|||
// Initial binding for checkbox events |
|||
bindCheckboxEvents(); |
|||
|
|||
// Function to fetch category dropdown |
|||
function fetchCategoryDropdown() { |
|||
$.ajax({ |
|||
url: '/gcc/api/callcenter/admin/getcategory', |
|||
type: 'GET', |
|||
dataType: 'json' |
|||
}) |
|||
.done(function (data) { |
|||
let categoryDropdown = $('#category'); |
|||
categoryDropdown.empty(); |
|||
categoryDropdown.append($('<option selected value="0"></option>').text('Select a category')); |
|||
$.each(data, function (index, category) { |
|||
categoryDropdown.append($('<option></option>').attr('value', category.category_id).text(category.category_name)); |
|||
}); |
|||
}) |
|||
.fail(function (xhr, status, error) { |
|||
console.error('Error fetching category:', error); |
|||
}); |
|||
} |
|||
|
|||
// Function to fetch campaigns based on selected category |
|||
function fetchCampaignDropdown(categoryId) { |
|||
$('#campaign').prop('disabled', false); |
|||
$.ajax({ |
|||
url: '/gcc/api/callcenter/admin/getcampaignbycategory?id=' + categoryId, |
|||
type: 'GET', |
|||
dataType: 'json' |
|||
}) |
|||
.done(function (data) { |
|||
let campaignDropdown = $('#campaign'); |
|||
campaignDropdown.empty(); |
|||
campaignDropdown.append($('<option selected value="0"></option>').text('Select a campaign')); |
|||
$.each(data, function (index, campaign) { |
|||
campaignDropdown.append($('<option></option>').attr('value', campaign.campaign_id).text(campaign.campaign_name)); |
|||
}); |
|||
}) |
|||
.fail(function (xhr, status, error) { |
|||
console.error('Error fetching campaign:', error); |
|||
}); |
|||
} |
|||
|
|||
// Function to fetch campaign details |
|||
function fetchCampaignDetails(campaignId) { |
|||
$.ajax({ |
|||
url: '/gcc/api/callcenter/admin/getcampaignbyid?id=' + campaignId, |
|||
method: 'GET', |
|||
dataType: 'json', |
|||
success: function (response) { |
|||
if (response.length === 0) { |
|||
console.error("No campaign details found."); |
|||
return; |
|||
} |
|||
|
|||
document.getElementById("campaignName").innerHTML = response[0].campaign_name; |
|||
document.getElementById("campaignStartdate").innerHTML = response[0].start_date; |
|||
document.getElementById("campaignEnddate").innerHTML = response[0].end_date; |
|||
document.getElementById("campaignAgents").innerHTML = response[0].no_of_agents; |
|||
document.getElementById("campaignCalls").innerHTML = response[0].calls_per_agent; |
|||
document.getElementById("campaignDesc").innerHTML = response[0].description; |
|||
|
|||
// Show the campaign details card |
|||
document.getElementById('campaignDetailsCard').style.display = 'block'; |
|||
}, |
|||
error: function () { |
|||
console.error("An error occurred while fetching campaign details."); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
// Function to check if campaign is already assigned and fetch agents |
|||
function checkCampaignInAssigned(selectedCampaignId) { |
|||
|
|||
$.ajax({ |
|||
url: '/gcc/api/callcenter/admin/getassignedcampaign?id=' + selectedCampaignId, |
|||
type: 'GET', |
|||
dataType: 'json', |
|||
success: function(response) { |
|||
//console.log('checkCampaignInAssigned response:', response); |
|||
fetchAgentsForCampaign(selectedCampaignId); // Always fetch agents |
|||
|
|||
if (response.length > 0) { |
|||
populateEditAgentList(response); |
|||
document.getElementById('editagentCard').style.display = 'block'; |
|||
initializeEditAgentsDataTable(); |
|||
} |
|||
else{ |
|||
document.getElementById('editagentCard').style.display = 'none'; |
|||
} |
|||
}, |
|||
error: function(xhr, status, error) { |
|||
console.error('Error fetching assigned agents:', error); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
// Function to populate the edit agent list |
|||
function populateEditAgentList(agents) { |
|||
let editagentList = $('#editagentList'); |
|||
editagentList.empty(); |
|||
|
|||
$.each(agents, function(index, agent) { |
|||
|
|||
|
|||
let row = ` |
|||
<tr data-assigned-id="${agent.assigned_id}"> |
|||
<td>${index + 1}</td> |
|||
<td>${agent.agent_id}</td> |
|||
<td>${agent.agent_name}</td> |
|||
<td> |
|||
<button class="btn btn-warning" onclick="editagent(${agent.assigned_id})">Remove</button> |
|||
</td> |
|||
</tr> |
|||
`; |
|||
// Log the row HTML to debug |
|||
// console.log('Appending row:', row); |
|||
|
|||
editagentList.append(row); |
|||
}); |
|||
} |
|||
|
|||
function editagent(assignedId) { |
|||
|
|||
$.ajax({ |
|||
url: '/gcc/api/callcenter/admin/deleteassignedbyid?id=' + assignedId, |
|||
type: 'GET', |
|||
dataType: 'json', |
|||
success: function(response) { |
|||
$('tr[data-assigned-id="' + assignedId + '"]').remove(); |
|||
Swal.fire({ |
|||
title: 'Success!', |
|||
text: 'Agents have been removed!', |
|||
icon: 'success', |
|||
timer: 2000, |
|||
//timerProgressBar: true, |
|||
showConfirmButton: false |
|||
}) |
|||
}, |
|||
error: function(xhr, status, error) { |
|||
console.error('Error removing agents:', error); |
|||
reject(error); // Reject the promise in case of an error |
|||
} |
|||
}); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
// Function to fetch agents for the selected campaign |
|||
function fetchAgentsForCampaign(campaignId) { |
|||
$.ajax({ |
|||
url: '/gcc/api/callcenter/admin/getagentsfortask?id=' +campaignId, |
|||
type: 'GET', |
|||
dataType: 'json', |
|||
success: function(response) { |
|||
let agentList = $('#agentList'); |
|||
agentList.empty(); |
|||
|
|||
if (response.length > 0) { |
|||
$.each(response, function(index, agent) { |
|||
let row = ` |
|||
<tr> |
|||
<td>${index + 1}</td> |
|||
<td>${agent.agent_id}</td> |
|||
<td>${agent.agent_name}</td> |
|||
<td><input type="checkbox" class="agentCheckbox" value="${agent.agent_id}"></td> |
|||
</tr> |
|||
`; |
|||
agentList.append(row); |
|||
}); |
|||
|
|||
document.getElementById('agentCard').style.display = 'block'; |
|||
initializeAgentsDataTable(); |
|||
} else { |
|||
agentList.append('<tr><td colspan="4">No agents available</td></tr>'); |
|||
} |
|||
|
|||
bindCheckboxEvents(); // Rebind checkbox events after adding new checkboxes |
|||
}, |
|||
error: function(xhr, status, error) { |
|||
console.error('Error fetching agents:', error); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
// Function to hide campaign and agent details |
|||
function hideCampaignAndAgentDetails() { |
|||
document.getElementById('campaignDetailsCard').style.display = 'none'; |
|||
document.getElementById('agentCard').style.display = 'none'; |
|||
document.getElementById('editagentCard').style.display = 'none'; |
|||
} |
|||
|
|||
// Function to bind checkbox events and handle "Select All" functionality |
|||
function bindCheckboxEvents() { |
|||
$('#selectAllAgents').on('click', function() { |
|||
let campaignAgentsCount = parseInt($('#campaignAgents').text(), 10); |
|||
let totalCheckboxes = $('.agentCheckbox').length; |
|||
|
|||
if ($(this).is(':checked')) { |
|||
if (campaignAgentsCount > totalCheckboxes) { |
|||
Swal.fire({ |
|||
title: 'Sorry!', |
|||
text: 'You cannot select more checkboxes than available.', |
|||
icon: 'error', |
|||
timer: 2000 |
|||
}).then(() => { |
|||
$('#selectAllAgents').prop('checked', false); |
|||
}); |
|||
} else { |
|||
let checkboxes = $('.agentCheckbox'); |
|||
checkboxes.prop('checked', false); |
|||
for (let i = 0; i < campaignAgentsCount; i++) { |
|||
if (checkboxes[i]) { |
|||
$(checkboxes[i]).prop('checked', true); |
|||
} |
|||
} |
|||
} |
|||
} else { |
|||
$('.agentCheckbox').prop('checked', false); |
|||
} |
|||
|
|||
updateSelectedCount(); |
|||
}); |
|||
|
|||
$(document).on('change', '.agentCheckbox', function () { |
|||
if ($('.agentCheckbox:checked').length === $('.agentCheckbox').length) { |
|||
$('#selectAllAgents').prop('checked', true); |
|||
} else { |
|||
$('#selectAllAgents').prop('checked', false); |
|||
} |
|||
|
|||
updateSelectedCount(); |
|||
}); |
|||
} |
|||
|
|||
// Function to update the selected count |
|||
function updateSelectedCount() { |
|||
let selectedCount = $('.agentCheckbox:checked').length; |
|||
$('#selectedCount').html('<i class="ik ik-user-plus f-16 mr-2"></i>' + selectedCount); |
|||
} |
|||
|
|||
// Function to handle form submission and assign agents |
|||
function handleSubmit() { |
|||
|
|||
let selectedCategoryId = $('#category').val(); |
|||
let selectedCampaignId = $('#campaign').val(); |
|||
let campaignAgentsCount = parseInt($('#campaignAgents').text(), 10); // Get the required agent count |
|||
let assignedAgentCount = $('#editagentList tr').length; // Count already assigned agents |
|||
|
|||
// Ensure category and campaign are selected |
|||
if (selectedCategoryId == 0 || selectedCampaignId == 0) { |
|||
Swal.fire({ |
|||
title: 'Info!', |
|||
text: 'Please select a category and campaign before proceeding.', |
|||
icon: 'info', |
|||
timer: 2000, |
|||
timerProgressBar: true |
|||
}); |
|||
return; |
|||
} |
|||
|
|||
let selectedAgentsCount = $(".agentCheckbox:checked").length; // Count of selected checkboxes |
|||
|
|||
// Total agent count (new selections + already assigned) |
|||
let totalSelectedCount = selectedAgentsCount + assignedAgentCount; |
|||
|
|||
// Validation: Check if total selected count matches the campaignAgentsCount |
|||
if (totalSelectedCount < campaignAgentsCount) { |
|||
Swal.fire({ |
|||
title: 'Error!', |
|||
text: `You need to select ${campaignAgentsCount - totalSelectedCount} more agents to meet the required count.`, |
|||
icon: 'error', |
|||
timer: 3000, |
|||
timerProgressBar: true |
|||
}); |
|||
return; |
|||
} else if (totalSelectedCount > campaignAgentsCount) { |
|||
Swal.fire({ |
|||
title: 'Error!', |
|||
text: `You have selected more agents than allowed. Please reduce the number of selected agents.`, |
|||
icon: 'error', |
|||
timer: 3000, |
|||
timerProgressBar: true |
|||
}); |
|||
return; |
|||
} |
|||
|
|||
let requestData = []; |
|||
$(".agentCheckbox:checked").each(function () { |
|||
requestData.push({ |
|||
categoryId: parseInt(selectedCategoryId), |
|||
campaignId: parseInt(selectedCampaignId), |
|||
agentId: parseInt($(this).val()) |
|||
}); |
|||
}); |
|||
|
|||
if (requestData.length === 0) { |
|||
Swal.fire({ |
|||
title: 'Info!', |
|||
text: 'Please select at least one agent to assign.', |
|||
icon: 'info', |
|||
timer: 3000, |
|||
timerProgressBar: true |
|||
}); |
|||
return; |
|||
} |
|||
|
|||
// AJAX request to submit the data |
|||
$.ajax({ |
|||
url: "/gcc/api/callcenter/admin/addagentsfortask", |
|||
type: "POST", |
|||
contentType: "application/json", |
|||
data: JSON.stringify(requestData), |
|||
success: function (response) { |
|||
Swal.fire({ |
|||
title: 'Success!', |
|||
text: 'Agents have been successfully assigned!', |
|||
icon: 'success', |
|||
timer: 2000, |
|||
timerProgressBar: true, |
|||
showConfirmButton: false |
|||
}).then(() => { |
|||
location.reload(); // Reload after success |
|||
}); |
|||
}, |
|||
error: function (xhr, status, error) { |
|||
Swal.fire({ |
|||
title: 'Error!', |
|||
text: 'There was an error while assigning agents.', |
|||
icon: 'error', |
|||
timer: 3000, |
|||
timerProgressBar: true |
|||
}); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
//Initialize the first table: agentsDatatable |
|||
function initializeAgentsDataTable() { |
|||
if (!$.fn.DataTable.isDataTable('#agentsDatatable')) { |
|||
$('#agentsDatatable').DataTable({ |
|||
dom: 'Bftip', |
|||
columnDefs: [{ targets: 'no-sort', orderable: false }], |
|||
lengthMenu: [ |
|||
[50, 100, 200, 500, -1], |
|||
['50 rows', '100 rows', '200 rows', '500 rows', 'Show all'] |
|||
], |
|||
scrollY: '30vh', |
|||
fixedColumns: { left: 1, right: 1 }, |
|||
buttons: [ |
|||
{ extend: 'pageLength', className: 'btn btn-warning' }, |
|||
{ extend: 'copyHtml5', text: 'Copy', className: 'btn btn-secondary' }, |
|||
{ extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary' }, |
|||
{ extend: 'csvHtml5', text: 'CSV', className: 'btn btn-secondary' }, |
|||
{ extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-secondary' } |
|||
], |
|||
fixedHeader: true, |
|||
autoWidth: true, |
|||
responsive: true, |
|||
searching: true, |
|||
select: false, |
|||
processing: false |
|||
}); |
|||
} else { |
|||
$('#agentsDatatable').DataTable().clear().draw(); |
|||
} |
|||
} |
|||
|
|||
// Initialize the second table: editagentsDatatable |
|||
function initializeEditAgentsDataTable() { |
|||
if (!$.fn.DataTable.isDataTable('#editagentsDatatable')) { |
|||
$('#editagentsDatatable').DataTable({ |
|||
dom: 'Bftip', |
|||
columnDefs: [{ targets: 'no-sort', orderable: false }], |
|||
lengthMenu: [ |
|||
[50, 100, 200, 500, -1], |
|||
['50 rows', '100 rows', '200 rows', '500 rows', 'Show all'] |
|||
], |
|||
scrollY: '30vh', |
|||
fixedColumns: { left: 1, right: 1 }, |
|||
buttons: [ |
|||
{ extend: 'pageLength', className: 'btn btn-warning' }, |
|||
{ extend: 'copyHtml5', text: 'Copy', className: 'btn btn-secondary' }, |
|||
{ extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary' }, |
|||
{ extend: 'csvHtml5', text: 'CSV', className: 'btn btn-secondary' }, |
|||
{ extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-secondary' } |
|||
], |
|||
fixedHeader: true, |
|||
autoWidth: true, |
|||
responsive: true, |
|||
searching: true, |
|||
select: false, |
|||
processing: false |
|||
}); |
|||
} else { |
|||
$('#editagentsDatatable').DataTable().clear().draw(); |
|||
} |
|||
} |
|||
|
|||
</script> |
|||
|
|||
|
|||
|
|||
</body> |
|||
</html> |
|||
1954
src/main/resources/templates/modules/pensioner/department/dashboard.html
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1932
src/main/resources/templates/modules/pensioner/pensioner/dashboard.html
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue