111111111111111

master
任广鹏 8 months ago
parent 09ec3980f0
commit 7b62002bf1

@ -0,0 +1,133 @@
package com.api.mobilemode.web.mobile.browser;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.api.fna.service.impl.BudgetfeeTypeBrowserService;
import com.api.fna.util.FnaConstant;
import com.api.mobilemode.web.mobile.ActionMapping;
import com.api.mobilemode.web.mobile.BaseMobileAction;
import com.cloudstore.dev.api.service.Service_DevTable;
import com.weaver.formmodel.mobile.utils.BrowserUtil;
import com.weaver.formmodel.util.StringHelper;
import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* action
* commonbrowser
*/
public class SystemBrowserAction extends BaseMobileAction {
private static final long serialVersionUID = 393862748977092668L;
// 部门浏览框id
private static final String[] DEPT_IDS = {"4", "57", "167", "168"};
// 分部浏览框id
private static final String[] SUBCOMPANY_IDS = {"164", "194", "169", "170"};
private static final String DEPT_FIELD = "19135";
public SystemBrowserAction(HttpServletRequest request,
HttpServletResponse response) {
super(request, response);
}
/**
* browseriddataKey
* @return
*/
@ActionMapping(name = "getData")
public JSONObject getData() {// 22:报销费用类型, 4:部门, 57:多部门, 167:分权单部门, 168:分权多部门, 164:分部, 194:多分部, 169:分权单分部, 170:分权多分部
String browserId = Util.null2String(getParameter("browserId"));
JSONObject apidatas = new JSONObject();
String fieldid = Util.null2String(pageParam.get("fieldid"));
if (DEPT_FIELD.equals(fieldid)){
pageParam.put("fromModule","model");
pageParam.put("isFromMode","1");
pageParam.put("modeId","147");
pageParam.put("isbill","1");
}
apidatas.putAll(JSONObject.parseObject(JSON.toJSONString(BrowserUtil.getDataBySysApiService(browserId, pageParam, user))));
boolean isSubCompany = Arrays.asList(SUBCOMPANY_IDS).contains(browserId);
if (Arrays.asList(DEPT_IDS).contains(browserId) || isSubCompany) {// 分部 or 部门
String selectedIds = Util.null2String(getParameter("selectedIds"));
if (selectedIds.length() > 0) {
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
JSONArray selArr = new JSONArray();
Arrays.asList(selectedIds.split(",")).forEach(id -> {
String name = isSubCompany ? subCompanyComInfo.getSubCompanyname(id) : departmentComInfo.getDepartmentname(id);// 分部/部门名称
if (StringHelper.isNotEmpty(name)) {
JSONObject dept = new JSONObject();
dept.put("id", id);
dept.put("name", name);
selArr.add(dept);
}
});
apidatas.put("sel_datas", selArr);
}
}
if ("1".equals(getParameter("list"))) {
//获取列表
String dataKey = Util.null2String(apidatas.get("datas"));
String pageSize = Util.null2String(getParameter("pageSize"));
String current = Util.null2String(getParameter("current"));
return executeWithSession(() -> {
JSONObject datas = new JSONObject();
Service_DevTable devTableService = new Service_DevTable();
String dataTable = devTableService.datas(this.getRequest(), this.getResponse(), dataKey, pageSize, "", "", "", current, "1");
datas.putAll(JSON.parseObject(dataTable));
datas.put("sel_datas", apidatas.get("sel_datas"));
return datas;
});
}
return apidatas;
}
/**
* dataKey
* @return
*/
@ActionMapping(name = "getListData")
public JSONObject getListData() {
String dataKey = Util.null2String(getParameter("dataKey"));
String pageSize = Util.null2String(getParameter("pageSize"));
String min = Util.null2String(getParameter("min"));
String max = Util.null2String(getParameter("max"));
String current = Util.null2String(getParameter("current"));
return executeWithSession(() -> {
JSONObject apidatas = new JSONObject();
Service_DevTable devTableService = new Service_DevTable();
String dataTable = devTableService.datas(this.getRequest(), this.getResponse(), dataKey, pageSize, "", min, max, current, "1");
apidatas.putAll(JSON.parseObject(dataTable));
return apidatas;
});
}
/**
*
*/
@ActionMapping(name = "updateBudgetfeeTypeUsed")
public JSONObject updateBudgetfeeTypeUsed() {
Map<String, Object> apidatas = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<>();
params.putAll(pageParam);
if (user == null) {
apidatas.put(FnaConstant.FNA_RESULT_DATA, null);
} else {
apidatas = new BudgetfeeTypeBrowserService().updateBudgetfeeTypeUsed(user, params);
}
return JSONObject.parseObject(JSON.toJSONString(apidatas));
}
}

