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");
|
}
|
}
|
|
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-jquery.min.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,\"/general/Viewer/js/viewer-jquery.min.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);
|
}
|
// else {
|
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", "");
|
}
|
|
|
}
|