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,6 +368,11 @@ 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
@ -416,7 +421,7 @@ public class WorkflowToDocCus {
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() ;
@ -429,10 +434,10 @@ 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) {
@ -482,11 +487,9 @@ 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()) {
@ -496,7 +499,9 @@ public class WorkflowToDocCus {
inputStream.read(buffer); inputStream.read(buffer);
inputStream.close(); inputStream.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
}finally {
inputStream.close();
} }
} }
@ -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