@ -97,7 +97,7 @@ public class WorkflowToDocCus {
try { try {
cookie = (String)class_MultiLangFilter.getMethod("getThreadlocalCookies").invoke(class_MultiLangFilter); cookie = (String)class_MultiLangFilter.getMethod("getThreadlocalCookies").invoke(class_MultiLangFilter);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
} }
} }
@ -336,7 +336,7 @@ public class WorkflowToDocCus {
params[3] = new String(loginid.getBytes(), "8859_1"); params[3] = new String(loginid.getBytes(), "8859_1");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace();
}*/ }*/
params[3] = PoppupRemindInfoUtil.encrypt(loginid);//解决中文账号问题 params[3] = PoppupRemindInfoUtil.encrypt(loginid);//解决中文账号问题
params[4] = password; params[4] = password;
@ -368,23 +368,28 @@ public class WorkflowToDocCus {
PostMethod method = new PostMethod(url[0]);//oa地址 PostMethod method = new PostMethod(url[0]);//oa地址
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(3, false)); new DefaultHttpMethodRetryHandler(3, false));
BufferedWriter bw = null;
BufferedReader in = null;
OutputStream os = null;
InputStream inputStream = null;
OutputStreamWriter output = null;
try { try {
NameValuePair[] params = { NameValuePair[] params = {
new NameValuePair("urlfrom", url[1]),//urlfrom new NameValuePair("urlfrom", url[1]),//urlfrom
new NameValuePair("para1",url[2]),//requesturl new NameValuePair("para1", url[2]),//requesturl
new NameValuePair("para2",url[3] ),//loginid new NameValuePair("para2", url[3]),//loginid
new NameValuePair("para3",url[4])};//url4密码 new NameValuePair("para3", url[4])};//url4密码
method.setRequestBody(params); method.setRequestBody(params);
//log.info("----workflowtodoc----"+url[0] + "?urlfrom="+url[1]+"&para1="+url[2]+"&para2="+url[3]+"&para3="+url[4]); //log.info("----workflowtodoc----"+url[0] + "?urlfrom="+url[1]+"&para1="+url[2]+"&para2="+url[3]+"&para3="+url[4]);
int statusCode = client.executeMethod(method); int statusCode = client.executeMethod(method);
new BaseBean().writeLog("WorkflowToDoc statusCode :"+statusCode); new BaseBean().writeLog("WorkflowToDoc statusCode :" + statusCode);
String temppath = getFileSavePath(); String temppath = getFileSavePath();
String filename = System.currentTimeMillis() + ""; String filename = System.currentTimeMillis() + "";
String htmlname = temppath + filename; String htmlname = temppath + filename;
File _temppath = new File(temppath); File _temppath = new File(temppath);
if(!_temppath.exists()){ if (!_temppath.exists()) {
_temppath.mkdirs(); _temppath.mkdirs();
} }
@ -393,7 +398,7 @@ public class WorkflowToDocCus {
Header locationHeader = method.getResponseHeader("location"); Header locationHeader = method.getResponseHeader("location");
if (locationHeader != null) { if (locationHeader != null) {
String tempurl = locationHeader.getValue(); String tempurl = locationHeader.getValue();
if(!tempurl.startsWith("http://") && !tempurl.startsWith("https://")) { if (!tempurl.startsWith("http://") && !tempurl.startsWith("https://")) {
//GET PORT //GET PORT
String port_string = ""; String port_string = "";
Matcher matcher = port_pattern.matcher(url[0]); Matcher matcher = port_pattern.matcher(url[0]);
@ -402,23 +407,23 @@ public class WorkflowToDocCus {
} }
tempurl = "http://" tempurl = "http://"
// + (port_string.isEmpty()? "" : "localhost"+port_string) // + (port_string.isEmpty()? "" : "localhost"+port_string)
+ (port_string.isEmpty()? "" : "127.0.0.1"+port_string) + (port_string.isEmpty() ? "" : "127.0.0.1" + port_string)
+ tempurl; + tempurl;
} }
new BaseBean().writeLog("WorkflowToDoc cookie :"+cookie); new BaseBean().writeLog("WorkflowToDoc cookie :" + cookie);
tempurl = getFinallyUrl(client, tempurl,cookie); tempurl = getFinallyUrl(client, tempurl, cookie);
tempurl = tempurl.replaceFirst(".jsp", "Iframe.jsp"); tempurl = tempurl.replaceFirst(".jsp", "Iframe.jsp");
tempurl = tempurl+"&urlfrom=workflowtodoc"; tempurl = tempurl + "&urlfrom=workflowtodoc";
new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) start :"+System.currentTimeMillis()); new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) start :" + System.currentTimeMillis());
new BaseBean().writeLog("WorkflowToDoc tempurl :"+tempurl); new BaseBean().writeLog("WorkflowToDoc tempurl :" + tempurl);
GetMethod g = new GetMethod(tempurl); GetMethod g = new GetMethod(tempurl);
g.setRequestHeader("cookie", cookie); g.setRequestHeader("cookie", cookie);
client.executeMethod(g); client.executeMethod(g);
OutputStream os=new FileOutputStream(htmlname); os = new FileOutputStream(htmlname);
new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) end :"+System.currentTimeMillis()); new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) end :" + System.currentTimeMillis());
// SystemComInfo syscominfo=new SystemComInfo() ; // SystemComInfo syscominfo=new SystemComInfo() ;
// this.isaesencrypt = syscominfo.getIsaesencrypt(); // this.isaesencrypt = syscominfo.getIsaesencrypt();
// this.aescode = Util.getRandomString(13); // this.aescode = Util.getRandomString(13);
@ -429,31 +434,31 @@ public class WorkflowToDocCus {
// //
// } // }
// } // }
OutputStreamWriter output = new OutputStreamWriter(os, "UTF-8"); output = new OutputStreamWriter(os, "UTF-8");
BufferedWriter bw = new BufferedWriter(output); bw = new BufferedWriter(output);
BufferedReader in = new BufferedReader(new InputStreamReader(g.getResponseBodyAsStream(), "UTF-8")); in = new BufferedReader(new InputStreamReader(g.getResponseBodyAsStream(), "UTF-8"));
StringBuffer sb=new StringBuffer(); StringBuffer sb = new StringBuffer();
String line = in.readLine(); String line = in.readLine();
while (line != null) { while (line != null) {
line = line.trim(); line = line.trim();
if(line.indexOf("</a>")>=0&&line.indexOf("openSignPrint()")>=0&&line.indexOf("onclick")>=0){ if (line.indexOf("</a>") >= 0 && line.indexOf("openSignPrint()") >= 0 && line.indexOf("onclick") >= 0) {
//去掉转发按钮 //去掉转发按钮
}else if(line.indexOf("<img")>=0&&line.indexOf("class=\"transto\"")>=0&&line.indexOf("onclick")>=0&&line.indexOf("transtoClick(this)")>=0){ } else if (line.indexOf("<img") >= 0 && line.indexOf("class=\"transto\"") >= 0 && line.indexOf("onclick") >= 0 && line.indexOf("transtoClick(this)") >= 0) {
}else if(line.indexOf("var")>=0&&line.indexOf("bar")>=0&&line.indexOf("eval")>=0&&line.indexOf("handler")>=0&&line.indexOf("text")>=0){ } else if (line.indexOf("var") >= 0 && line.indexOf("bar") >= 0 && line.indexOf("eval") >= 0 && line.indexOf("handler") >= 0 && line.indexOf("text") >= 0) {
sb.append("var bar=eval(\"[]\");\n"); sb.append("var bar=eval(\"[]\");\n");
}else{ } else {
sb.append(line + "\n"); sb.append(line + "\n");
} }
line = in.readLine(); line = in.readLine();
} }
//添加水印 //添加水印
if(WfWaterMark4WfToDocBiz.isOpenWaterMark(Util.getIntValue(workflowid))){ if (WfWaterMark4WfToDocBiz.isOpenWaterMark(Util.getIntValue(workflowid))) {
WfWaterMark4WfToDocBiz wfWaterMark4WfToDocBizCus = new WfWaterMark4WfToDocBiz(new User(Util.getIntValue(userid))); WfWaterMark4WfToDocBiz wfWaterMark4WfToDocBizCus = new WfWaterMark4WfToDocBiz(new User(Util.getIntValue(userid)));
wfWaterMark4WfToDocBizCus.generateFormData(requestid); wfWaterMark4WfToDocBizCus.generateFormData(requestid);
String watetmarkhtml = wfWaterMark4WfToDocBizCus.getWaterMarkHtml(false,Util.getIntValue(workflowid),Util.getIntValue(requestid),true); String watetmarkhtml = wfWaterMark4WfToDocBizCus.getWaterMarkHtml(false, Util.getIntValue(workflowid), Util.getIntValue(requestid), true);
int begIndex = sb.lastIndexOf("</body>"); int begIndex = sb.lastIndexOf("</body>");
String frontcontent = sb.substring(0, begIndex); String frontcontent = sb.substring(0, begIndex);
String behindcontent = sb.substring(begIndex); String behindcontent = sb.substring(begIndex);
@ -472,8 +477,8 @@ public class WorkflowToDocCus {
sb.append("window.attachEvent(\"onload\", drm4request2doc);\n"); sb.append("window.attachEvent(\"onload\", drm4request2doc);\n");
sb.append("</script>"); sb.append("</script>");
String sdata=sb.toString(); String sdata = sb.toString();
bw.write(sdata,0,sdata.length()); bw.write(sdata, 0, sdata.length());
// long size = 0l; // long size = 0l;
// File f = new File(htmlname); // File f = new File(htmlname);
@ -482,21 +487,21 @@ public class WorkflowToDocCus {
// } // }
bw.flush(); bw.flush();
bw.close();
in.close();
InputStream inputStream = null;
byte[] buffer = null; byte[] buffer = null;
File file = new File(htmlname); File file = new File(htmlname);
if (file.exists()){ if (file.exists()) {
try { try {
inputStream = new FileInputStream(file); inputStream = new FileInputStream(file);
buffer = new byte[(int) file.length()]; buffer = new byte[(int) file.length()];
inputStream.read(buffer); inputStream.read(buffer);
inputStream.close(); inputStream.close();
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace();
}finally {
inputStream.close();
} }
} }
@ -530,23 +535,23 @@ public class WorkflowToDocCus {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
imageFileManager.setComefrom("WorkflowToDoc"); imageFileManager.setComefrom("WorkflowToDoc");
imageFileManager.setData(buffer); imageFileManager.setData(buffer);
imageFileManager.setImagFileName(requestname+".html"); imageFileManager.setImagFileName(requestname + ".html");
int imagefileid = imageFileManager.saveImageFile(); int imagefileid = imageFileManager.saveImageFile();
// System.out.println("-在线-imagefileid----"+imagefileid); // System.out.println("-在线-imagefileid----"+imagefileid);
// 保存imagefile // 保存imagefile
//int imagefileid = saveImageFile(requestname, htmlname, size,false); //int imagefileid = saveImageFile(requestname, htmlname, size,false);
if (imagefileid <= 0) { if (imagefileid <= 0) {
log.error("保存在线HTML文件失败"); log.error("保存在线HTML文件失败");
return ; return;
} }
//把fileid存入fileidsmap中最后一起保存文档-附件关联关系 //把fileid存入fileidsmap中最后一起保存文档-附件关联关系
fileids.put("online_html",imagefileid+""); fileids.put("online_html", imagefileid + "");
//saveDocDetail(requestname, htmlname, size, workflowid,requestid, wfdocpath,userid); //saveDocDetail(requestname, htmlname, size, workflowid,requestid, wfdocpath,userid);
if(g!=null){ if (g != null) {
g.releaseConnection(); g.releaseConnection();
} }
if(method!=null){ if (method != null) {
method.releaseConnection(); method.releaseConnection();
} }
} }
@ -554,15 +559,38 @@ public class WorkflowToDocCus {
} catch (HttpException e) { } catch (HttpException e) {
log.error("Fatal protocol violation: " + e.getMessage()); log.error("Fatal protocol violation: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
log.error("Fatal transport error: " + e.getMessage()); log.error("Fatal transport error: " + e.getMessage());
e.printStackTrace();
}catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
new BaseBean().writeLog(e); new BaseBean().writeLog(e);
}finally { } finally {
method.releaseConnection(); method.releaseConnection();
try {
if (bw != null){
bw.close();
}
if (in != null){
in.close();
}
if (os != null){
os.close();
}
if (inputStream != null){
inputStream.close();
}
if (output != null){
output.close();
}
} catch (IOException e) {
log.info("error");
}
} }
} }
@ -581,7 +609,7 @@ public class WorkflowToDocCus {
} }
client.executeMethod(g); client.executeMethod(g);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
return url; return url;
} }
Header locationHeader = g.getResponseHeader("location"); Header locationHeader = g.getResponseHeader("location");
@ -1413,7 +1441,7 @@ public class WorkflowToDocCus {
} }
} }
}catch(Exception e){ }catch(Exception e){
log.info("error");
} }
if(wfdocowner <= 0){ if(wfdocowner <= 0){
wfdocowner = 1; wfdocowner = 1;

@ -6,6 +6,9 @@
<%@ page import="com.weaver.formmodel.mobile.utils.MobileCommonUtil"%> <%@ page import="com.weaver.formmodel.mobile.utils.MobileCommonUtil"%>
<%@ page import="com.weaver.formmodel.exception.MobileModeException"%> <%@ page import="com.weaver.formmodel.exception.MobileModeException"%>
<%@ page import="weaver.general.Base64" %> <%@ page import="weaver.general.Base64" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="com.engine.common.util.ParamUtil" %>
<%@ page import="java.util.Map" %>
<% <%
response.addHeader("Access-Control-Allow-Origin", "*"); response.addHeader("Access-Control-Allow-Origin", "*");
String invoker = Util.null2String(request.getParameter("invoker")).trim(); String invoker = Util.null2String(request.getParameter("invoker")).trim();
@ -19,9 +22,16 @@ if(!invoker.contains("com.api.mobilemode")){
try { try {
// if ("19135".equals(Util.null2String(request.getParameter("fieldid")).trim())){ // if ("19135".equals(Util.null2String(request.getParameter("fieldid")).trim())){
// request.setAttribute(""); // new BaseBean().writeLog("fieldid====19135");
// request.setAttribute("fromModule","model");
// request.setAttribute("isFromMode","1");
// request.setAttribute("modeId","147");
// request.setAttribute("isbill","1");
// } // }
// Map<String, Object> stringObjectMap = ParamUtil.request2Map(request);
// new BaseBean().writeLog("stringObjectMap:"+stringObjectMap);
Class clazz = Class.forName(invoker); Class clazz = Class.forName(invoker);
if(BaseMobileAction.class.isAssignableFrom(clazz)){ if(BaseMobileAction.class.isAssignableFrom(clazz)){
Constructor ctor = clazz.getConstructor(new Class[] {HttpServletRequest.class, HttpServletResponse.class}); Constructor ctor = clazz.getConstructor(new Class[] {HttpServletRequest.class, HttpServletResponse.class});

Loading…
Cancel
Save