55 changed files with 9482 additions and 212 deletions
-
BIN.DS_Store
-
BINmobileservice/.DS_Store
-
BINmobileservice/src/.DS_Store
-
BINmobileservice/src/main/.DS_Store
-
78mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/ImageUrlValidator.java
-
92mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/busshelters/controller/BusShelterController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/busshelters/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/busshelters/package-info.java
-
507mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/busshelters/service/BusShelterActivity.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/busshelters/service/package-info.java
-
285mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/controller/APIC_D_WasteController.java
-
59mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/controller/API_C_D_WasteUserController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/package-info.java
-
1397mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/service/c_d_WasteService.java
-
1073mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/service/c_d_WasteUserService.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/service/package-info.java
-
64mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/component/ApiLoggingFilter.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/component/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/AppConfig.java
-
89mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/DataSourceConfig.java
-
26mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/WebConfig.java
-
42mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccactivity/service/Activity.java
-
149mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gcceducation/controller/EducationController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gcceducation/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gcceducation/package-info.java
-
1067mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gcceducation/service/EducationActivity.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gcceducation/service/package-info.java
-
70mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/controller/ParksController.java
-
277mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ParksService.java
-
10mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/controller/SchoolUserController.java
-
64mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/SchoolUserActivity.java
-
267mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstreetvendor/controller/StreetVendorController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstreetvendor/controller/package-info.java
-
337mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstreetvendor/service/StreetVendorService.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstreetvendor/service/package-info.java
-
25mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/hoardings/services/HoardingsService.java
-
213mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/mosquitosurvey/controller/API_FoggingController.java
-
136mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/mosquitosurvey/controller/API_MosquitoController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/mosquitosurvey/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/mosquitosurvey/package-info.java
-
1404mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/mosquitosurvey/service/FoggingService.java
-
570mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/mosquitosurvey/service/MosquitoService.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/mosquitosurvey/service/package-info.java
-
137mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/CattleCatchService.java
-
33mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/toilets/controller/APIController.java
-
198mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/toilets/service/activity.java
-
98mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/works/controller/WorksController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/works/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/works/package-info.java
-
699mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/works/service/WorksService.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/works/service/package-info.java
-
2mobileservice/src/main/resources/application-local.properties
-
2mobileservice/src/main/resources/application-production.properties
-
11mobileservice/src/main/resources/application.properties
@ -0,0 +1,78 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice; |
||||
|
import java.sql.*; |
||||
|
|
||||
|
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.RestController; |
||||
|
|
||||
|
import java.net.HttpURLConnection; |
||||
|
import java.net.URL; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/imgval/") |
||||
|
@RestController("imgval") |
||||
|
public class ImageUrlValidator { |
||||
|
|
||||
|
// JDBC connection details |
||||
|
private static final String DB_URL = "jdbc:mysql://localhost:3306/cmdashboard"; |
||||
|
private static final String DB_USER = "root"; |
||||
|
private static final String DB_PASSWORD = ""; |
||||
|
|
||||
|
@GetMapping("/imagecheck") |
||||
|
public String imagecheck(){ |
||||
|
String query = "SELECT data_id, abs_est_number, regionname, typeofwork, imageurl, zonename, wardname FROM tbl_cmdashboard" |
||||
|
+ " WHERE abs_est_number LIKE '%2024-25%'"; |
||||
|
String updateQuery = "UPDATE tbl_cmdashboard SET image_status = ? WHERE data_id = ?"; |
||||
|
|
||||
|
try ( |
||||
|
Connection conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD); |
||||
|
PreparedStatement stmt = conn.prepareStatement(query); |
||||
|
PreparedStatement updateStmt = conn.prepareStatement(updateQuery); |
||||
|
ResultSet rs = stmt.executeQuery() |
||||
|
) { |
||||
|
while (rs.next()) { |
||||
|
int dataId = rs.getInt("data_id"); |
||||
|
String estNumber = rs.getString("abs_est_number"); |
||||
|
String region = rs.getString("regionname"); |
||||
|
String typeOfWork = rs.getString("typeofwork"); |
||||
|
String imageUrl = rs.getString("imageurl"); |
||||
|
String zone = rs.getString("zonename"); |
||||
|
String ward = rs.getString("wardname"); |
||||
|
|
||||
|
boolean isValid = isImageUrlValid(imageUrl); |
||||
|
updateStmt.setBoolean(1, isValid ? true : false); |
||||
|
updateStmt.setInt(2, dataId); |
||||
|
updateStmt.executeUpdate(); |
||||
|
|
||||
|
System.out.printf("ID: %d | Estimate: %s | URL: %s | Valid: %s%n", |
||||
|
dataId, estNumber, imageUrl, isValid ? "✅" : "❌"); |
||||
|
} |
||||
|
System.out.println("All image statuses updated."); |
||||
|
} catch (SQLException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return ""; |
||||
|
} |
||||
|
|
||||
|
// Checks if the image URL is valid and accessible |
||||
|
private static boolean isImageUrlValid(String imageUrl) { |
||||
|
if (imageUrl == null || imageUrl.isBlank()) return false; |
||||
|
|
||||
|
try { |
||||
|
URL url = new URL(imageUrl); |
||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
||||
|
conn.setRequestMethod("HEAD"); |
||||
|
conn.setConnectTimeout(5000); |
||||
|
conn.setReadTimeout(5000); |
||||
|
conn.connect(); |
||||
|
|
||||
|
int statusCode = conn.getResponseCode(); |
||||
|
String contentType = conn.getContentType(); |
||||
|
|
||||
|
return statusCode == 200 && contentType != null && contentType.startsWith("image/"); |
||||
|
} catch (Exception e) { |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,92 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.busshelters.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
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.mobileservice.busshelters.service.BusShelterActivity; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/busshelter/") |
||||
|
@RestController("busshelterRest") |
||||
|
public class BusShelterController { |
||||
|
@Autowired |
||||
|
private JdbcTemplate jdbcBusShelterTemplate; |
||||
|
@Autowired |
||||
|
private BusShelterActivity busShelterActivity; |
||||
|
|
||||
|
@GetMapping(value="/getBusShelterList") |
||||
|
public List<?> getBusShelterList(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId){ |
||||
|
return busShelterActivity.getBusShelterList(formData, latitude, longitude,loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getQuestionsList") // Old App |
||||
|
public List<?> getQuestionsList(@RequestParam(value="loginId", required = false) String cby){ |
||||
|
return busShelterActivity.getQuestionsList(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getParentQuestionsList") |
||||
|
public List<?> getParentQuestionsList( |
||||
|
@RequestParam(value="loginId", required = false) String cby, |
||||
|
@RequestParam(value="qtype", required = true) String qtype){ |
||||
|
return busShelterActivity.getParentQuestionsList(qtype); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getChildQuestionsList") |
||||
|
public List<?> getChildQuestionsList( |
||||
|
@RequestParam(value="loginId", required = false) String cby, |
||||
|
@RequestParam(value="pid", required = true) String pid |
||||
|
){ |
||||
|
return busShelterActivity.getChildQuestionsList(pid); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveFeedback") |
||||
|
public List<?> saveFeedback( |
||||
|
@RequestParam(value="shelter_id", required = true) String shelter_id, |
||||
|
@RequestParam(value="loginId", required = true) String cby, |
||||
|
@RequestParam(value="latitude", required = true) String latitude, |
||||
|
@RequestParam(value="longitude", required = true) String longitude, |
||||
|
@RequestParam(value="action", required = true) String type, |
||||
|
@RequestParam(value="zone", required = true) String zone, |
||||
|
@RequestParam(value="ward", required = true) String ward, |
||||
|
@RequestParam(value="q_1", required = false) String q_1, |
||||
|
@RequestParam(value="q_2", required = false) String q_2, |
||||
|
@RequestParam(value="q_3", required = false) String q_3, |
||||
|
@RequestParam(value="q_4", required = false) String q_4, |
||||
|
@RequestParam(value="q_5", required = false) String q_5, |
||||
|
@RequestParam(value="q_6", required = false) String q_6, |
||||
|
@RequestParam(value="q_7", required = false) String q_7, |
||||
|
@RequestParam(value="q_8", required = false) String q_8, |
||||
|
@RequestParam(value="q_9", required = false) String q_9, |
||||
|
@RequestParam(value="q_10", required = false) String q_10, |
||||
|
@RequestParam(value="q_11", required = false) String q_11, |
||||
|
@RequestParam(value="remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile filedata, |
||||
|
|
||||
|
@RequestParam(value="file_1", required = false) MultipartFile file_1, |
||||
|
@RequestParam(value="file_2", required = false) MultipartFile file_2, |
||||
|
@RequestParam(value="file_3", required = false) MultipartFile file_3, |
||||
|
@RequestParam(value="file_4", required = false) MultipartFile file_4, |
||||
|
@RequestParam(value="file_5", required = false) MultipartFile file_5, |
||||
|
@RequestParam(value="file_6", required = false) MultipartFile file_6, |
||||
|
@RequestParam(value="file_7", required = false) MultipartFile file_7, |
||||
|
@RequestParam(value="file_8", required = false) MultipartFile file_8, |
||||
|
@RequestParam(value="file_9", required = false) MultipartFile file_9, |
||||
|
@RequestParam(value="file_10", required = false) MultipartFile file_10, |
||||
|
@RequestParam(value="file_11", required = false) MultipartFile file_11 |
||||
|
){ |
||||
|
return busShelterActivity.saveFeedback(shelter_id, cby, latitude, longitude, zone, ward, |
||||
|
q_1, q_2, q_3, q_4, q_5, q_6, q_7, q_8, q_9, q_10, q_11, remarks, filedata, |
||||
|
file_1, file_2, file_3, file_4, file_5, file_6, file_7, file_8, file_9, file_10, file_11,type); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.busshelters.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.busshelters; |
||||
@ -0,0 +1,507 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.busshelters.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.Connection; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.SQLException; |
||||
|
import java.time.LocalDate; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.Collections; |
||||
|
import java.util.HashMap; |
||||
|
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.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.jdbc.core.PreparedStatementCreator; |
||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder; |
||||
|
import org.springframework.jdbc.support.KeyHolder; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; |
||||
|
|
||||
|
@Service |
||||
|
public class BusShelterActivity { |
||||
|
private JdbcTemplate jdbcBusShelterTemplate; |
||||
|
|
||||
|
private final Environment environment; |
||||
|
private String fileBaseUrl; |
||||
|
|
||||
|
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
||||
|
private static final int STRING_LENGTH = 15; |
||||
|
private static final Random RANDOM = new SecureRandom(); |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqlBusShelterDataSource") DataSource BusShelterDataSource) { |
||||
|
this.jdbcBusShelterTemplate = new JdbcTemplate(BusShelterDataSource); |
||||
|
} |
||||
|
|
||||
|
@Autowired |
||||
|
public BusShelterActivity(Environment environment) { |
||||
|
this.environment = environment; |
||||
|
this.fileBaseUrl=environment.getProperty("fileBaseUrl"); |
||||
|
} |
||||
|
|
||||
|
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 static String generateRandomStringForFile(int String_Lenth) { |
||||
|
StringBuilder result = new StringBuilder(String_Lenth); |
||||
|
for (int i = 0; i < STRING_LENGTH; i++) { |
||||
|
result.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); |
||||
|
} |
||||
|
return result.toString(); |
||||
|
} |
||||
|
|
||||
|
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 String fileUpload(String name, String id, MultipartFile file) { |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
// Set the file path where you want to save it |
||||
|
String uploadDirectory = environment.getProperty("file.upload.directory"); |
||||
|
String serviceFolderName = environment.getProperty("busshelter_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 |
||||
|
System.out.println(file.getOriginalFilename()); |
||||
|
String fileName = name+ "_" +id + "_" + datetimetxt + "_" + generateRandomStringForFile(10) + "_" + 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, bytes); |
||||
|
|
||||
|
System.out.println(filePath); |
||||
|
return filepath_txt; |
||||
|
|
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
return "Failed to save file " + file.getOriginalFilename(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
////////////////////////////// |
||||
|
public String getConfigValue() { |
||||
|
String sqlQuery = "SELECT `id`, `lat_long_radius` FROM `config` LIMIT 1"; |
||||
|
String value = "50"; // default fallback value |
||||
|
List<Map<String, Object>> results = jdbcBusShelterTemplate.queryForList(sqlQuery); |
||||
|
|
||||
|
if (!results.isEmpty()) { |
||||
|
Map<String, Object> row = results.get(0); |
||||
|
value = String.valueOf(row.get("lat_long_radius")); // corrected key name |
||||
|
} |
||||
|
|
||||
|
return value; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
////////////////////////////// |
||||
|
|
||||
|
public List<Map<String, Object>> getBusShelterList( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String loginid |
||||
|
) { |
||||
|
|
||||
|
String sqlWhere = ""; |
||||
|
String radius = getConfigValue(); |
||||
|
|
||||
|
if (latitude != null && longitude != null && !latitude.isBlank() && !latitude.isEmpty() && !longitude.isBlank() |
||||
|
&& !longitude.isEmpty()) { |
||||
|
sqlWhere += " AND ((6371008.8 * acos(ROUND(cos(radians(" + latitude |
||||
|
+ ")) * cos(radians(bsl.latitude)) * cos(radians(bsl.longitude) - radians(" + longitude |
||||
|
+ ")) + sin(radians(" + latitude + ")) * sin(radians(bsl.latitude)), 9))) < "+radius+")" |
||||
|
+ " ORDER BY" |
||||
|
+ " bsl.`id` DESC"; |
||||
|
} |
||||
|
|
||||
|
String sql = "SELECT " |
||||
|
+ " bsl.*, " |
||||
|
+ " CONCAT('"+fileBaseUrl+"/gccofficialapp/files', bsl.image) AS photo, " |
||||
|
+ " bf.type AS qtype, " |
||||
|
+ " DATE_FORMAT(bf.latest_feedback_date, '%d-%m-%Y') AS latestfeedbackdate " |
||||
|
+ "FROM " |
||||
|
+ " bus_shelter_list bsl " |
||||
|
+ "LEFT JOIN ( " |
||||
|
+ " SELECT " |
||||
|
+ " bsf.shelter_id, " |
||||
|
+ " bsf.type, " |
||||
|
+ " bsf.cdate AS latest_feedback_date " |
||||
|
+ " FROM " |
||||
|
+ " bus_shelter_feedback bsf " |
||||
|
+ " INNER JOIN ( " |
||||
|
+ " SELECT " |
||||
|
+ " shelter_id, " |
||||
|
+ " MAX(id) AS max_id " |
||||
|
+ " FROM " |
||||
|
+ " bus_shelter_feedback " |
||||
|
+ " GROUP BY shelter_id " |
||||
|
+ " ) latest ON bsf.shelter_id = latest.shelter_id AND bsf.id = latest.max_id " |
||||
|
+ ") bf ON bsl.id = bf.shelter_id " |
||||
|
+ "WHERE " |
||||
|
+ " bsl.isactive = 1 " |
||||
|
+ " AND bsl.gcc_app_updated = 0 "+sqlWhere; |
||||
|
System.out.println(sql); |
||||
|
List<Map<String, Object>> result = jdbcBusShelterTemplate.queryForList(sql); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Bus Shelter List."); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getQuestionsList() { |
||||
|
String sql = "SELECT * FROM question_list WHERE isactive=1"; |
||||
|
List<Map<String, Object>> result = jdbcBusShelterTemplate.queryForList(sql); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Bus Shelter Question List."); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getParentQuestionsList(String qtype) { |
||||
|
//String sql = "SELECT * FROM question_list WHERE isactive=1 AND `pid`=0 AND `qtype` LIKE ?"; |
||||
|
String sql = "SELECT ql.id AS question_id, ql.q_english, ql.q_tamil, " |
||||
|
+ "ql.isactive, ql.img_required, ql.pid, ql.qtype, ql.feedbacktype, " |
||||
|
+ "CASE WHEN ql.feedbacktype = 'select' THEN JSON_ARRAYAGG" |
||||
|
+ "( JSON_OBJECT( 'option_id', qov.id, 'english_name', qov.english_name, 'tamil_name', " |
||||
|
+ "qov.tamil_name, 'value', qov.value, 'isactive', qov.isactive, 'isdelete', qov.isdelete ) ) " |
||||
|
+ "ELSE NULL END AS options FROM question_list ql " |
||||
|
+ "LEFT JOIN q_option_value qov ON qov.qid = ql.id " |
||||
|
+ "AND ql.feedbacktype = 'select' WHERE ql.isactive = 1 AND `pid`=0 AND `qtype` LIKE ? GROUP BY ql.id"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcBusShelterTemplate.queryForList(sql,"%" + qtype + "%"); |
||||
|
|
||||
|
ObjectMapper mapper = new ObjectMapper(); |
||||
|
for (Map<String, Object> row : result) { |
||||
|
Object optionsRaw = row.get("options"); |
||||
|
if (optionsRaw != null && optionsRaw instanceof String) { |
||||
|
try { |
||||
|
List<Map<String, Object>> optionsParsed = mapper.readValue((String) optionsRaw, List.class); |
||||
|
row.put("options", optionsParsed); |
||||
|
} catch (Exception e) { |
||||
|
row.put("options", null); // fallback if malformed |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Bus Shelter Parent Question List."); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getChildQuestionsList(String pid) { |
||||
|
String sql = "SELECT * FROM question_list WHERE isactive=1 AND `pid`=?"; |
||||
|
List<Map<String, Object>> result = jdbcBusShelterTemplate.queryForList(sql,pid); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Bus Shelter Child Question List."); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public String inactiveFeedBack(String type, String toilet_id) { |
||||
|
|
||||
|
String sql = "UPDATE `bus_shelter_feedback` SET `isactive`=0 WHERE DATE(`bus_shelter_feedback`.`cdate`) = CURDATE() AND `type`= ? AND `shelter_id`=?"; |
||||
|
jdbcBusShelterTemplate.update(sql,type,toilet_id); |
||||
|
|
||||
|
return "sussess"; |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> saveFeedback( |
||||
|
String shelter_id, |
||||
|
String cby, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String q_1, |
||||
|
String q_2, |
||||
|
String q_3, |
||||
|
String q_4, |
||||
|
String q_5, |
||||
|
String q_6, |
||||
|
String q_7, |
||||
|
String q_8, |
||||
|
String q_9, |
||||
|
String q_10, |
||||
|
String q_11, |
||||
|
String remarks, |
||||
|
MultipartFile file, |
||||
|
|
||||
|
MultipartFile file_1, |
||||
|
MultipartFile file_2, |
||||
|
MultipartFile file_3, |
||||
|
MultipartFile file_4, |
||||
|
MultipartFile file_5, |
||||
|
MultipartFile file_6, |
||||
|
MultipartFile file_7, |
||||
|
MultipartFile file_8, |
||||
|
MultipartFile file_9, |
||||
|
MultipartFile file_10, |
||||
|
MultipartFile file_11, |
||||
|
String type) { |
||||
|
List<Map<String, Object>> result = null; |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String image = ""; |
||||
|
String image_q1 = ""; |
||||
|
String image_q2 = ""; |
||||
|
String image_q3 = ""; |
||||
|
String image_q4 = ""; |
||||
|
String image_q5 = ""; |
||||
|
String image_q6 = ""; |
||||
|
String image_q7 = ""; |
||||
|
String image_q8 = ""; |
||||
|
String image_q9 = ""; |
||||
|
String image_q10 = ""; |
||||
|
String image_q11 = ""; |
||||
|
|
||||
|
var year = DateTimeUtil.getCurrentYear(); |
||||
|
var month = DateTimeUtil.getCurrentMonth(); |
||||
|
|
||||
|
// Handle file upload if a file is provided |
||||
|
if (file != null && !file.isEmpty()) { |
||||
|
image = fileUpload("feedback", "0", file); |
||||
|
} |
||||
|
|
||||
|
// Question Images |
||||
|
if (file_1 != null && !file_1.isEmpty()) { |
||||
|
image_q1 = fileUpload("1", "q1", file_1); |
||||
|
} |
||||
|
|
||||
|
if (file_2 != null && !file_2.isEmpty()) { |
||||
|
image_q2 = fileUpload("2", "q2", file_2); |
||||
|
} |
||||
|
|
||||
|
if (file_3 != null && !file_3.isEmpty()) { |
||||
|
image_q3 = fileUpload("3", "q3", file_3); |
||||
|
} |
||||
|
|
||||
|
if (file_4 != null && !file_4.isEmpty()) { |
||||
|
image_q4 = fileUpload("4", "q4", file_4); |
||||
|
} |
||||
|
|
||||
|
if (file_5 != null && !file_5.isEmpty()) { |
||||
|
image_q5 = fileUpload("5", "q5", file_5); |
||||
|
} |
||||
|
|
||||
|
if (file_6 != null && !file_6.isEmpty()) { |
||||
|
image_q6 = fileUpload("6", "q6", file_6); |
||||
|
} |
||||
|
|
||||
|
if (file_7 != null && !file_7.isEmpty()) { |
||||
|
image_q7 = fileUpload("7", "q7", file_7); |
||||
|
} |
||||
|
|
||||
|
if (file_8 != null && !file_8.isEmpty()) { |
||||
|
image_q8 = fileUpload("8", "q8", file_8); |
||||
|
} |
||||
|
|
||||
|
if (file_9 != null && !file_9.isEmpty()) { |
||||
|
image_q9 = fileUpload("9", "q9", file_9); |
||||
|
} |
||||
|
|
||||
|
if (file_10 != null && !file_10.isEmpty()) { |
||||
|
image_q10 = fileUpload("10", "q10", file_10); |
||||
|
} |
||||
|
|
||||
|
if (file_11 != null && !file_11.isEmpty()) { |
||||
|
image_q11 = fileUpload("11", "q11", file_11); |
||||
|
} |
||||
|
|
||||
|
String feedbackimg = image; |
||||
|
|
||||
|
String q1_image = image_q1; |
||||
|
String q2_image = image_q2; |
||||
|
String q3_image = image_q3; |
||||
|
String q4_image = image_q4; |
||||
|
String q5_image = image_q5; |
||||
|
String q6_image = image_q6; |
||||
|
String q7_image = image_q7; |
||||
|
String q8_image = image_q8; |
||||
|
String q9_image = image_q9; |
||||
|
String q10_image = image_q10; |
||||
|
String q11_image = image_q11; |
||||
|
|
||||
|
//String type = // Get before & after |
||||
|
|
||||
|
// Get today's date |
||||
|
LocalDate today = LocalDate.now(); |
||||
|
|
||||
|
// Format it in the desired format (yyyy-MM-dd) |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
||||
|
String todayDate = today.format(formatter); |
||||
|
|
||||
|
inactiveFeedBack(type, shelter_id); // Upadte already insert data. |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `bus_shelter_feedback`(" |
||||
|
+ "`shelter_id`, `cby`, " |
||||
|
+ "`q1`, `q2`, `q3`, `q4`, `q5`, `q6`, `q7`, `q8`, `q9`, `q10`, `q11`, " |
||||
|
+ "`remarks`,`latitude`, `longitude`,`zone`,`ward`,`type`,`image`," |
||||
|
+ "`q1_image`, `q2_image`, `q3_image`, `q4_image`, `q5_image`, `q6_image`, " |
||||
|
+ "`q7_image`, `q8_image`, `q9_image`, `q10_image`, `q11_image`" |
||||
|
+ ") " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcBusShelterTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "id" }); |
||||
|
ps.setString(1, shelter_id); |
||||
|
ps.setString(2, cby); |
||||
|
ps.setString(3, q_1); |
||||
|
ps.setString(4, q_2); |
||||
|
ps.setString(5, q_3); |
||||
|
ps.setString(6, q_4); |
||||
|
ps.setString(7, q_5); |
||||
|
ps.setString(8, q_6); |
||||
|
ps.setString(9, q_7); |
||||
|
ps.setString(10, q_8); |
||||
|
ps.setString(11, q_9); |
||||
|
ps.setString(12, q_10); |
||||
|
ps.setString(13, q_11); |
||||
|
ps.setString(14, remarks); |
||||
|
ps.setString(15, latitude); |
||||
|
ps.setString(16, longitude); |
||||
|
ps.setString(17, zone); |
||||
|
ps.setString(18, ward); |
||||
|
ps.setString(19, type); |
||||
|
ps.setString(20, feedbackimg); |
||||
|
|
||||
|
ps.setString(21, q1_image); |
||||
|
ps.setString(22, q2_image); |
||||
|
ps.setString(23, q3_image); |
||||
|
ps.setString(24, q4_image); |
||||
|
ps.setString(25, q5_image); |
||||
|
ps.setString(26, q6_image); |
||||
|
ps.setString(27, q7_image); |
||||
|
ps.setString(28, q8_image); |
||||
|
ps.setString(29, q9_image); |
||||
|
ps.setString(30, q10_image); |
||||
|
ps.setString(31, q11_image); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "A new feedback was inserted successfully!"); |
||||
|
System.out.println("A new feedback was inserted successfully! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert a new feedback. Asset ID:" + shelter_id); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.busshelters.service; |
||||
@ -0,0 +1,285 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.c_d_waste.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
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.mobileservice.c_d_waste.service.c_d_WasteService; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/c_dwaste/api") |
||||
|
@RestController("apiCandDWasteRest") |
||||
|
public class APIC_D_WasteController { |
||||
|
|
||||
|
@Autowired |
||||
|
private c_d_WasteService c_d_WasteService; |
||||
|
|
||||
|
@GetMapping("/getWasteTypeList") |
||||
|
public List<?> getWasteTypeList( |
||||
|
) { |
||||
|
return c_d_WasteService.getWasteTypeList(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/checkComplaintExits") |
||||
|
public List<?> checkComplaintExits( |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return c_d_WasteService.checkComplaintExits(latitude,longitude); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveWaste") |
||||
|
public List<?> saveWaste(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "address", required = true) String address, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "tonage", required = true) String tonage, |
||||
|
@RequestParam(value = "file", required = true) MultipartFile file, |
||||
|
@RequestParam(value = "wastetype", required = true) String type |
||||
|
) { |
||||
|
return c_d_WasteService.saveWaste(cby,latitude,longitude,zone,ward,address,tonage,file, type); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveVendorWaste") |
||||
|
public List<?> saveVendorWaste(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "address", required = true) String address, |
||||
|
@RequestParam(value = "ref_id", required = true) String ref_id, |
||||
|
@RequestParam(value = "tonage", required = true) int tonage, |
||||
|
@RequestParam(value = "file", required = true) MultipartFile file, |
||||
|
@RequestParam(value = "wastetype", required = true) String type |
||||
|
) { |
||||
|
return c_d_WasteService.saveVendorWaste(latitude,longitude,zone,ward,address,tonage,file,type,ref_id); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getComplaintList") |
||||
|
public List<?> getComplaintList( |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = true) String toDATE |
||||
|
) { |
||||
|
return c_d_WasteService.getComplaintList(fromDATE,toDATE); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateComplaint") |
||||
|
public List<?> updateComplaint(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "comp_id", required = true) String wlid, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "after_image", required = true) String file, |
||||
|
@RequestParam(value = "remarks", required = true) String remarks, |
||||
|
@RequestParam(value = "completed_date", required = true) String datetxt, |
||||
|
@RequestParam(value = "tonage", required = true) String tonage |
||||
|
) { |
||||
|
return c_d_WasteService.saveReply(wlid,latitude,longitude,file,remarks,datetxt,tonage); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/getMyticketllist") |
||||
|
public List<?> getMyticketllist( |
||||
|
@RequestParam(value = "loginId", required = true) String loginId |
||||
|
) { |
||||
|
return c_d_WasteService.getMyticketllist(loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getApprovalPendingList") |
||||
|
public List<?> getApprovalPendingList( |
||||
|
@RequestParam(value = "loginId", required = true) String loginId, |
||||
|
@RequestParam(value = "ward", required = true) String ward |
||||
|
) { |
||||
|
return c_d_WasteService.getApprovalPendingList(loginId,ward); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/checkApprovalLocation") |
||||
|
public List<?> checkApprovalLocation( |
||||
|
@RequestParam(value = "comp_id", required = true) String id, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return c_d_WasteService.checkApprovalLocation(id,latitude,longitude); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveApproval") |
||||
|
public List<?> saveApproval(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = true) String loginId, |
||||
|
@RequestParam(value = "comp_id", required = true) String comp_id, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "in_out", required = true) String in_out, |
||||
|
@RequestParam(value = "status", required = true) String status, |
||||
|
@RequestParam(value = "reject_txt", required = false) String reject_txt |
||||
|
) { |
||||
|
return c_d_WasteService.saveApproval(loginId, comp_id, latitude, longitude, in_out, status, reject_txt); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/get2ApprovalPendingList") |
||||
|
public List<?> get2ApprovalPendingList( |
||||
|
@RequestParam(value = "loginId", required = true) String loginId, |
||||
|
@RequestParam(value = "ward", required = true) String ward |
||||
|
) { |
||||
|
return c_d_WasteService.get2ApprovalPendingList(loginId,ward); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/save2Approval") |
||||
|
public List<?> save2Approval(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = true) String loginId, |
||||
|
@RequestParam(value = "comp_id", required = true) String comp_id, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "status", required = true) String status |
||||
|
) { |
||||
|
return c_d_WasteService.save2Approval(loginId, comp_id, latitude, longitude, status); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getZoneWiseCount") |
||||
|
public List<?> getZoneWiseCount( |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = true) String toDATE, |
||||
|
@RequestParam(value = "requestBy", required = false) String requestBy |
||||
|
) { |
||||
|
|
||||
|
if (requestBy == null || requestBy.isBlank()) { |
||||
|
requestBy = "'Vendor','Officer'"; |
||||
|
} |
||||
|
else { |
||||
|
requestBy = "'"+requestBy+"'"; |
||||
|
} |
||||
|
|
||||
|
return c_d_WasteService.getZoneWiseCount(fromDATE,toDATE,requestBy); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getWardWiseCount") |
||||
|
public List<?> getWardWiseCount( |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = true) String toDATE, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "requestBy", required = false) String requestBy |
||||
|
) { |
||||
|
|
||||
|
if (requestBy == null || requestBy.isBlank()) { |
||||
|
requestBy = "'Vendor','Officer'"; |
||||
|
} |
||||
|
else { |
||||
|
requestBy = "'"+requestBy+"'"; |
||||
|
} |
||||
|
|
||||
|
return c_d_WasteService.getWardWiseCount(fromDATE,toDATE, zone,requestBy); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getOfficerZoneWiseCount") |
||||
|
public List<?> getOfficerZoneWiseCount( |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = true) String toDATE, |
||||
|
@RequestParam(value = "requestBy", required = false) String requestBy |
||||
|
) { |
||||
|
|
||||
|
if (requestBy == null || requestBy.isBlank()) { |
||||
|
requestBy = "'Officer'"; |
||||
|
} |
||||
|
else { |
||||
|
requestBy = "'"+requestBy+"'"; |
||||
|
} |
||||
|
|
||||
|
return c_d_WasteService.getOfficerZoneWiseCount(fromDATE,toDATE,requestBy); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getOfficerWardWiseCount") |
||||
|
public List<?> getOfficerWardWiseCount( |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = true) String toDATE, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "requestBy", required = false) String requestBy |
||||
|
) { |
||||
|
|
||||
|
if (requestBy == null || requestBy.isBlank()) { |
||||
|
requestBy = "'Officer'"; |
||||
|
} |
||||
|
else { |
||||
|
requestBy = "'"+requestBy+"'"; |
||||
|
} |
||||
|
|
||||
|
return c_d_WasteService.getOfficerWardWiseCount(fromDATE,toDATE, zone,requestBy); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getVendorZoneWiseCount") |
||||
|
public List<?> getVendorZoneWiseCount( |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = true) String toDATE, |
||||
|
@RequestParam(value = "requestBy", required = false) String requestBy |
||||
|
) { |
||||
|
|
||||
|
if (requestBy == null || requestBy.isBlank()) { |
||||
|
requestBy = "'Vendor'"; |
||||
|
} |
||||
|
else { |
||||
|
requestBy = "'"+requestBy+"'"; |
||||
|
} |
||||
|
|
||||
|
return c_d_WasteService.getVendorZoneWiseCount(fromDATE,toDATE,requestBy); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getVendorWardWiseCount") |
||||
|
public List<?> getVendorWardWiseCount( |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = true) String toDATE, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "requestBy", required = false) String requestBy |
||||
|
) { |
||||
|
|
||||
|
if (requestBy == null || requestBy.isBlank()) { |
||||
|
requestBy = "'Vendor'"; |
||||
|
} |
||||
|
else { |
||||
|
requestBy = "'"+requestBy+"'"; |
||||
|
} |
||||
|
|
||||
|
return c_d_WasteService.getVendorWardWiseCount(fromDATE,toDATE, zone,requestBy); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getListByStatus") |
||||
|
public List<?> getComplaintList( |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = true) String toDATE, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "status", required = true) String status, |
||||
|
@RequestParam(value = "requestBy", required = false) String requestBy |
||||
|
) { |
||||
|
|
||||
|
if (requestBy == null || requestBy.isBlank()) { |
||||
|
requestBy = "'Vendor','Officer'"; |
||||
|
} |
||||
|
else { |
||||
|
requestBy = "'"+requestBy+"'"; |
||||
|
} |
||||
|
|
||||
|
return c_d_WasteService.getListByStatus(fromDATE,toDATE, zone, ward, status,requestBy); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getWardSumReport") |
||||
|
public List<?> getWardSumReport( |
||||
|
@RequestParam(value = "fromDate", required = false) String fromDATE, |
||||
|
@RequestParam(value = "toDate", required = false) String toDATE, |
||||
|
@RequestParam(value = "ward", required = true) String ward |
||||
|
) { |
||||
|
return c_d_WasteService.getWardSumReport(ward); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getTicketDetailsByWLID") |
||||
|
public List<?> getTicketDetailsByWLID( |
||||
|
@RequestParam(value = "wlid", required = true) String wlid |
||||
|
) { |
||||
|
return c_d_WasteService.getTicketDetailsByWLID(wlid); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,59 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.c_d_waste.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
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.mobileservice.c_d_waste.service.c_d_WasteUserService; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/c_dwaste/api") |
||||
|
@RestController("apiCandDUserWasteRest") |
||||
|
public class API_C_D_WasteUserController { |
||||
|
|
||||
|
@Autowired |
||||
|
private c_d_WasteUserService c_d_WasteUserService; |
||||
|
|
||||
|
@PostMapping(value="/saveUserWaste") |
||||
|
public List<?> saveuserWaste(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "latitude", required = false) String latitude, |
||||
|
@RequestParam(value = "longitude", required = false) String longitude, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "address", required = true) String address, |
||||
|
@RequestParam(value = "ref_id", required = true) String ref_id, |
||||
|
@RequestParam(value = "tonage", required = true) String tonage, |
||||
|
@RequestParam(value = "file", required = true) MultipartFile file, |
||||
|
@RequestParam(value = "wastetype", required = true) String type |
||||
|
) { |
||||
|
return c_d_WasteUserService.saveUserWaste(latitude,longitude,zone,ward,address,tonage,file,type,ref_id); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getUserApprovalPendingList") |
||||
|
public List<?> getApprovalPendingList( |
||||
|
@RequestParam(value = "loginId", required = true) String loginId, |
||||
|
@RequestParam(value = "ward", required = true) String ward |
||||
|
) { |
||||
|
return c_d_WasteUserService.getApprovalPendingList(loginId,ward); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveUserApproval") |
||||
|
public List<?> saveApproval(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = true) String loginId, |
||||
|
@RequestParam(value = "comp_id", required = true) String comp_id, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "in_out", required = true) String in_out, |
||||
|
@RequestParam(value = "status", required = true) String status, |
||||
|
@RequestParam(value = "tonage_kg", required = true) String tonage_kg, |
||||
|
@RequestParam(value = "reject_txt", required = false) String reject_txt |
||||
|
) { |
||||
|
return c_d_WasteUserService.saveApproval(loginId, comp_id, latitude, longitude, in_out, status, reject_txt, tonage_kg); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.c_d_waste.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.c_d_waste; |
||||
1397
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/service/c_d_WasteService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1073
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/c_d_waste/service/c_d_WasteUserService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.c_d_waste.service; |
||||
@ -0,0 +1,64 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.component; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import jakarta.servlet.Filter; |
||||
|
import jakarta.servlet.FilterChain; |
||||
|
import jakarta.servlet.FilterConfig; |
||||
|
import jakarta.servlet.ServletException; |
||||
|
import jakarta.servlet.ServletRequest; |
||||
|
import jakarta.servlet.ServletResponse; |
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import javax.sql.DataSource; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
@Component |
||||
|
public class ApiLoggingFilter implements Filter { |
||||
|
|
||||
|
@Autowired |
||||
|
private JdbcTemplate jdbcAPITemplate; |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqlAPIDataSource") DataSource apiDataSource) { |
||||
|
this.jdbcAPITemplate = new JdbcTemplate(apiDataSource); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
||||
|
throws IOException, ServletException { |
||||
|
|
||||
|
System.out.println("API Logging Filter triggered"); |
||||
|
|
||||
|
HttpServletRequest httpRequest = (HttpServletRequest) request; |
||||
|
String ipAddress = request.getRemoteAddr(); |
||||
|
LocalDateTime accessTime = LocalDateTime.now(); |
||||
|
String endpoint = httpRequest.getRequestURI(); |
||||
|
String userAgent = httpRequest.getHeader("User-Agent"); |
||||
|
|
||||
|
// Log to check if filter is being triggered |
||||
|
System.out.println("Request Details: IP Address = " + ipAddress + ", Endpoint = " + endpoint); |
||||
|
|
||||
|
|
||||
|
// Insert log into the database |
||||
|
String sql = "INSERT INTO api_access_log (ip_address, access_time, endpoint, user_agent) VALUES (?, ?, ?, ?)"; |
||||
|
jdbcAPITemplate.update(sql, ipAddress, accessTime, endpoint, userAgent); |
||||
|
|
||||
|
// Continue with the request-response cycle |
||||
|
chain.doFilter(request, response); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void init(FilterConfig filterConfig) throws ServletException { |
||||
|
// Initialization logic if needed |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void destroy() { |
||||
|
// Cleanup logic if needed |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.component; |
||||
@ -0,0 +1,26 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.configuration; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.component.ApiLoggingFilter; |
||||
|
|
||||
|
@Configuration |
||||
|
public class WebConfig { |
||||
|
|
||||
|
@Autowired |
||||
|
private ApiLoggingFilter apiLoggingFilter; |
||||
|
|
||||
|
// Register the ApiLoggingFilter using FilterRegistrationBean |
||||
|
@Bean |
||||
|
public FilterRegistrationBean<ApiLoggingFilter> loggingFilter() { |
||||
|
FilterRegistrationBean<ApiLoggingFilter> registrationBean = new FilterRegistrationBean<>(); |
||||
|
registrationBean.setFilter(apiLoggingFilter); // Set the filter |
||||
|
registrationBean.addUrlPatterns("/**/api/*"); // Apply to all API endpoints |
||||
|
registrationBean.setOrder(1); // Optional: Set order if needed |
||||
|
System.out.println("API Logging Filter Registered for URL patterns: /api/*"); |
||||
|
return registrationBean; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,149 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gcceducation.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
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.mobileservice.gcceducation.service.EducationActivity; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/gcceducation/") |
||||
|
@RestController("gccofficialappEducationRest") |
||||
|
public class EducationController { |
||||
|
@Autowired |
||||
|
private JdbcTemplate jdbcEducationTemplate; |
||||
|
|
||||
|
@Autowired |
||||
|
private EducationActivity educationActivity; |
||||
|
|
||||
|
@GetMapping(value="/getUnmapSchoolList") |
||||
|
public List<?> getSchoolList(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId){ |
||||
|
return educationActivity.getUnmapSchoolList(formData,loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getSchoolList") |
||||
|
public List<?> getSchoolList(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId){ |
||||
|
return educationActivity.getSchoolList(formData, latitude, longitude, loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getMenu") |
||||
|
public List<?> getMenu(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId){ |
||||
|
return educationActivity.getMenu(formData, loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getBuildings") |
||||
|
public List<?> getBuildings(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(required = true) String school_details_id, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId){ |
||||
|
return educationActivity.getBuildings(formData, school_details_id, loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getBuilding_list") |
||||
|
public List<?> getBuilding_list(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(required = true) String school_details_id, |
||||
|
@RequestParam(required = true) String menu_id, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId){ |
||||
|
return educationActivity.getBuilding_list(formData, school_details_id, menu_id, loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getFloor_list") |
||||
|
public List<?> getFloor_list(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(required = true) String school_details_id, |
||||
|
@RequestParam(required = true) String menu_id, |
||||
|
@RequestParam(required = true) String building_id, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId){ |
||||
|
return educationActivity.getFloor_list(formData, school_details_id, menu_id, building_id, loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getRoom_list") |
||||
|
public List<?> getRoom_list(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(required = true) String school_details_id, |
||||
|
@RequestParam(required = true) String menu_id, |
||||
|
@RequestParam(required = true) String building_id, |
||||
|
@RequestParam(required = true) String floors_id, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId){ |
||||
|
return educationActivity.getRoom_list(formData, school_details_id, menu_id, building_id, floors_id, loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getParentQuestionsList") |
||||
|
public List<?> getParentQuestionsList( |
||||
|
@RequestParam(required = true) String school_details_id, |
||||
|
@RequestParam(value="menu_id", required = true) String menu_id, |
||||
|
@RequestParam(required = true) String building_id, |
||||
|
@RequestParam(required = true) String floors_id, |
||||
|
@RequestParam(required = true) String room_id, |
||||
|
@RequestParam(value="loginId", required = false) String cby, |
||||
|
@RequestParam(value="qtype", required = true) String qtype){ |
||||
|
return educationActivity.getParentQuestionsList(school_details_id, menu_id, building_id, floors_id, room_id, qtype); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getChildQuestionsList") |
||||
|
public List<?> getChildQuestionsList( |
||||
|
@RequestParam(required = true) String school_details_id, |
||||
|
@RequestParam(required = true) String menu_id, |
||||
|
@RequestParam(required = true) String building_id, |
||||
|
@RequestParam(required = true) String floors_id, |
||||
|
@RequestParam(required = true) String room_id, |
||||
|
@RequestParam(value="loginId", required = false) String cby, |
||||
|
@RequestParam(value="pid", required = true) String pid |
||||
|
){ |
||||
|
return educationActivity.getChildQuestionsList(school_details_id, menu_id, building_id, floors_id, room_id, pid); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/saveFeedback") |
||||
|
public List<?> saveFeedback( |
||||
|
@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam Map<String, MultipartFile> fileMap, |
||||
|
@RequestParam(required = true) String school_details_id, |
||||
|
@RequestParam(required = true) String building_id, |
||||
|
@RequestParam(required = true) String floor_id, |
||||
|
@RequestParam(required = true) String room_id, |
||||
|
@RequestParam(required = true) String categoryId, |
||||
|
@RequestParam(required = true) String zone, |
||||
|
@RequestParam(required = true) String division, |
||||
|
@RequestParam(required = true) String latitude, |
||||
|
@RequestParam(required = true) String longitude, |
||||
|
@RequestParam(required = true) String inby |
||||
|
) { |
||||
|
return educationActivity.saveFeedback( |
||||
|
formData, fileMap, school_details_id, building_id, floor_id, room_id, |
||||
|
categoryId, zone, division, latitude, longitude, inby); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/saveCompoundAndBoard") |
||||
|
public ResponseEntity<?> saveCompoundAndBoard( |
||||
|
|
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, // file is optional |
||||
|
@RequestParam(required = true) int school_details_id, // school_details_id is optional |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam double latitude, |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id ) { |
||||
|
|
||||
|
try { |
||||
|
// Save feedback for both questions |
||||
|
//educationActivity.saveCompoundAndBoard(categoryId, newboardconstructQa, newboardconstructAns, |
||||
|
// SchoolunderConstructQa, SchoolunderConstructAns, feedPhoto, school_details_id, zone, division,latitude,longitude,user_id); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gcceducation.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gcceducation; |
||||
1067
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gcceducation/service/EducationActivity.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gcceducation.service; |
||||
@ -0,0 +1,267 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccstreetvendor.controller; |
||||
|
|
||||
|
import com.fasterxml.jackson.databind.JsonNode; |
||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
|
import in.gov.chennaicorporation.mobileservice.configuration.AppConfig; |
||||
|
import in.gov.chennaicorporation.mobileservice.gccstreetvendor.service.StreetVendorService; |
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import jakarta.servlet.http.HttpSession; |
||||
|
import org.bytedeco.opencv.presets.opencv_core; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.web.client.RestTemplate; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.*; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/streetvendor") |
||||
|
@RestController("gccofficialappstreetvendor") |
||||
|
|
||||
|
public class StreetVendorController { |
||||
|
|
||||
|
@Autowired |
||||
|
StreetVendorService streetVendorService; |
||||
|
|
||||
|
@Autowired |
||||
|
AppConfig appConfig; |
||||
|
|
||||
|
//To fetch all social category |
||||
|
@GetMapping("/social-categories") |
||||
|
public List<Map<String,Object>> getSocialCategories() { |
||||
|
return streetVendorService.getAllSocialCategories(); |
||||
|
} |
||||
|
|
||||
|
//To fetch all vending category |
||||
|
@GetMapping("/vending-categories") |
||||
|
public List<Map<String,Object>> getVendingCategories() { |
||||
|
return streetVendorService.getAllVendingCategories(); |
||||
|
} |
||||
|
|
||||
|
// To save Vendor details |
||||
|
@PostMapping("/save-street-vendor") |
||||
|
public ResponseEntity<String> saveStreetVendor( |
||||
|
@RequestParam("name") String name, |
||||
|
@RequestParam("fh_name") String fhname, |
||||
|
@RequestParam("gender") String gender, |
||||
|
@RequestParam("dob") String dob, |
||||
|
@RequestParam("social_category") String socialCategory, |
||||
|
@RequestParam("diff_abled") boolean diffAbled, |
||||
|
@RequestParam("mob_no") String mobileNo, |
||||
|
@RequestParam("aadhar_no") String aadharNo, |
||||
|
@RequestParam("present_address") String presentAddress, |
||||
|
@RequestParam("present_district") String presentDistrict, |
||||
|
@RequestParam("present_pincode") String presentPincode, |
||||
|
@RequestParam("vending_address") String vendingAddress, |
||||
|
@RequestParam("vending_district") String vendingDistrict, |
||||
|
@RequestParam("vending_pincode") String vendingPincode, |
||||
|
@RequestParam("vending_category") String vendingCategory, |
||||
|
@RequestParam("vending_space") String vendingSpace, |
||||
|
@RequestParam("bank_acc_status") boolean bankAccStatus, |
||||
|
@RequestParam("zone") String zone, |
||||
|
@RequestParam("ward") String ward, |
||||
|
@RequestParam("pm_svanidhi_loan") boolean pmSvanidhiLoan, |
||||
|
@RequestParam(required = false, name = "bank_passbook") MultipartFile bankPassbook, |
||||
|
@RequestParam("ration_card") MultipartFile rationCard, |
||||
|
@RequestParam("education_status") int education_status, |
||||
|
@RequestParam("marital_status") int marital_status, |
||||
|
@RequestParam("no_of_fam_mem") int no_of_fam_mem, |
||||
|
@RequestParam("fam_mem_invol_str_ven") boolean are_fam_mem_invol_str_ven, |
||||
|
@RequestParam("street_vendor_photo") MultipartFile streetVendorPhoto, |
||||
|
@RequestParam("aadhar_front_photo") MultipartFile aadharFrontPhoto, |
||||
|
@RequestParam("aadhar_back_photo") MultipartFile aadharBackPhoto) { |
||||
|
|
||||
|
// File upload paths |
||||
|
String bankPassbookPath = (bankPassbook != null) ? |
||||
|
streetVendorService.fileUpload(bankPassbook, "street_vendor_bank") : ""; |
||||
|
|
||||
|
String rationCardPath = (rationCard != null) ? |
||||
|
streetVendorService.fileUpload(rationCard, "street_vendor_ration") : ""; |
||||
|
|
||||
|
String streetVendorPhotoPath = (streetVendorPhoto != null) ? |
||||
|
streetVendorService.fileUpload(streetVendorPhoto, "street_vendor_photo") : ""; |
||||
|
|
||||
|
String aadharFrontPhotoPath = (aadharFrontPhoto != null) ? |
||||
|
streetVendorService.fileUpload(aadharFrontPhoto, "aadhar_front") : ""; |
||||
|
|
||||
|
String aadharBackPhotoPath = (aadharBackPhoto != null) ? |
||||
|
streetVendorService.fileUpload(aadharBackPhoto, "aadhar_back") : ""; |
||||
|
|
||||
|
// Save to DB |
||||
|
String saveStatus = streetVendorService.saveStreetVendorDetails( |
||||
|
name, fhname, gender, dob, socialCategory, diffAbled, mobileNo, aadharNo, |
||||
|
presentAddress, presentDistrict, presentPincode, |
||||
|
vendingAddress, vendingDistrict, vendingPincode, |
||||
|
vendingCategory, vendingSpace, bankAccStatus, zone, ward, pmSvanidhiLoan, |
||||
|
bankPassbookPath, rationCardPath, streetVendorPhotoPath, |
||||
|
aadharFrontPhotoPath, aadharBackPhotoPath, |
||||
|
education_status,marital_status,no_of_fam_mem,are_fam_mem_invol_str_ven |
||||
|
); |
||||
|
|
||||
|
if (saveStatus == null || saveStatus.isEmpty() || saveStatus.equals("error")) { |
||||
|
return ResponseEntity.ok(Map.of( |
||||
|
"status", false, |
||||
|
"message", "failed", |
||||
|
"description", "Failed to save the details" |
||||
|
).toString()); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(Map.of( |
||||
|
"status", true, |
||||
|
"message", "success", |
||||
|
"description", "Details were saved successfully" |
||||
|
).toString()); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = "/sendOTP") |
||||
|
@ResponseBody |
||||
|
public Map<String, Object> sendOtp(HttpServletRequest request, @RequestParam String mobile) { |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
String MobileNo = mobile; |
||||
|
Random rand = new Random(); |
||||
|
int otp = rand.nextInt(9000) + 1000;; |
||||
|
|
||||
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm"); |
||||
|
LocalDateTime now = LocalDateTime.now(); |
||||
|
|
||||
|
String generatedToken = "Welcome to GCC! Your OTP for GCC Street Vendor Application is " + otp; |
||||
|
String key = "pfTEYN6H"; |
||||
|
String urlString = appConfig.otpurl + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + |
||||
|
"&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407174410515874750"; |
||||
|
|
||||
|
try { |
||||
|
RestTemplate restTemplate = new RestTemplate(); |
||||
|
String apiResponse = restTemplate.getForObject(urlString, String.class); |
||||
|
|
||||
|
// Parse the response using ObjectMapper |
||||
|
ObjectMapper objectMapper = new ObjectMapper(); |
||||
|
JsonNode jsonNode = objectMapper.readTree(apiResponse); |
||||
|
|
||||
|
int statusCode = jsonNode.get("status").asInt(); |
||||
|
String description = jsonNode.get("description").asText(); |
||||
|
|
||||
|
if (statusCode == 100) { |
||||
|
HttpSession session = request.getSession(); |
||||
|
session.setAttribute("otp", otp); |
||||
|
response.put("status", true); |
||||
|
} else { |
||||
|
response.put("status", false); |
||||
|
} |
||||
|
|
||||
|
response.put("description", description); |
||||
|
response.put("otp", otp); // Optional: for debugging only (don't include in production) |
||||
|
} catch (Exception e) { |
||||
|
response.put("status", false); |
||||
|
response.put("description", "Error sending OTP: " + e.getMessage()); |
||||
|
} |
||||
|
|
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = "/verifyOTP") |
||||
|
@ResponseBody |
||||
|
public Map<String, Object> verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
HttpSession session = request.getSession(); |
||||
|
|
||||
|
try { |
||||
|
Integer session_otp = (Integer) session.getAttribute("otp"); |
||||
|
Integer entered_otp = Integer.parseInt(otp); |
||||
|
|
||||
|
//System.out.println("session_otp---:" + session_otp); |
||||
|
//System.out.println("entered_otp---:" + entered_otp); |
||||
|
|
||||
|
if (session_otp != null && session_otp.equals(entered_otp)) { |
||||
|
session.setAttribute("verifiedotp", "success"); |
||||
|
response.put("status", true); |
||||
|
response.put("message", "Success"); |
||||
|
} else { |
||||
|
session.setAttribute("verifiedotp", "error"); |
||||
|
response.put("status", false); |
||||
|
response.put("message", "Incorrect OTP"); |
||||
|
} |
||||
|
} catch (NumberFormatException e) { |
||||
|
//System.out.println("Invalid OTP format: " + otp); |
||||
|
response.put("status", false); |
||||
|
response.put("message", "Invalid OTP format"); |
||||
|
} catch (Exception e) { |
||||
|
//System.out.println("Error verifying OTP: " + e.getMessage()); |
||||
|
response.put("status", false); |
||||
|
response.put("message", "Error verifying OTP"); |
||||
|
} |
||||
|
|
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getvendorlist") |
||||
|
public List<Map<String, Object>> getVendorList( |
||||
|
@RequestParam(value = "loginId", required = false) String loginid |
||||
|
) { |
||||
|
return streetVendorService.getAllVendorDetails(loginid); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getvendingtimes") |
||||
|
public List<Map<String, Object>> getVendingTimes() { |
||||
|
return streetVendorService.getAllVendingTimes(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getmaritalstatus") |
||||
|
public List<Map<String, Object>> getMaritalStatus() { |
||||
|
return streetVendorService.getAllMaritalStatus(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/gettransactionmodes") |
||||
|
public List<Map<String, Object>> getTransactionMode() { |
||||
|
return streetVendorService.getAllTransactionModes(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/geteducationstatus") |
||||
|
public List<Map<String, Object>> getEducationSatus() { |
||||
|
return streetVendorService.getAllEducationSatus(); |
||||
|
} |
||||
|
|
||||
|
// save the entered li details |
||||
|
@PostMapping("/saveFirstApproval") |
||||
|
public ResponseEntity<String> saveFirstApproval( |
||||
|
@RequestParam(required = true, name = "loginId") String loginid, |
||||
|
@RequestParam(required = true, name = "vdid") String vdid, |
||||
|
@RequestParam(required = false, name = "vendor_type") String vendor_type, |
||||
|
@RequestParam(required = true, name = "latitude") String latitude, |
||||
|
@RequestParam(required = true, name = "longitude") String longitude, |
||||
|
@RequestParam(required = false, name = "vendor_id_card") boolean vendor_id_card, |
||||
|
@RequestParam(required = false, name = "vending_nature") String vending_nature, |
||||
|
@RequestParam(required = false, name = "vending_time") String vending_time, |
||||
|
//@RequestParam(required = false, name = "education_status") String education_status, |
||||
|
//@RequestParam(required = false, name = "marital_status") String marital_status, |
||||
|
//@RequestParam(required = false, name = "no_of_family_mem") String no_of_family_mem, |
||||
|
//@RequestParam(required = false, name = "fam_mem_street_vendor") boolean fam_mem_street_vendor, |
||||
|
@RequestParam(required = false, name = "transaction_mode") String transaction_mode, |
||||
|
@RequestParam(required = false, name = "svanidhi_loan_amount") String svanidhi_loan_amount, |
||||
|
@RequestParam(required = false, name = "vendor_space_photo") MultipartFile vendor_space_photo, |
||||
|
@RequestParam(required = true, name = "status") String status, |
||||
|
@RequestParam(required = true, name = "remarks") String remarks){ |
||||
|
|
||||
|
|
||||
|
String vendor_space_path = ""; |
||||
|
if ( vendor_space_photo != null) { |
||||
|
vendor_space_path = streetVendorService.fileUpload(vendor_space_photo, "vendor_space_photo"); |
||||
|
} |
||||
|
//String status = "Approved"; |
||||
|
|
||||
|
String saveStatus = streetVendorService.saveFirstApproval(loginid,vdid,vendor_type, latitude, longitude, vendor_id_card, vending_nature, |
||||
|
vending_time, transaction_mode, |
||||
|
svanidhi_loan_amount, status, remarks, vendor_space_path); |
||||
|
|
||||
|
if (saveStatus ==null || saveStatus.isEmpty()) { |
||||
|
return ResponseEntity.ok(Map |
||||
|
.of("status", false, "message", "failed", "description", "Failed to save the details").toString()); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(Map |
||||
|
.of("status", true, "message", "success", "description", "Details were saved successfully").toString()); |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccstreetvendor.controller; |
||||
@ -0,0 +1,337 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccstreetvendor.service; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; |
||||
|
import jakarta.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.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; |
||||
|
|
||||
|
|
||||
|
import javax.imageio.ImageIO; |
||||
|
import javax.imageio.ImageWriteParam; |
||||
|
import javax.imageio.ImageWriter; |
||||
|
import javax.imageio.stream.ImageOutputStream; |
||||
|
import javax.sql.DataSource; |
||||
|
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.sql.Statement; |
||||
|
import java.time.LocalDate; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
@Service |
||||
|
public class StreetVendorService { |
||||
|
|
||||
|
@Autowired |
||||
|
private JdbcTemplate jdbcStreetVendorTemplate; |
||||
|
|
||||
|
private final Environment environment; |
||||
|
private String fileBaseUrl; |
||||
|
|
||||
|
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
||||
|
private static final int STRING_LENGTH = 15; |
||||
|
private static final Random RANDOM = new SecureRandom(); |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqlGccStreetVendorDataSource") DataSource streetVendorDataSource) { |
||||
|
this.jdbcStreetVendorTemplate = new JdbcTemplate(streetVendorDataSource); |
||||
|
} |
||||
|
|
||||
|
public StreetVendorService(Environment environment) { |
||||
|
this.environment = environment; |
||||
|
this.fileBaseUrl = environment.getProperty("fileBaseUrl"); |
||||
|
} |
||||
|
|
||||
|
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(); |
||||
|
} |
||||
|
|
||||
|
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 String fileUpload(MultipartFile file, String name) { |
||||
|
|
||||
|
// Set the file path where you want to save it |
||||
|
String uploadDirectory = environment.getProperty("file.upload.directory"); |
||||
|
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); |
||||
|
|
||||
|
System.out.println(filePath); |
||||
|
return filepath_txt; |
||||
|
|
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
return "Failed to save file " + file.getOriginalFilename(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public String getWardByLoginId(String loginid, String type) { |
||||
|
String sqlQuery = "SELECT `ward` FROM `gcc_penalty_hoardings`.`hoading_user_list` WHERE `userid` = ? LIMIT 1"; |
||||
|
|
||||
|
// Query the database using queryForList |
||||
|
List<Map<String, Object>> results = jdbcStreetVendorTemplate.queryForList(sqlQuery, loginid); |
||||
|
|
||||
|
// Check if results is not empty and extract the ward value |
||||
|
if (!results.isEmpty()) { |
||||
|
// Extract the ward value from the first result |
||||
|
return (String) results.get(0).get("ward"); |
||||
|
} |
||||
|
|
||||
|
// Handle the case where no result is found |
||||
|
return "000"; // or return null based on your needs |
||||
|
} |
||||
|
|
||||
|
//To fetch all social category |
||||
|
public List<Map<String,Object>> getAllSocialCategories() { |
||||
|
String sql = "SELECT id, category_name FROM social_category_master WHERE is_active = true AND is_delete = false"; |
||||
|
return jdbcStreetVendorTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
//To fetch all vending category |
||||
|
public List<Map<String,Object>> getAllVendingCategories() { |
||||
|
String sql = "SELECT id, vending_category_name FROM vending_category_master WHERE is_active = true AND is_delete = false"; |
||||
|
return jdbcStreetVendorTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
// To save Vendor details |
||||
|
public String saveStreetVendorDetails(String name, String fhname, String gender, String dob, String socialCategory, |
||||
|
boolean diffAbled, String mobNo, String aadharNo, String presentAddress, String presentDistrict, |
||||
|
String presentPincode, String vendingAddress, String vendingDistrict, String vendingPincode, |
||||
|
String vendingCategory, String vendingSpace, boolean bankAccStatus, String zone, String ward, |
||||
|
boolean pmSvanidhiLoan, String bankPassbookPath, String rationCardPath, String streetVendorPhotoPath, |
||||
|
String aadharFrontPhotoPath, String aadharBackPhotoPath, |
||||
|
int educationStatus, int maritalStatus, int noOfFamMem,boolean areAnyFamMemInvolStrVen) { |
||||
|
|
||||
|
String sql = "INSERT INTO vendor_details (" |
||||
|
+ "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, zone, ward, pm_svanidhi_loan, " |
||||
|
+ "bank_passbook, ration_card_photo, street_vendor_photo, aadhar_front_photo, aadhar_back_photo, " |
||||
|
+ "education_status, marital_status, no_of_fam_mem, are_any_fam_mem_invol_str_ven" |
||||
|
+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int result = jdbcStreetVendorTemplate.update(connection -> { |
||||
|
PreparedStatement ps = connection.prepareStatement(sql, new String[] { "id" }); |
||||
|
ps.setString(1, name); |
||||
|
ps.setString(2, fhname); |
||||
|
ps.setString(3, gender); |
||||
|
ps.setString(4, dob); |
||||
|
ps.setString(5, socialCategory); |
||||
|
ps.setBoolean(6, diffAbled); |
||||
|
ps.setString(7, mobNo); |
||||
|
ps.setString(8, aadharNo); |
||||
|
ps.setString(9, presentAddress); |
||||
|
ps.setString(10, presentDistrict); |
||||
|
ps.setString(11, presentPincode); |
||||
|
ps.setString(12, vendingAddress); |
||||
|
ps.setString(13, vendingDistrict); |
||||
|
ps.setString(14, vendingPincode); |
||||
|
ps.setString(15, vendingCategory); |
||||
|
ps.setString(16, vendingSpace); |
||||
|
ps.setBoolean(17, bankAccStatus); |
||||
|
ps.setString(18, zone); |
||||
|
ps.setString(19, ward); |
||||
|
ps.setBoolean(20, pmSvanidhiLoan); |
||||
|
ps.setString(21, bankPassbookPath); |
||||
|
ps.setString(22, rationCardPath); |
||||
|
ps.setString(23, streetVendorPhotoPath); |
||||
|
ps.setString(24, aadharFrontPhotoPath); |
||||
|
ps.setString(25, aadharBackPhotoPath); |
||||
|
ps.setInt(26, educationStatus); |
||||
|
ps.setInt(27, maritalStatus); |
||||
|
ps.setInt(28, noOfFamMem); |
||||
|
ps.setBoolean(29, areAnyFamMemInvolStrVen); |
||||
|
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 = ? "; |
||||
|
jdbcStreetVendorTemplate.update(updateSql,refId, generatedId); |
||||
|
return refId; |
||||
|
} |
||||
|
//return "error"; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return "error"; |
||||
|
} |
||||
|
|
||||
|
// To fetch street vendor details |
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> getAllVendorDetails(String loginid) { |
||||
|
|
||||
|
String ward = getWardByLoginId(loginid,"li"); |
||||
|
|
||||
|
StringBuilder query = new StringBuilder( |
||||
|
" SELECT vd.id, vd.name, vd.f_h_name, vd.gender, vd.zone, vd.ward," + |
||||
|
" vd.dob,vd.mob_no, vd.vending_space, vd.pm_svanidhi_loan, vd.bank_acc_status, " + |
||||
|
" vd.diff_abled, scm.category_name, vcm.vending_category_name," + |
||||
|
" em.education, msm.marital_status, vd.no_of_fam_mem, CASE " |
||||
|
+ " WHEN vd.are_any_fam_mem_invol_str_ven = TRUE THEN 'Yes' " |
||||
|
+ " ELSE 'No' " |
||||
|
+ " END AS family_member_involved, " + |
||||
|
" CONCAT(vd.present_district, ', ', vd.present_pincode, ', ', vd.present_address) AS residental_address," + |
||||
|
" CONCAT(vd.vending_district, ', ', vd.vending_pincode, ', ', vd.vending_address) AS business_address," + |
||||
|
|
||||
|
" CONCAT('" + fileBaseUrl + "/gccofficialapp/files',vd.street_vendor_photo) as street_vendor_photo," + |
||||
|
" CONCAT('" + fileBaseUrl + "/gccofficialapp/files',vd.aadhar_front_photo) as aadhar_front_photo," + |
||||
|
" CONCAT('" + fileBaseUrl + "/gccofficialapp/files',vd.aadhar_back_photo) as aadhar_back_photo," + |
||||
|
" CONCAT('" + fileBaseUrl + "/gccofficialapp/files',vd.ration_card_photo) as ration_card_photo," + |
||||
|
" CONCAT('" + fileBaseUrl + "/gccofficialapp/files',vd.bank_passbook) as bank_passbook," + |
||||
|
|
||||
|
" DATE_FORMAT(vd.cdate, '%d-%m-%Y') as request_date" + |
||||
|
" 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` msm ON vd.marital_status=msm.id " + |
||||
|
" WHERE vd.ward IN (?)"); |
||||
|
|
||||
|
return jdbcStreetVendorTemplate.queryForList(query.toString(),ward); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public List<Map<String, Object>> getAllVendingTimes() { |
||||
|
String sql = " SELECT id, vending_time FROM vending_time_master WHERE is_active = 1 AND is_delete = 0 "; |
||||
|
return jdbcStreetVendorTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getAllMaritalStatus() { |
||||
|
String sql = " SELECT id, marital_status FROM marital_status_master WHERE is_active = 1 AND is_delete = 0 "; |
||||
|
return jdbcStreetVendorTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getAllTransactionModes() { |
||||
|
String sql = "SELECT id, transaction_mode FROM transaction_mode_master WHERE is_active = 1 AND is_delete = 0"; |
||||
|
return jdbcStreetVendorTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getAllEducationSatus() { |
||||
|
String sql = "SELECT id, education FROM education_master WHERE is_active = 1 AND is_delete = 0"; |
||||
|
return jdbcStreetVendorTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
public String saveFirstApproval(String loginid, String vdid, String vendor_type, String latitude, String longitude, |
||||
|
boolean vendor_id_card, String vending_nature, String vending_time, |
||||
|
String transaction_mode,String svanidhi_loan_amount, |
||||
|
String status, String remarks, String vendor_space_path) { |
||||
|
|
||||
|
String sql = "INSERT INTO vendor_approval (" |
||||
|
+ "vendor_type, latitude, longitude, vendor_id_card, vending_nature, vendor_timing_id, transaction_mode_id, swanidi_loan_amount, status, remarks, " |
||||
|
+ "vendor_space_photo, vdid, cby" |
||||
|
+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
|
||||
|
int result = jdbcStreetVendorTemplate.update(connection -> { |
||||
|
PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); |
||||
|
ps.setString(1, vendor_type); |
||||
|
ps.setString(2, latitude); |
||||
|
ps.setString(3, longitude); |
||||
|
ps.setBoolean(4, vendor_id_card); |
||||
|
ps.setString(5, vending_nature); |
||||
|
ps.setString(6, vending_time); |
||||
|
|
||||
|
ps.setString(7, transaction_mode); |
||||
|
ps.setString(8, svanidhi_loan_amount); |
||||
|
ps.setString(9, status); |
||||
|
ps.setString(10, remarks); |
||||
|
ps.setString(11, vendor_space_path); |
||||
|
ps.setString(12, vdid); |
||||
|
ps.setString(13, loginid); |
||||
|
// ps.setString(16, vendingSpace); add the additional flag variable |
||||
|
|
||||
|
return ps; |
||||
|
}, keyHolder); |
||||
|
|
||||
|
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 = ? "; |
||||
|
jdbcStreetVendorTemplate.update(updateSql,refId, generatedId); |
||||
|
return refId; |
||||
|
} |
||||
|
|
||||
|
return "error"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccstreetvendor.service; |
||||
@ -0,0 +1,213 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.mosquitosurvey.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
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.mobileservice.mosquitosurvey.service.FoggingService; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/mosquito/api") |
||||
|
@RestController("apiFoggingRest") |
||||
|
public class API_FoggingController { |
||||
|
@Autowired |
||||
|
private FoggingService foggingService; |
||||
|
|
||||
|
@GetMapping("/getMaintainByList") |
||||
|
public List<?> getMaintainByList() { |
||||
|
return foggingService.getMaintainByList(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getCanalsList") |
||||
|
public List<?> getCanalsList( |
||||
|
@RequestParam(value = "maintainedby", required = true) String maintainedby, |
||||
|
@RequestParam(value = "zone", required = true) String zone |
||||
|
) { |
||||
|
return foggingService.getCanalsList(maintainedby, zone); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveCanalFlow") |
||||
|
public List<?> saveCanalFlow(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "category", required = true) String cid, |
||||
|
@RequestParam(value = "typeofsite", required = true) String scid, |
||||
|
@RequestParam(value = "maintainedby", required = true) String maintainedby, |
||||
|
@RequestParam(value = "canalid", required = true) String canalid, |
||||
|
@RequestParam(value = "sprayingmedium", required = true) String q4, |
||||
|
@RequestParam(value = "sprayingtype", required = true) String q5, |
||||
|
@RequestParam(value = "file", required = true) MultipartFile file, |
||||
|
@RequestParam(value = "remarks", required = true) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return foggingService.saveCanalFlow(cid,scid,maintainedby,canalid,q4,q5,file,remarks,cby,zone,ward,latitude,longitude,"pending"); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/checkHasCanalPending") |
||||
|
public List<?> checkHasPending( |
||||
|
@RequestParam(value = "loginId", required = true) String cby |
||||
|
) { |
||||
|
return foggingService.checkHasCanalPending(cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getCanalPendingList") |
||||
|
public List<?> getCanalPendingList( |
||||
|
@RequestParam(value = "loginId", required = true) String cby |
||||
|
) { |
||||
|
return foggingService.getCanalPendingList(cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/checkCanalPendingUpdateLocation") |
||||
|
public List<?> checkPendingUpdateLocation( |
||||
|
@RequestParam(value = "activityid", required = true) String canalactivityid, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return foggingService.checkCanalPendingUpdateLocation(canalactivityid,latitude,longitude); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveCanalData") |
||||
|
public List<?> saveCanalFlow(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "activityid", required = true) String canalactivityid, |
||||
|
@RequestParam(value = "isfinal", required = true) String isfinal, |
||||
|
@RequestParam(value = "file", required = true) MultipartFile file, |
||||
|
@RequestParam(value = "remarks", required = true) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return foggingService.saveCanalActivityData(canalactivityid,isfinal,file,remarks,cby,zone,ward,latitude,longitude); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// ************************************************************************************************************************* // |
||||
|
// For SWD Activity |
||||
|
|
||||
|
@PostMapping(value="/saveSWDFlow") |
||||
|
public List<?> saveSWDFlow(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "category", required = true) String cid, |
||||
|
@RequestParam(value = "typeofsite", required = true) String scid, |
||||
|
@RequestParam(value = "streetname", required = true) String streetname, |
||||
|
@RequestParam(value = "streetid", required = true) String streetid, |
||||
|
@RequestParam(value = "breedfound", required = true) String q2, |
||||
|
@RequestParam(value = "sprayingmedium", required = true) String q4, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
@RequestParam(value = "remarks", required = true) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return foggingService.saveSWDFlow(cid,scid,streetname,streetid,q2,q4,file,remarks,cby,zone,ward,latitude,longitude,"pending"); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/checkHasSWDPending") |
||||
|
public List<?> checkHasSWDPending( |
||||
|
@RequestParam(value = "loginId", required = true) String cby |
||||
|
) { |
||||
|
return foggingService.checkHasSWDPending(cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getSWDPendingList") |
||||
|
public List<?> getSWDPendingList( |
||||
|
@RequestParam(value = "loginId", required = true) String cby |
||||
|
) { |
||||
|
return foggingService.getSWDPendingList(cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/checkSWDPendingUpdateLocation") |
||||
|
public List<?> checkSWDPendingUpdateLocation( |
||||
|
@RequestParam(value = "activityid", required = true) String swdactivityid, |
||||
|
@RequestParam(value = "streetid", required = true) String streetid |
||||
|
) { |
||||
|
return foggingService.checkSWDPendingUpdateLocation(swdactivityid,streetid); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateSWDPendingStatus") |
||||
|
public List<?> updatePendingStatus(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "activityid", required = true) String swdactivityid, |
||||
|
@RequestParam(value = "file", required = true) MultipartFile file, |
||||
|
@RequestParam(value = "streetname", required = true) String streetname, |
||||
|
@RequestParam(value = "streetid", required = true) String streetid, |
||||
|
@RequestParam(value = "q2", required = true) String q2, |
||||
|
@RequestParam(value = "q4", required = true) String q4, |
||||
|
@RequestParam(value = "remarks", required = true) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "did", required = true) String did |
||||
|
) { |
||||
|
return foggingService.updateSWDPendingStatus(swdactivityid, file, streetname, streetid, |
||||
|
q2, q4, remarks, cby, zone, ward, latitude, longitude, "close", did); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveStreetData") |
||||
|
public List<?> saveStreetData(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "category", required = true) String cid, |
||||
|
@RequestParam(value = "typeofsite", required = true) String scid, |
||||
|
@RequestParam(value = "streetid", required = true) String streetid, |
||||
|
@RequestParam(value = "streetname", required = true) String streetname, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
@RequestParam(value = "remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return foggingService.saveStreetData(cid, scid, streetid, streetname, file, remarks, cby, zone, ward, latitude, longitude, "close"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveVacantLandData") |
||||
|
public List<?> saveVacantLandData(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "category", required = true) String cid, |
||||
|
@RequestParam(value = "typeofsite", required = true) String scid, |
||||
|
@RequestParam(value = "name", required = true) String name, |
||||
|
@RequestParam(value = "breedfound", required = true) String q2, |
||||
|
@RequestParam(value = "action", required = false) String q3, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
@RequestParam(value = "remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return foggingService.saveVacantLandData(cid, scid, name, q2, q3, file, remarks, cby, zone, ward, latitude, longitude, "close"); |
||||
|
} |
||||
|
|
||||
|
// SAMPLE COLLECTION |
||||
|
@PostMapping(value="/saveLarvalAdultCollectionFlow") |
||||
|
public List<?> saveLarvalAdultCollectionFlow(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "category", required = true) String cid, |
||||
|
@RequestParam(value = "maintainedby", required = true) String maintainedby, |
||||
|
@RequestParam(value = "canalid", required = true) String canalid, |
||||
|
@RequestParam(value = "breedfound", required = true) String q2, |
||||
|
@RequestParam(value = "lavasample", required = false) String q6, |
||||
|
@RequestParam(value = "action", required = false) String q7, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
@RequestParam(value = "remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return foggingService.saveLarvalAdultCollectionFlow(cid,maintainedby,canalid,q2,q6,q7, |
||||
|
file,remarks,cby,zone,ward,latitude,longitude,"close"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,136 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.mosquitosurvey.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
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.mobileservice.mosquitosurvey.service.MosquitoService; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/mosquito/api") |
||||
|
@RestController("apiMosquitoRest") |
||||
|
public class API_MosquitoController { |
||||
|
@Autowired |
||||
|
private MosquitoService mosquitoService; |
||||
|
|
||||
|
@GetMapping("/getCategoryList") |
||||
|
public List<?> getCategoryList( |
||||
|
) { |
||||
|
return mosquitoService.getCategoryList(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getSubCategoryList") |
||||
|
public List<?> getSubCategoryList( |
||||
|
@RequestParam(value = "cid", required = true) String cid |
||||
|
) { |
||||
|
return mosquitoService.getSubCategoryList(cid); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getTreatmentList") |
||||
|
public List<?> getTreatmentList( |
||||
|
) { |
||||
|
return mosquitoService.getTreatmentList(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getBreadingSourceCategoryList") |
||||
|
public List<?> getBreadingSourceCategoryList( |
||||
|
) { |
||||
|
return mosquitoService.getBreadingSourceCategoryList(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getBreadingSourceList") |
||||
|
public List<?> getBreadingSourceList( |
||||
|
) { |
||||
|
return mosquitoService.getBreadingSourceList(); |
||||
|
} |
||||
|
|
||||
|
// ************************************************************************************************************************* // |
||||
|
// For House, Companies & Education Institution |
||||
|
|
||||
|
@PostMapping(value="/saveSurveyFlow1") |
||||
|
public List<?> saveSurveyFlow1(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "category", required = true) String cid, |
||||
|
@RequestParam(value = "typeofsite", required = true) String scid, |
||||
|
@RequestParam(value = "visitstatus", required = true) String visitstatus, |
||||
|
@RequestParam(value = "feverfound", required = true) String q1, |
||||
|
@RequestParam(value = "treatment", required = false) String treatment, |
||||
|
@RequestParam(value = "breedfound", required = true) String q2, |
||||
|
@RequestParam(value = "sourcetype", required = false) String sourcetype, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "name", required = true) String name, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
//@RequestParam(value = "file", required = true) MultipartFile file, |
||||
|
|
||||
|
) { |
||||
|
return mosquitoService.saveSurveyFlow1(cid,scid,q1,treatment,q2,sourcetype,cby,name,zone,ward,latitude,longitude,visitstatus); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/checkHasPending") |
||||
|
public List<?> checkHasPending( |
||||
|
@RequestParam(value = "loginId", required = true) String cby |
||||
|
) { |
||||
|
return mosquitoService.checkHasPending(cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getHousePendingList") |
||||
|
public List<?> getHousePendingList( |
||||
|
@RequestParam(value = "loginId", required = true) String cby |
||||
|
) { |
||||
|
return mosquitoService.getHousePendingList(cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/checkPendingUpdateLocation") |
||||
|
public List<?> checkPendingUpdateLocation( |
||||
|
@RequestParam(value = "id", required = true) String id, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return mosquitoService.checkPendingUpdateLocation(id,latitude,longitude); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateSurveyFlow1Pending") |
||||
|
public List<?> updatePendingStatus(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "sid", required = true) String sid, |
||||
|
@RequestParam(value = "action", required = true) String q3, |
||||
|
@RequestParam(value = "file", required = true) MultipartFile file, |
||||
|
@RequestParam(value = "remarks", required = true) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return mosquitoService.updateFlow1PendingStatus("close", q3, file, remarks, cby, zone, ward, latitude, longitude, sid); |
||||
|
} |
||||
|
|
||||
|
// ************************************************************************************************************************* // |
||||
|
|
||||
|
// For Construction Site & Vacant Land |
||||
|
|
||||
|
@PostMapping(value="/saveSurveyFlow2") |
||||
|
public List<?> saveSurveyFlow2(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "category", required = true) String cid, |
||||
|
@RequestParam(value = "typeofsite", required = true) String scid, |
||||
|
@RequestParam(value = "name", required = true) String name, |
||||
|
@RequestParam(value = "breedfound", required = true) String q2, |
||||
|
@RequestParam(value = "action", required = false) String q3, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
@RequestParam(value = "remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return mosquitoService.saveSurveyFlow2(cid, scid, name, q2, q3, file, remarks, cby, zone, ward, latitude, longitude, "close"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.mosquitosurvey.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.mosquitosurvey; |
||||
1404
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/mosquitosurvey/service/FoggingService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,570 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.mosquitosurvey.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.Connection; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.SQLException; |
||||
|
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 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.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.jdbc.core.PreparedStatementCreator; |
||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder; |
||||
|
import org.springframework.jdbc.support.KeyHolder; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; |
||||
|
|
||||
|
@Service |
||||
|
public class MosquitoService { |
||||
|
private JdbcTemplate jdbcMosquitoTemplate; |
||||
|
|
||||
|
private final Environment environment; |
||||
|
private String fileBaseUrl; |
||||
|
|
||||
|
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
||||
|
private static final int STRING_LENGTH = 15; |
||||
|
private static final Random RANDOM = new SecureRandom(); |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqlMosquitoDataSource") DataSource mosquitoDataSource) { |
||||
|
this.jdbcMosquitoTemplate = new JdbcTemplate(mosquitoDataSource); |
||||
|
} |
||||
|
|
||||
|
@Autowired |
||||
|
public MosquitoService(Environment environment) { |
||||
|
this.environment = environment; |
||||
|
this.fileBaseUrl=environment.getProperty("fileBaseUrl"); |
||||
|
} |
||||
|
|
||||
|
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 static String generateRandomStringForFile(int String_Lenth) { |
||||
|
StringBuilder result = new StringBuilder(String_Lenth); |
||||
|
for (int i = 0; i < STRING_LENGTH; i++) { |
||||
|
result.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); |
||||
|
} |
||||
|
return result.toString(); |
||||
|
} |
||||
|
|
||||
|
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 String fileUpload(String name, String id, MultipartFile file) { |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
// Set the file path where you want to save it |
||||
|
String uploadDirectory = environment.getProperty("file.upload.directory"); |
||||
|
String serviceFolderName = environment.getProperty("mosquito_foldername"); |
||||
|
var year =DateTimeUtil.getCurrentYear(); |
||||
|
var month =DateTimeUtil.getCurrentMonth(); |
||||
|
var date =DateTimeUtil.getCurrentDay(); |
||||
|
|
||||
|
uploadDirectory = uploadDirectory + serviceFolderName + year +"/"+month+"/"+date; |
||||
|
|
||||
|
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 |
||||
|
System.out.println(file.getOriginalFilename()); |
||||
|
String fileName = name+ "_" +id + "_" + datetimetxt + "_" + generateRandomStringForFile(10) + "_" + file.getOriginalFilename(); |
||||
|
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename |
||||
|
|
||||
|
String filePath = uploadDirectory + "/" + fileName; |
||||
|
|
||||
|
String filepath_txt = "/"+serviceFolderName + year + "/" + month + "/" + date + "/" + 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); |
||||
|
|
||||
|
System.out.println(filePath); |
||||
|
return filepath_txt; |
||||
|
|
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
return "Failed to save file " + file.getOriginalFilename(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getCategoryList() { |
||||
|
String sql = "SELECT * FROM `category` WHERE isactive=1 ORDER BY `orderby`"; |
||||
|
return jdbcMosquitoTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getSubCategoryList(String cid) { |
||||
|
String sql = "SELECT * FROM `subcategory` WHERE `cid`=? AND isactive=1 ORDER BY `orderby`"; |
||||
|
return jdbcMosquitoTemplate.queryForList(sql, cid); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getTreatmentList() { |
||||
|
String sql = "SELECT * FROM `treatment` WHERE isactive=1 ORDER BY `orderby`"; |
||||
|
return jdbcMosquitoTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getBreadingSourceCategoryList() { |
||||
|
String sql = "SELECT * FROM `breadingsource_category` WHERE isactive=1 ORDER BY `orderby`"; |
||||
|
return jdbcMosquitoTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getBreadingSourceList() { |
||||
|
String sql = "SELECT * FROM `breadingsource` WHERE isactive=1 ORDER BY `orderby`"; |
||||
|
return jdbcMosquitoTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
// ************************************************************************************************************************* // |
||||
|
// For House, Companies & Education Institution |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> saveSurveyFlow1( |
||||
|
String cid, |
||||
|
String scid, |
||||
|
String q1, |
||||
|
String treatment, |
||||
|
String q2, |
||||
|
String sourcetype, |
||||
|
String cby, |
||||
|
String name, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String visitstatus) { |
||||
|
List<Map<String, Object>> result = null; |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
/* |
||||
|
String image = ""; |
||||
|
|
||||
|
// Handle file upload if a file is provided |
||||
|
if (file != null && !file.isEmpty()) { |
||||
|
var year = DateTimeUtil.getCurrentYear(); |
||||
|
var month = DateTimeUtil.getCurrentMonth(); |
||||
|
image = fileUpload("Created", cby, file); |
||||
|
} |
||||
|
|
||||
|
String storeIMG = image; |
||||
|
*/ |
||||
|
String sqlQuery = "INSERT INTO `survey_of_house`" |
||||
|
+ "(`cid`, `scid`, `q1`, `treatment`, `q2`, `sourcetype`, `cby`, " |
||||
|
+ "`name`, `zone`, `ward`, `latitude`, `longitude`,`visitstatus`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
LocalDateTime approvedDate = LocalDateTime.now(); |
||||
|
|
||||
|
String formattedDate = approvedDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcMosquitoTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "id" }); |
||||
|
ps.setString(1, cid); |
||||
|
ps.setString(2, scid); |
||||
|
ps.setString(3, q1); |
||||
|
ps.setString(4, treatment); |
||||
|
ps.setString(5, q2); |
||||
|
ps.setString(6, sourcetype); |
||||
|
ps.setString(7, cby); |
||||
|
ps.setString(8, name); |
||||
|
ps.setString(9, zone); |
||||
|
ps.setString(10, ward); |
||||
|
ps.setString(11, latitude); |
||||
|
ps.setString(12, longitude); |
||||
|
ps.setString(13, visitstatus); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
|
||||
|
String surveyid = lastInsertId+""; |
||||
|
|
||||
|
// Split the sourcetype string by comma |
||||
|
String[] sourcetypeArray = sourcetype.split(","); |
||||
|
|
||||
|
// Loop through the array and process each value |
||||
|
for (String type : sourcetypeArray) { |
||||
|
System.out.println("Sourcetype: " + type); |
||||
|
createSurveyPending(surveyid, type, "pending",cby); |
||||
|
} |
||||
|
|
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "New House Survey inserted successfully!"); |
||||
|
System.out.println("A new House Survey was inserted successfully! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert a new House Survey."); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> createSurveyPending( |
||||
|
String surveyid, |
||||
|
String sourceid, |
||||
|
String status, |
||||
|
String cby) { |
||||
|
List<Map<String, Object>> result = null; |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `survey_of_house_data`" |
||||
|
+ "(`surveyid`, `sourceid`, `status`, `q3`, `treatedfile`, `remarks`, `cby`, " |
||||
|
+ "`zone`, `ward`, `latitude`, `longitude`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
LocalDateTime approvedDate = LocalDateTime.now(); |
||||
|
|
||||
|
String formattedDate = approvedDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
|
||||
|
String q3 = ""; |
||||
|
String treatedfile = ""; |
||||
|
String remarks = ""; |
||||
|
|
||||
|
String zone = ""; |
||||
|
String ward = ""; |
||||
|
String latitude = ""; |
||||
|
String longitude = ""; |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcMosquitoTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "sid" }); |
||||
|
ps.setString(1, surveyid); |
||||
|
ps.setString(2, sourceid); |
||||
|
ps.setString(3, status); |
||||
|
ps.setString(4, q3); |
||||
|
ps.setString(5, treatedfile); |
||||
|
ps.setString(6, remarks); |
||||
|
ps.setString(7, cby); |
||||
|
ps.setString(8, zone); |
||||
|
ps.setString(9, ward); |
||||
|
ps.setString(10, latitude); |
||||
|
ps.setString(11, longitude); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "New House Survey inserted successfully!"); |
||||
|
System.out.println("A new House Survey was inserted successfully! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert a new House Survey."); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> checkHasPending(String cby) { |
||||
|
|
||||
|
String pending = "true"; |
||||
|
|
||||
|
String sql = "SELECT `sid` FROM `survey_of_house_data` WHERE (isactive=1 AND `status`='pending') AND `cby`=?"; |
||||
|
List<Map<String, Object>> result = jdbcMosquitoTemplate.queryForList(sql, cby); |
||||
|
|
||||
|
// Check if result is empty or not |
||||
|
if (result.isEmpty()) { |
||||
|
pending = "false"; // If no rows are found, set pending to "true" |
||||
|
} |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "Pending found"); |
||||
|
response.put("pending", pending); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getHousePendingList(String cby) { |
||||
|
|
||||
|
String sql = "SELECT shd.sid, sh.id, sh.name, bs.name AS sourcetype, sc.name AS sitetype, " |
||||
|
+ "sh.zone, sh.ward, sh.latitude, sh.longitude, " |
||||
|
+ "bsc.actiontype AS actionrequired, " |
||||
|
+ "DATE_FORMAT(sh.`cdate`, '%d-%m-%Y %r') AS createddate " |
||||
|
+ "FROM survey_of_house_data AS shd " |
||||
|
+ "JOIN survey_of_house AS sh ON shd.surveyid = sh.id " |
||||
|
+ "JOIN breadingsource AS bs ON shd.sourceid = bs.sid " |
||||
|
+ "JOIN breadingsource_category AS bsc ON bs.scid = bsc.scid " |
||||
|
+ "JOIN subcategory AS sc ON sc.scid = sh.scid " |
||||
|
+ "WHERE shd.isactive = 1 AND shd.status='pending' AND sh.cby = ?"; |
||||
|
|
||||
|
return jdbcMosquitoTemplate.queryForList(sql, cby); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> checkPendingUpdateLocation(String id, String latitude, String longitude) { |
||||
|
|
||||
|
String sql = "SELECT `id` FROM `survey_of_house` WHERE " |
||||
|
+ "`isactive` = 1 AND `id` = ? " |
||||
|
+ "AND ((6371008.8 * acos(ROUND(cos(radians(?)) * cos(radians(latitude)) * cos(radians(longitude) - radians(?)) + sin(radians(?)) * sin(radians(latitude)), 9))) < 50) " |
||||
|
+ ""; |
||||
|
List<Map<String, Object>> result = jdbcMosquitoTemplate.queryForList(sql, new Object[]{id, latitude, longitude, latitude}); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", !result.isEmpty()); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> updateFlow1PendingStatus( |
||||
|
String status, String q3, |
||||
|
MultipartFile file, String remarks, |
||||
|
String cby, String zone, String ward, |
||||
|
String latitude, String longitude, |
||||
|
String sid |
||||
|
) { |
||||
|
|
||||
|
String treatedfile =""; |
||||
|
|
||||
|
// Handle file upload if a file is provided |
||||
|
if (file != null && !file.isEmpty()) { |
||||
|
treatedfile = fileUpload(sid, cby, file); |
||||
|
} |
||||
|
|
||||
|
String finaltreatedfile = treatedfile; |
||||
|
|
||||
|
LocalDateTime approvedDate = LocalDateTime.now(); |
||||
|
|
||||
|
String formattedDate = approvedDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
|
||||
|
String sqlQuery = "UPDATE `survey_of_house_data` SET " |
||||
|
+ "`status`=?, `q3`=?, `treatedfile`=?, `remarks`=?, `cby`=?, " |
||||
|
+ "`zone`=?, `ward`=?, `latitude`=?, `longitude`=? ,`updatedate`=? " |
||||
|
+ "WHERE `sid`=?"; |
||||
|
|
||||
|
// Execute the update query |
||||
|
int rowsAffected = jdbcMosquitoTemplate.update(sqlQuery, new Object[]{ |
||||
|
status, q3, finaltreatedfile, remarks, cby, zone, ward, latitude, longitude,formattedDate, sid |
||||
|
}); |
||||
|
|
||||
|
// Create a response map |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
// If rows are affected, it means the update was successful |
||||
|
response.put("status", rowsAffected > 0); |
||||
|
|
||||
|
// Wrap the response in a list as required |
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
// ************************************************************************************************************************* // |
||||
|
|
||||
|
// For Construction Site & Vacant Land |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> saveSurveyFlow2( |
||||
|
String cid, |
||||
|
String scid, |
||||
|
String name, |
||||
|
String q2, |
||||
|
String q3, |
||||
|
MultipartFile file, |
||||
|
String remarks, |
||||
|
String cby, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String status) { |
||||
|
List<Map<String, Object>> result = null; |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String treatedfile = ""; |
||||
|
|
||||
|
// Handle file upload if a file is provided |
||||
|
if (file != null && !file.isEmpty()) { |
||||
|
treatedfile = fileUpload(cid+"_"+scid, cby, file); |
||||
|
} |
||||
|
|
||||
|
String finaltreatedfile = treatedfile; |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `survey_of_construction_land_data` " |
||||
|
+ "(`cid`, `scid`, `name`, `q2`, `q3`, `treatedfile`, " |
||||
|
+ "`remarks`, `cby`, `zone`, `ward`, `latitude`, `longitude`, `status`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
LocalDateTime approvedDate = LocalDateTime.now(); |
||||
|
|
||||
|
String formattedDate = approvedDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcMosquitoTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "id" }); |
||||
|
ps.setString(1, cid); |
||||
|
ps.setString(2, scid); |
||||
|
ps.setString(3, name); |
||||
|
ps.setString(4, q2); |
||||
|
ps.setString(5, q3); |
||||
|
ps.setString(6, finaltreatedfile); |
||||
|
ps.setString(7, remarks); |
||||
|
ps.setString(8, cby); |
||||
|
ps.setString(9, zone); |
||||
|
ps.setString(10, ward); |
||||
|
ps.setString(11, latitude); |
||||
|
ps.setString(12, longitude); |
||||
|
ps.setString(13, status); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
|
||||
|
String surveyid = lastInsertId+""; |
||||
|
|
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "New Survey inserted successfully!"); |
||||
|
System.out.println("A new Survey was inserted successfully! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert a new House Survey."); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.mosquitosurvey.service; |
||||
@ -0,0 +1,98 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.works.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
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.mobileservice.works.service.WorksService; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/works/api") |
||||
|
@RestController("worksRestapi") |
||||
|
public class WorksController { |
||||
|
|
||||
|
@Autowired |
||||
|
private WorksService worksService; |
||||
|
|
||||
|
/* |
||||
|
@GetMapping("/getESTList") |
||||
|
public List<?> getTaskList( |
||||
|
@RequestParam(value = "typeofworkid", required = true) String typeofworkid |
||||
|
) { |
||||
|
return worksService.getTaskList(typeofworkid); |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
@GetMapping("/getESTList") |
||||
|
public List<?> getESTList( |
||||
|
@RequestParam(value = "typeofworkid", required = false) String typeofworkid, |
||||
|
@RequestParam(value = "loginId", required = true) String loginId |
||||
|
) { |
||||
|
return worksService.getESTList(loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getESTWorkListData") |
||||
|
public List<?> getESTWorkListData( |
||||
|
@RequestParam(value = "estid", required = true) String estid, |
||||
|
@RequestParam(value = "loginId", required = false) String cby |
||||
|
) { |
||||
|
return worksService.getESTWorkListData(estid); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getTaskDataListWithData") |
||||
|
public List<?> getTaskDataListWithData( |
||||
|
@RequestParam(value = "worktasktid", required = true) String wtid, |
||||
|
@RequestParam(value = "estid", required = true) String estid, |
||||
|
@RequestParam(value = "typeofworkid", required = true) String typeofworkid |
||||
|
) { |
||||
|
return worksService.getTaskDataListWithData(wtid, estid,typeofworkid); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/addTaskStageActivityData") |
||||
|
public List<?> addTaskStageActivityData(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "estid", required = true) String estid, |
||||
|
@RequestParam(value = "tmid", required = true) String tmid, |
||||
|
@RequestParam(value = "worktasktid", required = true) String wtid, |
||||
|
@RequestParam(value = "activityfile", required = true) MultipartFile activityfile, |
||||
|
@RequestParam(value = "percentage", required = true) String percentage, |
||||
|
@RequestParam(value = "remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "loginId", required = true) String cby, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude |
||||
|
) { |
||||
|
return worksService.addTaskStageActivityData(estid, tmid, wtid, activityfile, percentage, remarks, cby, zone, ward, latitude, longitude,"open"); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getZoneReport") |
||||
|
public List<?> getZoneReport( |
||||
|
@RequestParam(value = "loginId", required = false) String cby |
||||
|
) { |
||||
|
return worksService.getZoneReport(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getWardReport") |
||||
|
public List<?> getWardReport( |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "loginId", required = false) String cby |
||||
|
) { |
||||
|
return worksService.getWardReport(zone); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getListReport") |
||||
|
public List<?> getListReport( |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "statusFilter", required = true) String statusFilter, |
||||
|
@RequestParam(value = "loginId", required = false) String cby |
||||
|
) { |
||||
|
return worksService.getListReport(ward, statusFilter); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.works.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.works; |
||||
@ -0,0 +1,699 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.works.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.Connection; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.SQLException; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Collections; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
import 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.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.jdbc.core.PreparedStatementCreator; |
||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder; |
||||
|
import org.springframework.jdbc.support.KeyHolder; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; |
||||
|
|
||||
|
@Service |
||||
|
public class WorksService { |
||||
|
private JdbcTemplate jdbcWorksTemplate; |
||||
|
|
||||
|
private final Environment environment; |
||||
|
private String fileBaseUrl; |
||||
|
|
||||
|
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
||||
|
private static final int STRING_LENGTH = 15; |
||||
|
private static final Random RANDOM = new SecureRandom(); |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqlWorksDataSource") DataSource worksDataSource) { |
||||
|
this.jdbcWorksTemplate = new JdbcTemplate(worksDataSource); |
||||
|
} |
||||
|
|
||||
|
@Autowired |
||||
|
public WorksService(Environment environment) { |
||||
|
this.environment = environment; |
||||
|
this.fileBaseUrl=environment.getProperty("fileBaseUrl"); |
||||
|
} |
||||
|
|
||||
|
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 static String generateRandomStringForFile(int String_Lenth) { |
||||
|
StringBuilder result = new StringBuilder(String_Lenth); |
||||
|
for (int i = 0; i < STRING_LENGTH; i++) { |
||||
|
result.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); |
||||
|
} |
||||
|
return result.toString(); |
||||
|
} |
||||
|
|
||||
|
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 String fileUpload(String name, String id, MultipartFile file) { |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
// Set the file path where you want to save it |
||||
|
String uploadDirectory = environment.getProperty("file.upload.directory"); |
||||
|
String serviceFolderName = environment.getProperty("works_task_foldername"); |
||||
|
var year =DateTimeUtil.getCurrentYear(); |
||||
|
var month =DateTimeUtil.getCurrentMonth(); |
||||
|
var date =DateTimeUtil.getCurrentDay(); |
||||
|
|
||||
|
uploadDirectory = uploadDirectory + serviceFolderName + year +"/"+month+"/"+date; |
||||
|
|
||||
|
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 |
||||
|
System.out.println(file.getOriginalFilename()); |
||||
|
String fileName = name+ "_" +id + "_" + datetimetxt + "_" + generateRandomStringForFile(10) + "_" + file.getOriginalFilename(); |
||||
|
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename |
||||
|
|
||||
|
String filePath = uploadDirectory + "/" + fileName; |
||||
|
|
||||
|
String filepath_txt = "/"+serviceFolderName + year + "/" + month + "/" + date + "/" + 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); |
||||
|
|
||||
|
System.out.println(filePath); |
||||
|
return filepath_txt; |
||||
|
|
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
return "Failed to save file " + file.getOriginalFilename(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public String getWardByLoginId(String loginid, String type) { |
||||
|
String sqlQuery = "SELECT `ward`, `works` FROM `gcc_penalty_hoardings`.`hoading_user_list` WHERE `userid` = ? LIMIT 1"; |
||||
|
|
||||
|
List<Map<String, Object>> results = jdbcWorksTemplate.queryForList(sqlQuery, loginid); |
||||
|
|
||||
|
if (!results.isEmpty()) { |
||||
|
Map<String, Object> row = results.get(0); |
||||
|
String wardClause; |
||||
|
String departmentClause = ""; |
||||
|
|
||||
|
Object wardValue = row.get("ward"); |
||||
|
Object worksValue = row.get("works"); |
||||
|
|
||||
|
if (wardValue == null || wardValue.toString().equals("0")) { |
||||
|
wardClause = "wu.`ward` NOT IN (0)"; |
||||
|
} else { |
||||
|
wardClause = "wu.`ward` IN ('" + wardValue + "')"; |
||||
|
} |
||||
|
|
||||
|
if (worksValue != null) { |
||||
|
departmentClause = " AND wu.`department` IN (" + worksValue + ")"; |
||||
|
} |
||||
|
|
||||
|
return wardClause + departmentClause; |
||||
|
} |
||||
|
|
||||
|
return "wu.`ward` IN ('-')"; |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getESTList(String loginid) { |
||||
|
/* |
||||
|
String sql = "SELECT wu.`Id` AS estid, `wu`.`sub_category` AS works, tw.id AS typeofworkid, `wu`.`estimate_no`, " |
||||
|
+ "`wu`.`estimate_date`, `wu`.`zone`, `wu`.`ward`, `wu`.`project_name`, `wu`.`location`, `wu`.`department`, " |
||||
|
+ "`wu`.`contractor_name`, `wu`.`contractor_period`, `wu`.`fund_source`, `wu`.`scheme`, `wu`.`category`, `wu`.`sub_category` AS `sub_category`, " |
||||
|
+ "`wu`.`est_amount`, `wu`.`tech_sanc_date`, `wu`.`admin_sanc_date`, `wu`.`tender_call_date`, `wu`.`tender_fin_date`, " |
||||
|
+ "`wu`.`loa_date`, `wu`.`agreement_date`, `wu`.`work_order_date`, `wu`.`work_comm_date` " |
||||
|
+ "FROM `works_update` `wu` LEFT JOIN EGW_TYPEOFWORK `tw` ON trim(`tw`.description) = trim(`wu`.`sub_category`)"; |
||||
|
*/ |
||||
|
|
||||
|
String where = getWardByLoginId(loginid,"ae"); |
||||
|
//System.out.println("ward: "+ward); |
||||
|
String sql = "SELECT " |
||||
|
+ "wu.`estid` AS estid, " |
||||
|
+ "tm.`description` AS works, " |
||||
|
+ "tm.id AS typeofworkid, " |
||||
|
+ "wu.`estimate_no`, " |
||||
|
+ "wu.`estimate_date`, " |
||||
|
+ "wu.`zone`, " |
||||
|
+ "wu.`ward`, " |
||||
|
+ "wu.`project_name`, " |
||||
|
+ "wu.`location`, " |
||||
|
+ "dm.`dept_name` AS `department`, " |
||||
|
+ "wu.`contractor_name`, " |
||||
|
+ "CAST(wu.contractor_period AS CHAR) AS contractor_period, " |
||||
|
+ "fs.`name` AS `fund_source`, " |
||||
|
+ "s.`name` AS `scheme`, " |
||||
|
+ "wm.`name` AS `category`, " |
||||
|
+ "tm.`description` AS `sub_category`, " |
||||
|
+ "wu.`estimation_amount` AS `est_amount`, " |
||||
|
+ "wu.`technical_sanction_date` AS `tech_sanc_date`, " |
||||
|
+ "wu.`admin_sanction_date` AS `admin_sanc_date`, " |
||||
|
+ "wu.`tender_called_date` AS `tender_call_date`, " |
||||
|
+ "wu.`tender_finalized_date` AS `tender_fin_date`, " |
||||
|
+ "wu.`loa_date` AS `loa_date`, " |
||||
|
+ "wu.`agreement_date` AS `agreement_date`, " |
||||
|
+ "wu.`work_order_date` AS `work_order_date`, " |
||||
|
+ "wu.`work_commenced_date` AS `work_comm_date`, " |
||||
|
+ "wu.`percentage` AS `percentage` " |
||||
|
+ "FROM `erp_works` wu " |
||||
|
//+ "LEFT JOIN typeofwork_master tw ON trim(tw.description) = trim(wu.`sub_category`)" |
||||
|
+ "LEFT JOIN department_master dm ON dm.id = wu.`department`" |
||||
|
+ "LEFT JOIN fundsource_master fs ON fs.id = wu.`fund_source` " |
||||
|
+ "LEFT JOIN scheme_master s ON s.id = wu.`scheme` " |
||||
|
+ "LEFT JOIN workstype_master wm ON wm.id = wu.`category` " |
||||
|
+ "LEFT JOIN typeofwork_master tm ON tm.id = wu.`sub_category` " |
||||
|
+ "WHERE "+where; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcWorksTemplate.queryForList(sql); |
||||
|
/* |
||||
|
List<Map<String, Object>> estWorklistData = new ArrayList<>(); |
||||
|
|
||||
|
for (Map<String, Object> row : result) { |
||||
|
// CHECK IN WORK_TASK |
||||
|
|
||||
|
// CHECK IN typeofwork_task_master |
||||
|
|
||||
|
// CHECK IN task_data last DATA for each typeofwork_task_master |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
return jdbcWorksTemplate.queryForList(sql); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
public List<Map<String, Object>> getTaskDataListWithData(String estid, String typeofworkid) { |
||||
|
String sql = "SELECT `tdid`, `estid`, `tmid`, `percentage`, `cdate`, `cby`, `zone`, `ward`, `latitude`, `longitude`, `stage_file`, `status`, `isactive` FROM `task_data` WHERE 1"; |
||||
|
return jdbcWorksTemplate.queryForList(sql,typeofworkid); |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
public List<Map<String, Object>> getESTWorkListData(String estid) { |
||||
|
|
||||
|
String sql = "SELECT `id` AS wtid, `estid`, `estimate_no`, `sub_cat_id`, `question_id`, `ans_id`," |
||||
|
+ " `remarks`, `cdate`, `isactive`, `isdelete`, `percentage` " |
||||
|
+ " FROM `erp_works_task` " |
||||
|
+ " WHERE `isactive`=1 AND `isdelete`=0 AND `estid`= ?"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcWorksTemplate.queryForList(sql, estid); |
||||
|
|
||||
|
// Prepare the response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("estWorklistData", result); |
||||
|
response.put("message", "EST Activity Data List."); |
||||
|
|
||||
|
// Return the response wrapped in a singleton list |
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getTaskDataListWithData(String wtid, String estid, String typeofworkid) { |
||||
|
|
||||
|
String sql = "SELECT `id`, `estid`, `estimate_no`, `sub_cat_id`, `question_id`, `ans_id`," |
||||
|
+ " `remarks`, `cdate`, `isactive`, `isdelete`, `percentage` FROM `erp_works_task` " |
||||
|
+ "WHERE `id`=? AND `estid`= ? AND `isactive`=1 AND `isdelete`=0"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcWorksTemplate.queryForList(sql, wtid, estid); |
||||
|
|
||||
|
List<Map<String, Object>> estTaskWorklistData = new ArrayList<>(); |
||||
|
|
||||
|
for (Map<String, Object> row : result) { |
||||
|
|
||||
|
// Query for the task related to the current activity |
||||
|
String sqlForTask = "SELECT `tmid`, `stagename` AS `taskname`, `isactive`, `isdelete`, `orderby`, " |
||||
|
+ "(" |
||||
|
+ " SELECT `percentage` " |
||||
|
+ " FROM `erp_task_data` " |
||||
|
+ " WHERE `tmid` = `erp_works_stages`.`tmid` AND wtid=? AND `isactive`=1 " |
||||
|
+ " ORDER BY `cdate` DESC " |
||||
|
+ " LIMIT 1 " |
||||
|
+ " ) AS percentage " |
||||
|
+ "FROM `erp_works_stages` WHERE `isactive`=1 AND `isdelete`=0 AND `estid`=? ORDER BY `orderby`"; |
||||
|
|
||||
|
List<Map<String, Object>> taskresult = jdbcWorksTemplate.queryForList(sqlForTask, wtid, estid); |
||||
|
|
||||
|
if (!taskresult.isEmpty()) { |
||||
|
// For each task in the taskresult, add taskdataresult |
||||
|
for (Map<String, Object> task : taskresult) { |
||||
|
// Query for the task-related data |
||||
|
String tmid = ""+task.get("tmid"); // Assuming tmid is a field in task |
||||
|
String sqlForTaskData = "SELECT `tdid`, `estid`, `tmid`, `percentage`, `remarks`, " |
||||
|
+ "DATE_FORMAT(`cdate`, '%d-%m-%Y %r') AS createddate, " |
||||
|
+ "`cby`, `zone`, `ward`, `latitude`, `longitude`, " |
||||
|
+ " CONCAT('"+fileBaseUrl+"/gccofficialapp/files', `stage_file`) AS image, " |
||||
|
+ "`status`, `isactive` FROM `erp_task_data` WHERE `wtid`=? AND `tmid`=? AND `estid`=? AND `isactive`=1"; |
||||
|
|
||||
|
List<Map<String, Object>> taskdataresult = jdbcWorksTemplate.queryForList(sqlForTaskData, wtid, tmid, estid); |
||||
|
|
||||
|
// Add taskdataresult to each task |
||||
|
task.put("taskdata", taskdataresult); |
||||
|
} |
||||
|
} |
||||
|
// Add tasklist (with taskdata) to the row |
||||
|
row.put("tasklist", taskresult); |
||||
|
|
||||
|
// Add the row to SWDData |
||||
|
estTaskWorklistData.add(row); |
||||
|
} |
||||
|
|
||||
|
// Prepare the response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("estTaskWorklistData", estTaskWorklistData); |
||||
|
response.put("message", "EST Activity Data List."); |
||||
|
|
||||
|
// Return the response wrapped in a singleton list |
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> addTaskStageActivityData( |
||||
|
String estid, |
||||
|
String tmid, |
||||
|
String wtid, |
||||
|
MultipartFile file, |
||||
|
String percentage, |
||||
|
String remarks, |
||||
|
String cby, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String status) { |
||||
|
List<Map<String, Object>> result = null; |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String filetxt = ""; |
||||
|
|
||||
|
// Handle file upload if a file is provided |
||||
|
if (file != null && !file.isEmpty()) { |
||||
|
filetxt = fileUpload(estid+"_"+tmid, cby, file); |
||||
|
} |
||||
|
String finalfile = filetxt; |
||||
|
String sqlQuery = "INSERT INTO `erp_task_data`" |
||||
|
+ "(`estid`, `tmid`, `percentage`, `remarks`, `cby`, `zone`, `ward`, `latitude`, `longitude`, `stage_file`, `status`,`wtid`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
LocalDateTime approvedDate = LocalDateTime.now(); |
||||
|
|
||||
|
String formattedDate = approvedDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
|
||||
|
try { |
||||
|
status = "open"; |
||||
|
if(percentage.contains("100")) { |
||||
|
status = "close"; |
||||
|
} |
||||
|
|
||||
|
String statustxt = status; |
||||
|
|
||||
|
// Insert the data the required number of times |
||||
|
int affectedRows = jdbcWorksTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "did" }); |
||||
|
ps.setString(1, estid); |
||||
|
ps.setString(2, tmid); |
||||
|
ps.setString(3, percentage); |
||||
|
ps.setString(4, remarks); |
||||
|
ps.setString(5, cby); |
||||
|
ps.setString(6, zone); |
||||
|
ps.setString(7, ward); |
||||
|
ps.setString(8, latitude); |
||||
|
ps.setString(9, longitude); |
||||
|
ps.setString(10, finalfile); |
||||
|
ps.setString(11, statustxt); |
||||
|
ps.setString(12, wtid); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "Stage Task data inserted successfully!"); |
||||
|
System.out.println("Stage Task was inserted successfully! Insert ID: " + generatedId); |
||||
|
updateStatus(percentage, estid, wtid); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert stage task data."); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
/* |
||||
|
// Update Percentage of works progress |
||||
|
String sqlUpdateQuery ="UPDATE erp_works ew " |
||||
|
+ "JOIN ( " |
||||
|
+ " SELECT " |
||||
|
+ " ew.estid, " |
||||
|
+ " ROUND(SUM(COALESCE(etd.percentage, 0)) / COUNT(*), 0) AS physical_progress " |
||||
|
+ " FROM erp_works ew " |
||||
|
+ " JOIN erp_works_task ewt ON ewt.estid = ew.estid " |
||||
|
+ " JOIN erp_works_stages ews ON ews.estid = ew.estid " |
||||
|
+ " LEFT JOIN erp_task_data etd " |
||||
|
+ " ON etd.estid = ew.estid " |
||||
|
+ " AND etd.wtid = ewt.id " |
||||
|
+ " AND etd.tmid = ews.tmid " |
||||
|
+ " GROUP BY ew.estid " |
||||
|
+ " HAVING physical_progress > 0 " |
||||
|
+ ") AS prog " |
||||
|
+ "ON ew.estid = prog.estid " |
||||
|
+ "SET " |
||||
|
+ " ew.percentage = prog.physical_progress, " |
||||
|
+ " ew.update_status = CASE " |
||||
|
+ " WHEN prog.physical_progress = 0 THEN 'pending' " |
||||
|
+ " WHEN prog.physical_progress < 100 THEN 'Inprogress' " |
||||
|
+ " ELSE 'Completed' " |
||||
|
+ " END"; |
||||
|
*/ |
||||
|
String sqlUpdateQuery ="UPDATE erp_works ew " |
||||
|
+ "JOIN ( " |
||||
|
+ " SELECT " |
||||
|
+ " ew.estid, " |
||||
|
+ " ROUND(SUM(COALESCE(etd.percentage, 0)) / COUNT(*), 0) AS physical_progress " |
||||
|
+ " FROM erp_works ew " |
||||
|
+ " JOIN erp_works_task ewt ON ewt.estid = ew.estid " |
||||
|
+ " JOIN erp_works_stages ews ON ews.estid = ew.estid " |
||||
|
+ " LEFT JOIN ( " |
||||
|
//+ " -- Get only the latest active record per (estid, wtid, tmid) " |
||||
|
+ " SELECT etd.* " |
||||
|
+ " FROM erp_task_data etd " |
||||
|
+ " INNER JOIN ( " |
||||
|
+ " SELECT estid, wtid, tmid, MAX(tdid) AS max_tdid " |
||||
|
+ " FROM erp_task_data " |
||||
|
+ " WHERE isactive = 1 " |
||||
|
+ " GROUP BY estid, wtid, tmid " |
||||
|
+ " ) latest ON latest.estid = etd.estid " |
||||
|
+ " AND latest.wtid = etd.wtid " |
||||
|
+ " AND latest.tmid = etd.tmid " |
||||
|
+ " AND latest.max_tdid = etd.tdid " |
||||
|
+ " ) etd ON etd.estid = ew.estid " |
||||
|
+ " AND etd.wtid = ewt.id " |
||||
|
+ " AND etd.tmid = ews.tmid " |
||||
|
+ " GROUP BY ew.estid " |
||||
|
+ " HAVING physical_progress > 0 " |
||||
|
+ ") AS prog " |
||||
|
+ "ON ew.estid = prog.estid " |
||||
|
+ "SET " |
||||
|
+ " ew.percentage = prog.physical_progress, " |
||||
|
+ " ew.update_status = CASE " |
||||
|
+ " WHEN prog.physical_progress = 0 THEN 'pending' " |
||||
|
+ " WHEN prog.physical_progress < 100 THEN 'Inprogress' " |
||||
|
+ " ELSE 'Completed' " |
||||
|
+ " END"; |
||||
|
|
||||
|
System.out.println("Percentage Update : " + sqlUpdateQuery + " --> ESTID : " + estid); |
||||
|
jdbcWorksTemplate.update(sqlUpdateQuery); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public boolean updateStatus(String percentage,String estid, String wtid) { |
||||
|
int statusAffected = 0; |
||||
|
/* |
||||
|
String selectSql = "SELECT " |
||||
|
+ " ewt.id," |
||||
|
+ " ROUND(SUM(COALESCE(etd.percentage, 0)) / COUNT(*), 0) AS physical_progress" |
||||
|
+ " FROM erp_works ew" |
||||
|
+ " JOIN erp_works_task ewt ON ewt.estid = ew.estid" |
||||
|
+ " JOIN erp_works_stages ews ON ews.estid = ew.estid" |
||||
|
+ " LEFT JOIN erp_task_data etd " |
||||
|
+ " ON etd.estid = ew.estid " |
||||
|
+ " AND etd.wtid = ewt.id " |
||||
|
+ " AND etd.tmid = ews.tmid" |
||||
|
+ " AND ewt.id = ?" |
||||
|
+ " GROUP BY ew.estid" |
||||
|
+ " HAVING physical_progress > 0"; |
||||
|
*/ |
||||
|
|
||||
|
String selectSql ="SELECT " |
||||
|
+ " ewt.id, " |
||||
|
+ " ROUND(SUM(COALESCE(etd.percentage, 0)) / COUNT(*), 0) AS physical_progress " |
||||
|
+ "FROM " |
||||
|
+ " erp_works ew " |
||||
|
+ "JOIN " |
||||
|
+ " erp_works_task ewt ON ewt.estid = ew.estid " |
||||
|
+ "JOIN " |
||||
|
+ " erp_works_stages ews ON ews.estid = ew.estid " |
||||
|
+ "LEFT JOIN ( " |
||||
|
+ " -- Subquery to get only latest entry per estid/wtid/tmid based on highest tdid " |
||||
|
+ " SELECT etd.* " |
||||
|
+ " FROM erp_task_data etd " |
||||
|
+ " INNER JOIN ( " |
||||
|
+ " SELECT estid, wtid, tmid, MAX(tdid) AS max_tdid " |
||||
|
+ " FROM erp_task_data " |
||||
|
+ " WHERE isactive = 1 " |
||||
|
+ " GROUP BY estid, wtid, tmid " |
||||
|
+ " ) latest ON latest.estid = etd.estid " |
||||
|
+ " AND latest.wtid = etd.wtid " |
||||
|
+ " AND latest.tmid = etd.tmid " |
||||
|
+ " AND latest.max_tdid = etd.tdid " |
||||
|
+ ") etd ON etd.estid = ew.estid " |
||||
|
+ " AND etd.wtid = ewt.id " |
||||
|
+ " AND etd.tmid = ews.tmid " |
||||
|
+ "WHERE " |
||||
|
+ " ewt.id = ? " |
||||
|
+ "GROUP BY " |
||||
|
+ " ew.estid " |
||||
|
+ "HAVING " |
||||
|
+ " physical_progress > 0"; |
||||
|
|
||||
|
List<Map<String, Object>> rows = jdbcWorksTemplate.queryForList(selectSql, new Object[]{wtid}); |
||||
|
|
||||
|
for (Map<String, Object> row : rows) { |
||||
|
int physical_progress = ((Number) row.get("physical_progress")).intValue(); |
||||
|
|
||||
|
String updateSql = "UPDATE `erp_works_task` SET `percentage`=? WHERE `estid`=? AND `id`=?"; |
||||
|
statusAffected = jdbcWorksTemplate.update(updateSql, physical_progress, estid, wtid); |
||||
|
|
||||
|
System.out.println("Updated " + statusAffected + " row(s) for estid=" + estid + ", wtid=" + wtid); |
||||
|
} |
||||
|
|
||||
|
// System.out.println("UPDATE `erp_works_task` SET `percentage`="+percentage+" WHERE `estid`="+estid+" AND `id`="+wtid); |
||||
|
// System.out.println("UPDATE `erp_works_task` Status: " + statusAffected); |
||||
|
|
||||
|
int rowsAffected = 0; |
||||
|
if (statusAffected > 0) { |
||||
|
/* |
||||
|
sqlQuery = "UPDATE `works_update` SET `percentage`=? WHERE `id`=?"; |
||||
|
rowsAffected = jdbcWorksTemplate.update(sqlQuery, new Object[]{percentage,estid}); |
||||
|
|
||||
|
System.out.println("UPDATE `works_update` SET `percentage`="+percentage+" WHERE `id`="+estid); |
||||
|
System.out.println("UPDATE `works_update` Status: " + rowsAffected); |
||||
|
*/ |
||||
|
} |
||||
|
return rowsAffected > 0; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public List<Map<String, Object>> getZoneReport() { |
||||
|
|
||||
|
String sql = "SELECT " |
||||
|
+ " CASE " |
||||
|
+ " WHEN zone = '00' THEN 'HQ' " |
||||
|
+ " ELSE zone " |
||||
|
+ " END AS zone, " |
||||
|
+ " COUNT(estid) AS Total, " |
||||
|
+ " SUM(CASE WHEN percentage = 100 THEN 1 ELSE 0 END) AS CompletedTotal, " |
||||
|
+ " SUM(CASE WHEN percentage > 0 AND percentage < 100 THEN 1 ELSE 0 END) AS OngoingTotal, " |
||||
|
+ " SUM(CASE WHEN percentage = 0 THEN 1 ELSE 0 END) AS NotStartedTotal " |
||||
|
+ "FROM " |
||||
|
+ " `erp_works` " |
||||
|
+ "GROUP BY " |
||||
|
+ " zone " |
||||
|
+ "ORDER BY " |
||||
|
+ " zone;"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcWorksTemplate.queryForList(sql); |
||||
|
|
||||
|
// Prepare the response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("ZoneData", result); |
||||
|
response.put("message", "EST Activity Zone Data List."); |
||||
|
|
||||
|
// Return the response wrapped in a singleton list |
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getWardReport(String zone) { |
||||
|
|
||||
|
String sql = "SELECT " |
||||
|
+ " CASE " |
||||
|
+ " WHEN zone = '00' THEN 'HQ' " |
||||
|
+ " ELSE zone " |
||||
|
+ " END AS zone, " |
||||
|
+ " CASE " |
||||
|
+ " WHEN ward = '000' THEN 'HQ' " |
||||
|
+ " ELSE ward " |
||||
|
+ " END AS ward, " |
||||
|
+ " COUNT(estid) AS Total, " |
||||
|
+ " SUM(CASE WHEN percentage = 100 THEN 1 ELSE 0 END) AS CompletedTotal, " |
||||
|
+ " SUM(CASE WHEN percentage > 0 AND percentage < 100 THEN 1 ELSE 0 END) AS OngoingTotal, " |
||||
|
+ " SUM(CASE WHEN percentage = 0 THEN 1 ELSE 0 END) AS NotStartedTotal " |
||||
|
+ "FROM " |
||||
|
+ " `erp_works` " |
||||
|
+ "WHERE zone=? " |
||||
|
+ "GROUP BY " |
||||
|
+ " zone, ward " |
||||
|
+ "ORDER BY " |
||||
|
+ " ward"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcWorksTemplate.queryForList(sql,zone); |
||||
|
|
||||
|
// Prepare the response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("estWorklistData", result); |
||||
|
response.put("message", "EST Activity Data List."); |
||||
|
|
||||
|
// Return the response wrapped in a singleton list |
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getListReport(String ward, String statusFilter) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
StringBuilder sqlBuilder = new StringBuilder("SELECT " |
||||
|
+ "wu.`estid` AS estid, " |
||||
|
+ "tm.`description` AS works, " |
||||
|
+ "tm.id AS typeofworkid, " |
||||
|
+ "wu.`estimate_no`, " |
||||
|
+ "wu.`estimate_date`, " |
||||
|
+ "wu.`zone`, " |
||||
|
+ "wu.`ward`, " |
||||
|
+ "wu.`project_name`, " |
||||
|
+ "wu.`location`, " |
||||
|
+ "dm.`dept_name` AS `department`, " |
||||
|
+ "wu.`contractor_name`, " |
||||
|
+ "CAST(wu.contractor_period AS CHAR) AS contractor_period, " |
||||
|
+ "fs.`name` AS `fund_source`, " |
||||
|
+ "s.`name` AS `scheme`, " |
||||
|
+ "wm.`name` AS `category`, " |
||||
|
+ "tm.`description` AS `sub_category`, " |
||||
|
+ "wu.`estimation_amount` AS `est_amount`, " |
||||
|
+ "wu.`technical_sanction_date` AS `tech_sanc_date`, " |
||||
|
+ "wu.`admin_sanction_date` AS `admin_sanc_date`, " |
||||
|
+ "wu.`tender_called_date` AS `tender_call_date`, " |
||||
|
+ "wu.`tender_finalized_date` AS `tender_fin_date`, " |
||||
|
+ "wu.`loa_date` AS `loa_date`, " |
||||
|
+ "wu.`agreement_date` AS `agreement_date`, " |
||||
|
+ "wu.`work_order_date` AS `work_order_date`, " |
||||
|
+ "wu.`work_commenced_date` AS `work_comm_date`, " |
||||
|
+ "wu.`percentage` AS `percentage` " |
||||
|
+ "FROM `erp_works` wu " |
||||
|
+ "LEFT JOIN department_master dm ON dm.id = wu.`department` " |
||||
|
+ "LEFT JOIN fundsource_master fs ON fs.id = wu.`fund_source` " |
||||
|
+ "LEFT JOIN scheme_master s ON s.id = wu.`scheme` " |
||||
|
+ "LEFT JOIN workstype_master wm ON wm.id = wu.`category` " |
||||
|
+ "LEFT JOIN typeofwork_master tm ON tm.id = wu.`sub_category` " |
||||
|
+ "WHERE wu.`ward` = '" + ward + "' "); |
||||
|
|
||||
|
switch (statusFilter) { |
||||
|
case "completed": |
||||
|
sqlBuilder.append("AND wu.percentage = 100 "); |
||||
|
break; |
||||
|
case "ongoing": |
||||
|
sqlBuilder.append("AND wu.percentage > 0 AND wu.percentage < 100 "); |
||||
|
break; |
||||
|
case "not_started": |
||||
|
sqlBuilder.append("AND wu.percentage = 0 "); |
||||
|
break; |
||||
|
// default is no filtering (all) |
||||
|
} |
||||
|
|
||||
|
String sql = sqlBuilder.toString(); |
||||
|
List<Map<String, Object>> result = jdbcWorksTemplate.queryForList(sql); |
||||
|
|
||||
|
// Prepare the response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("estWorklistData", result); |
||||
|
response.put("message", "EST Data List."); |
||||
|
|
||||
|
// Return the response wrapped in a singleton list |
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.works.service; |
||||
@ -1 +1,3 @@ |
|||||
assets.base-url=/assets/ |
assets.base-url=/assets/ |
||||
|
|
||||
|
fileBaseUrl=http://localhost:8064 |
||||
@ -1 +1,3 @@ |
|||||
assets.base-url=/gccofficialapp/assets/ |
assets.base-url=/gccofficialapp/assets/ |
||||
|
|
||||
|
fileBaseUrl=https://gccservices.in |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue