You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.6 KiB

3 years ago
package com.dsideal.FengHuang.TouPiao.Model;
3 years ago
import com.jfinal.kit.Kv;
3 years ago
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
3 years ago
import com.jfinal.plugin.activerecord.SqlPara;
3 years ago
3 years ago
import java.util.ArrayList;
import java.util.HashMap;
3 years ago
import java.util.List;
3 years ago
import java.util.Map;
3 years ago
@SuppressWarnings("unchecked")
public class TouPiaoModel {
public List<Record> getHouXuanRenList(int type_id) {
3 years ago
String sql = "select * from t_toupiao_houxuanren where houxuanren_type_id=? order by sort_id";
3 years ago
return Db.find(sql, type_id);
}
3 years ago
3 years ago
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) {
3 years ago
String sql = "select * from t_toupiao_toupiaoren where toupiaoren_tel=?";
3 years ago
return Db.findFirst(sql, toupiaoren_tel);
}
3 years ago
public boolean haveFinishTouPiao(String toupiaoren_tel) {
String sql = "select count(1) as c from t_toupiao_result where toupiaoren_tel=?";
3 years ago
int cnt=Db.findFirst(sql, toupiaoren_tel).getInt("c");
return cnt > 0;
3 years ago
}
3 years ago
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);
3 years ago
record.set("toupiaoren_tel", toupiaoren_tel);
3 years ago
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);
3 years ago
record.set("toupiaoren_tel", toupiaoren_tel);
3 years ago
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);
3 years ago
}
3 years ago
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");
}
3 years ago
3 years ago
public List<Record> getYingTouPiaoRenSummary() {
3 years ago
String sql = "select toupiaoren_type_id,count(1) as c from t_toupiao_toupiaoren group by toupiaoren_type_id";
return Db.find(sql);
}
3 years ago
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;
}
3 years ago
/*
25251015
= 1.0 * / *10
= 1.0 * / *15
30
7
5232.
*/
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;
}
3 years ago
}