#HJ-22# 提交最新的代码

feature-LeeD-20221025
shilei 2 years ago
parent 04107fffc1
commit c479c7626d

@ -0,0 +1,10 @@
package com.api.dito.createauth;
import com.engine.dito.createauth.web.CreateAuthAction;
import javax.ws.rs.Path;
@Path("/dito/auth")
public class CreateAuthActionApi extends CreateAuthAction {
}

@ -4,6 +4,6 @@ import com.engine.dito.excel.web.ImportExcelAction;
import javax.ws.rs.Path; import javax.ws.rs.Path;
@Path("/dito/import") @Path("/dito/hrmexcel")
public class ImportExcelActionApi extends ImportExcelAction { public class ImportExcelActionApi extends ImportExcelAction {
} }

@ -24,6 +24,8 @@ public class HttpRequestUtil extends BaseBean{
bb.writeLog("auth:"+auth); bb.writeLog("auth:"+auth);
String msgData = "" ; String msgData = "" ;
try {
OkHttpClient client = new OkHttpClient().newBuilder().build(); OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json"); MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, dataJson); RequestBody body = RequestBody.create(mediaType, dataJson);
@ -33,7 +35,7 @@ public class HttpRequestUtil extends BaseBean{
.addHeader("Authorization", authorization) .addHeader("Authorization", authorization)
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")
.build(); .build();
try {
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
int code = response.code(); int code = response.code();
@ -45,6 +47,7 @@ public class HttpRequestUtil extends BaseBean{
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
bb.writeLog("HttpRequestUtil--e:"+e);
} }
bb.writeLog("msgData:"+msgData); bb.writeLog("msgData:"+msgData);
return msgData; return msgData;

@ -29,9 +29,11 @@ public class SendMailUtil {
String emailVersion = PropBean.getUfPropValue("emailVersion"); String emailVersion = PropBean.getUfPropValue("emailVersion");
String emailkey = PropBean.getUfPropValue("emailkey"); String emailkey = PropBean.getUfPropValue("emailkey");
baseBean.writeLog("emailkey:"+emailkey);
if(StringUtils.isEmpty(emailkey)){ if(StringUtils.isEmpty(emailkey)){
emailkey = "email"; emailkey = "email";
} }
baseBean.writeLog("emailkey2:"+emailkey);
String triggerTime = sdf.format(new Date()); String triggerTime = sdf.format(new Date());

@ -0,0 +1,352 @@
package com.customization.dito.sendtodo;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SendPortalToReadUtil {
//public static String EMAIL_REGEX_DEFAULT = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
public static String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
/***
*
* @param requestid
* @param noideid
* @param user
*/
public void sendToReadDataByCreateNode(String requestid,String noideid,User user,String portal_todourl,String bpm_app_workflowurl,String username,String passwd,String bpm_workflowurl,String center,String bpm_app_requesturl){
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
SendMailUtil sendMailUtil = new SendMailUtil();
RecordSet rs = new RecordSet();
String requestname = "";
JSONObject requestObject = new JSONObject();
String emailArray = "";
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
BaseBean bb = new BaseBean();
bb.writeLog("sendToReadDataByCreateNode");
String terminal = "1" ;
String actionType = "0" ;
String taskType = "1";
String objectAction = "0" ;
String objectType = "0";
String objectId = "" ;
try {
JSONArray taskObjectList = new JSONArray();
String sql =" select t1.workflowid,t1.requestname,t1.requestmark,t1.creater,t1.createdate,t1.createtime,h1.lastname,h1.loginid,\n" +
" t1.requestid as taskCode,t1.currentnodeid as nodeid,d1.nodename\n" +
" from workflow_requestbase t1\n" +
" inner join workflow_base t3 on t1.workflowid = t3.id\n" +
" left join workflow_nodebase d1 on d1.id = t1.currentnodeid "+
" left join (select id, lastname,loginid from hrmresource where status = 1 union all select id, lastname,loginid from hrmresourcemanager ) h1 on h1.id = t1.creater\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = "+requestid ;
bb.writeLog("sendTodoDataByNode--sql:"+sql);
rs.executeQuery(sql);
if (rs.next()){
String workflowid = Util.null2String(rs.getString("workflowid")) ;
String workflowname = getWorkflowname(workflowid);
String title = Util.null2String(rs.getString("requestname")) ;
String creator = Util.null2String(rs.getString("loginid")) ;
String workcode = Util.null2String(rs.getString("loginid")) ;
String taskCode = Util.null2String(rs.getString("taskcode")) ;
String nodeId = Util.null2String(rs.getString("nodeid")) ;
String createdate = Util.null2String(rs.getString("createdate")) ;
String createtime = Util.null2String(rs.getString("createtime")) ;
String messageTitle = Util.null2String(rs.getString("requestname")) ;
String messageContent = Util.null2String(rs.getString("requestname")) ;
requestname = messageTitle;
messageTitle = getShortMessageTitle(messageTitle);
String urlPc = "[newtab]"+bpm_workflowurl+"/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid ;
String app_requestUrl = bpm_app_requesturl+requestid;
app_requestUrl = URLEncoder.encode(app_requestUrl,"UTF-8");
String urlApp = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+workcode+"&forwardurl="+app_requestUrl;
String urlDing = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+workcode+"&forwardurl="+app_requestUrl;
String nodeName = Util.null2String(rs.getString("nodeName")) ;
requestObject.put("center",center);
requestObject.put("title",title);
requestObject.put("creator",creator);
requestObject.put("taskCode",taskCode);
requestObject.put("nodeId",nodeId);
requestObject.put("taskType",taskType);
requestObject.put("actionType",actionType);
requestObject.put("createDate",createdate+" "+createtime);
requestObject.put("messageTitle",messageTitle);
requestObject.put("messageContent",messageContent);
requestObject.put("terminal",terminal);
requestObject.put("urlPc",urlPc);
requestObject.put("urlApp",urlApp);
requestObject.put("urlDing",urlDing);
requestObject.put("nodeName",nodeName);
requestObject.put("ticketType",workflowname);
}
sql = " select t2.userid,h1.loginid,h1.email\n" +
" from workflow_requestbase t1\n" +
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t2.isremark in ('9')\n" +
" and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.requestid = "+requestid;
bb.writeLog("sendTodoDataByNode--sql:"+sql);
rs.executeQuery(sql);
while (rs.next()){
String usercode = Util.null2String(rs.getString("loginid")) ;
bb.writeLog("usercode--sql:"+usercode);
JSONObject taskObject = new JSONObject();
String objectCode = usercode ;
String operatorCode = usercode ;
taskObject.put("objectAction",objectAction);
taskObject.put("objectType",objectType);
taskObject.put("objectCode",objectCode);
taskObject.put("objectId",objectId);
taskObject.put("operatorCode",operatorCode);
taskObjectList.add(taskObject);
String email = Util.null2String(rs.getString("email")) ;
bb.writeLog("email2:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
}
}
requestObject.put("taskObjectList",taskObjectList);
String auth = username + ":" + passwd;
//bb.writeLog("requestObject:"+requestObject.toJSONString());
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
bb.writeLog("msgdata:"+msgdata);
if(!"".equals(msgdata)){
JSONObject msgObject = JSONObject.parseObject(msgdata);
//{"resultCode":"1","resultMsg":"No Result"}
if(msgObject.containsKey("resultCode")){
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
bb.writeLog("emailArray:"+emailArray);
if(StringUtils.isNotEmpty(emailArray))
{
String notificationSubject = "You have a new to-read list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-read list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestid,emailArray,notificationSubject,notificationContent);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/***
*
*
*
* @param requestid
* @param noideid
* @param user
*/
public void sendToReadDataByNode(String requestid,String noideid,User user,String portal_todourl,String bpm_app_workflowurl,String username,String passwd,String bpm_workflowurl,String center,String bpm_app_requesturl){
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
SendMailUtil sendMailUtil = new SendMailUtil();
JSONObject requestObject = new JSONObject();
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
bb.writeLog("sendToReadDataByNode");
String terminal = "1" ;
String taskType = "1";
String objectId = "" ;
String requestname = "" ;
String emailArray = "";
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
try {
int count = 0 ;
String countSql =" select t2.userid,h1.loginid\n" +
" from workflow_requestbase t1\n" +
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join (select id, lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '7', '11'))\n" +
" and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.REQUESTID = "+requestid+
" and t2.nodeid = " + noideid ;
bb.writeLog("sendTodoDataByNode--countSql:"+countSql);
rs.executeQuery(countSql);
while (rs.next()){
count++;
}
bb.writeLog("sendTodoDataByNode--count:"+count);
if(count == 0)
{
String actionType = "2" ;
String objectAction = "0" ;
String objectType = "0";
JSONArray taskObjectList = new JSONArray();
String sql =" select t1.workflowid,t1.requestname,t1.requestmark,t1.creater,t1.createdate,t1.createtime,h1.lastname,h1.loginid,\n" +
" t1.requestid as taskCode,t1.currentnodeid as nodeid,d1.nodename\n" +
" from workflow_requestbase t1\n" +
" inner join workflow_base t3 on t1.workflowid = t3.id\n" +
" left join workflow_nodebase d1 on d1.id = t1.currentnodeid "+
" left join (select id, lastname,loginid from hrmresource where status = 1 union all select id, lastname,loginid from hrmresourcemanager ) h1 on h1.id = t1.creater\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = "+requestid ;
bb.writeLog("sendTodoDataByNode--sql:"+sql);
rs.executeQuery(sql);
if (rs.next()){
String workflowid = Util.null2String(rs.getString("workflowid")) ;
String workflowname = getWorkflowname(workflowid);
String title = Util.null2String(rs.getString("requestname")) ;
requestname = title;
String creator = Util.null2String(rs.getString("loginid")) ;
String taskCode = Util.null2String(rs.getString("taskcode")) ;
String nodeId = Util.null2String(rs.getString("nodeid")) ;
String workcode = Util.null2String(rs.getString("loginid")) ;
String createdate = Util.null2String(rs.getString("createdate")) ;
String createtime = Util.null2String(rs.getString("createtime")) ;
String messageTitle = Util.null2String(rs.getString("requestname")) ;
messageTitle = getShortMessageTitle(messageTitle);
String messageContent = Util.null2String(rs.getString("requestname")) ;
String urlPc = "[newtab]"+bpm_workflowurl+"/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid ;
String app_requestUrl = bpm_app_requesturl+requestid;
app_requestUrl = URLEncoder.encode(app_requestUrl,"UTF-8");
String urlApp = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+workcode+"&forwardurl="+app_requestUrl;
String urlDing = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+workcode+"&forwardurl="+app_requestUrl;
String nodeName = Util.null2String(rs.getString("nodeName")) ;
requestObject.put("center",center);
requestObject.put("title",title);
requestObject.put("creator",creator);
requestObject.put("taskCode",taskCode);
requestObject.put("nodeId",nodeId);
requestObject.put("taskType",taskType);
requestObject.put("actionType",actionType);
requestObject.put("createDate",createdate+" "+createtime);
requestObject.put("messageTitle",messageTitle);
requestObject.put("messageContent",messageContent);
requestObject.put("terminal",terminal);
requestObject.put("urlPc",urlPc);
requestObject.put("urlApp",urlApp);
requestObject.put("urlDing",urlDing);
requestObject.put("nodeName",nodeName);
requestObject.put("ticketType",workflowname);
}
sql = " select t2.userid,h1.loginid,h1.email\n" +
" from workflow_requestbase t1\n" +
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t2.isremark in ('9')\n" +
" and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.REQUESTID = "+requestid;
bb.writeLog("sendTodoDataByNode--sql:"+sql);
rs.executeQuery(sql);
while (rs.next()){
String usercode = Util.null2String(rs.getString("loginid")) ;
String objectCode = usercode ;
String operatorCode = usercode ;
JSONObject taskObject = new JSONObject();
taskObject.put("objectAction",objectAction);
taskObject.put("objectType",objectType);
taskObject.put("objectCode",objectCode);
taskObject.put("objectId",objectId);
taskObject.put("operatorCode",operatorCode);
taskObjectList.add(taskObject);
String email = Util.null2String(rs.getString("email")) ;
bb.writeLog("email3:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
}
}
requestObject.put("taskObjectList",taskObjectList);
}
String auth = username + ":" + passwd;
//bb.writeLog("requestObject:"+requestObject.toJSONString());
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
bb.writeLog("msgdata:"+msgdata);
if(!"".equals(msgdata)){
JSONObject msgObject = JSONObject.parseObject(msgdata);
//{"resultCode":"1","resultMsg":"No Result"}
if(msgObject.containsKey("resultCode")){
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
bb.writeLog("emailArray:"+emailArray);
if(StringUtils.isNotEmpty(emailArray))
{
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestid,emailArray,notificationSubject,notificationContent);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private String getShortMessageTitle(String messageTitle) {
if (messageTitle.length() > 20) {
messageTitle = messageTitle.substring(0, 17) + "...";
}
return messageTitle;
}
private String getWorkflowname(String id){
RecordSet rs = new RecordSet();
String name = "";
rs.executeQuery("select workflowname from workflow_base where id = ?",id);
while (rs.next()){
name = Util.null2String(rs.getString("workflowname"));
}
return name;
}
}

@ -26,7 +26,7 @@ public class SendPortalTodoRunnable implements Runnable{
SendPortalTodoUtil sendPortalTodoUtil = new SendPortalTodoUtil(); SendPortalTodoUtil sendPortalTodoUtil = new SendPortalTodoUtil();
SendPortalDoneUtil sendPortalDoneUtil = new SendPortalDoneUtil(); SendPortalDoneUtil sendPortalDoneUtil = new SendPortalDoneUtil();
SendPortalToReadUtil sendPortalToReadUtil = new SendPortalToReadUtil();
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl"); String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String portal_doneurl = PropBean.getUfPropValue("portal_doneurl"); String portal_doneurl = PropBean.getUfPropValue("portal_doneurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl"); String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
@ -42,9 +42,13 @@ public class SendPortalTodoRunnable implements Runnable{
}else if(Util.getIntValue(requestid) == -1 && "submit".equals(src)){ }else if(Util.getIntValue(requestid) == -1 && "submit".equals(src)){
sendPortalTodoUtil.sendTodoDataByCreateNode(new_requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl); sendPortalTodoUtil.sendTodoDataByCreateNode(new_requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
sendPortalDoneUtil.sendPortalDoneData( new_requestid, nodeid, user, portal_doneurl,bpm_app_workflowurl, username, passwd, bpm_workflowurl,bpm_app_requesturl); sendPortalDoneUtil.sendPortalDoneData( new_requestid, nodeid, user, portal_doneurl,bpm_app_workflowurl, username, passwd, bpm_workflowurl,bpm_app_requesturl);
sendPortalToReadUtil.sendToReadDataByCreateNode(new_requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
}else if(Util.getIntValue(requestid)> 0 && "submit".equals(src)){ }else if(Util.getIntValue(requestid)> 0 && "submit".equals(src)){
sendPortalTodoUtil.sendTodoDataByNode(requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl); sendPortalTodoUtil.sendTodoDataByNode(requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
sendPortalDoneUtil.sendPortalDoneData( requestid, nodeid, user, portal_doneurl,bpm_app_workflowurl, username, passwd, bpm_workflowurl,bpm_app_requesturl); sendPortalDoneUtil.sendPortalDoneData( requestid, nodeid, user, portal_doneurl,bpm_app_workflowurl, username, passwd, bpm_workflowurl,bpm_app_requesturl);
sendPortalToReadUtil.sendToReadDataByNode(requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
}else if(Util.getIntValue(requestid)> 0 && "reject".equals(src)){ }else if(Util.getIntValue(requestid)> 0 && "reject".equals(src)){
sendPortalTodoUtil.sendTodoDataByReject(requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl); sendPortalTodoUtil.sendTodoDataByReject(requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
sendPortalDoneUtil.sendPortalDoneData( requestid, nodeid, user, portal_doneurl,bpm_app_workflowurl, username, passwd, bpm_workflowurl,bpm_app_requesturl); sendPortalDoneUtil.sendPortalDoneData( requestid, nodeid, user, portal_doneurl,bpm_app_workflowurl, username, passwd, bpm_workflowurl,bpm_app_requesturl);

@ -57,7 +57,7 @@ public class SendPortalTodoUtil {
" left join (select id, lastname,loginid,email from hrmresource where status = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t1.creater\n" + " left join (select id, lastname,loginid,email from hrmresource where status = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t1.creater\n" +
" where t2.userid in ("+userid+") \n" + " where t2.userid in ("+userid+") \n" +
" and (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + " and (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '9', '7', '11'))\n" + " and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '7', '11'))\n" +
" and (ifnull(t1.currentstatus, -1) = -1 or (ifnull(t1.currentstatus, -1) = 0 and t1.creater in ("+userid+"))) \n" + " and (ifnull(t1.currentstatus, -1) = -1 or (ifnull(t1.currentstatus, -1) = 0 and t1.creater in ("+userid+"))) \n" +
" and t2.islasttimes = 1 \n" + " and t2.islasttimes = 1 \n" +
" and (t2.isprocessing = '' or t2.isprocessing is null) \n" + " and (t2.isprocessing = '' or t2.isprocessing is null) \n" +
@ -261,7 +261,7 @@ public class SendPortalTodoUtil {
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" + " left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '9', '7', '11'))\n" + " and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '7', '11'))\n" +
" and t2.islasttimes = 1\n" + " and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.requestid = "+requestid; " and t2.requestid = "+requestid;
@ -356,7 +356,7 @@ public class SendPortalTodoUtil {
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join (select id, lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h1 on h1.id = t2.userid\n" + " left join (select id, lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '9', '7', '11'))\n" + " and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '7', '11'))\n" +
" and t2.islasttimes = 1\n" + " and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.REQUESTID = "+requestid+ " and t2.REQUESTID = "+requestid+
@ -494,7 +494,7 @@ public class SendPortalTodoUtil {
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" + " left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '9', '7', '11'))\n" + " and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '7', '11'))\n" +
" and t2.islasttimes = 1\n" + " and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.REQUESTID = "+requestid; " and t2.REQUESTID = "+requestid;
@ -644,7 +644,7 @@ public class SendPortalTodoUtil {
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" + " left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '9', '7', '11'))\n" + " and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '7', '11'))\n" +
" and t2.islasttimes = 1\n" + " and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.REQUESTID = "+requestid; " and t2.REQUESTID = "+requestid;

@ -0,0 +1,30 @@
package com.engine.dito.createauth.cmd;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.dito.job.WorkflowAuthModelingUtil;
import java.util.Map;
public class CreateAuthCmd extends AbstractCommonCommand<Map<String,Object>> {
@Override
public BizLogContext getLogContext() {
return null;
}
public CreateAuthCmd(Map<String,Object> params, User user) {
this.params = params;
this.user = user;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
WorkflowAuthModelingUtil workflowAuthModelingUtil = new WorkflowAuthModelingUtil();
String lcids = Util.null2String(params.get("lcids")) ;
Map<String,Object> map = workflowAuthModelingUtil.executeData(lcids);
return map;
}
}

@ -0,0 +1,11 @@
package com.engine.dito.createauth.service;
import weaver.hrm.User;
import java.util.Map;
public interface CreateAuthService {
Map<String,Object> createAuthData(Map<String,Object> datas,User user);
}

@ -0,0 +1,16 @@
package com.engine.dito.createauth.service.impl;
import com.engine.core.impl.Service;
import com.engine.dito.createauth.cmd.CreateAuthCmd;
import com.engine.dito.createauth.service.CreateAuthService;
import weaver.hrm.User;
import java.util.Map;
public class CreateAuthServiceImpl extends Service implements CreateAuthService {
@Override
public Map<String, Object> createAuthData(Map<String, Object> datas, User user) {
return commandExecutor.execute(new CreateAuthCmd(datas,user));
}
}

@ -0,0 +1,48 @@
package com.engine.dito.createauth.web;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.dito.createauth.service.CreateAuthService;
import com.engine.dito.createauth.service.impl.CreateAuthServiceImpl;
import weaver.general.BaseBean;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
public class CreateAuthAction {
public CreateAuthService getService(){
return (CreateAuthService) ServiceUtil.getService(CreateAuthServiceImpl.class);
}
@GET
@Path("/create")
@Produces({MediaType.TEXT_PLAIN})
public String createAuthData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
BaseBean bb = new BaseBean();
bb.writeLog("createAuthData");
Map<String,Object> apidatas = new HashMap<String,Object>();
try{
User user = HrmUserVarify.getUser(request, response);
Map<String,Object> dataMap = ParamUtil.request2Map(request);
apidatas.putAll(getService().createAuthData(dataMap,user));
apidatas.put("api_status",true);
}catch (Exception e){
apidatas.put("api_status",false);
apidatas.put("api_errormsg","exception:"+e.getMessage());
}
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
return JSONObject.toJSONString(apidatas);
}
}

@ -19,7 +19,6 @@ import java.util.Map;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
@Slf4j
public class ImportOrgExcelCmd extends AbstractCommonCommand<Map<String,Object>> { public class ImportOrgExcelCmd extends AbstractCommonCommand<Map<String,Object>> {
public ImportOrgExcelCmd(Map<String,Object> params, User user) { public ImportOrgExcelCmd(Map<String,Object> params, User user) {

@ -3,10 +3,8 @@ package com.engine.dito.excel.cmd;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
@Slf4j
public class ImportOrgExcelUtil { public class ImportOrgExcelUtil {
public boolean backupTableByData(String tName,String bName){ public boolean backupTableByData(String tName,String bName){
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
boolean isExist = checkTableIsExist(bName); boolean isExist = checkTableIsExist(bName);

@ -27,7 +27,7 @@ public class ImportExcelAction {
@GET @GET
@Path("/orgexcel") @Path("/import")
@Produces({MediaType.TEXT_PLAIN}) @Produces({MediaType.TEXT_PLAIN})
public String importOrgExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { public String importOrgExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) {
BaseBean bb = new BaseBean(); BaseBean bb = new BaseBean();

@ -10,10 +10,14 @@ public class PropBean {
public static BaseBean bb = new BaseBean(); public static BaseBean bb = new BaseBean();
public static String active = Util.null2String(bb.getPropValue("developProp","active")).toUpperCase(); public static String active = Util.null2String(bb.getPropValue("developProp","active")).toUpperCase();
/***
*
* @param pkey
* @return
*/
public static String getUfPropValue(String pkey) public static String getUfPropValue(String pkey)
{ {
BaseBean baseBean = new BaseBean(); BaseBean baseBean = new BaseBean();
if(StringUtils.isEmpty(pkey)){ if(StringUtils.isEmpty(pkey)){
return ""; return "";
} }
@ -22,17 +26,55 @@ public class PropBean {
active = Util.null2String(baseBean.getPropValue("developProp","active")).toUpperCase(); active = Util.null2String(baseBean.getPropValue("developProp","active")).toUpperCase();
} }
baseBean.writeLog("propbeanactive:"+active+" pkey:"+pkey+" "+active+"VALUE");
String pvalue = ""; String pvalue = "";
try{ try{
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
baseBean.writeLog("22222:");
String sql = " SELECT DEVVALUE,TESTVALUE,PRODVALUE FROM UF_PROP WHERE PKEY = ?"; String sql = " SELECT DEVVALUE,TESTVALUE,PRODVALUE FROM UF_PROP WHERE PKEY = ?";
rs.executeQuery(sql,new Object[]{pkey});
baseBean.writeLog("22222:");
baseBean.writeLog("propbeansql:"+sql);
rs.executeQuery(sql,new Object[]{pkey.trim()});
baseBean.writeLog("33333:");
if(rs.next()){ if(rs.next()){
pvalue = Util.null2String(rs.getString(active+"VALUE")); pvalue = Util.null2String(rs.getString(active+"VALUE"));
} }
baseBean.writeLog("4444444:");
baseBean.writeLog("pvalue:"+pvalue); baseBean.writeLog("pvalue:"+pvalue);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace();
bb.writeLog("propbean-e:"+e);
}
return pvalue;
}
/***
*
* @param pkey
* @return
*/
public String getUfPropValueStatic(String pkey)
{
BaseBean baseBean = new BaseBean();
if(StringUtils.isEmpty(pkey)){
return "";
}
String active = Util.null2String(baseBean.getPropValue("developProp","active")).toUpperCase();
String pvalue = "";
try{
RecordSet rs = new RecordSet();
String sql = " SELECT DEVVALUE,TESTVALUE,PRODVALUE FROM UF_PROP WHERE PKEY = ?";
rs.executeQuery(sql,new Object[]{pkey.trim()});
if(rs.next()){
pvalue = Util.null2String(rs.getString(active+"VALUE"));
}
baseBean.writeLog("pvalue:"+pvalue);
}catch (Exception e){
e.printStackTrace();
bb.writeLog("propbean-e:"+e);
} }
return pvalue; return pvalue;
} }

@ -21,16 +21,15 @@ public class PortalLoginBeforeFilter implements Filter {
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
PropBean propBean = new PropBean();
BaseBean bb = new BaseBean(); String bpm_host_array = propBean.getUfPropValueStatic("bpm_host_array");
String bpm_host_array = PropBean.getUfPropValue("bpm_host_array"); if (StringUtils.isNotEmpty(bpm_host_array)) {
if (!"".equals(bpm_host_array)) {
String[] bpm_host_arr = bpm_host_array.split(";"); String[] bpm_host_arr = bpm_host_array.split(";");
for (int i = 0; i < bpm_host_arr.length; i++) { for (int i = 0; i < bpm_host_arr.length; i++) {
bpmHostList.add(bpm_host_arr[i]); bpmHostList.add(bpm_host_arr[i]);
} }
} }
portalUserAuth = PropBean.getUfPropValue("portal_user_auth"); portalUserAuth = propBean.getUfPropValueStatic("portal_user_auth");
} }
@Override @Override

@ -0,0 +1,23 @@
package weaver.interfaces.dito.job;
import weaver.general.BaseBean;
import weaver.interfaces.schedule.BaseCronJob;
/**
* @version 1.0
* @Title ecology-9
* @Company
* @CreateDate 2022/11/14
* @Description ${description}
* @Author Lee
*/
public class WorkflowAuthModelingCronJobTest extends BaseCronJob {
@Override
public void execute() {
BaseBean bb = new BaseBean();
bb.writeLog("start WorkflowAuthModelingCronJobTest");
WorkflowAuthModelingUtil workflowAuthModelingUtil = new WorkflowAuthModelingUtil();
workflowAuthModelingUtil.executeData("");
}
}

@ -0,0 +1,259 @@
package weaver.interfaces.dito.job;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.share.ShareManager;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @version 1.0
* @Title ecology-9
* @Company
* @CreateDate 2022/11/14
* @Description ${description}
* @Author Lee
*/
public class WorkflowAuthModelingUtil {
public Map<String,Object> executeData(String lcids) {
Map<String,Object> map = new HashMap<String, Object>();
int successDelete = 0;
int failureDelete = 0;
int successInsert = 0;
int failureInsert = 0;
int unchangecount = 0;
int exceptioncount = 0;
BaseBean bb = new BaseBean();
bb.writeLog("start WorkflowAuthModelingCronJobTest");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
bb.writeLog("WorkflowAuthModelingUtil---date:"+sdf.format(new Date()));
RecordSet rs = new RecordSet();
ShareManager shareManager = new ShareManager();
String currentTime = TimeUtil.getCurrentTimeString();
ModeRightInfo modeRightInfo = new ModeRightInfo();
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formatter2 = new SimpleDateFormat("HH:mm:ss");
String modedatacreatedate = formatter1.format(new Date());
String modedatacreatetime = formatter2.format(new Date());
String modedatacreater = "1";
String modedatacreatertype = "0";
String modedatamodifier = "1";
String uf_tablename = "uf_workflow_auth";
try{
String formmodeid = "";
//查询模块id
String formModeSql =" select k.id from modeinfo k \n" +
" inner join workflow_bill l on formid = l.id\n" +
" where l.tablename = ? ";
rs.executeQuery(formModeSql,new Object[]{uf_tablename});
if (rs.next()) {
formmodeid = Util.null2String(rs.getString("id"));
}
bb.writeLog("formmodeid:"+formmodeid);
String where = "" ;
if(StringUtils.isNotEmpty(lcids)){
where = " and in in("+lcids+")" ;
}
List<Map<String,String>> workflowList = new ArrayList<Map<String,String>>();
Map<String,String> workflowMap = null;
String baseWorkflowSql = " select id,workflowname from workflow_base where isvalid = 1 and id <> 1 "+where+" order by id ";
rs.execute(baseWorkflowSql);
while (rs.next()) {
String workflowId = rs.getString("id");
String workflowname = rs.getString("workflowname");
workflowMap = new HashMap<String,String>();
workflowMap.put("workflowId",workflowId);
workflowMap.put("workflowname",workflowname);
workflowList.add(workflowMap);
}
bb.writeLog("workflowList:"+workflowList.size());
for(int i=0;i<workflowList.size();i++)
{
Map<String,String> workflowUserMap = workflowList.get(i);
String workflowId = workflowUserMap.get("workflowId");
List<String> dbUserList = new ArrayList<String>();
String sql = " select userselect from "+uf_tablename+" where effective = 0 and workflowselect = ? " ;
rs.executeQuery(sql,new Object[]{});
while (rs.next()){
String userselect = rs.getString("userselect");
if(!dbUserList.contains(userselect)){
dbUserList.add(userselect);
}
}
bb.writeLog("dbUserList:"+dbUserList.size());
String workflowUserIds = shareManager.getWorkflowCreater(Integer.parseInt(workflowId));
//bb.writeLog("userIds:"+userIds);
if(StringUtils.isNotEmpty(workflowUserIds))
{
Set<String> userSet = new HashSet<String>(Arrays.asList(workflowUserIds.split(",")));
String[] workflowUserArray = userSet.toArray(new String[userSet.size()]);
List<String> workflowUserList = new ArrayList<String>(workflowUserArray.length);
Collections.addAll(workflowUserList, workflowUserArray);
if(workflowUserList !=null && workflowUserList.size() > 0){
// 交集
List<String> intersectionList = workflowUserList.stream().filter(item -> dbUserList.contains(item)).collect(Collectors.toList());
System.out.println("---交集 intersection---:"+intersectionList.size());
unchangecount = intersectionList.size();
// 差集 (list1 - list2)
List<String> addUserList = workflowUserList.stream().filter(item -> !dbUserList.contains(item)).collect(Collectors.toList());
bb.writeLog("---差集 addUserList (workflowUserList - dbUserList)---:"+addUserList.size());
// 差集 (list2 - list1)
List<String> delUserList = dbUserList.stream().filter(item -> !workflowUserList.contains(item)).collect(Collectors.toList());
bb.writeLog("---差集 delUserList (dbUserList - workflowUserList)---:"+delUserList.size());
workflowUserMap.put("adduserids",addUserList.stream().collect(Collectors.joining(",")));
workflowUserMap.put("deluserids",delUserList.stream().collect(Collectors.joining(",")));
}
}else{
workflowUserMap.put("adduserids","");
workflowUserMap.put("deluserids",dbUserList.stream().collect(Collectors.joining(",")));
}
}
for(int i=0;i<workflowList.size();i++)
{
bb.writeLog("iiiiiii:"+i);
Map<String,String> workflowUserMap = workflowList.get(i);
String workflowId = workflowUserMap.get("workflowId");
String workflowname = workflowUserMap.get("workflowname");
String adduserids = workflowUserMap.get("adduserids");
String deluserids = workflowUserMap.get("deluserids");
//bb.writeLog("distinctuserids:"+distinctuserids);
if(StringUtils.isNotEmpty(adduserids))
{
List<String> addUserList = Arrays.asList(adduserids.split(","));
bb.writeLog("userList:"+addUserList.size());
for(int k=0;k<addUserList.size();k++)
{
String userselect = addUserList.get(k) ;
bb.writeLog("k:"+k+" userselect:"+userselect);
String dataid = "" ;
String sql = " select id from "+uf_tablename+" where workflowselect = ? and userselect = ?" ;
bb.writeLog("sql:"+sql);
rs.executeQuery(sql,new Object[]{workflowId,userselect});
if(rs.next()){
dataid = Util.null2String(rs.getString("id"));
}
if(StringUtils.isNotEmpty(dataid))
{
sql = " update "+uf_tablename+" set modedatamodifydatetime=?,effective=0 where id = ?" ;
boolean isTrue = rs.executeUpdate(sql,new Object[]{currentTime,dataid});
bb.writeLog("sql:"+sql);
if(isTrue){
bb.writeLog("更新成功,effective更新成0");
successInsert++;
}else{
bb.writeLog("更新失败,effective更新成0");
failureInsert++;
}
}else{
String workcode = "" ;
sql = " select workcode from hrmresource where id = ?" ;
rs.executeQuery(sql,new Object[]{userselect});
if(rs.next()){
workcode = Util.null2String(rs.getString("workcode"));
}
bb.writeLog("workcode:"+workcode);
int count = 0;
String effective = "0";
String uuid = UUID.randomUUID().toString();
sql = " insert into "+uf_tablename+" (formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,modedatamodifier,modedatamodifydatetime,userselect,effective,workflowselect,workflowname,workcode,uuid) " +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
boolean isTrue = rs.executeUpdate(sql, new Object[]{formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,modedatamodifier,currentTime,userselect,effective,workflowId,workflowname,workcode,uuid});
bb.writeLog("sql:"+sql);
if(isTrue){
count++;
}
if(count >0)
{
String data_id = "" ;
sql = " select id from "+uf_tablename+" where uuid=? " ;
rs.executeQuery(sql,new Object[]{uuid});
bb.writeLog("sql:"+sql);
if(rs.next()){
data_id = Util.null2String(rs.getString("id"));
}
if(StringUtils.isNotEmpty(data_id)){
modeRightInfo.editModeDataShare(Integer.valueOf(modedatacreater), Integer.parseInt(formmodeid), Integer.parseInt(data_id));
bb.writeLog("权限更新成功,:");
}
successInsert++;
}else{
bb.writeLog("新增数据失败,:");
failureInsert++;
}
}
}
}
if(StringUtils.isNotEmpty(deluserids))
{
List<String> addUserList = Arrays.asList(adduserids.split(","));
bb.writeLog("userList:"+addUserList.size());
for(int k=0;k<addUserList.size();k++)
{
String userselect = addUserList.get(k);
String dataid = "" ;
String sql = " select id from "+uf_tablename+" where workflowselect = ? and userselect = ?" ;
bb.writeLog("sql:"+sql);
rs.executeQuery(sql,new Object[]{workflowId,userselect});
if(rs.next()){
dataid = Util.null2String(rs.getString("id"));
}
if(StringUtils.isNotEmpty(dataid))
{
sql = " update "+uf_tablename+" set modedatamodifydatetime=?,effective=0 where id = ?" ;
boolean isTrue = rs.executeUpdate(sql,new Object[]{currentTime,dataid});
bb.writeLog("sql:"+sql);
if(isTrue){
successDelete++;
bb.writeLog("更新成功,effective更新成0");
}else{
failureDelete++;
bb.writeLog("更新失败,effective更新成0");
}
}
}
}
}
}catch (Exception e){
e.printStackTrace();
bb.writeLog("e:"+e);
exceptioncount++;
}
bb.writeLog("WorkflowAuthModelingUtil---date:"+sdf.format(new Date()));
map.put("successDelete",successDelete+"");
map.put("failureDelete",failureDelete+"");
map.put("successInsert",successInsert+"");
map.put("failureInsert",failureInsert+"");
map.put("unchangecount",unchangecount+"");
map.put("exceptioncount",exceptioncount+"");
return map;
}
}

@ -0,0 +1,40 @@
package weaver.interfaces.dito.mq;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt;
import weaver.general.BaseBean;
import java.io.UnsupportedEncodingException;
import java.util.List;
public class RocketMsgListener implements MessageListenerConcurrently {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext consumeConcurrentlyContext) {
BaseBean bb = new BaseBean();
MessageExt msg = msgs.get(0);
RocketmqUtil rocketmqUtil = new RocketmqUtil();
try {
bb.writeLog("Consumer---3----"+new String(msg.getBody()));
String msgdata = new String(msg.getBody(),"UTF-8");
if(!"".equals(msgdata))
{
String data = msgdata.substring(msgdata.indexOf("{"));
int errcount = rocketmqUtil.updateOrgData(data);
bb.writeLog("Consumer---errcount---:"+errcount);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
bb.writeLog("Consumer---UnsupportedEncodingException---e:"+e);
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
}

@ -0,0 +1,216 @@
package weaver.interfaces.dito.mq;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import weaver.file.Prop;
import weaver.general.BaseBean;
import weaver.general.GCONST;
import weaver.general.InitServer;
import weaver.interfaces.dito.comInfo.PropBean;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class RocketmqServlet extends HttpServlet {
private boolean isMainIp = false;//是否为主节点
private boolean isSampleMode = false;//是否为单机启用ridis并且配置了主节点的则不是单机否则认为是集群环境
@Override
public void init() throws ServletException
{
BaseBean bb = new BaseBean();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
bb.writeLog("initiated---进入时间:"+sdf.format(new Date()));
bb.writeLog("***** resource model initiated");
bb.writeLog("***** resource model initiated");
bb.writeLog("***** resource model initiated");
try{
isMainIp = isMainIp();//计算是否为集群中的主节点
isSampleMode = isSampleMode();//判断是否为单机
bb.writeLog("isMainIp:"+isMainIp);
bb.writeLog("isSampleMode:"+isSampleMode);
if(isSampleMode){
initData();
}else{
if (isMainIp) {
//则调用service方法加载设置重新获取workflowid相关超时设置OvertimeEntity
initData();
}
}
//DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("portal-producer-group_nj");
//DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("cbec-consumer-group_nj_133");
//consumer.setNamesrvAddr("172.16.84.183:9001;172.16.84.187:9001");
// consumer.subscribe("dataSync_topic_nj", "BPM");
// consumer.setInstanceName("dataSync_topic_nj");
// String consumerGroup = PropBean.getUfPropValue("consumerGroup");
// bb.writeLog("consumerGroup:"+consumerGroup);
// DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(consumerGroup);
//
// String namesrvAddr = PropBean.getUfPropValue("namesrvAddr");
// bb.writeLog("namesrvAddr:"+namesrvAddr);
// consumer.setNamesrvAddr(namesrvAddr);
//
// String instanceName = PropBean.getUfPropValue("instanceName");
// bb.writeLog("instanceName:"+instanceName);
// consumer.setInstanceName(instanceName);
// consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
// //consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
//
// String topic = PropBean.getUfPropValue("topic");
// String subExpression = PropBean.getUfPropValue("subExpression");
//
// bb.writeLog("topic:"+topic);
// bb.writeLog("subExpression:"+subExpression);
//
// consumer.subscribe(topic,subExpression);
// consumer.setConsumeThreadMin(1);
// consumer.setConsumeThreadMax(1);
// consumer.setConsumeMessageBatchMaxSize(1);
// consumer.setMessageModel(MessageModel.BROADCASTING);
// consumer.registerMessageListener(new RocketMsgListener());
// consumer.registerMessageListener(new RocketMsgOrderListener());
/**
* Consumer使start<br>
*/
// consumer.start();
// bb.writeLog("Consumer Started.");
}catch (Exception e){
bb.writeLog("Consumer resource model initiated--MQClientException:"+e);
}
bb.writeLog("***** resource model initiated");
bb.writeLog("***** resource model initiated");
bb.writeLog("***** resource model initiated");
}
public void initData(){
BaseBean bb = new BaseBean();
PropBean propBean = new PropBean();
try {
String consumerGroup = propBean.getUfPropValueStatic("consumerGroup");
bb.writeLog("consumerGroup:" + consumerGroup);
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(consumerGroup);
String namesrvAddr = propBean.getUfPropValueStatic("namesrvAddr");
bb.writeLog("namesrvAddr:" + namesrvAddr);
consumer.setNamesrvAddr(namesrvAddr);
String instanceName = propBean.getUfPropValueStatic("instanceName");
bb.writeLog("instanceName:" + instanceName);
consumer.setInstanceName(instanceName);
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
String topic = propBean.getUfPropValueStatic("topic");
String subExpression = propBean.getUfPropValueStatic("subExpression");
bb.writeLog("topic:" + topic);
bb.writeLog("subExpression:" + subExpression);
String authid = propBean.getUfPropValueStatic("authid");
String authpwd = propBean.getUfPropValueStatic("authpwd");
String clustername = propBean.getUfPropValueStatic("clustername");
String tenantid = propBean.getUfPropValueStatic("tenantid");
bb.writeLog("authid:" + authid);
bb.writeLog("authpwd:" + authpwd);
bb.writeLog("clustername:" + clustername);
bb.writeLog("tenantid:" + tenantid);
consumer.subscribe(topic, subExpression);
consumer.setAuthID(authid);
consumer.setAuthPWD(authpwd);
consumer.setClusterName(clustername);
consumer.setTenantID(tenantid);
consumer.setConsumeThreadMin(1);
consumer.setConsumeThreadMax(1);
consumer.setConsumeMessageBatchMaxSize(1);
consumer.setMessageModel(MessageModel.BROADCASTING);
consumer.registerMessageListener(new RocketMsgListener());
consumer.start();
bb.writeLog("Consumer66Started.");
} catch (MQClientException var13) {
bb.writeLog("Consumer resource model initiated--MQClientException:" + var13);
}
}
/**
* HttpServlet doGet
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
/**
* HttpServlet doPost
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
@Override
public void destroy()
{
// 什么也不做
}
private boolean isMainIp() {
new BaseBean().writeLog("超时判断主节点");
String mainControlIp = "";
ArrayList<String> hostIps = new InitServer().getRealIp();
Prop prop = Prop.getInstance();
mainControlIp = prop.getPropValue(GCONST.getConfigFile(), "MainControlIP");
if (hostIps == null || hostIps.size() == 0) {
new BaseBean().writeLog("System Init Error:Cannot get local Ip address,This may cause scripts or Timed task not run! ");
} else {
new BaseBean().writeLog("System Init Message:mainControlIp=" + mainControlIp + " localIp:" + hostIps.toString());
}
if ((!"".equals(mainControlIp) && hostIps.contains(mainControlIp)) || "".equals(mainControlIp)) {
return true;
}
return false;
}
public boolean isSampleMode() {
BaseBean base = new BaseBean();
boolean redis_flag = "1".equals(base.getPropValue("weaver_new_session", "status"));
boolean mainIp_flag = !"".equals(base.getPropValue("weaver", "MainControlIP"));
base.writeLog("超时判断是否为集群环境redis_flag======"+redis_flag);
base.writeLog("超时判断是否为集群环境mainIp_flag======="+mainIp_flag);
return !(redis_flag && mainIp_flag);
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save