评论审核流程
This commit is contained in:
parent
6f394a3f99
commit
a911fdeee9
|
@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,10 +110,12 @@ public class AbilityCenterController {
|
||||||
processStartDTO.setVariables(variables);
|
processStartDTO.setVariables(variables);
|
||||||
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
|
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
|
||||||
|
|
||||||
if (Long.valueOf(dto.getBusinessKey()) != null) {
|
// 仿照请求接口 /processForm/tabilityapplication/updateInstanceId
|
||||||
// 仿照请求接口 /processForm/tabilityapplication/updateInstanceId
|
CompletableFuture.runAsync(() -> {
|
||||||
tAbilityApplicationService.updateInstanceId(dto.getProcessInstanceId(), Long.valueOf(dto.getBusinessKey()));
|
if (Long.valueOf(dto.getBusinessKey()) != null) {
|
||||||
}
|
tAbilityApplicationService.updateInstanceId(dto.getProcessInstanceId(), Long.valueOf(dto.getBusinessKey()));
|
||||||
|
}
|
||||||
|
});
|
||||||
return dto;
|
return dto;
|
||||||
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList()));
|
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
package io.renren.common.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import io.renren.common.page.PageData;
|
||||||
|
import io.renren.common.utils.Result;
|
||||||
|
import io.renren.modules.activiti.dto.ProcessInstanceDTO;
|
||||||
|
import io.renren.modules.activiti.dto.ProcessStartDTO;
|
||||||
|
import io.renren.modules.activiti.service.ActProcessService;
|
||||||
|
import io.renren.modules.activiti.service.ActRunningService;
|
||||||
|
import io.renren.modules.demandComment.dto.TDemandCommentDTO;
|
||||||
|
import io.renren.modules.demandComment.service.TDemandCommentService;
|
||||||
|
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Api(tags = "")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/comment/center")
|
||||||
|
public class CommentController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ActProcessService actProcessService;
|
||||||
|
@Autowired
|
||||||
|
private TAbilityApplicationService tAbilityApplicationService;
|
||||||
|
@Autowired
|
||||||
|
private ActRunningService actRunningService;
|
||||||
|
@Autowired
|
||||||
|
private TDemandCommentService tDemandCommentService;
|
||||||
|
@Autowired
|
||||||
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(CommentController.class);
|
||||||
|
|
||||||
|
private static String key = "comment_review";
|
||||||
|
|
||||||
|
private static Map<String, Object> params = new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("isLatestVersion", true); // 取最新版本
|
||||||
|
put("key", key); // 限定
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量进行批量能力申请
|
||||||
|
*
|
||||||
|
* @param tDemandCommentDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/apply")
|
||||||
|
@ApiOperation("批量进行评论审核申请")
|
||||||
|
public Result<ProcessInstanceDTO> apply(@RequestBody TDemandCommentDTO tDemandCommentDTO) {
|
||||||
|
// 仿照请求接口 /act/process/lastestPage
|
||||||
|
PageData<Map<String, Object>> page = actProcessService.page(params);
|
||||||
|
if (page.getTotal() <= 0) { //
|
||||||
|
return new Result().error("联系管理员添加流程");
|
||||||
|
}
|
||||||
|
if (tDemandCommentDTO.getId() == null) {
|
||||||
|
return new Result().error("参数异常");
|
||||||
|
}
|
||||||
|
tDemandCommentDTO = tDemandCommentService.get(tDemandCommentDTO.getId());
|
||||||
|
if (tDemandCommentDTO.getId() == null) {
|
||||||
|
return new Result().error("该评论不存在");
|
||||||
|
}
|
||||||
|
tDemandCommentDTO.setDelFlag(2); // 待审核
|
||||||
|
tDemandCommentDTO.setCompleteEntry(Boolean.TRUE);
|
||||||
|
tDemandCommentService.update(tDemandCommentDTO);
|
||||||
|
|
||||||
|
// 仿照请求接口 /act/running/startOfBusinessKey
|
||||||
|
ProcessStartDTO processStartDTO = new ProcessStartDTO();
|
||||||
|
processStartDTO.setBusinessKey(tDemandCommentDTO.getId().toString());
|
||||||
|
processStartDTO.setProcessDefinitionKey(key); //限定
|
||||||
|
ObjectMapper oMapper = new ObjectMapper();
|
||||||
|
Map<String, Object> variables = oMapper.convertValue(tDemandCommentDTO, Map.class);
|
||||||
|
processStartDTO.setVariables(variables);
|
||||||
|
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
|
||||||
|
|
||||||
|
tDemandCommentDTO.setDelFlag(3); // 审核中
|
||||||
|
tDemandCommentService.update(tDemandCommentDTO);
|
||||||
|
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
if (Long.valueOf(dto.getBusinessKey()) != null) {
|
||||||
|
jdbcTemplate.update(String.format("UPDATE t_demand_comment SET instance_id = '%s' WHERE id = %s", dto.getProcessInstanceId(), dto.getBusinessKey()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new Result<ProcessInstanceDTO>().ok(dto);
|
||||||
|
}
|
||||||
|
}
|
|
@ -104,7 +104,7 @@ public class TDemandCommentController {
|
||||||
@ApiOperation("保存")
|
@ApiOperation("保存")
|
||||||
@LogOperation("保存")
|
@LogOperation("保存")
|
||||||
// @RequiresPermissions("demandComment:tdemandcomment:save")
|
// @RequiresPermissions("demandComment:tdemandcomment:save")
|
||||||
public Result save(@RequestBody TDemandCommentDTO dto) {
|
public Result<TDemandCommentDTO> save(@RequestBody TDemandCommentDTO dto) {
|
||||||
//效验数据
|
//效验数据
|
||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
TDemandDataDTO dto1 =
|
TDemandDataDTO dto1 =
|
||||||
|
@ -115,9 +115,10 @@ public class TDemandCommentController {
|
||||||
if (dto1.getFlag() != 3) {
|
if (dto1.getFlag() != 3) {
|
||||||
return new Result().error("该评论主题未审批通过!");
|
return new Result().error("该评论主题未审批通过!");
|
||||||
}
|
}
|
||||||
|
dto.setDelFlag(1);
|
||||||
tDemandCommentService.save(dto);
|
tDemandCommentService.save(dto);
|
||||||
|
|
||||||
return new Result();
|
return new Result().ok(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
package io.renren.modules.demandComment.listener;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import io.renren.common.annotation.ActivitiNoticeOperation;
|
||||||
|
import io.renren.modules.demandComment.dto.TDemandCommentDTO;
|
||||||
|
import io.renren.modules.demandComment.service.TDemandCommentService;
|
||||||
|
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||||
|
import io.renren.modules.sys.dto.SysRoleDTO;
|
||||||
|
import io.renren.modules.sys.dto.SysUserDTO;
|
||||||
|
import io.renren.modules.sys.service.SysDeptService;
|
||||||
|
import io.renren.modules.sys.service.SysRoleService;
|
||||||
|
import io.renren.modules.sys.service.SysRoleUserService;
|
||||||
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
|
import org.activiti.engine.TaskService;
|
||||||
|
import org.activiti.engine.delegate.*;
|
||||||
|
import org.activiti.engine.delegate.event.ActivitiEvent;
|
||||||
|
import org.activiti.engine.delegate.event.ActivitiEventListener;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大数据局动态审批人
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class CommentListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(CommentListener.class);
|
||||||
|
|
||||||
|
@Value("${big_date.name}")
|
||||||
|
private String bigDateDeptName; // 大数据局名称
|
||||||
|
@Value("${big_date.assignee_role_name}")
|
||||||
|
private String roleName; // 具备审批的角色名称
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRoleService sysRoleService;
|
||||||
|
@Autowired
|
||||||
|
private TaskService taskService;
|
||||||
|
@Autowired
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
@Autowired
|
||||||
|
private SysRoleUserService sysRoleUserService;
|
||||||
|
@Autowired
|
||||||
|
private SysDeptService sysDeptService;
|
||||||
|
@Autowired
|
||||||
|
private TDemandCommentService tDemandCommentService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notify(DelegateExecution delegateExecution) throws Exception {
|
||||||
|
logger.error("----------------------进入审批结束节点---------------------------");
|
||||||
|
delegateExecution.getProcessBusinessKey();
|
||||||
|
final String eventName = delegateExecution.getEventName();
|
||||||
|
switch (eventName) {
|
||||||
|
case EVENTNAME_END:
|
||||||
|
endTake(delegateExecution.getVariables());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束审批
|
||||||
|
*
|
||||||
|
* @param kv
|
||||||
|
*/
|
||||||
|
private void endTake(Map<String, Object> kv) { // 进入最后结束节点
|
||||||
|
GsonBuilder builder = new GsonBuilder();
|
||||||
|
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
|
||||||
|
|
||||||
|
Gson gson = builder.create();
|
||||||
|
JsonElement jsonElement = gson.toJsonTree(kv);
|
||||||
|
TDemandCommentDTO tDemandCommentDTO = gson.fromJson(jsonElement, TDemandCommentDTO.class);
|
||||||
|
if (tDemandCommentDTO != null) {
|
||||||
|
if (tDemandCommentDTO.getReject() != null && tDemandCommentDTO.getReject() == Boolean.TRUE) { // 存在被拒绝的节点
|
||||||
|
tDemandCommentDTO.setDelFlag(1);
|
||||||
|
tDemandCommentService.update(tDemandCommentDTO);
|
||||||
|
logger.error("评论审核不通过不通过!申请id:" + tDemandCommentDTO.getId());
|
||||||
|
} else {
|
||||||
|
tDemandCommentDTO.setDelFlag(0);
|
||||||
|
tDemandCommentService.update(tDemandCommentDTO);
|
||||||
|
logger.error("审批通过!评论id:" + tDemandCommentDTO.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(DelegateExecution delegateExecution) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ActivitiNoticeOperation(value = "评论审核", process = "评论审核流程")
|
||||||
|
public void notify(DelegateTask delegateTask) {
|
||||||
|
logger.error("事件类型:" + delegateTask.getEventName());
|
||||||
|
final String eventName = delegateTask.getEventName();
|
||||||
|
switch (eventName) {
|
||||||
|
case EVENTNAME_CREATE:
|
||||||
|
createEvent(delegateTask);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logger.error("未处理该事件:" + eventName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(ActivitiEvent activitiEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFailOnException() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点创建时动态分配大数据局审批人
|
||||||
|
*
|
||||||
|
* @param delegateTask
|
||||||
|
*/
|
||||||
|
private void createEvent(DelegateTask delegateTask) {
|
||||||
|
logger.error("大数据局名称:" + bigDateDeptName);
|
||||||
|
SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName);
|
||||||
|
logger.error("deptDTOId:" + deptDTO.getId());
|
||||||
|
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
|
||||||
|
logger.error("roleDTOId:" + roleDTO.getId());
|
||||||
|
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId());
|
||||||
|
|
||||||
|
if (userDTO != null) {
|
||||||
|
logger.error("审批人id:" + userDTO.getId());
|
||||||
|
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
|
||||||
|
} else {
|
||||||
|
delegateTask.setAssignee("1516728698224427010");
|
||||||
|
logger.error("未查到该部门对应 " + roleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -76,23 +76,30 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao
|
||||||
@Override
|
@Override
|
||||||
public void save(TDemandCommentDTO tDemandCommentDTO) {
|
public void save(TDemandCommentDTO tDemandCommentDTO) {
|
||||||
super.save(tDemandCommentDTO);
|
super.save(tDemandCommentDTO);
|
||||||
CompletableFuture.runAsync(() -> { // 发起人
|
}
|
||||||
Optional<TDemandDataDTO> tDemandDataDTO = Optional.ofNullable(tDemandDataService.get(tDemandCommentDTO.getTargetId()));
|
|
||||||
Optional<SysUserDTO> sysUserDTO = Optional.ofNullable(sysUserService.get(tDemandDataDTO.isPresent() ? tDemandDataDTO.get().getCreator() : null));
|
@Override
|
||||||
String content = "【评论】" + (sysUserDTO.isPresent() ? sysUserDTO.get().getRealName() : "") + "您发起的需求 " + tDemandDataDTO.orElse(new TDemandDataDTO()).getDemandSubject() + "有新的评论,请前往查看详情";
|
public void update(TDemandCommentDTO tDemandCommentDTO) {
|
||||||
SysNoticeDTO dto = new SysNoticeDTO();
|
super.update(tDemandCommentDTO);
|
||||||
dto.setType(2);
|
if (tDemandCommentDTO.getDelFlag() == 0) {
|
||||||
dto.setTitle("需求评论系统通知");
|
CompletableFuture.runAsync(() -> { // 发起人
|
||||||
dto.setContent(content); // 通知内容
|
Optional<TDemandDataDTO> tDemandDataDTO = Optional.ofNullable(tDemandDataService.get(tDemandCommentDTO.getTargetId()));
|
||||||
dto.setReceiverType(1);
|
Optional<SysUserDTO> sysUserDTO = Optional.ofNullable(sysUserService.get(tDemandDataDTO.isPresent() ? tDemandDataDTO.get().getCreator() : null));
|
||||||
dto.setReceiverTypeIds(tDemandDataDTO.isPresent() ? tDemandDataDTO.get().getCreator().toString() : "");
|
String content = "【评论】" + (sysUserDTO.isPresent() ? sysUserDTO.get().getRealName() : "") + "您发起的需求 " + tDemandDataDTO.orElse(new TDemandDataDTO()).getDemandSubject() + "有新的评论,请前往查看详情";
|
||||||
dto.setStatus(NoticeStatusEnum.SEND.value());
|
SysNoticeDTO dto = new SysNoticeDTO();
|
||||||
dto.setSenderName("流程系统");
|
dto.setType(2);
|
||||||
dto.setSenderDate(new Date());
|
dto.setTitle("需求评论系统通知");
|
||||||
dto.setCreator(sysUserService.getByUsername("admin").getId());
|
dto.setContent(content); // 通知内容
|
||||||
dto.setCreateDate(new Date());
|
dto.setReceiverType(1);
|
||||||
dto.setFrom("评论");
|
dto.setReceiverTypeIds(tDemandDataDTO.isPresent() ? tDemandDataDTO.get().getCreator().toString() : "");
|
||||||
sysNoticeService.save(dto);
|
dto.setStatus(NoticeStatusEnum.SEND.value());
|
||||||
});
|
dto.setSenderName("流程系统");
|
||||||
|
dto.setSenderDate(new Date());
|
||||||
|
dto.setCreator(sysUserService.getByUsername("admin").getId());
|
||||||
|
dto.setCreateDate(new Date());
|
||||||
|
dto.setFrom("评论");
|
||||||
|
sysNoticeService.save(dto);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `t_demand_comment` ADD COLUMN `instance_id` varchar(64) NULL COMMENT '流程实例ID';
|
Loading…
Reference in New Issue