Browse Source

As of 21-12-2022

master
aswinsundar 4 years ago
parent
commit
b2a313e0d2
  1. 20
      src/main/java/com/asset/master/MasterController.java
  2. 15
      src/main/java/com/asset/test/testController.java
  3. 124
      src/main/java/com/asset/test/testRestController.java
  4. 10
      src/main/resources/templates/asset-master-entry.html

20
src/main/java/com/asset/master/MasterController.java

@ -33,11 +33,11 @@ public class MasterController {
@GetMapping(value = "entry")
public String masterEntry(Model model, Master master, MasterQuestion masterQuestion, MasterParameters masterParameters) {
//model.addAttribute("masterObj", new MasterView());
model.addAttribute("masterList", new Master());
model.addAttribute("masterListObj", new Master());
//model.addAttribute("masterParametersList", new MasterParameters());
model.addAttribute("masterParametersList", masterParameters.getMasterParameters());
model.addAttribute("masterDetailList", new MasterQuestion());
model.addAttribute("masterParametersListObj", new MasterParameters());
//model.addAttribute("masterParametersListObj", masterParameters.getMasterParameters());
model.addAttribute("masterQuestionListObj", new MasterQuestion());
return "asset-master-entry";
}
@ -45,10 +45,16 @@ public class MasterController {
public String masterEntrySubmit(@ModelAttribute Master master, MasterQuestion masterQuestion,
MasterParameters masterParameters) {
System.out.println("-master-:"+master);
System.out.println("-masterQuestion-:"+masterQuestion);
System.out.println("-masterParameters-:"+masterParameters);
Master obj = new Master();
obj.setMasterId(master.getMasterId());
obj.setMasterName(master.getMasterName());
masterRepo.saveAndFlush(obj);
masterRepo.save(obj);
System.out.println("-master-obj-:"+obj);
MasterQuestion obj2 = new MasterQuestion();
obj2.setMasterId(master.getMasterId());
@ -76,10 +82,10 @@ public class MasterController {
obj3.setMasterName(master.getMasterName());
obj3.setMasterParameters(masterParameters.getMasterParameters());
masterParametersRepo.saveAndFlush(obj3);
return "redirect:/qr-feedback/master/entry";
}
@GetMapping(value = "/list")
public String masterList(Model model) {

15
src/main/java/com/asset/test/testController.java

@ -1,15 +0,0 @@
package com.asset.test;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value = "/qr-feedback")
public class testController {
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String test() {
return "z-test";
}
}

124
src/main/java/com/asset/test/testRestController.java

@ -1,124 +0,0 @@
package com.asset.test;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.json.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
@RequestMapping(value = "/qr-feedback")
public class testRestController {
@RequestMapping(value = "/test/map", method = RequestMethod.GET)
public Map<String, String> testMap(HttpServletRequest request, @RequestParam String locationName) {
String sSearchLocation ="";
//String sTmp = request.getParameter("locname");
String sTmp = locationName;
String sLATITUDE = "";
String sLONGITUDE = "";
if ( sTmp != null && !sTmp.equals("") ) sSearchLocation = sTmp;
System.out.println("sSearchLocation---: "+ sSearchLocation);
String str=request.getParameter("serviceinput");
if (str==null )
{
}
else
{
JSONObject lg = new JSONObject(str);
System.out.println("latitude : "+ lg.get("latitude"));
System.out.println("longitude : "+ lg.get("longitude"));
sLATITUDE =""+ (Double)lg.get("latitude");
sLONGITUDE = ""+ (Double)lg.get("longitude");
}
if ( (sLATITUDE==null || sLATITUDE.equals("")) && ( sLONGITUDE==null || sLONGITUDE.equals("") ) )
{
if (!sSearchLocation.equals("")) {
try{
String urlString ="http://10.1.0.122/geocode_api.php?address="+ URLEncoder.encode( sSearchLocation, "UTF-8" );
System.out.println(urlString);
ResponseEntity<String> response = null;
RestTemplate restTemplate = new RestTemplate();
String bodyMessage = "";
HttpHeaders headers = new HttpHeaders();
try {
HttpEntity<String> postData = new HttpEntity<String>(headers);
response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class);
bodyMessage = response.getBody();
//System.out.println("\n bodyMessage" + bodyMessage);
} catch (Exception e) {
e.printStackTrace();
//System.out.print("\n ERROR---: " + e);
bodyMessage = "Error";
}
JSONObject object = new JSONObject(bodyMessage);
if ( (Boolean)object.get("status"))
{
JSONObject dataObject = (JSONObject) object.get("data");
System.out.println("latitude 1 : "+ dataObject.get("latitude"));
System.out.println("longitude 1 : "+ dataObject.get("longitude"));
sLATITUDE = ""+ (BigDecimal)dataObject.get("latitude");
sLONGITUDE = ""+ (BigDecimal)dataObject.get("longitude");
}
}
catch(Exception e)
{ System.out.println(e); }
}
else if(request.getParameter("latitude")!=null && request.getParameter("longitude")!=null)
{
sLATITUDE = request.getParameter("latitude");
sLONGITUDE = request.getParameter("longitude");
}
else
{
sLATITUDE = "13.0827";
sLONGITUDE = "80.2707";
}
}
if ( sLATITUDE == null || sLATITUDE.equals("") || sLONGITUDE == null || sLONGITUDE.equals("") )
{
//out.println("<br><br><center><b>No Data Found</b></center>");
System.out.println("Record Not Found");
//return;
}
//String bodyMessage = sLATITUDE;
System.out.println("sLATITUDE---:"+sLATITUDE);
System.out.println("sLONGITUDE---:"+sLONGITUDE);
// JSONObject jsonObj = new JSONObject();
// jsonObj.put("sLATITUDE", sLATITUDE);
// jsonObj.put("sLONGITUDE", sLONGITUDE);
//
// System.out.println("jsonObj :"+jsonObj);
Map<String, String> hasMap = new HashMap<String, String>();
hasMap.put("sLATITUDE", sLATITUDE);
hasMap.put("sLONGITUDE", sLONGITUDE);
return hasMap;
}
}

10
src/main/resources/templates/asset-master-entry.html

@ -34,7 +34,7 @@ $("#addParameters").click(function(){
//alert("#masterParameters_"+size+"");
$("#appendParameters").append("<div class='col-10'> "+
"<label for='masterParameters' class='form-label'> </label>"+
"<input type='text' class='form-control' id='masterParameters_"+size+"' name='masterParameters_"+size+"'>" +
"<input type='text' class='form-control' id='masterParameters_"+size+"'>" +
"</div>");
}
else{
@ -105,7 +105,7 @@ $('#assetMasterEntryFormRest').click(function(){
<div class="row g-3">
<div class="col-md-4">
<label for="assetName" class="form-label">Asset Type Name</label>
<input type="text" class="form-control" id="masterName" th:object="${masterList}" th:field="*{masterName}">
<input type="text" class="form-control" id="masterName" th:value="${masterListObj.masterName}" name="masterListObj.masterName" autocomplete="off">
</div>
</div>
</div>
@ -126,7 +126,7 @@ $('#assetMasterEntryFormRest').click(function(){
<div class="col-10">
<label for="assetParameters" class="form-label">Asset Parameters</label>
<!-- <input type="text" class="form-control" id="masterParameters" th:field="*{masterParametersList.masterParameters}" required> -->
<input type="text" class="form-control" id="masterParameters_1" required>
<input type="text" class="form-control" id="masterParameters_1" name="masterParametersListObj.masterParameters" required autocomplete="off">
</div>
<div class="col-2">
@ -156,10 +156,10 @@ $('#assetMasterEntryFormRest').click(function(){
<div class="row g-3">
<div class="col-10">
<label for="assetQuestionEnglish" class="form-label">English</label>
<input type="text" class="form-control" id="masterQuestionEnglish_1" th:object="${masterDetailList}" th:field="*{masterQuestionEnglish}" required>
<input type="text" class="form-control" id="masterQuestionEnglish_1" name="masterQuestionListObj.masterQuestionEnglish" required autocomplete="off">
<label for="assetQuestionTamil" class="form-label">&#2980;&#2990;&#3007;&#2996;&#3021;</label>
<input type="text" class="form-control" id="masterQuestionTamil_1" th:object="${masterDetailList}" th:field="*{masterQuestionTamil}" required>
<input type="text" class="form-control" id="masterQuestionTamil_1" name="masterQuestionListObj.masterQuestionTamil" required autocomplete="off">
</div>
<div class="col-2">

Loading…
Cancel
Save