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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
package com.yc.service.build.type.v2;
 
import com.yc.action.grid.GridUtils;
import com.yc.action.grid.TreeGridIfc;
import com.yc.service.BaseService;
import com.yc.service.build.BuildFuncIfc;
import com.yc.service.build.top.v2.BuildTopIfc;
import com.yc.service.commons.GformIfc;
import com.yc.service.impl.DBHelper;
import com.yc.service.panel.v2.PanelServiceIfc;
import com.yc.utils.HtmlUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.support.rowset.SqlRowSet;
import org.springframework.stereotype.Service;
 
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
/*
 * 窗体类型生成基类V2
 * by danaus 2020/2/13 17:47
 */
@Service("VbaseImpl")
public class BaseImpl extends BaseService implements BaseIfc {
    @Autowired
    protected BuildFuncIfc BFI;
    @Autowired
    protected TreeGridIfc treeGrid;
    @Autowired
    protected GformIfc gformIfc;
    @Autowired
    private BuildTopIfc buildTopIfc;
 
    @Autowired
    protected PanelServiceIfc pIfc;
 
    public static String BEAN_INFO = "beaninfo";
    private static String GFORM_SQL = " isTitle,formname,showdetail,isopenFuncshowpwdedit,isshowpwdedit,optype,HDTable,version,dataformid,formdatafilters,panellabellayout,CancelBtnProcName,CancelBtnExpression,CancelBtnEditStatus,CancelBtnName,RevokeBtnProcName,RevokeBtnExpression,RevokeBtnEditStatus,isShowOnlineMsg,isShowProcessTracking,autoOpen,predocstatus,procgroupaftersavedoc,dealafterdocsave,transgroupcode,dttable,isShowNewDocButton,isshowinserialbtn,inserialbtneditstatus,isshowoutserialbtn ,outserialbtneditstatus,isshowonlinepaymentbutton,isshowgridstyleforapp ";
    protected Map<String, Object> getGformInfo(String formid) {
        return gformIfc.getGformInfo(GFORM_SQL, Integer.parseInt(formid));
    }
 
 
//    public String getTitle() {
//    return "【<%=session.getAttribute(\""+SessionKey.USERNAME+"\")%>】" + this.formName[0] + "-" + this.formID;
//    }
//
//    public String getTitle2() {// 针对5,8,16类型
//    return "【<%=session.getAttribute(\""+SessionKey.USERNAME+"\")%>】" + this.formName[1] + "-" + this.formID;
//    }
 
 
    // 查找哪些功能号把当前功能号作为主表使用
    // 格式:引用的功能号|外表的关联字段;当前表的关联字段,......
    protected String[] getPrIndex(String formid, List<Map<String, Object>> list, String type) {
        String ind = "";
        int index = 0;
        for (Map<String, Object> map : list) {
            if (type.equalsIgnoreCase((Integer) map.get("formtype") + "") && !formid.equalsIgnoreCase((Integer) map.get("formid") + "")) {
                index++;
                if (formid.equalsIgnoreCase((Integer) map.get("FT") + "")) {
                    ind += "T_" + map.get("formid") + "|" + ((((String) map.get("SeekGroupID")).split(";").length > 1) ? ((String) map.get("SeekGroupID")).split(";")[1] : "")
                            + ";" +
                            ((((String) map.get("FK")).split(";").length > 1) ? ((String) map.get("FK")).split(";")[1] : "")
                            + ",";
                }
            }
        }
        return new String[]{(ind != "" || !ind.isEmpty()) ? ind.substring(0, ind.length() - 1) : "", index + ""};
    }
 
    // 去除字符串中的换行符等
    public String replaceBlank(String str) {
        if (str == null) {
            return "";
        }
        Pattern p = Pattern.compile("\t|\r|\n");
        Matcher m = p.matcher(str);
        return m.replaceAll("");
    }
 
 
    @Override
    public int build(BaseBean baseBean) throws Exception {
        return 0;
    }
 
