Commit 50bab80d authored by Quxl's avatar Quxl

x

parent 4af1ab44
......@@ -29,5 +29,11 @@ public interface ReviewService {
List<Fc_review_record_ext> queryReviewRecordExtList(Integer record_id);
List<Map<String, Object>> queryReviewRecordList(Integer review_id);
void toFirstRound(Long member_film_id, Integer enroll_type_id);
void toNextRound(Integer review_id);
void tryNextRound(Integer review_id);
}
\ No newline at end of file
package com.egolm.film.api.service;
public interface VoteService {
/**
* 进入下一个审片环节
* @param member_film_id
*/
void toFirstRound(Long member_film_id, Integer enroll_type_id);
void toNextRound(Integer review_id);
void tryNextRound(Integer review_id);
}
package com.egolm.film.api.service.impl;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -118,4 +120,92 @@ public class ReviewServiceImpl implements ReviewService {
return jdbcTemplate.queryForList(sql, review_id);
}
@Override
@Transactional
public void toFirstRound(Long member_film_id, Integer enroll_type_id) {
Date now = new Date();
Fc_review review = new Fc_review();
review.setEnroll_type_id(enroll_type_id);
review.setFilm_id(member_film_id.intValue());
review.setReview_round(1);
review.setPush_time(now);
review.setAllot_state(0);
review.setState(0);
review.setReview_state(null);
review.setCreate_time(now);
jdbcTemplate.save(review);
}
@Override
public void toNextRound(Integer review_id) {
Integer count = jdbcTemplate.queryForInt("select count(*) from fc_review_record where review_id = ?", review_id);
Integer allot_state = count > 0 ? 1 : 0;
jdbcTemplate.executeUpdate("update fc_review set review_round = review_round + 1, state = 0, allot_state = ?, review_state = null, push_time = now() where id = ?", allot_state, review_id);
}
private Integer reviewStateElection(List<Fc_review_record> records) {
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for(Fc_review_record record : records) {
Integer review_state = record.getReview_state();;
if(review_state.intValue() <= 1) {
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) {
Integer i = 0;
Integer review_state = null;
for(Integer key : map.keySet()) {
Integer value = map.get(key);
if(value.intValue() == maxCount.intValue()) {
review_state = key;
i++;
}
}
if(i.intValue() == 1) {
return review_state;
} else {
return -1;
}
}
return null;
}
/**
* 1剧情
* 2纪录
* 3动画
* 4短片
*/
@Override
public void tryNextRound(Integer 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 = ?", Fc_review_record.class, review.getId());
Integer enroll_type_id = review.getEnroll_type_id();
Integer review_round = review.getReview_round();
Integer review_state = this.reviewStateElection(records);
if(review_state == null) {
//没有审完
return;
} else if(review_state == -1) {
//审片结果有争议,等待增加新评委或管理员决定本轮最终结果
jdbcTemplate.executeUpdate("update fc_review set state = 1 where id = ?", review.getId());
} else if((enroll_type_id.intValue() == 2 || enroll_type_id.intValue() == 4) && (review_round == 2 || review_round == 3)) {
//理员决定是否晋级下一轮评选
jdbcTemplate.executeUpdate("update fc_review set state = 2 where id = ?", review.getId());
} else {
if(review_round < 6) {
//自动进入下一轮评选
this.toNextRound(review.getId());
} else {
//已经是最后一轮评选
jdbcTemplate.executeUpdate("update fc_review set state = 3 where id = ?", review.getId());
}
}
}
}
package com.egolm.film.api.service.impl;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.film.api.service.VoteService;
import com.egolm.film.bean.Fc_review;
import com.egolm.film.bean.Fc_review_record;
@Service
public class VoteServiceImpl implements VoteService {
@Autowired
JdbcTemplate jdbcTemplate;
@Override
@Transactional
public void toFirstRound(Long member_film_id, Integer enroll_type_id) {
Date now = new Date();
Fc_review review = new Fc_review();
review.setEnroll_type_id(enroll_type_id);
review.setFilm_id(member_film_id.intValue());
review.setReview_round(1);
review.setPush_time(now);
review.setAllot_state(0);
review.setState(0);
review.setReview_state(null);
review.setCreate_time(now);
jdbcTemplate.save(review);
}
@Override
public void toNextRound(Integer review_id) {
Integer count = jdbcTemplate.queryForInt("select count(*) from fc_review_record where review_id = ?", review_id);
Integer allot_state = count > 0 ? 1 : 0;
jdbcTemplate.executeUpdate("update fc_review set review_round = review_round + 1, state = 0, allot_state = ?, review_state = null, push_time = now() where id = ?", allot_state, review_id);
}
private Integer reviewStateElection(List<Fc_review_record> records) {
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for(Fc_review_record record : records) {
Integer review_state = record.getReview_state();;
if(review_state.intValue() <= 1) {
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) {
Integer i = 0;
Integer review_state = null;
for(Integer key : map.keySet()) {
Integer value = map.get(key);
if(value.intValue() == maxCount.intValue()) {
review_state = key;
i++;
}
}
if(i.intValue() == 1) {
return review_state;
} else {
return -1;
}
}
return null;
}
/**
* 1剧情
* 2纪录
* 3动画
* 4短片
*/
@Override
public void tryNextRound(Integer 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 = ?", Fc_review_record.class, review.getId());
Integer enroll_type_id = review.getEnroll_type_id();
Integer review_round = review.getReview_round();
Integer review_state = this.reviewStateElection(records);
if(review_state == null) {
//没有审完
return;
} else if(review_state == -1) {
//审片结果有争议,等待增加新评委或管理员决定本轮最终结果
jdbcTemplate.executeUpdate("update fc_review set state = 1 where id = ?", review.getId());
} else if((enroll_type_id.intValue() == 2 || enroll_type_id.intValue() == 4) && (review_round == 2 || review_round == 3)) {
//理员决定是否晋级下一轮评选
jdbcTemplate.executeUpdate("update fc_review set state = 2 where id = ?", review.getId());
} else {
if(review_round < 6) {
//自动进入下一轮评选
this.toNextRound(review.getId());
} else {
//已经是最后一轮评选
jdbcTemplate.executeUpdate("update fc_review set state = 3 where id = ?", review.getId());
}
}
}
}
......@@ -22,7 +22,7 @@ import com.egolm.film.api.service.EmailService;
import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.MemberService;
import com.egolm.film.api.service.Messages;
import com.egolm.film.api.service.VoteService;
import com.egolm.film.api.service.ReviewService;
import com.egolm.film.bean.Fc_member;
import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.bean.Fc_member_film_enroll;
......@@ -60,7 +60,7 @@ public class AdminFirstController {
Messages messages;
@Autowired
VoteService voteService;
ReviewService reviewService;
@ResponseBody
@PostMapping("list")
......@@ -124,7 +124,7 @@ public class AdminFirstController {
memberFilmService.pass(member_film_id);
List<Fc_member_film_enroll> enrolls = memberFilmService.queryFilmEnrollList(member_film_id);
for(Fc_member_film_enroll enroll : enrolls) {
voteService.toFirstRound(member_film_id, enroll.getEnroll_type_id());
reviewService.toFirstRound(member_film_id, enroll.getEnroll_type_id());
}
Fc_member_film memberFilm = memberFilmService.queryMemberFilmById(member_film_id);
Fc_member member = memberService.getMemberById(memberFilm.getMember_id());
......
......@@ -18,7 +18,6 @@ import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.ReviewService;
import com.egolm.film.api.service.UserTokenService;
import com.egolm.film.api.service.VoteService;
import com.egolm.film.bean.Fc_review_doubtful;
import com.egolm.film.bean.Fc_review_record;
import com.egolm.film.bean.Fc_review_record_ext;
......@@ -44,9 +43,6 @@ public class UserReviewController {
@Autowired
FilmService filmService;
@Autowired
VoteService voteService;
@ResponseBody
@PostMapping("review_list")
@ApiOperation("审核列表")
......@@ -149,7 +145,7 @@ public class UserReviewController {
throw new XException("评奖项目参数数量错误");
}
service.saveReviewRecord(ru, exts);
voteService.tryNextRound(review_id);
service.tryNextRound(review_id);
return Rjx.jsonOk();
}
......
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