diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index cb28b0e..0000000 Binary files a/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 5f0536e..0000000 --- a/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/src/main/java/com/feedback/it_asset/controller/APIController.java b/src/main/java/com/feedback/it_asset/controller/APIController.java index 4567df3..7dc925e 100644 --- a/src/main/java/com/feedback/it_asset/controller/APIController.java +++ b/src/main/java/com/feedback/it_asset/controller/APIController.java @@ -61,6 +61,7 @@ import com.feedback.it_asset.repository.GccAssetDetailsRep; import com.feedback.it_asset.repository.GccFeedbackDataRep; import com.feedback.it_asset.repository.GccFeedbackRep; import com.feedback.it_asset.repository.GccFileDataRep; +import com.feedback.it_asset.service.AssetDetailsService; import com.google.zxing.WriterException; import jakarta.servlet.http.HttpServletRequest; @@ -87,6 +88,24 @@ public class APIController { private GccFeedbackRep gccFeedbackRep; @Autowired private GccFeedbackDataRep gccFeedbackDataRep; + @Autowired + private AssetDetailsService assetDetailsService; + + public APIController(AssetDetailsService assetDetailsService) { + this.assetDetailsService = assetDetailsService; + } + + @GetMapping("/migrateData") + public String migrateData() { + try { + // Invoke the migrateData method from YourServiceClass + assetDetailsService.migrateData(); + return "Data migration completed successfully."; + } catch (Exception e) { + e.printStackTrace(); + return "Error during data migration: " + e.getMessage(); + } + } @GetMapping("/dashboard-summary") public ResponseEntity> getDashboardSummary() { diff --git a/src/main/java/com/feedback/it_asset/controller/FeedbackController.java b/src/main/java/com/feedback/it_asset/controller/FeedbackController.java index e4bc922..f140342 100644 --- a/src/main/java/com/feedback/it_asset/controller/FeedbackController.java +++ b/src/main/java/com/feedback/it_asset/controller/FeedbackController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import com.feedback.it_asset.AppConfig; +import com.feedback.it_asset.entity.AssetCategory; import com.feedback.it_asset.entity.AssetCategoryQuestions; import com.feedback.it_asset.entity.AssetParameterQuestions; import com.feedback.it_asset.entity.GccAssetDetails; @@ -54,37 +55,73 @@ public class FeedbackController { } */ } +// @GetMapping("/gcc-complaint/{qrcode}") +// public String viewPublicFeedbackForm(Model model, @PathVariable String qrcode) { +// String assetId = gccAssetDetailsRep.findByAssetCode(qrcode); +// Integer assetid = 0; +// if (assetId != null) { +// assetid = Integer.valueOf(assetId); +// } +// +// List assetDetailsList = gccAssetDetailsRep.findByAssetId(assetid); +// List paramDbVal = new ArrayList<>(); +// for (GccAssetDetails ad : assetDetailsList) { +// //Basic Asset Details +// model.addAttribute("assetId", ad.getAssetId()); +// model.addAttribute("assetName", ad.getAssetName()); +// ///////////////////// +// List assetCategoryQuestionList = assetCategoryQuestionsRep.findByCatId(ad.getAssetCategory().getcId()); +// model.addAttribute("feedbackquestionlist", assetCategoryQuestionList); +// System.out.println(ad.getParamId()); +// String paramDbStr = ad.getParamId().replaceAll("[\\[\\]\\s]", ""); +// String[] paramIdStr = paramDbStr.split(","); +// for (String a : paramIdStr) { +// paramDbVal.add(Integer.parseInt(a)); +// } +// List assetParameterQuestionList = assetParameterQuestionsRep.findByParameterId(paramDbVal); +// model.addAttribute("assetparameterquestionlist", assetParameterQuestionList); +// } +// model.addAttribute("title", "GCC Complaint Form"); +// //model.addAttribute("baseurl", appConfig.getBaseUrl()); +// return "gcc-complaint"; +// } + @GetMapping("/gcc-complaint/{qrcode}") public String viewPublicFeedbackForm(Model model, @PathVariable String qrcode) { - String assetId = gccAssetDetailsRep.findByAssetCode(qrcode); - Integer assetid = 0; - if (assetId != null) { - assetid = Integer.valueOf(assetId); - } + String assetId = gccAssetDetailsRep.findByAssetCode(qrcode); + Integer assetid = (assetId != null) ? Integer.valueOf(assetId) : null; + + List assetDetailsList = gccAssetDetailsRep.findByAssetId(assetid); + + for (GccAssetDetails ad : assetDetailsList) { + // Basic Asset Details + model.addAttribute("assetId", ad.getAssetId()); + model.addAttribute("assetName", ad.getAssetName()); + + AssetCategory assetCategory = ad.getAssetCategory(); + if (assetCategory != null) { + model.addAttribute("assetCategoryId", assetCategory.getcId()); - List assetDetailsList = gccAssetDetailsRep.findByAssetId(assetid); - List paramDbVal = new ArrayList<>(); - for (GccAssetDetails ad : assetDetailsList) { - //Basic Asset Details - model.addAttribute("assetId", ad.getAssetId()); - model.addAttribute("assetName", ad.getAssetName()); - ///////////////////// - List assetCategoryQuestionList = assetCategoryQuestionsRep.findByCatId(ad.getAssetCategory().getcId()); + List assetCategoryQuestionList = assetCategoryQuestionsRep.findByCatId(assetCategory.getcId()); model.addAttribute("feedbackquestionlist", assetCategoryQuestionList); - System.out.println(ad.getParamId()); - String paramDbStr = ad.getParamId().replaceAll("[\\[\\]\\s]", ""); - String[] paramIdStr = paramDbStr.split(","); - for (String a : paramIdStr) { - paramDbVal.add(Integer.parseInt(a)); + + List paramDbVal = new ArrayList<>(); + if (ad.getParamId() != null) { + String paramDbStr = ad.getParamId().replaceAll("[\\[\\]\\s]", ""); + String[] paramIdStr = paramDbStr.split(","); + for (String a : paramIdStr) { + paramDbVal.add(Integer.parseInt(a)); + } } List assetParameterQuestionList = assetParameterQuestionsRep.findByParameterId(paramDbVal); model.addAttribute("assetparameterquestionlist", assetParameterQuestionList); } - model.addAttribute("title", "GCC Complaint Form"); - //model.addAttribute("baseurl", appConfig.getBaseUrl()); - return "gcc-complaint"; } + model.addAttribute("title", "GCC Complaint Form"); + return "gcc-complaint"; +} + @RequestMapping(value="/gcc-complaint/save", method = RequestMethod.POST) public String savePublicFeedback(@RequestParam MultiValueMap formData, @RequestParam(name = "uname") String name, diff --git a/src/main/java/com/feedback/it_asset/entity/AssetCategory.java b/src/main/java/com/feedback/it_asset/entity/AssetCategory.java index 1421379..57f6e18 100644 --- a/src/main/java/com/feedback/it_asset/entity/AssetCategory.java +++ b/src/main/java/com/feedback/it_asset/entity/AssetCategory.java @@ -15,9 +15,9 @@ import jakarta.persistence.Table; public class AssetCategory { @Id @GeneratedValue(strategy= GenerationType.IDENTITY) - @Column(name = "cat_id",nullable = false) + @Column(name = "cat_id",nullable = true) private Integer cId; - @Column(name = "name",nullable = false) + @Column(name = "name",nullable = true) private String catName; @Column(name = "isdelete",nullable = false, columnDefinition = "Boolean default false") private Boolean isDelete; diff --git a/src/main/java/com/feedback/it_asset/entity/AssetCategoryQuestions.java b/src/main/java/com/feedback/it_asset/entity/AssetCategoryQuestions.java index ebf3b3e..8fde37b 100644 --- a/src/main/java/com/feedback/it_asset/entity/AssetCategoryQuestions.java +++ b/src/main/java/com/feedback/it_asset/entity/AssetCategoryQuestions.java @@ -16,17 +16,17 @@ import jakarta.persistence.Table; public class AssetCategoryQuestions { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "cmq_id", nullable = false) + @Column(name = "cmq_id", nullable = true) private Integer cmqId; @ManyToOne - @JoinColumn(name="cat_id", nullable = false) + @JoinColumn(name="cat_id", nullable = true) private AssetCategory assetCategory; - @Column(name = "eng_question", nullable = false) + @Column(name = "eng_question", nullable = true) private String engQuestion; - @Column(name = "tamil_question", nullable = false) + @Column(name = "tamil_question", nullable = true) private String tamilQuestion; @Column(name = "com_group_id", nullable = true) diff --git a/src/main/java/com/feedback/it_asset/service/AssetDetailsService.java b/src/main/java/com/feedback/it_asset/service/AssetDetailsService.java new file mode 100644 index 0000000..0654782 --- /dev/null +++ b/src/main/java/com/feedback/it_asset/service/AssetDetailsService.java @@ -0,0 +1,78 @@ +package com.feedback.it_asset.service; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.springframework.stereotype.Service; + + +@Service +public class AssetDetailsService { + + + private static final String SOURCE_JDBC_URL = "jdbc:mysql://localhost:3306/gcc_asset_details"; + private static final String DESTINATION_JDBC_URL = "jdbc:mysql://localhost:3306/it_assets"; + private static final String SOURCE_USERNAME = "root"; + private static final String SOURCE_PASSWORD = "root"; + private static final String DESTINATION_USERNAME = "root"; + private static final String DESTINATION_PASSWORD = "root"; + + public void migrateData() { + try { + // Load the JDBC driver + Class.forName("com.mysql.cj.jdbc.Driver"); + + // Establish connections for source and destination databases + try ( + Connection sourceConnection = DriverManager.getConnection(SOURCE_JDBC_URL, SOURCE_USERNAME, SOURCE_PASSWORD); + Connection destinationConnection = DriverManager.getConnection(DESTINATION_JDBC_URL, DESTINATION_USERNAME, DESTINATION_PASSWORD) + ) { + // SQL query to fetch data from the source schema + String sqlQuery = "SELECT ta.ASSET_ID, ta.ASSET_NO, td.DEPT_NAME, tl.LOC_NAME, tsu.SEC_USER_NAME " + + "FROM tbl_asset ta " + + "JOIN tbl_mas_dept td ON ta.DEPT_ID = td.DEPT_ID " + + "JOIN tbl_mas_loc tl ON ta.LOC_ID = tl.LOC_ID " + + "JOIN tbl_mas_sec_user tsu ON ta.SECUSER_ID = tsu.SEC_USER_ID "; + + + // Create a prepared statement for the source database + try (PreparedStatement preparedStatementSource = sourceConnection.prepareStatement(sqlQuery)) { + + // Execute the query in the source database + try (var resultSet = preparedStatementSource.executeQuery()) { + // SQL query to insert data into the destination schema for asset_data + String insertAssetDataQuery = "INSERT INTO gcc_asset_details (asset_id, asset_code, department_name, position, assign_person) VALUES (?, ?, ?, ?, ?)"; + + // SQL query to insert data into the destination schema for asset_category +// String insertAssetCategoryQuery = "INSERT INTO asset_category (category_name) VALUES (?)"; + + // Create prepared statements for the destination database + try (PreparedStatement preparedStatementDestinationAssetData = destinationConnection.prepareStatement(insertAssetDataQuery)) { + + // Process the result set and insert data into the destination schema + while (resultSet.next()) { + // Insert data into asset_data table + preparedStatementDestinationAssetData.setString(1, resultSet.getString("ASSET_ID")); + preparedStatementDestinationAssetData.setString(2, resultSet.getString("ASSET_NO")); + preparedStatementDestinationAssetData.setString(3, resultSet.getString("DEPT_NAME")); + preparedStatementDestinationAssetData.setString(4, resultSet.getString("LOC_NAME")); + preparedStatementDestinationAssetData.setString(5, resultSet.getString("SEC_USER_NAME")); + int rowsAffectedAssetData = preparedStatementDestinationAssetData.executeUpdate(); + System.out.println("Rows affected for asset_data: " + rowsAffectedAssetData); + + // Insert data into asset_category table +// preparedStatementDestinationAssetCategory.setString(1, resultSet.getString("category_name")); +// int rowsAffectedAssetCategory = preparedStatementDestinationAssetCategory.executeUpdate(); +// System.out.println("Rows affected for asset_category: " + rowsAffectedAssetCategory); + } + } + } + } + } + } catch (ClassNotFoundException | SQLException e) { + e.printStackTrace(); // Handle the exception appropriately + } + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a2b7f5a..4d2052a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ -spring.datasource.url=jdbc:mysql://localhost:3306/it_asset +spring.datasource.url=jdbc:mysql://localhost:3306/it_assets spring.datasource.username=root -spring.datasource.password=root +spring.datasource.password=Sha619!@ #spring.datasource.password=gccroot diff --git a/src/main/resources/templates/dashboard.html b/src/main/resources/templates/dashboard.html index 5058d3d..fbaddaf 100644 --- a/src/main/resources/templates/dashboard.html +++ b/src/main/resources/templates/dashboard.html @@ -1,19 +1,5 @@ - - - - - - - - - - - - - - @@ -157,7 +143,7 @@
-
000
+
000
Closed Complaints
@@ -173,11 +159,12 @@ - + + @@ -196,240 +183,156 @@ - - - - - - - - - - + + + + + + + + + + - - - - +}); + - + \ No newline at end of file diff --git a/src/main/resources/templates/gcc-asset-list.html b/src/main/resources/templates/gcc-asset-list.html index f8dc792..3299381 100644 --- a/src/main/resources/templates/gcc-asset-list.html +++ b/src/main/resources/templates/gcc-asset-list.html @@ -65,18 +65,20 @@ 0 - + - - + + + + Active InActive - + @@ -218,12 +220,18 @@ -
+
- - + +
+
@@ -377,6 +385,7 @@ }); function getParameter(){ + var catid = $('#assetCategory').val();//$('#catId').find(":selected").val(); var paramHTML='' if(catid!='' || catid>0){ @@ -403,27 +412,24 @@ } return false; } - - function views (assetlist){ - $('#views').modal({ - backdrop: 'static', - keyboard: false - }); - $('#views').modal('show'); - document.getElementById("PopAssetId").value =assetlist.assetId; - document.getElementById("catName").value =assetlist.assetCategory.catName; - document.getElementById("departmentName").value =assetlist.departmentName; - document.getElementById("person").value =assetlist.person; - document.getElementById("position").value =assetlist.position; - document.getElementById("assetName").value =assetlist.assetName; - - +function views(assetlist) { + console.log(assetlist) + $('#views').modal({ + backdrop: 'static', + keyboard: false + }); + $('#views').modal('show'); + document.getElementById("PopAssetId").value = assetlist.assetId; + /* document.getElementById("catName").value = assetlist.assetCategory.catName;*/ + document.getElementById("departmentName").value = assetlist.departmentName; + document.getElementById("person").value = assetlist.person; + document.getElementById("position").value = assetlist.position; + document.getElementById("assetId").value = assetlist.assetId; +} -} - // ERP DATA CALL via API diff --git a/src/main/resources/templates/gcc-complaint.html b/src/main/resources/templates/gcc-complaint.html index 13f4c8c..47ddecc 100644 --- a/src/main/resources/templates/gcc-complaint.html +++ b/src/main/resources/templates/gcc-complaint.html @@ -61,12 +61,18 @@
Gcc Asset Details
+ + +
+ +
+ +
+ + +
-
-

Title

- -

Address

@@ -81,9 +87,9 @@
- - - + + +

Address

@@ -362,3 +368,4 @@ + diff --git a/src/main/resources/templates/pending-complaint.html b/src/main/resources/templates/pending-complaint.html index 436125a..8b6b75e 100644 --- a/src/main/resources/templates/pending-complaint.html +++ b/src/main/resources/templates/pending-complaint.html @@ -201,7 +201,7 @@ function viewnegfeedback (feedback) { - //console.log(feedback); + console.log(feedback); alert("ji"); document.getElementById("assetCode").value =feedback.gccAssetDetails.assetCode; document.getElementById("assetName").value =feedback.gccAssetDetails.assetName;