    protected Map<String, Object> init(BaseBean baseBean) {
        Map<String, Object> gformInfo = this.getGformInfo(baseBean.getFormID());
        gformInfo.put(BEAN_INFO, baseBean);//把传进去的参数值加到map,再传给各个方法调用,避免出现并发问题
        return gformInfo;
    }
 
    protected String getValue(Map<String, String> map, String col) {
        return (map.get(col) == null) ? "" : map.get(col).toString();
    }
 
    protected String getValueInt(Map<String, String> map, String col) {
        return (map.get(col) == null) ? "0" : map.get(col).toString();
    }
 
    protected String getToPath(BaseBean baseBean) {
        String path1 = "";
        try {
            path1 = baseBean.URI + File.separator + "app" + File.separator + BFI.getPath(baseBean.formID, baseBean.type, baseBean.versionId, baseBean.dataBaseId, baseBean.language) + File.separator;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return path1;
    }
 
 
    /**
     * 根据是否存在主功能号做相应的处理
     *
     * @return
     */
    private String getFormidCreate(BaseBean baseBean) {
        if (baseBean.mainformid != null)
            return baseBean.mainformid + "_" + baseBean.formID;
        else
            return baseBean.formID;
    }
 
    /**
     * 生成panel页面
     *
     * @throws Exception
     */
    public void buildPanel(Map<String,Object> gformInfo) throws Exception {
        BaseBean baseBean = (BaseBean) gformInfo.get(BEAN_INFO);
        String fileName = "panel.jsp";
        String[] data = new String[2];
        data[0] = FileUtils.readFileToString(new File(getBuildPath(baseBean) + fileName), "utf-8");
        data[1] = FileUtils.readFileToString(new File(getTemPath(baseBean) + "panelControl.jsp"), "utf-8");
        // ----------------
        Map<String, String> map = pIfc.getPanelHtml(Integer.parseInt(baseBean.formID), baseBean.type, data, gformInfo);
        buildPageCode(map.get("panHTML"), fileName, baseBean);
        buildPageCode(map.get("panelControl"), "panelControl" + baseBean.formID + ".jsp", baseBean);
        if(map!=null&&map.get("zhu")!=null){
            baseBean.zhu=map.get("zhu");
        }
    }
 
    /**
     * --生成功能号时,要检查单据表头必须的字段是否存在,如果不存在,则需要新增 xin 2022-3-14 09:28:17
     */
    public void getDoesItExist(Integer formId){
        try {
            String sql="--生成功能号时,要检查单据表头必须的字段是否存在,如果不存在,则需要新增\n" +
                    " --Author : Johns Wang,2022-03-11 \n"+
                    " set nocount on \n" +
                    " declare @tableName varchar(50) ,@formid int =" +formId+" \n"+
                    " declare @sql nvarchar(max) = ' set nocount on; '\n" +
                    " declare @fieldid varchar(50),@fieldtype varchar(50)\n" +
                    " declare @objName varchar(50) ,@createOrAlter varchar(50)\n" +
                    " declare @uploadFieldId varchar(2000),@formType int\n" +
                    " if isnull(@formid,0) = 0 \n" +
                    " begin \n" +
                    " raiserror('请传递@formid参数',16,1) \n" +
                    " return \n" +
                    " end \n" +
                    " select @formType = formType from _sysmenu a where a.formid = @formid \n" +
                    " if @@ROWCOUNT = 0 \n" +
                    " begin \n" +
                    " raiserror('请在9810功能号中为此功能号%d设置菜单',16,1,@formid) \n" +
                    " return \n" +
                    " end \n" +
                    " if @formtype not in (5,9,8,15,16,17,496,497,498,499) \n" +
                    " begin \n" +
                    " raiserror('请在9810功能号中为此功能号%d设置【窗体类型】,肯该字段值只能是【5,9,8,15,16,17,496,497,498,499】',16,1,@formid) \n" +
                    " return \n" +
                    " end \n" +
                    " select @tableName = a.hdtable \n" +
                    " from gform a \n" +
                    " join INFORMATION_SCHEMA.TABLES c on a.hdtable = c.TABLE_NAME \n" +
                    " where a.formid = @formid \n" +
                    " and c.TABLE_TYPE = 'BASE TABLE' \n" +
                    " and isnull(a.hdtable,'') <> '' \n" +
                    " if @@ROWCOUNT = 0 or isnull(@tableName,'') = ''  return \n" +
                    " declare mycurFieldType cursor for \n" +
                    " select fieldid,fieldtype \n" +
                    " from _sys_DocTableExistsField where TableType = '单据主表' \n" +
                    " order by num asc \n" +
                    " open mycurFieldType \n" +
                    " fetch next from mycurFieldType into @fieldid,@fieldtype \n" +
                    " while @@FETCH_STATUS  = 0 \n" +
                    " begin \n" +
                    " if not exists(select 1 from INFORMATION_SCHEMA.COLUMNS a where a.TABLE_NAME = isnull(@tableName,'') and a.COLUMN_NAME = isnull(@fieldid,'')) \n" +
                    " begin \n" +
                    " set @sql = isnull(@sql,'') + ' alter table ' + isnull(@tableName,'') + ' add ' + isnull(@fieldid,'') + ' ' + isnull(@fieldtype,'') +'; ' \n" +
                    " end \n" +
                    " fetch next from mycurFieldType into @fieldid,@fieldtype\n" +
                    " end \n" +
                    " close mycurFieldType\n" +
                    " deallocate mycurFieldType \n" +
                    " if isnull(@sql,'') <> ''\n" +
                    " begin\n" +
                    " exec(@sql)\n" +
                    " end \n" +
                    " set @sql = ' set nocount on; declare @StatisID int ; ' +char(13)+\n" +
                    " ' if not exists(select 1 from INFORMATION_SCHEMA.COLUMNS a where a.TABLE_NAME = ''' + isnull(@tableName,'') + ''' and a.COLUMN_NAME = ''DocVersion'') '+char(13)+\n" +
                    " '   and exists(select 1 from INFORMATION_SCHEMA.COLUMNS a where a.TABLE_NAME = ''' + isnull(@tableName,'') + ''' and a.COLUMN_NAME = ''DocCode'') ' + char(13)+\n" +
                    " ' begin ' + char(13)+\n" +
                    " '   alter table ' + isnull(@tableName,'') + ' add DocVersion int ' + char(13)+\n" +
                    " ' end ' + char(13) +\n" +
                    " ' if exists(select 1 from INFORMATION_SCHEMA.COLUMNS a where a.TABLE_NAME = ''' + isnull(@tableName,'') + ''' and a.COLUMN_NAME = ''DocVersion'')'+char(13)+\n" +
                    " ' begin \n" +
                    "      if not exists(select 1 from gfield where formid = ' + cast(isnull(@formid,0) as varchar(20)) + ' and headflag = 0 and fieldid = ''DocVersion'')  \n" +
                    "   begin \n" +
                    "      select @StatisID = max(StatisID)  from gfield  where formid = ' + cast(isnull(@formid,0) as varchar(20)) + ' and headflag = 0 \n" +
                    "   insert into gfield(formid,headflag,fieldid,fieldname,statisId,DataLink,isLoad,MasterFieldShowLocation)\n" +
                    "   values('+cast(isnull(@formid,0) as varchar(20)) + ',0,''DocVersion'',''单据版本号'',cast(isnull(@StatisID,0) as varchar(20)) ,1,1,0 )\n" +
                    "  end \n" +
                    "  end '\n" +
                    " if isnull(@sql,'') <> ''\n" +
                    " begin\n" +
                    "  exec(@sql)\n" +
                    " end \n" +
                    " if exists(select 1 from INFORMATION_SCHEMA.COLUMNS a where a.TABLE_NAME =  isnull(@tableName,'')  and a.COLUMN_NAME = 'DocVersion')\n" +
                    " begin \n" +
                    "  set @objName = isnull(@tableName,'') + 'UpdateDocVersion'\n" +
                    "  if OBJECT_ID(isnull(@objName,'')) is  null \n" +
                    "  begin\n" +
                    "    set @createOrAlter = ' create '\n" +
                    "  end else \n" +
                    "  begin\n" +
                    "   set @createOrAlter = ' alter '\n" +
                    "  end \n" +
                    "   set @uploadFieldId = 'not UPDATE(DocVersion)'\n" +
                    " select @uploadFieldId = isnull(@uploadFieldId,'') + case when isnull(@uploadFieldId,'') <> '' then ' and ' else '' end \n" +
                    " + 'not UPDATE(' + isnull(fieldid,'') + ')' \n" +
                    " from gfield where formid = @formid and headflag = 0 and ControlType = 9 \n" +
                    "  select @uploadFieldId = isnull(@uploadFieldId,'') + case when isnull(@uploadFieldId,'') <> '' then ' and ' else '' end \n" +
                    "  + 'not UPDATE(' + isnull(fieldid,'') + ')' \n" +
                    " from gfield where formid = @formid and headflag = 0 and ControlType = 19\n" +
                    " set @sql = isnull(@createOrAlter,'') + ' trigger [dbo].['+ isnull(@objName,'') + '] on [dbo].['+ isnull(@tableName,'') + '] after update \n" +
                    " --目的:单据表头更新时,将版本号 DocVersion 字段值自动+1, 此触发器脚本为自动生成,请不要尝试修改它 \n" +
                    " --Author : Johns Wang,' + convert(varchar(19),getdate(),120) + '\n" +
                    "  as\n" +
                    "  begin \n" +
                    "  set nocount on\n" +
                    "  declare @DocVersionTable table(DocCode varchar(50) primary key,DocVersion int) ' + char(13)+\n" +
                    "  case when isnull(@uploadFieldId,'') <> '' then '    if ' + isnull(@uploadFieldId,'')  else '' end +char(13)+\n" +
                    "  --if not UPDATE(DocVersion)    --不能加此条件,因为加了之后,如果更新DocVersion字段时,同时更新其它字段,则会导致DocVersion不能自动+1\n" +
                    " '    begin\n" +
                    "   insert into @DocVersionTable (DocCode,DocVersion)\n" +
                    "   select DocCode,DocVersion from inserted \n" +
                    "   --int 从 -2^31 (-2,147,483,648) 到 2^31 - 1 (2,147,483,647) 的整型数据(所有数字)。\n" +
                    "   update a set DocVersion = 0 from @DocVersionTable a where DocVersion > 2147483000   --避免数字溢出\n" +
                    "   update a set DocVersion = isnull(b.DocVersion,0) + 1  from '+isnull(@tableName,'')+' a join @DocVersionTable b on a.DocCode = b.DocCode \n" +
                    "   end \n" +
                    " end '\n" +
                    "  if isnull(@sql,'') <> ''\n" +
                    "  begin\n" +
                    "   exec(@sql)\n" +
                    "  end \n" +
                    "  end \n";
            jdbcTemplate.update(sql);
        }catch (Exception e){
            throw e;
        }
    }
 
    protected String getDomainUrl(BaseBean baseBean) {
        if (baseBean.hostUrl == "") return "";
        String str = HtmlUtil.getDomain(baseBean.hostUrl);
        int inx = str.indexOf(".");
        if (inx == -1) {
            int y = str.indexOf(":");
            return y == -1 ? str : str.substring(0, y);
        }
        return str.substring(0, inx);
    }
 
    /**
     * 生成主页面
     *
     * @throws Exception
     */
    public void buildIndex(Map<String, Object> gformInfo) throws Exception {
        BaseBean baseBean = (BaseBean) gformInfo.get(BEAN_INFO);
        String fileName = "index.jsp";
        String data = getPageCode(fileName, baseBean);
        //--------从gform表获取是否显示大标题字段值(isTitle)判断是否显示大标题,并替换标识符-2012-02-20-syz--------[begin]----------------------
 
        if (GridUtils.prossRowSetDataType_Int(gformInfo, "isTitle") == 1) {//如果配置了显示大标题
            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" +
                            "</div>\n";
            data = data.replace("[?TopAndTitle]", TopAndTitle_str);//替换功能号标识符
        }
 
        //--------从gform表获取是否显示大标题字段值(isTitle)判断是否显示大标题,并替换标识符-2012-02-20-syz-----[end]-------------------------//
 
        // ----------------
        data = data.replace("[?title]", gformInfo.get("formname") + "");
        data = data.replaceAll("@gridJsp@", baseBean.formID + "_grid.jsp");
        data = data.replace("[?treewidth]", gformInfo.get("treewidth")+"");
        buildPageCode(data, fileName, baseBean);
    }
 
    /**
     * 生成foolter页面(资源释放页)
     *
     * @throws Exception
     */
    public void buildFoolter(BaseBean baseBean) throws Exception {
        String fileName = "foolter.jsp";
        String data = getPageCode(fileName, baseBean);
        // ----------------
 
        buildPageCode(data, fileName, baseBean);
    }
 
    /**
     * 生成Grid页面
     *
     * @throws Exception
     */
    public void buildGrid(BaseBean baseBean) throws Exception {
        treeGrid.createGrid(baseBean.type, Integer.parseInt(baseBean.formID), baseBean.URI, "app/" + baseBean.gPath + "/", new String[]{baseBean.formID + "_grid.jsp"}, getTemPath(baseBean), "/" + baseBean.formID + "/" + baseBean.type + "/", null, baseBean.dataBaseId);
    }
 
    /**
     * 生成js css 导入的页面
     *
     * @throws Exception
     */
    protected void buildJsCssHead(BaseBean baseBean) throws Exception {
        String fileName = "jsCssHead.jsp";
        String data = getPageCode(fileName, baseBean);
        buildPageCode(data, fileName, baseBean);
    }
 
    /**
     * 生成帮助页面
     *
     * @throws Exception
     */
    public void buildHelpPage(Map<String, Object> gformInfo) throws Exception {
        BaseBean baseBean = (BaseBean) gformInfo.get(BEAN_INFO);
        buildTopIfc.build(Integer.parseInt(baseBean.formID), baseBean.type, getTemPath(baseBean) + "help.jsp", getToPath(baseBean) + "help.jsp", gformInfo, this);
    }
 
    /**
     * 生成top页面
     *
     * @throws Exception
     */
    public void buildTop(Map<String, Object> gformInfo) throws Exception {
        BaseBean baseBean = (BaseBean) gformInfo.get(BEAN_INFO);
        buildTopIfc.build(Integer.parseInt(baseBean.formID), baseBean.type, getBuildPath(baseBean) + "top.jsp", getToPath(baseBean) + "top.jsp", gformInfo, this);
    }
 
    @Override
    public void buildPageCode(String data, String targetFileName, BaseBean baseBean) throws Exception {
        File file = new File(baseBean.URI + File.separator + "app" + File.separator + BFI.getPath(baseBean.formID, baseBean.type, baseBean.versionId, baseBean.dataBaseId, baseBean.language) + File.separator);
        //处理上传控件需要增加js,css的导出,根据功能号是否设置有9,19,40控件决定加不加上这些页面,从而优化页面加载 by danaus 17-11-23
        //根据formid查找9802中是不是有包括上面所说的控件,有则加载。
        SqlRowSet row = this.getRowSet(" set nocount on ; select count(1) as a from gfield where  formid=" + baseBean.formID + " and (gridcontroltype in(9,19,40) or controltype in(9,19,40))");
        row.next();
        int num = row.getInt(1);
        String js_css = "<!--Bootstrap插件包(包含fileInput),bootstrap版本是5.1.3-->\n";
        js_css += "<link rel=\"stylesheet\" type=\"text/css\" href=\"/js/bootstrap/v5.1.3/css/bootstrap.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap/v5.1.3/css/bootstrap.css\")%>\">\n" +
                "<link rel=\"stylesheet\" type=\"text/css\" href=\"/js/bootstrap/v5.1.3/icons/font/bootstrap-icons.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap/v5.1.3/icons/font/bootstrap-icons.css\")%>\">\n" +
                "<script type=\"text/javascript\" src=\"/js/bootstrap/v5.1.3/js/bootstrap.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap/v5.1.3/js/bootstrap.js\")%>\"></script>\n" +
                "<script type=\"text/javascript\" src=\"/js/bootstrap/v5.1.3/js/bootstrap.bundle.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap/v5.1.3/js/bootstrap.bundle.js\")%>\"></script>\n";
        if (num != 0) {//表示存在有上传控件
            js_css +=
//                    "<link rel=\"stylesheet\" type=\"text/css\" href=\"/js/bootstrap-upload/css/fileinput.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap-upload/css/fileinput.css\")%>\">\n" +
//                    "<link rel=\"stylesheet\" type=\"text/css\" href=\"/js/bootstrap-upload/css/bootstrap.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap-upload/css/bootstrap.css\")%>\">\n" +
//                    "<link rel=\"stylesheet\" type=\"text/css\" href=\"/js/bootstrap-upload/css/rotationscaling.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap-upload/css/rotationscaling.css\")%>\">\n" +
//                    "<script type=\"text/javascript\" src=\"/js/bootstrap-upload/js/fileinput.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap-upload/js/fileinput.js\")%>\"></script>\n" +
//                    "<script type=\"text/javascript\" src=\"/js/bootstrap-upload/js/locales/zh.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap-upload/js/locales/zh.js\")%>\"></script>\n" +
//                    "<script type=\"text/javascript\" src=\"/shopping/view/javascript/bootstrap/js/bootstrap.min.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/shopping/view/javascript/bootstrap/js/bootstrap.min.js\")%>\"></script>\n";
                    "<link rel=\"stylesheet\" type=\"text/css\" href=\"/js/bootstrap/fileinput/css/fileinput.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap/fileinput/css/fileinput.css\")%>\">\n" +
                            "<link rel=\"stylesheet\" type=\"text/css\" href=\"/general/Viewer/css/viewer.min.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/general/Viewer/css/viewer.min.css\")%>\">\n" +
                            "<script type=\"text/javascript\" src=\"/js/bootstrap/fileinput/js/fileinput.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap/fileinput/js/fileinput.js\")%>\"></script>\n" +
                            "<script type=\"text/javascript\" src=\"/js/bootstrap/fileinput/js/locales/zh.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/js/bootstrap/fileinput/js/locales/zh.js\")%>\"></script>\n" +
                            "<script type=\"text/javascript\" src=\"/general/Viewer/js/viewer.min.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/general/Viewer/js/viewer.min.js\")%>\"></script>";
        }
        data = data.replace("@_add_js_css_@", js_css);
        if (!file.exists() || !file.isDirectory()) file.mkdirs();
        file = new File(file.getPath() + File.separator + targetFileName);
        FileUtils.writeStringToFile(file, data, "utf-8");
    }
 
    @Override
    public String getPageCode(String templateFileName, BaseBean baseBean) throws IOException {
        return FileUtils.readFileToString(new File(baseBean.URI + File.separator + "public" + File.separator + "template" + File.separator + baseBean.versionId + File.separator + baseBean.type + File.separator + templateFileName), "utf-8");
    }
 
    @Override
    public String toString(Object str) {
        return str == null ? "" : str.toString();
    }
 
    @Override
    public String getBuildPath(BaseBean baseBean) {
        return getTemPath(baseBean) + baseBean.type + File.separator;
    }
 
 
    public String getTemPath(BaseBean baseBean) {
        return baseBean.URI + File.separator + "public" + File.separator + "template" + File.separator + baseBean.versionId + File.separator;
    }
 
 
    /**
     * 生成jsp数据处理头页面
     *
     * @throws Exception
     */
    public String buildDataHead(Map<String, Object> gformInfo) throws Exception {
        BaseBean baseBean = (BaseBean) gformInfo.get(BEAN_INFO);
        String fileName = "dataHead.jsp";
        String tmpJsp = getPageCode(fileName, baseBean);
        tmpJsp = tmpJsp.replace("[?formId]", baseBean.formID);
        tmpJsp = tmpJsp.replace("[?table]", toString(gformInfo.get("HDTable")));
        tmpJsp = tmpJsp.replace("[?formType]", baseBean.type + "");
        tmpJsp = tmpJsp.replace("[?canelProc]",toString(gformInfo.get("CancelBtnProcName")));//取消确认
        tmpJsp = tmpJsp.replace("[?revokeProc]",toString(gformInfo.get("RevokeBtnProcName")));//撤回
        tmpJsp= tmpJsp.replace("[?zhu]", baseBean.zhu);
        tmpJsp = tmpJsp.replace("[?sousuo]", baseBean.sous);
        tmpJsp = tmpJsp.replace("@doc", baseBean.doc);
        tmpJsp = tmpJsp.replace("@id_info", baseBean.id_info);
        tmpJsp = tmpJsp.replace("[?predocstatus]", gformInfo.get("predocstatus") + "");
        tmpJsp = tmpJsp.replace("[?isShowOnlineMsg]", gformInfo.get("isShowOnlineMsg") + "");
        tmpJsp = tmpJsp.replace("[?isShowProcessTracking]", gformInfo.get("isShowProcessTracking") + "");
        tmpJsp = tmpJsp.replace("[?isOpenFuncShowPwdEdit]", toString(gformInfo.get("isopenFuncshowpwdedit")));
        tmpJsp = tmpJsp.replace("[?version]", ("".equalsIgnoreCase(toString(gformInfo.get("version"))) ? "0" : toString(gformInfo.get("version"))));
        // 序列号扫码 xin 2021-8-2 17:45:43
        //入库
        tmpJsp = tmpJsp.replace("[?isshowinserialbtn]", DBHelper.getValueInt(gformInfo,"isshowinserialbtn")+"");
        tmpJsp = tmpJsp.replace("[?inserialbtneditstatus]", DBHelper.getValue(gformInfo,"inserialbtneditstatus"));
        //出库
        tmpJsp = tmpJsp.replace("[?isshowoutserialbtn]", DBHelper.getValueInt(gformInfo,"isshowoutserialbtn")+"");
        tmpJsp = tmpJsp.replace("[?outserialbtneditstatus]", DBHelper.getValue(gformInfo,"outserialbtneditstatus"));
        //农行支付收付款控制 xin 2021-8-23 14:30:39
        //在线收
        tmpJsp = tmpJsp.replace("[?isshowonlinepaymentbutton]", DBHelper.getValueInt(gformInfo,"isshowonlinepaymentbutton")+"");
 
        //--操作类型
        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, gformInfo);
        buildPageCode(tmpJsp, fileName, baseBean);
        return tmpJsp;
    }
 
    public String replaceGform(String tmpJsp, Map<String, Object> formInfo) {
        String dataformid = DBHelper.getValue(formInfo, "dataformid");
        tmpJsp = tmpJsp.replaceAll("#dataformid#", (dataformid.equals("")) ? "" : ("," + dataformid));//" or formid in(" + dataformid + ")"
        String formdatafilters = DBHelper.getValue(formInfo, "formdatafilters");
        tmpJsp = tmpJsp.replaceAll("#formdatafilters#", (formdatafilters.equals("")) ? "" : " and " + formdatafilters);
        return tmpJsp;
    }
 
    public String trim(Object str) {
        if (str == null) {
            return "";
        }
        return str.toString().trim().replaceAll("\\r\\n|\\n|\\r", "");
    }
 
 
}