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.

66 lines
2.5 KiB

3 years ago
package com.dsideal.FengHuang.TouPiao.Model;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
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=?";
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);
}
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);
3 years ago
}
3 years ago
}