/** * 添加全量统计 * * @param ids * @return */ @RequestMapping(params = "save") @ResponseBody public AjaxJson save(FullStatisticsMonthEntity fullStatisticsMonth, HttpServletRequest request) { AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(fullStatisticsMonth.getId())) { message = "全量统计更新成功"; FullStatisticsMonthEntity t = fullStatisticsMonthService.get( FullStatisticsMonthEntity.class, fullStatisticsMonth.getId()); try { MyBeanUtils.copyBeanNotNull2Bean(fullStatisticsMonth, t); fullStatisticsMonthService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); message = "全量统计更新失败"; } } else { message = "全量统计添加成功"; fullStatisticsMonthService.save(fullStatisticsMonth); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); } j.setMsg(message); return j; }
/** * 终端信息列表页面跳转 * * @return */ @RequestMapping(params = "addorupdate") public ModelAndView addorupdate(TerminalInfoEntity terminalInfo, HttpServletRequest req) { if (StringUtil.isNotEmpty(terminalInfo.getId())) { try { terminalInfo = terminalInfoService.getEntity(TerminalInfoEntity.class, terminalInfo.getId()); TerminalInfoPage page = new TerminalInfoPage(); MyBeanUtils.copyBeanNotNull2Bean(terminalInfo, page); TSTerritory self = systemService.get(TSTerritory.class, page.getGroupid()); String territoryName = ""; List<TSTerritory> ts = new ArrayList<TSTerritory>(); TSTerritory parent = self.getTSTerritory(); ts.add(self); String pid = parent.getId(); // 当父组织机构不为根机构时,查找父机构 while (!"1".equals(pid)) { parent = systemService.get(TSTerritory.class, pid); ts.add(parent); parent = parent.getTSTerritory(); pid = parent.getId(); } // 按照添加顺序逆序 Collections.reverse(ts); for (TSTerritory te : ts) { territoryName += "-" + te.getTerritoryName(); } page.setGroupname(territoryName.substring(1)); req.setAttribute("terminalInfoPage", page); } catch (Exception e) { logger.error("获取终端信息错误"); e.printStackTrace(); } } return new ModelAndView("vod/terminalinfo/terminalInfo"); }
/** * 添加终端信息 * * @param ids * @return */ @RequestMapping(params = "save") @ResponseBody public AjaxJson save(TerminalInfoEntity terminalInfo, HttpServletRequest request) { AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(terminalInfo.getId())) { message = "终端信息更新成功"; TerminalInfoEntity t = terminalInfoService.get(TerminalInfoEntity.class, terminalInfo.getId()); try { MyBeanUtils.copyBeanNotNull2Bean(terminalInfo, t); terminalInfoService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); message = "终端信息更新失败"; } } else { message = "终端信息添加成功"; terminalInfo.setStatus(Integer.valueOf(SystemType.TERMINAL_STATE_0)); terminalInfoService.save(terminalInfo); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); } j.setMsg(message); return j; }
@RequestMapping(params = "articleSave") @ResponseBody public AjaxJson articleSave( ItemEntity item, String content, String contentTxt, HttpServletRequest req) { AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(item.getId())) { message = "内容信息添加成功"; ItemEntity t = commonItemService.get(ItemEntity.class, item.getId()); ArticleEntity a = t.getArticle(); a.setContent(content); a.setContentTxt(contentTxt); t.setArticle(a); if (item.getParentId().equals("0")) { item.setLevel(1); // 设置为目录级 } else { item.setLevel( commonItemService.findParticalItemById(item.getParentId()).getLevel() + 1); // 设置为内容级别 } try { MyBeanUtils.copyBeanNotNull2Bean(item, t); commonItemService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); message = "类目基本信息更新失败"; } } else { CommonAdminSession sessionAdmin = (CommonAdminSession) req.getSession().getAttribute(Constant.COMMON_ADMIN_SESSION); Date curDate = new Date(System.currentTimeMillis()); message = "内容信息添加成功"; item.setCreateTime(curDate); item.setUpdateTime(curDate); item.setBelongs(sessionAdmin.getDistrict().getDistrictCode()); item.setCreator(sessionAdmin.getId()); item.setType(Constant.Article); item.setStatus(DictionaryBean.keyDict.get("item_status_normal").getValue()); if (item.getParentId().equals("0")) { item.setLevel(1); // 设置为目录级 } else { item.setLevel( commonItemService.findParticalItemById(item.getParentId()).getLevel() + 1); // 设置为内容级别 } ArticleEntity article = new ArticleEntity(); article.setContent(content); article.setContentTxt(contentTxt); article.setParentId(item.getParentId()); article.setBelongId(DictionaryBean.keyDict.get("item_belongs_private").getValue()); commonItemService.save(article); item.setArticle(article); commonItemService.save(item); } j.setMsg(message); return j; }
/** * easyui AJAX请求数据 * * @param request * @param response * @param dataGrid * @param user * @throws Exception */ @SuppressWarnings("unchecked") @RequestMapping(params = "datagrid") public void datagrid( TerminalInfoEntity terminalInfo, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid, String groupname) throws Exception { CriteriaQuery cq = new CriteriaQuery(TerminalInfoEntity.class, dataGrid); // 查询条件组装器,fuzzy search String name = terminalInfo.getName(); if (StringUtil.isNotEmpty(name)) { terminalInfo.setName("*" + name + "*"); } org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql( cq, terminalInfo, request.getParameterMap()); this.terminalInfoService.getDataGridReturn(cq, true); List<TerminalInfoEntity> terminals = dataGrid.getResults(); List<TerminalInfoPage> results = new ArrayList<TerminalInfoPage>(); // 添加地理位置 for (TerminalInfoEntity t : terminals) { if (StringUtil.isNotEmpty(t.getGroupid())) { TerminalInfoPage page = new TerminalInfoPage(); MyBeanUtils.copyBeanNotNull2Bean(t, page); TSTerritory self = systemService.get(TSTerritory.class, t.getGroupid()); String territoryName = ""; List<TSTerritory> ts = new ArrayList<TSTerritory>(); TSTerritory parent = self.getTSTerritory(); ts.add(self); String pid = parent.getId(); // 当父组织机构不为根机构时,查找父机构 while (!"1".equals(pid)) { parent = systemService.get(TSTerritory.class, pid); ts.add(parent); parent = parent.getTSTerritory(); pid = parent.getId(); } // 按照添加顺序逆序 Collections.reverse(ts); for (TSTerritory te : ts) { territoryName += "-" + te.getTerritoryName(); } page.setGroupname(territoryName.substring(1)); results.add(page); } } dataGrid.setResults(results); TagUtil.datagrid(response, dataGrid); }
/** * 更新微站点信息 * * @param ids * @return */ @RequestMapping(params = "doUpdate") @ResponseBody public AjaxJson doUpdate(WeixinCmsSiteEntity weixinCmsSite, HttpServletRequest request) { AjaxJson j = new AjaxJson(); message = "微站点信息更新成功"; WeixinCmsSiteEntity t = weixinCmsSiteService.get(WeixinCmsSiteEntity.class, weixinCmsSite.getId()); try { MyBeanUtils.copyBeanNotNull2Bean(weixinCmsSite, t); weixinCmsSiteService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); message = "微站点信息更新失败"; throw new BusinessException(e.getMessage()); } j.setMsg(message); return j; }
/** * 保存DEMO维护 * * @param demo * @param request * @return * @throws Exception */ @RequestMapping(params = "saveDemo") @ResponseBody public AjaxJson saveDemo(TSDemo demo, HttpServletRequest request) throws Exception { AjaxJson j = new AjaxJson(); if (!StringUtil.isEmpty(demo.getId())) { message = "Demo维护例子: " + demo.getDemotitle() + "被更新成功"; TSDemo entity = this.systemService.get(TSDemo.class, demo.getId()); MyBeanUtils.copyBeanNotNull2Bean(demo, entity); if (demo.getTSDemo() == null || StringUtil.isEmpty(demo.getTSDemo().getId())) { entity.setTSDemo(null); } this.systemService.saveOrUpdate(entity); } else { message = "Demo例子: " + demo.getDemotitle() + "被添加成功"; if (demo.getTSDemo() == null || StringUtil.isEmpty(demo.getTSDemo().getId())) { demo.setTSDemo(null); } this.systemService.save(demo); } j.setMsg(message); return j; }
/** * 添加订单跟踪信息 * * @param ids * @return */ @RequestMapping(params = "save") @ResponseBody public AjaxJson save(TbOrderTrackingEntity tbOrderTracking, HttpServletRequest request) { AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(tbOrderTracking.getId())) { message = "更新成功"; TbOrderTrackingEntity t = tbOrderTrackingService.get(TbOrderTrackingEntity.class, tbOrderTracking.getId()); try { MyBeanUtils.copyBeanNotNull2Bean(tbOrderTracking, t); tbOrderTrackingService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); } } else { message = "添加成功"; tbOrderTrackingService.save(tbOrderTracking); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); } return j; }
/** * 添加编码器录制服务器关系 * * @param ids * @return */ @RequestMapping(params = "save") @ResponseBody public AjaxJson save(ConfCodecRecordSrvEntity confCodecRecordSrv, HttpServletRequest request) { AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(confCodecRecordSrv.getId())) { message = "编码器录制服务器关系更新成功"; ConfCodecRecordSrvEntity t = confCodecRecordSrvService.get(ConfCodecRecordSrvEntity.class, confCodecRecordSrv.getId()); try { MyBeanUtils.copyBeanNotNull2Bean(confCodecRecordSrv, t); confCodecRecordSrvService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); message = "编码器录制服务器关系更新失败"; } } else { message = "编码器录制服务器关系添加成功"; confCodecRecordSrvService.save(confCodecRecordSrv); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); } j.setMsg(message); return j; }
/** * 导出excel * * @param request * @param response */ @SuppressWarnings("unchecked") @RequestMapping(params = "exportXls") public void exportXls( TerminalInfoEntity terminalInfo, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { response.setContentType("application/vnd.ms-excel"); String codedFileName = null; OutputStream fOut = null; try { codedFileName = "终端信息"; // 根据浏览器进行转码,使其支持中文文件名 if (BrowserUtils.isIE(request)) { response.setHeader( "content-disposition", "attachment;filename=" + java.net.URLEncoder.encode(codedFileName, "UTF-8") + ".xls"); } else { String newtitle = new String(codedFileName.getBytes("UTF-8"), "ISO8859-1"); response.setHeader("content-disposition", "attachment;filename=" + newtitle + ".xls"); } // 产生工作簿对象 HSSFWorkbook workbook = null; CriteriaQuery cq = new CriteriaQuery(TerminalInfoEntity.class, dataGrid); org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql( cq, terminalInfo, request.getParameterMap()); List<TerminalInfoEntity> courses = systemService.getListByCriteriaQuery(cq, false); List<TerminalInfoPage> pages = new ArrayList<TerminalInfoPage>(); // 转换代码为汉字 for (TerminalInfoEntity t : courses) { TerminalInfoPage p = new TerminalInfoPage(); MyBeanUtils.copyBeanNotNull2Bean(t, p); // 组织结构 TSTerritory te = systemService.get(TSTerritory.class, t.getGroupid()); if (te != null) { p.setGroupname(te.getTerritoryName()); } // 状态 TSType tp = systemService.getType( p.getStatus() == null ? null : p.getStatus().toString(), SystemType.TERMINAL_STATE); if (tp != null) { p.setStatusname(tp.getTypename()); } pages.add(p); } TSUser user = ResourceUtil.getSessionUserName(); workbook = ExcelExportUtil.exportExcel( new ExcelTitle("终端状态", "导出人:" + user.getRealName(), "导出信息"), TerminalInfoPage.class, pages); fOut = response.getOutputStream(); workbook.write(fOut); } catch (Exception e) { } finally { try { fOut.flush(); fOut.close(); } catch (IOException e) { } } }