复核审批流程归档动作,事权变更操作,流程自动提交

This commit is contained in:
dxfeng 2025-04-10 10:03:31 +08:00
parent 42bb66d19d
commit 3bf6ad29f6
7 changed files with 296 additions and 0 deletions

View File

@ -0,0 +1,12 @@
package com.api.secret.web;
import javax.ws.rs.Path;
/**
* @author:dxfeng
* @createTime: 2025/04/09
* @version: 1.0
*/
@Path("/secret/authority/change")
public class AuthorityChangeController extends com.engine.secret.web.AuthorityChangeController{
}

View File

@ -0,0 +1,19 @@
package com.engine.secret.service;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2025/04/09
* @version: 1.0
*/
public interface AuthorityChangeService {
/**
* 将审批事权移交至省级
*
* @param param
* @return
*/
Map<String, Object> delegateToProvincialAuthority(Map<String, Object> param);
}

View File

@ -0,0 +1,67 @@
package com.engine.secret.service.impl;
import com.engine.core.impl.Service;
import com.engine.secret.exception.CustomizeRunTimeException;
import com.engine.secret.service.AuthorityChangeService;
import com.engine.secret.util.FlowUtil;
import com.engine.secret.util.ModeUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2025/04/09
* @version: 1.0
*/
public class AuthorityChangeServiceImpl extends Service implements AuthorityChangeService {
@Override
public Map<String, Object> delegateToProvincialAuthority(Map<String, Object> param) {
RecordSet rs = new RecordSet();
String ids = Util.null2String(param.get("ids"));
if (StringUtils.isBlank(ids)) {
throw new CustomizeRunTimeException("请至少选择一条数据");
}
String customId = Util.null2String(param.get("customId"));
if (StringUtils.isBlank(customId)) {
throw new CustomizeRunTimeException("未获取到查询列表ID");
}
String modeTableName = ModeUtil.getTableNameByCustomId(customId);
rs.writeLog("ids==" + ids);
rs.writeLog("customId==" + customId);
rs.writeLog("modeTableName==" + modeTableName);
String options = user.getLastname() + "-自动提交流程-";
// 查询对应的流程,并更新
String[] split = ids.split(",");
for (String s : split) {
rs.writeLog("id==" + s);
// 更新事权类别为省级事权
rs.executeUpdate("update " + modeTableName + " set bmzzzgsqlb = ?,tjdqjd = ? where id =? ", 0, 1, s);
// 查询对应的requestId
rs.executeQuery("select requestId from " + modeTableName + " where id = ?", s);
if (rs.next()) {
String requestId = rs.getString("requestId");
rs.writeLog("requestId==" + requestId);
List<Integer> currentUserIds = FlowUtil.getCurrentUserIds(requestId);
if (CollectionUtils.isEmpty(currentUserIds)) {
throw new CustomizeRunTimeException("requestId[" + requestId + "],流程提交失败,未获取到当前节点处理人");
}
String submitResult = FlowUtil.submitWorkflowRequest(requestId, currentUserIds.get(0), options + DateUtil.getFullDate());
if (!"success".equals(submitResult)) {
throw new CustomizeRunTimeException("requestId[" + requestId + "],流程提交失败");
}
}
}
return new HashMap<>();
}
}

View File

@ -0,0 +1,69 @@
package com.engine.secret.util;
import com.alibaba.fastjson.JSON;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.workflow.webservices.WorkflowRequestInfo;
import weaver.workflow.webservices.WorkflowServiceImpl;
import java.util.ArrayList;
import java.util.List;
/**
* @author:dxfeng
* @createTime: 2025/04/09
* @version: 1.0
*/
public class FlowUtil {
/**
* 根据流程请求ID获取对应流程的表名
*
* @param requestId
* @return
*/
public static String getTableNameByRequestId(String requestId) {
RecordSet rs = new RecordSet();
rs.executeQuery("select a.tablename from workflow_bill a join workflow_base b on a.id = b.formid where b.id = ( select workflowid from workflow_requestbase where requestid = ?)", requestId);
if (rs.next()) {
return rs.getString("tablename");
}
return "";
}
/**
* 获取流程的当前处理人
*
* @param requestId
* @return
*/
public static List<Integer> getCurrentUserIds(String requestId) {
RecordSet rs = new RecordSet();
String sql = "select * from workflow_currentoperator where isremark = '0' and usertype = 0 and requestid=? order by id asc";
List<Integer> currentUserIds = new ArrayList();
rs.executeQuery(sql, requestId);
while (rs.next()) {
currentUserIds.add(Util.getIntValue(Util.null2String(rs.getString("userid"))));
}
return currentUserIds;
}
/**
* 提交流程到下一节点
*
* @param requestId
* @param creator
* @param opinions
* @return
*/
public static String submitWorkflowRequest(String requestId, int creator, String opinions) {
BaseBean bean = new BaseBean();
WorkflowServiceImpl workflowService = new WorkflowServiceImpl();
WorkflowRequestInfo wri = workflowService.getWorkflowRequest(Util.getIntValue(requestId, 0), creator, 0);
bean.writeLog("wri==" + JSON.toJSONString(wri));
return workflowService.submitWorkflowRequest(wri, Util.getIntValue(requestId, 0), creator, "submit", opinions);
}
}

