Commit 5adbdb9d authored by Quxl's avatar Quxl

Merge branch 'master' of

http://key@gitlab.egolm.com/hanxu/siff-film-api.git

Conflicts:
	src/main/java/com/egolm/film/api/web/admin/AdminFirstController.java
parents b9475773 d4c69c3c
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.egolm.common.jdbc.Page;
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_issuer;
import com.egolm.film.bean.Fc_member_film_playactor;
import com.egolm.film.bean.Fc_member_film_show;
import com.egolm.film.bean.model.Fc_member_film_base_model;
public interface FilmService {
Logger logger = LoggerFactory.getLogger(FilmService.class);
List<Fc_member_film_issuer> queryMemberFilmIssuerList(Long member_film_id);
List<Fc_member_film_playactor> queryMemberFilmPlayactorList(Long member_film_id);
List<Fc_member_film_show> queryMemberFilmShowList(Long member_film_id);
void doApply(
Integer member_id,
Long member_film_id);
Long saveMemberFilmType(
Integer member_id,
String film_type_name,
String enroll_type_name);
void saveMemberFilmBase(
Integer member_id,
Long member_film_id,
String[] enroll_type_name_other,
String cn_name,
String en_name,
String intro);
void saveMemberFilmInfo(
Integer member_id,
Long member_film_id,
String film_country,
String dialogue_lang,
String subtitle_lang,
String[] co_production_country,
String film_total_time,
String completion_date,
String show_date,
String first_show_date,
String first_show_city,
Integer is_apply_other_filmfest,
String other_filmfest_name,
String film_medium,
String film_format,
String film_format_url,
String film_format_passw,
String film_format_other);
void saveMemberFilmPlayactor(
Long member_film_id,
String[] playactor_type,
String[] playactor_role_name,
String[] playactor_name,
String[] playactor_film_nums,
String[] playactor_country,
String[] playactor_birthday,
String[] playactor_intro,
Integer[] is_play_shanghai);
void saveMemberFilmIssuer(
Long member_film_id,
String[] issuer_company,
String[] issuer_contacts,
String[] issuer_email,
String[] issuer_tel);
void saveMemberFilmShow(
Long member_film_id,
String play_shanghai,
String[] show_filmfest,
String[] show_filmfest_type,
String[] show_filmfest_intro);
void saveMemberFilmCompany(
Integer member_id,
Long member_film_id,
String film_apply_company,
String film_apply_realname,
String film_apply_email,
String film_apply_tel,
String film_apply_mobile,
String film_apply_country);
List<Map<String, Object>> queryListAll(String keyword);
List<Map<String, Object>> queryFilmList(
Integer admin_group_id,
String keyword,
Integer state,
Integer apply_state,
Integer upload_state,
Integer film_type,
Integer enroll_type,
String film_country,
Integer film_type_short,
String play_shanghai,
Integer review_round,
Integer review_state,
Integer allot_atate,
Integer opt_state,
Integer[] film_group_id,
Page page);
Integer pass(Long member_film_id);
void reject(Boolean is_stop_apply, Long member_film_id, String apply_state_intro);
Fc_member_film queryMemberFilmById(Long member_film_id);
Object queryEnrollList();
Object queryTypeList();
void mergeMemberFilm(Fc_member_film film);
/**
* 更新影片基本信息
* @param filmBase
*/
void updateFilmBase(Fc_member_film_base_model filmBase);
void updateEnroll(Long member_film_id);
void saveUploadId(Long member_film_id, String upload_id);
void saveUploadState(Long member_film_id, Integer upload_state);
List<Fc_member_film_enroll> queryFilmEnrollList(Long member_film_id);
void verifyFilmDuplicate(Long member_film_id);
void updateFilmState(Long member_film_id, Integer state);
void saveCreateBase(Long id, Integer admin_id, Integer member_id, String create_ip);
void exchangeFilmNo(Integer id1, Integer id2);
void initKeywords(Long member_film_id);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.egolm.common.jdbc.Page;
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_issuer;
import com.egolm.film.bean.Fc_member_film_playactor;
import com.egolm.film.bean.Fc_member_film_show;
import com.egolm.film.bean.model.Fc_member_film_base_model;
public interface FilmService {
Logger logger = LoggerFactory.getLogger(FilmService.class);
List<Fc_member_film_issuer> queryMemberFilmIssuerList(Long member_film_id);
List<Fc_member_film_playactor> queryMemberFilmPlayactorList(Long member_film_id);
List<Fc_member_film_show> queryMemberFilmShowList(Long member_film_id);
void doApply(
Integer member_id,
Long member_film_id);
Long saveMemberFilmType(
Integer member_id,
String film_type_name,
String enroll_type_name);
void saveMemberFilmBase(
Integer member_id,
Long member_film_id,
String[] enroll_type_name_other,
String cn_name,
String en_name,
String intro);
void saveMemberFilmInfo(
Integer member_id,
Long member_film_id,
String film_country,
String dialogue_lang,
String subtitle_lang,
String[] co_production_country,
String film_total_time,
String completion_date,
String show_date,
String first_show_date,
String first_show_city,
Integer is_apply_other_filmfest,
String other_filmfest_name,
String film_medium,
String film_format,
String film_format_url,
String film_format_passw,
String film_format_other);
void saveMemberFilmPlayactor(
Long member_film_id,
String[] playactor_type,
String[] playactor_role_name,
String[] playactor_name,
String[] playactor_film_nums,
String[] playactor_country,
String[] playactor_birthday,
String[] playactor_intro,
Integer[] is_play_shanghai);
void saveMemberFilmIssuer(
Long member_film_id,
String[] issuer_company,
String[] issuer_contacts,
String[] issuer_email,
String[] issuer_tel);
void saveMemberFilmShow(
Long member_film_id,
String play_shanghai,
String[] show_filmfest,
String[] show_filmfest_type,
String[] show_filmfest_intro);
void saveMemberFilmCompany(
Integer member_id,
Long member_film_id,
String film_apply_company,
String film_apply_realname,
String film_apply_email,
String film_apply_tel,
String film_apply_mobile,
String film_apply_country);
List<Map<String, Object>> queryListAll(String keyword);
List<Map<String, Object>> queryFilmList(
Integer admin_group_id,
String keyword,
Integer state,
Integer apply_state,
Integer upload_state,
Integer film_type,
Integer enroll_type,
String film_country,
Integer film_type_short,
String play_shanghai,
Integer review_round,
Integer review_state,
Integer allot_atate,
Integer opt_state,
Integer[] film_group_id,
Page page);
Integer pass(Long member_film_id);
void reject(Boolean is_stop_apply, Long member_film_id, String apply_state_intro);
Fc_member_film queryMemberFilmById(Long member_film_id);
Object queryEnrollList();
Object queryTypeList();
void mergeMemberFilm(Fc_member_film film);
/**
* 更新影片基本信息
* @param filmBase
*/
void updateFilmBase(Fc_member_film_base_model filmBase);
void updateEnroll(Long member_film_id);
void saveUploadId(Long member_film_id, String upload_id);
void saveUploadState(Long member_film_id, Integer upload_state);
List<Fc_member_film_enroll> queryFilmEnrollList(Long member_film_id);
void verifyFilmDuplicate(Long member_film_id);
void updateFilmState(Long member_film_id, Integer state);
void saveCreateBase(Long id, Integer admin_id, Integer member_id, String create_ip);
void exchangeFilmNo(Integer id1, Integer id2);
void initKeywords(Long member_film_id);
List<Map<String, Object>> queryMonitorUploadList(String keyword,Integer upload_state, Page page);
public void updateFilmUploadState(String[] film_id,String[] number);
}
package com.egolm.film.api.service.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
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.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.Messages;
import com.egolm.film.bean.Enum_enroll;
import com.egolm.film.bean.Enum_filmtype;
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_issuer;
import com.egolm.film.bean.Fc_member_film_playactor;
import com.egolm.film.bean.Fc_member_film_show;
import com.egolm.film.bean.model.Fc_member_film_base_model;
import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XException;
import com.egolm.film.config.XRException;
import com.egolm.film.util.SqlWhere;
@Service
public class FilmServiceImpl implements FilmService {
@Autowired
private Messages messages;
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public List<Fc_member_film_issuer> queryMemberFilmIssuerList(Long member_film_id) {
return jdbcTemplate.queryForBeans("select * from fc_member_film_issuer where film_id = ?", Fc_member_film_issuer.class, member_film_id);
}
@Override
public List<Fc_member_film_playactor> queryMemberFilmPlayactorList(Long member_film_id) {
return jdbcTemplate.queryForBeans("select * from fc_member_film_playactor where film_id = ?", Fc_member_film_playactor.class, member_film_id);
}
@Override
public List<Fc_member_film_show> queryMemberFilmShowList(Long member_film_id) {
return jdbcTemplate.queryForBeans("select * from fc_member_film_show where film_id = ?", Fc_member_film_show.class, member_film_id);
}
@Override
public void doApply(Integer member_id, Long member_film_id) {
int count = jdbcTemplate.executeUpdate("update fc_member_film set state = 2, apply_state = 1 where id = ? and member_id = ? and state = 1", member_film_id, member_id);
if(count == 0) {
throw new XRException("该片当前状态不能提交申报");
}
}
@Override
@Transactional
public Long saveMemberFilmType(
Integer member_id,
String film_type_name,
String enroll_type_name) {
Integer film_group_id = 0;
Integer state = 1;
Integer is_show = 1;
Integer apply_state = 1;
Integer is_check_director = 0;
Long create_time = System.currentTimeMillis()/1000;
Long last_modify_time = create_time;
String create_ip = ServletUtil.remoteIp(WebMvcConfig.getRequest());
String sql = ""
+ "insert into fc_member_film "
+ "("
+ "member_id, "
+ "film_type_name, "
+ "enroll_type_name, "
+ "film_group_id, "
+ "state, "
+ "is_show, "
+ "apply_state, "
+ "is_check_director, "
+ "create_time, "
+ "create_ip, "
+ "last_modify_time"
+ ") "
+ "values "
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
Object[] args = new Object[]{
member_id,
film_type_name,
enroll_type_name,
film_group_id,
state,
is_show,
apply_state,
is_check_director,
create_time,
create_ip,
last_modify_time};
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
for(int i = 0; i <args.length; i++) {
Object argObj = args[i];
if(argObj instanceof java.util.Date) {
java.util.Date argDate = (java.util.Date)argObj;
ps.setObject(i+1, new java.sql.Timestamp(argDate.getTime()));
} else if(argObj.getClass().isEnum()) {
ps.setObject(i+1, args[i].toString());
} else {
ps.setObject(i+1, args[i]);
}
}
return ps;
}
}, keyHolder);
Long film_id = keyHolder.getKey().longValue();
this.updateEnroll(film_id);
return keyHolder.getKey().longValue();
}
@Override
@Transactional
public void saveMemberFilmBase(
Integer member_id,
Long member_film_id,
String[] enroll_type_name_other,
String cn_name,
String en_name,
String intro) {
Long last_modify_time = System.currentTimeMillis()/1000;
String sql = "update fc_member_film set enroll_type_name_other = ?, cn_name = ?, en_name = ?, intro = ?, last_modify_time = ? where member_id = ? and id = ?";
String string = StringUtil.join(",", "", "", "", enroll_type_name_other);
Object[] args = new Object[]{string, cn_name, en_name, intro, last_modify_time, member_id, member_film_id};
this.updateEnroll(member_film_id);
jdbcTemplate.executeUpdate(sql, args);
}
@Override
public void saveMemberFilmInfo(
Integer member_id,
Long member_film_id,
String film_country,
String dialogue_lang,
String subtitle_lang,
String[] co_production_country,
String film_total_time,
String completion_date,
String show_date,
String first_show_date,
String first_show_city,
Integer is_apply_other_filmfest,
String other_filmfest_name,
String film_medium,
String film_format,
String film_format_url,
String film_format_passw,
String film_format_other) {
Long last_modify_time = System.currentTimeMillis()/1000;
String sql = ""
+ "update "
+ "fc_member_film "
+ "set "
+ "film_country = ?, "
+ "dialogue_lang = ?, "
+ "subtitle_lang = ?, "
+ "co_production_country = ?, "
+ "film_total_time = ?, "
+ "completion_date = ?, "
+ "show_date = ?, "
+ "first_show_date = ?, "
+ "first_show_city = ?, "
+ "is_apply_other_filmfest = ?, "
+ "other_filmfest_name = ?, "
+ "film_medium = ?, "
+ "film_format = ?, "
+ "film_format_url = ?, "
+ "film_format_passw = ?, "
+ "film_format_other = ?, "
+ "last_modify_time = ? "
+ "where "
+ "member_id = ? "
+ "and id = ?";
String str = StringUtil.join(",", "", "", "", co_production_country);
Object[] args = new Object[]{
film_country,
dialogue_lang,
subtitle_lang,
str,
film_total_time,
completion_date,
show_date,
first_show_date,
first_show_city,
is_apply_other_filmfest,
other_filmfest_name,
film_medium,
film_format,
film_format_url,
film_format_passw,
film_format_other,
last_modify_time,
member_id,
member_film_id};
jdbcTemplate.executeUpdate(sql, args);
}
@Override
@Transactional
public void saveMemberFilmPlayactor(
Long member_film_id,
String[] playactor_type,
String[] playactor_role_name,
String[] playactor_name,
String[] playactor_film_nums,
String[] playactor_country,
String[] playactor_birthday,
String[] playactor_intro,
Integer[] is_play_shanghai) {
Long create_time = System.currentTimeMillis()/1000;
List<Object[]> playactors = new ArrayList<Object[]>();
for(int i = 0; i < playactor_type.length; i++) {
playactors.add(new Object[]{
member_film_id,
playactor_name[i],
playactor_film_nums[i],
playactor_intro[i],
playactor_country[i],
playactor_birthday[i],
create_time,
playactor_type[i],
playactor_role_name[i]});
}
jdbcTemplate.executeUpdate("delete from fc_member_film_playactor where film_id = ?", member_film_id);
String sql_playactor = ""
+ "insert into fc_member_film_playactor("
+ "film_id, "
+ "playactor_name, "
+ "playactor_film_nums, "
+ "playactor_film_intro, "
+ "playactor_country, "
+ "playactor_birthday, "
+ "create_time, "
+ "playactor_type, "
+ "playactor_role_name)"
+ "values "
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?)";
jdbcTemplate.batchUpdate(sql_playactor, playactors);
}
@Override
@Transactional
public void saveMemberFilmIssuer(
Long member_film_id,
String[] issuer_company,
String[] issuer_contacts,
String[] issuer_email,
String[] issuer_tel) {
if(issuer_company.length == issuer_contacts.length &&
issuer_contacts.length == issuer_email.length &&
issuer_email.length == issuer_tel.length) {
Long create_time = System.currentTimeMillis()/1000;
Object[][] args = new Object[issuer_company.length][];
for(int i = 0; i < issuer_company.length; i++) {
args[i] = new Object[]{member_film_id, issuer_company[i], issuer_contacts[i], issuer_email[i], issuer_tel[i], create_time};
}
jdbcTemplate.executeUpdate("delete from fc_member_film_issuer where film_id = ?", member_film_id);
String sql = ""
+ "insert into fc_member_film_issuer ("
+ "film_id, "
+ "issuer_company, "
+ "issuer_contacts, "
+ "issuer_email, "
+ "issuer_tel, "
+ "create_time) "
+ "values "
+ "(?, ?, ?, ?, ?, ?);";
jdbcTemplate.batchUpdate(sql, args);
} else {
throw new XException(messages.get("err.args_nums"));
}
}
@Override
@Transactional
public void saveMemberFilmShow(
Long member_film_id,
String play_shanghai,
String[] show_filmfest,
String[] show_filmfest_type,
String[] show_filmfest_intro) {
if(show_filmfest.length == show_filmfest_type.length && show_filmfest_type.length == show_filmfest_intro.length) {
Long create_time = System.currentTimeMillis()/1000;
Object[][] args = new Object[show_filmfest.length][];
for(int i = 0; i < show_filmfest.length; i++) {
args[i] = new Object[]{member_film_id, show_filmfest[i], show_filmfest_type[i], show_filmfest_intro[i], create_time};
}
Long last_modify_time = System.currentTimeMillis()/1000;
jdbcTemplate.executeUpdate("update fc_member_film set play_shanghai = ?, last_modify_time = ? where id = ?", play_shanghai, last_modify_time, member_film_id);
jdbcTemplate.executeUpdate("delete from fc_member_film_show where film_id = ?", member_film_id);
String sql = "insert into fc_member_film_show (film_id, show_filmfest, show_filmfest_type, show_filmfest_intro, create_time) values (?, ?, ?, ?, ?);";
jdbcTemplate.batchUpdate(sql, args);
} else {
throw new XException(messages.get("err.args_nums"));
}
}
@Override
public void saveMemberFilmCompany(
Integer member_id,
Long member_film_id,
String film_apply_company,
String film_apply_realname,
String film_apply_email,
String film_apply_tel,
String film_apply_mobile,
String film_apply_country) {
Long last_modify_time = System.currentTimeMillis()/1000;
String sql = ""
+ "update "
+ "fc_member_film "
+ "set "
+ "film_apply_company = ?, "
+ "film_apply_realname = ?, "
+ "film_apply_email = ?, "
+ "film_apply_tel = ?, "
+ "film_apply_mobile = ?, "
+ "film_apply_country = ?,"
+ "last_modify_time = ? "
+ "where "
+ "member_id = ? "
+ "and id = ?";
Object[] args = new Object[]{
film_apply_company,
film_apply_realname,
film_apply_email,
film_apply_tel,
film_apply_mobile,
film_apply_country,
last_modify_time,
member_id,
member_film_id};
jdbcTemplate.executeUpdate(sql, args);
}
@Override
public Fc_member_film queryMemberFilmById(Long id) {
return jdbcTemplate.queryForBean("select * from fc_member_film where id = ?", Fc_member_film.class, id);
}
@Override
public List<Map<String, Object>> queryListAll(String keyword) {
if(StringUtil.isBlank(keyword)) {
String sql = "select * from fc_member_film";
return jdbcTemplate.queryForList(sql);
} else {
String sql = "select * from fc_member_film where en_name like ? or cn_name like ?";
return jdbcTemplate.queryForList(sql, "%" + keyword + "%", "%" + keyword + "%");
}
}
@Override
public List<Map<String, Object>> queryFilmList(
Integer admin_group_id,
String keyword,
Integer state,
Integer apply_state,
Integer upload_state,
Integer film_type,
Integer enroll_type_id,
String film_country,
Integer film_type_short,
String play_shanghai,
Integer review_round,
Integer review_state,
Integer allot_atate,
Integer opt_state,
Integer[] film_type_id,
Page page) {
SqlWhere where = new SqlWhere()
.where("mf.film_type_name = agf.film_type_id and agf.group_id = ?", admin_group_id)
.eq("mf.state", state)
.eq("mf.apply_state", apply_state)
.eq("mf.upload_state", upload_state)
.eq("mf.film_type_name", film_type)
.eq("mf.film_type_name_short", film_type_short)
.eq("mf.film_country", film_country)
.eq("mf.play_shanghai", play_shanghai)
.in("mf.film_type_id", film_type_id)
.lk("mf.keywords", keyword)
;
String sql_film = "fc_member_film";
if(StringUtil.isNotBlank(enroll_type_id)) {
sql_film = "(select mf0.* from fc_member_film mf0, fc_member_film_enroll mfe where mf0.id = mfe.film_id and mfe.enroll_type_id = " + enroll_type_id + ")";
}
String sql = ""
+ "select "
+ "mf.*, "
+ "fg.group_name, "
+ "r.review_round, "
+ "r.review_state, "
+ "r.allot_state, "
+ "r.opt_state, "
+ "m.username member_name, "
+ "a.realname admin_name "
+ "from " + sql_film + " mf "
+ "left join fc_review r on r.film_id = mf.id "
+ "left join fc_film_group fg on fg.id = mf.film_group_id "
+ "left join fc_member m on m.id = mf.member_id "
+ "left join fc_admin a on a.adminid = mf.admin_creator"
+ ", fc_admin_group_filmtype agf"
+ StringUtil.join(" and ", " where ", " ", " ", where.getStringList());
List<Object> objs = new ArrayList<Object>();
objs.addAll(where.getObjectList());
SqlWhere where2 = new SqlWhere()
.eq("t.review_round", review_round)
.eq("t.review_state", review_state)
.eq("t.allot_atate", allot_atate)
.eq("t.opt_state", opt_state)
;
sql = "select t.* from (" + sql + ") t" + StringUtil.join(" and ", " where ", " ", " ", where2.getStringList()) + " order by t.id desc";
objs.addAll(where2.getObjectList());
return jdbcTemplate.limit(sql, page, objs.toArray());
}
@Override
public synchronized Integer pass(Long member_film_id) {
this.updateEnroll(member_film_id);
Integer film_no = jdbcTemplate.queryForInt("select ifnull(max(film_no), 0) + 1 from fc_member_film");
String sql = "update fc_member_film set film_no = ?, apply_state = 2, upload_state = 0, pass_time = ? where id = ? and (film_no is null or film_no = '')";
jdbcTemplate.executeUpdate(sql, film_no, System.currentTimeMillis()/1000L, member_film_id);
return film_no;
}
@Override
public void reject(Boolean is_stop_apply, Long member_film_id, String apply_state_intro) {
if(is_stop_apply) {
String sql = "update fc_member_film set pass_time = ?, apply_state = 3, apply_state_intro = ? where id = ?";
jdbcTemplate.executeUpdate(sql, System.currentTimeMillis()/1000L, apply_state_intro, member_film_id);
} else {
String sql = "update fc_member_film set pass_time = ?, apply_state = 1, apply_state_intro = ?, state = 1 where id = ?";
jdbcTemplate.executeUpdate(sql, System.currentTimeMillis()/1000L, apply_state_intro, member_film_id);
}
}
@Override
public List<Enum_enroll> queryEnrollList() {
return jdbcTemplate.queryForBeansByField(Enum_enroll.class, new HashMap<String,Object>());
}
@Override
public List<Enum_filmtype> queryTypeList() {
return jdbcTemplate.queryForBeansByField(Enum_filmtype.class, new HashMap<String,Object>());
}
@Override
public void mergeMemberFilm(Fc_member_film film) {
jdbcTemplate.merge(film);
}
@Override
@Transactional
public void updateFilmBase(Fc_member_film_base_model filmBase) {
jdbcTemplate.saveOrUpdate(filmBase);
this.updateEnroll(filmBase.getId());
}
@Override
@Transactional
public void updateEnroll(Long member_film_id) {
Fc_member_film film = jdbcTemplate.queryForBean("select enroll_type_name, enroll_type_name_other from fc_member_film where id = ?", Fc_member_film.class, member_film_id);
String enroll_type_name = film.getEnroll_type_name();
List<Fc_member_film_enroll> enrolls = new ArrayList<Fc_member_film_enroll>();
if(enroll_type_name != null) {
String[] strs = enroll_type_name.split(",");
if(strs != null && strs.length > 0) {
for(String str : strs) {
if(str != null && str.matches("\\d+")) {
Fc_member_film_enroll enroll = new Fc_member_film_enroll();
enroll.setEnroll_type_id(Integer.valueOf(str));
enroll.setFilm_id(member_film_id.intValue());
enrolls.add(enroll);
}
}
}
}
jdbcTemplate.executeUpdate("delete from fc_member_film_enroll where film_id = ?", member_film_id);
if(enrolls.size() > 0) {
jdbcTemplate.batchSave(enrolls);
}
}
@Override
public void saveUploadId(Long member_film_id, String upload_id) {
jdbcTemplate.executeUpdate("update fc_member_film set upload_id = ?, upload_time = ? where id = ?", upload_id, new Date(), member_film_id);
}
@Override
public void saveUploadState(Long member_film_id, Integer upload_state) {
jdbcTemplate.executeUpdate("update fc_member_film set upload_state = ? where id = ?", upload_state, member_film_id);
}
@Override
public List<Fc_member_film_enroll> queryFilmEnrollList(Long member_film_id) {
return jdbcTemplate.queryForBeans("select * from fc_member_film_enroll where film_id = ?", Fc_member_film_enroll.class, member_film_id.intValue());
}
@Override
public void verifyFilmDuplicate(Long filmId) {
String sql0 = ""
+ "select "
+ "f.* "
+ "from "
+ "fc_member_film f, "
+ "fc_member_film f2 "
+ "where "
+ "f.apply_state = 2 "
+ "and (f.en_name = f2.en_name or (f.en_name is null and f2.en_name is null)) "
+ "and (f.cn_name = f2.cn_name or (f.cn_name is null and f2.cn_name is null)) "
+ "and f2.id = ? "
+ "and f.id != ?";
List<Fc_member_film> list = jdbcTemplate.queryForBeans(sql0, Fc_member_film.class, filmId, filmId);
String sql = "select playactor_name from fc_member_film_playactor where playactor_type = 'director' and film_id = ?";
List<String> directorList = jdbcTemplate.queryForObjects(sql, String.class, filmId);
for(Fc_member_film film : list) {
List<String> directorListTmp = jdbcTemplate.queryForObjects(sql, String.class, film.getId());
if(directorList.size() == directorListTmp.size()) {
directorList.removeAll(directorListTmp);
if(directorList.size() == 0) {
Long passtime = film.getPass_time();
if(passtime == null) {
passtime = film.getLast_modify_time();
}
String no = StringUtil.formatLength(film.getFilm_no(), "0000");
String str = "通过";
if(film.getApply_state().intValue() == 3) {
str = "否决";
}
int state = film.getApply_state().intValue();
throw new XRException("该片名已经在" + DateUtil.format(new Date(passtime*1000), "yyyy年MM月dd日HH") + "时被管理员" + str + (state == 2 ? ",通过的影片ID号为" + no : ""));
}
}
}
}
@Override
public void updateFilmState(Long member_film_id, Integer state) {
jdbcTemplate.executeUpdate("update fc_member_film set state = ? where id = ?", state, member_film_id);
}
@Override
public void saveCreateBase(Long id, Integer admin_id, Integer member_id, String create_ip) {
Long now = System.currentTimeMillis()/1000;
jdbcTemplate.executeUpdate("update fc_member_film set admin_creator = ?, member_id = ?, create_ip = ?, create_time = ?, last_modify_time = ? where id = ?", admin_id, member_id, create_ip, now, now, id);
}
@Override
@Transactional
public void exchangeFilmNo(Integer id1, Integer id2) {
Fc_member_film f1 = jdbcTemplate.queryForBean("select id, film_no from fc_member_film where id = ?", Fc_member_film.class, id1);
Fc_member_film f2 = jdbcTemplate.queryForBean("select id, film_no from fc_member_film where id = ?", Fc_member_film.class, id2);
jdbcTemplate.batchUpdate("update fc_member_film set film_no = ? where id = ?", new Object[][]{ {f1.getFilm_no(), id2}, {f2.getFilm_no(), id1}});
jdbcTemplate.batchUpdate("update fc_member_film set state = 2, apply_state = ? where id = ?", new Object[][] {{1, id1}, {3, id2}});
jdbcTemplate.batchUpdate("delete from fc_review_record_ext where record_id in (select id from fc_review_record where review_id in (select id from fc_review where film_id = ?))", new Object[][]{{id1}, {id2}});
jdbcTemplate.batchUpdate("delete from fc_review_record where review_id in (select id from fc_review where film_id = ?)", new Object[][]{{id1}, {id2}});
jdbcTemplate.batchUpdate("delete from fc_review_history where review_id in (select id from fc_review where film_id = ?)", new Object[][]{{id1}, {id2}});
jdbcTemplate.batchUpdate("delete from fc_review where id = ?", new Object[][]{{id1}, {id2}});
}
@Override
public void initKeywords(Long member_film_id) {
Fc_member_film film = this.queryMemberFilmById(member_film_id);
List<Fc_member_film_playactor> playactors = this.queryMemberFilmPlayactorList(member_film_id);
List<String> strs = new ArrayList<String>();
for(Fc_member_film_playactor playactor : playactors) {
if(playactor.getPlayactor_type() != null && playactor.getPlayactor_type().equals("director")) {
strs.add(playactor.getPlayactor_name());
}
}
String directors = StringUtil.join(", ", strs);
if(film.getFilm_no() != null) {
strs.add(StringUtil.formatLength(film.getFilm_no(), "0000"));
}
if(StringUtil.isNotBlank(film.getEn_name())) {
strs.add(film.getEn_name());
}
if(StringUtil.isNotBlank(film.getCn_name())) {
strs.add(film.getCn_name());
}
String keywords = StringUtil.join(", ", strs);
jdbcTemplate.executeUpdate("update fc_member_film set director_name = ?, keywords = ? where id = ?", directors, keywords, member_film_id);
}
}
package com.egolm.film.api.service.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
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.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.Messages;
import com.egolm.film.bean.Enum_enroll;
import com.egolm.film.bean.Enum_filmtype;
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_issuer;
import com.egolm.film.bean.Fc_member_film_playactor;
import com.egolm.film.bean.Fc_member_film_show;
import com.egolm.film.bean.model.Fc_member_film_base_model;
import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XException;
import com.egolm.film.config.XRException;
import com.egolm.film.util.SqlWhere;
@Service
public class FilmServiceImpl implements FilmService {
@Autowired
private Messages messages;
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public List<Fc_member_film_issuer> queryMemberFilmIssuerList(Long member_film_id) {
return jdbcTemplate.queryForBeans("select * from fc_member_film_issuer where film_id = ?", Fc_member_film_issuer.class, member_film_id);
}
@Override
public List<Fc_member_film_playactor> queryMemberFilmPlayactorList(Long member_film_id) {
return jdbcTemplate.queryForBeans("select * from fc_member_film_playactor where film_id = ?", Fc_member_film_playactor.class, member_film_id);
}
@Override
public List<Fc_member_film_show> queryMemberFilmShowList(Long member_film_id) {
return jdbcTemplate.queryForBeans("select * from fc_member_film_show where film_id = ?", Fc_member_film_show.class, member_film_id);
}
@Override
public void doApply(Integer member_id, Long member_film_id) {
int count = jdbcTemplate.executeUpdate("update fc_member_film set state = 2, apply_state = 1 where id = ? and member_id = ? and state = 1", member_film_id, member_id);
if(count == 0) {
throw new XRException("该片当前状态不能提交申报");
}
}
@Override
@Transactional
public Long saveMemberFilmType(
Integer member_id,
String film_type_name,
String enroll_type_name) {
Integer film_group_id = 0;
Integer state = 1;
Integer is_show = 1;
Integer apply_state = 1;
Integer is_check_director = 0;
Long create_time = System.currentTimeMillis()/1000;
Long last_modify_time = create_time;
String create_ip = ServletUtil.remoteIp(WebMvcConfig.getRequest());
String sql = ""
+ "insert into fc_member_film "
+ "("
+ "member_id, "
+ "film_type_name, "
+ "enroll_type_name, "
+ "film_group_id, "
+ "state, "
+ "is_show, "
+ "apply_state, "
+ "is_check_director, "
+ "create_time, "
+ "create_ip, "
+ "last_modify_time"
+ ") "
+ "values "
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
Object[] args = new Object[]{
member_id,
film_type_name,
enroll_type_name,
film_group_id,
state,
is_show,
apply_state,
is_check_director,
create_time,
create_ip,
last_modify_time};
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
for(int i = 0; i <args.length; i++) {
Object argObj = args[i];
if(argObj instanceof java.util.Date) {
java.util.Date argDate = (java.util.Date)argObj;
ps.setObject(i+1, new java.sql.Timestamp(argDate.getTime()));
} else if(argObj.getClass().isEnum()) {
ps.setObject(i+1, args[i].toString());
} else {
ps.setObject(i+1, args[i]);
}
}
return ps;
}
}, keyHolder);
Long film_id = keyHolder.getKey().longValue();
this.updateEnroll(film_id);
return keyHolder.getKey().longValue();
}
@Override
@Transactional
public void saveMemberFilmBase(
Integer member_id,
Long member_film_id,
String[] enroll_type_name_other,
String cn_name,
String en_name,
String intro) {
Long last_modify_time = System.currentTimeMillis()/1000;
String sql = "update fc_member_film set enroll_type_name_other = ?, cn_name = ?, en_name = ?, intro = ?, last_modify_time = ? where member_id = ? and id = ?";
String string = StringUtil.join(",", "", "", "", enroll_type_name_other);
Object[] args = new Object[]{string, cn_name, en_name, intro, last_modify_time, member_id, member_film_id};
this.updateEnroll(member_film_id);
jdbcTemplate.executeUpdate(sql, args);
}
@Override
public void saveMemberFilmInfo(
Integer member_id,
Long member_film_id,
String film_country,
String dialogue_lang,
String subtitle_lang,
String[] co_production_country,
String film_total_time,
String completion_date,
String show_date,
String first_show_date,
String first_show_city,
Integer is_apply_other_filmfest,
String other_filmfest_name,
String film_medium,
String film_format,
String film_format_url,
String film_format_passw,
String film_format_other) {
Long last_modify_time = System.currentTimeMillis()/1000;
String sql = ""
+ "update "
+ "fc_member_film "
+ "set "
+ "film_country = ?, "
+ "dialogue_lang = ?, "
+ "subtitle_lang = ?, "
+ "co_production_country = ?, "
+ "film_total_time = ?, "
+ "completion_date = ?, "
+ "show_date = ?, "
+ "first_show_date = ?, "
+ "first_show_city = ?, "
+ "is_apply_other_filmfest = ?, "
+ "other_filmfest_name = ?, "
+ "film_medium = ?, "
+ "film_format = ?, "
+ "film_format_url = ?, "
+ "film_format_passw = ?, "
+ "film_format_other = ?, "
+ "last_modify_time = ? "
+ "where "
+ "member_id = ? "
+ "and id = ?";
String str = StringUtil.join(",", "", "", "", co_production_country);
Object[] args = new Object[]{
film_country,
dialogue_lang,
subtitle_lang,
str,
film_total_time,
completion_date,
show_date,
first_show_date,
first_show_city,
is_apply_other_filmfest,
other_filmfest_name,
film_medium,
film_format,
film_format_url,
film_format_passw,
film_format_other,
last_modify_time,
member_id,
member_film_id};
jdbcTemplate.executeUpdate(sql, args);
}
@Override
@Transactional
public void saveMemberFilmPlayactor(
Long member_film_id,
String[] playactor_type,
String[] playactor_role_name,
String[] playactor_name,
String[] playactor_film_nums,
String[] playactor_country,
String[] playactor_birthday,
String[] playactor_intro,
Integer[] is_play_shanghai) {
Long create_time = System.currentTimeMillis()/1000;
List<Object[]> playactors = new ArrayList<Object[]>();
for(int i = 0; i < playactor_type.length; i++) {
playactors.add(new Object[]{
member_film_id,
playactor_name[i],
playactor_film_nums[i],
playactor_intro[i],
playactor_country[i],
playactor_birthday[i],
create_time,
playactor_type[i],
playactor_role_name[i]});
}
jdbcTemplate.executeUpdate("delete from fc_member_film_playactor where film_id = ?", member_film_id);
String sql_playactor = ""
+ "insert into fc_member_film_playactor("
+ "film_id, "
+ "playactor_name, "
+ "playactor_film_nums, "
+ "playactor_film_intro, "
+ "playactor_country, "
+ "playactor_birthday, "
+ "create_time, "
+ "playactor_type, "
+ "playactor_role_name)"
+ "values "
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?)";
jdbcTemplate.batchUpdate(sql_playactor, playactors);
}
@Override
@Transactional
public void saveMemberFilmIssuer(
Long member_film_id,
String[] issuer_company,
String[] issuer_contacts,
String[] issuer_email,
String[] issuer_tel) {
if(issuer_company.length == issuer_contacts.length &&
issuer_contacts.length == issuer_email.length &&
issuer_email.length == issuer_tel.length) {
Long create_time = System.currentTimeMillis()/1000;
Object[][] args = new Object[issuer_company.length][];
for(int i = 0; i < issuer_company.length; i++) {
args[i] = new Object[]{member_film_id, issuer_company[i], issuer_contacts[i], issuer_email[i], issuer_tel[i], create_time};
}
jdbcTemplate.executeUpdate("delete from fc_member_film_issuer where film_id = ?", member_film_id);
String sql = ""
+ "insert into fc_member_film_issuer ("
+ "film_id, "
+ "issuer_company, "
+ "issuer_contacts, "
+ "issuer_email, "
+ "issuer_tel, "
+ "create_time) "
+ "values "
+ "(?, ?, ?, ?, ?, ?);";
jdbcTemplate.batchUpdate(sql, args);
} else {
throw new XException(messages.get("err.args_nums"));
}
}
@Override
@Transactional
public void saveMemberFilmShow(
Long member_film_id,
String play_shanghai,
String[] show_filmfest,
String[] show_filmfest_type,
String[] show_filmfest_intro) {
if(show_filmfest.length == show_filmfest_type.length && show_filmfest_type.length == show_filmfest_intro.length) {
Long create_time = System.currentTimeMillis()/1000;
Object[][] args = new Object[show_filmfest.length][];
for(int i = 0; i < show_filmfest.length; i++) {
args[i] = new Object[]{member_film_id, show_filmfest[i], show_filmfest_type[i], show_filmfest_intro[i], create_time};
}
Long last_modify_time = System.currentTimeMillis()/1000;
jdbcTemplate.executeUpdate("update fc_member_film set play_shanghai = ?, last_modify_time = ? where id = ?", play_shanghai, last_modify_time, member_film_id);
jdbcTemplate.executeUpdate("delete from fc_member_film_show where film_id = ?", member_film_id);
String sql = "insert into fc_member_film_show (film_id, show_filmfest, show_filmfest_type, show_filmfest_intro, create_time) values (?, ?, ?, ?, ?);";
jdbcTemplate.batchUpdate(sql, args);
} else {
throw new XException(messages.get("err.args_nums"));
}
}
@Override
public void saveMemberFilmCompany(
Integer member_id,
Long member_film_id,
String film_apply_company,
String film_apply_realname,
String film_apply_email,
String film_apply_tel,
String film_apply_mobile,
String film_apply_country) {
Long last_modify_time = System.currentTimeMillis()/1000;
String sql = ""
+ "update "
+ "fc_member_film "
+ "set "
+ "film_apply_company = ?, "
+ "film_apply_realname = ?, "
+ "film_apply_email = ?, "
+ "film_apply_tel = ?, "
+ "film_apply_mobile = ?, "
+ "film_apply_country = ?,"
+ "last_modify_time = ? "
+ "where "
+ "member_id = ? "
+ "and id = ?";
Object[] args = new Object[]{
film_apply_company,
film_apply_realname,
film_apply_email,
film_apply_tel,
film_apply_mobile,
film_apply_country,
last_modify_time,
member_id,
member_film_id};
jdbcTemplate.executeUpdate(sql, args);
}
@Override
public Fc_member_film queryMemberFilmById(Long id) {
return jdbcTemplate.queryForBean("select * from fc_member_film where id = ?", Fc_member_film.class, id);
}
@Override
public List<Map<String, Object>> queryListAll(String keyword) {
if(StringUtil.isBlank(keyword)) {
String sql = "select * from fc_member_film";
return jdbcTemplate.queryForList(sql);
} else {
String sql = "select * from fc_member_film where en_name like ? or cn_name like ?";
return jdbcTemplate.queryForList(sql, "%" + keyword + "%", "%" + keyword + "%");
}
}
@Override
public List<Map<String, Object>> queryFilmList(
Integer admin_group_id,
String keyword,
Integer state,
Integer apply_state,
Integer upload_state,
Integer film_type,
Integer enroll_type_id,
String film_country,
Integer film_type_short,
String play_shanghai,
Integer review_round,
Integer review_state,
Integer allot_atate,
Integer opt_state,
Integer[] film_type_id,
Page page) {
SqlWhere where = new SqlWhere()
.where("mf.film_type_name = agf.film_type_id and agf.group_id = ?", admin_group_id)
.eq("mf.state", state)
.eq("mf.apply_state", apply_state)
.eq("mf.upload_state", upload_state)
.eq("mf.film_type_name", film_type)
.eq("mf.film_type_name_short", film_type_short)
.eq("mf.film_country", film_country)
.eq("mf.play_shanghai", play_shanghai)
.in("mf.film_type_id", film_type_id)
.lk("mf.keywords", keyword)
;
String sql_film = "fc_member_film";
if(StringUtil.isNotBlank(enroll_type_id)) {
sql_film = "(select mf0.* from fc_member_film mf0, fc_member_film_enroll mfe where mf0.id = mfe.film_id and mfe.enroll_type_id = " + enroll_type_id + ")";
}
String sql = ""
+ "select "
+ "mf.*, "
+ "fg.group_name, "
+ "r.review_round, "
+ "r.review_state, "
+ "r.allot_state, "
+ "r.opt_state, "
+ "m.username member_name, "
+ "a.realname admin_name "
+ "from " + sql_film + " mf "
+ "left join fc_review r on r.film_id = mf.id "
+ "left join fc_film_group fg on fg.id = mf.film_group_id "
+ "left join fc_member m on m.id = mf.member_id "
+ "left join fc_admin a on a.adminid = mf.admin_creator"
+ ", fc_admin_group_filmtype agf"
+ StringUtil.join(" and ", " where ", " ", " ", where.getStringList());
List<Object> objs = new ArrayList<Object>();
objs.addAll(where.getObjectList());
SqlWhere where2 = new SqlWhere()
.eq("t.review_round", review_round)
.eq("t.review_state", review_state)
.eq("t.allot_atate", allot_atate)
.eq("t.opt_state", opt_state)
;
sql = "select t.* from (" + sql + ") t" + StringUtil.join(" and ", " where ", " ", " ", where2.getStringList()) + " order by t.id desc";
objs.addAll(where2.getObjectList());
return jdbcTemplate.limit(sql, page, objs.toArray());
}
@Override
public synchronized Integer pass(Long member_film_id) {
this.updateEnroll(member_film_id);
Integer film_no = jdbcTemplate.queryForInt("select ifnull(max(film_no), 0) + 1 from fc_member_film");
String sql = "update fc_member_film set film_no = ?, apply_state = 2, upload_state = 0, pass_time = ? where id = ? and (film_no is null or film_no = '')";
jdbcTemplate.executeUpdate(sql, film_no, System.currentTimeMillis()/1000L, member_film_id);
return film_no;
}
@Override
public void reject(Boolean is_stop_apply, Long member_film_id, String apply_state_intro) {
if(is_stop_apply) {
String sql = "update fc_member_film set pass_time = ?, apply_state = 3, apply_state_intro = ? where id = ?";
jdbcTemplate.executeUpdate(sql, System.currentTimeMillis()/1000L, apply_state_intro, member_film_id);
} else {
String sql = "update fc_member_film set pass_time = ?, apply_state = 1, apply_state_intro = ?, state = 1 where id = ?";
jdbcTemplate.executeUpdate(sql, System.currentTimeMillis()/1000L, apply_state_intro, member_film_id);
}
}
@Override
public List<Enum_enroll> queryEnrollList() {
return jdbcTemplate.queryForBeansByField(Enum_enroll.class, new HashMap<String,Object>());
}
@Override
public List<Enum_filmtype> queryTypeList() {
return jdbcTemplate.queryForBeansByField(Enum_filmtype.class, new HashMap<String,Object>());
}
@Override
public void mergeMemberFilm(Fc_member_film film) {
jdbcTemplate.merge(film);
}
@Override
@Transactional
public void updateFilmBase(Fc_member_film_base_model filmBase) {
jdbcTemplate.saveOrUpdate(filmBase);
this.updateEnroll(filmBase.getId());
}
@Override
@Transactional
public void updateEnroll(Long member_film_id) {
Fc_member_film film = jdbcTemplate.queryForBean("select enroll_type_name, enroll_type_name_other from fc_member_film where id = ?", Fc_member_film.class, member_film_id);
String enroll_type_name = film.getEnroll_type_name();
List<Fc_member_film_enroll> enrolls = new ArrayList<Fc_member_film_enroll>();
if(enroll_type_name != null) {
String[] strs = enroll_type_name.split(",");
if(strs != null && strs.length > 0) {
for(String str : strs) {
if(str != null && str.matches("\\d+")) {
Fc_member_film_enroll enroll = new Fc_member_film_enroll();
enroll.setEnroll_type_id(Integer.valueOf(str));
enroll.setFilm_id(member_film_id.intValue());
enrolls.add(enroll);
}
}
}
}
jdbcTemplate.executeUpdate("delete from fc_member_film_enroll where film_id = ?", member_film_id);
if(enrolls.size() > 0) {
jdbcTemplate.batchSave(enrolls);
}
}
@Override
public void saveUploadId(Long member_film_id, String upload_id) {
jdbcTemplate.executeUpdate("update fc_member_film set upload_id = ?, upload_time = ? where id = ?", upload_id, new Date(), member_film_id);
}
@Override
public void saveUploadState(Long member_film_id, Integer upload_state) {
jdbcTemplate.executeUpdate("update fc_member_film set upload_state = ? where id = ?", upload_state, member_film_id);
}
@Override
public List<Fc_member_film_enroll> queryFilmEnrollList(Long member_film_id) {
return jdbcTemplate.queryForBeans("select * from fc_member_film_enroll where film_id = ?", Fc_member_film_enroll.class, member_film_id.intValue());
}
@Override
public void verifyFilmDuplicate(Long filmId) {
String sql0 = ""
+ "select "
+ "f.* "
+ "from "
+ "fc_member_film f, "
+ "fc_member_film f2 "
+ "where "
+ "f.apply_state = 2 "
+ "and (f.en_name = f2.en_name or (f.en_name is null and f2.en_name is null)) "
+ "and (f.cn_name = f2.cn_name or (f.cn_name is null and f2.cn_name is null)) "
+ "and f2.id = ? "
+ "and f.id != ?";
List<Fc_member_film> list = jdbcTemplate.queryForBeans(sql0, Fc_member_film.class, filmId, filmId);
String sql = "select playactor_name from fc_member_film_playactor where playactor_type = 'director' and film_id = ?";
List<String> directorList = jdbcTemplate.queryForObjects(sql, String.class, filmId);
for(Fc_member_film film : list) {
List<String> directorListTmp = jdbcTemplate.queryForObjects(sql, String.class, film.getId());
if(directorList.size() == directorListTmp.size()) {
directorList.removeAll(directorListTmp);
if(directorList.size() == 0) {
Long passtime = film.getPass_time();
if(passtime == null) {
passtime = film.getLast_modify_time();
}
String no = StringUtil.formatLength(film.getFilm_no(), "0000");
String str = "通过";
if(film.getApply_state().intValue() == 3) {
str = "否决";
}
int state = film.getApply_state().intValue();
throw new XRException("该片名已经在" + DateUtil.format(new Date(passtime*1000), "yyyy年MM月dd日HH") + "时被管理员" + str + (state == 2 ? ",通过的影片ID号为" + no : ""));
}
}
}
}
@Override
public void updateFilmState(Long member_film_id, Integer state) {
jdbcTemplate.executeUpdate("update fc_member_film set state = ? where id = ?", state, member_film_id);
}
@Override
public void saveCreateBase(Long id, Integer admin_id, Integer member_id, String create_ip) {
Long now = System.currentTimeMillis()/1000;
jdbcTemplate.executeUpdate("update fc_member_film set admin_creator = ?, member_id = ?, create_ip = ?, create_time = ?, last_modify_time = ? where id = ?", admin_id, member_id, create_ip, now, now, id);
}
@Override
@Transactional
public void exchangeFilmNo(Integer id1, Integer id2) {
Fc_member_film f1 = jdbcTemplate.queryForBean("select id, film_no from fc_member_film where id = ?", Fc_member_film.class, id1);
Fc_member_film f2 = jdbcTemplate.queryForBean("select id, film_no from fc_member_film where id = ?", Fc_member_film.class, id2);
jdbcTemplate.batchUpdate("update fc_member_film set film_no = ? where id = ?", new Object[][]{ {f1.getFilm_no(), id2}, {f2.getFilm_no(), id1}});
jdbcTemplate.batchUpdate("update fc_member_film set state = 2, apply_state = ? where id = ?", new Object[][] {{1, id1}, {3, id2}});
jdbcTemplate.batchUpdate("delete from fc_review_record_ext where record_id in (select id from fc_review_record where review_id in (select id from fc_review where film_id = ?))", new Object[][]{{id1}, {id2}});
jdbcTemplate.batchUpdate("delete from fc_review_record where review_id in (select id from fc_review where film_id = ?)", new Object[][]{{id1}, {id2}});
jdbcTemplate.batchUpdate("delete from fc_review_history where review_id in (select id from fc_review where film_id = ?)", new Object[][]{{id1}, {id2}});
jdbcTemplate.batchUpdate("delete from fc_review where id = ?", new Object[][]{{id1}, {id2}});
}
@Override
public void initKeywords(Long member_film_id) {
Fc_member_film film = this.queryMemberFilmById(member_film_id);
List<Fc_member_film_playactor> playactors = this.queryMemberFilmPlayactorList(member_film_id);
List<String> strs = new ArrayList<String>();
for(Fc_member_film_playactor playactor : playactors) {
if(playactor.getPlayactor_type() != null && playactor.getPlayactor_type().equals("director")) {
strs.add(playactor.getPlayactor_name());
}
}
String directors = StringUtil.join(", ", strs);
if(film.getFilm_no() != null) {
strs.add(StringUtil.formatLength(film.getFilm_no(), "0000"));
}
if(StringUtil.isNotBlank(film.getEn_name())) {
strs.add(film.getEn_name());
}
if(StringUtil.isNotBlank(film.getCn_name())) {
strs.add(film.getCn_name());
}
String keywords = StringUtil.join(", ", strs);
jdbcTemplate.executeUpdate("update fc_member_film set director_name = ?, keywords = ? where id = ?", directors, keywords, member_film_id);
}
@Override
public List<Map<String, Object>> queryMonitorUploadList(String keyword,Integer upload_state, Page page) {
SqlWhere w = new SqlWhere().lk(new String[]{"file_name", "film_id"}, keyword).eq("upload_state", upload_state);
String sql = "select * from fc_film_upload "+ StringUtil.join(" and ", " where ", "", "", w.getStringList());;
return jdbcTemplate.limit(sql, page, w.getObjectArray());
}
/**
* 批量修改上传状态 为 未上传
* @Title: updateFilmUploadState
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param film_id
* @param: @param number
* @return: void
* @throws
*/
@Override
public void updateFilmUploadState(String[] film_id,String[] number) {
if(film_id.length == number.length) {
List<Object[]> objs = new ArrayList<Object[]>();
for(int i = 0; i < film_id.length; i++) {
objs.add(new Object[]{
film_id[i],
number[i]});
}
String sql = "update fc_film_upload set upload_state = 0 ,upload__error_message= '',upload_progress='0%' where film_id = ? and number = ? ";
jdbcTemplate.batchUpdate(sql, objs);
}
}
}
......@@ -203,6 +203,23 @@ public class AdminFirstController {
public Object save_upload_state(Long member_film_id, Integer upload_state) {
filmService.saveUploadState(member_film_id, upload_state);
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("upload_monitor")
@ApiOperation("影片上传监控列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", dataType="String", required=false, name="keyword", value="关键字"),
@ApiImplicitParam(paramType="query", dataType="int", required=false, name="upload_state", value="上传状态( 0未上传, 1上传中, 2已上传)"),
@ApiImplicitParam(paramType="query", dataType="long", required=true, name="index", value="分页编号"),
@ApiImplicitParam(paramType="query", dataType="long", required=true, name="limit", value="分页大小"),
})
public Object upload_monitor(String keyword,Integer upload_state,Long index, Long limit) {
index = index == null ? 1 : index;
limit = limit == null ? 20 : limit;
Page page = new Page(index, limit);
List<Map<String, Object>> list = filmService.queryMonitorUploadList(keyword,upload_state,page);
return Rjx.jsonOk().setData(list).setPage(page);
}
@ResponseBody
......@@ -261,4 +278,4 @@ public class AdminFirstController {
exportService.exportApplyPassList(response.getOutputStream(), columns);
}
}
}
\ No newline at end of file
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