|
|
@ -1,19 +1,15 @@ |
|
|
|
package com.yxt.anrui.oa.biz.oaform; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import com.yxt.anrui.oa.biz.oaform.flowable.*; |
|
|
|
import com.yxt.anrui.oa.biz.oamendapply.OaMendApply; |
|
|
|
import com.yxt.anrui.oa.biz.oamendapply.SubmitOaMendApplyDto; |
|
|
|
import com.yxt.anrui.oa.feign.base.BillNo; |
|
|
|
import com.yxt.anrui.oa.feign.base.Rule; |
|
|
|
import com.yxt.anrui.oa.feign.flowable.flow.BusinessVariables; |
|
|
|
import com.yxt.anrui.oa.feign.flowable.flow.FlowableFeign; |
|
|
|
import com.yxt.anrui.oa.feign.flowable.flow.ProcDefEnum; |
|
|
|
import com.yxt.anrui.oa.feign.flowable.flow.UpdateFlowFieldVo; |
|
|
|
import com.yxt.anrui.oa.feign.flowable.flow2.FlowDelegateQuery; |
|
|
|
import com.yxt.anrui.oa.feign.flowable.flow2.FlowFeign; |
|
|
@ -23,12 +19,14 @@ import com.yxt.anrui.oa.feign.flowable.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.anrui.oa.feign.message.MessageFeign; |
|
|
|
import com.yxt.anrui.oa.feign.message.MessageFlowVo; |
|
|
|
import com.yxt.anrui.oa.feign.message.MessageFlowableQuery; |
|
|
|
import com.yxt.anrui.oa.feign.portal.sysorganization.OrgVo; |
|
|
|
import com.yxt.anrui.oa.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.anrui.oa.feign.portal.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.anrui.oa.feign.portal.sysstafforg.OrgVo; |
|
|
|
import com.yxt.anrui.oa.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.oa.feign.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.oa.feign.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.oa.feign.sysuser.UserQuery; |
|
|
|
import com.yxt.anrui.oa.feign.sysuser.UserRoleQuery; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
@ -37,7 +35,6 @@ import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import org.apache.tomcat.util.threads.ThreadPoolExecutor; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
@ -81,7 +78,7 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
BeanUtil.copyProperties(dto, oaForm, "billNo", "orgSidPath"); |
|
|
|
try { |
|
|
|
// 获取组织信息,根据orgSidPath字段调用外部服务
|
|
|
|
OrgVo orgVo = sysStaffOrgFeign.getOrgByPath(dto.getOrgSidPath()).getData(); |
|
|
|
OrgVo orgVo = sysOrganizationFeign.getOrgByPath(dto.getOrgSidPath()).getData(); |
|
|
|
// 如果组织信息为空,返回失败信息
|
|
|
|
if (orgVo == null) { |
|
|
|
return rb.setMsg("未找到对应的组织信息"); |
|
|
@ -123,6 +120,12 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 详情初始化 |
|
|
|
* |
|
|
|
* @param sid |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<OaFormDetailsVo> fetchDetailsBySid(String sid) { |
|
|
|
ResultBean<OaFormDetailsVo> rb = ResultBean.fireFail(); |
|
|
|
OaFormDetailsVo detailsVo = baseMapper.fetchDetailsBySid(sid); |
|
|
@ -132,6 +135,12 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
return rb.success().setData(detailsVo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 分页列表 |
|
|
|
* |
|
|
|
* @param pq |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public PagerVo<OaFormVo> listPageVo(PagerQuery<OaFormQuery> pq) { |
|
|
|
OaFormQuery query = pq.getParams(); |
|
|
|
QueryWrapper<OaForm> qw = new QueryWrapper<>(); |
|
|
@ -141,6 +150,12 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除 |
|
|
|
* |
|
|
|
* @param sids |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean delAll(String[] sids) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
delBySids(sids); |
|
|
@ -164,20 +179,27 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
return baseMapper.updateFlowFiled(map); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean complete(BusinessVariables bv) { |
|
|
|
/** |
|
|
|
* 办理(同意) |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean complete(BusinessVariablesDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String formSid = bv.getFormVariables().get("formSid").toString(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(dto, bv); |
|
|
|
String businessSid = bv.getBusinessSid(); |
|
|
|
OaForm oaForm = fetchBySid(formSid); |
|
|
|
//添加网关
|
|
|
|
Map<String, Object> variables = bv.getFormVariables(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
SysOrganizationVo deptVo = sysOrganizationFeign.fetchBySid(oaForm.getDeptSid()).getData(); |
|
|
|
bv.setOrgSidPath(deptVo.getOrgSidPath()); |
|
|
|
bv.setModelId(oaForm.getProcDefId()); |
|
|
|
OaForm oaForm = fetchBySid(businessSid); |
|
|
|
SubmitDto submitDto = new SubmitDto(); |
|
|
|
BeanUtil.copyProperties(dto, submitDto); |
|
|
|
//构造参数
|
|
|
|
ResultBean<BusinessVariables> businessVariablesResultBean = getGatewayParameter(submitDto); |
|
|
|
if (!businessVariablesResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(businessVariablesResultBean.getMsg()); |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(businessVariablesResultBean.getData(), bv, "taskDefKey", "taskId"); |
|
|
|
bv.setInstanceId(oaForm.getProcInstId()); |
|
|
|
if (bv.getTaskId().equals(oaForm.getTaskId())) { |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowFeign.handleProsess(bv); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
@ -185,8 +207,7 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
} |
|
|
|
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|
|
|
OaFormFlowDto oaFormFlowDto = new OaFormFlowDto(); |
|
|
|
BeanUtil.copyProperties(ufVo, oaFormFlowDto, "sid"); |
|
|
|
oaFormFlowDto.setSid(formSid); |
|
|
|
BeanUtil.copyProperties(ufVo, oaFormFlowDto); |
|
|
|
updateFlow(oaFormFlowDto); |
|
|
|
if ("Event_end".equals(resultBean.getData().getTaskDefKey())) { |
|
|
|
|
|
|
@ -209,7 +230,7 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
ufVo.setProcDefId(oaForms.getProcDefId()); |
|
|
|
ufVo.setProcInsId(oaForms.getProcInstId()); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setAppMap((Map<String, Object>) bv.getFormVariables().get("app")); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName(oaForms.getFormType()); |
|
|
|
messageFlowableQuery.setMsgContent(oaForms.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
@ -227,36 +248,38 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取上一环节 |
|
|
|
* |
|
|
|
* @param query |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<List<NodeVo>> getPreviousNodesForReject(NodeQuery query) { |
|
|
|
ResultBean<List<NodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
//查询业务信息
|
|
|
|
OaForm oaForm = fetchBySid(query.getBusinessSid()); |
|
|
|
//网关
|
|
|
|
|
|
|
|
bv.setModelId(oaForm.getProcDefId()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<NodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), NodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取下一环节 |
|
|
|
* |
|
|
|
* @param query |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<List<NodeVo>> getNextNodesForSubmit(NodeQuery query) { |
|
|
|
ResultBean<List<NodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
//查询业务信息
|
|
|
|
OaForm oaForm = fetchBySid(query.getBusinessSid()); |
|
|
|
//网关
|
|
|
|
|
|
|
|
bv.setModelId(oaForm.getProcDefId()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
//=======================================
|
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
@ -264,31 +287,31 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean reject(TaskQuery query) { |
|
|
|
/** |
|
|
|
* 驳回 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean reject(TaskDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = query.getBusinessSid(); |
|
|
|
String businessSid = dto.getBusinessSid(); |
|
|
|
OaForm oaForm = fetchBySid(businessSid); |
|
|
|
if (oaForm == null) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
String businessTaskId = oaForm.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
if (StringUtils.isBlank(query.getComment())) { |
|
|
|
if (businessTaskId.equals(dto.getTaskId())) { |
|
|
|
if (StringUtils.isBlank(dto.getComment())) { |
|
|
|
return rb.setMsg("请填写意见"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
if (StringUtils.isBlank(dto.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
//网关
|
|
|
|
|
|
|
|
BeanUtil.copyProperties(dto, flowTaskVo); |
|
|
|
Map<String, Object> variables = dto.getFormVariables(); |
|
|
|
flowTaskVo.setValues(variables); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.taskReject(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
@ -316,7 +339,7 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
ufVo.setProcInsId(oaForms.getProcInstId()); |
|
|
|
ufVo.setProcDefId(oaForms.getProcDefId()); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setAppMap((Map<String, Object>) dto.getFormVariables().get("app")); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName(oaForms.getFormType()); |
|
|
|
ResultBean<List<LatestTaskVo>> listResultBean = flowTaskFeign.getLatestTasks(oaForms.getProcInstId()); |
|
|
@ -340,17 +363,23 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean revokeProcess(TaskQuery query) { |
|
|
|
/** |
|
|
|
* 撤回 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean revokeProcess(TaskDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
if (StringUtils.isBlank(dto.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
OaForm oaForm = fetchBySid(query.getBusinessSid()); |
|
|
|
OaForm oaForm = fetchBySid(dto.getBusinessSid()); |
|
|
|
String businessTaskId = oaForm.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
if (businessTaskId.equals(dto.getTaskId())) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
BeanUtil.copyProperties(dto, flowTaskVo); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.revokeProcess(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
@ -364,23 +393,29 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
return rb.setMsg("操作失败,提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean breakProcess(TaskQuery query) { |
|
|
|
/** |
|
|
|
* 终止 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean breakProcess(TaskDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getInstanceId())) { |
|
|
|
return rb.setMsg("参数错误:instanceId"); |
|
|
|
if (StringUtils.isBlank(dto.getProcInsId())) { |
|
|
|
return rb.setMsg("参数错误:procInsId"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
if (StringUtils.isBlank(dto.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(query.getComment())) { |
|
|
|
if (StringUtils.isBlank(dto.getComment())) { |
|
|
|
return rb.setMsg("请填写意见"); |
|
|
|
} |
|
|
|
OaForm oaForm = fetchBySid(query.getBusinessSid()); |
|
|
|
OaForm oaForm = fetchBySid(dto.getBusinessSid()); |
|
|
|
String businessTaskId = oaForm.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (query.getUserSid().equals(oaForm.getCreateBySid())) { |
|
|
|
if (dto.getUserSid().equals(oaForm.getCreateBySid())) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
BeanUtil.copyProperties(dto, flowTaskVo); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
@ -390,9 +425,9 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
updateFlow(oaFormFlowDto); |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
if (businessTaskId.equals(dto.getTaskId())) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
BeanUtil.copyProperties(dto, flowTaskVo); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
@ -407,63 +442,52 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean delegate(DelegateQuery query) { |
|
|
|
/** |
|
|
|
* 加签 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean delegate(DelegateDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FlowDelegateQuery delegateQuery = new FlowDelegateQuery(); |
|
|
|
BeanUtil.copyProperties(query, delegateQuery); |
|
|
|
BeanUtil.copyProperties(dto, delegateQuery); |
|
|
|
delegateQuery.setInstanceId(dto.getProcInsId()); |
|
|
|
flowFeign.delegate(delegateQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean assignTask(DelegateQuery query) { |
|
|
|
/** |
|
|
|
* 转办 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean assignTask(DelegateDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FlowDelegateQuery delegateQuery = new FlowDelegateQuery(); |
|
|
|
BeanUtil.copyProperties(query, delegateQuery); |
|
|
|
BeanUtil.copyProperties(dto, delegateQuery); |
|
|
|
delegateQuery.setInstanceId(dto.getProcInsId()); |
|
|
|
flowFeign.assignTask(delegateQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 更新流程名称和标题 |
|
|
|
* |
|
|
|
* @param oaForm |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public int updateFormType(OaForm oaForm) { |
|
|
|
return baseMapper.updateById(oaForm); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean submit1(BusinessVariables bv) { |
|
|
|
String businessSid = bv.getBusinessSid(); |
|
|
|
//启动流程
|
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowFeign.startProcess(bv); |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
OaFormFlowDto oaFormFlowDto = new OaFormFlowDto(); |
|
|
|
BeanUtil.copyProperties(ufVo, oaFormFlowDto, "sid"); |
|
|
|
oaFormFlowDto.setSid(businessSid); |
|
|
|
updateFlow(oaFormFlowDto); |
|
|
|
OaForm oaForm = fetchBySid(businessSid); |
|
|
|
try { |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() |
|
|
|
.setNameFormat("demo-pool-%d").build(); |
|
|
|
ExecutorService pool = new ThreadPoolExecutor(2, 100, |
|
|
|
0L, TimeUnit.MILLISECONDS, |
|
|
|
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); |
|
|
|
Future future1 = pool.submit(() -> { |
|
|
|
//极光推送
|
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap((Map<String, Object>) bv.getFormVariables().get("app")); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName(oaForm.getFormType()); |
|
|
|
messageFlowableQuery.setMsgContent(oaForm.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle(oaForm.getFormType()); |
|
|
|
messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return voResultBean; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean submit(SubmitDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ResultBean<BusinessVariables> businessVariablesResultBean = getGatewayParameter(dto); |
|
|
@ -478,7 +502,7 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowFeign.startProcess(bv); |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
OaFormFlowDto oaFormFlowDto = new OaFormFlowDto(); |
|
|
|
BeanUtil.copyProperties(ufVo, oaFormFlowDto, "sid"); |
|
|
|
BeanUtil.copyProperties(ufVo, oaFormFlowDto); |
|
|
|
updateFlow(oaFormFlowDto); |
|
|
|
try { |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() |
|
|
@ -504,23 +528,33 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
} |
|
|
|
return voResultBean; |
|
|
|
} else if (r == 2) { |
|
|
|
bv.setTaskId(oaForm.getTaskId()); |
|
|
|
bv.setTaskDefKey(oaForm.getNodeId()); |
|
|
|
bv.setComment("重新提交"); |
|
|
|
bv.setInstanceId(oaForm.getProcInstId()); |
|
|
|
return complete(bv); |
|
|
|
BusinessVariablesDto businessVariablesDto = new BusinessVariablesDto(); |
|
|
|
BeanUtil.copyProperties(bv, businessVariablesDto); |
|
|
|
businessVariablesDto.setProcInsId(oaForm.getProcInstId()); |
|
|
|
businessVariablesDto.setTaskId(oaForm.getTaskId()); |
|
|
|
businessVariablesDto.setTaskDefKey(oaForm.getNodeId()); |
|
|
|
businessVariablesDto.setComment("重新提交"); |
|
|
|
return complete(businessVariablesDto); |
|
|
|
} |
|
|
|
return rb; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交锁 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private synchronized int submitBusinessData(SubmitDto dto) { |
|
|
|
int r = 0; |
|
|
|
if (dto.isNew()) { |
|
|
|
OaForm oaForm = fetchBySid(dto.getBusinessSid()); |
|
|
|
if (StringUtils.isBlank(oaForm.getTaskId()) && StringUtils.isBlank(dto.getNextNodeSid())) { |
|
|
|
//新提交
|
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
} else if (StringUtils.isNotBlank(oaForm.getTaskId()) && oaForm.getTaskId().equals(dto.getNextNodeSid())) { |
|
|
|
//二次提交//只有数据一致的时候才能进行下一步
|
|
|
|
r = 2; |
|
|
|
|
|
|
|
} |
|
|
|
return r; |
|
|
|
} |
|
|
@ -541,7 +575,11 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
SysOrganizationVo deptVo = sysOrganizationFeign.fetchBySid(oaForm.getDeptSid()).getData(); |
|
|
|
bv.setOrgSidPath(deptVo.getOrgSidPath()); |
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(dto.getProcDefId()); |
|
|
|
if (StringUtils.isBlank(oaForm.getProcDefId())) { |
|
|
|
bv.setModelId(dto.getProcDefId()); |
|
|
|
} else { |
|
|
|
bv.setModelId(oaForm.getProcDefId()); |
|
|
|
} |
|
|
|
int rule = dto.getRule(); |
|
|
|
if (rule == OaFormRuleEnum.DIRECTLY_UNDER.getRule()) { |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(oaForm.getDeptSid()).getData(); |
|
|
@ -551,9 +589,56 @@ public class OaFormService extends MybatisBaseService<OaFormMapper, OaForm> { |
|
|
|
bv.setNextNodeUserSids(organizationVo.getManagerSid()); |
|
|
|
|
|
|
|
} else if (rule == OaFormRuleEnum.INSTITUTION.getRule()) { |
|
|
|
//获取本机构链(含集团、事业部、分公司部门)中角色的用户(角色sid,发起人orgsidPath)
|
|
|
|
NodeQuery query = new NodeQuery(); |
|
|
|
query.setBusinessSid(dto.getBusinessSid()); |
|
|
|
query.setTaskDefKey(oaForm.getNodeId()); |
|
|
|
ResultBean<List<NodeVo>> resultBean = getNextNodesForSubmit(query); |
|
|
|
List<NodeVo> voList = resultBean.getData(); |
|
|
|
List<String> candidateGroups = voList.get(0).getCandidateGroups(); |
|
|
|
UserQuery userQuery = new UserQuery(); |
|
|
|
userQuery.setRoleSid(candidateGroups.get(0)); |
|
|
|
userQuery.setOrgSidPath(bv.getOrgSidPath()); |
|
|
|
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData(); |
|
|
|
StringBuilder nextNodeUserSids = new StringBuilder(); |
|
|
|
if (sysUserVos.size() > 0) { |
|
|
|
for (SysUserVo sysUserVo : sysUserVos) { |
|
|
|
String sid = sysUserVo.getSid(); |
|
|
|
nextNodeUserSids.append(sid).append(","); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(nextNodeUserSids)) { |
|
|
|
bv.setNextNodeUserSids(""); |
|
|
|
} else { |
|
|
|
String substring = nextNodeUserSids.substring(0, nextNodeUserSids.lastIndexOf(",")); |
|
|
|
bv.setNextNodeUserSids(substring); |
|
|
|
} |
|
|
|
|
|
|
|
} else if (rule == OaFormRuleEnum.OTHER_INSTITUTION.getRule()) { |
|
|
|
|
|
|
|
//获取其他机构链角色的用户(角色sid,机构sid])
|
|
|
|
NodeQuery query = new NodeQuery(); |
|
|
|
query.setBusinessSid(dto.getBusinessSid()); |
|
|
|
query.setTaskDefKey(oaForm.getNodeId()); |
|
|
|
ResultBean<List<NodeVo>> resultBean = getNextNodesForSubmit(query); |
|
|
|
List<NodeVo> voList = resultBean.getData(); |
|
|
|
List<String> candidateGroups = voList.get(0).getCandidateGroups(); |
|
|
|
UserRoleQuery userRoleQuery = new UserRoleQuery(); |
|
|
|
userRoleQuery.setRoleSid(candidateGroups.get(0)); |
|
|
|
userRoleQuery.setOrgSid(dto.getOrgSid()); |
|
|
|
List<SysUserVo> sysUserVos = sysUserFeign.getOtherOrgRoleUser(userRoleQuery).getData(); |
|
|
|
StringBuilder nextNodeUserSids = new StringBuilder(); |
|
|
|
if (sysUserVos.size() > 0) { |
|
|
|
for (SysUserVo sysUserVo : sysUserVos) { |
|
|
|
String sid = sysUserVo.getSid(); |
|
|
|
nextNodeUserSids.append(sid).append(","); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(nextNodeUserSids)) { |
|
|
|
bv.setNextNodeUserSids(""); |
|
|
|
} else { |
|
|
|
String substring = nextNodeUserSids.substring(0, nextNodeUserSids.lastIndexOf(",")); |
|
|
|
bv.setNextNodeUserSids(substring); |
|
|
|
} |
|
|
|
} else { |
|
|
|
bv.setNextNodeUserSids(""); |
|
|
|
} |
|
|
|