|
|
|
@ -27,6 +27,7 @@ public class PRPostData { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private JdbcTemplate jdbcTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AppConfig appConfig; |
|
|
|
|
|
|
|
@ -45,7 +46,7 @@ public class PRPostData { |
|
|
|
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|
|
|
} |
|
|
|
|
|
|
|
public void fetpetData(String sql) { |
|
|
|
public void fetpetData(String sql,String id) { |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("sql:" + sql); |
|
|
|
@ -65,7 +66,7 @@ public class PRPostData { |
|
|
|
|
|
|
|
// Unique data |
|
|
|
data.put("ASSESSMENTNO", row[10].toString()); |
|
|
|
data.put("UNIQUERECEIPTID", row[1].toString()); // uniqueid |
|
|
|
data.put("UNIQUERECEIPTID", row[0].toString()); // uniqueid |
|
|
|
data.put("TRANSACTIONNO", row[9].toString()); // order_id |
|
|
|
data.put("TRANSACTIONREFNO", row[6].toString()); // payment_id |
|
|
|
data.put("TRANSACTIONDATE", row[8].toString()); // paymentdate |
|
|
|
@ -84,23 +85,23 @@ public class PRPostData { |
|
|
|
} |
|
|
|
|
|
|
|
// Call the method with the fetched data |
|
|
|
postDataToERP(petDataList); |
|
|
|
postDataToERP(petDataList,id); |
|
|
|
} |
|
|
|
|
|
|
|
public void postDataToERP(List<Map<String, Object>> petlist) { |
|
|
|
public void postDataToERP(List<Map<String, Object>> petlist,String id) { |
|
|
|
for (Map<String, Object> data : petlist) { |
|
|
|
System.out.println("Sending Data: " + data); |
|
|
|
System.out.println("ERP URL before request: " + appConfig.getErpUrl()); |
|
|
|
|
|
|
|
String erpBaseUrl = "http://coc-staging.egovernments.org:9980/pgr/external/mobileservice?"; |
|
|
|
StringBuilder encodedUrl = new StringBuilder(erpBaseUrl); |
|
|
|
|
|
|
|
try { |
|
|
|
// String erpBaseUrl = "http://coc-staging.egovernments.org:9980/pgr/external/mobileservice?"; |
|
|
|
StringBuilder encodedUrl = new StringBuilder(appConfig.getErpUrl()); |
|
|
|
boolean firstParam = true; |
|
|
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); // Original format |
|
|
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); // Expected format |
|
|
|
outputFormat.setTimeZone(TimeZone.getTimeZone("Asia/Kolkata")); // Adjust timezone if needed |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
for (Map.Entry<String, Object> entry : data.entrySet()) { |
|
|
|
if (!firstParam) { |
|
|
|
encodedUrl.append("&"); |
|
|
|
@ -128,8 +129,8 @@ public class PRPostData { |
|
|
|
} |
|
|
|
|
|
|
|
encodedUrl.append(key).append("=").append(URLEncoder.encode(value, "UTF-8")); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
String finalUrl = encodedUrl.toString(); |
|
|
|
System.out.println("Final Encoded URL: " + finalUrl); |
|
|
|
|
|
|
|
@ -148,14 +149,34 @@ public class PRPostData { |
|
|
|
} |
|
|
|
in.close(); |
|
|
|
System.out.println("Response: " + response.toString()); |
|
|
|
saveTheLog(data,response); |
|
|
|
if(id != null){ |
|
|
|
updateTheLog(data,response,id); |
|
|
|
}else { |
|
|
|
saveTheLog(data, response); |
|
|
|
} |
|
|
|
} else { |
|
|
|
System.out.println("GET request failed."); |
|
|
|
saveTheLog(data,null); |
|
|
|
if(id != null){ |
|
|
|
updateTheLog(data,null,id); |
|
|
|
}else { |
|
|
|
saveTheLog(data, null); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch(Exception e){ |
|
|
|
try { |
|
|
|
if(id != null){ |
|
|
|
updateTheLog(data,null,id); |
|
|
|
}else { |
|
|
|
saveTheLog(data, null); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e1) { |
|
|
|
e1.printStackTrace(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -167,15 +188,20 @@ public class PRPostData { |
|
|
|
if(response != null) { |
|
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
|
Map<String, Object> res = objectMapper.readValue(response.toString(), Map.class); |
|
|
|
status = res.get("ResultStatus").toString(); |
|
|
|
msgStatus = res.get("Message").toString(); |
|
|
|
if(res.get("ResultStatus") != null) { |
|
|
|
status = res.get("ResultStatus").toString(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("ResultStatus: " + status); |
|
|
|
String msg = "Already Updated this collection"; |
|
|
|
|
|
|
|
|
|
|
|
if(msg.equals(msgStatus) && status.equals("false")) { |
|
|
|
String conFailure = "Connection Failure"; |
|
|
|
if(conFailure.equals(msgStatus) ) { |
|
|
|
statusCode="1"; |
|
|
|
} |
|
|
|
else if(msg.equals(msgStatus) && status.equals("false")) { |
|
|
|
statusCode="1"; |
|
|
|
} else if ("Failure".equals(msgStatus) && status.equals("false")) { |
|
|
|
statusCode="2"; |
|
|
|
|