kgdxpr 3 years ago
commit d33534a535

@ -112,7 +112,7 @@
async: false,
success: function (result) {
if (result.success) {
window.location.href = '/FengHuang/html/xxxx.html';
window.location.href = '/FengHuang/html/tp/index.html';
} else {
alert(result.msg);
refreshCaptcha();

@ -10,6 +10,7 @@ import com.dsideal.FengHuang.Swagger.annotation.Api;
import com.dsideal.FengHuang.Swagger.annotation.Param;
import com.dsideal.FengHuang.Swagger.annotation.Params;
import com.dsideal.FengHuang.Base.Model.BaseModel;
import com.dsideal.FengHuang.TouPiao.Model.TouPiaoModel;
import com.dsideal.FengHuang.Util.*;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
@ -22,6 +23,7 @@ import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.redis.Redis;
import org.apache.poi.ss.formula.functions.T;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@ -136,7 +138,7 @@ public class LoginPersonController extends Controller {
return;
}
if (!password.equals(username.substring(username.length()-6))) {
if (!password.equals(username.substring(username.length() - 6))) {
//扩展支持连续输入用户名密码错误停用账号5分钟功能 2022.06.07
cntNum = 1;
if (Redis.use().exists(PassWordKey))
@ -160,6 +162,15 @@ public class LoginPersonController extends Controller {
renderJson(resultJson);
return;
}
//检查是不是已经投票过了?
TouPiaoModel tm = new TouPiaoModel();
if (tm.haveFinishTouPiao(username)) {
resultJson.put("success", false);
resultJson.put("msg", "您已经投票完成,不能再次进入系统!");
renderJson(resultJson);
return;
}
//去掉限制
Redis.use().del(PassWordKey);
Redis.use().del(checkCodeKey);

@ -7,8 +7,10 @@ import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
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.List;
@ -40,7 +42,58 @@ public class TouPiaoController extends Controller {
@IsLoginInterface({})
public void getTouPiaoRenInfo() {
String toupiaoren_tel = getCookie("toupiaoren_tel");
List<Record> list = tm.getTouPiaoRenInfo(toupiaoren_tel);
Record record = tm.getTouPiaoRenInfo(toupiaoren_tel);
renderJson(record);
}
@Before({POST.class})
@IsLoginInterface({})
public void save(String gaoji, String zhongji) {
String toupiaoren_tel = getCookie("toupiaoren_tel");
//检查中级是不是2个高级是不是3个
String[] gaojiArray = gaoji.split(",");
String[] zhongjiArray = zhongji.split(",");
if (gaojiArray.length != 3) {
Kv kv = Kv.create();
kv.set("success", false);
kv.set("message", "本次投票高级只能投3人!");
renderJson(kv);
return;
}
if (zhongjiArray.length != 2) {
Kv kv = Kv.create();
kv.set("success", false);
kv.set("message", "本次投票中级只能投2人!");
renderJson(kv);
return;
}
tm.save(toupiaoren_tel, gaojiArray, zhongjiArray);
Kv kv = Kv.create();
kv.set("success", true);
kv.set("message", "投票成功 !");
renderJson(kv);
}
/*
http://10.10.11.124:9000/FengHuang/TouPiao/TongJi?houxuanren_type_id=1
*/
public void TongJi(int houxuanren_type_id) {
/*
25251015
= 1.0 * / *10
= 1.0 * / *15
30
7
5232.
*/
int PingWeiHuiAllCount = tm.getTouPiaoRenSummary(1);
int QunZhongAllCount = tm.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);
renderJson(CommonUtil.renderJsonForLayUI(list));
}
}

@ -1,18 +1,12 @@
package com.dsideal.FengHuang.TouPiao.Model;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.dsideal.FengHuang.Util.IpUtil;
import com.dsideal.FengHuang.Util.MysqlAesUtil;
import com.dsideal.FengHuang.Util.PkUtil;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
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.UUID;
import java.util.Map;
@SuppressWarnings("unchecked")
public class TouPiaoModel {
@ -22,8 +16,61 @@ public class TouPiaoModel {
return Db.find(sql, type_id);
}
public List<Record> getTouPiaoRenInfo(String toupiaoren_tel) {
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.find(sql, 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=?";
return Db.findFirst(sql, toupiaoren_tel).getInt("c") > 0;
}
public void save(String toupiaoren_tel, String[] gaojiArray, String[] zhongjiArray) {
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", s);
record.set("toupiaoren_name", _map.get(s).getStr("toupiaoren_name"));
record.set("toupiaoren_type_id", toupiaoren_type_id);
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", s);
record.set("toupiaoren_name", _map.get(s).getStr("toupiaoren_name"));
record.set("toupiaoren_type_id", toupiaoren_type_id);
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");
}
}

@ -0,0 +1,11 @@
#namespace("TouPiao")
#sql("TongJi")
select *,format(1.0 * ta.pingweihui_count /#(PingWeiHuiAllCount) *10 + 1.0*ta.qunzhong_count/#(QunZhongAllCount) *15,1) as score
from (select t1.houxuanren_tel,t1.houxuanren_name,t1.houxuanren_type_id,
(select count(1) from t_toupiao_result as t2 where t2.toupiaoren_type_id=1 and t1.houxuanren_tel=t2.toupiaoren_tel) as pingweihui_count,
(select count(1) from t_toupiao_result as t2 where t2.toupiaoren_type_id=2 and t1.houxuanren_tel=t2.toupiaoren_tel) as qunzhong_count
from t_toupiao_houxuanren as t1) as ta where ta.houxuanren_type_id=#(houxuanren_type_id)
order by 1.0 * ta.pingweihui_count /#(PingWeiHuiAllCount) *10 + 1.0*ta.qunzhong_count/#(QunZhongAllCount) *15 desc
#end
#end

@ -0,0 +1,11 @@
#namespace("TouPiao")
#sql("TongJi")
select *,format(1.0 * ta.pingweihui_count /#(PingWeiHuiAllCount) *10 + 1.0*ta.qunzhong_count/#(QunZhongAllCount) *15,1) as score
from (select t1.houxuanren_tel,t1.houxuanren_name,t1.houxuanren_type_id,
(select count(1) from t_toupiao_result as t2 where t2.toupiaoren_type_id=1 and t1.houxuanren_tel=t2.toupiaoren_tel) as pingweihui_count,
(select count(1) from t_toupiao_result as t2 where t2.toupiaoren_type_id=2 and t1.houxuanren_tel=t2.toupiaoren_tel) as qunzhong_count
from t_toupiao_houxuanren as t1) as ta where ta.houxuanren_type_id=#(houxuanren_type_id)
order by 1.0 * ta.pingweihui_count /#(PingWeiHuiAllCount) *10 + 1.0*ta.qunzhong_count/#(QunZhongAllCount) *15 desc
#end
#end
Loading…
Cancel
Save