新增功能:通知消息支持跳转
This commit is contained in:
parent
be042a94b0
commit
c645e0f177
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE `sys_notice`
|
||||
ADD COLUMN `apply_id` varchar(255) NULL COMMENT '通知来源id',
|
||||
ADD COLUMN `apply_state` int NULL COMMENT '通知来源状态';
|
|
@ -1,11 +1,14 @@
|
|||
package io.renren.common.aspect;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import io.renren.common.annotation.ActivitiNoticeOperation;
|
||||
import io.renren.modules.notice.dto.SysNoticeDTO;
|
||||
import io.renren.modules.notice.enums.NoticeStatusEnum;
|
||||
import io.renren.modules.notice.service.SysNoticeService;
|
||||
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
|
||||
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||
import io.renren.modules.processForm.service.impl.TAbilityApplicationServiceImpl;
|
||||
import io.renren.modules.resource.service.ResourceService;
|
||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||
import io.renren.modules.sys.dto.SysRoleDTO;
|
||||
|
@ -17,6 +20,7 @@ import org.activiti.engine.delegate.DelegateExecution;
|
|||
import org.activiti.engine.delegate.DelegateTask;
|
||||
import org.activiti.engine.delegate.ExecutionListener;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import org.apache.commons.collections.MultiMap;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.After;
|
||||
|
@ -57,6 +61,8 @@ public class ActivitiNoticeAspect {
|
|||
private SysDeptService sysDeptService;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private TAbilityApplicationService tAbilityApplicationService;
|
||||
|
||||
private Set<String> work = new CopyOnWriteArraySet<>();
|
||||
|
||||
|
@ -136,14 +142,15 @@ public class ActivitiNoticeAspect {
|
|||
} else if (kv.containsKey("_id")) {
|
||||
key = kv.getOrDefault("_id", "").toString();
|
||||
}
|
||||
final List<TAbilityApplicationDTO> tAbilityApplicationDTOList=kv.containsKey("tAbilityApplicationDTOList") ? (List<TAbilityApplicationDTO>) kv.get("tAbilityApplicationDTOList") : null;
|
||||
final StringBuilder resourceName = new StringBuilder();
|
||||
if (kv.containsKey("resourceDTO")) {
|
||||
resourceName.append("'");
|
||||
resourceName.append(((Map) kv.get("resourceDTO")).get("name"));
|
||||
resourceName.append("'");
|
||||
} else if (kv.containsKey("tAbilityApplicationDTOList")) {
|
||||
} else if (tAbilityApplicationDTOList != null) {
|
||||
resourceName.append("'");
|
||||
resourceName.append(((List<TAbilityApplicationDTO>) kv.get("tAbilityApplicationDTOList")).get(0).getTitle());
|
||||
resourceName.append(tAbilityApplicationDTOList.get(0).getTitle());
|
||||
resourceName.append("'");
|
||||
}
|
||||
final String workKey = TaskListener.EVENTNAME_COMPLETE + key;
|
||||
|
@ -186,8 +193,20 @@ public class ActivitiNoticeAspect {
|
|||
CompletableFuture.runAsync(() -> { // 发起人
|
||||
SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator));
|
||||
String content = "【通知】" + userDTO.getRealName() + ",您发起的" + resourceName + activitiNoticeOperation.process() + " " + activitiNoticeOperation.value() + "节点" + finalResult;
|
||||
Integer type=10;
|
||||
if("能力申请流程".equals(activitiNoticeOperation.process())){
|
||||
type=0;
|
||||
}else if("能力资源上架".equals(activitiNoticeOperation.process())){
|
||||
type=2;
|
||||
}else if("能力资源下架".equals(activitiNoticeOperation.process())){
|
||||
type=4;
|
||||
}else if("能力需求申请".equals(activitiNoticeOperation.process())){
|
||||
type=6;
|
||||
}else if("需求评论审核流程".equals(activitiNoticeOperation.process())){
|
||||
type=8;
|
||||
}
|
||||
SysNoticeDTO dto = new SysNoticeDTO();
|
||||
dto.setType(2);
|
||||
dto.setType(type);
|
||||
dto.setTitle("流程节点系统通知");
|
||||
dto.setContent(content); // 通知内容
|
||||
dto.setReceiverType(1);
|
||||
|
@ -198,6 +217,8 @@ public class ActivitiNoticeAspect {
|
|||
dto.setCreator(sysUserService.getByUsername("admin").getId());
|
||||
dto.setCreateDate(new Date());
|
||||
dto.setFrom("通知");
|
||||
dto.setApplyId(tAbilityApplicationDTOList.get(0).getApplyFlag());
|
||||
dto.setApplyState(0);
|
||||
sysNoticeService.save(dto);
|
||||
}, EXECUTOR);
|
||||
} catch (Exception e) {
|
||||
|
@ -231,14 +252,15 @@ public class ActivitiNoticeAspect {
|
|||
} else if (kv.containsKey("_id")) {
|
||||
key = kv.getOrDefault("_id", "").toString();
|
||||
}
|
||||
final List<TAbilityApplicationDTO> tAbilityApplicationDTOList=kv.containsKey("tAbilityApplicationDTOList") ? (List<TAbilityApplicationDTO>) kv.get("tAbilityApplicationDTOList") : null;
|
||||
final StringBuilder resourceName = new StringBuilder();
|
||||
if (kv.containsKey("resourceDTO")) {
|
||||
resourceName.append("'");
|
||||
resourceName.append(((Map) kv.get("resourceDTO")).get("name"));
|
||||
resourceName.append("'");
|
||||
} else if (kv.containsKey("tAbilityApplicationDTOList")) {
|
||||
} else if (tAbilityApplicationDTOList != null) {
|
||||
resourceName.append("'");
|
||||
resourceName.append(((List<TAbilityApplicationDTO>) kv.get("tAbilityApplicationDTOList")).get(0).getTitle());
|
||||
resourceName.append(tAbilityApplicationDTOList.get(0).getTitle());
|
||||
resourceName.append("'");
|
||||
}
|
||||
final String workKey = ExecutionListener.EVENTNAME_END + key;
|
||||
|
@ -281,8 +303,20 @@ public class ActivitiNoticeAspect {
|
|||
CompletableFuture.runAsync(() -> { // 发起人
|
||||
SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator));
|
||||
String content = "【通知】" + userDTO.getRealName() + ",您发起的" + resourceName + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult;
|
||||
Integer type=10;
|
||||
if("能力申请流程".equals(activitiNoticeOperation.process())){
|
||||
type=0;
|
||||
}else if("能力资源上架".equals(activitiNoticeOperation.process())){
|
||||
type=2;
|
||||
}else if("能力资源下架".equals(activitiNoticeOperation.process())){
|
||||
type=4;
|
||||
}else if("能力需求申请".equals(activitiNoticeOperation.process())){
|
||||
type=6;
|
||||
}else if("需求评论审核流程".equals(activitiNoticeOperation.process())){
|
||||
type=8;
|
||||
}
|
||||
SysNoticeDTO dto = new SysNoticeDTO();
|
||||
dto.setType(2);
|
||||
dto.setType(type);
|
||||
dto.setTitle("流程结束系统通知");
|
||||
dto.setContent(content); // 通知内容
|
||||
dto.setReceiverType(1);
|
||||
|
@ -293,6 +327,8 @@ public class ActivitiNoticeAspect {
|
|||
dto.setCreator(sysUserService.getByUsername("admin").getId());
|
||||
dto.setCreateDate(new Date());
|
||||
dto.setFrom("通知");
|
||||
dto.setApplyId(tAbilityApplicationDTOList.get(0).getApplyFlag());
|
||||
dto.setApplyState(0);
|
||||
sysNoticeService.save(dto);
|
||||
}, EXECUTOR).thenRunAsync(() -> {
|
||||
LOGGER.error("大数据局名称:{}", bigDateDeptName);
|
||||
|
@ -307,6 +343,19 @@ public class ActivitiNoticeAspect {
|
|||
dto.setType(2);
|
||||
dto.setTitle("流程结束系统通知");
|
||||
String content = "【通知】" + user.getRealName() + "," + creatorDTO.getRealName() + "发起的" + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult;
|
||||
Integer type=10;
|
||||
if("能力申请流程".equals(activitiNoticeOperation.process())){
|
||||
type=1;
|
||||
}else if("能力资源上架".equals(activitiNoticeOperation.process())){
|
||||
type=3;
|
||||
}else if("能力资源下架".equals(activitiNoticeOperation.process())){
|
||||
type=5;
|
||||
}else if("能力需求申请".equals(activitiNoticeOperation.process())){
|
||||
type=7;
|
||||
}else if("需求评论审核流程".equals(activitiNoticeOperation.process())){
|
||||
type=9;
|
||||
}
|
||||
dto.setType(type);
|
||||
dto.setContent(content); // 通知内容
|
||||
dto.setReceiverType(1);
|
||||
dto.setReceiverTypeIds(userDTO.get().getId().toString());
|
||||
|
@ -316,6 +365,8 @@ public class ActivitiNoticeAspect {
|
|||
dto.setCreator(sysUserService.getByUsername("admin").getId());
|
||||
dto.setCreateDate(new Date());
|
||||
dto.setFrom("通知");
|
||||
dto.setApplyId(execution.getProcessInstanceId());
|
||||
dto.setApplyState(1);
|
||||
sysNoticeService.save(dto);
|
||||
});
|
||||
}, EXECUTOR);
|
||||
|
@ -355,6 +406,7 @@ public class ActivitiNoticeAspect {
|
|||
} else if (kv.containsKey("_id")) {
|
||||
key = kv.getOrDefault("_id", "").toString();
|
||||
}
|
||||
final List<TAbilityApplicationDTO> tAbilityApplicationDTOList=kv.containsKey("tAbilityApplicationDTOList") ? (List<TAbilityApplicationDTO>) kv.get("tAbilityApplicationDTOList") : null;
|
||||
final StringBuilder resourceName = new StringBuilder();
|
||||
if (kv.containsKey("resourceDTO")) {
|
||||
resourceName.append("'");
|
||||
|
@ -390,8 +442,20 @@ public class ActivitiNoticeAspect {
|
|||
LOGGER.error("审核人:{}", assignee.getId());
|
||||
String content = "【通知】您发起的流程 " + resourceName + activitiNoticeOperation.process() + " 当前审核节点为:" + activitiNoticeOperation.value() + ";当前审核部门为:\"" + assignee.getDeptName() + "\";审核负责人\"" + assignee.getRealName() + "\"";
|
||||
LOGGER.info("通知内容:{}", content);
|
||||
Integer type=10;
|
||||
if("能力申请流程".equals(activitiNoticeOperation.process())){
|
||||
type=0;
|
||||
}else if("能力资源上架".equals(activitiNoticeOperation.process())){
|
||||
type=2;
|
||||
}else if("能力资源下架".equals(activitiNoticeOperation.process())){
|
||||
type=4;
|
||||
}else if("能力需求申请".equals(activitiNoticeOperation.process())){
|
||||
type=6;
|
||||
}else if("需求评论审核流程".equals(activitiNoticeOperation.process())){
|
||||
type=8;
|
||||
}
|
||||
SysNoticeDTO dto = new SysNoticeDTO();
|
||||
dto.setType(2);
|
||||
dto.setType(type);
|
||||
dto.setTitle("流程流转系统通知");
|
||||
dto.setContent(content); // 通知内容
|
||||
dto.setReceiverType(1);
|
||||
|
@ -402,6 +466,8 @@ public class ActivitiNoticeAspect {
|
|||
dto.setCreator(sysUserService.getByUsername("admin").getId());
|
||||
dto.setCreateDate(new Date());
|
||||
dto.setFrom("通知");
|
||||
dto.setApplyId(tAbilityApplicationDTOList.get(0).getApplyFlag());
|
||||
dto.setApplyState(0);
|
||||
sysNoticeService.save(dto);
|
||||
} catch (Exception exception) {
|
||||
LOGGER.error("通知发起人失败", exception);
|
||||
|
@ -410,8 +476,20 @@ public class ActivitiNoticeAspect {
|
|||
try {
|
||||
SysUserDTO owner = sysUserService.get(Long.valueOf(finalCreator));
|
||||
String content = "【通知】" + owner.getRealName() + "发起的流程" + resourceName + activitiNoticeOperation.process() + " 已进入审核节点:" + activitiNoticeOperation.value() + ";当前审核人指派为您";
|
||||
Integer type=10;
|
||||
if("能力申请流程".equals(activitiNoticeOperation.process())){
|
||||
type=1;
|
||||
}else if("能力资源上架".equals(activitiNoticeOperation.process())){
|
||||
type=3;
|
||||
}else if("能力资源下架".equals(activitiNoticeOperation.process())){
|
||||
type=5;
|
||||
}else if("能力需求申请".equals(activitiNoticeOperation.process())){
|
||||
type=7;
|
||||
}else if("需求评论审核流程".equals(activitiNoticeOperation.process())){
|
||||
type=9;
|
||||
}
|
||||
SysNoticeDTO dto = new SysNoticeDTO();
|
||||
dto.setType(2);
|
||||
dto.setType(type);
|
||||
dto.setTitle("流程流转系统通知");
|
||||
dto.setContent(content); // 通知内容
|
||||
dto.setReceiverType(1);
|
||||
|
@ -422,6 +500,8 @@ public class ActivitiNoticeAspect {
|
|||
dto.setCreator(sysUserService.getByUsername("admin").getId());
|
||||
dto.setCreateDate(new Date());
|
||||
dto.setFrom("通知");
|
||||
dto.setApplyId(delegateTask.getProcessInstanceId());
|
||||
dto.setApplyState(0);
|
||||
sysNoticeService.save(dto);
|
||||
} catch (Exception exception) {
|
||||
LOGGER.error("通知审批人失败", exception);
|
||||
|
|
|
@ -15,6 +15,7 @@ import io.renren.modules.demanData.dto.TDemandDataDTO;
|
|||
import io.renren.modules.demanData.service.TDemandDataService;
|
||||
import io.renren.modules.demandComment.dto.TDemandCommentDTO;
|
||||
import io.renren.modules.demandComment.service.TDemandCommentService;
|
||||
import io.renren.modules.notice.service.SysNoticeService;
|
||||
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
|
||||
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||
import io.renren.modules.resource.dao.ResourceDao;
|
||||
|
@ -119,6 +120,8 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
private SysDeptDao sysDeptDao;
|
||||
@Autowired
|
||||
private ResourceDao resourceDao;
|
||||
@Autowired
|
||||
private SysNoticeService sysNoticeService;
|
||||
|
||||
/**
|
||||
* 根据参数获取当前运行的任务信息
|
||||
|
@ -401,6 +404,7 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
taskService.setVariable(taskId, Task_HANDLE_STATE, Task_HANDLE_STATE_AGREE);
|
||||
taskService.setVariable(taskId, "backToFirst", Boolean.FALSE);
|
||||
taskService.complete(taskId);
|
||||
sysNoticeService.updateApplyStateById(task.getProcessInstanceId(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -681,7 +685,7 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
pvmTransitionListC.clear();
|
||||
pvmTransitionListC.addAll(oriPvmTransitionList);
|
||||
}
|
||||
|
||||
sysNoticeService.updateApplyStateById(task.getProcessInstanceId(), 1);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -739,7 +743,7 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
pvmTransitionListC.clear();
|
||||
pvmTransitionListC.addAll(oriPvmTransitionList);
|
||||
}
|
||||
|
||||
sysNoticeService.updateApplyStateById(instanceId, 1);
|
||||
}
|
||||
|
||||
private ActivityImpl findActivitiImpl(String taskId, String activityId) {
|
||||
|
@ -867,6 +871,8 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
currActivity.getOutgoingTransitions().remove(transitionImpl);
|
||||
|
||||
pvmTransitionList.addAll(originPvmTransitionList);
|
||||
|
||||
sysNoticeService.updateApplyStateById(currTask.getProcessInstanceId(), 1);
|
||||
}
|
||||
|
||||
public void completeTaskByVariables(TaskDTO taskDTO) {
|
||||
|
|
|
@ -99,7 +99,7 @@ public class CommentListener implements TaskListener, ExecutionListener, Activit
|
|||
}
|
||||
|
||||
@Override
|
||||
@ActivitiNoticeOperation(value = "评论审核", process = "评论审核流程")
|
||||
@ActivitiNoticeOperation(value = "评论审核", process = "需求评论审核流程")
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
logger.error("事件类型: {}", delegateTask.getEventName());
|
||||
final String eventName = delegateTask.getEventName();
|
||||
|
|
|
@ -20,7 +20,7 @@ public class SysNoticeDTO implements Serializable {
|
|||
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "通知类型")
|
||||
@ApiModelProperty(value = "通知类型 0:申请前台 1:申请后台 2:上架前台 3:上架后台 4:下架前台 5:下架后台 6:需求前台 7:需求后台 8:评论前台 9:评论后台 10:其他")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
@ -50,4 +50,8 @@ public class SysNoticeDTO implements Serializable {
|
|||
private Integer readStatus;
|
||||
@ApiModelProperty(value = "通知来源 (通知、评论、其他)")
|
||||
private String from;
|
||||
@ApiModelProperty(value = "通知来源id ,跳转使用")
|
||||
private String applyId;
|
||||
@ApiModelProperty(value = "通知来源状态 0:待办 1:已办")
|
||||
private Integer applyState;
|
||||
}
|
|
@ -89,4 +89,12 @@ public class SysNoticeEntity {
|
|||
*/
|
||||
@TableField(value = "`from`")
|
||||
private String from;
|
||||
/**
|
||||
* 通知来源id
|
||||
*/
|
||||
private String applyId;
|
||||
/**
|
||||
* 通知来源状态
|
||||
*/
|
||||
private Integer applyState;
|
||||
}
|
|
@ -21,4 +21,6 @@ public interface SysNoticeService extends CrudService<SysNoticeEntity, SysNotice
|
|||
* 获取我的通知列表
|
||||
*/
|
||||
PageData<SysNoticeDTO> getMyNoticePage(Map<String, Object> params);
|
||||
|
||||
void updateApplyStateById(String id, Integer state);
|
||||
}
|
|
@ -73,6 +73,9 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
|
|||
case "from":
|
||||
wrapper.eq(StringUtils.isNotBlank((String) params.get("from")), "`from`", (String) params.get("from"));
|
||||
break;
|
||||
case "applyId":
|
||||
wrapper.eq(StringUtils.isNotBlank((String) params.get("applyId")), "apply_id", (String) params.get("applyId"));
|
||||
break;
|
||||
}
|
||||
});
|
||||
wrapper.orderByDesc(Constant.CREATE_DATE);
|
||||
|
@ -102,6 +105,17 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
|
|||
return getPageData(list, page.getTotal(), SysNoticeDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApplyStateById(String id, Integer state) {
|
||||
Map params=new HashMap();
|
||||
params.put("apply_id",id);
|
||||
List<SysNoticeDTO> list=this.list(params);
|
||||
list.stream().filter(it->it.getReceiverTypeIds().contains(SecurityUser.getUserId().toString())).forEach(it->{
|
||||
it.setApplyState(state);
|
||||
this.update(it);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysNoticeDTO dto) {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<!-- 获取我的通知列表 -->
|
||||
<select id="getMyNoticeList" resultType="io.renren.modules.notice.entity.SysNoticeEntity">
|
||||
select t2.id, t2.title, t2.type, t2.sender_name, t2.sender_date, t1.read_status, t2.content ,t2.`from` from
|
||||
select t2.id, t2.title, t2.type, t2.sender_name, t2.sender_date, t1.read_status, t2.content ,t2.`from`, t2.apply_id, t2.apply_state from
|
||||
sys_notice_user t1, sys_notice t2
|
||||
where t1.notice_id = t2.id and t1.receiver_id = #{receiverId}
|
||||
<if test="readStatus != null">
|
||||
|
|
|
@ -1785,7 +1785,7 @@
|
|||
|
||||
<select id="selectCensusResourceTable" resultType="java.util.Map">
|
||||
SELECT sd.name AS deptName, tdr.name AS resourceName, tdr.type, tdr.create_date AS createDate,
|
||||
if(tdr.del_flag=0, '审核通过', '审核中') AS approveStatus, trma.apply_number AS applyNumber
|
||||
if(tdr.del_flag=0, '审核通过', '审核中') AS approveStatus, trma.instance_id AS applyNumber
|
||||
FROM (SELECT IF(d.type='组件服务', A.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date,
|
||||
d.name
|
||||
FROM tb_data_resource d LEFT JOIN tb_data_attr a ON d.id=a.data_resource_id AND a.attr_type='组件类型' AND
|
||||
|
@ -1819,7 +1819,7 @@
|
|||
|
||||
<select id="selectCensusApplyTable" resultType="java.util.Map">
|
||||
SELECT sd.name AS deptName, tdr.name AS resourceName, tdr.type, taa.create_date AS createDate,
|
||||
taa.approve_status AS approveStatus, taa.apply_number AS applyNumber
|
||||
taa.approve_status AS approveStatus, taa.apply_flag AS applyNumber
|
||||
FROM (SELECT IF(d.type='组件服务', A.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date,
|
||||
d.name
|
||||
FROM tb_data_resource d LEFT JOIN tb_data_attr a ON d.id=a.data_resource_id AND a.attr_type='组件类型' AND
|
||||
|
|
Loading…
Reference in New Issue