| | |
| | | import com.yc.factory.FactoryBean; |
| | | import com.yc.multiData.SpObserver; |
| | | import com.yc.service.build.type.T_22_Ifc; |
| | | import com.yc.service.customControl.ControlLayoutIfc; |
| | | import com.yc.service.grid.GridServiceIfc; |
| | | import com.yc.service.impl.DBHelper; |
| | | import com.yc.utils.EncodeUtil; |
| | |
| | | */ |
| | | @Autowired |
| | | private GridServiceIfc gridService;//表格处理的业务类 |
| | | |
| | | @Autowired |
| | | ControlLayoutIfc controlLayoutIfc; |
| | | //static String domain= AttachmentConfig.get("attachment.server"); |
| | | |
| | | /** |
| | |
| | | |
| | | //只有明细表才需要执行,其他的都只是输出{} |
| | | private String setToolAddForNew(TreeGridDTO dto) { |
| | | if (dto.postStatusAddNew) return "<%=bdMap.toString()%>"; |
| | | if (dto.postStatusAddNew) return "panMain[panIndex].buttonInfoByGrid"; |
| | | switch (dto.winType) { |
| | | case 9: |
| | | case 15: |
| | |
| | | if (dto.conNum == 0) |
| | | return "{}"; |
| | | else |
| | | return "<%=bdMap.toString()%>"; |
| | | return "panMain[panIndex].buttonInfoByGrid"; |
| | | case 18: |
| | | case 38: |
| | | case 19: |
| | |
| | | if (dto.winType != 9 && dto.winType != 15) {//针对只生成一个表格的情况,17类型由于第二个没有表格所以也存在这里了 |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + dto.dbid); |
| | | dto.gfields = gridService.getGfiledByFormID9(dto.formID, this.setGetPrivaryTable(dto.winType));//取得所有字段信息 增加类型 |
| | | dto.gfields = gridService.getGfiledByFormID9(dto.formID,dto.winType, this.setGetPrivaryTable(dto.winType),dto.userCode);//取得所有字段信息 增加类型 |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | |
| | | if (dto.conNum < 2) { |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + dto.dbid); |
| | | dto.gfields = gridService.getGfiledByFormID9(dto.formID, dto.conNum);//取得所有字段信息 |
| | | //9,15明细转成对应的从表 |
| | | int formType=dto.winType; |
| | | if(formType==9&&dto.conNum==1) { |
| | | //处理自定义布局 |
| | | formType=5; |
| | | boolean hasControlLayout = controlLayoutIfc.hasControlLayout(dto.formID+"", dto.userCode, formType, ExprotType.Grid, false); |
| | | dto.hasControlLayout=hasControlLayout; |
| | | } |
| | | if(formType==15&&dto.conNum==1){ |
| | | //处理自定义布局 |
| | | formType=8; |
| | | boolean hasControlLayout = controlLayoutIfc.hasControlLayout(dto.formID+"", dto.userCode, formType, ExprotType.Grid, false); |
| | | dto.hasControlLayout=hasControlLayout; |
| | | } |
| | | dto.gfields = gridService.getGfiledByFormID9(dto.formID,formType, dto.conNum,dto.userCode);//取得所有字段信息 |
| | | dto.lastField = gridService.getSimpleJdbcTemplate().queryForObject(sql, new Object[]{dto.formID, 1}, String.class); |
| | | } catch (DataAccessException e) { |
| | | dto.lastField = ""; |
| | |
| | | dto.formID = dto.formID3; |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + dto.dbid); |
| | | dto.gfields = gridService.getGfiledByFormID9(dto.formID, 0);//取得所有 字段信息 |
| | | dto.gfields = gridService.getGfiledByFormID9(dto.formID,1, 0,dto.userCode);//取得所有 字段信息 |
| | | dto.lastField = gridService.getSimpleJdbcTemplate().queryForObject(sql, new Object[]{dto.formID, 0}, String.class); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | } |
| | | //try { |
| | | this.getTableName(dto.formID, dto.winType + "|" + dto.conNum, dto);// 增加类型 |
| | | if (dto.table == null) throw new ApplicationException(dto.formID + "--未设置明细表,请在9802设置后重新生成!"); |
| | | if (dto.winType == 1 && ("".equals(dto.table) || dto.table == null)) { |
| | | throw new ApplicationException(dto.formID + ",类型:" + dto.winType + "--未设置主表,请在9801设置后重新生成!"); |
| | | } |
| | | // if (dto.isTable) { |
| | | this.getFirstField(dto); |
| | | // } |
| | | this.getFirstField(dto); |
| | | if (dto.conNum >= 2) |
| | | if (dto.tempGridHeight != 0) dto.gridHeight = dto.tempGridHeight; |
| | | |
| | | gridConfig(root, dto); |
| | | createCoumtHeader(dto); |
| | | //} catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | //} |
| | | } |
| | | |
| | | private synchronized void fillColumnNumTree(int num, TreeGridDTO dto) {//根据最大行值填充列 |
| | |
| | | */ |
| | | private String getDetailGridTitle(TreeGridDTO dto, boolean keyInput, String id) { |
| | | if (!keyInput) return " "; |
| | | boolean isDeatail = false; |
| | | boolean isDetail = false; |
| | | switch (dto.winType) { |
| | | case 1: |
| | | case 10: |
| | | case 3: |
| | | case 30: |
| | | case 7: |
| | | case 301: |
| | | case 302: |
| | | case 304: |
| | | isDeatail = true; |
| | | isDetail = true; |
| | | break; |
| | | case 9: |
| | | if (dto.conNum == 1) isDeatail = true; |
| | | if (dto.conNum == 1) isDetail = true; |
| | | break; |
| | | case 15: |
| | | if (dto.conNum > 0) isDeatail = true; |
| | | if (dto.conNum > 0) isDetail = true; |
| | | break; |
| | | case 497: |
| | | if (dto.conNum == 1) isDeatail = true; |
| | | if (dto.conNum == 1) isDetail = true; |
| | | break; |
| | | } |
| | | return isDeatail ? (id.toLowerCase() + "HtmlPostfix=\"<span style='color:white;'> *</span>\"") : " "; |
| | | return isDetail ? (id.toLowerCase() + "HtmlPostfix=\"<span style='color:white;'> *</span>\" ") : " "; |
| | | } |
| | | |
| | | /** |
| | |
| | | StringBuilder id = new StringBuilder(); |
| | | StringBuilder value = new StringBuilder(); |
| | | if (type != 30 && type != 32) { |
| | | if(dto.isSuppressBlankLineForDropDown==0) { |
| | | //只有为0才需要增加空白列 |
| | | id.append("| "); |
| | | value.append("| "); |
| | | } |
| | | if(dto.isSuppressBlankLineForDropDown==0) { |
| | | //只有为0才需要增加空白列 |
| | | id.append("| "); |
| | | value.append("| "); |
| | | } |
| | | } |
| | | try { |
| | | if (sql != null && sql != "" && sql.length() > 0) {//有sql参数 |
| | |
| | | */ |
| | | private String getEnumMenu(TreeGridDTO dto,SqlRowSet rst,String colName){ |
| | | String menu="{Items:[";//{Value:''},{Value:'-',Text:'-'},{Value:'+',Text:'+'} |
| | | StringJoiner joiner=new StringJoiner(","); |
| | | if(dto.isSuppressBlankLineForDropDown==0){ |
| | | //有留白列 |
| | | joiner.add("{Value:'',Text:''}"); |
| | | } |
| | | while (rst.next()) { |
| | | if(colName==null) |
| | | joiner.add("{Value:'"+rst.getString(1)+"',Text:'"+rst.getString(2)+"'}"); |
| | | else |
| | | joiner.add("{Value:'"+rst.getString(colName)+"',Text:'"+rst.getString("dictvalue")+"'}"); |
| | | StringJoiner joiner=new StringJoiner(","); |
| | | if(dto.isSuppressBlankLineForDropDown==0){ |
| | | //有留白列 |
| | | joiner.add("{Value:'',Text:''}"); |
| | | } |
| | | while (rst.next()) { |
| | | if(colName==null) |
| | | joiner.add("{Value:'"+rst.getString(1)+"',Text:'"+rst.getString(2)+"'}"); |
| | | else |
| | | joiner.add("{Value:'"+rst.getString(colName)+"',Text:'"+rst.getString("dictvalue")+"'}"); |
| | | |
| | | } |
| | | rst.beforeFirst(); |
| | | return menu+=joiner.toString()+"]}"; |
| | | } |
| | | rst.beforeFirst(); |
| | | return menu+=joiner.toString()+"]}"; |
| | | } |
| | | private synchronized String setJsName(TreeGridDTO dto) { |
| | | return "grid_" + dto.formID + "_" + dto.winType + ".xml"; |
| | | } |
| | | |
| | | return "grid_" + dto.formID +(dto.hasControlLayout?("_"+dto.userCode):"")+ "_" + dto.winType + ".xml"; |
| | | } |
| | | private synchronized String setFileName(TreeGridDTO dto) { |
| | | //由于8类型的二三表共用一个页面,且用2表的功能号作为文件名称,所以这里需要特殊处理 |
| | | int formid= dto.formID; |
| | | if(dto.winType==15&&dto.conNum!=0){ |
| | | formid=dto.minID; |
| | | } |
| | | return formid +(dto.hasControlLayout?("_"+dto.userCode):"") + "_grid.jsp"; |
| | | } |
| | | /** |
| | | * 生成页面时需要检查的关键字段名,避免生成格线有问题 |
| | | */ |
| | |
| | | boolean uppercase = GridUtils.prossRowSetDataType_Boolean(map, "uppercase");//大写 |
| | | String ValueExp = GridUtils.prossRowSetDataType_String(map, "showFieldValueExpression");//权限控制是否显示该值 |
| | | String editStatus = GridUtils.prossRowSetDataType_String(map, "editStatus");//权限控制是否显示该值 |
| | | if(org.apache.commons.lang3.StringUtils.isNotBlank(editStatus)){ |
| | | if(editStatus.contains("'")){ |
| | | throw new ApplicationException(id+"-editStatus参数值["+editStatus+"】不能存在单引号"); |
| | | } |
| | | } |
| | | boolean oneRec = GridUtils.prossRowSetDataType_Boolean(map, "return_one_record");//是否返回到单记录 |
| | | boolean onlyOne = GridUtils.prossRowSetDataType_Boolean(map, "onlyOne");//只返回单条记录 |
| | | String sqlScript = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "SqlScript"));// 控件sql |
| | |
| | | } |
| | | } |
| | | |
| | | if (dto.order == 1 && "".equalsIgnoreCase(dto.orderFiled)) {//排序字段 |
| | | if (dto.order == 1) {//排序字段 |
| | | String sybmol=""; |
| | | if(org.apache.commons.lang3.StringUtils.isNotBlank(dto.orderFiled)){ |
| | | sybmol=","; |
| | | } |
| | | if (id.equalsIgnoreCase("doccode")) { |
| | | dto.orderFiled = id + " desc"; |
| | | dto.orderFiled += sybmol+id + " desc"; |
| | | } |
| | | if (id.equalsIgnoreCase("docdate")) { |
| | | dto.orderFiled = dto.orderFiled.length() == 0 ? id + " desc" : "," + id + " desc"; |
| | | dto.orderFiled += sybmol + id + " desc"; |
| | | } |
| | | } else if (dto.order == 2 && "".equalsIgnoreCase(dto.orderFiled)) { |
| | | if (id.equalsIgnoreCase("docitem")) |
| | |
| | | //控件类型 |
| | | String typeName = Control.getTypeName(type == 0 ? 1 : type, typeInfo, id, displayformat, dto.winType); |
| | | StringBuilder sb = new StringBuilder(); |
| | | if (type == 9 || type == 40) { |
| | | if (type == 9 || type == 40 || type == 19) { |
| | | if (dto.picFild != null && dto.picFild != "") { |
| | | if (!dto.picFild.contains(id + ";")) |
| | | dto.picFild += id.toLowerCase() + ";";//保存是哪一个字段是图片字段 |
| | |
| | | dto.picFild += id.toLowerCase() + ";";//用来保存是哪一个字段是图片字段 |
| | | } |
| | | sb.append(" CanFocus='0' ");//图片不需要取得焦点,避免在进入编辑状态时上传图片,返回不显示的问题 |
| | | sb.append(" ImgType='" + type + "' ");//区分是9,还是19 |
| | | sb.append(" showType='" + (type == 9 ? 0 : 2) + "' ");//以后增加格线支持多附件显示需要用到,区别出到时应该取哪一个附件表(_sys_Attachment9,_sys_Attachment)的数据 |
| | | } |
| | | if (type == 2 || type == 35 || type == 31 || type == 43 || type == 30 || type == 32|| type == 46) { |
| | |
| | | } else if (type == 1 || type == 0 || type == 7) { |
| | | sb.append(uppercase ? " uppercase='" + uppercase + "'" : ""); |
| | | |
| | | } else if (type == 9) {//图片控件 |
| | | } else if (type == 9 || type == 19) {//图片控件 |
| | | sb.append(" Button='/images/d.jpg' WidthPad='20' "); |
| | | dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
| | | }else if (type == 46) {//颜色控件 |
| | | } else if (type == 46) {//颜色控件 |
| | | sb.append(" colType='46' "); |
| | | dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
| | | }else if (type == 47) {//进度条控件 |
| | | } else if (type == 47) {//进度条控件 |
| | | sb.append(" colType='47' "); |
| | | dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
| | | } else if (type == 48) {//css样式选择器 |
| | | sb.append(" CanEmpty='0' Button='/images/ppp.gif' WidthPad='20' colType='48' "); |
| | | dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
| | | } |
| | | if (type != 2 && type != 31) {//下拉类型的不需要显示 |
| | |
| | | |
| | | } |
| | | //while(dto.gfields.next()); |
| | | if ("".equalsIgnoreCase(dto.orderFiled)) dto.orderFiled = firstID + " desc"; |
| | | if ("".equalsIgnoreCase(dto.primeKey)) dto.orderFiled = firstID + " desc"; |
| | | dto.expr = valExp.length() > 0 ? valExp.substring(0, valExp.length() - 1) : ""; |
| | | dto.cspr = cssExp.length() > 0 ? cssExp.substring(0, cssExp.length() - 1) : ""; |
| | | dto.tipspr = tipsExp.length() > 0 ? tipsExp.substring(0, tipsExp.length() - 1) : ""; |
| | |
| | | } else if (dto.order == 2 && dto.index2 != null && !dto.index2.isEmpty()) {//明细表 |
| | | temp = setSqlOrderBy(dto.index2, " asc"); |
| | | } else { |
| | | if (dto.field.isEmpty()) |
| | | if (!dto.orderFiled.isEmpty()) { |
| | | temp = dto.orderFiled; |
| | | else { |
| | | //处理8类型第三表的排序不是默认的docitm的情况,也就是9801定义有排序 |
| | | if (dto.winType == 15 && dto.order == 2 && org.apache.commons.lang3.StringUtils.isNotBlank(dto.index1)) { |
| | | temp = setSqlOrderBy(dto.index1, " asc"); |
| | | } else { |
| | | temp = setSqlOrderBy(dto.field, dto.order == 1 ? " desc" : " asc"); |
| | | } else { |
| | | if (dto.field.isEmpty()) { |
| | | temp = dto.orderFiled; |
| | | }else { |
| | | //处理8类型第三表的排序不是默认的docitm的情况,也就是9801定义有排序 |
| | | if (dto.winType == 15 && dto.order == 2 && dto.conNum == 2 && org.apache.commons.lang3.StringUtils.isNotBlank(dto.index1)) { |
| | | temp = setSqlOrderBy(dto.index1, " asc"); |
| | | } else { |
| | | temp = setSqlOrderBy(dto.field, dto.order == 1 ? " desc" : " asc"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | * @see com.yc.action.grid.TreeGridIfc#createGrid(int, int, java.lang.String, java.lang.String, java.lang.String[]) |
| | | */ |
| | | @Override |
| | | public void createGrid(int type, int formID, String root, String path, String fileName[], String tempPath, String pst, TMuiDTO dt, String dbid) throws DataAccessException, SQLException { |
| | | public void createGrid(int type, int formID, String root, String path, String fileName[], String tempPath, String pst, TMuiDTO dt, String dbid,String userCode,boolean isCustomLayout) throws DataAccessException, SQLException { |
| | | try { |
| | | StringBuilder sb = new StringBuilder();//总的js |
| | | StringBuilder jsp = new StringBuilder();//总的jsp |
| | |
| | | dto.winType = type; |
| | | dto.othType = 0; |
| | | dto.dbid = dbid; |
| | | dto.userCode=userCode; |
| | | dto.hasControlLayout=isCustomLayout; |
| | | if (dt != null) {//把多表的值传过来填充 |
| | | this.setTabPage497(dt.type, dt.height1, dt.indexs, dt.tolkey, dt.fromid, dt.index, dto); |
| | | this.setXxk(dt.xxk, dto); |
| | |
| | | dto.treefield = this.getTreeFields(formID, dto.dbid); |
| | | } |
| | | String str = FileUtil.readFile(tempPath + "/grid.jsp");//页面模板 |
| | | if(dto.b497){ |
| | | //多表页面不需要这个,因为页面是用静态包含,其他用动态包含<jsp:include page="......" /> |
| | | str=str.replace("<%@ include file=\"dataHead.jsp\" %>",""); |
| | | } |
| | | if (dto.muilGrid && i == 0) jsp.append(str).append("\n"); //先保存好模板,以便生成多表时候用 |
| | | dto.conNum = i; |
| | | dto.order = setOrderName(dto); |
| | | dto.orderFiled="";//还原到初始状态 |
| | | this.print(root, dto); |
| | | String strJs = FileUtil.readFile(tempPath + (((dto.gantt && dto.order == 2) || (dto.gantt && dto.winType == 18)) ? "/grid_Gantt.js" : "/grid.js"));//页面js |
| | | String[] ver = dto.verNo.split("/"); |
| | |
| | | .replaceAll("@lang", ver[ver.length - 1])//语言 |
| | | .replaceAll("@foot2", this.replaceBlank(dto.foot2)) |
| | | .replaceAll("@_ycaddnew_@", this.setToolAddForNew(dto))//当前用户是否存在OA审核按钮,其中有为1的则格线需要显示增行按钮 |
| | | .replaceAll("@_isCustomLayout_@", dto.hasControlLayout?(true+""):(false+""))//当前用户是否存在OA审核按钮,其中有为1的则格线需要显示增行按钮 |
| | | //.replaceAll("@_attachment_server_@", domain==null?"":domain)//附件服务器地址 |
| | | .replaceAll("@picFild", this.replaceBlank("&picFild=" + dto.picFild)) |
| | | .replaceAll("@TBCols", "&tbCols=" + EncodeUtil.base64Encode(this.replaceBlank(dto.totalCols)))//统计列 |
| | |
| | | .replaceAll("@layout", this.setJsName(dto))//js文件名称 |
| | | .replaceAll("@hasGrid", hasGrid)//js文件名称 |
| | | .replaceAll("@isTree", (dto.mainCol == null || "".equalsIgnoreCase(dto.mainCol)) ? "" : "&isTree=1") |
| | | .replaceAll("@winType", dto.winType + "@p@" + i)//表的顺序 0表示读取主表 1表示读取从表 |
| | | .replaceAll("@winType", dto.winType + "@p@" + (dto.winType==19?1:i))//表的顺序 0表示读取主表 1表示读取从表,19类型特定为1 |
| | | .replaceAll("@id", dto.formID + "")//功能号 |
| | | .replaceAll("@DealAfterDocSave", ddsave)//保存时执行 |
| | | .replaceAll("@CancelProc", "&cancelProc=" + this.replaceBlank(EncodeUtil.base64Encode(dto.cancelProc)) + "&cancelisSave=" + dto.cancelisSave + "&isExchangeDataWithHost=" + dto.isExchangeDataWithHost)//取消确认 |
| | |
| | | .replaceAll("@suggstDiv", dto.sugList.toString())//自动补全 |
| | | .replaceAll("@gridconnum", String.valueOf(dto.conNum));//判断单表用来计算grid高度需要。。。替换grid.jsp里面的@gridconnum |
| | | FileUtil.writeFile(js, root.replaceAll("\\\\", "/") + File.separatorChar + this.setFilePath(path.replaceAll("\\\\", "/"), this.setJsName(dto), pst, dto));//生成新页面js |
| | | FileUtil.writeFile(str, root.replaceAll("\\\\", "/") + File.separatorChar + this.setFilePath(path.replaceAll("\\\\", "/"), fileName[0], pst, dto));//生成新页面 |
| | | FileUtil.writeFile(str, root.replaceAll("\\\\", "/") + File.separatorChar + this.setFilePath(path.replaceAll("\\\\", "/"), this.setFileName(dto), pst, dto));//生成新页面 |
| | | } else {//多表,整个页面生成多个表格 |
| | | if (refgrid != "") refgrid += ","; |
| | | refgrid += ("T_" + dto.formID);//为了引用其它grid,3表 |
| | |
| | | .replaceAll("@head", hd.toString())//自定义表头 |
| | | .replaceAll("@suggstDiv", dto.sugList.toString())//自动补全 |
| | | .replaceAll("@gridconnum", String.valueOf(dto.conNum));//判断多表用来计算grid高度需要。。。替换grid.jsp里面的@gridconnum |
| | | FileUtil.writeFile(strd, root.replaceAll("\\\\", "/") + this.setFilePath(path.replaceAll("\\\\", "/"), fileName[0], pst, dto));//生成新页面 |
| | | FileUtil.writeFile(strd, root.replaceAll("\\\\", "/") + this.setFilePath(path.replaceAll("\\\\", "/"), this.setFileName(dto), pst, dto));//生成新页面 |
| | | } |
| | | sb = null; |
| | | jsp = null; |