xinyb
2022-05-18 c2dc593c9b8948718381f3a2996b6f94a59ad80a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
 * 生成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.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.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;
 
 
@Service("T_77_impl")
@Scope("prototype")
public class T_77_Impl extends BaseImpl implements T_77_Ifc {
    // 通过功能号id获得明细设置
    private static final String GET_TABPAGE_DETAIL = " set nocount on ; select * from _sys_tabpageformid where  mainformid=? order by sortby asc";
    @Autowired
    private GformIfc gformIfc;
    @Autowired
    private BuildTopIfc buildTopIfc;
    @Autowired
    private PanelServiceIfc pIfc;
    @Autowired
    SqlDBHelperIfc sqlDBHelperIfc;
    @Autowired
    private ApiServiceIfc apiServiceIfc;
    String doc="";//关联字段
    /*
     * 生成文件
     */
    @Override
    public synchronized int build() throws Exception {
        Map<String, Object> gformInfo = gformIfc.getGformInfo("predocstatus,formname,showdetail,isopenFuncshowpwdedit,isshowpwdedit,optype,HDTable", Integer.parseInt(formID));
        buildJsCssHead(gformInfo);
        buildTop(gformInfo);
        buildHelpPage(gformInfo);
        buildFoolter();
        buildIndex(gformInfo);
        buildDataHead(gformInfo);
        return 0;
    }
    /**
     * 生成jsp数据处理头页面
     * @throws Exception 
     */
    public void buildDataHead(Map<String,Object> 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")));
        //--操作类型
        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<String,Object> gformInfo) throws Exception{
        String fileName = "jsCssHead.jsp";
        String data = getPageCode(fileName);
        // ----------------
 
        buildPageCode(data, fileName);
    }
    /**
     * 生成top页面
     * @throws Exception 
     */
    public void buildTop(Map<String,Object> gformInfo) throws Exception{
        buildTopIfc.build(Integer.parseInt(formID), type,getBuildPath()+"top.jsp",getToPath()+"top.jsp",gformInfo,this);
    }
    /**
     * 生成帮助页面
     * @throws Exception 
     */
    public void buildHelpPage(Map<String,Object> 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+页框id获得明细设置
         * 
         * @param groupid
         * @param formGroupId
         * @return
         */
        public List<Map<String, Object>> getTabPageDetail(
            String formGroupId) {
        return this.jdbcTemplate.queryForList(GET_TABPAGE_DETAIL,
            formGroupId);
        } 
    /**
     * 生成主页面
     * @throws Exception 
     */
    public void buildIndex(Map<String,Object> gformInfo) throws Exception{
        String fileName = "index.jsp";
        String data = getPageCode(fileName);
        //--------从gform表获取是否显示大标题字段值(isTitle)判断是否显示大标题,并替换标识符-2012-02-20-syz--------[begin]----------------------
                if(true)
                {
                    //String menuname_str="";
                    String sSQL=" set nocount on ; select * from gform where formid='"+formID+"' and isTitle='1' ";//isTitle=1表示配置了显示大标题
                    List<Map<String,Object>> arrayList = new ArrayList<Map<String,Object>>();
                    arrayList=getArrayList(sSQL);
                    if(arrayList.size()>0)
                    {//如果配置了显示大标题
                        String TopAndTitle_str=
                                "<table id=\"top_table\" width=\"100%\" bgcolor=\"#DEEDF7\">\n" +
                                        "<tr>\n" + 
                                        "<td>\n" + 
                                        "<div id=\"title_top\">[?title]</div>\n" + 
                                        "</td></tr>\n" + 
//                                        "<tr>\n" +
//                                        "<td>\n" +
//                                        "<hr style=\"position: absolute;left:0px;top:28px;height: 1px;color: #bdc7c6;width: 99%;\">\n" +
//                                        "</td>\n" +
//                                        "</tr>\n" +
                                        "<tr><td>\n" + 
                                        "<div id=\"tplt-top\">\n" + 
                                        "\t\t\t<%@ include file=\"top.jsp\" %>\n" + 
                                        "\t\t</div>\n" + 
                                        "</td></tr>\n" + 
                                        "</table>\n";
                        data=data.replace("[?TopAndTitle]", TopAndTitle_str);//替换功能号标识符
                    }else
                    {//如果没有配置显示大标题
                        String TopAndTitle_str=
                                "<div id=\"tplt-top\">\n" +
                                        "\t\t\t<%@ include file=\"top.jsp\" %>\n";
                        data=data.replace("[?TopAndTitle]", TopAndTitle_str);//替换功能号标识符
                    }
                }
                //--------从gform表获取是否显示大标题字段值(isTitle)判断是否显示大标题,并替换标识符-2012-02-20-syz-----[end]-------------------------//
                
        //----------------
//        String jspName="";
        String indexInc="";
        int panNo=0;
        String panNoStr="";
        try{
          List<Map<String, Object>> sheMap = this.getTabPageDetail(formID);
        String[] data1=null;
         String fileName1=null;
         int formid_Pan=0;
         int formtype_Pan=0;
            int height1=0;
            int index=0;
        for (Map<String, Object> map : sheMap) {
            indexInc+="<div style=\"font-family:黑体;\">"+DBHelper.getValue(map, "LabelName")+"</div>";
            if(doc=="") doc=DBHelper.getValue(map, "SeekGroupID");//取得第一个功能号的关联字段
            formid_Pan=DBHelper.getValueInt(map, "formid");
            formtype_Pan=DBHelper.getValueInt(map, "formtype");
            switch (formtype_Pan) {// 功能号类型        
            case 7:
                    fileName1 = "panel_"+formid_Pan+".jsp";
                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);
                panNoStr=(panNo!=0)?String.valueOf(panNo):"";
                Map<String, String> map1 = pIfc.getPanelHtml(formid_Pan,type, data1, this);
                buildPageCode(map1.get("panHTML").replaceAll("@panelNo@", panNoStr), fileName1);
                buildPageCode(map1.get("panelControl"), "panelControl"+formID+".jsp");
                indexInc+="<%@ include file=\""+fileName1+"\" %>";
                pIfc.setIndexPan(0);
                //--------grid
//                 jspName=DBHelper.getValueInt(map, "formid")+"_grid.jsp";
                String indexs[]=this.getPrIndex(DBHelper.getValue(map, "formid"), sheMap,"7");
                height1 = DBHelper.getValueInt(map, "gridheight");
                if (height1 == 0)
                height1 = treeGrid.getGrigHieght(DBHelper
                    .getValueInt(map, "formid"), DBHelper
                    .getValueInt(map, "formtype"),this.dataBaseId);
 
                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=7;
                    dto.height1=height1;
                    dto.indexs="";
                    dto.tolkey="";
                    dto.fromid=0;
                    dto.index=index;
                    //treeGrid.setTabPage497(7, height1, "","",0,index);
                }
                treeGrid.createGrid(7,formid_Pan, URI, "app/" + gPath+"/", new String[]{formid_Pan+"_grid.jsp"}, getTemPath(), "/"+this.formID+"/"+this.type+"/", dto,this.dataBaseId);
                //height1 = (height1 <= 0) ? 320 : height1 + 20;
                index++;
                //--------end
                panNo++;
                break;
            }
        }
            }catch(Exception e){
                e.printStackTrace();
            }
 
        //-------------文字颜色说明---------xin 2022-5-18 16:09:54-----------//
        StringBuilder colorText =new StringBuilder();//文字颜色说明
        if(StringUtils.isNotBlank(formID)) {
            List<T9685Entity> colorList = apiServiceIfc.get9685List(Integer.parseInt(formID));
            if (colorList != null && colorList.size() > 0) {
                colorText.append("文字颜色说明");
                for (T9685Entity t : colorList) {
                    colorText.append("<div><span title=\"" + t.getItemMemo() + "\" class=\"spanColor\" " +
                            "style=\"background-color: " + t.getHexColor() + "\"></span>" +
                            "<span style=\"color: " + t.getHexColor() + "\">" +
                            t.getColorName() + "</span></div>");
                }
            }
        }
        //文字颜色说明 xin 2022-5-18 15:53:13
        data = data.replace("[?ColorDescription]",colorText);
        data = data.replace("[?title]", gformInfo.get("formname")+"");
        data = data.replace("@panFou@",indexInc);
        buildPageCode(data, fileName);
    }
}