源码修改和代码修改1018

main
wcf 2 years ago
parent 04d8078f75
commit cadd64ab0f

@ -0,0 +1,199 @@
package com.customization.dito.sendtodo;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.constant.Constants;
import com.time.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.dito.comInfo.PropBean;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
/**
* @Title
* @Author wangchaofa
* @CreateDate 2023/9/26
* @Version 1.0
* @Description
*/
public class SendPortalAtAddTodoCmd {
private Map<String,Object> params;
public static String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
public SendPortalAtAddTodoCmd(){
}
public SendPortalAtAddTodoCmd(Map<String,Object> params){
this.params=params;
}
public String getShortMessageTitle(String messageTitle) {
if (messageTitle.length() > 20) {
messageTitle = messageTitle.substring(0, 17) + "...";
}
return messageTitle;
}
/**
*
* @param username
* @param passwd
* @param portal_todourl
* @param bpm_workflowurl
* @param bpm_app_workflowurl
* @param bpm_app_requesturl
*/
public void sendTodoDataByNode(String requestid, List<Map<String,Object>> todolist, String username, String passwd, String center, String portal_todourl, String bpm_workflowurl, String bpm_app_workflowurl, String bpm_app_requesturl){
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
JSONObject requestObject = new JSONObject();
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
bb.writeLog("SendPortalQithRawRunnable--sendTodoDataByNode");
String terminal = "1" ;
String taskType = "0";
String actionType = "0" ;
try {
bb.writeLog("SendPortalAtAddTodoCmd sleep start");
Thread.sleep(2000);
bb.writeLog("sleep end ");
String sql = "";
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
String urlPc = "[newtab]"+bpm_workflowurl+"/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid ;
String replace = bpm_app_workflowurl.replace("/bpm", "");
String urlDing = replace+bpm_app_requesturl+requestid;
String urlApp = replace+bpm_app_requesturl+requestid;
if(StringUtils.isNotEmpty(mobileJumpUrl)){
urlDing += "&returnUrl="+ URLEncoder.encode(mobileJumpUrl,"UTF-8");
urlApp += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8");
}
bb.writeLog("urlDing", urlDing);
String requestname = "" ;
String workflowname = "" ;
String nodeId = "" ;
String nodeName = "" ;
String lastName = "";
sql =" select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid"+
" 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 ) h2 on h2.id = t1.creater \n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = "+requestid ;
bb.writeLog("sendTodoDataByNode--sql2:"+sql);
rs.executeQuery(sql);
if (rs.next()){
requestname = Util.null2String(rs.getString("requestname")) ;
workflowname = Util.null2String(rs.getString("workflowname")) ;
nodeId = Util.null2String(rs.getString("nodeid")) ;
nodeName = Util.null2String(rs.getString("nodeName")) ;
lastName = Util.null2String(rs.getString("loginid")) ;
}
requestObject.put("center",center);
requestObject.put("title",requestname);
requestObject.put("creator",lastName);
// requestObject.put("taskCode","weaver"+requestid);
requestObject.put("taskType",taskType);
requestObject.put("actionType",actionType);
requestObject.put("createDate",processTime);
requestObject.put("messageTitle",getShortMessageTitle(requestname));
requestObject.put("messageContent",requestname);
requestObject.put("terminal",terminal);
requestObject.put("urlPc",urlPc);
requestObject.put("urlApp",urlApp);
requestObject.put("urlDing",urlDing);
requestObject.put("nodeName",nodeName);
requestObject.put("ticketType",workflowname);
JSONArray taskObjectList = new JSONArray();
for (Map<String,Object> todoMap: todolist){
JSONObject taskObject = new JSONObject();
JSONArray list = new JSONArray();
JSONObject requestObject2 = new JSONObject();
requestObject2.putAll(requestObject);
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
requestObject2.put("nodeName",todoMap.get("nodename"));
requestObject2.put("nodeId",todoMap.get("nodeid"));
requestObject2.put("taskCode",requestid+"_at_"+todoMap.get("id"));
String creator = (String) todoMap.get("loginid");
if("sysadmin".equals(creator)){
creator = "Admin";
}
taskObject.put("objectAction","0");
taskObject.put("objectType","0");
taskObject.put("objectCode",creator);
taskObject.put("objectId",todoMap.get("id"));
taskObject.put("operatorCode",creator);
list.add(taskObject);
requestObject2.put("messageTitle",getShortMessageTitle(requestname));
requestObject2.put("messageContent", requestname);
requestObject2.put("terminal", "1");
requestObject2.put("taskType", "1");
requestObject2.put("actionType", "0");
requestObject2.put("taskObjectList",list);
String auth = username + ":" + passwd;
bb.writeLog("SendPortalToReadUtil--requestObject:" + requestObject2.toJSONString());
String msgdata = httpRequestUtil.doPostByAuth(Constants.portal_todourl, requestObject2.toJSONString(), auth);
bb.writeLog("SendPortalToReadUtil-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)) {
sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,rs.getString("nodename"),rs.getString("userid"),requestObject2.toJSONString(),resultCode,"");
}else if ("TODO-FAIL-002".equals(resultCode)){
//The task does not exist.任务不存在,则新增
User user = new User();
user.setUid(Integer.valueOf(todoMap.get("id").toString()));
SendPortalToReadUtil sendPortalToReadUtil = new SendPortalToReadUtil();
sendPortalToReadUtil.sendToReadDataByCreateNode(requestid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
}else{
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,rs.getString("nodename"),rs.getString("userid"),requestObject2.toJSONString(),resultCode,resultmsg);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,600 @@
package com.customization.dito.sendtodo;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.constant.Constants;
import com.time.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.dito.comInfo.PropBean;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Title
* @Author wangchaofa
* @CreateDate 2023/10/9
* @Version 1.0
* @Description
*/
public class SendPortalForwardCmd {
private Map<String,Object> params;
public static String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
public BaseBean bb = new BaseBean();
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
SendMailUtil sendMailUtil = new SendMailUtil();
String scopeid = "-1";
String scope = "HrmCustomFieldByInfoType" ;
public SendPortalForwardCmd(){
}
public SendPortalForwardCmd(Map<String,Object> params){
this.params=params;
}
//转发
public void forwardSendPortal(String requestid,int currentnodeid,User user) {
bb.writeLog("======== SendPortalForwardCmd forwardSendPortal =========================");
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
String username = PropBean.getUfPropValue("username");
String passwd = PropBean.getUfPropValue("passwd");
String center = PropBean.getUfPropValue("center");
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
String portal_doneurl = PropBean.getUfPropValue("portal_doneurl");
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
RecordSet rs = new RecordSet();
try {
String zhjkbs = "com.customization.dito.sendtodo.SendPortalForwardCmd.forwardSendPortal";
String actionType = "0";
String terminal = "1";
String taskType = "0";
String objectAction = "0";
String objectType = "0";
String sql = "";
String workflowname = "";
String nodeId = "";
String nodeName = "";
JSONObject requestObject = new JSONObject();
String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid;
String replace = bpm_app_workflowurl.replace("/bpm", "");
String urlDing = replace + bpm_app_requesturl + requestid;
String urlApp = replace + bpm_app_requesturl + requestid;
String msgdata = "";
String requestname = "";
String lastname = "";
String userids = "";
String loginid = "";
String emailArray = "";
sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " +
" 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 ) h2 on h2.id = t1.creater \n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = " + requestid;
bb.writeLog("SendPortalForwardCmd --sql2:" + sql);
rs.executeQuery(sql);
if (rs.next()) {
requestname = Util.null2String(rs.getString("requestname"));
workflowname = Util.null2String(rs.getString("workflowname"));
nodeId = Util.null2String(rs.getString("nodeid") + user.getUID());
nodeName = Util.null2String(rs.getString("nodeName"));
lastname = Util.null2String(rs.getString("lastname"));
loginid = Util.null2String(rs.getString("loginid"));
}
if (StringUtils.isNotEmpty(mobileJumpUrl)) {
urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
}
JSONArray taskObjectList = new JSONArray();
bb.writeLog("SendPortalForwardCmd urlDing", urlDing);
requestObject.put("center", center);
requestObject.put("title", requestname);
requestObject.put("creator", loginid);
requestObject.put("taskCode", "weaver_zf_" + requestid);
requestObject.put("nodeId", currentnodeid);
requestObject.put("taskType", taskType);
requestObject.put("actionType", actionType);
requestObject.put("createDate", processTime);
requestObject.put("messageTitle", getShortMessageTitle(requestname));
requestObject.put("messageContent", requestname);
requestObject.put("terminal", terminal);
requestObject.put("urlPc", urlPc);
requestObject.put("urlApp", urlApp);
requestObject.put("urlDing", urlDing);
requestObject.put("nodeName", getNodeName(currentnodeid));
requestObject.put("ticketType", workflowname);
sql = " select t2.userid,h1.loginid,h1.email,c1." + cus_staff + " as staffid " +
" from workflow_requestbase t1\n" +
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= " + scopeid + " and c1.scope = '" + scope + "' " +
" 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 = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '7','11'))\n" +
" and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.requestid = " + requestid;
bb.writeLog("SendPortalForwardCmd forward --sql:" + sql);
rs.executeQuery(sql);
while (rs.next()) {
JSONObject taskObject = new JSONObject();
String usercode = Util.null2String(rs.getString("loginid"));
String staffid = Util.null2String(rs.getString("staffid"));
String userid1 = Util.null2String(rs.getString("userid"));
userids += StringUtils.isEmpty(userids) ? userid1 : "," + userid1;
if ("sysadmin".equals(usercode)) {
usercode = "Admin";
}
String objectCode = usercode;
String operatorCode = usercode;
taskObject.put("objectAction", objectAction);
taskObject.put("objectType", objectType);
taskObject.put("objectCode", objectCode);
taskObject.put("objectId", staffid);
taskObject.put("operatorCode", operatorCode);
taskObjectList.add(taskObject);
String email = Util.null2String(rs.getString("email"));
bb.writeLog("SendPortalForwardCmd email3:" + email);
Matcher matcher = regex.matcher(email);
if (matcher.matches()) {
emailArray += StringUtils.isEmpty(emailArray) ? email : "," + email;
}
}
if (taskObjectList.size() > 0) {
requestObject.put("taskObjectList", taskObjectList);
} else {
requestObject.put("actionType", "3");
}
bb.writeLog("SendPortalForwardCmd requestObject:" + requestObject.toJSONString());
String auth = username + ":" + passwd;
msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth);
if (!"".equals(msgdata)) {
JSONObject msgObject = JSONObject.parseObject(msgdata);
if (msgObject.containsKey("resultCode")) {
String resultCode = msgObject.getString("resultCode");
if ("0".equals(resultCode)) {
bb.writeLog("SendPortalForwardCmd emailArray:" + emailArray);
if (StringUtils.isNotEmpty(emailArray)) {
Map<String, String> templateMap = getEmailTemplate(requestname, lastname, processTime);
String notificationSubject = templateMap.get("notificationSubject");
String notificationContent = templateMap.get("notificationContent");
sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
}
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, "", zhjkbs);
} else {
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, resultmsg, zhjkbs);
}
}
}
}catch (Exception e){
bb.writeLog(e);
e.printStackTrace();
}
}
//转办
public void transferSendPortal(String requestid,int currentnodeid,User user){
bb.writeLog("======== SendPortalForwardCmd transferSendPortal =========================");
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
String username = PropBean.getUfPropValue("username");
String passwd = PropBean.getUfPropValue("passwd");
String center = PropBean.getUfPropValue("center");
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
String portal_doneurl = PropBean.getUfPropValue("portal_doneurl");
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
RecordSet rs = new RecordSet();
try {
String zhjkbs = "com.customization.dito.sendtodo.SendPortalForwardCmd.transferSendPortal";
String actionType = "2";
String terminal = "1";
String taskType = "0";
String objectAction = "0";
String objectType = "0";
String sql = "";
String workflowname = "";
String nodeId = "";
String nodeName = "";
JSONObject requestObject = new JSONObject();
String urlPc = "[newtab]"+ Constants.bpm_workflowurl+"/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid ;
String replace = bpm_app_workflowurl.replace("/bpm", "");
String urlDing = replace+bpm_app_requesturl+requestid ;
String urlApp = replace+bpm_app_requesturl+requestid ;
if(StringUtils.isNotEmpty(mobileJumpUrl)){
urlDing += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8");
urlApp += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8");
}
String msgdata = "";
String requestname = "";
String lastname = "";
String userids = "";
String loginid = "";
String emailArray = "";
sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " +
" 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 ) h2 on h2.id = t1.creater \n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = " + requestid;
bb.writeLog("SendPortalForwardCmd --sql2:" + sql);
rs.executeQuery(sql);
if (rs.next()) {
requestname = Util.null2String(rs.getString("requestname"));
workflowname = Util.null2String(rs.getString("workflowname"));
nodeId = Util.null2String(rs.getString("nodeid") + user.getUID());
nodeName = Util.null2String(rs.getString("nodeName"));
lastname = Util.null2String(rs.getString("lastname"));
loginid = Util.null2String(rs.getString("loginid"));
}
if (StringUtils.isNotEmpty(mobileJumpUrl)) {
urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
}
JSONArray taskObjectList = new JSONArray();
bb.writeLog("SendPortalForwardCmd urlDing", urlDing);
requestObject.put("center", center);
requestObject.put("title", requestname);
requestObject.put("creator", loginid);
requestObject.put("taskCode", "weaver" + requestid);
requestObject.put("nodeId", currentnodeid);
requestObject.put("taskType", taskType);
requestObject.put("actionType", actionType);
requestObject.put("createDate", processTime);
requestObject.put("messageTitle", getShortMessageTitle(requestname));
requestObject.put("messageContent", requestname);
requestObject.put("terminal", terminal);
requestObject.put("urlPc", urlPc);
requestObject.put("urlApp", urlApp);
requestObject.put("urlDing", urlDing);
requestObject.put("nodeName", getNodeName(currentnodeid));
requestObject.put("ticketType", workflowname);
sql = " select t2.userid,h1.loginid,h1.email,c1." + cus_staff + " as staffid " +
" from workflow_requestbase t1\n" +
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= " + scopeid + " and c1.scope = '" + scope + "' " +
" 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 = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '7','11'))\n" +
" and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.requestid = " + requestid;
bb.writeLog("SendPortalForwardCmd forward --sql:" + sql);
rs.executeQuery(sql);
while (rs.next()) {
JSONObject taskObject = new JSONObject();
String usercode = Util.null2String(rs.getString("loginid"));
String staffid = Util.null2String(rs.getString("staffid"));
String userid1 = Util.null2String(rs.getString("userid"));
userids += StringUtils.isEmpty(userids) ? userid1 : "," + userid1;
if ("sysadmin".equals(usercode)) {
usercode = "Admin";
}
String objectCode = usercode;
String operatorCode = usercode;
taskObject.put("objectAction", objectAction);
taskObject.put("objectType", objectType);
taskObject.put("objectCode", objectCode);
taskObject.put("objectId", staffid);
taskObject.put("operatorCode", operatorCode);
taskObjectList.add(taskObject);
String email = Util.null2String(rs.getString("email"));
bb.writeLog("SendPortalForwardCmd email3:" + email);
Matcher matcher = regex.matcher(email);
if (matcher.matches()) {
emailArray += StringUtils.isEmpty(emailArray) ? email : "," + email;
}
}
if (taskObjectList.size() > 0) {
requestObject.put("taskObjectList", taskObjectList);
} else {
requestObject.put("actionType", "3");
}
bb.writeLog("================ SendPortalForwardCmd requestObject ============= "+ requestObject.toJSONString());
String auth = username + ":" + passwd;
msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth);
if (!"".equals(msgdata)) {
JSONObject msgObject = JSONObject.parseObject(msgdata);
if (msgObject.containsKey("resultCode")) {
String resultCode = msgObject.getString("resultCode");
if ("0".equals(resultCode)) {
bb.writeLog("SendPortalForwardCmd emailArray:" + emailArray);
if (StringUtils.isNotEmpty(emailArray)) {
Map<String, String> templateMap = getEmailTemplate(requestname, lastname, processTime);
String notificationSubject = templateMap.get("notificationSubject");
String notificationContent = templateMap.get("notificationContent");
sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
}
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, "",zhjkbs);
} else {
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs);
}
}
}
}catch (Exception e){
bb.writeLog(e);
e.printStackTrace();
}
}
//流程归档转发处理
public void delTodoAddDoneSendPortal(String requestid,int currentnodeid,User user){
bb.writeLog("======== SendPortalForwardCmd delTodoAddDoneSendPortal =========================");
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
String username = PropBean.getUfPropValue("username");
String passwd = PropBean.getUfPropValue("passwd");
String center = PropBean.getUfPropValue("center");
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
String portal_doneurl = PropBean.getUfPropValue("portal_doneurl");
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
RecordSet rs = new RecordSet();
try {
String zhjkbs = "com.customization.dito.sendtodo.SendPortalForwardCmd.delTodoAddDoneSendPortal";
String sql = "";
String workflowname = "";
String nodeId = "";
String nodeName = "";
JSONObject requestObject = new JSONObject();
String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid;
String replace = bpm_app_workflowurl.replace("/bpm", "");
String urlDing = replace + bpm_app_requesturl + requestid;
String urlApp = replace + bpm_app_requesturl + requestid;
String msgdata = "";
String requestname = "";
String lastname = "";
String loginid = "";
sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " +
" 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 ) h2 on h2.id = t1.creater \n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = " + requestid;
bb.writeLog("SendPortalWithAddTodoCmd delTodoAddDoneSendPortal --sql:" + sql);
rs.executeQuery(sql);
if (rs.next()) {
requestname = Util.null2String(rs.getString("requestname"));
workflowname = Util.null2String(rs.getString("workflowname"));
nodeId = Util.null2String(rs.getString("nodeid") + user.getUID());
nodeName = Util.null2String(rs.getString("nodeName"));
loginid = Util.null2String(rs.getString("loginid"));
}
//判断是否为转发节点
sql = "SELECT c1." + PropBean.getUfPropValue("cus_staff") + " as staffid FROM workflow_currentoperator t1 left join cus_fielddata c1 on c1.id = t1.userid and c1.scopeid= " + scopeid + " and c1.scope = '" + scope + "' WHERE t1.preisremark=1 and t1.REQUESTID=? and t1.USERID=?";
rs.executeQuery(sql, requestid, user.getUID());
if (rs.next()) {
//删除转发的待办
JSONObject jsonObject = new JSONObject();
jsonObject.put("center", center);
jsonObject.put("title", requestname);
jsonObject.put("creator", loginid);
jsonObject.put("taskCode", "weaver_zf_" + requestid);
jsonObject.put("taskType", "0");
jsonObject.put("actionType", "1");
jsonObject.put("createDate", processTime);
jsonObject.put("messageTitle", getShortMessageTitle(requestname));
jsonObject.put("messageContent", requestname);
jsonObject.put("terminal", "1");
jsonObject.put("urlPc", urlPc);
jsonObject.put("urlApp", urlApp);
jsonObject.put("urlDing", urlDing);
jsonObject.put("nodeName", nodeName);
jsonObject.put("ticketType", workflowname);
JSONArray list = new JSONArray();
JSONObject taskObject = new JSONObject();
list.add(taskObject);
taskObject.put("objectAction", "1");
taskObject.put("objectType", "0");
taskObject.put("objectCode", user.getLoginid());
taskObject.put("objectId", rs.getString("staffid"));
taskObject.put("operatorCode", user.getLoginid());
jsonObject.put("taskObjectList", list);
bb.writeLog("SendPortalWithAddDoneCmd--delTodoAddDoneSendPortal--requestObject:" + jsonObject.toJSONString());
String auth = username + ":" + passwd;
msgdata = httpRequestUtil.doPostByAuth(Constants.portal_todourl, jsonObject.toJSONString(), auth);
bb.writeLog("SendPortalWithAddDoneCmd-delTodoAddDoneSendPortal-msgdata:" + msgdata);
if (StringUtils.isNotEmpty(msgdata)) {
JSONObject msgObject = JSONObject.parseObject(msgdata);
if (msgObject.containsKey("resultCode")) {
String resultCode = msgObject.getString("resultCode");
if (!"0".equals(resultCode)) {
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, user.getUID() + "", nodeName, user.getUID() + "", jsonObject.toJSONString(), resultCode, resultmsg, zhjkbs);
}
}
}
}
// 增加已办
requestObject.put("center", center);
requestObject.put("taskCode", "weaver" + requestid);
requestObject.put("nodeId", nodeId);
requestObject.put("ticketType", workflowname);
requestObject.put("title", requestname);
requestObject.put("creator", loginid);
requestObject.put("processStaff", loginid);
requestObject.put("processTime", processTime);
requestObject.put("isRecall", "1");
requestObject.put("actionType", "0");
requestObject.put("urlPC", urlPc);
requestObject.put("urlApp", urlApp);
requestObject.put("urlDing", urlDing);
String auth = username + ":" + passwd;
bb.writeLog("delTodoAddDoneSendPortal done requestObject:" + requestObject.toJSONString());
msgdata = httpRequestUtil.doPostByAuth(portal_doneurl, requestObject.toJSONString(), auth);
bb.writeLog("delTodoAddDoneSendPortal done msgdata:" + msgdata);
if (StringUtils.isNotEmpty(msgdata)) {
JSONObject msgObject = JSONObject.parseObject(msgdata);
//{"resultCode":"1","resultMsg":"No Result"}
if (msgObject.containsKey("resultCode")) {
String resultCode = msgObject.getString("resultCode");
if (!"0".equals(resultCode)) {
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, user.getUID() + "", requestObject.toJSONString(), resultCode, resultmsg, zhjkbs);
}
}
}
}catch (Exception e){
e.printStackTrace();
rs.writeLog(e);
}
}
public String getShortMessageTitle(String messageTitle) {
if (messageTitle.length() > 20) {
messageTitle = messageTitle.substring(0, 17) + "...";
}
return messageTitle;
}
/***
*
* @param requestname
* @param operator
* @param operatorTime
* @return
*/
public Map<String,String> getEmailTemplate(String requestname,String operator,String operatorTime){
Map<String,String> dataMap = new HashMap<String,String>();
String notificationSubject = "You have a new To-Read - <"+requestname+"> ";
String notificationContent = operator + " created this task on "+operatorTime+"\n" +
" Please handle it in time.";
dataMap.put("notificationSubject",notificationSubject);
dataMap.put("notificationContent",notificationContent);
return dataMap;
}
/**
*
* @param requestid
* @param nodeid
* @return
*/
public boolean checkIsOvertime(String requestid,String nodeid){
boolean flag = false;
RecordSet rs = new RecordSet();
rs.executeQuery("select * from workflow_currentoperator where requestid=? and nodeid=?",requestid,nodeid);
if(rs.next()){
double overtime = Util.getDoubleValue(rs.getString("overtime"),0);
if(overtime > 0){
flag = true;
}
}
return flag;
}
/**
* id
* @param requestid
* @param nodeid
* @return
*/
public String getLastnodeid(String requestid,int nodeid){
String result = "";
RecordSet rs = new RecordSet();
rs.executeQuery("select * from workflow_requestbase where requestid=? and currentnodeid=?",requestid,nodeid);
if(rs.next()){
result = Util.null2String(rs.getString("lastnodeid"));
}
return result;
}
/***
*
* @param nodeid
* @return
*/
public String getNodeName(int nodeid){
RecordSet rs = new RecordSet();
String name = "";
rs.executeQuery(" select nodename from workflow_nodebase where id = ?",nodeid);
while (rs.next()){
name = Util.null2String(rs.getString("nodename"));
}
return name;
}
}

