You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haojing/src/com/customization/dito/at/SendForword2CurrentOperator...

225 lines
9.7 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.customization.dito.at;
import com.customization.dito.sendtodo.RequestBaseInfoUtil;
import com.engine.core.cfg.annotation.CommandDynamicProxy;
import com.engine.core.interceptor.AbstractCommandProxy;
import com.engine.core.interceptor.Command;
import com.engine.workflow.cmd.requestForm.ForwardSubmitCmd;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import weaver.conn.RecordSet;
import weaver.file.FileUpload;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 转发、转办、意见征询等提交待办推送
*
* @author wangj
* @version 1.00版本
* @Date 2022/10/11
*/
@CommandDynamicProxy(target = ForwardSubmitCmd.class, desc = "流程转发、转办、意见征询等提交后推送消息卡片")
public class SendForword2CurrentOperatorCmd extends AbstractCommandProxy<Map<String, Object>> {
private RequestBaseInfoUtil requestBaseInfoUtil = new RequestBaseInfoUtil();
@Override
public Map<String, Object> execute(Command<Map<String, Object>> targetCommand) {
//获取到被代理对象
ForwardSubmitCmd forwardSubmitCmd = (ForwardSubmitCmd) targetCommand;
//获取被代理对象的参数
//对参数做预处理
BaseBean bb = new BaseBean();
bb.writeLog("-----------SendForword2CurrentOperatorCmd------start--");
HttpServletRequest request = forwardSubmitCmd.getRequest();
FileUpload fu = new FileUpload(request);
String requestid = Util.null2String(fu.getParameter("requestid"));
String nodeid = Util.null2String(fu.getParameter("nodeid"));
String workflowid = Util.null2String(fu.getParameter("workflowid"));
String f_weaver_belongto_userid = Util.null2String(fu.getParameter("f_weaver_belongto_userid"));
String f_weaver_belongto_usertype = Util.null2String(fu.getParameter("f_weaver_belongto_usertype"));
User user = forwardSubmitCmd.getUser();
String agentType = Util.null2String(fu.getParameter("agentType"));
String agentorByAgentId = Util.null2String(fu.getParameter("agentorByAgentId"));
String remark = Util.null2String(fu.getParameter("remark"));
// 2 征求意见3 转办 1 转发; 5 征询转办
int forwardflag = Util.getIntValue(fu.getParameter("forwardflag"));
bb.writeLog("SendForword2CurrentOperatorCmd-requestid:"+requestid);
bb.writeLog("SendForword2CurrentOperatorCmd-nodeid:"+nodeid);
bb.writeLog("SendForword2CurrentOperatorCmd-workflowid:"+workflowid);
bb.writeLog("SendForword2CurrentOperatorCmd-remark:"+remark);
//参数回写
//执行标准的业务处理
Map<String, Object> result = nextExecute(targetCommand);
sendDate(result,workflowid,requestid,nodeid,agentType,agentorByAgentId,remark,forwardflag,user);
bb.writeLog("-----------SendForword2CurrentOperatorCmd------end--");
return result;
}
public void sendDate(Map<String, Object> result, String workflowid, String requestid, String nodeid, String agentType, String agentorByAgentId, String remark, int forwardflag,User user) {
BaseBean bb = new BaseBean();
boolean status = (boolean) result.get("success");
bb.writeLog("-----------SendForword2CurrentOperatorCmd------status:"+status);
if (status) {
bb.writeLog("-----------SendForword2CurrentOperatorCmd------forwardflag:"+forwardflag);
if(forwardflag == 1){
insertAt2CurrentOperatorByForward(requestid,remark);
}
}
}
public void insertAt2CurrentOperatorByForward(String requestid,String remark) {
BaseBean bb = new BaseBean();
try{
bb.writeLog("SendForword2CurrentOperatorCmd-remark:"+remark);
List<String> result = new ArrayList<String>();
if(org.apache.commons.lang3.StringUtils.isNotBlank(remark)){
Document doc = Jsoup.parse(remark);
// 选择所有包含 atsome - uid 属性的元素
Elements uidElements = doc.select("[atsome-uid]");
Iterator<Element> uidIt = uidElements.iterator();
while(uidIt.hasNext()) {
Element element = uidIt.next();
String atsomeUid = element.attr("atsome-uid");
if(!result.contains(atsomeUid)){
result.add(atsomeUid);
}
}
}
if(result.size() > 0){
Map<String,String> baseMap = queryRequestBaseByRequestid(requestid);
String currentNodeId = baseMap.get("currentnodeid");
insertCurrentOperator(requestid,result,currentNodeId);
}
}catch (Exception e){
e.printStackTrace();
}
}
public void insertCurrentOperator(String requestid, List<String> addUsers, String currentNodeId) {
BaseBean bb = new BaseBean();
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();
int groupid = 0 ;
String workflowid = "";
String workflowtype = "";
String needwfback = "";
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, currentNodeId);
if (rs.next()) {
groupid = Util.getIntValue(rs.getString("groupid"));
workflowid = rs.getString("workflowid");
workflowtype = rs.getString("workflowtype") ;
needwfback = rs.getString("needwfback");
}
bb.writeLog("workflowid:"+workflowid);
ArrayList<List> lists = new ArrayList<>();
for (String addUser : addUsers) {
bb.writeLog("addUser:"+addUser);
if(StringUtils.isNotBlank(addUser)){
String islasttimes = "";
String sql = " select islasttimes from workflow_currentoperator where requestid = "+requestid+" and nodeid = "+currentNodeId +" and userid = "+addUser;
rs.executeQuery(sql);
if(rs.next()){
islasttimes = Util.null2String(rs.getString("islasttimes"));
}
bb.writeLog("islasttimes:"+islasttimes);
if(StringUtils.isBlank(islasttimes)){
islasttimes = "1";
}else{
islasttimes = "0";
}
groupid++;
String userIdTemp = addUser;
String agentorbyagentid = "-1";
String agenttype = "0";
showOrder = rs.getInt("showorder") + 1;
ArrayList list = new ArrayList();
list.add(requestid);
list.add(userIdTemp);
list.add(groupid);
list.add(workflowid);
list.add(workflowtype);
list.add(0);
list.add(currentNodeId);
list.add(agentorbyagentid);
list.add(agenttype);
list.add(showOrder);
list.add(receivedate);
list.add(receivetime);
list.add(0);
list.add(0);
list.add(islasttimes);
list.add(0);
list.add(needwfback);
list.add("8");
list.add("18");
lists.add(list);
}
}
boolean isTrue = rs.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);
bb.writeLog("isTrue:"+isTrue);
}
public Map<String,String> queryRequestBaseByRequestid(String requestid){
RecordSet rs = new RecordSet();
Map<String,String> baseMap = new HashMap<String,String>();
String requestname = "";
String currentnodeid = "";
String currentnodetype = "";
try{
String sql =" select t1.requestname,t1.currentnodetype,t1.currentnodeid" +
" from workflow_requestbase t1\n" +
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t1.requestid = "+requestid ;
rs.executeQuery(sql);
if (rs.next()){
requestname = Util.null2String(rs.getString("requestname")) ;
currentnodeid = Util.null2String(rs.getString("currentnodeid")) ;
currentnodetype = Util.null2String(rs.getString("currentnodetype")) ;
baseMap.put("requestname",requestname);
baseMap.put("currentnodeid",currentnodeid);
baseMap.put("currentnodetype",currentnodetype);
baseMap.put("requestid",requestid);
}
}catch (Exception e){
}
return baseMap;
}
}