Browse Source

Changes in registration form

master
Hariprasath S 1 month ago
parent
commit
74308fc302
  1. BIN
      cd_waste_docs/cdwaste_aadhar/10_bird.jpg
  2. BIN
      cd_waste_docs/cdwaste_aadhar/9_duck-7406987.jpg
  3. BIN
      cd_waste_docs/cdwaste_rcbookdoc/10_joban-khangura-hG8B9pKiilw-unsplash.jpg
  4. BIN
      cd_waste_docs/cdwaste_rcbookdoc/9_bird.jpg
  5. BIN
      cd_waste_docs/cdwaste_userphoto/10_duck-7406987.jpg
  6. BIN
      cd_waste_docs/cdwaste_userphoto/9_duck-7406987.jpg
  7. 12
      src/main/java/com/volunteersregistration/controller/ApiController.java
  8. 41
      src/main/java/com/volunteersregistration/controller/VolunteerController.java
  9. 154
      src/main/java/com/volunteersregistration/controller/VolunteerRegistrationController.java
  10. 34
      src/main/java/com/volunteersregistration/entity/CorporateInformation.java
  11. 35
      src/main/java/com/volunteersregistration/entity/NgoInformation.java
  12. 60
      src/main/java/com/volunteersregistration/entity/VolunteerInformation.java
  13. 7
      src/main/java/com/volunteersregistration/repository/VolunteerRegistrationRepo.java
  14. 35
      src/main/java/com/volunteersregistration/service/DateTimeUtil.java
  15. 7
      src/main/java/com/volunteersregistration/service/MobileAlreadyRegisteredException.java
  16. 371
      src/main/java/com/volunteersregistration/service/VolunteerRegistrationService.java
  17. 2
      src/main/java/com/volunteersregistration/wasteCollector/controller/ApiController.java
  18. 5
      src/main/resources/application-dev.properties
  19. 4
      src/main/resources/application-prod.properties
  20. 2
      src/main/resources/application.properties
  21. 2
      src/main/resources/templates/allreports.html
  22. 788
      src/main/resources/templates/index.html
  23. 773
      src/main/resources/templates/index_tamil.html
  24. 891
      src/main/resources/templates/webindex.html
  25. 836
      src/main/resources/templates/webindex_tamil.html

BIN
cd_waste_docs/cdwaste_aadhar/10_bird.jpg

After

Width: 1280  |  Height: 897  |  Size: 191 KiB

BIN
cd_waste_docs/cdwaste_aadhar/9_duck-7406987.jpg

After

Width: 5401  |  Height: 3601  |  Size: 3.2 MiB

BIN
cd_waste_docs/cdwaste_rcbookdoc/10_joban-khangura-hG8B9pKiilw-unsplash.jpg

After

Width: 2400  |  Height: 3001  |  Size: 2.5 MiB

BIN
cd_waste_docs/cdwaste_rcbookdoc/9_bird.jpg

After

Width: 1280  |  Height: 897  |  Size: 191 KiB

BIN
cd_waste_docs/cdwaste_userphoto/10_duck-7406987.jpg

After

Width: 5401  |  Height: 3601  |  Size: 3.2 MiB

BIN
cd_waste_docs/cdwaste_userphoto/9_duck-7406987.jpg

After

Width: 5401  |  Height: 3601  |  Size: 3.2 MiB

12
src/main/java/com/volunteersregistration/controller/ApiController.java

@ -84,7 +84,7 @@ public class ApiController {
System.out.print("\n otp---:"+otp); System.out.print("\n otp---:"+otp);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm"); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm");
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
System.out.println(dtf.format(now));
System.out.println("\n"+dtf.format(now));
// String generatedToken = "OTP for Volunteer "; // String generatedToken = "OTP for Volunteer ";
// String key="qxg4mklD"; // String key="qxg4mklD";
@ -161,5 +161,15 @@ public class ApiController {
public List<Map<String, Object>> getSubCategoryById(@RequestParam int category_id) { public List<Map<String, Object>> getSubCategoryById(@RequestParam int category_id) {
return volunteerRegistrationRepo.getSubCategoryById(category_id); return volunteerRegistrationRepo.getSubCategoryById(category_id);
} }
@GetMapping(value = "/getAllExpertise")
public List<Map<String, Object>> getAllExpertise() {
return volunteerRegistrationRepo.getAllExpertise();
}
@GetMapping(value = "/getAllVolunteerDocs")
public List<Map<String, Object>> getAllVolunteerDocs() {
return volunteerRegistrationRepo.getAllVolunteerDocs();
}
} }

