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.
234 lines
8.5 KiB
Java
234 lines
8.5 KiB
Java
8 months ago
|
package com.engine.workflow.cmd.monitor;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Date;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
import com.engine.common.biz.AbstractCommonCommand;
|
||
|
import com.engine.common.constant.BizLogOperateType;
|
||
|
import com.engine.common.constant.BizLogSmallType4Workflow;
|
||
|
import com.engine.common.constant.BizLogType;
|
||
|
import com.engine.common.constant.ParamConstant;
|
||
|
import com.engine.common.entity.BizLogContext;
|
||
|
import com.engine.common.util.ParamUtil;
|
||
|
|
||
|
import com.engine.core.interceptor.Command;
|
||
|
import com.engine.workflow.biz.requestForm.RequestRemindBiz;
|
||
|
import com.engine.workflow.constant.RemindTypeEnum;
|
||
|
import weaver.conn.RecordSet;
|
||
|
import weaver.general.BaseBean;
|
||
|
import weaver.general.Util;
|
||
|
import weaver.hrm.User;
|
||
|
import weaver.workflow.monitor.Monitor;
|
||
|
import weaver.workflow.workflow.WFManager;
|
||
|
import weaver.workflow.workflow.WfForceOver;
|
||
|
import weaver.workflow.workflow.WfFunctionManageUtil;
|
||
|
|
||
|
import com.engine.core.interceptor.CommandContext;
|
||
|
import weaver.workflow.request.RequestCheckAddinRules;
|
||
|
import weaver.workflow.request.RequestManager;
|
||
|
import weaver.workflow.workflow.WorkflowComInfo;
|
||
|
/**
|
||
|
* 流程强制归档
|
||
|
* @author luosy 2017/11/17
|
||
|
*
|
||
|
*/
|
||
|
public class DoArchivingCmd extends AbstractCommonCommand<Map<String,Object>> {
|
||
|
|
||
|
private HttpServletRequest request;
|
||
|
private HttpServletResponse response;
|
||
|
private User user;
|
||
|
|
||
|
public DoArchivingCmd(HttpServletRequest request,HttpServletResponse response,User user){
|
||
|
this.request = request;
|
||
|
this.response = response;
|
||
|
this.user = user;
|
||
|
}
|
||
|
|
||
|
public DoArchivingCmd(){
|
||
|
//空参构造器
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Map<String, Object> execute(CommandContext commandContext) {
|
||
|
return this.doArchiving(request, response, user);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 流程强制归档
|
||
|
* @param request
|
||
|
* @param response
|
||
|
* @param user
|
||
|
* @return
|
||
|
*/
|
||
|
public Map<String, Object> doArchiving(HttpServletRequest request,HttpServletResponse response,User user){
|
||
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||
|
String multiRequestIds = Util.null2String(request.getParameter("multiRequestIds"));
|
||
|
if(multiRequestIds.endsWith(",")) multiRequestIds = multiRequestIds.substring(0,multiRequestIds.length() - 1);
|
||
|
|
||
|
String[] requestids = Util.TokenizerString2(multiRequestIds, ",");
|
||
|
RecordSet rs = new RecordSet();
|
||
|
WfFunctionManageUtil WfFunctionManageUtil = new WfFunctionManageUtil();
|
||
|
Monitor Monitor = new Monitor();
|
||
|
WfForceOver WfForceOver = new WfForceOver();
|
||
|
int success = 0,fail = 0;
|
||
|
if (requestids != null) {
|
||
|
for (int i = 0; i < requestids.length; i++) {
|
||
|
ArrayList requestidsArr = new ArrayList();
|
||
|
int requestid_tmp = Util.getIntValue(requestids[i]);
|
||
|
if(requestid_tmp == -1){
|
||
|
fail++;
|
||
|
continue;
|
||
|
}
|
||
|
if(!WfFunctionManageUtil.haveOtherOperationRight(requestid_tmp)){
|
||
|
continue;
|
||
|
}
|
||
|
boolean isForceOver=false;
|
||
|
rs.execute("select creater,workflowid from workflow_requestbase where requestid = " + requestid_tmp);
|
||
|
rs.next();
|
||
|
String creater = rs.getString(1);
|
||
|
int workflowid_rs = rs.getInt(2);
|
||
|
|
||
|
weaver.workflow.monitor.MonitorDTO dto = Monitor.getMonitorInfo(user.getUID()+"",creater,workflowid_rs+"");
|
||
|
isForceOver = dto.getIsforceover();
|
||
|
|
||
|
if (isForceOver && !WfForceOver.isOver(requestid_tmp)) {
|
||
|
requestidsArr.add(requestids[i]);
|
||
|
WfForceOver.doForceOver(requestidsArr, request, response);
|
||
|
DoRepossessedCmd dor = new DoRepossessedCmd();
|
||
|
Map<String, String> data = dor.getWorkflowInfo(requestids[i]);
|
||
|
if(data.size() > 0){
|
||
|
dor.releaseNumber(Util.getIntValue(data.get("formid")), Util.getIntValue(data.get("workflowid")));
|
||
|
}
|
||
|
success++;
|
||
|
this.doRemind(requestid_tmp,workflowid_rs);
|
||
|
|
||
|
//no.2545225 强制归档需要触发节点附加操作,实现一键审批
|
||
|
try {
|
||
|
RequestManager requestManager = new RequestManager();
|
||
|
requestManager.setUser(user);
|
||
|
requestManager.setWorkflowid(workflowid_rs);
|
||
|
requestManager.setRequestid(requestid_tmp);
|
||
|
WorkflowComInfo wfComInfo = new WorkflowComInfo();
|
||
|
int formid = Util.getIntValue(wfComInfo.getFormId(workflowid_rs+""));
|
||
|
int isbill = Util.getIntValue(wfComInfo.getIsBill(workflowid_rs+""));
|
||
|
String sql2 = "select nodeid from workflow_flownode where workflowid = ? and nodetype = 3";
|
||
|
RecordSet recordSet = new RecordSet();
|
||
|
recordSet.executeQuery(sql2,workflowid_rs);
|
||
|
int nodeid = -1;
|
||
|
if(recordSet.next()) {
|
||
|
nodeid = recordSet.getInt("nodeid");
|
||
|
}
|
||
|
RequestCheckAddinRules requestCheckAddinRules = new RequestCheckAddinRules();
|
||
|
requestCheckAddinRules.resetParameter();
|
||
|
requestCheckAddinRules.setWorkflowid(workflowid_rs);
|
||
|
requestCheckAddinRules.setRequestid(requestid_tmp);
|
||
|
requestCheckAddinRules.setNodeid(nodeid);
|
||
|
requestCheckAddinRules.setObjid(nodeid);
|
||
|
requestCheckAddinRules.setObjtype(1);
|
||
|
requestCheckAddinRules.setIsbill(isbill);
|
||
|
requestCheckAddinRules.setFormid(formid);
|
||
|
requestCheckAddinRules.setIspreadd("0");
|
||
|
requestCheckAddinRules.setRequestManager(requestManager);
|
||
|
requestCheckAddinRules.checkAddinRules();
|
||
|
} catch (Exception e) {
|
||
|
e.printStackTrace();
|
||
|
apidatas.put("api_errormsg", "节点后附加操作执行失败!");
|
||
|
}
|
||
|
}else{
|
||
|
fail++;
|
||
|
}
|
||
|
}
|
||
|
apidatas.put("total", requestids.length);
|
||
|
apidatas.put("success", success);
|
||
|
apidatas.put("fail", fail);
|
||
|
}else{
|
||
|
apidatas.put("api_errormsg", "The parameters passed in are not valid");
|
||
|
}
|
||
|
return apidatas;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 流程监控强制归档
|
||
|
* @param requestId
|
||
|
* @param workflowId
|
||
|
*/
|
||
|
private void doRemind(int requestId,int workflowId){
|
||
|
RequestRemindBiz remindBiz = new RequestRemindBiz(user);
|
||
|
|
||
|
try{
|
||
|
WFManager wfManager = new WFManager();
|
||
|
wfManager.setWfid(workflowId);
|
||
|
wfManager.getWfInfo();
|
||
|
RecordSet rs = new RecordSet();
|
||
|
rs.executeQuery("select remindscope from workflow_base where id = ? ", workflowId);
|
||
|
rs.next();
|
||
|
int remindscope = Util.getIntValue(rs.getString("remindscope"),0);
|
||
|
if (remindscope ==1) {
|
||
|
remindBiz.requestRemind(requestId,workflowId,"", RemindTypeEnum.EMAIL,0);
|
||
|
} else {
|
||
|
|
||
|
String isArchiveNoRemind = wfManager.getIsArchiveNoRemind();
|
||
|
if("1".equals(isArchiveNoRemind)) return; //强制归档不需要提醒
|
||
|
|
||
|
String isSms = wfManager.getIsDefaultSmsRemind();
|
||
|
String isEmail = wfManager.getIsDefaultEmailRemind();
|
||
|
if("1".equals(isEmail) ){
|
||
|
remindBiz.requestRemind(requestId,workflowId,"", RemindTypeEnum.EMAIL,0);
|
||
|
}
|
||
|
if("1".equals(isSms)){
|
||
|
remindBiz.requestRemind(requestId,workflowId, "",RemindTypeEnum.SMS,0);
|
||
|
}
|
||
|
|
||
|
String archiveNoMsgAlert = wfManager.getArchiveNoMsgAlert();
|
||
|
String archiveNoMailAlert = wfManager.getArchiveNoMailAlert();
|
||
|
|
||
|
String messageType = wfManager.getMessageType();
|
||
|
String mailMessageType = wfManager.getMailMessageType();
|
||
|
|
||
|
if("1".equals(mailMessageType) && !"1".equals(archiveNoMailAlert)){
|
||
|
remindBiz.requestRemind(requestId,workflowId,"", RemindTypeEnum.EMAIL,0);
|
||
|
}
|
||
|
if(!"1".equals(archiveNoMsgAlert)){
|
||
|
if("2".equals(messageType)){
|
||
|
remindBiz.requestRemind(requestId,workflowId, "",RemindTypeEnum.SMS,0);
|
||
|
}
|
||
|
if("1".equals(messageType)){
|
||
|
remindBiz.requestRemind(requestId,workflowId,"", RemindTypeEnum.SMS,1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}catch (Exception e){
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public HttpServletRequest getRequest() {
|
||
|
return request;
|
||
|
}
|
||
|
|
||
|
public User getUser() {
|
||
|
return user;
|
||
|
}
|
||
|
@Override
|
||
|
public BizLogContext getLogContext() {
|
||
|
BizLogContext bizLogContext = new BizLogContext();
|
||
|
BizLogOperateType bizLogOperateType = BizLogOperateType.APPROVE;
|
||
|
bizLogContext.setDateObject(new Date());
|
||
|
bizLogContext.setUserid(user.getUID());
|
||
|
bizLogContext.setUsertype(Util.getIntValue(user.getLogintype()));
|
||
|
bizLogContext.setTargetId("monitor_archiving");
|
||
|
bizLogContext.setTargetName("流程强制归档");
|
||
|
bizLogContext.setLogType(BizLogType.WORKFLOW);
|
||
|
bizLogContext.setLogSmallType(BizLogSmallType4Workflow.WORKFLOW_APPROVE);
|
||
|
bizLogContext.setOperateType(bizLogOperateType);
|
||
|
bizLogContext.setClientIp(Util.null2String(Util.getIpAddr(request)));
|
||
|
bizLogContext.setParams(ParamUtil.request2Map(request));
|
||
|
bizLogContext.setDesc(String.format(user.getLastname() + "进行了流程强制归档操作"));
|
||
|
return bizLogContext;
|
||
|
}
|
||
|
}
|