549 lines
35 KiB
Java
549 lines
35 KiB
Java
package com.awspaas.user.bpa.webapi;
|
||
|
||
import com.actionsoft.bpms.bo.engine.BO;
|
||
import com.actionsoft.bpms.commons.database.RowMap;
|
||
import com.actionsoft.bpms.org.model.UserModel;
|
||
import com.actionsoft.bpms.server.UserContext;
|
||
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
||
import com.actionsoft.bpms.server.bind.annotation.HandlerType;
|
||
import com.actionsoft.bpms.server.bind.annotation.Param;
|
||
import com.actionsoft.bpms.util.DBSql;
|
||
import com.actionsoft.bpms.util.UtilString;
|
||
import com.actionsoft.sdk.local.SDK;
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.awspaas.user.bpa.util.UtilUrls;
|
||
import org.dom4j.Document;
|
||
import org.dom4j.DocumentException;
|
||
import org.dom4j.DocumentHelper;
|
||
import org.dom4j.Element;
|
||
|
||
import javax.ws.rs.GET;
|
||
import javax.ws.rs.POST;
|
||
import javax.ws.rs.Path;
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.Date;
|
||
import java.util.LinkedHashMap;
|
||
import java.util.LinkedList;
|
||
import java.util.List;
|
||
|
||
|
||
@Controller(type = HandlerType.RESTFUL, apiName = "workfolwapi", desc = "伊利新版BPA接口")
|
||
@Path("/workfolw")
|
||
public class WorkFlowAPI {
|
||
|
||
@GET
|
||
public String sayHello() {
|
||
return "hello,world! - get请求";
|
||
}
|
||
|
||
@POST
|
||
public String sayHelloPost() {
|
||
return "hello,world!- post请求";
|
||
}
|
||
|
||
|
||
/**
|
||
* 这个是传流程结束的json数据的
|
||
* @return activiti流程信息
|
||
* @throws DocumentException
|
||
* @throws ParseException
|
||
*/
|
||
@Path("/process/endprocess")
|
||
@GET
|
||
public String getEndProcess(
|
||
@Param String starttime,
|
||
@Param String endtime) throws DocumentException, ParseException {
|
||
JSONArray jsonArray_new = new JSONArray(new LinkedList<>());
|
||
JSONObject results = new JSONObject(new LinkedHashMap<>());
|
||
System.out.println("这里是end_process流程的伊利OA数据");
|
||
|
||
|
||
//List<BO> bo_eu_oa_process = SDK.getBOAPI().query("BO_EU_MODEL", true).list();
|
||
List<RowMap> maps = DBSql.getMaps("select * from APP_ACT_BPAD_P_VER_ACTIVITY where ID = '124' order by CAST(EXT1 as int) asc");
|
||
int q=0;
|
||
for (RowMap bos:maps
|
||
) {
|
||
if (q<=maps.size()){
|
||
|
||
JSONObject jsonObject = new JSONObject(new LinkedHashMap());
|
||
String soap_page = SDK.getAppAPI().getProperty("com.awspaas.user.apps.performance_indicator_library", "soap_page");//这里是获取配置的SOAP接口传的多少页,如果3500左右不够可以自行往上增加
|
||
|
||
|
||
int size = Integer.valueOf(soap_page);
|
||
|
||
for (int j = 1; j < size; j++) {
|
||
|
||
int tale = Integer.valueOf(bos.getString("ID").trim());
|
||
|
||
jsonObject.put("workflowId", tale);
|
||
// jsonObject.put("workflowId",bo.getString("WORKFLOWID"));
|
||
//jsonObject.put("createDateStart","2019-07-01 00:00:00");//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
|
||
//jsonObject.put("createDateEnd","2023-09-01 00:00:00");//processExecutionContext.getProcessInstance().getCreateUser()
|
||
jsonObject.put("pageIndex", j);
|
||
jsonObject.put("pageSize", 1000);
|
||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.services.weaver.com.cn\">\n" +
|
||
" <soapenv:Header/>" +
|
||
" <soapenv:Body>" +
|
||
" <web:getFlowListByWfId>" +
|
||
" <web:in0>" +
|
||
"" + jsonObject + "" +
|
||
" </web:in0>" +
|
||
" </web:getFlowListByWfId>" +
|
||
" </soapenv:Body>" +
|
||
"</soapenv:Envelope>";
|
||
|
||
System.out.println("参数===============" + xmlStr);
|
||
//System.out.println("参数==============="+xmls);
|
||
//HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||
int timeout = 600000;
|
||
// HttpURLConnection 发送SOAP请求
|
||
System.out.println("HttpURLConnection 发送SOAP请求");
|
||
|
||
String postSoap = UtilUrls.doPostSoap("http://10.119.22.207:80/services/WorkflowService", xmlStr, "");
|
||
|
||
|
||
Document document = DocumentHelper.parseText(postSoap);
|
||
Element rootElement = document.getRootElement();
|
||
// System.out.println("rootElement>>>>>>"+rootElement);
|
||
Element result = rootElement.element("Body").element("getFlowListByWfIdResponse").element("out");
|
||
String resultString = result.getData().toString();
|
||
System.out.println("resultString=>>>>>>>>>>"+resultString);
|
||
//if (!StringUtils.isEmpty(resultString)){
|
||
JSONObject jsonObject1 = JSON.parseObject(resultString);
|
||
String datas = jsonObject1.getString("datas");
|
||
JSONArray jsonArray = JSONArray.parseArray(datas);
|
||
if (jsonArray != null && jsonArray.size() != 0) {
|
||
for (int i = 0; i < jsonArray.size(); i++) {
|
||
// JSONObject.parseObject(jsonArray.get(i).toString()).get("requestId")
|
||
JSONObject end_process = new JSONObject(new LinkedHashMap<>());
|
||
end_process.put("processinstid", JSONObject.parseObject(jsonArray.get(i).toString()).get("requestId").toString().trim());//流程实例id
|
||
end_process.put("processdefid", JSONObject.parseObject(jsonArray.get(i).toString()).get("workflowId").toString().trim());//流程定义id
|
||
RowMap workflowId = DBSql.getMap("select * from APP_ACT_BPAD_P_VER_ACTIVITY where ID = '" + JSONObject.parseObject(jsonArray.get(i).toString()).get("workflowId") + "'");
|
||
if (workflowId.getString("PROCESSVERSION") != null) {
|
||
end_process.put("processdefverid", workflowId.getString("VERSION"));//流程版本定义
|
||
} else {
|
||
end_process.put("processdefverid", "1");
|
||
}
|
||
end_process.put("starttime", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate"));//开始时间
|
||
end_process.put("endtime", JSONObject.parseObject(jsonArray.get(i).toString()).get("receiveDate"));//结束时间
|
||
end_process.put("createtime", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate"));//创建时间
|
||
|
||
|
||
UserModel operatorWorkCode = SDK.getORGAPI().getUser(JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode").toString());
|
||
if (operatorWorkCode != null) {
|
||
end_process.put("createuser", JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode"));//创建人
|
||
UserContext userContext = UserContext.fromUID(JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode").toString());
|
||
end_process.put("createuserorgid", userContext.getCompanyModel().getId());//公司id
|
||
end_process.put("createuserdeptid", userContext.getDepartmentModel().getId());//部门id
|
||
end_process.put("createuserroleid", userContext.getRoleModel().getId());//角色id
|
||
} else {
|
||
end_process.put("createuser", "admin");//创建人
|
||
UserContext userContext = UserContext.fromUID("admin");
|
||
end_process.put("createuserorgid", userContext.getCompanyModel().getId());//公司id
|
||
end_process.put("createuserdeptid", userContext.getDepartmentModel().getId());//部门id
|
||
end_process.put("createuserroleid", userContext.getRoleModel().getId());//角色id
|
||
}
|
||
|
||
end_process.put("controlstate", JSONObject.parseObject(jsonArray.get(i).toString()).get("status"));
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
Date beginDate = sdf.parse(JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate").toString());
|
||
if (UtilString.isNotEmpty(JSONObject.parseObject(jsonArray.get(i).toString()).get("receiveDate").toString())) {
|
||
Date endDate = sdf.parse(JSONObject.parseObject(jsonArray.get(i).toString()).get("receiveDate").toString());
|
||
long dates = (endDate.getTime() - beginDate.getTime()) / (1000 * 60);
|
||
end_process.put("executecosttime", dates);//开始时间-结束时间如果结束时间为空,则这个时间也为空
|
||
} else {
|
||
end_process.put("executecosttime", "");//开始时间-结束时间如果结束时间为空,则这个时间也为空
|
||
}
|
||
end_process.put("timedur", "");
|
||
end_process.put("warningtimedur", "");
|
||
jsonArray_new.add(end_process);
|
||
}
|
||
} else {
|
||
break;
|
||
}
|
||
|
||
}
|
||
}else {
|
||
break;
|
||
}
|
||
q++;
|
||
}
|
||
System.out.println("jsonArray_new.toString()>>>>>>>>>>>>>"+jsonArray_new.toString());
|
||
return jsonArray_new.toString();
|
||
}
|
||
|
||
/**
|
||
* 2.这里是传开始流程的startprocess的json数据的
|
||
* @return 开始流程
|
||
* @throws DocumentException
|
||
* @throws ParseException
|
||
*/
|
||
|
||
@Path("/process/startprocess")
|
||
@GET
|
||
public String getStartProcess(
|
||
@Param String starttime,
|
||
@Param String endtime) throws DocumentException, ParseException {
|
||
System.out.println("这里是开始流程的接口数据传递");
|
||
JSONArray jsonArray_new = new JSONArray(new LinkedList<>());
|
||
JSONObject results = new JSONObject(new LinkedHashMap<>());
|
||
List<RowMap> maps = DBSql.getMaps("select * from APP_ACT_BPAD_P_VER_ACTIVITY where ID = '124' order by CAST(EXT1 as int) asc");
|
||
int q = 0;
|
||
for (RowMap bos:maps
|
||
) {
|
||
if (q<=maps.size()){
|
||
|
||
JSONObject jsonObject = new JSONObject(new LinkedHashMap());
|
||
String soap_page = SDK.getAppAPI().getProperty("com.awspaas.user.apps.performance_indicator_library", "soap_page");//这里是获取配置的SOAP接口传的多少页,如果3500左右不够可以自行往上增加
|
||
|
||
|
||
int size = Integer.valueOf(soap_page);
|
||
|
||
for (int j = 1; j < size; j++) {
|
||
|
||
int tale = Integer.valueOf(bos.getString("ID").trim());
|
||
BO bo = new BO();
|
||
UserContext userContexts = UserContext.fromUID("admin");
|
||
bo.set("WORKID",bos.getString("ID"));
|
||
SDK.getBOAPI().createDataBO("BO_EU_TEST2",bo,userContexts);
|
||
jsonObject.put("workflowId", tale);
|
||
// jsonObject.put("workflowId",bo.getString("WORKFLOWID"));
|
||
//jsonObject.put("createDateStart","2019-07-01 00:00:00");//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
|
||
//jsonObject.put("createDateEnd","2023-09-01 00:00:00");//processExecutionContext.getProcessInstance().getCreateUser()
|
||
jsonObject.put("pageIndex", j);
|
||
jsonObject.put("pageSize", 1000);
|
||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.services.weaver.com.cn\">\n" +
|
||
" <soapenv:Header/>" +
|
||
" <soapenv:Body>" +
|
||
" <web:getFlowListByWfId>" +
|
||
" <web:in0>" +
|
||
"" + jsonObject + "" +
|
||
" </web:in0>" +
|
||
" </web:getFlowListByWfId>" +
|
||
" </soapenv:Body>" +
|
||
"</soapenv:Envelope>";
|
||
|
||
System.out.println("参数===============" + xmlStr);
|
||
//System.out.println("参数==============="+xmls);
|
||
//HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||
int timeout = 600000;
|
||
// HttpURLConnection 发送SOAP请求
|
||
System.out.println("HttpURLConnection 发送SOAP请求");
|
||
|
||
String postSoap = UtilUrls.doPostSoap("http://10.119.22.207:80/services/WorkflowService", xmlStr, "");
|
||
|
||
|
||
Document document = DocumentHelper.parseText(postSoap);
|
||
Element rootElement = document.getRootElement();
|
||
// System.out.println("rootElement>>>>>>"+rootElement);
|
||
Element result = rootElement.element("Body").element("getFlowListByWfIdResponse").element("out");
|
||
String resultString = result.getData().toString();
|
||
System.out.println("resultString=>>>>>>>>>>"+resultString);
|
||
//if (!StringUtils.isEmpty(resultString)){
|
||
JSONObject jsonObject1 = JSON.parseObject(resultString);
|
||
String datas = jsonObject1.getString("datas");
|
||
JSONArray jsonArray = JSONArray.parseArray(datas);
|
||
if (jsonArray != null && jsonArray.size() != 0) {
|
||
for (int i = 0; i < jsonArray.size(); i++) {
|
||
// JSONObject.parseObject(jsonArray.get(i).toString()).get("requestId")
|
||
JSONObject start_process = new JSONObject(new LinkedHashMap<>());
|
||
start_process.put("processinstid", JSONObject.parseObject(jsonArray.get(i).toString()).get("requestId"));//流程实例id
|
||
start_process.put("processdefid", JSONObject.parseObject(jsonArray.get(i).toString()).get("workflowId"));//流程定义id
|
||
RowMap workflowId = DBSql.getMap("select * from APP_ACT_BPAD_P_VER_ACTIVITY where ID = '" + JSONObject.parseObject(jsonArray.get(i).toString()).get("workflowId") + "'");
|
||
if (workflowId != null) {
|
||
start_process.put("processdefverid", workflowId.getString("PROCESSVERSION"));//流程版本定义
|
||
} else {
|
||
start_process.put("processdefverid", "1");
|
||
}
|
||
start_process.put("starttime", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate"));//开始时间
|
||
start_process.put("createtime", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate"));//创建时间
|
||
UserModel operatorWorkCode = SDK.getORGAPI().getUser(JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode").toString());
|
||
if (operatorWorkCode != null) {
|
||
start_process.put("createuser", JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode"));//创建人
|
||
UserContext userContext = UserContext.fromUID(JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode").toString());
|
||
start_process.put("createuserorgid", userContext.getCompanyModel().getId());//公司id
|
||
start_process.put("createuserdeptid", userContext.getDepartmentModel().getId());//部门id
|
||
start_process.put("createuserroleid", userContext.getRoleModel().getId());//角色id
|
||
} else {
|
||
start_process.put("createuser", "admin");//创建人
|
||
UserContext userContext = UserContext.fromUID("admin");
|
||
start_process.put("createuserorgid", userContext.getCompanyModel().getId());//公司id
|
||
start_process.put("createuserdeptid", userContext.getDepartmentModel().getId());//部门id
|
||
start_process.put("createuserroleid", userContext.getRoleModel().getId());//角色id
|
||
}
|
||
start_process.put("timedur", "");
|
||
start_process.put("warningtimedur", "");
|
||
start_process.put("controlstate", JSONObject.parseObject(jsonArray.get(i).toString()).get("status"));
|
||
jsonArray_new.add(start_process);
|
||
}
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
}else {
|
||
break;
|
||
}
|
||
q++;
|
||
}
|
||
System.out.println("jsonArray_new.toString()>>>>>>>>>>>>>"+jsonArray_new.toString());
|
||
return jsonArray_new.toString();
|
||
}
|
||
|
||
@Path("/task/startTask")
|
||
@GET
|
||
public String getStartTask(
|
||
@Param String starttime,
|
||
@Param String endtime) throws DocumentException {
|
||
System.out.println("开始任务数据对应的json数据");
|
||
JSONArray jsonArray_new = new JSONArray(new LinkedList<>());
|
||
JSONObject results = new JSONObject(new LinkedHashMap<>());
|
||
List<RowMap> maps = DBSql.getMaps("select * from APP_ACT_BPAD_P_VER_ACTIVITY where ID = '124' order by CAST(EXT1 as int) asc");
|
||
int q=0;
|
||
for (RowMap bos:maps
|
||
) {
|
||
if (q<=maps.size()){
|
||
|
||
JSONObject jsonObject = new JSONObject(new LinkedHashMap());
|
||
String soap_page = SDK.getAppAPI().getProperty("com.awspaas.user.apps.performance_indicator_library", "soap_page");//这里是获取配置的SOAP接口传的多少页,如果3500左右不够可以自行往上增加
|
||
|
||
|
||
int size = Integer.valueOf(soap_page);
|
||
|
||
for (int j = 1; j < size; j++) {
|
||
|
||
int tale = Integer.valueOf(bos.getString("ID").trim());
|
||
|
||
jsonObject.put("workflowId", tale);
|
||
// jsonObject.put("workflowId",bo.getString("WORKFLOWID"));
|
||
//jsonObject.put("createDateStart","2019-07-01 00:00:00");//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
|
||
//jsonObject.put("createDateEnd","2023-09-01 00:00:00");//processExecutionContext.getProcessInstance().getCreateUser()
|
||
jsonObject.put("pageIndex", j);
|
||
jsonObject.put("pageSize", 1000);
|
||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.services.weaver.com.cn\">\n" +
|
||
" <soapenv:Header/>" +
|
||
" <soapenv:Body>" +
|
||
" <web:getFlowListByWfId>" +
|
||
" <web:in0>" +
|
||
"" + jsonObject + "" +
|
||
" </web:in0>" +
|
||
" </web:getFlowListByWfId>" +
|
||
" </soapenv:Body>" +
|
||
"</soapenv:Envelope>";
|
||
|
||
System.out.println("参数===============" + xmlStr);
|
||
//System.out.println("参数==============="+xmls);
|
||
//HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||
int timeout = 600000;
|
||
// HttpURLConnection 发送SOAP请求
|
||
System.out.println("HttpURLConnection 发送SOAP请求");
|
||
|
||
String postSoap = UtilUrls.doPostSoap("http://10.119.22.207:80/services/WorkflowService", xmlStr, "");
|
||
|
||
|
||
Document document = DocumentHelper.parseText(postSoap);
|
||
Element rootElement = document.getRootElement();
|
||
// System.out.println("rootElement>>>>>>"+rootElement);
|
||
Element result = rootElement.element("Body").element("getFlowListByWfIdResponse").element("out");
|
||
String resultString = result.getData().toString();
|
||
System.out.println("resultString=>>>>>>>>>>"+resultString);
|
||
//if (!StringUtils.isEmpty(resultString)){
|
||
JSONObject jsonObject1 = JSON.parseObject(resultString);
|
||
String datas = jsonObject1.getString("datas");
|
||
JSONArray jsonArray = JSONArray.parseArray(datas);
|
||
if (jsonArray != null && jsonArray.size() != 0) {
|
||
for (int i = 0; i < jsonArray.size(); i++) {
|
||
// JSONObject.parseObject(jsonArray.get(i).toString()).get("requestId")
|
||
JSONObject start_task = new JSONObject(new LinkedHashMap<>());
|
||
start_task.put("taskinstid", JSONObject.parseObject(jsonArray.get(i).toString()).get("id"));//流程实例id
|
||
start_task.put("processdefid", JSONObject.parseObject(jsonArray.get(i).toString()).get("workflowId"));//流程定义id
|
||
RowMap workflowId = DBSql.getMap("select * from APP_ACT_BPAD_P_VER_ACTIVITY where ID = '" + JSONObject.parseObject(jsonArray.get(i).toString()).get("workflowId") + "'");
|
||
if (workflowId.getString("PROCESSVERSION") != null) {
|
||
start_task.put("processdefverid", workflowId.getString("PROCESSVERSION"));//流程版本定义
|
||
} else {
|
||
start_task.put("processdefverid", "1");
|
||
}
|
||
start_task.put("processinstid", JSONObject.parseObject(jsonArray.get(i).toString()).get("requestId"));
|
||
start_task.put("state", JSONObject.parseObject(jsonArray.get(i).toString()).get("status"));
|
||
start_task.put("begintime", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate"));//开始时间
|
||
UserModel operatorWorkCode = SDK.getORGAPI().getUser(JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode").toString());
|
||
if (operatorWorkCode != null) {
|
||
start_task.put("createuser", JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode"));//创建人
|
||
UserContext userContext = UserContext.fromUID(JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode").toString());
|
||
start_task.put("createuserorgid", userContext.getCompanyModel().getId());//公司id
|
||
start_task.put("createuserdeptid", userContext.getDepartmentModel().getId());//部门id
|
||
start_task.put("createuserroleid", userContext.getRoleModel().getId());//角色id
|
||
} else {
|
||
start_task.put("createuser", "admin");//创建人
|
||
UserContext userContext = UserContext.fromUID("admin");
|
||
start_task.put("createuserorgid", userContext.getCompanyModel().getId());//公司id
|
||
start_task.put("createuserdeptid", userContext.getDepartmentModel().getId());//部门id
|
||
start_task.put("createuserroleid", userContext.getRoleModel().getId());//角色id
|
||
}
|
||
|
||
start_task.put("activitydefid", JSONObject.parseObject(jsonArray.get(i).toString()).get("nodeid"));//角色id
|
||
start_task.put("timedur", "");
|
||
start_task.put("warningtimedur", "");
|
||
start_task.put("createtime", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate"));
|
||
jsonArray_new.add(start_task);
|
||
}
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
}else {
|
||
break;
|
||
}
|
||
q++;
|
||
}
|
||
System.out.println("jsonArray_new.toString()>>>>>>>>>>>>>"+jsonArray_new.toString());
|
||
return jsonArray_new.toString();
|
||
}
|
||
|
||
@Path("/task/endTask")
|
||
/**
|
||
* structFieldList.add(DataTypes.createStructField("activitydefid", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("executecosttime", DataTypes.LongType, true));
|
||
* structFieldList.add(DataTypes.createStructField("processdefverid", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("processdefid", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("processinstid", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("taskinstid", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("actionname", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("state", DataTypes.IntegerType, true));
|
||
* structFieldList.add(DataTypes.createStructField("timedur", DataTypes.LongType, true));
|
||
* structFieldList.add(DataTypes.createStructField("warningtimedur", DataTypes.LongType, true));
|
||
* structFieldList.add(DataTypes.createStructField("begintime", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("endtime", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("createuser", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("createuserorgid", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("createuserdeptid", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("createuserroleid", DataTypes.StringType, true));
|
||
* structFieldList.add(DataTypes.createStructField("createtime", DataTypes.TimestampType, true));
|
||
*/
|
||
@GET
|
||
public String getEndTask(
|
||
@Param String starttime,
|
||
@Param String endtime) throws DocumentException, ParseException {
|
||
System.out.println("结束任务开始获取数据");
|
||
JSONArray jsonArray_new = new JSONArray(new LinkedList<>());
|
||
JSONObject results = new JSONObject(new LinkedHashMap<>());
|
||
List<RowMap> maps = DBSql.getMaps("select * from APP_ACT_BPAD_P_VER_ACTIVITY where ID = '124' order by CAST(EXT1 as int) asc");
|
||
int q=0;
|
||
for (RowMap bos:maps
|
||
) {
|
||
if (q<=maps.size()){
|
||
|
||
JSONObject jsonObject = new JSONObject(new LinkedHashMap());
|
||
String soap_page = SDK.getAppAPI().getProperty("com.awspaas.user.apps.performance_indicator_library", "soap_page");//这里是获取配置的SOAP接口传的多少页,如果3500左右不够可以自行往上增加
|
||
|
||
int size = Integer.valueOf(soap_page);
|
||
|
||
for (int j = 1; j < size; j++) {
|
||
|
||
int tale = Integer.valueOf(bos.getString("ID").trim());
|
||
|
||
jsonObject.put("workflowId", tale);
|
||
// jsonObject.put("workflowId",bo.getString("WORKFLOWID"));
|
||
//jsonObject.put("createDateStart","2019-07-01 00:00:00");//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
|
||
//jsonObject.put("createDateEnd","2023-09-01 00:00:00");//processExecutionContext.getProcessInstance().getCreateUser()
|
||
jsonObject.put("pageIndex", j);
|
||
jsonObject.put("pageSize", 1000);
|
||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.services.weaver.com.cn\">\n" +
|
||
" <soapenv:Header/>" +
|
||
" <soapenv:Body>" +
|
||
" <web:getFlowListByWfId>" +
|
||
" <web:in0>" +
|
||
"" + jsonObject + "" +
|
||
" </web:in0>" +
|
||
" </web:getFlowListByWfId>" +
|
||
" </soapenv:Body>" +
|
||
"</soapenv:Envelope>";
|
||
|
||
System.out.println("参数===============" + xmlStr);
|
||
//System.out.println("参数==============="+xmls);
|
||
//HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||
int timeout = 600000;
|
||
// HttpURLConnection 发送SOAP请求
|
||
System.out.println("HttpURLConnection 发送SOAP请求");
|
||
|
||
String postSoap = UtilUrls.doPostSoap("http://10.119.22.207:80/services/WorkflowService", xmlStr, "");
|
||
|
||
|
||
Document document = DocumentHelper.parseText(postSoap);
|
||
Element rootElement = document.getRootElement();
|
||
// System.out.println("rootElement>>>>>>"+rootElement);
|
||
Element result = rootElement.element("Body").element("getFlowListByWfIdResponse").element("out");
|
||
String resultString = result.getData().toString();
|
||
System.out.println("resultString=>>>>>>>>>>"+resultString);
|
||
//if (!StringUtils.isEmpty(resultString)){
|
||
JSONObject jsonObject1 = JSON.parseObject(resultString);
|
||
String datas = jsonObject1.getString("datas");
|
||
JSONArray jsonArray = JSONArray.parseArray(datas);
|
||
if (jsonArray != null && jsonArray.size() != 0) {
|
||
for (int i = 0; i < jsonArray.size(); i++) {
|
||
// JSONObject.parseObject(jsonArray.get(i).toString()).get("requestId")
|
||
JSONObject end_task = new JSONObject(new LinkedHashMap<>());
|
||
end_task.put("taskinstid", JSONObject.parseObject(jsonArray.get(i).toString()).get("id"));//流程实例id
|
||
end_task.put("processdefid", JSONObject.parseObject(jsonArray.get(i).toString()).get("workflowId"));//流程定义id
|
||
RowMap workflowId = DBSql.getMap("select * from APP_ACT_BPAD_P_VER_ACTIVITY where ID = '" + JSONObject.parseObject(jsonArray.get(i).toString()).get("workflowId") + "'");
|
||
if (workflowId.getString("PROCESSVERSION") != null) {
|
||
end_task.put("processdefverid", workflowId.getString("VERSION"));//流程版本定义
|
||
} else {
|
||
end_task.put("processdefverid", "1");
|
||
}
|
||
end_task.put("processinstid", JSONObject.parseObject(jsonArray.get(i).toString()).get("requestId"));
|
||
end_task.put("state", JSONObject.parseObject(jsonArray.get(i).toString()).get("status"));
|
||
end_task.put("begintime", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate"));//开始时间
|
||
end_task.put("createuser", JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode"));//创建人
|
||
|
||
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
Date beginDate = sdf.parse(JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate").toString());
|
||
if (UtilString.isNotEmpty(JSONObject.parseObject(jsonArray.get(i).toString()).get("receiveDate").toString())) {
|
||
Date endDate = sdf.parse(JSONObject.parseObject(jsonArray.get(i).toString()).get("receiveDate").toString());
|
||
long dates = (endDate.getTime() - beginDate.getTime()) / (1000 * 60);
|
||
end_task.put("executecosttime", dates);//开始时间-结束时间如果结束时间为空,则这个时间也为空
|
||
} else {
|
||
end_task.put("executecosttime", "");//开始时间-结束时间如果结束时间为空,则这个时间也为空
|
||
}
|
||
|
||
end_task.put("endtime", JSONObject.parseObject(jsonArray.get(i).toString()).get("receiveDate"));
|
||
|
||
UserModel operatorWorkCode = SDK.getORGAPI().getUser(JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode").toString());
|
||
if (operatorWorkCode != null) {
|
||
UserContext userContext = UserContext.fromUID(JSONObject.parseObject(jsonArray.get(i).toString()).get("operatorWorkCode").toString());
|
||
end_task.put("createuserorgid", userContext.getCompanyModel().getId());//公司id
|
||
end_task.put("createuserdeptid", userContext.getDepartmentModel().getId());//部门id
|
||
end_task.put("createuserroleid", userContext.getRoleModel().getId());//角色id
|
||
} else {
|
||
UserContext userContext = UserContext.fromUID("admin");
|
||
end_task.put("createuserorgid", userContext.getCompanyModel().getId());//公司id
|
||
end_task.put("createuserdeptid", userContext.getDepartmentModel().getId());//部门id
|
||
end_task.put("createuserroleid", userContext.getRoleModel().getId());//角色id
|
||
}
|
||
|
||
end_task.put("activitydefid", JSONObject.parseObject(jsonArray.get(i).toString()).get("nodeid"));//角色id
|
||
end_task.put("timedur", "");
|
||
end_task.put("warningtimedur", "");
|
||
end_task.put("createtime", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateDate"));
|
||
end_task.put("actionname", JSONObject.parseObject(jsonArray.get(i).toString()).get("operateType"));
|
||
jsonArray_new.add(end_task);
|
||
}
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
}else {
|
||
break;
|
||
}
|
||
q++;
|
||
}
|
||
System.out.println("jsonArray_new.toString()>>>>>>>>>>>>>"+jsonArray_new.toString());
|
||
return jsonArray_new.toString();
|
||
}
|
||
|
||
|
||
}
|