public boolean appendSubTableStr4Main(CgFormHeadEntity entity) { // step.1 获取本表的名称 String thisSubTable = entity.getTableName(); List<CgFormFieldEntity> columns = entity.getColumns(); // step.2 扫描字段配置,循环处理填有主表以及主表字段的条目 for (CgFormFieldEntity fieldE : columns) { String mainT = fieldE.getMainTable(); String mainF = fieldE.getMainField(); if (!StringUtil.isEmpty(mainT) && !StringUtil.isEmpty(mainF)) { CgFormHeadEntity mainE = this.getCgFormHeadByTableName(mainT); if (mainE == null) { continue; } // step.4 追加处理主表的附表串 String subTableStr = String.valueOf(mainE.getSubTableStr() == null ? "" : mainE.getSubTableStr()); // step.5 判断是否已经存在于附表串 if (!subTableStr.contains(thisSubTable)) { // step.6 追加到附表串 if (!StringUtil.isEmpty(subTableStr)) { subTableStr += "," + thisSubTable; } else { subTableStr += thisSubTable; } mainE.setSubTableStr(subTableStr); logger.info("--主表" + mainE.getTableName() + "的附表串:" + mainE.getSubTableStr()); } // step.7 更新主表的表配置 this.updateTable(mainE, "sign"); } } return true; }
public void sortSubTableStr(CgFormHeadEntity entity) { if (entity == null) return; CgFormHeadEntity main = null; List<CgFormFieldEntity> columns = entity.getColumns(); for (CgFormFieldEntity fieldE : columns) { String mainT = fieldE.getMainTable(); String mainF = fieldE.getMainField(); if (!StringUtil.isEmpty(mainT) && !StringUtil.isEmpty(mainF)) { CgFormHeadEntity mainE = this.getCgFormHeadByTableName(mainT); if (mainE == null) { continue; } main = mainE; } } if (main == null) { return; } String subTableStr = main.getSubTableStr(); if (StringUtils.isNotEmpty(subTableStr)) { String[] subTables = subTableStr.split(","); if (subTables.length <= 1) return; List<CgFormHeadEntity> subList = new ArrayList<CgFormHeadEntity>(); for (String subTable : subTables) { CgFormHeadEntity sub = this.getCgFormHeadByTableName(subTable); subList.add(sub); } Collections.sort( subList, new Comparator<CgFormHeadEntity>() { public int compare(CgFormHeadEntity arg0, CgFormHeadEntity arg1) { Integer tabOrder0 = arg0.getTabOrder(); if (tabOrder0 == null) { tabOrder0 = 0; } Integer tabOrder1 = arg1.getTabOrder(); if (tabOrder1 == null) { tabOrder1 = 0; } return tabOrder0.compareTo(tabOrder1); } }); subTableStr = ""; for (CgFormHeadEntity sub : subList) { subTableStr += sub.getTableName() + ","; } subTableStr = subTableStr.substring(0, subTableStr.length() - 1); main.setSubTableStr(subTableStr); this.updateTable(main, "sign"); } }
/** * 通过JDBC访问数据库列表页面跳转 * * @return */ @RequestMapping(params = "addorupdate") public ModelAndView addorupdate(SbJdbcEntity sbJdbc, HttpServletRequest req) { if (StringUtil.isNotEmpty(sbJdbc.getId())) { sbJdbc = sbJdbcService.getEntity(SbJdbcEntity.class, sbJdbc.getId()); req.setAttribute("sbJdbcPage", sbJdbc); } List<Department> departList = systemService.getList(Department.class); req.setAttribute("departList", departList); return new ModelAndView("sb/demo/notag/sbEasyUI"); }
/** * 订单信息列表页面跳转 * * @return */ @RequestMapping(params = "addorupdateNoTag") public ModelAndView addorupdate(SbOrderMainEntity sbOrderMain, HttpServletRequest req) { if (StringUtil.isNotEmpty(sbOrderMain.getId())) { sbOrderMain = sbOrderMainService.getEntity(SbOrderMainEntity.class, sbOrderMain.getId()); req.setAttribute("sbOrderMainPage", sbOrderMain); } if (StringUtil.isNotEmpty(sbOrderMain.getGoOrderCode())) { List<SbOrderProductEntity> sbOrderProductEntityList = sbOrderMainService.findByProperty( SbOrderProductEntity.class, "goOrderCode", sbOrderMain.getGoOrderCode()); req.setAttribute("sbOrderProductList", sbOrderProductEntityList); } if (StringUtil.isNotEmpty(sbOrderMain.getGoOrderCode())) { List<SbOrderCustomEntity> sbSbOrderCustomEntityList = sbOrderMainService.findByProperty( SbOrderCustomEntity.class, "goOrderCode", sbOrderMain.getGoOrderCode()); req.setAttribute("sbOrderCustomList", sbSbOrderCustomEntityList); } return new ModelAndView("sb/demo/notag/sbOrderMainNoTag"); }
public boolean removeSubTableStr4Main(CgFormHeadEntity entity) { if (entity == null) { return false; } // step.1 获取本表的名称 String thisSubTable = entity.getTableName(); List<CgFormFieldEntity> columns = entity.getColumns(); // step.2 扫描字段配置,循环处理填有主表以及主表字段的条目 for (CgFormFieldEntity fieldE : columns) { String mainT = fieldE.getMainTable(); String mainF = fieldE.getMainField(); if (!StringUtil.isEmpty(mainT) && !StringUtil.isEmpty(mainF)) { CgFormHeadEntity mainE = this.getCgFormHeadByTableName(mainT); if (mainE == null) { continue; } // step.4 追加处理主表的附表串 String subTableStr = String.valueOf(mainE.getSubTableStr() == null ? "" : mainE.getSubTableStr()); // step.5 判断是否已经存在于附表串 if (subTableStr.contains(thisSubTable)) { // step.6 剔除主表的附表串 if (subTableStr.contains(thisSubTable + ",")) { subTableStr = subTableStr.replace(thisSubTable + ",", ""); } else if (subTableStr.contains("," + thisSubTable)) { subTableStr = subTableStr.replace("," + thisSubTable, ""); } else { subTableStr = subTableStr.replace(thisSubTable, ""); } mainE.setSubTableStr(subTableStr); logger.info("--主表" + mainE.getTableName() + "的附表串:" + mainE.getSubTableStr()); // step.7 更新主表的表配置,不用更新,因为hibernate是读取的缓存,所以和那边操作的对象是一个的 // this.updateTable(mainE, null); } } } return true; }
/** * 添加订单及明细信息 * * @param ids * @return */ @RequestMapping(params = "save") @ResponseBody public AjaxJson save( SbOrderMainEntity sbOrderMain, SbOrderMainPage sbOrderMainPage, HttpServletRequest request) { List<SbOrderProductEntity> sbOrderProducList = sbOrderMainPage.getSbOrderProductList(); List<SbOrderCustomEntity> sbOrderCustomList = sbOrderMainPage.getSbOrderCustomList(); Boolean sbOrderCustomShow = "true".equals(request.getParameter("sbOrderCustomShow")); AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(sbOrderMain.getId())) { message = "更新成功"; sbOrderMainService.updateMain( sbOrderMain, sbOrderProducList, sbOrderCustomList, sbOrderCustomShow); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } else { message = "添加成功"; sbOrderMainService.addMain(sbOrderMain, sbOrderProducList, sbOrderCustomList); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); } j.setMessage(message); return j; }
/** * 添加通过JDBC访问数据库 * * @param ids * @return */ @RequestMapping(params = "save") @ResponseBody public AjaxJson save(SbJdbcEntity sbJdbc, HttpServletRequest request) { AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(sbJdbc.getId())) { message = "更新成功"; SbJdbcEntity t = sbJdbcService.get(SbJdbcEntity.class, sbJdbc.getId()); try { MyBeanUtils.copyBeanNotNull2Bean(sbJdbc, t); sbJdbcService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); } } else { message = "添加成功"; sbJdbcService.save(sbJdbc); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); } return j; }
public String getCgFormVersionById(String id) { String version = cgFormVersionDao.getCgFormVersionById(id); return StringUtil.isEmpty(version) ? "0" : version; }
public String getCgFormVersionByTableName(String tableName) { String version = cgFormVersionDao.getCgFormVersionByTableName(tableName); return StringUtil.isEmpty(version) ? "0" : version; }