|
|
@ -0,0 +1,724 @@
|
|
|
|
|
|
|
|
package weaver.interfaces.nl.job;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import org.apache.http.HttpEntity;
|
|
|
|
|
|
|
|
import org.apache.http.NameValuePair;
|
|
|
|
|
|
|
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
|
|
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
|
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
|
|
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
|
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
|
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
|
|
|
import weaver.conn.RecordSetTrans;
|
|
|
|
|
|
|
|
import weaver.file.Prop;
|
|
|
|
|
|
|
|
import weaver.general.AES;
|
|
|
|
|
|
|
|
import weaver.general.TimeUtil;
|
|
|
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
import weaver.integration.logging.Logger;
|
|
|
|
|
|
|
|
import weaver.integration.logging.LoggerFactory;
|
|
|
|
|
|
|
|
import weaver.interfaces.sso.cas.CasUtil;
|
|
|
|
|
|
|
|
import weaver.ofs.interfaces.SendRequestStatusDataInterfaces;
|
|
|
|
|
|
|
|
import weaver.workflow.request.todo.DataObj;
|
|
|
|
|
|
|
|
import weaver.workflow.request.todo.RequestStatusObj;
|
|
|
|
|
|
|
|
import weaver.interfaces.cxh.util.SendIMUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
import java.net.URLConnection;
|
|
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SendRequestForJZ implements SendRequestStatusDataInterfaces {
|
|
|
|
|
|
|
|
//系统变量start
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 日志打印对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(SendRequestForJZ.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 配置id
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String id = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 系统编号
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String syscode = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 服务地址
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String serverurl = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 流程白名单
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public ArrayList<String> workflowwhitelist ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 人员白名单
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public ArrayList<String> userwhitelist ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* settingid为ofs_sendinfo的id,实现类需要定义String id
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public String getId() {
|
|
|
|
|
|
|
|
return this.id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* syscode为系统标识,实现类需要定义String syscode ;
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public String getSyscode() {
|
|
|
|
|
|
|
|
return this.syscode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* serverurl为服务端访问url,实现类需要定义String serverurl ;
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public String getServerurl() {
|
|
|
|
|
|
|
|
return this.serverurl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 流程白名单 实现类需要定义ArrayList<String> workflowwhitelist
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public ArrayList<String> getWorkflowwhitelist() {
|
|
|
|
|
|
|
|
return this.workflowwhitelist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 人员白名单 实现类需要定义ArrayList<String> userwhitelist
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public ArrayList<String> getUserwhitelist() {
|
|
|
|
|
|
|
|
return this.userwhitelist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//系统变量end
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//接口变量start
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//接口变量end
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String oaaddress = "" ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String accessToken = "" ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String appId = "" ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String bizDomain = "OA" ;//任务来源 --业务域:该工作流所在的业务域如学工、人事、教务、OA等(必填)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String processSource = "泛微OA" ;//流程来源,如:"一表通平台"、"学工自定义状态机"
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 发送接口数据
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param datas
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void SendRequestStatusData(ArrayList<DataObj> datas) {
|
|
|
|
|
|
|
|
log.error("原始数据:"+JSONObject.toJSONString(datas));
|
|
|
|
|
|
|
|
if ("".equals(this.oaaddress)){
|
|
|
|
|
|
|
|
RecordSet rsrtx = new RecordSet();
|
|
|
|
|
|
|
|
String sqlStr = "select * from SystemSet";
|
|
|
|
|
|
|
|
rsrtx.execute(sqlStr);
|
|
|
|
|
|
|
|
rsrtx.next();
|
|
|
|
|
|
|
|
this.oaaddress = rsrtx.getString("oaaddress");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject() ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray insert = new JSONArray() ;
|
|
|
|
|
|
|
|
JSONArray update = new JSONArray() ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < datas.size(); i++) {
|
|
|
|
|
|
|
|
DataObj obj = datas.get(i);//获取推送数据
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//已办批量传输异构系统start
|
|
|
|
|
|
|
|
for (RequestStatusObj request:obj.getDonedatas()) {
|
|
|
|
|
|
|
|
if (!this.isPush(request)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.getIsSend(request)){
|
|
|
|
|
|
|
|
update.add(this.getUpdate(request , 1)) ;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
insert.add(this.getInsert(request , 1)) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//已办批量传输异构系统end
|
|
|
|
|
|
|
|
//代办批量传输异构系统start
|
|
|
|
|
|
|
|
for (RequestStatusObj request:obj.getTododatas()) {
|
|
|
|
|
|
|
|
if (!this.isPush(request)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.getIsSend(request)){
|
|
|
|
|
|
|
|
update.add(this.getUpdate(request , 2)) ;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
insert.add(this.getInsert(request , 2)) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//代办批量传输异构系统end
|
|
|
|
|
|
|
|
//删除批量传输异构系统start
|
|
|
|
|
|
|
|
for (RequestStatusObj request:obj.getDeldatas()) {
|
|
|
|
|
|
|
|
if (!this.isPush(request)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.getIsSend(request)){
|
|
|
|
|
|
|
|
update.add(this.getUpdate(request , 3)) ;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
insert.add(this.getInsert(request , 3)) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("inserttasks" , insert) ;
|
|
|
|
|
|
|
|
json.put("updatetasks" , update) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.sendData(json);
|
|
|
|
|
|
|
|
//删除批量传输异构系统end
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void sendData(JSONObject json){
|
|
|
|
|
|
|
|
log.error("最终发送的数据为:"+json.toJSONString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*JSONObject data = new JSONObject() ;
|
|
|
|
|
|
|
|
data.put("appId",this.appId) ;
|
|
|
|
|
|
|
|
data.put("taskInfo",json.toJSONString()) ;*/
|
|
|
|
|
|
|
|
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
|
|
|
|
|
|
params.add(new BasicNameValuePair("appId", appId));
|
|
|
|
|
|
|
|
params.add(new BasicNameValuePair("taskInfo", json.toJSONString()));
|
|
|
|
|
|
|
|
String result = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
result = this.post(this.serverurl , params);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
log.error("返回结果 "+result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param obj
|
|
|
|
|
|
|
|
* @return true 已发送过 false 未发送过
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private boolean getIsSend(RequestStatusObj obj){
|
|
|
|
|
|
|
|
RecordSetTrans rs = new RecordSetTrans();
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
rs.executeQuery("select * from ofs_send_jz_log where cid = ? " , obj.getCid()) ;
|
|
|
|
|
|
|
|
if (rs.next()){
|
|
|
|
|
|
|
|
return true ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rs.executeUpdate("insert into ofs_send_jz_log (cid , request_id , workflow_id ,node_id,user_id,request_name,send_time)values(?,?,?,?,?,?,?) ",
|
|
|
|
|
|
|
|
obj.getCid() , obj.getRequestid() , obj.getWorkflowid() , obj.getNodeid() , obj.getUser().getUID() , obj.getRequestnamenew() , System.currentTimeMillis()) ;
|
|
|
|
|
|
|
|
return false ;
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
rs.rollback() ;
|
|
|
|
|
|
|
|
//插入数据失败按照 以发送过数据处理
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param obj
|
|
|
|
|
|
|
|
* @param type
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private JSONObject getInsert(RequestStatusObj obj , int type){
|
|
|
|
|
|
|
|
String createDepartmentName = this.getDepartmentName(obj.getCreator().getUserDepartment()) ;
|
|
|
|
|
|
|
|
String receiverDepartmentName = this.getDepartmentName(obj.getUser().getUserDepartment()) ;//候选人(任务审批人)部门
|
|
|
|
|
|
|
|
String pcURL = this.getPcURL(obj.getRequestid() , obj.getUser().getUID() , 1) ;
|
|
|
|
|
|
|
|
String appURL = this.getAppURL(obj.getRequestid() , obj.getUser().getUID()) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject() ;
|
|
|
|
|
|
|
|
json.put("app_id", appId);
|
|
|
|
|
|
|
|
json.put("task_id", appId+Util.null2String(obj.getCid()));
|
|
|
|
|
|
|
|
json.put("created_by_ids", obj.getCreator().getLoginid());
|
|
|
|
|
|
|
|
json.put("created_by_names", obj.getCreator().getLastname());
|
|
|
|
|
|
|
|
json.put("created_by_depts", Util.processBody(createDepartmentName, "7"));
|
|
|
|
|
|
|
|
json.put("subject", obj.getRequestnamenew());
|
|
|
|
|
|
|
|
json.put("created_on", this.getDateTime(obj.getReceivedate() , obj.getReceivetime()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("form_url", pcURL);
|
|
|
|
|
|
|
|
json.put("form_url_view", pcURL);
|
|
|
|
|
|
|
|
json.put("form_mobile_url", appURL);
|
|
|
|
|
|
|
|
json.put("form_mobile_url_view", appURL);
|
|
|
|
|
|
|
|
json.put("priority", this.getPriority(obj.getRequestlevel())) ;//1: 特急 2:紧急 3:一般
|
|
|
|
|
|
|
|
json.put("biz_key", Util.null2String(obj.getRequestid())) ;
|
|
|
|
|
|
|
|
json.put("biz_domain", this.bizDomain) ;//任务来源 --业务域:该工作流所在的业务域如学工、人事、教务、OA等(必填)
|
|
|
|
|
|
|
|
json.put("biz_domain_subtype", Util.processBody(obj.getWorkflowname(), "7"));//所属类别
|
|
|
|
|
|
|
|
json.put("is_merge_task", "0" ) ;//0:普通任务 1:合并型任务 固定值0
|
|
|
|
|
|
|
|
json.put("merge_num", "");//合并任务数
|
|
|
|
|
|
|
|
json.put("process_instance_id", Util.null2String(obj.getRequestid())) ;//流程实例ID(必填)
|
|
|
|
|
|
|
|
json.put("process_instance_initiator_id", obj.getCreator().getLoginid()) ;//流程实例发起人ID
|
|
|
|
|
|
|
|
json.put("process_instance_initiator" , obj.getCreator().getLastname()) ;//流程实例发起人姓名
|
|
|
|
|
|
|
|
json.put("process_instance_initiator_dp" , createDepartmentName) ;//流程实例发起人所在部门
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("process_instance_start_date", this.getDateTime(obj.getCreatedate() , obj.getCreatetime())) ;//流程实例开始时间
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("process_instance_image_url", this.getPcURL(obj.getRequestid() , obj.getUser().getUID() , 2)) ;//流程图页面
|
|
|
|
|
|
|
|
json.put("process_instance_subject" , obj.getRequestnamenew()) ;//流程实例主题(我发起的名称)
|
|
|
|
|
|
|
|
json.put("process_instance_form", pcURL) ;//流程实例查看表单
|
|
|
|
|
|
|
|
json.put("process_instance_form_view", pcURL) ;//流程实例查看表单
|
|
|
|
|
|
|
|
json.put("process_id", Util.null2String(obj.getWorkflowid())) ;//类型ID
|
|
|
|
|
|
|
|
json.put("process_source", this.processSource);
|
|
|
|
|
|
|
|
json.put("process_version", this.getProcessVersion(obj.getWorkflowid())) ;//流程版本
|
|
|
|
|
|
|
|
json.put("process_name", Util.processBody(obj.getWorkflowname(), "7")) ;//流程定义名称
|
|
|
|
|
|
|
|
json.put("task_delete_flag", "0");
|
|
|
|
|
|
|
|
json.put("process_delete_flag", "0");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("task_comment", this.getTaskComment(obj.getRequestid() , obj.getNodeid() , obj.getUser().getUID()));
|
|
|
|
|
|
|
|
json.put("node_name", obj.getNodename());
|
|
|
|
|
|
|
|
json.put("node_id", obj.getNodeid());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type != 2){
|
|
|
|
|
|
|
|
String endOn = this.getEndOn(obj.getRequestid()) ;
|
|
|
|
|
|
|
|
json.put("end_on", endOn);
|
|
|
|
|
|
|
|
json.put("process_instance_ent_date", endOn);//流程实例结束时间
|
|
|
|
|
|
|
|
json.put("actual_owner_id", obj.getUser().getLoginid());
|
|
|
|
|
|
|
|
json.put("actual_owner_name", obj.getUser().getLastname());
|
|
|
|
|
|
|
|
json.put("actual_owner_dept", Util.processBody(receiverDepartmentName, "7"));
|
|
|
|
|
|
|
|
json.put("process_instance_status", "COMPLETE");
|
|
|
|
|
|
|
|
json.put("status", "COMPLETE");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//待办
|
|
|
|
|
|
|
|
json.put("process_instance_ent_date", "");//流程实例结束时间
|
|
|
|
|
|
|
|
json.put("process_instance_status", "RUNNING");
|
|
|
|
|
|
|
|
json.put("status", "ACTIVE");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("assignments", this.getAssignments(obj.getUser().getLoginid() , obj.getUser().getLastname(), receiverDepartmentName));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//推送消息到今日校园
|
|
|
|
|
|
|
|
new SendIMUtil().sendIM(obj.getUser().getLoginid(),obj.getRequestnamenew());
|
|
|
|
|
|
|
|
return json ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param obj
|
|
|
|
|
|
|
|
* @param type 1 已办 2 待办 3 删除
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private JSONObject getUpdate(RequestStatusObj obj , int type){
|
|
|
|
|
|
|
|
String createDepartmentName = this.getDepartmentName(obj.getCreator().getUserDepartment()) ;
|
|
|
|
|
|
|
|
String receiverDepartmentName = this.getDepartmentName(obj.getUser().getUserDepartment()) ;//候选人(任务审批人)部门
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject() ;
|
|
|
|
|
|
|
|
json.put("app_id", this.appId);
|
|
|
|
|
|
|
|
json.put("task_id", appId+Util.null2String(obj.getCid()));
|
|
|
|
|
|
|
|
json.put("created_by_ids", obj.getCreator().getLoginid());
|
|
|
|
|
|
|
|
json.put("created_by_names", obj.getCreator().getLastname());
|
|
|
|
|
|
|
|
json.put("created_by_depts", Util.processBody(createDepartmentName, "7"));
|
|
|
|
|
|
|
|
json.put("subject", obj.getRequestnamenew()) ;//任务主题
|
|
|
|
|
|
|
|
json.put("created_on", this.getDateTime(obj.getReceivedate() , obj.getReceivetime())) ;
|
|
|
|
|
|
|
|
if (type != 2){
|
|
|
|
|
|
|
|
String endOn = this.getEndOn(obj.getRequestid()) ;
|
|
|
|
|
|
|
|
json.put("end_on", endOn);
|
|
|
|
|
|
|
|
json.put("actual_owner_id", obj.getUser().getLoginid());
|
|
|
|
|
|
|
|
json.put("actual_owner_name", obj.getUser().getLastname());
|
|
|
|
|
|
|
|
json.put("actual_owner_dept", Util.processBody(receiverDepartmentName, "7"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
json.put("task_comment", this.getTaskComment(obj.getRequestid() , obj.getNodeid() , obj.getUser().getUID()));
|
|
|
|
|
|
|
|
//删除需要的数据
|
|
|
|
|
|
|
|
if (type == 3){
|
|
|
|
|
|
|
|
//json.put("status", "ACTIVE");
|
|
|
|
|
|
|
|
json.put("status", "COMPLETE");
|
|
|
|
|
|
|
|
json.put("process_instance_status", "RUNNING");
|
|
|
|
|
|
|
|
json.put("task_delete_flag", "1");
|
|
|
|
|
|
|
|
json.put("process_delete_flag", "0");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if (type == 1){
|
|
|
|
|
|
|
|
json.put("status", "COMPLETE");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
json.put("status", "ACTIVE");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("process_name", Util.processBody(obj.getWorkflowname(), "7"));//流程定义名称
|
|
|
|
|
|
|
|
json.put("process_version", this.getProcessVersion(obj.getWorkflowid())) ;//流程版本
|
|
|
|
|
|
|
|
json.put("node_id", obj.getNodeid());
|
|
|
|
|
|
|
|
json.put("node_name", obj.getNodename());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("operate_on", this.getDateTime("",""));
|
|
|
|
|
|
|
|
json.put("operator_id", obj.getUser().getLoginid());
|
|
|
|
|
|
|
|
json.put("operator_name", obj.getUser().getLastname());
|
|
|
|
|
|
|
|
json.put("operator_dept", Util.processBody(receiverDepartmentName, "7"));
|
|
|
|
|
|
|
|
json.put("operate_type", "ACTIVE");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("assignments", this.getAssignments(obj.getUser().getLoginid() , obj.getUser().getLastname(), receiverDepartmentName));
|
|
|
|
|
|
|
|
return json ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getEndOn(int requestId){
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
rs.executeQuery("select * from workflow_requestbase where requestid = ?",requestId);
|
|
|
|
|
|
|
|
if(rs.next()){
|
|
|
|
|
|
|
|
String nodeType = rs.getString("currentnodetype");//0:创建 1:审批 2:实现 3:归档
|
|
|
|
|
|
|
|
if ("3".equals(nodeType)){
|
|
|
|
|
|
|
|
return this.getDateTime(rs.getString("lastoperatedate") , rs.getString("lastoperatetime"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "" ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JSONArray getAssignments(String loginId , String name , String deptName){
|
|
|
|
|
|
|
|
JSONArray list = new JSONArray() ;
|
|
|
|
|
|
|
|
JSONObject assignment = new JSONObject() ;
|
|
|
|
|
|
|
|
assignment.put("assign_dept" , Util.processBody(deptName, "7")) ;//候选人(任务审批人)部门
|
|
|
|
|
|
|
|
assignment.put("assign_id" , loginId) ;//候选人(任务审批人)ID
|
|
|
|
|
|
|
|
assignment.put("assign_name" , name) ;//候选人(任务审批人)姓名
|
|
|
|
|
|
|
|
list.add(assignment) ;
|
|
|
|
|
|
|
|
return list ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getProcessVersion(int workflowId){
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet() ;
|
|
|
|
|
|
|
|
rs.executeQuery("select * from workflow_base where id= ? " , workflowId) ;
|
|
|
|
|
|
|
|
if (rs.next()){
|
|
|
|
|
|
|
|
String processVersion = Util.null2String(rs.getString("version"));
|
|
|
|
|
|
|
|
if (!"".equals(processVersion)){
|
|
|
|
|
|
|
|
return processVersion ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "1" ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 任务的紧急程度:用于任务排序,1: 特急 2:紧急 3:一般
|
|
|
|
|
|
|
|
* 修改说明PS: 流程提供的 requestLevel 可以自定义 项目 定制了 4 特提 和5 普通,并且商议 后续在加的所以类型 默认都按照 一般处理。
|
|
|
|
|
|
|
|
* @param requestLevel
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String getPriority(int requestLevel){
|
|
|
|
|
|
|
|
if (requestLevel == 1 || requestLevel == 2)
|
|
|
|
|
|
|
|
return "2";
|
|
|
|
|
|
|
|
else if (requestLevel == 4)
|
|
|
|
|
|
|
|
return "1";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return "3" ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getDepartmentName(int departmentId){
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
rs.executeQuery("select departmentname from hrmdepartment where id = ?",departmentId);
|
|
|
|
|
|
|
|
if(rs.next()){
|
|
|
|
|
|
|
|
return rs.getString("departmentname") ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "" ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getDateTime(String date , String time){
|
|
|
|
|
|
|
|
StringBuilder dateTime = new StringBuilder() ;
|
|
|
|
|
|
|
|
if ("".equals(Util.null2String(date))){
|
|
|
|
|
|
|
|
dateTime.append(TimeUtil.getCurrentDateString()) ;
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
dateTime.append(date) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dateTime.append(" ") ;
|
|
|
|
|
|
|
|
if ("".equals(Util.null2String(time))){
|
|
|
|
|
|
|
|
dateTime.append(TimeUtil.getOnlyCurrentTimeString()) ;
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
dateTime.append(time) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return dateTime.toString().trim() ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String post(String url, List<? extends NameValuePair> params) throws Exception {
|
|
|
|
|
|
|
|
CloseableHttpClient httpclient = HttpClients.createDefault();
|
|
|
|
|
|
|
|
HttpPost httppost = new HttpPost(url);
|
|
|
|
|
|
|
|
System.out.println("url===== "+url);
|
|
|
|
|
|
|
|
httppost.setHeader("serviceId", syscode);
|
|
|
|
|
|
|
|
httppost.setHeader("appId", appId);
|
|
|
|
|
|
|
|
httppost.setHeader("accessToken", accessToken);
|
|
|
|
|
|
|
|
System.out.println("syscode===== "+syscode);
|
|
|
|
|
|
|
|
System.out.println("appId===== "+appId);
|
|
|
|
|
|
|
|
System.out.println("accessToken===== "+accessToken);
|
|
|
|
|
|
|
|
UrlEncodedFormEntity uefEntity;
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (params != null) {
|
|
|
|
|
|
|
|
uefEntity = new UrlEncodedFormEntity(params, "UTF-8");
|
|
|
|
|
|
|
|
httppost.setEntity(uefEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseableHttpResponse response = httpclient.execute(httppost);
|
|
|
|
|
|
|
|
BufferedReader in = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
HttpEntity entity = response.getEntity();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
in = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));
|
|
|
|
|
|
|
|
String str = null;
|
|
|
|
|
|
|
|
while ((str = in.readLine()) != null) {
|
|
|
|
|
|
|
|
sb.append(str);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
response.close();
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
httpclient.close();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 将流程请求数据post出去
|
|
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String postData(String url , String param) {
|
|
|
|
|
|
|
|
OutputStreamWriter out = null;
|
|
|
|
|
|
|
|
BufferedReader in = null;
|
|
|
|
|
|
|
|
String result = "";
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
URL realUrl = new URL(url);
|
|
|
|
|
|
|
|
// 打开和URL之间的连接
|
|
|
|
|
|
|
|
URLConnection conn = realUrl.openConnection();
|
|
|
|
|
|
|
|
// 设置通用的请求属性
|
|
|
|
|
|
|
|
conn.setRequestProperty("accept", "*/*");
|
|
|
|
|
|
|
|
conn.setRequestProperty("connection", "Keep-Alive");
|
|
|
|
|
|
|
|
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn.setRequestProperty("appId", this.appId);
|
|
|
|
|
|
|
|
conn.setRequestProperty("accessToken", this.accessToken);
|
|
|
|
|
|
|
|
// 发送POST请求必须设置如下两行
|
|
|
|
|
|
|
|
conn.setDoOutput(true);
|
|
|
|
|
|
|
|
conn.setDoInput(true);
|
|
|
|
|
|
|
|
// 获取URLConnection对象对应的输出流
|
|
|
|
|
|
|
|
out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
|
|
|
|
|
|
|
|
// 发送请求参数
|
|
|
|
|
|
|
|
String encode = URLEncoder.encode(param, "UTF-8");
|
|
|
|
|
|
|
|
out.write(encode);
|
|
|
|
|
|
|
|
// flush输出流的缓冲
|
|
|
|
|
|
|
|
out.flush();
|
|
|
|
|
|
|
|
// 定义BufferedReader输入流来读取URL的响应
|
|
|
|
|
|
|
|
in = new BufferedReader(
|
|
|
|
|
|
|
|
new InputStreamReader(conn.getInputStream(),"UTF-8"));
|
|
|
|
|
|
|
|
String line;
|
|
|
|
|
|
|
|
while ((line = in.readLine()) != null) {
|
|
|
|
|
|
|
|
result += line;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("发送 POST 请求出现异常!",e);
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//使用finally块来关闭输出流、输入流
|
|
|
|
|
|
|
|
finally{
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
if(out!=null){
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(in!=null){
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(IOException ex){
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return result ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 判定是否推送数据
|
|
|
|
|
|
|
|
* @param obj
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private boolean isPush(RequestStatusObj obj){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String workflowid = obj.getWorkflowid()+"";
|
|
|
|
|
|
|
|
String requestid = obj.getRequestid()+"";
|
|
|
|
|
|
|
|
String resourceid = obj.getUser().getUID()+"";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断该条流程是否需要发送异构系统
|
|
|
|
|
|
|
|
if(this.workflowwhitelist==null){
|
|
|
|
|
|
|
|
this.workflowwhitelist = new ArrayList<String>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.workflowwhitelist.size() > 0 && this.workflowwhitelist.indexOf(workflowid)==-1){//流程白名单
|
|
|
|
|
|
|
|
log.info("Ecology统一待办数据推送:流程白名单中没有设置该流程,不需要发送,workflowid="+workflowid+",requestid="+requestid);
|
|
|
|
|
|
|
|
return false; //不发送
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断该条人员是否需要发送异构系统或者
|
|
|
|
|
|
|
|
if(this.userwhitelist==null){
|
|
|
|
|
|
|
|
this.userwhitelist = new ArrayList<String>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.userwhitelist.size() > 0 && this.userwhitelist.indexOf(resourceid)==-1){//人员白名单
|
|
|
|
|
|
|
|
log.info("Ecology统一待办数据推送:人员白名单中没有设置该用户,不需要发送,workflowid="+workflowid+", requestid="+requestid+",userid="+resourceid);
|
|
|
|
|
|
|
|
return false; //不发送
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
rs.executeQuery("select status from hrmresource where id = ?",obj.getUser().getUID());
|
|
|
|
|
|
|
|
if(rs.next()){
|
|
|
|
|
|
|
|
int status = rs.getInt("status");
|
|
|
|
|
|
|
|
if(status<4){
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
log.info("当前人员离职,不发送,userid:"+obj.getUser().getUID());
|
|
|
|
|
|
|
|
return false; //不发送
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
log.info("当前人员信息无效,不发送,userid:"+obj.getUser().getUID());
|
|
|
|
|
|
|
|
return false; //不发送
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 构造PC地址
|
|
|
|
|
|
|
|
* @param requestId
|
|
|
|
|
|
|
|
* @param userId
|
|
|
|
|
|
|
|
* @param type 1 流程地址 2流程图页面
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String getPcURL(int requestId , int userId , int type){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//StringBuffer url = new StringBuffer(this.oaaddress) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder tempURL = new StringBuilder(this.oaaddress);
|
|
|
|
|
|
|
|
if (type == 1){
|
|
|
|
|
|
|
|
tempURL.append("/common/chatResource/view.html?resourcetype=0&resourceid=").append(requestId)
|
|
|
|
|
|
|
|
.append("&f_weaver_belongto_userid=").append(userId).append("&f_weaver_belongto_usertype=0");
|
|
|
|
|
|
|
|
//tempURL.append("/workflow/request/ViewRequest.jsp");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
tempURL.append("/workflow/request/WorkflowRequestPictureInner.jsp");
|
|
|
|
|
|
|
|
tempURL.append("?fromofs=1&requestid=").append(requestId)
|
|
|
|
|
|
|
|
.append("&f_weaver_belongto_userid=").append(userId).append("&f_weaver_belongto_usertype=0");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//没有开启cas 情况下
|
|
|
|
|
|
|
|
//if (!isUseCas()){
|
|
|
|
|
|
|
|
// String loginId = getMainLoginId(userId);
|
|
|
|
|
|
|
|
// tempURL.append("#").append(loginId) ;
|
|
|
|
|
|
|
|
// String password=Util.null2s(Prop.getPropValue("AESpassword", "pwd") , "1") ;
|
|
|
|
|
|
|
|
// url.append("/login/VerifySSoLogin.jsp?para=")
|
|
|
|
|
|
|
|
// .append(AES.encrypt(tempURL.toString(),password)) ;
|
|
|
|
|
|
|
|
//}else {
|
|
|
|
|
|
|
|
// url.append(tempURL) ;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
return tempURL.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getAppURL(int requestId , int userId){
|
|
|
|
|
|
|
|
String url = this.getURL(requestId , userId);
|
|
|
|
|
|
|
|
log.info("Ecology统一待办数据推送:getAppUrl(): result="+url);
|
|
|
|
|
|
|
|
return url;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getURL(int requestId , int userId){
|
|
|
|
|
|
|
|
StringBuilder url = new StringBuilder(this.oaaddress) ;
|
|
|
|
|
|
|
|
url.append("/wui/cas-entrance.jsp?path=");
|
|
|
|
|
|
|
|
url.append("https%3A%2F%2Fofficeauto.njfu.edu.cn%2Fspa%2Fworkflow%2Fstatic4mobileform%2Findex.html%3F_random%3D1640316447860%23%2Freq%3Frequestid%3D").append(requestId)
|
|
|
|
|
|
|
|
.append("%26f_weaver_belongto_userid%3D").append(userId).append("&f_weaver_belongto_usertype=0");
|
|
|
|
|
|
|
|
return url.toString() ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getMainLoginId(int id){
|
|
|
|
|
|
|
|
//判断是否是主账号
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
rs.executeQuery("select accounttype,belongto from hrmresource where id= ?" ,id);
|
|
|
|
|
|
|
|
if(rs.next()){
|
|
|
|
|
|
|
|
String accounttype = Util.null2String(rs.getString("accounttype"));
|
|
|
|
|
|
|
|
if("1".equals(accounttype)){
|
|
|
|
|
|
|
|
return new User(Util.getIntValue(rs.getString("belongto") , 1)).getLoginid() ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new User(id).getLoginid() ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 是否使用CAS集成
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private boolean isUseCas(){
|
|
|
|
|
|
|
|
return new CasUtil().isUseCAS();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getTaskComment(int requestId , int nodeId , int userId){
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet() ;
|
|
|
|
|
|
|
|
rs.executeQuery("select remark from workflow_requestlog where requestid=? and nodeid=? and operator= ?" , requestId , nodeId , userId) ;
|
|
|
|
|
|
|
|
if (rs.next()){
|
|
|
|
|
|
|
|
return this.getTextFromHtml(Util.null2String(rs.getString("remark"))) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "" ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取html代码中的文本
|
|
|
|
|
|
|
|
* @param htmlStr
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String getTextFromHtml(String htmlStr) {
|
|
|
|
|
|
|
|
htmlStr = this.delHTMLTag(htmlStr);
|
|
|
|
|
|
|
|
htmlStr = htmlStr.replaceAll(" ", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return htmlStr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 删除不需要的html代码
|
|
|
|
|
|
|
|
* @param htmlStr
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String delHTMLTag(String htmlStr) {
|
|
|
|
|
|
|
|
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>";
|
|
|
|
|
|
|
|
String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>";
|
|
|
|
|
|
|
|
String regEx_html = "<[^>]+>";
|
|
|
|
|
|
|
|
String regEx_space = "\\s*|\t|\r|\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pattern p_script = Pattern.compile(regEx_script, 2);
|
|
|
|
|
|
|
|
Matcher m_script = p_script.matcher(htmlStr);
|
|
|
|
|
|
|
|
htmlStr = m_script.replaceAll("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pattern p_style = Pattern.compile(regEx_style, 2);
|
|
|
|
|
|
|
|
Matcher m_style = p_style.matcher(htmlStr);
|
|
|
|
|
|
|
|
htmlStr = m_style.replaceAll("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pattern p_html = Pattern.compile(regEx_html, 2);
|
|
|
|
|
|
|
|
Matcher m_html = p_html.matcher(htmlStr);
|
|
|
|
|
|
|
|
htmlStr = m_html.replaceAll("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pattern p_space = Pattern.compile(regEx_space, 2);
|
|
|
|
|
|
|
|
Matcher m_space = p_space.matcher(htmlStr);
|
|
|
|
|
|
|
|
htmlStr = m_space.replaceAll("");
|
|
|
|
|
|
|
|
return htmlStr.trim();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|