Commit 8e2c4876 authored by Quxl's avatar Quxl

x

parent c49dee3b
...@@ -310,68 +310,98 @@ public class ReviewServiceImpl implements ReviewService { ...@@ -310,68 +310,98 @@ public class ReviewServiceImpl implements ReviewService {
} }
private Integer toReviewState(List<Fc_review_record> records) { private Integer toReviewState(List<Fc_review_record> records) {
if(records != null && records.size() > 1) { Map<Integer, Integer> map = new HashMap<Integer, Integer>();
Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for(Fc_review_record record : records) {
for(Fc_review_record record : records) { Integer review_state = record.getReview_state();;
Integer review_state = record.getReview_state();; if(review_state == null) {
if(review_state == null) { return null;
return null;
}
map.put(review_state, map.get(review_state) == null ? 1 : (map.get(review_state) + 1));
}
Collection<Integer> ary = map.values();
Integer maxCount = 0;
for(Integer count : ary) {
maxCount = count > maxCount ? count : maxCount;
} }
if(maxCount > 0) { map.put(review_state, map.get(review_state) == null ? 1 : (map.get(review_state) + 1));
Integer i = 0; }
Integer review_state = null; Collection<Integer> ary = map.values();
for(Integer key : map.keySet()) { Integer maxCount = 0;
Integer value = map.get(key); for(Integer count : ary) {
if(value.intValue() == maxCount.intValue()) { maxCount = count > maxCount ? count : maxCount;
review_state = key; }
i++; if(maxCount > 0) {
} Integer i = 0;
} Integer review_state = null;
if(i.intValue() == 1) { for(Integer key : map.keySet()) {
return review_state; Integer value = map.get(key);
} else { if(value.intValue() == maxCount.intValue()) {
return -1; review_state = key;
i++;
} }
} }
if(i.intValue() == 1) {
return review_state;
} else {
return -1;
}
} }
return null; return null;
} }
private void closeFlow(int reviewState, int reviewId) {
jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = ? where id = ?", reviewState, reviewId);
}
@Override @Override
@Transactional @Transactional
public void tryNextRound(Integer review_id) { public void tryNextRound(Integer review_id) {
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);
List<Fc_review_record> records = jdbcTemplate.queryForBeans("select * from fc_review_record where review_id = ? and review_round = ?", Fc_review_record.class, review.getId(), review.getReview_round()); List<Fc_review_record> records = jdbcTemplate.queryForBeans("select * from fc_review_record where review_id = ? and review_round = ?", Fc_review_record.class, review.getId(), review.getReview_round());
Integer review_round = review.getReview_round(); int reviewRound = review.getReview_round().intValue();
Integer enroll_type_id = review.getEnroll_type_id(); int enrollType = review.getEnroll_type_id().intValue();
Integer review_state = this.toReviewState(records); int reviewState = 0;
if(review_state == null) {//未完 try {
reviewState = this.toReviewState(records).intValue();
} catch (NullPointerException e) {
//未完成
return; return;
} }
if(review_state.intValue() == 2) {//否决 if(reviewState == 2) {//否决
jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = 2 where id = ?", review.getId()); jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = 2 where id = ?", review.getId());
} else if(review_state.intValue() == -1) {//争议 } else if(reviewState == -1) {//争议
jdbcTemplate.executeUpdate("update fc_review set opt_state = 1, allot_state = 0 where id = ?", review.getId()); jdbcTemplate.executeUpdate("update fc_review set opt_state = 1, allot_state = 0 where id = ?", review.getId());
} else { } else {
jdbcTemplate.executeUpdate("update fc_review set opt_state = 2, review_state = ? where id = ?", review_state, review.getId()); jdbcTemplate.executeUpdate("update fc_review set opt_state = 2, review_state = ? where id = ?", reviewState, review.getId());
if(enroll_type_id.intValue() == 2 && (review_round.intValue() == 2 || review_round.intValue() == 3)) { if(enrollType == 1) {
if(reviewRound == 6 && reviewState == 1) {
this.closeFlow(reviewState, review.getId());
} else if(reviewRound == 5 && reviewState == 5) {
this.toType4(review.getId());
this.closeFlow(1, review.getId());
} else if((reviewRound == 2 || reviewRound == 3) && reviewState == 5) {
this.toType4(review.getId());
this.toRound(review.getId(), 4);
}
} else if(enrollType == 2) {
if(reviewRound == 6 && reviewState == 1) {
this.closeFlow(reviewState, review.getId());
} else if(reviewRound == 5 && reviewState == 5) {
this.toType4(review.getId());
this.closeFlow(1, review.getId());
} else if(reviewRound == 2 && reviewState == 5) {
this.toType4(review.getId());
this.toRound(review.getId(), 4);
}
} else if(enrollType == 4) {
if((reviewRound == 4 || reviewRound == 5) && reviewState == 1) {
this.closeFlow(1, review.getId());
}
}
if(enrollType == 2 && (reviewRound == 2 || reviewRound == 3)) {
this.createAsiaNewReport(review.getId()); this.createAsiaNewReport(review.getId());
} }
} }
Integer opt_state = jdbcTemplate.queryForInt("select opt_state from fc_review where id = ?", review.getId()); Integer opt_state = jdbcTemplate.queryForInt("select opt_state from fc_review where id = ?", review.getId());
Fc_review_history history = new Fc_review_history(); Fc_review_history history = new Fc_review_history();
history.setReview_id(review.getId()); history.setReview_id(review.getId());
history.setEnroll_type_id(enroll_type_id); history.setEnroll_type_id(enrollType);
history.setFilm_id(review.getFilm_id()); history.setFilm_id(review.getFilm_id());
history.setReview_round(review_round); history.setReview_round(reviewRound);
history.setReview_state(review_state); history.setReview_state(reviewState);
history.setCreate_time(new Date()); history.setCreate_time(new Date());
history.setOpt_state(opt_state); history.setOpt_state(opt_state);
jdbcTemplate.save(history); jdbcTemplate.save(history);
...@@ -379,7 +409,25 @@ public class ReviewServiceImpl implements ReviewService { ...@@ -379,7 +409,25 @@ public class ReviewServiceImpl implements ReviewService {
public void createAsiaNewReport(Integer review_id) { public void createAsiaNewReport(Integer review_id) {
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 enrollType = review.getEnroll_type_id();
if(enrollType == 2 && (round == 2 || round == 3)) {
}
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分 //TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
//TODO 计算单个亚新影片得分
} }
public void save(Object obj) { public void save(Object obj) {
...@@ -390,7 +438,7 @@ public class ReviewServiceImpl implements ReviewService { ...@@ -390,7 +438,7 @@ public class ReviewServiceImpl implements ReviewService {
@Transactional @Transactional
public void saveReviewRecordIfNotExists(Integer review_id, Integer review_round, Integer[] user_id) { public void saveReviewRecordIfNotExists(Integer review_id, Integer review_round, Integer[] user_id) {
Integer count = jdbcTemplate.queryForInt("select count(*) from fc_review_record where review_id = ? and review_round = ?", review_id, review_round); Integer count = jdbcTemplate.queryForInt("select count(*) from fc_review_record where review_id = ? and review_round = ?", review_id, review_round);
if(count + user_id.length < 2) { if(count + user_id.length < 2 && review_round.intValue() != 5 && review_round.intValue() != 6) {
throw new XRException("请至少分配两个审片评委"); throw new XRException("请至少分配两个审片评委");
} }
String sql = "" String sql = ""
......
...@@ -257,36 +257,41 @@ public class AdminReviewController { ...@@ -257,36 +257,41 @@ public class AdminReviewController {
} else { } else {
throw new XRException("参数不平衡"); throw new XRException("参数不平衡");
} }
Integer toRoundNumber = review_round;
if(saveList.size() > 0) { if(saveList.size() > 0) {
reviewService.saveReviewRecordIfNotExists(review_id, review_round, saveList.toArray(new Integer[saveList.size()])); reviewService.saveReviewRecordIfNotExists(review_id, toRoundNumber, saveList.toArray(new Integer[saveList.size()]));
Fc_admin admin = Util.mapTo(tokenService.getTokenObj(), Fc_admin.class); Fc_admin admin = Util.mapTo(tokenService.getTokenObj(), Fc_admin.class);
newsService.sendAllotNews(review_id, review_round, user_id, admin); newsService.sendAllotNews(review_id, toRoundNumber, user_id, admin);
} }
if(cancelList.size() > 0) { if(cancelList.size() > 0) {
reviewService.deleteReviewRecord(review_id, review_round, cancelList.toArray(new Integer[cancelList.size()])); reviewService.deleteReviewRecord(review_id, toRoundNumber, cancelList.toArray(new Integer[cancelList.size()]));
} }
Fc_review review = reviewService.queryReviewById(review_id); Fc_review review = reviewService.queryReviewById(review_id);
if(review_round.intValue() == 5 int reviewRound = review.getReview_round();
|| (review_round.intValue() > review.getReview_round().intValue() && review.getOpt_state().intValue() == 2)) { int enrollType = review.getEnroll_type_id();
if(review.getOpt_state() != 2) { int optState = review.getOpt_state();
throw new XRException("当前审片结论不能分配下一环节评委"); if(toRoundNumber > reviewRound) {
} if(optState == 2) {
if(review.getEnroll_type_id().intValue() == 2) { if(enrollType == 2 && ((reviewRound <= 1 && reviewRound >= 3) || (reviewRound <= 2 && reviewRound >= 4))) {
if((review.getReview_round().intValue() <= 1 && review_round.intValue() >= 3)
|| (review.getReview_round().intValue() <= 2 && review_round.intValue() >= 4)) {
throw new XRException("亚新二选和三选评分不能跳过"); throw new XRException("亚新二选和三选评分不能跳过");
} }
} if((enrollType == 2 || enrollType == 3) && toRoundNumber == 5) {
if(review.getReview_state().intValue() == 5 && review.getEnroll_type_id().intValue() != 4) { throw new XRException("亚新金爵影片没有把关流程");
reviewService.toType4(review.getId()); }
if(enrollType == 4 && (toRoundNumber == 3 || toRoundNumber == 6)) {
throw new XRException("展映影片没有三选和总局审片流程");
}
reviewService.toRound(review_id, toRoundNumber);
} else {
throw new XRException("当前审片状态为" + rounds[reviewRound] + opts[optState] + ",不能分配" + rounds[toRoundNumber] + "评委") ;
} }
reviewService.toRound(review_id, review_round);
} else {
throw new XRException("审片流程不能后退");
} }
return Rjx.jsonOk(); return Rjx.jsonOk();
} }
static String[] rounds = new String[] {"", "一选", "二选", "三选", "影片把关", "选片委员会", "总局审片"};
static String[] opts = new String[] {"未审片", "有争议", "待分配", "已完成"};
@ResponseBody @ResponseBody
@Transactional @Transactional
@PostMapping("allot_show_user") @PostMapping("allot_show_user")
......
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