|
|
|
|
package com.dsideal.FengHuang.Zjb.Model;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void delFillPage(int task_id, int page) {
|
|
|
|
|
String sql = "delete from t_zjb_task_fill where task_id=? and page=?";
|
|
|
|
|
Db.update(sql, task_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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveFillPage(int task_id, int page, String json) {
|
|
|
|
|
delFillPage(task_id, page);
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("task_id", task_id);
|
|
|
|
|
Record rTask = getTaskInfo(task_id);
|
|
|
|
|
int module_id = rTask.getInt("module_id");
|
|
|
|
|
record.set("module_id", module_id);
|
|
|
|
|
record.set("page", page);
|
|
|
|
|
record.set("json", json);
|
|
|
|
|
record.set("create_time", DateTime.now());
|
|
|
|
|
Db.save("t_zjb_task_fill", "task_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 String getTaskPage(int task_id, int page) {
|
|
|
|
|
String sql = "select json from t_zjb_task_fill where task_id=? and page=?";
|
|
|
|
|
List<Record> list = Db.find(sql, task_id, page);
|
|
|
|
|
if (list.size() > 0) return list.get(0).getStr("json");
|
|
|
|
|
//直接获取原始模板json进行显示
|
|
|
|
|
Record record = getTaskInfo(task_id);
|
|
|
|
|
return getModulePage(record.getInt("module_id"), page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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<>();
|
|
|
|
|
Map<Integer, String> _map2 = new HashMap<>();
|
|
|
|
|
for (Record record : exist) {
|
|
|
|
|
_map.put(record.getInt("page"), record.getStr("json"));
|
|
|
|
|
_map2.put(record.getInt("page"), record.getStr("doc_file"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
r.set("doc_file", _map2.get(i));
|
|
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//模板的填充完成情况
|
|
|
|
|
sql = "select * from t_zjb_module_page where module_id=?";
|
|
|
|
|
List<Record> listModuleFinish = Db.find(sql, module_id);
|
|
|
|
|
Map<Integer, String> _mapModuleFinish = new HashMap<>();
|
|
|
|
|
for (Record r2 : listModuleFinish) {
|
|
|
|
|
_mapModuleFinish.put(r2.getInt("page"), r2.getStr("json"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Record> res = new ArrayList<>();
|
|
|
|
|
for (int i = 1; i <= page_count; i++) {
|
|
|
|
|
Record r = new Record();
|
|
|
|
|
r.set("page", i);
|
|
|
|
|
r.set("module_id", module_id);
|
|
|
|
|
if (_map.containsKey(i)) {
|
|
|
|
|
r.set("json", _map.get(i));
|
|
|
|
|
r.set("page_finish", true);
|
|
|
|
|
} else {
|
|
|
|
|
r.set("json", "[]");
|
|
|
|
|
r.set("page_finish", false);
|
|
|
|
|
}
|
|
|
|
|
if (_mapModuleFinish.containsKey(i)) {
|
|
|
|
|
r.set("module_finish", true);
|
|
|
|
|
} else {
|
|
|
|
|
r.set("module_finish", false);
|
|
|
|
|
}
|
|
|
|
|
res.add(r);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveUploadFile(int task_id, int page, String upload_id, String file_name) {
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("task_id", task_id);
|
|
|
|
|
record.set("page", page);
|
|
|
|
|
record.set("upload_id", upload_id);
|
|
|
|
|
record.set("file_name", file_name);
|
|
|
|
|
Db.save("t_zjb_task_fill_upload", "task_id,page,upload_id,file_name", record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveDoc(int module_id, int page, String doc_file) {
|
|
|
|
|
String sql = "update t_zjb_module_page set doc_file=? where module_id=? and page=?";
|
|
|
|
|
Db.update(sql, doc_file, module_id, page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clearUpload(int task_id, int page) {
|
|
|
|
|
String sql = "delete from t_zjb_task_fill_upload where task_id=? and page=?";
|
|
|
|
|
Db.update(sql, task_id, page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Record> getTreeData() {
|
|
|
|
|
String sql = "select t1.id,t1.name,t1.parent_id as pId,t1.sort_id,t1.level_id,true as open,(select count(1) from t_zjb_tree as t2 where t1.id=t2.parent_id) as childCount from t_zjb_tree as t1 order by sort_id";
|
|
|
|
|
return Db.find(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteNode(int id) {
|
|
|
|
|
Db.deleteById("t_zjb_tree", "id", id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveTreeNode(int level_id, int parent_id, String name,int sort_id) {
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("name", name);
|
|
|
|
|
record.set("level_id", level_id + 1);
|
|
|
|
|
record.set("parent_id", parent_id);
|
|
|
|
|
record.set("sort_id",sort_id);
|
|
|
|
|
Db.save("t_zjb_tree", "id", record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateTreeNode(int id, String name,int sort_id) {
|
|
|
|
|
Record record = getTreeNode(id);
|
|
|
|
|
record.set("name", name);
|
|
|
|
|
record.set("sort_id",sort_id);
|
|
|
|
|
Db.update("t_zjb_tree", "id", record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Record getTreeNode(int id) {
|
|
|
|
|
Record record = Db.findById("t_zjb_tree", "id", id);
|
|
|
|
|
return record;
|
|
|
|
|
}
|
|
|
|
|
}
|