|
|
package com.dsideal.FengHuang.TouPiao.Model;
|
|
|
|
|
|
import com.jfinal.kit.Kv;
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
import com.jfinal.plugin.activerecord.SqlPara;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public class TouPiaoModel {
|
|
|
|
|
|
public List<Record> getHouXuanRenList(int type_id) {
|
|
|
String sql = "select * from t_toupiao_houxuanren where houxuanren_type_id=? order by sort_id";
|
|
|
return Db.find(sql, type_id);
|
|
|
}
|
|
|
|
|
|
public Map<String, Record> getTouPiaoRenInfoMap() {
|
|
|
String sql = "select * from t_toupiao_toupiaoren";
|
|
|
List<Record> list = Db.find(sql);
|
|
|
Map<String, Record> _map = new HashMap<>();
|
|
|
for (Record record : list)
|
|
|
_map.put(record.getStr("toupiaoren_tel"), record);
|
|
|
return _map;
|
|
|
}
|
|
|
|
|
|
public Record getTouPiaoRenInfo(String toupiaoren_tel) {
|
|
|
String sql = "select * from t_toupiao_toupiaoren where toupiaoren_tel=?";
|
|
|
return Db.findFirst(sql, toupiaoren_tel);
|
|
|
}
|
|
|
|
|
|
public boolean haveFinishTouPiao(String toupiaoren_tel) {
|
|
|
String sql = "select count(1) as c from t_toupiao_result where toupiaoren_tel=?";
|
|
|
int cnt = Db.findFirst(sql, toupiaoren_tel).getInt("c");
|
|
|
return cnt > 0;
|
|
|
}
|
|
|
|
|
|
public void save(String toupiaoren_tel, String[] gaojiArray, String[] zhongjiArray, String ip) {
|
|
|
Record r = getTouPiaoRenInfo(toupiaoren_tel);
|
|
|
int toupiaoren_type_id = r.getInt("toupiaoren_type_id");
|
|
|
String sql = "delete from t_toupiao_result where toupiaoren_tel=?";
|
|
|
Db.update(sql, toupiaoren_tel);
|
|
|
|
|
|
Map<String, Record> _map = getTouPiaoRenInfoMap();
|
|
|
List<Record> saveList = new ArrayList<>();
|
|
|
|
|
|
for (String s : gaojiArray) {
|
|
|
Record record = new Record();
|
|
|
record.set("houxuanren_tel", s);
|
|
|
record.set("houxuanren_name", _map.get(s).getStr("toupiaoren_name"));
|
|
|
record.set("houxuanren_type_id", 1);
|
|
|
|
|
|
record.set("toupiaoren_tel", toupiaoren_tel);
|
|
|
record.set("toupiaoren_name", _map.get(toupiaoren_tel).getStr("toupiaoren_name"));
|
|
|
record.set("toupiaoren_type_id", toupiaoren_type_id);
|
|
|
record.set("ip", ip);
|
|
|
saveList.add(record);
|
|
|
}
|
|
|
for (String s : zhongjiArray) {
|
|
|
Record record = new Record();
|
|
|
record.set("houxuanren_tel", s);
|
|
|
record.set("houxuanren_name", _map.get(s).getStr("toupiaoren_name"));
|
|
|
record.set("houxuanren_type_id", 2);
|
|
|
|
|
|
record.set("toupiaoren_tel", toupiaoren_tel);
|
|
|
record.set("toupiaoren_name", _map.get(toupiaoren_tel).getStr("toupiaoren_name"));
|
|
|
record.set("toupiaoren_type_id", toupiaoren_type_id);
|
|
|
record.set("ip", ip);
|
|
|
saveList.add(record);
|
|
|
}
|
|
|
Db.batchSave("t_toupiao_result", saveList, 100);
|
|
|
}
|
|
|
|
|
|
public int getTouPiaoRenSummary(int toupiaoren_type_id) {
|
|
|
String sql = "select count(1) as c from t_toupiao_toupiaoren where toupiaoren_type_id=?";
|
|
|
return Db.findFirst(sql, toupiaoren_type_id).getInt("c");
|
|
|
}
|
|
|
|
|
|
public List<Record> getYingTouPiaoRenSummary() {
|
|
|
String sql = "select toupiaoren_type_id,count(1) as c from t_toupiao_toupiaoren group by toupiaoren_type_id";
|
|
|
return Db.find(sql);
|
|
|
}
|
|
|
|
|
|
public List<Record> getYiTouPiaoRenSummary() {
|
|
|
String sql = "select ? as toupiaoren_type_id,count(distinct toupiaoren_tel) as c from t_toupiao_result where toupiaoren_type_id=?";
|
|
|
Record r1 = Db.findFirst(sql, 1, 1);
|
|
|
Record r2 = Db.findFirst(sql, 2, 2);
|
|
|
List<Record> res = new ArrayList<>();
|
|
|
res.add(r1);
|
|
|
res.add(r2);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
此程序占25分,这25分里面,有评委会的10分,有群众15分。
|
|
|
评委会得分= 1.0 * 评委会投票人数/评委会总人数 *10
|
|
|
群众得分= 1.0 * 群众投票人数/群从总人数 *15
|
|
|
投一票是一票,统计票数即可
|
|
|
群众可投票人数:30人
|
|
|
评审小组可投票人数:7人
|
|
|
投票规则:
|
|
|
高级是5选2,中级是3选2.
|
|
|
*/
|
|
|
public List<Record> TongJi(int houxuanren_type_id) {
|
|
|
int PingWeiHuiAllCount = getTouPiaoRenSummary(1);
|
|
|
int QunZhongAllCount = getTouPiaoRenSummary(2);
|
|
|
Kv kv = Kv.by("PingWeiHuiAllCount", PingWeiHuiAllCount).set("QunZhongAllCount", QunZhongAllCount).set("houxuanren_type_id", houxuanren_type_id);
|
|
|
SqlPara sq = Db.getSqlPara("TouPiao.TongJi", kv);
|
|
|
List<Record> list = Db.find(sq);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<Record> getTouPiaoInfo() {
|
|
|
SqlPara sq = Db.getSqlPara("TouPiao.getTouPiaoInfo");
|
|
|
List<Record> list = Db.find(sq);
|
|
|
return list;
|
|
|
}
|
|
|
} |