Merge branch 'develop' of git@git2.tenwa.com.cn:ApzlDev/apzl_leasing.git into yexuan
This commit is contained in:
commit
e12865f35d
@ -1,438 +1,439 @@
|
||||
package apx.com.amarsoft.als.base.awe.controller;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import apx.com.amarsoft.als.base.awe.util.AweDoCommUtil;
|
||||
import apx.com.amarsoft.als.base.flow.AppConfigFlow;
|
||||
import apx.com.amarsoft.als.base.flow.FlowTask;
|
||||
|
||||
import com.amarsoft.are.ARE;
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
import com.amarsoft.are.lang.StringX;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.base.constant.RestfullConstant;
|
||||
import com.base.util.MultipartDataUtil;
|
||||
import com.base.util.ReturnMapUtil;
|
||||
|
||||
@Path("/comm/query/by/dono")
|
||||
public class AweDoQueryController {
|
||||
private String dono;
|
||||
private String groupCode;
|
||||
private String interfaceDesc;
|
||||
private String initialCondition;
|
||||
private String auxiliaryCondition;
|
||||
// private String addWhere;
|
||||
private Map<String, Object> fieldMap;
|
||||
|
||||
// ReturnMapUtil ReturnMapUtil = new ReturnMapUtil();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Path("/data")
|
||||
@POST
|
||||
public Map<String, Object> query(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response, @Context JBOTransaction tx,
|
||||
@Context Transaction sqlca) throws Exception {
|
||||
ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(tx, sqlca);
|
||||
ARE.getLog().info(
|
||||
"[CONTROLLER] AweDoQueryController run .................");
|
||||
ARE.getLog().info(
|
||||
"[Path] /comm/query/by/dono/data" + " run .................");
|
||||
try {
|
||||
|
||||
Map<String, Object> testMap = (Map<String, Object>) MultipartDataUtil
|
||||
.readRequestParam(request, "UTF-8");
|
||||
fieldMap = (Map<String, Object>) testMap.get("fieldMap");
|
||||
String objectNo = fieldMap.get("OBJECTNO") == null ? "" : fieldMap
|
||||
.get("OBJECTNO").toString();
|
||||
fieldMap.put("OBJECTNO", objectNo);
|
||||
fieldMap.put("OBJECTNO".toLowerCase(), objectNo);
|
||||
fieldMap.put("FLOWUNID", objectNo);
|
||||
fieldMap.put("FLOWUNID".toLowerCase(), objectNo);
|
||||
fieldMap.put("FLOW_UNID", objectNo);
|
||||
fieldMap.put("FLOW_UNID".toLowerCase(), objectNo);
|
||||
|
||||
FlowTask FlowTask = new FlowTask();
|
||||
BizObject bo = FlowTask.queryFlowTask(request, sqlca, tx, fieldMap);
|
||||
if (null != bo) {
|
||||
if (null == bo.getAttribute("SERIALNO")) {
|
||||
ReturnMapUtil.setReturnMap(null,
|
||||
RestfullConstant.baseProperty.get("FAIL")
|
||||
.toString(), "获取流程实例流水号失败!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
String taskNo = bo.getAttribute("SERIALNO").getValue()
|
||||
.toString();
|
||||
fieldMap.put("taskNo", taskNo);
|
||||
fieldMap.put("taskNo".toLowerCase(), taskNo);
|
||||
fieldMap.put("task_no", taskNo);
|
||||
fieldMap.put("task_No".toLowerCase(), taskNo);
|
||||
} else {
|
||||
ReturnMapUtil.setReturnMap(null,
|
||||
RestfullConstant.baseProperty.get("FAIL")
|
||||
.toString(), "未找到该流程!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
|
||||
String id = request.getParameter("id");
|
||||
|
||||
AppConfigFlow AppConfigFlow = new AppConfigFlow();
|
||||
AppConfigFlow.setId(id);
|
||||
BizObject library = AppConfigFlow.queryLibraryById(tx);
|
||||
if (null == library) {
|
||||
ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
.get("FAIL").toString(), "未找到模板配置!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
// APP页签模板分组号
|
||||
groupCode = library.getAttribute("APP_BUSINESS_GROUP_CODE") == null ? ""
|
||||
: library.getAttribute("APP_BUSINESS_GROUP_CODE")
|
||||
.toString();
|
||||
if (StringX.isSpace(groupCode)) {
|
||||
ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
.get("FAIL").toString(), "APP页签模板分组号码无效!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
// 接口描述 DefaultDoManage 默认类型
|
||||
interfaceDesc = library.getAttribute("INTERFACE_DESC") == null ? ""
|
||||
: library.getAttribute("INTERFACE_DESC").toString();
|
||||
// if (!"DefaultDoManage".equals(interfaceDesc)) {
|
||||
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
// .get("FAIL").toString(),
|
||||
// "调用模板接口错误,此页面不是默认模板查询!请使用接口:/webapi/resf" + interfaceDesc);
|
||||
// return ReturnMapUtil.getReturnMap();
|
||||
// }
|
||||
String classpath = "apx.com.amarsoft.als.base.awe.controller.DefaultDoManage";
|
||||
//
|
||||
if (!"DefaultDoManage".equals(interfaceDesc)) {
|
||||
classpath = library.getAttribute("DISPLAY_MANAGE_CLASS") == null ? ""
|
||||
: library.getAttribute("DISPLAY_MANAGE_CLASS")
|
||||
.toString();
|
||||
}
|
||||
initialCondition = library.getAttribute("INITIAL_CONDITION") == null ? ""
|
||||
: library.getAttribute("INITIAL_CONDITION").toString();
|
||||
initialConditionHandler(library);
|
||||
auxiliaryCondition = library.getAttribute("AUXILIARY_CONDITION") == null ? ""
|
||||
: library.getAttribute("AUXILIARY_CONDITION").toString();
|
||||
String otherWhere = auxiliaryConditionHandle(library);
|
||||
System.out.println("othereWhere :" + otherWhere);
|
||||
|
||||
AppConfigFlow.setGroupCode(groupCode);
|
||||
BizObject group = AppConfigFlow.queryGroup(tx);
|
||||
if (null == group) {
|
||||
ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
.get("FAIL").toString(), "未找到模板配置!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
List<BizObject> templates = AppConfigFlow.queryTemplate(tx);
|
||||
if (templates.size() < 1) {
|
||||
ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
.get("FAIL").toString(), "未找到模板配置!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
BizObject template = templates.get(0);
|
||||
// dono = template.getAttribute("dono") == null ? "" : template
|
||||
// .getAttribute("dono").toString();
|
||||
dono = groupCode;
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class classPathClass = Class.forName(classpath);
|
||||
Object obj = classPathClass.newInstance();
|
||||
Method targetMethod = null;
|
||||
Method[] cls = classPathClass.getDeclaredMethods();
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase("setDono")) {
|
||||
targetMethod = cls[j];
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
Lparam.add(this.dono);
|
||||
targetMethod.invoke(obj, Lparam.toArray());
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase("setsAddWhere")) {
|
||||
targetMethod = cls[j];
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
Lparam.add(otherWhere);
|
||||
targetMethod.invoke(obj, Lparam.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase("setFieldMap")) {
|
||||
targetMethod = cls[j];
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
Lparam.add(fieldMap);
|
||||
targetMethod.invoke(obj, Lparam.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
// for (int j = 0; j < cls.length; j++) {
|
||||
// if (cls[j].getName().equalsIgnoreCase("setReturnMapUtil")) {
|
||||
// targetMethod = cls[j];
|
||||
// List<Object> Lparam = new ArrayList<Object>();
|
||||
// Lparam.add(ReturnMapUtil);
|
||||
// targetMethod.invoke(obj, Lparam.toArray());
|
||||
// }
|
||||
// }
|
||||
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase("queryDefaultDo")) {
|
||||
targetMethod = cls[j];
|
||||
Lparam.add(request);
|
||||
Lparam.add(sqlca);
|
||||
Lparam.add(tx);
|
||||
Lparam.add(ReturnMapUtil);
|
||||
}
|
||||
}
|
||||
return (Map<String, Object>) targetMethod.invoke(obj,
|
||||
Lparam.toArray());
|
||||
// if (value == null) {
|
||||
// value = "";
|
||||
// }
|
||||
|
||||
// DefaultDoManage manage = new DefaultDoManage();
|
||||
// manage.setDono(this.dono);
|
||||
// manage.setsAddWhere(otherWhere);
|
||||
// manage.setParamMap(fieldMap);
|
||||
// return manage.queryDefaultDo(request, sqlca, tx);
|
||||
} catch (Exception e) {
|
||||
return ReturnMapUtil.rollback(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void initialConditionHandler(BizObject library) throws JBOException {
|
||||
// groupcode,userid
|
||||
if (StringX.isSpace(initialCondition)) {
|
||||
return;
|
||||
}
|
||||
String[] array = initialCondition.split(",");
|
||||
for (String str : array) {
|
||||
str = str.trim();
|
||||
if (fieldMap.get(str.toLowerCase()) != null)
|
||||
continue;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
String param = "ATTRIBUTE" + i;
|
||||
String str2 = library.getAttribute(param) == null ? ""
|
||||
: library.getAttribute(param).toString();
|
||||
str2 = str2.trim();
|
||||
if (StringX.isSpace(str2) || StringX.isSpace(str)) {
|
||||
continue;
|
||||
}
|
||||
// where条件参数处理
|
||||
String str3 = whereParamHandle(str, str2);
|
||||
if ("continue".equals(str3))
|
||||
continue;
|
||||
else if ("execute".equals(str3))
|
||||
continue;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String auxiliaryConditionHandle(BizObject library)
|
||||
throws JBOException {
|
||||
// " and groupcode=:groupcode and userid=:userid@groupcode,userid"
|
||||
// and groupcode=:groupcode and userid=:userid
|
||||
// groupcode,userid
|
||||
// 附加查询条件
|
||||
String otherWhere = "";
|
||||
if (!StringX.isSpace(auxiliaryCondition)) {
|
||||
String[] array = auxiliaryCondition.split("@");
|
||||
if (array.length > 0)
|
||||
otherWhere = array[0];
|
||||
if (array.length > 1) {
|
||||
String otherWhereParam = array[1];
|
||||
String[] array2 = otherWhereParam.split(",");
|
||||
if (array2.length > 0) {
|
||||
for (String str : array2) {
|
||||
str = str.trim();
|
||||
for (int i = 1; i < 10; i++) {
|
||||
if (fieldMap.get(str.toLowerCase()) == null) {
|
||||
String param = "ATTRIBUTE" + i;
|
||||
String str2 = library.getAttribute(param) == null ? ""
|
||||
: library.getAttribute(param)
|
||||
.toString();
|
||||
str2 = str2.trim();
|
||||
if (StringX.isSpace(str2)
|
||||
|| StringX.isSpace(str)) {
|
||||
// otherWhere = otherWhere.replace(":" +
|
||||
// str,
|
||||
// "''");
|
||||
continue;
|
||||
}
|
||||
// 附加条件 和 where条件参数处理
|
||||
String str3 = whereParamHandle(str, str2);
|
||||
if ("continue".equals(str3))
|
||||
continue;
|
||||
else if ("execute".equals(str3))
|
||||
continue;
|
||||
else
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return otherWhere;
|
||||
}
|
||||
|
||||
public String executeMethod(String colactualname, String... params) {
|
||||
|
||||
String value = "";
|
||||
|
||||
try {
|
||||
String classpath = colactualname.substring(0,
|
||||
colactualname.lastIndexOf("."));
|
||||
String methodName = colactualname.substring(
|
||||
colactualname.lastIndexOf(".") + 1,
|
||||
colactualname.indexOf("("));
|
||||
String paramsname = colactualname.substring(
|
||||
colactualname.indexOf("(") + 1, colactualname.indexOf(")"));
|
||||
String[] vParams = paramsname.split(",");
|
||||
if (vParams.length == 1 && "".equals(vParams[0].trim()))
|
||||
vParams = new String[0];
|
||||
if (vParams.length != params.length) {
|
||||
return null;
|
||||
}
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
for (String param : params) {
|
||||
Lparam.add(param);
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class classPathClass = Class.forName(classpath);
|
||||
Object obj = classPathClass.newInstance();
|
||||
Method targetMethod = null;
|
||||
Method[] cls = classPathClass.getDeclaredMethods();
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase(methodName)) {
|
||||
targetMethod = cls[j];
|
||||
}
|
||||
}
|
||||
value = (String) targetMethod.invoke(obj, Lparam.toArray());
|
||||
if (value == null) {
|
||||
value = "";
|
||||
}
|
||||
} catch (ClassNotFoundException | InstantiationException
|
||||
| IllegalAccessException | SecurityException
|
||||
| IllegalArgumentException | InvocationTargetException e) {
|
||||
ARE.getLog().error("executeMethod" + e);
|
||||
return null;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String whereParamHandle(String paramStr, String attribute) {
|
||||
// attribute:com.amarsoft.app.lc.workflow.action.GetFlowActionGetFlowAction.getFlowParamByFlowUnid(FlowUnid,serialno)@CustomerId
|
||||
// com.amarsoft.app.lc.workflow.action.GetFlowActionGetFlowAction.getFlowParamByFlowUnid(FlowUnid,serialno)
|
||||
// CustomerId
|
||||
String[] array = attribute.split("@");
|
||||
if (array.length < 2)
|
||||
return "continue";
|
||||
String classStr = array[0];
|
||||
String paramStr2 = array[1];
|
||||
classStr = classStr.trim();
|
||||
paramStr2.trim();
|
||||
if (!paramStr.toLowerCase().equals(paramStr2.toLowerCase())) {
|
||||
return "continue";
|
||||
}
|
||||
System.out.println(classStr);
|
||||
String param = classStr.substring(classStr.indexOf("(") + 1,
|
||||
classStr.indexOf(")"));
|
||||
param = param.trim();
|
||||
System.out.println(param);
|
||||
|
||||
String[] array1 = param.split(",");
|
||||
if (array1.length == 1 && "".equals(array1[0])) {
|
||||
String[] aSet = new String[0];
|
||||
String value = executeMethod(classStr, aSet);
|
||||
fieldMap.put(paramStr.toLowerCase(), value);
|
||||
fieldMap.put(paramStr.toUpperCase(), value);
|
||||
fieldMap.put(paramStr, value);
|
||||
return "execute";
|
||||
}
|
||||
|
||||
int count = array1.length;
|
||||
String[] aSet = new String[count];
|
||||
int i = 0;
|
||||
for (String str : array1) {
|
||||
str = str.trim();
|
||||
if (fieldMap.get(param.toLowerCase()) == null) {
|
||||
return "continue";
|
||||
}
|
||||
aSet[i] = fieldMap.get(param.toLowerCase()).toString();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fieldMap.get(param.toLowerCase()) == null) {
|
||||
return "continue";
|
||||
}
|
||||
|
||||
String value = executeMethod(classStr, aSet);
|
||||
fieldMap.put(paramStr.toLowerCase(), value);
|
||||
fieldMap.put(paramStr.toUpperCase(), value);
|
||||
fieldMap.put(paramStr, value);
|
||||
return "execute";
|
||||
}
|
||||
|
||||
public String whereParamHandle(String sqlWhere, String whereParam,
|
||||
String attribute) {
|
||||
String[] array = attribute.split("@");
|
||||
if (array.length < 2)
|
||||
return "continue";
|
||||
String classStr = array[0];
|
||||
String paramStr2 = array[1];
|
||||
classStr = classStr.trim();
|
||||
paramStr2.trim();
|
||||
if (!whereParam.toLowerCase().equals(paramStr2.toLowerCase())) {
|
||||
return "continue";
|
||||
}
|
||||
System.out.println(classStr);
|
||||
String param = classStr.substring(classStr.indexOf("(") + 1,
|
||||
classStr.indexOf(")"));
|
||||
param = param.trim();
|
||||
System.out.println(param);
|
||||
|
||||
String[] array1 = param.split(",");
|
||||
int count = array1.length;
|
||||
String[] aSet = new String[count];
|
||||
int i = 0;
|
||||
for (String str : array1) {
|
||||
str = str.trim();
|
||||
if (fieldMap.get(param.toLowerCase()) == null) {
|
||||
return "continue";
|
||||
}
|
||||
aSet[i] = fieldMap.get(param.toLowerCase()).toString();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fieldMap.get(param.toLowerCase()) == null) {
|
||||
return "continue";
|
||||
}
|
||||
|
||||
String value = executeMethod(classStr, aSet);
|
||||
fieldMap.put(whereParam.toLowerCase(), value);
|
||||
fieldMap.put(whereParam.toUpperCase(), value);
|
||||
fieldMap.put(whereParam, value);
|
||||
return "execute";
|
||||
}
|
||||
|
||||
public String whereHandle(String sqlWhere) {
|
||||
return AweDoCommUtil.whereHandle(sqlWhere, fieldMap);
|
||||
}
|
||||
|
||||
}
|
||||
package apx.com.amarsoft.als.base.awe.controller;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import apx.com.amarsoft.als.base.awe.util.AweDoCommUtil;
|
||||
import apx.com.amarsoft.als.base.flow.AppConfigFlow;
|
||||
import apx.com.amarsoft.als.base.flow.FlowTask;
|
||||
|
||||
import com.amarsoft.are.ARE;
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
import com.amarsoft.are.lang.StringX;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.base.constant.RestfullConstant;
|
||||
import com.base.util.MultipartDataUtil;
|
||||
import com.base.util.ReturnMapUtil;
|
||||
|
||||
@Path("/comm/query/by/dono")
|
||||
public class AweDoQueryController {
|
||||
private String dono;
|
||||
private String groupCode;
|
||||
private String interfaceDesc;
|
||||
private String initialCondition;
|
||||
private String auxiliaryCondition;
|
||||
// private String addWhere;
|
||||
private Map<String, Object> fieldMap;
|
||||
|
||||
// ReturnMapUtil ReturnMapUtil = new ReturnMapUtil();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Path("/data")
|
||||
@POST
|
||||
public Map<String, Object> query(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response, @Context JBOTransaction tx,
|
||||
@Context Transaction sqlca) throws Exception {
|
||||
ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(tx, sqlca);
|
||||
ARE.getLog().info(
|
||||
"[CONTROLLER] AweDoQueryController run .................");
|
||||
ARE.getLog().info(
|
||||
"[Path] /comm/query/by/dono/data" + " run .................");
|
||||
try {
|
||||
|
||||
Map<String, Object> testMap = (Map<String, Object>) MultipartDataUtil
|
||||
.readRequestParam(request, "UTF-8");
|
||||
fieldMap = (Map<String, Object>) testMap.get("fieldMap");
|
||||
String objectNo = fieldMap.get("OBJECTNO") == null ? "" : fieldMap
|
||||
.get("OBJECTNO").toString();
|
||||
fieldMap.put("OBJECTNO", objectNo);
|
||||
fieldMap.put("OBJECTNO".toLowerCase(), objectNo);
|
||||
fieldMap.put("FLOWUNID", objectNo);
|
||||
fieldMap.put("FLOWUNID".toLowerCase(), objectNo);
|
||||
fieldMap.put("FLOW_UNID", objectNo);
|
||||
fieldMap.put("FLOW_UNID".toLowerCase(), objectNo);
|
||||
if (objectNo.length() > 1) {
|
||||
FlowTask FlowTask = new FlowTask();
|
||||
BizObject bo = FlowTask.queryFlowTask(request, sqlca, tx, fieldMap);
|
||||
if (null != bo) {
|
||||
if (null == bo.getAttribute("SERIALNO")) {
|
||||
ReturnMapUtil.setReturnMap(null,
|
||||
RestfullConstant.baseProperty.get("FAIL")
|
||||
.toString(), "获取流程实例流水号失败!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
String taskNo = bo.getAttribute("SERIALNO").getValue()
|
||||
.toString();
|
||||
fieldMap.put("taskNo", taskNo);
|
||||
fieldMap.put("taskNo".toLowerCase(), taskNo);
|
||||
fieldMap.put("task_no", taskNo);
|
||||
fieldMap.put("task_No".toLowerCase(), taskNo);
|
||||
} else {
|
||||
ReturnMapUtil.setReturnMap(null,
|
||||
RestfullConstant.baseProperty.get("FAIL")
|
||||
.toString(), "未找到该流程!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
}
|
||||
|
||||
String id = request.getParameter("id");
|
||||
|
||||
AppConfigFlow AppConfigFlow = new AppConfigFlow();
|
||||
AppConfigFlow.setId(id);
|
||||
BizObject library = AppConfigFlow.queryLibraryById(tx);
|
||||
if (null == library) {
|
||||
ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
.get("FAIL").toString(), "未找到模板配置!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
// APP页签模板分组号
|
||||
groupCode = library.getAttribute("APP_BUSINESS_GROUP_CODE") == null ? ""
|
||||
: library.getAttribute("APP_BUSINESS_GROUP_CODE")
|
||||
.toString();
|
||||
if (StringX.isSpace(groupCode)) {
|
||||
ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
.get("FAIL").toString(), "APP页签模板分组号码无效!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
// 接口描述 DefaultDoManage 默认类型
|
||||
interfaceDesc = library.getAttribute("INTERFACE_DESC") == null ? ""
|
||||
: library.getAttribute("INTERFACE_DESC").toString();
|
||||
// if (!"DefaultDoManage".equals(interfaceDesc)) {
|
||||
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
// .get("FAIL").toString(),
|
||||
// "调用模板接口错误,此页面不是默认模板查询!请使用接口:/webapi/resf" + interfaceDesc);
|
||||
// return ReturnMapUtil.getReturnMap();
|
||||
// }
|
||||
String classpath = "apx.com.amarsoft.als.base.awe.controller.DefaultDoManage";
|
||||
//
|
||||
if (!"DefaultDoManage".equals(interfaceDesc)) {
|
||||
classpath = library.getAttribute("DISPLAY_MANAGE_CLASS") == null ? ""
|
||||
: library.getAttribute("DISPLAY_MANAGE_CLASS")
|
||||
.toString();
|
||||
}
|
||||
initialCondition = library.getAttribute("INITIAL_CONDITION") == null ? ""
|
||||
: library.getAttribute("INITIAL_CONDITION").toString();
|
||||
initialConditionHandler(library);
|
||||
auxiliaryCondition = library.getAttribute("AUXILIARY_CONDITION") == null ? ""
|
||||
: library.getAttribute("AUXILIARY_CONDITION").toString();
|
||||
String otherWhere = auxiliaryConditionHandle(library);
|
||||
System.out.println("othereWhere :" + otherWhere);
|
||||
|
||||
AppConfigFlow.setGroupCode(groupCode);
|
||||
BizObject group = AppConfigFlow.queryGroup(tx);
|
||||
if (null == group) {
|
||||
ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
.get("FAIL").toString(), "未找到模板配置!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
List<BizObject> templates = AppConfigFlow.queryTemplate(tx);
|
||||
if (templates.size() < 1) {
|
||||
ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
.get("FAIL").toString(), "未找到模板配置!");
|
||||
return ReturnMapUtil.getReturnMap();
|
||||
}
|
||||
BizObject template = templates.get(0);
|
||||
// dono = template.getAttribute("dono") == null ? "" : template
|
||||
// .getAttribute("dono").toString();
|
||||
dono = groupCode;
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class classPathClass = Class.forName(classpath);
|
||||
Object obj = classPathClass.newInstance();
|
||||
Method targetMethod = null;
|
||||
Method[] cls = classPathClass.getDeclaredMethods();
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase("setDono")) {
|
||||
targetMethod = cls[j];
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
Lparam.add(this.dono);
|
||||
targetMethod.invoke(obj, Lparam.toArray());
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase("setsAddWhere")) {
|
||||
targetMethod = cls[j];
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
Lparam.add(otherWhere);
|
||||
targetMethod.invoke(obj, Lparam.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase("setFieldMap")) {
|
||||
targetMethod = cls[j];
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
Lparam.add(fieldMap);
|
||||
targetMethod.invoke(obj, Lparam.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
// for (int j = 0; j < cls.length; j++) {
|
||||
// if (cls[j].getName().equalsIgnoreCase("setReturnMapUtil")) {
|
||||
// targetMethod = cls[j];
|
||||
// List<Object> Lparam = new ArrayList<Object>();
|
||||
// Lparam.add(ReturnMapUtil);
|
||||
// targetMethod.invoke(obj, Lparam.toArray());
|
||||
// }
|
||||
// }
|
||||
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase("queryDefaultDo")) {
|
||||
targetMethod = cls[j];
|
||||
Lparam.add(request);
|
||||
Lparam.add(sqlca);
|
||||
Lparam.add(tx);
|
||||
Lparam.add(ReturnMapUtil);
|
||||
}
|
||||
}
|
||||
return (Map<String, Object>) targetMethod.invoke(obj,
|
||||
Lparam.toArray());
|
||||
// if (value == null) {
|
||||
// value = "";
|
||||
// }
|
||||
|
||||
// DefaultDoManage manage = new DefaultDoManage();
|
||||
// manage.setDono(this.dono);
|
||||
// manage.setsAddWhere(otherWhere);
|
||||
// manage.setParamMap(fieldMap);
|
||||
// return manage.queryDefaultDo(request, sqlca, tx);
|
||||
} catch (Exception e) {
|
||||
return ReturnMapUtil.rollback(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void initialConditionHandler(BizObject library) throws JBOException {
|
||||
// groupcode,userid
|
||||
if (StringX.isSpace(initialCondition)) {
|
||||
return;
|
||||
}
|
||||
String[] array = initialCondition.split(",");
|
||||
for (String str : array) {
|
||||
str = str.trim();
|
||||
if (fieldMap.get(str.toLowerCase()) != null)
|
||||
continue;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
String param = "ATTRIBUTE" + i;
|
||||
String str2 = library.getAttribute(param) == null ? ""
|
||||
: library.getAttribute(param).toString();
|
||||
str2 = str2.trim();
|
||||
if (StringX.isSpace(str2) || StringX.isSpace(str)) {
|
||||
continue;
|
||||
}
|
||||
// where条件参数处理
|
||||
String str3 = whereParamHandle(str, str2);
|
||||
if ("continue".equals(str3))
|
||||
continue;
|
||||
else if ("execute".equals(str3))
|
||||
continue;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String auxiliaryConditionHandle(BizObject library)
|
||||
throws JBOException {
|
||||
// " and groupcode=:groupcode and userid=:userid@groupcode,userid"
|
||||
// and groupcode=:groupcode and userid=:userid
|
||||
// groupcode,userid
|
||||
// 附加查询条件
|
||||
String otherWhere = "";
|
||||
if (!StringX.isSpace(auxiliaryCondition)) {
|
||||
String[] array = auxiliaryCondition.split("@");
|
||||
if (array.length > 0)
|
||||
otherWhere = array[0];
|
||||
if (array.length > 1) {
|
||||
String otherWhereParam = array[1];
|
||||
String[] array2 = otherWhereParam.split(",");
|
||||
if (array2.length > 0) {
|
||||
for (String str : array2) {
|
||||
str = str.trim();
|
||||
for (int i = 1; i < 10; i++) {
|
||||
if (fieldMap.get(str.toLowerCase()) == null) {
|
||||
String param = "ATTRIBUTE" + i;
|
||||
String str2 = library.getAttribute(param) == null ? ""
|
||||
: library.getAttribute(param)
|
||||
.toString();
|
||||
str2 = str2.trim();
|
||||
if (StringX.isSpace(str2)
|
||||
|| StringX.isSpace(str)) {
|
||||
// otherWhere = otherWhere.replace(":" +
|
||||
// str,
|
||||
// "''");
|
||||
continue;
|
||||
}
|
||||
// 附加条件 和 where条件参数处理
|
||||
String str3 = whereParamHandle(str, str2);
|
||||
if ("continue".equals(str3))
|
||||
continue;
|
||||
else if ("execute".equals(str3))
|
||||
continue;
|
||||
else
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return otherWhere;
|
||||
}
|
||||
|
||||
public String executeMethod(String colactualname, String... params) {
|
||||
|
||||
String value = "";
|
||||
|
||||
try {
|
||||
String classpath = colactualname.substring(0,
|
||||
colactualname.lastIndexOf("."));
|
||||
String methodName = colactualname.substring(
|
||||
colactualname.lastIndexOf(".") + 1,
|
||||
colactualname.indexOf("("));
|
||||
String paramsname = colactualname.substring(
|
||||
colactualname.indexOf("(") + 1, colactualname.indexOf(")"));
|
||||
String[] vParams = paramsname.split(",");
|
||||
if (vParams.length == 1 && "".equals(vParams[0].trim()))
|
||||
vParams = new String[0];
|
||||
if (vParams.length != params.length) {
|
||||
return null;
|
||||
}
|
||||
List<Object> Lparam = new ArrayList<Object>();
|
||||
for (String param : params) {
|
||||
Lparam.add(param);
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class classPathClass = Class.forName(classpath);
|
||||
Object obj = classPathClass.newInstance();
|
||||
Method targetMethod = null;
|
||||
Method[] cls = classPathClass.getDeclaredMethods();
|
||||
for (int j = 0; j < cls.length; j++) {
|
||||
if (cls[j].getName().equalsIgnoreCase(methodName)) {
|
||||
targetMethod = cls[j];
|
||||
}
|
||||
}
|
||||
value = (String) targetMethod.invoke(obj, Lparam.toArray());
|
||||
if (value == null) {
|
||||
value = "";
|
||||
}
|
||||
} catch (ClassNotFoundException | InstantiationException
|
||||
| IllegalAccessException | SecurityException
|
||||
| IllegalArgumentException | InvocationTargetException e) {
|
||||
ARE.getLog().error("executeMethod" + e);
|
||||
return null;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String whereParamHandle(String paramStr, String attribute) {
|
||||
// attribute:com.amarsoft.app.lc.workflow.action.GetFlowActionGetFlowAction.getFlowParamByFlowUnid(FlowUnid,serialno)@CustomerId
|
||||
// com.amarsoft.app.lc.workflow.action.GetFlowActionGetFlowAction.getFlowParamByFlowUnid(FlowUnid,serialno)
|
||||
// CustomerId
|
||||
String[] array = attribute.split("@");
|
||||
if (array.length < 2)
|
||||
return "continue";
|
||||
String classStr = array[0];
|
||||
String paramStr2 = array[1];
|
||||
classStr = classStr.trim();
|
||||
paramStr2.trim();
|
||||
if (!paramStr.toLowerCase().equals(paramStr2.toLowerCase())) {
|
||||
return "continue";
|
||||
}
|
||||
System.out.println(classStr);
|
||||
String param = classStr.substring(classStr.indexOf("(") + 1,
|
||||
classStr.indexOf(")"));
|
||||
param = param.trim();
|
||||
System.out.println(param);
|
||||
|
||||
String[] array1 = param.split(",");
|
||||
if (array1.length == 1 && "".equals(array1[0])) {
|
||||
String[] aSet = new String[0];
|
||||
String value = executeMethod(classStr, aSet);
|
||||
fieldMap.put(paramStr.toLowerCase(), value);
|
||||
fieldMap.put(paramStr.toUpperCase(), value);
|
||||
fieldMap.put(paramStr, value);
|
||||
return "execute";
|
||||
}
|
||||
|
||||
int count = array1.length;
|
||||
String[] aSet = new String[count];
|
||||
int i = 0;
|
||||
for (String str : array1) {
|
||||
str = str.trim();
|
||||
if (fieldMap.get(param.toLowerCase()) == null) {
|
||||
return "continue";
|
||||
}
|
||||
aSet[i] = fieldMap.get(param.toLowerCase()).toString();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fieldMap.get(param.toLowerCase()) == null) {
|
||||
return "continue";
|
||||
}
|
||||
|
||||
String value = executeMethod(classStr, aSet);
|
||||
fieldMap.put(paramStr.toLowerCase(), value);
|
||||
fieldMap.put(paramStr.toUpperCase(), value);
|
||||
fieldMap.put(paramStr, value);
|
||||
return "execute";
|
||||
}
|
||||
|
||||
public String whereParamHandle(String sqlWhere, String whereParam,
|
||||
String attribute) {
|
||||
String[] array = attribute.split("@");
|
||||
if (array.length < 2)
|
||||
return "continue";
|
||||
String classStr = array[0];
|
||||
String paramStr2 = array[1];
|
||||
classStr = classStr.trim();
|
||||
paramStr2.trim();
|
||||
if (!whereParam.toLowerCase().equals(paramStr2.toLowerCase())) {
|
||||
return "continue";
|
||||
}
|
||||
System.out.println(classStr);
|
||||
String param = classStr.substring(classStr.indexOf("(") + 1,
|
||||
classStr.indexOf(")"));
|
||||
param = param.trim();
|
||||
System.out.println(param);
|
||||
|
||||
String[] array1 = param.split(",");
|
||||
int count = array1.length;
|
||||
String[] aSet = new String[count];
|
||||
int i = 0;
|
||||
for (String str : array1) {
|
||||
str = str.trim();
|
||||
if (fieldMap.get(param.toLowerCase()) == null) {
|
||||
return "continue";
|
||||
}
|
||||
aSet[i] = fieldMap.get(param.toLowerCase()).toString();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fieldMap.get(param.toLowerCase()) == null) {
|
||||
return "continue";
|
||||
}
|
||||
|
||||
String value = executeMethod(classStr, aSet);
|
||||
fieldMap.put(whereParam.toLowerCase(), value);
|
||||
fieldMap.put(whereParam.toUpperCase(), value);
|
||||
fieldMap.put(whereParam, value);
|
||||
return "execute";
|
||||
}
|
||||
|
||||
public String whereHandle(String sqlWhere) {
|
||||
return AweDoCommUtil.whereHandle(sqlWhere, fieldMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user