41
src/main/java/com/volunteersregistration/controller/VolunteerController.java

@ -44,8 +44,8 @@ public class VolunteerController {
model.addAttribute("ref", ref); model.addAttribute("ref", ref);
//return "webindex";
return "coming_soon";
return "webindex";
//return "coming_soon";
} }
@GetMapping("/webtamil") @GetMapping("/webtamil")
@ -54,8 +54,8 @@ public class VolunteerController {
model.addAttribute("ref", ref); model.addAttribute("ref", ref);
//return "webindex_tamil";
return "coming_soon";
return "webindex_tamil";
//return "coming_soon";
} }
@GetMapping(value = { "/", "", "/index" }) @GetMapping(value = { "/", "", "/index" })
@ -64,8 +64,8 @@ public class VolunteerController {
model.addAttribute("ref", ref); model.addAttribute("ref", ref);
//return "index";
return "coming_soon";
return "index";
//return "coming_soon";
} }
@GetMapping(value = {"/index_tamil" }) @GetMapping(value = {"/index_tamil" })
@ -74,10 +74,35 @@ public class VolunteerController {
model.addAttribute("ref", ref); model.addAttribute("ref", ref);
//return "index_tamil";
return "coming_soon";
return "index_tamil";
//return "coming_soon";
} }
//testing urls
@GetMapping("/devtest")
public String MobileViewdevtest(@RequestParam(required = false) String ref, Model model) {
System.out.println("indesx page....." + ref);
model.addAttribute("ref", ref);
return "index";
//return "coming_soon";
}
@GetMapping("/devtestweb")
public String MobileViewdevtestweb(@RequestParam(required = false) String ref, Model model) {
System.out.println("indesx page....." + ref);
model.addAttribute("ref", ref);
return "webindex";
//return "coming_soon";
}
//
// Check session and redirect to login if user is not logged in // Check session and redirect to login if user is not logged in

154
src/main/java/com/volunteersregistration/controller/VolunteerRegistrationController.java