View File

@ -422,5 +422,14 @@ public class ModeUtil {
return new String(c);
}
public static String getTableNameByCustomId(String customId) {
RecordSet rs = new RecordSet();
rs.executeQuery("select tablename from workflow_bill where id = (select formid from mode_customsearch where id = ?)", customId);
if (rs.next()) {
return rs.getString("tablename");
}
return "";
}
}

View File

@ -0,0 +1,39 @@
package com.engine.secret.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.secret.service.AuthorityChangeService;
import com.engine.secret.service.impl.AuthorityChangeServiceImpl;
import com.engine.secret.util.ResponseResult;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
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.Map;
/**
* @author:dxfeng
* @createTime: 2025/04/09
* @version: 1.0
*/
public class AuthorityChangeController {
public AuthorityChangeService getService(User user) {
return ServiceUtil.getService(AuthorityChangeServiceImpl.class, user);
}
@POST
@Path("/delegateToProvincialAuthority")
@Produces(MediaType.APPLICATION_JSON)
public String delegateToProvincialAuthority(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::delegateToProvincialAuthority, params);
}
}

View File

@ -0,0 +1,81 @@
package weaver.interfaces.secret.action;
import com.engine.secret.exception.CustomizeRunTimeException;
import com.engine.secret.util.FlowUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 审批复核 归档Action
*
* @author:dxfeng
* @createTime: 2025/04/09
* @version: 1.0
*/
public class ApprovalReviewEndAction implements Action {
RecordSet rs = new RecordSet();
@Override
public String execute(RequestInfo requestInfo) {
try {
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
Property[] properties = mainTableInfo.getProperty();
Map<String, String> mainDataMap = new HashMap<>();
for (Property property : properties) {
mainDataMap.put(property.getName(), property.getValue());
}
// 获取主流程ID
String mainRequestId = mainDataMap.get("zlcid");
if (StringUtils.isBlank(mainRequestId)) {
requestInfo.getRequestManager().setMessagecontent("未获取到主流程请求ID");
return FAILURE_AND_CONTINUE;
}
// 获取审批复核结论
String conclusion = mainDataMap.get("spfhjl");
// 更新主流程表单的审批复核结论
String tableNameByRequestId = FlowUtil.getTableNameByRequestId(mainRequestId);
if (StringUtils.isBlank(tableNameByRequestId)) {
requestInfo.getRequestManager().setMessagecontent("主流程表单名称获取异常,请确认");
return FAILURE_AND_CONTINUE;
}
String sql = "update " + tableNameByRequestId + " set spfhjl = ? where requestid = ?";
rs.writeLog("mainRequestId==" + mainRequestId);
rs.writeLog("conclusion==" + conclusion);
rs.writeLog("tableNameByRequestId==" + tableNameByRequestId);
rs.writeLog("sql==" + sql);
rs.executeUpdate(sql, conclusion, mainRequestId);
// 更新完成后自动提交流程到下一节点
rs.writeLog("mainRequestId==" + mainRequestId);
List<Integer> currentUserIds = FlowUtil.getCurrentUserIds(mainRequestId);
if (CollectionUtils.isEmpty(currentUserIds)) {
throw new CustomizeRunTimeException("requestId[" + mainRequestId + "],流程提交失败,未获取到当前节点处理人");
}
String options = requestInfo.getCreatorid() + "-自动提交流程-" + DateUtil.getFullDate();
String submitResult = FlowUtil.submitWorkflowRequest(mainRequestId, currentUserIds.get(0), options);
if (!"success".equals(submitResult)) {
throw new CustomizeRunTimeException("requestId[" + mainRequestId + "],流程提交失败");
}
return SUCCESS;
} catch (Exception e) {
rs.writeLog(e);
requestInfo.getRequestManager().setMessagecontent(e.getMessage());
return FAILURE_AND_CONTINUE;
}
}
}