/* * 生成1类型窗体文件,生成路径已系统菜单为准,文件为formID_file.jsp为准。 xiangluan 2010-04-16 */ package com.yc.service.build.type; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.yc.api.bean.T9685Entity; import com.yc.api.service.ApiServiceIfc; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.stereotype.Service; import com.yc.action.grid.TMuiDTO; import com.yc.service.build.top.BuildTopIfc; import com.yc.service.commons.GformIfc; import com.yc.service.impl.DBHelper; import com.yc.service.panel.PanelServiceIfc; import com.yc.service.panel.SqlDBHelperIfc; import com.yc.service.panel.SystemSettingsDao; @Service("T_498_impl") @Scope("prototype") public class T_498_Impl extends BaseImpl implements T_498_Ifc { // 通过功能号活动分组id SQL private static final String GET_GROUP_ID = " set nocount on ; select groupid from _sys_TabPageGroupID where mainformid=?"; // 通过分组id获得属于该分组的页框id private static final String GET_FORMGROUP_ID = " set nocount on ; select formgroupid from _sys_TabPageFormGroup where mainformid=?"; // 通过页框id获得明细设置 private static final String GET_TABPAGE_DETAIL = " set nocount on ; select groupid,groupname,formgroupid,formgroupname,sortby,formid,formname,formtype,labelname,fk,seekgroupid,gridheight from _sys_tabpageformid where formgroupid=? and mainformid=?"; // 表单页框tabPage分组 private static final String GET_TAB_PAGE = " set nocount on ; select formgroupid,formgroupname from _sys_TabPageFormGroup where groupid=(select groupid from _sys_TabPageGroupID where mainformid=?)"; // 查找当前页有多少个表格 // private static final String GET_TABPAGE_DETAIL_COUNT = "select count(*) from _sys_tabpageformid where formgroupid=? and groupid=? and formtype=1"; @Autowired private GformIfc gformIfc; @Autowired private BuildTopIfc buildTopIfc; @Autowired private PanelServiceIfc pIfc; @Autowired private SystemSettingsDao systemSettingsDao; @Autowired SqlDBHelperIfc sqlDBHelperIfc; @Autowired private ApiServiceIfc apiServiceIfc; String doc = "";// 关联字段 /* * 生成文件 */ @Override public synchronized int build() throws Exception { Map gformInfo = gformIfc.getGformInfo("predocstatus,formname,showdetail,isopenFuncshowpwdedit," + "isshowpwdedit,isShowOnlineMsg,isShowProcessTracking,optype,HDTable,version,isShowNewDocButton ", Integer.parseInt(formID)); buildJsCssHead(gformInfo); buildTop(gformInfo); buildHelpPage(gformInfo); buildFoolter(); buildIndex(gformInfo); buildDataHead(gformInfo); return 0; } /** * 生成jsp数据处理头页面 * * @throws Exception */ public void buildDataHead(Map gformInfo) throws Exception { String fileName = "dataHead.jsp"; String tmpJsp = getPageCode(fileName); tmpJsp = tmpJsp.replace("[?formId]", formID); tmpJsp = tmpJsp.replace("[?formType]", type + ""); // tmpJsp = // tmpJsp.replace("[?isShowPwdEdit]",toString(map.get("isshowpwdedit")));//1类型没有确认 tmpJsp = tmpJsp.replace("[?isOpenFuncShowPwdEdit]", toString(gformInfo.get("isopenFuncshowpwdedit"))); tmpJsp = tmpJsp.replace("[?version]",("".equalsIgnoreCase(toString(gformInfo.get("version")))?"0":toString(gformInfo.get("version")))); //--操作类型 if(gformInfo.get("optype")!=null&&!StringUtils.isBlank(gformInfo.get("optype").toString())){ tmpJsp = tmpJsp.replace("[?formOptType]", gformInfo.get("optype").toString().equalsIgnoreCase("0")?"-1":gformInfo.get("optype").toString()); }else{ tmpJsp = tmpJsp.replace("[?formOptType]","-1"); } tmpJsp = replaceGform(tmpJsp); tmpJsp = tmpJsp.replaceAll("@doc", doc); buildPageCode(tmpJsp, fileName); } /** * 生成js css 导入的页面 * * @throws Exception */ public void buildJsCssHead(Map gformInfo) throws Exception { String fileName = "jsCssHead.jsp"; String data = getPageCode(fileName); // ---------------- List> listS = null; listS = systemSettingsDao.getListIn(Integer.valueOf(formID), 9303); String companyId = ""; if (listS == null || listS.size() < 1) { throw new Exception("凭证定义未定义" + formID + "功能号"); } else { companyId = listS.get(0).get("periodorgfield").toLowerCase(); if (companyId.trim().equals("")) { throw new Exception("凭证定义未定义" + formID + "功能号的期间组织代码"); } } data = data.replaceAll("@CustomDoccode@", this.getValue(listS.get(0), "customdoccode")); data = data.replace("#periodtype#", listS.get(0).get("periodtype")); data = data.replace("#comanyId#", companyId); String sql = " set nocount on ; select predocstatus,procgroupaftersavedoc,dealafterdocsave,transgroupcode from gform where formid=" + formID; listS = sqlDBHelperIfc.getHashMap(sql); data = data.replaceAll("#predocstatus#", getValueInt(listS.get(0), "predocstatus")); data = data.replace("[?predocstatus]", gformInfo.get("predocstatus") + ""); data = data.replace("[?isShowOnlineMsg]", gformInfo.get("isShowOnlineMsg") + ""); data = data.replace("[?isShowProcessTracking]", gformInfo.get("isShowProcessTracking") + ""); buildPageCode(data, fileName); } /** * 生成top页面 * * @throws Exception */ public void buildTop(Map gformInfo) throws Exception { buildTopIfc.build(Integer.parseInt(formID), type, getBuildPath() + "top.jsp", getToPath() + "top.jsp", gformInfo,this); } /** * 生成帮助页面 * * @throws Exception */ public void buildHelpPage(Map gformInfo) throws Exception { buildTopIfc.build(Integer.parseInt(formID), type, getTemPath() + "help.jsp", getToPath() + "help.jsp", gformInfo,this); } /** * 生成foolter页面(资源释放页) * * @throws Exception */ public void buildFoolter() throws Exception { String fileName = "foolter.jsp"; String data = getPageCode(fileName); // ---------------- buildPageCode(data, fileName); } /** * 获得分组id * * @param mainFormid * @return 分组id * @throws Exception */ public int getGroupIdByMainFormid(String mainFormid) throws Exception { try { Integer in= this.jdbcTemplate.queryForObject(GET_GROUP_ID,Integer.class, new Object[] {mainFormid}); return in==null?0:in; } catch (RuntimeException e) { throw new Exception(mainFormid + "在 表单页框tabPage分组 设置有误!"); } } /** * 通过分组id获得相关的页框id * * @param groupId * @return * @throws Exception */ public int[] getFormGroupIds() throws Exception { SqlRowSet rs = this.jdbcTemplate.queryForRowSet(GET_FORMGROUP_ID, this.formID); List list = new ArrayList(); while (rs.next()) { list.add(rs.getInt(1)); } if (list.size() < 0) { throw new RuntimeException("在 表单页框tabPage分组--页框 没有找到分组ID:" + this.formID + " 的相关数据!"); } int[] temp = new int[list.size()]; for (int i = 0; i < list.size(); i++) { temp[i] = list.get(i); } list = null; return temp; } /** * 通过分组id+页框id获得明细设置 * * @param groupid * @param formGroupId * @return */ public List> getTabPageDetail(int formGroupId) { return this.jdbcTemplate.queryForList(GET_TABPAGE_DETAIL, formGroupId, this.formID); } /** * 通过分组mainFormid 获得最终的 明细设置 * * @param mainFormid * @return Map<页框id,List<(map明细设置)> * @throws Exception */ public Map>> getTabPages(String mainFormid) throws Exception { int[] formGroupIds = getFormGroupIds(); Map>> info = new HashMap>>(); for (int fgid : formGroupIds) { info.put(fgid + "", getTabPageDetail(fgid)); } return info; } /** * 生成主页面 * * @throws Exception */ public void buildIndex(Map gformInfo) throws Exception { String fileName = "index.jsp"; String data = getPageCode(fileName); // --------从gform表获取是否显示大标题字段值(isTitle)判断是否显示大标题,并替换标识符-2012-02-20-syz--------[begin]---------------------- if (true) { String sSQL = " set nocount on ; select * from gform where formid='" + formID + "' and isTitle='1' ";// isTitle=1表示配置了显示大标题 List> arrayList = new ArrayList>(); arrayList = getArrayList(sSQL); if (arrayList.size() > 0) {// 如果配置了显示大标题 String TopAndTitle_str = "\n" + "\n" + "\n" // + "\n" + "\n" + "\n" + "\n" + "
\n" + "
[?title]
\n" + "
\n" + "
\n" // + "
\n" + "
\n" + "\t\t\t<%@ include file=\"top.jsp\" %>\n" + "\t\t
\n" + "
\n"; data = data.replace("[?TopAndTitle]", TopAndTitle_str);// 替换功能号标识符 } else {// 如果没有配置显示大标题 String TopAndTitle_str = "
\n" + "\t\t\t<%@ include file=\"top.jsp\" %>\n"; data = data.replace("[?TopAndTitle]", TopAndTitle_str);// 替换功能号标识符 } } // --------从gform表获取是否显示大标题字段值(isTitle)判断是否显示大标题,并替换标识符-2012-02-20-syz-----[end]-------------------------// // ---------------- Map endCreate = new HashMap();// 延长生成文件 String inc = ""; String jspName = ""; String indexInc = ""; String inPan = ""; String indexInc2 = ""; try { Map>> sheMap = this.getTabPages(formID); String[] data1 = null; List> mapList = null; int panNo = 0; for (String no : sheMap.keySet()) { mapList = sheMap.get(no); inc = ""; jspName = ""; indexInc = ""; inPan = ""; panNo = 0; int height1 = 0; int index = 0; for (Map map : mapList) { if (doc == "") doc = DBHelper.getValue(map, "SeekGroupID");// 取得第一个功能号的关联字段 switch (DBHelper.getValueInt(map, "formtype")) {// 功能号类型 case 1:// 表格 // 生成关联关系 if (index == 0) indexInc = "
" + DBHelper.getValue(map, "LabelName") + "
"; else indexInc = ""; jspName = DBHelper.getValueInt(map, "formid") + "_grid.jsp"; String indexs[] = this.getPrIndex(DBHelper.getValue(map, "formid"), mapList, "1"); height1 = DBHelper.getValueInt(map, "gridheight"); if (height1 == 0) height1 = treeGrid.getGrigHieght(DBHelper.getValueInt(map, "formid"), DBHelper.getValueInt(map, "formtype"),this.dataBaseId); height1 = (height1 <= 0) ? 320 : height1 + 20; TMuiDTO dto=new TMuiDTO(); if (index == 0 || indexs[0] != "") { dto.type=this.type; dto.height1=height1; dto.indexs=indexs[0]; dto.tolkey=indexs[1]; dto.fromid=Integer.parseInt(formID); dto.index=0; //treeGrid.setTabPage497(this.type, height1, indexs[0], indexs[1], Integer.parseInt(formID), 0); } else { dto.type=1; dto.height1=height1; dto.indexs=""; dto.tolkey=""; dto.fromid=0; dto.index=index; //treeGrid.setTabPage497(1, height1, "", "", 0, index); } dto.addnew=true;//表示需要生成处理+号的按钮代码 treeGrid.createGrid(DBHelper.getValueInt(map, "formtype"), DBHelper.getValueInt(map, "formid"), URI, "app/" + gPath, new String[] { jspName }, getTemPath(), "/" + this.formID + "/" + this.type + "/", dto,this.dataBaseId); height1 = (height1 <= 0) ? 320 : height1 + 20; index++; indexInc += "<%@ include file=\"" + jspName + "\" %>" + getPanFile(DBHelper.getValueInt(map, "formid")); inc += indexInc; break; case 16: indexInc = "
" + DBHelper.getValue(map, "LabelName") + "
"; data1 = new String[2]; data1[0] = FileUtils.readFileToString(new File(getBuildPath() + "panel.jsp"), "utf-8"); data1[1] = FileUtils.readFileToString(new File(getTemPath() + "panelControl.jsp"), "utf-8"); // ---------------- pIfc.setIndexPan(panNo); Map mapIf = pIfc.getPanelHtml(DBHelper.getValueInt(map, "formid"), DBHelper.getValueInt(map, "formtype"), data1, this); if (Integer.parseInt(formID) == DBHelper.getValueInt(map, "formid")) { endCreate.put("panel.jsp", mapIf.get("panHTML").replace("@isMaster@","true")); buildPageCode(mapIf.get("panelControl"), "panelControl" + formID + ".jsp"); indexInc += "<%@ include file=\"panel.jsp\" %>"; inPan = indexInc; } else {// 这里需要处理 jspName = DBHelper.getValueInt(map, "formid") + "_panel.jsp"; buildPageCode(mapIf.get("panHTML").replace("@include@", "").replace("@isMaster@","false"), jspName); buildPageCode(mapIf.get("panelControl"), "panelControl" + formID + ".jsp"); indexInc += "<%@ include file=\"" + jspName + "\" %>" + getPanFile(DBHelper.getValueInt(map, "formid")); inc += indexInc; } pIfc.setIndexPan(0); panNo++; break; } } if (endCreate.get("panel.jsp") != null) { indexInc = inPan; buildPageCode(endCreate.get("panel.jsp").replace("@include@", inc), "panel.jsp"); } else { indexInc = inc; } indexInc2 += "<%if(fl.equals(\"" + no + "\")){%>" + indexInc + "<%}%>"; } } catch (Exception e) { e.printStackTrace(); } //-------------文字颜色说明---------xin 2022-5-18 16:09:54-----------// StringBuilder colorText =new StringBuilder();//文字颜色说明 if(StringUtils.isNotBlank(formID)) { List colorList = apiServiceIfc.get9685List(Integer.parseInt(formID)); if (colorList != null && colorList.size() > 0) { colorText.append("
"); colorText.append("
文字颜色说明
"); colorText.append("
"); for (T9685Entity t : colorList) { colorText.append("
" + "" + t.getColorName() + "
"); } colorText.append("
"); } } //文字颜色说明 xin 2022-5-18 15:53:13 data = data.replace("[?ColorDescription]",colorText); data = data.replace("[?title]", gformInfo.get("formname") + ""); data = data.replace("@panFou@", indexInc2); String tabPage = tabPageCode(formID); data = data.replace("[?tabPageLength]", getTabPage(formID).size() + ""); data = data.replace("[?tabPage]", tabPage); buildPageCode(data, fileName); } /** * 表单页框tabPage分组 * * @param formid * @return */ public List> getTabPage(String formid) { return this.jdbcTemplate.queryForList(GET_TAB_PAGE, formid); } public String tabPageCode(String formid) { List> list = getTabPage(formID); StringBuilder sb = new StringBuilder(); for (Map map : list) { sb.append("").append(map.get("formgroupname")).append(""); } list = null; return sb.toString(); } /** * 添加需显示字段 * * @param formId 某功能号后 * @return String */ private String getPanFile(int formId) { StringBuffer sBuffer = new StringBuffer(); sBuffer.append("\r\n
"); return sBuffer.toString(); } }