1.JAVA
@Controller
//我用的是springmvc哈!
//这个方法是进入上一篇的页面的方法,很关键哦!!
@RequestMapping(value = "/taskpage")
public String taskpage(String globalId,String type,
Model model) throws ParseException {
Field[] field = TaskInfo.class.getDeclaredFields(); //获取实体类的所有属性,返回Field数组
for(int j=0 ; j<field.length ; j++){ //遍历所有属性
String name = field[j].getName(); //获取属性的名字
model.addAttribute(name, "${"+name+"}");
}
//因为jsPlumbToolkit插件原因需要自定义字段
//我插个图片哈!
2.图片
3.JAVA
//上面图片是jsPlumbToolkit自带的方法,把值自动装载到页面上,他所用的标签也是${}这就和EL表达式${}冲突了,会导致页面无法显示正常所传递的值,所以我在里面又嵌套了一层 嘻嘻!!就是下面这样了
//例:${userid}传到页面→${${userid}},在页面上他会先被el解析成${userid},再被jsPlumbToolkit解析
model.addAttribute("userid", "${userid}");//当前userid
model.addAttribute("SETime", "${SETime}");//时间显示
model.addAttribute("tasktimeType", "${tasktimeType}");//状态
model.addAttribute("Fziduan", "${Fziduan}");//字段1 负责人
model.addAttribute("Zziduan", "${Zziduan}");//字段2 周报
model.addAttribute("Xziduan", "${Xziduan}");//字段3 详情
model.addAttribute("username", "${username}");//字段4 负责人
model.addAttribute("top_right", "${top_right}");//字段5 显示
model.addAttribute("top_right_delete", "${top_right_delete}");//字段6 显示
model.addAttribute("user_right", "${user_right}");//字段7 显示
model.addAttribute("bow_delide", "${bow_delide}");//字段8 显示
model.addAttribute("bow_left", "${bow_left}");//字段8 显示
model.addAttribute("globalId", globalId);
model.addAttribute("jumpType", type);
if(type.equals("1")){
return "/meeting/task_list";
}else if(type.equals("2")){
return "/meeting/mytask_list";
}else if(type.equals("0")){
return "/meeting/task_admin_list";
}
return null;
}
@Controller
//这个是ajax请求的方法返回json字符串
@ResponseBody
@RequestMapping(value = "/taskjson")
public String taskjson(String globalId,String jumpType,Model model) {
//这个Map里面是。。。。。看Impl吧
Map tasklist = meetingService.taskList(globalId,jumpType);
SysUser user = (SysUser) this.getUser();
//注释的这个是Json数据时间格式化的方法,以后的文章可能会给出、也可自行搜索,我这里没用到。
//JsonConfig jsonConfig = new JsonConfig();
//jsonConfig.registerJsonValueProcessor(Timestamp.class , new JsonDateValueProcessor("yyyy-MM-dd"));
JSONArray json = JSONArray.fromObject(tasklist.get("info"));
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//把map里面的值取出来,以下面这种格式手动拼接json就可以了!
//根据你自己的需求做更改
String jos = "{"nodes":"+json+","edges":"+tasklist.get("jsons")+","taskTime":[{"taskNow": ""+sdf.format(d).toString()+""}],"NowUser":[{"userid": ""+user.getId().toString()+""}]}";
return jos;
}
//Impl
//这两个json包哦!!
import org.json.JSONArray;
import org.json.JSONObject;
@Override
public Map taskList(String globalId, String jumpType) {
List<Map<String, Object>> info = null;
String sql = null;
Map map = new HashMap();
Map t = new HashMap();//这里定义的是根节点
t.put("ID", "00000000000000000000000000000000");
t.put("IF_DEL", "1");
t.put("TASK_NAME", "管理系统2.0");
t.put("TASK_LEV", 0);
if (StringUtils.isNotBlank(jumpType)) {
//下面就是查数据
if (jumpType.equals("0")) {
sql = "SELECT t.*,m.`NAME`,m.id as mid from TASK_INFO t LEFT JOIN MEETING_USER m on t.TASK_USER_ID = m.id "
+ "where t.IF_DEL = '1' ORDER BY t.CREATE_TIME desc";
info = jdbcTemplate.queryForList(sql);
} else if (jumpType.equals("1") || jumpType.equals("2")) {
sql = "SELECT t.*,m.`NAME`,m.id as mid from TASK_INFO t LEFT JOIN MEETING_USER m on t.TASK_USER_ID = m.id "
+ "where t.IF_DEL = '1' and MEETING_ID = ? ORDER BY t.CREATE_TIME desc";
if (StringUtils.isNotBlank(globalId)) {
//info = baseTransaction.find("FROM TaskInfo WHERE ifDel = '1' and meetingId = ? ORDER BY createTime desc", new Object[]{globalId});
info = jdbcTemplate.queryForList(sql, new Object[]{globalId});
}
}
//查数据结束
}
JSONArray jsons = new JSONArray();
if (info != null && info.size() > 0) {
info.add(0, t);//t是根节点,需要让他一直在集合的第一个
/*我在下面插一个图片 ,数据库的
ID 节点的ID
TASK_LEV 子节点级别
SUPER_TASK_ID 上一级的ID
通过下面的方法循环添加到jsons里
*/
for (Map<String, Object> pLog : info) {
JSONObject jo = new JSONObject();
if (pLog.get("SUPER_TASK_ID") != null) {
jo.put("source", pLog.get("SUPER_TASK_ID"));
jo.put("target", pLog.get("ID"));
jsons.put(jo);
}
}
} else {
info = new ArrayList();
info.add(0, t);
}
map.put("info", info);
map.put("jsons", jsons);
return map;
}
//用到的 css,js
<link rel="stylesheet" type="text/css" href="jsplumbtoolkit/demo.css">
<link rel="stylesheet" type="text/css" href="jsplumbtoolkit/app.css">
<link rel="stylesheet" type="text/css" href="jsplumbtoolkit/jsplumbtoolkit-defaults.css">
<link rel="stylesheet" type="text/css" href="jsplumbtoolkit/jsplumbtoolkit-demo.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="${base}/common/layer/layer.js"></script>
<script src="jsplumbtoolkit/jquery.validate.js"></script>
<script src="jsplumbtoolkit/additional-methods.js"></script>
<script src="jsplumbtoolkit/jsplumbtoolkit.js"></script>
<script src="jsplumbtoolkit/syntax-highlighter.js"></script>
<script src="jsplumbtoolkit/demo-support.js"></script>
enmmm ,我会给出我的百度云哈,我整理整理
好啦!差不多到这啦!QAQ 这里百度云链接 ~~ 我才不告诉你密码是 2czw 呢!!!