@ -24,8 +24,9 @@ public class SendPortalToReadUtil {
/***
*
* @param requestid
* @param user
*/
public void sendToReadDataByCreateNode(String requestid,String portal_todourl,String bpm_app_workflowurl,String username,String passwd,String bpm_workflowurl,String center,String bpm_app_requesturl){
public void sendToReadDataByCreateNode(String requestid,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();
@ -52,10 +53,25 @@ public class SendPortalToReadUtil {
try {
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
JSONArray taskObjectList = new JSONArray();
// int u_userid = user.getUID();
String lastname = "";
String loginid = "" ;
// String workcode = "";
// String sql = " select * from (select id, lastname,loginid from hrmresource where status = 1 union all select id, lastname,loginid from hrmresourcemanager ) w where w.id = '" + u_userid + "'";
// rs.executeQuery(sql);
// while (rs.next()) {
// workcode = Util.null2String(rs.getString("loginid"));
// }
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 replace = bpm_app_workflowurl.replace("/bpm", "");
// String urlDing = replace+bpm_app_requesturl+requestid;
// bb.writeLog("urlDing", urlDing);
// String urlApp = replace+bpm_app_requesturl+requestid;
String urlDing = replace+bpm_app_requesturl+requestid;
String urlApp = replace+bpm_app_requesturl+requestid;
if(StringUtils.isNotEmpty(mobileJumpUrl)){
@ -65,8 +81,13 @@ public class SendPortalToReadUtil {
String requestname = "";
String workflowname = "" ;
String lastname = "";
String loginid = "";
// sql =" select t1.requestname,t1.requestmark,t3.workflowname\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 "+
// " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
// " and t1.requestid = "+requestid ;
String sql =" select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid "+
" from workflow_requestbase t1\n" +
" inner join workflow_base t3 on t1.workflowid = t3.id\n" +
@ -74,6 +95,7 @@ public class SendPortalToReadUtil {
" left join (select id,lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h2 on h2.id = t1.creater \n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = "+requestid ;
bb.writeLog("sendToReadDataByNode--sql:"+sql);
rs.executeQuery(sql);
if (rs.next()){
@ -178,6 +200,8 @@ public class SendPortalToReadUtil {
if(matcher.matches()){
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
}
bb.writeLog("emailArray:"+emailArray);
if(StringUtils.isNotEmpty(emailArray))
{
@ -210,8 +234,9 @@ public class SendPortalToReadUtil {
*
* @param requestid
* @param noideid
* @param user
*/
public void sendToReadDataByNode(String requestid,String noideid,String portal_todourl,String bpm_app_workflowurl,String username,String passwd,String bpm_workflowurl,String center,String bpm_app_requesturl){
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();
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
@ -237,6 +262,17 @@ public class SendPortalToReadUtil {
String taskType = "1";
try {
// int u_userid = user.getUID();
String lastname = "";
//
// String workcode = "";
// String sql = " select * from (select id, lastname,loginid from hrmresource where status = 1 union all select id, lastname,loginid from hrmresourcemanager ) w where w.id = '" + u_userid + "'";
// rs.executeQuery(sql);
// while (rs.next()) {
// workcode = Util.null2String(rs.getString("loginid"));
// }
int count = 0 ;
String countSql =" select t2.userid \n" +
" from workflow_requestbase t1\n" +
@ -261,8 +297,13 @@ public class SendPortalToReadUtil {
String urlPc = "[newtab]"+bpm_workflowurl+"/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid ;
String replace = bpm_app_workflowurl.replace("/bpm", "");
// String urlDing = replace+bpm_app_requesturl+requestid;
//// String urlApp = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+creator+"&forwardurl="+app_requestUrl;
// String urlApp = replace+bpm_app_requesturl+requestid;
String urlDing = replace+bpm_app_requesturl+requestid;
String urlApp = replace+bpm_app_requesturl+requestid;
if(StringUtils.isNotEmpty(mobileJumpUrl)){
urlDing += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8");
urlApp += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8");
@ -273,9 +314,13 @@ public class SendPortalToReadUtil {
String workflowname = "" ;
String requestname = "";
String loginid = "";
String lastname = "" ;
JSONArray taskObjectList = new JSONArray();
// sql =" select t1.workflowid,t1.requestname,t1.requestmark,t3.workflowname\n" +
// " from workflow_requestbase t1\n" +
// " inner join workflow_base t3 on t1.workflowid = t3.id\n" +
// " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
// " and t1.requestid = " + requestid;
String sql =" select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid "+
" from workflow_requestbase t1\n" +
@ -296,6 +341,7 @@ public class SendPortalToReadUtil {
requestObject.put("center", center);
requestObject.put("title", requestname);
requestObject.put("taskType", taskType);
requestObject.put("actionType", actionType);
requestObject.put("createDate", processTime);
@ -401,9 +447,10 @@ public class SendPortalToReadUtil {
sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeid,nodename,userid,requestObject.toJSONString(),resultCode,"");
}else if ("TODO-FAIL-002".equals(resultCode)){
//The task does not exist.任务不存在,则新增
sendToReadDataByCreateNode(requestid,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
sendToReadDataByCreateNode(requestid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
} else{
@ -414,17 +461,14 @@ public class SendPortalToReadUtil {
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/***
*
* @param messageTitle
* @return
*/
private String getShortMessageTitle(String messageTitle) {
if (messageTitle.length() > 20) {
messageTitle = messageTitle.substring(0, 17) + "...";

@ -6,10 +6,10 @@ import com.engine.core.interceptor.AbstractCommandProxy;
import com.engine.core.interceptor.Command;
import com.engine.workflow.cmd.requestForm.RequestSubmitCmd;
import com.engine.workflow.entity.requestForm.RequestOperationResultBean;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.dito.comInfo.PropBean;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@ -45,6 +45,13 @@ public class SendPortalTodoCmd extends AbstractCommandProxy<Map<String,Object>>
// System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
// }
RecordSet rs = new RecordSet();
rs.executeQuery("select * from workflow_requestlogAtInfo where requestid=? ",requestid);
while(rs.next()){
String atuserid = Util.null2String(rs.getString("atuserid"));
bb.writeLog(requestid+"======================== SendPortalTodoCmd ========================="+ atuserid);
}
User user = requestSubmitCmd.getUser();
bb.writeLog("requestid:"+requestid);
bb.writeLog("workflowid:"+workflowid);
@ -63,32 +70,29 @@ public class SendPortalTodoCmd extends AbstractCommandProxy<Map<String,Object>>
String new_requestid = Util.null2String(resultBean.getResultInfo().get("requestid"));
bb.writeLog("new_requestid:"+new_requestid);
SendPortalTodoUtil sendPortalTodoUtil = new SendPortalTodoUtil();
SendPortalToReadUtil sendPortalToReadUtil = new SendPortalToReadUtil();
String portal_todourl = Constants.portal_todourl;
String bpm_app_workflowurl = Constants.bpm_app_workflowurl;
String username = Constants.username;
String passwd = Constants.passwd;
String bpm_workflowurl = Constants.bpm_workflowurl;
String center = Constants.center;
String bpm_app_requesturl = Constants.bpm_app_requesturl;
// String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
// String portal_doneurl = PropBean.getUfPropValue("portal_doneurl");
// String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
// String portal_todourl = PropBean.getUfPropValue("portal_todourl");
// String username = PropBean.getUfPropValue("username");
// String passwd = PropBean.getUfPropValue("passwd");
// String center = PropBean.getUfPropValue("center");
// String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
SendPortalTodoUtil sendPortalTodoUtil = new SendPortalTodoUtil();
if(Util.getIntValue(requestid) == -1 && "save".equals(src)){
sendPortalTodoUtil.sendTodoDataByCreater(new_requestid,user, portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
sendPortalTodoUtil.sendTodoDataByCreater(new_requestid,user, Constants.portal_todourl, Constants.bpm_app_workflowurl, Constants.username, Constants.passwd, Constants.bpm_workflowurl, Constants.center, Constants.bpm_app_requesturl);
}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);
sendPortalToReadUtil.sendToReadDataByCreateNode(new_requestid,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
sendPortalTodoUtil.sendTodoDataByCreateNode(new_requestid,nodeid,user, Constants.portal_todourl, Constants.bpm_app_workflowurl, Constants.username, Constants.passwd, Constants.bpm_workflowurl, Constants.center, Constants.bpm_app_requesturl);
}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);
sendPortalToReadUtil.sendToReadDataByNode(requestid,nodeid,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
sendPortalTodoUtil.sendTodoDataByNode(requestid,nodeid,user, Constants.portal_todourl, Constants.bpm_app_workflowurl, Constants.username, Constants.passwd, Constants.bpm_workflowurl, Constants.center, Constants.bpm_app_requesturl);
}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, Constants.portal_todourl, Constants.bpm_app_workflowurl, Constants.username, Constants.passwd, Constants.bpm_workflowurl, Constants.center, Constants.bpm_app_requesturl);
}
// SendPortalTodoRunnable sendPortalTodoRunnable = new SendPortalTodoRunnable(src,new_requestid,requestid,nodeid,user);
// new Thread(sendPortalTodoRunnable).start();

@ -44,12 +44,12 @@ public class SendPortalTodoRunnable implements Runnable{
}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);
// sendPortalDoneUtil.sendPortalDoneData( new_requestid, nodeid, user, portal_doneurl,bpm_app_workflowurl, username, passwd, bpm_workflowurl,bpm_app_requesturl);
sendPortalToReadUtil.sendToReadDataByCreateNode(new_requestid,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
sendPortalToReadUtil.sendToReadDataByCreateNode(new_requestid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
}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);
// sendPortalDoneUtil.sendPortalDoneData( requestid, nodeid, user, portal_doneurl,bpm_app_workflowurl, username, passwd, bpm_workflowurl,bpm_app_requesturl);
sendPortalToReadUtil.sendToReadDataByNode(requestid,nodeid,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,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)){
// sendPortalTodoUtil.sendTodoDataByReject(requestid,nodeid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);

@ -2,6 +2,7 @@ package com.customization.dito.sendtodo;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.constant.Constants;
import com.time.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
@ -373,6 +374,101 @@ public class SendPortalTodoUtil {
}
}
}
//处理抄送的
JSONObject taskObject = new JSONObject();
sql = " select t2.userid,h1.loginid,h1.lastname,h1.email,t2.isremark,t1.requestid,t2.nodeid,d1.nodename,c1."+cus_staff+" as staffid "+
" from workflow_requestbase t1\n" +
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= "+scopeid+" and c1.scope = '"+scope+"' "+
" 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 workflow_nodebase d1 on d1.id = t2.nodeid "+
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
// " and t1.currentnodetype = 3"+
// " and ((t2.isremark = '8' and t2.preisremark='8') or (t2.isremark = '9' and t2.preisremark='9'))\n" +
" and t2.isremark in ('2','9','8')\n" +
" and t2.preisremark in ('8','9')\n" +
" and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.requestid = "+requestid+ " and t2.userid = "+user.getUID();
rs.executeQuery(sql);
boolean hasData = true;
if (rs.next()){
hasData = false;
JSONArray list = new JSONArray();
JSONObject requestObject2 = new JSONObject();
requestObject2.putAll(requestObject);
//归档节点抄送
String email = Util.null2String(rs.getString("email"));
requestObject2.put("nodeName",rs.getString("nodename"));
requestObject2.put("nodeId",rs.getString("nodeid"));
requestObject2.put("taskCode",rs.getString("requestid")+"_cs_"+rs.getString("userid"));
String creator = rs.getString("loginid");
if("sysadmin".equals(creator)){
creator = "Admin";
}
taskObject.put("objectAction","0");
taskObject.put("objectType","0");
taskObject.put("objectCode",creator);
taskObject.put("objectId",rs.getString("staffid"));
taskObject.put("operatorCode",creator);
list.add(taskObject);
//归档节点抄送
requestObject2.put("messageTitle",getShortMessageTitle(requestname));
requestObject2.put("messageContent", requestname);
requestObject2.put("terminal", "1");
requestObject2.put("taskType", "1");
requestObject2.put("actionType", "2");
requestObject2.put("taskObjectList",list);
String auth = username + ":" + passwd;
bb.writeLog("SendPortalToReadUtil--requestObject:" + requestObject2.toJSONString());
String msgdata = httpRequestUtil.doPostByAuth(Constants.portal_todourl, requestObject2.toJSONString(), auth);
bb.writeLog("SendPortalToReadUtil-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)) {
Matcher matcher = regex.matcher(email);
if (matcher.matches()) {
emailArray += StringUtils.isEmpty(emailArray) ? email : "," + email;
}
bb.writeLog("emailArray:" + emailArray);
if (StringUtils.isNotEmpty(emailArray)) {
Map<String,String> templateMap = getEmailTemplate(requestname,rs.getString("lastname"),processTime);
String notificationSubject = templateMap.get("notificationSubject");
String notificationContent = templateMap.get("notificationContent");
//sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
}
sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,rs.getString("nodename"),rs.getString("userid"),requestObject2.toJSONString(),resultCode,"");
}else if ("TODO-FAIL-002".equals(resultCode)){
//The task does not exist.任务不存在,则新增
SendPortalToReadUtil sendPortalToReadUtil = new SendPortalToReadUtil();
sendPortalToReadUtil.sendToReadDataByCreateNode(requestid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
}else{
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,rs.getString("nodename"),rs.getString("userid"),requestObject2.toJSONString(),resultCode,resultmsg);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
@ -700,6 +796,101 @@ public class SendPortalTodoUtil {
}
}
}
//处理抄送的
JSONObject taskObject = new JSONObject();
String sql = " select t2.userid,h1.loginid,h1.lastname,h1.email,t2.isremark,t1.requestid,t2.nodeid,d1.nodename,c1."+cus_staff+" as staffid "+
" from workflow_requestbase t1\n" +
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
" left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= "+scopeid+" and c1.scope = '"+scope+"' "+
" 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 workflow_nodebase d1 on d1.id = t2.nodeid "+
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
// " and t1.currentnodetype = 3"+
// " and ((t2.isremark = '8' and t2.preisremark='8') or (t2.isremark = '9' and t2.preisremark='9'))\n" +
" and t2.isremark in ('2','9','8')\n" +
" and t2.preisremark in ('8','9')\n" +
" and t2.islasttimes = 1\n" +
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
" and t2.requestid = "+requestid+ " and t2.userid = "+user.getUID();
rs.executeQuery(sql);
boolean hasData = true;
if (rs.next()){
hasData = false;
JSONArray list = new JSONArray();
JSONObject requestObject2 = new JSONObject();
requestObject2.putAll(requestObject);
//归档节点抄送
String email = Util.null2String(rs.getString("email"));
requestObject2.put("nodeName",rs.getString("nodename"));
requestObject2.put("nodeId",rs.getString("nodeid"));
requestObject2.put("taskCode",rs.getString("requestid")+"_cs_"+rs.getString("userid"));
String creator = rs.getString("loginid");
if("sysadmin".equals(creator)){
creator = "Admin";
}
taskObject.put("objectAction","0");
taskObject.put("objectType","0");
taskObject.put("objectCode",creator);
taskObject.put("objectId",rs.getString("staffid"));
taskObject.put("operatorCode",creator);
list.add(taskObject);
//归档节点抄送
requestObject2.put("messageTitle",getShortMessageTitle(requestname));
requestObject2.put("messageContent", requestname);
requestObject2.put("terminal", "1");
requestObject2.put("taskType", "1");
requestObject2.put("actionType", "2");
requestObject2.put("taskObjectList",list);
String auth = username + ":" + passwd;
bb.writeLog("SendPortalToReadUtil--requestObject:" + requestObject2.toJSONString());
msgdata = httpRequestUtil.doPostByAuth(Constants.portal_todourl, requestObject2.toJSONString(), auth);
bb.writeLog("SendPortalToReadUtil-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)) {
Matcher matcher = regex.matcher(email);
if (matcher.matches()) {
emailArray += StringUtils.isEmpty(emailArray) ? email : "," + email;
}
bb.writeLog("emailArray:" + emailArray);
if (StringUtils.isNotEmpty(emailArray)) {
Map<String,String> templateMap = getEmailTemplate(requestname,rs.getString("lastname"),processTime);
String notificationSubject = templateMap.get("notificationSubject");
String notificationContent = templateMap.get("notificationContent");
//sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
}
sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,rs.getString("nodename"),rs.getString("userid"),requestObject2.toJSONString(),resultCode,"");
}else if ("TODO-FAIL-002".equals(resultCode)){
//The task does not exist.任务不存在,则新增
SendPortalToReadUtil sendPortalToReadUtil = new SendPortalToReadUtil();
sendPortalToReadUtil.sendToReadDataByCreateNode(requestid,user,portal_todourl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,center,bpm_app_requesturl);
}else{
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,rs.getString("nodename"),rs.getString("userid"),requestObject2.toJSONString(),resultCode,resultmsg);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}

@ -332,7 +332,8 @@ public class SendRemarkOperateTodoCmd extends AbstractCommandProxy<Map<String, O
* @param user
*/
public void sendTodoDataByCreateNode(String requestid,String noideid,User user,String portal_todourl,String username,String passwd,String bpm_workflowurl,String center){
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
HttpReqUtils httpReqUtils = new HttpReqUtils();
JSONObject requestObject = new JSONObject();
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
@ -388,8 +389,9 @@ public class SendRemarkOperateTodoCmd extends AbstractCommandProxy<Map<String, O
String taskType = "0";
String urlPc = "[newtab]"+bpm_workflowurl+"/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid ;
String urlApp = "[newtab]"+bpm_workflowurl+"/spa/workflow/static4mobileform/index.html#/req?requestid="+requestid;
String urlDing = "[newtab]"+bpm_workflowurl+"/spa/workflow/static4mobileform/index.html#/req?requestid="+requestid;
String replace = bpm_app_workflowurl.replace("/bpm", "");
String urlDing = replace + bpm_app_requesturl + requestid;
String urlApp = replace + bpm_app_requesturl + requestid;
if(StringUtils.isNotEmpty(mobileJumpUrl)){
urlDing += "&returnUrl="+ URLEncoder.encode(mobileJumpUrl,"UTF-8");

@ -0,0 +1,155 @@
package com.customization.qc2563600;
import com.cloudstore.dev.api.bean.MessageType;
import com.engine.workflow.biz.requestForm.RequestRemindBiz;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.workflow.msg.MsgPushUtil;
import weaver.workflow.msg.entity.MsgEntity;
import weaver.workflow.msg.entity.MsgNoticeType;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class CCOperatorUtil {
/**
*
*/
public static void sendMessage(int requestid, List<String> userIds, String nodeid, MessageType messageType, MsgNoticeType msgNoticeType,User user) {
List<MsgEntity> requestMsgEntity = requestFlowMsg(requestid, userIds, nodeid, requestid + "", messageType, msgNoticeType, true);
//发送消息提醒
new MsgPushUtil().pushMsg(requestMsgEntity);
//先判断是否开启了流程邮件提醒功能,如果开启了则发送邮件提醒
RecordSet recordSet = new RecordSet();
recordSet.executeQuery("select a.isemailremind,a.id from workflow_base a left join workflow_requestbase b on b.workflowid = a.id where b.requestid = ?",requestid);
if(recordSet.next()) {
if("1".equals(recordSet.getString("isemailremind"))){
int workflowid = recordSet.getInt("id");
String src = "submit";
RequestRemindBiz requestRemindBiz = new RequestRemindBiz(user,requestid,workflowid,src);
requestRemindBiz.doRemind(requestid,user.getUID(),workflowid,src,"0","1");
}
}
}
public static List<MsgEntity> requestFlowMsg(int requestId, List<String> userIds, String current_node, String targetid, MessageType messageType, MsgNoticeType msgNoticeType,boolean isRejectCC) {
List<MsgEntity> innerMsg = new ArrayList<>();
try {
MsgEntity baseEntity = getBaseInfo(Util.null2String(requestId));
if (baseEntity == null) return null;
//MessageType.WF_COPY WF_ALREADY_TIMEOUT
//MessageType.CC OVERED_TIME
baseEntity.setMsgType(messageType);
baseEntity.setNoticeType(msgNoticeType);
//流程流转提醒消息
baseEntity.addAllUserId(userIds);
baseEntity.setDetailTitleParams("current_node", current_node); //当前节点
baseEntity.setDetailId(targetid);
innerMsg.add(baseEntity);
} catch (Exception e) {
e.printStackTrace();
}
return innerMsg;
}
private static MsgEntity getBaseInfo(String requestId) {
MsgEntity msgEntity = null;
//查询流程基本信息
RecordSet rs = new RecordSet();
rs.executeQuery("select requestname,requestnamenew,workflowid,creater,createdate,createtime from workflow_requestbase where requestid = ? and (deleted = 0 or deleted is null)", requestId);
if (rs.next()) {
msgEntity = new MsgEntity();
String detailName = Util.null2String(rs.getString("requestname"));
String detailTitle = Util.null2String(rs.getString("requestnamenew"));
String workflowId = Util.null2String(rs.getString("workflowid"));
String creator = Util.null2String(rs.getString("creater"));
String createDate = Util.null2String(rs.getString("createdate"));
String createTime = Util.null2String(rs.getString("createtime"));
msgEntity.setDetailId(requestId);
msgEntity.setDetailName(detailName);
msgEntity.setDetailTitle(detailTitle);
msgEntity.setDetailBaseId(workflowId);
msgEntity.setCreator(creator);
msgEntity.setCreateDate(createDate);
msgEntity.setCreateTime(createTime);
rs.executeQuery("select wfb.workflowname,wft.id,wft.typename from workflow_base wfb,workflow_type wft where wfb.id = ? and wfb.workflowtype = wft.id", workflowId);
if (rs.next()) {
msgEntity.setDetailBaseName(Util.null2String(rs.getString("workflowname")));
msgEntity.setDetailTypeId(Util.null2String(rs.getString("id")));
msgEntity.setDetailTypeName(Util.null2String(rs.getString("typename")));
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
msgEntity.setOperaterDate(sdf.format(new Date()));
}
return msgEntity;
}
public static void insert(String requestid, List<String> addUsers, String nodeid, String isremark, User user) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("HH:mm:ss");
Date date = new Date();
String receivedate = simpleDateFormat.format(date);
String receivetime = simpleDateFormat1.format(date);
int showOrder = 0;
RecordSet rs = new RecordSet();
RecordSet rs3 = new RecordSet();
rs.executeQuery("select requestid,userid,groupid,workflowid,workflowtype,usertype,nodeid,agentorbyagentid,agenttype,showorder,receivedate,receivetime," +
"viewtype,iscomplete,islasttimes,groupdetailid,needwfback,isremark,preisremark,multiTakLevel " +
"from workflow_currentoperator where requestid=? and nodeid=? order by groupid desc", requestid, nodeid);
if (rs.next()) {
int groupid = Util.getIntValue(rs.getString("groupid"));
ArrayList<List> lists = new ArrayList<>();
for (String addUser : addUsers) {
groupid++;
String userIdTemp = addUser;
String agentorbyagentid = "-1";
String agenttype = "0";
showOrder = rs.getInt("showorder") + 1;
ArrayList list = new ArrayList();
list.add(rs.getString("requestid"));
list.add(userIdTemp);
list.add(groupid);
list.add(rs.getString("workflowid"));
list.add(rs.getString("workflowtype"));
list.add(0);
list.add(rs.getString("nodeid"));
list.add(agentorbyagentid);
list.add(agenttype);
list.add(showOrder);
list.add(receivedate);
list.add(receivetime);
list.add(0);
list.add(0);
list.add(1);
list.add(0);
list.add(rs.getString("needwfback"));
list.add(isremark);
list.add(isremark);
// list.add(takid);
// list.add(2);
// list.add(rs.getString("multiTakLevel"));
lists.add(list);
rs3.executeUpdate("update workflow_currentoperator set islasttimes = 0 where requestid = ? and userid = ?", requestid, userIdTemp);
}
RecordSet rs2 = new RecordSet();
boolean b = rs2.executeBatchSql("INSERT into workflow_currentoperator(requestid,userid,groupid,workflowid,workflowtype,usertype,nodeid,agentorbyagentid,agenttype,showorder,receivedate,receivetime,viewtype,iscomplete,islasttimes,groupdetailid,needwfback,isremark,preisremark) " +
"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", lists);
if (b) {
//发送消息给抄送人
sendMessage(Util.getIntValue(requestid), addUsers, nodeid, MessageType.WF_COPY, MsgNoticeType.CC,user);
}
}
}
}

@ -0,0 +1,194 @@
package com.engine.dito.reqremark.cmd;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.customization.dito.sendtodo.HttpRequestUtil;
import com.customization.dito.sendtodo.SendPortalErrorUtil;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.dito.comInfo.PropBean;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/**
* @Title
* @Author wangchaofa
* @CreateDate 2023/9/28
* @Version 1.0
* @Description
*/
public class AtRequestRemarkCmd extends AbstractCommonCommand<Map<String,Object>> {
@Override
public BizLogContext getLogContext() {
return null;
}
public AtRequestRemarkCmd(Map<String,Object> params, User user) {
this.params = params;
this.user = user;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> map = new HashMap<String,Object>();
int userid = user.getUID();
BaseBean bb = new BaseBean();
String requestid = Util.null2String(params.get("requestid"));
String nodeid = Util.null2String(params.get("nodeid"));
String resultCode = completePortalReadData(requestid,nodeid,userid+"");
map.put("resultcode",resultCode);
return map;
}
/***
*
* @param requestid
* @param nodeid
* @param userid
*/
public String completePortalReadData(String requestid, String nodeid,String userid){
String resultCode = "" ;
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
String username = PropBean.getUfPropValue("username");
String passwd = PropBean.getUfPropValue("passwd");
String center = PropBean.getUfPropValue("center");
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
String actionType = "3" ;
String terminal = "1" ;
String taskType = "1"; //0 待办 1 –待阅
String objectAction = "0" ;
String objectType = "0";
String objectId = "" ;
JSONObject requestObject = new JSONObject();
try {
String workcode = "";
String sql = " select * from (select id, lastname,loginid from hrmresource where status = 1 union all select id, lastname,loginid from hrmresourcemanager ) w where w.id = '" + userid + "'";
rs.executeQuery(sql);
while (rs.next()) {
workcode = Util.null2String(rs.getString("loginid"));
}
String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid;
String replace = bpm_app_workflowurl.replace("/bpm", "");
String urlDing = replace+bpm_app_requesturl+requestid;
String urlApp = replace+bpm_app_requesturl+requestid;
if(StringUtils.isNotEmpty(mobileJumpUrl)){
urlDing += "&returnUrl="+ URLEncoder.encode(mobileJumpUrl,"UTF-8");
urlApp += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8");
}
String requestname = "";
String workflowname = "" ;
sql = " select t1.requestname,t3.workflowname\n" +
" from workflow_requestbase t1\n" +
" inner join workflow_base t3 on t1.workflowid = t3.id\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = " + requestid;
rs.execute(sql);
if (rs.next()) {
workflowname = Util.null2String(rs.getString("workflowname")) ;
requestname = Util.null2String(rs.getString("requestname")) ;
}
String createdate = TimeUtil.getCurrentDateString();
String createtime = TimeUtil.getCurrentTimeString();
String nodename = getNodeName(nodeid);
requestObject.put("center",center);
requestObject.put("title",requestname);
requestObject.put("creator",workcode);
requestObject.put("taskCode", requestid+"_at_"+userid);
requestObject.put("nodeId",nodeid);
requestObject.put("taskType",taskType);
requestObject.put("actionType",actionType);
requestObject.put("createDate",createdate+" "+createtime);
requestObject.put("messageTitle",requestname);
requestObject.put("messageContent",requestname);
requestObject.put("terminal",terminal);
requestObject.put("urlPc",urlPc);
requestObject.put("urlApp",urlApp);
requestObject.put("urlDing",urlDing);
requestObject.put("nodeName",getNodeName(nodeid));
requestObject.put("ticketType",workflowname);
JSONArray taskObjectList = new JSONArray();
JSONObject taskObject = new JSONObject();
String objectCode = workcode ;
String operatorCode = workcode ;
taskObject.put("objectAction",objectAction);
taskObject.put("objectType",objectType);
taskObject.put("objectCode",objectCode);
taskObject.put("objectId",objectId);
taskObject.put("operatorCode",operatorCode);
taskObjectList.add(taskObject);
requestObject.put("taskObjectList",taskObjectList);
String auth = username + ":" + passwd;
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
bb.writeLog("msgdata:"+msgdata);
if(StringUtils.isNotEmpty(msgdata)){
JSONObject msgObject = JSONObject.parseObject(msgdata);
//{"resultCode":"1","resultMsg":"No Result"}
if(msgObject.containsKey("resultCode")){
resultCode = msgObject.getString("resultCode");
if(!"0".equals(resultCode)){
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeid,nodename,userid,requestObject.toJSONString(),resultCode,resultmsg);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return resultCode;
}
/***
*
* @param id
* @return
*/
private String getNodeName(String id){
RecordSet rs = new RecordSet();
String name = "";
rs.executeQuery(" select nodename from workflow_nodebase where id = ?",id);
while (rs.next()){
name = Util.null2String(rs.getString("nodename"));
}
return name;
}
}

@ -0,0 +1,18 @@
package com.engine.dito.reqremark.service;
import weaver.hrm.User;
import java.util.Map;
/**
* @Title
* @Author wangchaofa
* @CreateDate 2023/9/28
* @Version 1.0
* @Description
*/
public interface AtRequestRemarkService {
Map<String,Object> AtRequestRemarkSubmit(Map<String, Object> datas, User user);
}

@ -0,0 +1,24 @@
package com.engine.dito.reqremark.service.impl;
import com.engine.core.impl.Service;
import com.engine.dito.reqremark.cmd.AtRequestRemarkCmd;
import com.engine.dito.reqremark.service.AtRequestRemarkService;
import weaver.hrm.User;
import java.util.Map;
/**
* @Title
* @Author wangchaofa
* @CreateDate 2023/9/28
* @Version 1.0
* @Description
*/
public class AtRequestRemarkServiceImpl extends Service implements AtRequestRemarkService {
@Override
public Map<String, Object> AtRequestRemarkSubmit(Map<String, Object> datas, User user) {
return commandExecutor.execute(new AtRequestRemarkCmd(datas,user));
}
}

@ -0,0 +1,55 @@
package com.engine.dito.reqremark.web;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.dito.reqremark.service.AtRequestRemarkService;
import com.engine.dito.reqremark.service.impl.AtRequestRemarkServiceImpl;
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;
/**
* @Title
* @Author wangchaofa
* @CreateDate 2023/9/27
* @Version 1.0
* @Description
*/
public class AtRequestRemarkAction {
public AtRequestRemarkService getService(){
return (AtRequestRemarkService) ServiceUtil.getService(AtRequestRemarkServiceImpl.class);
}
@GET
@Path("/atreqsubmit")
@Produces({MediaType.TEXT_PLAIN})
public String AtRequestRemarkSubmit(@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().AtRequestRemarkSubmit(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);
}
}

@ -0,0 +1,287 @@
package com.engine.workflow.cmd.agent;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.customization.dito.sendtodo.HttpRequestUtil;
import com.customization.dito.sendtodo.SendMailUtil;
import com.customization.dito.sendtodo.SendPortalErrorUtil;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.workflow.biz.AgentBiz;
import com.time.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.dito.comInfo.PropBean;
import weaver.workflow.agent.AgentBean;
import weaver.workflow.agent.AgentManager;
import javax.servlet.http.HttpServletRequest;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
public class AddAgentSaveCmd extends AbstractCommonCommand<Map<String,Object>>{
private HttpServletRequest request;
public AddAgentSaveCmd(HttpServletRequest request, User user){
this.request = request;
this.user = user;
}
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> apidatas = new HashMap<String,Object>();
try{
int usertype = "2".equals(user.getLogintype()) ? 1 : 0;
AgentBean bean = new AgentBean();
int agentuid = Util.getIntValue(request.getParameter("agentuid"), 0);
int isPendThing = Util.getIntValue(request.getParameter("isPendThing"), 0);
bean.setAgentuid(agentuid);
bean.setBegindate(Util.null2String(request.getParameter("beginDate")));
bean.setBegintime(Util.null2String(request.getParameter("beginTime")));
bean.setEnddate(Util.null2String(request.getParameter("endDate")));
bean.setEndtime(Util.null2String(request.getParameter("endTime")));
bean.setIscreateagenter(isPendThing);
bean.setIsSysCreateAgenter(bean.getIscreateagenter() == 0 ? "0" : request.getParameter("isSysCreateAgenter"));
bean.setIspendthing(Util.getIntValue(request.getParameter("isPendThing"), 0));
bean.setIsproxydeal(Util.getIntValue(request.getParameter("isProxyDeal"), 0));
AgentManager agentManager = new AgentManager(user);
String agentrange = Util.null2String(request.getParameter("agentrange"));
String rangetype = Util.null2String(request.getParameter("rangetype"));
String workflowids = agentManager.getAgentWorkflowRange(agentrange, rangetype, usertype);
//重复处理方式 1、从新保存的代理设置中去除重复设置内容 2、以新保存的代理设置替换已有重复的代理设置
int overlapMethod = Util.getIntValue(request.getParameter("overlapMethod"), 0);
String agentresult = "";
List<Integer> bagentuidRange = AgentBiz.getBagentuidRange(request, user);
for(int bagentuid : bagentuidRange){
bean.setBagentuid(bagentuid);
//当开启了代理原有待办时,对接门户,删除被代理人的待办,增加代理人的待办,部分流转 1
if(isPendThing == 1){
DealPortalTodoAndDone(agentuid,bagentuid,workflowids);
}
agentresult = agentManager.batchAddAgent(workflowids, bean, overlapMethod);
if(!"success".equals(agentresult)) {
break;
}
}
apidatas.put("agentresult", agentresult);
}catch(Exception e){
apidatas.put("api_status", false);
apidatas.put("api_errormsg", e.getMessage());
}
return apidatas;
}
@Override
public BizLogContext getLogContext() {
return null;
}
/**
*
* @param agenterid
* @param beagenterid
* @param workflowids id
*/
public void DealPortalTodoAndDone(int agenterid, int beagenterid, String workflowids){
RecordSet rs = new RecordSet();
JSONArray taskObjectList = new JSONArray();
String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
JSONObject taskObject = new JSONObject();
rs.writeLog("==================== AddAgentSaveCmd DealPortalTodoAndDone ===================");
try {
taskObject.put("objectAction", "0");
taskObject.put("objectType", "0");
taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
taskObject.put("objectId", getStaffId(agenterid));
taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
taskObjectList.add(taskObject);
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
SendMailUtil sendMailUtil = new SendMailUtil();
String scopeid = "-1";
String scope = "HrmCustomFieldByInfoType" ;
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
String username = PropBean.getUfPropValue("username");
String passwd = PropBean.getUfPropValue("passwd");
String center = PropBean.getUfPropValue("center");
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
String sql = " select distinct t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " +
" from workflow_base t " +
" left join workflow_requestbase t1 on t.id=t1.workflowid " +
" left join workflow_currentoperator t2 on t1.requestid = t2.requestid " +
" left join hrmresource h1 on h1.id = t1.creater "+
" where t2.usertype=0 and t2.userid in (" + beagenterid +") and t.id in (" + workflowids +") "+
" and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('1','5','9','7','8','9','11') ) " +
" and t2.islasttimes=1 " +
" and (t.isvalid=3 or t.isvalid=1) ";
String zhjkbs = "com.engine.workflow.cmd.agent.AddAgentSaveCmd.DealPortalTodoAndDone";
String actionType = "1";
String terminal = "1";
String taskType = "0";
rs.executeQuery(sql);
while (rs.next()) {
String requestid = Util.null2String(rs.getString("requestid"));
String workflowname = "";
String nodeId = "";
String nodeName = "";
JSONObject requestObject = new JSONObject();
String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid;
String replace = bpm_app_workflowurl.replace("/bpm", "");
String urlDing = replace + bpm_app_requesturl + requestid;
String urlApp = replace + bpm_app_requesturl + requestid;
if (StringUtils.isNotEmpty(mobileJumpUrl)) {
urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
}
String msgdata = "";
String requestname = "";
String lastname = "";
String userids = "";
String loginid = "";
String emailArray = "";
sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " +
" 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 ) h2 on h2.id = t1.creater \n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = " + requestid;
rs.writeLog("AddAgentSaveCmd DealPortalTodoAndDone -- sql:" + sql);
rs.executeQuery(sql);
if (rs.next()) {
requestname = Util.null2String(rs.getString("requestname"));
workflowname = Util.null2String(rs.getString("workflowname"));
nodeId = Util.null2String(rs.getString("nodeid") + user.getUID());
nodeName = Util.null2String(rs.getString("nodeName"));
lastname = Util.null2String(rs.getString("lastname"));
loginid = Util.null2String(rs.getString("loginid"));
}
requestObject.put("center", center);
requestObject.put("title", requestname);
requestObject.put("creator", loginid);
requestObject.put("taskCode", "weaver" + requestid);
requestObject.put("nodeId", nodeId);
requestObject.put("taskType", taskType);
requestObject.put("actionType", actionType);
requestObject.put("createDate", processTime);
requestObject.put("messageTitle", getShortMessageTitle(requestname));
requestObject.put("messageContent", requestname);
requestObject.put("terminal", terminal);
requestObject.put("urlPc", urlPc);
requestObject.put("urlApp", urlApp);
requestObject.put("urlDing", urlDing);
requestObject.put("nodeName", nodeName);
requestObject.put("ticketType", workflowname);
JSONObject taskObject1 = new JSONObject();
taskObject1.put("objectAction", "1");
taskObject1.put("objectType", "0");
taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
taskObject1.put("objectId", getStaffId(beagenterid));
taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
taskObjectList.add(taskObject1);
if (taskObjectList.size() > 0) {
requestObject.put("taskObjectList", taskObjectList);
} else {
requestObject.put("actionType", "3");
}
String auth = username + ":" + passwd;
rs.writeLog("================== AddAgentSaveCmd DealPortalTodoAndDone ======================== "+requestObject.toJSONString());
msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth);
if (!"".equals(msgdata)) {
JSONObject msgObject = JSONObject.parseObject(msgdata);
if (msgObject.containsKey("resultCode")) {
String resultCode = msgObject.getString("resultCode");
if ("0".equals(resultCode)) {
rs.writeLog("SendPortalForwardCmd emailArray:" + emailArray);
if (StringUtils.isNotEmpty(emailArray)) {
Map<String, String> templateMap = getEmailTemplate(requestname, lastname, processTime);
String notificationSubject = templateMap.get("notificationSubject");
String notificationContent = templateMap.get("notificationContent");
sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
}
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, "",zhjkbs);
} else {
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs);
}
}
}
}
}catch (Exception e){
e.printStackTrace();
rs.writeLog(e);
}
}
public String getShortMessageTitle(String messageTitle) {
if (messageTitle.length() > 20) {
messageTitle = messageTitle.substring(0, 17) + "...";
}
return messageTitle;
}
/***
*
* @param requestname
* @param operator
* @param operatorTime
* @return
*/
public Map<String,String> getEmailTemplate(String requestname,String operator,String operatorTime){
Map<String,String> dataMap = new HashMap<String,String>();
String notificationSubject = "You have a new To-Read - <"+requestname+"> ";
String notificationContent = operator + " created this task on "+operatorTime+"\n" +
" Please handle it in time.";
dataMap.put("notificationSubject",notificationSubject);
dataMap.put("notificationContent",notificationContent);
return dataMap;
}
public int getStaffId(int userid){
int result = -1;
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
RecordSet rs = new RecordSet();
rs.executeQuery("select "+ cus_staff + " from cus_fielddata where scopeid=-1 and scope = 'HrmCustomFieldByInfoType' and id=?",userid);
rs.next();
result = Util.getIntValue(rs.getString(""));
return result;
}
}

@ -0,0 +1,301 @@
package com.engine.workflow.cmd.agent;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.api.workflow.util.ServiceUtil;
import com.customization.dito.sendtodo.HttpRequestUtil;
import com.customization.dito.sendtodo.SendMailUtil;
import com.customization.dito.sendtodo.SendPortalErrorUtil;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.workflow.biz.AgentBiz;
import com.time.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.dito.comInfo.PropBean;
import weaver.workflow.agent.AgentManager;
import javax.servlet.http.HttpServletRequest;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
public class TakeBackAgentCmd extends AbstractCommonCommand<Map<String,Object>>{
private HttpServletRequest request;
public TakeBackAgentCmd(HttpServletRequest request, User user){
this.request = request;
this.user = user;
}
public Map<String, Object> execute(CommandContext commandContext) {
boolean flag = true;
try {
AgentManager agentManager = new AgentManager(user);
String symbol = Util.null2String(request.getParameter("symbol"));
boolean needBackRunning = "1".equals(Util.null2String(request.getParameter("backRunning"))); //收回流转中数据
if ("it".equals(symbol) || "mt".equals(symbol)) { //单个、批量收回代理
String agentids = Util.null2String(request.getParameter("agentid"));
agentids = this.getAuthByUser(agentids);
List<String> range = new ArrayList<String>();
for(String keyid : agentids.split(",")){
if(!"".equals(keyid))
range.add(keyid);
}
agentManager.takeBackAgent(range, needBackRunning);
}else if ("pt".equals(symbol)) { // 全部收回逻辑
int agentid = Util.getIntValue(request.getParameter("agentid"));
int bagentuid = Util.getIntValue(request.getParameter("bagentuid"));
String agentuid = agentManager.getAgentuid(agentid, bagentuid);
if(Util.getIntValue(agentuid) > 0){
List<String> range = agentManager.getAgentRangeByUser(Util.getIntValue(agentuid), bagentuid);
agentManager.takeBackAgent(range, needBackRunning);
}
}
} catch (Exception e) {
flag = false;
e.printStackTrace();
}
Map<String,Object> apidatas = new HashMap<String,Object>();
apidatas.put("flag", flag);
return apidatas;
}
private String getAuthByUser(String agentids){
boolean haveAgentAllRight = AgentBiz.judgeHaveAgentAllRight(user);
if(haveAgentAllRight){
return agentids;
}
if(agentids.startsWith(",")){
agentids = agentids.substring(1);
}
if(agentids.endsWith(",")){
agentids = agentids.substring(0,agentids.length()-1);
}
String allUserid = ServiceUtil.getAllUserid(user); //所有用户id包括主从账号
String agentids_temp = "";
RecordSet rs = new RecordSet();
/*
rs.executeQuery("select agentid from workflow_agent where beagenterid in ("+allUserid+") and agentid IN("+agentids+")");
*/
String sql_in = Util.getSubINClause(agentids, "agentid", "IN");
String sql = "select agentid from workflow_agent where beagenterid in ("+allUserid+") and " + sql_in;
rs.executeQuery(sql);
while(rs.next()){
agentids_temp += "," + rs.getString(1);
}
return "".equals(agentids_temp)?agentids_temp:agentids_temp.substring(1);
}
@Override
public BizLogContext getLogContext() {
return null;
}
public void SendPortalTodoAndDone(List<String> range){
int agenterid = -1;
int beagenterid = -1;
String workflowids = "";
for(String agentid : range){
}
RecordSet rs = new RecordSet();
JSONArray taskObjectList = new JSONArray();
String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
JSONObject taskObject = new JSONObject();
rs.writeLog("==================== AddAgentSaveCmd DealPortalTodoAndDone ===================");
try {
taskObject.put("objectAction", "0");
taskObject.put("objectType", "0");
taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
taskObject.put("objectId", getStaffId(agenterid));
taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
taskObjectList.add(taskObject);
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
SendMailUtil sendMailUtil = new SendMailUtil();
String scopeid = "-1";
String scope = "HrmCustomFieldByInfoType" ;
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
String username = PropBean.getUfPropValue("username");
String passwd = PropBean.getUfPropValue("passwd");
String center = PropBean.getUfPropValue("center");
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
String sql = " select distinct t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " +
" from workflow_base t " +
" left join workflow_requestbase t1 on t.id=t1.workflowid " +
" left join workflow_currentoperator t2 on t1.requestid = t2.requestid " +
" left join hrmresource h1 on h1.id = t1.creater "+
" where t2.usertype=0 and t2.userid in (" + beagenterid +") and t.id in (" + workflowids +") "+
" and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('1','5','9','7','8','9','11') ) " +
" and t2.islasttimes=1 " +
" and (t.isvalid=3 or t.isvalid=1) ";
String zhjkbs = "com.engine.workflow.cmd.agent.AddAgentSaveCmd.DealPortalTodoAndDone";
String actionType = "1";
String terminal = "1";
String taskType = "0";
rs.executeQuery(sql);
while (rs.next()) {
String requestid = Util.null2String(rs.getString("requestid"));
String workflowname = "";
String nodeId = "";
String nodeName = "";
JSONObject requestObject = new JSONObject();
String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid;
String replace = bpm_app_workflowurl.replace("/bpm", "");
String urlDing = replace + bpm_app_requesturl + requestid;
String urlApp = replace + bpm_app_requesturl + requestid;
if (StringUtils.isNotEmpty(mobileJumpUrl)) {
urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
}
String msgdata = "";
String requestname = "";
String lastname = "";
String userids = "";
String loginid = "";
String emailArray = "";
sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " +
" 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 ) h2 on h2.id = t1.creater \n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = " + requestid;
rs.writeLog("AddAgentSaveCmd DealPortalTodoAndDone -- sql:" + sql);
rs.executeQuery(sql);
if (rs.next()) {
requestname = Util.null2String(rs.getString("requestname"));
workflowname = Util.null2String(rs.getString("workflowname"));
nodeId = Util.null2String(rs.getString("nodeid") + user.getUID());
nodeName = Util.null2String(rs.getString("nodeName"));
lastname = Util.null2String(rs.getString("lastname"));
loginid = Util.null2String(rs.getString("loginid"));
}
requestObject.put("center", center);
requestObject.put("title", requestname);
requestObject.put("creator", loginid);
requestObject.put("taskCode", "weaver" + requestid);
requestObject.put("nodeId", nodeId);
requestObject.put("taskType", taskType);
requestObject.put("actionType", actionType);
requestObject.put("createDate", processTime);
requestObject.put("messageTitle", getShortMessageTitle(requestname));
requestObject.put("messageContent", requestname);
requestObject.put("terminal", terminal);
requestObject.put("urlPc", urlPc);
requestObject.put("urlApp", urlApp);
requestObject.put("urlDing", urlDing);
requestObject.put("nodeName", nodeName);
requestObject.put("ticketType", workflowname);
JSONObject taskObject1 = new JSONObject();
taskObject1.put("objectAction", "1");
taskObject1.put("objectType", "0");
taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
taskObject1.put("objectId", getStaffId(beagenterid));
taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
taskObjectList.add(taskObject1);
if (taskObjectList.size() > 0) {
requestObject.put("taskObjectList", taskObjectList);
} else {
requestObject.put("actionType", "3");
}
String auth = username + ":" + passwd;
rs.writeLog("================== AddAgentSaveCmd DealPortalTodoAndDone ======================== "+requestObject.toJSONString());
msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth);
if (!"".equals(msgdata)) {
JSONObject msgObject = JSONObject.parseObject(msgdata);
if (msgObject.containsKey("resultCode")) {
String resultCode = msgObject.getString("resultCode");
if ("0".equals(resultCode)) {
rs.writeLog("SendPortalForwardCmd emailArray:" + emailArray);
if (StringUtils.isNotEmpty(emailArray)) {
Map<String, String> templateMap = getEmailTemplate(requestname, lastname, processTime);
String notificationSubject = templateMap.get("notificationSubject");
String notificationContent = templateMap.get("notificationContent");
sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
}
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, "",zhjkbs);
} else {
String resultmsg = msgObject.getString("resultMsg");
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs);
}
}
}
}
}catch (Exception e){
e.printStackTrace();
rs.writeLog(e);
}
}
public String getShortMessageTitle(String messageTitle) {
if (messageTitle.length() > 20) {
messageTitle = messageTitle.substring(0, 17) + "...";
}
return messageTitle;
}
/***
*
* @param requestname
* @param operator
* @param operatorTime
* @return
*/
public Map<String,String> getEmailTemplate(String requestname,String operator,String operatorTime){
Map<String,String> dataMap = new HashMap<String,String>();
String notificationSubject = "You have a new To-Read - <"+requestname+"> ";
String notificationContent = operator + " created this task on "+operatorTime+"\n" +
" Please handle it in time.";
dataMap.put("notificationSubject",notificationSubject);
dataMap.put("notificationContent",notificationContent);
return dataMap;
}
public int getStaffId(int userid){
int result = -1;
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
RecordSet rs = new RecordSet();
rs.executeQuery("select "+ cus_staff + " from cus_fielddata where scopeid=-1 and scope = 'HrmCustomFieldByInfoType' and id=?",userid);
rs.next();
result = Util.getIntValue(rs.getString(""));
return result;
}
}

@ -0,0 +1,896 @@
package com.engine.workflow.cmd.requestForm;
import com.api.workflow.service.RequestAuthenticationService;
import com.api.workflow.util.ServiceUtil;
import com.cloudstore.dev.api.util.Util_TableMap;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.common.util.AttrSignatureUtil;
import com.engine.core.interceptor.CommandContext;
import com.engine.hrm.biz.HrmClassifiedProtectionBiz;
import com.engine.workflow.biz.SecondAuthBiz;
import com.engine.workflow.biz.freeNode.FreeNodeBiz;
import com.engine.workflow.biz.operationMenu.MenuDefaultSignBiz;
import com.engine.workflow.biz.requestForm.RequestRemindBiz;
import com.engine.workflow.biz.requestForm.RequestSecLevelBiz;
import com.engine.workflow.biz.requestForm.SubmitErrorMsgBiz;
import com.engine.workflow.biz.requestForm.TakReplyBiz;
import com.engine.workflow.biz.workflowCore.RequestBaseBiz;
import com.engine.workflow.constant.OperationMenuType;
import com.engine.workflow.constant.RemindTypeEnum;
import com.engine.workflow.constant.SecondAuthType;
import com.engine.workflow.constant.SignSource;
import com.engine.workflow.constant.requestForm.PromptType;
import com.engine.workflow.constant.requestForm.RequestConstant;
import com.engine.workflow.constant.requestForm.RequestExecuteType;
import com.engine.workflow.entity.requestForm.RequestOperationResultBean;
import com.engine.workflow.service.RequestSecondAuthService;
import com.engine.workflow.service.impl.RequestSecondAuthServiceImpl;
import com.engine.workflow.util.ChuanyueUtil;
import com.engine.workflow.util.SecondAuthUtil;
import com.engine.workflow.util.WfDataCorrectionUtils;
import com.engine.workflow.util.WorkflowOvertimeSettingsUtil;
import com.google.common.base.Strings;
import org.json.JSONObject;
import weaver.conn.RecordSet;
import weaver.file.FileUpload;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.mobile.webservices.workflow.soa.RequestPreProcessing;
import weaver.systeminfo.SystemEnv;
import weaver.workflow.agent.AgentManager;
import weaver.workflow.msg.MsgPushUtil;
import weaver.workflow.msg.entity.MsgEntity;
import weaver.workflow.request.*;
import weaver.workflow.request.entity.RequestOperateEntityTableNameEnum;
import weaver.workflow.request.entity.RequestOperateTypeEnum;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.*;
/**
*
*/
public class RemarkSubmitCmd extends AbstractCommonCommand<Map<String,Object>>{
private HttpServletRequest request;
public HttpServletRequest getRequest() {
return request;
}
private static final int SPACE_TIME_MILLIS = 2000;//两秒步长
public void setRequest(HttpServletRequest request) {
this.request = request;
}
public RemarkSubmitCmd(HttpServletRequest request, User user){
this.request = request;
this.user = user;
}
public Map<String,Object> execute(CommandContext commandContext){
Map<String,Object> result = new HashMap<String,Object>();
try {
RequestOperationResultBean resultBean = this.getResult();
result.put("data", resultBean);
Util_TableMap.setObjVal(Util.null2String(resultBean.getResultInfo().get("sessionkey")), resultBean);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public RequestOperationResultBean getResult() throws Exception {
RequestOperationResultBean resultBean = new RequestOperationResultBean();
RecordSet rs = new RecordSet();
FileUpload fu = new FileUpload(request);
String comemessage = Util.null2String(request.getParameter("comemessage"));
String userid = "" + user.getUID();
int usertype = (user.getLogintype()).equals("1") ? 0 : 1;
int requestid = Util.getIntValue(fu.getParameter("requestid"), -1);
//代替session
AttrSignatureUtil attrSignatureUtil = new AttrSignatureUtil(user.getUID(), request.getHeader("user-agent"));
String _attributesString = Util.null2String(request.getParameter(RequestConstant.SIGNATURE_ATTRIBUTES_STR));
String _attributesSignature = Util.null2o(request.getParameter(RequestConstant.SIGNATURE_SECRET_KEY));
if(!attrSignatureUtil.verifySignature(_attributesString, _attributesSignature)) {
resultBean.setType(RequestExecuteType.FAILD);
resultBean.getResultInfo().put("requestid",requestid);
return resultBean;
}
String src = Util.null2String(fu.getParameter("src"));
String iscreate = Util.null2String(fu.getParameter("iscreate"));
//*********防重复提交验证*************
//小于时间间隔内,判定为重复提交
String requestKey = new StringBuilder(String.valueOf(requestid)).append("_").append(user.getUID()).toString();
String tokenValueCache = Util_TableMap.getVal(requestKey);
if(tokenValueCache != null && System.currentTimeMillis() - Long.parseLong(tokenValueCache) < SPACE_TIME_MILLIS) {
writeLog("RemarkSubmitCmd-----过滤重复提交 requestid = " + requestKey);
Util_TableMap.setVal(requestKey, System.currentTimeMillis()+"", 120);
resultBean.setType(RequestExecuteType.SUCCESS);
return resultBean;
} else {
Util_TableMap.setVal(requestKey, System.currentTimeMillis()+"", 120);
}
//*********防重复提交验证*************
int workflowid = Util.getIntValue(fu.getParameter("workflowid"), -1);
String workflowtype = Util.null2String(fu.getParameter("workflowtype"));
int nodeid = Util.getIntValue(fu.getParameter("nodeid"), -1);
String nodetype = Util.null2String(fu.getParameter("nodetype"));
String needwfback = Util.null2String(fu.getParameter("needwfback"));
String remark = Util.null2String(fu.getParameter("remark"));
int formid = Util.getIntValue(fu.getParameter("formid"), -1);
int isbill = Util.getIntValue(fu.getParameter("isbill"), -1);
int billid = Util.getIntValue(fu.getParameter("billid"), -1);
String requestname = Util.fromScreen3(fu.getParameter("requestname"), user.getLanguage());
String requestlevel = Util.fromScreen(fu.getParameter("requestlevel"), user.getLanguage());
String messageType = Util.fromScreen(fu.getParameter("messageType"), user.getLanguage());
String isFromEditDocument = Util.null2String(fu.getParameter("isFromEditDocument"));
String submitNodeId = Util.null2String(fu.getParameter("submitNodeId"));
String Intervenorid = Util.null2String(fu.getParameter("Intervenorid"));
int isremark = Util.getIntValue(fu.getParameter("isremark"), -1);
int realIsReamrk = isremark;
String remarkLocation = Util.null2String(fu.getParameter("remarkLocation"));
boolean IsCanModify = "true".equals(attrSignatureUtil.getAttribute("IsCanModify")) ? true : false;
String ifchangstatus = WorkflowOvertimeSettingsUtil.getOverTimeSettingsEntity().getChangestatus() ;
int agentType = Util.getIntValue(Util.null2String(fu.getParameter("agentType")));
int agentorByAgentId = Util.getIntValue(Util.null2String(fu.getParameter("agentorByAgentId")));
String f_weaver_belongto_userid = request.getParameter("f_weaver_belongto_userid");// 需要增加的代码
String f_weaver_belongto_usertype = request.getParameter("f_weaver_belongto_usertype");// 需要增加的代码
String sessionkey = workflowid + "_" + nodeid + "_" + user.getUID() + "_" + System.currentTimeMillis();
Map<String,Object> resultInfo = resultBean.getResultInfo();
resultInfo.put("f_weaver_belongto_userid", f_weaver_belongto_userid);
resultInfo.put("f_weaver_belongto_usertype", f_weaver_belongto_usertype);
resultInfo.put("requestid", requestid);
resultInfo.put("sessionkey", sessionkey);
if (Util.getIntValue(fu.getParameter("takisremark"), -1) == 2 && agentType == 1) {//被代理人意见征询回复提交, 收回代理
AgentManager agentManager = new AgentManager(user);
agentManager.agentBackRequest(agentorByAgentId, user.getUID(), workflowid + "", requestid);
}
if (src.equals("") || workflowid == -1 || nodeid == -1 || nodetype.equals("")) {
resultBean.setType(RequestExecuteType.SEND_PAGE);
resultBean.setSendPage(weaver.general.GCONST.getContextPath()+"/notice/RequestError.jsp");
return resultBean;
}
RequestAuthenticationService authenticationService = new RequestAuthenticationService();
authenticationService.setUser(user);
boolean hasRight = authenticationService.getRequestUserRight(null, requestid);
if (!hasRight) {
resultBean.setType(RequestExecuteType.FAILD);
resultBean.setMessageInfo(SubmitErrorMsgBiz.getMsgInfo(request, user, "1", ""));
resultBean.getResultInfo().put("requestid",requestid);
return resultBean;
}
Map<String, Object> authInfo = authenticationService.getAuthInfo();
int isreamrk = Util.getIntValue(Util.null2String(authInfo.get("isremarkForRM")));
//**********加个注释,强制编译下
if(!(isreamrk == 1 || isreamrk == 0 || isreamrk == 9 || isreamrk==11)) {
resultBean.setType(RequestExecuteType.FAILD);
Map message = new HashMap();
message.put("prompttype", PromptType.ERRORMSG.getType());
message.put("title", SystemEnv.getHtmlLabelName(18015,user.getLanguage()) + SystemEnv.getHtmlLabelName(1454,user.getLanguage()));
resultBean.setMessageInfo(message);
return resultBean;
}
int extendnodeid = FreeNodeBiz.getExtendNodeId(requestid,nodeid);
RequestManager requestManager = new RequestManager();
requestManager.setSrc(src);
requestManager.setIscreate(iscreate);
requestManager.setRequestid(requestid);
requestManager.setWorkflowid(workflowid);
requestManager.setWorkflowtype(workflowtype);
requestManager.setIsremark(isremark);
requestManager.setFormid(formid);
requestManager.setIsbill(isbill);
requestManager.setBillid(billid);
requestManager.setNodeid(nodeid);
requestManager.setNodetype(nodetype);
requestManager.setRequestname(requestname);
requestManager.setRequestlevel(requestlevel);
requestManager.setRemark(remark);
requestManager.setRequest(fu);
requestManager.setSubmitNodeId(submitNodeId);
requestManager.setIntervenorid(Intervenorid);
requestManager.setRemarkLocation(remarkLocation);
requestManager.setMessageType(messageType);
requestManager.setIsFromEditDocument(isFromEditDocument);
requestManager.setUser(user);
requestManager.setTakisremark(Util.getIntValue(fu.getParameter("takisremark"), -1));
requestManager.setCanModify(IsCanModify);
boolean savestatus = requestManager.saveRequestInfo();
requestid = requestManager.getRequestid();
if (!savestatus) {
if (requestid != 0) {
String message = requestManager.getMessage();
message = "".equals(message) ? "1" : message;
resultBean.setType(RequestExecuteType.FAILD);
resultBean.setMessageInfo(SubmitErrorMsgBiz.getMsgInfo(request, user, message, requestManager.getMessagecontent()));
resultBean.getResultInfo().put("requestid",requestid);
return resultBean;
}
}
/**======================流程数据加密处理========================*/
String isCAAuth = Util.null2String(request.getParameter("isCAAuth")); //是否是CA认证主要是需要CA认证时的参数
String CAKey = Util.null2String(request.getParameter("CAKey")); //缓存提交时的数据的key主要是需要CA认证时的参数
int protectType = Util.getIntValue(Util.null2String(request.getParameter("protectType")), 0); //二次认证认证成功后的参数,数据保护的方式
int secondAuthType = Util.getIntValue(Util.null2String(request.getParameter("secondAuthType")), 0); //二次认证认证成功后的参数,二次认证的方式
int qysSignWay = Util.getIntValue(Util.null2String(request.getParameter("qysSignWay")), 0); //契约锁认证的方式1ukey2契约锁服务
String uuidStr = "";
boolean isNeedUpdate = false;
RequestSecondAuthService requestSecondAuthService = com.engine.common.util.ServiceUtil.getService(RequestSecondAuthServiceImpl.class, user);
if (savestatus) {
if ("1".equals(isCAAuth)) { //需要CA认证保存后不提交流程直接返回
//先保存签字意见
requestManager.setIsremark(0);
requestManager.setSrc("save");
requestManager.saveRequestLog2();
resultBean.setType(RequestExecuteType.SUCCESS);
resultInfo.put("isCAAuth", isCAAuth);
resultInfo.put("CAKey", CAKey);
return resultBean;
} else if (protectType == SecondAuthType.QYS.getId()&&qysSignWay == 2) { //契约锁数据保护
String tempRemark = requestManager.getRemark();
Map<String, Object> protectResult = requestSecondAuthService.protectDatas(requestid, workflowid, formid, isbill, nodeid, tempRemark);
String protectSuccess = Util.null2String(protectResult.get("success"));
if ("0".equals(protectSuccess)) { //说明数据保护失败
resultBean.setType(RequestExecuteType.FAILD);
String protectMsg = Util.null2String(protectResult.get("message"));
resultBean.setMessageInfo(SecondAuthUtil.getErrorMsg(user, protectMsg));
return resultBean;
} else if ("1".equals(protectSuccess)) {
isNeedUpdate = true;
uuidStr = Util.null2String(protectResult.get("uuid"));
}
}
}
int currid = -1;
int takisremark = -1;
int handleforwardid = -1;
String zsql = ServiceUtil.calculateCurrentNodeSql(String.valueOf(requestid),Util.getIntValue(userid),usertype);
rs.executeQuery(zsql);
if (rs.next()) {
takisremark = Util.getIntValue(rs.getString("takisremark"));
handleforwardid = Util.getIntValue(rs.getString("handleforwardid"));
currid = Util.getIntValue(rs.getString("id"));
}
RequestOperationMsgManager romm = new RequestOperationMsgManager();
List<MsgEntity> requestMsgEntity = null;
if(handleforwardid <= 0 && isremark != 11 && isremark != 1){
requestMsgEntity = romm.getForwardReplyMsg(String.valueOf(requestid),userid); //抄送回复消息
}else if(handleforwardid <= 0 && realIsReamrk == 1) {
requestMsgEntity = romm.forwardReplyNotice(requestid,user); //转发批注
}else if(isremark == 11){
requestMsgEntity = romm.getChuanyueMsg(requestid,userid,nodeid,0);//传阅批示
}
if (takisremark == 2 && HrmClassifiedProtectionBiz.isOpenClassification()) {//意见征询回复时,对征询人做密级校验
List<String> userIds = this.getForwardUserId(rs,requestid,nodeid,userid,false);
String userId = userIds.isEmpty() ? "" : userIds.get(0);
int userSecLevel = Util.getIntValue(new HrmClassifiedProtectionBiz().getMaxResourceSecLevelById2(userId));
int requestSecLevel = new RequestSecLevelBiz().getSecLevelByRequestId(requestid+"");
if (requestSecLevel < userSecLevel) {
StringBuffer errorInfoMsgBuffer = new StringBuffer();
String nextnodename = WorkflowRequestMessage.getWorkflowNodename(nodeid);
WorkflowRequestMessage.getNodeErrorMsgTitle(errorInfoMsgBuffer, nextnodename, user.getLanguage());
String messageContent = "";
try {
ResourceComInfo rci = new ResourceComInfo();
messageContent = rci.getLastname(userId);
} catch (Exception e) {
e.printStackTrace();
}
messageContent = errorInfoMsgBuffer.toString() + WorkflowRequestMessage.getBoldInfo(messageContent) + " " + SystemEnv.getHtmlLabelName(501273, user.getLanguage());
JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540,user.getLanguage()),workflowid,WorkflowRequestMessage.WF_NODE_SET);
msgInfo.put("details", messageContent);
resultBean.setType(RequestExecuteType.FAILD);
resultBean.setMessageInfo(SubmitErrorMsgBiz.getMsgInfo(request, user, "126221", msgInfo.toString()));
resultBean.getResultInfo().put("requestid",requestid);
//String sessionkey = workflowid + "_" + nodeid + "_" + user.getUID() + "_" + System.currentTimeMillis();
//resultBean.getResultInfo().put("sessionkey", sessionkey);
//Util_TableMap.setObjVal(sessionkey, resultBean);
return resultBean;
}
}
RequestOperationLogManager rolm = new RequestOperationLogManager(requestManager);
rolm.setLastNodetype(nodeid);
rolm.flowTransStartBefore();
int optLogid = -1;
// 强制收回
int wfcuroptid = -1;
if (isremark == 9) {
rs.executeQuery("select id from workflow_currentoperator where requestid = ? and userid = ? and usertype = ? and isremark = ?",requestid,userid,usertype,isremark);
if (rs.next()) {
wfcuroptid = Util.getIntValue(rs.getString(1));
optLogid = rolm.getOptLogID(wfcuroptid);
}
}
char flag = Util.getSeparator();
// 提交
if (isremark == 9) {
if (!"0".equals(needwfback)) {
this.workflow_CurOpe_UbyForward(rs, requestid, Util.getIntValue(userid), usertype, requestManager.getCurrentDate(), requestManager.getCurrentTime());
} else {
this.workflow_CurOpe_UbyForwardNB(rs,requestid, Util.getIntValue(userid), usertype, requestManager.getCurrentDate(), requestManager.getCurrentTime());
}
} else if (isremark != 11){
if(isremark == 1 && takisremark != 2){
//当操作者在同一节点同时是转发接收人以及抄送不需提交的抄送人,打开表单时,不会将抄送记录修改为已操作,在这里修改一下,进行批注时,将抄送记录修改为已操作
rs.executeUpdate("update workflow_currentoperator set isremark= 2 where requestid = ? and userid = ? and usertype = ? and preisremark = '8' and isremark = 8 ",requestid,userid,usertype);
}
if (!"0".equals(needwfback)) {
rs.executeProc("workflow_CurOpe_UbySend", "" + requestid + flag + userid + flag + usertype + flag + isremark);
} else {
rs.executeProc("workflow_CurOpe_UbySendNB", "" + requestid + flag + userid + flag + usertype + flag + isremark);
}
}
// 推送处理start
//new Thread(new RequestPreProcessing(workflowid, isbill, formid, requestid, requestname, "", nodeid, 0, false, "", user, true)).start();
WFPathUtil wfutil = new WFPathUtil();
wfutil.getFixedThreadPool().execute(new RequestPreProcessing(workflowid, isbill, formid, requestid, requestname, "", nodeid, 0, false, "", user, true));
//提交反馈
RequestBaseBiz.operateFeedBack(requestid,workflowid,extendnodeid,user.getUID(),remark,requestManager.getCurrentDate(),requestManager.getCurrentTime());
String curnodetype = "";
int currentnodeid = 0;
rs.executeSql("select currentnodetype,currentnodeid from workflow_Requestbase where requestid=" + requestid);
if (rs.next()) {
curnodetype = Util.null2String(rs.getString(1));
currentnodeid = rs.getInt(2);
}
if (curnodetype.equals("3"))// 归档流程转发后,转发人或抄送人提交后到办结事宜。
rs.executeSql("update workflow_currentoperator set iscomplete=1 where userid=" + userid + " and usertype=" + usertype + " and requestid=" + requestid);
RequestLog requestlog = new RequestLog();
requestlog.setRequest(fu);
////取数据库服务器的当前时间 || 和RequestManager统一避免批注的时间和提交的时间不一致导致先批注的签字意见显示在后提交的签字意见前面
requestlog.setCurrentdate(requestManager.getCurrentDate());
requestlog.setCurrenttime(requestManager.getCurrentTime());
requestlog.setIsremark(isremark);
requestlog.setCurrId(currid);
if("".equals(remark.trim())) {
OperationMenuType type = null;
if (isremark == 1) {
if(takisremark == 2) {
type = OperationMenuType.TAKING_OPINIONS;
} else {
type = OperationMenuType.FORSUB;
}
} else if (isremark == 9) {
type = OperationMenuType.CCSUB;
}
if(type != null) {
remark = Util.null2String(MenuDefaultSignBiz.getMenuDefaultSignMap(workflowid,nodeid,type));
}
}
//语音附件
int speechAttachment = Util.getIntValue(fu.getParameter("speechAttachment"),0);
String handWrittenSign = Util.null2String(request.getParameter("handWrittenSign"),"");
String fulltextannotation = Util.null2String(fu.getParameter("fulltextannotation"));
String speechAttachmente9 = Util.null2String(fu.getParameter("speechAttachmente9"));
String clientType = Util.null2String(fu.getParameter("clientType"), SignSource.PC_BROWSER.getType());
//传阅回复默认签字意见
if(isremark==11)remark = getRemark(workflowid,currentnodeid,remark);
String currentString = "";
if (takisremark == 2) {
currentString = requestlog.saveLog2(workflowid, requestid, nodeid, "b", remark, user, clientType, speechAttachment, handWrittenSign, "", remarkLocation,fulltextannotation,speechAttachmente9); // 意见征询
} else if (handleforwardid > 0) {
currentString = requestlog.saveLog2(workflowid, requestid, nodeid, "j", remark, user, clientType, speechAttachment, handWrittenSign, "", remarkLocation,fulltextannotation,speechAttachmente9); // 转办
} else {
currentString = requestlog.saveLog2(workflowid, requestid, nodeid, isremark==11?"y":"9", remark, user, clientType, speechAttachment, handWrittenSign, "", remarkLocation,fulltextannotation,speechAttachmente9);
// 抄送需要提交 时, 添加 强制收回支持
if (isremark == 9) {
rs.executeSql("select logid from workflow_requestlog where requestid = " + requestid + " and nodeid = " + nodeid + " and operator=" + user.getUID() + " and operatortype=" + usertype
+ " and logtype = '9' order by operatedate, operatetime");
if (rs.next()) {
int newlogid = rs.getInt(1);
if (newlogid > 0) {
// 向之前的日志中添加本条提交的记录, 方便在强制收回的时候能够收回
rolm.addDetailLog(optLogid, RequestOperateEntityTableNameEnum.REQUESTLOG.getTableName(), newlogid, 0, "", "", "");
}
}
}
}
/***================数据保护==============*/
if (!"".equals(currentString) && currentString.indexOf("~~current~~") > -1) {
String authKey = Util.null2String(request.getParameter("authKey"));
String isProtectSuccess = Util.null2String(request.getParameter("isProtectSuccess"));
String isAuthSuccess = Util.null2String(request.getParameter("isAuthSuccess"));
if (protectType == SecondAuthType.QYS.getId()&&qysSignWay == 2) { //契约锁数据保护
if (isNeedUpdate && !"".equals(uuidStr)) {
requestSecondAuthService.updateProtectDatas(requestid, workflowid, currentnodeid, uuidStr);
}
} else if (protectType == SecondAuthType.CAAuth.getId()||
(protectType == SecondAuthType.QYS.getId()&&qysSignWay == 1)) { //CA数据保护
if ("1".equals(isProtectSuccess) && !"".equals(authKey)) {
requestSecondAuthService.updateProtectDatas(requestid, workflowid, currentnodeid, authKey);
}
}
//契约锁二次认证或者契约锁数据保护
if ((secondAuthType == SecondAuthType.QYS.getId() && "1".equals(isAuthSuccess)) ||
(protectType == SecondAuthType.QYS.getId() && (isNeedUpdate || (qysSignWay == 1 && "1".equals(isProtectSuccess))))) {
String sealId = Util.null2String(request.getParameter("qysSealId"));
String sealImg = Util.null2String(request.getParameter("qysSealImg"));
String certDetails = Util.null2String(request.getParameter("qysCertDetails"));
//查询本次操作插入的日志的id
int logId = SecondAuthBiz.getLogId(requestid, workflowid, nodeid, user);
//保存契约锁验证的盖章信息
Map<String, Object> authParam = new HashMap<String, Object>();
authParam.put("sealId", sealId);
authParam.put("sealImg", sealImg);
authParam.put("certDetails", certDetails);
authParam.put("logid", logId);
authParam.put("requestId", requestid);
SecondAuthBiz.saveQYSSignature(authParam, user);
}
}
WFLinkInfo wflinkinfo = new WFLinkInfo();
int nodeattr = wflinkinfo.getNodeAttribute(nodeid);
Set<String> branchNodeSet = new HashSet<String>();
if (nodeattr == 2) { // 分支中间节点
String branchnodes = "";
branchnodes = wflinkinfo.getNowNodeids(requestid);
if (!"".equals(branchnodes)) {
String[] strs = branchnodes.split(",");
for (int k = 0; k < strs.length; k++) {
String nodestr = strs[k];
if (!"-1".equals(nodestr)) {
branchNodeSet.add(nodestr);
}
}
}
}
/** 日志权限的处理,非归档节点,且提交时的节点,跟流程当前节点相同才需要权限控制 */
if (!"".equals(currentString) && currentString.indexOf("~~current~~") > -1 && !"3".equals(curnodetype) && (nodeid == currentnodeid || branchNodeSet.contains(nodeid + ""))) {
int wfcurrrid = Util.getIntValue((String) attrSignatureUtil.getAttribute("wfcurrrid"), 0);
if (wfcurrrid == 0) {
rs.executeSql("select isremark,isreminded,preisremark,id,groupdetailid,nodeid from workflow_currentoperator where requestid=" + requestid + " and userid=" + userid + " and usertype="
+ usertype + " order by isremark,id");
while (rs.next()) {
String isremark_tmp = Util.null2String(rs.getString("isremark"));
wfcurrrid = Util.getIntValue(rs.getString("id"));
// 转发特殊处理,转发信息本人未处理一直需要处理即使流程已归档
if (isremark_tmp.equals("1") || isremark_tmp.equals("5") || isremark_tmp.equals("7") || isremark_tmp.equals("9") || (isremark_tmp.equals("0") && !nodetype.equals("3"))) {
break;
}
if (isremark_tmp.equals("8")) {
break;
}
}
}
String[] arraycurrent = Util.TokenizerString2(currentString, "~~current~~");
String currentdate = arraycurrent[0];
String currenttime = arraycurrent[1];
RequestRemarkRight remarkRight = new RequestRemarkRight();
remarkRight.setRequestid(requestid);
remarkRight.setNodeid(nodeid);
remarkRight.setWorkflow_currentid(wfcurrrid);
String logtype = "7";
if (takisremark == 2) { // 征询
logtype = "b";
} else if (handleforwardid > 0) { // 转办
logtype = "j";
} else if (isremark == 11) { // 传阅批示
logtype = "y";
} else { // 转发
logtype = "9";
}
String rightSql = " select logid from workflow_requestlog where workflowid = " + workflowid + " and nodeid = " + nodeid + " and logtype = '" + logtype + "' and requestid = " + requestid
+ " and operatedate = '" + currentdate + "' and operatetime = '" + currenttime + "' and operator = " + userid;
rs.executeSql(rightSql);
int logid = -1;
if (rs.next()) {
logid = rs.getInt("logid");
}
String userids = "";
remarkRight.saveRemarkRight(logid, userids);
}
String logtype = "7";
if (!"".equals(currentString) && currentString.indexOf("~~current~~") > -1) {
String[] arraycurrent = Util.TokenizerString2(currentString, "~~current~~");
String currentdate = arraycurrent[0];
String currenttime = arraycurrent[1];
if (takisremark == 2) { // 征询
logtype = "b";
} else if (handleforwardid > 0) { // 转办
logtype = "j";
} else { // 转发
logtype = "9";
}
RequestSignRelevanceWithMe reqsignwm = new RequestSignRelevanceWithMe();
reqsignwm.inertRelevanceInfo(workflowid + "", requestid + "", currentnodeid + "", logtype, currentdate, currenttime, userid, remark);
}
if(isremark==11 || takisremark == 2){
String[] arraycurrent = Util.TokenizerString2(currentString, "~~current~~");
String currentdate = Util.null2String(arraycurrent[0]);
String currenttime = Util.null2String(arraycurrent[1]);
ChuanyueUtil.executeProc4Chuanyue(workflowid,requestid,nodeid,user.getUID(),usertype,currentdate,currenttime,needwfback);
}
if (takisremark == 2) {//暂不清楚为什么屏蔽这么久
ArrayList resourceids = new ArrayList();
resourceids.add(userid);
RequestAddShareInfo requestAddShareInfo = new RequestAddShareInfo();
requestAddShareInfo.addShareInfo("" + requestid, resourceids, "false", true, false, true); // 收回被征询人的文档编辑权限
String forwardids = "";//记录需要做数据修正的forwardid
// 多个分叉中间点意见征询给同一人时, 需要找到当前所有的节点,判断是否存在意见征询动作
WFLinkInfo wfLinkinfo = new WFLinkInfo();
TakReplyBiz takOptionBiz = new TakReplyBiz(requestid, workflowid, user);
String takNodeIds = wfLinkinfo.getNowNodeids(requestid);
String taksql = "select id,takid,multiTakLevel, nodeid from workflow_currentoperator where requestid= " + requestid + " and nodeid in ( " + takNodeIds + ") and userid = " + userid
+ " and preisremark='1' and takisremark = 2 order by userid,id";
rs.executeSql(taksql);
RecordSet rs1 = new RecordSet();
while (rs.next()) {
int beforwardid = Util.getIntValue(rs.getString("id"));
int beforwardNodeId = Util.getIntValue(rs.getString("nodeid"));
int forwardid = Util.getIntValue(rs.getString("takid"));
int multiTakLevel = Util.getIntValue(rs.getString("multiTakLevel"), 0);
//兼容老数据workflow_currentoperator表中没存takid时从workflow_forward中取
if (forwardid <= 0) {
rs1.executeSql("select forwardid from workflow_forward where requestid = " + requestid + " and beforwardid = " + beforwardid);
rs1.next();
forwardid = Util.getIntValue(rs1.getString("forwardid"));
}
if (forwardid > 0) { // 找到征询人
if (multiTakLevel <= 0) {//添加回复人
rs1.executeQuery("select 1 from workflow_currentoperator where isremark = 0 and takisremark = '-2' and id = ?", forwardid);
if(rs1.next()) {
takOptionBiz.getReplyToIds().add(forwardid);
}
}
String sumBeforWardSql = "select * from workflow_currentoperator where requestid= " + requestid + " and nodeid = " + beforwardNodeId
+ " and ((isremark=1 and preisremark='1') or istakout = 1) and takisremark = 2 and (id in (select beforwardid from workflow_forward where requestid=" + requestid + " and forwardid="
+ forwardid + " and beforwardid<>" + beforwardid + ") or takid = " + forwardid + ")";
rs1.executeSql(sumBeforWardSql);
if (!rs1.next()) { // 判断是否所有被征询人都已回复
forwardids += forwardid + ",";
String uptaksql2 = "update workflow_currentoperator set takisremark=0 where requestid= " + requestid + " and nodeid = " + beforwardNodeId
+ " and isremark = 0 and takisremark = -2 and id=" + forwardid;
rs1.executeSql(uptaksql2);
//多重意见征询回复
if (multiTakLevel > 0) {
takOptionBiz.doTakingReply(forwardid, multiTakLevel, beforwardid);
} else {
int forwardUserid = 0;
rs1.executeQuery("select userid from workflow_currentoperator where id = ?", forwardid);
if (rs1.next()) {
forwardUserid = Util.getIntValue(rs1.getString("userid"), 0);
}
//调整islasttimes让流程回到待办
rs1.executeQuery("select id from workflow_currentoperator where islasttimes = 1 and requestid = ? and userid = ?", requestid, forwardUserid);
int count = rs1.getCounts();//一个requestiduserid存在islasttimes = 1的记录数量只要不等于1说明需要修复
int forwardid_temp = -1;//islasttimes = 1的记录与征询人的这条记录不相同则需要修复
if(rs1.next()){
forwardid_temp = rs1.getInt("id");
}
//增加需要进入修复逻辑的条件(增加条件的原因是因为很多客户再执行这段逻辑时,执行完第一句时,执行第二句就死锁了,导致出问题了)
if(count != 1 || forwardid_temp != forwardid){
rs1.executeUpdate("update workflow_currentoperator set islasttimes = 0 where requestid = ? and userid = ? and id != ?", requestid, forwardUserid, forwardid);
rs1.executeUpdate("update workflow_currentoperator set islasttimes = 1 where id = ?", forwardid);
}
// 如果意见征询接收人可以上传附件,需要对意见征询人赋权
try {
RequestAddShareInfo shareinfo = new RequestAddShareInfo();
shareinfo.setRequestid(requestid);
shareinfo.SetWorkFlowID(workflowid);
shareinfo.SetNowNodeID(nodeid);
shareinfo.SetNextNodeID(nodeid);
shareinfo.setIsbill(isbill);
shareinfo.setUser(user);
shareinfo.SetIsWorkFlow(1);
String billtablename = "";
if (isbill == 1) {
rs1.executeSql("select tablename from workflow_bill where id = " + formid);
if (rs1.next())
billtablename = rs1.getString("tablename");
}
shareinfo.setBillTableName(billtablename);
shareinfo.setHaspassnode(false);
shareinfo.addShareInfo();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
rs1.executeQuery("select userid from workflow_currentoperator where id = ?",forwardid);
rs1.next();
//修正A提交BA再转发给BB意见征询给CC回复后流程在B的已办问题
String uptaksql2 = "update workflow_currentoperator set takisremark=0 , isremark = 1 where requestid= ? and userid = ? and nodeid not in ("+takNodeIds+") and isremark = 0 and takisremark = -2 and islasttimes = 0" ;
rs1.executeUpdate(uptaksql2,requestid,Util.null2String(rs1.getString("userid")));
}
//意见征询回复后,更新签字意见的接收人
takOptionBiz.updateRequestLog();
//修正意见征询人在currentoperator表有两条数据意见征询时workflow_forward表存的forwardid不对导致回复时更新takisremark更新错的情况,导致流程回不到待办
WfDataCorrectionUtils.correctTakData(requestid,forwardids);
}
if("b".equals(logtype) || "9".equals(logtype) ){
if("b".equals(logtype)){
rolm.setSrc(RequestOperateTypeEnum.TAKEREPLY.getId());
}else if("9".equals(logtype)){
rolm.setSrc(RequestOperateTypeEnum.FORWARDREPLY.getId());
}
rolm.flowTransSubmitAfter();
}
//意见征询的加强处理,防止被征询回复后,流程不在待办
rs.executeQuery("select id from workflow_currentoperator where requestid = ? and isremark = '0' and takisremark = '-2'", requestid);
while (rs.next()) {
int tempId = rs.getInt(1);
if(!checkIsTakOut(requestid, tempId)) {//征询出去的记录都已回复,将此记录设置为已回复状态
rs.executeUpdate("update workflow_currentoperator set takisremark = '0' where requestid = ? and id = ?", requestid, tempId);
}
}
if (takisremark == 2){
this.remarkRemind(requestid,workflowid,src,fu,resultInfo,nodeid);
}
if("1".equals(comemessage)){
resultBean.setType(RequestExecuteType.SEND_PAGE);
resultBean.setSendPage(weaver.general.GCONST.getContextPath()+"/spa/workflow/index_mobx.jsp#/main/workflow/listDoing");
}else{
resultBean.setType(RequestExecuteType.SUCCESS);
}
new MsgPushUtil().pushMsg(requestMsgEntity);
try {
Class<?> clazz = Class.forName("com.customization.dito.sendtodo.SendPortalForwardCmd");
if (clazz.getMethod("delTodoAddDoneSendPortal", new Class[]{String.class, int.class, User.class}) != null) {
Method method = clazz.getMethod("delTodoAddDoneSendPortal", new Class[]{String.class, int.class, User.class});
Object newInstance = clazz.newInstance();
method.invoke(newInstance, requestid+"", currentnodeid, user);
}
}catch (Exception e){
e.printStackTrace();
rs.writeLog(e);
}
return resultBean;
}
/**
*
* @param id
* @return
*/
public boolean checkIsTakOut(int requestid, int id) {
RecordSet rs = new RecordSet();
rs.executeQuery("select id,isremark from workflow_currentoperator where requestid = ? and takid = ? and takisremark = '2'", requestid, id);
while (rs.next()) {
int tempId = rs.getInt(1);
String tempIsremark = rs.getString(2);
if ("1".equals(tempIsremark)) {//存在未回复的记录
return true;
} else if(checkIsTakOut(requestid, tempId)){
//isremark为2的情况验证多级征询
return true;
}
}
return false;
}
/**
* \ \
* @param rs
* @param requestid
* @param nodeid
* @param userid \
* @return \
*/
private List<String> getForwardUserId(RecordSet rs,int requestid,int nodeid,String userid,boolean isShowReplyNotice){
List<String> forwardUserId = new ArrayList<>();
//根据当前被征询人找出征询人
rs.executeQuery("select id,takisremark from workflow_currentoperator where requestid = ? and nodeid = ? and userid = ? and isremark = 1", requestid, nodeid, userid);
List<String> beforwardIds = new ArrayList<>();
while(rs.next()){
beforwardIds.add(Util.null2String(rs.getString("id")));
}
if(beforwardIds.isEmpty()) return forwardUserId;;
List<String> forwardIds = this.getForwardIds(rs,beforwardIds,requestid,isShowReplyNotice);
if(forwardIds.isEmpty()) return forwardUserId;
rs.executeQuery("select userid from workflow_currentoperator where " + Util.getSubINClause(String.join(",",forwardIds),"id","in"));
while (rs.next()){
forwardUserId.add(Util.null2String(rs.getString("userid")));
}
return forwardUserId;
}
/**
*
* @param rs
* @param beforwardIds
* @param requestid
* @return
*/
private List<String> getForwardIds(RecordSet rs,List<String> beforwardIds,int requestid,boolean isShowReplyNotice){
List<String> forwardIds = new ArrayList<>();
String sql = "select forwardid from workflow_forward where requestid = ? ";
if(isShowReplyNotice){
sql += " and isShowReplyNotice = '1'";
}
sql += " and "+ Util.getSubINClause(String.join(",",beforwardIds),"beforwardid","in");
rs.executeQuery(sql, requestid);
while(rs.next()){
forwardIds.add(Util.null2String(rs.getString("forwardid")));
}
return forwardIds;
}
private String getRemark(int workflowid,int nodeid,String remark){
if("".equals(remark) || "\n".equals(remark) ){
RecordSet rs = new RecordSet();
rs.executeQuery("select newname7 from workflow_nodeCustomNewMenu where menutype = -25 and wfid = ? and nodeid = ?",workflowid,nodeid);
if(rs.next()){
String newname7 = rs.getString(1);
remark = Util.processBody(Util.null2String(rs.getString(1)).trim(),
"" + user.getLanguage());
}
}
return remark;
}
@Override
public BizLogContext getLogContext() {
return null;
}
/**
* PROCEDURE workflow_CurOpe_UbyForward
* @param rs
* @throws Exception
*/
private static void workflow_CurOpe_UbyForward(RecordSet rs, int requestid, int userid, int usertype, String currentdate, String currenttime) throws Exception {
String upSql = "update workflow_currentoperator set isremark = 2, operatedate = '" + currentdate + "', operatetime = '" + currenttime + "',processUser = "+userid
+ " where requestid = " + requestid + " and userid =" + userid
+ " and usertype = " + usertype + " and (isremark = 1 or isremark = 8 or isremark = 9)";
rs.executeSql(upSql);
}
/**
* PROCEDURE workflow_CurOpe_UbyForwardNB
* @param rs
* @throws Exception
*/
private static void workflow_CurOpe_UbyForwardNB(RecordSet rs, int requestid, int userid, int usertype, String currentdate, String currenttime) throws Exception {
String upSql = " update workflow_currentoperator set isremark='2', operatedate = '" + currentdate + "', operatetime = '" + currenttime + "', needwfback = '0',processUser = "+userid
+ " where requestid = " + requestid
+ " and userid = " + userid
+ " and usertype = " + usertype
+ " and (isremark = '1' or isremark = '8' or isremark = '9')";
rs.executeSql(upSql);
}
/**
*
* @param requestid
* @param workflowid
* @param src
* @param fu
* @param resultInfo
*/
private void remarkRemind(int requestid,int workflowid,String src,FileUpload fu,Map<String,Object> resultInfo,int nodeid ){
RecordSet rs = new RecordSet();
//根据当前被征询人找出征询人
rs.executeQuery("select id from workflow_currentoperator where requestid = ? and nodeid = ? and userid = ? and isremark = 2 and takisremark = 2", requestid, nodeid, user.getUID());
rs.next();
int beforwardId = Util.getIntValue(Util.null2String(rs.getString("id")));
rs.executeQuery("select forwardid from workflow_forward where requestid = ? and beforwardid = ?", requestid, beforwardId);
rs.next();
int forwardId = Util.getIntValue(Util.null2String(rs.getString("forwardid")));
Set<String> allBeforwardId = new HashSet<>();
rs.executeQuery("select beforwardid from workflow_forward where requestid = ? and forwardid = ?",requestid,forwardId); //所有被征询人
while(rs.next()){
allBeforwardId.add(Util.null2String(rs.getString("beforwardid")));
}
if (allBeforwardId.isEmpty()) return;
String ss = String.join(",",allBeforwardId);
rs.executeQuery("select 1 from workflow_currentoperator where ("+Util.getSubINClause(ss,"id","in")+") and isremark = 1 and takisremark = 2");
//
if(!rs.next()){
rs.executeQuery("select userid from workflow_currentoperator where id = ? ", forwardId );
String remindTypes = Util.null2String(fu.getParameter("remindTypes"));
if(!Strings.isNullOrEmpty(remindTypes) && rs.next()){
// boolean isChooseReminder = RequestRemindBiz.isNeedRemind(workflowid,requestid,src,user.getUID());
// if (isChooseReminder) {
// resultInfo.put("needRemind", true);
// } else {
String isSmsRemind = remindTypes.indexOf(RemindTypeEnum.SMS.getCode()) > -1 ? "1" : "0";
String isEmailRemind = remindTypes.indexOf(RemindTypeEnum.EMAIL.getCode()) > -1 ? "1" : "0";
String taker = rs.getString(1);
Map<String,Object> params = new HashMap<>();
params.put("reminder",taker);
params.put("requestId",requestid);
params.put("workflowId",workflowid);
params.put("submitType", "");
RequestRemindBiz requestRemindBiz = new RequestRemindBiz(user);
if("1".equals(isSmsRemind)) requestRemindBiz.requestRemind(params,RemindTypeEnum.SMS);
if("1".equals(isEmailRemind)) requestRemindBiz.requestRemind(params,RemindTypeEnum.EMAIL);
// }
}
}
}
/**
*
* @param requestid
* @param nodeid
* @return
*/
private boolean isDidremarkSubmit(int requestid , int nodeid){
RecordSet recordSet = new RecordSet();
String sql = "select takid from workflow_currentoperator t where t.requestid=? and nodeid=? and userid=? and islasttimes=1 and isremark=1 and takisremark=2";
recordSet.executeQuery(sql,requestid,nodeid,user.getUID());
if(recordSet.next()){
return false;
}
return true;
}
}

@ -0,0 +1,238 @@
package com.engine.workflow.cmd.requestForm.communication;
import com.customization.qc2563600.CCOperatorUtil;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.workflow.biz.WorkflowCommunicationBiz;
import com.engine.workflow.entity.requestForm.communication.Content;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.dito.comInfo.PropBean;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
*/
public class DoSaveContentCmd extends AbstractCommonCommand<Map<String, Object>> {
public DoSaveContentCmd() {}
public DoSaveContentCmd(Map<String, Object> params, User user) {
this.params = params;
this.user = user;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> apidatas = new HashMap<>();
int communicationId = Util.getIntValue(Util.null2String(params.get("communicationId")), 0);
int requestId = Util.getIntValue(Util.null2String(params.get("requestid")));
String nodeid = Util.null2String(params.get("nodeid"));
//没有传交流id,补偿一下
if (communicationId == 0) {
int workflowId = Util.getIntValue(Util.null2String(params.get("workflowid")));
int refRequestId = Util.getIntValue(Util.null2String(params.get("refRequestId")));
int isSubReqeuestid = Util.getIntValue(Util.null2String(params.get("isSubReqeuestid")));
if(isSubReqeuestid==1){
RecordSet rs = new RecordSet();
rs.executeQuery("select * from workflow_requestbase where requestid = ?",refRequestId);
rs.next();
communicationId = WorkflowCommunicationBiz.getOrNewCommunicationId(refRequestId, Util.getIntValue(rs.getString("workflowid")));
requestId = refRequestId;
}else{
communicationId = WorkflowCommunicationBiz.getOrNewCommunicationId(requestId, workflowId);
}
}
String remark = Util.null2String(params.get("remark"));
String quouteRemark = Util.null2String(params.get("quouteRemark"));
int quoteContentId = Util.getIntValue(Util.null2String(params.get("contentId")), -1);
String quoteType = Util.null2String(params.get("quote_type"));
//引用的是签字意见先保存签字意见作为内容返回contentId
if("quoteSign".equals(quoteType)) {
int logUserId = Util.getIntValue(Util.null2String(params.get("log_useid")));
int logUserType = Util.getIntValue(Util.null2String(params.get("log_userType")), 1);
String logOperatedate = Util.null2String(params.get("log_operatedate"));
String logOperatetime = Util.null2String(params.get("log_operatetime"));
String logNodeName = Util.null2String(params.get("log_nodename"));
int logId = Util.getIntValue(Util.null2String(params.get("sign_logid")));
String logOperationName = Util.null2String(params.get("operationname"));
String signReplyText = Util.null2String(params.get("signReplyText"));
Content quoteContent = new Content();
quoteContent.setIsSignLog("1");
quoteContent.setCommunicationid(communicationId);
quoteContent.setRemark(signReplyText, "");
quoteContent.setCreateUser(logUserId);
quoteContent.setCreateUserType(logUserType);
quoteContent.setCreateDate(logOperatedate);
quoteContent.setCreateTime(logOperatetime);
quoteContent.setLogNodeName(logNodeName);
quoteContent.setLogOperationName(logOperationName);
quoteContent.setSignLogId(logId);
quoteContentId = quoteContent.insertContentToDB();
}
String projectIDs = Util.null2String(params.get("projectIDs"));
String relatedacc = Util.null2String(params.get("relatedacc"));
String relatedcus = Util.null2String(params.get("relatedcus"));
String relateddoc = Util.null2String(params.get("relateddoc"));
String relatedprj = Util.null2String(params.get("relatedprj"));
String relatedwf = Util.null2String(params.get("relatedwf"));
Date newDate = new Date();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
String dateStr = dateFormat.format(newDate);
String timeStr = timeFormat.format(newDate);
Content content = new Content();
content.setCommunicationid(communicationId);
content.setRemark(remark, quouteRemark);
content.setCreateUser(user.getUID());
content.setCreateUserType(Util.getIntValue(user.getLogintype(), 1));
content.setCreateDate(dateStr);
content.setCreateTime(timeStr);
content.setQuoteContentId(quoteContentId);
content.setProjectIds(projectIDs);
content.setRelatedAcc(relatedacc);
content.setRelatedCus(relatedcus);
content.setRelatedDoc(relateddoc);
content.setRelatedPrj(relatedprj);
content.setRelatedWf(relatedwf);
int contentId = content.insertContentToDB();
if(quoteContentId != -1 && contentId != -1) {
//引用成功后,更新消息提醒
WorkflowCommunicationBiz.updateMessageRemind(contentId);
}
//修改内容后,重置相关交流的新消息提醒
if (contentId > 0) {
WorkflowCommunicationBiz.resetNewCommunicationReadLog(communicationId, user, remark);
}
//抄送(不需提交)给@的人员
new BaseBean().writeLog("qc2563600===>>开始执行抄送(不需提交)给@的人员,remark:" + remark);
CctoAtUser(nodeid,requestId,remark,user);
//发送给门户抄送不需提交,待阅
toMenhuDaiyue(requestId+"",nodeid,remark);
apidatas.put("result", contentId != -1);
return apidatas;
}
/**
* @
* @param nodeid
* @param requestid
* @param remark
*/
private void CctoAtUser(String nodeid, int requestid, String remark,User user) {
String pattern = "(?i)atsome=\\\"\\@[0-9]*";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(remark);
Set<String> userIds = new HashSet<>();
while (m.find()) {
String replace = m.group().replace("atsome=\"@", "");
if(!"".equals(replace))
userIds.add(replace);
}
List<String> list = new ArrayList<>(userIds);
if(list.size() > 0) {
new BaseBean().writeLog("qc2563600===>>开始执行抄送逻辑userIds" + userIds + "requestid:" + requestid + "nodeid:" + nodeid);
CCOperatorUtil.insert(requestid + "", list, nodeid, "8", user);
}
}
private void toMenhuDaiyue(String reqid,String nodeid,String remark){
List<Map<String, Object>> todolist = new ArrayList();
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
Map<String, Object> rsojson = new HashMap<>();
try {
String pattern = "(?i)atsome=\\\"\\@[0-9]*";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(remark);
Set<String> userIds = new HashSet<>();
while (m.find()) {
String replace = m.group().replace("atsome=\"@", "");
if(!"".equals(replace)) {
userIds.add(replace);
}
}
rs1.executeQuery("select * from workflow_requestbase where requestid=?", reqid);
rs1.next();
String requestname = Util.null2String(rs1.getString("requestname"));
nodeid = Util.null2String(rs1.getString("currentnodeid"));
rs1.executeQuery("select * from workflow_nodebase where id=?", nodeid);
rs1.next();
String nodename = Util.null2String(rs1.getString("nodename"));
List<String> list = new ArrayList<>(userIds);
if(list.size() > 0){
for(String userid : list){
rsojson.put("requestname", requestname);
rsojson.put("requestid", reqid);
rsojson.put("username", new ResourceComInfo().getLastname(userid) + "(" + userid + ")");
rsojson.put("id", userid);
rsojson.put("nodeid", nodeid);
rsojson.put("nodename", nodename);
rsojson.put("isremark", "8");//抄送无需提交
rsojson.put("loginid", new ResourceComInfo().getLoginID(userid));
rs.writeLog("=================== DoSaveContentCmd toMenhuDaiyue ============== " + rsojson);
todolist.add(rsojson);
}
Map<String, Object> params = new HashMap<>();
params.put("TodoDatas", todolist);
params.put("requestid", reqid);
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
String username = PropBean.getUfPropValue("username");
String passwd = PropBean.getUfPropValue("passwd");
String center = PropBean.getUfPropValue("center");
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
Class<?> clazz = Class.forName("com.customization.dito.sendtodo.SendPortalAtAddTodoCmd");
if(clazz.getMethod("sendTodoDataByNode",new Class[]{String.class,List.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class}) != null) {
Method method = clazz.getMethod("sendTodoDataByNode",new Class[]{String.class,List.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class});
Object newInstance = clazz.newInstance();
method.invoke(newInstance,reqid,todolist,username,passwd,center,portal_todourl,bpm_workflowurl,bpm_app_workflowurl,bpm_app_requesturl);
}
}
}catch (Exception e){
rs.writeLog(e);
e.printStackTrace();
}
}
}

@ -0,0 +1,441 @@
package weaver.workflow.request;
import com.engine.common.service.HrmCommonService;
import com.engine.common.service.impl.HrmCommonServiceImpl;
import com.engine.integration.util.StringUtils;
import com.engine.workflow.biz.wfPathAdvanceSet.DataRanageBiz;
import com.engine.workflow.util.CollectionUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.companyvirtual.DepartmentVirtualComInfo;
import weaver.hrm.companyvirtual.SubCompanyVirtualComInfo;
import weaver.matrix.MatrixUtil;
import java.util.*;
public class DevWorkflowCreater {
/**
*
* @param workflowId
* @return ,"1,2,3"
*/
public String getWorkflowCreater(int workflowId){
StringBuffer resourcesb = new StringBuffer();
HashSet<String> resourceSet = new HashSet<>();
int id = -1;
int type = -1; //操作者类型
int content = -1; //操作者具体内容
int min_seclevel = -1; //最小安全级别
int max_seclevel = -1; //最大安全级别
int isBelong = -1; //属于 or 不属于
int bhxj = 0;//包含下级
int groupid = 0;
String sql = "select id, workflowid, type, content, min_seclevel, max_seclevel, isBelong,bhxj from ShareInnerWfCreate where usertype=0 and workflowid=" + workflowId;
RecordSet rs = new RecordSet();
rs.executeSql(sql);
HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
while (rs.next()) {
id = Util.getIntValue(rs.getString("id"));
type = Util.getIntValue(rs.getString("type"));
content = Util.getIntValue(rs.getString("content"));
min_seclevel = Util.getIntValue(rs.getString("min_seclevel"));
max_seclevel = Util.getIntValue(rs.getString("max_seclevel"));
isBelong = Util.getIntValue(rs.getString("isBelong"));
bhxj = Util.getIntValue(rs.getString("bhxj"));
groupid = Util.getIntValue(rs.getString("groupid"));
String resourceSql = "";
if (type == 1) { //部门
String allParentDepartId = "";
String allChildDepartId = "";
try {
ArrayList<String> list = new ArrayList<>();
allParentDepartId = departmentComInfo.getAllParentDepartId(content + "", content + "");
ArrayList<String> allChildDept = departmentComInfo.getAllChildDeptByDepId(list, content + "");
if (allChildDept.size()>0) {
allChildDepartId = StringUtils.join(allChildDept, ",")+","+content;
}else
allChildDepartId = content+"";
} catch (Exception e) {
e.printStackTrace();
}
if (isBelong == 1) {
if (bhxj == 1){
resourceSql = "select id from HrmResource where departmentid in (" + allChildDepartId + ") and seclevel>=" + min_seclevel + " and seclevel<=" + max_seclevel;
}else if (bhxj == 2){
resourceSql = "select id from HrmResource where departmentid in (" + allParentDepartId + ") and seclevel>=" + min_seclevel + " and seclevel<=" + max_seclevel;
}else if (bhxj == 0){
resourceSql = "select id from HrmResource where departmentid in (" + content + ") and seclevel>=" + min_seclevel + " and seclevel<=" + max_seclevel;
}
} else if (isBelong == 2) {
if (bhxj ==1){
resourceSql = "select id from HrmResource where (departmentid not in ("+allChildDepartId+") or (departmentid in("+allChildDepartId+") and (seclevel<" + min_seclevel + " or seclevel>" + max_seclevel + " )))";
}else if (bhxj ==2){
resourceSql = "select id from HrmResource where (departmentid not in ("+allParentDepartId+") or (departmentid in("+allParentDepartId+") and (seclevel< "+min_seclevel+" or seclevel>"+max_seclevel+" )))";
}else if (bhxj == 0){
resourceSql = "select id from HrmResource where (departmentid not in (" + content + ") or (departmentid in(" + content + ") and (seclevel<" + min_seclevel + " or seclevel>" + max_seclevel + " )))";
}
}
} else if (type == 2) { //角色
String roleid = String.valueOf(content).substring(0, String.valueOf(content).length() - 1);
String roleLv = String.valueOf(content).substring(String.valueOf(content).length() - 1);
String roleMemberSql = hrmCommonService.getHrmRoleMemeberSqlByRoleIds(roleid);
if (isBelong == 1) {
resourceSql = "select id from HrmResource where id in (";
resourceSql += "select distinct resourceid from ("+roleMemberSql+")t2 where t2.roleid=" + roleid + " and t2.rolelevel=" + roleLv;
} else if (isBelong == 2){
resourceSql = "select id from HrmResource where id not in (";
resourceSql += "select distinct resourceid from ("+roleMemberSql+")t2 where t2.roleid=" + roleid + " and t2.rolelevel=" + roleLv;
} else {
resourceSql += "-1";
}
resourceSql += ")";
} else if (type == 3) { //指定人
if ("-1".equals(isBelong)) continue;
resourceSql = "select id from HrmResource where id=" + content;
} else if (type == 4) { //所有人
if ("-1".equals(isBelong)) continue;
resourceSql = "select id from HrmResource where seclevel>=" + min_seclevel + " and seclevel<=" + max_seclevel;
} else if (type == 30) { //分部
String allSubCompany = "";
String parentSubCompany = "";
try {
allSubCompany= subCompanyComInfo.getSubCompanyTreeStr(content + "");
parentSubCompany = subCompanyComInfo.getAllSupCompany(content + "");
if (!"".equals(allSubCompany)){
if (allSubCompany.endsWith(",")) {
allSubCompany += content;
}else
allSubCompany += ","+content;
}else
allSubCompany = content+"";
if (!"".endsWith(parentSubCompany)){
if (parentSubCompany.endsWith(","))
parentSubCompany += content;
else {
parentSubCompany += ","+ content;
}
}else
parentSubCompany = content+"";
} catch (Exception e) {
e.printStackTrace();
}
if (isBelong == 1) {
if (bhxj == 1){
resourceSql = "select id from HrmResource where subcompanyid1 in("+allSubCompany+") and seclevel>=" + min_seclevel + " and seclevel<=" + max_seclevel;
}else if (bhxj == 2){
resourceSql = "select id from HrmResource where subcompanyid1 in ("+parentSubCompany+") and seclevel>=" + min_seclevel + " and seclevel<=" + max_seclevel;
}else if (bhxj == 0){
resourceSql = "select id from HrmResource where subcompanyid1=" + content + " and seclevel>=" + min_seclevel + " and seclevel<=" + max_seclevel;
}
} else if (isBelong == 2) {
if (bhxj ==1){
resourceSql = "select id from HrmResource where (subcompanyid1 not in ("+allSubCompany+") or (subcompanyid1 in ("+allSubCompany+") and (seclevel<" + min_seclevel + " or seclevel>" + max_seclevel + "))) ";
}else if (bhxj==2){
resourceSql = "select id from HrmResource where (subcompanyid1 not in ("+parentSubCompany+") or (subcompanyid1 in (" + parentSubCompany + ") and (seclevel<" + min_seclevel + " or seclevel>" + max_seclevel + ") ))";
}else if (bhxj == 0)
resourceSql = "select id from HrmResource where (subcompanyid1<>" + content + " or (subcompanyid1=" + content + " and (seclevel<" + min_seclevel + " or seclevel>" + max_seclevel + ")) )";
}
}else if (type == 58){//岗位
if (isBelong == 1){
resourceSql = "select id from HrmResource where JOBTITLE in ("+content+")";
if (min_seclevel == 0 && max_seclevel>0 ){
String allParentDepartId = "";
String allChildDepartId = "";
try {
ArrayList<String> list = new ArrayList<>();
allParentDepartId = departmentComInfo.getAllParentDepartId(max_seclevel + "", max_seclevel + "");
ArrayList<String> allChildDept = departmentComInfo.getAllChildDeptByDepId(list, max_seclevel + "");
if (allChildDept.size()>0) {
allChildDepartId = StringUtils.join(allChildDept, ",")+","+max_seclevel;
}else
allChildDepartId = max_seclevel+"";
} catch (Exception e) {
e.printStackTrace();
}
if (bhxj ==1){
resourceSql+=" and DEPARTMENTID in ("+allChildDepartId+") ";
}else if (bhxj ==2){
resourceSql+=" and DEPARTMENTID in ("+allParentDepartId+") ";
}else if (bhxj == 0){
resourceSql+=" and DEPARTMENTID in ("+max_seclevel+")";
}
}else if (min_seclevel == 1 && max_seclevel>0){
String allSubCompany = "";
String parentSubCompany = "";
try {
allSubCompany= subCompanyComInfo.getSubCompanyTreeStr(max_seclevel + "");
parentSubCompany = subCompanyComInfo.getAllSupCompany(max_seclevel + "");
if (!"".equals(allSubCompany)){
if (allSubCompany.endsWith(",")) {
allSubCompany += max_seclevel;
}else
allSubCompany += ","+max_seclevel;
}else
allSubCompany = max_seclevel+"";
if (!"".endsWith(parentSubCompany)){
if (parentSubCompany.endsWith(","))
parentSubCompany += max_seclevel;
else {
parentSubCompany += ","+ max_seclevel;
}
}else
parentSubCompany = max_seclevel+"";
} catch (Exception e) {
e.printStackTrace();
}
if (bhxj == 1){
resourceSql += " and SUBCOMPANYID1 in("+allSubCompany+") ";
}else if (bhxj ==2){
resourceSql += " and SUBCOMPANYID1 in("+parentSubCompany+") ";
}else if (bhxj == 0)
resourceSql += " and SUBCOMPANYID1 in("+max_seclevel+") ";
}
}else if (isBelong == 2){
resourceSql = "select id from HrmResource where jobtitle not in ("+content+")";
if (min_seclevel == 0 && max_seclevel>0 ){
resourceSql += " or (jobtitle in ("+content+")";
String allParentDepartId = "";
String allChildDepartId = "";
try {
ArrayList<String> list = new ArrayList<>();
allParentDepartId = departmentComInfo.getAllParentDepartId(max_seclevel + "", max_seclevel + "");
ArrayList<String> allChildDept = departmentComInfo.getAllChildDeptByDepId(list, max_seclevel + "");
if (allChildDept.size()>0) {
allChildDepartId = StringUtils.join(allChildDept, ",")+","+max_seclevel;
}else
allChildDepartId = max_seclevel+"";
} catch (Exception e) {
e.printStackTrace();
}
if (bhxj ==1){
resourceSql+=" and DEPARTMENTID not in ("+allChildDepartId+") ";
}else if (bhxj ==2){
resourceSql+=" and DEPARTMENTID not in ("+allParentDepartId+") ";
}else if (bhxj == 0){
resourceSql+=" and DEPARTMENTID not in ("+max_seclevel+")";
}
resourceSql+=")";
}else if (min_seclevel == 1 && max_seclevel>0){
resourceSql += " or (jobtitle in ("+content+")";
String allSubCompany = "";
String parentSubCompany = "";
try {
allSubCompany= subCompanyComInfo.getSubCompanyTreeStr(max_seclevel + "");
parentSubCompany = subCompanyComInfo.getAllSupCompany(max_seclevel + "");
if (!"".equals(allSubCompany)){
if (allSubCompany.endsWith(",")) {
allSubCompany += max_seclevel;
}else
allSubCompany += ","+max_seclevel;
}else
allSubCompany = max_seclevel+"";
if (!"".endsWith(parentSubCompany)){
if (parentSubCompany.endsWith(","))
parentSubCompany += max_seclevel;
else {
parentSubCompany += ","+ max_seclevel;
}
}else
parentSubCompany = max_seclevel+"";
} catch (Exception e) {
e.printStackTrace();
}
if (bhxj == 1){
resourceSql += " and SUBCOMPANYID1 not in("+allSubCompany+") ";
}else if (bhxj ==2){
resourceSql += " and SUBCOMPANYID1 not in("+parentSubCompany+")";
}else if (bhxj == 0) {
resourceSql += " and SUBCOMPANYID1 not in(" + max_seclevel + ") ";
}
resourceSql += ")";
}
}else if (isBelong == -1){
continue;
}
}else if (type == 99){
DepartmentComInfo dc = new DepartmentComInfo();
DepartmentVirtualComInfo dvc = new DepartmentVirtualComInfo();
SubCompanyComInfo scc = new SubCompanyComInfo();
SubCompanyVirtualComInfo svc = new SubCompanyVirtualComInfo();
Map<String,Map<String, String>> groupdetailMatrix = getGroupdetailMatrix();
Map<String,List<Map<String, String>>> groupdetailMatrixdetail = getGroupdetailMatrixdetail();
MatrixUtil matrixUtil = new MatrixUtil();
matrixUtil.setMatrixFieldnameMap(getMatrixFieldname());
String sql1 = "select t1.workflowid,t3.* from workflow_flownode t1 , workflow_nodegroup t2 , workflow_groupdetail t3 where t1.nodeid = t2.nodeid and t2.id = t3.groupid and t1.nodetype = '0' and t3.type = '99'";
if(workflowId > 0){
sql1 += " and t1.workflowid = " + workflowId;
}
RecordSet rs1 = new RecordSet();
//查出所有创建节点设置的矩阵
rs.executeQuery(sql1);
//优化性能,相同的设置计算一次即可
Map<String, Boolean> matrixCreateResultMap = new HashMap<>();
while(rs.next()){
String workflowid = rs.getString("workflowid");
String groupdetailid = rs.getString("id");
//查出引用的矩阵以及取值字段
String matrix = "";
String value_field = "";
Map<String, String> groupdetailMatrixData = groupdetailMatrix.get(groupdetailid);
if(groupdetailMatrixData != null){
matrix = Util.null2String(groupdetailMatrixData.get("matrix"));
value_field = Util.null2String(groupdetailMatrixData.get("value_field"));
}
Map<String, String> matchs = new HashMap<String, String>();
List<Map<String, String>> groupdetailMatrixdetailData = groupdetailMatrixdetail.get(groupdetailid);
int workflowBhxj = 0;
if(groupdetailMatrixdetailData!=null) {
String key = matrix +"_"+value_field;
for (Map<String, String> matrixdetailData : groupdetailMatrixdetailData) {
key += "_"+Util.null2String(matrixdetailData.get("condition_field"));
key += "_"+Util.null2String(matrixdetailData.get("workflow_field"));
key += "_"+Util.getIntValue(Util.null2String(matrixdetailData.get("workflow_bhxj")));
key += "_"+Util.null2String(matrixdetailData.get("workflow_objId"));
}
Boolean map_result = matrixCreateResultMap.get(key);
if(map_result != null){
continue;
}
for (Map<String, String> matrixdetailData : groupdetailMatrixdetailData) {
String conditionField = Util.null2String(matrixdetailData.get("condition_field"));
String fieldId = Util.null2String(matrixdetailData.get("workflow_field"));
workflowBhxj = Util.getIntValue(Util.null2String(matrixdetailData.get("workflow_bhxj")));
String fieldValue = Util.null2String(matrixdetailData.get("workflow_objId"));
switch (fieldId) {
case "-1"://指定分部
fieldValue = CollectionUtil.list2String(DataRanageBiz.loadAllSubcompany(fieldValue, workflowBhxj, scc, svc), ",");
break;
case "-2"://指定部门
fieldValue = CollectionUtil.list2String(DataRanageBiz.loadAllDepartmet(fieldValue, workflowBhxj, dc, dvc), ",");
break;
default:
break;
}
matchs.put(conditionField, fieldValue);
}
String userids = matrixUtil.getMatrixUsers(matrix, value_field, matchs, workflowBhxj, rs1);
resourceSet.addAll(Util.TokenizerString(userids,","));
}
}
}
if (!"".equals(resourceSql)) {
RecordSet rs2 = new RecordSet();
rs2.writeLog("wcq:::sql="+resourceSql + " and (status =0 or status = 1 or status = 2 or status = 3)");
rs2.executeSql(resourceSql + " and (status =0 or status = 1 or status = 2 or status = 3)");
while (rs2.next()) {
String resourceid = rs2.getString("id");
resourceSet.add(resourceid);
}
}
}
//end
return StringUtils.join(resourceSet,",");
}
/**
* MatrixFieldInfomaporacle
* @return
*/
private Map<String,Map<String, String>> getMatrixFieldname(){
Map<String,Map<String, String>> result = new HashMap<>();
String sql = "select id,fieldname,browsertypeid,matrixid from MatrixFieldInfo where id in (select condition_field from workflow_matrixdetail where groupdetailid in (select t3.id from workflow_flownode t1 , workflow_nodegroup t2 , workflow_groupdetail t3 where t1.nodeid = t2.nodeid and t2.id = t3.groupid and t1.nodetype = '0' and t3.type = '99')) "+
" union all select id, fieldname, browsertypeid, matrixid from MatrixFieldInfo where id in (SELECT value_field FROM workflow_groupdetail_matrix WHERE groupdetailid in (select t3.id from workflow_flownode t1 , workflow_nodegroup t2 , workflow_groupdetail t3 where t1.nodeid = t2.nodeid and t2.id = t3.groupid and t1.nodetype = '0' and t3.type = '99'))";
RecordSet rs = new RecordSet();
rs.executeQuery(sql);
while(rs.next()){
String id = Util.null2String(rs.getString("id"));
String fieldname = Util.null2String(rs.getString("fieldname"));
String browsertypeid = Util.null2String(rs.getString("browsertypeid"));
String matrixid = Util.null2String(rs.getString("matrixid"));
Map matrixDeatil = new HashMap();
matrixDeatil.put("id", id);
matrixDeatil.put("fieldname", fieldname);
matrixDeatil.put("browsertypeid", browsertypeid);
matrixDeatil.put("matrixid", matrixid);
result.put(id, matrixDeatil);
result.put(id+"_"+matrixid, matrixDeatil);
}
return result;
}
/**
* workflow_groupdetail_matrixmaporacle
* @return
*/
private Map<String, Map<String, String>> getGroupdetailMatrix(){
Map<String,Map<String, String>> result = new HashMap<>();
String sql = "SELECT matrix,value_field,groupdetailid FROM workflow_groupdetail_matrix WHERE groupdetailid in (select t3.id from workflow_flownode t1 , workflow_nodegroup t2 , workflow_groupdetail t3 where t1.nodeid = t2.nodeid and t2.id = t3.groupid and t1.nodetype = '0' and t3.type = '99')";
RecordSet rs = new RecordSet();
rs.executeQuery(sql);
while(rs.next()){
Map<String, String> tempData = new HashMap<>();
String groupdetailid = Util.null2String(rs.getString("groupdetailid"));
String matrix = Util.null2String(rs.getString("matrix"));
String value_field = Util.null2String(rs.getString("value_field"));
tempData.put("matrix",matrix);
tempData.put("value_field",value_field);
result.put(groupdetailid, tempData);
}
return result;
}
/**
* workflow_matrixdetailmaporacle
* @return
*/
private Map<String, List<Map<String, String>>> getGroupdetailMatrixdetail(){
Map<String,List<Map<String, String>>> result = new HashMap<>();
String sql = "select condition_field,workflow_field,workflow_objid,workflow_bhxj,virtualid,groupdetailid from workflow_matrixdetail where groupdetailid in (select t3.id from workflow_flownode t1 , workflow_nodegroup t2 , workflow_groupdetail t3 where t1.nodeid = t2.nodeid and t2.id = t3.groupid and t1.nodetype = '0' and t3.type = '99')";
RecordSet rs = new RecordSet();
rs.executeQuery(sql);
while(rs.next()){
String groupdetailid = Util.null2String(rs.getString("groupdetailid"));
String conditionField = Util.null2String(rs.getString("condition_field"));
String fieldId = Util.null2String(rs.getString("workflow_field"));
int workflowBhxj = Util.getIntValue(Util.null2String(rs.getString("workflow_bhxj")));
String fieldValue = Util.null2String(rs.getString("workflow_objId"));
List<Map<String, String>> tempData = result.get(groupdetailid) == null ? new ArrayList<>() : result.get(groupdetailid);
Map matrixDeatil = new HashMap();
matrixDeatil.put("groupdetailid", groupdetailid);
matrixDeatil.put("condition_field", conditionField);
matrixDeatil.put("workflow_field", fieldId);
matrixDeatil.put("workflow_bhxj", workflowBhxj+"");
matrixDeatil.put("workflow_objId", fieldValue);
tempData.add(matrixDeatil);
result.put(groupdetailid, tempData);
}
return result;
}
}

@ -0,0 +1,205 @@
package weaver.workflow.request;
import com.google.common.base.Strings;
import weaver.conn.ConnStatement;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.dito.comInfo.PropBean;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RequestSignRelevanceWithMe extends BaseBean {
/**
* Logid
* @param wfid
* @param reqid
* @param userid
* @return
*/
public String getRelevanceinfo(String wfid, String reqid, String userid) {
String result = "";
//所有@我的log
String sql = "select t2.logid from workflow_requestlogatinfo t1 inner join workflow_requestlog t2 "
+ " on t1.nodeid=t2.nodeid "
+ " and t1.logtype=t2.logtype "
+ " and t1.operatedate=t2.operatedate "
+ " and t1.operatetime=t2.operatetime "
+ " and t1.operator=t2.operator"
+ " where t1.workflowid=" + wfid + " and t1.requestid=" + reqid + " and ((t1.atuserid is not null and t1.atuserid=" + userid + ") or (t1.forwardresource is not null and t1.forwardresource like '%," + userid + ",%'))";
RecordSet rs = new RecordSet();
rs.executeSql(sql);
while (rs.next()) {
result += Util.null2String(rs.getString(1)) + ",";
}
result += "0";
return result;
}
/**
*
* @param remark
* @param wfid id
* @param reqid id
* @param nodeid id
* @param logtype
* @param operatedate
* @param operatetime
* @param operator
* @param atuserid @
* @return
*/
public void inertRelevanceInfo(String wfid, String reqid, String nodeid, String logtype, String operatedate, String operatetime, String operator, String remark) {
inertRelevanceInfo(wfid, reqid, nodeid, logtype, operatedate, operatetime, operator, remark, null);
}
/**
*
* @param wfid id
* @param reqid id
* @param nodeid id
* @param logtype
* @param operatedate
* @param operatetime
* @param operator
* @param remark
* @param resourceids @
* @return
*/
public void inertRelevanceInfo(String wfid, String reqid, String nodeid, String logtype, String operatedate, String operatetime, String operator, String remark, String resourceids) {
List<String> atlist = this.parseRemark(remark);
RecordSet rs = new RecordSet();
try {
RecordSet rs1 = new RecordSet();
List<Map<String, Object>> todolist = new ArrayList();
for (int i = 0; i < atlist.size(); i++) {
String atuserid = atlist.get(i);
String sql = "insert into workflow_requestlogAtInfo(workflowid, requestid, nodeid, logtype, operatedate, operatetime, operator, atuserid)";
sql += " values (" + wfid + ", " + reqid + ", " + nodeid + ", '" + logtype + "', '" + operatedate + "', '" + operatetime + "', " + operator + ", " + atuserid + ")";
rs.execute(sql);
Map<String, Object> rsojson = new HashMap<>();
rs1.executeQuery("select * from workflow_requestbase where requestid=?", reqid);
rs1.next();
String requestname = Util.null2String(rs1.getString("requestname"));
rs1.executeQuery("select * from workflow_nodebase where id=?", nodeid);
rs1.next();
String nodename = Util.null2String(rs1.getString("nodename"));
rsojson.put("requestname", requestname);
rsojson.put("requestid", reqid);
rsojson.put("username", new ResourceComInfo().getLastname(atuserid) + "(" + atuserid + ")");
rsojson.put("id", atuserid);
rsojson.put("nodeid", nodeid);
rsojson.put("nodename", nodename);
rsojson.put("isremark", "8");//抄送无需提交
rsojson.put("loginid", new ResourceComInfo().getLoginID(atuserid));
rs.writeLog("=================== RequestSignRelevanceWithMe inertRelevanceInfo ============== "+ rsojson);
todolist.add(rsojson);
}
Map<String, Object> params = new HashMap<>();
params.put("TodoDatas", todolist);
params.put("requestid", reqid);
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
String username = PropBean.getUfPropValue("username");
String passwd = PropBean.getUfPropValue("passwd");
String center = PropBean.getUfPropValue("center");
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
Class<?> clazz = Class.forName("com.customization.dito.sendtodo.SendPortalAtAddTodoCmd");
if(clazz.getMethod("sendTodoDataByNode",new Class[]{String.class,List.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class}) != null) {
Method method = clazz.getMethod("sendTodoDataByNode",new Class[]{String.class,List.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class});
Object newInstance = clazz.newInstance();
method.invoke(newInstance,reqid,todolist,username,passwd,center,portal_todourl,bpm_workflowurl,bpm_app_workflowurl,bpm_app_requesturl);
}
}catch (Exception e){
e.printStackTrace();
rs.writeLog(e);
}
if (resourceids != null && resourceids.length() > 0) {
resourceids = "," + resourceids + ",";
String sql = "insert into workflow_requestlogAtInfo(workflowid, requestid, nodeid, logtype, operatedate, operatetime, operator, forwardresource)";
if(rs.getDBType().equals("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")){
sql += " values (" + wfid + ", " + reqid + ", " + nodeid + ", '" + logtype + "', '" + operatedate + "', '" + operatetime + "', " + operator + ", '')";
}else{
sql += " values (" + wfid + ", " + reqid + ", " + nodeid + ", '" + logtype + "', '" + operatedate + "', '" + operatetime + "', " + operator + ", '" + resourceids + "')";
}
rs.execute(sql);
/***多人力clob***/
if(rs.getDBType().equals("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")){
ConnStatement hrmsta = null;
try {
String maxidsql = "select max(id) maxid from workflow_requestlogAtInfo where workflowid = " + wfid + " and requestid =" + reqid;
rs.executeSql(maxidsql);
if(rs.next()){
String maxid = Util.null2String(rs.getString("maxid"));
if(!"".equals(maxid)){
String hrmsql = "update workflow_requestlogAtInfo set forwardresource = ? where id = "+maxid;
hrmsta = new ConnStatement();
hrmsta.setStatementSql(hrmsql);
hrmsta.setString(1, resourceids);
hrmsta.executeUpdate();
}
}
}catch(Exception e){
writeLog(e);
}finally {
if(hrmsta!=null) {
hrmsta.close();
}
}
//
}
/******/
}
}
/**
* at
* @param remark
* @return at
*/
public List<String> parseRemark(String remark) {
List<String> result = new ArrayList<String>();
if (Strings.isNullOrEmpty(remark)) return result;
try {
//匹配atsome="@3"
Pattern ptrn = Pattern.compile("atsome=\\\"@[\\d]+\\\"");
Pattern atptrn = Pattern.compile("[\\d]+");
Matcher matcher = ptrn.matcher(remark);
if(ptrn == null || atptrn == null){
return result;
}
while (matcher.find()) {
String atsome = matcher.group();
Matcher atMatcher = atptrn.matcher(atsome);
if (atMatcher.find()) {
if (!result.contains(atMatcher.group())) {
result.add(atMatcher.group());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
Loading…
Cancel
Save