|
|
package com.dsideal.FengHuang.Zjb.Model;
|
|
|
|
|
|
import com.dsideal.FengHuang.LoginPerson.Model.LoginPersonModel;
|
|
|
import com.dsideal.FengHuang.Util.CommonUtil;
|
|
|
import com.dsideal.FengHuang.Util.IpUtil;
|
|
|
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.Map;
|
|
|
|
|
|
public class ZjbModel {
|
|
|
|
|
|
/*
|
|
|
功能:删除指定模板下的指定页码内容
|
|
|
*/
|
|
|
public void delModulePage(int module_id, int page) {
|
|
|
String sql = "delete from t_zjb_module_page where module_id=? and page=?";
|
|
|
Db.update(sql, module_id, page);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
功能:保存模块页面的内容
|
|
|
作者:黄海
|
|
|
时间:2022-12-26
|
|
|
*/
|
|
|
public void saveModulePage(int module_id, int page, String json) {
|
|
|
delModulePage(module_id, page);
|
|
|
Record record = new Record();
|
|
|
record.set("module_id", module_id);
|
|
|
record.set("page", page);
|
|
|
record.set("json", json);
|
|
|
Db.save("t_zjb_module_page", "module_id,page", record);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
功能:获取指定模板,指定页码的JSON内容
|
|
|
*/
|
|
|
public String getModulePage(int module_id, int page) {
|
|
|
String sql = "select json from t_zjb_module_page where module_id=? and page=?";
|
|
|
List<Record> list = Db.find(sql, module_id, page);
|
|
|
if (list.size() > 0) return list.get(0).getStr("json");
|
|
|
return "[]";
|
|
|
}
|
|
|
|
|
|
public Record getMoudleInfo(int module_id) {
|
|
|
String sql = "select * from t_zjb_module where module_id=?";
|
|
|
return Db.findFirst(sql, module_id);
|
|
|
}
|
|
|
|
|
|
public List<Record> getModulePageFillInfo(int module_id) {
|
|
|
String sql = "select * from t_zjb_module_page where module_id=?";
|
|
|
List<Record> exist = Db.find(sql, module_id);
|
|
|
Map<Integer, String> _map = new HashMap<>();
|
|
|
for (Record record : exist) {
|
|
|
_map.put(record.getInt("page"), record.getStr("json"));
|
|
|
}
|
|
|
Record record = getMoudleInfo(module_id);
|
|
|
int page_count = record.getInt("page_count");
|
|
|
List<Record> res = new ArrayList<>();
|
|
|
for (int i = 1; i <= page_count; i++) {
|
|
|
Record r = new Record();
|
|
|
r.set("page", i);
|
|
|
if (_map.containsKey(i)) {
|
|
|
r.set("json", _map.get(i));
|
|
|
r.set("filled", true);
|
|
|
} else {
|
|
|
r.set("json", "[]");
|
|
|
r.set("filled", false);
|
|
|
}
|
|
|
res.add(r);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
public Record getTaskInfo(int task_id) {
|
|
|
return Db.findById("t_zjb_task", "task_id", task_id);
|
|
|
}
|
|
|
|
|
|
public List<Record> getTaskPageFillInfo(int task_id) {
|
|
|
Record rTask = getTaskInfo(task_id);
|
|
|
int module_id = rTask.getInt("module_id");
|
|
|
Record record = getMoudleInfo(module_id);
|
|
|
int page_count = record.getInt("page_count");
|
|
|
|
|
|
String sql = "select * from t_zjb_task_fill where task_id=?";
|
|
|
List<Record> exist = Db.find(sql, task_id);
|
|
|
|
|
|
Map<Integer, String> _map = new HashMap<>();
|
|
|
for (Record r1 : exist) {
|
|
|
_map.put(r1.getInt("page"), r1.getStr("json"));
|
|
|
}
|
|
|
|
|
|
List<Record> res = new ArrayList<>();
|
|
|
for (int i = 1; i <= page_count; i++) {
|
|
|
Record r = new Record();
|
|
|
r.set("page", i);
|
|
|
if (_map.containsKey(i)) {
|
|
|
r.set("json", _map.get(i));
|
|
|
r.set("filled", true);
|
|
|
} else {
|
|
|
r.set("json", "[]");
|
|
|
r.set("filled", false);
|
|
|
}
|
|
|
res.add(r);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
} |