|
|
@ -61,7 +61,6 @@ public class ShelterResucueService { |
|
|
this.jdbcShelterRescueTemplate = new JdbcTemplate(ShelterRescueataSource); |
|
|
this.jdbcShelterRescueTemplate = new JdbcTemplate(ShelterRescueataSource); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getSurveyQuestions(Integer cid) { |
|
|
public List<Map<String, Object>> getSurveyQuestions(Integer cid) { |
|
|
|
|
|
|
|
|
String childSql = "SELECT DISTINCT child_qid FROM shelter_resuce_question_mapping " + |
|
|
String childSql = "SELECT DISTINCT child_qid FROM shelter_resuce_question_mapping " + |
|
|
@ -429,7 +428,8 @@ public class ShelterResucueService { |
|
|
if (cid != null && cid.equals("1") && (zone != null || resolvedLat != null || resolvedLng != null)) { |
|
|
if (cid != null && cid.equals("1") && (zone != null || resolvedLat != null || resolvedLng != null)) { |
|
|
try { |
|
|
try { |
|
|
// String logindetailsSql = "INSERT INTO surveyor_location_resuce_details " + |
|
|
// String logindetailsSql = "INSERT INTO surveyor_location_resuce_details " + |
|
|
// "(loginId, zone, ward, latitude, longitude, shelter_id, is_active, is_delete, cdate) " + |
|
|
|
|
|
|
|
|
// "(loginId, zone, ward, latitude, longitude, shelter_id, is_active, is_delete, |
|
|
|
|
|
// cdate) " + |
|
|
// "VALUES (?, ?, ?, ?, ?, ?, 1, 0, NOW())"; |
|
|
// "VALUES (?, ?, ?, ?, ?, ?, 1, 0, NOW())"; |
|
|
|
|
|
|
|
|
String logindetailsSql = "INSERT INTO surveyor_location_resuce_details " + |
|
|
String logindetailsSql = "INSERT INTO surveyor_location_resuce_details " + |
|
|
@ -496,7 +496,8 @@ public class ShelterResucueService { |
|
|
// if (familyMembersJson != null && !familyMembersJson.trim().isEmpty() |
|
|
// if (familyMembersJson != null && !familyMembersJson.trim().isEmpty() |
|
|
// && familyMembersJson.trim().startsWith("[")) { |
|
|
// && familyMembersJson.trim().startsWith("[")) { |
|
|
// try { |
|
|
// try { |
|
|
// List<Map<String, Object>> familyList = parseFamilyMembersJson(familyMembersJson); |
|
|
|
|
|
|
|
|
// List<Map<String, Object>> familyList = |
|
|
|
|
|
// parseFamilyMembersJson(familyMembersJson); |
|
|
// if (familyList != null && !familyList.isEmpty()) { |
|
|
// if (familyList != null && !familyList.isEmpty()) { |
|
|
// saveFamilyMembers(familyList, surveyId, cby); |
|
|
// saveFamilyMembers(familyList, surveyId, cby); |
|
|
// } |
|
|
// } |
|
|
@ -572,14 +573,10 @@ public class ShelterResucueService { |
|
|
+ |
|
|
+ |
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, NOW(), 1, 0)"; |
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, NOW(), 1, 0)"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String insertSql = "INSERT INTO shelter_resuce_response (qid, answer, others_answer, survey_id, cid, cby, parent_answer_id, cdate, isactive, isdelete) " |
|
|
String insertSql = "INSERT INTO shelter_resuce_response (qid, answer, others_answer, survey_id, cid, cby, parent_answer_id, cdate, isactive, isdelete) " |
|
|
+ |
|
|
+ |
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, NOW(), 1, 0)"; |
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, NOW(), 1, 0)"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String qSql = "SELECT qid, question_type, field_name, q_english FROM shelter_resuce_questions_master " |
|
|
String qSql = "SELECT qid, question_type, field_name, q_english FROM shelter_resuce_questions_master " |
|
|
+ "WHERE cid = ? AND (isactive = 1 AND isdelete = 0 OR (cid = '1' AND field_name IN ('q2', 'q78', 'q11', 'q8', 'q9', 'q10', 'q77')))"; |
|
|
+ "WHERE cid = ? AND (isactive = 1 AND isdelete = 0 OR (cid = '1' AND field_name IN ('q2', 'q78', 'q11', 'q8', 'q9', 'q10', 'q77')))"; |
|
|
List<Map<String, Object>> questions = jdbcShelterRescueTemplate.queryForList(qSql, cid); |
|
|
List<Map<String, Object>> questions = jdbcShelterRescueTemplate.queryForList(qSql, cid); |
|
|
@ -1098,7 +1095,6 @@ public class ShelterResucueService { |
|
|
return resultList; |
|
|
return resultList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Map<String, Object>> parseFamilyMembersJson(String jsonStr) { |
|
|
private List<Map<String, Object>> parseFamilyMembersJson(String jsonStr) { |
|
|
if (jsonStr == null || jsonStr.trim().isEmpty()) { |
|
|
if (jsonStr == null || jsonStr.trim().isEmpty()) { |
|
|
return new ArrayList<>(); |
|
|
return new ArrayList<>(); |
|
|
@ -1156,7 +1152,6 @@ public class ShelterResucueService { |
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void saveFamilyMembers(List<Map<String, Object>> familyList, String surveyId, String cby) { |
|
|
private void saveFamilyMembers(List<Map<String, Object>> familyList, String surveyId, String cby) { |
|
|
if (familyList == null || familyList.isEmpty()) { |
|
|
if (familyList == null || familyList.isEmpty()) { |
|
|
return; |
|
|
return; |
|
|
@ -1202,14 +1197,13 @@ public class ShelterResucueService { |
|
|
qid = 8; |
|
|
qid = 8; |
|
|
} else if ("gender".equals(cleanKey)) { |
|
|
} else if ("gender".equals(cleanKey)) { |
|
|
qid = 9; |
|
|
qid = 9; |
|
|
} |
|
|
|
|
|
else if ("remark".equals(cleanKey)) { |
|
|
|
|
|
|
|
|
} else if ("remark".equals(cleanKey)) { |
|
|
qid = 10; |
|
|
qid = 10; |
|
|
|
|
|
} else if ("resucelocaton".equals(cleanKey)) { |
|
|
|
|
|
qid = 11; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fallback: If still null, try resolving by field_name or matching q_english |
|
|
// Fallback: If still null, try resolving by field_name or matching q_english |
|
|
// (case-insensitive) from DB without active/delete constraint |
|
|
// (case-insensitive) from DB without active/delete constraint |
|
|
if (qid == null) { |
|
|
if (qid == null) { |
|
|
@ -1251,20 +1245,20 @@ public class ShelterResucueService { |
|
|
parentAnswerId = 2; |
|
|
parentAnswerId = 2; |
|
|
} else if (qid == 9) { |
|
|
} else if (qid == 9) { |
|
|
parentAnswerId = 3; |
|
|
parentAnswerId = 3; |
|
|
} |
|
|
|
|
|
else if (qid == 10) { |
|
|
|
|
|
|
|
|
} else if (qid == 10) { |
|
|
parentAnswerId = 4; |
|
|
parentAnswerId = 4; |
|
|
|
|
|
} else if (qid == 11) { |
|
|
|
|
|
parentAnswerId = 5; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fallback: If still null, try resolving from mapping table (without |
|
|
// Fallback: If still null, try resolving from mapping table (without |
|
|
// active/delete constraint) |
|
|
// active/delete constraint) |
|
|
if (parentAnswerId == null) { |
|
|
if (parentAnswerId == null) { |
|
|
try { |
|
|
try { |
|
|
String parentAidSql = "SELECT parent_aid FROM rag_picker_question_mapping WHERE child_qid = ? LIMIT 1"; |
|
|
String parentAidSql = "SELECT parent_aid FROM rag_picker_question_mapping WHERE child_qid = ? LIMIT 1"; |
|
|
List<Integer> list = jdbcShelterRescueTemplate.queryForList(parentAidSql, Integer.class, qid); |
|
|
|
|
|
|
|
|
List<Integer> list = jdbcShelterRescueTemplate.queryForList(parentAidSql, Integer.class, |
|
|
|
|
|
qid); |
|
|
if (!list.isEmpty()) { |
|
|
if (!list.isEmpty()) { |
|
|
parentAnswerId = list.get(0); |
|
|
parentAnswerId = list.get(0); |
|
|
} |
|
|
} |
|
|
@ -1290,6 +1284,4 @@ public class ShelterResucueService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |