Commit 636f0358 authored by 张永's avatar 张永
parents 4cb47f31 399a638e
......@@ -92,6 +92,8 @@ public interface ReviewService {
void tryNextRound(Integer review_id);
void createAsiaNewReport(int review_id, int review_round);
void save(Object obj);
void saveReviewRecordIfNotExists(Integer review_id, Integer review_round, Integer[] user_id);
......
......@@ -31,6 +31,7 @@ import com.egolm.film.bean.Fc_review_record;
import com.egolm.film.bean.Fc_review_record_ext;
import com.egolm.film.bean.Fc_user;
import com.egolm.film.bean.Fc_user_film;
import com.egolm.film.config.XException;
import com.egolm.film.config.XRException;
import com.egolm.film.util.SqlWhere;
......@@ -139,9 +140,8 @@ public class ReviewServiceImpl implements ReviewService {
@Override
public List<Map<String, Object>> queryBestMvListByGroup(String keyword, Integer user_group_id, Integer review_round, String ext_type, Page page) {
XRException.assertNotBlank("选片轮数不能为空", review_round);
String sql = "select r.* from fc_review r, fc_review_record rr, fc_review_record_ext rre where rre.record_id = rr.id and rr.review_id = r.id and r.enroll_type_id = 2 and review_round >= " + review_round + " group by rr.review_id, rre.record_id, ";
//TODO
return null;
String sql = "select ran.*, mf.film_no from fc_report_asia_new ran left join fc_member_film mf on mf.id = ran.film_id where ran.user_group_id = " + user_group_id + " and ran.review_round = " + review_round + (StringUtil.isNotBlank(ext_type) ? (" and ran.item_" + ext_type + " is not null") : "");
return jdbcTemplate.limit(sql, page);
}
@Override
......@@ -311,17 +311,19 @@ public class ReviewServiceImpl implements ReviewService {
public void toRound(Integer review_id, Integer review_round) {
Integer count = jdbcTemplate.queryForInt("select count(rr.id) from fc_review_record rr, fc_review r where rr.review_id = r.id and rr.review_round = ? and r.id = ?", review_round, review_id);
Integer allot_state = count > 0 ? 1 : 0;
jdbcTemplate.executeUpdate("update fc_review set review_round = ?, opt_state = 0, allot_state = ?, review_state = null, push_time = now() where id = ?", review_round, allot_state, review_id);
jdbcTemplate.executeUpdate("update fc_review set review_round = ?, opt_state = 0, allot_state = ?, review_state = 0, push_time = now() where id = ?", review_round, allot_state, review_id);
}
private int toReviewState(List<Fc_review_record> records) {
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
Integer noReviewCount = 0;
for(Fc_review_record record : records) {
Integer review_state = record.getReview_state();;
if(review_state == null) {
return 0;
Integer review_state = record.getReview_state();
if(review_state == 0) {
noReviewCount ++;
} else {
map.put(review_state, map.get(review_state) == null ? 1 : (map.get(review_state) + 1));
}
map.put(review_state, map.get(review_state) == null ? 1 : (map.get(review_state) + 1));
}
Collection<Integer> ary = map.values();
Integer maxCount = 0;
......@@ -329,7 +331,7 @@ public class ReviewServiceImpl implements ReviewService {
maxCount = count > maxCount ? count : maxCount;
}
if(maxCount > 0) {
Integer i = 0;
int i = 0;
Integer review_state = null;
for(Integer key : map.keySet()) {
Integer value = map.get(key);
......@@ -338,9 +340,10 @@ public class ReviewServiceImpl implements ReviewService {
i++;
}
}
if(i.intValue() == 1) {
if(i == 1 && (noReviewCount == 0 || maxCount*2 > records.size())) {
return review_state;
} else {
} else if(i > 1 && noReviewCount == 0) {
return -1;
}
}
......@@ -374,9 +377,6 @@ public class ReviewServiceImpl implements ReviewService {
} 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) {
......@@ -384,9 +384,6 @@ public class ReviewServiceImpl implements ReviewService {
} 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) {
......@@ -394,7 +391,7 @@ public class ReviewServiceImpl implements ReviewService {
}
}
if(enrollType == 2 && (reviewRound == 2 || reviewRound == 3)) {
this.createAsiaNewReport(review.getId());
this.createAsiaNewReport(review.getId().intValue(), reviewRound);
}
}
Integer opt_state = jdbcTemplate.queryForInt("select opt_state from fc_review where id = ?", review.getId());
......@@ -409,73 +406,73 @@ public class ReviewServiceImpl implements ReviewService {
jdbcTemplate.save(history);
}
public void createAsiaNewReport(Integer review_id) {
public void createAsiaNewReport(int review_id, int review_round) {
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();
int optState = review.getOpt_state();
if(enrollType == 2 && (round == 2 || round == 3) && optState == 2) {
if(enrollType == 2 && ((review_round == 2 && optState == 2 || review_round > 2) || (review_round == 3 && optState == 2 || review_round > 3))) {
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.setReview_round(review_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";
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);
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);
if(list != null && list.size() > 0) {
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.valueOf((Double)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);
}
@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());
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 if(fieldName.startsWith("item_")) {
field.set(asiaNew, ((BigDecimal)fields.get(fieldName)).doubleValue());
}
} catch (Exception e) {
throw new XException("生成亚新榜单中间结果错误", e);
}
} catch (Exception e) {
throw new XRException("生成亚新榜单中间结果错误", e);
}
jdbcTemplate.save(asiaNew);
}
}
}
......@@ -516,6 +513,7 @@ public class ReviewServiceImpl implements ReviewService {
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";
sql0 = "select count(t.user_group_id) from (" + sql0 + ") t";
Integer groupCount = jdbcTemplate.queryForInt(sql0, review_id, review_round);
if(groupCount > 1) {
throw new XRException("亚新二选或三选只能分配一组评委");
......
......@@ -140,6 +140,7 @@ public class AdminReviewController {
@ApiImplicitParam(paramType="query", dataType="int", name="review_round", value="第2或3选(2,3)"),
@ApiImplicitParam(paramType="query", dataType="long", name="index", value="分页编号"),
@ApiImplicitParam(paramType="query", dataType="long", name="limit", value="分页大小"),
@ApiImplicitParam(paramType="query", dataType="string", name="limitKey", value="分页排序", allowMultiple=true),
})
public Object getBestMvList(
String keyword,
......@@ -147,10 +148,11 @@ public class AdminReviewController {
Integer review_round,
String ext_type,
Long index,
Long limit) {
Long limit,
String[] limitKey) {
index = index == null ? 1 : index;
limit = limit == null ? 20 : limit;
Page page = new Page(index, limit);
Page page = new Page(index, limit, limitKey);
List<Map<String, Object>> list = reviewService.queryBestMvListByGroup(keyword, user_group_id, review_round, ext_type, page);
return Rjx.jsonOk().setData(list).setPage(page);
}
......@@ -270,8 +272,9 @@ public class AdminReviewController {
int reviewRound = review.getReview_round();
int enrollType = review.getEnroll_type_id();
int optState = review.getOpt_state();
int reviewState = review.getReview_state();
if(toRoundNumber > reviewRound) {
if(optState == 2) {
if(optState == 2 || (optState == 1 && reviewRound == 4 && toRoundNumber == 5)) {
if(enrollType == 2 && ((reviewRound <= 1 && reviewRound >= 3) || (reviewRound <= 2 && reviewRound >= 4))) {
throw new XRException("亚新二选和三选评分步骤不能跳过");
}
......@@ -281,6 +284,12 @@ public class AdminReviewController {
if(enrollType == 4 && (toRoundNumber == 3 || toRoundNumber == 6)) {
throw new XRException("展映影片没有三选和总局审片流程");
}
boolean isJinJue23Round = enrollType == 1 && (reviewRound == 2 || reviewRound == 3);
boolean isAsia2Round = enrollType == 2 && reviewRound == 2;
if(reviewState == 5 && (isJinJue23Round || isAsia2Round)) {//金爵二选三选或亚新二选转参赛影片把关流程
reviewService.toType4(review.getId());
reviewService.toRound(review.getId(), 4);
}
reviewService.toRound(review_id, toRoundNumber);
} else {
throw new XRException("当前审片状态为" + rounds[reviewRound] + opts[optState] + ",不能分配" + rounds[toRoundNumber] + "评委");
......
......@@ -28,6 +28,7 @@ import com.egolm.film.bean.Fc_admin;
import com.egolm.film.bean.Fc_logs_ext;
import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.bean.Fc_member_film_enroll;
import com.egolm.film.bean.Fc_review;
import com.egolm.film.config.XRException;
import io.swagger.annotations.Api;
......@@ -173,4 +174,23 @@ public class WebUtilController {
return Rjx.jsonOk();
}
@ResponseBody
@Transactional
@PostMapping("initAsiaNewBest")
@ApiOperation("初始化亚新榜单")
public Object initAsiaNewBest() {
this.verifyAuth();
List<Fc_review> reviews = jdbcTemplate.queryForBeans("select * from fc_review where enroll_type_id = 2 and review_round >= 2", Fc_review.class);
jdbcTemplate.executeUpdate("delete from fc_report_asia_new");
for(Fc_review review : reviews) {
if(review.getReview_round().intValue() >= 2) {
service.createAsiaNewReport(review.getId(), 2);
}
if(review.getReview_round().intValue() >= 3) {
service.createAsiaNewReport(review.getId(), 3);
}
}
return Rjx.jsonOk();
}
}
......@@ -51,6 +51,9 @@ public class Fc_report_asia_new implements java.io.Serializable {
@Column(columnDefinition="double(4,2)")
private Double item_photographer;
@Column(columnDefinition="double(4,2)")
private Double item_bestfilm;
@Column(columnDefinition="varchar(255)")
private String item_actor_data;
......@@ -66,6 +69,9 @@ public class Fc_report_asia_new implements java.io.Serializable {
@Column(columnDefinition="varchar(255)")
private String item_photographer_data;
@Column(columnDefinition="varchar(255)")
private String item_bestfilm_data;
public void setId(Integer id) {
this.id = id;
......@@ -171,6 +177,14 @@ public class Fc_report_asia_new implements java.io.Serializable {
return item_photographer;
}
public void setItem_bestfilm(Double item_bestfilm) {
this.item_bestfilm = item_bestfilm;
}
public Double getItem_bestfilm() {
return item_bestfilm;
}
public void setItem_actor_data(String item_actor_data) {
this.item_actor_data = item_actor_data;
}
......@@ -211,5 +225,13 @@ public class Fc_report_asia_new implements java.io.Serializable {
return item_photographer_data;
}
public void setItem_bestfilm_data(String item_bestfilm_data) {
this.item_bestfilm_data = item_bestfilm_data;
}
public String getItem_bestfilm_data() {
return item_bestfilm_data;
}
}
package com.egolm.film.util;
import sun.misc.BASE64Encoder;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import com.egolm.common.HttpUtil;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.SignatureException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.SimpleTimeZone;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import com.egolm.common.HttpUtil;
import sun.misc.BASE64Encoder;
/**
* 视频点播OpenAPI调用示例
* 以GetVideoPlayAuth接口为例,其他接口请替换相应接口名称及私有参数
*/
@SuppressWarnings("restriction")
public class AliyunSign {
//账号AK信息请填写(必选)
private static String access_key_id = "LTAIOtHCCpDLXYp8";
......@@ -222,7 +233,8 @@ public class AliyunSign {
return df.format(date);
}
private static String httpGet(String url) throws IOException {
@SuppressWarnings("unused")
private static String httpGet(String url) throws IOException {
/*
* Read and covert a inputStream to a String.
* Referred this:
......
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