Browse Source

设置自动转办添加抄送

zhanglei
dimengzhe 2 years ago
parent
commit
7bcd947002
  1. 7
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java
  2. 119
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowRest.java
  3. 141
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowService.java
  4. 2
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentMapper.java
  5. 4
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentMapper.xml
  6. 4
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentService.java

7
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java

@ -205,6 +205,13 @@ public class FlowableRest implements FlowableFeign {
if (processVariables.containsKey("sendRecommendSid")) {//增加的其他的抄送人
userSids.append(processVariables.get("sendRecommendSid").toString()).append(",");
}
//查询是否有设置转办的,抄送给设置转办人员
List<String> zbUserSids = processCommentService.selectByIdAndComment("转办",bv.getInstanceId());
zbUserSids.removeAll(Collections.singleton(null));
if(!zbUserSids.isEmpty()){
String zbUser = String.join(",",zbUserSids);
userSids.append(zbUser).append(",");
}
userSids.deleteCharAt(userSids.length() - 1);
mfq.setUserSids(userSids.toString());
mfq.setOrgPath(createrOrgPath);

119
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowRest.java

@ -44,19 +44,9 @@ public class FlowRest implements FlowFeign {
@Autowired
private FlowService flowService;
@Autowired
private SysFlowccFeign sysFlowccFeign;
@Autowired
private SysUserFeign sysUserFeign;
@Autowired
protected HistoryService historyService;
@Autowired
private ProcessService processService;
@Autowired
private MessageFeign messageFeign;
private SysUserFeign sysUserFeign;
@Override
public ResultBean<UpdateFlowFieldVo> startProcess(BusinessVariables bv) {
@ -99,7 +89,7 @@ public class FlowRest implements FlowFeign {
UpdateFlowFieldVo ufVo = updateFlowFieldVoResultBean.getData();
ufVo.setTaskId(bv.getTaskId());
map.put("uff", ufVo);
cc(map, bv.getTaskDefKey());
flowService.cc(map, bv.getTaskDefKey());
});
} catch (Exception e) {
e.printStackTrace();
@ -110,110 +100,5 @@ public class FlowRest implements FlowFeign {
return updateFlowFieldVoResultBean;
}
/**
* 流程抄送的功能
*
* @param map
* @return
*/
public ResultBean cc(Map<String, Object> map, String taskDefKey) {
ResultBean rb = ResultBean.fireFail();
log.info("FlowableRest-cc:{}", JSONObject.toJSONString(map));
Object bv1 = map.get("bv");
BusinessVariables bv = new BusinessVariables();
BeanUtil.copyProperties(bv1, bv);
Object uff1 = map.get("uff");
UpdateFlowFieldVo uff = new UpdateFlowFieldVo();
BeanUtil.copyProperties(uff1, uff);
uff.setTaskDefKey(taskDefKey);
//流程定义的id
String modelId = bv.getModelId();
//将modelId根据冒号:分成三部分,取第一部分作为key
List<String> stringList = Arrays.asList(modelId.split(":"));
modelId = stringList.get(0);
//抄送的角色的sid
ResultBean<SysFlowccVo> roleSidByModelId = sysFlowccFeign.getRoleSidByModelId(modelId);
//组织机构sid
String orgSidPath = bv.getOrgSidPath();
if (roleSidByModelId.getData() == null) {
log.info("抄送失败,没有配置对应的角色!");
return rb.setMsg("抄送失败,没有配置对应的角色!");
}
SysFlowccVo data = roleSidByModelId.getData();
if (StringUtils.isBlank(data.getRoleSid())) {
log.info("抄送失败,没有配置对应的角色!");
return rb.setMsg("抄送失败,没有配置对应的角色!");
}
List<String> list = Arrays.asList(data.getRoleSid().split(","));
UserByRolesAndOrgQuery userQuery = new UserByRolesAndOrgQuery();
userQuery.setRoleSids(list);
userQuery.setOrgSidPath(orgSidPath);
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRoles(userQuery).getData();
if (sysUserVos == null || sysUserVos.size() < 1) {
log.info("抄送失败,没有用户!");
return rb.setMsg("抄送失败,没有用户!");
}
StringBuilder userName = new StringBuilder();
StringBuilder userSids = new StringBuilder();
sysUserVos.forEach(f -> {
userName.append(f.getName()).append(",");
userSids.append(f.getSid()).append(",");
});
//抄送的业务逻辑
MessageFlowableQuery mfq = new MessageFlowableQuery();
MessageFlowVo messageFlowVo = new MessageFlowVo();
BeanUtil.copyProperties(uff, messageFlowVo);
mfq.setUfVo(messageFlowVo);
//移动端的参数
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery()
.includeProcessVariables().taskId(bv.getTaskId()).singleResult();
if (historicTaskInstance == null) {
log.info("抄送失败:没有获取到业务参数!");
return rb.setMsg("抄送失败!");
}
Map<String, Object> processVariables = historicTaskInstance.getProcessVariables();
String createrOrgPath = (String) processVariables.get("createrOrgPath");
if (historicTaskInstance == null) {
log.info("抄送失败:没有获取到业务参数!");
return rb.setMsg("抄送失败!");
}
Map<String, Object> app = new HashMap<>();
if (processVariables.get("app") != null) {
app = (Map<String, Object>) processVariables.get("app");
}
log.info("抄送方法-historicTaskInstance:{}", JSONObject.toJSONString(historicTaskInstance));
mfq.setAppMap(app);
mfq.setBusinessSid(bv.getBusinessSid());
mfq.setMsgContent("系统抄送的流程审批,请查看");
// act_re_procdef
Map<String, String> process = processService.getProcessDefByDefId(historicTaskInstance.getProcessDefinitionId());
log.info("抄送成功-process:{}", process);
if (process == null) {
log.info("抄送失败,流程定义不存在!");
return rb.setMsg("抄送失败,流程定义不存在!");
}
mfq.setModuleName(process.get("NAME_"));
if (processVariables.containsKey("orderNames")) {
mfq.setMsgTitle(processVariables.get("orderNames").toString());
} else {
mfq.setMsgTitle(process.get("NAME_"));
}
if (processVariables.containsKey("sendRecommendSid")) {//增加的其他的抄送人
userSids.append(processVariables.get("sendRecommendSid").toString()).append(",");
}
userSids.deleteCharAt(userSids.length() - 1);
mfq.setUserSids(userSids.toString());
mfq.setOrgPath(createrOrgPath);
ResultBean<String> resultBean = messageFeign.pushMessageCC(mfq);
log.info("抄送成功:{}", userName.toString());
log.info("抄送成功-resultBean:{}", resultBean);
if (!resultBean.getSuccess()) {
log.info("抄送失败,同送消息异常!:{}", JSONObject.toJSONString(resultBean));
return rb.setMsg("抄送失败,同送消息异常!");
}
return rb.success().setMsg("抄送" + userName.toString() + "成功!");
}
}

141
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowService.java

@ -1,5 +1,6 @@
package com.yxt.anrui.flowable.biz.flow2;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -12,16 +13,19 @@ import com.yxt.anrui.flowable.api.processcomment.ProcessCommentDto;
import com.yxt.anrui.flowable.api.utils.ProcDefEnum;
import com.yxt.anrui.flowable.biz.flowtask.FlowTaskService;
import com.yxt.anrui.flowable.biz.process.ExpressionCmd;
import com.yxt.anrui.flowable.biz.process.ProcessService;
import com.yxt.anrui.flowable.biz.processcomment.ProcessCommentService;
import com.yxt.anrui.flowable.common.ProcessConstants;
import com.yxt.anrui.flowable.feign.MessageFeign;
import com.yxt.anrui.flowable.feign.form.MessageFlowVo;
import com.yxt.anrui.flowable.feign.form.MessageFlowableQuery;
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables;
import com.yxt.anrui.portal.api.sysflowableconfig.SysFlowableConfigFeign;
import com.yxt.anrui.portal.api.sysflowableconfig.SysFlowableConfigQuery;
import com.yxt.anrui.portal.api.sysflowableconfig.SysFlowableConfigVvo;
import com.yxt.anrui.portal.api.sysuser.SysUserFeign;
import com.yxt.anrui.portal.api.sysuser.SysUserVo;
import com.yxt.anrui.portal.api.sysuser.UserQuery;
import com.yxt.anrui.portal.api.sysuser.UserssQuery;
import com.yxt.anrui.portal.api.sysflowcc.SysFlowccFeign;
import com.yxt.anrui.portal.api.sysflowcc.SysFlowccVo;
import com.yxt.anrui.portal.api.sysuser.*;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.result.ResultBean;
@ -33,6 +37,7 @@ import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.DelegationState;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -70,6 +75,17 @@ public class FlowService extends MybatisBaseService<FlowMapper, Flowable> {
@Autowired
private ProcessCommentService processCommentService;
@Autowired
protected HistoryService historyService;
@Autowired
private ProcessService processService;
@Autowired
private MessageFeign messageFeign;
@Autowired
private SysFlowccFeign sysFlowccFeign;
public ResultBean<String> getNextNodeUser(BusinessVariables bv) {
ResultBean<String> rb = ResultBean.fireFail();
//根据业务参数取流程流转的环节 信息
@ -121,7 +137,6 @@ public class FlowService extends MybatisBaseService<FlowMapper, Flowable> {
map.put("candidateGroups", candidateGroups);
list.add(map);
}
// List<Map<String,Object>> list= JSON.parseObject(JSON.toJSONString(flowElements), new TypeReference<List<Map<String,Object>>>() {});
return rb.setData(list);
}
@ -301,7 +316,7 @@ public class FlowService extends MybatisBaseService<FlowMapper, Flowable> {
updateFlowFieldVo.setTaskDefKey(vo.getTaskDefKey());
updateFlowFieldVo.setProcDefId(bv.getModelId());
updateFlowFieldVo.setSid(bv.getBusinessSid());
rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功");
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功");
}
}
if (bv.getUserSid().equals(nextNodeUserSids)) {
@ -326,7 +341,7 @@ public class FlowService extends MybatisBaseService<FlowMapper, Flowable> {
updateFlowFieldVo.setTaskDefKey(vo.getTaskDefKey());
updateFlowFieldVo.setProcDefId(bv.getModelId());
updateFlowFieldVo.setSid(bv.getBusinessSid());
rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功");
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功");
}
}
updateFlowFieldVo.setProcInsId(task.getProcessInstanceId());
@ -586,7 +601,119 @@ public class FlowService extends MybatisBaseService<FlowMapper, Flowable> {
}
return rb.success().setData(nextNodeUserSids_);
}
}
/**
* 流程抄送的功能
*
* @param map
* @return
*/
public ResultBean cc(Map<String, Object> map, String taskDefKey) {
ResultBean rb = ResultBean.fireFail();
log.info("FlowableRest-cc:{}", JSONObject.toJSONString(map));
Object bv1 = map.get("bv");
BusinessVariables bv = new BusinessVariables();
BeanUtil.copyProperties(bv1, bv);
Object uff1 = map.get("uff");
UpdateFlowFieldVo uff = new UpdateFlowFieldVo();
BeanUtil.copyProperties(uff1, uff);
uff.setTaskDefKey(taskDefKey);
//流程定义的id
String modelId = bv.getModelId();
//将modelId根据冒号:分成三部分,取第一部分作为key
List<String> stringList = Arrays.asList(modelId.split(":"));
modelId = stringList.get(0);
//抄送的角色的sid
ResultBean<SysFlowccVo> roleSidByModelId = sysFlowccFeign.getRoleSidByModelId(modelId);
//组织机构sid
String orgSidPath = bv.getOrgSidPath();
if (roleSidByModelId.getData() == null) {
log.info("抄送失败,没有配置对应的角色!");
return rb.setMsg("抄送失败,没有配置对应的角色!");
}
SysFlowccVo data = roleSidByModelId.getData();
if (StringUtils.isBlank(data.getRoleSid())) {
log.info("抄送失败,没有配置对应的角色!");
return rb.setMsg("抄送失败,没有配置对应的角色!");
}
List<String> list = Arrays.asList(data.getRoleSid().split(","));
UserByRolesAndOrgQuery userQuery = new UserByRolesAndOrgQuery();
userQuery.setRoleSids(list);
userQuery.setOrgSidPath(orgSidPath);
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRoles(userQuery).getData();
if (sysUserVos == null || sysUserVos.size() < 1) {
log.info("抄送失败,没有用户!");
return rb.setMsg("抄送失败,没有用户!");
}
StringBuilder userName = new StringBuilder();
StringBuilder userSids = new StringBuilder();
sysUserVos.forEach(f -> {
userName.append(f.getName()).append(",");
userSids.append(f.getSid()).append(",");
});
//抄送的业务逻辑
MessageFlowableQuery mfq = new MessageFlowableQuery();
MessageFlowVo messageFlowVo = new MessageFlowVo();
BeanUtil.copyProperties(uff, messageFlowVo);
mfq.setUfVo(messageFlowVo);
//移动端的参数
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery()
.includeProcessVariables().taskId(bv.getTaskId()).singleResult();
if (historicTaskInstance == null) {
log.info("抄送失败:没有获取到业务参数!");
return rb.setMsg("抄送失败!");
}
Map<String, Object> processVariables = historicTaskInstance.getProcessVariables();
String createrOrgPath = (String) processVariables.get("createrOrgPath");
if (historicTaskInstance == null) {
log.info("抄送失败:没有获取到业务参数!");
return rb.setMsg("抄送失败!");
}
Map<String, Object> app = new HashMap<>();
if (processVariables.get("app") != null) {
app = (Map<String, Object>) processVariables.get("app");
}
log.info("抄送方法-historicTaskInstance:{}", JSONObject.toJSONString(historicTaskInstance));
mfq.setAppMap(app);
mfq.setBusinessSid(bv.getBusinessSid());
mfq.setMsgContent("系统抄送的流程审批,请查看");
// act_re_procdef
Map<String, String> process = processService.getProcessDefByDefId(historicTaskInstance.getProcessDefinitionId());
log.info("抄送成功-process:{}", process);
if (process == null) {
log.info("抄送失败,流程定义不存在!");
return rb.setMsg("抄送失败,流程定义不存在!");
}
mfq.setModuleName(process.get("NAME_"));
if (processVariables.containsKey("orderNames")) {
mfq.setMsgTitle(processVariables.get("orderNames").toString());
} else {
mfq.setMsgTitle(process.get("NAME_"));
}
if (processVariables.containsKey("sendRecommendSid")) {//增加的其他的抄送人
userSids.append(processVariables.get("sendRecommendSid").toString()).append(",");
}
//查询是否有设置转办的,抄送给设置转办人员
List<String> zbUserSids = processCommentService.selectByIdAndComment("转办",bv.getInstanceId());
zbUserSids.removeAll(Collections.singleton(null));
if(!zbUserSids.isEmpty()){
String zbUser = String.join(",",zbUserSids);
userSids.append(zbUser).append(",");
}
userSids.deleteCharAt(userSids.length() - 1);
mfq.setUserSids(userSids.toString());
mfq.setOrgPath(createrOrgPath);
ResultBean<String> resultBean = messageFeign.pushMessageCC(mfq);
log.info("抄送成功:{}", userName.toString());
log.info("抄送成功-resultBean:{}", resultBean);
if (!resultBean.getSuccess()) {
log.info("抄送失败,同送消息异常!:{}", JSONObject.toJSONString(resultBean));
return rb.setMsg("抄送失败,同送消息异常!");
}
return rb.success().setMsg("抄送" + userName.toString() + "成功!");
}
}

2
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentMapper.java

@ -69,4 +69,6 @@ public interface ProcessCommentMapper extends BaseMapper<ProcessComment> {
ProcessComment fetchBySid(@Param("sid")String sid);
void insertByDto(ProcessCommentDto dto);
List<String> selectByIdAndComment(@Param("comment") String comment, @Param("instanceId") String instanceId);
}

4
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentMapper.xml

@ -17,4 +17,8 @@
insert into `process_comment` ( `sid`, `reviewer`, `reviewerSid`, `time`, `content`, `processId`, `processInstSid`,processFile)
values(#{sid},#{reviewer},#{reviewerSid},#{time},#{content},#{processId},#{processInstSid},#{processFile});
</insert>
<select id="selectByIdAndComment" resultType="java.lang.String">
select reviewerSid from process_comment where content like concat('%',#{comment}) and processId = #{instanceId}
</select>
</mapper>

4
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentService.java

@ -135,4 +135,8 @@ public class ProcessCommentService extends MybatisBaseService<ProcessCommentMapp
}
return commentList;
}
public List<String> selectByIdAndComment(String comment, String instanceId) {
return baseMapper.selectByIdAndComment(comment, instanceId);
}
}
Loading…
Cancel
Save