@ -1,38 +1,174 @@
package com.volunteersregistration.controller; package com.volunteersregistration.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.volunteersregistration.entity.CorporateInformation; import com.volunteersregistration.entity.CorporateInformation;
import com.volunteersregistration.entity.NgoInformation; import com.volunteersregistration.entity.NgoInformation;
import com.volunteersregistration.entity.VolunteerInformation; import com.volunteersregistration.entity.VolunteerInformation;
import com.volunteersregistration.service.MobileAlreadyRegisteredException;
import com.volunteersregistration.service.VolunteerRegistrationService; import com.volunteersregistration.service.VolunteerRegistrationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import java.util.Map;
@RestController @RestController
@RequestMapping("/volunteer/api") @RequestMapping("/volunteer/api")
public class VolunteerRegistrationController { public class VolunteerRegistrationController {
@Autowired
private ObjectMapper objectMapper;
@Autowired @Autowired
private VolunteerRegistrationService volunteerRegistrationService; private VolunteerRegistrationService volunteerRegistrationService;
@PostMapping("/register")
public String register(@RequestBody VolunteerInformation vol, Model model) {
System.out.println("save volunteers.....");
return volunteerRegistrationService.register(vol);
}
// @PostMapping("/register")
// public String register(@RequestBody VolunteerInformation vol, Model model) {
// System.out.println("save volunteers.....");
// return volunteerRegistrationService.register(vol);
// }
// @PostMapping(value = "/register", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
// public String register(
// @RequestPart("volunteer") String volunteerJson,
// @RequestPart("doc_url") MultipartFile docFile) {
//
// try {
//
// VolunteerInformation vol =
// objectMapper.readValue(
// volunteerJson,
// VolunteerInformation.class
// );
//
// return volunteerRegistrationService.register(vol, docFile);
//
// } catch (Exception e) {
//
// e.printStackTrace();
// return "error";
// }
// }
@PostMapping(
value = "/register",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE
)
public ResponseEntity<?> register(
@RequestPart("volunteer") String volunteerJson,
@RequestPart("doc_url") MultipartFile docFile) {
try {
VolunteerInformation vol =
objectMapper.readValue(
volunteerJson,
VolunteerInformation.class
);
String result =
volunteerRegistrationService.register(vol, docFile);
return ResponseEntity.ok(result);
} catch (MobileAlreadyRegisteredException e) {
return ResponseEntity
.status(HttpStatus.CONFLICT)
.body(Map.of(
"status", "DUPLICATE_MOBILE",
"message", "This mobile number is already registered"
));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Map.of(
"status", "ERROR",
"message", "Error saving data"
));
}
}
@PostMapping("/registerAsCorporate") @PostMapping("/registerAsCorporate")
public String register(@RequestBody CorporateInformation copInfo, Model model) {
public ResponseEntity<?> register(@RequestBody CorporateInformation copInfo, Model model) {
System.out.println("save volunteers....."); System.out.println("save volunteers.....");
return volunteerRegistrationService.registerAsCorporate(copInfo);
try {
String result = volunteerRegistrationService.registerAsCorporate(copInfo);
return ResponseEntity.ok(result);
} catch (MobileAlreadyRegisteredException e) {
return ResponseEntity
.status(HttpStatus.CONFLICT)
.body(Map.of(
"status", "DUPLICATE_MOBILE",
"message", "This mobile number is already registered"
));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Map.of(
"status", "ERROR",
"message", "Error saving data"
));
}
} }
@PostMapping("/registerAsNgo") @PostMapping("/registerAsNgo")
public String register(@RequestBody NgoInformation ngoInfo, Model model) {
public ResponseEntity<?> register(@RequestBody NgoInformation ngoInfo, Model model) {
System.out.println("save volunteers....."); System.out.println("save volunteers.....");
return volunteerRegistrationService.registerAsNgo(ngoInfo);
try {
String result = volunteerRegistrationService.registerAsNgo(ngoInfo);
return ResponseEntity.ok(result);
} catch (MobileAlreadyRegisteredException e) {
return ResponseEntity
.status(HttpStatus.CONFLICT)
.body(Map.of(
"status", "DUPLICATE_MOBILE",
"message", "This mobile number is already registered"
));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Map.of(
"status", "ERROR",
"message", "Error saving data"
));
}
} }

34
src/main/java/com/volunteersregistration/entity/CorporateInformation.java

