From 7b62002bf1af38f4d1ebc42a271695a094b0544f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E5=B9=BF=E9=B9=8F?= Date: Tue, 5 Nov 2024 15:35:15 +0800 Subject: [PATCH] 111111111111111 --- .../mobile/browser/SystemBrowserAction.java | 133 ++++++++++++++++++ .../archives/action/WorkflowToDocCus.java | 124 +++++++++------- mobilemode/mobile/server.jsp | 12 +- 3 files changed, 220 insertions(+), 49 deletions(-) create mode 100644 com/api/mobilemode/web/mobile/browser/SystemBrowserAction.java diff --git a/com/api/mobilemode/web/mobile/browser/SystemBrowserAction.java b/com/api/mobilemode/web/mobile/browser/SystemBrowserAction.java new file mode 100644 index 0000000..7dfc4fa --- /dev/null +++ b/com/api/mobilemode/web/mobile/browser/SystemBrowserAction.java @@ -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); + } + + /** + * 通过browserid获取浏览框数据,列表数据返回dataKey,树形数据返回节点信息 + * @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 apidatas = new HashMap(); + Map 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)); + } +} diff --git a/com/engine/custom/archives/action/WorkflowToDocCus.java b/com/engine/custom/archives/action/WorkflowToDocCus.java index f457f6f..544bc14 100644 --- a/com/engine/custom/archives/action/WorkflowToDocCus.java +++ b/com/engine/custom/archives/action/WorkflowToDocCus.java @@ -97,7 +97,7 @@ public class WorkflowToDocCus { try { cookie = (String)class_MultiLangFilter.getMethod("getThreadlocalCookies").invoke(class_MultiLangFilter); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - e.printStackTrace(); + } } @@ -129,7 +129,7 @@ public class WorkflowToDocCus { * @param userid * 用户id * @param requestname - * 流程名 流程名作为文档的文档名 + * 流程名 流程名作为文档的文档名 * @param workflowid * @return */ @@ -336,7 +336,7 @@ public class WorkflowToDocCus { params[3] = new String(loginid.getBytes(), "8859_1"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block - e.printStackTrace(); + }*/ params[3] = PoppupRemindInfoUtil.encrypt(loginid);//解决中文账号问题 params[4] = password; @@ -363,28 +363,33 @@ public class WorkflowToDocCus { public void getWorkflowHtml(String url[], String requestid, String requestname, String workflowid, String wfdocpath,String userid, String cookie,LinkedHashMap fileids) { - HttpClient client = FWHttpConnectionManager.getHttpClient(); + HttpClient client = FWHttpConnectionManager.getHttpClient(); PostMethod method = new PostMethod(url[0]);//oa地址 method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); + BufferedWriter bw = null; + BufferedReader in = null; + OutputStream os = null; + InputStream inputStream = null; + OutputStreamWriter output = null; try { NameValuePair[] params = { new NameValuePair("urlfrom", url[1]),//urlfrom - new NameValuePair("para1",url[2]),//requesturl - new NameValuePair("para2",url[3] ),//loginid - new NameValuePair("para3",url[4])};//url4密码 + new NameValuePair("para1", url[2]),//requesturl + new NameValuePair("para2", url[3]),//loginid + new NameValuePair("para3", url[4])};//url4密码 method.setRequestBody(params); //log.info("----workflowtodoc----"+url[0] + "?urlfrom="+url[1]+"¶1="+url[2]+"¶2="+url[3]+"¶3="+url[4]); int statusCode = client.executeMethod(method); - new BaseBean().writeLog("WorkflowToDoc statusCode :"+statusCode); + new BaseBean().writeLog("WorkflowToDoc statusCode :" + statusCode); String temppath = getFileSavePath(); String filename = System.currentTimeMillis() + ""; String htmlname = temppath + filename; File _temppath = new File(temppath); - if(!_temppath.exists()){ + if (!_temppath.exists()) { _temppath.mkdirs(); } @@ -393,7 +398,7 @@ public class WorkflowToDocCus { Header locationHeader = method.getResponseHeader("location"); if (locationHeader != null) { String tempurl = locationHeader.getValue(); - if(!tempurl.startsWith("http://") && !tempurl.startsWith("https://")) { + if (!tempurl.startsWith("http://") && !tempurl.startsWith("https://")) { //GET PORT String port_string = ""; Matcher matcher = port_pattern.matcher(url[0]); @@ -402,23 +407,23 @@ public class WorkflowToDocCus { } tempurl = "http://" // + (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; } - new BaseBean().writeLog("WorkflowToDoc cookie :"+cookie); - tempurl = getFinallyUrl(client, tempurl,cookie); + new BaseBean().writeLog("WorkflowToDoc cookie :" + cookie); + tempurl = getFinallyUrl(client, tempurl, cookie); 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 tempurl :"+tempurl); + new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) start :" + System.currentTimeMillis()); + new BaseBean().writeLog("WorkflowToDoc tempurl :" + tempurl); GetMethod g = new GetMethod(tempurl); g.setRequestHeader("cookie", cookie); 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() ; // this.isaesencrypt = syscominfo.getIsaesencrypt(); // this.aescode = Util.getRandomString(13); @@ -429,31 +434,31 @@ public class WorkflowToDocCus { // // } // } - OutputStreamWriter output = new OutputStreamWriter(os, "UTF-8"); - BufferedWriter bw = new BufferedWriter(output); + output = new OutputStreamWriter(os, "UTF-8"); + bw = new BufferedWriter(output); - BufferedReader in = new BufferedReader(new InputStreamReader(g.getResponseBodyAsStream(), "UTF-8")); - StringBuffer sb=new StringBuffer(); + in = new BufferedReader(new InputStreamReader(g.getResponseBodyAsStream(), "UTF-8")); + StringBuffer sb = new StringBuffer(); String line = in.readLine(); while (line != null) { line = line.trim(); - if(line.indexOf("")>=0&&line.indexOf("openSignPrint()")>=0&&line.indexOf("onclick")>=0){ + if (line.indexOf("") >= 0 && line.indexOf("openSignPrint()") >= 0 && line.indexOf("onclick") >= 0) { //去掉转发按钮 - }else if(line.indexOf("=0&&line.indexOf("class=\"transto\"")>=0&&line.indexOf("onclick")>=0&&line.indexOf("transtoClick(this)")>=0){ + } else if (line.indexOf("= 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"); - }else{ + } else { sb.append(line + "\n"); } line = in.readLine(); } //添加水印 - if(WfWaterMark4WfToDocBiz.isOpenWaterMark(Util.getIntValue(workflowid))){ + if (WfWaterMark4WfToDocBiz.isOpenWaterMark(Util.getIntValue(workflowid))) { WfWaterMark4WfToDocBiz wfWaterMark4WfToDocBizCus = new WfWaterMark4WfToDocBiz(new User(Util.getIntValue(userid))); 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(""); String frontcontent = sb.substring(0, begIndex); String behindcontent = sb.substring(begIndex); @@ -472,8 +477,8 @@ public class WorkflowToDocCus { sb.append("window.attachEvent(\"onload\", drm4request2doc);\n"); sb.append(""); - String sdata=sb.toString(); - bw.write(sdata,0,sdata.length()); + String sdata = sb.toString(); + bw.write(sdata, 0, sdata.length()); // long size = 0l; // File f = new File(htmlname); @@ -482,21 +487,21 @@ public class WorkflowToDocCus { // } bw.flush(); - bw.close(); - in.close(); - InputStream inputStream = null; + byte[] buffer = null; File file = new File(htmlname); - if (file.exists()){ + if (file.exists()) { try { inputStream = new FileInputStream(file); buffer = new byte[(int) file.length()]; inputStream.read(buffer); inputStream.close(); - }catch (Exception e){ - e.printStackTrace(); + } catch (Exception e) { + + }finally { + inputStream.close(); } } @@ -530,23 +535,23 @@ public class WorkflowToDocCus { ImageFileManager imageFileManager = new ImageFileManager(); imageFileManager.setComefrom("WorkflowToDoc"); imageFileManager.setData(buffer); - imageFileManager.setImagFileName(requestname+".html"); + imageFileManager.setImagFileName(requestname + ".html"); int imagefileid = imageFileManager.saveImageFile(); // System.out.println("-在线-imagefileid----"+imagefileid); // 保存imagefile //int imagefileid = saveImageFile(requestname, htmlname, size,false); if (imagefileid <= 0) { log.error("保存在线HTML文件失败"); - return ; + return; } //把fileid存入fileidsmap中最后一起保存文档-附件关联关系 - fileids.put("online_html",imagefileid+""); + fileids.put("online_html", imagefileid + ""); //saveDocDetail(requestname, htmlname, size, workflowid,requestid, wfdocpath,userid); - if(g!=null){ + if (g != null) { g.releaseConnection(); } - if(method!=null){ + if (method != null) { method.releaseConnection(); } } @@ -554,15 +559,38 @@ public class WorkflowToDocCus { } catch (HttpException e) { log.error("Fatal protocol violation: " + e.getMessage()); - e.printStackTrace(); + } catch (IOException e) { log.error("Fatal transport error: " + e.getMessage()); - e.printStackTrace(); - }catch (Exception e) { - e.printStackTrace(); + + } catch (Exception e) { + new BaseBean().writeLog(e); - }finally { + } finally { 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); } catch (Exception e) { - e.printStackTrace(); + return url; } Header locationHeader = g.getResponseHeader("location"); @@ -1413,7 +1441,7 @@ public class WorkflowToDocCus { } } }catch(Exception e){ - + log.info("error"); } if(wfdocowner <= 0){ wfdocowner = 1; diff --git a/mobilemode/mobile/server.jsp b/mobilemode/mobile/server.jsp index 9fc63d4..cf876e5 100644 --- a/mobilemode/mobile/server.jsp +++ b/mobilemode/mobile/server.jsp @@ -6,6 +6,9 @@ <%@ page import="com.weaver.formmodel.mobile.utils.MobileCommonUtil"%> <%@ page import="com.weaver.formmodel.exception.MobileModeException"%> <%@ 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", "*"); String invoker = Util.null2String(request.getParameter("invoker")).trim(); @@ -19,9 +22,16 @@ if(!invoker.contains("com.api.mobilemode")){ try { + // 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 stringObjectMap = ParamUtil.request2Map(request); + // new BaseBean().writeLog("stringObjectMap:"+stringObjectMap); Class clazz = Class.forName(invoker); if(BaseMobileAction.class.isAssignableFrom(clazz)){ Constructor ctor = clazz.getConstructor(new Class[] {HttpServletRequest.class, HttpServletResponse.class});