Commit 6eef0f0b authored by 张永's avatar 张永
parents 8b01284b 2b8b3f44
package com.egolm.film.api.service.impl; package com.egolm.film.api.service.impl;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
...@@ -12,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
...@@ -20,6 +23,7 @@ import com.egolm.film.api.service.FilmService; ...@@ -20,6 +23,7 @@ import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.ReviewService; import com.egolm.film.api.service.ReviewService;
import com.egolm.film.bean.Fc_member_film; import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.bean.Fc_member_film_enroll; import com.egolm.film.bean.Fc_member_film_enroll;
import com.egolm.film.bean.Fc_report_asia_new;
import com.egolm.film.bean.Fc_review; import com.egolm.film.bean.Fc_review;
import com.egolm.film.bean.Fc_review_doubtful; import com.egolm.film.bean.Fc_review_doubtful;
import com.egolm.film.bean.Fc_review_history; import com.egolm.film.bean.Fc_review_history;
...@@ -409,24 +413,70 @@ public class ReviewServiceImpl implements ReviewService { ...@@ -409,24 +413,70 @@ public class ReviewServiceImpl implements ReviewService {
Fc_review review = jdbcTemplate.queryForBean("select * from fc_review where id = ?", Fc_review.class, review_id); Fc_review review = jdbcTemplate.queryForBean("select * from fc_review where id = ?", Fc_review.class, review_id);
int round = review.getReview_round(); int round = review.getReview_round();
int enrollType = review.getEnroll_type_id(); int enrollType = review.getEnroll_type_id();
if(enrollType == 2 && (round == 2 || round == 3)) { int optState = review.getOpt_state();
if(enrollType == 2 && (round == 2 || round == 3) && optState == 2) {
Fc_member_film film = filmService.queryMemberFilmById(review.getFilm_id().longValue()); Fc_member_film film = filmService.queryMemberFilmById(review.getFilm_id().longValue());
Fc_report_asia_new asiaNew = new Fc_report_asia_new();
asiaNew.setReview_id(review_id);
asiaNew.setReview_round(round);
asiaNew.setFilm_id(review.getFilm_id());
asiaNew.setCn_name(film.getCn_name());
asiaNew.setEn_name(film.getEn_name());
asiaNew.setOriginal_name(film.getOrigion_name());
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 + " group by rr.user_group_id, rre.ext_type, rre.ext_name";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
for(Map<String, Object> map : list) {
Integer user_group_id = (Integer)map.get("user_group_id");
String ext_type = (String)map.get("ext_type");
String ext_name = (String)map.get("ext_name");
BigDecimal ext_score = ((BigDecimal)map.get("ext_score")).setScale(2, BigDecimal.ROUND_HALF_UP);
String setScoreFildName = "item_" + ext_type;
String setDataFieldName = "item_" + ext_type + "_data";
Integer tmpGroupId = (Integer)fields.get("user_group_id");
if(tmpGroupId == null) {
fields.put("user_group_id", user_group_id);
} 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) {
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);
}
for(String fieldName : fields.keySet()) {
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 {
field.set(asiaNew, ((BigDecimal)fields.get(fieldName)).doubleValue());
}
} catch (Exception e) {
throw new XRException("生成亚新榜单中间结果错误", e);
}
}
} }
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
} }
public void save(Object obj) { public void save(Object obj) {
...@@ -464,6 +514,12 @@ public class ReviewServiceImpl implements ReviewService { ...@@ -464,6 +514,12 @@ public class ReviewServiceImpl implements ReviewService {
} }
jdbcTemplate.batchUpdate("update fc_review_record set user_group_id = ? where review_id = ? and review_round = ? and user_id = ?", objs2); jdbcTemplate.batchUpdate("update fc_review_record set user_group_id = ? where review_id = ? and review_round = ? and user_id = ?", objs2);
jdbcTemplate.executeUpdate("update fc_review set allot_state = 1, opt_state = 0 where id = ? and review_round = ?", review_id, review_round); jdbcTemplate.executeUpdate("update fc_review set allot_state = 1, opt_state = 0 where id = ? and review_round = ?", review_id, review_round);
String sql0 = "select rr.user_group_id from fc_review_record rr, fc_review r where rr.review_id = r.id and r.enroll_type_id = 2 and rr.review_id = ? and rr.review_round = ? and rr.review_round in (2,3) group by rr.user_group_id";
Integer groupCount = jdbcTemplate.queryForInt(sql0, review_id, review_round);
if(groupCount > 1) {
throw new XRException("亚新二选或三选只能分配一组评委");
}
} }
@Override @Override
......
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