@ -31,13 +31,45 @@ public class CorporateInformation {
private String category; private String category;
private String subCategory; private String subCategory;
private String ephno;
private int expertise_area;
private String other_expertise;
// @Column(name = "category_id") // @Column(name = "category_id")
// private Category category; // private Category category;
private String referBy; private String referBy;
public int getCop_id() {
public String getEphno() {
return ephno;
}
public void setEphno(String ephno) {
this.ephno = ephno;
}
public int getExpertise_area() {
return expertise_area;
}
public void setExpertise_area(int expertise_area) {
this.expertise_area = expertise_area;
}
public String getOther_expertise() {
return other_expertise;
}
public void setOther_expertise(String other_expertise) {
this.other_expertise = other_expertise;
}
public int getCop_id() {
return cop_id; return cop_id;
} }

35
src/main/java/com/volunteersregistration/entity/NgoInformation.java

@ -34,11 +34,44 @@ public class NgoInformation {
private String subCategory; private String subCategory;
private String referBy; private String referBy;
private String ephno;
private int expertise_area;
private String other_expertise;
// @Column(name = "category_id") // @Column(name = "category_id")
// private Category category; // private Category category;
public int getNgo_id() {
public String getEphno() {
return ephno;
}
public void setEphno(String ephno) {
this.ephno = ephno;
}
public int getExpertise_area() {
return expertise_area;
}
public void setExpertise_area(int expertise_area) {
this.expertise_area = expertise_area;
}
public String getOther_expertise() {
return other_expertise;
}
public void setOther_expertise(String other_expertise) {
this.other_expertise = other_expertise;
}
public int getNgo_id() {
return ngo_id; return ngo_id;
} }

60
src/main/java/com/volunteersregistration/entity/VolunteerInformation.java

@ -54,6 +54,66 @@ public class VolunteerInformation {
private String aadhar; private String aadhar;
private String bloodgroup; private String bloodgroup;
private String ephno;
private int expertise_area;
private String other_expertise;
private int doc_type;
private String doc_number;
private String doc_url;
public String getEphno() {
return ephno;
}
public void setEphno(String ephno) {
this.ephno = ephno;
}
public int getExpertise_area() {
return expertise_area;
}
public void setExpertise_area(int expertise_area) {
this.expertise_area = expertise_area;
}
public String getOther_expertise() {
return other_expertise;
}
public void setOther_expertise(String other_expertise) {
this.other_expertise = other_expertise;
}
public int getDoc_type() {
return doc_type;
}
public void setDoc_type(int doc_type) {
this.doc_type = doc_type;
}
public String getDoc_number() {
return doc_number;
}
public void setDoc_number(String doc_number) {
this.doc_number = doc_number;
}
public String getDoc_url() {
return doc_url;
}
public void setDoc_url(String doc_url) {
this.doc_url = doc_url;
}
public int getVolunteer_id() { public int getVolunteer_id() {
return volunteer_id; return volunteer_id;

7
src/main/java/com/volunteersregistration/repository/VolunteerRegistrationRepo.java

@ -29,4 +29,11 @@ public interface VolunteerRegistrationRepo extends JpaRepository<VolunteerInform
@Query(value ="SELECT * FROM sub_category_master WHERE is_active=1 AND is_delete=0 AND category_id=:category_id", nativeQuery = true) @Query(value ="SELECT * FROM sub_category_master WHERE is_active=1 AND is_delete=0 AND category_id=:category_id", nativeQuery = true)
List<Map<String, Object>> getSubCategoryById(@Param("category_id") int category_id); List<Map<String, Object>> getSubCategoryById(@Param("category_id") int category_id);
@Query(value = "SELECT * FROM expertise_area_master WHERE is_active=1 AND is_delete=0 order by orderby ASC", nativeQuery = true)
List<Map<String, Object>> getAllExpertise();
@Query(value = "SELECT * FROM volunteer_docs WHERE is_active=1 AND is_delete=0", nativeQuery = true)
List<Map<String, Object>> getAllVolunteerDocs();
} }

35
src/main/java/com/volunteersregistration/service/DateTimeUtil.java

@ -0,0 +1,35 @@
package com.volunteersregistration.service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.springframework.stereotype.Component;
@Component("volunteerDateTimeUtil")
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);
}
}

7
src/main/java/com/volunteersregistration/service/MobileAlreadyRegisteredException.java

@ -0,0 +1,7 @@
package com.volunteersregistration.service;
public class MobileAlreadyRegisteredException extends RuntimeException{
public MobileAlreadyRegisteredException(String message) {
super(message);
}
}

371
src/main/java/com/volunteersregistration/service/VolunteerRegistrationService.java

@ -6,13 +6,26 @@ import com.volunteersregistration.entity.VolunteerInformation;
import com.volunteersregistration.repository.CompanyInfoRepo; import com.volunteersregistration.repository.CompanyInfoRepo;
import com.volunteersregistration.repository.NgoInfoRepo; import com.volunteersregistration.repository.NgoInfoRepo;
import com.volunteersregistration.repository.VolunteerRegistrationRepo; import com.volunteersregistration.repository.VolunteerRegistrationRepo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
@ -20,9 +33,24 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.StringJoiner; import java.util.StringJoiner;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
@Service @Service
public class VolunteerRegistrationService { public class VolunteerRegistrationService {
private final Environment environment;
public VolunteerRegistrationService(Environment environment) {
this.environment = environment;
}
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired @Autowired
private VolunteerRegistrationRepo volunteerRegistrationRepo; private VolunteerRegistrationRepo volunteerRegistrationRepo;
@ -32,46 +60,268 @@ public class VolunteerRegistrationService {
@Autowired @Autowired
private NgoInfoRepo ngoInfoRepo; private NgoInfoRepo ngoInfoRepo;
private boolean isMobileAlreadyRegistered(Long mobileNo) {
String sql = " SELECT COUNT(*) "
+ " FROM ( "
+ " SELECT mobile_no "
+ " FROM volunteer_information"
+ " WHERE mobile_no = ? and isactive=1 "
+ ""
+ " UNION ALL "
+ ""
+ " SELECT contact_per_mobile "
+ " FROM corporate_information "
+ " WHERE contact_per_mobile = ? and isactive=1 "
+ ""
+ " UNION ALL "
+ ""
+ " SELECT mobile_no "
+ " FROM ngo_information "
+ " WHERE mobile_no = ? and isactive=1 "
+ " ) AS mobile_check ";
public String register(VolunteerInformation volun) {
Integer count = jdbcTemplate.queryForObject(
sql,
Integer.class,
mobileNo,
mobileNo,
mobileNo
);
volun.setCdate(LocalDateTime.now());
volun.setIsactive(true);
try{
if(volun!=null){
String preferredAreas[] =volun.getPreferredAreas();
if (preferredAreas != null) {
StringJoiner zones = new StringJoiner(",");
StringJoiner joiner = new StringJoiner(",");
for (String area : preferredAreas) {
String areaWZone[] =area.split("-");
if(areaWZone != null && areaWZone.length==2) {
joiner.add(areaWZone[1]);
zones.add(areaWZone[0]);
}else{
joiner.add(area);
}
return count != null && count > 0;
}
// public String register(VolunteerInformation volun, MultipartFile docFile) {
//
// volun.setCdate(LocalDateTime.now());
// volun.setIsactive(true);
// try{
// if(volun!=null){
//
// if (docFile != null && !docFile.isEmpty()) {
//
// String docPath = fileUpload(docFile,"volunteer");
//
// // Set returned path into entity
// volun.setDoc_url(docPath);
// }
//
// String preferredAreas[] =volun.getPreferredAreas();
// if (preferredAreas != null) {
// StringJoiner zones = new StringJoiner(",");
// StringJoiner joiner = new StringJoiner(",");
// for (String area : preferredAreas) {
// String areaWZone[] =area.split("-");
// if(areaWZone != null && areaWZone.length==2) {
// joiner.add(areaWZone[1]);
// zones.add(areaWZone[0]);
// }else{
// joiner.add(area);
// }
// }
// volun.setPreferred_area(joiner.toString());
// volun.setPreferred_zones(zones.toString());
// }
// volun= volunteerRegistrationRepo.save(volun);
//
// sendWhatsappMsgENG(volun.getVolunteer_id(),volun.getMobile_no(),"GCC-VOL-");
// sendWhatsappMsgTam(volun.getVolunteer_id(),volun.getMobile_no(),"GCC-VOL-");
//
// return "VOL-"+String.format("%05d",volun.getVolunteer_id());
// } else {
// return "Not Saved";
// }
//
// }catch(Exception e) {
// e.printStackTrace();
// }
// return "error";
// }
public String register(
VolunteerInformation volun,
MultipartFile docFile) {
try {
if (volun == null) {
return "Not Saved";
}
// ------------------------------------
// Check mobile number duplication
// ------------------------------------
Long mobileNo = volun.getMobile_no();
if (isMobileAlreadyRegistered(mobileNo)) {
throw new MobileAlreadyRegisteredException(
"This mobile number is already registered"
);
}
// ------------------------------------
// Set common fields
// ------------------------------------
volun.setCdate(LocalDateTime.now());
volun.setIsactive(true);
// ------------------------------------
// Save document
// ------------------------------------
if (docFile != null && !docFile.isEmpty()) {
String docPath = fileUpload(docFile,"volunteer");
volun.setDoc_url(docPath);
}
// ------------------------------------
// Preferred Areas
// ------------------------------------
String preferredAreas[] = volun.getPreferredAreas();
if (preferredAreas != null) {
StringJoiner zones = new StringJoiner(",");
StringJoiner joiner = new StringJoiner(",");
for (String area : preferredAreas) {
String areaWZone[] = area.split("-");
if (areaWZone.length == 2) {
joiner.add(areaWZone[1]);
zones.add(areaWZone[0]);
} else {
joiner.add(area);
} }
volun.setPreferred_area(joiner.toString());
volun.setPreferred_zones(zones.toString());
} }
volun= volunteerRegistrationRepo.save(volun);
sendWhatsappMsgENG(volun.getVolunteer_id(),volun.getMobile_no(),"GCC-VOL-");
sendWhatsappMsgTam(volun.getVolunteer_id(),volun.getMobile_no(),"GCC-VOL-");
return "VOL-"+String.format("%05d",volun.getVolunteer_id());
volun.setPreferred_area(joiner.toString());
volun.setPreferred_zones(zones.toString());
}
// ------------------------------------
// Save volunteer
// ------------------------------------
volun = volunteerRegistrationRepo.save(volun);
// ------------------------------------
// Send WhatsApp
// ------------------------------------
sendWhatsappMsgENG(
volun.getVolunteer_id(),
volun.getMobile_no(),
"GCC-VOL-"
);
sendWhatsappMsgTam(
volun.getVolunteer_id(),
volun.getMobile_no(),
"GCC-VOL-"
);
return "VOL-" + String.format(
"%05d",
volun.getVolunteer_id()
);
} catch (MobileAlreadyRegisteredException e) {
// IMPORTANT:
// Don't convert this to generic "error"
throw e;
} 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("volunteer_individual_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();
String originalFileName = file.getOriginalFilename();
String extension = originalFileName.substring(originalFileName.lastIndexOf('.') + 1).toLowerCase();
if ("jpg".equals(extension) || "jpeg".equals(extension)) {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes));
byte[] compressedBytes = compressImage(image, 0.5f); // Compress with 50% quality
// Write the compressed bytes to the file
Files.write(path, compressedBytes);
} else { } else {
return "Not Saved";
// Write the original bytes to the file
Files.write(path, bytes);
} }
}catch(Exception e) {
//System.out.println(filePath);
return filepath_txt;
} catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return "Failed to save file " + file.getOriginalFilename();
} }
return "error";
} }
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();
}
private String sendWhatsappMsgTam(int id, Long mob_no,String prefix) { private String sendWhatsappMsgTam(int id, Long mob_no,String prefix) {
String urlString = ""; String urlString = "";
@ -152,7 +402,23 @@ public class VolunteerRegistrationService {
public String registerAsNgo(NgoInformation ngo) { public String registerAsNgo(NgoInformation ngo) {
try { try {
if (ngo != null) {
if (ngo == null) {
return "Not Saved";
}
// ------------------------------------
// Check mobile number duplication
// ------------------------------------
Long mobileNo = ngo.getMobileNo();
if (isMobileAlreadyRegistered(mobileNo)) {
throw new MobileAlreadyRegisteredException(
"This mobile number is already registered"
);
}
ngo.setCdate(LocalDateTime.now()); ngo.setCdate(LocalDateTime.now());
ngo.setIsactive(true); ngo.setIsactive(true);
String preferredAreas[] = ngo.getPreferredAreas(); String preferredAreas[] = ngo.getPreferredAreas();
@ -177,19 +443,40 @@ public class VolunteerRegistrationService {
sendWhatsappMsgTam(ngo.getNgo_id(),ngo.getMobileNo(),"GCC-NGO_VOL-"); sendWhatsappMsgTam(ngo.getNgo_id(),ngo.getMobileNo(),"GCC-NGO_VOL-");
return "NGO_VOL-"+String.format("%05d",ngo.getNgo_id()); return "NGO_VOL-"+String.format("%05d",ngo.getNgo_id());
} else {
return "Not Saved";
}
}catch (MobileAlreadyRegisteredException e) {
// IMPORTANT:
// Don't convert this to generic "error"
throw e;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return "error";
} }
return "error";
} }
public String registerAsCorporate(CorporateInformation cop){ public String registerAsCorporate(CorporateInformation cop){
try{ try{
if(cop!=null){
if (cop == null) {
return "Not Saved";
}
// ------------------------------------
// Check mobile number duplication
// ------------------------------------
Long mobileNo = cop.getContactPerMobile();
if (isMobileAlreadyRegistered(mobileNo)) {
throw new MobileAlreadyRegisteredException(
"This mobile number is already registered"
);
}
cop.setCdate(LocalDateTime.now()); cop.setCdate(LocalDateTime.now());
cop.setIsactive(true); cop.setIsactive(true);
String preferredAreas[] =cop.getPreferredAreas(); String preferredAreas[] =cop.getPreferredAreas();
@ -214,14 +501,20 @@ public class VolunteerRegistrationService {
sendWhatsappMsgTam(cop.getCop_id(),cop.getContactPerMobile(),"GCC-COR_VOL-"); sendWhatsappMsgTam(cop.getCop_id(),cop.getContactPerMobile(),"GCC-COR_VOL-");
return "COR_VOL-"+String.format("%05d",cop.getCop_id()); return "COR_VOL-"+String.format("%05d",cop.getCop_id());
} else {
return "Not Saved";
}
} catch (MobileAlreadyRegisteredException e) {
// IMPORTANT:
// Don't convert this to generic "error"
throw e;
} catch (Exception e) {
}catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
return "error";
} }
return "error";
} }

2
src/main/java/com/volunteersregistration/wasteCollector/controller/ApiController.java

@ -212,7 +212,7 @@ public class ApiController {
System.out.print("\n otp---:"+otp); System.out.print("\n otp---:"+otp);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm"); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm");
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
System.out.println(dtf.format(now));
System.out.println("\n"+dtf.format(now));
//String generatedToken = "Welcome to GCC! Your OTP for C%26D waste collectors Registration process is "+otp; //String generatedToken = "Welcome to GCC! Your OTP for C%26D waste collectors Registration process is "+otp;
//String generatedToken = "Welcome to GCC "+otp+" is your OTP for gcc QR System"; //String generatedToken = "Welcome to GCC "+otp+" is your OTP for gcc QR System";

5
src/main/resources/application-dev.properties

@ -31,5 +31,10 @@ file.leasedoc.fullpath=/cd_waste_docs/
file.rcbookdoc.fullpath=/cd_waste_docs/ file.rcbookdoc.fullpath=/cd_waste_docs/
file.userphoto.fullpath=/cd_waste_docs/ file.userphoto.fullpath=/cd_waste_docs/
file.upload.directory.mobile=${user.dir}/gcc_mobile_service_uploads/
volunteer_individual_foldername=volunteer_individual_docs
#testing key #testing key
payment.razorpay.my_key_id=rzp_test_tDkHFEqWXmuEi8 payment.razorpay.my_key_id=rzp_test_tDkHFEqWXmuEi8

4
src/main/resources/application-prod.properties

@ -32,6 +32,10 @@ file.leasedoc.fullpath=/cd_waste_docs/
file.rcbookdoc.fullpath=/cd_waste_docs/ file.rcbookdoc.fullpath=/cd_waste_docs/
file.userphoto.fullpath=/cd_waste_docs/ file.userphoto.fullpath=/cd_waste_docs/
file.upload.directory.mobile=${user.dir}/gcc_mobile_service_uploads/
volunteer_individual_foldername=volunteer_individual_docs
#live key #live key
payment.razorpay.my_key_id=rzp_live_ySI5Ns54Y7qOcJ payment.razorpay.my_key_id=rzp_live_ySI5Ns54Y7qOcJ

2
src/main/resources/application.properties

@ -1 +1 @@
spring.profiles.active=prod
spring.profiles.active=dev

2
src/main/resources/templates/allreports.html

@ -310,7 +310,7 @@
<td th:text="${corporate.cnt_per_email}"></td> <td th:text="${corporate.cnt_per_email}"></td>
<td th:text="${corporate.contact_per_mobile}"></td> <td th:text="${corporate.contact_per_mobile}"></td>
<td th:text="${corporate.contact_person}"></td> <td th:text="${corporate.contact_person}"></td>
<td th:text="${corporate.landline == null or corporate.landline == 0} ? 'NA' : corporate.landline"></td>
<td th:text="${corporate.landline == '' or corporate.landline == 0} ? 'NA' : corporate.landline"></td>
<td th:text="${corporate.no_of_vol}"></td> <td th:text="${corporate.no_of_vol}"></td>
<td th:text="${corporate.pin_code}"></td> <td th:text="${corporate.pin_code}"></td>
<td th:text="${corporate.preferred_area}"></td> <td th:text="${corporate.preferred_area}"></td>

788
src/main/resources/templates/index.html
File diff suppressed because it is too large
View File

773
src/main/resources/templates/index_tamil.html
File diff suppressed because it is too large
View File

891
src/main/resources/templates/webindex.html
File diff suppressed because it is too large
View File

836
src/main/resources/templates/webindex_tamil.html
File diff suppressed because it is too large
View File

Loading…
Cancel
Save