| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- package com.jeecg.demo.controller;
- import java.io.IOException;
- import java.util.*;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.xml.ws.Response;
- import net.sf.json.JSONArray;
- import org.apache.log4j.Logger;
- import org.jeecgframework.core.common.controller.BaseController;
- import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
- import org.jeecgframework.core.common.model.common.UploadFile;
- import org.jeecgframework.core.common.model.json.AjaxJson;
- import org.jeecgframework.core.common.model.json.ComboTree;
- import org.jeecgframework.core.common.model.json.DataGrid;
- import org.jeecgframework.core.common.model.json.TreeGrid;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil;
- import org.jeecgframework.core.util.*;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.jeecgframework.tag.vo.datatable.SortDirection;
- import org.jeecgframework.tag.vo.easyui.ComboTreeModel;
- import org.jeecgframework.tag.vo.easyui.TreeGridModel;
- import org.jeecgframework.web.system.pojo.base.TSDepart;
- import org.jeecgframework.web.system.pojo.base.TSFunction;
- import org.jeecgframework.web.system.pojo.base.TSType;
- import org.jeecgframework.web.system.pojo.base.TSTypegroup;
- import org.jeecgframework.web.system.service.SystemService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- import com.alibaba.fastjson.JSONObject;
- import com.jeecg.demo.dao.JeecgMinidaoDao;
- import com.jeecg.demo.entity.TSDocument;
- /**
- * @ClassName: JeecgFormDemoController
- * @Description: TODO(演示例子处理类)
- * @author jeecg
- */
- @Controller
- @RequestMapping("/jeecgFormDemoController")
- public class JeecgFormDemoController extends BaseController {
- private static final Logger logger = Logger.getLogger(JeecgFormDemoController.class);
-
- @Autowired
- private SystemService systemService;
- @Autowired
- private JeecgMinidaoDao jeecgMinidaoDao;
-
- @RequestMapping(params = "uitag")
- public ModelAndView uitag(HttpServletRequest request) {
- return new ModelAndView("com/jeecg/demo/form_uitag");
- }
-
- @RequestMapping(params = "formValidDemo")
- public ModelAndView formValidDemo(HttpServletRequest request) {
- return new ModelAndView("com/jeecg/demo/form_valid");
- }
- @RequestMapping(params = "testsubmit=1",method ={RequestMethod.GET, RequestMethod.POST})
- public ModelAndView testsubmit(HttpServletRequest request) {
- logger.info("请求成功byebye");
- return new ModelAndView("com/jeecg/demo/form_valid");
- }
-
- @RequestMapping(params = "nature")
- public ModelAndView easyDemo(HttpServletRequest request) {
- logger.info("demo-nature");
- //ztree同步加载
- JSONArray jsonArray=JSONArray.fromObject(getZtreeData());
- request.setAttribute("regions", jsonArray.toString().replaceAll("pid","pId"));
- return new ModelAndView("com/jeecg/demo/form_nature");
- }
- //update-begin--Author:dangzhenghui Date:20170408 for:TASK #1836 【demo】动态创建多tab demo,参考截图效果
- @RequestMapping(params = "ueditor")
- public ModelAndView ueditor(HttpServletRequest request) {
- logger.info("ueditor");
- return new ModelAndView("com/jeecg/demo/ueditor");
- }
- //update-end--Author:dangzhenghui Date:20170408 for:TASK #1836 【demo】动态创建多tab demo,参考截图效果
- /**
- *下拉联动数据---省市区
- */
- @RequestMapping(params="regionSelect",method = RequestMethod.GET)
- @ResponseBody
- public List<Map<String, String>> cityselect(HttpServletRequest req) throws Exception{
- logger.info("----省市区联动-----");
- String pid=req.getParameter("pid");
- List<Map<String, String>> list=jeecgMinidaoDao.getProCity(pid);
- return jeecgMinidaoDao.getProCity(pid);
- }
-
- /**
- * Ztree
- * 获取所有的省市区数据
- * @return
- */
- public List<Map<String, String>> getZtreeData(){
- return jeecgMinidaoDao.getAllRegions();
- }
-
- /**
- * 父级DEMO下拉菜单
- */
- @RequestMapping(params = "getComboTreeData")
- @ResponseBody
- public List<ComboTree> getComboTreeData(HttpServletRequest request, ComboTree comboTree) {
- CriteriaQuery cq = new CriteriaQuery(TSDepart.class);
- if (comboTree.getId() != null) {
- cq.eq("TSPDepart.id", comboTree.getId());
- }
- if (comboTree.getId() == null) {
- cq.isNull("TSPDepart");
- }
- cq.add();
- List<TSDepart> demoList = systemService.getListByCriteriaQuery(cq, false);
- List<ComboTree> comboTrees = new ArrayList<ComboTree>();
- ComboTreeModel comboTreeModel = new ComboTreeModel("id", "departname", "TSDeparts");
- comboTrees = systemService.ComboTree(demoList, comboTreeModel, null, false);
- return comboTrees;
- }
-
- /**
- * 加载ztree
- * @param response
- * @param request
- * @return
- */
- @RequestMapping(params="getTreeData",method ={RequestMethod.GET, RequestMethod.POST})
- @ResponseBody
- public AjaxJson getTreeData(TSDepart depatr,HttpServletResponse response,HttpServletRequest request ){
- AjaxJson j = new AjaxJson();
- try{
- List<TSDepart> depatrList = new ArrayList<TSDepart>();
- StringBuffer hql = new StringBuffer(" from TSDepart t");
- //hql.append(" and (parent.id is null or parent.id='')");
- depatrList = this.systemService.findHql(hql.toString());
- List<Map<String,Object>> dataList = new ArrayList<Map<String,Object>>();
- Map<String,Object> map = null;
- for (TSDepart tsdepart : depatrList) {
- String sqls = null;
- Object[] paramss = null;
- map = new HashMap<String,Object>();
- map.put("id", tsdepart.getId());
- map.put("name", tsdepart.getDepartname());
- if (tsdepart.getTSPDepart() != null) {
- map.put("pId", tsdepart.getTSPDepart().getId());
- map.put("open",false);
- }else {
- map.put("pId", "1");
- map.put("open",false);
- }
- sqls = "select count(1) from t_s_depart t where t.parentdepartid = ?";
- paramss = new Object[]{tsdepart.getId()};
- long counts = this.systemService.getCountForJdbcParam(sqls, paramss);
- if(counts>0){
- dataList.add(map);
- }else{
- TSDepart de = this.systemService.get(TSDepart.class, tsdepart.getId());
- if (de != null) {
- map.put("id", de.getId());
- map.put("name", de.getDepartname());
- if(tsdepart.getTSPDepart()!=null){
- map.put("pId", tsdepart.getTSPDepart().getId());
- map.put("open",false);
- }else{
- map.put("pId", "1");
- map.put("open",false);
- }
- dataList.add(map);
- }else{
- map.put("open",false);
- dataList.add(map);
- }
- }
- }
- j.setObj(dataList);
- }catch(Exception e){
- e.printStackTrace();
- }
- return j;
- }
-
-
- /**
- * 自动完成请求返回数据
- * @param request
- * @param responss
- */
- @RequestMapping(params = "getAutocompleteData",method ={RequestMethod.GET, RequestMethod.POST})
- public void getAutocompleteData(HttpServletRequest request, HttpServletResponse response) {
- String searchVal = request.getParameter("searchVal");
- String hql = "from TSUser where userName like '%"+searchVal+"%'";
- List autoList = systemService.findHql(hql);
- try {
- response.setContentType("application/json;charset=UTF-8");
- response.setHeader("Pragma", "No-cache");
- response.setHeader("Cache-Control", "no-cache");
- response.setDateHeader("Expires", 0);
- response.getWriter().write(JSONHelper.listtojson(new String[]{"userName"},1,autoList));
- response.getWriter().flush();
- } catch (Exception e1) {
- e1.printStackTrace();
- }finally{
- try {
- response.getWriter().close();
- } catch (IOException e) {
- }
- }
- }
- //update-begin--Author:dangzhenghui Date:20170429 for:TASK #1904 【demo】电子签章
- @RequestMapping(params = "eSign")
- public ModelAndView eSignDemo(HttpServletRequest request) {
- return new ModelAndView("com/jeecg/demo/zsign");
- }
- //update-end--Author:dangzhenghui Date:20170429 for:TASK #1904 【demo】电子签章
- //add-begin--Author:xuelin Date:20170503 for:#1903 【demo】左右布局demo--------------------
- @RequestMapping(params = "siteSelect")
- public ModelAndView siteSelect(HttpServletRequest request) {
- logger.info("----左右布局 demo转入页面-----");
- return new ModelAndView("com/jeecg/demo/siteSelect");
- }
- //add-end--Author:xuelin Date:20170503 for:#1903 【demo】左右布局demo----------------------
- //add-begin--Author:xuelin Date:20170506 for:TASK #1902 【demo】上下特殊布局--------------------
- /**
- * 上下特殊布局
- */
- @RequestMapping(params = "specialLayout")
- public ModelAndView rowListDemo(HttpServletRequest request) {
- logger.info("----上下特殊布局 demo转入页面-----");
- return new ModelAndView("com/jeecg/demo/specialLayout");
- }
- //add-end--Author:xuelin Date:20170506 for:TASK #1902 【demo】上下特殊布局----------------------
-
-
- //update--begin--author:zhangjiaqiang date:20170618 for:通用上传demo
- @RequestMapping(params = "commonUpload")
- public ModelAndView commonUploadDemo(){
- return new ModelAndView("system/commonupload/commonUploadFile");
- }
-
- /**
- *
- * @return
- */
- @RequestMapping(params = "saveUploadFile")
- @ResponseBody
- public AjaxJson saveUploadFile(String documentTitle,String filename){
- AjaxJson ajaxJson = new AjaxJson();
- try {
- TSTypegroup tsTypegroup=systemService.getTypeGroup("fieltype","文档分类");
- TSType tsType = systemService.getType("files","附件", tsTypegroup);
- TSDocument document = new TSDocument();
- document.setDocumentTitle(documentTitle);
- document.setRealpath(filename);
- document.setSubclassname(MyClassLoader.getPackPath(document));
- document.setCreatedate(DateUtils.gettimestamp());
- document.setTSType(tsType);
- //update--begin--author:zhangjiaqiang date:20170621 for:修订通用文件上传之后,下载和预览异常
- String fileName = filename.substring(filename.lastIndexOf("/")+1,filename.lastIndexOf("."));
- document.setAttachmenttitle(fileName);
- document.setExtend(filename.substring(filename.lastIndexOf(".") + 1));
- //update--end--author:zhangjiaqiang date:20170621 for:修订通用文件上传之后,下载和预览异常
- systemService.save(document);
- } catch (Exception e) {
- e.printStackTrace();
- ajaxJson.setSuccess(false);
- ajaxJson.setMsg("失败:"+e.getMessage());
- }
- return ajaxJson;
- }
-
-
-
- //update--end--author:zhangjiaqiang date:20170618 for:通用上传demo
-
-
-
- //update-begin--Author:dangzhenghui Date:20170524 for:TASK #1901 【demo】文档管理demo
- /**
- * 文件添加跳转
- *
- * @param req
- * @return
- */
- @RequestMapping(params = "addFiles")
- public ModelAndView addFiles(HttpServletRequest req) {
- return new ModelAndView("system/document/files");
- }
- /**
- * 文件编辑跳转
- *
- * @return
- */
- @RequestMapping(params = "editFiles")
- public ModelAndView editFiles(TSDocument doc, ModelMap map) {
- if (StringUtil.isNotEmpty(doc.getId())) {
- doc = systemService.getEntity(TSDocument.class, doc.getId());
- map.put("doc", doc);
- }
- return new ModelAndView("system/document/files");
- }
- /**
- * 保存文件
- *
- * @param document
- * @return
- * @throws Exception
- */
- @RequestMapping(params = "saveFiles", method = RequestMethod.POST)
- @ResponseBody
- public AjaxJson saveFiles(HttpServletRequest request, HttpServletResponse response, TSDocument document) {
- AjaxJson j = new AjaxJson();
- Map<String, Object> attributes = new HashMap<String, Object>();
- TSTypegroup tsTypegroup=systemService.getTypeGroup("fieltype","文档分类");
- TSType tsType = systemService.getType("files","附件", tsTypegroup);
- String fileKey = oConvertUtils.getString(request.getParameter("fileKey"));// 文件ID
- String documentTitle = oConvertUtils.getString(request.getParameter("documentTitle"));// 文件标题
- if (StringUtil.isNotEmpty(fileKey)) {
- document.setId(fileKey);
- document = systemService.getEntity(TSDocument.class, fileKey);
- document.setDocumentTitle(documentTitle);
- }
- document.setSubclassname(MyClassLoader.getPackPath(document));
- document.setCreatedate(DateUtils.gettimestamp());
- document.setTSType(tsType);
- UploadFile uploadFile = new UploadFile(request, document);
- uploadFile.setCusPath("files");
- //设置weboffice转化【不设置该字段,则不做在线预览转化】
- uploadFile.setSwfpath("swfpath");
- document = systemService.uploadFile(uploadFile);
- attributes.put("url", document.getRealpath());
- attributes.put("fileKey", document.getId());
- attributes.put("name", document.getAttachmenttitle());
- attributes.put("viewhref", "commonController.do?objfileList&fileKey=" + document.getId());
- attributes.put("delurl", "commonController.do?delObjFile&fileKey=" + document.getId());
- j.setMsg("文件添加成功");
- j.setAttributes(attributes);
- return j;
- }
-
- /**
- * 新闻法规文件列表
- */
- @RequestMapping(params = "documentList")
- public void documentList(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- CriteriaQuery cq = new CriteriaQuery(TSDocument.class, dataGrid);
- String typecode = oConvertUtils.getString(request.getParameter("typecode"));
- cq.createAlias("TSType", "TSType");
- cq.eq("TSType.typecode", typecode);
- cq.add();
- this.systemService.getDataGridReturn(cq, true);
- TagUtil.datagrid(response, dataGrid);
- }
- /**
- * 删除文档
- *
- * @param document
- * @return
- */
- @RequestMapping(params = "delDocument")
- @ResponseBody
- public AjaxJson delDocument(TSDocument document, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- document = systemService.getEntity(TSDocument.class, document.getId());
- message = "" + document.getDocumentTitle() + "被删除成功";
- systemService.delete(document);
- systemService.addLog(message, Globals.Log_Type_DEL,
- Globals.Log_Leavel_INFO);
- j.setSuccess(true);
- j.setMsg(message);
- return j;
- }
- //update-end--Author:dangzhenghui Date:20170524 for:TASK #1901 【demo】文档管理demo
- //update-begin--Author:dangzhenghui Date:20170531 for:TASK #2038 【demo】树形列表 分页demo
- /**
- * 权限列表
- */
- @RequestMapping(params = "functionGrid")
- @ResponseBody
- public Object functionGrid(HttpServletRequest request,TreeGrid treegrid, Integer type,HttpServletResponse response, DataGrid dataGrid) {
- CriteriaQuery cq = new CriteriaQuery(TSFunction.class,dataGrid);
- boolean pageflag=true;
- String selfId = request.getParameter("selfId");
- if (selfId != null) {
- cq.notEq("id", selfId);
- }
- if (treegrid.getId() != null) {
- pageflag=false;
- cq.eq("TSFunction.id", treegrid.getId());
- }
- if (treegrid.getId() == null) {
- cq.isNull("TSFunction");
- }
- if(type != null){
- cq.eq("functionType", type.shortValue());
- }
- cq.addOrder("functionOrder", SortDirection.asc);
- cq.add();
- //update--begin------author:scott--------------date:20151208-----------for:手工加载数据权限条件--------
- //获取装载数据权限的条件HQL
- cq = HqlGenerateUtil.getDataAuthorConditionHql(cq, new TSFunction());
- cq.add();
- //update--end------author:scott--------------date:20151208-----------for:手工加载数据权限条件--------
- List<TSFunction> functionList = systemService.getListByCriteriaQuery(cq, pageflag);
- Long total=systemService.getCountForJdbc("select count(*) from t_s_function where functionlevel=0");
- // update-start-Author:zhangguoming Date:20140914 for:菜单管理页面:菜单排序
- Collections.sort(functionList, new NumberComparator());
- // update-end-Author:zhangguoming Date:20140914 for:菜单管理页面:菜单排序
- List<TreeGrid> treeGrids = new ArrayList<TreeGrid>();
- TreeGridModel treeGridModel = new TreeGridModel();
- treeGridModel.setIcon("TSIcon_iconPath");
- treeGridModel.setTextField("functionName");
- treeGridModel.setParentText("TSFunction_functionName");
- treeGridModel.setParentId("TSFunction_id");
- treeGridModel.setSrc("functionUrl");
- treeGridModel.setIdField("id");
- treeGridModel.setChildList("TSFunctions");
- // 添加排序字段
- treeGridModel.setOrder("functionOrder");
- // update-begin--Author:chenj Date:20160722 for:添加菜单图标样式
- treeGridModel.setIconStyle("functionIconStyle");
- // update-end--Author:chenj Date:20160722 for:添加菜单图标样式
- treeGridModel.setFunctionType("functionType");
- treeGrids = systemService.treegrid(functionList, treeGridModel);
- MutiLangUtil.setMutiTree(treeGrids);
- JSONObject jsonObject=new JSONObject();
- jsonObject.put("rows",treeGrids);
- jsonObject.put("total",total);
- if (pageflag){
- return jsonObject;
- }
- return treeGrids;
- }
- /**
- * 权限列表页面跳转
- *
- * @return
- */
- @RequestMapping(params = "function")
- public ModelAndView function(ModelMap model) {
- return new ModelAndView("com/jeecg/demo/functionList");
- }
- //update-end--Author:dangzhenghui Date:20170531 for:TASK #2038 【demo】树形列表 分页demo
- }
|