From 01728a8cfb002d081e7651a99642035d5fc25594 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 25 Apr 2022 17:05:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E7=94=B3=E8=AF=B7=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/DemandDataListener.java | 132 ++++++++++++++++++ .../service/impl/TDemandDataServiceImpl.java | 5 +- .../controller/ResourceController.java | 3 +- .../service/impl/ResourceServiceImpl.java | 4 +- 4 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/demanData/listener/DemandDataListener.java diff --git a/renren-admin/src/main/java/io/renren/modules/demanData/listener/DemandDataListener.java b/renren-admin/src/main/java/io/renren/modules/demanData/listener/DemandDataListener.java new file mode 100644 index 00000000..b4cb2c29 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/demanData/listener/DemandDataListener.java @@ -0,0 +1,132 @@ +package io.renren.modules.demanData.listener; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import io.renren.modules.demanData.dto.TDemandDataDTO; +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.Map; + +/** + * + */ +@Component +public class DemandDataListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate { + private static Logger logger = LoggerFactory.getLogger(DemandDataListener.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; + + @Override + public void notify(DelegateExecution execution) throws Exception { + + } + + @Override + public void execute(DelegateExecution execution) throws Exception { + + } + + @Override + public void notify(DelegateTask delegateTask) { + logger.error("----------------------进入能力需求受理者1节点---------------------------"); + logger.info("事件类型:" + delegateTask.getEventName()); + SysRoleDTO roleDTO = sysRoleService.getByName(roleName); + logger.error("roleDTOId:" + roleDTO.getId()); + final String eventName = delegateTask.getEventName(); + switch (eventName) { + case EVENTNAME_CREATE: + create(delegateTask, roleDTO); + break; + default: + logger.info("未处理该事件:" + eventName); + } + } + + /** + * Called when an event has been fired + * + * @param event the event + */ + @Override + public void onEvent(ActivitiEvent event) { + + } + + /** + * @return whether or not the current operation should fail when this listeners execution + * throws an exception. + */ + @Override + public boolean isFailOnException() { + return false; + } + + private void create(DelegateTask delegateTask, final SysRoleDTO roleDTO) { + Map kv = delegateTask.getVariables(); + Gson gson = new Gson(); + JsonElement jsonElement = gson.toJsonTree(kv); + TDemandDataDTO demandDataDTO = gson.fromJson(jsonElement, TDemandDataDTO.class); + + if (demandDataDTO != null) { + logger.info(JSONObject.toJSONString(demandDataDTO)); + SysDeptDTO deptDTO = + sysDeptService.get(Long.valueOf(demandDataDTO.getApplyUserDeptId())); + SysUserDTO userDTO = null; + if (deptDTO.getId() != null) { + userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); // 搜出审批人 + } + if (userDTO != null) { + logger.error("审批人id:" + userDTO.getId()); + taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); + } else { + logger.error("未查到该部门对应的 " + roleName); + taskService.setAssignee(delegateTask.getId(), "1513432847327199233"); + } + } else { // 填入大数据审批人 + logger.info("大数据局名称:" + bigDateDeptName); + SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName); + logger.info("roleDTOId:" + roleDTO.getId()); + SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); + + if (userDTO != null) { + logger.info("大数据审批人id:" + userDTO.getId()); + taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); + } else { + taskService.setAssignee(delegateTask.getId(), "1513432847327199233"); + logger.info("未查到大数据部门对应 " + roleName); + + } + } + + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/demanData/service/impl/TDemandDataServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/demanData/service/impl/TDemandDataServiceImpl.java index 2eb442ad..c0ea3ca0 100644 --- a/renren-admin/src/main/java/io/renren/modules/demanData/service/impl/TDemandDataServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/demanData/service/impl/TDemandDataServiceImpl.java @@ -22,8 +22,9 @@ public class TDemandDataServiceImpl extends CrudServiceImpl getWrapper(Map params) { QueryWrapper wrapper = new QueryWrapper<>(); - - + if (params.containsKey("flag")) { + wrapper.eq("flag", params.get("flag")); + } return wrapper; } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 794d90e7..e97c5549 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -120,8 +120,9 @@ public class ResourceController { @ApiImplicitParam(name = "source", value = "请求来源", paramType = "string", dataType = "string") }) //@RequiresPermissions("resource:resource:save") - public Result save(@RequestBody ResourceDTO dto, String source) { + public Result save(@RequestBody ResourceDTO dto, @RequestParam String source) { // 效验数据 + logger.info("source:" + source); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); if ("f".equals(source)) { dto.setDelFlag(2); // 来自前端页面 走审批流程 diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 183a11c0..cac66963 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -78,7 +78,9 @@ public class ResourceServiceImpl extends CrudServiceImpl