Commit 3d0d57c8 authored by Quxl's avatar Quxl

x

parent 6ddda5fe
...@@ -420,55 +420,56 @@ public class ReviewServiceImpl implements ReviewService { ...@@ -420,55 +420,56 @@ public class ReviewServiceImpl implements ReviewService {
Map<String, Object> fields = new HashMap<String, Object>(); Map<String, Object> fields = new HashMap<String, Object>();
String sql = "select rr.user_group_id, rre.ext_type, rre.ext_name, avg(rre.ext_score) ext_score from fc_review_record rr, fc_review_record_ext rre where rre.record_id = rr.id and rr.review_id = " + review_id + " and rr.review_round = " + review_round + " group by rr.user_group_id, rre.ext_type, rre.ext_name"; String sql = "select rr.user_group_id, rre.ext_type, rre.ext_name, avg(rre.ext_score) ext_score from fc_review_record rr, fc_review_record_ext rre where rre.record_id = rr.id and rr.review_id = " + review_id + " and rr.review_round = " + review_round + " group by rr.user_group_id, rre.ext_type, rre.ext_name";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
for(Map<String, Object> map : list) { if(list != null && list.size() > 0) {
Integer user_group_id = (Integer)map.get("user_group_id"); for(Map<String, Object> map : list) {
String ext_type = (String)map.get("ext_type"); Integer user_group_id = (Integer)map.get("user_group_id");
String ext_name = (String)map.get("ext_name"); String ext_type = (String)map.get("ext_type");
BigDecimal ext_score = BigDecimal.valueOf((Double)map.get("ext_score")).setScale(2, BigDecimal.ROUND_HALF_UP); String ext_name = (String)map.get("ext_name");
String setScoreFildName = "item_" + ext_type; BigDecimal ext_score = BigDecimal.valueOf((Double)map.get("ext_score")).setScale(2, BigDecimal.ROUND_HALF_UP);
String setDataFieldName = "item_" + ext_type + "_data"; String setScoreFildName = "item_" + ext_type;
String setDataFieldName = "item_" + ext_type + "_data";
Integer tmpGroupId = (Integer)fields.get("user_group_id");
if(tmpGroupId == null) { Integer tmpGroupId = (Integer)fields.get("user_group_id");
fields.put("user_group_id", user_group_id); if(tmpGroupId == null) {
} else if(tmpGroupId.intValue() != user_group_id.intValue()) { fields.put("user_group_id", user_group_id);
throw new XRException("亚新影片出现同一影片由多组评委审片情况"); } else if(tmpGroupId.intValue() != user_group_id.intValue()) {
} throw new XRException("亚新影片出现同一影片由多组评委审片情况");
}
BigDecimal max_score = (BigDecimal)fields.get(setScoreFildName);
if(max_score == null || ext_score.compareTo(max_score) > 0) { BigDecimal max_score = (BigDecimal)fields.get(setScoreFildName);
fields.put(setScoreFildName, ext_score); if(max_score == null || ext_score.compareTo(max_score) > 0) {
fields.put(setScoreFildName, ext_score);
}
@SuppressWarnings("unchecked")
List<Map<String, Object>> datas = (List<Map<String, Object>>)fields.get(setDataFieldName);
if(datas == null) {
datas = new ArrayList<Map<String, Object>>();
fields.put(setDataFieldName, datas);
}
Map<String, Object> scoreMap = new HashMap<String, Object>();
scoreMap.put("ext_name", ext_name);
scoreMap.put("ext_score", ext_score);
datas.add(scoreMap);
} }
@SuppressWarnings("unchecked") for(String fieldName : fields.keySet()) {
List<Map<String, Object>> datas = (List<Map<String, Object>>)fields.get(setDataFieldName); try {
if(datas == null) { Field field = Fc_report_asia_new.class.getDeclaredField(fieldName);
datas = new ArrayList<Map<String, Object>>(); field.setAccessible(true);
fields.put(setDataFieldName, datas); if(fieldName.equals("user_group_id")) {
} field.set(asiaNew, fields.get(fieldName));
Map<String, Object> scoreMap = new HashMap<String, Object>(); } else if(fieldName.endsWith("_data")) {
scoreMap.put("ext_name", ext_name); field.set(asiaNew, JSON.toJSONString(fields.get(fieldName)));
scoreMap.put("ext_score", ext_score); } else if(fieldName.startsWith("item_")) {
datas.add(scoreMap); field.set(asiaNew, ((BigDecimal)fields.get(fieldName)).doubleValue());
} }
} catch (Exception e) {
for(String fieldName : fields.keySet()) { throw new XException("生成亚新榜单中间结果错误", e);
try {
Field field = Fc_report_asia_new.class.getDeclaredField(fieldName);
field.setAccessible(true);
if(fieldName.equals("user_group_id")) {
field.set(asiaNew, fields.get(fieldName));
} else if(fieldName.endsWith("_data")) {
field.set(asiaNew, JSON.toJSONString(fields.get(fieldName)));
} else if(fieldName.startsWith("item_")) {
field.set(asiaNew, ((BigDecimal)fields.get(fieldName)).doubleValue());
} }
} catch (Exception e) {
throw new XException("生成亚新榜单中间结果错误", e);
} }
jdbcTemplate.save(asiaNew);
} }
jdbcTemplate.save(asiaNew);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment